xref: /titanic_41/usr/src/uts/common/sys/nxge/nxge_mac.h (revision f48205be61a214698b763ff550ab9e657525104c)
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	_SYS_NXGE_NXGE_MAC_H
27 #define	_SYS_NXGE_NXGE_MAC_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #ifdef	__cplusplus
32 extern "C" {
33 #endif
34 
35 #include <nxge_mac_hw.h>
36 #include <npi_mac.h>
37 
38 #define	NXGE_MTU_DEFAULT_MAX	1522	/* 0x5f2 */
39 
40 #define	NXGE_XMAC_TX_INTRS	(ICFG_XMAC_TX_ALL & \
41 					~(ICFG_XMAC_TX_FRAME_XMIT |\
42 					ICFG_XMAC_TX_BYTE_CNT_EXP |\
43 					ICFG_XMAC_TX_FRAME_CNT_EXP))
44 #define	NXGE_XMAC_RX_INTRS	(ICFG_XMAC_RX_ALL & \
45 					~(ICFG_XMAC_RX_FRAME_RCVD |\
46 					ICFG_XMAC_RX_OCT_CNT_EXP |\
47 					ICFG_XMAC_RX_HST_CNT1_EXP |\
48 					ICFG_XMAC_RX_HST_CNT2_EXP |\
49 					ICFG_XMAC_RX_HST_CNT3_EXP |\
50 					ICFG_XMAC_RX_HST_CNT4_EXP |\
51 					ICFG_XMAC_RX_HST_CNT5_EXP |\
52 					ICFG_XMAC_RX_HST_CNT6_EXP |\
53 					ICFG_XMAC_RX_BCAST_CNT_EXP |\
54 					ICFG_XMAC_RX_MCAST_CNT_EXP |\
55 					ICFG_XMAC_RX_HST_CNT7_EXP))
56 #define	NXGE_BMAC_TX_INTRS	(ICFG_BMAC_TX_ALL & \
57 					~(ICFG_BMAC_TX_FRAME_SENT |\
58 					ICFG_BMAC_TX_BYTE_CNT_EXP |\
59 					ICFG_BMAC_TX_FRAME_CNT_EXP))
60 #define	NXGE_BMAC_RX_INTRS	(ICFG_BMAC_RX_ALL & \
61 					~(ICFG_BMAC_RX_FRAME_RCVD |\
62 					ICFG_BMAC_RX_FRAME_CNT_EXP |\
63 					ICFG_BMAC_RX_BYTE_CNT_EXP))
64 
65 typedef enum  {
66 	LINK_NO_CHANGE,
67 	LINK_IS_UP,
68 	LINK_IS_DOWN
69 } nxge_link_state_t;
70 
71 /* Common MAC statistics */
72 
73 typedef	struct _nxge_mac_stats {
74 	/*
75 	 * MTU size
76 	 */
77 	uint32_t	mac_mtu;
78 	uint16_t	rev_id;
79 
80 	/*
81 	 * Transciever state informations.
82 	 */
83 	uint32_t	xcvr_inits;
84 	xcvr_inuse_t	xcvr_inuse;
85 	uint32_t	xcvr_portn;
86 	uint32_t	xcvr_id;
87 	uint32_t	serdes_inits;
88 	uint32_t	serdes_portn;
89 	uint32_t	cap_autoneg;
90 	uint32_t	cap_10gfdx;
91 	uint32_t	cap_10ghdx;
92 	uint32_t	cap_1000fdx;
93 	uint32_t	cap_1000hdx;
94 	uint32_t	cap_100T4;
95 	uint32_t	cap_100fdx;
96 	uint32_t	cap_100hdx;
97 	uint32_t	cap_10fdx;
98 	uint32_t	cap_10hdx;
99 	uint32_t	cap_asmpause;
100 	uint32_t	cap_pause;
101 
102 	/*
103 	 * Advertised capabilities.
104 	 */
105 	uint32_t	adv_cap_autoneg;
106 	uint32_t	adv_cap_10gfdx;
107 	uint32_t	adv_cap_10ghdx;
108 	uint32_t	adv_cap_1000fdx;
109 	uint32_t	adv_cap_1000hdx;
110 	uint32_t	adv_cap_100T4;
111 	uint32_t	adv_cap_100fdx;
112 	uint32_t	adv_cap_100hdx;
113 	uint32_t	adv_cap_10fdx;
114 	uint32_t	adv_cap_10hdx;
115 	uint32_t	adv_cap_asmpause;
116 	uint32_t	adv_cap_pause;
117 
118 	/*
119 	 * Link partner capabilities.
120 	 */
121 	uint32_t	lp_cap_autoneg;
122 	uint32_t	lp_cap_10gfdx;
123 	uint32_t	lp_cap_10ghdx;
124 	uint32_t	lp_cap_1000fdx;
125 	uint32_t	lp_cap_1000hdx;
126 	uint32_t	lp_cap_100T4;
127 	uint32_t	lp_cap_100fdx;
128 	uint32_t	lp_cap_100hdx;
129 	uint32_t	lp_cap_10fdx;
130 	uint32_t	lp_cap_10hdx;
131 	uint32_t	lp_cap_asmpause;
132 	uint32_t	lp_cap_pause;
133 
134 	/*
135 	 * Physical link statistics.
136 	 */
137 	uint32_t	link_T4;
138 	uint32_t	link_speed;
139 	uint32_t	link_duplex;
140 	uint32_t	link_asmpause;
141 	uint32_t	link_pause;
142 	uint32_t	link_up;
143 
144 	/* Promiscous mode */
145 	boolean_t	promisc;
146 } nxge_mac_stats_t;
147 
148 /* XMAC Statistics */
149 
150 typedef	struct _nxge_xmac_stats {
151 	uint32_t tx_frame_cnt;
152 	uint32_t tx_underflow_err;
153 	uint32_t tx_maxpktsize_err;
154 	uint32_t tx_overflow_err;
155 	uint32_t tx_fifo_xfr_err;
156 	uint64_t tx_byte_cnt;
157 	uint32_t rx_frame_cnt;
158 	uint32_t rx_underflow_err;
159 	uint32_t rx_overflow_err;
160 	uint32_t rx_crc_err_cnt;
161 	uint32_t rx_len_err_cnt;
162 	uint32_t rx_viol_err_cnt;
163 	uint64_t rx_byte_cnt;
164 	uint64_t rx_hist1_cnt;
165 	uint64_t rx_hist2_cnt;
166 	uint64_t rx_hist3_cnt;
167 	uint64_t rx_hist4_cnt;
168 	uint64_t rx_hist5_cnt;
169 	uint64_t rx_hist6_cnt;
170 	uint64_t rx_hist7_cnt;
171 	uint64_t rx_broadcast_cnt;
172 	uint64_t rx_mult_cnt;
173 	uint32_t rx_frag_cnt;
174 	uint32_t rx_frame_align_err_cnt;
175 	uint32_t rx_linkfault_err_cnt;
176 	uint32_t rx_remotefault_err;
177 	uint32_t rx_localfault_err;
178 	uint32_t rx_pause_cnt;
179 	uint32_t tx_pause_state;
180 	uint32_t tx_nopause_state;
181 	uint32_t xpcs_deskew_err_cnt;
182 	uint32_t xpcs_ln0_symbol_err_cnt;
183 	uint32_t xpcs_ln1_symbol_err_cnt;
184 	uint32_t xpcs_ln2_symbol_err_cnt;
185 	uint32_t xpcs_ln3_symbol_err_cnt;
186 } nxge_xmac_stats_t, *p_nxge_xmac_stats_t;
187 
188 /* BMAC Statistics */
189 
190 typedef	struct _nxge_bmac_stats {
191 	uint64_t tx_frame_cnt;
192 	uint32_t tx_underrun_err;
193 	uint32_t tx_max_pkt_err;
194 	uint64_t tx_byte_cnt;
195 	uint64_t rx_frame_cnt;
196 	uint64_t rx_byte_cnt;
197 	uint32_t rx_overflow_err;
198 	uint32_t rx_align_err_cnt;
199 	uint32_t rx_crc_err_cnt;
200 	uint32_t rx_len_err_cnt;
201 	uint32_t rx_viol_err_cnt;
202 	uint32_t rx_pause_cnt;
203 	uint32_t tx_pause_state;
204 	uint32_t tx_nopause_state;
205 } nxge_bmac_stats_t, *p_nxge_bmac_stats_t;
206 
207 typedef struct _hash_filter_t {
208 	uint_t hash_ref_cnt;
209 	uint16_t hash_filter_regs[NMCFILTER_REGS];
210 	uint32_t hash_bit_ref_cnt[NMCFILTER_BITS];
211 } hash_filter_t, *p_hash_filter_t;
212 
213 typedef	struct _nxge_mac {
214 	uint8_t			portnum;
215 	nxge_port_t		porttype;
216 	nxge_port_mode_t	portmode;
217 	nxge_linkchk_mode_t	linkchkmode;
218 	boolean_t		is_jumbo;
219 	uint32_t		tx_config;
220 	uint32_t		rx_config;
221 	uint32_t		xif_config;
222 	uint32_t		tx_iconfig;
223 	uint32_t		rx_iconfig;
224 	uint32_t		ctl_iconfig;
225 	uint16_t		minframesize;
226 	uint16_t		maxframesize;
227 	uint16_t		maxburstsize;
228 	uint16_t		ctrltype;
229 	uint16_t		pa_size;
230 	uint8_t			ipg[3];
231 	struct ether_addr	mac_addr;
232 	struct ether_addr	alt_mac_addr[MAC_MAX_ALT_ADDR_ENTRY];
233 	struct ether_addr	mac_addr_filter;
234 	uint16_t		hashtab[MAC_MAX_HASH_ENTRY];
235 	hostinfo_t		hostinfo[MAC_MAX_HOST_INFO_ENTRY];
236 	nxge_mac_stats_t	*mac_stats;
237 	nxge_xmac_stats_t	*xmac_stats;
238 	nxge_bmac_stats_t	*bmac_stats;
239 } nxge_mac_t;
240 
241 #ifdef	__cplusplus
242 }
243 #endif
244 
245 #endif	/* _SYS_NXGE_NXGE_MAC_H */
246