xref: /titanic_44/usr/src/uts/common/io/nxge/npi/npi_espc.h (revision 2e59129a8dc96d4082395c338ad696e29471d4e0)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _NPI_ESPC_H
27 #define	_NPI_ESPC_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #ifdef	__cplusplus
32 extern "C" {
33 #endif
34 
35 #include <npi.h>
36 #include <nxge_espc_hw.h>
37 
38 #define	EPC_WAIT_RW_COMP(handle, val_p, comp_bit) {\
39 	uint32_t cnt = MAX_PIO_RETRIES;\
40 	do {\
41 		NXGE_DELAY(EPC_RW_WAIT);\
42 		NXGE_REG_RD64(handle, ESPC_REG_ADDR(ESPC_PIO_STATUS_REG),\
43 				val_p); cnt--;\
44 	} while (((val & comp_bit) == 0) && (cnt > 0));\
45 }
46 
47 /* ESPC specific errors */
48 
49 #define	ESPC_EEPROM_ADDR_INVALID	0x51
50 #define	ESPC_STR_LEN_INVALID		0x91
51 
52 /* ESPC error return macros */
53 
54 #define	NPI_ESPC_EEPROM_ADDR_INVALID	((ESPC_BLK_ID << 8) |\
55 					ESPC_EEPROM_ADDR_INVALID)
56 #define	NPI_ESPC_EEPROM_WRITE_FAILED	((ESPC_BLK_ID << 8) | WRITE_FAILED)
57 #define	NPI_ESPC_EEPROM_READ_FAILED	((ESPC_BLK_ID << 8) | READ_FAILED)
58 #define	NPI_ESPC_OPCODE_INVALID		((ESPC_BLK_ID << 8) | OPCODE_INVALID)
59 #define	NPI_ESPC_STR_LEN_INVALID	((ESPC_BLK_ID << 8) |\
60 					ESPC_STR_LEN_INVALID)
61 #define	NPI_ESPC_PORT_INVALID		((ESPC_BLK_ID << 8) | PORT_INVALID)
62 
63 /* EEPROM size, Fcode and VPD definitions */
64 
65 /*
66  * VPD information.
67  */
68 #define	NXGE_VPD_MOD_LEN	32
69 #define	NXGE_VPD_BD_MOD_LEN	16
70 #define	NXGE_VPD_PHY_LEN	5
71 #define	NXGE_VPD_VER_LEN	60
72 typedef struct _npi_vpd_info_t {
73 	uint8_t		mac_addr[ETHERADDRL];
74 	uint8_t		num_macs;
75 	char		model[NXGE_VPD_MOD_LEN];
76 	char		bd_model[NXGE_VPD_BD_MOD_LEN];
77 	char		phy_type[NXGE_VPD_PHY_LEN];
78 	char		ver[NXGE_VPD_VER_LEN];
79 	boolean_t	ver_valid;
80 	boolean_t	present;
81 } npi_vpd_info_t, *p_npi_vpd_info_t;
82 
83 #define	NXGE_FCODE_ID_STR	"FCode "
84 #define	NXGE_FCODE_VER_STR_LEN	5
85 #define	NXGE_VPD_VALID_VER_W	3
86 #define	NXGE_VPD_VALID_VER_F	4
87 #define	EXPANSION_ROM_SIZE	65536
88 #define	FD_MODEL		0x01
89 #define	FD_BD_MODEL		0x02
90 #define	FD_MAC_ADDR		0x04
91 #define	FD_NUM_MACS		0x08
92 #define	FD_PHY_TYPE		0x10
93 #define	FD_FW_VERSION		0x20
94 #define	FD_ALL			0x3f
95 
96 npi_status_t npi_espc_pio_enable(npi_handle_t);
97 npi_status_t npi_espc_pio_disable(npi_handle_t);
98 npi_status_t npi_espc_eeprom_entry(npi_handle_t, io_op_t,
99 				uint32_t, uint8_t *);
100 npi_status_t npi_espc_mac_addr_get(npi_handle_t, uint8_t *);
101 npi_status_t npi_espc_num_ports_get(npi_handle_t, uint8_t *);
102 	npi_status_t npi_espc_num_macs_get(npi_handle_t, uint8_t *);
103 npi_status_t npi_espc_model_str_get(npi_handle_t, char *);
104 npi_status_t npi_espc_bd_model_str_get(npi_handle_t, char *);
105 npi_status_t npi_espc_phy_type_get(npi_handle_t, uint8_t *);
106 npi_status_t npi_espc_port_phy_type_get(npi_handle_t, uint8_t *,
107 				uint8_t);
108 npi_status_t npi_espc_max_frame_get(npi_handle_t, uint16_t *);
109 npi_status_t npi_espc_version_get(npi_handle_t, uint16_t *);
110 	npi_status_t npi_espc_img_sz_get(npi_handle_t, uint16_t *);
111 npi_status_t npi_espc_chksum_get(npi_handle_t, uint8_t *);
112 npi_status_t npi_espc_intr_num_get(npi_handle_t, uint8_t *);
113 uint32_t npi_espc_reg_get(npi_handle_t, int);
114 void npi_espc_dump(npi_handle_t);
115 npi_status_t npi_espc_vpd_info_get(npi_handle_t, p_npi_vpd_info_t, uint32_t);
116 
117 #ifdef	__cplusplus
118 }
119 #endif
120 
121 #endif	/* _NPI_ESPC_H */
122