12675Szh199473 /* 22675Szh199473 * CDDL HEADER START 32675Szh199473 * 42675Szh199473 * The contents of this file are subject to the terms of the 52675Szh199473 * Common Development and Distribution License (the "License"). 62675Szh199473 * You may not use this file except in compliance with the License. 72675Szh199473 * 82675Szh199473 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 92675Szh199473 * or http://www.opensolaris.org/os/licensing. 102675Szh199473 * See the License for the specific language governing permissions 112675Szh199473 * and limitations under the License. 122675Szh199473 * 132675Szh199473 * When distributing Covered Code, include this CDDL HEADER in each 142675Szh199473 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 152675Szh199473 * If applicable, add the following below this CDDL HEADER, with the 162675Szh199473 * fields enclosed by brackets "[]" replaced with your own identifying 172675Szh199473 * information: Portions Copyright [yyyy] [name of copyright owner] 182675Szh199473 * 192675Szh199473 * CDDL HEADER END 202675Szh199473 */ 212675Szh199473 222675Szh199473 /* 233907Szh199473 * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 242675Szh199473 * Use is subject to license terms. 252675Szh199473 */ 262675Szh199473 273334Sgs150176 #ifndef _BGE_IMPL_H 283334Sgs150176 #define _BGE_IMPL_H 292675Szh199473 302675Szh199473 #pragma ident "%Z%%M% %I% %E% SMI" 312675Szh199473 322675Szh199473 #ifdef __cplusplus 332675Szh199473 extern "C" { 342675Szh199473 #endif 352675Szh199473 362675Szh199473 #include <sys/types.h> 372675Szh199473 #include <sys/stream.h> 382675Szh199473 #include <sys/strsun.h> 392675Szh199473 #include <sys/strsubr.h> 402675Szh199473 #include <sys/stat.h> 412675Szh199473 #include <sys/pci.h> 422675Szh199473 #include <sys/note.h> 432675Szh199473 #include <sys/modctl.h> 442675Szh199473 #include <sys/crc32.h> 452675Szh199473 #ifdef __sparcv9 462675Szh199473 #include <v9/sys/membar.h> 472675Szh199473 #endif /* __sparcv9 */ 482675Szh199473 #include <sys/kstat.h> 492675Szh199473 #include <sys/ethernet.h> 502675Szh199473 #include <sys/vlan.h> 512675Szh199473 #include <sys/errno.h> 522675Szh199473 #include <sys/dlpi.h> 532675Szh199473 #include <sys/devops.h> 542675Szh199473 #include <sys/debug.h> 552675Szh199473 #include <sys/conf.h> 562675Szh199473 572675Szh199473 #include <netinet/ip6.h> 582675Szh199473 592675Szh199473 #include <inet/common.h> 602675Szh199473 #include <inet/ip.h> 612675Szh199473 #include <inet/mi.h> 622675Szh199473 #include <inet/nd.h> 632675Szh199473 #include <sys/pattr.h> 642675Szh199473 65*5107Seota #include <sys/disp.h> 662675Szh199473 #include <sys/ddi.h> 672675Szh199473 #include <sys/sunddi.h> 682675Szh199473 692675Szh199473 #include <sys/ddifm.h> 702675Szh199473 #include <sys/fm/protocol.h> 712675Szh199473 #include <sys/fm/util.h> 722675Szh199473 #include <sys/fm/io/ddi.h> 732675Szh199473 742675Szh199473 #include <sys/mac.h> 752675Szh199473 #include <sys/mac_ether.h> 762675Szh199473 772675Szh199473 #ifdef __amd64 782675Szh199473 #include <sys/x86_archext.h> 792675Szh199473 #endif 802675Szh199473 812675Szh199473 /* 822675Szh199473 * <sys/ethernet.h> *may* already have provided the typedef ether_addr_t; 832675Szh199473 * but of course C doesn't provide a way to check this directly. So here 842675Szh199473 * we rely on the fact that the symbol ETHERTYPE_AT was added to the 852675Szh199473 * header file (as a #define, which we *can* test for) at the same time 862675Szh199473 * as the typedef for ether_addr_t ;-! 872675Szh199473 */ 882675Szh199473 #ifndef ETHERTYPE_AT 892675Szh199473 typedef uchar_t ether_addr_t[ETHERADDRL]; 902675Szh199473 #endif /* ETHERTYPE_AT */ 912675Szh199473 922675Szh199473 /* 932675Szh199473 * Reconfiguring the network devices requires the net_config privilege 942681Sgs150176 * in Solaris 10+. 952675Szh199473 */ 962675Szh199473 extern int secpolicy_net_config(const cred_t *, boolean_t); 972675Szh199473 982675Szh199473 #include <sys/netlb.h> /* originally from cassini */ 992675Szh199473 #include <sys/miiregs.h> /* by fjlite out of intel */ 1002675Szh199473 1012675Szh199473 #include "bge.h" 1022675Szh199473 #include "bge_hw.h" 1032675Szh199473 1042675Szh199473 /* 1052675Szh199473 * Compile-time feature switches ... 1062675Szh199473 */ 1072675Szh199473 #define BGE_DO_PPIO 0 /* peek/poke ioctls */ 1082675Szh199473 #define BGE_RX_SOFTINT 0 /* softint per receive ring */ 1092675Szh199473 #define BGE_CHOOSE_SEND_METHOD 0 /* send by copying only */ 1102675Szh199473 1112675Szh199473 /* 1122675Szh199473 * NOTES: 1132675Szh199473 * 1142675Szh199473 * #defines: 1152675Szh199473 * 1162675Szh199473 * BGE_PCI_CONFIG_RNUMBER and BGE_PCI_OPREGS_RNUMBER are the 1172675Szh199473 * register-set numbers to use for the config space registers 1182675Szh199473 * and the operating registers respectively. On an OBP-based 1192675Szh199473 * machine, regset 0 refers to CONFIG space, and regset 1 will 1202675Szh199473 * be the operating registers in MEMORY space. If an expansion 1212675Szh199473 * ROM is fitted, it may appear as a further register set. 1222675Szh199473 * 1232675Szh199473 * BGE_DMA_MODE defines the mode (STREAMING/CONSISTENT) used 1242675Szh199473 * for the data buffers. The descriptors are always set up 1252675Szh199473 * in CONSISTENT mode. 1262675Szh199473 * 1272675Szh199473 * BGE_HEADROOM defines how much space we'll leave in allocated 1282675Szh199473 * mblks before the first valid data byte. This should be chosen 1292675Szh199473 * to be 2 modulo 4, so that once the ethernet header (14 bytes) 1302675Szh199473 * has been stripped off, the packet data will be 4-byte aligned. 1312675Szh199473 * The remaining space can be used by upstream modules to prepend 1322675Szh199473 * any headers required. 1332675Szh199473 */ 1342675Szh199473 1352675Szh199473 #define BGE_PCI_CONFIG_RNUMBER 0 1362675Szh199473 #define BGE_PCI_OPREGS_RNUMBER 1 1372675Szh199473 #define BGE_DMA_MODE DDI_DMA_STREAMING 1382675Szh199473 #define BGE_HEADROOM 34 1392675Szh199473 1402675Szh199473 /* 1412675Szh199473 * BGE_HALFTICK is half the period of the cyclic callback (in 1422675Szh199473 * nanoseconds), chosen so that 0.5s <= cyclic period <= 1s. 1432675Szh199473 * Other time values are derived as odd multiples of this value 1442675Szh199473 * so that there's little chance of ambiguity w.r.t. which tick 1452675Szh199473 * a timeout expires on. 1462675Szh199473 * 1472675Szh199473 * BGE_PHY_STABLE_TIME is the period for which the contents of the 1482675Szh199473 * PHY's status register must remain unchanging before we accept 1492675Szh199473 * that the link has come up. [Sometimes the link comes up, only 1502675Szh199473 * to go down again within a short time as the autonegotiation 1512675Szh199473 * process cycles through various options before finding the best 1522675Szh199473 * compatible mode. We don't want to report repeated link up/down 1532675Szh199473 * cycles, so we wait until we think it's stable.] 1542675Szh199473 * 1552675Szh199473 * BGE_SERDES_STABLE_TIME is the analogous value for the SerDes 1562675Szh199473 * interface. It's much shorter, 'cos the SerDes doesn't show 1572675Szh199473 * these effects as much as the copper PHY. 1582675Szh199473 * 1592675Szh199473 * BGE_LINK_SETTLE_TIME is the period during which we regard link 1602675Szh199473 * up/down cycles as an normal event after resetting/reprogramming 1612675Szh199473 * the PHY. During this time, link up/down messages are sent to 1622675Szh199473 * the log only, not the console. At any other time, link change 1632675Szh199473 * events are regarded as unexpected and sent to both console & log. 1642675Szh199473 * 1652675Szh199473 * These latter two values have no theoretical justification, but 1662675Szh199473 * are derived from observations and heuristics - the values below 1672675Szh199473 * just seem to work quite well. 1682675Szh199473 */ 1692675Szh199473 1702675Szh199473 #define BGE_HALFTICK 268435456LL /* 2**28 ns! */ 1712675Szh199473 #define BGE_CYCLIC_PERIOD (2*BGE_HALFTICK) /* ~0.5s */ 1722675Szh199473 #define BGE_SERDES_STABLE_TIME (3*BGE_HALFTICK) /* ~0.8s */ 1732675Szh199473 #define BGE_PHY_STABLE_TIME (11*BGE_HALFTICK) /* ~3.0s */ 1742675Szh199473 #define BGE_LINK_SETTLE_TIME (111*BGE_HALFTICK) /* ~30.0s */ 1752675Szh199473 1762675Szh199473 /* 1772675Szh199473 * Indices used to identify the different buffer rings internally 1782675Szh199473 */ 1792675Szh199473 #define BGE_STD_BUFF_RING 0 1802675Szh199473 #define BGE_JUMBO_BUFF_RING 1 1812675Szh199473 #define BGE_MINI_BUFF_RING 2 1822675Szh199473 1832675Szh199473 /* 1842675Szh199473 * Current implementation limits 1852675Szh199473 */ 1862675Szh199473 #define BGE_BUFF_RINGS_USED 2 /* std & jumbo ring */ 1872675Szh199473 /* for now */ 1882675Szh199473 #define BGE_RECV_RINGS_USED 16 /* up to 16 rtn rings */ 1892675Szh199473 /* for now */ 1902675Szh199473 #define BGE_SEND_RINGS_USED 4 /* up to 4 tx rings */ 1912675Szh199473 /* for now */ 1922675Szh199473 #define BGE_HASH_TABLE_SIZE 128 /* may be 256 later */ 1932675Szh199473 1942675Szh199473 /* 1952675Szh199473 * Ring/buffer size parameters 1962675Szh199473 * 1972675Szh199473 * All of the (up to) 16 TX rings & and the corresponding buffers are the 1982675Szh199473 * same size. 1992675Szh199473 * 2002675Szh199473 * Each of the (up to) 3 receive producer (aka buffer) rings is a different 2012675Szh199473 * size and has different sized buffers associated with it too. 2022675Szh199473 * 2032675Szh199473 * The (up to) 16 receive return rings have no buffers associated with them. 2042675Szh199473 * The number of slots per receive return ring must be 2048 if the mini 2052675Szh199473 * ring is enabled, otherwise it may be 1024. See Broadcom document 2062675Szh199473 * 570X-PG102-R page 56. 2072675Szh199473 * 2082675Szh199473 * Note: only the 5700 supported external memory (and therefore the mini 2092675Szh199473 * ring); the 5702/3/4 don't. This driver doesn't support the original 2102675Szh199473 * 5700, so we won't ever use the mini ring capability. 2112675Szh199473 */ 2122675Szh199473 2132675Szh199473 #define BGE_SEND_RINGS_DEFAULT 1 2142675Szh199473 #define BGE_RECV_RINGS_DEFAULT 1 2152675Szh199473 2162675Szh199473 #define BGE_SEND_BUFF_SIZE_DEFAULT 1536 2172675Szh199473 #define BGE_SEND_BUFF_SIZE_JUMBO 9022 2182675Szh199473 #define BGE_SEND_SLOTS_USED 512 2192675Szh199473 2202675Szh199473 #define BGE_STD_BUFF_SIZE 1536 /* 0x600 */ 2212675Szh199473 #define BGE_STD_SLOTS_USED 512 2222675Szh199473 2232675Szh199473 #define BGE_JUMBO_BUFF_SIZE 9022 /* 9k */ 2242675Szh199473 #define BGE_JUMBO_SLOTS_USED 256 2252675Szh199473 2262675Szh199473 #define BGE_MINI_BUFF_SIZE 128 /* 64? 256? */ 2272675Szh199473 #define BGE_MINI_SLOTS_USED 0 /* must be 0; see above */ 2282675Szh199473 2292675Szh199473 #define BGE_RECV_BUFF_SIZE 0 2302675Szh199473 #if BGE_MINI_SLOTS_USED > 0 2312675Szh199473 #define BGE_RECV_SLOTS_USED 2048 /* required */ 2322675Szh199473 #else 2332675Szh199473 #define BGE_RECV_SLOTS_USED 1024 /* could be 2048 anyway */ 2342675Szh199473 #endif 2352675Szh199473 2363334Sgs150176 #define BGE_SEND_BUF_NUM 512 2373334Sgs150176 #define BGE_SEND_BUF_ARRAY 16 2383334Sgs150176 #define BGE_SEND_BUF_ARRAY_JUMBO 3 2393334Sgs150176 #define BGE_SEND_BUF_MAX (BGE_SEND_BUF_NUM*BGE_SEND_BUF_ARRAY) 2403334Sgs150176 2412675Szh199473 /* 2422675Szh199473 * PCI type. PCI-Express or PCI/PCIX 2432675Szh199473 */ 2442675Szh199473 #define BGE_PCI 0 2452675Szh199473 #define BGE_PCI_E 1 2462675Szh199473 #define BGE_PCI_X 2 2472675Szh199473 2482675Szh199473 /* 2492675Szh199473 * Statistic type. There are two type of statistic: 2502675Szh199473 * statistic block and statistic registers 2512675Szh199473 */ 2522675Szh199473 #define BGE_STAT_BLK 1 2532675Szh199473 #define BGE_STAT_REG 2 2542675Szh199473 2552675Szh199473 /* 2562675Szh199473 * MTU.for all chipsets ,the default is 1500 ,and some chipsets 2572675Szh199473 * support 9k jumbo frames size 2582675Szh199473 */ 2592675Szh199473 #define BGE_DEFAULT_MTU 1500 2602675Szh199473 #define BGE_MAXIMUM_MTU 9000 2612675Szh199473 2622675Szh199473 /* 2632675Szh199473 * Pad the h/w defined status block (which can be up to 80 bytes long) 2642675Szh199473 * to a power-of-two boundary 2652675Szh199473 */ 2662675Szh199473 #define BGE_STATUS_PADDING (128 - sizeof (bge_status_t)) 2672675Szh199473 2682675Szh199473 /* 2692675Szh199473 * On platforms which support DVMA, we can simply allocate one big piece 2702675Szh199473 * of memory for all the Tx buffers and another for the Rx buffers, and 2712675Szh199473 * then carve them up as required. It doesn't matter if they aren't just 2722675Szh199473 * one physically contiguous piece each, because both the CPU *and* the 2732675Szh199473 * I/O device can see them *as though they were*. 2742675Szh199473 * 2752675Szh199473 * However, if only physically-addressed DMA is possible, this doesn't 2762675Szh199473 * work; we can't expect to get enough contiguously-addressed memory for 2772675Szh199473 * all the buffers of each type, so in this case we request a number of 2782675Szh199473 * smaller pieces, each still large enough for several buffers but small 2792675Szh199473 * enough to fit within "an I/O page" (e.g. 64K). 2802675Szh199473 * 2812675Szh199473 * The #define below specifies how many pieces of memory are to be used; 2822675Szh199473 * 16 has been shown to work on an i86pc architecture but this could be 2832675Szh199473 * different on other non-DVMA platforms ... 2842675Szh199473 */ 2852675Szh199473 #ifdef _DMA_USES_VIRTADDR 2862675Szh199473 #define BGE_SPLIT 1 /* no split required */ 2872675Szh199473 #else 2882675Szh199473 #if ((BGE_BUFF_RINGS_USED > 1) || (BGE_SEND_RINGS_USED > 1) || \ 2892675Szh199473 (BGE_RECV_RINGS_USED > 1)) 2902675Szh199473 #define BGE_SPLIT 128 /* split 128 ways */ 2912675Szh199473 #else 2922675Szh199473 #define BGE_SPLIT 16 /* split 16 ways */ 2932675Szh199473 #endif 2942675Szh199473 #endif /* _DMA_USES_VIRTADDR */ 2952675Szh199473 2962675Szh199473 #define BGE_RECV_RINGS_SPLIT (BGE_RECV_RINGS_MAX + 1) 2972675Szh199473 2982675Szh199473 /* 2992675Szh199473 * STREAMS parameters 3002675Szh199473 */ 3012675Szh199473 #define BGE_IDNUM 0 /* zero seems to work */ 3022675Szh199473 #define BGE_LOWAT (256) 3032675Szh199473 #define BGE_HIWAT (256*1024) 3042675Szh199473 3052675Szh199473 3062675Szh199473 /* 3072675Szh199473 * Basic data types, for clarity in distinguishing 'numbers' 3082675Szh199473 * used for different purposes ... 3092675Szh199473 * 3102675Szh199473 * A <bge_regno_t> is a register 'address' (offset) in any one of 3112675Szh199473 * various address spaces (PCI config space, PCI memory-mapped I/O 3122675Szh199473 * register space, MII registers, etc). None of these exceeds 64K, 3132675Szh199473 * so we could use a 16-bit representation but pointer-sized objects 3142675Szh199473 * are more "natural" in most architectures; they seem to be handled 3152675Szh199473 * more efficiently on SPARC and no worse on x86. 3162675Szh199473 * 3172675Szh199473 * BGE_REGNO_NONE represents the non-existent value in this space. 3182675Szh199473 */ 3192675Szh199473 typedef uintptr_t bge_regno_t; /* register # (offset) */ 3202675Szh199473 #define BGE_REGNO_NONE (~(uintptr_t)0u) 3212675Szh199473 3222675Szh199473 /* 3232675Szh199473 * Describes one chunk of allocated DMA-able memory 3242675Szh199473 * 3252675Szh199473 * In some cases, this is a single chunk as allocated from the system; 3262675Szh199473 * but we also use this structure to represent slices carved off such 3272675Szh199473 * a chunk. Even when we don't really need all the information, we 3282675Szh199473 * use this structure as a convenient way of correlating the various 3292675Szh199473 * ways of looking at a piece of memory (kernel VA, IO space DVMA, 3302675Szh199473 * handle+offset, etc). 3312675Szh199473 */ 3322675Szh199473 typedef struct { 3332675Szh199473 ddi_acc_handle_t acc_hdl; /* handle for memory */ 3342675Szh199473 void *mem_va; /* CPU VA of memory */ 3352675Szh199473 uint32_t nslots; /* number of slots */ 3362675Szh199473 uint32_t size; /* size per slot */ 3372675Szh199473 size_t alength; /* allocated size */ 3382675Szh199473 /* >= product of above */ 3392675Szh199473 3402675Szh199473 ddi_dma_handle_t dma_hdl; /* DMA handle */ 3412675Szh199473 offset_t offset; /* relative to handle */ 3422675Szh199473 ddi_dma_cookie_t cookie; /* associated cookie */ 3432675Szh199473 uint32_t ncookies; /* must be 1 */ 3442675Szh199473 uint32_t token; /* arbitrary identifier */ 3452675Szh199473 } dma_area_t; /* 0x50 (80) bytes */ 3462675Szh199473 3473334Sgs150176 typedef struct bge_queue_item { 3483334Sgs150176 struct bge_queue_item *next; 3493334Sgs150176 void *item; 3503334Sgs150176 } bge_queue_item_t; 3513334Sgs150176 3523334Sgs150176 typedef struct bge_queue { 3533334Sgs150176 bge_queue_item_t *head; 3543334Sgs150176 uint32_t count; 3553334Sgs150176 kmutex_t *lock; 3563334Sgs150176 } bge_queue_t; 3572675Szh199473 /* 3582675Szh199473 * Software version of the Receive Buffer Descriptor 3592675Szh199473 * There's one of these for each receive buffer (up to 256/512/1024 per ring). 3602675Szh199473 */ 3612675Szh199473 typedef struct sw_rbd { 3622675Szh199473 dma_area_t pbuf; /* (const) related */ 3632675Szh199473 /* buffer area */ 3642675Szh199473 } sw_rbd_t; /* 0x50 (80) bytes */ 3652675Szh199473 3662675Szh199473 /* 3672675Szh199473 * Software Receive Buffer (Producer) Ring Control Block 3682675Szh199473 * There's one of these for each receiver producer ring (up to 3), 3692675Szh199473 * but each holds buffers of a different size. 3702675Szh199473 */ 3712675Szh199473 typedef struct buff_ring { 3722675Szh199473 dma_area_t desc; /* (const) related h/w */ 3732675Szh199473 /* descriptor area */ 3742675Szh199473 dma_area_t buf[BGE_SPLIT]; /* (const) related */ 3752675Szh199473 /* buffer area(s) */ 3762675Szh199473 bge_rcb_t hw_rcb; /* (const) image of h/w */ 3772675Szh199473 /* RCB, and used to */ 3782675Szh199473 struct bge *bgep; /* (const) containing */ 3792675Szh199473 /* driver soft state */ 3802675Szh199473 /* initialise same */ 3812675Szh199473 volatile uint16_t *cons_index_p; /* (const) ptr to h/w */ 3822675Szh199473 /* "consumer index" */ 3832675Szh199473 /* (in status block) */ 3842675Szh199473 3852675Szh199473 /* 3862675Szh199473 * The rf_lock must be held when updating the h/w producer index 3872675Szh199473 * mailbox register (*chip_mbox_reg), or the s/w producer index 3882675Szh199473 * (rf_next). 3892675Szh199473 */ 3902675Szh199473 bge_regno_t chip_mbx_reg; /* (const) h/w producer */ 3912675Szh199473 /* index mailbox offset */ 3922675Szh199473 kmutex_t rf_lock[1]; /* serialize refill */ 3932675Szh199473 uint64_t rf_next; /* next slot to refill */ 3942675Szh199473 /* ("producer index") */ 3952675Szh199473 3962675Szh199473 sw_rbd_t *sw_rbds; /* software descriptors */ 3972675Szh199473 void *spare[4]; /* padding */ 3982675Szh199473 } buff_ring_t; /* 0x100 (256) bytes */ 3992675Szh199473 4002675Szh199473 /* 4012675Szh199473 * Software Receive (Return) Ring Control Block 4022675Szh199473 * There's one of these for each receiver return ring (up to 16). 4032675Szh199473 */ 4042675Szh199473 typedef struct recv_ring { 4052675Szh199473 /* 4062675Szh199473 * The elements flagged (const) in the comments below are 4072675Szh199473 * set up once during initialiation and thereafter unchanged. 4082675Szh199473 */ 4092675Szh199473 dma_area_t desc; /* (const) related h/w */ 4102675Szh199473 /* descriptor area */ 4112675Szh199473 bge_rcb_t hw_rcb; /* (const) image of h/w */ 4122675Szh199473 /* RCB, and used to */ 4132675Szh199473 /* initialise same */ 4142675Szh199473 struct bge *bgep; /* (const) containing */ 4152675Szh199473 /* driver soft state */ 4162675Szh199473 ddi_softintr_t rx_softint; /* (const) per-ring */ 4172675Szh199473 /* receive callback */ 4182675Szh199473 volatile uint16_t *prod_index_p; /* (const) ptr to h/w */ 4192675Szh199473 /* "producer index" */ 4202675Szh199473 /* (in status block) */ 4212675Szh199473 4222675Szh199473 /* 4232675Szh199473 * The rx_lock must be held when updating the h/w consumer index 4242675Szh199473 * mailbox register (*chip_mbox_reg), or the s/w consumer index 4252675Szh199473 * (rx_next). 4262675Szh199473 */ 4272675Szh199473 bge_regno_t chip_mbx_reg; /* (const) h/w consumer */ 4282675Szh199473 /* index mailbox offset */ 4292675Szh199473 kmutex_t rx_lock[1]; /* serialize receive */ 4302675Szh199473 uint64_t rx_next; /* next slot to examine */ 4312675Szh199473 mac_resource_handle_t handle; /* per ring cookie */ 4322675Szh199473 /* ("producer index") */ 4332675Szh199473 } recv_ring_t; /* 0x90 (144) bytes */ 4342675Szh199473 4352675Szh199473 /* 4363334Sgs150176 * Send packet structure 4373334Sgs150176 */ 4383334Sgs150176 typedef struct send_pkt { 4393334Sgs150176 uint16_t vlan_tci; 4403334Sgs150176 uint32_t pflags; 4413334Sgs150176 boolean_t tx_ready; 4423334Sgs150176 bge_queue_item_t *txbuf_item; 4433334Sgs150176 } send_pkt_t; 4443334Sgs150176 4453334Sgs150176 /* 4463334Sgs150176 * Software version of tx buffer structure 4473334Sgs150176 */ 4483334Sgs150176 typedef struct sw_txbuf { 4493334Sgs150176 dma_area_t buf; 4503334Sgs150176 uint32_t copy_len; 4513334Sgs150176 } sw_txbuf_t; 4523334Sgs150176 4533334Sgs150176 /* 4542675Szh199473 * Software version of the Send Buffer Descriptor 4552675Szh199473 * There's one of these for each send buffer (up to 512 per ring) 4562675Szh199473 */ 4572675Szh199473 typedef struct sw_sbd { 4582675Szh199473 dma_area_t desc; /* (const) related h/w */ 4592675Szh199473 /* descriptor area */ 4603334Sgs150176 bge_queue_item_t *pbuf; /* (const) related */ 4612675Szh199473 /* buffer area */ 4623334Sgs150176 } sw_sbd_t; 4632675Szh199473 4642675Szh199473 /* 4652675Szh199473 * Software Send Ring Control Block 4662675Szh199473 * There's one of these for each of (up to) 16 send rings 4672675Szh199473 */ 4682675Szh199473 typedef struct send_ring { 4692675Szh199473 /* 4702675Szh199473 * The elements flagged (const) in the comments below are 4712675Szh199473 * set up once during initialiation and thereafter unchanged. 4722675Szh199473 */ 4732675Szh199473 dma_area_t desc; /* (const) related h/w */ 4742675Szh199473 /* descriptor area */ 4753334Sgs150176 dma_area_t buf[BGE_SEND_BUF_ARRAY][BGE_SPLIT]; 4762675Szh199473 /* buffer area(s) */ 4772675Szh199473 bge_rcb_t hw_rcb; /* (const) image of h/w */ 4782675Szh199473 /* RCB, and used to */ 4792675Szh199473 /* initialise same */ 4802675Szh199473 struct bge *bgep; /* (const) containing */ 4812675Szh199473 /* driver soft state */ 4822675Szh199473 volatile uint16_t *cons_index_p; /* (const) ptr to h/w */ 4832675Szh199473 /* "consumer index" */ 4842675Szh199473 /* (in status block) */ 4852675Szh199473 4862675Szh199473 bge_regno_t chip_mbx_reg; /* (const) h/w producer */ 4872675Szh199473 /* index mailbox offset */ 4883334Sgs150176 /* 4893334Sgs150176 * Tx buffer queue 4903334Sgs150176 */ 4913334Sgs150176 bge_queue_t txbuf_queue; 4923334Sgs150176 bge_queue_t freetxbuf_queue; 4933334Sgs150176 bge_queue_t *txbuf_push_queue; 4943334Sgs150176 bge_queue_t *txbuf_pop_queue; 4953334Sgs150176 kmutex_t txbuf_lock[1]; 4963334Sgs150176 kmutex_t freetxbuf_lock[1]; 4973334Sgs150176 bge_queue_item_t *txbuf_head; 4983334Sgs150176 send_pkt_t *pktp; 4993334Sgs150176 uint64_t txpkt_next; 5003334Sgs150176 uint64_t txfill_next; 5013334Sgs150176 sw_txbuf_t *txbuf; 5023334Sgs150176 uint32_t tx_buffers; 5033334Sgs150176 uint32_t tx_buffers_low; 5043334Sgs150176 uint32_t tx_array_max; 5053334Sgs150176 uint32_t tx_array; 5062675Szh199473 kmutex_t tx_lock[1]; /* serialize h/w update */ 5072675Szh199473 /* ("producer index") */ 5082675Szh199473 uint64_t tx_next; /* next slot to use */ 5092675Szh199473 uint64_t tx_flow; /* # concurrent sends */ 5103334Sgs150176 uint64_t tx_block; 5113334Sgs150176 uint64_t tx_nobd; 5123334Sgs150176 uint64_t tx_nobuf; 5133334Sgs150176 uint64_t tx_alloc_fail; 5142675Szh199473 5152675Szh199473 /* 5162675Szh199473 * These counters/indexes are manipulated in the transmit 5172675Szh199473 * path using atomics rather than mutexes for speed 5182675Szh199473 */ 5192675Szh199473 uint64_t tx_free; /* # of slots available */ 5202675Szh199473 5212675Szh199473 /* 5222675Szh199473 * The tc_lock must be held while manipulating the s/w consumer 5232675Szh199473 * index (tc_next). 5242675Szh199473 */ 5252675Szh199473 kmutex_t tc_lock[1]; /* serialize recycle */ 5262675Szh199473 uint64_t tc_next; /* next slot to recycle */ 5272675Szh199473 /* ("consumer index") */ 5282675Szh199473 5292675Szh199473 sw_sbd_t *sw_sbds; /* software descriptors */ 5302675Szh199473 uint64_t mac_resid; /* special per resource id */ 5312675Szh199473 } send_ring_t; /* 0x100 (256) bytes */ 5322675Szh199473 5332675Szh199473 typedef struct { 5342675Szh199473 ether_addr_t addr; /* in canonical form */ 5352675Szh199473 uint8_t spare; 5362675Szh199473 boolean_t set; /* B_TRUE => valid */ 5372675Szh199473 } bge_mac_addr_t; 5382675Szh199473 5392675Szh199473 /* 5402675Szh199473 * The original 5700/01 supported only SEEPROMs. Later chips (5702+) 5412675Szh199473 * support both SEEPROMs (using the same 2-wire CLK/DATA interface for 5422675Szh199473 * the hardware and a backwards-compatible software access method), and 5432675Szh199473 * buffered or unbuffered FLASH devices connected to the 4-wire SPI bus 5442675Szh199473 * and using a new software access method. 5452675Szh199473 * 5462675Szh199473 * The access methods for SEEPROM and Flash are generally similar, with 5472675Szh199473 * the chip handling the serialisation/deserialisation and handshaking, 5482675Szh199473 * but the registers used are different, as are a few details of the 5492675Szh199473 * protocol, and the timing, so we have to determine which (if any) is 5502675Szh199473 * fitted. 5512675Szh199473 * 5522675Szh199473 * The value UNKNOWN means just that; we haven't yet tried to determine 5532675Szh199473 * the device type. 5542675Szh199473 * 5552675Szh199473 * The value NONE can indicate either that a real and definite absence of 5562675Szh199473 * any NVmem has been detected, or that there may be NVmem but we can't 5572675Szh199473 * determine its type, perhaps because the NVconfig pins on the chip have 5582675Szh199473 * been wired up incorrectly. In either case, access to the NVmem (if any) 5592675Szh199473 * is not supported. 5602675Szh199473 */ 5612675Szh199473 enum bge_nvmem_type { 5622675Szh199473 BGE_NVTYPE_NONE = -1, /* (or indeterminable) */ 5632675Szh199473 BGE_NVTYPE_UNKNOWN, /* not yet checked */ 5642675Szh199473 BGE_NVTYPE_SEEPROM, /* BCM5700/5701 only */ 5652675Szh199473 BGE_NVTYPE_LEGACY_SEEPROM, /* 5702+ */ 5662675Szh199473 BGE_NVTYPE_UNBUFFERED_FLASH, /* 5702+ */ 5672675Szh199473 BGE_NVTYPE_BUFFERED_FLASH /* 5702+ */ 5682675Szh199473 }; 5692675Szh199473 5702675Szh199473 /* 5712675Szh199473 * Describes the characteristics of a specific chip 5722675Szh199473 * 5732675Szh199473 * Note: elements from <businfo> to <latency> are filled in by during 5742675Szh199473 * the first phase of chip initialisation (see bge_chip_cfg_init()). 5752675Szh199473 * The remaining ones are determined just after the first RESET, in 5762675Szh199473 * bge_poll_firmware(). Thereafter, the entire structure is readonly. 5772675Szh199473 */ 5782675Szh199473 typedef struct { 5792675Szh199473 uint32_t asic_rev; /* masked from MHCR */ 5802675Szh199473 uint32_t businfo; /* from private reg */ 5812675Szh199473 uint16_t command; /* saved during attach */ 5822675Szh199473 5832675Szh199473 uint16_t vendor; /* vendor-id */ 5842675Szh199473 uint16_t device; /* device-id */ 5852675Szh199473 uint16_t subven; /* subsystem-vendor-id */ 5862675Szh199473 uint16_t subdev; /* subsystem-id */ 5872675Szh199473 uint8_t revision; /* revision-id */ 5882675Szh199473 uint8_t clsize; /* cache-line-size */ 5892675Szh199473 uint8_t latency; /* latency-timer */ 5902675Szh199473 5912675Szh199473 uint8_t flags; 5922675Szh199473 uint16_t chip_label; /* numeric part only */ 5932675Szh199473 /* (e.g. 5703/5794/etc) */ 5942675Szh199473 uint32_t mbuf_base; /* Mbuf pool parameters */ 5952675Szh199473 uint32_t mbuf_length; /* depend on chiptype */ 5962675Szh199473 uint32_t pci_type; 5972675Szh199473 uint32_t statistic_type; 5982675Szh199473 uint32_t bge_dma_rwctrl; 5992675Szh199473 uint32_t bge_mlcr_default; 6002675Szh199473 uint32_t recv_slots; /* receive ring size */ 6012675Szh199473 enum bge_nvmem_type nvtype; /* SEEPROM or Flash */ 6022675Szh199473 6032675Szh199473 uint16_t jumbo_slots; 6042675Szh199473 uint16_t ethmax_size; 6052675Szh199473 uint16_t snd_buff_size; 6062675Szh199473 uint16_t recv_jumbo_size; 6072675Szh199473 uint16_t std_buf_size; 6082675Szh199473 uint32_t mbuf_hi_water; 6092675Szh199473 uint32_t mbuf_lo_water_rmac; 6102675Szh199473 uint32_t mbuf_lo_water_rdma; 6112675Szh199473 6123334Sgs150176 uint32_t rx_rings; /* from bge.conf */ 6133334Sgs150176 uint32_t tx_rings; /* from bge.conf */ 6143334Sgs150176 uint32_t default_mtu; /* from bge.conf */ 6152675Szh199473 6162675Szh199473 uint64_t hw_mac_addr; /* from chip register */ 6172675Szh199473 bge_mac_addr_t vendor_addr; /* transform of same */ 6182675Szh199473 boolean_t msi_enabled; /* default to true */ 6192675Szh199473 } chip_id_t; 6202675Szh199473 6212675Szh199473 #define CHIP_FLAG_SUPPORTED 0x80 6222675Szh199473 #define CHIP_FLAG_SERDES 0x40 6232675Szh199473 #define CHIP_FLAG_PARTIAL_CSUM 0x20 6242675Szh199473 #define CHIP_FLAG_NO_JUMBO 0x1 6252675Szh199473 6262675Szh199473 /* 6272675Szh199473 * Collection of physical-layer functions to: 6282675Szh199473 * (re)initialise the physical layer 6292675Szh199473 * update it to match software settings 6302675Szh199473 * check for link status change 6312675Szh199473 */ 6322675Szh199473 typedef struct { 6332675Szh199473 int (*phys_restart)(struct bge *, boolean_t); 6342675Szh199473 int (*phys_update)(struct bge *); 6352675Szh199473 boolean_t (*phys_check)(struct bge *, boolean_t); 6362675Szh199473 } phys_ops_t; 6372675Szh199473 6382675Szh199473 /* 6392675Szh199473 * Named Data (ND) Parameter Management Structure 6402675Szh199473 */ 6412675Szh199473 typedef struct { 6422675Szh199473 int ndp_info; 6432675Szh199473 int ndp_min; 6442675Szh199473 int ndp_max; 6452675Szh199473 int ndp_val; 6462675Szh199473 char *ndp_name; 6472675Szh199473 } nd_param_t; /* 0x18 (24) bytes */ 6482675Szh199473 6492675Szh199473 /* 6502675Szh199473 * NDD parameter indexes, divided into: 6512675Szh199473 * 6522675Szh199473 * read-only parameters describing the hardware's capabilities 6532675Szh199473 * read-write parameters controlling the advertised capabilities 6542675Szh199473 * read-only parameters describing the partner's capabilities 6552675Szh199473 * read-only parameters describing the link state 6562675Szh199473 */ 6572675Szh199473 enum { 6582675Szh199473 PARAM_AUTONEG_CAP, 6592675Szh199473 PARAM_PAUSE_CAP, 6602675Szh199473 PARAM_ASYM_PAUSE_CAP, 6612675Szh199473 PARAM_1000FDX_CAP, 6622675Szh199473 PARAM_1000HDX_CAP, 6632675Szh199473 PARAM_100T4_CAP, 6642675Szh199473 PARAM_100FDX_CAP, 6652675Szh199473 PARAM_100HDX_CAP, 6662675Szh199473 PARAM_10FDX_CAP, 6672675Szh199473 PARAM_10HDX_CAP, 6682675Szh199473 6692675Szh199473 PARAM_ADV_AUTONEG_CAP, 6702675Szh199473 PARAM_ADV_PAUSE_CAP, 6712675Szh199473 PARAM_ADV_ASYM_PAUSE_CAP, 6722675Szh199473 PARAM_ADV_1000FDX_CAP, 6732675Szh199473 PARAM_ADV_1000HDX_CAP, 6742675Szh199473 PARAM_ADV_100T4_CAP, 6752675Szh199473 PARAM_ADV_100FDX_CAP, 6762675Szh199473 PARAM_ADV_100HDX_CAP, 6772675Szh199473 PARAM_ADV_10FDX_CAP, 6782675Szh199473 PARAM_ADV_10HDX_CAP, 6792675Szh199473 6802675Szh199473 PARAM_LP_AUTONEG_CAP, 6812675Szh199473 PARAM_LP_PAUSE_CAP, 6822675Szh199473 PARAM_LP_ASYM_PAUSE_CAP, 6832675Szh199473 PARAM_LP_1000FDX_CAP, 6842675Szh199473 PARAM_LP_1000HDX_CAP, 6852675Szh199473 PARAM_LP_100T4_CAP, 6862675Szh199473 PARAM_LP_100FDX_CAP, 6872675Szh199473 PARAM_LP_100HDX_CAP, 6882675Szh199473 PARAM_LP_10FDX_CAP, 6892675Szh199473 PARAM_LP_10HDX_CAP, 6902675Szh199473 6912675Szh199473 PARAM_LINK_STATUS, 6922675Szh199473 PARAM_LINK_SPEED, 6932675Szh199473 PARAM_LINK_DUPLEX, 6942675Szh199473 6952675Szh199473 PARAM_LINK_AUTONEG, 6962675Szh199473 PARAM_LINK_RX_PAUSE, 6972675Szh199473 PARAM_LINK_TX_PAUSE, 6982675Szh199473 6992675Szh199473 PARAM_LOOP_MODE, 7002675Szh199473 PARAM_MSI_CNT, 7012675Szh199473 7023334Sgs150176 PARAM_DRAIN_MAX, 7033334Sgs150176 7042675Szh199473 PARAM_COUNT 7052675Szh199473 }; 7062675Szh199473 7072675Szh199473 /* 7082675Szh199473 * Actual state of the BCM570x chip 7092675Szh199473 */ 7102675Szh199473 enum bge_chip_state { 7112675Szh199473 BGE_CHIP_FAULT = -2, /* fault, need reset */ 7122675Szh199473 BGE_CHIP_ERROR, /* error, want reset */ 7132675Szh199473 BGE_CHIP_INITIAL, /* Initial state only */ 7142675Szh199473 BGE_CHIP_RESET, /* reset, need init */ 7152675Szh199473 BGE_CHIP_STOPPED, /* Tx/Rx stopped */ 7162675Szh199473 BGE_CHIP_RUNNING /* with interrupts */ 7172675Szh199473 }; 7182675Szh199473 7192675Szh199473 enum bge_mac_state { 7202675Szh199473 BGE_MAC_STOPPED = 0, 7212675Szh199473 BGE_MAC_STARTED 7222675Szh199473 }; 7232675Szh199473 7242675Szh199473 /* 7252675Szh199473 * (Internal) return values from ioctl subroutines 7262675Szh199473 */ 7272675Szh199473 enum ioc_reply { 7282675Szh199473 IOC_INVAL = -1, /* bad, NAK with EINVAL */ 7292675Szh199473 IOC_DONE, /* OK, reply sent */ 7302675Szh199473 IOC_ACK, /* OK, just send ACK */ 7312675Szh199473 IOC_REPLY, /* OK, just send reply */ 7322675Szh199473 IOC_RESTART_ACK, /* OK, restart & ACK */ 7332675Szh199473 IOC_RESTART_REPLY /* OK, restart & reply */ 7342675Szh199473 }; 7352675Szh199473 7362675Szh199473 /* 7372675Szh199473 * (Internal) return values from send_msg subroutines 7382675Szh199473 */ 7392675Szh199473 enum send_status { 7402675Szh199473 SEND_FAIL = -1, /* Not OK */ 7412675Szh199473 SEND_KEEP, /* OK, msg queued */ 7422675Szh199473 SEND_FREE /* OK, free msg */ 7432675Szh199473 }; 7442675Szh199473 7452675Szh199473 /* 7462675Szh199473 * (Internal) enumeration of this driver's kstats 7472675Szh199473 */ 7482675Szh199473 enum { 7492675Szh199473 BGE_KSTAT_RAW = 0, 7502675Szh199473 BGE_KSTAT_STATS, 7512675Szh199473 BGE_KSTAT_CHIPID, 7522675Szh199473 BGE_KSTAT_DRIVER, 7532675Szh199473 BGE_KSTAT_PHYS, 7542675Szh199473 7552675Szh199473 BGE_KSTAT_COUNT 7562675Szh199473 }; 7572675Szh199473 7582675Szh199473 #define BGE_MAX_RESOURCES 255 7592675Szh199473 7602675Szh199473 /* 7612675Szh199473 * Per-instance soft-state structure 7622675Szh199473 */ 7632675Szh199473 typedef struct bge { 7642675Szh199473 /* 7652675Szh199473 * These fields are set by attach() and unchanged thereafter ... 7662675Szh199473 */ 7672675Szh199473 dev_info_t *devinfo; /* device instance */ 7682675Szh199473 mac_handle_t mh; /* mac module handle */ 7692675Szh199473 ddi_acc_handle_t cfg_handle; /* DDI I/O handle */ 7702675Szh199473 ddi_acc_handle_t io_handle; /* DDI I/O handle */ 7712675Szh199473 void *io_regs; /* mapped registers */ 772*5107Seota ddi_periodic_t periodic_id; /* periodical callback */ 7732675Szh199473 ddi_softintr_t factotum_id; /* factotum callback */ 7743334Sgs150176 ddi_softintr_t drain_id; /* reschedule callback */ 7752675Szh199473 7762675Szh199473 ddi_intr_handle_t *htable; /* For array of interrupts */ 7772675Szh199473 int intr_type; /* What type of interrupt */ 7782675Szh199473 int intr_cnt; /* # of intrs count returned */ 7792675Szh199473 uint_t intr_pri; /* Interrupt priority */ 7802675Szh199473 int intr_cap; /* Interrupt capabilities */ 7812675Szh199473 uint32_t progress; /* attach tracking */ 7822675Szh199473 uint32_t debug; /* per-instance debug */ 7832675Szh199473 chip_id_t chipid; 7842675Szh199473 const phys_ops_t *physops; 7852675Szh199473 char ifname[8]; /* "bge0" ... "bge999" */ 7862675Szh199473 7872675Szh199473 int fm_capabilities; /* FMA capabilities */ 7882675Szh199473 7892675Szh199473 /* 7902675Szh199473 * These structures describe the blocks of memory allocated during 7912675Szh199473 * attach(). They remain unchanged thereafter, although the memory 7922675Szh199473 * they describe is carved up into various separate regions and may 7932675Szh199473 * therefore be described by other structures as well. 7942675Szh199473 */ 7952675Szh199473 dma_area_t tx_desc; /* transmit descriptors */ 7962675Szh199473 dma_area_t rx_desc[BGE_RECV_RINGS_SPLIT]; 7972675Szh199473 /* receive descriptors */ 7982675Szh199473 dma_area_t tx_buff[BGE_SPLIT]; 7992675Szh199473 dma_area_t rx_buff[BGE_SPLIT]; 8002675Szh199473 8012675Szh199473 /* 8022675Szh199473 * The memory described by the <dma_area> structures above 8032675Szh199473 * is carved up into various pieces, which are described by 8042675Szh199473 * the structures below. 8052675Szh199473 */ 8062675Szh199473 dma_area_t statistics; /* describes hardware */ 8072675Szh199473 /* statistics area */ 8082675Szh199473 dma_area_t status_block; /* describes hardware */ 8092675Szh199473 /* status block */ 8102675Szh199473 /* 8112675Szh199473 * For the BCM5705/5788/5721/5751/5752/5714 and 5715, 8122675Szh199473 * the statistic block is not available,the statistic counter must 8132675Szh199473 * be gotten from statistic registers.And bge_statistics_reg_t record 8142675Szh199473 * the statistic registers value 8152675Szh199473 */ 8163334Sgs150176 bge_statistics_reg_t *pstats; 8172675Szh199473 8182675Szh199473 /* 8192675Szh199473 * Runtime read-write data starts here ... 8202675Szh199473 * 8212675Szh199473 * 3 Buffer Rings (std/jumbo/mini) 8222675Szh199473 * 16 Receive (Return) Rings 8232675Szh199473 * 16 Send Rings 8242675Szh199473 * 8252675Szh199473 * Note: they're not necessarily all used. 8262675Szh199473 */ 8272675Szh199473 buff_ring_t buff[BGE_BUFF_RINGS_MAX]; /* 3*0x0100 */ 8282675Szh199473 recv_ring_t recv[BGE_RECV_RINGS_MAX]; /* 16*0x0090 */ 8292675Szh199473 send_ring_t send[BGE_SEND_RINGS_MAX]; /* 16*0x0100 */ 8302675Szh199473 8312675Szh199473 /* 8322675Szh199473 * Locks: 8332675Szh199473 * 8342675Szh199473 * Each buffer ring contains its own <rf_lock> which regulates 8352675Szh199473 * ring refilling. 8362675Szh199473 * 8372675Szh199473 * Each receive (return) ring contains its own <rx_lock> which 8382675Szh199473 * protects the critical cyclic counters etc. 8392675Szh199473 * 8402675Szh199473 * Each send ring contains two locks: <tx_lock> for the send-path 8412675Szh199473 * protocol data and <tc_lock> for send-buffer recycling. 8422675Szh199473 * 8432675Szh199473 * Finally <genlock> is a general lock, protecting most other 8442675Szh199473 * operational data in the state structure and chip register 8452675Szh199473 * accesses. It is acquired by the interrupt handler and 8462675Szh199473 * most "mode-control" routines. 8472675Szh199473 * 8482675Szh199473 * Any of the locks can be acquired singly, but where multiple 8492675Szh199473 * locks are acquired, they *must* be in the order: 8502675Szh199473 * 8512675Szh199473 * genlock >>> rx_lock >>> rf_lock >>> tx_lock >>> tc_lock. 8522675Szh199473 * 8532675Szh199473 * and within any one class of lock the rings must be locked in 8542675Szh199473 * ascending order (send[0].tc_lock >>> send[1].tc_lock), etc. 8552675Szh199473 * 8562675Szh199473 * Note: actually I don't believe there's any need to acquire 8572675Szh199473 * locks on multiple rings, or even locks of all these classes 8582675Szh199473 * concurrently; but I've set out the above order so there is a 8592675Szh199473 * clear definition of lock hierarchy in case it's ever needed. 8602675Szh199473 * 8612675Szh199473 * Note: the combinations of locks that are actually held 8622675Szh199473 * concurrently are: 8632675Szh199473 * 8642675Szh199473 * genlock >>> (bge_chip_interrupt()) 8652675Szh199473 * rx_lock[i] >>> (bge_receive()) 8662675Szh199473 * rf_lock[n] (bge_refill()) 8672675Szh199473 * tc_lock[i] (bge_recycle()) 8682675Szh199473 */ 8692675Szh199473 kmutex_t genlock[1]; 8702675Szh199473 krwlock_t errlock[1]; 8712675Szh199473 kmutex_t softintrlock[1]; 8722675Szh199473 8732675Szh199473 /* 8742675Szh199473 * Current Ethernet addresses and multicast hash (bitmap) and 8752675Szh199473 * refcount tables, protected by <genlock> 8762675Szh199473 */ 8772675Szh199473 bge_mac_addr_t curr_addr[MAC_ADDRESS_REGS_MAX]; 8782675Szh199473 uint32_t mcast_hash[BGE_HASH_TABLE_SIZE/32]; 8792675Szh199473 uint8_t mcast_refs[BGE_HASH_TABLE_SIZE]; 8802675Szh199473 uint32_t unicst_addr_total; /* total unicst addresses */ 8812675Szh199473 uint32_t unicst_addr_avail; 8822675Szh199473 /* unused unicst addr slots */ 8832675Szh199473 8842675Szh199473 /* 8852675Szh199473 * Link state data (protected by genlock) 8862675Szh199473 */ 8872675Szh199473 link_state_t link_state; 8882675Szh199473 8892675Szh199473 /* 8902675Szh199473 * Physical layer: copper only 8912675Szh199473 */ 8922675Szh199473 bge_regno_t phy_mii_addr; /* should be (const) 1! */ 8932675Szh199473 uint16_t phy_gen_status; 8942675Szh199473 uint16_t phy_aux_status; 8952675Szh199473 8962675Szh199473 /* 8972675Szh199473 * Physical layer: serdes only 8982675Szh199473 */ 8992675Szh199473 uint32_t serdes_status; 9002675Szh199473 uint32_t serdes_advert; 9012675Szh199473 uint32_t serdes_lpadv; 9022675Szh199473 9032675Szh199473 /* 9042675Szh199473 * Driver kstats, protected by <genlock> where necessary 9052675Szh199473 */ 9062675Szh199473 kstat_t *bge_kstats[BGE_KSTAT_COUNT]; 9072675Szh199473 9082675Szh199473 /* 9092675Szh199473 * Miscellaneous operating variables (protected by genlock) 9102675Szh199473 */ 9112675Szh199473 uint64_t chip_resets; /* # of chip RESETs */ 9122675Szh199473 uint64_t missed_dmas; /* # of missed DMAs */ 9133907Szh199473 uint64_t missed_updates; /* # of missed updates */ 9142675Szh199473 enum bge_mac_state bge_mac_state; /* definitions above */ 9152675Szh199473 enum bge_chip_state bge_chip_state; /* definitions above */ 9162675Szh199473 boolean_t send_hw_tcp_csum; 9172675Szh199473 boolean_t recv_hw_tcp_csum; 9182675Szh199473 boolean_t promisc; 9192675Szh199473 9202675Szh199473 /* 9212675Szh199473 * Miscellaneous operating variables (not synchronised) 9222675Szh199473 */ 9232675Szh199473 uint32_t watchdog; /* watches for Tx stall */ 9242675Szh199473 boolean_t bge_intr_running; 9252675Szh199473 boolean_t bge_dma_error; 9263334Sgs150176 boolean_t tx_resched_needed; 9273334Sgs150176 uint64_t tx_resched; 9282675Szh199473 uint32_t factotum_flag; /* softint pending */ 9292675Szh199473 uintptr_t pagemask; 9302675Szh199473 9312675Szh199473 /* 9322675Szh199473 * NDD parameters (protected by genlock) 9332675Szh199473 */ 9342675Szh199473 caddr_t nd_data_p; 9353334Sgs150176 nd_param_t *nd_params; 9362675Szh199473 9372675Szh199473 /* 9382675Szh199473 * A flag to prevent excessive config space accesses 9392675Szh199473 * on platforms having BCM5714C/15C 9402675Szh199473 */ 9412675Szh199473 boolean_t lastWriteZeroData; 9422675Szh199473 9432675Szh199473 /* 9442675Szh199473 * Spare space, plus guard element used to check data integrity 9452675Szh199473 */ 9462675Szh199473 uint64_t spare[5]; 9472675Szh199473 uint64_t bge_guard; 9482675Szh199473 9492675Szh199473 /* 9502675Szh199473 * Receive rules configure 9512675Szh199473 */ 9522675Szh199473 bge_recv_rule_t recv_rules[RECV_RULES_NUM_MAX]; 9532675Szh199473 9542675Szh199473 #ifdef BGE_IPMI_ASF 9552675Szh199473 boolean_t asf_enabled; 9562675Szh199473 boolean_t asf_wordswapped; 9572675Szh199473 boolean_t asf_newhandshake; 9582675Szh199473 boolean_t asf_pseudostop; 9592675Szh199473 9602675Szh199473 uint32_t asf_status; 9612675Szh199473 timeout_id_t asf_timeout_id; 9622675Szh199473 #endif 9632675Szh199473 } bge_t; 9642675Szh199473 9652675Szh199473 /* 9662675Szh199473 * 'Progress' bit flags ... 9672675Szh199473 */ 9682675Szh199473 #define PROGRESS_CFG 0x0001 /* config space mapped */ 9692675Szh199473 #define PROGRESS_REGS 0x0002 /* registers mapped */ 9702675Szh199473 #define PROGRESS_BUFS 0x0004 /* ring buffers allocated */ 9712675Szh199473 #define PROGRESS_RESCHED 0x0010 /* resched softint registered */ 9722675Szh199473 #define PROGRESS_FACTOTUM 0x0020 /* factotum softint registered */ 9732675Szh199473 #define PROGRESS_HWINT 0x0040 /* h/w interrupt registered */ 9742675Szh199473 /* and mutexen initialised */ 9752675Szh199473 #define PROGRESS_INTR 0x0080 /* Intrs enabled */ 9762675Szh199473 #define PROGRESS_PHY 0x0100 /* PHY initialised */ 9772675Szh199473 #define PROGRESS_NDD 0x1000 /* NDD parameters set up */ 9782675Szh199473 #define PROGRESS_KSTATS 0x2000 /* kstats created */ 9792675Szh199473 #define PROGRESS_READY 0x8000 /* ready for work */ 9802675Szh199473 9812675Szh199473 /* 9822675Szh199473 * Shorthand for the NDD parameters 9832675Szh199473 */ 9842675Szh199473 #define param_adv_autoneg nd_params[PARAM_ADV_AUTONEG_CAP].ndp_val 9852675Szh199473 #define param_adv_pause nd_params[PARAM_ADV_PAUSE_CAP].ndp_val 9862675Szh199473 #define param_adv_asym_pause nd_params[PARAM_ADV_ASYM_PAUSE_CAP].ndp_val 9872675Szh199473 #define param_adv_1000fdx nd_params[PARAM_ADV_1000FDX_CAP].ndp_val 9882675Szh199473 #define param_adv_1000hdx nd_params[PARAM_ADV_1000HDX_CAP].ndp_val 9892675Szh199473 #define param_adv_100fdx nd_params[PARAM_ADV_100FDX_CAP].ndp_val 9902675Szh199473 #define param_adv_100hdx nd_params[PARAM_ADV_100HDX_CAP].ndp_val 9912675Szh199473 #define param_adv_10fdx nd_params[PARAM_ADV_10FDX_CAP].ndp_val 9922675Szh199473 #define param_adv_10hdx nd_params[PARAM_ADV_10HDX_CAP].ndp_val 9932675Szh199473 9942675Szh199473 #define param_lp_autoneg nd_params[PARAM_LP_AUTONEG_CAP].ndp_val 9952675Szh199473 #define param_lp_pause nd_params[PARAM_LP_PAUSE_CAP].ndp_val 9962675Szh199473 #define param_lp_asym_pause nd_params[PARAM_LP_ASYM_PAUSE_CAP].ndp_val 9972675Szh199473 #define param_lp_1000fdx nd_params[PARAM_LP_1000FDX_CAP].ndp_val 9982675Szh199473 #define param_lp_1000hdx nd_params[PARAM_LP_1000HDX_CAP].ndp_val 9992675Szh199473 #define param_lp_100fdx nd_params[PARAM_LP_100FDX_CAP].ndp_val 10002675Szh199473 #define param_lp_100hdx nd_params[PARAM_LP_100HDX_CAP].ndp_val 10012675Szh199473 #define param_lp_10fdx nd_params[PARAM_LP_10FDX_CAP].ndp_val 10022675Szh199473 #define param_lp_10hdx nd_params[PARAM_LP_10HDX_CAP].ndp_val 10032675Szh199473 10042675Szh199473 #define param_link_up nd_params[PARAM_LINK_STATUS].ndp_val 10052675Szh199473 #define param_link_speed nd_params[PARAM_LINK_SPEED].ndp_val 10062675Szh199473 #define param_link_duplex nd_params[PARAM_LINK_DUPLEX].ndp_val 10072675Szh199473 10082675Szh199473 #define param_link_autoneg nd_params[PARAM_LINK_AUTONEG].ndp_val 10092675Szh199473 #define param_link_rx_pause nd_params[PARAM_LINK_RX_PAUSE].ndp_val 10102675Szh199473 #define param_link_tx_pause nd_params[PARAM_LINK_TX_PAUSE].ndp_val 10112675Szh199473 10122675Szh199473 #define param_loop_mode nd_params[PARAM_LOOP_MODE].ndp_val 10132675Szh199473 #define param_msi_cnt nd_params[PARAM_MSI_CNT].ndp_val 10143334Sgs150176 #define param_drain_max nd_params[PARAM_DRAIN_MAX].ndp_val 10152675Szh199473 10162675Szh199473 /* 10172675Szh199473 * Sync a DMA area described by a dma_area_t 10182675Szh199473 */ 10192675Szh199473 #define DMA_SYNC(area, flag) ((void) ddi_dma_sync((area).dma_hdl, \ 10202675Szh199473 (area).offset, (area).alength, (flag))) 10212675Szh199473 10222675Szh199473 /* 10232675Szh199473 * Find the (kernel virtual) address of block of memory 10242675Szh199473 * described by a dma_area_t 10252675Szh199473 */ 10262675Szh199473 #define DMA_VPTR(area) ((area).mem_va) 10272675Szh199473 10282675Szh199473 /* 10292675Szh199473 * Zero a block of memory described by a dma_area_t 10302675Szh199473 */ 10312675Szh199473 #define DMA_ZERO(area) bzero(DMA_VPTR(area), (area).alength) 10322675Szh199473 10332675Szh199473 /* 10342675Szh199473 * Next value of a cyclic index 10352675Szh199473 */ 10363334Sgs150176 #define NEXT(index, limit) ((index)+1 < (limit) ? (index)+1 : 0) 10372675Szh199473 10382675Szh199473 /* 10392675Szh199473 * Property lookups 10402675Szh199473 */ 10412675Szh199473 #define BGE_PROP_EXISTS(d, n) ddi_prop_exists(DDI_DEV_T_ANY, (d), \ 10422675Szh199473 DDI_PROP_DONTPASS, (n)) 10432675Szh199473 #define BGE_PROP_GET_INT(d, n) ddi_prop_get_int(DDI_DEV_T_ANY, (d), \ 10442675Szh199473 DDI_PROP_DONTPASS, (n), -1) 10452675Szh199473 10462675Szh199473 /* 10472675Szh199473 * Copy an ethernet address 10482675Szh199473 */ 10492675Szh199473 #define ethaddr_copy(src, dst) bcopy((src), (dst), ETHERADDRL) 10502675Szh199473 10512675Szh199473 /* 10522675Szh199473 * Endian swap 10532675Szh199473 */ 10542675Szh199473 /* BEGIN CSTYLED */ 10552675Szh199473 #define BGE_BSWAP_32(x) ((((x) & 0xff000000) >> 24) | \ 10562675Szh199473 (((x) & 0x00ff0000) >> 8) | \ 10572675Szh199473 (((x) & 0x0000ff00) << 8) | \ 10582675Szh199473 (((x) & 0x000000ff) << 24)) 10592675Szh199473 /* END CSTYLED */ 10602675Szh199473 10612675Szh199473 /* 10622675Szh199473 * Marker value placed at the end of the driver's state 10632675Szh199473 */ 10642675Szh199473 #define BGE_GUARD 0x1919306009031802 10652675Szh199473 10662675Szh199473 /* 10672675Szh199473 * Bit flags in the 'debug' word ... 10682675Szh199473 */ 10692675Szh199473 #define BGE_DBG_STOP 0x00000001 /* early debug_enter() */ 10702675Szh199473 #define BGE_DBG_TRACE 0x00000002 /* general flow tracing */ 10712675Szh199473 10722675Szh199473 #define BGE_DBG_REGS 0x00000010 /* low-level accesses */ 10732675Szh199473 #define BGE_DBG_MII 0x00000020 /* low-level MII access */ 10742675Szh199473 #define BGE_DBG_SEEPROM 0x00000040 /* low-level SEEPROM IO */ 10752675Szh199473 #define BGE_DBG_CHIP 0x00000080 /* low(ish)-level code */ 10762675Szh199473 10772675Szh199473 #define BGE_DBG_RECV 0x00000100 /* receive-side code */ 10782675Szh199473 #define BGE_DBG_SEND 0x00000200 /* packet-send code */ 10792675Szh199473 10802675Szh199473 #define BGE_DBG_INT 0x00001000 /* interrupt handler */ 10812675Szh199473 #define BGE_DBG_FACT 0x00002000 /* factotum (softint) */ 10822675Szh199473 10832675Szh199473 #define BGE_DBG_PHY 0x00010000 /* Copper PHY code */ 10842675Szh199473 #define BGE_DBG_SERDES 0x00020000 /* SerDes code */ 10852675Szh199473 #define BGE_DBG_PHYS 0x00040000 /* Physical layer code */ 10862675Szh199473 #define BGE_DBG_LINK 0x00080000 /* Link status check */ 10872675Szh199473 10882675Szh199473 #define BGE_DBG_INIT 0x00100000 /* initialisation */ 10892675Szh199473 #define BGE_DBG_NEMO 0x00200000 /* nemo interaction */ 10902675Szh199473 #define BGE_DBG_ADDR 0x00400000 /* address-setting code */ 10912675Szh199473 #define BGE_DBG_STATS 0x00800000 /* statistics */ 10922675Szh199473 10932675Szh199473 #define BGE_DBG_IOCTL 0x01000000 /* ioctl handling */ 10942675Szh199473 #define BGE_DBG_LOOP 0x02000000 /* loopback ioctl code */ 10952675Szh199473 #define BGE_DBG_PPIO 0x04000000 /* Peek/poke ioctls */ 10962675Szh199473 #define BGE_DBG_BADIOC 0x08000000 /* unknown ioctls */ 10972675Szh199473 10982675Szh199473 #define BGE_DBG_MCTL 0x10000000 /* mctl (csum) code */ 10992675Szh199473 #define BGE_DBG_NDD 0x20000000 /* NDD operations */ 11002675Szh199473 11012675Szh199473 /* 11022675Szh199473 * Debugging ... 11032675Szh199473 */ 11042675Szh199473 #ifdef DEBUG 11052675Szh199473 #define BGE_DEBUGGING 1 11062675Szh199473 #else 11072675Szh199473 #define BGE_DEBUGGING 0 11082675Szh199473 #endif /* DEBUG */ 11092675Szh199473 11102675Szh199473 11112675Szh199473 /* 11122675Szh199473 * 'Do-if-debugging' macro. The parameter <command> should be one or more 11132675Szh199473 * C statements (but without the *final* semicolon), which will either be 11142675Szh199473 * compiled inline or completely ignored, depending on the BGE_DEBUGGING 11152675Szh199473 * compile-time flag. 11162675Szh199473 * 11172675Szh199473 * You should get a compile-time error (at least on a DEBUG build) if 11182675Szh199473 * your statement isn't actually a statement, rather than unexpected 11192675Szh199473 * run-time behaviour caused by unintended matching of if-then-elses etc. 11202675Szh199473 * 11212675Szh199473 * Note that the BGE_DDB() macro itself can only be used as a statement, 11222675Szh199473 * not an expression, and should always be followed by a semicolon. 11232675Szh199473 */ 11242675Szh199473 #if BGE_DEBUGGING 11252675Szh199473 #define BGE_DDB(command) do { \ 11262675Szh199473 { command; } \ 11272675Szh199473 _NOTE(CONSTANTCONDITION) \ 11282675Szh199473 } while (0) 11292675Szh199473 #else /* BGE_DEBUGGING */ 11302675Szh199473 #define BGE_DDB(command) do { \ 11312675Szh199473 { _NOTE(EMPTY); } \ 11322675Szh199473 _NOTE(CONSTANTCONDITION) \ 11332675Szh199473 } while (0) 11342675Szh199473 #endif /* BGE_DEBUGGING */ 11352675Szh199473 11362675Szh199473 /* 11372675Szh199473 * 'Internal' macros used to construct the TRACE/DEBUG macros below. 11382675Szh199473 * These provide the primitive conditional-call capability required. 11392675Szh199473 * Note: the parameter <args> is a parenthesised list of the actual 11402675Szh199473 * printf-style arguments to be passed to the debug function ... 11412675Szh199473 */ 11422675Szh199473 #define BGE_XDB(b, w, f, args) BGE_DDB(if ((b) & (w)) f args) 11432675Szh199473 #define BGE_GDB(b, args) BGE_XDB(b, bge_debug, (*bge_gdb()), args) 11442675Szh199473 #define BGE_LDB(b, args) BGE_XDB(b, bgep->debug, (*bge_db(bgep)), args) 11452675Szh199473 #define BGE_CDB(f, args) BGE_XDB(BGE_DBG, bgep->debug, f, args) 11462675Szh199473 11472675Szh199473 /* 11482675Szh199473 * Conditional-print macros. 11492675Szh199473 * 11502675Szh199473 * Define BGE_DBG to be the relevant member of the set of BGE_DBG_* values 11512675Szh199473 * above before using the BGE_GDEBUG() or BGE_DEBUG() macros. The 'G' 11522675Szh199473 * versions look at the Global debug flag word (bge_debug); the non-G 11532675Szh199473 * versions look in the per-instance data (bgep->debug) and so require a 11542675Szh199473 * variable called 'bgep' to be in scope (and initialised!) before use. 11552675Szh199473 * 11562675Szh199473 * You could redefine BGE_TRC too if you really need two different 11572675Szh199473 * flavours of debugging output in the same area of code, but I don't 11582675Szh199473 * really recommend it. 11592675Szh199473 * 11602675Szh199473 * Note: the parameter <args> is a parenthesised list of the actual 11612675Szh199473 * arguments to be passed to the debug function, usually a printf-style 11622675Szh199473 * format string and corresponding values to be formatted. 11632675Szh199473 */ 11642675Szh199473 11652675Szh199473 #define BGE_TRC BGE_DBG_TRACE /* default 'trace' bit */ 11662675Szh199473 #define BGE_GTRACE(args) BGE_GDB(BGE_TRC, args) 11672675Szh199473 #define BGE_GDEBUG(args) BGE_GDB(BGE_DBG, args) 11682675Szh199473 #define BGE_TRACE(args) BGE_LDB(BGE_TRC, args) 11692675Szh199473 #define BGE_DEBUG(args) BGE_LDB(BGE_DBG, args) 11702675Szh199473 11712675Szh199473 /* 11722675Szh199473 * Debug-only action macros 11732675Szh199473 */ 11742675Szh199473 #define BGE_BRKPT(bgep, s) BGE_DDB(bge_dbg_enter(bgep, s)) 11752675Szh199473 #define BGE_MARK(bgep) BGE_DDB(bge_led_mark(bgep)) 11762675Szh199473 #define BGE_PCICHK(bgep) BGE_DDB(bge_pci_check(bgep)) 11772675Szh199473 #define BGE_PKTDUMP(args) BGE_DDB(bge_pkt_dump args) 11782675Szh199473 #define BGE_REPORT(args) BGE_DDB(bge_log args) 11792675Szh199473 11802675Szh199473 /* 11812675Szh199473 * Inter-source-file linkage ... 11822675Szh199473 */ 11832675Szh199473 11842675Szh199473 /* bge_chip.c */ 11852675Szh199473 uint16_t bge_mii_get16(bge_t *bgep, bge_regno_t regno); 11862675Szh199473 void bge_mii_put16(bge_t *bgep, bge_regno_t regno, uint16_t value); 11872675Szh199473 uint32_t bge_reg_get32(bge_t *bgep, bge_regno_t regno); 11882675Szh199473 void bge_reg_put32(bge_t *bgep, bge_regno_t regno, uint32_t value); 11892675Szh199473 void bge_reg_set32(bge_t *bgep, bge_regno_t regno, uint32_t bits); 11902675Szh199473 void bge_reg_clr32(bge_t *bgep, bge_regno_t regno, uint32_t bits); 11912675Szh199473 void bge_mbx_put(bge_t *bgep, bge_regno_t regno, uint64_t value); 11922675Szh199473 void bge_chip_cfg_init(bge_t *bgep, chip_id_t *cidp, boolean_t enable_dma); 11932675Szh199473 int bge_chip_id_init(bge_t *bgep); 11942675Szh199473 int bge_chip_start(bge_t *bgep, boolean_t reset_phy); 11952675Szh199473 void bge_chip_stop(bge_t *bgep, boolean_t fault); 11962675Szh199473 #ifdef BGE_IPMI_ASF 11972675Szh199473 void bge_nic_put32(bge_t *bgep, bge_regno_t addr, uint32_t data); 11982675Szh199473 #pragma inline(bge_nic_put32) 11992675Szh199473 uint32_t bge_nic_read32(bge_t *bgep, bge_regno_t addr); 12003918Sml149210 void bge_ind_put32(bge_t *bgep, bge_regno_t regno, uint32_t val); 12013918Sml149210 #pragma inline(bge_ind_put32) 12023918Sml149210 uint32_t bge_ind_get32(bge_t *bgep, bge_regno_t regno); 12033918Sml149210 #pragma inline(bge_ind_get32) 12042675Szh199473 void bge_asf_update_status(bge_t *bgep); 12052675Szh199473 void bge_asf_heartbeat(void *bgep); 12062675Szh199473 void bge_asf_stop_timer(bge_t *bgep); 12072675Szh199473 void bge_asf_get_config(bge_t *bgep); 12082675Szh199473 void bge_asf_pre_reset_operations(bge_t *bgep, uint32_t mode); 12092675Szh199473 void bge_asf_post_reset_old_mode(bge_t *bgep, uint32_t mode); 12102675Szh199473 void bge_asf_post_reset_new_mode(bge_t *bgep, uint32_t mode); 12112675Szh199473 int bge_chip_reset(bge_t *bgep, boolean_t enable_dma, uint_t asf_mode); 12122675Szh199473 int bge_chip_sync(bge_t *bgep, boolean_t asf_keeplive); 12132675Szh199473 #else 12142675Szh199473 int bge_chip_reset(bge_t *bgep, boolean_t enable_dma); 12152675Szh199473 int bge_chip_sync(bge_t *bgep); 12162675Szh199473 #endif 12172675Szh199473 void bge_chip_blank(void *arg, time_t ticks, uint_t count); 12182675Szh199473 uint_t bge_chip_factotum(caddr_t arg); 12192675Szh199473 void bge_chip_cyclic(void *arg); 12202675Szh199473 enum ioc_reply bge_chip_ioctl(bge_t *bgep, queue_t *wq, mblk_t *mp, 12212675Szh199473 struct iocblk *iocp); 12222675Szh199473 uint_t bge_intr(caddr_t arg1, caddr_t arg2); 12232675Szh199473 extern uint32_t bge_rx_ticks_norm; 12242675Szh199473 extern uint32_t bge_tx_ticks_norm; 12252675Szh199473 extern uint32_t bge_rx_count_norm; 12262675Szh199473 extern uint32_t bge_tx_count_norm; 12272675Szh199473 extern boolean_t bge_jumbo_enable; 12283907Szh199473 extern boolean_t bge_relaxed_ordering; 12293907Szh199473 12302675Szh199473 void bge_chip_msi_trig(bge_t *bgep); 12312675Szh199473 12322675Szh199473 /* bge_kstats.c */ 12332675Szh199473 void bge_init_kstats(bge_t *bgep, int instance); 12342675Szh199473 void bge_fini_kstats(bge_t *bgep); 12352675Szh199473 int bge_m_stat(void *arg, uint_t stat, uint64_t *val); 12362675Szh199473 12372675Szh199473 /* bge_log.c */ 12382675Szh199473 #if BGE_DEBUGGING 12392675Szh199473 void (*bge_db(bge_t *bgep))(const char *fmt, ...); 12402675Szh199473 void (*bge_gdb(void))(const char *fmt, ...); 12412675Szh199473 void bge_pkt_dump(bge_t *bgep, bge_rbd_t *hbp, sw_rbd_t *sdp, const char *msg); 12422675Szh199473 void bge_dbg_enter(bge_t *bgep, const char *msg); 12432675Szh199473 #endif /* BGE_DEBUGGING */ 12442675Szh199473 void bge_problem(bge_t *bgep, const char *fmt, ...); 12452675Szh199473 void bge_log(bge_t *bgep, const char *fmt, ...); 12462675Szh199473 void bge_error(bge_t *bgep, const char *fmt, ...); 12472675Szh199473 void bge_fm_ereport(bge_t *bgep, char *detail); 12482675Szh199473 extern kmutex_t bge_log_mutex[1]; 12492675Szh199473 extern uint32_t bge_debug; 12502675Szh199473 12512675Szh199473 /* bge_main.c */ 12522675Szh199473 int bge_restart(bge_t *bgep, boolean_t reset_phy); 12532675Szh199473 int bge_check_acc_handle(bge_t *bgep, ddi_acc_handle_t handle); 12542675Szh199473 int bge_check_dma_handle(bge_t *bgep, ddi_dma_handle_t handle); 12552675Szh199473 void bge_init_rings(bge_t *bgep); 12562675Szh199473 void bge_fini_rings(bge_t *bgep); 12573334Sgs150176 bge_queue_item_t *bge_alloc_txbuf_array(bge_t *bgep, send_ring_t *srp); 12583334Sgs150176 void bge_free_txbuf_arrays(send_ring_t *srp); 12592675Szh199473 int bge_alloc_bufs(bge_t *bgep); 12602675Szh199473 void bge_free_bufs(bge_t *bgep); 12612675Szh199473 void bge_intr_enable(bge_t *bgep); 12622675Szh199473 void bge_intr_disable(bge_t *bgep); 12632675Szh199473 12642675Szh199473 /* bge_phys.c */ 12652675Szh199473 int bge_phys_init(bge_t *bgep); 12662675Szh199473 void bge_phys_reset(bge_t *bgep); 12672675Szh199473 int bge_phys_idle(bge_t *bgep); 12682675Szh199473 int bge_phys_update(bge_t *bgep); 12692675Szh199473 boolean_t bge_phys_check(bge_t *bgep); 12702675Szh199473 12712675Szh199473 /* bge_ndd.c */ 12722675Szh199473 int bge_nd_init(bge_t *bgep); 12732675Szh199473 enum ioc_reply bge_nd_ioctl(bge_t *bgep, queue_t *wq, mblk_t *mp, 12742675Szh199473 struct iocblk *iocp); 12752675Szh199473 void bge_nd_cleanup(bge_t *bgep); 12762675Szh199473 12772675Szh199473 /* bge_recv.c */ 12782675Szh199473 void bge_receive(bge_t *bgep, bge_status_t *bsp); 12792675Szh199473 12802675Szh199473 /* bge_send.c */ 12812675Szh199473 mblk_t *bge_m_tx(void *arg, mblk_t *mp); 12822675Szh199473 void bge_recycle(bge_t *bgep, bge_status_t *bsp); 12833334Sgs150176 uint_t bge_send_drain(caddr_t arg); 12842675Szh199473 12853334Sgs150176 /* bge_atomic.c */ 12862675Szh199473 uint64_t bge_atomic_reserve(uint64_t *count_p, uint64_t n); 12872675Szh199473 void bge_atomic_renounce(uint64_t *count_p, uint64_t n); 12882675Szh199473 uint64_t bge_atomic_claim(uint64_t *count_p, uint64_t limit); 12893334Sgs150176 uint64_t bge_atomic_next(uint64_t *sp, uint64_t limit); 12903334Sgs150176 void bge_atomic_sub64(uint64_t *count_p, uint64_t n); 12912675Szh199473 uint64_t bge_atomic_clr64(uint64_t *sp, uint64_t bits); 12922675Szh199473 uint32_t bge_atomic_shl32(uint32_t *sp, uint_t count); 12932675Szh199473 12942675Szh199473 /* 12952675Szh199473 * Reset type 12962675Szh199473 */ 12972675Szh199473 #define BGE_SHUTDOWN_RESET 0 12982675Szh199473 #define BGE_INIT_RESET 1 12992675Szh199473 #define BGE_SUSPEND_RESET 2 13002675Szh199473 13012675Szh199473 /* For asf_status */ 13022675Szh199473 #define ASF_STAT_NONE 0 13032675Szh199473 #define ASF_STAT_STOP 1 13042675Szh199473 #define ASF_STAT_RUN 2 13052675Szh199473 #define ASF_STAT_RUN_INIT 3 /* attached but don't plumb */ 13062675Szh199473 13072675Szh199473 /* ASF modes for bge_reset() and bge_chip_reset() */ 13082675Szh199473 #define ASF_MODE_NONE 0 /* don't launch asf */ 13092675Szh199473 #define ASF_MODE_SHUTDOWN 1 /* asf shutdown mode */ 13102675Szh199473 #define ASF_MODE_INIT 2 /* asf init mode */ 13112675Szh199473 #define ASF_MODE_POST_SHUTDOWN 3 /* only do post-shutdown */ 13122675Szh199473 #define ASF_MODE_POST_INIT 4 /* only do post-init */ 13132675Szh199473 13142675Szh199473 #define BGE_ASF_HEARTBEAT_INTERVAL 1500000 13152675Szh199473 13162675Szh199473 #ifdef __cplusplus 13172675Szh199473 } 13182675Szh199473 #endif 13192675Szh199473 13203334Sgs150176 #endif /* _BGE_IMPL_H */ 1321