xref: /titanic_50/usr/src/uts/common/io/nxge/nxge_kstats.c (revision 67318e4a54c292d543e6b077199ce492b3d3a049)
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 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #pragma ident	"%Z%%M%	%I%	%E% SMI"
27 
28 #include <sys/nxge/nxge_impl.h>
29 #include <sys/nxge/nxge_hio.h>
30 
31 #include <inet/mi.h>
32 
33 #define	RDC_NAME_FORMAT1	"RDC Channel"
34 #define	TDC_NAME_FORMAT1	"TDC Channel"
35 #define	CH_NAME_FORMAT		" %d Stats"
36 #define	TDC_NAME_FORMAT		"TDC Channel %d Stats"
37 #define	RDC_NAME_FORMAT		"RDC Channel %d Stats"
38 
39 void nxge_mac_init_kstats(p_nxge_t, struct kstat *);
40 void nxge_xmac_init_kstats(struct kstat *);
41 void nxge_bmac_init_kstats(struct kstat *);
42 
43 /* ARGSUSED */
44 void
45 nxge_init_statsp(p_nxge_t nxgep)
46 {
47 	size_t stats_size;
48 
49 	NXGE_DEBUG_MSG((nxgep, KST_CTL, "==> nxge_init_statsp"));
50 
51 	stats_size = sizeof (nxge_stats_t);
52 	nxgep->statsp = KMEM_ZALLOC(stats_size, KM_SLEEP);
53 	nxgep->statsp->stats_size = stats_size;
54 
55 	NXGE_DEBUG_MSG((nxgep, KST_CTL, " <== nxge_init_statsp"));
56 }
57 
58 typedef struct {
59 	uint8_t index;
60 	uint8_t type;
61 	char *name;
62 } nxge_kstat_index_t;
63 
64 typedef enum {
65 	RDC_STAT_PACKETS = 0,
66 	RDC_STAT_BYTES,
67 	RDC_STAT_ERRORS,
68 	RDC_STAT_DCF_ERR,
69 	RDC_STAT_RCR_ACK_ERR,
70 	RDC_STAT_RCR_DC_FIFOFLOW_ERR,
71 	RDC_STAT_RCR_SHA_PAR_ERR,
72 	RDC_STAT_RBR_PRE_PAR_ERR,
73 	RDC_STAT_WRED_DROP,
74 	RDC_STAT_RBR_PRE_EMTY,
75 	RDC_STAT_RCR_SHADOW_FULL,
76 	RDC_STAT_RBR_TMOUT,
77 	RDC_STAT_RSP_CNT_ERR,
78 	RDC_STAT_BYTE_EN_BUS,
79 	RDC_STAT_RSP_DAT_ERR,
80 	RDC_STAT_PKT_TOO_LONG_ERR,
81 	RDC_STAT_COMPL_L2_ERR,
82 	RDC_STAT_COMPL_L4_CKSUM_ERR,
83 	RDC_STAT_COMPL_ZCP_SOFT_ERR,
84 	RDC_STAT_COMPL_FFLP_SOFT_ERR,
85 	RDC_STAT_CONFIG_ERR,
86 	RDC_STAT_RCRINCON,
87 	RDC_STAT_RCRFULL,
88 	RDC_STAT_RBR_EMPTY,
89 	RDC_STAT_RBR_FULL,
90 	RDC_STAT_RBRLOGPAGE,
91 	RDC_STAT_CFIGLOGPAGE,
92 	RDC_STAT_PORT_DROP_PKT,
93 	RDC_STAT_RCRTO,
94 	RDC_STAT_RCRTHRES,
95 	RDC_STAT_MEX,
96 	RDC_STAT_ID_MIS,
97 	RDC_STAT_ZCP_EOP,
98 	RDC_STAT_IPP_EOP,
99 	RDC_STAT_END
100 } nxge_rdc_stat_index_t;
101 
102 nxge_kstat_index_t nxge_rdc_stats[] = {
103 	{RDC_STAT_PACKETS, KSTAT_DATA_UINT64, "rdc_packets"},
104 	{RDC_STAT_BYTES, KSTAT_DATA_UINT64, "rdc_bytes"},
105 	{RDC_STAT_ERRORS, KSTAT_DATA_ULONG, "rdc_errors"},
106 	{RDC_STAT_DCF_ERR, KSTAT_DATA_ULONG, "rdc_dcf_err"},
107 	{RDC_STAT_RCR_ACK_ERR, KSTAT_DATA_ULONG, "rdc_rcr_ack_err"},
108 	{RDC_STAT_RCR_DC_FIFOFLOW_ERR, KSTAT_DATA_ULONG, "rdc_dc_fifoflow_err"},
109 	{RDC_STAT_RCR_SHA_PAR_ERR, KSTAT_DATA_ULONG, "rdc_rcr_sha_par_err"},
110 	{RDC_STAT_RBR_PRE_PAR_ERR, KSTAT_DATA_ULONG, "rdc_rbr_pre_par_err"},
111 	{RDC_STAT_WRED_DROP, KSTAT_DATA_ULONG, "rdc_wred_drop"},
112 	{RDC_STAT_RBR_PRE_EMTY, KSTAT_DATA_ULONG, "rdc_rbr_pre_empty"},
113 	{RDC_STAT_RCR_SHADOW_FULL, KSTAT_DATA_ULONG, "rdc_rcr_shadow_full"},
114 	{RDC_STAT_RBR_TMOUT, KSTAT_DATA_ULONG, "rdc_rbr_tmout"},
115 	{RDC_STAT_RSP_CNT_ERR, KSTAT_DATA_ULONG, "rdc_rsp_cnt_err"},
116 	{RDC_STAT_BYTE_EN_BUS, KSTAT_DATA_ULONG, "rdc_byte_en_bus"},
117 	{RDC_STAT_RSP_DAT_ERR, KSTAT_DATA_ULONG, "rdc_rsp_dat_err"},
118 	{RDC_STAT_PKT_TOO_LONG_ERR, KSTAT_DATA_ULONG, "rdc_pkt_too_long_err"},
119 	{RDC_STAT_COMPL_L2_ERR, KSTAT_DATA_ULONG, "rdc_compl_l2_err"},
120 	{RDC_STAT_COMPL_L4_CKSUM_ERR, KSTAT_DATA_ULONG, "rdc_compl_l4_cksum"},
121 	{RDC_STAT_COMPL_ZCP_SOFT_ERR, KSTAT_DATA_ULONG,
122 		"rdc_compl_zcp_soft_err"},
123 	{RDC_STAT_COMPL_FFLP_SOFT_ERR, KSTAT_DATA_ULONG,
124 		"rdc_compl_fflp_soft_err"},
125 	{RDC_STAT_CONFIG_ERR, KSTAT_DATA_ULONG, "rdc_config_err"},
126 	{RDC_STAT_RCRINCON, KSTAT_DATA_ULONG, "rdc_rcrincon"},
127 	{RDC_STAT_RCRFULL, KSTAT_DATA_ULONG, "rdc_rcrfull"},
128 	{RDC_STAT_RBR_EMPTY, KSTAT_DATA_ULONG, "rdc_rbr_empty"},
129 	{RDC_STAT_RBR_FULL, KSTAT_DATA_ULONG, "rdc_rbrfull"},
130 	{RDC_STAT_RBRLOGPAGE, KSTAT_DATA_ULONG, "rdc_rbrlogpage"},
131 	{RDC_STAT_CFIGLOGPAGE, KSTAT_DATA_ULONG, "rdc_cfiglogpage"},
132 	{RDC_STAT_PORT_DROP_PKT, KSTAT_DATA_ULONG, "rdc_port_drop_pkt"},
133 	{RDC_STAT_RCRTO, KSTAT_DATA_ULONG, "rdc_rcrto"},
134 	{RDC_STAT_RCRTHRES, KSTAT_DATA_ULONG, "rdc_rcrthres"},
135 	{RDC_STAT_MEX, KSTAT_DATA_ULONG, "rdc_mex"},
136 	{RDC_STAT_ID_MIS, KSTAT_DATA_ULONG, "rdc_id_mismatch"},
137 	{RDC_STAT_ZCP_EOP, KSTAT_DATA_ULONG, "rdc_zcp_eop"},
138 	{RDC_STAT_IPP_EOP, KSTAT_DATA_ULONG, "rdc_ipp_eop"},
139 	{RDC_STAT_END, NULL, NULL}
140 };
141 
142 typedef enum {
143 	RDC_SYS_STAT_PRE_PAR_ERR = 0,
144 	RDC_SYS_STAT_SHA_PAR_ERR,
145 	RDC_SYS_STAT_ID_MISMATCH,
146 	RDC_SYS_STAT_IPP_EOP_ERR,
147 	RDC_SYS_STAT_ZCP_EOP_ERR,
148 	RDC_SYS_STAT_END
149 } nxge_rdc_sys_stat_idx_t;
150 
151 nxge_kstat_index_t nxge_rdc_sys_stats[] = {
152 	{RDC_SYS_STAT_PRE_PAR_ERR, KSTAT_DATA_UINT64, "rdc_pre_par_err"},
153 	{RDC_SYS_STAT_SHA_PAR_ERR, KSTAT_DATA_UINT64, "rdc_sha_par_err"},
154 	{RDC_SYS_STAT_ID_MISMATCH, KSTAT_DATA_UINT64, "rdc_stat_id_mismatch"},
155 	{RDC_SYS_STAT_IPP_EOP_ERR, KSTAT_DATA_UINT64, "rdc_ipp_eop_err"},
156 	{RDC_SYS_STAT_ZCP_EOP_ERR, KSTAT_DATA_UINT64, "rdc_zcp_eop_err"},
157 	{RDC_SYS_STAT_END, NULL, NULL}
158 };
159 
160 typedef enum {
161 	TDC_STAT_PACKETS = 0,
162 	TDC_STAT_BYTES,
163 	TDC_STAT_ERRORS,
164 	TDC_STAT_TX_INITS,
165 	TDC_STAT_TX_NO_BUF,
166 	TDC_STAT_MBOX_ERR,
167 	TDC_STAT_PKT_SIZE_ERR,
168 	TDC_STAT_TX_RING_OFLOW,
169 	TDC_STAT_PREF_BUF_ECC_ERR,
170 	TDC_STAT_NACK_PREF,
171 	TDC_STAT_NACK_PKT_RD,
172 	TDC_STAT_CONF_PART_ERR,
173 	TDC_STAT_PKT_PRT_ERR,
174 	TDC_STAT_RESET_FAIL,
175 	TDC_STAT_TX_STARTS,
176 	TDC_STAT_TX_NOCANPUT,
177 	TDC_STAT_TX_MSGDUP_FAIL,
178 	TDC_STAT_TX_ALLOCB_FAIL,
179 	TDC_STAT_TX_NO_DESC,
180 	TDC_STAT_TX_DMA_BIND_FAIL,
181 	TDC_STAT_TX_UFLOW,
182 	TDC_STAT_TX_HDR_PKTS,
183 	TDC_STAT_TX_DDI_PKTS,
184 	TDC_STAT_TX_DVMA_PKTS,
185 	TDC_STAT_TX_MAX_PEND,
186 	TDC_STAT_END
187 } nxge_tdc_stats_index_t;
188 
189 nxge_kstat_index_t nxge_tdc_stats[] = {
190 	{TDC_STAT_PACKETS, KSTAT_DATA_UINT64, "tdc_packets"},
191 	{TDC_STAT_BYTES, KSTAT_DATA_UINT64, "tdc_bytes"},
192 	{TDC_STAT_ERRORS, KSTAT_DATA_UINT64, "tdc_errors"},
193 	{TDC_STAT_TX_INITS, KSTAT_DATA_ULONG, "tdc_tx_inits"},
194 	{TDC_STAT_TX_NO_BUF, KSTAT_DATA_ULONG, "tdc_tx_no_buf"},
195 	{TDC_STAT_MBOX_ERR, KSTAT_DATA_ULONG, "tdc_mbox_err"},
196 	{TDC_STAT_PKT_SIZE_ERR, KSTAT_DATA_ULONG, "tdc_pkt_size_err"},
197 	{TDC_STAT_TX_RING_OFLOW,
198 		KSTAT_DATA_ULONG, "tdc_tx_ring_oflow"},
199 	{TDC_STAT_PREF_BUF_ECC_ERR,
200 		KSTAT_DATA_ULONG, "tdc_pref_buf_err_err"},
201 	{TDC_STAT_NACK_PREF, KSTAT_DATA_ULONG, "tdc_nack_pref"},
202 	{TDC_STAT_NACK_PKT_RD, KSTAT_DATA_ULONG, "tdc_nack_pkt_rd"},
203 	{TDC_STAT_CONF_PART_ERR,
204 		KSTAT_DATA_ULONG, "tdc_conf_part_err"},
205 	{TDC_STAT_PKT_PRT_ERR, KSTAT_DATA_ULONG, "tdc_pkt_prt_err"},
206 	{TDC_STAT_RESET_FAIL, KSTAT_DATA_ULONG, "tdc_reset_fail"},
207 	{TDC_STAT_TX_STARTS, KSTAT_DATA_ULONG, "tdc_tx_starts"},
208 	{TDC_STAT_TX_NOCANPUT, KSTAT_DATA_ULONG, "tdc_tx_nocanput"},
209 	{TDC_STAT_TX_MSGDUP_FAIL, KSTAT_DATA_ULONG, "tdc_tx_msgdup_fail"},
210 	{TDC_STAT_TX_ALLOCB_FAIL, KSTAT_DATA_ULONG, "tdc_tx_allocb_fail"},
211 	{TDC_STAT_TX_NO_DESC, KSTAT_DATA_ULONG, "tdc_tx_no_desc"},
212 	{TDC_STAT_TX_DMA_BIND_FAIL, KSTAT_DATA_ULONG, "tdc_tx_dma_bind_fail"},
213 	{TDC_STAT_TX_UFLOW, KSTAT_DATA_ULONG, "tdc_tx_uflow"},
214 	{TDC_STAT_TX_HDR_PKTS, KSTAT_DATA_ULONG, "tdc_tx_hdr_pkts"},
215 	{TDC_STAT_TX_DDI_PKTS, KSTAT_DATA_ULONG, "tdc_tx_ddi_pkts"},
216 	{TDC_STAT_TX_DVMA_PKTS, KSTAT_DATA_ULONG, "tdc_tx_dvma_pkts"},
217 	{TDC_STAT_TX_MAX_PEND, KSTAT_DATA_ULONG, "tdc_tx_max_pend"},
218 	{TDC_STAT_END, NULL, NULL}
219 };
220 
221 /* IPP Statistics definitions */
222 typedef enum {
223 	IPP_STAT_EOP_MISS = 0,
224 	IPP_STAT_SOP_MISS,
225 	IPP_STAT_DFIFO_UE,
226 	IPP_STAT_ECC_ERR,
227 	IPP_STAT_PFIFO_PERR,
228 	IPP_STAT_PFIFO_OVER,
229 	IPP_STAT_PFIFO_UND,
230 	IPP_STAT_BAD_CS,
231 	IPP_STAT_BAD_DIS,
232 	IPP_STAT_END
233 } nxge_ipp_stat_index_t;
234 
235 nxge_kstat_index_t nxge_ipp_stats[] = {
236 	{IPP_STAT_EOP_MISS, KSTAT_DATA_ULONG, "rxipp_eop_miss"},
237 	{IPP_STAT_SOP_MISS, KSTAT_DATA_ULONG, "rxipp_sop_miss"},
238 	{IPP_STAT_DFIFO_UE, KSTAT_DATA_ULONG, "rxipp_dfifo_ue"},
239 	{IPP_STAT_ECC_ERR, KSTAT_DATA_ULONG, "rxipp_ecc_err"},
240 	{IPP_STAT_PFIFO_PERR, KSTAT_DATA_ULONG, "rxipp_pfifo_perr"},
241 	{IPP_STAT_PFIFO_OVER, KSTAT_DATA_ULONG, "rxipp_pfifo_over"},
242 	{IPP_STAT_PFIFO_UND, KSTAT_DATA_ULONG, "rxipp_pfifo_und"},
243 	{IPP_STAT_BAD_CS, KSTAT_DATA_ULONG, "rxipp_bad_cs"},
244 	{IPP_STAT_BAD_DIS, KSTAT_DATA_ULONG, "rxipp_bad_dis"},
245 	{IPP_STAT_END, NULL, NULL}
246 };
247 
248 /* TXC Statistics definitions */
249 typedef enum {
250 	TXC_STAT_PKT_STUFFED = 0,
251 	TXC_STAT_PKT_XMIT,
252 	TXC_STAT_RO_CORRECT_ERR,
253 	TXC_STAT_RO_UNCORRECT_ERR,
254 	TXC_STAT_SF_CORRECT_ERR,
255 	TXC_STAT_SF_UNCORRECT_ERR,
256 	TXC_STAT_ADDRESS_FAILED,
257 	TXC_STAT_DMA_FAILED,
258 	TXC_STAT_LENGTH_FAILED,
259 	TXC_STAT_PKT_ASSY_DEAD,
260 	TXC_STAT_REORDER_ERR,
261 	TXC_STAT_END
262 } nxge_txc_stat_index_t;
263 
264 nxge_kstat_index_t nxge_txc_stats[] = {
265 	{TXC_STAT_PKT_STUFFED, KSTAT_DATA_ULONG, "txc_pkt_stuffed"},
266 	{TXC_STAT_PKT_XMIT, KSTAT_DATA_ULONG, "txc_pkt_xmit"},
267 	{TXC_STAT_RO_CORRECT_ERR, KSTAT_DATA_ULONG, "txc_ro_correct_err"},
268 	{TXC_STAT_RO_UNCORRECT_ERR, KSTAT_DATA_ULONG, "txc_ro_uncorrect_err"},
269 	{TXC_STAT_SF_CORRECT_ERR, KSTAT_DATA_ULONG, "txc_sf_correct_err"},
270 	{TXC_STAT_SF_UNCORRECT_ERR, KSTAT_DATA_ULONG, "txc_sf_uncorrect_err"},
271 	{TXC_STAT_ADDRESS_FAILED, KSTAT_DATA_ULONG, "txc_address_failed"},
272 	{TXC_STAT_DMA_FAILED, KSTAT_DATA_ULONG, "txc_dma_failed"},
273 	{TXC_STAT_LENGTH_FAILED, KSTAT_DATA_ULONG, "txc_length_failed"},
274 	{TXC_STAT_PKT_ASSY_DEAD, KSTAT_DATA_ULONG, "txc_pkt_assy_dead"},
275 	{TXC_STAT_REORDER_ERR, KSTAT_DATA_ULONG, "txc_reorder_err"},
276 	{TXC_STAT_END, NULL, NULL}
277 };
278 
279 typedef enum {
280 	XMAC_STAT_TX_FRAME_CNT = 0,
281 	XMAC_STAT_TX_UNDERFLOW_ERR,
282 	XMAC_STAT_TX_MAXPKTSIZE_ERR,
283 	XMAC_STAT_TX_OVERFLOW_ERR,
284 	XMAC_STAT_TX_FIFO_XFR_ERR,
285 	XMAC_STAT_TX_BYTE_CNT,
286 	XMAC_STAT_RX_FRAME_CNT,
287 	XMAC_STAT_RX_UNDERFLOW_ERR,
288 	XMAC_STAT_RX_OVERFLOW_ERR,
289 	XMAC_STAT_RX_CRC_ERR_CNT,
290 	XMAC_STAT_RX_LEN_ERR_CNT,
291 	XMAC_STAT_RX_VIOL_ERR_CNT,
292 	XMAC_STAT_RX_BYTE_CNT,
293 	XMAC_STAT_RX_HIST1_CNT,
294 	XMAC_STAT_RX_HIST2_CNT,
295 	XMAC_STAT_RX_HIST3_CNT,
296 	XMAC_STAT_RX_HIST4_CNT,
297 	XMAC_STAT_RX_HIST5_CNT,
298 	XMAC_STAT_RX_HIST6_CNT,
299 	XMAC_STAT_RX_HIST7_CNT,
300 	XMAC_STAT_RX_BROADCAST_CNT,
301 	XMAC_STAT_RX_MULT_CNT,
302 	XMAC_STAT_RX_FRAG_CNT,
303 	XMAC_STAT_RX_FRAME_ALIGN_ERR_CNT,
304 	XMAC_STAT_RX_LINKFAULT_ERR_CNT,
305 	XMAC_STAT_RX_REMOTEFAULT_ERR,
306 	XMAC_STAT_RX_LOCALFAULT_ERR,
307 	XMAC_STAT_RX_PAUSE_CNT,
308 	XMAC_STAT_TX_PAUSE_STATE,
309 	XMAC_STAT_TX_NOPAUSE_STATE,
310 	XMAC_STAT_XPCS_DESKEW_ERR_CNT,
311 #ifdef	NXGE_DEBUG_SYMBOL_ERR
312 	XMAC_STAT_XPCS_SYMBOL_L0_ERR_CNT,
313 	XMAC_STAT_XPCS_SYMBOL_L1_ERR_CNT,
314 	XMAC_STAT_XPCS_SYMBOL_L2_ERR_CNT,
315 	XMAC_STAT_XPCS_SYMBOL_L3_ERR_CNT,
316 #endif
317 	XMAC_STAT_END
318 } nxge_xmac_stat_index_t;
319 
320 nxge_kstat_index_t nxge_xmac_stats[] = {
321 	{XMAC_STAT_TX_FRAME_CNT, KSTAT_DATA_ULONG, "txmac_frame_cnt"},
322 	{XMAC_STAT_TX_UNDERFLOW_ERR, KSTAT_DATA_ULONG, "tmac_underflow_err"},
323 	{XMAC_STAT_TX_MAXPKTSIZE_ERR, KSTAT_DATA_ULONG, "txmac_maxpktsize_err"},
324 	{XMAC_STAT_TX_OVERFLOW_ERR, KSTAT_DATA_ULONG, "txmac_overflow_err"},
325 	{XMAC_STAT_TX_FIFO_XFR_ERR, KSTAT_DATA_ULONG, "txmac_fifo_xfr_err"},
326 	{XMAC_STAT_TX_BYTE_CNT, KSTAT_DATA_ULONG, "txmac_byte_cnt"},
327 	{XMAC_STAT_RX_FRAME_CNT, KSTAT_DATA_ULONG, "rxmac_frame_cnt"},
328 	{XMAC_STAT_RX_UNDERFLOW_ERR, KSTAT_DATA_ULONG, "rxmac_underflow_err"},
329 	{XMAC_STAT_RX_OVERFLOW_ERR, KSTAT_DATA_ULONG, "rxmac_overflow_err"},
330 	{XMAC_STAT_RX_CRC_ERR_CNT, KSTAT_DATA_ULONG, "rxmac_crc_err"},
331 	{XMAC_STAT_RX_LEN_ERR_CNT, KSTAT_DATA_ULONG, "rxmac_length_err"},
332 	{XMAC_STAT_RX_VIOL_ERR_CNT, KSTAT_DATA_ULONG, "rxmac_code_violations"},
333 	{XMAC_STAT_RX_BYTE_CNT, KSTAT_DATA_ULONG, "rxmac_byte_cnt"},
334 	{XMAC_STAT_RX_HIST1_CNT, KSTAT_DATA_ULONG, "rxmac_64_cnt"},
335 	{XMAC_STAT_RX_HIST2_CNT, KSTAT_DATA_ULONG, "rxmac_65_127_cnt"},
336 	{XMAC_STAT_RX_HIST3_CNT, KSTAT_DATA_ULONG, "rxmac_128_255_cnt"},
337 	{XMAC_STAT_RX_HIST4_CNT, KSTAT_DATA_ULONG, "rxmac_256_511_cnt"},
338 	{XMAC_STAT_RX_HIST5_CNT, KSTAT_DATA_ULONG, "rxmac_512_1023_cnt"},
339 	{XMAC_STAT_RX_HIST6_CNT, KSTAT_DATA_ULONG, "rxmac_1024_1522_cnt"},
340 	{XMAC_STAT_RX_HIST7_CNT, KSTAT_DATA_ULONG, "rxmac_jumbo_cnt"},
341 	{XMAC_STAT_RX_BROADCAST_CNT, KSTAT_DATA_ULONG, "rxmac_broadcast_cnt"},
342 	{XMAC_STAT_RX_MULT_CNT, KSTAT_DATA_ULONG, "rxmac_multicast_cnt"},
343 	{XMAC_STAT_RX_FRAG_CNT, KSTAT_DATA_ULONG, "rxmac_fragment_cnt"},
344 	{XMAC_STAT_RX_FRAME_ALIGN_ERR_CNT,
345 		KSTAT_DATA_ULONG, "rxmac_alignment_err"},
346 	{XMAC_STAT_RX_LINKFAULT_ERR_CNT,
347 		KSTAT_DATA_ULONG, "rxmac_linkfault_errs"},
348 	{XMAC_STAT_RX_REMOTEFAULT_ERR,
349 		KSTAT_DATA_ULONG, "rxmac_remote_faults"},
350 	{XMAC_STAT_RX_LOCALFAULT_ERR,
351 		KSTAT_DATA_ULONG, "rxmac_local_faults"},
352 	{XMAC_STAT_RX_PAUSE_CNT, KSTAT_DATA_ULONG, "rxmac_pause_cnt"},
353 	{XMAC_STAT_TX_PAUSE_STATE, KSTAT_DATA_ULONG, "txmac_pause_state"},
354 	{XMAC_STAT_TX_NOPAUSE_STATE, KSTAT_DATA_ULONG, "txmac_nopause_state"},
355 	{XMAC_STAT_XPCS_DESKEW_ERR_CNT,
356 		KSTAT_DATA_ULONG, "xpcs_deskew_err_cnt"},
357 #ifdef	NXGE_DEBUG_SYMBOL_ERR
358 	{XMAC_STAT_XPCS_SYMBOL_L0_ERR_CNT,
359 		KSTAT_DATA_ULONG, "xpcs_ln0_symbol_err_cnt"},
360 	{XMAC_STAT_XPCS_SYMBOL_L1_ERR_CNT,
361 		KSTAT_DATA_ULONG, "xpcs_ln1_symbol_err_cnt"},
362 	{XMAC_STAT_XPCS_SYMBOL_L2_ERR_CNT,
363 		KSTAT_DATA_ULONG, "xpcs_ln2_symbol_err_cnt"},
364 	{XMAC_STAT_XPCS_SYMBOL_L3_ERR_CNT,
365 		KSTAT_DATA_ULONG, "xpcs_ln3_symbol_err_cnt"},
366 #endif
367 	{XMAC_STAT_END, NULL, NULL}
368 };
369 
370 typedef enum {
371 	BMAC_STAT_TX_FRAME_CNT = 0,
372 	BMAC_STAT_TX_UNDERRUN_ERR,
373 	BMAC_STAT_TX_MAX_PKT_ERR,
374 	BMAC_STAT_TX_BYTE_CNT,
375 	BMAC_STAT_RX_FRAME_CNT,
376 	BMAC_STAT_RX_BYTE_CNT,
377 	BMAC_STAT_RX_OVERFLOW_ERR,
378 	BMAC_STAT_RX_ALIGN_ERR_CNT,
379 	BMAC_STAT_RX_CRC_ERR_CNT,
380 	BMAC_STAT_RX_LEN_ERR_CNT,
381 	BMAC_STAT_RX_VIOL_ERR_CNT,
382 	BMAC_STAT_RX_PAUSE_CNT,
383 	BMAC_STAT_RX_PAUSE_STATE,
384 	BMAC_STAT_RX_NOPAUSE_STATE,
385 	BMAC_STAT_END
386 } nxge_bmac_stat_index_t;
387 
388 nxge_kstat_index_t nxge_bmac_stats[] = {
389 	{BMAC_STAT_TX_FRAME_CNT, KSTAT_DATA_ULONG, "txmac_frame_cnt"},
390 	{BMAC_STAT_TX_UNDERRUN_ERR, KSTAT_DATA_ULONG, "txmac_underrun_err"},
391 	{BMAC_STAT_TX_MAX_PKT_ERR, KSTAT_DATA_ULONG, "txmac_max_pkt_err"},
392 	{BMAC_STAT_TX_BYTE_CNT, KSTAT_DATA_ULONG, "txmac_byte_cnt"},
393 	{BMAC_STAT_RX_FRAME_CNT, KSTAT_DATA_ULONG, "rxmac_frame_cnt"},
394 	{BMAC_STAT_RX_BYTE_CNT, KSTAT_DATA_ULONG, "rxmac_byte_cnt"},
395 	{BMAC_STAT_RX_OVERFLOW_ERR, KSTAT_DATA_ULONG, "rxmac_overflow_err"},
396 	{BMAC_STAT_RX_ALIGN_ERR_CNT, KSTAT_DATA_ULONG, "rxmac_align_err_cnt"},
397 	{BMAC_STAT_RX_CRC_ERR_CNT, KSTAT_DATA_ULONG, "rxmac_crc_err_cnt"},
398 	{BMAC_STAT_RX_LEN_ERR_CNT, KSTAT_DATA_ULONG, "rxmac_len_err_cnt"},
399 	{BMAC_STAT_RX_VIOL_ERR_CNT, KSTAT_DATA_ULONG, "rxmac_viol_err_cnt"},
400 	{BMAC_STAT_RX_PAUSE_CNT, KSTAT_DATA_ULONG, "rxmac_pause_cnt"},
401 	{BMAC_STAT_RX_PAUSE_STATE, KSTAT_DATA_ULONG, "txmac_pause_state"},
402 	{BMAC_STAT_RX_NOPAUSE_STATE, KSTAT_DATA_ULONG, "tx_nopause_state"},
403 	{BMAC_STAT_END, NULL, NULL}
404 };
405 
406 typedef enum {
407 	ZCP_STAT_ERRORS,
408 	ZCP_STAT_INITS,
409 	ZCP_STAT_RRFIFO_UNDERRUN,
410 	ZCP_STAT_RRFIFO_OVERRUN,
411 	ZCP_STAT_RSPFIFO_UNCORR_ERR,
412 	ZCP_STAT_BUFFER_OVERFLOW,
413 	ZCP_STAT_STAT_TBL_PERR,
414 	ZCP_STAT_DYN_TBL_PERR,
415 	ZCP_STAT_BUF_TBL_PERR,
416 	ZCP_STAT_TT_PROGRAM_ERR,
417 	ZCP_STAT_RSP_TT_INDEX_ERR,
418 	ZCP_STAT_SLV_TT_INDEX_ERR,
419 	ZCP_STAT_ZCP_TT_INDEX_ERR,
420 	ZCP_STAT_ZCP_ACCESS_FAIL,
421 	ZCP_CFIFO_ECC,
422 	ZCP_STAT_END
423 } nxge_zcp_stat_index_t;
424 
425 nxge_kstat_index_t nxge_zcp_stats[] = {
426 	{ZCP_STAT_ERRORS, KSTAT_DATA_ULONG, "zcp_erros"},
427 	{ZCP_STAT_INITS, KSTAT_DATA_ULONG, "zcp_inits"},
428 	{ZCP_STAT_RRFIFO_UNDERRUN, KSTAT_DATA_ULONG, "zcp_rrfifo_underrun"},
429 	{ZCP_STAT_RRFIFO_OVERRUN, KSTAT_DATA_ULONG, "zcp_rrfifo_overrun"},
430 	{ZCP_STAT_RSPFIFO_UNCORR_ERR, KSTAT_DATA_ULONG,
431 	"zcp_rspfifo_uncorr_err"},
432 	{ZCP_STAT_BUFFER_OVERFLOW, KSTAT_DATA_ULONG, "zcp_buffer_overflow"},
433 	{ZCP_STAT_STAT_TBL_PERR, KSTAT_DATA_ULONG, "zcp_stat_tbl_perr"},
434 	{ZCP_STAT_DYN_TBL_PERR, KSTAT_DATA_ULONG, "zcp_dyn_tbl_perr"},
435 	{ZCP_STAT_BUF_TBL_PERR, KSTAT_DATA_ULONG, "zcp_buf_tbl_perr"},
436 	{ZCP_STAT_TT_PROGRAM_ERR, KSTAT_DATA_ULONG, "zcp_tt_program_err"},
437 	{ZCP_STAT_RSP_TT_INDEX_ERR, KSTAT_DATA_ULONG, "zcp_rsp_tt_index_err"},
438 	{ZCP_STAT_SLV_TT_INDEX_ERR, KSTAT_DATA_ULONG, "zcp_slv_tt_index_err"},
439 	{ZCP_STAT_ZCP_TT_INDEX_ERR, KSTAT_DATA_ULONG, "zcp_zcp_tt_index_err"},
440 	{ZCP_STAT_ZCP_ACCESS_FAIL, KSTAT_DATA_ULONG, "zcp_access_fail"},
441 	{ZCP_STAT_ZCP_ACCESS_FAIL, KSTAT_DATA_ULONG, "zcp_cfifo_ecc"},
442 	{ZCP_STAT_END, NULL, NULL}
443 };
444 
445 typedef enum {
446 	FFLP_STAT_TCAM_PERR,
447 	FFLP_STAT_TCAM_ECC_ERR,
448 	FFLP_STAT_VLAN_PERR,
449 	FFLP_STAT_HASH_LOOKUP_ERR,
450 	FFLP_STAT_HASH_P0_PIO_ERR,
451 	FFLP_STAT_HASH_P1_PIO_ERR,
452 	FFLP_STAT_HASH_P2_PIO_ERR,
453 	FFLP_STAT_HASH_P3_PIO_ERR,
454 	FFLP_STAT_HASH_P4_PIO_ERR,
455 	FFLP_STAT_HASH_P5_PIO_ERR,
456 	FFLP_STAT_HASH_P6_PIO_ERR,
457 	FFLP_STAT_HASH_P7_PIO_ERR,
458 	FFLP_STAT_END
459 } nxge_fflp_stat_index_t;
460 
461 nxge_kstat_index_t nxge_fflp_stats[] = {
462 	{FFLP_STAT_TCAM_PERR, KSTAT_DATA_ULONG, "fflp_tcam_perr"},
463 	{FFLP_STAT_TCAM_ECC_ERR, KSTAT_DATA_ULONG, "fflp_tcam_ecc_err"},
464 	{FFLP_STAT_VLAN_PERR, KSTAT_DATA_ULONG, "fflp_vlan_perr"},
465 	{FFLP_STAT_HASH_LOOKUP_ERR, KSTAT_DATA_ULONG, "fflp_hash_lookup_err"},
466 	{FFLP_STAT_HASH_P0_PIO_ERR, KSTAT_DATA_ULONG, "fflp_hash_p0_pio_err"},
467 	{FFLP_STAT_HASH_P1_PIO_ERR, KSTAT_DATA_ULONG, "fflp_hash_p1_pio_err"},
468 	{FFLP_STAT_HASH_P2_PIO_ERR, KSTAT_DATA_ULONG, "fflp_hash_p2_pio_err"},
469 	{FFLP_STAT_HASH_P3_PIO_ERR, KSTAT_DATA_ULONG, "fflp_hash_p3_pio_err"},
470 	{FFLP_STAT_HASH_P4_PIO_ERR, KSTAT_DATA_ULONG, "fflp_hash_p4_pio_err"},
471 	{FFLP_STAT_HASH_P5_PIO_ERR, KSTAT_DATA_ULONG, "fflp_hash_p5_pio_err"},
472 	{FFLP_STAT_HASH_P6_PIO_ERR, KSTAT_DATA_ULONG, "fflp_hash_p6_pio_err"},
473 	{FFLP_STAT_HASH_P7_PIO_ERR, KSTAT_DATA_ULONG, "fflp_hash_p7_pio_err"},
474 	{FFLP_STAT_END, NULL, NULL}
475 };
476 
477 typedef enum {
478 	MMAC_MAX_ADDR,
479 	MMAC_AVAIL_ADDR,
480 	MMAC_ADDR_POOL1,
481 	MMAC_ADDR_POOL2,
482 	MMAC_ADDR_POOL3,
483 	MMAC_ADDR_POOL4,
484 	MMAC_ADDR_POOL5,
485 	MMAC_ADDR_POOL6,
486 	MMAC_ADDR_POOL7,
487 	MMAC_ADDR_POOL8,
488 	MMAC_ADDR_POOL9,
489 	MMAC_ADDR_POOL10,
490 	MMAC_ADDR_POOL11,
491 	MMAC_ADDR_POOL12,
492 	MMAC_ADDR_POOL13,
493 	MMAC_ADDR_POOL14,
494 	MMAC_ADDR_POOL15,
495 	MMAC_ADDR_POOL16,
496 	MMAC_STATS_END
497 } nxge_mmac_stat_index_t;
498 
499 nxge_kstat_index_t nxge_mmac_stats[] = {
500 	{MMAC_MAX_ADDR, KSTAT_DATA_UINT64, "max_mmac_addr"},
501 	{MMAC_AVAIL_ADDR, KSTAT_DATA_UINT64, "avail_mmac_addr"},
502 	{MMAC_ADDR_POOL1, KSTAT_DATA_UINT64, "mmac_addr_1"},
503 	{MMAC_ADDR_POOL2, KSTAT_DATA_UINT64, "mmac_addr_2"},
504 	{MMAC_ADDR_POOL3, KSTAT_DATA_UINT64, "mmac_addr_3"},
505 	{MMAC_ADDR_POOL4, KSTAT_DATA_UINT64, "mmac_addr_4"},
506 	{MMAC_ADDR_POOL5, KSTAT_DATA_UINT64, "mmac_addr_5"},
507 	{MMAC_ADDR_POOL6, KSTAT_DATA_UINT64, "mmac_addr_6"},
508 	{MMAC_ADDR_POOL7, KSTAT_DATA_UINT64, "mmac_addr_7"},
509 	{MMAC_ADDR_POOL8, KSTAT_DATA_UINT64, "mmac_addr_8"},
510 	{MMAC_ADDR_POOL9, KSTAT_DATA_UINT64, "mmac_addr_9"},
511 	{MMAC_ADDR_POOL10, KSTAT_DATA_UINT64, "mmac_addr_10"},
512 	{MMAC_ADDR_POOL11, KSTAT_DATA_UINT64, "mmac_addr_11"},
513 	{MMAC_ADDR_POOL12, KSTAT_DATA_UINT64, "mmac_addr_12"},
514 	{MMAC_ADDR_POOL13, KSTAT_DATA_UINT64, "mmac_addr_13"},
515 	{MMAC_ADDR_POOL14, KSTAT_DATA_UINT64, "mmac_addr_14"},
516 	{MMAC_ADDR_POOL15, KSTAT_DATA_UINT64, "mmac_addr_15"},
517 	{MMAC_ADDR_POOL16, KSTAT_DATA_UINT64, "mmac_addr_16"},
518 	{MMAC_STATS_END, NULL, NULL},
519 };
520 
521 /* ARGSUSED */
522 int
523 nxge_tdc_stat_update(kstat_t *ksp, int rw)
524 {
525 	p_nxge_t nxgep;
526 	p_nxge_tdc_kstat_t tdc_kstatsp;
527 	p_nxge_tx_ring_stats_t statsp;
528 	int channel;
529 	char *ch_name, *end;
530 
531 	nxgep = (p_nxge_t)ksp->ks_private;
532 	if (nxgep == NULL)
533 		return (-1);
534 
535 	NXGE_DEBUG_MSG((nxgep, KST_CTL, "==> nxge_rxstat_update"));
536 
537 	ch_name = ksp->ks_name;
538 	ch_name += strlen(TDC_NAME_FORMAT1);
539 	channel = mi_strtol(ch_name, &end, 10);
540 
541 	tdc_kstatsp = (p_nxge_tdc_kstat_t)ksp->ks_data;
542 	statsp = (p_nxge_tx_ring_stats_t)&nxgep->statsp->tdc_stats[channel];
543 
544 	NXGE_DEBUG_MSG((nxgep, KST_CTL,
545 	    "nxge_tdc_stat_update data $%p statsp $%p channel %d",
546 	    ksp->ks_data, statsp, channel));
547 
548 	if (rw == KSTAT_WRITE) {
549 		statsp->opackets = tdc_kstatsp->opackets.value.ull;
550 		statsp->obytes = tdc_kstatsp->obytes.value.ull;
551 		statsp->oerrors = tdc_kstatsp->oerrors.value.ull;
552 		statsp->mbox_err = tdc_kstatsp->mbox_err.value.ul;
553 		statsp->pkt_size_err = tdc_kstatsp->pkt_size_err.value.ul;
554 		statsp->tx_ring_oflow = tdc_kstatsp->tx_ring_oflow.value.ul;
555 		statsp->pre_buf_par_err =
556 		    tdc_kstatsp->pref_buf_ecc_err.value.ul;
557 		statsp->nack_pref = tdc_kstatsp->nack_pref.value.ul;
558 		statsp->nack_pkt_rd = tdc_kstatsp->nack_pkt_rd.value.ul;
559 		statsp->conf_part_err = tdc_kstatsp->conf_part_err.value.ul;
560 		statsp->pkt_part_err = tdc_kstatsp->pkt_prt_err.value.ul;
561 	} else {
562 		tdc_kstatsp->opackets.value.ull = statsp->opackets;
563 		tdc_kstatsp->obytes.value.ull = statsp->obytes;
564 		tdc_kstatsp->oerrors.value.ull = statsp->oerrors;
565 		tdc_kstatsp->tx_hdr_pkts.value.ull = statsp->tx_hdr_pkts;
566 		tdc_kstatsp->tx_ddi_pkts.value.ull = statsp->tx_ddi_pkts;
567 		tdc_kstatsp->tx_dvma_pkts.value.ull = statsp->tx_dvma_pkts;
568 		tdc_kstatsp->tx_max_pend.value.ull = statsp->tx_max_pend;
569 		tdc_kstatsp->mbox_err.value.ul = statsp->mbox_err;
570 		tdc_kstatsp->pkt_size_err.value.ul = statsp->pkt_size_err;
571 		tdc_kstatsp->tx_ring_oflow.value.ul = statsp->tx_ring_oflow;
572 		tdc_kstatsp->pref_buf_ecc_err.value.ul =
573 		    statsp->pre_buf_par_err;
574 		tdc_kstatsp->nack_pref.value.ul = statsp->nack_pref;
575 		tdc_kstatsp->nack_pkt_rd.value.ul = statsp->nack_pkt_rd;
576 		tdc_kstatsp->conf_part_err.value.ul = statsp->conf_part_err;
577 		tdc_kstatsp->pkt_prt_err.value.ul = statsp->pkt_part_err;
578 		tdc_kstatsp->tx_starts.value.ul = statsp->tx_starts;
579 		tdc_kstatsp->tx_nocanput.value.ul = statsp->tx_nocanput;
580 		tdc_kstatsp->tx_msgdup_fail.value.ul = statsp->tx_msgdup_fail;
581 		tdc_kstatsp->tx_allocb_fail.value.ul = statsp->tx_allocb_fail;
582 		tdc_kstatsp->tx_no_desc.value.ul = statsp->tx_no_desc;
583 		tdc_kstatsp->tx_dma_bind_fail.value.ul =
584 		    statsp->tx_dma_bind_fail;
585 	}
586 	NXGE_DEBUG_MSG((nxgep, KST_CTL, " <== nxge_tdc_stat_update"));
587 	return (0);
588 }
589 
590 /* ARGSUSED */
591 int
592 nxge_rdc_stat_update(kstat_t *ksp, int rw)
593 {
594 	p_nxge_t nxgep;
595 	p_nxge_rdc_kstat_t rdc_kstatsp;
596 	p_nxge_rx_ring_stats_t statsp;
597 	int channel;
598 	char *ch_name, *end;
599 
600 	nxgep = (p_nxge_t)ksp->ks_private;
601 	if (nxgep == NULL)
602 		return (-1);
603 
604 	NXGE_DEBUG_MSG((nxgep, KST_CTL, "==> nxge_rdc_stat_update"));
605 
606 	ch_name = ksp->ks_name;
607 	ch_name += strlen(RDC_NAME_FORMAT1);
608 	channel = mi_strtol(ch_name, &end, 10);
609 
610 	rdc_kstatsp = (p_nxge_rdc_kstat_t)ksp->ks_data;
611 	statsp = (p_nxge_rx_ring_stats_t)&nxgep->statsp->rdc_stats[channel];
612 
613 	NXGE_DEBUG_MSG((nxgep, KST_CTL,
614 	    "nxge_rdc_stat_update $%p statsp $%p channel %d",
615 	    ksp->ks_data, statsp, channel));
616 
617 	if (rw == KSTAT_WRITE) {
618 		statsp->dcf_err = rdc_kstatsp->dcf_err.value.ul;
619 		statsp->rcr_ack_err = rdc_kstatsp->rcr_ack_err.value.ul;
620 		statsp->dc_fifo_err = rdc_kstatsp->dc_fifoflow_err.value.ul;
621 		statsp->rcr_sha_par = rdc_kstatsp->rcr_sha_par_err.value.ul;
622 		statsp->rbr_pre_par = rdc_kstatsp->rbr_pre_par_err.value.ul;
623 		statsp->wred_drop = rdc_kstatsp->wred_drop.value.ul;
624 		statsp->rbr_pre_empty = rdc_kstatsp->rbr_pre_emty.value.ul;
625 		statsp->rcr_shadow_full = rdc_kstatsp->rcr_shadow_full.value.ul;
626 		statsp->rx_rbr_tmout = rdc_kstatsp->rbr_tmout.value.ul;
627 		statsp->rsp_cnt_err = rdc_kstatsp->rsp_cnt_err.value.ul;
628 		statsp->byte_en_bus = rdc_kstatsp->byte_en_bus.value.ul;
629 		statsp->rsp_dat_err = rdc_kstatsp->rsp_dat_err.value.ul;
630 		statsp->pkt_too_long_err =
631 		    rdc_kstatsp->pkt_too_long_err.value.ul;
632 		statsp->l2_err = rdc_kstatsp->compl_l2_err.value.ul;
633 		statsp->l4_cksum_err = rdc_kstatsp->compl_l4_cksum_err.value.ul;
634 		statsp->fflp_soft_err =
635 		    rdc_kstatsp->compl_fflp_soft_err.value.ul;
636 		statsp->zcp_soft_err = rdc_kstatsp->compl_zcp_soft_err.value.ul;
637 		statsp->config_err = rdc_kstatsp->config_err.value.ul;
638 		statsp->rcrincon = rdc_kstatsp->rcrincon.value.ul;
639 		statsp->rcrfull = rdc_kstatsp->rcrfull.value.ul;
640 		statsp->rbr_empty = rdc_kstatsp->rbr_empty.value.ul;
641 		statsp->rbrfull = rdc_kstatsp->rbrfull.value.ul;
642 		statsp->rbrlogpage = rdc_kstatsp->rbrlogpage.value.ul;
643 		statsp->cfiglogpage = rdc_kstatsp->cfiglogpage.value.ul;
644 	} else {
645 		rdc_kstatsp->ipackets.value.ull = statsp->ipackets;
646 		rdc_kstatsp->rbytes.value.ull = statsp->ibytes;
647 		rdc_kstatsp->errors.value.ul = statsp->ierrors;
648 		rdc_kstatsp->dcf_err.value.ul = statsp->dcf_err;
649 		rdc_kstatsp->rcr_ack_err.value.ul = statsp->rcr_ack_err;
650 		rdc_kstatsp->dc_fifoflow_err.value.ul = statsp->dc_fifo_err;
651 		rdc_kstatsp->rcr_sha_par_err.value.ul = statsp->rcr_sha_par;
652 		rdc_kstatsp->rbr_pre_par_err.value.ul = statsp->rbr_pre_par;
653 		rdc_kstatsp->wred_drop.value.ul = statsp->wred_drop;
654 		rdc_kstatsp->port_drop_pkt.value.ul = statsp->port_drop_pkt;
655 		rdc_kstatsp->rbr_pre_emty.value.ul = statsp->rbr_pre_empty;
656 		rdc_kstatsp->rcr_shadow_full.value.ul = statsp->rcr_shadow_full;
657 		rdc_kstatsp->rbr_tmout.value.ul = statsp->rx_rbr_tmout;
658 		rdc_kstatsp->rsp_cnt_err.value.ul = statsp->rsp_cnt_err;
659 		rdc_kstatsp->byte_en_bus.value.ul = statsp->byte_en_bus;
660 		rdc_kstatsp->rsp_dat_err.value.ul = statsp->rsp_dat_err;
661 		rdc_kstatsp->pkt_too_long_err.value.ul =
662 		    statsp->pkt_too_long_err;
663 		rdc_kstatsp->compl_l2_err.value.ul = statsp->l2_err;
664 		rdc_kstatsp->compl_l4_cksum_err.value.ul = statsp->l4_cksum_err;
665 		rdc_kstatsp->compl_fflp_soft_err.value.ul =
666 		    statsp->fflp_soft_err;
667 		rdc_kstatsp->compl_zcp_soft_err.value.ul = statsp->zcp_soft_err;
668 		rdc_kstatsp->config_err.value.ul = statsp->config_err;
669 		rdc_kstatsp->rcrincon.value.ul = statsp->rcrincon;
670 		rdc_kstatsp->rcrfull.value.ul = statsp->rcrfull;
671 		rdc_kstatsp->rbr_empty.value.ul = statsp->rbr_empty;
672 		rdc_kstatsp->rbrfull.value.ul = statsp->rbrfull;
673 		rdc_kstatsp->rbrlogpage.value.ul = statsp->rbrlogpage;
674 		rdc_kstatsp->cfiglogpage.value.ul = statsp->cfiglogpage;
675 	}
676 
677 	NXGE_DEBUG_MSG((nxgep, KST_CTL, " <== nxge_rdc_stat_update"));
678 	return (0);
679 }
680 
681 /* ARGSUSED */
682 int
683 nxge_rdc_sys_stat_update(kstat_t *ksp, int rw)
684 {
685 	p_nxge_t nxgep;
686 	p_nxge_rdc_sys_kstat_t rdc_sys_kstatsp;
687 	p_nxge_rdc_sys_stats_t statsp;
688 
689 	nxgep = (p_nxge_t)ksp->ks_private;
690 	if (nxgep == NULL)
691 		return (-1);
692 
693 	NXGE_DEBUG_MSG((nxgep, KST_CTL, "==> nxge_rdc_sys_stat_update"));
694 
695 	rdc_sys_kstatsp = (p_nxge_rdc_sys_kstat_t)ksp->ks_data;
696 	statsp = (p_nxge_rdc_sys_stats_t)&nxgep->statsp->rdc_sys_stats;
697 
698 	NXGE_DEBUG_MSG((nxgep, KST_CTL, "nxge_rdc_sys_stat_update %llx",
699 	    ksp->ks_data));
700 
701 	if (rw == KSTAT_WRITE) {
702 		statsp->id_mismatch = rdc_sys_kstatsp->id_mismatch.value.ul;
703 		statsp->ipp_eop_err = rdc_sys_kstatsp->ipp_eop_err.value.ul;
704 		statsp->zcp_eop_err = rdc_sys_kstatsp->zcp_eop_err.value.ul;
705 	} else {
706 		rdc_sys_kstatsp->id_mismatch.value.ul = statsp->id_mismatch;
707 		rdc_sys_kstatsp->ipp_eop_err.value.ul = statsp->ipp_eop_err;
708 		rdc_sys_kstatsp->zcp_eop_err.value.ul = statsp->zcp_eop_err;
709 	}
710 	NXGE_DEBUG_MSG((nxgep, KST_CTL, " <== nxge_rdc_sys_stat_update"));
711 	return (0);
712 }
713 
714 /* ARGSUSED */
715 static int
716 nxge_txc_stat_update(kstat_t *ksp, int rw)
717 {
718 	p_nxge_t nxgep;
719 	p_nxge_txc_kstat_t txc_kstatsp;
720 	p_nxge_txc_stats_t statsp;
721 
722 	nxgep = (p_nxge_t)ksp->ks_private;
723 
724 	if (nxgep == NULL)
725 		return (-1);
726 
727 	NXGE_DEBUG_MSG((nxgep, KST_CTL, "==> nxge_txc_stat_update"));
728 
729 	txc_kstatsp = (p_nxge_txc_kstat_t)ksp->ks_data;
730 	statsp = (p_nxge_txc_stats_t)&nxgep->statsp->txc_stats;
731 
732 	if (rw == KSTAT_WRITE) {
733 		statsp->pkt_stuffed = txc_kstatsp->pkt_stuffed.value.ul;
734 		statsp->pkt_xmit = txc_kstatsp->pkt_xmit.value.ul;
735 		statsp->ro_correct_err = txc_kstatsp->ro_correct_err.value.ul;
736 		statsp->ro_uncorrect_err =
737 		    txc_kstatsp->ro_uncorrect_err.value.ul;
738 		statsp->sf_correct_err = txc_kstatsp->sf_correct_err.value.ul;
739 		statsp->sf_uncorrect_err =
740 		    txc_kstatsp->sf_uncorrect_err.value.ul;
741 		statsp->address_failed = txc_kstatsp->address_failed.value.ul;
742 		statsp->dma_failed = txc_kstatsp->dma_failed.value.ul;
743 		statsp->length_failed = txc_kstatsp->length_failed.value.ul;
744 		statsp->pkt_assy_dead = txc_kstatsp->pkt_assy_dead.value.ul;
745 		statsp->reorder_err = txc_kstatsp->reorder_err.value.ul;
746 	} else {
747 		txc_kstatsp->pkt_stuffed.value.ul = statsp->pkt_stuffed;
748 		txc_kstatsp->pkt_xmit.value.ul = statsp->pkt_xmit;
749 		txc_kstatsp->ro_correct_err.value.ul = statsp->ro_correct_err;
750 		txc_kstatsp->ro_uncorrect_err.value.ul =
751 		    statsp->ro_uncorrect_err;
752 		txc_kstatsp->sf_correct_err.value.ul = statsp->sf_correct_err;
753 		txc_kstatsp->sf_uncorrect_err.value.ul =
754 		    statsp->sf_uncorrect_err;
755 		txc_kstatsp->address_failed.value.ul = statsp->address_failed;
756 		txc_kstatsp->dma_failed.value.ul = statsp->dma_failed;
757 		txc_kstatsp->length_failed.value.ul = statsp->length_failed;
758 		txc_kstatsp->pkt_assy_dead.value.ul = statsp->pkt_assy_dead;
759 		txc_kstatsp->reorder_err.value.ul = statsp->reorder_err;
760 	}
761 	NXGE_DEBUG_MSG((nxgep, KST_CTL, "<== nxge_txc_stat_update"));
762 	return (0);
763 }
764 
765 /* ARGSUSED */
766 int
767 nxge_ipp_stat_update(kstat_t *ksp, int rw)
768 {
769 	p_nxge_t nxgep;
770 	p_nxge_ipp_kstat_t ipp_kstatsp;
771 	p_nxge_ipp_stats_t statsp;
772 
773 	nxgep = (p_nxge_t)ksp->ks_private;
774 	if (nxgep == NULL)
775 		return (-1);
776 
777 	NXGE_DEBUG_MSG((nxgep, KST_CTL, "==> nxge_ipp_stat_update"));
778 
779 	ipp_kstatsp = (p_nxge_ipp_kstat_t)ksp->ks_data;
780 	statsp = (p_nxge_ipp_stats_t)&nxgep->statsp->ipp_stats;
781 
782 	if (rw == KSTAT_WRITE) {
783 		statsp->eop_miss = ipp_kstatsp->eop_miss.value.ul;
784 		statsp->sop_miss = ipp_kstatsp->sop_miss.value.ul;
785 		statsp->dfifo_ue = ipp_kstatsp->dfifo_ue.value.ul;
786 		statsp->ecc_err_cnt = ipp_kstatsp->ecc_err_cnt.value.ul;
787 		statsp->pfifo_perr = ipp_kstatsp->pfifo_perr.value.ul;
788 		statsp->pfifo_over = ipp_kstatsp->pfifo_over.value.ul;
789 		statsp->pfifo_und = ipp_kstatsp->pfifo_und.value.ul;
790 		statsp->bad_cs_cnt = ipp_kstatsp->bad_cs_cnt.value.ul;
791 		statsp->pkt_dis_cnt = ipp_kstatsp->pkt_dis_cnt.value.ul;
792 	} else {
793 		ipp_kstatsp->eop_miss.value.ul = statsp->eop_miss;
794 		ipp_kstatsp->sop_miss.value.ul = statsp->sop_miss;
795 		ipp_kstatsp->dfifo_ue.value.ul = statsp->dfifo_ue;
796 		ipp_kstatsp->ecc_err_cnt.value.ul = statsp->ecc_err_cnt;
797 		ipp_kstatsp->pfifo_perr.value.ul = statsp->pfifo_perr;
798 		ipp_kstatsp->pfifo_over.value.ul = statsp->pfifo_over;
799 		ipp_kstatsp->pfifo_und.value.ul = statsp->pfifo_und;
800 		ipp_kstatsp->bad_cs_cnt.value.ul = statsp->bad_cs_cnt;
801 		ipp_kstatsp->pkt_dis_cnt.value.ul = statsp->pkt_dis_cnt;
802 	}
803 	NXGE_DEBUG_MSG((nxgep, KST_CTL, "<== nxge_ipp_stat_update"));
804 	return (0);
805 }
806 
807 /* ARGSUSED */
808 int
809 nxge_xmac_stat_update(kstat_t *ksp, int rw)
810 {
811 	p_nxge_t nxgep;
812 	p_nxge_xmac_kstat_t xmac_kstatsp;
813 	p_nxge_xmac_stats_t statsp;
814 
815 	nxgep = (p_nxge_t)ksp->ks_private;
816 	if (nxgep == NULL)
817 		return (-1);
818 
819 	NXGE_DEBUG_MSG((nxgep, KST_CTL, "==> nxge_xmac_stat_update"));
820 
821 	xmac_kstatsp = (p_nxge_xmac_kstat_t)ksp->ks_data;
822 	statsp = (p_nxge_xmac_stats_t)&nxgep->statsp->xmac_stats;
823 
824 	if (rw == KSTAT_WRITE) {
825 		statsp->tx_frame_cnt = xmac_kstatsp->tx_frame_cnt.value.ul;
826 		statsp->tx_underflow_err =
827 		    xmac_kstatsp->tx_underflow_err.value.ul;
828 		statsp->tx_maxpktsize_err =
829 		    xmac_kstatsp->tx_maxpktsize_err.value.ul;
830 		statsp->tx_overflow_err =
831 		    xmac_kstatsp->tx_overflow_err.value.ul;
832 		statsp->tx_fifo_xfr_err =
833 		    xmac_kstatsp->tx_fifo_xfr_err.value.ul;
834 		statsp->tx_byte_cnt = xmac_kstatsp->tx_byte_cnt.value.ul;
835 		statsp->rx_underflow_err =
836 		    xmac_kstatsp->rx_underflow_err.value.ul;
837 		statsp->rx_overflow_err =
838 		    xmac_kstatsp->rx_overflow_err.value.ul;
839 		statsp->rx_crc_err_cnt = xmac_kstatsp->rx_crc_err_cnt.value.ul;
840 		statsp->rx_len_err_cnt = xmac_kstatsp->rx_len_err_cnt.value.ul;
841 		statsp->rx_viol_err_cnt =
842 		    xmac_kstatsp->rx_viol_err_cnt.value.ul;
843 		statsp->rx_byte_cnt = xmac_kstatsp->rx_byte_cnt.value.ul;
844 		statsp->rx_frame_cnt = xmac_kstatsp->rx_frame_cnt.value.ul;
845 		statsp->rx_hist1_cnt = xmac_kstatsp->rx_hist1_cnt.value.ul;
846 		statsp->rx_hist2_cnt = xmac_kstatsp->rx_hist2_cnt.value.ul;
847 		statsp->rx_hist3_cnt = xmac_kstatsp->rx_hist3_cnt.value.ul;
848 		statsp->rx_hist4_cnt = xmac_kstatsp->rx_hist4_cnt.value.ul;
849 		statsp->rx_hist5_cnt = xmac_kstatsp->rx_hist5_cnt.value.ul;
850 		statsp->rx_hist6_cnt = xmac_kstatsp->rx_hist6_cnt.value.ul;
851 		statsp->rx_hist7_cnt = xmac_kstatsp->rx_hist7_cnt.value.ul;
852 		statsp->rx_mult_cnt = xmac_kstatsp->rx_mult_cnt.value.ul;
853 		statsp->rx_frag_cnt = xmac_kstatsp->rx_frag_cnt.value.ul;
854 		statsp->rx_frame_align_err_cnt =
855 		    xmac_kstatsp->rx_frame_align_err_cnt.value.ul;
856 		statsp->rx_linkfault_err_cnt =
857 		    xmac_kstatsp->rx_linkfault_err_cnt.value.ul;
858 		statsp->rx_localfault_err =
859 		    xmac_kstatsp->rx_local_fault_err_cnt.value.ul;
860 		statsp->rx_remotefault_err =
861 		    xmac_kstatsp->rx_remote_fault_err_cnt.value.ul;
862 		statsp->xpcs_deskew_err_cnt =
863 		    xmac_kstatsp->xpcs_deskew_err_cnt.value.ul;
864 #ifdef	NXGE_DEBUG_SYMBOL_ERR
865 		statsp->xpcs_ln0_symbol_err_cnt =
866 		    xmac_kstatsp->xpcs_ln0_symbol_err_cnt.value.ul;
867 		statsp->xpcs_ln1_symbol_err_cnt =
868 		    xmac_kstatsp->xpcs_ln1_symbol_err_cnt.value.ul;
869 		statsp->xpcs_ln2_symbol_err_cnt =
870 		    xmac_kstatsp->xpcs_ln2_symbol_err_cnt.value.ul;
871 		statsp->xpcs_ln3_symbol_err_cnt =
872 		    xmac_kstatsp->xpcs_ln3_symbol_err_cnt.value.ul;
873 #endif
874 	} else {
875 		xmac_kstatsp->tx_frame_cnt.value.ul = statsp->tx_frame_cnt;
876 		xmac_kstatsp->tx_underflow_err.value.ul =
877 		    statsp->tx_underflow_err;
878 		xmac_kstatsp->tx_maxpktsize_err.value.ul =
879 		    statsp->tx_maxpktsize_err;
880 		xmac_kstatsp->tx_overflow_err.value.ul =
881 		    statsp->tx_overflow_err;
882 		xmac_kstatsp->tx_fifo_xfr_err.value.ul =
883 		    statsp->tx_fifo_xfr_err;
884 		xmac_kstatsp->tx_byte_cnt.value.ul = statsp->tx_byte_cnt;
885 		xmac_kstatsp->rx_underflow_err.value.ul =
886 		    statsp->rx_underflow_err;
887 		xmac_kstatsp->rx_overflow_err.value.ul =
888 		    statsp->rx_overflow_err;
889 		xmac_kstatsp->rx_crc_err_cnt.value.ul = statsp->rx_crc_err_cnt;
890 		xmac_kstatsp->rx_len_err_cnt.value.ul = statsp->rx_len_err_cnt;
891 		xmac_kstatsp->rx_viol_err_cnt.value.ul =
892 		    statsp->rx_viol_err_cnt;
893 		xmac_kstatsp->rx_byte_cnt.value.ul = statsp->rx_byte_cnt;
894 		xmac_kstatsp->rx_frame_cnt.value.ul = statsp->rx_frame_cnt;
895 		xmac_kstatsp->rx_hist1_cnt.value.ul = statsp->rx_hist1_cnt;
896 		xmac_kstatsp->rx_hist2_cnt.value.ul = statsp->rx_hist2_cnt;
897 		xmac_kstatsp->rx_hist3_cnt.value.ul = statsp->rx_hist3_cnt;
898 		xmac_kstatsp->rx_hist4_cnt.value.ul = statsp->rx_hist4_cnt;
899 		xmac_kstatsp->rx_hist5_cnt.value.ul = statsp->rx_hist5_cnt;
900 		xmac_kstatsp->rx_hist6_cnt.value.ul = statsp->rx_hist6_cnt;
901 		xmac_kstatsp->rx_hist7_cnt.value.ul = statsp->rx_hist7_cnt;
902 		xmac_kstatsp->rx_mult_cnt.value.ul = statsp->rx_mult_cnt;
903 		xmac_kstatsp->rx_frag_cnt.value.ul = statsp->rx_frag_cnt;
904 		xmac_kstatsp->rx_frame_align_err_cnt.value.ul =
905 		    statsp->rx_frame_align_err_cnt;
906 		xmac_kstatsp->rx_linkfault_err_cnt.value.ul =
907 		    statsp->rx_linkfault_err_cnt;
908 		xmac_kstatsp->rx_local_fault_err_cnt.value.ul =
909 		    statsp->rx_localfault_err;
910 		xmac_kstatsp->rx_remote_fault_err_cnt.value.ul =
911 		    statsp->rx_remotefault_err;
912 		xmac_kstatsp->xpcs_deskew_err_cnt.value.ul =
913 		    statsp->xpcs_deskew_err_cnt;
914 #ifdef	NXGE_DEBUG_SYMBOL_ERR
915 		xmac_kstatsp->xpcs_ln0_symbol_err_cnt.value.ul =
916 		    statsp->xpcs_ln0_symbol_err_cnt;
917 		xmac_kstatsp->xpcs_ln1_symbol_err_cnt.value.ul =
918 		    statsp->xpcs_ln1_symbol_err_cnt;
919 		xmac_kstatsp->xpcs_ln2_symbol_err_cnt.value.ul =
920 		    statsp->xpcs_ln2_symbol_err_cnt;
921 		xmac_kstatsp->xpcs_ln3_symbol_err_cnt.value.ul =
922 		    statsp->xpcs_ln3_symbol_err_cnt;
923 #endif
924 	}
925 	NXGE_DEBUG_MSG((nxgep, KST_CTL, "<== nxge_xmac_stat_update"));
926 	return (0);
927 }
928 
929 /* ARGSUSED */
930 int
931 nxge_bmac_stat_update(kstat_t *ksp, int rw)
932 {
933 	p_nxge_t nxgep;
934 	p_nxge_bmac_kstat_t bmac_kstatsp;
935 	p_nxge_bmac_stats_t statsp;
936 
937 	nxgep = (p_nxge_t)ksp->ks_private;
938 	if (nxgep == NULL)
939 		return (-1);
940 
941 	NXGE_DEBUG_MSG((nxgep, KST_CTL, "==> nxge_bmac_stat_update"));
942 
943 	bmac_kstatsp = (p_nxge_bmac_kstat_t)ksp->ks_data;
944 	statsp = (p_nxge_bmac_stats_t)&nxgep->statsp->bmac_stats;
945 
946 	if (rw == KSTAT_WRITE) {
947 		statsp->tx_frame_cnt = bmac_kstatsp->tx_frame_cnt.value.ul;
948 		statsp->tx_underrun_err =
949 		    bmac_kstatsp->tx_underrun_err.value.ul;
950 		statsp->tx_max_pkt_err = bmac_kstatsp->tx_max_pkt_err.value.ul;
951 		statsp->tx_byte_cnt = bmac_kstatsp->tx_byte_cnt.value.ul;
952 		statsp->rx_frame_cnt = bmac_kstatsp->rx_frame_cnt.value.ul;
953 		statsp->rx_byte_cnt = bmac_kstatsp->rx_byte_cnt.value.ul;
954 		statsp->rx_overflow_err =
955 		    bmac_kstatsp->rx_overflow_err.value.ul;
956 		statsp->rx_align_err_cnt =
957 		    bmac_kstatsp->rx_align_err_cnt.value.ul;
958 		statsp->rx_crc_err_cnt = bmac_kstatsp->rx_crc_err_cnt.value.ul;
959 		statsp->rx_len_err_cnt = bmac_kstatsp->rx_len_err_cnt.value.ul;
960 		statsp->rx_viol_err_cnt =
961 		    bmac_kstatsp->rx_viol_err_cnt.value.ul;
962 	} else {
963 		bmac_kstatsp->tx_frame_cnt.value.ul = statsp->tx_frame_cnt;
964 		bmac_kstatsp->tx_underrun_err.value.ul =
965 		    statsp->tx_underrun_err;
966 		bmac_kstatsp->tx_max_pkt_err.value.ul = statsp->tx_max_pkt_err;
967 		bmac_kstatsp->tx_byte_cnt.value.ul = statsp->tx_byte_cnt;
968 		bmac_kstatsp->rx_frame_cnt.value.ul = statsp->rx_frame_cnt;
969 		bmac_kstatsp->rx_byte_cnt.value.ul = statsp->rx_byte_cnt;
970 		bmac_kstatsp->rx_overflow_err.value.ul =
971 		    statsp->rx_overflow_err;
972 		bmac_kstatsp->rx_align_err_cnt.value.ul =
973 		    statsp->rx_align_err_cnt;
974 		bmac_kstatsp->rx_crc_err_cnt.value.ul = statsp->rx_crc_err_cnt;
975 		bmac_kstatsp->rx_len_err_cnt.value.ul = statsp->rx_len_err_cnt;
976 		bmac_kstatsp->rx_viol_err_cnt.value.ul =
977 		    statsp->rx_viol_err_cnt;
978 	}
979 	NXGE_DEBUG_MSG((nxgep, KST_CTL, "<== nxge_bmac_stat_update"));
980 	return (0);
981 }
982 
983 /* ARGSUSED */
984 int
985 nxge_zcp_stat_update(kstat_t *ksp, int rw)
986 {
987 	p_nxge_t nxgep;
988 	p_nxge_zcp_kstat_t zcp_kstatsp;
989 	p_nxge_zcp_stats_t statsp;
990 
991 	nxgep = (p_nxge_t)ksp->ks_private;
992 	if (nxgep == NULL)
993 		return (-1);
994 
995 	NXGE_DEBUG_MSG((nxgep, KST_CTL, "==> nxge_zcp_stat_update"));
996 
997 	zcp_kstatsp = (p_nxge_zcp_kstat_t)ksp->ks_data;
998 	statsp = (p_nxge_zcp_stats_t)&nxgep->statsp->zcp_stats;
999 
1000 	if (rw == KSTAT_WRITE) {
1001 		statsp->rrfifo_underrun = zcp_kstatsp->rrfifo_underrun.value.ul;
1002 		statsp->rrfifo_overrun = zcp_kstatsp->rrfifo_overrun.value.ul;
1003 		statsp->rspfifo_uncorr_err =
1004 		    zcp_kstatsp->rspfifo_uncorr_err.value.ul;
1005 		statsp->buffer_overflow = zcp_kstatsp->buffer_overflow.value.ul;
1006 		statsp->stat_tbl_perr = zcp_kstatsp->stat_tbl_perr.value.ul;
1007 		statsp->dyn_tbl_perr = zcp_kstatsp->dyn_tbl_perr.value.ul;
1008 		statsp->buf_tbl_perr = zcp_kstatsp->buf_tbl_perr.value.ul;
1009 		statsp->tt_program_err = zcp_kstatsp->tt_program_err.value.ul;
1010 		statsp->rsp_tt_index_err =
1011 		    zcp_kstatsp->rsp_tt_index_err.value.ul;
1012 		statsp->slv_tt_index_err =
1013 		    zcp_kstatsp->slv_tt_index_err.value.ul;
1014 		statsp->zcp_tt_index_err =
1015 		    zcp_kstatsp->zcp_tt_index_err.value.ul;
1016 		statsp->cfifo_ecc = zcp_kstatsp->cfifo_ecc.value.ul;
1017 	} else {
1018 		zcp_kstatsp->rrfifo_underrun.value.ul = statsp->rrfifo_underrun;
1019 		zcp_kstatsp->rrfifo_overrun.value.ul = statsp->rrfifo_overrun;
1020 		zcp_kstatsp->rspfifo_uncorr_err.value.ul =
1021 		    statsp->rspfifo_uncorr_err;
1022 		zcp_kstatsp->buffer_overflow.value.ul =
1023 		    statsp->buffer_overflow;
1024 		zcp_kstatsp->stat_tbl_perr.value.ul = statsp->stat_tbl_perr;
1025 		zcp_kstatsp->dyn_tbl_perr.value.ul = statsp->dyn_tbl_perr;
1026 		zcp_kstatsp->buf_tbl_perr.value.ul = statsp->buf_tbl_perr;
1027 		zcp_kstatsp->tt_program_err.value.ul = statsp->tt_program_err;
1028 		zcp_kstatsp->rsp_tt_index_err.value.ul =
1029 		    statsp->rsp_tt_index_err;
1030 		zcp_kstatsp->slv_tt_index_err.value.ul =
1031 		    statsp->slv_tt_index_err;
1032 		zcp_kstatsp->zcp_tt_index_err.value.ul =
1033 		    statsp->zcp_tt_index_err;
1034 		zcp_kstatsp->cfifo_ecc.value.ul = statsp->cfifo_ecc;
1035 	}
1036 	NXGE_DEBUG_MSG((nxgep, KST_CTL, "<== nxge_zcp_stat_update"));
1037 	return (0);
1038 }
1039 
1040 /* ARGSUSED */
1041 int
1042 nxge_fflp_stat_update(kstat_t *ksp, int rw)
1043 {
1044 	p_nxge_t nxgep;
1045 	p_nxge_fflp_kstat_t fflp_kstatsp;
1046 	p_nxge_fflp_stats_t statsp;
1047 	int ldc_grp;
1048 
1049 	nxgep = (p_nxge_t)ksp->ks_private;
1050 	if (nxgep == NULL)
1051 		return (-1);
1052 
1053 	NXGE_DEBUG_MSG((nxgep, KST_CTL, "==> nxge_fflp_stat_update"));
1054 
1055 	fflp_kstatsp = (p_nxge_fflp_kstat_t)ksp->ks_data;
1056 	statsp = (p_nxge_fflp_stats_t)&nxgep->statsp->fflp_stats;
1057 
1058 	if (rw == KSTAT_WRITE) {
1059 		statsp->tcam_parity_err = fflp_kstatsp->fflp_tcam_perr.value.ul;
1060 		statsp->tcam_ecc_err = fflp_kstatsp->fflp_tcam_ecc_err.value.ul;
1061 		statsp->vlan_parity_err = fflp_kstatsp->fflp_vlan_perr.value.ul;
1062 		statsp->hash_lookup_err =
1063 		    fflp_kstatsp->fflp_hasht_lookup_err.value.ul;
1064 		for (ldc_grp = 0; ldc_grp < MAX_PARTITION; ldc_grp++) {
1065 			statsp->hash_pio_err[ldc_grp] =
1066 			    fflp_kstatsp->fflp_hasht_data_err[ldc_grp].
1067 			    value.ul;
1068 		}
1069 	} else {
1070 		fflp_kstatsp->fflp_tcam_perr.value.ul =
1071 		    fflp_kstatsp->fflp_tcam_perr.value.ul;
1072 		fflp_kstatsp->fflp_tcam_ecc_err.value.ul = statsp->tcam_ecc_err;
1073 		fflp_kstatsp->fflp_vlan_perr.value.ul = statsp->vlan_parity_err;
1074 		fflp_kstatsp->fflp_hasht_lookup_err.value.ul =
1075 		    statsp->hash_lookup_err;
1076 		for (ldc_grp = 0; ldc_grp < MAX_PARTITION; ldc_grp++) {
1077 			fflp_kstatsp->fflp_hasht_data_err[ldc_grp].value.ul =
1078 			    statsp->hash_pio_err[ldc_grp];
1079 		}
1080 	}
1081 	NXGE_DEBUG_MSG((nxgep, KST_CTL, "<== nxge_fflp_stat_update"));
1082 	return (0);
1083 }
1084 
1085 /* ARGSUSED */
1086 static uint64_t
1087 nxge_mac_octet_to_u64(struct ether_addr addr)
1088 {
1089 	int i;
1090 	uint64_t addr64 = 0;
1091 
1092 	for (i = ETHERADDRL - 1; i >= 0; i--) {
1093 		addr64 <<= 8;
1094 		addr64 |= addr.ether_addr_octet[i];
1095 	}
1096 	return (addr64);
1097 }
1098 
1099 /* ARGSUSED */
1100 int
1101 nxge_mmac_stat_update(kstat_t *ksp, int rw)
1102 {
1103 	p_nxge_t nxgep;
1104 	p_nxge_mmac_kstat_t mmac_kstatsp;
1105 	p_nxge_mmac_stats_t statsp;
1106 
1107 	nxgep = (p_nxge_t)ksp->ks_private;
1108 	if (nxgep == NULL)
1109 		return (-1);
1110 
1111 	NXGE_DEBUG_MSG((nxgep, KST_CTL, "==> nxge_mmac_stat_update"));
1112 
1113 	mmac_kstatsp = (p_nxge_mmac_kstat_t)ksp->ks_data;
1114 	statsp = (p_nxge_mmac_stats_t)&nxgep->statsp->mmac_stats;
1115 
1116 	if (rw == KSTAT_WRITE) {
1117 		cmn_err(CE_WARN, "Can not write mmac stats");
1118 	} else {
1119 		mmac_kstatsp->mmac_max_addr_cnt.value.ul =
1120 		    statsp->mmac_max_cnt;
1121 		mmac_kstatsp->mmac_avail_addr_cnt.value.ul =
1122 		    statsp->mmac_avail_cnt;
1123 		mmac_kstatsp->mmac_addr1.value.ul =
1124 		    nxge_mac_octet_to_u64(statsp->mmac_avail_pool[0]);
1125 		mmac_kstatsp->mmac_addr2.value.ul =
1126 		    nxge_mac_octet_to_u64(statsp->mmac_avail_pool[1]);
1127 		mmac_kstatsp->mmac_addr3.value.ul =
1128 		    nxge_mac_octet_to_u64(statsp->mmac_avail_pool[2]);
1129 		mmac_kstatsp->mmac_addr4.value.ul =
1130 		    nxge_mac_octet_to_u64(statsp->mmac_avail_pool[3]);
1131 		mmac_kstatsp->mmac_addr5.value.ul =
1132 		    nxge_mac_octet_to_u64(statsp->mmac_avail_pool[4]);
1133 		mmac_kstatsp->mmac_addr6.value.ul =
1134 		    nxge_mac_octet_to_u64(statsp->mmac_avail_pool[5]);
1135 		mmac_kstatsp->mmac_addr7.value.ul =
1136 		    nxge_mac_octet_to_u64(statsp->mmac_avail_pool[6]);
1137 		mmac_kstatsp->mmac_addr8.value.ul =
1138 		    nxge_mac_octet_to_u64(statsp->mmac_avail_pool[7]);
1139 		mmac_kstatsp->mmac_addr9.value.ul =
1140 		    nxge_mac_octet_to_u64(statsp->mmac_avail_pool[8]);
1141 		mmac_kstatsp->mmac_addr10.value.ul =
1142 		    nxge_mac_octet_to_u64(statsp->mmac_avail_pool[9]);
1143 		mmac_kstatsp->mmac_addr11.value.ul =
1144 		    nxge_mac_octet_to_u64(statsp->mmac_avail_pool[10]);
1145 		mmac_kstatsp->mmac_addr12.value.ul =
1146 		    nxge_mac_octet_to_u64(statsp->mmac_avail_pool[11]);
1147 		mmac_kstatsp->mmac_addr13.value.ul =
1148 		    nxge_mac_octet_to_u64(statsp->mmac_avail_pool[12]);
1149 		mmac_kstatsp->mmac_addr14.value.ul =
1150 		    nxge_mac_octet_to_u64(statsp->mmac_avail_pool[13]);
1151 		mmac_kstatsp->mmac_addr15.value.ul =
1152 		    nxge_mac_octet_to_u64(statsp->mmac_avail_pool[14]);
1153 		mmac_kstatsp->mmac_addr16.value.ul =
1154 		    nxge_mac_octet_to_u64(statsp->mmac_avail_pool[15]);
1155 	}
1156 	NXGE_DEBUG_MSG((nxgep, KST_CTL, "<== nxge_mmac_stat_update"));
1157 	return (0);
1158 }
1159 
1160 /* ARGSUSED */
1161 static kstat_t *
1162 nxge_setup_local_kstat(p_nxge_t nxgep, int instance, char *name,
1163 	const nxge_kstat_index_t *ksip, size_t count,
1164 	int (*update) (kstat_t *, int))
1165 {
1166 	kstat_t *ksp;
1167 	kstat_named_t *knp;
1168 	int i;
1169 
1170 	ksp = kstat_create(NXGE_DRIVER_NAME, instance, name, "net",
1171 	    KSTAT_TYPE_NAMED, count, 0);
1172 	if (ksp == NULL)
1173 		return (NULL);
1174 
1175 	ksp->ks_private = (void *)nxgep;
1176 	ksp->ks_update = update;
1177 	knp = ksp->ks_data;
1178 
1179 	for (i = 0; ksip[i].name != NULL; i++) {
1180 		kstat_named_init(&knp[i], ksip[i].name, ksip[i].type);
1181 	}
1182 
1183 	kstat_install(ksp);
1184 	return (ksp);
1185 }
1186 
1187 /* ARGSUSED */
1188 void
1189 nxge_setup_rdc_kstats(p_nxge_t nxgep, int channel)
1190 {
1191 	char stat_name[64];
1192 
1193 	/* Setup RDC statistics */
1194 	(void) sprintf(stat_name, "%s" CH_NAME_FORMAT,
1195 	    RDC_NAME_FORMAT1, channel);
1196 	nxgep->statsp->rdc_ksp[channel] = nxge_setup_local_kstat(nxgep,
1197 	    nxgep->instance,
1198 	    stat_name,
1199 	    nxge_rdc_stats,
1200 	    RDC_STAT_END,
1201 	    nxge_rdc_stat_update);
1202 #ifdef	NXGE_DEBUG_ERROR
1203 	if (nxgep->statsp->rdc_ksp[channel] == NULL)
1204 		NXGE_DEBUG_MSG((nxgep, KST_CTL,
1205 		    "kstat_create failed for rdc channel %d", channel));
1206 #endif
1207 }
1208 
1209 void
1210 nxge_setup_tdc_kstats(p_nxge_t nxgep, int channel)
1211 {
1212 	char stat_name[64];
1213 
1214 	/* Setup TDC statistics */
1215 	(void) sprintf(stat_name, "%s" CH_NAME_FORMAT,
1216 	    TDC_NAME_FORMAT1, channel);
1217 	nxgep->statsp->tdc_ksp[channel] = nxge_setup_local_kstat(nxgep,
1218 	    nxgep->instance,
1219 	    stat_name,
1220 	    nxge_tdc_stats,
1221 	    TDC_STAT_END,
1222 	    nxge_tdc_stat_update);
1223 #ifdef	NXGE_DEBUG_ERROR
1224 	if (nxgep->statsp->tdc_ksp[channel] == NULL) {
1225 		NXGE_DEBUG_MSG((nxgep, KST_CTL,
1226 		    "kstat_create failed for tdc channel %d", channel));
1227 	}
1228 #endif
1229 }
1230 
1231 void
1232 nxge_setup_kstats(p_nxge_t nxgep)
1233 {
1234 	struct kstat *ksp;
1235 	p_nxge_port_kstat_t nxgekp;
1236 	size_t nxge_kstat_sz;
1237 	char mmac_name[64];
1238 
1239 	NXGE_DEBUG_MSG((nxgep, KST_CTL, "==> nxge_setup_kstats"));
1240 
1241 	/* Setup RDC System statistics */
1242 	nxgep->statsp->rdc_sys_ksp = nxge_setup_local_kstat(nxgep,
1243 	    nxgep->instance,
1244 	    "RDC System Stats",
1245 	    &nxge_rdc_sys_stats[0],
1246 	    RDC_SYS_STAT_END,
1247 	    nxge_rdc_sys_stat_update);
1248 
1249 	/* Setup IPP statistics */
1250 	nxgep->statsp->ipp_ksp = nxge_setup_local_kstat(nxgep,
1251 	    nxgep->instance,
1252 	    "IPP Stats",
1253 	    &nxge_ipp_stats[0],
1254 	    IPP_STAT_END,
1255 	    nxge_ipp_stat_update);
1256 #ifdef	NXGE_DEBUG_ERROR
1257 	if (nxgep->istatsp->pp_ksp == NULL)
1258 		NXGE_DEBUG_MSG((nxgep, KST_CTL, "kstat_create failed for ipp"));
1259 #endif
1260 
1261 	/* Setup TXC statistics */
1262 	nxgep->statsp->txc_ksp = nxge_setup_local_kstat(nxgep,
1263 	    nxgep->instance, "TXC Stats", &nxge_txc_stats[0],
1264 	    TXC_STAT_END, nxge_txc_stat_update);
1265 #ifdef	NXGE_DEBUG_ERROR
1266 	if (nxgep->statsp->txc_ksp == NULL)
1267 		NXGE_DEBUG_MSG((nxgep, KST_CTL, "kstat_create failed for txc"));
1268 #endif
1269 
1270 	/* Setup ZCP statistics */
1271 	nxgep->statsp->zcp_ksp = nxge_setup_local_kstat(nxgep,
1272 	    nxgep->instance, "ZCP Stats", &nxge_zcp_stats[0],
1273 	    ZCP_STAT_END, nxge_zcp_stat_update);
1274 #ifdef	NXGE_DEBUG_ERROR
1275 	if (nxgep->statsp->zcp_ksp == NULL)
1276 		NXGE_DEBUG_MSG((nxgep, KST_CTL, "kstat_create failed for zcp"));
1277 #endif
1278 
1279 	/* Setup FFLP statistics */
1280 	nxgep->statsp->fflp_ksp[0] = nxge_setup_local_kstat(nxgep,
1281 	    nxgep->instance, "FFLP Stats", &nxge_fflp_stats[0],
1282 	    FFLP_STAT_END, nxge_fflp_stat_update);
1283 
1284 #ifdef	NXGE_DEBUG_ERROR
1285 	if (nxgep->statsp->fflp_ksp == NULL)
1286 		NXGE_DEBUG_MSG((nxgep, KST_CTL,
1287 		    "kstat_create failed for fflp"));
1288 #endif
1289 
1290 	(void) sprintf(mmac_name, "MMAC Stats%d", nxgep->instance);
1291 	nxgep->statsp->mmac_ksp = nxge_setup_local_kstat(nxgep,
1292 	    nxgep->instance, "MMAC Stats", &nxge_mmac_stats[0],
1293 	    MMAC_STATS_END, nxge_mmac_stat_update);
1294 
1295 	nxge_kstat_sz = sizeof (nxge_port_kstat_t) +
1296 	    sizeof (nxge_mac_kstat_t) - sizeof (kstat_named_t);
1297 
1298 	if ((ksp = kstat_create(NXGE_DRIVER_NAME, nxgep->instance,
1299 	    "Port Stats", "net", KSTAT_TYPE_NAMED,
1300 	    nxge_kstat_sz / sizeof (kstat_named_t), 0)) == NULL) {
1301 		NXGE_DEBUG_MSG((nxgep, KST_CTL, "kstat_create failed"));
1302 		NXGE_DEBUG_MSG((nxgep, KST_CTL, "<== nxge_setup_kstats"));
1303 		return;
1304 	}
1305 
1306 	/*
1307 	 * kstats
1308 	 */
1309 	nxgekp = (p_nxge_port_kstat_t)ksp->ks_data;
1310 
1311 	/*
1312 	 * transceiver state informations.
1313 	 */
1314 	kstat_named_init(&nxgekp->xcvr_inits, "xcvr_inits",
1315 	    KSTAT_DATA_ULONG);
1316 	kstat_named_init(&nxgekp->xcvr_inuse, "xcvr_inuse",
1317 	    KSTAT_DATA_ULONG);
1318 	kstat_named_init(&nxgekp->xcvr_addr, "xcvr_addr",
1319 	    KSTAT_DATA_ULONG);
1320 	kstat_named_init(&nxgekp->xcvr_id, "xcvr_id",
1321 	    KSTAT_DATA_ULONG);
1322 	kstat_named_init(&nxgekp->cap_autoneg, "cap_autoneg",
1323 	    KSTAT_DATA_ULONG);
1324 	kstat_named_init(&nxgekp->cap_10gfdx, "cap_10gfdx",
1325 	    KSTAT_DATA_ULONG);
1326 	kstat_named_init(&nxgekp->cap_10ghdx, "cap_10ghdx",
1327 	    KSTAT_DATA_ULONG);
1328 	kstat_named_init(&nxgekp->cap_1000fdx, "cap_1000fdx",
1329 	    KSTAT_DATA_ULONG);
1330 	kstat_named_init(&nxgekp->cap_1000hdx, "cap_1000hdx",
1331 	    KSTAT_DATA_ULONG);
1332 	kstat_named_init(&nxgekp->cap_100T4, "cap_100T4",
1333 	    KSTAT_DATA_ULONG);
1334 	kstat_named_init(&nxgekp->cap_100fdx, "cap_100fdx",
1335 	    KSTAT_DATA_ULONG);
1336 	kstat_named_init(&nxgekp->cap_100hdx, "cap_100hdx",
1337 	    KSTAT_DATA_ULONG);
1338 	kstat_named_init(&nxgekp->cap_10fdx, "cap_10fdx",
1339 	    KSTAT_DATA_ULONG);
1340 	kstat_named_init(&nxgekp->cap_10hdx, "cap_10hdx",
1341 	    KSTAT_DATA_ULONG);
1342 	kstat_named_init(&nxgekp->cap_asmpause, "cap_asmpause",
1343 	    KSTAT_DATA_ULONG);
1344 	kstat_named_init(&nxgekp->cap_pause, "cap_pause",
1345 	    KSTAT_DATA_ULONG);
1346 
1347 	/*
1348 	 * Link partner capabilities.
1349 	 */
1350 	kstat_named_init(&nxgekp->lp_cap_autoneg, "lp_cap_autoneg",
1351 	    KSTAT_DATA_ULONG);
1352 	kstat_named_init(&nxgekp->lp_cap_10gfdx, "lp_cap_10gfdx",
1353 	    KSTAT_DATA_ULONG);
1354 	kstat_named_init(&nxgekp->lp_cap_10ghdx, "lp_cap_10ghdx",
1355 	    KSTAT_DATA_ULONG);
1356 	kstat_named_init(&nxgekp->lp_cap_1000fdx, "lp_cap_1000fdx",
1357 	    KSTAT_DATA_ULONG);
1358 	kstat_named_init(&nxgekp->lp_cap_1000hdx, "lp_cap_1000hdx",
1359 	    KSTAT_DATA_ULONG);
1360 	kstat_named_init(&nxgekp->lp_cap_100T4, "lp_cap_100T4",
1361 	    KSTAT_DATA_ULONG);
1362 	kstat_named_init(&nxgekp->lp_cap_100fdx, "lp_cap_100fdx",
1363 	    KSTAT_DATA_ULONG);
1364 	kstat_named_init(&nxgekp->lp_cap_100hdx, "lp_cap_100hdx",
1365 	    KSTAT_DATA_ULONG);
1366 	kstat_named_init(&nxgekp->lp_cap_10fdx, "lp_cap_10fdx",
1367 	    KSTAT_DATA_ULONG);
1368 	kstat_named_init(&nxgekp->lp_cap_10hdx, "lp_cap_10hdx",
1369 	    KSTAT_DATA_ULONG);
1370 	kstat_named_init(&nxgekp->lp_cap_asmpause, "lp_cap_asmpause",
1371 	    KSTAT_DATA_ULONG);
1372 	kstat_named_init(&nxgekp->lp_cap_pause, "lp_cap_pause",
1373 	    KSTAT_DATA_ULONG);
1374 	/*
1375 	 * Shared link setup.
1376 	 */
1377 	kstat_named_init(&nxgekp->link_T4, "link_T4",
1378 	    KSTAT_DATA_ULONG);
1379 	kstat_named_init(&nxgekp->link_speed, "link_speed",
1380 	    KSTAT_DATA_ULONG);
1381 	kstat_named_init(&nxgekp->link_duplex, "link_duplex",
1382 	    KSTAT_DATA_CHAR);
1383 	kstat_named_init(&nxgekp->link_asmpause, "link_asmpause",
1384 	    KSTAT_DATA_ULONG);
1385 	kstat_named_init(&nxgekp->link_pause, "link_pause",
1386 	    KSTAT_DATA_ULONG);
1387 	kstat_named_init(&nxgekp->link_up, "link_up",
1388 	    KSTAT_DATA_ULONG);
1389 
1390 	/*
1391 	 * Let the user know the MTU currently in use by the physical MAC
1392 	 * port.
1393 	 */
1394 	kstat_named_init(&nxgekp->mac_mtu, "mac_mtu",
1395 	    KSTAT_DATA_ULONG);
1396 
1397 	/*
1398 	 * Loopback statistics.
1399 	 */
1400 	kstat_named_init(&nxgekp->lb_mode, "lb_mode",
1401 	    KSTAT_DATA_ULONG);
1402 
1403 	/*
1404 	 * This tells the user whether the driver is in QOS mode or not.
1405 	 */
1406 	kstat_named_init(&nxgekp->qos_mode, "qos_mode",
1407 	    KSTAT_DATA_ULONG);
1408 
1409 	/*
1410 	 * This tells whether the instance is trunked or not
1411 	 */
1412 	kstat_named_init(&nxgekp->trunk_mode, "trunk_mode",
1413 	    KSTAT_DATA_ULONG);
1414 
1415 #if defined MULTI_DATA_TX || defined MULTI_DATA_TXV2
1416 	kstat_named_init(&nxgekp->mdt_reqs, "mdt_reqs",
1417 	    KSTAT_DATA_ULONG);
1418 	kstat_named_init(&nxgekp->mdt_hdr_bufs, "mdt_hdr_bufs",
1419 	    KSTAT_DATA_ULONG);
1420 	kstat_named_init(&nxgekp->mdt_pld_bufs, "mdt_pld_bufs",
1421 	    KSTAT_DATA_ULONG);
1422 	kstat_named_init(&nxgekp->mdt_pkts, "mdt_pkts",
1423 	    KSTAT_DATA_ULONG);
1424 	kstat_named_init(&nxgekp->mdt_hdrs, "mdt_hdrs",
1425 	    KSTAT_DATA_ULONG);
1426 	kstat_named_init(&nxgekp->mdt_plds, "mdt_plds",
1427 	    KSTAT_DATA_ULONG);
1428 	kstat_named_init(&nxgekp->mdt_hdr_bind_fail, "mdt_hdr_bind_fail",
1429 	    KSTAT_DATA_ULONG);
1430 	kstat_named_init(&nxgekp->mdt_pld_bind_fail, "mdt_pld_bind_fail",
1431 	    KSTAT_DATA_ULONG);
1432 #endif
1433 #ifdef ACCEPT_JUMBO
1434 	kstat_named_init(&nxgekp->tx_jumbo_pkts, "tx_jumbo_pkts",
1435 	    KSTAT_DATA_ULONG);
1436 #endif
1437 
1438 	/*
1439 	 * Rx Statistics.
1440 	 */
1441 #ifdef ACCEPT_JUMBO
1442 	kstat_named_init(&nxgekp->rx_jumbo_pkts, "rx_jumbo_pkts",
1443 	    KSTAT_DATA_ULONG);
1444 #endif
1445 	/* General MAC statistics */
1446 	kstat_named_init(&nxgekp->ifspeed, "ifspeed",
1447 	    KSTAT_DATA_UINT64);
1448 	kstat_named_init(&nxgekp->promisc, "promisc",
1449 	    KSTAT_DATA_CHAR);
1450 	kstat_named_init(&nxgekp->rev_id, "rev_id",
1451 	    KSTAT_DATA_ULONG);
1452 
1453 	ksp->ks_update = nxge_port_kstat_update;
1454 	ksp->ks_private = (void *) nxgep;
1455 	if (nxgep->mac.porttype == PORT_TYPE_XMAC)
1456 		nxge_xmac_init_kstats(ksp);
1457 	else
1458 		nxge_bmac_init_kstats(ksp);
1459 	kstat_install(ksp);
1460 	nxgep->statsp->port_ksp = ksp;
1461 	NXGE_DEBUG_MSG((nxgep, KST_CTL, "<== nxge_setup_kstats"));
1462 }
1463 
1464 /* ARGSUSED */
1465 void
1466 nxge_xmac_init_kstats(struct kstat *ksp)
1467 {
1468 	p_nxge_xmac_kstat_t nxgekp;
1469 
1470 	nxgekp = (p_nxge_xmac_kstat_t)ksp->ks_data;
1471 
1472 	/*
1473 	 * Transmit MAC statistics.
1474 	 */
1475 	kstat_named_init(&nxgekp->tx_frame_cnt, "txmac_frame_cnt",
1476 	    KSTAT_DATA_ULONG);
1477 	kstat_named_init(&nxgekp->tx_underflow_err, "txmac_underflow_err",
1478 	    KSTAT_DATA_ULONG);
1479 	kstat_named_init(&nxgekp->tx_overflow_err, "txmac_overflow_err",
1480 	    KSTAT_DATA_ULONG);
1481 	kstat_named_init(&nxgekp->tx_maxpktsize_err, "txmac_maxpktsize_err",
1482 	    KSTAT_DATA_ULONG);
1483 	kstat_named_init(&nxgekp->tx_fifo_xfr_err, "txmac_fifo_xfr_err",
1484 	    KSTAT_DATA_ULONG);
1485 	kstat_named_init(&nxgekp->tx_byte_cnt, "txmac_byte_cnt",
1486 	    KSTAT_DATA_ULONG);
1487 
1488 	/* Receive MAC statistics */
1489 	kstat_named_init(&nxgekp->rx_frame_cnt, "rxmac_frame_cnt",
1490 	    KSTAT_DATA_ULONG);
1491 	kstat_named_init(&nxgekp->rx_overflow_err, "rxmac_overflow_err",
1492 	    KSTAT_DATA_ULONG);
1493 	kstat_named_init(&nxgekp->rx_underflow_err, "rxmac_underflow_err",
1494 	    KSTAT_DATA_ULONG);
1495 	kstat_named_init(&nxgekp->rx_crc_err_cnt, "rxmac_crc_err",
1496 	    KSTAT_DATA_ULONG);
1497 	kstat_named_init(&nxgekp->rx_len_err_cnt, "rxmac_length_err",
1498 	    KSTAT_DATA_ULONG);
1499 	kstat_named_init(&nxgekp->rx_viol_err_cnt, "rxmac_code_violations",
1500 	    KSTAT_DATA_ULONG);
1501 	kstat_named_init(&nxgekp->rx_byte_cnt, "rxmac_byte_cnt",
1502 	    KSTAT_DATA_ULONG);
1503 	kstat_named_init(&nxgekp->rx_frame_align_err_cnt,
1504 	    "rxmac_alignment_err",
1505 	    KSTAT_DATA_ULONG);
1506 	kstat_named_init(&nxgekp->rx_hist1_cnt, "rxmac_64_cnt",
1507 	    KSTAT_DATA_ULONG);
1508 	kstat_named_init(&nxgekp->rx_hist2_cnt, "rxmac_65_127_cnt",
1509 	    KSTAT_DATA_ULONG);
1510 	kstat_named_init(&nxgekp->rx_hist3_cnt, "rxmac_128_255_cnt",
1511 	    KSTAT_DATA_ULONG);
1512 	kstat_named_init(&nxgekp->rx_hist4_cnt, "rxmac_256_511_cnt",
1513 	    KSTAT_DATA_ULONG);
1514 	kstat_named_init(&nxgekp->rx_hist5_cnt, "rxmac_512_1023_cnt",
1515 	    KSTAT_DATA_ULONG);
1516 	kstat_named_init(&nxgekp->rx_hist6_cnt, "rxmac_1024_1522_cnt",
1517 	    KSTAT_DATA_ULONG);
1518 	kstat_named_init(&nxgekp->rx_hist7_cnt, "rxmac_jumbo_cnt",
1519 	    KSTAT_DATA_ULONG);
1520 	kstat_named_init(&nxgekp->rx_broadcast_cnt, "rxmac_broadcast_cnt",
1521 	    KSTAT_DATA_ULONG);
1522 	kstat_named_init(&nxgekp->rx_mult_cnt, "rxmac_multicast_cnt",
1523 	    KSTAT_DATA_ULONG);
1524 	kstat_named_init(&nxgekp->rx_frag_cnt, "rxmac_fragment_cnt",
1525 	    KSTAT_DATA_ULONG);
1526 	kstat_named_init(&nxgekp->rx_linkfault_err_cnt, "rxmac_linkfault_errs",
1527 	    KSTAT_DATA_ULONG);
1528 	kstat_named_init(&nxgekp->rx_remote_fault_err_cnt,
1529 	    "rxmac_remote_faults",
1530 	    KSTAT_DATA_ULONG);
1531 	kstat_named_init(&nxgekp->rx_local_fault_err_cnt, "rxmac_local_faults",
1532 	    KSTAT_DATA_ULONG);
1533 
1534 	/* XPCS statistics */
1535 
1536 	kstat_named_init(&nxgekp->xpcs_deskew_err_cnt, "xpcs_deskew_err_cnt",
1537 	    KSTAT_DATA_ULONG);
1538 #ifdef	NXGE_DEBUG_SYMBOL_ERR
1539 	kstat_named_init(&nxgekp->xpcs_ln0_symbol_err_cnt,
1540 	    "xpcs_ln0_symbol_err_cnt",
1541 	    KSTAT_DATA_ULONG);
1542 	kstat_named_init(&nxgekp->xpcs_ln1_symbol_err_cnt,
1543 	    "xpcs_ln1_symbol_err_cnt",
1544 	    KSTAT_DATA_ULONG);
1545 	kstat_named_init(&nxgekp->xpcs_ln2_symbol_err_cnt,
1546 	    "xpcs_ln2_symbol_err_cnt",
1547 	    KSTAT_DATA_ULONG);
1548 	kstat_named_init(&nxgekp->xpcs_ln3_symbol_err_cnt,
1549 	    "xpcs_ln3_symbol_err_cnt",
1550 	    KSTAT_DATA_ULONG);
1551 #endif
1552 }
1553 
1554 /* ARGSUSED */
1555 void
1556 nxge_bmac_init_kstats(struct kstat *ksp)
1557 {
1558 	p_nxge_bmac_kstat_t nxgekp;
1559 
1560 	nxgekp = (p_nxge_bmac_kstat_t)ksp->ks_data;
1561 
1562 	/*
1563 	 * Transmit MAC statistics.
1564 	 */
1565 	kstat_named_init(&nxgekp->tx_frame_cnt, "txmac_frame_cnt",
1566 	    KSTAT_DATA_ULONG);
1567 	kstat_named_init(&nxgekp->tx_underrun_err, "txmac_underflow_err",
1568 	    KSTAT_DATA_ULONG);
1569 	kstat_named_init(&nxgekp->tx_max_pkt_err, "txmac_maxpktsize_err",
1570 	    KSTAT_DATA_ULONG);
1571 	kstat_named_init(&nxgekp->tx_byte_cnt, "txmac_byte_cnt",
1572 	    KSTAT_DATA_ULONG);
1573 
1574 	/* Receive MAC statistics */
1575 	kstat_named_init(&nxgekp->rx_overflow_err, "rxmac_overflow_err",
1576 	    KSTAT_DATA_ULONG);
1577 	kstat_named_init(&nxgekp->rx_crc_err_cnt, "rxmac_crc_err",
1578 	    KSTAT_DATA_ULONG);
1579 	kstat_named_init(&nxgekp->rx_len_err_cnt, "rxmac_length_err",
1580 	    KSTAT_DATA_ULONG);
1581 	kstat_named_init(&nxgekp->rx_viol_err_cnt, "rxmac_code_violations",
1582 	    KSTAT_DATA_ULONG);
1583 	kstat_named_init(&nxgekp->rx_byte_cnt, "rxmac_byte_cnt",
1584 	    KSTAT_DATA_ULONG);
1585 	kstat_named_init(&nxgekp->rx_align_err_cnt, "rxmac_alignment_err",
1586 	    KSTAT_DATA_ULONG);
1587 	kstat_named_init(&nxgekp->rx_frame_cnt, "rxmac_frame_cnt",
1588 	    KSTAT_DATA_ULONG);
1589 }
1590 
1591 /* ARGSUSED */
1592 void
1593 nxge_mac_init_kstats(p_nxge_t nxgep, struct kstat *ksp)
1594 {
1595 	p_nxge_mac_kstat_t nxgekp;
1596 
1597 	nxgekp = (p_nxge_mac_kstat_t)ksp->ks_data;
1598 
1599 	/*
1600 	 * Transmit MAC statistics.
1601 	 */
1602 	kstat_named_init(&nxgekp->tx_frame_cnt, "txmac_frame_cnt",
1603 	    KSTAT_DATA_ULONG);
1604 	kstat_named_init(&nxgekp->tx_underflow_err, "txmac_underflow_err",
1605 	    KSTAT_DATA_ULONG);
1606 	kstat_named_init(&nxgekp->tx_overflow_err, "txmac_overflow_err",
1607 	    KSTAT_DATA_ULONG);
1608 	kstat_named_init(&nxgekp->tx_maxpktsize_err, "txmac_maxpktsize_err",
1609 	    KSTAT_DATA_ULONG);
1610 	kstat_named_init(&nxgekp->tx_fifo_xfr_err, "txmac_fifo_xfr_err",
1611 	    KSTAT_DATA_ULONG);
1612 	kstat_named_init(&nxgekp->tx_byte_cnt, "txmac_byte_cnt",
1613 	    KSTAT_DATA_ULONG);
1614 
1615 	/*
1616 	 * Receive MAC statistics
1617 	 */
1618 	kstat_named_init(&nxgekp->rx_overflow_err, "rxmac_overflow_err",
1619 	    KSTAT_DATA_ULONG);
1620 	kstat_named_init(&nxgekp->rx_underflow_err, "rxmac_underflow_err",
1621 	    KSTAT_DATA_ULONG);
1622 	kstat_named_init(&nxgekp->rx_crc_err_cnt, "rxmac_crc_err",
1623 	    KSTAT_DATA_ULONG);
1624 	kstat_named_init(&nxgekp->rx_len_err_cnt, "rxmac_length_err",
1625 	    KSTAT_DATA_ULONG);
1626 	kstat_named_init(&nxgekp->rx_viol_err_cnt, "rxmac_code_violations",
1627 	    KSTAT_DATA_ULONG);
1628 	kstat_named_init(&nxgekp->rx_byte_cnt, "rxmac_byte_cnt",
1629 	    KSTAT_DATA_ULONG);
1630 	kstat_named_init(&nxgekp->rx_frame_align_err_cnt,
1631 	    "rxmac_alignment_err",
1632 	    KSTAT_DATA_ULONG);
1633 	kstat_named_init(&nxgekp->rx_frame_cnt, "rxmac_frame_cnt",
1634 	    KSTAT_DATA_ULONG);
1635 	if (nxgep->mac.porttype == PORT_TYPE_XMAC) {
1636 		kstat_named_init(&nxgekp->rx_hist1_cnt, "rxmac_64_cnt",
1637 		    KSTAT_DATA_ULONG);
1638 		kstat_named_init(&nxgekp->rx_hist2_cnt, "rxmac_65_127_cnt",
1639 		    KSTAT_DATA_ULONG);
1640 		kstat_named_init(&nxgekp->rx_hist3_cnt, "rxmac_128_255_cnt",
1641 		    KSTAT_DATA_ULONG);
1642 		kstat_named_init(&nxgekp->rx_hist4_cnt, "rxmac_256_511_cnt",
1643 		    KSTAT_DATA_ULONG);
1644 		kstat_named_init(&nxgekp->rx_hist5_cnt, "rxmac_512_1023_cnt",
1645 		    KSTAT_DATA_ULONG);
1646 		kstat_named_init(&nxgekp->rx_hist6_cnt, "rxmac_1024_1522_cnt",
1647 		    KSTAT_DATA_ULONG);
1648 		kstat_named_init(&nxgekp->rx_hist7_cnt, "rxmac_jumbo_cnt",
1649 		    KSTAT_DATA_ULONG);
1650 		kstat_named_init(&nxgekp->rx_broadcast_cnt,
1651 		    "rxmac_broadcast_cnt",
1652 		    KSTAT_DATA_ULONG);
1653 		kstat_named_init(&nxgekp->rx_mult_cnt, "rxmac_multicast_cnt",
1654 		    KSTAT_DATA_ULONG);
1655 		kstat_named_init(&nxgekp->rx_frag_cnt, "rxmac_fragment_cnt",
1656 		    KSTAT_DATA_ULONG);
1657 		kstat_named_init(&nxgekp->rx_linkfault_err_cnt,
1658 		    "rxmac_linkfault_errs",
1659 		    KSTAT_DATA_ULONG);
1660 		kstat_named_init(&nxgekp->rx_remote_fault_err_cnt,
1661 		    "rxmac_remote_faults",
1662 		    KSTAT_DATA_ULONG);
1663 		kstat_named_init(&nxgekp->rx_local_fault_err_cnt,
1664 		    "rxmac_local_faults",
1665 		    KSTAT_DATA_ULONG);
1666 	}
1667 }
1668 
1669 /* ARGSUSED */
1670 void
1671 nxge_destroy_kstats(p_nxge_t nxgep)
1672 {
1673 	NXGE_DEBUG_MSG((nxgep, KST_CTL, "==> nxge_destroy_kstats"));
1674 
1675 	if (nxgep->statsp == NULL)
1676 		return;
1677 	if (nxgep->statsp->ksp)
1678 		kstat_delete(nxgep->statsp->ksp);
1679 
1680 	if (nxgep->statsp->rdc_sys_ksp)
1681 		kstat_delete(nxgep->statsp->rdc_sys_ksp);
1682 	if (nxgep->statsp->fflp_ksp[0])
1683 		kstat_delete(nxgep->statsp->fflp_ksp[0]);
1684 	if (nxgep->statsp->ipp_ksp)
1685 		kstat_delete(nxgep->statsp->ipp_ksp);
1686 	if (nxgep->statsp->txc_ksp)
1687 		kstat_delete(nxgep->statsp->txc_ksp);
1688 	if (nxgep->statsp->mac_ksp)
1689 		kstat_delete(nxgep->statsp->mac_ksp);
1690 	if (nxgep->statsp->zcp_ksp)
1691 		kstat_delete(nxgep->statsp->zcp_ksp);
1692 	if (nxgep->statsp->port_ksp)
1693 		kstat_delete(nxgep->statsp->port_ksp);
1694 	if (nxgep->statsp->mmac_ksp)
1695 		kstat_delete(nxgep->statsp->mmac_ksp);
1696 	if (nxgep->statsp)
1697 		KMEM_FREE(nxgep->statsp, nxgep->statsp->stats_size);
1698 
1699 	NXGE_DEBUG_MSG((nxgep, KST_CTL, "<== nxge_destroy_kstats"));
1700 }
1701 
1702 /* ARGSUSED */
1703 int
1704 nxge_port_kstat_update(kstat_t *ksp, int rw)
1705 {
1706 	p_nxge_t nxgep;
1707 	p_nxge_stats_t statsp;
1708 	p_nxge_port_kstat_t nxgekp;
1709 
1710 	nxgep = (p_nxge_t)ksp->ks_private;
1711 	if (nxgep == NULL)
1712 		return (-1);
1713 
1714 	NXGE_DEBUG_MSG((nxgep, KST_CTL, "==> nxge_port_kstat_update"));
1715 	statsp = (p_nxge_stats_t)nxgep->statsp;
1716 	nxgekp = (p_nxge_port_kstat_t)ksp->ks_data;
1717 	nxge_save_cntrs(nxgep);
1718 
1719 	if (rw == KSTAT_WRITE) {
1720 		/*
1721 		 * transceiver state informations.
1722 		 */
1723 		statsp->mac_stats.xcvr_inits = nxgekp->xcvr_inits.value.ul;
1724 
1725 		/*
1726 		 * Tx Statistics.
1727 		 */
1728 #if defined MULTI_DATA_TX || defined MULTI_DATA_TXV2
1729 		statsp->port_stats.mdt_reqs = nxgekp->mdt_reqs.value.ul;
1730 		statsp->port_stats.mdt_hdr_bufs = nxgekp->mdt_hdr_bufs.value.ul;
1731 		statsp->port_stats.mdt_pld_bufs = nxgekp->mdt_pld_bufs.value.ul;
1732 		statsp->port_stats.mdt_pkts = nxgekp->mdt_pkts.value.ul;
1733 		statsp->port_stats.mdt_hdrs = nxgekp->mdt_hdrs.value.ul;
1734 		statsp->port_stats.mdt_plds = nxgekp->mdt_plds.value.ul;
1735 		statsp->port_stats.mdt_hdr_bind_fail =
1736 		    nxgekp->mdt_hdr_bind_fail.value.ul;
1737 		statsp->port_stats.mdt_pld_bind_fail =
1738 		    nxgekp->mdt_pld_bind_fail.value.ul;
1739 #endif
1740 #ifdef ACCEPT_JUMBO
1741 		statsp->port_stats.tx_jumbo_pkts =
1742 		    nxgekp->tx_jumbo_pkts.value.ul;
1743 #endif
1744 		/*
1745 		 * Rx Statistics.
1746 		 */
1747 #ifdef ACCEPT_JUMBO
1748 		statsp->port_stats.rx_jumbo_pkts =
1749 		    nxgekp->rx_jumbo_pkts.value.ul;
1750 #endif
1751 		if (nxgep->mac.porttype == PORT_TYPE_XMAC) {
1752 			(void) nxge_xmac_stat_update(ksp, KSTAT_WRITE);
1753 		} else {
1754 			(void) nxge_bmac_stat_update(ksp, KSTAT_WRITE);
1755 		}
1756 		return (0);
1757 	} else {
1758 		if (nxgep->filter.all_phys_cnt)
1759 			(void) strcpy(nxgekp->promisc.value.c, "phys");
1760 		else if (nxgep->filter.all_multicast_cnt)
1761 			(void) strcpy(nxgekp->promisc.value.c, "multi");
1762 		else
1763 			(void) strcpy(nxgekp->promisc.value.c, "off");
1764 		nxgekp->ifspeed.value.ul =
1765 		    statsp->mac_stats.link_speed * 1000000ULL;
1766 		nxgekp->rev_id.value.ul = statsp->mac_stats.rev_id;
1767 
1768 		/*
1769 		 * transceiver state informations.
1770 		 */
1771 		nxgekp->xcvr_inits.value.ul = statsp->mac_stats.xcvr_inits;
1772 		nxgekp->xcvr_inuse.value.ul = statsp->mac_stats.xcvr_inuse;
1773 		nxgekp->xcvr_addr.value.ul = statsp->mac_stats.xcvr_portn;
1774 		nxgekp->xcvr_id.value.ul = statsp->mac_stats.xcvr_id;
1775 		nxgekp->cap_autoneg.value.ul = statsp->mac_stats.cap_autoneg;
1776 		nxgekp->cap_10gfdx.value.ul = statsp->mac_stats.cap_10gfdx;
1777 		nxgekp->cap_10ghdx.value.ul = statsp->mac_stats.cap_10ghdx;
1778 		nxgekp->cap_1000fdx.value.ul = statsp->mac_stats.cap_1000fdx;
1779 		nxgekp->cap_1000hdx.value.ul = statsp->mac_stats.cap_1000hdx;
1780 		nxgekp->cap_100T4.value.ul = statsp->mac_stats.cap_100T4;
1781 		nxgekp->cap_100fdx.value.ul = statsp->mac_stats.cap_100fdx;
1782 		nxgekp->cap_100hdx.value.ul = statsp->mac_stats.cap_100hdx;
1783 		nxgekp->cap_10fdx.value.ul = statsp->mac_stats.cap_10fdx;
1784 		nxgekp->cap_10hdx.value.ul = statsp->mac_stats.cap_10hdx;
1785 		nxgekp->cap_asmpause.value.ul =
1786 		    statsp->mac_stats.cap_asmpause;
1787 		nxgekp->cap_pause.value.ul = statsp->mac_stats.cap_pause;
1788 
1789 		/*
1790 		 * Link partner capabilities.
1791 		 */
1792 		nxgekp->lp_cap_autoneg.value.ul =
1793 		    statsp->mac_stats.lp_cap_autoneg;
1794 		nxgekp->lp_cap_10gfdx.value.ul =
1795 		    statsp->mac_stats.lp_cap_10gfdx;
1796 		nxgekp->lp_cap_10ghdx.value.ul =
1797 		    statsp->mac_stats.lp_cap_10ghdx;
1798 		nxgekp->lp_cap_1000fdx.value.ul =
1799 		    statsp->mac_stats.lp_cap_1000fdx;
1800 		nxgekp->lp_cap_1000hdx.value.ul =
1801 		    statsp->mac_stats.lp_cap_1000hdx;
1802 		nxgekp->lp_cap_100T4.value.ul =
1803 		    statsp->mac_stats.lp_cap_100T4;
1804 		nxgekp->lp_cap_100fdx.value.ul =
1805 		    statsp->mac_stats.lp_cap_100fdx;
1806 		nxgekp->lp_cap_100hdx.value.ul =
1807 		    statsp->mac_stats.lp_cap_100hdx;
1808 		nxgekp->lp_cap_10fdx.value.ul =
1809 		    statsp->mac_stats.lp_cap_10fdx;
1810 		nxgekp->lp_cap_10hdx.value.ul =
1811 		    statsp->mac_stats.lp_cap_10hdx;
1812 		nxgekp->lp_cap_asmpause.value.ul =
1813 		    statsp->mac_stats.lp_cap_asmpause;
1814 		nxgekp->lp_cap_pause.value.ul =
1815 		    statsp->mac_stats.lp_cap_pause;
1816 
1817 		/*
1818 		 * Physical link statistics.
1819 		 */
1820 		nxgekp->link_T4.value.ul = statsp->mac_stats.link_T4;
1821 		nxgekp->link_speed.value.ul = statsp->mac_stats.link_speed;
1822 		if (statsp->mac_stats.link_duplex == 2)
1823 			(void) strcpy(nxgekp->link_duplex.value.c, "full");
1824 		else if (statsp->mac_stats.link_duplex == 1)
1825 			(void) strcpy(nxgekp->link_duplex.value.c, "half");
1826 		else
1827 			(void) strcpy(nxgekp->link_duplex.value.c, "unknown");
1828 		nxgekp->link_asmpause.value.ul =
1829 		    statsp->mac_stats.link_asmpause;
1830 		nxgekp->link_pause.value.ul = statsp->mac_stats.link_pause;
1831 		nxgekp->link_up.value.ul = statsp->mac_stats.link_up;
1832 
1833 		/*
1834 		 * Lets the user know the MTU currently in use by the physical
1835 		 * MAC port.
1836 		 */
1837 		nxgekp->mac_mtu.value.ul = statsp->mac_stats.mac_mtu;
1838 
1839 		/*
1840 		 * Loopback statistics.
1841 		 */
1842 		nxgekp->lb_mode.value.ul = statsp->port_stats.lb_mode;
1843 
1844 		/*
1845 		 * This tells the user whether the driver is in QOS mode or
1846 		 * not.
1847 		 */
1848 		nxgekp->qos_mode.value.ul = statsp->port_stats.qos_mode;
1849 
1850 		/*
1851 		 * This tells whether the instance is trunked or not
1852 		 */
1853 		nxgekp->trunk_mode.value.ul = statsp->port_stats.trunk_mode;
1854 
1855 #if defined MULTI_DATA_TX || defined MULTI_DATA_TXV2
1856 		nxgekp->mdt_reqs.value.ul = statsp->port_stats.mdt_reqs;
1857 		nxgekp->mdt_hdr_bufs.value.ul =
1858 		    statsp->port_stats.mdt_hdr_bufs;
1859 		nxgekp->mdt_pld_bufs.value.ul =
1860 		    statsp->port_stats.mdt_pld_bufs;
1861 		nxgekp->mdt_pkts.value.ul = statsp->port_stats.mdt_pkts;
1862 		nxgekp->mdt_hdrs.value.ul = statsp->port_stats.mdt_hdrs;
1863 		nxgekp->mdt_plds.value.ul = statsp->port_stats.mdt_plds;
1864 		nxgekp->mdt_hdr_bind_fail.value.ul =
1865 		    statsp->port_stats.mdt_hdr_bind_fail;
1866 		nxgekp->mdt_pld_bind_fail.value.ul =
1867 		    statsp->port_stats.mdt_pld_bind_fail;
1868 #endif
1869 #ifdef ACCEPT_JUMBO
1870 		nxgekp->tx_jumbo_pkts.value.ul =
1871 		    statsp->port_stats.tx_jumbo_pkts;
1872 #endif
1873 #ifdef TX_MBLK_DEST
1874 		nxgekp->tx_1_desc.value.ul = statsp->port_stats.tx_1_desc;
1875 		nxgekp->tx_2_desc.value.ul = statsp->port_stats.tx_2_desc;
1876 		nxgekp->tx_3_desc.value.ul = statsp->port_stats.tx_3_desc;
1877 		nxgekp->tx_4_desc.value.ul = statsp->port_stats.tx_4_desc;
1878 		nxgekp->tx_5_desc.value.ul = statsp->port_stats.tx_5_desc;
1879 		nxgekp->tx_6_desc.value.ul = statsp->port_stats.tx_6_desc;
1880 		nxgekp->tx_7_desc.value.ul = statsp->port_stats.tx_7_desc;
1881 		nxgekp->tx_8_desc.value.ul = statsp->port_stats.tx_8_desc;
1882 		nxgekp->tx_max_desc.value.ul =
1883 		    statsp->port_stats.tx_max_desc;
1884 #endif
1885 		/*
1886 		 * Rx Statistics.
1887 		 */
1888 #ifdef ACCEPT_JUMBO
1889 		nxgekp->rx_jumbo_pkts.value.ul =
1890 		    statsp->port_stats.rx_jumbo_pkts;
1891 #endif
1892 		if (nxgep->mac.porttype == PORT_TYPE_XMAC) {
1893 			(void) nxge_xmac_stat_update(ksp, KSTAT_READ);
1894 		} else {
1895 			(void) nxge_bmac_stat_update(ksp, KSTAT_READ);
1896 		}
1897 	}
1898 
1899 	NXGE_DEBUG_MSG((nxgep, KST_CTL, "<== nxge_port_kstat_update"));
1900 	return (0);
1901 }
1902 
1903 /*
1904  * if this is the first init do not bother to save the
1905  * counters.
1906  */
1907 /* ARGSUSED */
1908 void
1909 nxge_save_cntrs(p_nxge_t nxgep)
1910 {
1911 	p_nxge_stats_t statsp;
1912 	uint64_t val;
1913 	npi_handle_t handle;
1914 	uint8_t portn;
1915 	uint8_t cnt8;
1916 	uint16_t cnt16;
1917 	uint32_t cnt32;
1918 
1919 	NXGE_DEBUG_MSG((nxgep, DDI_CTL, "==> nxge_save_cntrs"));
1920 
1921 	statsp = (p_nxge_stats_t)nxgep->statsp;
1922 	handle = nxgep->npi_handle;
1923 	portn = nxgep->mac.portnum;
1924 
1925 	MUTEX_ENTER(&nxgep->ouraddr_lock);
1926 
1927 	if (nxgep->mac.porttype == PORT_TYPE_XMAC) {
1928 		/*
1929 		 * Transmit MAC statistics.
1930 		 */
1931 		XMAC_REG_RD(handle, portn, XTXMAC_FRM_CNT_REG, &val);
1932 		statsp->xmac_stats.tx_frame_cnt += (val & XTXMAC_FRM_CNT_MASK);
1933 		XMAC_REG_RD(handle, portn, XTXMAC_BYTE_CNT_REG, &val);
1934 		statsp->xmac_stats.tx_byte_cnt += (val & XTXMAC_BYTE_CNT_MASK);
1935 		/*
1936 		 * Receive XMAC statistics.
1937 		 */
1938 		XMAC_REG_RD(handle, portn, XRXMAC_CRC_ER_CNT_REG, &val);
1939 		statsp->xmac_stats.rx_crc_err_cnt +=
1940 		    (val & XRXMAC_CRC_ER_CNT_MASK);
1941 
1942 		XMAC_REG_RD(handle, portn, XRXMAC_MPSZER_CNT_REG, &val);
1943 		statsp->xmac_stats.rx_len_err_cnt +=
1944 		    (val & XRXMAC_MPSZER_CNT_MASK);
1945 
1946 		XMAC_REG_RD(handle, portn, XRXMAC_CD_VIO_CNT_REG, &val);
1947 		statsp->xmac_stats.rx_viol_err_cnt +=
1948 		    (val & XRXMAC_CD_VIO_CNT_MASK);
1949 
1950 		XMAC_REG_RD(handle, portn, XRXMAC_BT_CNT_REG, &val);
1951 		statsp->xmac_stats.rx_byte_cnt += (val & XRXMAC_BT_CNT_MASK);
1952 
1953 		XMAC_REG_RD(handle, portn, XRXMAC_HIST_CNT1_REG, &val);
1954 		statsp->xmac_stats.rx_hist1_cnt +=
1955 		    (val & XRXMAC_HIST_CNT1_MASK);
1956 		statsp->xmac_stats.rx_frame_cnt +=
1957 		    (val & XRXMAC_HIST_CNT1_MASK);
1958 
1959 		XMAC_REG_RD(handle, portn, XRXMAC_HIST_CNT2_REG, &val);
1960 		statsp->xmac_stats.rx_hist2_cnt +=
1961 		    (val & XRXMAC_HIST_CNT2_MASK);
1962 		statsp->xmac_stats.rx_frame_cnt +=
1963 		    (val & XRXMAC_HIST_CNT2_MASK);
1964 
1965 		XMAC_REG_RD(handle, portn, XRXMAC_HIST_CNT3_REG, &val);
1966 		statsp->xmac_stats.rx_hist3_cnt +=
1967 		    (val & XRXMAC_HIST_CNT3_MASK);
1968 		statsp->xmac_stats.rx_frame_cnt +=
1969 		    (val & XRXMAC_HIST_CNT3_MASK);
1970 
1971 		XMAC_REG_RD(handle, portn, XRXMAC_HIST_CNT4_REG, &val);
1972 		statsp->xmac_stats.rx_hist4_cnt +=
1973 		    (val & XRXMAC_HIST_CNT4_MASK);
1974 		statsp->xmac_stats.rx_frame_cnt +=
1975 		    (val & XRXMAC_HIST_CNT4_MASK);
1976 
1977 		XMAC_REG_RD(handle, portn, XRXMAC_HIST_CNT5_REG, &val);
1978 		statsp->xmac_stats.rx_hist5_cnt +=
1979 		    (val & XRXMAC_HIST_CNT5_MASK);
1980 		statsp->xmac_stats.rx_frame_cnt +=
1981 		    (val & XRXMAC_HIST_CNT5_MASK);
1982 
1983 		XMAC_REG_RD(handle, portn, XRXMAC_HIST_CNT6_REG, &val);
1984 		statsp->xmac_stats.rx_hist6_cnt +=
1985 		    (val & XRXMAC_HIST_CNT6_MASK);
1986 		statsp->xmac_stats.rx_frame_cnt +=
1987 		    (val & XRXMAC_HIST_CNT6_MASK);
1988 
1989 		XMAC_REG_RD(handle, portn, XRXMAC_HIST_CNT7_REG, &val);
1990 		statsp->xmac_stats.rx_hist7_cnt +=
1991 		    (val & XRXMAC_HIST_CNT7_MASK);
1992 		statsp->xmac_stats.rx_frame_cnt +=
1993 		    (val & XRXMAC_HIST_CNT7_MASK);
1994 
1995 		XMAC_REG_RD(handle, portn, XRXMAC_BC_FRM_CNT_REG, &val);
1996 		statsp->xmac_stats.rx_broadcast_cnt +=
1997 		    (val & XRXMAC_BC_FRM_CNT_MASK);
1998 
1999 		XMAC_REG_RD(handle, portn, XRXMAC_MC_FRM_CNT_REG, &val);
2000 		statsp->xmac_stats.rx_mult_cnt +=
2001 		    (val & XRXMAC_MC_FRM_CNT_MASK);
2002 
2003 		XMAC_REG_RD(handle, portn, XRXMAC_FRAG_CNT_REG, &val);
2004 		statsp->xmac_stats.rx_frag_cnt += (val & XRXMAC_FRAG_CNT_MASK);
2005 
2006 		XMAC_REG_RD(handle, portn, XRXMAC_AL_ER_CNT_REG, &val);
2007 		statsp->xmac_stats.rx_frame_align_err_cnt +=
2008 		    (val & XRXMAC_AL_ER_CNT_MASK);
2009 
2010 		XMAC_REG_RD(handle, portn, XMAC_LINK_FLT_CNT_REG, &val);
2011 		statsp->xmac_stats.rx_linkfault_err_cnt +=
2012 		    (val & XMAC_LINK_FLT_CNT_MASK);
2013 
2014 		(void) npi_xmac_xpcs_read(handle, portn,
2015 		    XPCS_REG_DESCWERR_COUNTER, &cnt32);
2016 		statsp->xmac_stats.xpcs_deskew_err_cnt +=
2017 		    (val & XMAC_XPCS_DESKEW_ERR_CNT_MASK);
2018 
2019 #ifdef	NXGE_DEBUG_SYMBOL_ERR
2020 		(void) npi_xmac_xpcs_read(handle, portn,
2021 		    XPCS_REG_SYMBOL_ERR_L0_1_COUNTER, &cnt32);
2022 		statsp->xmac_stats.xpcs_ln0_symbol_err_cnt +=
2023 		    (cnt32 & XMAC_XPCS_SYM_ERR_CNT_L0_MASK);
2024 		statsp->xmac_stats.xpcs_ln1_symbol_err_cnt +=
2025 		    ((cnt32 & XMAC_XPCS_SYM_ERR_CNT_L1_MASK) >>
2026 		    XMAC_XPCS_SYM_ERR_CNT_L1_SHIFT);
2027 		(void) npi_xmac_xpcs_read(handle, portn,
2028 		    XPCS_REG_SYMBOL_ERR_L2_3_COUNTER, &cnt32);
2029 		statsp->xmac_stats.xpcs_ln2_symbol_err_cnt +=
2030 		    (cnt32 & XMAC_XPCS_SYM_ERR_CNT_L2_MASK);
2031 		statsp->xmac_stats.xpcs_ln3_symbol_err_cnt +=
2032 		    ((cnt32 & XMAC_XPCS_SYM_ERR_CNT_L3_MASK) >>
2033 		    XMAC_XPCS_SYM_ERR_CNT_L3_SHIFT);
2034 #endif
2035 	} else if (nxgep->mac.porttype == PORT_TYPE_BMAC) {
2036 		/*
2037 		 * Transmit MAC statistics.
2038 		 */
2039 		BMAC_REG_RD(handle, portn, BTXMAC_FRM_CNT_REG, &val);
2040 		statsp->bmac_stats.tx_frame_cnt += (val & BTXMAC_FRM_CNT_MASK);
2041 		/* Clear register as it is not auto clear on read */
2042 		BMAC_REG_WR(handle, portn, BTXMAC_FRM_CNT_REG, 0);
2043 
2044 		BMAC_REG_RD(handle, portn, BTXMAC_BYTE_CNT_REG, &val);
2045 		statsp->bmac_stats.tx_byte_cnt += (val & BTXMAC_BYTE_CNT_MASK);
2046 		/* Clear register as it is not auto clear on read */
2047 		BMAC_REG_WR(handle, portn, BTXMAC_BYTE_CNT_REG, 0);
2048 
2049 		/*
2050 		 * Receive MAC statistics.
2051 		 */
2052 		BMAC_REG_RD(handle, portn, RXMAC_FRM_CNT_REG, &val);
2053 		statsp->bmac_stats.rx_frame_cnt += (val & RXMAC_FRM_CNT_MASK);
2054 		/* Clear register as it is not auto clear on read */
2055 		BMAC_REG_WR(handle, portn, RXMAC_FRM_CNT_REG, 0);
2056 
2057 		BMAC_REG_RD(handle, portn, BRXMAC_BYTE_CNT_REG, &val);
2058 		statsp->bmac_stats.rx_byte_cnt += (val & BRXMAC_BYTE_CNT_MASK);
2059 		/* Clear register as it is not auto clear on read */
2060 		BMAC_REG_WR(handle, portn, BRXMAC_BYTE_CNT_REG, 0);
2061 
2062 		BMAC_REG_RD(handle, portn, BMAC_AL_ER_CNT_REG, &val);
2063 		statsp->bmac_stats.rx_align_err_cnt +=
2064 		    (val & BMAC_AL_ER_CNT_MASK);
2065 		/* Clear register as it is not auto clear on read */
2066 		BMAC_REG_WR(handle, portn, BMAC_AL_ER_CNT_REG, 0);
2067 
2068 		BMAC_REG_RD(handle, portn, MAC_LEN_ER_CNT_REG, &val);
2069 		statsp->bmac_stats.rx_len_err_cnt +=
2070 		    (val & MAC_LEN_ER_CNT_MASK);
2071 		/* Clear register as it is not auto clear on read */
2072 		BMAC_REG_WR(handle, portn, MAC_LEN_ER_CNT_REG, 0);
2073 
2074 		BMAC_REG_RD(handle, portn, BMAC_CRC_ER_CNT_REG, &val);
2075 		statsp->bmac_stats.rx_crc_err_cnt +=
2076 		    (val & BMAC_CRC_ER_CNT_MASK);
2077 		/* Clear register as it is not auto clear on read */
2078 		BMAC_REG_WR(handle, portn, BMAC_CRC_ER_CNT_REG, 0);
2079 
2080 		BMAC_REG_RD(handle, portn, BMAC_CD_VIO_CNT_REG, &val);
2081 		statsp->bmac_stats.rx_viol_err_cnt +=
2082 		    (val & BMAC_CD_VIO_CNT_MASK);
2083 		/* Clear register as it is not auto clear on read */
2084 		BMAC_REG_WR(handle, portn, BMAC_CD_VIO_CNT_REG, 0);
2085 	}
2086 	if (isLDOMguest(nxgep)) {
2087 		MUTEX_EXIT(&nxgep->ouraddr_lock);
2088 		goto nxge_save_cntrs_exit;
2089 	}
2090 	/* Update IPP counters */
2091 	(void) npi_ipp_get_ecc_err_count(handle, portn, &cnt8);
2092 	statsp->ipp_stats.ecc_err_cnt += cnt8;
2093 	(void) npi_ipp_get_pkt_dis_count(handle, portn, &cnt16);
2094 	statsp->ipp_stats.pkt_dis_cnt += cnt16;
2095 	(void) npi_ipp_get_cs_err_count(handle, portn, &cnt16);
2096 	statsp->ipp_stats.bad_cs_cnt += cnt16;
2097 
2098 	MUTEX_EXIT(&nxgep->ouraddr_lock);
2099 
2100 nxge_save_cntrs_exit:
2101 	NXGE_DEBUG_MSG((nxgep, DDI_CTL, "<== nxge_save_cntrs"));
2102 }
2103 
2104 uint64_t
2105 nxge_m_rx_stat(
2106 	nxge_t *nxgep,
2107 	uint_t stat)
2108 {
2109 	p_nxge_stats_t statsp;
2110 	nxge_grp_set_t *rx_set;
2111 	int8_t set[NXGE_MAX_RDCS];
2112 	int i, cursor;
2113 
2114 	uint64_t val = 0;
2115 
2116 	NXGE_DEBUG_MSG((nxgep, KST_CTL, "==> nxge_m_rx_stat"));
2117 	statsp = (p_nxge_stats_t)nxgep->statsp;
2118 
2119 	rx_set = &nxgep->rx_set;
2120 	for (i = 0, cursor = 0; i < NXGE_MAX_RDCS; i++) {
2121 		if ((1 << i) & rx_set->owned.map) {
2122 			set[cursor++] = (uint8_t)i;
2123 		}
2124 	}
2125 
2126 	for (i = 0; i < cursor; i++) {
2127 		int rdc = set[i];
2128 		switch (stat) {
2129 		case MAC_STAT_IERRORS:
2130 		case ETHER_STAT_MACRCV_ERRORS:
2131 			val += statsp->rdc_stats[rdc].ierrors;
2132 			break;
2133 
2134 		case MAC_STAT_RBYTES:
2135 			val += statsp->rdc_stats[rdc].ibytes;
2136 			break;
2137 
2138 		case MAC_STAT_IPACKETS:
2139 			val += statsp->rdc_stats[rdc].ipackets;
2140 			break;
2141 
2142 		default:
2143 			break;
2144 		}
2145 	}
2146 
2147 	return (val);
2148 }
2149 
2150 uint64_t
2151 nxge_m_tx_stat(
2152 	nxge_t *nxgep,
2153 	uint_t stat)
2154 {
2155 	p_nxge_stats_t statsp;
2156 	nxge_grp_set_t *tx_set;
2157 	int8_t set[NXGE_MAX_TDCS];
2158 	int i, cursor;
2159 
2160 	uint64_t val = 0;
2161 
2162 	NXGE_DEBUG_MSG((nxgep, KST_CTL, "==> nxge_m_tx_stat"));
2163 	statsp = (p_nxge_stats_t)nxgep->statsp;
2164 
2165 	tx_set = &nxgep->tx_set;
2166 	for (i = 0, cursor = 0; i < NXGE_MAX_TDCS; i++) {
2167 		if ((1 << i) & tx_set->owned.map) {
2168 			set[cursor++] = (uint8_t)i;
2169 		}
2170 	}
2171 
2172 	for (i = 0; i < cursor; i++) {
2173 		int tdc = set[i];
2174 		switch (stat) {
2175 		case MAC_STAT_OERRORS:
2176 			val += statsp->tdc_stats[tdc].oerrors;
2177 			break;
2178 
2179 		case MAC_STAT_OBYTES:
2180 			val += statsp->tdc_stats[tdc].obytes;
2181 			break;
2182 
2183 		case MAC_STAT_OPACKETS:
2184 			val += statsp->tdc_stats[tdc].opackets;
2185 			break;
2186 
2187 		default:
2188 			break;
2189 		}
2190 	}
2191 
2192 	return (val);
2193 }
2194 
2195 /* ARGSUSED */
2196 int
2197 nxge_m_stat(void *arg, uint_t stat, uint64_t *value)
2198 {
2199 	p_nxge_t nxgep = (p_nxge_t)arg;
2200 	p_nxge_stats_t statsp;
2201 	uint64_t val = 0;
2202 
2203 	NXGE_DEBUG_MSG((nxgep, KST_CTL, "==> nxge_m_stat"));
2204 	statsp = (p_nxge_stats_t)nxgep->statsp;
2205 
2206 	switch (stat) {
2207 	case MAC_STAT_IFSPEED:
2208 		val = statsp->mac_stats.link_speed * 1000000ull;
2209 		break;
2210 
2211 	case MAC_STAT_MULTIRCV:
2212 		val = statsp->port_stats.multircv;
2213 		break;
2214 
2215 	case MAC_STAT_BRDCSTRCV:
2216 		val = statsp->port_stats.brdcstrcv;
2217 		break;
2218 
2219 	case MAC_STAT_MULTIXMT:
2220 		val = statsp->port_stats.multixmt;
2221 		break;
2222 
2223 	case MAC_STAT_BRDCSTXMT:
2224 		val = statsp->port_stats.brdcstxmt;
2225 		break;
2226 
2227 	case MAC_STAT_NORCVBUF:
2228 		val = statsp->port_stats.norcvbuf;
2229 		break;
2230 
2231 	case MAC_STAT_IERRORS:
2232 	case ETHER_STAT_MACRCV_ERRORS:
2233 		val = nxge_m_rx_stat(nxgep, stat);
2234 		break;
2235 
2236 	case MAC_STAT_OERRORS:
2237 		val = nxge_m_tx_stat(nxgep, stat);
2238 		break;
2239 
2240 	case MAC_STAT_NOXMTBUF:
2241 		val = statsp->port_stats.noxmtbuf;
2242 		break;
2243 
2244 	case MAC_STAT_COLLISIONS:
2245 		val = 0;
2246 		break;
2247 
2248 	case MAC_STAT_RBYTES:
2249 		val = nxge_m_rx_stat(nxgep, stat);
2250 		break;
2251 
2252 	case MAC_STAT_IPACKETS:
2253 		val = nxge_m_rx_stat(nxgep, stat);
2254 		break;
2255 
2256 	case MAC_STAT_OBYTES:
2257 		val = nxge_m_tx_stat(nxgep, stat);
2258 		break;
2259 
2260 	case MAC_STAT_OPACKETS:
2261 		val = nxge_m_tx_stat(nxgep, stat);
2262 		break;
2263 	case MAC_STAT_LINK_STATE:
2264 		val = statsp->mac_stats.link_duplex;
2265 		break;
2266 	case MAC_STAT_LINK_UP:
2267 		val = statsp->mac_stats.link_up;
2268 		break;
2269 	case MAC_STAT_PROMISC:
2270 		val = statsp->mac_stats.promisc;
2271 		break;
2272 	case ETHER_STAT_SQE_ERRORS:
2273 		val = 0;
2274 		break;
2275 
2276 	case ETHER_STAT_ALIGN_ERRORS:
2277 		if (nxgep->mac.porttype == PORT_TYPE_XMAC)
2278 			val = statsp->xmac_stats.rx_frame_align_err_cnt;
2279 		else if (nxgep->mac.porttype == PORT_TYPE_BMAC)
2280 			val = statsp->bmac_stats.rx_align_err_cnt;
2281 		else
2282 			val = 0;
2283 		break;
2284 
2285 	case ETHER_STAT_FCS_ERRORS:
2286 		if (nxgep->mac.porttype == PORT_TYPE_XMAC)
2287 			val = statsp->xmac_stats.rx_crc_err_cnt;
2288 		else if (nxgep->mac.porttype == PORT_TYPE_BMAC)
2289 			val = statsp->bmac_stats.rx_crc_err_cnt;
2290 		else
2291 			val = 0;
2292 		break;
2293 
2294 	case ETHER_STAT_FIRST_COLLISIONS:
2295 		val = 0;
2296 		break;
2297 
2298 	case ETHER_STAT_MULTI_COLLISIONS:
2299 		val = 0;
2300 		break;
2301 
2302 	case ETHER_STAT_TX_LATE_COLLISIONS:
2303 		val = 0;
2304 		break;
2305 
2306 	case ETHER_STAT_EX_COLLISIONS:
2307 		val = 0;
2308 		break;
2309 
2310 	case ETHER_STAT_DEFER_XMTS:
2311 		val = 0;
2312 		break;
2313 
2314 	case ETHER_STAT_MACXMT_ERRORS:
2315 		if (nxgep->mac.porttype == PORT_TYPE_XMAC) {
2316 			val = statsp->xmac_stats.tx_underflow_err +
2317 			    statsp->xmac_stats.tx_maxpktsize_err +
2318 			    statsp->xmac_stats.tx_overflow_err +
2319 			    statsp->xmac_stats.tx_fifo_xfr_err;
2320 		} else {
2321 			val = statsp->bmac_stats.tx_underrun_err +
2322 			    statsp->bmac_stats.tx_max_pkt_err;
2323 		}
2324 		break;
2325 
2326 	case ETHER_STAT_CARRIER_ERRORS:
2327 		if (nxgep->mac.porttype == PORT_TYPE_XMAC) {
2328 			val = statsp->xmac_stats.rx_linkfault_err_cnt;
2329 		} else {
2330 			val = statsp->mac_stats.xcvr_inits +
2331 			    statsp->mac_stats.serdes_inits;
2332 		}
2333 		break;
2334 
2335 	case ETHER_STAT_TOOLONG_ERRORS:
2336 		if (nxgep->mac.porttype == PORT_TYPE_XMAC) {
2337 			val = statsp->xmac_stats.tx_maxpktsize_err +
2338 			    statsp->xmac_stats.rx_len_err_cnt;
2339 
2340 		} else {
2341 			val = statsp->bmac_stats.rx_len_err_cnt +
2342 			    statsp->bmac_stats.tx_max_pkt_err;
2343 		}
2344 		break;
2345 
2346 
2347 	case ETHER_STAT_XCVR_ADDR:
2348 		val = statsp->mac_stats.xcvr_portn;
2349 		break;
2350 	case ETHER_STAT_XCVR_ID:
2351 		val = statsp->mac_stats.xcvr_id;
2352 		break;
2353 
2354 	case ETHER_STAT_XCVR_INUSE:
2355 		val = statsp->mac_stats.xcvr_inuse;
2356 		break;
2357 
2358 	case ETHER_STAT_CAP_1000FDX:
2359 		val = statsp->mac_stats.cap_1000fdx;
2360 		break;
2361 
2362 	case ETHER_STAT_CAP_1000HDX:
2363 		val = statsp->mac_stats.cap_1000hdx;
2364 		break;
2365 
2366 	case ETHER_STAT_CAP_100FDX:
2367 		val = statsp->mac_stats.cap_100fdx;
2368 		break;
2369 
2370 	case ETHER_STAT_CAP_100HDX:
2371 		val = statsp->mac_stats.cap_100hdx;
2372 		break;
2373 
2374 	case ETHER_STAT_CAP_10FDX:
2375 		val = statsp->mac_stats.cap_10fdx;
2376 		break;
2377 
2378 	case ETHER_STAT_CAP_10HDX:
2379 		val = statsp->mac_stats.cap_10hdx;
2380 		break;
2381 
2382 	case ETHER_STAT_CAP_ASMPAUSE:
2383 		val = statsp->mac_stats.cap_asmpause;
2384 		val = 1;
2385 		break;
2386 
2387 	case ETHER_STAT_CAP_PAUSE:
2388 		val = statsp->mac_stats.cap_pause;
2389 		break;
2390 
2391 	case ETHER_STAT_CAP_AUTONEG:
2392 		val = statsp->mac_stats.cap_autoneg;
2393 		break;
2394 
2395 	case ETHER_STAT_ADV_CAP_1000FDX:
2396 		val = statsp->mac_stats.adv_cap_1000fdx;
2397 		break;
2398 
2399 	case ETHER_STAT_ADV_CAP_1000HDX:
2400 		val = statsp->mac_stats.adv_cap_1000hdx;
2401 		break;
2402 
2403 	case ETHER_STAT_ADV_CAP_100FDX:
2404 		val = statsp->mac_stats.adv_cap_100fdx;
2405 		break;
2406 
2407 	case ETHER_STAT_ADV_CAP_100HDX:
2408 		val = statsp->mac_stats.adv_cap_100hdx;
2409 		break;
2410 
2411 	case ETHER_STAT_ADV_CAP_10FDX:
2412 		val = statsp->mac_stats.adv_cap_10fdx;
2413 		break;
2414 
2415 	case ETHER_STAT_ADV_CAP_10HDX:
2416 		val = statsp->mac_stats.adv_cap_10hdx;
2417 		break;
2418 
2419 	case ETHER_STAT_ADV_CAP_ASMPAUSE:
2420 		val = statsp->mac_stats.adv_cap_asmpause;
2421 		break;
2422 
2423 	case ETHER_STAT_ADV_CAP_PAUSE:
2424 		val = statsp->mac_stats.adv_cap_pause;
2425 		break;
2426 
2427 	case ETHER_STAT_ADV_CAP_AUTONEG:
2428 		val = statsp->mac_stats.adv_cap_autoneg;
2429 		break;
2430 
2431 	case ETHER_STAT_LP_CAP_1000FDX:
2432 		val = statsp->mac_stats.lp_cap_1000fdx;
2433 		break;
2434 
2435 	case ETHER_STAT_LP_CAP_1000HDX:
2436 		val = statsp->mac_stats.lp_cap_1000hdx;
2437 		break;
2438 
2439 	case ETHER_STAT_LP_CAP_100FDX:
2440 		val = statsp->mac_stats.lp_cap_100fdx;
2441 		break;
2442 
2443 	case ETHER_STAT_LP_CAP_100HDX:
2444 		val = statsp->mac_stats.lp_cap_100hdx;
2445 		break;
2446 
2447 	case ETHER_STAT_LP_CAP_10FDX:
2448 		val = statsp->mac_stats.lp_cap_10fdx;
2449 		break;
2450 
2451 	case ETHER_STAT_LP_CAP_10HDX:
2452 		val = statsp->mac_stats.lp_cap_10hdx;
2453 		break;
2454 
2455 	case ETHER_STAT_LP_CAP_ASMPAUSE:
2456 		val = statsp->mac_stats.lp_cap_asmpause;
2457 		break;
2458 
2459 	case ETHER_STAT_LP_CAP_PAUSE:
2460 		val = statsp->mac_stats.lp_cap_pause;
2461 		break;
2462 
2463 	case ETHER_STAT_LP_CAP_AUTONEG:
2464 		val = statsp->mac_stats.lp_cap_autoneg;
2465 		break;
2466 
2467 	case ETHER_STAT_LINK_ASMPAUSE:
2468 		val = statsp->mac_stats.link_asmpause;
2469 		break;
2470 
2471 	case ETHER_STAT_LINK_PAUSE:
2472 		val = statsp->mac_stats.link_pause;
2473 		break;
2474 
2475 	case ETHER_STAT_LINK_AUTONEG:
2476 		val = statsp->mac_stats.cap_autoneg;
2477 		break;
2478 
2479 	case ETHER_STAT_LINK_DUPLEX:
2480 		val = statsp->mac_stats.link_duplex;
2481 		break;
2482 
2483 	default:
2484 		/*
2485 		 * Shouldn't reach here...
2486 		 */
2487 #ifdef NXGE_DEBUG
2488 		NXGE_ERROR_MSG((nxgep, KST_CTL,
2489 		    "nxge_m_stat: unrecognized parameter value = 0x%x",
2490 		    stat));
2491 #endif
2492 
2493 		return (ENOTSUP);
2494 	}
2495 	*value = val;
2496 	return (0);
2497 }
2498