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 /*
2244961713Sgirish  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
2344961713Sgirish  * Use is subject to license terms.
2444961713Sgirish  */
2544961713Sgirish 
2644961713Sgirish #ifndef	_SYS_NXGE_NXGE_ESPC_H
2744961713Sgirish #define	_SYS_NXGE_NXGE_ESPC_H
2844961713Sgirish 
2944961713Sgirish #ifdef	__cplusplus
3044961713Sgirish extern "C" {
3144961713Sgirish #endif
3244961713Sgirish 
3344961713Sgirish #include <nxge_espc_hw.h>
3444961713Sgirish 
3544961713Sgirish #define	ESPC_MAC_ADDR_0		ESPC_NCR_REGN(0)
3644961713Sgirish #define	ESPC_MAC_ADDR_1		ESPC_NCR_REGN(1)
3744961713Sgirish #define	ESPC_NUM_PORTS_MACS	ESPC_NCR_REGN(2)
3844961713Sgirish #define	ESPC_MOD_STR_LEN	ESPC_NCR_REGN(4)
3944961713Sgirish #define	ESPC_MOD_STR_1		ESPC_NCR_REGN(5)
4044961713Sgirish #define	ESPC_MOD_STR_2		ESPC_NCR_REGN(6)
4144961713Sgirish #define	ESPC_MOD_STR_3		ESPC_NCR_REGN(7)
4244961713Sgirish #define	ESPC_MOD_STR_4		ESPC_NCR_REGN(8)
4344961713Sgirish #define	ESPC_MOD_STR_5		ESPC_NCR_REGN(9)
4444961713Sgirish #define	ESPC_MOD_STR_6		ESPC_NCR_REGN(10)
4544961713Sgirish #define	ESPC_MOD_STR_7		ESPC_NCR_REGN(11)
4644961713Sgirish #define	ESPC_MOD_STR_8		ESPC_NCR_REGN(12)
4744961713Sgirish #define	ESPC_BD_MOD_STR_LEN	ESPC_NCR_REGN(13)
4844961713Sgirish #define	ESPC_BD_MOD_STR_1	ESPC_NCR_REGN(14)
4944961713Sgirish #define	ESPC_BD_MOD_STR_2	ESPC_NCR_REGN(15)
5044961713Sgirish #define	ESPC_BD_MOD_STR_3	ESPC_NCR_REGN(16)
5144961713Sgirish #define	ESPC_BD_MOD_STR_4	ESPC_NCR_REGN(17)
5244961713Sgirish #define	ESPC_PHY_TYPE		ESPC_NCR_REGN(18)
5344961713Sgirish #define	ESPC_MAX_FM_SZ		ESPC_NCR_REGN(19)
5444961713Sgirish #define	ESPC_INTR_NUM		ESPC_NCR_REGN(20)
5544961713Sgirish #define	ESPC_VER_IMGSZ		ESPC_NCR_REGN(21)
5644961713Sgirish #define	ESPC_CHKSUM		ESPC_NCR_REGN(22)
5744961713Sgirish 
5844961713Sgirish #define	NUM_PORTS_MASK		0xff
5944961713Sgirish #define	NUM_MAC_ADDRS_MASK	0xff0000
6044961713Sgirish #define	NUM_MAC_ADDRS_SHIFT	16
6144961713Sgirish #define	MOD_STR_LEN_MASK	0xffff
6244961713Sgirish #define	BD_MOD_STR_LEN_MASK	0xffff
6344961713Sgirish #define	MAX_FM_SZ_MASK		0xffff
6444961713Sgirish #define	VER_NUM_MASK		0xffff
6544961713Sgirish #define	IMG_SZ_MASK		0xffff0000
6644961713Sgirish #define	IMG_SZ_SHIFT		16
6744961713Sgirish #define	CHKSUM_MASK		0xff
6844961713Sgirish 
6944961713Sgirish /* 0 <= n < 8 */
7044961713Sgirish #define	ESPC_MOD_STR(n)		(ESPC_MOD_STR_1 + n*8)
7144961713Sgirish #define	MAX_MOD_STR_LEN		32
7244961713Sgirish 
7344961713Sgirish /* 0 <= n < 4 */
7444961713Sgirish #define	ESPC_BD_MOD_STR(n)	(ESPC_BD_MOD_STR_1 + n*8)
7544961713Sgirish #define	MAX_BD_MOD_STR_LEN	16
7644961713Sgirish 
7744961713Sgirish #define	ESC_PHY_10G_FIBER	0x0
7844961713Sgirish #define	ESC_PHY_10G_COPPER	0x1
7944961713Sgirish #define	ESC_PHY_1G_FIBER	0x2
8044961713Sgirish #define	ESC_PHY_1G_COPPER	0x3
8144961713Sgirish #define	ESC_PHY_NONE		0xf
8244961713Sgirish 
8344961713Sgirish #define	ESC_IMG_CHKSUM_VAL	0xab
8444961713Sgirish 
8544961713Sgirish typedef union _mac_addr_0_t {
8644961713Sgirish 	uint64_t value;
8744961713Sgirish 
8844961713Sgirish 	struct {
8944961713Sgirish #if defined(_BIG_ENDIAN)
9044961713Sgirish 		uint32_t msw;	/* Most significant word */
9144961713Sgirish 		uint32_t lsw;	/* Least significant word */
9244961713Sgirish #elif defined(_LITTLE_ENDIAN)
9344961713Sgirish 		uint32_t lsw;	/* Least significant word */
9444961713Sgirish 		uint32_t msw;	/* Most significant word */
9544961713Sgirish #endif
9644961713Sgirish 	} val;
9744961713Sgirish 	struct {
9844961713Sgirish #if defined(_BIG_ENDIAN)
9944961713Sgirish 		uint32_t	w1;
10044961713Sgirish #endif
10144961713Sgirish 		struct {
10244961713Sgirish #if defined(_BIT_FIELDS_HTOL)
10344961713Sgirish 		uint32_t byte3		: 8;
10444961713Sgirish 		uint32_t byte2		: 8;
10544961713Sgirish 		uint32_t byte1		: 8;
10644961713Sgirish 		uint32_t byte0		: 8;
10744961713Sgirish #elif defined(_BIT_FIELDS_LTOH)
10844961713Sgirish 		uint32_t byte0		: 8;
10944961713Sgirish 		uint32_t byte1		: 8;
11044961713Sgirish 		uint32_t byte2		: 8;
11144961713Sgirish 		uint32_t byte3		: 8;
11244961713Sgirish #endif
11344961713Sgirish 		} w0;
11444961713Sgirish 
11544961713Sgirish #if defined(_LITTLE_ENDIAN)
11644961713Sgirish 		uint32_t	w1;
11744961713Sgirish #endif
11844961713Sgirish 	} bits;
11944961713Sgirish } mac_addr_0_t;
12044961713Sgirish 
12144961713Sgirish typedef union _mac_addr_1_t {
12244961713Sgirish 	uint64_t value;
12344961713Sgirish 
12444961713Sgirish 	struct {
12544961713Sgirish #if defined(_BIG_ENDIAN)
12644961713Sgirish 		uint32_t msw;	/* Most significant word */
12744961713Sgirish 		uint32_t lsw;	/* Least significant word */
12844961713Sgirish #elif defined(_LITTLE_ENDIAN)
12944961713Sgirish 		uint32_t lsw;	/* Least significant word */
13044961713Sgirish 		uint32_t msw;	/* Most significant word */
13144961713Sgirish #endif
13244961713Sgirish 	} val;
13344961713Sgirish 	struct {
13444961713Sgirish #if defined(_BIG_ENDIAN)
13544961713Sgirish 		uint32_t	w1;
13644961713Sgirish #endif
13744961713Sgirish 		struct {
13844961713Sgirish #if defined(_BIT_FIELDS_HTOL)
13944961713Sgirish 		uint32_t res		: 16;
14044961713Sgirish 		uint32_t byte5		: 8;
14144961713Sgirish 		uint32_t byte4		: 8;
14244961713Sgirish #elif defined(_BIT_FIELDS_LTOH)
14344961713Sgirish 		uint32_t byte4		: 8;
14444961713Sgirish 		uint32_t byte5		: 8;
14544961713Sgirish 		uint32_t res		: 16;
14644961713Sgirish #endif
14744961713Sgirish 		} w0;
14844961713Sgirish 
14944961713Sgirish #if defined(_LITTLE_ENDIAN)
15044961713Sgirish 		uint32_t	w1;
15144961713Sgirish #endif
15244961713Sgirish 	} bits;
15344961713Sgirish } mac_addr_1_t;
15444961713Sgirish 
15544961713Sgirish 
15644961713Sgirish typedef union _phy_type_t {
15744961713Sgirish 	uint64_t value;
15844961713Sgirish 
15944961713Sgirish 	struct {
16044961713Sgirish #if defined(_BIG_ENDIAN)
16144961713Sgirish 		uint32_t msw;	/* Most significant word */
16244961713Sgirish 		uint32_t lsw;	/* Least significant word */
16344961713Sgirish #elif defined(_LITTLE_ENDIAN)
16444961713Sgirish 		uint32_t lsw;	/* Least significant word */
16544961713Sgirish 		uint32_t msw;	/* Most significant word */
16644961713Sgirish #endif
16744961713Sgirish 	} val;
16844961713Sgirish 	struct {
16944961713Sgirish #if defined(_BIG_ENDIAN)
17044961713Sgirish 		uint32_t	w1;
17144961713Sgirish #endif
17244961713Sgirish 		struct {
17344961713Sgirish #if defined(_BIT_FIELDS_HTOL)
17444961713Sgirish 		uint32_t pt0_phy_type	: 8;
17544961713Sgirish 		uint32_t pt1_phy_type	: 8;
17644961713Sgirish 		uint32_t pt2_phy_type	: 8;
17744961713Sgirish 		uint32_t pt3_phy_type	: 8;
17844961713Sgirish #elif defined(_BIT_FIELDS_LTOH)
17944961713Sgirish 		uint32_t pt3_phy_type	: 8;
18044961713Sgirish 		uint32_t pt2_phy_type	: 8;
18144961713Sgirish 		uint32_t pt1_phy_type	: 8;
18244961713Sgirish 		uint32_t pt0_phy_type	: 8;
18344961713Sgirish #endif
18444961713Sgirish 		} w0;
18544961713Sgirish 
18644961713Sgirish #if defined(_LITTLE_ENDIAN)
18744961713Sgirish 		uint32_t	w1;
18844961713Sgirish #endif
18944961713Sgirish 	} bits;
19044961713Sgirish } phy_type_t;
19144961713Sgirish 
19244961713Sgirish 
19344961713Sgirish typedef union _intr_num_t {
19444961713Sgirish 	uint64_t value;
19544961713Sgirish 
19644961713Sgirish 	struct {
19744961713Sgirish #if defined(_BIG_ENDIAN)
19844961713Sgirish 		uint32_t msw;	/* Most significant word */
19944961713Sgirish 		uint32_t lsw;	/* Least significant word */
20044961713Sgirish #elif defined(_LITTLE_ENDIAN)
20144961713Sgirish 		uint32_t lsw;	/* Least significant word */
20244961713Sgirish 		uint32_t msw;	/* Most significant word */
20344961713Sgirish #endif
20444961713Sgirish 	} val;
20544961713Sgirish 	struct {
20644961713Sgirish #if defined(_BIG_ENDIAN)
20744961713Sgirish 		uint32_t	w1;
20844961713Sgirish #endif
20944961713Sgirish 		struct {
21044961713Sgirish #if defined(_BIT_FIELDS_HTOL)
21144961713Sgirish 		uint32_t pt0_intr_num	: 8;
21244961713Sgirish 		uint32_t pt1_intr_num	: 8;
21344961713Sgirish 		uint32_t pt2_intr_num	: 8;
21444961713Sgirish 		uint32_t pt3_intr_num	: 8;
21544961713Sgirish #elif defined(_BIT_FIELDS_LTOH)
21644961713Sgirish 		uint32_t pt3_intr_num	: 8;
21744961713Sgirish 		uint32_t pt2_intr_num	: 8;
21844961713Sgirish 		uint32_t pt1_intr_num	: 8;
21944961713Sgirish 		uint32_t pt0_intr_num	: 8;
22044961713Sgirish #endif
22144961713Sgirish 		} w0;
22244961713Sgirish 
22344961713Sgirish #if defined(_LITTLE_ENDIAN)
22444961713Sgirish 		uint32_t	w1;
22544961713Sgirish #endif
22644961713Sgirish 	} bits;
22744961713Sgirish } intr_num_t;
22844961713Sgirish 
22944961713Sgirish 
23044961713Sgirish #ifdef __cplusplus
23144961713Sgirish }
23244961713Sgirish #endif
23344961713Sgirish 
23444961713Sgirish #endif	/* _SYS_NXGE_NXGE_ESPC_H */
235