Home | History | Annotate | Download | only in nxge
      1 /*
      2  * CDDL HEADER START
      3  *
      4  * The contents of this file are subject to the terms of the
      5  * Common Development and Distribution License (the "License").
      6  * You may not use this file except in compliance with the License.
      7  *
      8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
      9  * or http://www.opensolaris.org/os/licensing.
     10  * See the License for the specific language governing permissions
     11  * and limitations under the License.
     12  *
     13  * When distributing Covered Code, include this CDDL HEADER in each
     14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
     15  * If applicable, add the following below this CDDL HEADER, with the
     16  * fields enclosed by brackets "[]" replaced with your own identifying
     17  * information: Portions Copyright [yyyy] [name of copyright owner]
     18  *
     19  * CDDL HEADER END
     20  */
     21 /*
     22  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
     23  * Use is subject to license terms.
     24  */
     25 
     26 #ifndef	_SYS_NXGE_NXGE_IMPL_H
     27 #define	_SYS_NXGE_NXGE_IMPL_H
     28 
     29 #ifdef	__cplusplus
     30 extern "C" {
     31 #endif
     32 
     33 /*
     34  * NIU HV API version definitions.
     35  *
     36  * If additional major (HV API) is to be supported,
     37  * please increment NIU_MAJOR_HI.
     38  * If additional minor # is to be supported,
     39  * please increment NIU_MINOR_HI.
     40  */
     41 #define	NIU_MAJOR_HI		2
     42 #define	NIU_MINOR_HI		1
     43 #define	NIU_MAJOR_VER		1
     44 #define	NIU_MINOR_VER		1
     45 #define	NIU_MAJOR_VER_2		2
     46 
     47 #if defined(sun4v)
     48 
     49 /*
     50  * NIU HV API v1.0 definitions
     51  */
     52 #define	N2NIU_RX_LP_CONF		0x142
     53 #define	N2NIU_RX_LP_INFO		0x143
     54 #define	N2NIU_TX_LP_CONF		0x144
     55 #define	N2NIU_TX_LP_INFO		0x145
     56 
     57 #endif /* defined(sun4v) */
     58 
     59 #ifndef _ASM
     60 
     61 #include	<sys/types.h>
     62 #include	<sys/byteorder.h>
     63 #include	<sys/debug.h>
     64 #include	<sys/stropts.h>
     65 #include	<sys/stream.h>
     66 #include	<sys/strlog.h>
     67 #include	<sys/strsubr.h>
     68 #include	<sys/cmn_err.h>
     69 #include	<sys/vtrace.h>
     70 #include	<sys/kmem.h>
     71 #include	<sys/ddi.h>
     72 #include	<sys/sunddi.h>
     73 #include	<sys/strsun.h>
     74 #include	<sys/stat.h>
     75 #include	<sys/cpu.h>
     76 #include	<sys/kstat.h>
     77 #include	<inet/common.h>
     78 #include	<inet/ip.h>
     79 #include	<sys/dlpi.h>
     80 #include	<inet/nd.h>
     81 #include	<netinet/in.h>
     82 #include	<sys/ethernet.h>
     83 #include	<sys/vlan.h>
     84 #include	<sys/pci.h>
     85 #include	<sys/taskq.h>
     86 #include	<sys/atomic.h>
     87 
     88 #include 	<sys/nxge/nxge_defs.h>
     89 #include 	<sys/nxge/nxge_hw.h>
     90 #include 	<sys/nxge/nxge_mac.h>
     91 #include	<sys/nxge/nxge_mii.h>
     92 #include	<sys/nxge/nxge_fm.h>
     93 #include	<sys/netlb.h>
     94 
     95 #include	<sys/ddi_intr.h>
     96 #include 	<sys/mac_provider.h>
     97 #include	<sys/mac_ether.h>
     98 
     99 #if	defined(sun4v)
    100 #include	<sys/hypervisor_api.h>
    101 #include 	<sys/machsystm.h>
    102 #include 	<sys/hsvc.h>
    103 #endif
    104 
    105 #include 	<sys/dld.h>
    106 
    107 /*
    108  * Handy macros (taken from bge driver)
    109  */
    110 #define	RBR_SIZE			4
    111 #define	DMA_COMMON_CHANNEL(area)	((area.dma_channel))
    112 #define	DMA_COMMON_VPTR(area)		((area.kaddrp))
    113 #define	DMA_COMMON_VPTR_INDEX(area, index)	\
    114 					(((char *)(area.kaddrp)) + \
    115 					(index * RBR_SIZE))
    116 #define	DMA_COMMON_HANDLE(area)		((area.dma_handle))
    117 #define	DMA_COMMON_ACC_HANDLE(area)	((area.acc_handle))
    118 #define	DMA_COMMON_IOADDR(area)		((area.dma_cookie.dmac_laddress))
    119 #define	DMA_COMMON_IOADDR_INDEX(area, index)	\
    120 					((area.dma_cookie.dmac_laddress) + \
    121 						(index * RBR_SIZE))
    122 
    123 #define	DMA_NPI_HANDLE(area)		((area.npi_handle)
    124 
    125 #define	DMA_COMMON_SYNC(area, flag)	((void) ddi_dma_sync((area).dma_handle,\
    126 						(area).offset, (area).alength, \
    127 						(flag)))
    128 #define	DMA_COMMON_SYNC_OFFSET(area, bufoffset, len, flag)	\
    129 					((void) ddi_dma_sync((area).dma_handle,\
    130 					(area.offset + bufoffset), len, \
    131 					(flag)))
    132 
    133 #define	DMA_COMMON_SYNC_RBR_DESC(area, index, flag)	\
    134 				((void) ddi_dma_sync((area).dma_handle,\
    135 				(index * RBR_SIZE), RBR_SIZE,	\
    136 				(flag)))
    137 
    138 #define	DMA_COMMON_SYNC_RBR_DESC_MULTI(area, index, count, flag)	\
    139 			((void) ddi_dma_sync((area).dma_handle,\
    140 			(index * RBR_SIZE), count * RBR_SIZE,	\
    141 				(flag)))
    142 #define	DMA_COMMON_SYNC_ENTRY(area, index, flag)	\
    143 				((void) ddi_dma_sync((area).dma_handle,\
    144 				(index * (area).block_size),	\
    145 				(area).block_size, \
    146 				(flag)))
    147 
    148 #define	NEXT_ENTRY(index, wrap)		((index + 1) & wrap)
    149 #define	NEXT_ENTRY_PTR(ptr, first, last)	\
    150 					((ptr == last) ? first : (ptr + 1))
    151 
    152 /*
    153  * NPI related macros
    154  */
    155 #define	NXGE_DEV_NPI_HANDLE(nxgep)	(nxgep->npi_handle)
    156 
    157 #define	NPI_PCI_ACC_HANDLE_SET(nxgep, ah) (nxgep->npi_pci_handle.regh = ah)
    158 #define	NPI_PCI_ADD_HANDLE_SET(nxgep, ap) (nxgep->npi_pci_handle.regp = ap)
    159 
    160 #define	NPI_ACC_HANDLE_SET(nxgep, ah)	(nxgep->npi_handle.regh = ah)
    161 #define	NPI_ADD_HANDLE_SET(nxgep, ap)	\
    162 		nxgep->npi_handle.is_vraddr = B_FALSE;	\
    163 		nxgep->npi_handle.function.instance = nxgep->instance;   \
    164 		nxgep->npi_handle.function.function = nxgep->function_num;   \
    165 		nxgep->npi_handle.nxgep = (void *) nxgep;   \
    166 		nxgep->npi_handle.regp = ap;
    167 
    168 #define	NPI_REG_ACC_HANDLE_SET(nxgep, ah) (nxgep->npi_reg_handle.regh = ah)
    169 #define	NPI_REG_ADD_HANDLE_SET(nxgep, ap)	\
    170 		nxgep->npi_reg_handle.is_vraddr = B_FALSE;	\
    171 		nxgep->npi_handle.function.instance = nxgep->instance;   \
    172 		nxgep->npi_handle.function.function = nxgep->function_num;   \
    173 		nxgep->npi_reg_handle.nxgep = (void *) nxgep;   \
    174 		nxgep->npi_reg_handle.regp = ap;
    175 
    176 #define	NPI_MSI_ACC_HANDLE_SET(nxgep, ah) (nxgep->npi_msi_handle.regh = ah)
    177 #define	NPI_MSI_ADD_HANDLE_SET(nxgep, ap) (nxgep->npi_msi_handle.regp = ap)
    178 
    179 #define	NPI_VREG_ACC_HANDLE_SET(nxgep, ah) (nxgep->npi_vreg_handle.regh = ah)
    180 #define	NPI_VREG_ADD_HANDLE_SET(nxgep, ap)	\
    181 		nxgep->npi_vreg_handle.is_vraddr = B_TRUE; \
    182 		nxgep->npi_handle.function.instance = nxgep->instance;   \
    183 		nxgep->npi_handle.function.function = nxgep->function_num;   \
    184 		nxgep->npi_vreg_handle.nxgep = (void *) nxgep;   \
    185 		nxgep->npi_vreg_handle.regp = ap;
    186 
    187 #define	NPI_V2REG_ACC_HANDLE_SET(nxgep, ah) (nxgep->npi_v2reg_handle.regh = ah)
    188 #define	NPI_V2REG_ADD_HANDLE_SET(nxgep, ap)	\
    189 		nxgep->npi_v2reg_handle.is_vraddr = B_TRUE; \
    190 		nxgep->npi_handle.function.instance = nxgep->instance;   \
    191 		nxgep->npi_handle.function.function = nxgep->function_num;   \
    192 		nxgep->npi_v2reg_handle.nxgep = (void *) nxgep;   \
    193 		nxgep->npi_v2reg_handle.regp = ap;
    194 
    195 #define	NPI_PCI_ACC_HANDLE_GET(nxgep) (nxgep->npi_pci_handle.regh)
    196 #define	NPI_PCI_ADD_HANDLE_GET(nxgep) (nxgep->npi_pci_handle.regp)
    197 #define	NPI_ACC_HANDLE_GET(nxgep) (nxgep->npi_handle.regh)
    198 #define	NPI_ADD_HANDLE_GET(nxgep) (nxgep->npi_handle.regp)
    199 #define	NPI_REG_ACC_HANDLE_GET(nxgep) (nxgep->npi_reg_handle.regh)
    200 #define	NPI_REG_ADD_HANDLE_GET(nxgep) (nxgep->npi_reg_handle.regp)
    201 #define	NPI_MSI_ACC_HANDLE_GET(nxgep) (nxgep->npi_msi_handle.regh)
    202 #define	NPI_MSI_ADD_HANDLE_GET(nxgep) (nxgep->npi_msi_handle.regp)
    203 #define	NPI_VREG_ACC_HANDLE_GET(nxgep) (nxgep->npi_vreg_handle.regh)
    204 #define	NPI_VREG_ADD_HANDLE_GET(nxgep) (nxgep->npi_vreg_handle.regp)
    205 #define	NPI_V2REG_ACC_HANDLE_GET(nxgep) (nxgep->npi_v2reg_handle.regh)
    206 #define	NPI_V2REG_ADD_HANDLE_GET(nxgep) (nxgep->npi_v2reg_handle.regp)
    207 
    208 #define	NPI_DMA_ACC_HANDLE_SET(dmap, ah) (dmap->npi_handle.regh = ah)
    209 #define	NPI_DMA_ACC_HANDLE_GET(dmap) 	(dmap->npi_handle.regh)
    210 
    211 /*
    212  * DMA handles.
    213  */
    214 #define	NXGE_DESC_D_HANDLE_GET(desc)	(desc.dma_handle)
    215 #define	NXGE_DESC_D_IOADD_GET(desc)	(desc.dma_cookie.dmac_laddress)
    216 #define	NXGE_DMA_IOADD_GET(dma_cookie) (dma_cookie.dmac_laddress)
    217 #define	NXGE_DMA_AREA_IOADD_GET(dma_area) (dma_area.dma_cookie.dmac_laddress)
    218 
    219 #define	LDV_ON(ldv, vector)	((vector >> ldv) & 0x1)
    220 #define	LDV2_ON_1(ldv, vector)	((vector >> (ldv - 64)) & 0x1)
    221 #define	LDV2_ON_2(ldv, vector)	(((vector >> 5) >> (ldv - 64)) & 0x1)
    222 
    223 typedef uint32_t		nxge_status_t;
    224 
    225 typedef enum  {
    226 	IDLE,
    227 	PROGRESS,
    228 	CONFIGURED
    229 } dev_func_shared_t;
    230 
    231 typedef enum  {
    232 	DVMA,
    233 	DMA,
    234 	SDMA
    235 } dma_method_t;
    236 
    237 typedef enum  {
    238 	BKSIZE_4K,
    239 	BKSIZE_8K,
    240 	BKSIZE_16K,
    241 	BKSIZE_32K
    242 } nxge_rx_block_size_t;
    243 
    244 #ifdef TX_ONE_BUF
    245 #define	TX_BCOPY_MAX 1514
    246 #else
    247 #if	defined(sun4v) && defined(NIU_LP_WORKAROUND)
    248 #define	TX_BCOPY_MAX	4096
    249 #define	TX_BCOPY_SIZE	4096
    250 #else
    251 #define	TX_BCOPY_MAX	2048
    252 #define	TX_BCOPY_SIZE	2048
    253 #endif
    254 #endif
    255 
    256 #define	TX_STREAM_MIN 512
    257 #define	TX_FASTDVMA_MIN 1024
    258 
    259 /*
    260  * Send repeated FMA ereports or display messages about some non-fatal
    261  * hardware errors only the the first NXGE_ERROR_SHOW_MAX -1 times
    262  */
    263 #define	NXGE_ERROR_SHOW_MAX	2
    264 
    265 
    266 /*
    267  * Defaults
    268  */
    269 #define	NXGE_RDC_RCR_THRESHOLD		32
    270 #define	NXGE_RDC_RCR_TIMEOUT		8
    271 
    272 #define	NXGE_RDC_RCR_THRESHOLD_MAX	1024
    273 #define	NXGE_RDC_RCR_TIMEOUT_MAX	64
    274 #define	NXGE_RDC_RCR_THRESHOLD_MIN	8
    275 #define	NXGE_RDC_RCR_TIMEOUT_MIN	1
    276 #define	NXGE_RCR_FULL_HEADER		1
    277 
    278 #define	NXGE_IS_VLAN_PACKET(ptr)				\
    279 	((((struct ether_vlan_header *)ptr)->ether_tpid) ==	\
    280 	htons(VLAN_ETHERTYPE))
    281 
    282 typedef enum {
    283 	NONE,
    284 	SMALL,
    285 	MEDIUM,
    286 	LARGE
    287 } dma_size_t;
    288 
    289 typedef enum {
    290 	USE_NONE,
    291 	USE_BCOPY,
    292 	USE_DVMA,
    293 	USE_DMA,
    294 	USE_SDMA
    295 } dma_type_t;
    296 
    297 typedef enum {
    298 	NOT_IN_USE,
    299 	HDR_BUF,
    300 	MTU_BUF,
    301 	RE_ASSEMBLY_BUF,
    302 	FREE_BUF
    303 } rx_page_state_t;
    304 
    305 struct _nxge_block_mv_t {
    306 	uint32_t msg_type;
    307 	dma_type_t dma_type;
    308 };
    309 
    310 typedef struct _nxge_block_mv_t nxge_block_mv_t, *p_nxge_block_mv_t;
    311 
    312 typedef enum {
    313 	NIU_TYPE_NONE = 0,
    314 
    315 	/* QGC NIC */
    316 	NEPTUNE_4_1GC =
    317 	    (NXGE_PORT_1G_COPPER |
    318 	    (NXGE_PORT_1G_COPPER << 4) |
    319 	    (NXGE_PORT_1G_COPPER << 8) |
    320 	    (NXGE_PORT_1G_COPPER << 12)),
    321 
    322 	/* Huron: 2 fiber XAUI cards */
    323 	NEPTUNE_2_10GF =
    324 	    (NXGE_PORT_10G_FIBRE |
    325 	    (NXGE_PORT_10G_FIBRE << 4) |
    326 	    (NXGE_PORT_NONE << 8) |
    327 	    (NXGE_PORT_NONE << 12)),
    328 
    329 	/* Huron: port0 is a TN1010 copper XAUI */
    330 	NEPTUNE_1_TN1010 =
    331 	    (NXGE_PORT_TN1010 |
    332 	    (NXGE_PORT_NONE << 4) |
    333 	    (NXGE_PORT_NONE << 8) |
    334 	    (NXGE_PORT_NONE << 12)),
    335 
    336 	/* Huron: port1 is a TN1010 copper XAUI */
    337 	NEPTUNE_1_NONE_1_TN1010 =
    338 	    (NXGE_PORT_NONE |
    339 	    (NXGE_PORT_TN1010 << 4) |
    340 	    (NXGE_PORT_NONE << 8) |
    341 	    (NXGE_PORT_NONE << 12)),
    342 
    343 	/* Huron: 2 TN1010 copper XAUI cards */
    344 	NEPTUNE_2_TN1010 =
    345 	    (NXGE_PORT_TN1010 |
    346 	    (NXGE_PORT_TN1010 << 4) |
    347 	    (NXGE_PORT_NONE << 8) |
    348 	    (NXGE_PORT_NONE << 12)),
    349 
    350 	/* Huron: port0 is fiber XAUI, port1 is copper XAUI */
    351 	NEPTUNE_1_10GF_1_TN1010 =
    352 	    (NXGE_PORT_10G_FIBRE |
    353 	    (NXGE_PORT_TN1010 << 4) |
    354 	    (NXGE_PORT_NONE << 8) |
    355 	    (NXGE_PORT_NONE << 12)),
    356 
    357 	/* Huron: port0 is copper XAUI, port1 is fiber XAUI */
    358 	NEPTUNE_1_TN1010_1_10GF =
    359 	    (NXGE_PORT_TN1010 |
    360 	    (NXGE_PORT_10G_FIBRE << 4) |
    361 	    (NXGE_PORT_NONE << 8) |
    362 	    (NXGE_PORT_NONE << 12)),
    363 
    364 	/* Maramba: port0 and port1 are fiber XAUIs */
    365 	NEPTUNE_2_10GF_2_1GC =
    366 	    (NXGE_PORT_10G_FIBRE |
    367 	    (NXGE_PORT_10G_FIBRE << 4) |
    368 	    (NXGE_PORT_1G_COPPER << 8) |
    369 	    (NXGE_PORT_1G_COPPER << 12)),
    370 
    371 	/* Maramba: port0 and port1 are copper TN1010 XAUIs */
    372 	NEPTUNE_2_TN1010_2_1GC =
    373 	    (NXGE_PORT_TN1010 |
    374 	    (NXGE_PORT_TN1010 << 4) |
    375 	    (NXGE_PORT_1G_COPPER << 8) |
    376 	    (NXGE_PORT_1G_COPPER << 12)),
    377 
    378 	/* Maramba: port0 is copper XAUI, port1 is Fiber XAUI */
    379 	NEPTUNE_1_TN1010_1_10GF_2_1GC =
    380 	    (NXGE_PORT_TN1010 |
    381 	    (NXGE_PORT_10G_FIBRE << 4) |
    382 	    (NXGE_PORT_1G_COPPER << 8) |
    383 	    (NXGE_PORT_1G_COPPER << 12)),
    384 
    385 	/* Maramba: port0 is fiber XAUI, port1 is copper XAUI */
    386 	NEPTUNE_1_10GF_1_TN1010_2_1GC =
    387 	    (NXGE_PORT_10G_FIBRE |
    388 	    (NXGE_PORT_TN1010 << 4) |
    389 	    (NXGE_PORT_1G_COPPER << 8) |
    390 	    (NXGE_PORT_1G_COPPER << 12)),
    391 
    392 	/* Maramba: port0 is fiber XAUI */
    393 	NEPTUNE_1_10GF_3_1GC =
    394 	    (NXGE_PORT_10G_FIBRE |
    395 	    (NXGE_PORT_1G_COPPER << 4) |
    396 	    (NXGE_PORT_1G_COPPER << 8) |
    397 	    (NXGE_PORT_1G_COPPER << 12)),
    398 
    399 	/* Maramba: port0 is TN1010 copper XAUI */
    400 	NEPTUNE_1_TN1010_3_1GC =
    401 	    (NXGE_PORT_TN1010 |
    402 	    (NXGE_PORT_1G_COPPER << 4) |
    403 	    (NXGE_PORT_1G_COPPER << 8) |
    404 	    (NXGE_PORT_1G_COPPER << 12)),
    405 
    406 	/* Maramba: port1 is fiber XAUI */
    407 	NEPTUNE_1_1GC_1_10GF_2_1GC =
    408 	    (NXGE_PORT_1G_COPPER |
    409 	    (NXGE_PORT_10G_FIBRE << 4) |
    410 	    (NXGE_PORT_1G_COPPER << 8) |
    411 	    (NXGE_PORT_1G_COPPER << 12)),
    412 
    413 	/* Maramba: port1 is TN1010 copper XAUI */
    414 	NEPTUNE_1_1GC_1_TN1010_2_1GC =
    415 	    (NXGE_PORT_1G_COPPER |
    416 	    (NXGE_PORT_TN1010 << 4) |
    417 	    (NXGE_PORT_1G_COPPER << 8) |
    418 	    (NXGE_PORT_1G_COPPER << 12)),
    419 
    420 	NEPTUNE_2_1GRF =
    421 	    (NXGE_PORT_NONE |
    422 	    (NXGE_PORT_NONE << 4) |
    423 	    (NXGE_PORT_1G_RGMII_FIBER << 8) |
    424 	    (NXGE_PORT_1G_RGMII_FIBER << 12)),
    425 
    426 	NEPTUNE_2_10GF_2_1GRF =
    427 	    (NXGE_PORT_10G_FIBRE |
    428 	    (NXGE_PORT_10G_FIBRE << 4) |
    429 	    (NXGE_PORT_1G_RGMII_FIBER << 8) |
    430 	    (NXGE_PORT_1G_RGMII_FIBER << 12)),
    431 
    432 	N2_NIU =
    433 	    (NXGE_PORT_RSVD |
    434 	    (NXGE_PORT_RSVD << 4) |
    435 	    (NXGE_PORT_RSVD << 8) |
    436 	    (NXGE_PORT_RSVD << 12))
    437 
    438 } niu_type_t;
    439 
    440 /*
    441  * The niu_hw_type is for non-PHY related functions
    442  * designed on various versions of NIU chips (i.e. RF/NIU has
    443  * additional classification features and communicates with
    444  * a different SerDes than N2/NIU).
    445  */
    446 typedef enum {
    447 	NIU_HW_TYPE_DEFAULT = 0,	/* N2/NIU */
    448 	NIU_HW_TYPE_RF = 1,		/* RF/NIU */
    449 } niu_hw_type_t;
    450 
    451 /*
    452  * P_NEPTUNE_GENERIC:
    453  *	The cover-all case for Neptune (as opposed to NIU) where we do not
    454  *	care the exact platform as we do not do anything that is platform
    455  *	specific.
    456  * P_NEPTUNE_ATLAS_2PORT:
    457  *	Dual Port Fiber Neptune based NIC (2XGF)
    458  * P_NEPTUNE_ATLAS_4PORT:
    459  *	Quad Port Copper Neptune based NIC (QGC)
    460  * P_NEPTUNE_NIU:
    461  *	This is NIU. Could be Huron, Glendale, Monza or any other NIU based
    462  *	platform.
    463  */
    464 typedef enum {
    465 	P_NEPTUNE_NONE,
    466 	P_NEPTUNE_GENERIC,
    467 	P_NEPTUNE_ATLAS_2PORT,
    468 	P_NEPTUNE_ATLAS_4PORT,
    469 	P_NEPTUNE_MARAMBA_P0,
    470 	P_NEPTUNE_MARAMBA_P1,
    471 	P_NEPTUNE_ALONSO,
    472 	P_NEPTUNE_ROCK,
    473 	P_NEPTUNE_NIU
    474 } platform_type_t;
    475 
    476 #define	NXGE_IS_VALID_NEPTUNE_TYPE(nxgep) \
    477 	(((nxgep->platform_type) == P_NEPTUNE_ATLAS_2PORT) || \
    478 	    ((nxgep->platform_type) == P_NEPTUNE_ATLAS_4PORT) || \
    479 	    ((nxgep->platform_type) == P_NEPTUNE_MARAMBA_P0) || \
    480 	    ((nxgep->platform_type) == P_NEPTUNE_MARAMBA_P1) || \
    481 	    ((nxgep->platform_type) == P_NEPTUNE_GENERIC) || \
    482 	    ((nxgep->platform_type) == P_NEPTUNE_ALONSO) || \
    483 	    ((nxgep->platform_type) == P_NEPTUNE_ROCK))
    484 
    485 #define	NXGE_IS_XAUI_PLATFORM(nxgep) \
    486 	(((nxgep->platform_type) == P_NEPTUNE_NIU) || \
    487 	    ((nxgep->platform_type) == P_NEPTUNE_MARAMBA_P0) || \
    488 	    ((nxgep->platform_type) == P_NEPTUNE_MARAMBA_P1))
    489 
    490 
    491 typedef enum {
    492 	CFG_DEFAULT = 0,	/* default cfg */
    493 	CFG_EQUAL,	/* Equal */
    494 	CFG_FAIR,	/* Equal */
    495 	CFG_CLASSIFY,
    496 	CFG_L2_CLASSIFY,
    497 	CFG_L3_CLASSIFY,
    498 	CFG_L3_DISTRIBUTE,
    499 	CFG_L3_WEB,
    500 	CFG_L3_TCAM,
    501 	CFG_NOT_SPECIFIED,
    502 	CFG_CUSTOM	/* Custom */
    503 } cfg_type_t;
    504 
    505 typedef enum {
    506 	NO_MSG = 0x0,		/* No message output or storage. */
    507 	CONSOLE = 0x1,		/* Messages are go to the console. */
    508 	BUFFER = 0x2,		/* Messages are go to the system buffer. */
    509 	CON_BUF = 0x3,		/* Messages are go to the console and */
    510 				/* system buffer. */
    511 	VERBOSE = 0x4		/* Messages are go out only in VERBOSE node. */
    512 } out_msg_t, *p_out_msg_t;
    513 
    514 typedef enum {
    515 	DBG_NO_MSG = 0x0,	/* No message output or storage. */
    516 	DBG_CONSOLE = 0x1,	/* Messages are go to the console. */
    517 	DBG_BUFFER = 0x2,	/* Messages are go to the system buffer. */
    518 	DBG_CON_BUF = 0x3,	/* Messages are go to the console and */
    519 				/* system buffer. */
    520 	STR_LOG = 4		/* Sessage sent to streams logging driver. */
    521 } out_dbgmsg_t, *p_out_dbgmsg_t;
    522 
    523 typedef enum {
    524 	DDI_MEM_ALLOC,		/* default (use ddi_dma_mem_alloc) */
    525 	KMEM_ALLOC,		/* use kmem_alloc(). */
    526 	CONTIG_MEM_ALLOC	/* use contig_mem_alloc() (N2/NIU only) */
    527 } buf_alloc_type_t;
    528 
    529 #define	BUF_ALLOCATED		0x00000001
    530 #define	BUF_ALLOCATED_WAIT_FREE	0x00000002
    531 
    532 typedef struct ether_addr ether_addr_st, *p_ether_addr_t;
    533 typedef struct ether_header ether_header_t, *p_ether_header_t;
    534 typedef queue_t *p_queue_t;
    535 typedef mblk_t *p_mblk_t;
    536 
    537 /*
    538  * Generic phy table to support different phy types.
    539  *
    540  * The argument for check_link is nxgep, which is passed to check_link
    541  * as an argument to the timer routine.
    542  */
    543 typedef struct _nxge_xcvr_table {
    544 	nxge_status_t	(*serdes_init)	();	/* Serdes init routine */
    545 	nxge_status_t	(*xcvr_init)	();	/* xcvr init routine */
    546 	nxge_status_t	(*link_intr_stop) ();	/* Link intr disable routine */
    547 	nxge_status_t	(*link_intr_start) ();	/* Link intr enable routine */
    548 	nxge_status_t	(*check_link) ();	/* Link check routine */
    549 
    550 	uint32_t	xcvr_inuse;
    551 } nxge_xcvr_table_t, *p_nxge_xcvr_table_t;
    552 
    553 /*
    554  * Common DMA data elements.
    555  */
    556 typedef struct _nxge_dma_pool_t nxge_dma_pool_t, *p_nxge_dma_pool_t;
    557 
    558 struct _nxge_dma_common_t {
    559 	uint16_t		dma_channel;
    560 	void			*kaddrp;
    561 	void			*last_kaddrp;
    562 	void			*ioaddr_pp;
    563 	void			*first_ioaddr_pp;
    564 	void			*last_ioaddr_pp;
    565 	ddi_dma_cookie_t 	dma_cookie;
    566 	uint32_t		ncookies;
    567 
    568 	ddi_dma_handle_t	dma_handle;
    569 	nxge_os_acc_handle_t	acc_handle;
    570 	npi_handle_t		npi_handle;
    571 
    572 	size_t			block_size;
    573 	uint32_t		nblocks;
    574 	size_t			alength;
    575 	uint_t			offset;
    576 	uint_t			dma_chunk_index;
    577 	void			*orig_ioaddr_pp;
    578 	uint64_t		orig_vatopa;
    579 	void			*orig_kaddrp;
    580 	size_t			orig_alength;
    581 	boolean_t		contig_alloc_type;
    582 	/*
    583 	 * Receive buffers may be allocated using
    584 	 * kmem_alloc(). The buffer free function
    585 	 * depends on its allocation function.
    586 	 */
    587 	boolean_t		kmem_alloc_type;
    588 	uint32_t		buf_alloc_state;
    589 	buf_alloc_type_t	buf_alloc_type;
    590 	p_nxge_dma_pool_t	rx_buf_pool_p;
    591 };
    592 
    593 typedef struct _nxge_t nxge_t, *p_nxge_t;
    594 typedef struct _nxge_dma_common_t nxge_dma_common_t, *p_nxge_dma_common_t;
    595 
    596 struct _nxge_dma_pool_t {
    597 	p_nxge_dma_common_t	*dma_buf_pool_p;
    598 	uint32_t		ndmas;
    599 	uint32_t		*num_chunks;
    600 	boolean_t		buf_allocated;
    601 };
    602 
    603 /*
    604  * Each logical device (69):
    605  *	- LDG #
    606  *	- flag bits
    607  *	- masks.
    608  *	- interrupt handler function.
    609  *
    610  * Generic system interrupt handler with two arguments:
    611  *	(nxge_sys_intr_t)
    612  *	Per device instance data structure
    613  *	Logical group data structure.
    614  *
    615  * Logical device interrupt handler with two arguments:
    616  *	(nxge_ldv_intr_t)
    617  *	Per device instance data structure
    618  *	Logical device number
    619  */
    620 typedef struct	_nxge_ldg_t nxge_ldg_t, *p_nxge_ldg_t;
    621 typedef struct	_nxge_ldv_t nxge_ldv_t, *p_nxge_ldv_t;
    622 typedef uint_t	(*nxge_sys_intr_t)(void *arg1, void *arg2);
    623 typedef uint_t	(*nxge_ldv_intr_t)(void *arg1, void *arg2);
    624 
    625 /*
    626  * Each logical device Group (64) needs to have the following
    627  * configurations:
    628  *	- timer counter (6 bits)
    629  *	- timer resolution (20 bits, number of system clocks)
    630  *	- system data (7 bits)
    631  */
    632 struct _nxge_ldg_t {
    633 	uint8_t			ldg;		/* logical group number */
    634 	uint8_t			vldg_index;
    635 	boolean_t		arm;
    636 	uint16_t		ldg_timer;	/* counter */
    637 	uint8_t			func;
    638 	uint8_t			vector;
    639 	uint8_t			intdata;
    640 	uint8_t			nldvs;
    641 	p_nxge_ldv_t		ldvp;
    642 	nxge_sys_intr_t		sys_intr_handler;
    643 	p_nxge_t		nxgep;
    644 };
    645 
    646 struct _nxge_ldv_t {
    647 	uint8_t			ldg_assigned;
    648 	uint8_t			ldv;
    649 	boolean_t		is_rxdma;
    650 	boolean_t		is_txdma;
    651 	boolean_t		is_mif;
    652 	boolean_t		is_mac;
    653 	boolean_t		is_syserr;
    654 	boolean_t		use_timer;
    655 	uint8_t			channel;
    656 	uint8_t			vdma_index;
    657 	uint8_t			func;
    658 	p_nxge_ldg_t		ldgp;
    659 	uint8_t			ldv_flags;
    660 	uint8_t			ldv_ldf_masks;
    661 	nxge_ldv_intr_t		ldv_intr_handler;
    662 	p_nxge_t		nxgep;
    663 };
    664 
    665 typedef struct _nxge_logical_page_t {
    666 	uint16_t		dma;
    667 	uint16_t		page;
    668 	boolean_t		valid;
    669 	uint64_t		mask;
    670 	uint64_t		value;
    671 	uint64_t		reloc;
    672 	uint32_t		handle;
    673 } nxge_logical_page_t, *p_nxge_logical_page_t;
    674 
    675 /*
    676  * (Internal) return values from ioctl subroutines.
    677  */
    678 enum nxge_ioc_reply {
    679 	IOC_INVAL = -1,				/* bad, NAK with EINVAL	*/
    680 	IOC_DONE,				/* OK, reply sent	*/
    681 	IOC_ACK,				/* OK, just send ACK	*/
    682 	IOC_REPLY,				/* OK, just send reply	*/
    683 	IOC_RESTART_ACK,			/* OK, restart & ACK	*/
    684 	IOC_RESTART_REPLY			/* OK, restart & reply	*/
    685 };
    686 
    687 typedef struct _pci_cfg_t {
    688 	uint16_t vendorid;
    689 	uint16_t devid;
    690 	uint16_t command;
    691 	uint16_t status;
    692 	uint8_t  revid;
    693 	uint8_t  res0;
    694 	uint16_t junk1;
    695 	uint8_t  cache_line;
    696 	uint8_t  latency;
    697 	uint8_t  header;
    698 	uint8_t  bist;
    699 	uint32_t base;
    700 	uint32_t base14;
    701 	uint32_t base18;
    702 	uint32_t base1c;
    703 	uint32_t base20;
    704 	uint32_t base24;
    705 	uint32_t base28;
    706 	uint32_t base2c;
    707 	uint32_t base30;
    708 	uint32_t res1[2];
    709 	uint8_t int_line;
    710 	uint8_t int_pin;
    711 	uint8_t	min_gnt;
    712 	uint8_t max_lat;
    713 } pci_cfg_t, *p_pci_cfg_t;
    714 
    715 typedef struct _dev_regs_t {
    716 	nxge_os_acc_handle_t	nxge_pciregh;	/* PCI config DDI IO handle */
    717 	p_pci_cfg_t		nxge_pciregp;	/* mapped PCI registers */
    718 
    719 	nxge_os_acc_handle_t	nxge_regh;	/* device DDI IO (BAR 0) */
    720 	void			*nxge_regp;	/* mapped device registers */
    721 
    722 	nxge_os_acc_handle_t	nxge_msix_regh;	/* MSI/X DDI handle (BAR 2) */
    723 	void 			*nxge_msix_regp; /* MSI/X register */
    724 
    725 	nxge_os_acc_handle_t	nxge_vir_regh;	/* virtualization (BAR 4) */
    726 	unsigned char		*nxge_vir_regp;	/* virtualization register */
    727 
    728 	nxge_os_acc_handle_t	nxge_vir2_regh;	/* second virtualization */
    729 	unsigned char		*nxge_vir2_regp; /* second virtualization */
    730 
    731 	nxge_os_acc_handle_t	nxge_romh;	/* fcode rom handle */
    732 	unsigned char		*nxge_romp;	/* fcode pointer */
    733 } dev_regs_t, *p_dev_regs_t;
    734 
    735 
    736 typedef struct _nxge_mac_addr_t {
    737 	ether_addr_t	addr;
    738 	uint_t		flags;
    739 } nxge_mac_addr_t;
    740 
    741 /*
    742  * The hardware supports 1 unique MAC and 16 alternate MACs (num_mmac)
    743  * for each XMAC port and supports 1 unique MAC and 7 alternate MACs
    744  * for each BMAC port.  The number of MACs assigned by the factory is
    745  * different and is as follows,
    746  * 	BMAC port:		   num_factory_mmac = num_mmac = 7
    747  *	XMAC port on a 2-port NIC: num_factory_mmac = num_mmac - 1 = 15
    748  *	XMAC port on a 4-port NIC: num_factory_mmac = 7
    749  * So num_factory_mmac is smaller than num_mmac.  nxge_m_mmac_add uses
    750  * num_mmac and nxge_m_mmac_reserve uses num_factory_mmac.
    751  *
    752  * total_factory_macs is the total number of factory MACs, including
    753  * the unique MAC, assigned to a Neptune based NIC card, it is 32.
    754  */
    755 typedef struct _nxge_mmac_t {
    756 	uint8_t		total_factory_macs;
    757 	uint8_t		num_mmac;
    758 	uint8_t		num_factory_mmac;
    759 	nxge_mac_addr_t	mac_pool[XMAC_MAX_ADDR_ENTRY];
    760 	ether_addr_t	factory_mac_pool[XMAC_MAX_ADDR_ENTRY];
    761 	uint8_t		naddrfree;  /* number of alt mac addr available */
    762 } nxge_mmac_t;
    763 
    764 /*
    765  * mmac stats structure
    766  */
    767 typedef struct _nxge_mmac_stats_t {
    768 	uint8_t mmac_max_cnt;
    769 	uint8_t	mmac_avail_cnt;
    770 	struct ether_addr mmac_avail_pool[16];
    771 } nxge_mmac_stats_t, *p_nxge_mmac_stats_t;
    772 
    773 /*
    774  * Copied from mac.h. Should be cleaned up by driver.
    775  */
    776 #define	MMAC_SLOT_USED		0x1   /* address slot used */
    777 #define	MMAC_VENDOR_ADDR	0x2   /* address returned is vendor supplied */
    778 
    779 
    780 #define	NXGE_MAX_MMAC_ADDRS	32
    781 #define	NXGE_NUM_MMAC_ADDRS	8
    782 #define	NXGE_NUM_OF_PORTS_QUAD	4
    783 #define	NXGE_NUM_OF_PORTS_DUAL	2
    784 
    785 #define	NXGE_QGC_LP_BM_STR		"501-7606"
    786 #define	NXGE_2XGF_LP_BM_STR		"501-7283"
    787 #define	NXGE_QGC_PEM_BM_STR		"501-7765"
    788 #define	NXGE_2XGF_PEM_BM_STR		"501-7626"
    789 #define	NXGE_ALONSO_BM_STR		"373-0202-01"
    790 #define	NXGE_ALONSO_MODEL_STR		"SUNW,CP3220"
    791 #define	NXGE_RFEM_BM_STR		"501-7961-01"
    792 #define	NXGE_RFEM_MODEL_STR		"SUNW,pcie-rfem"
    793 #define	NXGE_ARTM_BM_STR		"375-3544-01"
    794 #define	NXGE_ARTM_MODEL_STR		"SUNW,pcie-artm"
    795 /* ROCK OBP creates a compatible property for ROCK */
    796 #define	NXGE_ROCK_COMPATIBLE		"SUNW,rock-pciex108e,abcd"
    797 #define	NXGE_EROM_LEN			1048576
    798 
    799 #include 	<sys/nxge/nxge_common_impl.h>
    800 #include 	<sys/nxge/nxge_common.h>
    801 #include	<sys/nxge/nxge_txc.h>
    802 #include	<sys/nxge/nxge_rxdma.h>
    803 #include	<sys/nxge/nxge_txdma.h>
    804 #include	<sys/nxge/nxge_fflp.h>
    805 #include	<sys/nxge/nxge_ipp.h>
    806 #include	<sys/nxge/nxge_zcp.h>
    807 #include	<sys/nxge/nxge_fzc.h>
    808 #include	<sys/nxge/nxge_flow.h>
    809 #include	<sys/nxge/nxge_virtual.h>
    810 
    811 #include	<npi_espc.h>
    812 #include	<npi_vir.h>
    813 
    814 #include 	<sys/nxge/nxge.h>
    815 
    816 #include	<sys/modctl.h>
    817 #include	<sys/pattr.h>
    818 
    819 extern int secpolicy_net_config(const cred_t *, boolean_t);
    820 extern void nxge_fm_report_error(p_nxge_t, uint8_t,
    821 			uint8_t, nxge_fm_ereport_id_t);
    822 extern int fm_check_acc_handle(ddi_acc_handle_t);
    823 extern int fm_check_dma_handle(ddi_dma_handle_t);
    824 
    825 /* nxge_classify.c */
    826 nxge_status_t nxge_classify_init(p_nxge_t);
    827 nxge_status_t nxge_classify_uninit(p_nxge_t);
    828 nxge_status_t nxge_set_hw_classify_config(p_nxge_t);
    829 nxge_status_t nxge_classify_exit_sw(p_nxge_t);
    830 
    831 /* nxge_fflp.c */
    832 void nxge_put_tcam(p_nxge_t, p_mblk_t);
    833 void nxge_get_tcam(p_nxge_t, p_mblk_t);
    834 nxge_status_t nxge_classify_init_hw(p_nxge_t);
    835 nxge_status_t nxge_classify_init_sw(p_nxge_t);
    836 nxge_status_t nxge_fflp_ip_class_config_all(p_nxge_t);
    837 nxge_status_t nxge_fflp_ip_class_config(p_nxge_t, tcam_class_t,
    838 				    uint32_t);
    839 
    840 nxge_status_t nxge_fflp_ip_class_config_get(p_nxge_t,
    841 				    tcam_class_t,
    842 				    uint32_t *);
    843 
    844 nxge_status_t nxge_cfg_ip_cls_flow_key(p_nxge_t, tcam_class_t,
    845 				    uint32_t);
    846 
    847 nxge_status_t nxge_fflp_ip_usr_class_config(p_nxge_t, tcam_class_t,
    848 				    uint32_t);
    849 
    850 uint64_t nxge_classify_get_cfg_value(p_nxge_t, uint8_t, uint8_t);
    851 nxge_status_t nxge_add_flow(p_nxge_t, flow_resource_t *);
    852 nxge_status_t nxge_fflp_config_tcam_enable(p_nxge_t);
    853 nxge_status_t nxge_fflp_config_tcam_disable(p_nxge_t);
    854 
    855 nxge_status_t nxge_fflp_config_hash_lookup_enable(p_nxge_t);
    856 nxge_status_t nxge_fflp_config_hash_lookup_disable(p_nxge_t);
    857 
    858 nxge_status_t nxge_fflp_config_llc_snap_enable(p_nxge_t);
    859 nxge_status_t nxge_fflp_config_llc_snap_disable(p_nxge_t);
    860 
    861 nxge_status_t nxge_logical_mac_assign_rdc_table(p_nxge_t, uint8_t);
    862 nxge_status_t nxge_fflp_config_vlan_table(p_nxge_t, uint16_t);
    863 
    864 nxge_status_t nxge_fflp_set_hash1(p_nxge_t, uint32_t);
    865 
    866 nxge_status_t nxge_fflp_set_hash2(p_nxge_t, uint16_t);
    867 
    868 nxge_status_t nxge_fflp_init_hostinfo(p_nxge_t);
    869 
    870 void nxge_handle_tcam_fragment_bug(p_nxge_t);
    871 int nxge_rxclass_ioctl(p_nxge_t, queue_t *, mblk_t *);
    872 int nxge_rxhash_ioctl(p_nxge_t, queue_t *, mblk_t *);
    873 
    874 nxge_status_t nxge_fflp_hw_reset(p_nxge_t);
    875 nxge_status_t nxge_fflp_handle_sys_errors(p_nxge_t);
    876 nxge_status_t nxge_zcp_handle_sys_errors(p_nxge_t);
    877 
    878 /* nxge_kstats.c */
    879 void nxge_init_statsp(p_nxge_t);
    880 void nxge_setup_kstats(p_nxge_t);
    881 void nxge_setup_rdc_kstats(p_nxge_t, int);
    882 void nxge_setup_tdc_kstats(p_nxge_t, int);
    883 void nxge_destroy_kstats(p_nxge_t);
    884 int nxge_port_kstat_update(kstat_t *, int);
    885 void nxge_save_cntrs(p_nxge_t);
    886 
    887 int nxge_m_stat(void *arg, uint_t, uint64_t *);
    888 
    889 /* nxge_hw.c */
    890 void
    891 nxge_hw_ioctl(p_nxge_t, queue_t *, mblk_t *, struct iocblk *);
    892 void nxge_loopback_ioctl(p_nxge_t, queue_t *, mblk_t *, struct iocblk *);
    893 nxge_status_t nxge_global_reset(p_nxge_t);
    894 uint_t nxge_intr(void *, void *);
    895 void nxge_intr_enable(p_nxge_t);
    896 void nxge_intr_disable(p_nxge_t);
    897 void nxge_hw_blank(void *arg, time_t, uint_t);
    898 void nxge_hw_id_init(p_nxge_t);
    899 void nxge_hw_init_niu_common(p_nxge_t);
    900 void nxge_intr_hw_enable(p_nxge_t);
    901 void nxge_intr_hw_disable(p_nxge_t);
    902 void nxge_hw_stop(p_nxge_t);
    903 void nxge_check_hw_state(p_nxge_t);
    904 
    905 void nxge_rxdma_channel_put64(nxge_os_acc_handle_t,
    906 	void *, uint32_t, uint16_t,
    907 	uint64_t);
    908 uint64_t nxge_rxdma_channel_get64(nxge_os_acc_handle_t, void *,
    909 	uint32_t, uint16_t);
    910 
    911 
    912 void nxge_get32(p_nxge_t, p_mblk_t);
    913 void nxge_put32(p_nxge_t, p_mblk_t);
    914 
    915 void nxge_hw_set_mac_modes(p_nxge_t);
    916 
    917 /* nxge_send.c. */
    918 uint_t nxge_reschedule(caddr_t);
    919 mblk_t *nxge_tx_ring_send(void *, mblk_t *);
    920 int nxge_start(p_nxge_t, p_tx_ring_t, p_mblk_t);
    921 
    922 /* nxge_rxdma.c */
    923 nxge_status_t nxge_rxdma_cfg_rdcgrp_default_rdc(p_nxge_t,
    924 					    uint8_t, uint8_t);
    925 
    926 nxge_status_t nxge_rxdma_cfg_port_default_rdc(p_nxge_t,
    927 				    uint8_t, uint8_t);
    928 nxge_status_t nxge_rxdma_cfg_rcr_threshold(p_nxge_t, uint8_t,
    929 				    uint16_t);
    930 nxge_status_t nxge_rxdma_cfg_rcr_timeout(p_nxge_t, uint8_t,
    931 				    uint16_t, uint8_t);
    932 
    933 /* nxge_ndd.c */
    934 void nxge_get_param_soft_properties(p_nxge_t);
    935 void nxge_copy_hw_default_to_param(p_nxge_t);
    936 void nxge_copy_param_hw_to_config(p_nxge_t);
    937 void nxge_setup_param(p_nxge_t);
    938 void nxge_init_param(p_nxge_t);
    939 void nxge_destroy_param(p_nxge_t);
    940 boolean_t nxge_check_rxdma_rdcgrp_member(p_nxge_t, uint8_t, uint8_t);
    941 boolean_t nxge_check_rxdma_port_member(p_nxge_t, uint8_t);
    942 boolean_t nxge_check_rdcgrp_port_member(p_nxge_t, uint8_t);
    943 
    944 boolean_t nxge_check_txdma_port_member(p_nxge_t, uint8_t);
    945 
    946 int nxge_param_get_generic(p_nxge_t, queue_t *, mblk_t *, caddr_t);
    947 int nxge_param_set_generic(p_nxge_t, queue_t *, mblk_t *, char *, caddr_t);
    948 int nxge_get_default(p_nxge_t, queue_t *, p_mblk_t, caddr_t);
    949 int nxge_set_default(p_nxge_t, queue_t *, p_mblk_t, char *, caddr_t);
    950 int nxge_nd_get_names(p_nxge_t, queue_t *, p_mblk_t, caddr_t);
    951 int nxge_mk_mblk_tail_space(p_mblk_t, p_mblk_t *, size_t);
    952 long nxge_strtol(char *, char **, int);
    953 boolean_t nxge_param_get_instance(queue_t *, mblk_t *);
    954 void nxge_param_ioctl(p_nxge_t, queue_t *, mblk_t *, struct iocblk *);
    955 boolean_t nxge_nd_load(caddr_t *, char *, pfi_t, pfi_t, caddr_t);
    956 void nxge_nd_free(caddr_t *);
    957 int nxge_nd_getset(p_nxge_t, queue_t *, caddr_t, p_mblk_t);
    958 
    959 nxge_status_t nxge_set_lb_normal(p_nxge_t);
    960 boolean_t nxge_set_lb(p_nxge_t, queue_t *, p_mblk_t);
    961 boolean_t nxge_param_link_update(p_nxge_t);
    962 int nxge_param_set_ip_opt(p_nxge_t, queue_t *, mblk_t *, char *, caddr_t);
    963 int nxge_dld_get_ip_opt(p_nxge_t, caddr_t);
    964 int nxge_param_rx_intr_pkts(p_nxge_t, queue_t *,
    965 	mblk_t *, char *, caddr_t);
    966 int nxge_param_rx_intr_time(p_nxge_t, queue_t *,
    967 	mblk_t *, char *, caddr_t);
    968 
    969 
    970 /* nxge_virtual.c */
    971 nxge_status_t nxge_cntlops(dev_info_t *, nxge_ctl_enum_t, void *, void *);
    972 void nxge_common_lock_get(p_nxge_t);
    973 void nxge_common_lock_free(p_nxge_t);
    974 
    975 nxge_status_t nxge_get_config_properties(p_nxge_t);
    976 void nxge_get_xcvr_properties(p_nxge_t);
    977 void nxge_init_vlan_config(p_nxge_t);
    978 void nxge_init_mac_config(p_nxge_t);
    979 
    980 
    981 void nxge_init_logical_devs(p_nxge_t);
    982 int nxge_init_ldg_intrs(p_nxge_t);
    983 
    984 void nxge_set_ldgimgmt(p_nxge_t, uint32_t, boolean_t,
    985 	uint32_t);
    986 
    987 void nxge_init_fzc_txdma_channels(p_nxge_t);
    988 
    989 nxge_status_t nxge_init_fzc_txdma_channel(p_nxge_t, uint16_t,
    990 	p_tx_ring_t, p_tx_mbox_t);
    991 nxge_status_t nxge_init_fzc_txdma_port(p_nxge_t);
    992 
    993 nxge_status_t nxge_init_fzc_rxdma_channel(p_nxge_t, uint16_t);
    994 
    995 nxge_status_t nxge_init_fzc_rx_common(p_nxge_t);
    996 nxge_status_t nxge_init_fzc_rxdma_port(p_nxge_t);
    997 
    998 nxge_status_t nxge_init_fzc_rxdma_channel_pages(p_nxge_t,
    999 	uint16_t, p_rx_rbr_ring_t);
   1000 nxge_status_t nxge_init_fzc_rxdma_channel_red(p_nxge_t,
   1001 	uint16_t, p_rx_rcr_ring_t);
   1002 
   1003 nxge_status_t nxge_init_fzc_rxdma_channel_clrlog(p_nxge_t,
   1004 	uint16_t, p_rx_rbr_ring_t);
   1005 
   1006 
   1007 nxge_status_t nxge_init_fzc_txdma_channel_pages(p_nxge_t,
   1008 	uint16_t, p_tx_ring_t);
   1009 
   1010 nxge_status_t nxge_init_fzc_txdma_channel_drr(p_nxge_t, uint16_t,
   1011 	p_tx_ring_t);
   1012 
   1013 nxge_status_t nxge_init_fzc_txdma_port(p_nxge_t);
   1014 
   1015 void nxge_init_fzc_ldg_num(p_nxge_t);
   1016 void nxge_init_fzc_sys_int_data(p_nxge_t);
   1017 void nxge_init_fzc_ldg_int_timer(p_nxge_t);
   1018 nxge_status_t nxge_intr_mask_mgmt_set(p_nxge_t, boolean_t on);
   1019 
   1020 /* MAC functions */
   1021 nxge_status_t nxge_mac_init(p_nxge_t);
   1022 nxge_status_t nxge_link_init(p_nxge_t);
   1023 nxge_status_t nxge_xif_init(p_nxge_t);
   1024 nxge_status_t nxge_pcs_init(p_nxge_t);
   1025 nxge_status_t nxge_mac_ctrl_init(p_nxge_t);
   1026 nxge_status_t nxge_serdes_init(p_nxge_t);
   1027 nxge_status_t nxge_serdes_reset(p_nxge_t);
   1028 nxge_status_t nxge_xcvr_find(p_nxge_t);
   1029 nxge_status_t nxge_get_xcvr_type(p_nxge_t);
   1030 nxge_status_t nxge_setup_xcvr_table(p_nxge_t);
   1031 nxge_status_t nxge_xcvr_init(p_nxge_t);
   1032 nxge_status_t nxge_tx_mac_init(p_nxge_t);
   1033 nxge_status_t nxge_rx_mac_init(p_nxge_t);
   1034 nxge_status_t nxge_tx_mac_enable(p_nxge_t);
   1035 nxge_status_t nxge_tx_mac_disable(p_nxge_t);
   1036 nxge_status_t nxge_rx_mac_enable(p_nxge_t);
   1037 nxge_status_t nxge_rx_mac_disable(p_nxge_t);
   1038 nxge_status_t nxge_tx_mac_reset(p_nxge_t);
   1039 nxge_status_t nxge_rx_mac_reset(p_nxge_t);
   1040 nxge_status_t nxge_link_intr(p_nxge_t, link_intr_enable_t);
   1041 nxge_status_t nxge_mii_xcvr_init(p_nxge_t);
   1042 nxge_status_t nxge_mii_xcvr_fiber_init(p_nxge_t);
   1043 nxge_status_t nxge_mii_read(p_nxge_t, uint8_t,
   1044 			uint8_t, uint16_t *);
   1045 nxge_status_t nxge_mii_write(p_nxge_t, uint8_t,
   1046 			uint8_t, uint16_t);
   1047 nxge_status_t nxge_mdio_read(p_nxge_t, uint8_t, uint8_t,
   1048 			uint16_t, uint16_t *);
   1049 nxge_status_t nxge_mdio_write(p_nxge_t, uint8_t,
   1050 			uint8_t, uint16_t, uint16_t);
   1051 nxge_status_t nxge_mii_check(p_nxge_t, mii_bmsr_t,
   1052 			mii_bmsr_t, nxge_link_state_t *);
   1053 void nxge_pcs_check(p_nxge_t, uint8_t portn, nxge_link_state_t *);
   1054 nxge_status_t nxge_add_mcast_addr(p_nxge_t, struct ether_addr *);
   1055 nxge_status_t nxge_del_mcast_addr(p_nxge_t, struct ether_addr *);
   1056 nxge_status_t nxge_set_mac_addr(p_nxge_t, struct ether_addr *);
   1057 nxge_status_t nxge_check_bcm8704_link(p_nxge_t, boolean_t *);
   1058 nxge_status_t nxge_check_tn1010_link(p_nxge_t);
   1059 void nxge_link_is_down(p_nxge_t);
   1060 void nxge_link_is_up(p_nxge_t);
   1061 nxge_status_t nxge_link_monitor(p_nxge_t, link_mon_enable_t);
   1062 uint32_t crc32_mchash(p_ether_addr_t);
   1063 nxge_status_t nxge_set_promisc(p_nxge_t, boolean_t);
   1064 nxge_status_t nxge_mac_handle_sys_errors(p_nxge_t);
   1065 nxge_status_t nxge_10g_link_led_on(p_nxge_t);
   1066 nxge_status_t nxge_10g_link_led_off(p_nxge_t);
   1067 nxge_status_t nxge_scan_ports_phy(p_nxge_t, p_nxge_hw_list_t);
   1068 boolean_t nxge_is_valid_local_mac(ether_addr_st);
   1069 nxge_status_t nxge_mac_set_framesize(p_nxge_t);
   1070 
   1071 /* espc (sprom) prototypes */
   1072 nxge_status_t nxge_espc_mac_addrs_get(p_nxge_t);
   1073 nxge_status_t nxge_espc_num_macs_get(p_nxge_t, uint8_t *);
   1074 nxge_status_t nxge_espc_num_ports_get(p_nxge_t);
   1075 nxge_status_t nxge_espc_phy_type_get(p_nxge_t);
   1076 nxge_status_t nxge_espc_verify_chksum(p_nxge_t);
   1077 void nxge_espc_get_next_mac_addr(uint8_t *, uint8_t, struct ether_addr *);
   1078 void nxge_vpd_info_get(p_nxge_t);
   1079 
   1080 
   1081 void nxge_debug_msg(p_nxge_t, uint64_t, char *, ...);
   1082 int nxge_get_nports(p_nxge_t);
   1083 
   1084 void nxge_free_buf(buf_alloc_type_t, uint64_t, uint32_t);
   1085 
   1086 #if defined(sun4v)
   1087 
   1088 uint64_t hv_niu_rx_logical_page_conf(uint64_t, uint64_t,
   1089 	uint64_t, uint64_t);
   1090 #pragma weak	hv_niu_rx_logical_page_conf
   1091 
   1092 uint64_t hv_niu_rx_logical_page_info(uint64_t, uint64_t,
   1093 	uint64_t *, uint64_t *);
   1094 #pragma weak	hv_niu_rx_logical_page_info
   1095 
   1096 uint64_t hv_niu_tx_logical_page_conf(uint64_t, uint64_t,
   1097 	uint64_t, uint64_t);
   1098 #pragma weak	hv_niu_tx_logical_page_conf
   1099 
   1100 uint64_t hv_niu_tx_logical_page_info(uint64_t, uint64_t,
   1101 	uint64_t *, uint64_t *);
   1102 #pragma weak	hv_niu_tx_logical_page_info
   1103 
   1104 uint64_t hv_niu_vr_assign(uint64_t vridx, uint64_t ldc_id, uint32_t *cookie);
   1105 #pragma weak	hv_niu_vr_assign
   1106 
   1107 uint64_t hv_niu_vr_unassign(uint32_t cookie);
   1108 #pragma weak	hv_niu_vr_unassign
   1109 
   1110 uint64_t hv_niu_vr_getinfo(uint32_t cookie, uint64_t *real_start,
   1111     uint64_t *size);
   1112 #pragma weak	hv_niu_vr_getinfo
   1113 
   1114 uint64_t hv_niu_vr_get_rxmap(uint32_t cookie, uint64_t *dma_map);
   1115 #pragma weak	hv_niu_vr_get_rxmap
   1116 
   1117 uint64_t hv_niu_vr_get_txmap(uint32_t cookie, uint64_t *dma_map);
   1118 #pragma weak	hv_niu_vr_get_txmap
   1119 
   1120 uint64_t hv_niu_rx_dma_assign(uint32_t cookie, uint64_t chidx,
   1121     uint64_t *vchidx);
   1122 #pragma weak	hv_niu_rx_dma_assign
   1123 
   1124 uint64_t hv_niu_rx_dma_unassign(uint32_t cookie, uint64_t chidx);
   1125 #pragma weak	hv_niu_rx_dma_unassign
   1126 
   1127 uint64_t hv_niu_tx_dma_assign(uint32_t cookie, uint64_t chidx,
   1128     uint64_t *vchidx);
   1129 #pragma weak	hv_niu_tx_dma_assign
   1130 
   1131 uint64_t hv_niu_tx_dma_unassign(uint32_t cookie, uint64_t chidx);
   1132 #pragma weak	hv_niu_tx_dma_unassign
   1133 
   1134 uint64_t hv_niu_vrrx_logical_page_conf(uint32_t cookie, uint64_t chidx,
   1135     uint64_t pgidx, uint64_t raddr, uint64_t size);
   1136 #pragma weak	hv_niu_vrrx_logical_page_conf
   1137 
   1138 uint64_t hv_niu_vrrx_logical_page_info(uint32_t cookie, uint64_t chidx,
   1139     uint64_t pgidx, uint64_t *raddr, uint64_t *size);
   1140 #pragma weak	hv_niu_vrrx_logical_page_info
   1141 
   1142 uint64_t hv_niu_vrtx_logical_page_conf(uint32_t cookie, uint64_t chidx,
   1143     uint64_t pgidx, uint64_t raddr, uint64_t size);
   1144 #pragma weak	hv_niu_vrtx_logical_page_conf
   1145 
   1146 uint64_t hv_niu_vrtx_logical_page_info(uint32_t cookie, uint64_t chidx,
   1147     uint64_t pgidx, uint64_t *raddr, uint64_t *size);
   1148 #pragma weak	hv_niu_vrtx_logical_page_info
   1149 
   1150 uint64_t hv_niu_cfgh_rx_logical_page_conf(uint64_t, uint64_t, uint64_t,
   1151 	uint64_t, uint64_t);
   1152 #pragma weak	hv_niu_rx_logical_page_conf
   1153 
   1154 uint64_t hv_niu_cfgh_rx_logical_page_info(uint64_t, uint64_t, uint64_t,
   1155 	uint64_t *, uint64_t *);
   1156 #pragma weak	hv_niu_rx_logical_page_info
   1157 
   1158 uint64_t hv_niu_cfgh_tx_logical_page_conf(uint64_t, uint64_t, uint64_t,
   1159 	uint64_t, uint64_t);
   1160 #pragma weak	hv_niu_tx_logical_page_conf
   1161 
   1162 uint64_t hv_niu_cfgh_tx_logical_page_info(uint64_t, uint64_t, uint64_t,
   1163 	uint64_t *, uint64_t *);
   1164 #pragma weak	hv_niu_tx_logical_page_info
   1165 
   1166 uint64_t hv_niu_cfgh_vr_assign(uint64_t, uint64_t vridx, uint64_t ldc_id,
   1167 	uint32_t *cookie);
   1168 #pragma weak	hv_niu_vr_assign
   1169 
   1170 //
   1171 // NIU-specific interrupt API
   1172 //
   1173 uint64_t hv_niu_vrrx_getinfo(uint32_t cookie, uint64_t v_chidx,
   1174     uint64_t *group, uint64_t *logdev);
   1175 #pragma weak	hv_niu_vrrx_getinfo
   1176 
   1177 uint64_t hv_niu_vrtx_getinfo(uint32_t cookie, uint64_t v_chidx,
   1178     uint64_t *group, uint64_t *logdev);
   1179 #pragma weak	hv_niu_vrtx_getinfo
   1180 
   1181 uint64_t hv_niu_vrrx_to_logical_dev(uint32_t cookie, uint64_t v_chidx,
   1182     uint64_t *ldn);
   1183 #pragma weak	hv_niu_vrrx_to_logical_dev
   1184 
   1185 uint64_t hv_niu_vrtx_to_logical_dev(uint32_t cookie, uint64_t v_chidx,
   1186     uint64_t *ldn);
   1187 #pragma weak	hv_niu_vrtx_to_logical_dev
   1188 
   1189 #endif /* defined(sun4v) */
   1190 
   1191 #ifdef NXGE_DEBUG
   1192 char *nxge_dump_packet(char *, int);
   1193 #endif
   1194 
   1195 #endif	/* !_ASM */
   1196 
   1197 #ifdef	__cplusplus
   1198 }
   1199 #endif
   1200 
   1201 #endif	/* _SYS_NXGE_NXGE_IMPL_H */
   1202