19286SGarrett.Damore@Sun.COM /* 29286SGarrett.Damore@Sun.COM * CDDL HEADER START 39286SGarrett.Damore@Sun.COM * 49286SGarrett.Damore@Sun.COM * The contents of this file are subject to the terms of the 59286SGarrett.Damore@Sun.COM * Common Development and Distribution License (the "License"). 69286SGarrett.Damore@Sun.COM * You may not use this file except in compliance with the License. 79286SGarrett.Damore@Sun.COM * 89286SGarrett.Damore@Sun.COM * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 99286SGarrett.Damore@Sun.COM * or http://www.opensolaris.org/os/licensing. 109286SGarrett.Damore@Sun.COM * See the License for the specific language governing permissions 119286SGarrett.Damore@Sun.COM * and limitations under the License. 129286SGarrett.Damore@Sun.COM * 139286SGarrett.Damore@Sun.COM * When distributing Covered Code, include this CDDL HEADER in each 149286SGarrett.Damore@Sun.COM * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 159286SGarrett.Damore@Sun.COM * If applicable, add the following below this CDDL HEADER, with the 169286SGarrett.Damore@Sun.COM * fields enclosed by brackets "[]" replaced with your own identifying 179286SGarrett.Damore@Sun.COM * information: Portions Copyright [yyyy] [name of copyright owner] 189286SGarrett.Damore@Sun.COM * 199286SGarrett.Damore@Sun.COM * CDDL HEADER END 209286SGarrett.Damore@Sun.COM */ 219286SGarrett.Damore@Sun.COM 229286SGarrett.Damore@Sun.COM /* 23*11453Sgdamore@opensolaris.org * Copyright 2010 Sun Microsystems, Inc. All rights reserved. 249286SGarrett.Damore@Sun.COM * Use is subject to license terms. 259286SGarrett.Damore@Sun.COM */ 269286SGarrett.Damore@Sun.COM 279286SGarrett.Damore@Sun.COM /* 289286SGarrett.Damore@Sun.COM * rtls -- REALTEK 8139-serials PCI Fast Ethernet Driver. 299286SGarrett.Damore@Sun.COM * 309286SGarrett.Damore@Sun.COM * This product is covered by one or more of the following patents: 319286SGarrett.Damore@Sun.COM * US5,307,459, US5,434,872, US5,732,094, US6,570,884, US6,115,776, and 329286SGarrett.Damore@Sun.COM * US6,327,625. 339286SGarrett.Damore@Sun.COM * 349286SGarrett.Damore@Sun.COM * Currently supports: 359286SGarrett.Damore@Sun.COM * RTL8139 369286SGarrett.Damore@Sun.COM */ 379286SGarrett.Damore@Sun.COM 389286SGarrett.Damore@Sun.COM 399286SGarrett.Damore@Sun.COM #ifndef _SYS_RTLS_H 409286SGarrett.Damore@Sun.COM #define _SYS_RTLS_H 419286SGarrett.Damore@Sun.COM 429286SGarrett.Damore@Sun.COM #ifdef __cplusplus 439286SGarrett.Damore@Sun.COM extern "C" { 449286SGarrett.Damore@Sun.COM #endif 459286SGarrett.Damore@Sun.COM 469286SGarrett.Damore@Sun.COM /* Debug flags */ 479286SGarrett.Damore@Sun.COM #define RTLS_TRACE 0x01 489286SGarrett.Damore@Sun.COM #define RTLS_ERRS 0x02 499286SGarrett.Damore@Sun.COM #define RTLS_RECV 0x04 509286SGarrett.Damore@Sun.COM #define RTLS_DDI 0x08 519286SGarrett.Damore@Sun.COM #define RTLS_SEND 0x10 529286SGarrett.Damore@Sun.COM #define RTLS_INT 0x20 539286SGarrett.Damore@Sun.COM #define RTLS_SENSE 0x40 549286SGarrett.Damore@Sun.COM #define RTLS_REGCFG 0x80 559286SGarrett.Damore@Sun.COM 569286SGarrett.Damore@Sun.COM #ifdef DEBUG 579286SGarrett.Damore@Sun.COM #define RTLS_DEBUG 1 589286SGarrett.Damore@Sun.COM #endif 599286SGarrett.Damore@Sun.COM 609286SGarrett.Damore@Sun.COM /* 619286SGarrett.Damore@Sun.COM * Driver support device 629286SGarrett.Damore@Sun.COM */ 639286SGarrett.Damore@Sun.COM #define RT_VENDOR_ID 0x10EC /* RealTek */ 649286SGarrett.Damore@Sun.COM #define RT_DEVICE_8139 0x8139 659286SGarrett.Damore@Sun.COM #define RTLS_SUPPORT_DEVICE_1 ((RT_VENDOR_ID << 16) | RT_DEVICE_8139) 669286SGarrett.Damore@Sun.COM /* bind vendor and device id together */ 679286SGarrett.Damore@Sun.COM 689286SGarrett.Damore@Sun.COM #define RTLS_VENDOR_ID_2 0x1186 /* D-link */ 699286SGarrett.Damore@Sun.COM #define RTLS_DEVICE_ID_2 0x1301 709286SGarrett.Damore@Sun.COM #define RTLS_SUPPORT_DEVICE_2 ((RTLS_VENDOR_ID_2 << 16) | RTLS_DEVICE_ID_2) 719286SGarrett.Damore@Sun.COM 729286SGarrett.Damore@Sun.COM #define RTLS_VENDOR_ID_3 0x1113 /* Accton */ 739286SGarrett.Damore@Sun.COM #define RTLS_DEVICE_ID_3 0x1211 749286SGarrett.Damore@Sun.COM #define RTLS_SUPPORT_DEVICE_3 ((RTLS_VENDOR_ID_3 << 16) | RTLS_DEVICE_ID_3) 759286SGarrett.Damore@Sun.COM 76*11453Sgdamore@opensolaris.org #define RTLS_VENDOR_ID_4 0x1186 /* D-link */ 77*11453Sgdamore@opensolaris.org #define RTLS_DEVICE_ID_4 0x1300 78*11453Sgdamore@opensolaris.org #define RTLS_SUPPORT_DEVICE_4 ((RTLS_VENDOR_ID_4 << 16) | RTLS_DEVICE_ID_4) 79*11453Sgdamore@opensolaris.org 809286SGarrett.Damore@Sun.COM /* 819286SGarrett.Damore@Sun.COM * Driver tx/rx parameters 829286SGarrett.Damore@Sun.COM */ 839286SGarrett.Damore@Sun.COM #define RTLS_MAX_TX_DESC 4 849286SGarrett.Damore@Sun.COM #define RTLS_TX_BUF_COUNT 8 859286SGarrett.Damore@Sun.COM #define RTLS_TX_BUF_SIZE 2048 869286SGarrett.Damore@Sun.COM #define RTLS_RX_BUF_RING (32*1024) /* 32K */ 879286SGarrett.Damore@Sun.COM #define RTLS_RX_BUF_SIZE (RTLS_RX_BUF_RING + 2*1024) 889286SGarrett.Damore@Sun.COM #define RTLS_MCAST_BUF_SIZE 64 /* multicast hash table size in bits */ 899286SGarrett.Damore@Sun.COM 909286SGarrett.Damore@Sun.COM /* 919286SGarrett.Damore@Sun.COM * RTL8139 CRC poly 929286SGarrett.Damore@Sun.COM */ 939286SGarrett.Damore@Sun.COM #define RTLS_HASH_POLY 0x04C11DB7 /* 0x04C11DB6 */ 949286SGarrett.Damore@Sun.COM #define RTLS_HASH_CRC 0xFFFFFFFFU 959286SGarrett.Damore@Sun.COM 969286SGarrett.Damore@Sun.COM /* 979286SGarrett.Damore@Sun.COM * STREAMS parameters 989286SGarrett.Damore@Sun.COM */ 999286SGarrett.Damore@Sun.COM #define RTLS_HIWAT (RTLS_MAX_TX_DESC * ETHERMAX) 1009286SGarrett.Damore@Sun.COM /* driver flow control high water */ 1019286SGarrett.Damore@Sun.COM #define RTLS_LOWAT 1 /* driver flow control low water */ 1029286SGarrett.Damore@Sun.COM #define RTLS_IDNUM 0 /* RTL Id; zero works */ 1039286SGarrett.Damore@Sun.COM 1049286SGarrett.Damore@Sun.COM /* 1059286SGarrett.Damore@Sun.COM * Helpful defines for register access 1069286SGarrett.Damore@Sun.COM */ 1079286SGarrett.Damore@Sun.COM #define REG32(reg, off) ((uint32_t *)((uintptr_t)(reg) + off)) 1089286SGarrett.Damore@Sun.COM #define REG16(reg, off) ((uint16_t *)((uintptr_t)(reg) + off)) 1099286SGarrett.Damore@Sun.COM #define REG8(reg, off) ((uint8_t *)((uintptr_t)(reg) + off)) 1109286SGarrett.Damore@Sun.COM 1119286SGarrett.Damore@Sun.COM typedef struct { 1129286SGarrett.Damore@Sun.COM ddi_acc_handle_t acc_hdl; /* handle for memory */ 1139286SGarrett.Damore@Sun.COM void *mem_va; /* CPU VA of memory */ 1149286SGarrett.Damore@Sun.COM size_t alength; /* allocated size */ 1159286SGarrett.Damore@Sun.COM ddi_dma_handle_t dma_hdl; /* DMA handle */ 1169286SGarrett.Damore@Sun.COM ddi_dma_cookie_t cookie; /* associated cookie */ 1179286SGarrett.Damore@Sun.COM uint32_t ncookies; /* must be 1 */ 1189286SGarrett.Damore@Sun.COM } dma_area_t; 1199286SGarrett.Damore@Sun.COM 1209286SGarrett.Damore@Sun.COM typedef struct rtls_stats { 1219286SGarrett.Damore@Sun.COM uint64_t ipackets; 1229286SGarrett.Damore@Sun.COM uint64_t multi_rcv; /* ifInMulticastPkts */ 1239286SGarrett.Damore@Sun.COM uint64_t brdcst_rcv; /* ifInBroadcastPkts */ 1249286SGarrett.Damore@Sun.COM uint64_t rbytes; 1259286SGarrett.Damore@Sun.COM uint64_t opackets; 1269286SGarrett.Damore@Sun.COM uint64_t multi_xmt; 1279286SGarrett.Damore@Sun.COM uint64_t brdcst_xmt; 1289286SGarrett.Damore@Sun.COM uint64_t obytes; 1299286SGarrett.Damore@Sun.COM uint32_t collisions; 1309286SGarrett.Damore@Sun.COM uint32_t firstcol; 1319286SGarrett.Damore@Sun.COM uint32_t multicol; 1329286SGarrett.Damore@Sun.COM uint32_t rcv_err; /* ifInErrors */ 1339286SGarrett.Damore@Sun.COM uint32_t xmt_err; /* ifOutErrors */ 1349286SGarrett.Damore@Sun.COM uint32_t mac_rcv_err; 1359286SGarrett.Damore@Sun.COM uint32_t mac_xmt_err; 1369286SGarrett.Damore@Sun.COM uint32_t overflow; 1379286SGarrett.Damore@Sun.COM uint32_t underflow; 1389286SGarrett.Damore@Sun.COM uint32_t no_carrier; /* dot3StatsCarrierSenseErrors */ 1399286SGarrett.Damore@Sun.COM uint32_t xmt_latecoll; /* dot3StatsLateCollisions */ 1409286SGarrett.Damore@Sun.COM uint32_t defer; /* dot3StatsDeferredTransmissions */ 1419286SGarrett.Damore@Sun.COM uint32_t frame_err; /* dot3StatsAlignErrors */ 1429286SGarrett.Damore@Sun.COM uint32_t crc_err; /* dot3StatsFCSErrors */ 1439286SGarrett.Damore@Sun.COM uint32_t in_short; 1449286SGarrett.Damore@Sun.COM uint32_t too_long; 1459286SGarrett.Damore@Sun.COM uint32_t no_rcvbuf; /* ifInDiscards */ 1469286SGarrett.Damore@Sun.COM } rtls_stats_t; 1479286SGarrett.Damore@Sun.COM 1489286SGarrett.Damore@Sun.COM typedef struct rtls_instance { 1499286SGarrett.Damore@Sun.COM mac_handle_t mh; 150*11453Sgdamore@opensolaris.org mii_handle_t mii; 1519286SGarrett.Damore@Sun.COM dev_info_t *devinfo; /* device instance */ 1529286SGarrett.Damore@Sun.COM int32_t instance; 1539286SGarrett.Damore@Sun.COM 1549286SGarrett.Damore@Sun.COM /* instance name: "rtls" + instance num, 32 bytes is enough */ 1559286SGarrett.Damore@Sun.COM char ifname[32]; 1569286SGarrett.Damore@Sun.COM 1579286SGarrett.Damore@Sun.COM caddr_t io_reg; /* mapped chip register address */ 1589286SGarrett.Damore@Sun.COM 1599286SGarrett.Damore@Sun.COM 1609286SGarrett.Damore@Sun.COM /* io handle & iblock */ 1619286SGarrett.Damore@Sun.COM ddi_acc_handle_t io_handle; /* ddi I/O handle */ 1629286SGarrett.Damore@Sun.COM ddi_iblock_cookie_t iblk; 1639286SGarrett.Damore@Sun.COM 1649286SGarrett.Damore@Sun.COM /* dma buffer alloc used */ 1659286SGarrett.Damore@Sun.COM dma_area_t dma_area_rx; /* receive dma area */ 1669286SGarrett.Damore@Sun.COM dma_area_t dma_area_tx[RTLS_MAX_TX_DESC]; 1679286SGarrett.Damore@Sun.COM /* transmit dma area */ 1689286SGarrett.Damore@Sun.COM 1699286SGarrett.Damore@Sun.COM uint8_t netaddr[ETHERADDRL]; /* mac address */ 1709286SGarrett.Damore@Sun.COM uint16_t int_mask; /* interrupt mask */ 1719286SGarrett.Damore@Sun.COM 1729286SGarrett.Damore@Sun.COM /* used for multicast set */ 1739286SGarrett.Damore@Sun.COM char multicast_cnt[RTLS_MCAST_BUF_SIZE]; 1749286SGarrett.Damore@Sun.COM uint32_t multi_hash[2]; 1759286SGarrett.Damore@Sun.COM 1769286SGarrett.Damore@Sun.COM boolean_t promisc; /* promisc state flag */ 1779286SGarrett.Damore@Sun.COM 1789286SGarrett.Damore@Sun.COM /* used for send */ 1799286SGarrett.Damore@Sun.COM uint8_t *tx_buf[RTLS_MAX_TX_DESC]; 1809286SGarrett.Damore@Sun.COM uint16_t tx_current_desc; /* Current Tx page */ 1819286SGarrett.Damore@Sun.COM uint16_t tx_first_loop; 1829286SGarrett.Damore@Sun.COM 1839286SGarrett.Damore@Sun.COM uint32_t tx_retry; 1849286SGarrett.Damore@Sun.COM 1859286SGarrett.Damore@Sun.COM /* used for recv */ 1869286SGarrett.Damore@Sun.COM uint8_t *rx_ring; 1879286SGarrett.Damore@Sun.COM uint32_t cur_rx; 1889286SGarrett.Damore@Sun.COM 1899286SGarrett.Damore@Sun.COM /* mutex */ 1909286SGarrett.Damore@Sun.COM kmutex_t rtls_io_lock; /* i/o reg access */ 1919286SGarrett.Damore@Sun.COM kmutex_t rtls_tx_lock; /* send access */ 1929286SGarrett.Damore@Sun.COM kmutex_t rtls_rx_lock; /* receive access */ 1939286SGarrett.Damore@Sun.COM 1949286SGarrett.Damore@Sun.COM /* send reschedule used */ 1959286SGarrett.Damore@Sun.COM boolean_t need_sched; 1969286SGarrett.Damore@Sun.COM 1979286SGarrett.Damore@Sun.COM boolean_t chip_error; /* chip error flag */ 1989286SGarrett.Damore@Sun.COM 1999286SGarrett.Damore@Sun.COM /* current MAC state */ 2009286SGarrett.Damore@Sun.COM boolean_t rtls_running; 2019286SGarrett.Damore@Sun.COM boolean_t rtls_suspended; 2029286SGarrett.Damore@Sun.COM 2039286SGarrett.Damore@Sun.COM /* rtls statistics */ 2049286SGarrett.Damore@Sun.COM rtls_stats_t stats; 2059286SGarrett.Damore@Sun.COM } rtls_t; 2069286SGarrett.Damore@Sun.COM 2079286SGarrett.Damore@Sun.COM #define RTLS_TX_RETRY_NUM 16 2089286SGarrett.Damore@Sun.COM #define RTLS_TX_WAIT_TIMEOUT (void) (drv_usectohz(100 * 1000)) /* 100ms */ 2099286SGarrett.Damore@Sun.COM #define RTLS_RESET_WAIT_NUM 0x100 2109286SGarrett.Damore@Sun.COM #define RTLS_RESET_WAIT_INTERVAL (void) (drv_usecwait(100)) 2119286SGarrett.Damore@Sun.COM #define RTLS_RX_ADDR_ALIGNED(addr) (((addr + 3) & ~3) % RTLS_RX_BUF_RING) 2129286SGarrett.Damore@Sun.COM /* 4-bytes aligned, also with RTLS_RX_BUF_RING boundary */ 2139286SGarrett.Damore@Sun.COM 2149286SGarrett.Damore@Sun.COM /* parameter definition in rtls.conf file */ 2159286SGarrett.Damore@Sun.COM #define FOECE_NONE 0 /* no force */ 2169286SGarrett.Damore@Sun.COM #define FORCE_AUTO_NEGO 5 /* auto negotioation mode */ 2179286SGarrett.Damore@Sun.COM #define FORCE_100_FDX 4 /* 100 full_duplex mode */ 2189286SGarrett.Damore@Sun.COM #define FORCE_100_HDX 3 /* 100 half_duplex mode */ 2199286SGarrett.Damore@Sun.COM #define FORCE_10_FDX 2 /* 10 full_duplex mode */ 2209286SGarrett.Damore@Sun.COM #define FORCE_10_HDX 1 /* 10 half_duplex mode */ 2219286SGarrett.Damore@Sun.COM 2229286SGarrett.Damore@Sun.COM /* 2239286SGarrett.Damore@Sun.COM * RealTek 8129/8139 register offsets definition 2249286SGarrett.Damore@Sun.COM */ 2259286SGarrett.Damore@Sun.COM 2269286SGarrett.Damore@Sun.COM /* 2279286SGarrett.Damore@Sun.COM * MAC address register, initial value isautoloaded from the 2289286SGarrett.Damore@Sun.COM * EEPROM EthernetID field 2299286SGarrett.Damore@Sun.COM */ 2309286SGarrett.Damore@Sun.COM #define ID_0_REG 0x0000 2319286SGarrett.Damore@Sun.COM #define ID_1_REG 0x0001 2329286SGarrett.Damore@Sun.COM #define ID_2_REG 0x0002 2339286SGarrett.Damore@Sun.COM #define ID_3_REG 0x0003 2349286SGarrett.Damore@Sun.COM #define ID_4_REG 0x0004 2359286SGarrett.Damore@Sun.COM #define ID_5_REG 0x0005 2369286SGarrett.Damore@Sun.COM 2379286SGarrett.Damore@Sun.COM /* 2389286SGarrett.Damore@Sun.COM * Multicast register 2399286SGarrett.Damore@Sun.COM */ 2409286SGarrett.Damore@Sun.COM #define MULTICAST_0_REG 0x0008 2419286SGarrett.Damore@Sun.COM #define MULTICAST_1_REG 0x0009 2429286SGarrett.Damore@Sun.COM #define MULTICAST_2_REG 0x000a 2439286SGarrett.Damore@Sun.COM #define MULTICAST_3_REG 0x000b 2449286SGarrett.Damore@Sun.COM #define MULTICAST_4_REG 0x000c 2459286SGarrett.Damore@Sun.COM #define MULTICAST_5_REG 0x000d 2469286SGarrett.Damore@Sun.COM #define MULTICAST_6_REG 0x000e 2479286SGarrett.Damore@Sun.COM #define MULTICAST_7_REG 0x000f 2489286SGarrett.Damore@Sun.COM 2499286SGarrett.Damore@Sun.COM #define RCV_ALL_MULTI_PACKETS 0xffffffff 2509286SGarrett.Damore@Sun.COM 2519286SGarrett.Damore@Sun.COM /* 2529286SGarrett.Damore@Sun.COM * Transmit status register 2539286SGarrett.Damore@Sun.COM */ 2549286SGarrett.Damore@Sun.COM #define TX_STATUS_DESC0_REG 0x0010 2559286SGarrett.Damore@Sun.COM #define TX_STATUS_DESC1_REG 0x0014 2569286SGarrett.Damore@Sun.COM #define TX_STATUS_DESC2_REG 0x0018 2579286SGarrett.Damore@Sun.COM #define TX_STATUS_DESC3_REG 0x001c 2589286SGarrett.Damore@Sun.COM #define TX_STATUS_CS_LOST 0x80000000 /* Carrier Sense Lost */ 2599286SGarrett.Damore@Sun.COM #define TX_STATUS_TX_ABORT 0x40000000 /* Transmit Abort */ 2609286SGarrett.Damore@Sun.COM #define TX_STATUS_OWC 0x20000000 /* Out of Window Collision */ 2619286SGarrett.Damore@Sun.COM #define TX_STATUS_CDH 0x10000000 /* CD Heart Beat */ 2629286SGarrett.Damore@Sun.COM #define TX_STATUS_NCC 0x0f000000 /* Number of Collision Count */ 2639286SGarrett.Damore@Sun.COM #define TX_STATUS_NCC_SHIFT 24 2649286SGarrett.Damore@Sun.COM #define TX_STATUS_TX_THRESHOLD 0x003f0000 /* Early Tx Threshold */ 2659286SGarrett.Damore@Sun.COM #define TX_STATUS_TX_THRESHOLD_SHIFT 16 2669286SGarrett.Damore@Sun.COM #define TX_STATUS_TX_THRESHOLD_MAX 0x3f /* 0x3f * 32 Bytes */ 2679286SGarrett.Damore@Sun.COM #define TX_STATUS_TX_OK 0x00008000 /* Transmit OK */ 2689286SGarrett.Damore@Sun.COM #define TX_STATUS_TX_UNDERRUN 0x00004000 /* Transmit FIFO Underrun */ 2699286SGarrett.Damore@Sun.COM #define TX_STATUS_OWN 0x00002000 /* RTL8139 Own bit */ 2709286SGarrett.Damore@Sun.COM #define TX_STATUS_PACKET_SIZE 0x00001fff 2719286SGarrett.Damore@Sun.COM /* The total size in bytes of the data in this descriptor */ 2729286SGarrett.Damore@Sun.COM 2739286SGarrett.Damore@Sun.COM /* 2749286SGarrett.Damore@Sun.COM * The read-only bits (CRS, TABT, OWC, CDH, NCC3-0, TOK, TUN) will be cleared 2759286SGarrett.Damore@Sun.COM * by the RTL8139 when the Transmit Byte Count (bit12-0) in the corresponding 2769286SGarrett.Damore@Sun.COM * Tx descriptor is written. If h/w transmit finish, at least some of these 2779286SGarrett.Damore@Sun.COM * bits are none zero. 2789286SGarrett.Damore@Sun.COM */ 2799286SGarrett.Damore@Sun.COM #define TX_COMPLETE_FLAG (TX_STATUS_TX_ABORT | TX_STATUS_TX_OK | \ 2809286SGarrett.Damore@Sun.COM TX_STATUS_TX_UNDERRUN) 2819286SGarrett.Damore@Sun.COM #define TX_ERR_FLAG (TX_STATUS_TX_ABORT | TX_STATUS_TX_UNDERRUN | \ 2829286SGarrett.Damore@Sun.COM TX_STATUS_CS_LOST | TX_STATUS_OWC) 2839286SGarrett.Damore@Sun.COM 2849286SGarrett.Damore@Sun.COM /* 2859286SGarrett.Damore@Sun.COM * Transmit start address of descriptors 2869286SGarrett.Damore@Sun.COM */ 2879286SGarrett.Damore@Sun.COM #define TX_ADDR_DESC0_REG 0x0020 2889286SGarrett.Damore@Sun.COM #define TX_ADDR_DESC1_REG 0x0024 2899286SGarrett.Damore@Sun.COM #define TX_ADDR_DESC2_REG 0x0028 2909286SGarrett.Damore@Sun.COM #define TX_ADDR_DESC3_REG 0x002c 2919286SGarrett.Damore@Sun.COM 2929286SGarrett.Damore@Sun.COM /* 2939286SGarrett.Damore@Sun.COM * Receive buffer start address 2949286SGarrett.Damore@Sun.COM */ 2959286SGarrett.Damore@Sun.COM #define RX_BUFF_ADDR_REG 0x0030 2969286SGarrett.Damore@Sun.COM 2979286SGarrett.Damore@Sun.COM /* 2989286SGarrett.Damore@Sun.COM * Early receive byte count register 2999286SGarrett.Damore@Sun.COM */ 3009286SGarrett.Damore@Sun.COM #define RX_STATUS_REG 0x0036 3019286SGarrett.Damore@Sun.COM #define RX_STATUS_GOOD 0x08 3029286SGarrett.Damore@Sun.COM #define RX_STARUS_BAD 0x04 3039286SGarrett.Damore@Sun.COM #define RX_STATUS_COVERWRITE 0x02 3049286SGarrett.Damore@Sun.COM #define RX_STATUS_OK 0x01 3059286SGarrett.Damore@Sun.COM 3069286SGarrett.Damore@Sun.COM /* 3079286SGarrett.Damore@Sun.COM * Commond register 3089286SGarrett.Damore@Sun.COM */ 3099286SGarrett.Damore@Sun.COM #define RT_COMMAND_REG 0x0037 3109286SGarrett.Damore@Sun.COM #define RT_COMMAND_REG_RESERVE 0xe0 3119286SGarrett.Damore@Sun.COM #define RT_COMMAND_RESET 0x10 3129286SGarrett.Damore@Sun.COM #define RT_COMMAND_RX_ENABLE 0x08 3139286SGarrett.Damore@Sun.COM #define RT_COMMAND_TX_ENABLE 0x04 3149286SGarrett.Damore@Sun.COM #define RT_COMMAND_BUFF_EMPTY 0x01 3159286SGarrett.Damore@Sun.COM 3169286SGarrett.Damore@Sun.COM /* 3179286SGarrett.Damore@Sun.COM * Rx current read address register 3189286SGarrett.Damore@Sun.COM */ 3199286SGarrett.Damore@Sun.COM #define RX_CURRENT_READ_ADDR_REG 0x0038 3209286SGarrett.Damore@Sun.COM #define RX_READ_RESET_VAL 0xfff0 3219286SGarrett.Damore@Sun.COM /* 3229286SGarrett.Damore@Sun.COM * Value in RX_CURRENT_READ_ADDR_REG is 16 less than 3239286SGarrett.Damore@Sun.COM * the actual rx read address 3249286SGarrett.Damore@Sun.COM */ 3259286SGarrett.Damore@Sun.COM #define READ_ADDR_GAP 16 3269286SGarrett.Damore@Sun.COM 3279286SGarrett.Damore@Sun.COM #define RX_CURRENT_BUFF_ADDR_REG 0x003a 3289286SGarrett.Damore@Sun.COM 3299286SGarrett.Damore@Sun.COM /* 3309286SGarrett.Damore@Sun.COM * Interrupt register 3319286SGarrett.Damore@Sun.COM */ 3329286SGarrett.Damore@Sun.COM #define RT_INT_MASK_REG 0x003c 3339286SGarrett.Damore@Sun.COM #define RT_INT_STATUS_REG 0x003e 3349286SGarrett.Damore@Sun.COM #define RT_INT_STATUS_INTS 0xe07f 3359286SGarrett.Damore@Sun.COM #define SYS_ERR_INT 0x8000 3369286SGarrett.Damore@Sun.COM #define TIME_OUT_INT 0x4000 3379286SGarrett.Damore@Sun.COM #define CABLE_LEN_CHANGE_INT 0x2000 3389286SGarrett.Damore@Sun.COM #define RX_FIFO_OVERFLOW_INT 0x0040 3399286SGarrett.Damore@Sun.COM #define LINK_CHANGE_INT 0x0020 3409286SGarrett.Damore@Sun.COM #define RX_BUF_OVERFLOW_INT 0x0010 3419286SGarrett.Damore@Sun.COM #define TX_ERR_INT 0x0008 3429286SGarrett.Damore@Sun.COM #define TX_OK_INT 0x0004 3439286SGarrett.Damore@Sun.COM #define RX_ERR_INT 0x0002 3449286SGarrett.Damore@Sun.COM #define RX_OK_INT 0x0001 3459286SGarrett.Damore@Sun.COM 3469286SGarrett.Damore@Sun.COM #define RTLS_INT_MASK_ALL 0xe07f 3479286SGarrett.Damore@Sun.COM #define RTLS_INT_MASK_NONE 0x0000 3489286SGarrett.Damore@Sun.COM #define RTLS_RX_INT (RX_OK_INT | RX_ERR_INT | \ 3499286SGarrett.Damore@Sun.COM RX_BUF_OVERFLOW_INT | RX_FIFO_OVERFLOW_INT) 3509286SGarrett.Damore@Sun.COM #define RX_OVERFLOW_INT (RX_BUF_OVERFLOW_INT | RX_FIFO_OVERFLOW_INT) 3519286SGarrett.Damore@Sun.COM #define RTLS_INT_MASK (LINK_CHANGE_INT | TX_ERR_INT | TX_OK_INT | \ 3529286SGarrett.Damore@Sun.COM RX_BUF_OVERFLOW_INT | RX_FIFO_OVERFLOW_INT | \ 3539286SGarrett.Damore@Sun.COM RX_ERR_INT | RX_OK_INT) 3549286SGarrett.Damore@Sun.COM 3559286SGarrett.Damore@Sun.COM /* 3569286SGarrett.Damore@Sun.COM * Transmit configuration register 3579286SGarrett.Damore@Sun.COM */ 3589286SGarrett.Damore@Sun.COM #define TX_CONFIG_REG 0x0040 3599286SGarrett.Damore@Sun.COM #define TX_CONSIG_REG_RESERVE 0x8078f80e 3609286SGarrett.Damore@Sun.COM #define HW_VERSION_ID_5 0x7c000000 3619286SGarrett.Damore@Sun.COM #define TX_INTERFRAME_GAP_BITS 0x03000000 3629286SGarrett.Damore@Sun.COM #define TX_INTERFRAME_GAP_SHIFT 24 3639286SGarrett.Damore@Sun.COM #define TX_INTERFRAME_GAP_802_3 0x03000000 3649286SGarrett.Damore@Sun.COM #define HW_VERSION_ID_1 0x00800000 3659286SGarrett.Damore@Sun.COM #define LOOPBACK_MODE_ENABLE 0x00060000 3669286SGarrett.Damore@Sun.COM #define CRC_APPEND_ENABLE 0x00010000 3679286SGarrett.Damore@Sun.COM #define TX_DMA_BURST_BYTES 0x00000700 3689286SGarrett.Damore@Sun.COM #define TX_DMA_BURST_2048B 0x00000700 3699286SGarrett.Damore@Sun.COM #define TX_DMA_BURST_1024B 0x00000600 3709286SGarrett.Damore@Sun.COM #define TX_RETRY_COUNT_BITS 0x000000f0 3719286SGarrett.Damore@Sun.COM #define TX_RETRY_COUNT_DEFUALT 0x00000010 3729286SGarrett.Damore@Sun.COM /* re-transmit count (16 + 1 * 16) = 32 times before aborting */ 3739286SGarrett.Damore@Sun.COM #define TX_CLEAR_ABORT 0x00000001 3749286SGarrett.Damore@Sun.COM 3759286SGarrett.Damore@Sun.COM #define TX_CONFIG_DEFAULT (TX_INTERFRAME_GAP_802_3 | \ 3769286SGarrett.Damore@Sun.COM TX_DMA_BURST_1024B | \ 3779286SGarrett.Damore@Sun.COM TX_RETRY_COUNT_DEFUALT) 3789286SGarrett.Damore@Sun.COM #define TX_FIFO_THRESHHOLD 1024 3799286SGarrett.Damore@Sun.COM /* 3809286SGarrett.Damore@Sun.COM * Receive configuration register 3819286SGarrett.Damore@Sun.COM */ 3829286SGarrett.Damore@Sun.COM #define RX_CONFIG_REG 0x0044 3839286SGarrett.Damore@Sun.COM #define RX_CONSIG_REG_RESERVE 0xf0fc0000 3849286SGarrett.Damore@Sun.COM 3859286SGarrett.Damore@Sun.COM #define RX_THRESHOLD_BITS 0x0f000000 3869286SGarrett.Damore@Sun.COM #define RX_EARLY_INT_SEL 0x00020000 3879286SGarrett.Damore@Sun.COM #define RX_RER8_ENABLE 0x00010000 3889286SGarrett.Damore@Sun.COM 3899286SGarrett.Damore@Sun.COM #define RX_FIFO_THRESHOLD_BITS 0x0000e000 3909286SGarrett.Damore@Sun.COM #define RX_FIFO_THRESHOLD_16B 0x00000000 3919286SGarrett.Damore@Sun.COM #define RX_FIFO_THRESHOLD_32B 0x00002000 3929286SGarrett.Damore@Sun.COM #define RX_FIFO_THRESHOLD_64B 0x00004000 3939286SGarrett.Damore@Sun.COM #define RX_FIFO_THRESHOLD_128B 0x00006000 3949286SGarrett.Damore@Sun.COM #define RX_FIFO_THRESHOLD_256B 0x00008000 3959286SGarrett.Damore@Sun.COM #define RX_FIFO_THRESHOLD_512B 0x0000a000 3969286SGarrett.Damore@Sun.COM #define RX_FIFO_THRESHOLD_1024B 0x0000c000 3979286SGarrett.Damore@Sun.COM #define RX_FIFO_THRESHOLD_NONE 0x0000e000 3989286SGarrett.Damore@Sun.COM 3999286SGarrett.Damore@Sun.COM #define RX_BUF_LEN_BITS 0x00001800 4009286SGarrett.Damore@Sun.COM #define RX_BUF_LEN_8K 0x00000000 4019286SGarrett.Damore@Sun.COM #define RX_BUF_LEN_16K 0x00000800 4029286SGarrett.Damore@Sun.COM #define RX_BUF_LEN_32K 0x00001000 4039286SGarrett.Damore@Sun.COM #define RX_BUF_LEN_64K 0x00001800 4049286SGarrett.Damore@Sun.COM 4059286SGarrett.Damore@Sun.COM #define RX_DMA_BURST_BYTES 0x00000700 4069286SGarrett.Damore@Sun.COM #define RX_DMA_BURST_16B 0x00000000 4079286SGarrett.Damore@Sun.COM #define RX_DMA_BURST_32B 0x00000100 4089286SGarrett.Damore@Sun.COM #define RX_DMA_BURST_64B 0x00000200 4099286SGarrett.Damore@Sun.COM #define RX_DMA_BURST_128B 0x00000300 4109286SGarrett.Damore@Sun.COM #define RX_DMA_BURST_256B 0x00000400 4119286SGarrett.Damore@Sun.COM #define RX_DMA_BURST_512B 0x00000500 4129286SGarrett.Damore@Sun.COM #define RX_DMA_BURST_1024B 0x00000600 4139286SGarrett.Damore@Sun.COM #define RX_DMA_BURST_UNLIMITED 0x00000700 4149286SGarrett.Damore@Sun.COM 4159286SGarrett.Damore@Sun.COM #define RX_NOWRAP_ENABLE 0x00000080 4169286SGarrett.Damore@Sun.COM #define RX_EEPROM_9356 0x00000040 4179286SGarrett.Damore@Sun.COM #define RX_ACCEPT_ERR_PACKET 0x00000020 4189286SGarrett.Damore@Sun.COM #define RX_ACCEPT_RUNT_PACKET 0x00000010 4199286SGarrett.Damore@Sun.COM #define RX_ACCEPT_BROADCAST_PACKET 0x000000008 4209286SGarrett.Damore@Sun.COM #define RX_ACCEPT_MULTICAST_PACKET 0x000000004 4219286SGarrett.Damore@Sun.COM #define RX_ACCEPT_MAC_MATCH_PACKET 0x000000002 4229286SGarrett.Damore@Sun.COM #define RX_ACCEPT_ALL_PACKET 0x000000001 4239286SGarrett.Damore@Sun.COM 4249286SGarrett.Damore@Sun.COM #define RX_CONFIG_DEFAULT (RX_FIFO_THRESHOLD_NONE | \ 4259286SGarrett.Damore@Sun.COM RX_BUF_LEN_32K | \ 4269286SGarrett.Damore@Sun.COM RX_DMA_BURST_1024B | \ 4279286SGarrett.Damore@Sun.COM RX_ACCEPT_BROADCAST_PACKET | \ 4289286SGarrett.Damore@Sun.COM RX_ACCEPT_MULTICAST_PACKET | \ 4299286SGarrett.Damore@Sun.COM RX_ACCEPT_MAC_MATCH_PACKET) 4309286SGarrett.Damore@Sun.COM /* 4319286SGarrett.Damore@Sun.COM * Missed packet counter: indicates the number of packets 4329286SGarrett.Damore@Sun.COM * discarded due to rx FIFO overflow 4339286SGarrett.Damore@Sun.COM */ 4349286SGarrett.Damore@Sun.COM #define RX_PACKET_MISS_COUNT_REG 0x004c 4359286SGarrett.Damore@Sun.COM 4369286SGarrett.Damore@Sun.COM /* 4379286SGarrett.Damore@Sun.COM * 93c46(93c56) commond register: 4389286SGarrett.Damore@Sun.COM */ 439*11453Sgdamore@opensolaris.org #define RT_93c46_COMMAND_REG 0x0050 4409286SGarrett.Damore@Sun.COM #define RT_93c46_MODE_BITS 0xc0 4419286SGarrett.Damore@Sun.COM #define RT_93c46_MODE_NORMAL 0x00 4429286SGarrett.Damore@Sun.COM #define RT_93c46_MODE_AUTOLOAD 0x40 4439286SGarrett.Damore@Sun.COM #define RT_93c46_MODE_PROGRAM 0x80 4449286SGarrett.Damore@Sun.COM #define RT_93c46_MODE_CONFIG 0xc0 4459286SGarrett.Damore@Sun.COM 4469286SGarrett.Damore@Sun.COM #define RT_93c46_EECS 0x08 4479286SGarrett.Damore@Sun.COM #define RT_93c46_EESK 0x04 4489286SGarrett.Damore@Sun.COM #define RT_93c46_EEDI 0x02 4499286SGarrett.Damore@Sun.COM #define RT_93c46_EEDO 0x01 4509286SGarrett.Damore@Sun.COM 4519286SGarrett.Damore@Sun.COM /* 4529286SGarrett.Damore@Sun.COM * Configuration registers 4539286SGarrett.Damore@Sun.COM */ 4549286SGarrett.Damore@Sun.COM #define RT_CONFIG_0_REG 0x0051 4559286SGarrett.Damore@Sun.COM #define RT_CONFIG_1_REG 0x0052 4569286SGarrett.Damore@Sun.COM #define RT_CONFIG_3_REG 0x0059 4579286SGarrett.Damore@Sun.COM #define RT_CONFIG_4_REG 0x005a 4589286SGarrett.Damore@Sun.COM 4599286SGarrett.Damore@Sun.COM /* 4609286SGarrett.Damore@Sun.COM * Media status register 4619286SGarrett.Damore@Sun.COM */ 4629286SGarrett.Damore@Sun.COM #define MEDIA_STATUS_REG 0x0058 4639286SGarrett.Damore@Sun.COM #define MEDIA_STATUS_LINK 0x04 4649286SGarrett.Damore@Sun.COM #define MEDIA_STATUS_SPEED 0x08 4659286SGarrett.Damore@Sun.COM 4669286SGarrett.Damore@Sun.COM #define RTLS_SPEED_100M 100000000 4679286SGarrett.Damore@Sun.COM #define RTLS_SPEED_10M 10000000 4689286SGarrett.Damore@Sun.COM #define RTLS_SPEED_UNKNOWN 0 4699286SGarrett.Damore@Sun.COM /* 4709286SGarrett.Damore@Sun.COM * Multiple interrupt select register 4719286SGarrett.Damore@Sun.COM */ 4729286SGarrett.Damore@Sun.COM #define RT_MUL_INTSEL_REG 0x005c 4739286SGarrett.Damore@Sun.COM #define RT_MUL_INTSEL_BITS 0x0fff 4749286SGarrett.Damore@Sun.COM 4759286SGarrett.Damore@Sun.COM /* 4769286SGarrett.Damore@Sun.COM * Transmit status of all descriptor registers register 4779286SGarrett.Damore@Sun.COM */ 4789286SGarrett.Damore@Sun.COM #define TX_DESC_STAUS_REG 0x0060 4799286SGarrett.Damore@Sun.COM #define TX_DESC_STAUS_OWN_0 0x0001 4809286SGarrett.Damore@Sun.COM #define TX_DESC_STAUS_ABORT_0 0x0010 4819286SGarrett.Damore@Sun.COM #define TX_DESC_STAUS_UNDERRUN_0 0x0100 4829286SGarrett.Damore@Sun.COM #define TX_DESC_STAUS_TXOK_0 0x1000 4839286SGarrett.Damore@Sun.COM #define TX_DESC_STAUS_OWN_1 0x0002 4849286SGarrett.Damore@Sun.COM #define TX_DESC_STAUS_ABORT_1 0x0020 4859286SGarrett.Damore@Sun.COM #define TX_DESC_STAUS_UNDERRUN_1 0x0200 4869286SGarrett.Damore@Sun.COM #define TX_DESC_STAUS_TXOK_1 0x2000 4879286SGarrett.Damore@Sun.COM #define TX_DESC_STAUS_OWN_2 0x0004 4889286SGarrett.Damore@Sun.COM #define TX_DESC_STAUS_ABORT_2 0x0040 4899286SGarrett.Damore@Sun.COM #define TX_DESC_STAUS_UNDERRUN_2 0x0400 4909286SGarrett.Damore@Sun.COM #define TX_DESC_STAUS_TXOK_2 0x4000 4919286SGarrett.Damore@Sun.COM #define TX_DESC_STAUS_OWN_3 0x0008 4929286SGarrett.Damore@Sun.COM #define TX_DESC_STAUS_ABORT_3 0x0080 4939286SGarrett.Damore@Sun.COM #define TX_DESC_STAUS_UNDERRUN_3 0x0800 4949286SGarrett.Damore@Sun.COM #define TX_DESC_STAUS_TXOK_3 0x8000 4959286SGarrett.Damore@Sun.COM 4969286SGarrett.Damore@Sun.COM /* 4979286SGarrett.Damore@Sun.COM * Basic mode control register 4989286SGarrett.Damore@Sun.COM */ 4999286SGarrett.Damore@Sun.COM #define BASIC_MODE_CONTROL_REG 0x0062 5009286SGarrett.Damore@Sun.COM #define BASIC_MODE_CONTROL_BITS 0x3300 5019286SGarrett.Damore@Sun.COM 5029286SGarrett.Damore@Sun.COM #define BASIC_MODE_SPEED 0x2000 5039286SGarrett.Damore@Sun.COM #define BASIC_MODE_SPEED_100 0x2000 5049286SGarrett.Damore@Sun.COM 5059286SGarrett.Damore@Sun.COM #define BASIC_MODE_AUTONEGO 0x1000 5069286SGarrett.Damore@Sun.COM 5079286SGarrett.Damore@Sun.COM #define BASIC_MODE_RESTAR_AUTONEGO 0x0200 5089286SGarrett.Damore@Sun.COM 5099286SGarrett.Damore@Sun.COM #define BASIC_MODE_DUPLEX 0x0100 5109286SGarrett.Damore@Sun.COM #define BASIC_MODE_DUPLEX_FULL 0x0100 5119286SGarrett.Damore@Sun.COM 5129286SGarrett.Damore@Sun.COM /* 5139286SGarrett.Damore@Sun.COM * Basic mode status register 5149286SGarrett.Damore@Sun.COM */ 5159286SGarrett.Damore@Sun.COM #define BASIC_MODE_STATUS_REG 0x0064 5169286SGarrett.Damore@Sun.COM #define BASIC_MODE_STATUS_AUTONEGO_DONE 0x0020 5179286SGarrett.Damore@Sun.COM #define BASIC_MODE_STATUS_REMOTE_FAULT 0x0010 5189286SGarrett.Damore@Sun.COM 5199286SGarrett.Damore@Sun.COM /* 5209286SGarrett.Damore@Sun.COM * Auto-negotiation advertisement register 5219286SGarrett.Damore@Sun.COM */ 5229286SGarrett.Damore@Sun.COM #define AUTO_NEGO_AD_REG 0x0066 5239286SGarrett.Damore@Sun.COM #define AUTO_NEGO_MODE_BITS 0x01e0 5249286SGarrett.Damore@Sun.COM #define AUTO_NEGO_100FULL 0x0100 5259286SGarrett.Damore@Sun.COM #define AUTO_NEGO_100HALF 0x0080 5269286SGarrett.Damore@Sun.COM #define AUTO_NEGO_10FULL 0x0040 5279286SGarrett.Damore@Sun.COM #define AUTO_NEGO_10HALF 0x0020 5289286SGarrett.Damore@Sun.COM 5299286SGarrett.Damore@Sun.COM /* 5309286SGarrett.Damore@Sun.COM * Auto-negotiation link partner ability register 5319286SGarrett.Damore@Sun.COM */ 5329286SGarrett.Damore@Sun.COM #define AUTO_NEGO_LP_REG 0x0068 5339286SGarrett.Damore@Sun.COM 5349286SGarrett.Damore@Sun.COM /* 5359286SGarrett.Damore@Sun.COM * Auto-negotiation expansion register 5369286SGarrett.Damore@Sun.COM */ 5379286SGarrett.Damore@Sun.COM #define AUTO_NEGO_EXP_REG 0x006a 5389286SGarrett.Damore@Sun.COM #define AUTO_NEGO_EXP_LPCANAN 0x0001 5399286SGarrett.Damore@Sun.COM 5409286SGarrett.Damore@Sun.COM /* 5419286SGarrett.Damore@Sun.COM * Receive status in rx packet header 5429286SGarrett.Damore@Sun.COM */ 5439286SGarrett.Damore@Sun.COM #define RX_HEADER_SIZE 4 5449286SGarrett.Damore@Sun.COM 5459286SGarrett.Damore@Sun.COM #define RX_HEADER_LEN_BITS 0xffff0000 5469286SGarrett.Damore@Sun.COM #define RX_HEADER_STATUS_BITS 0x0000ffff 5479286SGarrett.Damore@Sun.COM #define RX_STATUS_DMA_BUSY 0xfff0 5489286SGarrett.Damore@Sun.COM #define RX_HEADER_STATUS_MULTI 0x8000 5499286SGarrett.Damore@Sun.COM #define RX_HEADER_STATUS_PAM 0x4000 5509286SGarrett.Damore@Sun.COM #define RX_HEADER_STATUS_BCAST 0x2000 5519286SGarrett.Damore@Sun.COM 5529286SGarrett.Damore@Sun.COM #define RX_HEADER_STATUS_ISE 0x0020 5539286SGarrett.Damore@Sun.COM #define RX_HEADER_STATUS_RUNT 0x0010 5549286SGarrett.Damore@Sun.COM #define RX_HEADER_STATUS_LONG 0x0008 5559286SGarrett.Damore@Sun.COM #define RX_HEADER_STATUS_CRC 0x0004 5569286SGarrett.Damore@Sun.COM #define RX_HEADER_STATUS_FAE 0x0002 5579286SGarrett.Damore@Sun.COM #define RX_HEADER_STATUS_ROK 0x0001 5589286SGarrett.Damore@Sun.COM 5599286SGarrett.Damore@Sun.COM #define RX_ERR_FLAGS (RX_HEADER_STATUS_ISE | RX_HEADER_STATUS_RUNT | \ 5609286SGarrett.Damore@Sun.COM RX_HEADER_STATUS_FAE | RX_HEADER_STATUS_CRC) 5619286SGarrett.Damore@Sun.COM 5629286SGarrett.Damore@Sun.COM #ifdef __cplusplus 5639286SGarrett.Damore@Sun.COM } 5649286SGarrett.Damore@Sun.COM #endif 5659286SGarrett.Damore@Sun.COM 5669286SGarrett.Damore@Sun.COM #endif /* _SYS_RTLS_H */ 567