xref: /titanic_51/usr/src/uts/common/sys/nxge/nxge_impl.h (revision c22d83cc405a14adc58fe3215604e4f485c0d821)
16f45ec7bSml29623 /*
26f45ec7bSml29623  * CDDL HEADER START
36f45ec7bSml29623  *
46f45ec7bSml29623  * The contents of this file are subject to the terms of the
56f45ec7bSml29623  * Common Development and Distribution License (the "License").
66f45ec7bSml29623  * You may not use this file except in compliance with the License.
76f45ec7bSml29623  *
86f45ec7bSml29623  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
96f45ec7bSml29623  * or http://www.opensolaris.org/os/licensing.
106f45ec7bSml29623  * See the License for the specific language governing permissions
116f45ec7bSml29623  * and limitations under the License.
126f45ec7bSml29623  *
136f45ec7bSml29623  * When distributing Covered Code, include this CDDL HEADER in each
146f45ec7bSml29623  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
156f45ec7bSml29623  * If applicable, add the following below this CDDL HEADER, with the
166f45ec7bSml29623  * fields enclosed by brackets "[]" replaced with your own identifying
176f45ec7bSml29623  * information: Portions Copyright [yyyy] [name of copyright owner]
186f45ec7bSml29623  *
196f45ec7bSml29623  * CDDL HEADER END
206f45ec7bSml29623  */
216f45ec7bSml29623 /*
220dc2366fSVenugopal Iyer  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
236f45ec7bSml29623  * Use is subject to license terms.
246f45ec7bSml29623  */
256f45ec7bSml29623 
266f45ec7bSml29623 #ifndef	_SYS_NXGE_NXGE_IMPL_H
276f45ec7bSml29623 #define	_SYS_NXGE_NXGE_IMPL_H
286f45ec7bSml29623 
296f45ec7bSml29623 #ifdef	__cplusplus
306f45ec7bSml29623 extern "C" {
316f45ec7bSml29623 #endif
326f45ec7bSml29623 
336f45ec7bSml29623 /*
346f45ec7bSml29623  * NIU HV API version definitions.
354df55fdeSJanie Lu  *
364df55fdeSJanie Lu  * If additional major (HV API) is to be supported,
374df55fdeSJanie Lu  * please increment NIU_MAJOR_HI.
384df55fdeSJanie Lu  * If additional minor # is to be supported,
394df55fdeSJanie Lu  * please increment NIU_MINOR_HI.
406f45ec7bSml29623  */
414df55fdeSJanie Lu #define	NIU_MAJOR_HI		2
424df55fdeSJanie Lu #define	NIU_MINOR_HI		1
436f45ec7bSml29623 #define	NIU_MAJOR_VER		1
446f45ec7bSml29623 #define	NIU_MINOR_VER		1
454df55fdeSJanie Lu #define	NIU_MAJOR_VER_2		2
466f45ec7bSml29623 
47da14cebeSEric Cheng #if defined(sun4v)
48da14cebeSEric Cheng 
496f45ec7bSml29623 /*
506f45ec7bSml29623  * NIU HV API v1.0 definitions
516f45ec7bSml29623  */
526f45ec7bSml29623 #define	N2NIU_RX_LP_CONF		0x142
536f45ec7bSml29623 #define	N2NIU_RX_LP_INFO		0x143
546f45ec7bSml29623 #define	N2NIU_TX_LP_CONF		0x144
556f45ec7bSml29623 #define	N2NIU_TX_LP_INFO		0x145
566f45ec7bSml29623 
57da14cebeSEric Cheng #endif /* defined(sun4v) */
58da14cebeSEric Cheng 
596f45ec7bSml29623 #ifndef _ASM
606f45ec7bSml29623 
616f45ec7bSml29623 #include	<sys/types.h>
626f45ec7bSml29623 #include	<sys/byteorder.h>
636f45ec7bSml29623 #include	<sys/debug.h>
646f45ec7bSml29623 #include	<sys/stropts.h>
656f45ec7bSml29623 #include	<sys/stream.h>
666f45ec7bSml29623 #include	<sys/strlog.h>
676f45ec7bSml29623 #include	<sys/strsubr.h>
686f45ec7bSml29623 #include	<sys/cmn_err.h>
696f45ec7bSml29623 #include	<sys/vtrace.h>
706f45ec7bSml29623 #include	<sys/kmem.h>
716f45ec7bSml29623 #include	<sys/ddi.h>
726f45ec7bSml29623 #include	<sys/sunddi.h>
736f45ec7bSml29623 #include	<sys/strsun.h>
746f45ec7bSml29623 #include	<sys/stat.h>
756f45ec7bSml29623 #include	<sys/cpu.h>
766f45ec7bSml29623 #include	<sys/kstat.h>
776f45ec7bSml29623 #include	<inet/common.h>
786f45ec7bSml29623 #include	<inet/ip.h>
796f45ec7bSml29623 #include	<sys/dlpi.h>
806f45ec7bSml29623 #include	<inet/nd.h>
816f45ec7bSml29623 #include	<netinet/in.h>
826f45ec7bSml29623 #include	<sys/ethernet.h>
836f45ec7bSml29623 #include	<sys/vlan.h>
846f45ec7bSml29623 #include	<sys/pci.h>
856f45ec7bSml29623 #include	<sys/taskq.h>
866f45ec7bSml29623 #include	<sys/atomic.h>
876f45ec7bSml29623 
886f45ec7bSml29623 #include 	<sys/nxge/nxge_defs.h>
896f45ec7bSml29623 #include 	<sys/nxge/nxge_hw.h>
906f45ec7bSml29623 #include 	<sys/nxge/nxge_mac.h>
916f45ec7bSml29623 #include	<sys/nxge/nxge_mii.h>
926f45ec7bSml29623 #include	<sys/nxge/nxge_fm.h>
936f45ec7bSml29623 #include	<sys/netlb.h>
946f45ec7bSml29623 
956f45ec7bSml29623 #include	<sys/ddi_intr.h>
96da14cebeSEric Cheng #include 	<sys/mac_provider.h>
976f45ec7bSml29623 #include	<sys/mac_ether.h>
986f45ec7bSml29623 
996f45ec7bSml29623 #if	defined(sun4v)
1006f45ec7bSml29623 #include	<sys/hypervisor_api.h>
1016f45ec7bSml29623 #include 	<sys/machsystm.h>
1026f45ec7bSml29623 #include 	<sys/hsvc.h>
1036f45ec7bSml29623 #endif
1046f45ec7bSml29623 
1051bd6825cSml29623 #include 	<sys/dld.h>
1061bd6825cSml29623 
1076f45ec7bSml29623 /*
1086f45ec7bSml29623  * Handy macros (taken from bge driver)
1096f45ec7bSml29623  */
1106f45ec7bSml29623 #define	RBR_SIZE			4
1116f45ec7bSml29623 #define	DMA_COMMON_CHANNEL(area)	((area.dma_channel))
1126f45ec7bSml29623 #define	DMA_COMMON_VPTR(area)		((area.kaddrp))
1136f45ec7bSml29623 #define	DMA_COMMON_VPTR_INDEX(area, index)	\
1146f45ec7bSml29623 					(((char *)(area.kaddrp)) + \
1156f45ec7bSml29623 					(index * RBR_SIZE))
1166f45ec7bSml29623 #define	DMA_COMMON_HANDLE(area)		((area.dma_handle))
1176f45ec7bSml29623 #define	DMA_COMMON_ACC_HANDLE(area)	((area.acc_handle))
1186f45ec7bSml29623 #define	DMA_COMMON_IOADDR(area)		((area.dma_cookie.dmac_laddress))
1196f45ec7bSml29623 #define	DMA_COMMON_IOADDR_INDEX(area, index)	\
1206f45ec7bSml29623 					((area.dma_cookie.dmac_laddress) + \
1216f45ec7bSml29623 						(index * RBR_SIZE))
1226f45ec7bSml29623 
1236f45ec7bSml29623 #define	DMA_NPI_HANDLE(area)		((area.npi_handle)
1246f45ec7bSml29623 
1256f45ec7bSml29623 #define	DMA_COMMON_SYNC(area, flag)	((void) ddi_dma_sync((area).dma_handle,\
1266f45ec7bSml29623 						(area).offset, (area).alength, \
1276f45ec7bSml29623 						(flag)))
1286f45ec7bSml29623 #define	DMA_COMMON_SYNC_OFFSET(area, bufoffset, len, flag)	\
1296f45ec7bSml29623 					((void) ddi_dma_sync((area).dma_handle,\
1306f45ec7bSml29623 					(area.offset + bufoffset), len, \
1316f45ec7bSml29623 					(flag)))
1326f45ec7bSml29623 
1336f45ec7bSml29623 #define	DMA_COMMON_SYNC_RBR_DESC(area, index, flag)	\
1346f45ec7bSml29623 				((void) ddi_dma_sync((area).dma_handle,\
1356f45ec7bSml29623 				(index * RBR_SIZE), RBR_SIZE,	\
1366f45ec7bSml29623 				(flag)))
1376f45ec7bSml29623 
1386f45ec7bSml29623 #define	DMA_COMMON_SYNC_RBR_DESC_MULTI(area, index, count, flag)	\
1396f45ec7bSml29623 			((void) ddi_dma_sync((area).dma_handle,\
1406f45ec7bSml29623 			(index * RBR_SIZE), count * RBR_SIZE,	\
1416f45ec7bSml29623 				(flag)))
1426f45ec7bSml29623 #define	DMA_COMMON_SYNC_ENTRY(area, index, flag)	\
1436f45ec7bSml29623 				((void) ddi_dma_sync((area).dma_handle,\
1446f45ec7bSml29623 				(index * (area).block_size),	\
1456f45ec7bSml29623 				(area).block_size, \
1466f45ec7bSml29623 				(flag)))
1476f45ec7bSml29623 
1486f45ec7bSml29623 #define	NEXT_ENTRY(index, wrap)		((index + 1) & wrap)
1496f45ec7bSml29623 #define	NEXT_ENTRY_PTR(ptr, first, last)	\
1506f45ec7bSml29623 					((ptr == last) ? first : (ptr + 1))
1516f45ec7bSml29623 
1526f45ec7bSml29623 /*
1536f45ec7bSml29623  * NPI related macros
1546f45ec7bSml29623  */
1556f45ec7bSml29623 #define	NXGE_DEV_NPI_HANDLE(nxgep)	(nxgep->npi_handle)
1566f45ec7bSml29623 
1576f45ec7bSml29623 #define	NPI_PCI_ACC_HANDLE_SET(nxgep, ah) (nxgep->npi_pci_handle.regh = ah)
1586f45ec7bSml29623 #define	NPI_PCI_ADD_HANDLE_SET(nxgep, ap) (nxgep->npi_pci_handle.regp = ap)
1596f45ec7bSml29623 
1606f45ec7bSml29623 #define	NPI_ACC_HANDLE_SET(nxgep, ah)	(nxgep->npi_handle.regh = ah)
1616f45ec7bSml29623 #define	NPI_ADD_HANDLE_SET(nxgep, ap)	\
1626f45ec7bSml29623 		nxgep->npi_handle.is_vraddr = B_FALSE;	\
1636f45ec7bSml29623 		nxgep->npi_handle.function.instance = nxgep->instance;   \
1646f45ec7bSml29623 		nxgep->npi_handle.function.function = nxgep->function_num;   \
1656f45ec7bSml29623 		nxgep->npi_handle.nxgep = (void *) nxgep;   \
1666f45ec7bSml29623 		nxgep->npi_handle.regp = ap;
1676f45ec7bSml29623 
1686f45ec7bSml29623 #define	NPI_REG_ACC_HANDLE_SET(nxgep, ah) (nxgep->npi_reg_handle.regh = ah)
1696f45ec7bSml29623 #define	NPI_REG_ADD_HANDLE_SET(nxgep, ap)	\
1706f45ec7bSml29623 		nxgep->npi_reg_handle.is_vraddr = B_FALSE;	\
1716f45ec7bSml29623 		nxgep->npi_handle.function.instance = nxgep->instance;   \
1726f45ec7bSml29623 		nxgep->npi_handle.function.function = nxgep->function_num;   \
1736f45ec7bSml29623 		nxgep->npi_reg_handle.nxgep = (void *) nxgep;   \
1746f45ec7bSml29623 		nxgep->npi_reg_handle.regp = ap;
1756f45ec7bSml29623 
1766f45ec7bSml29623 #define	NPI_MSI_ACC_HANDLE_SET(nxgep, ah) (nxgep->npi_msi_handle.regh = ah)
1776f45ec7bSml29623 #define	NPI_MSI_ADD_HANDLE_SET(nxgep, ap) (nxgep->npi_msi_handle.regp = ap)
1786f45ec7bSml29623 
1796f45ec7bSml29623 #define	NPI_VREG_ACC_HANDLE_SET(nxgep, ah) (nxgep->npi_vreg_handle.regh = ah)
1806f45ec7bSml29623 #define	NPI_VREG_ADD_HANDLE_SET(nxgep, ap)	\
1816f45ec7bSml29623 		nxgep->npi_vreg_handle.is_vraddr = B_TRUE; \
1826f45ec7bSml29623 		nxgep->npi_handle.function.instance = nxgep->instance;   \
1836f45ec7bSml29623 		nxgep->npi_handle.function.function = nxgep->function_num;   \
1846f45ec7bSml29623 		nxgep->npi_vreg_handle.nxgep = (void *) nxgep;   \
1856f45ec7bSml29623 		nxgep->npi_vreg_handle.regp = ap;
1866f45ec7bSml29623 
1876f45ec7bSml29623 #define	NPI_V2REG_ACC_HANDLE_SET(nxgep, ah) (nxgep->npi_v2reg_handle.regh = ah)
1886f45ec7bSml29623 #define	NPI_V2REG_ADD_HANDLE_SET(nxgep, ap)	\
1896f45ec7bSml29623 		nxgep->npi_v2reg_handle.is_vraddr = B_TRUE; \
1906f45ec7bSml29623 		nxgep->npi_handle.function.instance = nxgep->instance;   \
1916f45ec7bSml29623 		nxgep->npi_handle.function.function = nxgep->function_num;   \
1926f45ec7bSml29623 		nxgep->npi_v2reg_handle.nxgep = (void *) nxgep;   \
1936f45ec7bSml29623 		nxgep->npi_v2reg_handle.regp = ap;
1946f45ec7bSml29623 
1956f45ec7bSml29623 #define	NPI_PCI_ACC_HANDLE_GET(nxgep) (nxgep->npi_pci_handle.regh)
1966f45ec7bSml29623 #define	NPI_PCI_ADD_HANDLE_GET(nxgep) (nxgep->npi_pci_handle.regp)
1976f45ec7bSml29623 #define	NPI_ACC_HANDLE_GET(nxgep) (nxgep->npi_handle.regh)
1986f45ec7bSml29623 #define	NPI_ADD_HANDLE_GET(nxgep) (nxgep->npi_handle.regp)
1996f45ec7bSml29623 #define	NPI_REG_ACC_HANDLE_GET(nxgep) (nxgep->npi_reg_handle.regh)
2006f45ec7bSml29623 #define	NPI_REG_ADD_HANDLE_GET(nxgep) (nxgep->npi_reg_handle.regp)
2016f45ec7bSml29623 #define	NPI_MSI_ACC_HANDLE_GET(nxgep) (nxgep->npi_msi_handle.regh)
2026f45ec7bSml29623 #define	NPI_MSI_ADD_HANDLE_GET(nxgep) (nxgep->npi_msi_handle.regp)
2036f45ec7bSml29623 #define	NPI_VREG_ACC_HANDLE_GET(nxgep) (nxgep->npi_vreg_handle.regh)
2046f45ec7bSml29623 #define	NPI_VREG_ADD_HANDLE_GET(nxgep) (nxgep->npi_vreg_handle.regp)
2056f45ec7bSml29623 #define	NPI_V2REG_ACC_HANDLE_GET(nxgep) (nxgep->npi_v2reg_handle.regh)
2066f45ec7bSml29623 #define	NPI_V2REG_ADD_HANDLE_GET(nxgep) (nxgep->npi_v2reg_handle.regp)
2076f45ec7bSml29623 
2086f45ec7bSml29623 #define	NPI_DMA_ACC_HANDLE_SET(dmap, ah) (dmap->npi_handle.regh = ah)
2096f45ec7bSml29623 #define	NPI_DMA_ACC_HANDLE_GET(dmap) 	(dmap->npi_handle.regh)
2106f45ec7bSml29623 
2116f45ec7bSml29623 /*
2126f45ec7bSml29623  * DMA handles.
2136f45ec7bSml29623  */
2146f45ec7bSml29623 #define	NXGE_DESC_D_HANDLE_GET(desc)	(desc.dma_handle)
2156f45ec7bSml29623 #define	NXGE_DESC_D_IOADD_GET(desc)	(desc.dma_cookie.dmac_laddress)
2166f45ec7bSml29623 #define	NXGE_DMA_IOADD_GET(dma_cookie) (dma_cookie.dmac_laddress)
2176f45ec7bSml29623 #define	NXGE_DMA_AREA_IOADD_GET(dma_area) (dma_area.dma_cookie.dmac_laddress)
2186f45ec7bSml29623 
2196f45ec7bSml29623 #define	LDV_ON(ldv, vector)	((vector >> ldv) & 0x1)
2206f45ec7bSml29623 #define	LDV2_ON_1(ldv, vector)	((vector >> (ldv - 64)) & 0x1)
2216f45ec7bSml29623 #define	LDV2_ON_2(ldv, vector)	(((vector >> 5) >> (ldv - 64)) & 0x1)
2226f45ec7bSml29623 
2236f45ec7bSml29623 typedef uint32_t		nxge_status_t;
2246f45ec7bSml29623 
2256f45ec7bSml29623 typedef enum  {
2266f45ec7bSml29623 	IDLE,
2276f45ec7bSml29623 	PROGRESS,
2286f45ec7bSml29623 	CONFIGURED
2296f45ec7bSml29623 } dev_func_shared_t;
2306f45ec7bSml29623 
2316f45ec7bSml29623 typedef enum  {
2326f45ec7bSml29623 	DVMA,
2336f45ec7bSml29623 	DMA,
2346f45ec7bSml29623 	SDMA
2356f45ec7bSml29623 } dma_method_t;
2366f45ec7bSml29623 
2376f45ec7bSml29623 typedef enum  {
2386f45ec7bSml29623 	BKSIZE_4K,
2396f45ec7bSml29623 	BKSIZE_8K,
2406f45ec7bSml29623 	BKSIZE_16K,
2416f45ec7bSml29623 	BKSIZE_32K
2426f45ec7bSml29623 } nxge_rx_block_size_t;
2436f45ec7bSml29623 
2446f45ec7bSml29623 #ifdef TX_ONE_BUF
2456f45ec7bSml29623 #define	TX_BCOPY_MAX 1514
2466f45ec7bSml29623 #else
2476f45ec7bSml29623 #if	defined(sun4v) && defined(NIU_LP_WORKAROUND)
2486f45ec7bSml29623 #define	TX_BCOPY_MAX	4096
2496f45ec7bSml29623 #define	TX_BCOPY_SIZE	4096
2506f45ec7bSml29623 #else
2516f45ec7bSml29623 #define	TX_BCOPY_MAX	2048
2526f45ec7bSml29623 #define	TX_BCOPY_SIZE	2048
2536f45ec7bSml29623 #endif
2546f45ec7bSml29623 #endif
2556f45ec7bSml29623 
2566f45ec7bSml29623 #define	TX_STREAM_MIN 512
2576f45ec7bSml29623 #define	TX_FASTDVMA_MIN 1024
2586f45ec7bSml29623 
25953f3d8ecSyc148097 /*
26053f3d8ecSyc148097  * Send repeated FMA ereports or display messages about some non-fatal
26153f3d8ecSyc148097  * hardware errors only the the first NXGE_ERROR_SHOW_MAX -1 times
26253f3d8ecSyc148097  */
26353f3d8ecSyc148097 #define	NXGE_ERROR_SHOW_MAX	2
26453f3d8ecSyc148097 
2656f45ec7bSml29623 
2666f45ec7bSml29623 /*
2676f45ec7bSml29623  * Defaults
2686f45ec7bSml29623  */
2697b26d9ffSSantwona Behera #define	NXGE_RDC_RCR_THRESHOLD		32
2707b26d9ffSSantwona Behera #define	NXGE_RDC_RCR_TIMEOUT		8
2716f45ec7bSml29623 
2726f45ec7bSml29623 #define	NXGE_RDC_RCR_THRESHOLD_MAX	1024
2736f45ec7bSml29623 #define	NXGE_RDC_RCR_TIMEOUT_MAX	64
2747b26d9ffSSantwona Behera #define	NXGE_RDC_RCR_THRESHOLD_MIN	8
2756f45ec7bSml29623 #define	NXGE_RDC_RCR_TIMEOUT_MIN	1
2766f45ec7bSml29623 #define	NXGE_RCR_FULL_HEADER		1
2776f45ec7bSml29623 
2786f45ec7bSml29623 #define	NXGE_IS_VLAN_PACKET(ptr)				\
2796f45ec7bSml29623 	((((struct ether_vlan_header *)ptr)->ether_tpid) ==	\
2806f45ec7bSml29623 	htons(VLAN_ETHERTYPE))
2816f45ec7bSml29623 
2826f45ec7bSml29623 typedef enum {
2836f45ec7bSml29623 	NONE,
2846f45ec7bSml29623 	SMALL,
2856f45ec7bSml29623 	MEDIUM,
2866f45ec7bSml29623 	LARGE
2876f45ec7bSml29623 } dma_size_t;
2886f45ec7bSml29623 
2896f45ec7bSml29623 typedef enum {
2906f45ec7bSml29623 	USE_NONE,
2916f45ec7bSml29623 	USE_BCOPY,
2926f45ec7bSml29623 	USE_DVMA,
2936f45ec7bSml29623 	USE_DMA,
2946f45ec7bSml29623 	USE_SDMA
2956f45ec7bSml29623 } dma_type_t;
2966f45ec7bSml29623 
2976f45ec7bSml29623 typedef enum {
2986f45ec7bSml29623 	NOT_IN_USE,
2996f45ec7bSml29623 	HDR_BUF,
3006f45ec7bSml29623 	MTU_BUF,
3016f45ec7bSml29623 	RE_ASSEMBLY_BUF,
3026f45ec7bSml29623 	FREE_BUF
3036f45ec7bSml29623 } rx_page_state_t;
3046f45ec7bSml29623 
3056f45ec7bSml29623 struct _nxge_block_mv_t {
3066f45ec7bSml29623 	uint32_t msg_type;
3076f45ec7bSml29623 	dma_type_t dma_type;
3086f45ec7bSml29623 };
3096f45ec7bSml29623 
3106f45ec7bSml29623 typedef struct _nxge_block_mv_t nxge_block_mv_t, *p_nxge_block_mv_t;
3116f45ec7bSml29623 
3126f45ec7bSml29623 typedef enum {
31359ac0c16Sdavemq 	NIU_TYPE_NONE = 0,
31459ac0c16Sdavemq 
31500161856Syc148097 	/* QGC NIC */
31659ac0c16Sdavemq 	NEPTUNE_4_1GC =
31759ac0c16Sdavemq 	    (NXGE_PORT_1G_COPPER |
31859ac0c16Sdavemq 	    (NXGE_PORT_1G_COPPER << 4) |
31959ac0c16Sdavemq 	    (NXGE_PORT_1G_COPPER << 8) |
32059ac0c16Sdavemq 	    (NXGE_PORT_1G_COPPER << 12)),
32159ac0c16Sdavemq 
32200161856Syc148097 	/* Huron: 2 fiber XAUI cards */
32359ac0c16Sdavemq 	NEPTUNE_2_10GF =
32459ac0c16Sdavemq 	    (NXGE_PORT_10G_FIBRE |
32559ac0c16Sdavemq 	    (NXGE_PORT_10G_FIBRE << 4) |
32659ac0c16Sdavemq 	    (NXGE_PORT_NONE << 8) |
32759ac0c16Sdavemq 	    (NXGE_PORT_NONE << 12)),
32859ac0c16Sdavemq 
32900161856Syc148097 	/* Huron: port0 is a TN1010 copper XAUI */
33000161856Syc148097 	NEPTUNE_1_TN1010 =
33100161856Syc148097 	    (NXGE_PORT_TN1010 |
33200161856Syc148097 	    (NXGE_PORT_NONE << 4) |
33300161856Syc148097 	    (NXGE_PORT_NONE << 8) |
33400161856Syc148097 	    (NXGE_PORT_NONE << 12)),
33500161856Syc148097 
33600161856Syc148097 	/* Huron: port1 is a TN1010 copper XAUI */
33700161856Syc148097 	NEPTUNE_1_NONE_1_TN1010 =
33800161856Syc148097 	    (NXGE_PORT_NONE |
33900161856Syc148097 	    (NXGE_PORT_TN1010 << 4) |
34000161856Syc148097 	    (NXGE_PORT_NONE << 8) |
34100161856Syc148097 	    (NXGE_PORT_NONE << 12)),
34200161856Syc148097 
34300161856Syc148097 	/* Huron: 2 TN1010 copper XAUI cards */
34400161856Syc148097 	NEPTUNE_2_TN1010 =
34500161856Syc148097 	    (NXGE_PORT_TN1010 |
34600161856Syc148097 	    (NXGE_PORT_TN1010 << 4) |
34700161856Syc148097 	    (NXGE_PORT_NONE << 8) |
34800161856Syc148097 	    (NXGE_PORT_NONE << 12)),
34900161856Syc148097 
35000161856Syc148097 	/* Huron: port0 is fiber XAUI, port1 is copper XAUI */
35100161856Syc148097 	NEPTUNE_1_10GF_1_TN1010 =
35200161856Syc148097 	    (NXGE_PORT_10G_FIBRE |
35300161856Syc148097 	    (NXGE_PORT_TN1010 << 4) |
35400161856Syc148097 	    (NXGE_PORT_NONE << 8) |
35500161856Syc148097 	    (NXGE_PORT_NONE << 12)),
35600161856Syc148097 
35700161856Syc148097 	/* Huron: port0 is copper XAUI, port1 is fiber XAUI */
35800161856Syc148097 	NEPTUNE_1_TN1010_1_10GF =
35900161856Syc148097 	    (NXGE_PORT_TN1010 |
36000161856Syc148097 	    (NXGE_PORT_10G_FIBRE << 4) |
36100161856Syc148097 	    (NXGE_PORT_NONE << 8) |
36200161856Syc148097 	    (NXGE_PORT_NONE << 12)),
36300161856Syc148097 
36400161856Syc148097 	/* Maramba: port0 and port1 are fiber XAUIs */
36559ac0c16Sdavemq 	NEPTUNE_2_10GF_2_1GC =
36659ac0c16Sdavemq 	    (NXGE_PORT_10G_FIBRE |
36759ac0c16Sdavemq 	    (NXGE_PORT_10G_FIBRE << 4) |
36859ac0c16Sdavemq 	    (NXGE_PORT_1G_COPPER << 8) |
36959ac0c16Sdavemq 	    (NXGE_PORT_1G_COPPER << 12)),
37059ac0c16Sdavemq 
37100161856Syc148097 	/* Maramba: port0 and port1 are copper TN1010 XAUIs */
37200161856Syc148097 	NEPTUNE_2_TN1010_2_1GC =
37300161856Syc148097 	    (NXGE_PORT_TN1010 |
37400161856Syc148097 	    (NXGE_PORT_TN1010 << 4) |
37500161856Syc148097 	    (NXGE_PORT_1G_COPPER << 8) |
37600161856Syc148097 	    (NXGE_PORT_1G_COPPER << 12)),
37700161856Syc148097 
37800161856Syc148097 	/* Maramba: port0 is copper XAUI, port1 is Fiber XAUI */
37900161856Syc148097 	NEPTUNE_1_TN1010_1_10GF_2_1GC =
38000161856Syc148097 	    (NXGE_PORT_TN1010 |
38100161856Syc148097 	    (NXGE_PORT_10G_FIBRE << 4) |
38200161856Syc148097 	    (NXGE_PORT_1G_COPPER << 8) |
38300161856Syc148097 	    (NXGE_PORT_1G_COPPER << 12)),
38400161856Syc148097 
38500161856Syc148097 	/* Maramba: port0 is fiber XAUI, port1 is copper XAUI */
38600161856Syc148097 	NEPTUNE_1_10GF_1_TN1010_2_1GC =
38700161856Syc148097 	    (NXGE_PORT_10G_FIBRE |
38800161856Syc148097 	    (NXGE_PORT_TN1010 << 4) |
38900161856Syc148097 	    (NXGE_PORT_1G_COPPER << 8) |
39000161856Syc148097 	    (NXGE_PORT_1G_COPPER << 12)),
39100161856Syc148097 
39200161856Syc148097 	/* Maramba: port0 is fiber XAUI */
39359ac0c16Sdavemq 	NEPTUNE_1_10GF_3_1GC =
39459ac0c16Sdavemq 	    (NXGE_PORT_10G_FIBRE |
39559ac0c16Sdavemq 	    (NXGE_PORT_1G_COPPER << 4) |
39659ac0c16Sdavemq 	    (NXGE_PORT_1G_COPPER << 8) |
39759ac0c16Sdavemq 	    (NXGE_PORT_1G_COPPER << 12)),
39859ac0c16Sdavemq 
39900161856Syc148097 	/* Maramba: port0 is TN1010 copper XAUI */
40000161856Syc148097 	NEPTUNE_1_TN1010_3_1GC =
40100161856Syc148097 	    (NXGE_PORT_TN1010 |
40200161856Syc148097 	    (NXGE_PORT_1G_COPPER << 4) |
40300161856Syc148097 	    (NXGE_PORT_1G_COPPER << 8) |
40400161856Syc148097 	    (NXGE_PORT_1G_COPPER << 12)),
40500161856Syc148097 
40600161856Syc148097 	/* Maramba: port1 is fiber XAUI */
40759ac0c16Sdavemq 	NEPTUNE_1_1GC_1_10GF_2_1GC =
40859ac0c16Sdavemq 	    (NXGE_PORT_1G_COPPER |
40959ac0c16Sdavemq 	    (NXGE_PORT_10G_FIBRE << 4) |
41059ac0c16Sdavemq 	    (NXGE_PORT_1G_COPPER << 8) |
41159ac0c16Sdavemq 	    (NXGE_PORT_1G_COPPER << 12)),
41259ac0c16Sdavemq 
41300161856Syc148097 	/* Maramba: port1 is TN1010 copper XAUI */
41400161856Syc148097 	NEPTUNE_1_1GC_1_TN1010_2_1GC =
41500161856Syc148097 	    (NXGE_PORT_1G_COPPER |
41600161856Syc148097 	    (NXGE_PORT_TN1010 << 4) |
41700161856Syc148097 	    (NXGE_PORT_1G_COPPER << 8) |
41800161856Syc148097 	    (NXGE_PORT_1G_COPPER << 12)),
41900161856Syc148097 
42059a835ddSjoycey 	NEPTUNE_2_1GRF =
42159a835ddSjoycey 	    (NXGE_PORT_NONE |
42259a835ddSjoycey 	    (NXGE_PORT_NONE << 4) |
42359a835ddSjoycey 	    (NXGE_PORT_1G_RGMII_FIBER << 8) |
42459a835ddSjoycey 	    (NXGE_PORT_1G_RGMII_FIBER << 12)),
42559a835ddSjoycey 
42659a835ddSjoycey 	NEPTUNE_2_10GF_2_1GRF =
42759a835ddSjoycey 	    (NXGE_PORT_10G_FIBRE |
42859a835ddSjoycey 	    (NXGE_PORT_10G_FIBRE << 4) |
42959a835ddSjoycey 	    (NXGE_PORT_1G_RGMII_FIBER << 8) |
43059a835ddSjoycey 	    (NXGE_PORT_1G_RGMII_FIBER << 12)),
43159a835ddSjoycey 
43259ac0c16Sdavemq 	N2_NIU =
43359ac0c16Sdavemq 	    (NXGE_PORT_RSVD |
43459ac0c16Sdavemq 	    (NXGE_PORT_RSVD << 4) |
43559ac0c16Sdavemq 	    (NXGE_PORT_RSVD << 8) |
43659ac0c16Sdavemq 	    (NXGE_PORT_RSVD << 12))
43759ac0c16Sdavemq 
4386f45ec7bSml29623 } niu_type_t;
4396f45ec7bSml29623 
44000161856Syc148097 /*
4414df55fdeSJanie Lu  * The niu_hw_type is for non-PHY related functions
4424df55fdeSJanie Lu  * designed on various versions of NIU chips (i.e. RF/NIU has
4434df55fdeSJanie Lu  * additional classification features and communicates with
4444df55fdeSJanie Lu  * a different SerDes than N2/NIU).
4454df55fdeSJanie Lu  */
4464df55fdeSJanie Lu typedef enum {
4474df55fdeSJanie Lu 	NIU_HW_TYPE_DEFAULT = 0,	/* N2/NIU */
4484df55fdeSJanie Lu 	NIU_HW_TYPE_RF = 1,		/* RF/NIU */
4494df55fdeSJanie Lu } niu_hw_type_t;
4504df55fdeSJanie Lu 
4514df55fdeSJanie Lu /*
45200161856Syc148097  * P_NEPTUNE_GENERIC:
45300161856Syc148097  *	The cover-all case for Neptune (as opposed to NIU) where we do not
45400161856Syc148097  *	care the exact platform as we do not do anything that is platform
45500161856Syc148097  *	specific.
45600161856Syc148097  * P_NEPTUNE_ATLAS_2PORT:
45700161856Syc148097  *	Dual Port Fiber Neptune based NIC (2XGF)
45800161856Syc148097  * P_NEPTUNE_ATLAS_4PORT:
45900161856Syc148097  *	Quad Port Copper Neptune based NIC (QGC)
46000161856Syc148097  * P_NEPTUNE_NIU:
46100161856Syc148097  *	This is NIU. Could be Huron, Glendale, Monza or any other NIU based
46200161856Syc148097  *	platform.
46300161856Syc148097  */
4646f45ec7bSml29623 typedef enum {
46559ac0c16Sdavemq 	P_NEPTUNE_NONE,
4662d17280bSsbehera 	P_NEPTUNE_GENERIC,
4672e59129aSraghus 	P_NEPTUNE_ATLAS_2PORT,
4682e59129aSraghus 	P_NEPTUNE_ATLAS_4PORT,
46959ac0c16Sdavemq 	P_NEPTUNE_MARAMBA_P0,
47059ac0c16Sdavemq 	P_NEPTUNE_MARAMBA_P1,
471d81011f0Ssbehera 	P_NEPTUNE_ALONSO,
47223b952a3SSantwona Behera 	P_NEPTUNE_ROCK,
47359ac0c16Sdavemq 	P_NEPTUNE_NIU
47459ac0c16Sdavemq } platform_type_t;
47559ac0c16Sdavemq 
4762e59129aSraghus #define	NXGE_IS_VALID_NEPTUNE_TYPE(nxgep) \
4772e59129aSraghus 	(((nxgep->platform_type) == P_NEPTUNE_ATLAS_2PORT) || \
4782e59129aSraghus 	    ((nxgep->platform_type) == P_NEPTUNE_ATLAS_4PORT) || \
4792e59129aSraghus 	    ((nxgep->platform_type) == P_NEPTUNE_MARAMBA_P0) || \
480d81011f0Ssbehera 	    ((nxgep->platform_type) == P_NEPTUNE_MARAMBA_P1) || \
4812d17280bSsbehera 	    ((nxgep->platform_type) == P_NEPTUNE_GENERIC) || \
48223b952a3SSantwona Behera 	    ((nxgep->platform_type) == P_NEPTUNE_ALONSO) || \
48323b952a3SSantwona Behera 	    ((nxgep->platform_type) == P_NEPTUNE_ROCK))
48459ac0c16Sdavemq 
485cb9d3ae6Smisaki #define	NXGE_IS_XAUI_PLATFORM(nxgep) \
486cb9d3ae6Smisaki 	(((nxgep->platform_type) == P_NEPTUNE_NIU) || \
487cb9d3ae6Smisaki 	    ((nxgep->platform_type) == P_NEPTUNE_MARAMBA_P0) || \
488cb9d3ae6Smisaki 	    ((nxgep->platform_type) == P_NEPTUNE_MARAMBA_P1))
489cb9d3ae6Smisaki 
490cb9d3ae6Smisaki 
49159ac0c16Sdavemq typedef enum {
4926f45ec7bSml29623 	CFG_DEFAULT = 0,	/* default cfg */
4936f45ec7bSml29623 	CFG_EQUAL,	/* Equal */
4946f45ec7bSml29623 	CFG_FAIR,	/* Equal */
4956f45ec7bSml29623 	CFG_CLASSIFY,
4966f45ec7bSml29623 	CFG_L2_CLASSIFY,
4976f45ec7bSml29623 	CFG_L3_CLASSIFY,
4986f45ec7bSml29623 	CFG_L3_DISTRIBUTE,
4996f45ec7bSml29623 	CFG_L3_WEB,
5006f45ec7bSml29623 	CFG_L3_TCAM,
5016f45ec7bSml29623 	CFG_NOT_SPECIFIED,
5026f45ec7bSml29623 	CFG_CUSTOM	/* Custom */
5036f45ec7bSml29623 } cfg_type_t;
5046f45ec7bSml29623 
5056f45ec7bSml29623 typedef enum {
5066f45ec7bSml29623 	NO_MSG = 0x0,		/* No message output or storage. */
5076f45ec7bSml29623 	CONSOLE = 0x1,		/* Messages are go to the console. */
5086f45ec7bSml29623 	BUFFER = 0x2,		/* Messages are go to the system buffer. */
5096f45ec7bSml29623 	CON_BUF = 0x3,		/* Messages are go to the console and */
5106f45ec7bSml29623 				/* system buffer. */
5116f45ec7bSml29623 	VERBOSE = 0x4		/* Messages are go out only in VERBOSE node. */
5126f45ec7bSml29623 } out_msg_t, *p_out_msg_t;
5136f45ec7bSml29623 
5146f45ec7bSml29623 typedef enum {
5156f45ec7bSml29623 	DBG_NO_MSG = 0x0,	/* No message output or storage. */
5166f45ec7bSml29623 	DBG_CONSOLE = 0x1,	/* Messages are go to the console. */
5176f45ec7bSml29623 	DBG_BUFFER = 0x2,	/* Messages are go to the system buffer. */
5186f45ec7bSml29623 	DBG_CON_BUF = 0x3,	/* Messages are go to the console and */
5196f45ec7bSml29623 				/* system buffer. */
5206f45ec7bSml29623 	STR_LOG = 4		/* Sessage sent to streams logging driver. */
5216f45ec7bSml29623 } out_dbgmsg_t, *p_out_dbgmsg_t;
5226f45ec7bSml29623 
523678453a8Sspeer typedef enum {
524678453a8Sspeer 	DDI_MEM_ALLOC,		/* default (use ddi_dma_mem_alloc) */
525678453a8Sspeer 	KMEM_ALLOC,		/* use kmem_alloc(). */
526678453a8Sspeer 	CONTIG_MEM_ALLOC	/* use contig_mem_alloc() (N2/NIU only) */
527678453a8Sspeer } buf_alloc_type_t;
5286f45ec7bSml29623 
529678453a8Sspeer #define	BUF_ALLOCATED		0x00000001
530678453a8Sspeer #define	BUF_ALLOCATED_WAIT_FREE	0x00000002
5316f45ec7bSml29623 
5326f45ec7bSml29623 typedef struct ether_addr ether_addr_st, *p_ether_addr_t;
5336f45ec7bSml29623 typedef struct ether_header ether_header_t, *p_ether_header_t;
5346f45ec7bSml29623 typedef queue_t *p_queue_t;
5356f45ec7bSml29623 typedef mblk_t *p_mblk_t;
5366f45ec7bSml29623 
5376f45ec7bSml29623 /*
53859ac0c16Sdavemq  * Generic phy table to support different phy types.
53900161856Syc148097  *
54000161856Syc148097  * The argument for check_link is nxgep, which is passed to check_link
54100161856Syc148097  * as an argument to the timer routine.
54259ac0c16Sdavemq  */
54359ac0c16Sdavemq typedef struct _nxge_xcvr_table {
54459ac0c16Sdavemq 	nxge_status_t	(*serdes_init)	();	/* Serdes init routine */
54559ac0c16Sdavemq 	nxge_status_t	(*xcvr_init)	();	/* xcvr init routine */
54659ac0c16Sdavemq 	nxge_status_t	(*link_intr_stop) ();	/* Link intr disable routine */
54759ac0c16Sdavemq 	nxge_status_t	(*link_intr_start) ();	/* Link intr enable routine */
54859ac0c16Sdavemq 	nxge_status_t	(*check_link) ();	/* Link check routine */
54959ac0c16Sdavemq 
55059ac0c16Sdavemq 	uint32_t	xcvr_inuse;
55159ac0c16Sdavemq } nxge_xcvr_table_t, *p_nxge_xcvr_table_t;
55259ac0c16Sdavemq 
55359ac0c16Sdavemq /*
5546f45ec7bSml29623  * Common DMA data elements.
5556f45ec7bSml29623  */
556678453a8Sspeer typedef struct _nxge_dma_pool_t nxge_dma_pool_t, *p_nxge_dma_pool_t;
557678453a8Sspeer 
5586f45ec7bSml29623 struct _nxge_dma_common_t {
5596f45ec7bSml29623 	uint16_t		dma_channel;
5606f45ec7bSml29623 	void			*kaddrp;
5616f45ec7bSml29623 	void			*last_kaddrp;
5626f45ec7bSml29623 	void			*ioaddr_pp;
5636f45ec7bSml29623 	void			*first_ioaddr_pp;
5646f45ec7bSml29623 	void			*last_ioaddr_pp;
5656f45ec7bSml29623 	ddi_dma_cookie_t 	dma_cookie;
5666f45ec7bSml29623 	uint32_t		ncookies;
5676f45ec7bSml29623 
5686f45ec7bSml29623 	ddi_dma_handle_t	dma_handle;
5696f45ec7bSml29623 	nxge_os_acc_handle_t	acc_handle;
5706f45ec7bSml29623 	npi_handle_t		npi_handle;
5716f45ec7bSml29623 
5726f45ec7bSml29623 	size_t			block_size;
5736f45ec7bSml29623 	uint32_t		nblocks;
5746f45ec7bSml29623 	size_t			alength;
5756f45ec7bSml29623 	uint_t			offset;
5766f45ec7bSml29623 	uint_t			dma_chunk_index;
5776f45ec7bSml29623 	void			*orig_ioaddr_pp;
5786f45ec7bSml29623 	uint64_t		orig_vatopa;
5796f45ec7bSml29623 	void			*orig_kaddrp;
5806f45ec7bSml29623 	size_t			orig_alength;
5816f45ec7bSml29623 	boolean_t		contig_alloc_type;
582678453a8Sspeer 	/*
583678453a8Sspeer 	 * Receive buffers may be allocated using
584678453a8Sspeer 	 * kmem_alloc(). The buffer free function
585678453a8Sspeer 	 * depends on its allocation function.
586678453a8Sspeer 	 */
587678453a8Sspeer 	boolean_t		kmem_alloc_type;
588678453a8Sspeer 	uint32_t		buf_alloc_state;
589678453a8Sspeer 	buf_alloc_type_t	buf_alloc_type;
590678453a8Sspeer 	p_nxge_dma_pool_t	rx_buf_pool_p;
5916f45ec7bSml29623 };
5926f45ec7bSml29623 
5936f45ec7bSml29623 typedef struct _nxge_t nxge_t, *p_nxge_t;
5946f45ec7bSml29623 typedef struct _nxge_dma_common_t nxge_dma_common_t, *p_nxge_dma_common_t;
5956f45ec7bSml29623 
596678453a8Sspeer struct _nxge_dma_pool_t {
5976f45ec7bSml29623 	p_nxge_dma_common_t	*dma_buf_pool_p;
5986f45ec7bSml29623 	uint32_t		ndmas;
5996f45ec7bSml29623 	uint32_t		*num_chunks;
6006f45ec7bSml29623 	boolean_t		buf_allocated;
601678453a8Sspeer };
6026f45ec7bSml29623 
6036f45ec7bSml29623 /*
6046f45ec7bSml29623  * Each logical device (69):
6056f45ec7bSml29623  *	- LDG #
6066f45ec7bSml29623  *	- flag bits
6076f45ec7bSml29623  *	- masks.
6086f45ec7bSml29623  *	- interrupt handler function.
6096f45ec7bSml29623  *
6106f45ec7bSml29623  * Generic system interrupt handler with two arguments:
6116f45ec7bSml29623  *	(nxge_sys_intr_t)
6126f45ec7bSml29623  *	Per device instance data structure
6136f45ec7bSml29623  *	Logical group data structure.
6146f45ec7bSml29623  *
6156f45ec7bSml29623  * Logical device interrupt handler with two arguments:
6166f45ec7bSml29623  *	(nxge_ldv_intr_t)
6176f45ec7bSml29623  *	Per device instance data structure
6186f45ec7bSml29623  *	Logical device number
6196f45ec7bSml29623  */
6206f45ec7bSml29623 typedef struct	_nxge_ldg_t nxge_ldg_t, *p_nxge_ldg_t;
6216f45ec7bSml29623 typedef struct	_nxge_ldv_t nxge_ldv_t, *p_nxge_ldv_t;
6226f45ec7bSml29623 typedef uint_t	(*nxge_sys_intr_t)(void *arg1, void *arg2);
6236f45ec7bSml29623 typedef uint_t	(*nxge_ldv_intr_t)(void *arg1, void *arg2);
6246f45ec7bSml29623 
6256f45ec7bSml29623 /*
6266f45ec7bSml29623  * Each logical device Group (64) needs to have the following
6276f45ec7bSml29623  * configurations:
6286f45ec7bSml29623  *	- timer counter (6 bits)
6296f45ec7bSml29623  *	- timer resolution (20 bits, number of system clocks)
6306f45ec7bSml29623  *	- system data (7 bits)
6316f45ec7bSml29623  */
6326f45ec7bSml29623 struct _nxge_ldg_t {
6336f45ec7bSml29623 	uint8_t			ldg;		/* logical group number */
6346f45ec7bSml29623 	uint8_t			vldg_index;
6356f45ec7bSml29623 	boolean_t		arm;
6366f45ec7bSml29623 	uint16_t		ldg_timer;	/* counter */
6376f45ec7bSml29623 	uint8_t			func;
6386f45ec7bSml29623 	uint8_t			vector;
6396f45ec7bSml29623 	uint8_t			intdata;
6406f45ec7bSml29623 	uint8_t			nldvs;
6416f45ec7bSml29623 	p_nxge_ldv_t		ldvp;
6426f45ec7bSml29623 	nxge_sys_intr_t		sys_intr_handler;
6436f45ec7bSml29623 	p_nxge_t		nxgep;
6440dc2366fSVenugopal Iyer 	uint32_t		htable_idx;
6456f45ec7bSml29623 };
6466f45ec7bSml29623 
6476f45ec7bSml29623 struct _nxge_ldv_t {
6486f45ec7bSml29623 	uint8_t			ldg_assigned;
6496f45ec7bSml29623 	uint8_t			ldv;
6506f45ec7bSml29623 	boolean_t		is_rxdma;
6516f45ec7bSml29623 	boolean_t		is_txdma;
6526f45ec7bSml29623 	boolean_t		is_mif;
6536f45ec7bSml29623 	boolean_t		is_mac;
6546f45ec7bSml29623 	boolean_t		is_syserr;
6556f45ec7bSml29623 	boolean_t		use_timer;
6566f45ec7bSml29623 	uint8_t			channel;
6576f45ec7bSml29623 	uint8_t			vdma_index;
6586f45ec7bSml29623 	uint8_t			func;
6596f45ec7bSml29623 	p_nxge_ldg_t		ldgp;
6606f45ec7bSml29623 	uint8_t			ldv_flags;
6616f45ec7bSml29623 	uint8_t			ldv_ldf_masks;
6626f45ec7bSml29623 	nxge_ldv_intr_t		ldv_intr_handler;
6636f45ec7bSml29623 	p_nxge_t		nxgep;
6646f45ec7bSml29623 };
6656f45ec7bSml29623 
6666f45ec7bSml29623 typedef struct _nxge_logical_page_t {
6676f45ec7bSml29623 	uint16_t		dma;
6686f45ec7bSml29623 	uint16_t		page;
6696f45ec7bSml29623 	boolean_t		valid;
6706f45ec7bSml29623 	uint64_t		mask;
6716f45ec7bSml29623 	uint64_t		value;
6726f45ec7bSml29623 	uint64_t		reloc;
6736f45ec7bSml29623 	uint32_t		handle;
6746f45ec7bSml29623 } nxge_logical_page_t, *p_nxge_logical_page_t;
6756f45ec7bSml29623 
6766f45ec7bSml29623 /*
6776f45ec7bSml29623  * (Internal) return values from ioctl subroutines.
6786f45ec7bSml29623  */
6796f45ec7bSml29623 enum nxge_ioc_reply {
6806f45ec7bSml29623 	IOC_INVAL = -1,				/* bad, NAK with EINVAL	*/
6816f45ec7bSml29623 	IOC_DONE,				/* OK, reply sent	*/
6826f45ec7bSml29623 	IOC_ACK,				/* OK, just send ACK	*/
6836f45ec7bSml29623 	IOC_REPLY,				/* OK, just send reply	*/
6846f45ec7bSml29623 	IOC_RESTART_ACK,			/* OK, restart & ACK	*/
6856f45ec7bSml29623 	IOC_RESTART_REPLY			/* OK, restart & reply	*/
6866f45ec7bSml29623 };
6876f45ec7bSml29623 
6886f45ec7bSml29623 typedef struct _pci_cfg_t {
6896f45ec7bSml29623 	uint16_t vendorid;
6906f45ec7bSml29623 	uint16_t devid;
6916f45ec7bSml29623 	uint16_t command;
6926f45ec7bSml29623 	uint16_t status;
6936f45ec7bSml29623 	uint8_t  revid;
6946f45ec7bSml29623 	uint8_t  res0;
6956f45ec7bSml29623 	uint16_t junk1;
6966f45ec7bSml29623 	uint8_t  cache_line;
6976f45ec7bSml29623 	uint8_t  latency;
6986f45ec7bSml29623 	uint8_t  header;
6996f45ec7bSml29623 	uint8_t  bist;
7006f45ec7bSml29623 	uint32_t base;
7016f45ec7bSml29623 	uint32_t base14;
7026f45ec7bSml29623 	uint32_t base18;
7036f45ec7bSml29623 	uint32_t base1c;
7046f45ec7bSml29623 	uint32_t base20;
7056f45ec7bSml29623 	uint32_t base24;
7066f45ec7bSml29623 	uint32_t base28;
7076f45ec7bSml29623 	uint32_t base2c;
7086f45ec7bSml29623 	uint32_t base30;
7096f45ec7bSml29623 	uint32_t res1[2];
7106f45ec7bSml29623 	uint8_t int_line;
7116f45ec7bSml29623 	uint8_t int_pin;
7126f45ec7bSml29623 	uint8_t	min_gnt;
7136f45ec7bSml29623 	uint8_t max_lat;
7146f45ec7bSml29623 } pci_cfg_t, *p_pci_cfg_t;
7156f45ec7bSml29623 
7166f45ec7bSml29623 typedef struct _dev_regs_t {
7176f45ec7bSml29623 	nxge_os_acc_handle_t	nxge_pciregh;	/* PCI config DDI IO handle */
7186f45ec7bSml29623 	p_pci_cfg_t		nxge_pciregp;	/* mapped PCI registers */
7196f45ec7bSml29623 
7206f45ec7bSml29623 	nxge_os_acc_handle_t	nxge_regh;	/* device DDI IO (BAR 0) */
7216f45ec7bSml29623 	void			*nxge_regp;	/* mapped device registers */
7226f45ec7bSml29623 
7236f45ec7bSml29623 	nxge_os_acc_handle_t	nxge_msix_regh;	/* MSI/X DDI handle (BAR 2) */
7246f45ec7bSml29623 	void 			*nxge_msix_regp; /* MSI/X register */
7256f45ec7bSml29623 
7266f45ec7bSml29623 	nxge_os_acc_handle_t	nxge_vir_regh;	/* virtualization (BAR 4) */
7276f45ec7bSml29623 	unsigned char		*nxge_vir_regp;	/* virtualization register */
7286f45ec7bSml29623 
7296f45ec7bSml29623 	nxge_os_acc_handle_t	nxge_vir2_regh;	/* second virtualization */
7306f45ec7bSml29623 	unsigned char		*nxge_vir2_regp; /* second virtualization */
7316f45ec7bSml29623 
7326f45ec7bSml29623 	nxge_os_acc_handle_t	nxge_romh;	/* fcode rom handle */
7336f45ec7bSml29623 	unsigned char		*nxge_romp;	/* fcode pointer */
7346f45ec7bSml29623 } dev_regs_t, *p_dev_regs_t;
7356f45ec7bSml29623 
7366f45ec7bSml29623 
7376f45ec7bSml29623 typedef struct _nxge_mac_addr_t {
7386f45ec7bSml29623 	ether_addr_t	addr;
7396f45ec7bSml29623 	uint_t		flags;
7406f45ec7bSml29623 } nxge_mac_addr_t;
7416f45ec7bSml29623 
7426f45ec7bSml29623 /*
7436f45ec7bSml29623  * The hardware supports 1 unique MAC and 16 alternate MACs (num_mmac)
7446f45ec7bSml29623  * for each XMAC port and supports 1 unique MAC and 7 alternate MACs
7456f45ec7bSml29623  * for each BMAC port.  The number of MACs assigned by the factory is
7466f45ec7bSml29623  * different and is as follows,
7476f45ec7bSml29623  * 	BMAC port:		   num_factory_mmac = num_mmac = 7
7486f45ec7bSml29623  *	XMAC port on a 2-port NIC: num_factory_mmac = num_mmac - 1 = 15
7496f45ec7bSml29623  *	XMAC port on a 4-port NIC: num_factory_mmac = 7
7506f45ec7bSml29623  * So num_factory_mmac is smaller than num_mmac.  nxge_m_mmac_add uses
7516f45ec7bSml29623  * num_mmac and nxge_m_mmac_reserve uses num_factory_mmac.
7526f45ec7bSml29623  *
7536f45ec7bSml29623  * total_factory_macs is the total number of factory MACs, including
7546f45ec7bSml29623  * the unique MAC, assigned to a Neptune based NIC card, it is 32.
7556f45ec7bSml29623  */
7566f45ec7bSml29623 typedef struct _nxge_mmac_t {
7576f45ec7bSml29623 	uint8_t		total_factory_macs;
7586f45ec7bSml29623 	uint8_t		num_mmac;
7596f45ec7bSml29623 	uint8_t		num_factory_mmac;
7606f45ec7bSml29623 	nxge_mac_addr_t	mac_pool[XMAC_MAX_ADDR_ENTRY];
7616f45ec7bSml29623 	ether_addr_t	factory_mac_pool[XMAC_MAX_ADDR_ENTRY];
7626f45ec7bSml29623 	uint8_t		naddrfree;  /* number of alt mac addr available */
7636f45ec7bSml29623 } nxge_mmac_t;
7646f45ec7bSml29623 
7656f45ec7bSml29623 /*
7666f45ec7bSml29623  * mmac stats structure
7676f45ec7bSml29623  */
7686f45ec7bSml29623 typedef struct _nxge_mmac_stats_t {
7696f45ec7bSml29623 	uint8_t mmac_max_cnt;
7706f45ec7bSml29623 	uint8_t	mmac_avail_cnt;
7716f45ec7bSml29623 	struct ether_addr mmac_avail_pool[16];
7726f45ec7bSml29623 } nxge_mmac_stats_t, *p_nxge_mmac_stats_t;
7736f45ec7bSml29623 
774da14cebeSEric Cheng /*
775da14cebeSEric Cheng  * Copied from mac.h. Should be cleaned up by driver.
776da14cebeSEric Cheng  */
777da14cebeSEric Cheng #define	MMAC_SLOT_USED		0x1   /* address slot used */
778da14cebeSEric Cheng #define	MMAC_VENDOR_ADDR	0x2   /* address returned is vendor supplied */
779da14cebeSEric Cheng 
780da14cebeSEric Cheng 
7816f45ec7bSml29623 #define	NXGE_MAX_MMAC_ADDRS	32
7826f45ec7bSml29623 #define	NXGE_NUM_MMAC_ADDRS	8
78356d930aeSspeer #define	NXGE_NUM_OF_PORTS_QUAD	4
78456d930aeSspeer #define	NXGE_NUM_OF_PORTS_DUAL	2
78556d930aeSspeer 
7862e59129aSraghus #define	NXGE_QGC_LP_BM_STR		"501-7606"
7872e59129aSraghus #define	NXGE_2XGF_LP_BM_STR		"501-7283"
7882e59129aSraghus #define	NXGE_QGC_PEM_BM_STR		"501-7765"
7892e59129aSraghus #define	NXGE_2XGF_PEM_BM_STR		"501-7626"
790d81011f0Ssbehera #define	NXGE_ALONSO_BM_STR		"373-0202-01"
791d81011f0Ssbehera #define	NXGE_ALONSO_MODEL_STR		"SUNW,CP3220"
792321febdeSsbehera #define	NXGE_RFEM_BM_STR		"501-7961-01"
793321febdeSsbehera #define	NXGE_RFEM_MODEL_STR		"SUNW,pcie-rfem"
79459a835ddSjoycey #define	NXGE_ARTM_BM_STR		"375-3544-01"
79559a835ddSjoycey #define	NXGE_ARTM_MODEL_STR		"SUNW,pcie-artm"
79623b952a3SSantwona Behera /* ROCK OBP creates a compatible property for ROCK */
79723b952a3SSantwona Behera #define	NXGE_ROCK_COMPATIBLE		"SUNW,rock-pciex108e,abcd"
79856d930aeSspeer #define	NXGE_EROM_LEN			1048576
7996f45ec7bSml29623 
8006f45ec7bSml29623 #include 	<sys/nxge/nxge_common_impl.h>
8016f45ec7bSml29623 #include 	<sys/nxge/nxge_common.h>
8026f45ec7bSml29623 #include	<sys/nxge/nxge_txc.h>
8036f45ec7bSml29623 #include	<sys/nxge/nxge_rxdma.h>
8046f45ec7bSml29623 #include	<sys/nxge/nxge_txdma.h>
8056f45ec7bSml29623 #include	<sys/nxge/nxge_fflp.h>
8066f45ec7bSml29623 #include	<sys/nxge/nxge_ipp.h>
8076f45ec7bSml29623 #include	<sys/nxge/nxge_zcp.h>
8086f45ec7bSml29623 #include	<sys/nxge/nxge_fzc.h>
8096f45ec7bSml29623 #include	<sys/nxge/nxge_flow.h>
8106f45ec7bSml29623 #include	<sys/nxge/nxge_virtual.h>
8116f45ec7bSml29623 
81256d930aeSspeer #include	<npi_espc.h>
81356d930aeSspeer #include	<npi_vir.h>
81456d930aeSspeer 
8156f45ec7bSml29623 #include 	<sys/nxge/nxge.h>
8166f45ec7bSml29623 
8176f45ec7bSml29623 #include	<sys/modctl.h>
8186f45ec7bSml29623 #include	<sys/pattr.h>
8196f45ec7bSml29623 
8206f45ec7bSml29623 extern int secpolicy_net_config(const cred_t *, boolean_t);
8216f45ec7bSml29623 extern void nxge_fm_report_error(p_nxge_t, uint8_t,
8226f45ec7bSml29623 			uint8_t, nxge_fm_ereport_id_t);
8236f45ec7bSml29623 extern int fm_check_acc_handle(ddi_acc_handle_t);
8246f45ec7bSml29623 extern int fm_check_dma_handle(ddi_dma_handle_t);
8256f45ec7bSml29623 
8266f45ec7bSml29623 /* nxge_classify.c */
8276f45ec7bSml29623 nxge_status_t nxge_classify_init(p_nxge_t);
8286f45ec7bSml29623 nxge_status_t nxge_classify_uninit(p_nxge_t);
8296f45ec7bSml29623 nxge_status_t nxge_set_hw_classify_config(p_nxge_t);
8306f45ec7bSml29623 nxge_status_t nxge_classify_exit_sw(p_nxge_t);
8316f45ec7bSml29623 
8326f45ec7bSml29623 /* nxge_fflp.c */
8336f45ec7bSml29623 void nxge_put_tcam(p_nxge_t, p_mblk_t);
8346f45ec7bSml29623 void nxge_get_tcam(p_nxge_t, p_mblk_t);
8356f45ec7bSml29623 nxge_status_t nxge_classify_init_hw(p_nxge_t);
8366f45ec7bSml29623 nxge_status_t nxge_classify_init_sw(p_nxge_t);
8376f45ec7bSml29623 nxge_status_t nxge_fflp_ip_class_config_all(p_nxge_t);
8386f45ec7bSml29623 nxge_status_t nxge_fflp_ip_class_config(p_nxge_t, tcam_class_t,
8396f45ec7bSml29623 				    uint32_t);
8406f45ec7bSml29623 
8416f45ec7bSml29623 nxge_status_t nxge_fflp_ip_class_config_get(p_nxge_t,
8426f45ec7bSml29623 				    tcam_class_t,
8436f45ec7bSml29623 				    uint32_t *);
8446f45ec7bSml29623 
8456f45ec7bSml29623 nxge_status_t nxge_cfg_ip_cls_flow_key(p_nxge_t, tcam_class_t,
8466f45ec7bSml29623 				    uint32_t);
8476f45ec7bSml29623 
8486f45ec7bSml29623 nxge_status_t nxge_fflp_ip_usr_class_config(p_nxge_t, tcam_class_t,
8496f45ec7bSml29623 				    uint32_t);
8506f45ec7bSml29623 
8516f45ec7bSml29623 uint64_t nxge_classify_get_cfg_value(p_nxge_t, uint8_t, uint8_t);
8526f45ec7bSml29623 nxge_status_t nxge_add_flow(p_nxge_t, flow_resource_t *);
8536f45ec7bSml29623 nxge_status_t nxge_fflp_config_tcam_enable(p_nxge_t);
8546f45ec7bSml29623 nxge_status_t nxge_fflp_config_tcam_disable(p_nxge_t);
8556f45ec7bSml29623 
8566f45ec7bSml29623 nxge_status_t nxge_fflp_config_hash_lookup_enable(p_nxge_t);
8576f45ec7bSml29623 nxge_status_t nxge_fflp_config_hash_lookup_disable(p_nxge_t);
8586f45ec7bSml29623 
8596f45ec7bSml29623 nxge_status_t nxge_fflp_config_llc_snap_enable(p_nxge_t);
8606f45ec7bSml29623 nxge_status_t nxge_fflp_config_llc_snap_disable(p_nxge_t);
8616f45ec7bSml29623 
8626f45ec7bSml29623 nxge_status_t nxge_logical_mac_assign_rdc_table(p_nxge_t, uint8_t);
8636f45ec7bSml29623 nxge_status_t nxge_fflp_config_vlan_table(p_nxge_t, uint16_t);
8646f45ec7bSml29623 
8656f45ec7bSml29623 nxge_status_t nxge_fflp_set_hash1(p_nxge_t, uint32_t);
8666f45ec7bSml29623 
8676f45ec7bSml29623 nxge_status_t nxge_fflp_set_hash2(p_nxge_t, uint16_t);
8686f45ec7bSml29623 
8696f45ec7bSml29623 nxge_status_t nxge_fflp_init_hostinfo(p_nxge_t);
8706f45ec7bSml29623 
8716f45ec7bSml29623 void nxge_handle_tcam_fragment_bug(p_nxge_t);
8724df55fdeSJanie Lu int nxge_rxclass_ioctl(p_nxge_t, queue_t *, mblk_t *);
8734df55fdeSJanie Lu int nxge_rxhash_ioctl(p_nxge_t, queue_t *, mblk_t *);
8744df55fdeSJanie Lu 
8756f45ec7bSml29623 nxge_status_t nxge_fflp_hw_reset(p_nxge_t);
8766f45ec7bSml29623 nxge_status_t nxge_fflp_handle_sys_errors(p_nxge_t);
8776f45ec7bSml29623 nxge_status_t nxge_zcp_handle_sys_errors(p_nxge_t);
8786f45ec7bSml29623 
8796f45ec7bSml29623 /* nxge_kstats.c */
8806f45ec7bSml29623 void nxge_init_statsp(p_nxge_t);
8816f45ec7bSml29623 void nxge_setup_kstats(p_nxge_t);
882678453a8Sspeer void nxge_setup_rdc_kstats(p_nxge_t, int);
883678453a8Sspeer void nxge_setup_tdc_kstats(p_nxge_t, int);
8846f45ec7bSml29623 void nxge_destroy_kstats(p_nxge_t);
8856f45ec7bSml29623 int nxge_port_kstat_update(kstat_t *, int);
8866f45ec7bSml29623 void nxge_save_cntrs(p_nxge_t);
8876f45ec7bSml29623 
8886f45ec7bSml29623 int nxge_m_stat(void *arg, uint_t, uint64_t *);
8890dc2366fSVenugopal Iyer int nxge_rx_ring_stat(mac_ring_driver_t, uint_t, uint64_t *);
8900dc2366fSVenugopal Iyer int nxge_tx_ring_stat(mac_ring_driver_t, uint_t, uint64_t *);
8916f45ec7bSml29623 
8926f45ec7bSml29623 /* nxge_hw.c */
8936f45ec7bSml29623 void
8946f45ec7bSml29623 nxge_hw_ioctl(p_nxge_t, queue_t *, mblk_t *, struct iocblk *);
8956f45ec7bSml29623 void nxge_loopback_ioctl(p_nxge_t, queue_t *, mblk_t *, struct iocblk *);
896321febdeSsbehera nxge_status_t nxge_global_reset(p_nxge_t);
8976f45ec7bSml29623 uint_t nxge_intr(void *, void *);
8986f45ec7bSml29623 void nxge_intr_enable(p_nxge_t);
8996f45ec7bSml29623 void nxge_intr_disable(p_nxge_t);
9006f45ec7bSml29623 void nxge_hw_blank(void *arg, time_t, uint_t);
9016f45ec7bSml29623 void nxge_hw_id_init(p_nxge_t);
9026f45ec7bSml29623 void nxge_hw_init_niu_common(p_nxge_t);
9036f45ec7bSml29623 void nxge_intr_hw_enable(p_nxge_t);
9046f45ec7bSml29623 void nxge_intr_hw_disable(p_nxge_t);
9056f45ec7bSml29623 void nxge_hw_stop(p_nxge_t);
9066f45ec7bSml29623 void nxge_check_hw_state(p_nxge_t);
9076f45ec7bSml29623 
9086f45ec7bSml29623 void nxge_rxdma_channel_put64(nxge_os_acc_handle_t,
9096f45ec7bSml29623 	void *, uint32_t, uint16_t,
9106f45ec7bSml29623 	uint64_t);
9116f45ec7bSml29623 uint64_t nxge_rxdma_channel_get64(nxge_os_acc_handle_t, void *,
9126f45ec7bSml29623 	uint32_t, uint16_t);
9136f45ec7bSml29623 
9146f45ec7bSml29623 
9156f45ec7bSml29623 void nxge_get32(p_nxge_t, p_mblk_t);
9166f45ec7bSml29623 void nxge_put32(p_nxge_t, p_mblk_t);
9176f45ec7bSml29623 
9186f45ec7bSml29623 void nxge_hw_set_mac_modes(p_nxge_t);
9196f45ec7bSml29623 
9206f45ec7bSml29623 /* nxge_send.c. */
9216f45ec7bSml29623 uint_t nxge_reschedule(caddr_t);
922da14cebeSEric Cheng mblk_t *nxge_tx_ring_send(void *, mblk_t *);
923da14cebeSEric Cheng int nxge_start(p_nxge_t, p_tx_ring_t, p_mblk_t);
9246f45ec7bSml29623 
9256f45ec7bSml29623 /* nxge_rxdma.c */
9266f45ec7bSml29623 nxge_status_t nxge_rxdma_cfg_rdcgrp_default_rdc(p_nxge_t,
9276f45ec7bSml29623 					    uint8_t, uint8_t);
9286f45ec7bSml29623 
9296f45ec7bSml29623 nxge_status_t nxge_rxdma_cfg_port_default_rdc(p_nxge_t,
9306f45ec7bSml29623 				    uint8_t, uint8_t);
9316f45ec7bSml29623 nxge_status_t nxge_rxdma_cfg_rcr_threshold(p_nxge_t, uint8_t,
9326f45ec7bSml29623 				    uint16_t);
9336f45ec7bSml29623 nxge_status_t nxge_rxdma_cfg_rcr_timeout(p_nxge_t, uint8_t,
9346f45ec7bSml29623 				    uint16_t, uint8_t);
9356f45ec7bSml29623 
9366f45ec7bSml29623 /* nxge_ndd.c */
9376f45ec7bSml29623 void nxge_get_param_soft_properties(p_nxge_t);
9386f45ec7bSml29623 void nxge_copy_hw_default_to_param(p_nxge_t);
9396f45ec7bSml29623 void nxge_copy_param_hw_to_config(p_nxge_t);
9406f45ec7bSml29623 void nxge_setup_param(p_nxge_t);
9416f45ec7bSml29623 void nxge_init_param(p_nxge_t);
9426f45ec7bSml29623 void nxge_destroy_param(p_nxge_t);
9436f45ec7bSml29623 boolean_t nxge_check_rxdma_rdcgrp_member(p_nxge_t, uint8_t, uint8_t);
9446f45ec7bSml29623 boolean_t nxge_check_rxdma_port_member(p_nxge_t, uint8_t);
9456f45ec7bSml29623 boolean_t nxge_check_rdcgrp_port_member(p_nxge_t, uint8_t);
9466f45ec7bSml29623 
9476f45ec7bSml29623 boolean_t nxge_check_txdma_port_member(p_nxge_t, uint8_t);
9486f45ec7bSml29623 
9496f45ec7bSml29623 int nxge_param_get_generic(p_nxge_t, queue_t *, mblk_t *, caddr_t);
9506f45ec7bSml29623 int nxge_param_set_generic(p_nxge_t, queue_t *, mblk_t *, char *, caddr_t);
9516f45ec7bSml29623 int nxge_get_default(p_nxge_t, queue_t *, p_mblk_t, caddr_t);
9526f45ec7bSml29623 int nxge_set_default(p_nxge_t, queue_t *, p_mblk_t, char *, caddr_t);
9536f45ec7bSml29623 int nxge_nd_get_names(p_nxge_t, queue_t *, p_mblk_t, caddr_t);
9546f45ec7bSml29623 int nxge_mk_mblk_tail_space(p_mblk_t, p_mblk_t *, size_t);
9556f45ec7bSml29623 long nxge_strtol(char *, char **, int);
9566f45ec7bSml29623 boolean_t nxge_param_get_instance(queue_t *, mblk_t *);
9576f45ec7bSml29623 void nxge_param_ioctl(p_nxge_t, queue_t *, mblk_t *, struct iocblk *);
9586f45ec7bSml29623 boolean_t nxge_nd_load(caddr_t *, char *, pfi_t, pfi_t, caddr_t);
9596f45ec7bSml29623 void nxge_nd_free(caddr_t *);
9606f45ec7bSml29623 int nxge_nd_getset(p_nxge_t, queue_t *, caddr_t, p_mblk_t);
9616f45ec7bSml29623 
962321febdeSsbehera nxge_status_t nxge_set_lb_normal(p_nxge_t);
9636f45ec7bSml29623 boolean_t nxge_set_lb(p_nxge_t, queue_t *, p_mblk_t);
9641bd6825cSml29623 boolean_t nxge_param_link_update(p_nxge_t);
9651bd6825cSml29623 int nxge_param_set_ip_opt(p_nxge_t, queue_t *, mblk_t *, char *, caddr_t);
9661bd6825cSml29623 int nxge_dld_get_ip_opt(p_nxge_t, caddr_t);
9671bd6825cSml29623 int nxge_param_rx_intr_pkts(p_nxge_t, queue_t *,
9681bd6825cSml29623 	mblk_t *, char *, caddr_t);
9691bd6825cSml29623 int nxge_param_rx_intr_time(p_nxge_t, queue_t *,
9701bd6825cSml29623 	mblk_t *, char *, caddr_t);
9711bd6825cSml29623 
9726f45ec7bSml29623 
9736f45ec7bSml29623 /* nxge_virtual.c */
9746f45ec7bSml29623 nxge_status_t nxge_cntlops(dev_info_t *, nxge_ctl_enum_t, void *, void *);
9756f45ec7bSml29623 void nxge_common_lock_get(p_nxge_t);
9766f45ec7bSml29623 void nxge_common_lock_free(p_nxge_t);
9776f45ec7bSml29623 
9786f45ec7bSml29623 nxge_status_t nxge_get_config_properties(p_nxge_t);
9796f45ec7bSml29623 void nxge_get_xcvr_properties(p_nxge_t);
9806f45ec7bSml29623 void nxge_init_vlan_config(p_nxge_t);
9816f45ec7bSml29623 void nxge_init_mac_config(p_nxge_t);
9826f45ec7bSml29623 
9836f45ec7bSml29623 
9846f45ec7bSml29623 void nxge_init_logical_devs(p_nxge_t);
9856f45ec7bSml29623 int nxge_init_ldg_intrs(p_nxge_t);
9866f45ec7bSml29623 
9876f45ec7bSml29623 void nxge_set_ldgimgmt(p_nxge_t, uint32_t, boolean_t,
9886f45ec7bSml29623 	uint32_t);
9896f45ec7bSml29623 
9906f45ec7bSml29623 void nxge_init_fzc_txdma_channels(p_nxge_t);
9916f45ec7bSml29623 
9926f45ec7bSml29623 nxge_status_t nxge_init_fzc_txdma_channel(p_nxge_t, uint16_t,
9936f45ec7bSml29623 	p_tx_ring_t, p_tx_mbox_t);
9946f45ec7bSml29623 nxge_status_t nxge_init_fzc_txdma_port(p_nxge_t);
9956f45ec7bSml29623 
996678453a8Sspeer nxge_status_t nxge_init_fzc_rxdma_channel(p_nxge_t, uint16_t);
9976f45ec7bSml29623 
9986f45ec7bSml29623 nxge_status_t nxge_init_fzc_rx_common(p_nxge_t);
9996f45ec7bSml29623 nxge_status_t nxge_init_fzc_rxdma_port(p_nxge_t);
10006f45ec7bSml29623 
10016f45ec7bSml29623 nxge_status_t nxge_init_fzc_rxdma_channel_pages(p_nxge_t,
10026f45ec7bSml29623 	uint16_t, p_rx_rbr_ring_t);
10036f45ec7bSml29623 nxge_status_t nxge_init_fzc_rxdma_channel_red(p_nxge_t,
10046f45ec7bSml29623 	uint16_t, p_rx_rcr_ring_t);
10056f45ec7bSml29623 
10066f45ec7bSml29623 nxge_status_t nxge_init_fzc_rxdma_channel_clrlog(p_nxge_t,
10076f45ec7bSml29623 	uint16_t, p_rx_rbr_ring_t);
10086f45ec7bSml29623 
10096f45ec7bSml29623 
10106f45ec7bSml29623 nxge_status_t nxge_init_fzc_txdma_channel_pages(p_nxge_t,
10116f45ec7bSml29623 	uint16_t, p_tx_ring_t);
10126f45ec7bSml29623 
10136f45ec7bSml29623 nxge_status_t nxge_init_fzc_txdma_channel_drr(p_nxge_t, uint16_t,
10146f45ec7bSml29623 	p_tx_ring_t);
10156f45ec7bSml29623 
10166f45ec7bSml29623 nxge_status_t nxge_init_fzc_txdma_port(p_nxge_t);
10176f45ec7bSml29623 
10186f45ec7bSml29623 void nxge_init_fzc_ldg_num(p_nxge_t);
10196f45ec7bSml29623 void nxge_init_fzc_sys_int_data(p_nxge_t);
10206f45ec7bSml29623 void nxge_init_fzc_ldg_int_timer(p_nxge_t);
10216f45ec7bSml29623 nxge_status_t nxge_intr_mask_mgmt_set(p_nxge_t, boolean_t on);
10226f45ec7bSml29623 
10236f45ec7bSml29623 /* MAC functions */
10246f45ec7bSml29623 nxge_status_t nxge_mac_init(p_nxge_t);
10256f45ec7bSml29623 nxge_status_t nxge_link_init(p_nxge_t);
10266f45ec7bSml29623 nxge_status_t nxge_xif_init(p_nxge_t);
10276f45ec7bSml29623 nxge_status_t nxge_pcs_init(p_nxge_t);
1028cb9d3ae6Smisaki nxge_status_t nxge_mac_ctrl_init(p_nxge_t);
10296f45ec7bSml29623 nxge_status_t nxge_serdes_init(p_nxge_t);
1030d81011f0Ssbehera nxge_status_t nxge_serdes_reset(p_nxge_t);
10312e59129aSraghus nxge_status_t nxge_xcvr_find(p_nxge_t);
10322e59129aSraghus nxge_status_t nxge_get_xcvr_type(p_nxge_t);
103359ac0c16Sdavemq nxge_status_t nxge_setup_xcvr_table(p_nxge_t);
10346f45ec7bSml29623 nxge_status_t nxge_xcvr_init(p_nxge_t);
10356f45ec7bSml29623 nxge_status_t nxge_tx_mac_init(p_nxge_t);
10366f45ec7bSml29623 nxge_status_t nxge_rx_mac_init(p_nxge_t);
10376f45ec7bSml29623 nxge_status_t nxge_tx_mac_enable(p_nxge_t);
10386f45ec7bSml29623 nxge_status_t nxge_tx_mac_disable(p_nxge_t);
10396f45ec7bSml29623 nxge_status_t nxge_rx_mac_enable(p_nxge_t);
10406f45ec7bSml29623 nxge_status_t nxge_rx_mac_disable(p_nxge_t);
10416f45ec7bSml29623 nxge_status_t nxge_tx_mac_reset(p_nxge_t);
10426f45ec7bSml29623 nxge_status_t nxge_rx_mac_reset(p_nxge_t);
10436f45ec7bSml29623 nxge_status_t nxge_link_intr(p_nxge_t, link_intr_enable_t);
10446f45ec7bSml29623 nxge_status_t nxge_mii_xcvr_init(p_nxge_t);
1045d81011f0Ssbehera nxge_status_t nxge_mii_xcvr_fiber_init(p_nxge_t);
10466f45ec7bSml29623 nxge_status_t nxge_mii_read(p_nxge_t, uint8_t,
10476f45ec7bSml29623 			uint8_t, uint16_t *);
10486f45ec7bSml29623 nxge_status_t nxge_mii_write(p_nxge_t, uint8_t,
10496f45ec7bSml29623 			uint8_t, uint16_t);
10506f45ec7bSml29623 nxge_status_t nxge_mdio_read(p_nxge_t, uint8_t, uint8_t,
10516f45ec7bSml29623 			uint16_t, uint16_t *);
10526f45ec7bSml29623 nxge_status_t nxge_mdio_write(p_nxge_t, uint8_t,
10536f45ec7bSml29623 			uint8_t, uint16_t, uint16_t);
10546f45ec7bSml29623 nxge_status_t nxge_mii_check(p_nxge_t, mii_bmsr_t,
10556f45ec7bSml29623 			mii_bmsr_t, nxge_link_state_t *);
105600161856Syc148097 void nxge_pcs_check(p_nxge_t, uint8_t portn, nxge_link_state_t *);
10576f45ec7bSml29623 nxge_status_t nxge_add_mcast_addr(p_nxge_t, struct ether_addr *);
10586f45ec7bSml29623 nxge_status_t nxge_del_mcast_addr(p_nxge_t, struct ether_addr *);
10596f45ec7bSml29623 nxge_status_t nxge_set_mac_addr(p_nxge_t, struct ether_addr *);
10606f45ec7bSml29623 nxge_status_t nxge_check_bcm8704_link(p_nxge_t, boolean_t *);
106100161856Syc148097 nxge_status_t nxge_check_tn1010_link(p_nxge_t);
10626f45ec7bSml29623 void nxge_link_is_down(p_nxge_t);
10636f45ec7bSml29623 void nxge_link_is_up(p_nxge_t);
10646f45ec7bSml29623 nxge_status_t nxge_link_monitor(p_nxge_t, link_mon_enable_t);
10656f45ec7bSml29623 uint32_t crc32_mchash(p_ether_addr_t);
10666f45ec7bSml29623 nxge_status_t nxge_set_promisc(p_nxge_t, boolean_t);
10676f45ec7bSml29623 nxge_status_t nxge_mac_handle_sys_errors(p_nxge_t);
10686f45ec7bSml29623 nxge_status_t nxge_10g_link_led_on(p_nxge_t);
10696f45ec7bSml29623 nxge_status_t nxge_10g_link_led_off(p_nxge_t);
107059ac0c16Sdavemq nxge_status_t nxge_scan_ports_phy(p_nxge_t, p_nxge_hw_list_t);
107156d930aeSspeer boolean_t nxge_is_valid_local_mac(ether_addr_st);
10721bd6825cSml29623 nxge_status_t nxge_mac_set_framesize(p_nxge_t);
10736f45ec7bSml29623 
10746f45ec7bSml29623 /* espc (sprom) prototypes */
10756f45ec7bSml29623 nxge_status_t nxge_espc_mac_addrs_get(p_nxge_t);
10766f45ec7bSml29623 nxge_status_t nxge_espc_num_macs_get(p_nxge_t, uint8_t *);
10776f45ec7bSml29623 nxge_status_t nxge_espc_num_ports_get(p_nxge_t);
10786f45ec7bSml29623 nxge_status_t nxge_espc_phy_type_get(p_nxge_t);
107959ac0c16Sdavemq nxge_status_t nxge_espc_verify_chksum(p_nxge_t);
108056d930aeSspeer void nxge_espc_get_next_mac_addr(uint8_t *, uint8_t, struct ether_addr *);
10812e59129aSraghus void nxge_vpd_info_get(p_nxge_t);
10826f45ec7bSml29623 
10836f45ec7bSml29623 
10846f45ec7bSml29623 void nxge_debug_msg(p_nxge_t, uint64_t, char *, ...);
10852e59129aSraghus int nxge_get_nports(p_nxge_t);
10866f45ec7bSml29623 
1087678453a8Sspeer void nxge_free_buf(buf_alloc_type_t, uint64_t, uint32_t);
1088678453a8Sspeer 
1089da14cebeSEric Cheng #if defined(sun4v)
1090da14cebeSEric Cheng 
10916f45ec7bSml29623 uint64_t hv_niu_rx_logical_page_conf(uint64_t, uint64_t,
10926f45ec7bSml29623 	uint64_t, uint64_t);
10936f45ec7bSml29623 #pragma weak	hv_niu_rx_logical_page_conf
10946f45ec7bSml29623 
10956f45ec7bSml29623 uint64_t hv_niu_rx_logical_page_info(uint64_t, uint64_t,
10966f45ec7bSml29623 	uint64_t *, uint64_t *);
10976f45ec7bSml29623 #pragma weak	hv_niu_rx_logical_page_info
10986f45ec7bSml29623 
10996f45ec7bSml29623 uint64_t hv_niu_tx_logical_page_conf(uint64_t, uint64_t,
11006f45ec7bSml29623 	uint64_t, uint64_t);
11016f45ec7bSml29623 #pragma weak	hv_niu_tx_logical_page_conf
11026f45ec7bSml29623 
11036f45ec7bSml29623 uint64_t hv_niu_tx_logical_page_info(uint64_t, uint64_t,
11046f45ec7bSml29623 	uint64_t *, uint64_t *);
11056f45ec7bSml29623 #pragma weak	hv_niu_tx_logical_page_info
11066f45ec7bSml29623 
1107678453a8Sspeer uint64_t hv_niu_vr_assign(uint64_t vridx, uint64_t ldc_id, uint32_t *cookie);
1108678453a8Sspeer #pragma weak	hv_niu_vr_assign
1109678453a8Sspeer 
1110678453a8Sspeer uint64_t hv_niu_vr_unassign(uint32_t cookie);
1111678453a8Sspeer #pragma weak	hv_niu_vr_unassign
1112678453a8Sspeer 
1113678453a8Sspeer uint64_t hv_niu_vr_getinfo(uint32_t cookie, uint64_t *real_start,
1114678453a8Sspeer     uint64_t *size);
1115678453a8Sspeer #pragma weak	hv_niu_vr_getinfo
1116678453a8Sspeer 
1117678453a8Sspeer uint64_t hv_niu_vr_get_rxmap(uint32_t cookie, uint64_t *dma_map);
1118678453a8Sspeer #pragma weak	hv_niu_vr_get_rxmap
1119678453a8Sspeer 
1120678453a8Sspeer uint64_t hv_niu_vr_get_txmap(uint32_t cookie, uint64_t *dma_map);
1121678453a8Sspeer #pragma weak	hv_niu_vr_get_txmap
1122678453a8Sspeer 
1123678453a8Sspeer uint64_t hv_niu_rx_dma_assign(uint32_t cookie, uint64_t chidx,
1124678453a8Sspeer     uint64_t *vchidx);
1125678453a8Sspeer #pragma weak	hv_niu_rx_dma_assign
1126678453a8Sspeer 
1127678453a8Sspeer uint64_t hv_niu_rx_dma_unassign(uint32_t cookie, uint64_t chidx);
1128678453a8Sspeer #pragma weak	hv_niu_rx_dma_unassign
1129678453a8Sspeer 
1130678453a8Sspeer uint64_t hv_niu_tx_dma_assign(uint32_t cookie, uint64_t chidx,
1131678453a8Sspeer     uint64_t *vchidx);
1132678453a8Sspeer #pragma weak	hv_niu_tx_dma_assign
1133678453a8Sspeer 
1134678453a8Sspeer uint64_t hv_niu_tx_dma_unassign(uint32_t cookie, uint64_t chidx);
1135678453a8Sspeer #pragma weak	hv_niu_tx_dma_unassign
1136678453a8Sspeer 
1137678453a8Sspeer uint64_t hv_niu_vrrx_logical_page_conf(uint32_t cookie, uint64_t chidx,
1138678453a8Sspeer     uint64_t pgidx, uint64_t raddr, uint64_t size);
1139678453a8Sspeer #pragma weak	hv_niu_vrrx_logical_page_conf
1140678453a8Sspeer 
1141678453a8Sspeer uint64_t hv_niu_vrrx_logical_page_info(uint32_t cookie, uint64_t chidx,
1142678453a8Sspeer     uint64_t pgidx, uint64_t *raddr, uint64_t *size);
1143678453a8Sspeer #pragma weak	hv_niu_vrrx_logical_page_info
1144678453a8Sspeer 
1145678453a8Sspeer uint64_t hv_niu_vrtx_logical_page_conf(uint32_t cookie, uint64_t chidx,
1146678453a8Sspeer     uint64_t pgidx, uint64_t raddr, uint64_t size);
1147678453a8Sspeer #pragma weak	hv_niu_vrtx_logical_page_conf
1148678453a8Sspeer 
1149678453a8Sspeer uint64_t hv_niu_vrtx_logical_page_info(uint32_t cookie, uint64_t chidx,
1150678453a8Sspeer     uint64_t pgidx, uint64_t *raddr, uint64_t *size);
1151678453a8Sspeer #pragma weak	hv_niu_vrtx_logical_page_info
1152678453a8Sspeer 
11534df55fdeSJanie Lu uint64_t hv_niu_cfgh_rx_logical_page_conf(uint64_t, uint64_t, uint64_t,
11544df55fdeSJanie Lu 	uint64_t, uint64_t);
1155*c22d83ccStc99174@train #pragma weak	hv_niu_cfgh_rx_logical_page_conf
11564df55fdeSJanie Lu 
11574df55fdeSJanie Lu uint64_t hv_niu_cfgh_rx_logical_page_info(uint64_t, uint64_t, uint64_t,
11584df55fdeSJanie Lu 	uint64_t *, uint64_t *);
1159*c22d83ccStc99174@train #pragma weak	hv_niu_cfgh_rx_logical_page_info
11604df55fdeSJanie Lu 
11614df55fdeSJanie Lu uint64_t hv_niu_cfgh_tx_logical_page_conf(uint64_t, uint64_t, uint64_t,
11624df55fdeSJanie Lu 	uint64_t, uint64_t);
1163*c22d83ccStc99174@train #pragma weak	hv_niu_cfgh_tx_logical_page_conf
11644df55fdeSJanie Lu 
11654df55fdeSJanie Lu uint64_t hv_niu_cfgh_tx_logical_page_info(uint64_t, uint64_t, uint64_t,
11664df55fdeSJanie Lu 	uint64_t *, uint64_t *);
1167*c22d83ccStc99174@train #pragma weak	hv_niu_cfgh_tx_logical_page_info
11684df55fdeSJanie Lu 
11694df55fdeSJanie Lu uint64_t hv_niu_cfgh_vr_assign(uint64_t, uint64_t vridx, uint64_t ldc_id,
11704df55fdeSJanie Lu 	uint32_t *cookie);
1171*c22d83ccStc99174@train #pragma weak	hv_niu_cfgh_vr_assign
11724df55fdeSJanie Lu 
1173678453a8Sspeer //
1174678453a8Sspeer // NIU-specific interrupt API
1175678453a8Sspeer //
1176678453a8Sspeer uint64_t hv_niu_vrrx_getinfo(uint32_t cookie, uint64_t v_chidx,
1177678453a8Sspeer     uint64_t *group, uint64_t *logdev);
1178678453a8Sspeer #pragma weak	hv_niu_vrrx_getinfo
1179678453a8Sspeer 
1180678453a8Sspeer uint64_t hv_niu_vrtx_getinfo(uint32_t cookie, uint64_t v_chidx,
1181678453a8Sspeer     uint64_t *group, uint64_t *logdev);
1182678453a8Sspeer #pragma weak	hv_niu_vrtx_getinfo
1183678453a8Sspeer 
1184678453a8Sspeer uint64_t hv_niu_vrrx_to_logical_dev(uint32_t cookie, uint64_t v_chidx,
1185678453a8Sspeer     uint64_t *ldn);
1186678453a8Sspeer #pragma weak	hv_niu_vrrx_to_logical_dev
1187678453a8Sspeer 
1188678453a8Sspeer uint64_t hv_niu_vrtx_to_logical_dev(uint32_t cookie, uint64_t v_chidx,
1189678453a8Sspeer     uint64_t *ldn);
1190678453a8Sspeer #pragma weak	hv_niu_vrtx_to_logical_dev
1191678453a8Sspeer 
1192da14cebeSEric Cheng #endif /* defined(sun4v) */
1193da14cebeSEric Cheng 
11946f45ec7bSml29623 #ifdef NXGE_DEBUG
11956f45ec7bSml29623 char *nxge_dump_packet(char *, int);
11966f45ec7bSml29623 #endif
11976f45ec7bSml29623 
11986f45ec7bSml29623 #endif	/* !_ASM */
11996f45ec7bSml29623 
12006f45ec7bSml29623 #ifdef	__cplusplus
12016f45ec7bSml29623 }
12026f45ec7bSml29623 #endif
12036f45ec7bSml29623 
12046f45ec7bSml29623 #endif	/* _SYS_NXGE_NXGE_IMPL_H */
1205