144961713Sgirish /*
244961713Sgirish  * CDDL HEADER START
344961713Sgirish  *
444961713Sgirish  * The contents of this file are subject to the terms of the
544961713Sgirish  * Common Development and Distribution License (the "License").
644961713Sgirish  * You may not use this file except in compliance with the License.
744961713Sgirish  *
844961713Sgirish  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
944961713Sgirish  * or http://www.opensolaris.org/os/licensing.
1044961713Sgirish  * See the License for the specific language governing permissions
1144961713Sgirish  * and limitations under the License.
1244961713Sgirish  *
1344961713Sgirish  * When distributing Covered Code, include this CDDL HEADER in each
1444961713Sgirish  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1544961713Sgirish  * If applicable, add the following below this CDDL HEADER, with the
1644961713Sgirish  * fields enclosed by brackets "[]" replaced with your own identifying
1744961713Sgirish  * information: Portions Copyright [yyyy] [name of copyright owner]
1844961713Sgirish  *
1944961713Sgirish  * CDDL HEADER END
2044961713Sgirish  */
2144961713Sgirish /*
22*4df55fdeSJanie Lu  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
2344961713Sgirish  * Use is subject to license terms.
2444961713Sgirish  */
2544961713Sgirish 
2644961713Sgirish #ifndef	_SYS_NXGE_NXGE_DEFS_H
2744961713Sgirish #define	_SYS_NXGE_NXGE_DEFS_H
2844961713Sgirish 
2944961713Sgirish #ifdef	__cplusplus
3044961713Sgirish extern "C" {
3144961713Sgirish #endif
3244961713Sgirish 
3344961713Sgirish /*
3444961713Sgirish  * Block Address Assignment (24-bit base address)
3544961713Sgirish  * (bits [23:20]: block	 [19]: set to 1 for FZC	)
3644961713Sgirish  */
3744961713Sgirish #define	PIO			0x000000
3844961713Sgirish #define	FZC_PIO			0x080000
3944961713Sgirish #define	RESERVED_1		0x100000
4044961713Sgirish #define	FZC_MAC			0x180000
4144961713Sgirish #define	RESERVED_2		0x200000
4244961713Sgirish #define	FZC_IPP			0x280000
4344961713Sgirish #define	FFLP			0x300000
4444961713Sgirish #define	FZC_FFLP		0x380000
4544961713Sgirish #define	PIO_VADDR		0x400000
4644961713Sgirish #define	RESERVED_3		0x480000
4744961713Sgirish #define	ZCP			0x500000
4844961713Sgirish #define	FZC_ZCP			0x580000
4944961713Sgirish #define	DMC			0x600000
5044961713Sgirish #define	FZC_DMC			0x680000
5144961713Sgirish #define	TXC			0x700000
5244961713Sgirish #define	FZC_TXC			0x780000
5344961713Sgirish #define	PIO_LDSV		0x800000
5444961713Sgirish #define	RESERVED_4		0x880000
5544961713Sgirish #define	PIO_LDGIM		0x900000
5644961713Sgirish #define	RESERVED_5		0x980000
5744961713Sgirish #define	PIO_IMASK0		0xa00000
5844961713Sgirish #define	RESERVED_6		0xa80000
5944961713Sgirish #define	PIO_IMASK1		0xb00000
6044961713Sgirish #define	RESERVED_7_START	0xb80000
6144961713Sgirish #define	RESERVED_7_END		0xc00000
6244961713Sgirish #define	FZC_PROM		0xc80000
6344961713Sgirish #define	RESERVED_8		0xd00000
6444961713Sgirish #define	FZC_PIM			0xd80000
6544961713Sgirish #define	RESERVED_9_START 	0xe00000
6644961713Sgirish #define	RESERVED_9_END 		0xf80000
6744961713Sgirish 
6844961713Sgirish /* PIO		(0x000000) */
6944961713Sgirish 
7044961713Sgirish 
7144961713Sgirish /* FZC_PIO	(0x080000) */
7244961713Sgirish #define	LDGITMRES		(FZC_PIO + 0x00008)	/* timer resolution */
7344961713Sgirish #define	SID			(FZC_PIO + 0x10200)	/* 64 LDG, INT data */
7444961713Sgirish #define	LDG_NUM			(FZC_PIO + 0x20000)	/* 69 LDs */
7544961713Sgirish 
7644961713Sgirish 
7744961713Sgirish 
7844961713Sgirish /* FZC_IPP 	(0x280000) */
7944961713Sgirish 
8044961713Sgirish 
8144961713Sgirish /* FFLP		(0x300000), Header Parser */
8244961713Sgirish 
8344961713Sgirish /* PIO_VADDR	(0x400000), PIO Virtaul DMA Address */
8444961713Sgirish /* ?? how to access DMA via PIO_VADDR? */
8544961713Sgirish #define	VADDR			(PIO_VADDR + 0x00000) /* ?? not for driver */
8644961713Sgirish 
8744961713Sgirish 
8844961713Sgirish /* ZCP		(0x500000), Neptune Only */
8944961713Sgirish 
9044961713Sgirish 
9144961713Sgirish /* FZC_ZCP	(0x580000), Neptune Only */
9244961713Sgirish 
9344961713Sgirish 
9444961713Sgirish /* DMC 		(0x600000), register offset (32 DMA channels) */
9544961713Sgirish 
9644961713Sgirish /* Transmit Ring Register Offset (32 Channels) */
9744961713Sgirish #define	TX_RNG_CFIG		(DMC + 0x40000)
9844961713Sgirish #define	TX_RING_HDH		(DMC + 0x40008)
9944961713Sgirish #define	TX_RING_HDL		(DMC + 0x40010)
10044961713Sgirish #define	TX_RING_KICK		(DMC + 0x40018)
10144961713Sgirish /* Transmit Operations (32 Channels) */
10244961713Sgirish #define	TX_ENT_MSK		(DMC + 0x40020)
10344961713Sgirish #define	TX_CS			(DMC + 0x40028)
10444961713Sgirish #define	TXDMA_MBH		(DMC + 0x40030)
10544961713Sgirish #define	TXDMA_MBL		(DMC + 0x40038)
10644961713Sgirish #define	TX_DMA_PRE_ST		(DMC + 0x40040)
10744961713Sgirish #define	TX_RNG_ERR_LOGH		(DMC + 0x40048)
10844961713Sgirish #define	TX_RNG_ERR_LOGL		(DMC + 0x40050)
10944961713Sgirish #if OLD
11044961713Sgirish #define	SH_TX_RNG_ERR_LOGH	(DMC + 0x40058)
11144961713Sgirish #define	SH_TX_RNG_ERR_LOGL	(DMC + 0x40060)
11244961713Sgirish #endif
11344961713Sgirish 
11444961713Sgirish /* FZC_DMC RED Initial Random Value register offset (global) */
11544961713Sgirish #define	RED_RAN_INIT		(FZC_DMC + 0x00068)
11644961713Sgirish 
11744961713Sgirish #define	RX_ADDR_MD		(FZC_DMC + 0x00070)
11844961713Sgirish 
11944961713Sgirish /* FZC_DMC Ethernet Timeout Countue register offset (global) */
12044961713Sgirish #define	EING_TIMEOUT		(FZC_DMC + 0x00078)
12144961713Sgirish 
12244961713Sgirish /* RDC Table */
12344961713Sgirish #define	RDC_TBL			(FZC_DMC + 0x10000)	/* 256 * 8 */
12444961713Sgirish 
12544961713Sgirish /* FZC_DMC partitioning support register offset (32 channels) */
12644961713Sgirish 
12744961713Sgirish #define	TX_LOG_PAGE_VLD		(FZC_DMC + 0x40000)
12844961713Sgirish #define	TX_LOG_MASK1		(FZC_DMC + 0x40008)
12944961713Sgirish #define	TX_LOG_VAL1		(FZC_DMC + 0x40010)
13044961713Sgirish #define	TX_LOG_MASK2		(FZC_DMC + 0x40018)
13144961713Sgirish #define	TX_LOG_VAL2		(FZC_DMC + 0x40020)
13244961713Sgirish #define	TX_LOG_PAGE_RELO1	(FZC_DMC + 0x40028)
13344961713Sgirish #define	TX_LOG_PAGE_RELO2	(FZC_DMC + 0x40030)
13444961713Sgirish #define	TX_LOG_PAGE_HDL		(FZC_DMC + 0x40038)
13544961713Sgirish 
13644961713Sgirish #define	TX_ADDR_MOD		(FZC_DMC + 0x41000) /* only one? */
13744961713Sgirish 
13844961713Sgirish 
13944961713Sgirish /* FZC_DMC RED Parameters register offset (32 channels) */
14044961713Sgirish #define	RDC_RED_PARA1		(FZC_DMC + 0x30000)
14144961713Sgirish #define	RDC_RED_PARA2		(FZC_DMC + 0x30008)
14244961713Sgirish /* FZC_DMC RED Discard Cound Register offset (32 channels) */
14344961713Sgirish #define	RED_DIS_CNT		(FZC_DMC + 0x30010)
14444961713Sgirish 
14544961713Sgirish #if OLD /* This has been moved to TXC */
14644961713Sgirish /* Transmit Ring Scheduler (per port) */
14744961713Sgirish #define	TX_DMA_MAP0		(FZC_DMC + 0x50000)
14844961713Sgirish #define	TX_DMA_MAP1		(FZC_DMC + 0x50008)
14944961713Sgirish #define	TX_DMA_MAP2		(FZC_DMC + 0x50010)
15044961713Sgirish #define	TX_DMA_MAP3		(FZC_DMC + 0x50018)
15144961713Sgirish #endif
15244961713Sgirish 
15344961713Sgirish /* Transmit Ring Scheduler: DRR Weight (32 Channels) */
15444961713Sgirish #define	DRR_WT			(FZC_DMC + 0x51000)
15544961713Sgirish #if OLD
15644961713Sgirish #define	TXRNG_USE		(FZC_DMC + 0x51008)
15744961713Sgirish #endif
15844961713Sgirish 
15944961713Sgirish /* TXC		(0x700000)??	*/
16044961713Sgirish 
16144961713Sgirish 
16244961713Sgirish /* FZC_TXC	(0x780000)??	*/
16344961713Sgirish 
16444961713Sgirish 
16544961713Sgirish /*
16644961713Sgirish  * PIO_LDSV	(0x800000)
16744961713Sgirish  * Logical Device State Vector 0, 1, 2.
16844961713Sgirish  * (69 logical devices, 8192 apart, partitioning control)
16944961713Sgirish  */
17044961713Sgirish #define	LDSV0			(PIO_LDSV + 0x00000)	/* RO (64 - 69) */
17144961713Sgirish #define	LDSV1			(PIO_LDSV + 0x00008)	/* RO (32 - 63) */
17244961713Sgirish #define	LDSV2			(PIO_LDSV + 0x00010)	/* RO ( 0 - 31) */
17344961713Sgirish 
17444961713Sgirish /*
17544961713Sgirish  * PIO_LDGIM	(0x900000)
17644961713Sgirish  * Logical Device Group Interrupt Management (64 groups).
17744961713Sgirish  * (count 64, step 8192)
17844961713Sgirish  */
17944961713Sgirish #define	LDGIMGN			(PIO_LDGIMGN + 0x00000)	/* RW */
18044961713Sgirish 
18144961713Sgirish /*
18244961713Sgirish  * PIO_IMASK0	(0xA000000)
18344961713Sgirish  *
18444961713Sgirish  * Logical Device Masks 0, 1.
18544961713Sgirish  * (64 logical devices, 8192 apart, partitioning control)
18644961713Sgirish  */
18744961713Sgirish #define	LD_IM0			(PIO_IMASK0 + 0x00000)	/* RW ( 0 - 63) */
18844961713Sgirish 
18944961713Sgirish /*
19044961713Sgirish  * PIO_IMASK0	(0xB000000)
19144961713Sgirish  *
19244961713Sgirish  * Logical Device Masks 0, 1.
19344961713Sgirish  * (5 logical devices, 8192 apart, partitioning control)
19444961713Sgirish  */
19544961713Sgirish #define	LD_IM1			(PIO_IMASK1 + 0x00000)	/* RW (64 - 69) */
19644961713Sgirish 
19744961713Sgirish 
19844961713Sgirish /* DMC/TMC CSR size */
199678453a8Sspeer #define	DMA_CSR_SLL		9	/* Used to calculate VR addresses */
200678453a8Sspeer #define	DMA_CSR_SIZE		(1 << DMA_CSR_SLL) /* 512 */
201678453a8Sspeer #define	DMA_CSR_MASK		0xff	/* Used to calculate VR addresses */
202678453a8Sspeer 	/*
203678453a8Sspeer 	 * That is, each DMA CSR set must fit into a 512 byte space.
204678453a8Sspeer 	 * If you subtract DMC (0x60000) from each DMA register definition,
205678453a8Sspeer 	 * what you have left over is currently less than 255 (0xff)
206678453a8Sspeer 	 */
207678453a8Sspeer #define	DMA_CSR_MIN_PAGE_SIZE	(2 * DMA_CSR_SIZE) /* 1024 */
208678453a8Sspeer 	/*
209678453a8Sspeer 	 * There are 2 subpages per page in a VR.
210678453a8Sspeer 	 */
211678453a8Sspeer #define	VDMA_CSR_SIZE		(8 * DMA_CSR_MIN_PAGE_SIZE) /* 0x2000 */
212678453a8Sspeer 	/*
213678453a8Sspeer 	 * There are 8 pages in a VR.
214678453a8Sspeer 	 */
21544961713Sgirish 
21644961713Sgirish /*
21744961713Sgirish  * Define the Default RBR, RCR
21844961713Sgirish  */
21930ac2e7bSml #define	RBR_DEFAULT_MAX_BLKS	8192	/* each entry (16 blockaddr/64B) */
22044961713Sgirish #define	RBR_NBLK_PER_LINE	16	/* 16 block addresses per 64 B line */
22144961713Sgirish #define	RBR_DEFAULT_MAX_LEN	(RBR_DEFAULT_MAX_BLKS)
22244961713Sgirish #define	RBR_DEFAULT_MIN_LEN	1
22330ac2e7bSml #define	RCR_DEFAULT_MAX		8192
22444961713Sgirish 
22544961713Sgirish #define	SW_OFFSET_NO_OFFSET		0
22644961713Sgirish #define	SW_OFFSET_64			1	/* 64 bytes */
22744961713Sgirish #define	SW_OFFSET_128			2	/* 128 bytes */
228*4df55fdeSJanie Lu /* The following additional offsets are defined for Neptune-L and RF-NIU */
229*4df55fdeSJanie Lu #define	SW_OFFSET_192			3
230*4df55fdeSJanie Lu #define	SW_OFFSET_256			4
231*4df55fdeSJanie Lu #define	SW_OFFSET_320			5
232*4df55fdeSJanie Lu #define	SW_OFFSET_384			6
233*4df55fdeSJanie Lu #define	SW_OFFSET_448			7
23444961713Sgirish 
23530ac2e7bSml #define	TDC_DEFAULT_MAX		8192
23644961713Sgirish /*
23744961713Sgirish  * RBR block descriptor is 32 bits (bits [43:12]
23844961713Sgirish  */
23944961713Sgirish #define	RBR_BKADDR_SHIFT	12
24044961713Sgirish 
24144961713Sgirish 
24244961713Sgirish #define	RCR_DEFAULT_MAX_BLKS	4096	/* each entry (8 blockaddr/64B) */
24344961713Sgirish #define	RCR_NBLK_PER_LINE	8	/* 8 block addresses per 64 B line */
24444961713Sgirish #define	RCR_DEFAULT_MAX_LEN	(RCR_DEFAULT_MAX_BLKS)
24544961713Sgirish #define	RCR_DEFAULT_MIN_LEN	1
24644961713Sgirish 
24744961713Sgirish /*  DMA Channels.  */
24844961713Sgirish #define	NXGE_MAX_DMCS		(NXGE_MAX_RDCS + NXGE_MAX_TDCS)
24944961713Sgirish #define	NXGE_MAX_RDCS		16
25044961713Sgirish #define	NXGE_MAX_TDCS		24
25144961713Sgirish #define	NXGE_MAX_TDCS_NIU	16
25244961713Sgirish /*
25344961713Sgirish  * original mapping from Hypervisor
25444961713Sgirish  */
25544961713Sgirish #ifdef	ORIGINAL
25644961713Sgirish #define	NXGE_N2_RXDMA_START_LDG	0
25744961713Sgirish #define	NXGE_N2_TXDMA_START_LDG	16
25844961713Sgirish #define	NXGE_N2_MIF_LDG		32
25944961713Sgirish #define	NXGE_N2_MAC_0_LDG	33
26044961713Sgirish #define	NXGE_N2_MAC_1_LDG	34
26144961713Sgirish #define	NXGE_N2_SYS_ERROR_LDG	35
26244961713Sgirish #endif
26344961713Sgirish 
26444961713Sgirish #define	NXGE_N2_RXDMA_START_LDG	19
26544961713Sgirish #define	NXGE_N2_TXDMA_START_LDG	27
26644961713Sgirish #define	NXGE_N2_MIF_LDG		17
26744961713Sgirish #define	NXGE_N2_MAC_0_LDG	16
26844961713Sgirish #define	NXGE_N2_MAC_1_LDG	35
26944961713Sgirish #define	NXGE_N2_SYS_ERROR_LDG	18
27044961713Sgirish #define	NXGE_N2_LDG_GAP		17
27144961713Sgirish 
27244961713Sgirish #define	NXGE_MAX_RDC_GRPS	8
27344961713Sgirish 
27444961713Sgirish /*
27544961713Sgirish  * Max. ports per Neptune and NIU
27644961713Sgirish  */
27744961713Sgirish #define	NXGE_MAX_PORTS			4
27844961713Sgirish #define	NXGE_PORTS_NEPTUNE		4
27944961713Sgirish #define	NXGE_PORTS_NIU			2
28044961713Sgirish 
281678453a8Sspeer /*
282678453a8Sspeer  * Virtualization Regions.
283678453a8Sspeer  */
284678453a8Sspeer #define	NXGE_MAX_VRS			8
285678453a8Sspeer 
286da14cebeSEric Cheng /*
287da14cebeSEric Cheng  * TDC groups are used exclusively for the purpose of Hybrid I/O
288da14cebeSEric Cheng  * TX needs one group for each VR
289da14cebeSEric Cheng  */
290da14cebeSEric Cheng #define	NXGE_MAX_TDC_GROUPS		(NXGE_MAX_VRS)
291da14cebeSEric Cheng 
29244961713Sgirish /* Max. RDC table groups */
29344961713Sgirish #define	NXGE_MAX_RDC_GROUPS		8
29444961713Sgirish #define	NXGE_MAX_RDCS			16
29544961713Sgirish #define	NXGE_MAX_DMAS			32
29644961713Sgirish 
29744961713Sgirish #define	NXGE_MAX_MACS_XMACS		16
29844961713Sgirish #define	NXGE_MAX_MACS_BMACS		8
29944961713Sgirish #define	NXGE_MAX_MACS			(NXGE_MAX_PORTS * NXGE_MAX_MACS_XMACS)
30044961713Sgirish 
30144961713Sgirish #define	NXGE_MAX_VLANS			4096
30244961713Sgirish #define	VLAN_ETHERTYPE			(0x8100)
30344961713Sgirish 
30444961713Sgirish 
30544961713Sgirish /* Scaling factor for RBR (receive block ring) */
30644961713Sgirish #define	RBR_SCALE_1		0
30744961713Sgirish #define	RBR_SCALE_2		1
30844961713Sgirish #define	RBR_SCALE_3		2
30944961713Sgirish #define	RBR_SCALE_4		3
31044961713Sgirish #define	RBR_SCALE_5		4
31144961713Sgirish #define	RBR_SCALE_6		5
31244961713Sgirish #define	RBR_SCALE_7		6
31344961713Sgirish #define	RBR_SCALE_8		7
31444961713Sgirish 
31544961713Sgirish 
31644961713Sgirish #define	MAX_PORTS_PER_NXGE	4
31744961713Sgirish #define	MAX_MACS		32
31844961713Sgirish 
31944961713Sgirish #define	TX_GATHER_POINTER_SZ	8
32044961713Sgirish #define	TX_GP_PER_BLOCK		8
32144961713Sgirish #define	TX_DEFAULT_MAX_GPS	1024	/* Max. # of gather pointers */
32244961713Sgirish #define	TX_DEFAULT_JUMBO_MAX_GPS 4096	/* Max. # of gather pointers */
32344961713Sgirish #define	TX_DEFAULT_MAX_LEN	(TX_DEFAULT_MAX_GPS/TX_GP_PER_BLOCK)
32444961713Sgirish #define	TX_DEFAULT_JUMBO_MAX_LEN (TX_DEFAULT_JUMBO_MAX_GPS/TX_GP_PER_BLOCK)
32544961713Sgirish 
32644961713Sgirish #define	TX_RING_THRESHOLD		(TX_DEFAULT_MAX_GPS/4)
32744961713Sgirish #define	TX_RING_JUMBO_THRESHOLD		(TX_DEFAULT_JUMBO_MAX_GPS/4)
32844961713Sgirish 
32944961713Sgirish #define	TRANSMIT_HEADER_SIZE		16	/* 16 B frame header */
33044961713Sgirish 
33144961713Sgirish #define	TX_DESC_SAD_SHIFT	0
33244961713Sgirish #define	TX_DESC_SAD_MASK	0x00000FFFFFFFFFFFULL	/* start address */
33344961713Sgirish #define	TX_DESC_TR_LEN_SHIFT	44
33444961713Sgirish #define	TX_DESC_TR_LEN_MASK	0x00FFF00000000000ULL	/* Transfer Length */
33544961713Sgirish #define	TX_DESC_NUM_PTR_SHIFT	58
33644961713Sgirish #define	TX_DESC_NUM_PTR_MASK	0x2C00000000000000ULL	/* gather pointers */
33744961713Sgirish #define	TX_DESC_MASK_SHIFT	62
33844961713Sgirish #define	TX_DESC_MASK_MASK	0x4000000000000000ULL	/* Mark bit */
33944961713Sgirish #define	TX_DESC_SOP_SHIF	63
34044961713Sgirish #define	TX_DESC_NUM_MASK	0x8000000000000000ULL	/* Start of packet */
34144961713Sgirish 
34244961713Sgirish #define	TCAM_FLOW_KEY_MAX_CLASS		12
34344961713Sgirish #define	TCAM_L3_MAX_USER_CLASS		4
344*4df55fdeSJanie Lu #define	TCAM_MAX_ENTRY			256
34544961713Sgirish #define	TCAM_NIU_TCAM_MAX_ENTRY		128
34644961713Sgirish #define	TCAM_NXGE_TCAM_MAX_ENTRY	256
347*4df55fdeSJanie Lu #define	NXGE_L2_PROG_CLS		2
348*4df55fdeSJanie Lu #define	NXGE_L3_PROG_CLS		4
34944961713Sgirish 
35044961713Sgirish 
35144961713Sgirish 
35244961713Sgirish /* TCAM entry formats */
35344961713Sgirish #define	TCAM_IPV4_5TUPLE_FORMAT	0x00
35444961713Sgirish #define	TCAM_IPV6_5TUPLE_FORMAT	0x01
35544961713Sgirish #define	TCAM_ETHERTYPE_FORMAT	0x02
35644961713Sgirish 
35744961713Sgirish 
35844961713Sgirish /* TCAM */
35944961713Sgirish #define	TCAM_SELECT_IPV6	0x01
36044961713Sgirish #define	TCAM_LOOKUP		0x04
36144961713Sgirish #define	TCAM_DISCARD		0x08
36244961713Sgirish 
36344961713Sgirish /* FLOW Key */
36444961713Sgirish #define	FLOW_L4_1_34_BYTES	0x10
36544961713Sgirish #define	FLOW_L4_1_78_BYTES	0x11
36644961713Sgirish #define	FLOW_L4_0_12_BYTES	(0x10 << 2)
36744961713Sgirish #define	FLOW_L4_0_56_BYTES	(0x11 << 2)
36844961713Sgirish #define	FLOW_PROTO_NEXT		0x10
36944961713Sgirish #define	FLOW_IPDA		0x20
37044961713Sgirish #define	FLOW_IPSA		0x40
37144961713Sgirish #define	FLOW_VLAN		0x80
37244961713Sgirish #define	FLOW_L2DA		0x100
37344961713Sgirish #define	FLOW_PORT		0x200
37444961713Sgirish 
37544961713Sgirish /* TCAM */
37644961713Sgirish #define	MAX_EFRAME	11
37744961713Sgirish 
37844961713Sgirish #define	TCAM_USE_L2RDC_FLOW_LOOKUP	0x00
37944961713Sgirish #define	TCAM_USE_OFFSET_DONE		0x01
38044961713Sgirish #define	TCAM_OVERRIDE_L2_FLOW_LOOKUP	0x02
38144961713Sgirish #define	TCAM_OVERRIDE_L2_USE_OFFSET	0x03
38244961713Sgirish 
38344961713Sgirish /*
38444961713Sgirish  * FCRAM (Hashing):
38544961713Sgirish  *	1. IPv4 exact match
38644961713Sgirish  *	2. IPv6 exact match
38744961713Sgirish  *	3. IPv4 Optimistic match
38844961713Sgirish  *	4. IPv6 Optimistic match
38944961713Sgirish  *
39044961713Sgirish  */
39144961713Sgirish #define	FCRAM_IPV4_EXT_MATCH	0x00
39244961713Sgirish #define	FCRAM_IPV6_EXT_MATCH	0x01
39344961713Sgirish #define	FCRAM_IPV4_OPTI_MATCH	0x02
39444961713Sgirish #define	FCRAM_IPV6_OPTI_MATCH	0x03
39544961713Sgirish 
39644961713Sgirish 
39744961713Sgirish #define	NXGE_HASH_MAX_ENTRY	256
39844961713Sgirish 
39944961713Sgirish 
40044961713Sgirish #define	MAC_ADDR_LENGTH		6
40144961713Sgirish 
40244961713Sgirish /* convert values */
40344961713Sgirish #define	NXGE_BASE(x, y)		(((y) << (x ## _SHIFT)) & (x ## _MASK))
40444961713Sgirish #define	NXGE_VAL(x, y)		(((y) & (x ## _MASK)) >> (x ## _SHIFT))
40544961713Sgirish 
40644961713Sgirish /*
40744961713Sgirish  * Locate the DMA channel start offset (PIO_VADDR)
40844961713Sgirish  * (DMA virtual address space of the PIO block)
40944961713Sgirish  */
41044961713Sgirish #define	TDMC_PIOVADDR_OFFSET(channel)	(2 * DMA_CSR_SIZE * channel)
41144961713Sgirish #define	RDMC_PIOVADDR_OFFSET(channel)	(TDMC_OFFSET(channel) + DMA_CSR_SIZE)
41244961713Sgirish 
41344961713Sgirish /*
41444961713Sgirish  * PIO access using the DMC block directly (DMC)
41544961713Sgirish  */
41644961713Sgirish #define	DMC_OFFSET(channel)	(DMA_CSR_SIZE * channel)
41744961713Sgirish #define	TDMC_OFFSET(channel)	(TX_RNG_CFIG + DMA_CSR_SIZE * channel)
41844961713Sgirish 
41944961713Sgirish /*
42044961713Sgirish  * Number of logical pages.
42144961713Sgirish  */
42244961713Sgirish #define	NXGE_MAX_LOGICAL_PAGES		2
42344961713Sgirish 
42444961713Sgirish #ifdef	SOLARIS
42544961713Sgirish #ifndef	i386
42644961713Sgirish #define	_BIT_FIELDS_BIG_ENDIAN		_BIT_FIELDS_HTOL
42744961713Sgirish #else
42844961713Sgirish #define	_BIT_FIELDS_LITTLE_ENDIAN	_BIT_FIELDS_LTOH
42944961713Sgirish #endif
43044961713Sgirish #else
43144961713Sgirish #define	_BIT_FIELDS_LITTLE_ENDIAN	_LITTLE_ENDIAN_BITFIELD
43244961713Sgirish #endif
43344961713Sgirish 
43444961713Sgirish #define	MAX_PIO_RETRIES		32
43544961713Sgirish 
43644961713Sgirish #define	IS_PORT_NUM_VALID(portn)\
43744961713Sgirish 	(portn < 4)
43844961713Sgirish 
43944961713Sgirish /*
44044961713Sgirish  * The following macros expect unsigned input values.
44144961713Sgirish  */
44244961713Sgirish #define	TXDMA_CHANNEL_VALID(cn)		(cn < NXGE_MAX_TDCS)
44344961713Sgirish #define	TXDMA_PAGE_VALID(pn)		(pn < NXGE_MAX_LOGICAL_PAGES)
44444961713Sgirish #define	TXDMA_FUNC_VALID(fn)		(fn < MAX_PORTS_PER_NXGE)
44544961713Sgirish #define	FUNC_VALID(n)			(n < MAX_PORTS_PER_NXGE)
44644961713Sgirish 
44744961713Sgirish /*
44844961713Sgirish  * DMA channel binding definitions.
44944961713Sgirish  */
45044961713Sgirish #define	VIR_PAGE_INDEX_MAX		8
45144961713Sgirish #define	VIR_SUB_REGIONS			2
45244961713Sgirish #define	VIR_DMA_BIND			1
45344961713Sgirish 
45444961713Sgirish #define	SUBREGION_VALID(n)		(n < VIR_SUB_REGIONS)
45544961713Sgirish #define	VIR_PAGE_INDEX_VALID(n)		(n < VIR_PAGE_INDEX_MAX)
45644961713Sgirish #define	VRXDMA_CHANNEL_VALID(n)		(n < NXGE_MAX_RDCS)
45744961713Sgirish 
45844961713Sgirish /*
45944961713Sgirish  * Logical device definitions.
46044961713Sgirish  */
46144961713Sgirish #define	NXGE_INT_MAX_LD		69
46244961713Sgirish #define	NXGE_INT_MAX_LDG	64
46344961713Sgirish 
46444961713Sgirish #define	NXGE_RDMA_LD_START	 0
46544961713Sgirish #define	NXGE_TDMA_LD_START	32
46644961713Sgirish #define	NXGE_MIF_LD		63
46744961713Sgirish #define	NXGE_MAC_LD_PORT0	64
46844961713Sgirish #define	NXGE_MAC_LD_PORT1	65
46944961713Sgirish #define	NXGE_MAC_LD_PORT2	66
47044961713Sgirish #define	NXGE_MAC_LD_PORT3	67
47144961713Sgirish #define	NXGE_SYS_ERROR_LD	68
47244961713Sgirish 
47344961713Sgirish #define	LDG_VALID(n)			(n < NXGE_INT_MAX_LDG)
47444961713Sgirish #define	LD_VALID(n)			(n < NXGE_INT_MAX_LD)
47544961713Sgirish #define	LD_RXDMA_LD_VALID(n)		(n < NXGE_MAX_RDCS)
47644961713Sgirish #define	LD_TXDMA_LD_VALID(n)		(n >= NXGE_MAX_RDCS && \
47744961713Sgirish 					((n - NXGE_MAX_RDCS) < NXGE_MAX_TDCS)))
47844961713Sgirish #define	LD_MAC_VALID(n)			(IS_PORT_NUM_VALID(n))
47944961713Sgirish 
48044961713Sgirish #define	LD_TIMER_MAX			0x3f
48144961713Sgirish #define	LD_INTTIMER_VALID(n)		(n <= LD_TIMER_MAX)
48244961713Sgirish 
48344961713Sgirish /* System Interrupt Data */
48444961713Sgirish #define	SID_VECTOR_MAX			0x1f
48544961713Sgirish #define	SID_VECTOR_VALID(n)		(n <= SID_VECTOR_MAX)
48644961713Sgirish 
48744961713Sgirish #define	NXGE_COMPILE_32
48844961713Sgirish 
48944961713Sgirish #ifdef	__cplusplus
49044961713Sgirish }
49144961713Sgirish #endif
49244961713Sgirish 
49344961713Sgirish #endif	/* _SYS_NXGE_NXGE_DEFS_H */
494