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