19540SJoost.Mulders@Sun.COM /* 29540SJoost.Mulders@Sun.COM * CDDL HEADER START 39540SJoost.Mulders@Sun.COM * 49540SJoost.Mulders@Sun.COM * The contents of this file are subject to the terms of the 59540SJoost.Mulders@Sun.COM * Common Development and Distribution License (the "License"). 69540SJoost.Mulders@Sun.COM * You may not use this file except in compliance with the License. 79540SJoost.Mulders@Sun.COM * 89540SJoost.Mulders@Sun.COM * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 99540SJoost.Mulders@Sun.COM * or http://www.opensolaris.org/os/licensing. 109540SJoost.Mulders@Sun.COM * See the License for the specific language governing permissions 119540SJoost.Mulders@Sun.COM * and limitations under the License. 129540SJoost.Mulders@Sun.COM * 139540SJoost.Mulders@Sun.COM * When distributing Covered Code, include this CDDL HEADER in each 149540SJoost.Mulders@Sun.COM * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 159540SJoost.Mulders@Sun.COM * If applicable, add the following below this CDDL HEADER, with the 169540SJoost.Mulders@Sun.COM * fields enclosed by brackets "[]" replaced with your own identifying 179540SJoost.Mulders@Sun.COM * information: Portions Copyright [yyyy] [name of copyright owner] 189540SJoost.Mulders@Sun.COM * 199540SJoost.Mulders@Sun.COM * CDDL HEADER END 209540SJoost.Mulders@Sun.COM */ 219540SJoost.Mulders@Sun.COM 229540SJoost.Mulders@Sun.COM /* 23*11878SVenu.Iyer@Sun.COM * Copyright 2010 Sun Microsystems, Inc. All rights reserved. 249540SJoost.Mulders@Sun.COM * Use is subject to license terms. 259540SJoost.Mulders@Sun.COM */ 269540SJoost.Mulders@Sun.COM 279540SJoost.Mulders@Sun.COM #ifndef _VR_H 289540SJoost.Mulders@Sun.COM #define _VR_H 299540SJoost.Mulders@Sun.COM 309540SJoost.Mulders@Sun.COM #ifdef __cplusplus 319540SJoost.Mulders@Sun.COM extern "C" { 329540SJoost.Mulders@Sun.COM #endif 339540SJoost.Mulders@Sun.COM 349540SJoost.Mulders@Sun.COM /* 359540SJoost.Mulders@Sun.COM * Number of descriptor entries for each ring. The no. of descriptors is bound 369540SJoost.Mulders@Sun.COM * to 4K per ring (256 entries a 16 bytes). 379540SJoost.Mulders@Sun.COM */ 389540SJoost.Mulders@Sun.COM #define VR_TX_N_DESC 128 399540SJoost.Mulders@Sun.COM #define VR_RX_N_DESC 256 409540SJoost.Mulders@Sun.COM 419540SJoost.Mulders@Sun.COM /* 429540SJoost.Mulders@Sun.COM * The number of TX interrupts to "schedule" on the ring. 439540SJoost.Mulders@Sun.COM */ 449540SJoost.Mulders@Sun.COM #define VR_TX_INTRS_RING 3 459540SJoost.Mulders@Sun.COM 469540SJoost.Mulders@Sun.COM /* 479540SJoost.Mulders@Sun.COM * The the periodic check interval of 2 seconds, in nano seconds 489540SJoost.Mulders@Sun.COM */ 499540SJoost.Mulders@Sun.COM #define VR_CHECK_INTERVAL (2000 * 1000 * 1000) 509540SJoost.Mulders@Sun.COM 519540SJoost.Mulders@Sun.COM /* 529540SJoost.Mulders@Sun.COM * The number of TX checks that must pass without progress before we decide 539540SJoost.Mulders@Sun.COM * to reset the adapter. 549540SJoost.Mulders@Sun.COM */ 559540SJoost.Mulders@Sun.COM #define VR_MAXTXCHECKS 12 569540SJoost.Mulders@Sun.COM 579540SJoost.Mulders@Sun.COM /* 589540SJoost.Mulders@Sun.COM * All possible interrupts with the unwanted commented. 599540SJoost.Mulders@Sun.COM */ 609540SJoost.Mulders@Sun.COM #define VR_ICR0_CFG (VR_ICR0_RX_DONE | \ 619540SJoost.Mulders@Sun.COM VR_ICR0_TX_DONE | \ 629540SJoost.Mulders@Sun.COM VR_ICR0_RX_ERR | \ 639540SJoost.Mulders@Sun.COM VR_ICR0_TX_ERR | \ 649540SJoost.Mulders@Sun.COM VR_ICR0_TX_BUF_UFLOW| \ 659540SJoost.Mulders@Sun.COM VR_ICR0_RX_LINKERR | \ 669540SJoost.Mulders@Sun.COM VR_ICR0_BUSERR | \ 679540SJoost.Mulders@Sun.COM /* VR_ICR0_STATSMAX | */ \ 689540SJoost.Mulders@Sun.COM /* VR_ICR0_RX_EARLY | */ \ 699540SJoost.Mulders@Sun.COM VR_ICR0_TX_FIFO_UFLOW | \ 709540SJoost.Mulders@Sun.COM VR_ICR0_RX_FIFO_OFLOW | \ 719540SJoost.Mulders@Sun.COM VR_ICR0_RX_DROPPED | \ 729540SJoost.Mulders@Sun.COM VR_ICR0_RX_NOBUF | \ 739540SJoost.Mulders@Sun.COM VR_ICR0_TX_ABORT | \ 749540SJoost.Mulders@Sun.COM VR_ICR0_LINKSTATUS | \ 759540SJoost.Mulders@Sun.COM VR_ICR0_GENERAL) 769540SJoost.Mulders@Sun.COM 779540SJoost.Mulders@Sun.COM #define VR_ICR1_CFG (/* VR_ICR1_TIMER0 | */ \ 789540SJoost.Mulders@Sun.COM /* VR_ICR1_TIMER1 | */ \ 799540SJoost.Mulders@Sun.COM /* VR_ICR1_PHYEVENT | */ \ 809540SJoost.Mulders@Sun.COM /* VR_ICR1_TDERR | */ \ 819540SJoost.Mulders@Sun.COM /* VR_ICR1_SSRCI | */ \ 829540SJoost.Mulders@Sun.COM /* VR_ICR1_UINTR_SET| */ \ 839540SJoost.Mulders@Sun.COM /* VR_ICR1_UINTR_CLR| */ \ 849540SJoost.Mulders@Sun.COM /* VR_ICR1_PWEI */) 859540SJoost.Mulders@Sun.COM 869540SJoost.Mulders@Sun.COM /* 879540SJoost.Mulders@Sun.COM * Our definitions of RX and TX errors. 889540SJoost.Mulders@Sun.COM */ 899540SJoost.Mulders@Sun.COM #define VR_ISR_TX_ERR_BITS (VR_ICR0_TX_ERR | \ 909540SJoost.Mulders@Sun.COM VR_ICR0_TX_BUF_UFLOW | \ 919540SJoost.Mulders@Sun.COM VR_ICR0_TX_FIFO_UFLOW | \ 929540SJoost.Mulders@Sun.COM VR_ICR0_TX_ABORT) 939540SJoost.Mulders@Sun.COM 949540SJoost.Mulders@Sun.COM #define VR_ISR_RX_ERR_BITS (VR_ICR0_RX_ERR | \ 959540SJoost.Mulders@Sun.COM VR_ICR0_RX_LINKERR | \ 969540SJoost.Mulders@Sun.COM VR_ICR0_RX_FIFO_OFLOW | \ 979540SJoost.Mulders@Sun.COM VR_ICR0_RX_DROPPED | \ 989540SJoost.Mulders@Sun.COM VR_ICR0_RX_NOBUF) 999540SJoost.Mulders@Sun.COM 1009540SJoost.Mulders@Sun.COM #define VR_ISR_SYS_ERR_BITS (VR_ICR0_BUSERR) 1019540SJoost.Mulders@Sun.COM 1029540SJoost.Mulders@Sun.COM #define VR_ISR_ERR_BITS (VR_ISR_TX_ERR_BITS | \ 1039540SJoost.Mulders@Sun.COM VR_ISR_RX_ERR_BITS | \ 1049540SJoost.Mulders@Sun.COM VR_ISR_SYS_ERR_BITS) 1059540SJoost.Mulders@Sun.COM #define VR_TX_MAX_INTR_DISTANCE \ 1069540SJoost.Mulders@Sun.COM (VR_TX_N_DESC / VR_TX_INTRS_RING) 1079540SJoost.Mulders@Sun.COM 1089540SJoost.Mulders@Sun.COM 1099540SJoost.Mulders@Sun.COM #define MODULENAME "vr" /* Our name */ 1109540SJoost.Mulders@Sun.COM #define VR_SLOPSZ 2 1119540SJoost.Mulders@Sun.COM #define VR_MAX_PKTSZ (ETHERMAX + ETHERFCSL + VLAN_TAGSZ + VR_SLOPSZ) 1129540SJoost.Mulders@Sun.COM #define VR_DMABUFSZ (VR_MAX_PKTSZ) 1139540SJoost.Mulders@Sun.COM #define VR_MMI_WAITINCR (10) 1149540SJoost.Mulders@Sun.COM #define VR_MMI_WAITMAX (10000) 1159540SJoost.Mulders@Sun.COM #define VR_CAM_SZ (32) 1169540SJoost.Mulders@Sun.COM 1179540SJoost.Mulders@Sun.COM /* 1189540SJoost.Mulders@Sun.COM * PCI identification for the Rhine's. 1199540SJoost.Mulders@Sun.COM */ 1209540SJoost.Mulders@Sun.COM #define VR_PCI_VIA_VENID 0x1106 1219540SJoost.Mulders@Sun.COM #define VR_PCI_DEVID_RHINE 0x3043 1229540SJoost.Mulders@Sun.COM #define VR_PCI_DEVID_RHINE_IIIM 0x3053 1239540SJoost.Mulders@Sun.COM #define VR_PCI_DEVID_RHINE_II2 0x3065 1249540SJoost.Mulders@Sun.COM #define VR_PCI_DEVID_RHINE_III 0x3106 1259540SJoost.Mulders@Sun.COM #define VR_PCI_DEVID_RHINE_II 0x6100 1269540SJoost.Mulders@Sun.COM 1279540SJoost.Mulders@Sun.COM #define VR_PCI_REVID_VT86C100A_E 0x04 1289540SJoost.Mulders@Sun.COM #define VR_PCI_REVID_VT6102_A 0x40 1299540SJoost.Mulders@Sun.COM #define VR_PCI_REVID_VT6102_C 0x42 1309540SJoost.Mulders@Sun.COM #define VR_PCI_REVID_VT6105_A0 0x80 1319540SJoost.Mulders@Sun.COM #define VR_PCI_REVID_VT6105_B0 0x83 1329540SJoost.Mulders@Sun.COM #define VR_PCI_REVID_VT6105_LOM 0x8A 1339540SJoost.Mulders@Sun.COM #define VR_PCI_REVID_VT6107_A0 0x8C 1349540SJoost.Mulders@Sun.COM #define VR_PCI_REVID_VT6107_A1 0x8D 1359540SJoost.Mulders@Sun.COM #define VR_PCI_REVID_VT6105M_A0 0x90 1369540SJoost.Mulders@Sun.COM #define VR_PCI_REVID_VT6105M_B1 0x94 1379540SJoost.Mulders@Sun.COM 1389540SJoost.Mulders@Sun.COM /* 1399540SJoost.Mulders@Sun.COM * Feature bits for the different cards. 1409540SJoost.Mulders@Sun.COM */ 1419540SJoost.Mulders@Sun.COM #define VR_FEATURE_NONE (0) 1429540SJoost.Mulders@Sun.COM #define VR_FEATURE_RX_PAUSE_CAP (1 << 0) /* can receive pauses */ 1439540SJoost.Mulders@Sun.COM #define VR_FEATURE_TX_PAUSE_CAP (1 << 1) /* can transmit pauses */ 1449540SJoost.Mulders@Sun.COM #define VR_FEATURE_MRDLNMULTIPLE (1 << 2) /* can read mult cache lines */ 1459540SJoost.Mulders@Sun.COM #define VR_FEATURE_TXCHKSUM (1 << 3) /* can do TX TCP checksum */ 1469540SJoost.Mulders@Sun.COM #define VR_FEATURE_RXCHKSUM (1 << 4) /* can do RX TCP checksum */ 1479540SJoost.Mulders@Sun.COM #define VR_FEATURE_CAMSUPPORT (1 << 5) /* has a CAM filter */ 1489540SJoost.Mulders@Sun.COM #define VR_FEATURE_VLANTAGGING (1 << 6) /* can do VLAN tagging */ 1499540SJoost.Mulders@Sun.COM #define VR_FEATURE_MIBCOUNTER (1 << 7) /* has a MIB counter */ 1509540SJoost.Mulders@Sun.COM 1519540SJoost.Mulders@Sun.COM /* 1529540SJoost.Mulders@Sun.COM * Bug bits for the different cards. 1539540SJoost.Mulders@Sun.COM */ 1549540SJoost.Mulders@Sun.COM #define VR_BUG_NONE (0) 1559540SJoost.Mulders@Sun.COM #define VR_BUG_TXALIGN (1 << 0) /* needs aligned TX */ 1569540SJoost.Mulders@Sun.COM #define VR_BUG_NEEDMODE10T (1 << 1) /* chip needs mode10t secret */ 1579540SJoost.Mulders@Sun.COM #define VR_BUG_NEEDMIION (1 << 2) /* chip needs miion secret */ 1589540SJoost.Mulders@Sun.COM #define VR_BUG_NEEDMODE2PCEROPT (1 << 3) /* chip needs pceropt */ 1599540SJoost.Mulders@Sun.COM #define VR_BUG_NO_TXQUEUEING (1 << 4) /* chip cannot queue tx */ 1609540SJoost.Mulders@Sun.COM #define VR_BUG_NO_MEMIO (1 << 5) /* chip cannot memory space */ 1619540SJoost.Mulders@Sun.COM #define VR_BUG_MIIPOLLSTOP (1 << 6) /* special to stop polling */ 1629540SJoost.Mulders@Sun.COM 1639540SJoost.Mulders@Sun.COM #define VR_GET8(acc, p) \ 1649540SJoost.Mulders@Sun.COM ddi_get8((acc)->hdl, \ 1659540SJoost.Mulders@Sun.COM (uint8_t *)((void *)((acc)->addr + (p)))) 1669540SJoost.Mulders@Sun.COM #define VR_GET16(acc, p) \ 1679540SJoost.Mulders@Sun.COM ddi_get16((acc)->hdl, \ 1689540SJoost.Mulders@Sun.COM (uint16_t *)((void *)((acc)->addr + (p)))) 1699540SJoost.Mulders@Sun.COM #define VR_GET32(acc, p) \ 1709540SJoost.Mulders@Sun.COM ddi_get32((acc)->hdl, \ 1719540SJoost.Mulders@Sun.COM (uint32_t *)((void *)((acc)->addr + (p)))) 1729540SJoost.Mulders@Sun.COM 1739540SJoost.Mulders@Sun.COM #define VR_PUT8(acc, p, v) \ 1749540SJoost.Mulders@Sun.COM ddi_put8((acc)->hdl, \ 1759540SJoost.Mulders@Sun.COM (uint8_t *)((void *)((acc)->addr + (p))), v) 1769540SJoost.Mulders@Sun.COM #define VR_PUT16(acc, p, v) \ 1779540SJoost.Mulders@Sun.COM ddi_put16((acc)->hdl, \ 1789540SJoost.Mulders@Sun.COM (uint16_t *)((void *)((acc)->addr + (p))), v) 1799540SJoost.Mulders@Sun.COM #define VR_PUT32(acc, p, v) \ 1809540SJoost.Mulders@Sun.COM ddi_put32((acc)->hdl, \ 1819540SJoost.Mulders@Sun.COM (uint32_t *)((void *)((acc)->addr + (p))), v) 1829540SJoost.Mulders@Sun.COM 1839540SJoost.Mulders@Sun.COM /* 1849540SJoost.Mulders@Sun.COM * Clear bit b in register r. 1859540SJoost.Mulders@Sun.COM */ 1869540SJoost.Mulders@Sun.COM #define VR_CLRBIT8(acc, r, b) \ 1879540SJoost.Mulders@Sun.COM VR_PUT8(acc, r, VR_GET8(acc, r) & ~(b)) 1889540SJoost.Mulders@Sun.COM #define VR_CLRBIT16(acc, r, b) \ 1899540SJoost.Mulders@Sun.COM VR_PUT16(acc, r, VR_GET16(acc, r) & ~(b)) 1909540SJoost.Mulders@Sun.COM #define VR_CLRBIT32(acc, r, b) \ 1919540SJoost.Mulders@Sun.COM VR_PUT32(acc, r, VR_GET32(acc, r) & ~(b)) 1929540SJoost.Mulders@Sun.COM 1939540SJoost.Mulders@Sun.COM /* 1949540SJoost.Mulders@Sun.COM * Set bit b in register r. 1959540SJoost.Mulders@Sun.COM */ 1969540SJoost.Mulders@Sun.COM #define VR_SETBIT8(acc, r, b) \ 1979540SJoost.Mulders@Sun.COM VR_PUT8(acc, r, (VR_GET8(acc, r) | (b))) 1989540SJoost.Mulders@Sun.COM #define VR_SETBIT16(acc, r, b) \ 1999540SJoost.Mulders@Sun.COM VR_PUT16(acc, r, (VR_GET16(acc, r) | (b))) 2009540SJoost.Mulders@Sun.COM #define VR_SETBIT32(acc, r, b) \ 2019540SJoost.Mulders@Sun.COM VR_PUT32(acc, r, (VR_GET32(acc, r) | (b))) 2029540SJoost.Mulders@Sun.COM 2039540SJoost.Mulders@Sun.COM /* 2049540SJoost.Mulders@Sun.COM * Set bits b in register r to value v. 2059540SJoost.Mulders@Sun.COM */ 2069540SJoost.Mulders@Sun.COM #define VR_SETBITS8(acc, r, b, v) \ 2079540SJoost.Mulders@Sun.COM VR_PUT8(acc, r, (VR_GET8(acc, r) & ~(b)) | (v)) 2089540SJoost.Mulders@Sun.COM #define VR_SETBITS16(acc, r, b, v) \ 2099540SJoost.Mulders@Sun.COM VR_PUT16(acc, r, (VR_GET16(acc, r) & ~(b)) | (v)) 2109540SJoost.Mulders@Sun.COM #define VR_SETBITS32(acc, r, b, v) \ 2119540SJoost.Mulders@Sun.COM VR_PUT32(acc, r, (VR_GET32(acc, r) & ~(b)) | (v)) 2129540SJoost.Mulders@Sun.COM 2139540SJoost.Mulders@Sun.COM /* 2149540SJoost.Mulders@Sun.COM * The descriptor as used by the MAC. 2159540SJoost.Mulders@Sun.COM */ 2169540SJoost.Mulders@Sun.COM typedef struct { 2179540SJoost.Mulders@Sun.COM uint32_t stat0; 2189540SJoost.Mulders@Sun.COM uint32_t stat1; 2199540SJoost.Mulders@Sun.COM uint32_t data; 2209540SJoost.Mulders@Sun.COM uint32_t next; 2219540SJoost.Mulders@Sun.COM } vr_chip_desc_t; 2229540SJoost.Mulders@Sun.COM 2239540SJoost.Mulders@Sun.COM /* 2249540SJoost.Mulders@Sun.COM * A structure describing an DMA object. 2259540SJoost.Mulders@Sun.COM */ 2269540SJoost.Mulders@Sun.COM typedef struct data_dma { 2279540SJoost.Mulders@Sun.COM ddi_dma_handle_t handle; 2289540SJoost.Mulders@Sun.COM ddi_acc_handle_t acchdl; 2299540SJoost.Mulders@Sun.COM uint32_t paddr; 2309540SJoost.Mulders@Sun.COM char *buf; 2319540SJoost.Mulders@Sun.COM size_t bufsz; 2329540SJoost.Mulders@Sun.COM } vr_data_dma_t; 2339540SJoost.Mulders@Sun.COM 2349540SJoost.Mulders@Sun.COM /* 2359540SJoost.Mulders@Sun.COM * A descriptor as used by the host. 2369540SJoost.Mulders@Sun.COM */ 2379540SJoost.Mulders@Sun.COM typedef struct vr_desc { 2389540SJoost.Mulders@Sun.COM vr_chip_desc_t *cdesc; 2399540SJoost.Mulders@Sun.COM uint32_t paddr; /* paddr of cdesc */ 2409540SJoost.Mulders@Sun.COM uint32_t offset; /* offset to paddr */ 2419540SJoost.Mulders@Sun.COM struct vr_desc *next; 2429540SJoost.Mulders@Sun.COM vr_data_dma_t dmabuf; 2439540SJoost.Mulders@Sun.COM } vr_desc_t; 2449540SJoost.Mulders@Sun.COM 2459540SJoost.Mulders@Sun.COM typedef struct vr_ring { 2469540SJoost.Mulders@Sun.COM vr_desc_t *desc; 2479540SJoost.Mulders@Sun.COM vr_chip_desc_t *cdesc; 2489540SJoost.Mulders@Sun.COM uint32_t cdesc_paddr; 2499540SJoost.Mulders@Sun.COM ddi_dma_handle_t handle; 2509540SJoost.Mulders@Sun.COM ddi_acc_handle_t acchdl; 2519540SJoost.Mulders@Sun.COM } vr_ring_t; 2529540SJoost.Mulders@Sun.COM 2539540SJoost.Mulders@Sun.COM typedef struct { 2549540SJoost.Mulders@Sun.COM kmutex_t lock; 2559540SJoost.Mulders@Sun.COM uint32_t ndesc; 2569540SJoost.Mulders@Sun.COM uint32_t nfree; 2579540SJoost.Mulders@Sun.COM uint32_t stallticks; 2589540SJoost.Mulders@Sun.COM uint32_t resched; 2599540SJoost.Mulders@Sun.COM uint32_t intr_distance; 2609540SJoost.Mulders@Sun.COM vr_desc_t *ring; 2619540SJoost.Mulders@Sun.COM vr_desc_t *wp; /* write pointer */ 2629540SJoost.Mulders@Sun.COM vr_desc_t *cp; /* claim pointer */ 2639540SJoost.Mulders@Sun.COM } vr_tx_t; 2649540SJoost.Mulders@Sun.COM 2659540SJoost.Mulders@Sun.COM typedef struct { 2669540SJoost.Mulders@Sun.COM uint32_t ndesc; 2679540SJoost.Mulders@Sun.COM vr_desc_t *ring; 2689540SJoost.Mulders@Sun.COM vr_desc_t *rp; /* read pointer */ 2699540SJoost.Mulders@Sun.COM } vr_rx_t; 2709540SJoost.Mulders@Sun.COM 2719540SJoost.Mulders@Sun.COM typedef enum { 2729540SJoost.Mulders@Sun.COM VR_LINK_STATE_UNKNOWN = LINK_STATE_UNKNOWN, 2739540SJoost.Mulders@Sun.COM VR_LINK_STATE_DOWN = LINK_STATE_DOWN, 2749540SJoost.Mulders@Sun.COM VR_LINK_STATE_UP = LINK_STATE_UP 2759540SJoost.Mulders@Sun.COM } vr_link_state_t; 2769540SJoost.Mulders@Sun.COM 2779540SJoost.Mulders@Sun.COM typedef enum { 2789540SJoost.Mulders@Sun.COM VR_LINK_SPEED_UNKNOWN, 2799540SJoost.Mulders@Sun.COM VR_LINK_SPEED_10MBS, 2809540SJoost.Mulders@Sun.COM VR_LINK_SPEED_100MBS 2819540SJoost.Mulders@Sun.COM } vr_link_speed_t; 2829540SJoost.Mulders@Sun.COM 2839540SJoost.Mulders@Sun.COM typedef enum { 2849540SJoost.Mulders@Sun.COM VR_LINK_DUPLEX_UNKNOWN = LINK_DUPLEX_UNKNOWN, 2859540SJoost.Mulders@Sun.COM VR_LINK_DUPLEX_FULL = LINK_DUPLEX_FULL, 2869540SJoost.Mulders@Sun.COM VR_LINK_DUPLEX_HALF = LINK_DUPLEX_HALF 2879540SJoost.Mulders@Sun.COM } vr_link_duplex_t; 2889540SJoost.Mulders@Sun.COM 2899540SJoost.Mulders@Sun.COM typedef enum { 2909540SJoost.Mulders@Sun.COM VR_LINK_AUTONEG_UNKNOWN, 2919540SJoost.Mulders@Sun.COM VR_LINK_AUTONEG_OFF, 2929540SJoost.Mulders@Sun.COM VR_LINK_AUTONEG_ON 2939540SJoost.Mulders@Sun.COM } vr_link_autoneg_t; 2949540SJoost.Mulders@Sun.COM 2959540SJoost.Mulders@Sun.COM /* 2969540SJoost.Mulders@Sun.COM * Pause variations. 2979540SJoost.Mulders@Sun.COM */ 2989540SJoost.Mulders@Sun.COM typedef enum { 2999540SJoost.Mulders@Sun.COM VR_PAUSE_UNKNOWN, 3009540SJoost.Mulders@Sun.COM VR_PAUSE_NONE = LINK_FLOWCTRL_NONE, 3019540SJoost.Mulders@Sun.COM VR_PAUSE_TRANSMIT = LINK_FLOWCTRL_TX, 3029540SJoost.Mulders@Sun.COM VR_PAUSE_RECEIVE = LINK_FLOWCTRL_RX, 3039540SJoost.Mulders@Sun.COM VR_PAUSE_BIDIRECTIONAL = LINK_FLOWCTRL_BI 3049540SJoost.Mulders@Sun.COM } vr_link_flowctrl_t; 3059540SJoost.Mulders@Sun.COM 3069540SJoost.Mulders@Sun.COM /* 3079540SJoost.Mulders@Sun.COM * Type of medium attachement unit. 3089540SJoost.Mulders@Sun.COM */ 3099540SJoost.Mulders@Sun.COM typedef enum { 3109540SJoost.Mulders@Sun.COM VR_MAU_UNKNOWN = XCVR_UNDEFINED, 3119540SJoost.Mulders@Sun.COM VR_MAU_NONE = XCVR_NONE, 3129540SJoost.Mulders@Sun.COM VR_MAU_10 = XCVR_10, 3139540SJoost.Mulders@Sun.COM VR_MAU_100T4 = XCVR_100T4, 3149540SJoost.Mulders@Sun.COM VR_MAU_100X = XCVR_100X, 3159540SJoost.Mulders@Sun.COM VR_MAU_100T2 = XCVR_100T2, 3169540SJoost.Mulders@Sun.COM VR_MAU_1000X = XCVR_1000X, 3179540SJoost.Mulders@Sun.COM VR_MAU_1000T = XCVR_1000T 3189540SJoost.Mulders@Sun.COM } vr_mau_t; 3199540SJoost.Mulders@Sun.COM 3209540SJoost.Mulders@Sun.COM typedef struct { 3219540SJoost.Mulders@Sun.COM vr_link_state_t state; 3229540SJoost.Mulders@Sun.COM vr_link_speed_t speed; 3239540SJoost.Mulders@Sun.COM vr_link_duplex_t duplex; 3249540SJoost.Mulders@Sun.COM vr_link_flowctrl_t flowctrl; 3259540SJoost.Mulders@Sun.COM vr_mau_t mau; 3269540SJoost.Mulders@Sun.COM } vr_link_t; 3279540SJoost.Mulders@Sun.COM 3289540SJoost.Mulders@Sun.COM typedef enum { 3299540SJoost.Mulders@Sun.COM CHIPSTATE_UNKNOWN, 3309540SJoost.Mulders@Sun.COM CHIPSTATE_INITIALIZED, 3319540SJoost.Mulders@Sun.COM CHIPSTATE_RUNNING, 3329540SJoost.Mulders@Sun.COM CHIPSTATE_STOPPED, 3339540SJoost.Mulders@Sun.COM CHIPSTATE_SLEEPING, 3349540SJoost.Mulders@Sun.COM CHIPSTATE_SUSPENDED, 3359540SJoost.Mulders@Sun.COM CHIPSTATE_SUSPENDED_RUNNING, 3369540SJoost.Mulders@Sun.COM CHIPSTATE_ERROR 3379540SJoost.Mulders@Sun.COM } vr_chip_state_t; 3389540SJoost.Mulders@Sun.COM 3399540SJoost.Mulders@Sun.COM typedef struct { 3409540SJoost.Mulders@Sun.COM uint16_t control; 3419540SJoost.Mulders@Sun.COM uint16_t status; 3429540SJoost.Mulders@Sun.COM uint16_t identh; 3439540SJoost.Mulders@Sun.COM uint16_t identl; 3449540SJoost.Mulders@Sun.COM uint16_t anadv; 3459540SJoost.Mulders@Sun.COM uint16_t lpable; 3469540SJoost.Mulders@Sun.COM uint16_t anexp; 3479540SJoost.Mulders@Sun.COM } mii_t; 3489540SJoost.Mulders@Sun.COM 3499540SJoost.Mulders@Sun.COM /* 3509540SJoost.Mulders@Sun.COM * A structure defining the various types of cards and their habits. 3519540SJoost.Mulders@Sun.COM */ 3529540SJoost.Mulders@Sun.COM typedef struct { 3539540SJoost.Mulders@Sun.COM uint8_t revmin; 3549540SJoost.Mulders@Sun.COM uint8_t revmax; 3559540SJoost.Mulders@Sun.COM char name[128]; 3569540SJoost.Mulders@Sun.COM uint32_t bugs; 3579540SJoost.Mulders@Sun.COM uint32_t features; 3589540SJoost.Mulders@Sun.COM } chip_info_t; 3599540SJoost.Mulders@Sun.COM 3609540SJoost.Mulders@Sun.COM /* 3619540SJoost.Mulders@Sun.COM * A structure describing the card. 3629540SJoost.Mulders@Sun.COM */ 3639540SJoost.Mulders@Sun.COM typedef struct { 3649540SJoost.Mulders@Sun.COM uint16_t vendor; 3659540SJoost.Mulders@Sun.COM uint16_t device; 3669540SJoost.Mulders@Sun.COM uint8_t revision; 3679540SJoost.Mulders@Sun.COM vr_chip_state_t state; 3689540SJoost.Mulders@Sun.COM mii_t mii; 3699540SJoost.Mulders@Sun.COM vr_link_t link; 3709540SJoost.Mulders@Sun.COM chip_info_t info; 3719540SJoost.Mulders@Sun.COM uint32_t phyaddr; 3729540SJoost.Mulders@Sun.COM } vr_chip_t; 3739540SJoost.Mulders@Sun.COM 3749540SJoost.Mulders@Sun.COM /* 3759540SJoost.Mulders@Sun.COM * Operational parameters. 3769540SJoost.Mulders@Sun.COM */ 3779540SJoost.Mulders@Sun.COM typedef struct { 3789540SJoost.Mulders@Sun.COM uint16_t anadv_en; 3799540SJoost.Mulders@Sun.COM uint16_t an_phymask; 3809540SJoost.Mulders@Sun.COM uint16_t an_macmask; 3819540SJoost.Mulders@Sun.COM vr_link_autoneg_t an_en; 3829540SJoost.Mulders@Sun.COM uint32_t mtu; 3839540SJoost.Mulders@Sun.COM } vr_param_t; 3849540SJoost.Mulders@Sun.COM 3859540SJoost.Mulders@Sun.COM typedef enum { 3869540SJoost.Mulders@Sun.COM VR_SUCCESS = 0, 3879540SJoost.Mulders@Sun.COM VR_FAILURE = 1 3889540SJoost.Mulders@Sun.COM } vr_result_t; 3899540SJoost.Mulders@Sun.COM 3909540SJoost.Mulders@Sun.COM typedef struct { 3919540SJoost.Mulders@Sun.COM uint64_t ether_stat_align_errors; 3929540SJoost.Mulders@Sun.COM uint64_t ether_stat_carrier_errors; 3939540SJoost.Mulders@Sun.COM uint64_t ether_stat_ex_collisions; 3949540SJoost.Mulders@Sun.COM uint64_t ether_stat_fcs_errors; 3959540SJoost.Mulders@Sun.COM uint64_t ether_stat_first_collisions; 3969540SJoost.Mulders@Sun.COM uint64_t ether_stat_macrcv_errors; 3979540SJoost.Mulders@Sun.COM uint64_t ether_stat_macxmt_errors; 3989540SJoost.Mulders@Sun.COM uint64_t ether_stat_multi_collisions; 3999540SJoost.Mulders@Sun.COM uint64_t ether_stat_toolong_errors; 4009540SJoost.Mulders@Sun.COM uint64_t ether_stat_tooshort_errors; 4019540SJoost.Mulders@Sun.COM uint64_t ether_stat_tx_late_collisions; 4029540SJoost.Mulders@Sun.COM uint64_t ether_stat_defer_xmts; 4039540SJoost.Mulders@Sun.COM uint64_t mac_stat_brdcstrcv; 4049540SJoost.Mulders@Sun.COM uint64_t mac_stat_brdcstxmt; 4059540SJoost.Mulders@Sun.COM uint64_t mac_stat_multixmt; 4069540SJoost.Mulders@Sun.COM uint64_t mac_stat_collisions; 4079540SJoost.Mulders@Sun.COM uint64_t mac_stat_ierrors; 4089540SJoost.Mulders@Sun.COM uint64_t mac_stat_ipackets; 4099540SJoost.Mulders@Sun.COM uint64_t mac_stat_multircv; 4109540SJoost.Mulders@Sun.COM uint64_t mac_stat_norcvbuf; 4119540SJoost.Mulders@Sun.COM uint64_t mac_stat_noxmtbuf; 4129540SJoost.Mulders@Sun.COM uint64_t mac_stat_obytes; 4139540SJoost.Mulders@Sun.COM uint64_t mac_stat_opackets; 4149540SJoost.Mulders@Sun.COM uint64_t mac_stat_rbytes; 4159540SJoost.Mulders@Sun.COM uint64_t mac_stat_underflows; 4169540SJoost.Mulders@Sun.COM uint64_t mac_stat_overflows; 4179540SJoost.Mulders@Sun.COM uint64_t cyclics; 4189540SJoost.Mulders@Sun.COM uint64_t txchecks; 4199540SJoost.Mulders@Sun.COM uint64_t intr_claimed; 4209540SJoost.Mulders@Sun.COM uint64_t intr_unclaimed; 4219540SJoost.Mulders@Sun.COM uint64_t linkchanges; 4229540SJoost.Mulders@Sun.COM uint64_t txcpybytes; 4239540SJoost.Mulders@Sun.COM uint64_t txmapbytes; 4249540SJoost.Mulders@Sun.COM uint64_t rxcpybytes; 4259540SJoost.Mulders@Sun.COM uint64_t rxmapbytes; 4269540SJoost.Mulders@Sun.COM uint64_t txreclaim0; 4279540SJoost.Mulders@Sun.COM uint64_t txreclaims; 4289540SJoost.Mulders@Sun.COM uint32_t txstalls; 4299540SJoost.Mulders@Sun.COM uint32_t resets; 4309540SJoost.Mulders@Sun.COM uint32_t allocbfail; 4319540SJoost.Mulders@Sun.COM } vr_stats_t; 4329540SJoost.Mulders@Sun.COM 4339540SJoost.Mulders@Sun.COM /* 4349540SJoost.Mulders@Sun.COM * Access attributes for the card. 4359540SJoost.Mulders@Sun.COM */ 4369540SJoost.Mulders@Sun.COM typedef struct { 4379540SJoost.Mulders@Sun.COM ddi_acc_handle_t hdl; 4389540SJoost.Mulders@Sun.COM caddr_t addr; 4399540SJoost.Mulders@Sun.COM pci_regspec_t reg; 4409540SJoost.Mulders@Sun.COM } vr_acc_t; 4419540SJoost.Mulders@Sun.COM 4429540SJoost.Mulders@Sun.COM /* 4439540SJoost.Mulders@Sun.COM * Instance state structure. 4449540SJoost.Mulders@Sun.COM */ 4459540SJoost.Mulders@Sun.COM typedef struct { 4469540SJoost.Mulders@Sun.COM kmutex_t oplock; 4479540SJoost.Mulders@Sun.COM dev_info_t *devinfo; 4489540SJoost.Mulders@Sun.COM uint8_t vendor_ether_addr [ETHERADDRL]; 4499540SJoost.Mulders@Sun.COM char ifname[12]; 4509540SJoost.Mulders@Sun.COM mac_handle_t machdl; 4519540SJoost.Mulders@Sun.COM ddi_intr_handle_t intr_hdl; 4529540SJoost.Mulders@Sun.COM uint_t intr_pri; 4539540SJoost.Mulders@Sun.COM kmutex_t intrlock; 4549540SJoost.Mulders@Sun.COM vr_chip_t chip; 4559540SJoost.Mulders@Sun.COM vr_ring_t txring; 4569540SJoost.Mulders@Sun.COM vr_ring_t rxring; 4579540SJoost.Mulders@Sun.COM vr_rx_t rx; 4589540SJoost.Mulders@Sun.COM vr_tx_t tx; 4599540SJoost.Mulders@Sun.COM ddi_periodic_t periodic_id; 4609540SJoost.Mulders@Sun.COM int nsets; 4619540SJoost.Mulders@Sun.COM vr_acc_t *regset; 4629540SJoost.Mulders@Sun.COM vr_acc_t *acc_mem; 4639540SJoost.Mulders@Sun.COM vr_acc_t *acc_io; 4649540SJoost.Mulders@Sun.COM vr_acc_t *acc_cfg; 4659540SJoost.Mulders@Sun.COM vr_acc_t *acc_reg; 4669540SJoost.Mulders@Sun.COM vr_param_t param; 4679540SJoost.Mulders@Sun.COM vr_stats_t stats; 4689540SJoost.Mulders@Sun.COM struct kstat *ksp; 4699540SJoost.Mulders@Sun.COM vr_param_t defaults; 4709540SJoost.Mulders@Sun.COM uint32_t promisc; 4719540SJoost.Mulders@Sun.COM uint32_t mhash0; 4729540SJoost.Mulders@Sun.COM uint32_t mhash1; 4739540SJoost.Mulders@Sun.COM uint32_t mcount; 4749540SJoost.Mulders@Sun.COM uint32_t reset; 4759540SJoost.Mulders@Sun.COM } vr_t; 4769540SJoost.Mulders@Sun.COM 4779540SJoost.Mulders@Sun.COM /* 4789540SJoost.Mulders@Sun.COM * Function prototypes. 4799540SJoost.Mulders@Sun.COM */ 4809540SJoost.Mulders@Sun.COM int vr_mac_getstat(void *arg, uint_t stat, uint64_t *val); 4819540SJoost.Mulders@Sun.COM int vr_mac_start(void *vrp); 4829540SJoost.Mulders@Sun.COM void vr_mac_stop(void *vrp); 4839540SJoost.Mulders@Sun.COM int vr_mac_set_promisc(void *vrp, boolean_t promiscflag); 4849540SJoost.Mulders@Sun.COM int vr_mac_set_multicast(void *vrp, boolean_t add, 4859540SJoost.Mulders@Sun.COM const uint8_t *mca); 4869540SJoost.Mulders@Sun.COM int vr_mac_set_ether_addr(void *vrp, 4879540SJoost.Mulders@Sun.COM const uint8_t *macaddr); 4889540SJoost.Mulders@Sun.COM mblk_t *vr_mac_tx_enqueue_list(void *p, mblk_t *mp); 4899540SJoost.Mulders@Sun.COM int vr_mac_getprop(void *arg, const char *pr_name, 490*11878SVenu.Iyer@Sun.COM mac_prop_id_t pr_num, uint_t pr_valsize, 491*11878SVenu.Iyer@Sun.COM void *pr_val); 4929540SJoost.Mulders@Sun.COM int vr_mac_setprop(void *arg, const char *pr_name, 4939540SJoost.Mulders@Sun.COM mac_prop_id_t pr_num, 4949540SJoost.Mulders@Sun.COM uint_t pr_valsize, const void *pr_val); 495*11878SVenu.Iyer@Sun.COM void vr_mac_propinfo(void *arg, const char *pr_name, 496*11878SVenu.Iyer@Sun.COM mac_prop_id_t pr_num, mac_prop_info_handle_t prh); 4979540SJoost.Mulders@Sun.COM uint_t vr_intr(caddr_t arg1, caddr_t arg2); 4989540SJoost.Mulders@Sun.COM #ifdef __cplusplus 4999540SJoost.Mulders@Sun.COM } 5009540SJoost.Mulders@Sun.COM #endif 5019540SJoost.Mulders@Sun.COM #endif /* _VR_H */ 502