1*2675Szh199473 /* 2*2675Szh199473 * CDDL HEADER START 3*2675Szh199473 * 4*2675Szh199473 * The contents of this file are subject to the terms of the 5*2675Szh199473 * Common Development and Distribution License (the "License"). 6*2675Szh199473 * You may not use this file except in compliance with the License. 7*2675Szh199473 * 8*2675Szh199473 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*2675Szh199473 * or http://www.opensolaris.org/os/licensing. 10*2675Szh199473 * See the License for the specific language governing permissions 11*2675Szh199473 * and limitations under the License. 12*2675Szh199473 * 13*2675Szh199473 * When distributing Covered Code, include this CDDL HEADER in each 14*2675Szh199473 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*2675Szh199473 * If applicable, add the following below this CDDL HEADER, with the 16*2675Szh199473 * fields enclosed by brackets "[]" replaced with your own identifying 17*2675Szh199473 * information: Portions Copyright [yyyy] [name of copyright owner] 18*2675Szh199473 * 19*2675Szh199473 * CDDL HEADER END 20*2675Szh199473 */ 21*2675Szh199473 22*2675Szh199473 /* 23*2675Szh199473 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 24*2675Szh199473 * Use is subject to license terms. 25*2675Szh199473 */ 26*2675Szh199473 27*2675Szh199473 #ifndef _SYS_BGE_IMPL_H 28*2675Szh199473 #define _SYS_BGE_IMPL_H 29*2675Szh199473 30*2675Szh199473 #pragma ident "%Z%%M% %I% %E% SMI" 31*2675Szh199473 32*2675Szh199473 #ifdef __cplusplus 33*2675Szh199473 extern "C" { 34*2675Szh199473 #endif 35*2675Szh199473 36*2675Szh199473 #include <sys/types.h> 37*2675Szh199473 #include <sys/stream.h> 38*2675Szh199473 #include <sys/strsun.h> 39*2675Szh199473 #include <sys/strsubr.h> 40*2675Szh199473 #include <sys/stat.h> 41*2675Szh199473 #include <sys/pci.h> 42*2675Szh199473 #include <sys/note.h> 43*2675Szh199473 #include <sys/modctl.h> 44*2675Szh199473 #include <sys/crc32.h> 45*2675Szh199473 #ifdef __sparcv9 46*2675Szh199473 #include <v9/sys/membar.h> 47*2675Szh199473 #endif /* __sparcv9 */ 48*2675Szh199473 #include <sys/kstat.h> 49*2675Szh199473 #include <sys/ethernet.h> 50*2675Szh199473 #include <sys/vlan.h> 51*2675Szh199473 #include <sys/errno.h> 52*2675Szh199473 #include <sys/dlpi.h> 53*2675Szh199473 #include <sys/devops.h> 54*2675Szh199473 #include <sys/debug.h> 55*2675Szh199473 #include <sys/cyclic.h> 56*2675Szh199473 #include <sys/conf.h> 57*2675Szh199473 58*2675Szh199473 #include <netinet/ip6.h> 59*2675Szh199473 60*2675Szh199473 #include <inet/common.h> 61*2675Szh199473 #include <inet/ip.h> 62*2675Szh199473 #include <inet/mi.h> 63*2675Szh199473 #include <inet/nd.h> 64*2675Szh199473 #include <sys/pattr.h> 65*2675Szh199473 66*2675Szh199473 #include <sys/dditypes.h> 67*2675Szh199473 #include <sys/ddi.h> 68*2675Szh199473 #include <sys/sunddi.h> 69*2675Szh199473 70*2675Szh199473 #include <sys/ddifm.h> 71*2675Szh199473 #include <sys/fm/protocol.h> 72*2675Szh199473 #include <sys/fm/util.h> 73*2675Szh199473 #include <sys/fm/io/ddi.h> 74*2675Szh199473 75*2675Szh199473 #include <sys/mac.h> 76*2675Szh199473 #include <sys/mac_ether.h> 77*2675Szh199473 78*2675Szh199473 #ifdef __amd64 79*2675Szh199473 #include <sys/x86_archext.h> 80*2675Szh199473 #endif 81*2675Szh199473 82*2675Szh199473 /* 83*2675Szh199473 * <sys/ethernet.h> *may* already have provided the typedef ether_addr_t; 84*2675Szh199473 * but of course C doesn't provide a way to check this directly. So here 85*2675Szh199473 * we rely on the fact that the symbol ETHERTYPE_AT was added to the 86*2675Szh199473 * header file (as a #define, which we *can* test for) at the same time 87*2675Szh199473 * as the typedef for ether_addr_t ;-! 88*2675Szh199473 */ 89*2675Szh199473 #ifndef ETHERTYPE_AT 90*2675Szh199473 typedef uchar_t ether_addr_t[ETHERADDRL]; 91*2675Szh199473 #endif /* ETHERTYPE_AT */ 92*2675Szh199473 93*2675Szh199473 /* 94*2675Szh199473 * Reconfiguring the network devices requires the net_config privilege 95*2675Szh199473 * in Solaris 10+. Prior to this, root privilege is required. In order 96*2675Szh199473 * that the driver binary can run on both S10+ and earlier versions, we 97*2675Szh199473 * make the decision as to which to use at runtime. These declarations 98*2675Szh199473 * allow for either (or both) to exist ... 99*2675Szh199473 */ 100*2675Szh199473 extern int secpolicy_net_config(const cred_t *, boolean_t); 101*2675Szh199473 extern int drv_priv(cred_t *); 102*2675Szh199473 #pragma weak secpolicy_net_config 103*2675Szh199473 #pragma weak drv_priv 104*2675Szh199473 105*2675Szh199473 #include <sys/netlb.h> /* originally from cassini */ 106*2675Szh199473 #include <sys/miiregs.h> /* by fjlite out of intel */ 107*2675Szh199473 108*2675Szh199473 #include "bge.h" 109*2675Szh199473 #include "bge_hw.h" 110*2675Szh199473 111*2675Szh199473 /* 112*2675Szh199473 * Compile-time feature switches ... 113*2675Szh199473 */ 114*2675Szh199473 #define BGE_DO_PPIO 0 /* peek/poke ioctls */ 115*2675Szh199473 #define BGE_RX_SOFTINT 0 /* softint per receive ring */ 116*2675Szh199473 #define BGE_CHOOSE_SEND_METHOD 0 /* send by copying only */ 117*2675Szh199473 118*2675Szh199473 /* 119*2675Szh199473 * NOTES: 120*2675Szh199473 * 121*2675Szh199473 * #defines: 122*2675Szh199473 * 123*2675Szh199473 * BGE_PCI_CONFIG_RNUMBER and BGE_PCI_OPREGS_RNUMBER are the 124*2675Szh199473 * register-set numbers to use for the config space registers 125*2675Szh199473 * and the operating registers respectively. On an OBP-based 126*2675Szh199473 * machine, regset 0 refers to CONFIG space, and regset 1 will 127*2675Szh199473 * be the operating registers in MEMORY space. If an expansion 128*2675Szh199473 * ROM is fitted, it may appear as a further register set. 129*2675Szh199473 * 130*2675Szh199473 * BGE_DMA_MODE defines the mode (STREAMING/CONSISTENT) used 131*2675Szh199473 * for the data buffers. The descriptors are always set up 132*2675Szh199473 * in CONSISTENT mode. 133*2675Szh199473 * 134*2675Szh199473 * BGE_HEADROOM defines how much space we'll leave in allocated 135*2675Szh199473 * mblks before the first valid data byte. This should be chosen 136*2675Szh199473 * to be 2 modulo 4, so that once the ethernet header (14 bytes) 137*2675Szh199473 * has been stripped off, the packet data will be 4-byte aligned. 138*2675Szh199473 * The remaining space can be used by upstream modules to prepend 139*2675Szh199473 * any headers required. 140*2675Szh199473 */ 141*2675Szh199473 142*2675Szh199473 #define BGE_PCI_CONFIG_RNUMBER 0 143*2675Szh199473 #define BGE_PCI_OPREGS_RNUMBER 1 144*2675Szh199473 #define BGE_DMA_MODE DDI_DMA_STREAMING 145*2675Szh199473 #define BGE_HEADROOM 34 146*2675Szh199473 147*2675Szh199473 /* 148*2675Szh199473 * BGE_HALFTICK is half the period of the cyclic callback (in 149*2675Szh199473 * nanoseconds), chosen so that 0.5s <= cyclic period <= 1s. 150*2675Szh199473 * Other time values are derived as odd multiples of this value 151*2675Szh199473 * so that there's little chance of ambiguity w.r.t. which tick 152*2675Szh199473 * a timeout expires on. 153*2675Szh199473 * 154*2675Szh199473 * BGE_PHY_STABLE_TIME is the period for which the contents of the 155*2675Szh199473 * PHY's status register must remain unchanging before we accept 156*2675Szh199473 * that the link has come up. [Sometimes the link comes up, only 157*2675Szh199473 * to go down again within a short time as the autonegotiation 158*2675Szh199473 * process cycles through various options before finding the best 159*2675Szh199473 * compatible mode. We don't want to report repeated link up/down 160*2675Szh199473 * cycles, so we wait until we think it's stable.] 161*2675Szh199473 * 162*2675Szh199473 * BGE_SERDES_STABLE_TIME is the analogous value for the SerDes 163*2675Szh199473 * interface. It's much shorter, 'cos the SerDes doesn't show 164*2675Szh199473 * these effects as much as the copper PHY. 165*2675Szh199473 * 166*2675Szh199473 * BGE_LINK_SETTLE_TIME is the period during which we regard link 167*2675Szh199473 * up/down cycles as an normal event after resetting/reprogramming 168*2675Szh199473 * the PHY. During this time, link up/down messages are sent to 169*2675Szh199473 * the log only, not the console. At any other time, link change 170*2675Szh199473 * events are regarded as unexpected and sent to both console & log. 171*2675Szh199473 * 172*2675Szh199473 * These latter two values have no theoretical justification, but 173*2675Szh199473 * are derived from observations and heuristics - the values below 174*2675Szh199473 * just seem to work quite well. 175*2675Szh199473 */ 176*2675Szh199473 177*2675Szh199473 #define BGE_HALFTICK 268435456LL /* 2**28 ns! */ 178*2675Szh199473 #define BGE_CYCLIC_PERIOD (2*BGE_HALFTICK) /* ~0.5s */ 179*2675Szh199473 #define BGE_SERDES_STABLE_TIME (3*BGE_HALFTICK) /* ~0.8s */ 180*2675Szh199473 #define BGE_PHY_STABLE_TIME (11*BGE_HALFTICK) /* ~3.0s */ 181*2675Szh199473 #define BGE_LINK_SETTLE_TIME (111*BGE_HALFTICK) /* ~30.0s */ 182*2675Szh199473 183*2675Szh199473 /* 184*2675Szh199473 * Indices used to identify the different buffer rings internally 185*2675Szh199473 */ 186*2675Szh199473 #define BGE_STD_BUFF_RING 0 187*2675Szh199473 #define BGE_JUMBO_BUFF_RING 1 188*2675Szh199473 #define BGE_MINI_BUFF_RING 2 189*2675Szh199473 190*2675Szh199473 /* 191*2675Szh199473 * Current implementation limits 192*2675Szh199473 */ 193*2675Szh199473 #define BGE_BUFF_RINGS_USED 2 /* std & jumbo ring */ 194*2675Szh199473 /* for now */ 195*2675Szh199473 #define BGE_RECV_RINGS_USED 16 /* up to 16 rtn rings */ 196*2675Szh199473 /* for now */ 197*2675Szh199473 #define BGE_SEND_RINGS_USED 4 /* up to 4 tx rings */ 198*2675Szh199473 /* for now */ 199*2675Szh199473 #define BGE_HASH_TABLE_SIZE 128 /* may be 256 later */ 200*2675Szh199473 201*2675Szh199473 /* 202*2675Szh199473 * Ring/buffer size parameters 203*2675Szh199473 * 204*2675Szh199473 * All of the (up to) 16 TX rings & and the corresponding buffers are the 205*2675Szh199473 * same size. 206*2675Szh199473 * 207*2675Szh199473 * Each of the (up to) 3 receive producer (aka buffer) rings is a different 208*2675Szh199473 * size and has different sized buffers associated with it too. 209*2675Szh199473 * 210*2675Szh199473 * The (up to) 16 receive return rings have no buffers associated with them. 211*2675Szh199473 * The number of slots per receive return ring must be 2048 if the mini 212*2675Szh199473 * ring is enabled, otherwise it may be 1024. See Broadcom document 213*2675Szh199473 * 570X-PG102-R page 56. 214*2675Szh199473 * 215*2675Szh199473 * Note: only the 5700 supported external memory (and therefore the mini 216*2675Szh199473 * ring); the 5702/3/4 don't. This driver doesn't support the original 217*2675Szh199473 * 5700, so we won't ever use the mini ring capability. 218*2675Szh199473 */ 219*2675Szh199473 220*2675Szh199473 #define BGE_SEND_RINGS_DEFAULT 1 221*2675Szh199473 #define BGE_RECV_RINGS_DEFAULT 1 222*2675Szh199473 223*2675Szh199473 #define BGE_SEND_BUFF_SIZE_DEFAULT 1536 224*2675Szh199473 #define BGE_SEND_BUFF_SIZE_JUMBO 9022 225*2675Szh199473 #define BGE_SEND_SLOTS_USED 512 226*2675Szh199473 227*2675Szh199473 #define BGE_STD_BUFF_SIZE 1536 /* 0x600 */ 228*2675Szh199473 #define BGE_STD_SLOTS_USED 512 229*2675Szh199473 230*2675Szh199473 #define BGE_JUMBO_BUFF_SIZE 9022 /* 9k */ 231*2675Szh199473 #define BGE_JUMBO_SLOTS_USED 256 232*2675Szh199473 233*2675Szh199473 #define BGE_MINI_BUFF_SIZE 128 /* 64? 256? */ 234*2675Szh199473 #define BGE_MINI_SLOTS_USED 0 /* must be 0; see above */ 235*2675Szh199473 236*2675Szh199473 #define BGE_RECV_BUFF_SIZE 0 237*2675Szh199473 #if BGE_MINI_SLOTS_USED > 0 238*2675Szh199473 #define BGE_RECV_SLOTS_USED 2048 /* required */ 239*2675Szh199473 #else 240*2675Szh199473 #define BGE_RECV_SLOTS_USED 1024 /* could be 2048 anyway */ 241*2675Szh199473 #endif 242*2675Szh199473 243*2675Szh199473 /* 244*2675Szh199473 * PCI type. PCI-Express or PCI/PCIX 245*2675Szh199473 */ 246*2675Szh199473 #define BGE_PCI 0 247*2675Szh199473 #define BGE_PCI_E 1 248*2675Szh199473 #define BGE_PCI_X 2 249*2675Szh199473 250*2675Szh199473 /* 251*2675Szh199473 * Statistic type. There are two type of statistic: 252*2675Szh199473 * statistic block and statistic registers 253*2675Szh199473 */ 254*2675Szh199473 #define BGE_STAT_BLK 1 255*2675Szh199473 #define BGE_STAT_REG 2 256*2675Szh199473 257*2675Szh199473 /* 258*2675Szh199473 * MTU.for all chipsets ,the default is 1500 ,and some chipsets 259*2675Szh199473 * support 9k jumbo frames size 260*2675Szh199473 */ 261*2675Szh199473 #define BGE_DEFAULT_MTU 1500 262*2675Szh199473 #define BGE_MAXIMUM_MTU 9000 263*2675Szh199473 264*2675Szh199473 /* 265*2675Szh199473 * Pad the h/w defined status block (which can be up to 80 bytes long) 266*2675Szh199473 * to a power-of-two boundary 267*2675Szh199473 */ 268*2675Szh199473 #define BGE_STATUS_PADDING (128 - sizeof (bge_status_t)) 269*2675Szh199473 270*2675Szh199473 /* 271*2675Szh199473 * On platforms which support DVMA, we can simply allocate one big piece 272*2675Szh199473 * of memory for all the Tx buffers and another for the Rx buffers, and 273*2675Szh199473 * then carve them up as required. It doesn't matter if they aren't just 274*2675Szh199473 * one physically contiguous piece each, because both the CPU *and* the 275*2675Szh199473 * I/O device can see them *as though they were*. 276*2675Szh199473 * 277*2675Szh199473 * However, if only physically-addressed DMA is possible, this doesn't 278*2675Szh199473 * work; we can't expect to get enough contiguously-addressed memory for 279*2675Szh199473 * all the buffers of each type, so in this case we request a number of 280*2675Szh199473 * smaller pieces, each still large enough for several buffers but small 281*2675Szh199473 * enough to fit within "an I/O page" (e.g. 64K). 282*2675Szh199473 * 283*2675Szh199473 * The #define below specifies how many pieces of memory are to be used; 284*2675Szh199473 * 16 has been shown to work on an i86pc architecture but this could be 285*2675Szh199473 * different on other non-DVMA platforms ... 286*2675Szh199473 */ 287*2675Szh199473 #ifdef _DMA_USES_VIRTADDR 288*2675Szh199473 #define BGE_SPLIT 1 /* no split required */ 289*2675Szh199473 #else 290*2675Szh199473 #if ((BGE_BUFF_RINGS_USED > 1) || (BGE_SEND_RINGS_USED > 1) || \ 291*2675Szh199473 (BGE_RECV_RINGS_USED > 1)) 292*2675Szh199473 #define BGE_SPLIT 128 /* split 128 ways */ 293*2675Szh199473 #else 294*2675Szh199473 #define BGE_SPLIT 16 /* split 16 ways */ 295*2675Szh199473 #endif 296*2675Szh199473 #endif /* _DMA_USES_VIRTADDR */ 297*2675Szh199473 298*2675Szh199473 #define BGE_RECV_RINGS_SPLIT (BGE_RECV_RINGS_MAX + 1) 299*2675Szh199473 300*2675Szh199473 /* 301*2675Szh199473 * MONOLITHIC allocation is a hardware debugging aid, so that a logic 302*2675Szh199473 * analyser can more easily be programmed with the (single) range of 303*2675Szh199473 * memory addresses that the chip will then use for DMA. 304*2675Szh199473 * 305*2675Szh199473 * It's incompatible with non-DVMA architectures that require BGE_SPLIT 306*2675Szh199473 * to be set greater than 1. Here, it overrides BGE_SPLIT, so the code 307*2675Szh199473 * will compile correctly but will *probably* fail at runtime because it 308*2675Szh199473 * simply won't be able to allocate a big enough piece of memory ... 309*2675Szh199473 */ 310*2675Szh199473 #define BGE_MONOLITHIC 0 311*2675Szh199473 #if BGE_MONOLITHIC 312*2675Szh199473 #undef BGE_SPLIT 313*2675Szh199473 #define BGE_SPLIT 1 /* must be 1 if MONOLITHIC */ 314*2675Szh199473 #endif /* BGE_MONOLITHIC */ 315*2675Szh199473 316*2675Szh199473 /* 317*2675Szh199473 * STREAMS parameters 318*2675Szh199473 */ 319*2675Szh199473 #define BGE_IDNUM 0 /* zero seems to work */ 320*2675Szh199473 #define BGE_LOWAT (256) 321*2675Szh199473 #define BGE_HIWAT (256*1024) 322*2675Szh199473 323*2675Szh199473 324*2675Szh199473 /* 325*2675Szh199473 * Basic data types, for clarity in distinguishing 'numbers' 326*2675Szh199473 * used for different purposes ... 327*2675Szh199473 * 328*2675Szh199473 * A <bge_regno_t> is a register 'address' (offset) in any one of 329*2675Szh199473 * various address spaces (PCI config space, PCI memory-mapped I/O 330*2675Szh199473 * register space, MII registers, etc). None of these exceeds 64K, 331*2675Szh199473 * so we could use a 16-bit representation but pointer-sized objects 332*2675Szh199473 * are more "natural" in most architectures; they seem to be handled 333*2675Szh199473 * more efficiently on SPARC and no worse on x86. 334*2675Szh199473 * 335*2675Szh199473 * BGE_REGNO_NONE represents the non-existent value in this space. 336*2675Szh199473 */ 337*2675Szh199473 typedef uintptr_t bge_regno_t; /* register # (offset) */ 338*2675Szh199473 #define BGE_REGNO_NONE (~(uintptr_t)0u) 339*2675Szh199473 340*2675Szh199473 /* 341*2675Szh199473 * Describes one chunk of allocated DMA-able memory 342*2675Szh199473 * 343*2675Szh199473 * In some cases, this is a single chunk as allocated from the system; 344*2675Szh199473 * but we also use this structure to represent slices carved off such 345*2675Szh199473 * a chunk. Even when we don't really need all the information, we 346*2675Szh199473 * use this structure as a convenient way of correlating the various 347*2675Szh199473 * ways of looking at a piece of memory (kernel VA, IO space DVMA, 348*2675Szh199473 * handle+offset, etc). 349*2675Szh199473 */ 350*2675Szh199473 typedef struct { 351*2675Szh199473 ddi_acc_handle_t acc_hdl; /* handle for memory */ 352*2675Szh199473 void *mem_va; /* CPU VA of memory */ 353*2675Szh199473 uint32_t nslots; /* number of slots */ 354*2675Szh199473 uint32_t size; /* size per slot */ 355*2675Szh199473 size_t alength; /* allocated size */ 356*2675Szh199473 /* >= product of above */ 357*2675Szh199473 358*2675Szh199473 ddi_dma_handle_t dma_hdl; /* DMA handle */ 359*2675Szh199473 offset_t offset; /* relative to handle */ 360*2675Szh199473 ddi_dma_cookie_t cookie; /* associated cookie */ 361*2675Szh199473 uint32_t ncookies; /* must be 1 */ 362*2675Szh199473 uint32_t token; /* arbitrary identifier */ 363*2675Szh199473 } dma_area_t; /* 0x50 (80) bytes */ 364*2675Szh199473 365*2675Szh199473 /* 366*2675Szh199473 * Software version of the Receive Buffer Descriptor 367*2675Szh199473 * There's one of these for each receive buffer (up to 256/512/1024 per ring). 368*2675Szh199473 */ 369*2675Szh199473 typedef struct sw_rbd { 370*2675Szh199473 dma_area_t pbuf; /* (const) related */ 371*2675Szh199473 /* buffer area */ 372*2675Szh199473 } sw_rbd_t; /* 0x50 (80) bytes */ 373*2675Szh199473 374*2675Szh199473 /* 375*2675Szh199473 * Software Receive Buffer (Producer) Ring Control Block 376*2675Szh199473 * There's one of these for each receiver producer ring (up to 3), 377*2675Szh199473 * but each holds buffers of a different size. 378*2675Szh199473 */ 379*2675Szh199473 typedef struct buff_ring { 380*2675Szh199473 dma_area_t desc; /* (const) related h/w */ 381*2675Szh199473 /* descriptor area */ 382*2675Szh199473 dma_area_t buf[BGE_SPLIT]; /* (const) related */ 383*2675Szh199473 /* buffer area(s) */ 384*2675Szh199473 bge_rcb_t hw_rcb; /* (const) image of h/w */ 385*2675Szh199473 /* RCB, and used to */ 386*2675Szh199473 struct bge *bgep; /* (const) containing */ 387*2675Szh199473 /* driver soft state */ 388*2675Szh199473 /* initialise same */ 389*2675Szh199473 volatile uint16_t *cons_index_p; /* (const) ptr to h/w */ 390*2675Szh199473 /* "consumer index" */ 391*2675Szh199473 /* (in status block) */ 392*2675Szh199473 393*2675Szh199473 /* 394*2675Szh199473 * The rf_lock must be held when updating the h/w producer index 395*2675Szh199473 * mailbox register (*chip_mbox_reg), or the s/w producer index 396*2675Szh199473 * (rf_next). 397*2675Szh199473 */ 398*2675Szh199473 bge_regno_t chip_mbx_reg; /* (const) h/w producer */ 399*2675Szh199473 /* index mailbox offset */ 400*2675Szh199473 kmutex_t rf_lock[1]; /* serialize refill */ 401*2675Szh199473 uint64_t rf_next; /* next slot to refill */ 402*2675Szh199473 /* ("producer index") */ 403*2675Szh199473 404*2675Szh199473 sw_rbd_t *sw_rbds; /* software descriptors */ 405*2675Szh199473 void *spare[4]; /* padding */ 406*2675Szh199473 } buff_ring_t; /* 0x100 (256) bytes */ 407*2675Szh199473 408*2675Szh199473 /* 409*2675Szh199473 * Software Receive (Return) Ring Control Block 410*2675Szh199473 * There's one of these for each receiver return ring (up to 16). 411*2675Szh199473 */ 412*2675Szh199473 typedef struct recv_ring { 413*2675Szh199473 /* 414*2675Szh199473 * The elements flagged (const) in the comments below are 415*2675Szh199473 * set up once during initialiation and thereafter unchanged. 416*2675Szh199473 */ 417*2675Szh199473 dma_area_t desc; /* (const) related h/w */ 418*2675Szh199473 /* descriptor area */ 419*2675Szh199473 bge_rcb_t hw_rcb; /* (const) image of h/w */ 420*2675Szh199473 /* RCB, and used to */ 421*2675Szh199473 /* initialise same */ 422*2675Szh199473 struct bge *bgep; /* (const) containing */ 423*2675Szh199473 /* driver soft state */ 424*2675Szh199473 ddi_softintr_t rx_softint; /* (const) per-ring */ 425*2675Szh199473 /* receive callback */ 426*2675Szh199473 volatile uint16_t *prod_index_p; /* (const) ptr to h/w */ 427*2675Szh199473 /* "producer index" */ 428*2675Szh199473 /* (in status block) */ 429*2675Szh199473 430*2675Szh199473 /* 431*2675Szh199473 * The rx_lock must be held when updating the h/w consumer index 432*2675Szh199473 * mailbox register (*chip_mbox_reg), or the s/w consumer index 433*2675Szh199473 * (rx_next). 434*2675Szh199473 */ 435*2675Szh199473 bge_regno_t chip_mbx_reg; /* (const) h/w consumer */ 436*2675Szh199473 /* index mailbox offset */ 437*2675Szh199473 kmutex_t rx_lock[1]; /* serialize receive */ 438*2675Szh199473 uint64_t rx_next; /* next slot to examine */ 439*2675Szh199473 mac_resource_handle_t handle; /* per ring cookie */ 440*2675Szh199473 /* ("producer index") */ 441*2675Szh199473 } recv_ring_t; /* 0x90 (144) bytes */ 442*2675Szh199473 443*2675Szh199473 /* 444*2675Szh199473 * Software version of the Send Buffer Descriptor 445*2675Szh199473 * There's one of these for each send buffer (up to 512 per ring) 446*2675Szh199473 */ 447*2675Szh199473 typedef struct sw_sbd { 448*2675Szh199473 dma_area_t desc; /* (const) related h/w */ 449*2675Szh199473 /* descriptor area */ 450*2675Szh199473 dma_area_t pbuf; /* (const) related */ 451*2675Szh199473 /* buffer area */ 452*2675Szh199473 453*2675Szh199473 void (*recycle)(struct sw_sbd *); 454*2675Szh199473 uint64_t flags; 455*2675Szh199473 456*2675Szh199473 mblk_t *mp; /* related mblk, if any */ 457*2675Szh199473 ddi_dma_handle_t mblk_hdl; /* handle for same */ 458*2675Szh199473 } sw_sbd_t; /* 0xc0 (192) bytes */ 459*2675Szh199473 460*2675Szh199473 #define SW_SBD_FLAG_BUSY 0x0000000000000001 461*2675Szh199473 #define SW_SBD_FLAG_PBUF 0x0000000000000002 462*2675Szh199473 #define SW_SBD_FLAG_BIND 0x0000000000000004 463*2675Szh199473 464*2675Szh199473 /* 465*2675Szh199473 * Software Send Ring Control Block 466*2675Szh199473 * There's one of these for each of (up to) 16 send rings 467*2675Szh199473 */ 468*2675Szh199473 typedef struct send_ring { 469*2675Szh199473 /* 470*2675Szh199473 * The elements flagged (const) in the comments below are 471*2675Szh199473 * set up once during initialiation and thereafter unchanged. 472*2675Szh199473 */ 473*2675Szh199473 dma_area_t desc; /* (const) related h/w */ 474*2675Szh199473 /* descriptor area */ 475*2675Szh199473 dma_area_t buf[BGE_SPLIT]; /* (const) related */ 476*2675Szh199473 /* buffer area(s) */ 477*2675Szh199473 bge_rcb_t hw_rcb; /* (const) image of h/w */ 478*2675Szh199473 /* RCB, and used to */ 479*2675Szh199473 /* initialise same */ 480*2675Szh199473 struct bge *bgep; /* (const) containing */ 481*2675Szh199473 /* driver soft state */ 482*2675Szh199473 volatile uint16_t *cons_index_p; /* (const) ptr to h/w */ 483*2675Szh199473 /* "consumer index" */ 484*2675Szh199473 /* (in status block) */ 485*2675Szh199473 486*2675Szh199473 bge_regno_t chip_mbx_reg; /* (const) h/w producer */ 487*2675Szh199473 /* index mailbox offset */ 488*2675Szh199473 kmutex_t tx_lock[1]; /* serialize h/w update */ 489*2675Szh199473 /* ("producer index") */ 490*2675Szh199473 uint64_t tx_next; /* next slot to use */ 491*2675Szh199473 uint64_t tx_flow; /* # concurrent sends */ 492*2675Szh199473 493*2675Szh199473 /* 494*2675Szh199473 * These counters/indexes are manipulated in the transmit 495*2675Szh199473 * path using atomics rather than mutexes for speed 496*2675Szh199473 */ 497*2675Szh199473 uint64_t tx_free; /* # of slots available */ 498*2675Szh199473 499*2675Szh199473 /* 500*2675Szh199473 * The tc_lock must be held while manipulating the s/w consumer 501*2675Szh199473 * index (tc_next). 502*2675Szh199473 */ 503*2675Szh199473 kmutex_t tc_lock[1]; /* serialize recycle */ 504*2675Szh199473 uint64_t tc_next; /* next slot to recycle */ 505*2675Szh199473 /* ("consumer index") */ 506*2675Szh199473 507*2675Szh199473 sw_sbd_t *sw_sbds; /* software descriptors */ 508*2675Szh199473 uint64_t mac_resid; /* special per resource id */ 509*2675Szh199473 } send_ring_t; /* 0x100 (256) bytes */ 510*2675Szh199473 511*2675Szh199473 typedef struct { 512*2675Szh199473 ether_addr_t addr; /* in canonical form */ 513*2675Szh199473 uint8_t spare; 514*2675Szh199473 boolean_t set; /* B_TRUE => valid */ 515*2675Szh199473 } bge_mac_addr_t; 516*2675Szh199473 517*2675Szh199473 /* 518*2675Szh199473 * The original 5700/01 supported only SEEPROMs. Later chips (5702+) 519*2675Szh199473 * support both SEEPROMs (using the same 2-wire CLK/DATA interface for 520*2675Szh199473 * the hardware and a backwards-compatible software access method), and 521*2675Szh199473 * buffered or unbuffered FLASH devices connected to the 4-wire SPI bus 522*2675Szh199473 * and using a new software access method. 523*2675Szh199473 * 524*2675Szh199473 * The access methods for SEEPROM and Flash are generally similar, with 525*2675Szh199473 * the chip handling the serialisation/deserialisation and handshaking, 526*2675Szh199473 * but the registers used are different, as are a few details of the 527*2675Szh199473 * protocol, and the timing, so we have to determine which (if any) is 528*2675Szh199473 * fitted. 529*2675Szh199473 * 530*2675Szh199473 * The value UNKNOWN means just that; we haven't yet tried to determine 531*2675Szh199473 * the device type. 532*2675Szh199473 * 533*2675Szh199473 * The value NONE can indicate either that a real and definite absence of 534*2675Szh199473 * any NVmem has been detected, or that there may be NVmem but we can't 535*2675Szh199473 * determine its type, perhaps because the NVconfig pins on the chip have 536*2675Szh199473 * been wired up incorrectly. In either case, access to the NVmem (if any) 537*2675Szh199473 * is not supported. 538*2675Szh199473 */ 539*2675Szh199473 enum bge_nvmem_type { 540*2675Szh199473 BGE_NVTYPE_NONE = -1, /* (or indeterminable) */ 541*2675Szh199473 BGE_NVTYPE_UNKNOWN, /* not yet checked */ 542*2675Szh199473 BGE_NVTYPE_SEEPROM, /* BCM5700/5701 only */ 543*2675Szh199473 BGE_NVTYPE_LEGACY_SEEPROM, /* 5702+ */ 544*2675Szh199473 BGE_NVTYPE_UNBUFFERED_FLASH, /* 5702+ */ 545*2675Szh199473 BGE_NVTYPE_BUFFERED_FLASH /* 5702+ */ 546*2675Szh199473 }; 547*2675Szh199473 548*2675Szh199473 /* 549*2675Szh199473 * Describes the characteristics of a specific chip 550*2675Szh199473 * 551*2675Szh199473 * Note: elements from <businfo> to <latency> are filled in by during 552*2675Szh199473 * the first phase of chip initialisation (see bge_chip_cfg_init()). 553*2675Szh199473 * The remaining ones are determined just after the first RESET, in 554*2675Szh199473 * bge_poll_firmware(). Thereafter, the entire structure is readonly. 555*2675Szh199473 */ 556*2675Szh199473 typedef struct { 557*2675Szh199473 uint32_t asic_rev; /* masked from MHCR */ 558*2675Szh199473 uint32_t businfo; /* from private reg */ 559*2675Szh199473 uint16_t command; /* saved during attach */ 560*2675Szh199473 561*2675Szh199473 uint16_t vendor; /* vendor-id */ 562*2675Szh199473 uint16_t device; /* device-id */ 563*2675Szh199473 uint16_t subven; /* subsystem-vendor-id */ 564*2675Szh199473 uint16_t subdev; /* subsystem-id */ 565*2675Szh199473 uint8_t revision; /* revision-id */ 566*2675Szh199473 uint8_t clsize; /* cache-line-size */ 567*2675Szh199473 uint8_t latency; /* latency-timer */ 568*2675Szh199473 569*2675Szh199473 uint8_t flags; 570*2675Szh199473 uint16_t chip_label; /* numeric part only */ 571*2675Szh199473 /* (e.g. 5703/5794/etc) */ 572*2675Szh199473 uint32_t mbuf_base; /* Mbuf pool parameters */ 573*2675Szh199473 uint32_t mbuf_length; /* depend on chiptype */ 574*2675Szh199473 uint32_t pci_type; 575*2675Szh199473 uint32_t statistic_type; 576*2675Szh199473 uint32_t bge_dma_rwctrl; 577*2675Szh199473 uint32_t bge_mlcr_default; 578*2675Szh199473 uint32_t recv_slots; /* receive ring size */ 579*2675Szh199473 enum bge_nvmem_type nvtype; /* SEEPROM or Flash */ 580*2675Szh199473 581*2675Szh199473 uint16_t jumbo_slots; 582*2675Szh199473 uint16_t ethmax_size; 583*2675Szh199473 uint16_t snd_buff_size; 584*2675Szh199473 uint16_t recv_jumbo_size; 585*2675Szh199473 uint16_t std_buf_size; 586*2675Szh199473 uint32_t mbuf_hi_water; 587*2675Szh199473 uint32_t mbuf_lo_water_rmac; 588*2675Szh199473 uint32_t mbuf_lo_water_rdma; 589*2675Szh199473 590*2675Szh199473 uint64_t rx_rings; /* from bge.conf */ 591*2675Szh199473 uint64_t tx_rings; /* from bge.conf */ 592*2675Szh199473 uint64_t default_mtu; /* from bge.conf */ 593*2675Szh199473 594*2675Szh199473 uint64_t hw_mac_addr; /* from chip register */ 595*2675Szh199473 bge_mac_addr_t vendor_addr; /* transform of same */ 596*2675Szh199473 boolean_t msi_enabled; /* default to true */ 597*2675Szh199473 } chip_id_t; 598*2675Szh199473 599*2675Szh199473 #define CHIP_FLAG_SUPPORTED 0x80 600*2675Szh199473 #define CHIP_FLAG_SERDES 0x40 601*2675Szh199473 #define CHIP_FLAG_PARTIAL_CSUM 0x20 602*2675Szh199473 #define CHIP_FLAG_NO_JUMBO 0x1 603*2675Szh199473 604*2675Szh199473 /* 605*2675Szh199473 * Collection of physical-layer functions to: 606*2675Szh199473 * (re)initialise the physical layer 607*2675Szh199473 * update it to match software settings 608*2675Szh199473 * check for link status change 609*2675Szh199473 */ 610*2675Szh199473 typedef struct { 611*2675Szh199473 int (*phys_restart)(struct bge *, boolean_t); 612*2675Szh199473 int (*phys_update)(struct bge *); 613*2675Szh199473 boolean_t (*phys_check)(struct bge *, boolean_t); 614*2675Szh199473 } phys_ops_t; 615*2675Szh199473 616*2675Szh199473 /* 617*2675Szh199473 * Named Data (ND) Parameter Management Structure 618*2675Szh199473 */ 619*2675Szh199473 typedef struct { 620*2675Szh199473 int ndp_info; 621*2675Szh199473 int ndp_min; 622*2675Szh199473 int ndp_max; 623*2675Szh199473 int ndp_val; 624*2675Szh199473 char *ndp_name; 625*2675Szh199473 } nd_param_t; /* 0x18 (24) bytes */ 626*2675Szh199473 627*2675Szh199473 /* 628*2675Szh199473 * NDD parameter indexes, divided into: 629*2675Szh199473 * 630*2675Szh199473 * read-only parameters describing the hardware's capabilities 631*2675Szh199473 * read-write parameters controlling the advertised capabilities 632*2675Szh199473 * read-only parameters describing the partner's capabilities 633*2675Szh199473 * read-only parameters describing the link state 634*2675Szh199473 */ 635*2675Szh199473 enum { 636*2675Szh199473 PARAM_AUTONEG_CAP, 637*2675Szh199473 PARAM_PAUSE_CAP, 638*2675Szh199473 PARAM_ASYM_PAUSE_CAP, 639*2675Szh199473 PARAM_1000FDX_CAP, 640*2675Szh199473 PARAM_1000HDX_CAP, 641*2675Szh199473 PARAM_100T4_CAP, 642*2675Szh199473 PARAM_100FDX_CAP, 643*2675Szh199473 PARAM_100HDX_CAP, 644*2675Szh199473 PARAM_10FDX_CAP, 645*2675Szh199473 PARAM_10HDX_CAP, 646*2675Szh199473 647*2675Szh199473 PARAM_ADV_AUTONEG_CAP, 648*2675Szh199473 PARAM_ADV_PAUSE_CAP, 649*2675Szh199473 PARAM_ADV_ASYM_PAUSE_CAP, 650*2675Szh199473 PARAM_ADV_1000FDX_CAP, 651*2675Szh199473 PARAM_ADV_1000HDX_CAP, 652*2675Szh199473 PARAM_ADV_100T4_CAP, 653*2675Szh199473 PARAM_ADV_100FDX_CAP, 654*2675Szh199473 PARAM_ADV_100HDX_CAP, 655*2675Szh199473 PARAM_ADV_10FDX_CAP, 656*2675Szh199473 PARAM_ADV_10HDX_CAP, 657*2675Szh199473 658*2675Szh199473 PARAM_LP_AUTONEG_CAP, 659*2675Szh199473 PARAM_LP_PAUSE_CAP, 660*2675Szh199473 PARAM_LP_ASYM_PAUSE_CAP, 661*2675Szh199473 PARAM_LP_1000FDX_CAP, 662*2675Szh199473 PARAM_LP_1000HDX_CAP, 663*2675Szh199473 PARAM_LP_100T4_CAP, 664*2675Szh199473 PARAM_LP_100FDX_CAP, 665*2675Szh199473 PARAM_LP_100HDX_CAP, 666*2675Szh199473 PARAM_LP_10FDX_CAP, 667*2675Szh199473 PARAM_LP_10HDX_CAP, 668*2675Szh199473 669*2675Szh199473 PARAM_LINK_STATUS, 670*2675Szh199473 PARAM_LINK_SPEED, 671*2675Szh199473 PARAM_LINK_DUPLEX, 672*2675Szh199473 673*2675Szh199473 PARAM_LINK_AUTONEG, 674*2675Szh199473 PARAM_LINK_RX_PAUSE, 675*2675Szh199473 PARAM_LINK_TX_PAUSE, 676*2675Szh199473 677*2675Szh199473 PARAM_LOOP_MODE, 678*2675Szh199473 PARAM_MSI_CNT, 679*2675Szh199473 680*2675Szh199473 PARAM_COUNT 681*2675Szh199473 }; 682*2675Szh199473 683*2675Szh199473 /* 684*2675Szh199473 * Actual state of the BCM570x chip 685*2675Szh199473 */ 686*2675Szh199473 enum bge_chip_state { 687*2675Szh199473 BGE_CHIP_FAULT = -2, /* fault, need reset */ 688*2675Szh199473 BGE_CHIP_ERROR, /* error, want reset */ 689*2675Szh199473 BGE_CHIP_INITIAL, /* Initial state only */ 690*2675Szh199473 BGE_CHIP_RESET, /* reset, need init */ 691*2675Szh199473 BGE_CHIP_STOPPED, /* Tx/Rx stopped */ 692*2675Szh199473 BGE_CHIP_RUNNING /* with interrupts */ 693*2675Szh199473 }; 694*2675Szh199473 695*2675Szh199473 enum bge_mac_state { 696*2675Szh199473 BGE_MAC_STOPPED = 0, 697*2675Szh199473 BGE_MAC_STARTED 698*2675Szh199473 }; 699*2675Szh199473 700*2675Szh199473 /* 701*2675Szh199473 * (Internal) return values from ioctl subroutines 702*2675Szh199473 */ 703*2675Szh199473 enum ioc_reply { 704*2675Szh199473 IOC_INVAL = -1, /* bad, NAK with EINVAL */ 705*2675Szh199473 IOC_DONE, /* OK, reply sent */ 706*2675Szh199473 IOC_ACK, /* OK, just send ACK */ 707*2675Szh199473 IOC_REPLY, /* OK, just send reply */ 708*2675Szh199473 IOC_RESTART_ACK, /* OK, restart & ACK */ 709*2675Szh199473 IOC_RESTART_REPLY /* OK, restart & reply */ 710*2675Szh199473 }; 711*2675Szh199473 712*2675Szh199473 /* 713*2675Szh199473 * (Internal) return values from send_msg subroutines 714*2675Szh199473 */ 715*2675Szh199473 enum send_status { 716*2675Szh199473 SEND_FAIL = -1, /* Not OK */ 717*2675Szh199473 SEND_KEEP, /* OK, msg queued */ 718*2675Szh199473 SEND_FREE /* OK, free msg */ 719*2675Szh199473 }; 720*2675Szh199473 721*2675Szh199473 /* 722*2675Szh199473 * (Internal) enumeration of this driver's kstats 723*2675Szh199473 */ 724*2675Szh199473 enum { 725*2675Szh199473 BGE_KSTAT_RAW = 0, 726*2675Szh199473 BGE_KSTAT_STATS, 727*2675Szh199473 BGE_KSTAT_PARAMS, 728*2675Szh199473 BGE_KSTAT_CHIPID, 729*2675Szh199473 BGE_KSTAT_DRIVER, 730*2675Szh199473 BGE_KSTAT_PHYS, 731*2675Szh199473 BGE_KSTAT_MII, 732*2675Szh199473 733*2675Szh199473 BGE_KSTAT_COUNT 734*2675Szh199473 }; 735*2675Szh199473 736*2675Szh199473 #define BGE_MAX_RESOURCES 255 737*2675Szh199473 738*2675Szh199473 /* 739*2675Szh199473 * Per-instance soft-state structure 740*2675Szh199473 */ 741*2675Szh199473 typedef struct bge { 742*2675Szh199473 /* 743*2675Szh199473 * These fields are set by attach() and unchanged thereafter ... 744*2675Szh199473 */ 745*2675Szh199473 dev_info_t *devinfo; /* device instance */ 746*2675Szh199473 mac_handle_t mh; /* mac module handle */ 747*2675Szh199473 ddi_acc_handle_t cfg_handle; /* DDI I/O handle */ 748*2675Szh199473 ddi_acc_handle_t io_handle; /* DDI I/O handle */ 749*2675Szh199473 void *io_regs; /* mapped registers */ 750*2675Szh199473 cyclic_id_t cyclic_id; /* cyclic callback */ 751*2675Szh199473 ddi_softintr_t factotum_id; /* factotum callback */ 752*2675Szh199473 ddi_softintr_t resched_id; /* reschedule callback */ 753*2675Szh199473 754*2675Szh199473 ddi_intr_handle_t *htable; /* For array of interrupts */ 755*2675Szh199473 int intr_type; /* What type of interrupt */ 756*2675Szh199473 int intr_cnt; /* # of intrs count returned */ 757*2675Szh199473 uint_t intr_pri; /* Interrupt priority */ 758*2675Szh199473 int intr_cap; /* Interrupt capabilities */ 759*2675Szh199473 uint32_t progress; /* attach tracking */ 760*2675Szh199473 uint32_t debug; /* per-instance debug */ 761*2675Szh199473 chip_id_t chipid; 762*2675Szh199473 const phys_ops_t *physops; 763*2675Szh199473 char ifname[8]; /* "bge0" ... "bge999" */ 764*2675Szh199473 765*2675Szh199473 int fm_capabilities; /* FMA capabilities */ 766*2675Szh199473 767*2675Szh199473 /* 768*2675Szh199473 * These structures describe the blocks of memory allocated during 769*2675Szh199473 * attach(). They remain unchanged thereafter, although the memory 770*2675Szh199473 * they describe is carved up into various separate regions and may 771*2675Szh199473 * therefore be described by other structures as well. 772*2675Szh199473 */ 773*2675Szh199473 dma_area_t tx_desc; /* transmit descriptors */ 774*2675Szh199473 dma_area_t rx_desc[BGE_RECV_RINGS_SPLIT]; 775*2675Szh199473 /* receive descriptors */ 776*2675Szh199473 dma_area_t tx_buff[BGE_SPLIT]; 777*2675Szh199473 dma_area_t rx_buff[BGE_SPLIT]; 778*2675Szh199473 779*2675Szh199473 /* 780*2675Szh199473 * The memory described by the <dma_area> structures above 781*2675Szh199473 * is carved up into various pieces, which are described by 782*2675Szh199473 * the structures below. 783*2675Szh199473 */ 784*2675Szh199473 dma_area_t statistics; /* describes hardware */ 785*2675Szh199473 /* statistics area */ 786*2675Szh199473 dma_area_t status_block; /* describes hardware */ 787*2675Szh199473 /* status block */ 788*2675Szh199473 /* 789*2675Szh199473 * For the BCM5705/5788/5721/5751/5752/5714 and 5715, 790*2675Szh199473 * the statistic block is not available,the statistic counter must 791*2675Szh199473 * be gotten from statistic registers.And bge_statistics_reg_t record 792*2675Szh199473 * the statistic registers value 793*2675Szh199473 */ 794*2675Szh199473 bge_statistics_reg_t stat_val; 795*2675Szh199473 796*2675Szh199473 /* 797*2675Szh199473 * Runtime read-write data starts here ... 798*2675Szh199473 * 799*2675Szh199473 * 3 Buffer Rings (std/jumbo/mini) 800*2675Szh199473 * 16 Receive (Return) Rings 801*2675Szh199473 * 16 Send Rings 802*2675Szh199473 * 803*2675Szh199473 * Note: they're not necessarily all used. 804*2675Szh199473 */ 805*2675Szh199473 buff_ring_t buff[BGE_BUFF_RINGS_MAX]; /* 3*0x0100 */ 806*2675Szh199473 recv_ring_t recv[BGE_RECV_RINGS_MAX]; /* 16*0x0090 */ 807*2675Szh199473 send_ring_t send[BGE_SEND_RINGS_MAX]; /* 16*0x0100 */ 808*2675Szh199473 809*2675Szh199473 /* 810*2675Szh199473 * Locks: 811*2675Szh199473 * 812*2675Szh199473 * Each buffer ring contains its own <rf_lock> which regulates 813*2675Szh199473 * ring refilling. 814*2675Szh199473 * 815*2675Szh199473 * Each receive (return) ring contains its own <rx_lock> which 816*2675Szh199473 * protects the critical cyclic counters etc. 817*2675Szh199473 * 818*2675Szh199473 * Each send ring contains two locks: <tx_lock> for the send-path 819*2675Szh199473 * protocol data and <tc_lock> for send-buffer recycling. 820*2675Szh199473 * 821*2675Szh199473 * Finally <genlock> is a general lock, protecting most other 822*2675Szh199473 * operational data in the state structure and chip register 823*2675Szh199473 * accesses. It is acquired by the interrupt handler and 824*2675Szh199473 * most "mode-control" routines. 825*2675Szh199473 * 826*2675Szh199473 * Any of the locks can be acquired singly, but where multiple 827*2675Szh199473 * locks are acquired, they *must* be in the order: 828*2675Szh199473 * 829*2675Szh199473 * genlock >>> rx_lock >>> rf_lock >>> tx_lock >>> tc_lock. 830*2675Szh199473 * 831*2675Szh199473 * and within any one class of lock the rings must be locked in 832*2675Szh199473 * ascending order (send[0].tc_lock >>> send[1].tc_lock), etc. 833*2675Szh199473 * 834*2675Szh199473 * Note: actually I don't believe there's any need to acquire 835*2675Szh199473 * locks on multiple rings, or even locks of all these classes 836*2675Szh199473 * concurrently; but I've set out the above order so there is a 837*2675Szh199473 * clear definition of lock hierarchy in case it's ever needed. 838*2675Szh199473 * 839*2675Szh199473 * Note: the combinations of locks that are actually held 840*2675Szh199473 * concurrently are: 841*2675Szh199473 * 842*2675Szh199473 * genlock >>> (bge_chip_interrupt()) 843*2675Szh199473 * rx_lock[i] >>> (bge_receive()) 844*2675Szh199473 * rf_lock[n] (bge_refill()) 845*2675Szh199473 * tc_lock[i] (bge_recycle()) 846*2675Szh199473 */ 847*2675Szh199473 kmutex_t genlock[1]; 848*2675Szh199473 krwlock_t errlock[1]; 849*2675Szh199473 kmutex_t softintrlock[1]; 850*2675Szh199473 851*2675Szh199473 /* 852*2675Szh199473 * Current Ethernet addresses and multicast hash (bitmap) and 853*2675Szh199473 * refcount tables, protected by <genlock> 854*2675Szh199473 */ 855*2675Szh199473 bge_mac_addr_t curr_addr[MAC_ADDRESS_REGS_MAX]; 856*2675Szh199473 uint32_t mcast_hash[BGE_HASH_TABLE_SIZE/32]; 857*2675Szh199473 uint8_t mcast_refs[BGE_HASH_TABLE_SIZE]; 858*2675Szh199473 uint32_t unicst_addr_total; /* total unicst addresses */ 859*2675Szh199473 uint32_t unicst_addr_avail; 860*2675Szh199473 /* unused unicst addr slots */ 861*2675Szh199473 862*2675Szh199473 /* 863*2675Szh199473 * Link state data (protected by genlock) 864*2675Szh199473 */ 865*2675Szh199473 const char *link_mode_msg; /* describes link mode */ 866*2675Szh199473 const char *link_down_msg; /* reason for link DOWN */ 867*2675Szh199473 const char *link_up_msg; /* comment on link UP */ 868*2675Szh199473 869*2675Szh199473 link_state_t link_state; 870*2675Szh199473 871*2675Szh199473 /* 872*2675Szh199473 * Physical layer (PHY/SerDes) state data (protected by genlock) 873*2675Szh199473 */ 874*2675Szh199473 hrtime_t phys_write_time; /* when last written */ 875*2675Szh199473 hrtime_t phys_event_time; /* when status changed */ 876*2675Szh199473 hrtime_t phys_delta_time; /* time to settle */ 877*2675Szh199473 878*2675Szh199473 /* 879*2675Szh199473 * Physical layer: copper only 880*2675Szh199473 */ 881*2675Szh199473 bge_regno_t phy_mii_addr; /* should be (const) 1! */ 882*2675Szh199473 uint16_t phy_gen_status; 883*2675Szh199473 uint16_t phy_aux_status; 884*2675Szh199473 885*2675Szh199473 /* 886*2675Szh199473 * Physical layer: serdes only 887*2675Szh199473 */ 888*2675Szh199473 uint32_t serdes_status; 889*2675Szh199473 uint32_t serdes_advert; 890*2675Szh199473 uint32_t serdes_lpadv; 891*2675Szh199473 892*2675Szh199473 /* 893*2675Szh199473 * Driver kstats, protected by <genlock> where necessary 894*2675Szh199473 */ 895*2675Szh199473 kstat_t *bge_kstats[BGE_KSTAT_COUNT]; 896*2675Szh199473 897*2675Szh199473 /* 898*2675Szh199473 * Miscellaneous operating variables (protected by genlock) 899*2675Szh199473 */ 900*2675Szh199473 uint64_t chip_resets; /* # of chip RESETs */ 901*2675Szh199473 uint64_t missed_dmas; /* # of missed DMAs */ 902*2675Szh199473 enum bge_mac_state bge_mac_state; /* definitions above */ 903*2675Szh199473 enum bge_chip_state bge_chip_state; /* definitions above */ 904*2675Szh199473 boolean_t send_hw_tcp_csum; 905*2675Szh199473 boolean_t recv_hw_tcp_csum; 906*2675Szh199473 boolean_t promisc; 907*2675Szh199473 908*2675Szh199473 /* 909*2675Szh199473 * Miscellaneous operating variables (not synchronised) 910*2675Szh199473 */ 911*2675Szh199473 uint32_t watchdog; /* watches for Tx stall */ 912*2675Szh199473 boolean_t bge_intr_running; 913*2675Szh199473 boolean_t bge_dma_error; 914*2675Szh199473 boolean_t resched_needed; 915*2675Szh199473 boolean_t resched_running; 916*2675Szh199473 uint32_t factotum_flag; /* softint pending */ 917*2675Szh199473 uintptr_t pagemask; 918*2675Szh199473 919*2675Szh199473 /* 920*2675Szh199473 * NDD parameters (protected by genlock) 921*2675Szh199473 */ 922*2675Szh199473 caddr_t nd_data_p; 923*2675Szh199473 nd_param_t nd_params[PARAM_COUNT]; 924*2675Szh199473 925*2675Szh199473 uintptr_t resmap[BGE_MAX_RESOURCES]; 926*2675Szh199473 927*2675Szh199473 /* 928*2675Szh199473 * A flag to prevent excessive config space accesses 929*2675Szh199473 * on platforms having BCM5714C/15C 930*2675Szh199473 */ 931*2675Szh199473 boolean_t lastWriteZeroData; 932*2675Szh199473 933*2675Szh199473 /* 934*2675Szh199473 * Spare space, plus guard element used to check data integrity 935*2675Szh199473 */ 936*2675Szh199473 uint64_t spare[5]; 937*2675Szh199473 uint64_t bge_guard; 938*2675Szh199473 939*2675Szh199473 /* 940*2675Szh199473 * Receive rules configure 941*2675Szh199473 */ 942*2675Szh199473 bge_recv_rule_t recv_rules[RECV_RULES_NUM_MAX]; 943*2675Szh199473 944*2675Szh199473 #ifdef BGE_IPMI_ASF 945*2675Szh199473 boolean_t asf_enabled; 946*2675Szh199473 boolean_t asf_wordswapped; 947*2675Szh199473 boolean_t asf_newhandshake; 948*2675Szh199473 boolean_t asf_pseudostop; 949*2675Szh199473 950*2675Szh199473 uint32_t asf_status; 951*2675Szh199473 timeout_id_t asf_timeout_id; 952*2675Szh199473 #endif 953*2675Szh199473 } bge_t; 954*2675Szh199473 955*2675Szh199473 /* 956*2675Szh199473 * 'Progress' bit flags ... 957*2675Szh199473 */ 958*2675Szh199473 #define PROGRESS_CFG 0x0001 /* config space mapped */ 959*2675Szh199473 #define PROGRESS_REGS 0x0002 /* registers mapped */ 960*2675Szh199473 #define PROGRESS_BUFS 0x0004 /* ring buffers allocated */ 961*2675Szh199473 #define PROGRESS_RESCHED 0x0010 /* resched softint registered */ 962*2675Szh199473 #define PROGRESS_FACTOTUM 0x0020 /* factotum softint registered */ 963*2675Szh199473 #define PROGRESS_HWINT 0x0040 /* h/w interrupt registered */ 964*2675Szh199473 /* and mutexen initialised */ 965*2675Szh199473 #define PROGRESS_INTR 0x0080 /* Intrs enabled */ 966*2675Szh199473 #define PROGRESS_PHY 0x0100 /* PHY initialised */ 967*2675Szh199473 #define PROGRESS_NDD 0x1000 /* NDD parameters set up */ 968*2675Szh199473 #define PROGRESS_KSTATS 0x2000 /* kstats created */ 969*2675Szh199473 #define PROGRESS_READY 0x8000 /* ready for work */ 970*2675Szh199473 971*2675Szh199473 /* 972*2675Szh199473 * Shorthand for the NDD parameters 973*2675Szh199473 */ 974*2675Szh199473 #define param_adv_autoneg nd_params[PARAM_ADV_AUTONEG_CAP].ndp_val 975*2675Szh199473 #define param_adv_pause nd_params[PARAM_ADV_PAUSE_CAP].ndp_val 976*2675Szh199473 #define param_adv_asym_pause nd_params[PARAM_ADV_ASYM_PAUSE_CAP].ndp_val 977*2675Szh199473 #define param_adv_1000fdx nd_params[PARAM_ADV_1000FDX_CAP].ndp_val 978*2675Szh199473 #define param_adv_1000hdx nd_params[PARAM_ADV_1000HDX_CAP].ndp_val 979*2675Szh199473 #define param_adv_100fdx nd_params[PARAM_ADV_100FDX_CAP].ndp_val 980*2675Szh199473 #define param_adv_100hdx nd_params[PARAM_ADV_100HDX_CAP].ndp_val 981*2675Szh199473 #define param_adv_10fdx nd_params[PARAM_ADV_10FDX_CAP].ndp_val 982*2675Szh199473 #define param_adv_10hdx nd_params[PARAM_ADV_10HDX_CAP].ndp_val 983*2675Szh199473 984*2675Szh199473 #define param_lp_autoneg nd_params[PARAM_LP_AUTONEG_CAP].ndp_val 985*2675Szh199473 #define param_lp_pause nd_params[PARAM_LP_PAUSE_CAP].ndp_val 986*2675Szh199473 #define param_lp_asym_pause nd_params[PARAM_LP_ASYM_PAUSE_CAP].ndp_val 987*2675Szh199473 #define param_lp_1000fdx nd_params[PARAM_LP_1000FDX_CAP].ndp_val 988*2675Szh199473 #define param_lp_1000hdx nd_params[PARAM_LP_1000HDX_CAP].ndp_val 989*2675Szh199473 #define param_lp_100fdx nd_params[PARAM_LP_100FDX_CAP].ndp_val 990*2675Szh199473 #define param_lp_100hdx nd_params[PARAM_LP_100HDX_CAP].ndp_val 991*2675Szh199473 #define param_lp_10fdx nd_params[PARAM_LP_10FDX_CAP].ndp_val 992*2675Szh199473 #define param_lp_10hdx nd_params[PARAM_LP_10HDX_CAP].ndp_val 993*2675Szh199473 994*2675Szh199473 #define param_link_up nd_params[PARAM_LINK_STATUS].ndp_val 995*2675Szh199473 #define param_link_speed nd_params[PARAM_LINK_SPEED].ndp_val 996*2675Szh199473 #define param_link_duplex nd_params[PARAM_LINK_DUPLEX].ndp_val 997*2675Szh199473 998*2675Szh199473 #define param_link_autoneg nd_params[PARAM_LINK_AUTONEG].ndp_val 999*2675Szh199473 #define param_link_rx_pause nd_params[PARAM_LINK_RX_PAUSE].ndp_val 1000*2675Szh199473 #define param_link_tx_pause nd_params[PARAM_LINK_TX_PAUSE].ndp_val 1001*2675Szh199473 1002*2675Szh199473 #define param_loop_mode nd_params[PARAM_LOOP_MODE].ndp_val 1003*2675Szh199473 #define param_msi_cnt nd_params[PARAM_MSI_CNT].ndp_val 1004*2675Szh199473 1005*2675Szh199473 /* 1006*2675Szh199473 * Sync a DMA area described by a dma_area_t 1007*2675Szh199473 */ 1008*2675Szh199473 #define DMA_SYNC(area, flag) ((void) ddi_dma_sync((area).dma_hdl, \ 1009*2675Szh199473 (area).offset, (area).alength, (flag))) 1010*2675Szh199473 1011*2675Szh199473 /* 1012*2675Szh199473 * Find the (kernel virtual) address of block of memory 1013*2675Szh199473 * described by a dma_area_t 1014*2675Szh199473 */ 1015*2675Szh199473 #define DMA_VPTR(area) ((area).mem_va) 1016*2675Szh199473 1017*2675Szh199473 /* 1018*2675Szh199473 * Zero a block of memory described by a dma_area_t 1019*2675Szh199473 */ 1020*2675Szh199473 #define DMA_ZERO(area) bzero(DMA_VPTR(area), (area).alength) 1021*2675Szh199473 1022*2675Szh199473 /* 1023*2675Szh199473 * Next value of a cyclic index 1024*2675Szh199473 */ 1025*2675Szh199473 #define NEXT(index, limit) ((index)+1 < (limit) ? (index)+1 : 0); 1026*2675Szh199473 1027*2675Szh199473 /* 1028*2675Szh199473 * Property lookups 1029*2675Szh199473 */ 1030*2675Szh199473 #define BGE_PROP_EXISTS(d, n) ddi_prop_exists(DDI_DEV_T_ANY, (d), \ 1031*2675Szh199473 DDI_PROP_DONTPASS, (n)) 1032*2675Szh199473 #define BGE_PROP_GET_INT(d, n) ddi_prop_get_int(DDI_DEV_T_ANY, (d), \ 1033*2675Szh199473 DDI_PROP_DONTPASS, (n), -1) 1034*2675Szh199473 1035*2675Szh199473 /* 1036*2675Szh199473 * Copy an ethernet address 1037*2675Szh199473 */ 1038*2675Szh199473 #define ethaddr_copy(src, dst) bcopy((src), (dst), ETHERADDRL) 1039*2675Szh199473 1040*2675Szh199473 /* 1041*2675Szh199473 * Endian swap 1042*2675Szh199473 */ 1043*2675Szh199473 /* BEGIN CSTYLED */ 1044*2675Szh199473 #define BGE_BSWAP_32(x) ((((x) & 0xff000000) >> 24) | \ 1045*2675Szh199473 (((x) & 0x00ff0000) >> 8) | \ 1046*2675Szh199473 (((x) & 0x0000ff00) << 8) | \ 1047*2675Szh199473 (((x) & 0x000000ff) << 24)) 1048*2675Szh199473 /* END CSTYLED */ 1049*2675Szh199473 1050*2675Szh199473 /* 1051*2675Szh199473 * Marker value placed at the end of the driver's state 1052*2675Szh199473 */ 1053*2675Szh199473 #define BGE_GUARD 0x1919306009031802 1054*2675Szh199473 1055*2675Szh199473 /* 1056*2675Szh199473 * Bit flags in the 'debug' word ... 1057*2675Szh199473 */ 1058*2675Szh199473 #define BGE_DBG_STOP 0x00000001 /* early debug_enter() */ 1059*2675Szh199473 #define BGE_DBG_TRACE 0x00000002 /* general flow tracing */ 1060*2675Szh199473 1061*2675Szh199473 #define BGE_DBG_REGS 0x00000010 /* low-level accesses */ 1062*2675Szh199473 #define BGE_DBG_MII 0x00000020 /* low-level MII access */ 1063*2675Szh199473 #define BGE_DBG_SEEPROM 0x00000040 /* low-level SEEPROM IO */ 1064*2675Szh199473 #define BGE_DBG_CHIP 0x00000080 /* low(ish)-level code */ 1065*2675Szh199473 1066*2675Szh199473 #define BGE_DBG_RECV 0x00000100 /* receive-side code */ 1067*2675Szh199473 #define BGE_DBG_SEND 0x00000200 /* packet-send code */ 1068*2675Szh199473 1069*2675Szh199473 #define BGE_DBG_INT 0x00001000 /* interrupt handler */ 1070*2675Szh199473 #define BGE_DBG_FACT 0x00002000 /* factotum (softint) */ 1071*2675Szh199473 1072*2675Szh199473 #define BGE_DBG_PHY 0x00010000 /* Copper PHY code */ 1073*2675Szh199473 #define BGE_DBG_SERDES 0x00020000 /* SerDes code */ 1074*2675Szh199473 #define BGE_DBG_PHYS 0x00040000 /* Physical layer code */ 1075*2675Szh199473 #define BGE_DBG_LINK 0x00080000 /* Link status check */ 1076*2675Szh199473 1077*2675Szh199473 #define BGE_DBG_INIT 0x00100000 /* initialisation */ 1078*2675Szh199473 #define BGE_DBG_NEMO 0x00200000 /* nemo interaction */ 1079*2675Szh199473 #define BGE_DBG_ADDR 0x00400000 /* address-setting code */ 1080*2675Szh199473 #define BGE_DBG_STATS 0x00800000 /* statistics */ 1081*2675Szh199473 1082*2675Szh199473 #define BGE_DBG_IOCTL 0x01000000 /* ioctl handling */ 1083*2675Szh199473 #define BGE_DBG_LOOP 0x02000000 /* loopback ioctl code */ 1084*2675Szh199473 #define BGE_DBG_PPIO 0x04000000 /* Peek/poke ioctls */ 1085*2675Szh199473 #define BGE_DBG_BADIOC 0x08000000 /* unknown ioctls */ 1086*2675Szh199473 1087*2675Szh199473 #define BGE_DBG_MCTL 0x10000000 /* mctl (csum) code */ 1088*2675Szh199473 #define BGE_DBG_NDD 0x20000000 /* NDD operations */ 1089*2675Szh199473 1090*2675Szh199473 /* 1091*2675Szh199473 * Debugging ... 1092*2675Szh199473 */ 1093*2675Szh199473 #ifdef DEBUG 1094*2675Szh199473 #define BGE_DEBUGGING 1 1095*2675Szh199473 #else 1096*2675Szh199473 #define BGE_DEBUGGING 0 1097*2675Szh199473 #endif /* DEBUG */ 1098*2675Szh199473 1099*2675Szh199473 1100*2675Szh199473 /* 1101*2675Szh199473 * 'Do-if-debugging' macro. The parameter <command> should be one or more 1102*2675Szh199473 * C statements (but without the *final* semicolon), which will either be 1103*2675Szh199473 * compiled inline or completely ignored, depending on the BGE_DEBUGGING 1104*2675Szh199473 * compile-time flag. 1105*2675Szh199473 * 1106*2675Szh199473 * You should get a compile-time error (at least on a DEBUG build) if 1107*2675Szh199473 * your statement isn't actually a statement, rather than unexpected 1108*2675Szh199473 * run-time behaviour caused by unintended matching of if-then-elses etc. 1109*2675Szh199473 * 1110*2675Szh199473 * Note that the BGE_DDB() macro itself can only be used as a statement, 1111*2675Szh199473 * not an expression, and should always be followed by a semicolon. 1112*2675Szh199473 */ 1113*2675Szh199473 #if BGE_DEBUGGING 1114*2675Szh199473 #define BGE_DDB(command) do { \ 1115*2675Szh199473 { command; } \ 1116*2675Szh199473 _NOTE(CONSTANTCONDITION) \ 1117*2675Szh199473 } while (0) 1118*2675Szh199473 #else /* BGE_DEBUGGING */ 1119*2675Szh199473 #define BGE_DDB(command) do { \ 1120*2675Szh199473 { _NOTE(EMPTY); } \ 1121*2675Szh199473 _NOTE(CONSTANTCONDITION) \ 1122*2675Szh199473 } while (0) 1123*2675Szh199473 #endif /* BGE_DEBUGGING */ 1124*2675Szh199473 1125*2675Szh199473 /* 1126*2675Szh199473 * 'Internal' macros used to construct the TRACE/DEBUG macros below. 1127*2675Szh199473 * These provide the primitive conditional-call capability required. 1128*2675Szh199473 * Note: the parameter <args> is a parenthesised list of the actual 1129*2675Szh199473 * printf-style arguments to be passed to the debug function ... 1130*2675Szh199473 */ 1131*2675Szh199473 #define BGE_XDB(b, w, f, args) BGE_DDB(if ((b) & (w)) f args) 1132*2675Szh199473 #define BGE_GDB(b, args) BGE_XDB(b, bge_debug, (*bge_gdb()), args) 1133*2675Szh199473 #define BGE_LDB(b, args) BGE_XDB(b, bgep->debug, (*bge_db(bgep)), args) 1134*2675Szh199473 #define BGE_CDB(f, args) BGE_XDB(BGE_DBG, bgep->debug, f, args) 1135*2675Szh199473 1136*2675Szh199473 /* 1137*2675Szh199473 * Conditional-print macros. 1138*2675Szh199473 * 1139*2675Szh199473 * Define BGE_DBG to be the relevant member of the set of BGE_DBG_* values 1140*2675Szh199473 * above before using the BGE_GDEBUG() or BGE_DEBUG() macros. The 'G' 1141*2675Szh199473 * versions look at the Global debug flag word (bge_debug); the non-G 1142*2675Szh199473 * versions look in the per-instance data (bgep->debug) and so require a 1143*2675Szh199473 * variable called 'bgep' to be in scope (and initialised!) before use. 1144*2675Szh199473 * 1145*2675Szh199473 * You could redefine BGE_TRC too if you really need two different 1146*2675Szh199473 * flavours of debugging output in the same area of code, but I don't 1147*2675Szh199473 * really recommend it. 1148*2675Szh199473 * 1149*2675Szh199473 * Note: the parameter <args> is a parenthesised list of the actual 1150*2675Szh199473 * arguments to be passed to the debug function, usually a printf-style 1151*2675Szh199473 * format string and corresponding values to be formatted. 1152*2675Szh199473 */ 1153*2675Szh199473 1154*2675Szh199473 #define BGE_TRC BGE_DBG_TRACE /* default 'trace' bit */ 1155*2675Szh199473 #define BGE_GTRACE(args) BGE_GDB(BGE_TRC, args) 1156*2675Szh199473 #define BGE_GDEBUG(args) BGE_GDB(BGE_DBG, args) 1157*2675Szh199473 #define BGE_TRACE(args) BGE_LDB(BGE_TRC, args) 1158*2675Szh199473 #define BGE_DEBUG(args) BGE_LDB(BGE_DBG, args) 1159*2675Szh199473 1160*2675Szh199473 /* 1161*2675Szh199473 * Debug-only action macros 1162*2675Szh199473 */ 1163*2675Szh199473 #define BGE_BRKPT(bgep, s) BGE_DDB(bge_dbg_enter(bgep, s)) 1164*2675Szh199473 #define BGE_MARK(bgep) BGE_DDB(bge_led_mark(bgep)) 1165*2675Szh199473 #define BGE_PCICHK(bgep) BGE_DDB(bge_pci_check(bgep)) 1166*2675Szh199473 #define BGE_PKTDUMP(args) BGE_DDB(bge_pkt_dump args) 1167*2675Szh199473 #define BGE_REPORT(args) BGE_DDB(bge_log args) 1168*2675Szh199473 1169*2675Szh199473 /* 1170*2675Szh199473 * Inter-source-file linkage ... 1171*2675Szh199473 */ 1172*2675Szh199473 1173*2675Szh199473 /* bge_chip.c */ 1174*2675Szh199473 uint16_t bge_mii_get16(bge_t *bgep, bge_regno_t regno); 1175*2675Szh199473 void bge_mii_put16(bge_t *bgep, bge_regno_t regno, uint16_t value); 1176*2675Szh199473 uint32_t bge_reg_get32(bge_t *bgep, bge_regno_t regno); 1177*2675Szh199473 void bge_reg_put32(bge_t *bgep, bge_regno_t regno, uint32_t value); 1178*2675Szh199473 void bge_reg_set32(bge_t *bgep, bge_regno_t regno, uint32_t bits); 1179*2675Szh199473 void bge_reg_clr32(bge_t *bgep, bge_regno_t regno, uint32_t bits); 1180*2675Szh199473 void bge_mbx_put(bge_t *bgep, bge_regno_t regno, uint64_t value); 1181*2675Szh199473 void bge_chip_cfg_init(bge_t *bgep, chip_id_t *cidp, boolean_t enable_dma); 1182*2675Szh199473 int bge_chip_id_init(bge_t *bgep); 1183*2675Szh199473 int bge_chip_start(bge_t *bgep, boolean_t reset_phy); 1184*2675Szh199473 void bge_chip_stop(bge_t *bgep, boolean_t fault); 1185*2675Szh199473 #ifdef BGE_IPMI_ASF 1186*2675Szh199473 void bge_nic_put32(bge_t *bgep, bge_regno_t addr, uint32_t data); 1187*2675Szh199473 #pragma inline(bge_nic_put32) 1188*2675Szh199473 uint32_t bge_nic_read32(bge_t *bgep, bge_regno_t addr); 1189*2675Szh199473 void bge_asf_update_status(bge_t *bgep); 1190*2675Szh199473 void bge_asf_heartbeat(void *bgep); 1191*2675Szh199473 void bge_asf_stop_timer(bge_t *bgep); 1192*2675Szh199473 void bge_asf_get_config(bge_t *bgep); 1193*2675Szh199473 void bge_asf_pre_reset_operations(bge_t *bgep, uint32_t mode); 1194*2675Szh199473 void bge_asf_post_reset_old_mode(bge_t *bgep, uint32_t mode); 1195*2675Szh199473 void bge_asf_post_reset_new_mode(bge_t *bgep, uint32_t mode); 1196*2675Szh199473 int bge_chip_reset(bge_t *bgep, boolean_t enable_dma, uint_t asf_mode); 1197*2675Szh199473 int bge_chip_sync(bge_t *bgep, boolean_t asf_keeplive); 1198*2675Szh199473 #else 1199*2675Szh199473 int bge_chip_reset(bge_t *bgep, boolean_t enable_dma); 1200*2675Szh199473 int bge_chip_sync(bge_t *bgep); 1201*2675Szh199473 #endif 1202*2675Szh199473 void bge_chip_blank(void *arg, time_t ticks, uint_t count); 1203*2675Szh199473 uint_t bge_chip_factotum(caddr_t arg); 1204*2675Szh199473 void bge_chip_cyclic(void *arg); 1205*2675Szh199473 enum ioc_reply bge_chip_ioctl(bge_t *bgep, queue_t *wq, mblk_t *mp, 1206*2675Szh199473 struct iocblk *iocp); 1207*2675Szh199473 uint_t bge_intr(caddr_t arg1, caddr_t arg2); 1208*2675Szh199473 extern uint32_t bge_rx_ticks_norm; 1209*2675Szh199473 extern uint32_t bge_tx_ticks_norm; 1210*2675Szh199473 extern uint32_t bge_rx_count_norm; 1211*2675Szh199473 extern uint32_t bge_tx_count_norm; 1212*2675Szh199473 extern boolean_t bge_jumbo_enable; 1213*2675Szh199473 void bge_chip_msi_trig(bge_t *bgep); 1214*2675Szh199473 1215*2675Szh199473 /* bge_kstats.c */ 1216*2675Szh199473 void bge_init_kstats(bge_t *bgep, int instance); 1217*2675Szh199473 void bge_fini_kstats(bge_t *bgep); 1218*2675Szh199473 int bge_m_stat(void *arg, uint_t stat, uint64_t *val); 1219*2675Szh199473 1220*2675Szh199473 /* bge_log.c */ 1221*2675Szh199473 #if BGE_DEBUGGING 1222*2675Szh199473 void (*bge_db(bge_t *bgep))(const char *fmt, ...); 1223*2675Szh199473 void (*bge_gdb(void))(const char *fmt, ...); 1224*2675Szh199473 void bge_pkt_dump(bge_t *bgep, bge_rbd_t *hbp, sw_rbd_t *sdp, const char *msg); 1225*2675Szh199473 void bge_dbg_enter(bge_t *bgep, const char *msg); 1226*2675Szh199473 #endif /* BGE_DEBUGGING */ 1227*2675Szh199473 void bge_problem(bge_t *bgep, const char *fmt, ...); 1228*2675Szh199473 void bge_notice(bge_t *bgep, const char *fmt, ...); 1229*2675Szh199473 void bge_log(bge_t *bgep, const char *fmt, ...); 1230*2675Szh199473 void bge_error(bge_t *bgep, const char *fmt, ...); 1231*2675Szh199473 void bge_fm_ereport(bge_t *bgep, char *detail); 1232*2675Szh199473 extern kmutex_t bge_log_mutex[1]; 1233*2675Szh199473 extern uint32_t bge_debug; 1234*2675Szh199473 1235*2675Szh199473 /* bge_main.c */ 1236*2675Szh199473 int bge_restart(bge_t *bgep, boolean_t reset_phy); 1237*2675Szh199473 int bge_check_acc_handle(bge_t *bgep, ddi_acc_handle_t handle); 1238*2675Szh199473 int bge_check_dma_handle(bge_t *bgep, ddi_dma_handle_t handle); 1239*2675Szh199473 void bge_init_rings(bge_t *bgep); 1240*2675Szh199473 void bge_fini_rings(bge_t *bgep); 1241*2675Szh199473 int bge_alloc_bufs(bge_t *bgep); 1242*2675Szh199473 void bge_free_bufs(bge_t *bgep); 1243*2675Szh199473 void bge_intr_enable(bge_t *bgep); 1244*2675Szh199473 void bge_intr_disable(bge_t *bgep); 1245*2675Szh199473 1246*2675Szh199473 /* bge_phys.c */ 1247*2675Szh199473 int bge_phys_init(bge_t *bgep); 1248*2675Szh199473 void bge_phys_reset(bge_t *bgep); 1249*2675Szh199473 int bge_phys_idle(bge_t *bgep); 1250*2675Szh199473 int bge_phys_update(bge_t *bgep); 1251*2675Szh199473 boolean_t bge_phys_check(bge_t *bgep); 1252*2675Szh199473 1253*2675Szh199473 /* bge_ndd.c */ 1254*2675Szh199473 int bge_nd_init(bge_t *bgep); 1255*2675Szh199473 enum ioc_reply bge_nd_ioctl(bge_t *bgep, queue_t *wq, mblk_t *mp, 1256*2675Szh199473 struct iocblk *iocp); 1257*2675Szh199473 void bge_nd_cleanup(bge_t *bgep); 1258*2675Szh199473 1259*2675Szh199473 /* bge_recv.c */ 1260*2675Szh199473 void bge_receive(bge_t *bgep, bge_status_t *bsp); 1261*2675Szh199473 1262*2675Szh199473 /* bge_send.c */ 1263*2675Szh199473 mblk_t *bge_m_tx(void *arg, mblk_t *mp); 1264*2675Szh199473 void bge_recycle(bge_t *bgep, bge_status_t *bsp); 1265*2675Szh199473 uint_t bge_reschedule(caddr_t arg); 1266*2675Szh199473 1267*2675Szh199473 /* bge_atomic_sparc.s/bge_atomic_intel.c */ 1268*2675Szh199473 uint64_t bge_atomic_reserve(uint64_t *count_p, uint64_t n); 1269*2675Szh199473 void bge_atomic_renounce(uint64_t *count_p, uint64_t n); 1270*2675Szh199473 uint64_t bge_atomic_claim(uint64_t *count_p, uint64_t limit); 1271*2675Szh199473 uint64_t bge_atomic_clr64(uint64_t *sp, uint64_t bits); 1272*2675Szh199473 uint32_t bge_atomic_shl32(uint32_t *sp, uint_t count); 1273*2675Szh199473 1274*2675Szh199473 1275*2675Szh199473 /* 1276*2675Szh199473 * Reset type 1277*2675Szh199473 */ 1278*2675Szh199473 #define BGE_SHUTDOWN_RESET 0 1279*2675Szh199473 #define BGE_INIT_RESET 1 1280*2675Szh199473 #define BGE_SUSPEND_RESET 2 1281*2675Szh199473 1282*2675Szh199473 /* For asf_status */ 1283*2675Szh199473 #define ASF_STAT_NONE 0 1284*2675Szh199473 #define ASF_STAT_STOP 1 1285*2675Szh199473 #define ASF_STAT_RUN 2 1286*2675Szh199473 #define ASF_STAT_RUN_INIT 3 /* attached but don't plumb */ 1287*2675Szh199473 1288*2675Szh199473 /* ASF modes for bge_reset() and bge_chip_reset() */ 1289*2675Szh199473 #define ASF_MODE_NONE 0 /* don't launch asf */ 1290*2675Szh199473 #define ASF_MODE_SHUTDOWN 1 /* asf shutdown mode */ 1291*2675Szh199473 #define ASF_MODE_INIT 2 /* asf init mode */ 1292*2675Szh199473 #define ASF_MODE_POST_SHUTDOWN 3 /* only do post-shutdown */ 1293*2675Szh199473 #define ASF_MODE_POST_INIT 4 /* only do post-init */ 1294*2675Szh199473 1295*2675Szh199473 #define BGE_ASF_HEARTBEAT_INTERVAL 1500000 1296*2675Szh199473 1297*2675Szh199473 #ifdef __cplusplus 1298*2675Szh199473 } 1299*2675Szh199473 #endif 1300*2675Szh199473 1301*2675Szh199473 #endif /* _SYS_BGE_IMPL_H */ 1302