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 2010 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25
26 #include <sys/nxge/nxge_impl.h>
27 #include <sys/nxge/nxge_hio.h>
28
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
nxge_init_statsp(p_nxge_t nxgep)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
nxge_tdc_stat_update(kstat_t * ksp,int rw)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
nxge_rdc_stat_update(kstat_t * ksp,int rw)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
nxge_rdc_sys_stat_update(kstat_t * ksp,int rw)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
nxge_txc_stat_update(kstat_t * ksp,int rw)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
nxge_ipp_stat_update(kstat_t * ksp,int rw)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
nxge_xmac_stat_update(kstat_t * ksp,int rw)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_frame_cnt = xmac_kstatsp->rx_frame_cnt.value.ul;
843 statsp->rx_hist1_cnt = xmac_kstatsp->rx_hist1_cnt.value.ul;
844 statsp->rx_hist2_cnt = xmac_kstatsp->rx_hist2_cnt.value.ul;
845 statsp->rx_hist3_cnt = xmac_kstatsp->rx_hist3_cnt.value.ul;
846 statsp->rx_hist4_cnt = xmac_kstatsp->rx_hist4_cnt.value.ul;
847 statsp->rx_hist5_cnt = xmac_kstatsp->rx_hist5_cnt.value.ul;
848 statsp->rx_hist6_cnt = xmac_kstatsp->rx_hist6_cnt.value.ul;
849 statsp->rx_hist7_cnt = xmac_kstatsp->rx_hist7_cnt.value.ul;
850 statsp->rx_mult_cnt = xmac_kstatsp->rx_mult_cnt.value.ul;
851 statsp->rx_frag_cnt = xmac_kstatsp->rx_frag_cnt.value.ul;
852 statsp->rx_frame_align_err_cnt =
853 xmac_kstatsp->rx_frame_align_err_cnt.value.ul;
854 statsp->rx_linkfault_err_cnt =
855 xmac_kstatsp->rx_linkfault_err_cnt.value.ul;
856 statsp->rx_localfault_err =
857 xmac_kstatsp->rx_local_fault_err_cnt.value.ul;
858 statsp->rx_remotefault_err =
859 xmac_kstatsp->rx_remote_fault_err_cnt.value.ul;
860 statsp->xpcs_deskew_err_cnt =
861 xmac_kstatsp->xpcs_deskew_err_cnt.value.ul;
862 #ifdef NXGE_DEBUG_SYMBOL_ERR
863 statsp->xpcs_ln0_symbol_err_cnt =
864 xmac_kstatsp->xpcs_ln0_symbol_err_cnt.value.ul;
865 statsp->xpcs_ln1_symbol_err_cnt =
866 xmac_kstatsp->xpcs_ln1_symbol_err_cnt.value.ul;
867 statsp->xpcs_ln2_symbol_err_cnt =
868 xmac_kstatsp->xpcs_ln2_symbol_err_cnt.value.ul;
869 statsp->xpcs_ln3_symbol_err_cnt =
870 xmac_kstatsp->xpcs_ln3_symbol_err_cnt.value.ul;
871 #endif
872 } else {
873 xmac_kstatsp->tx_frame_cnt.value.ul = statsp->tx_frame_cnt;
874 xmac_kstatsp->tx_underflow_err.value.ul =
875 statsp->tx_underflow_err;
876 xmac_kstatsp->tx_maxpktsize_err.value.ul =
877 statsp->tx_maxpktsize_err;
878 xmac_kstatsp->tx_overflow_err.value.ul =
879 statsp->tx_overflow_err;
880 xmac_kstatsp->tx_fifo_xfr_err.value.ul =
881 statsp->tx_fifo_xfr_err;
882 xmac_kstatsp->tx_byte_cnt.value.ul = statsp->tx_byte_cnt;
883 xmac_kstatsp->rx_underflow_err.value.ul =
884 statsp->rx_underflow_err;
885 xmac_kstatsp->rx_overflow_err.value.ul =
886 statsp->rx_overflow_err;
887 xmac_kstatsp->rx_crc_err_cnt.value.ul = statsp->rx_crc_err_cnt;
888 xmac_kstatsp->rx_len_err_cnt.value.ul = statsp->rx_len_err_cnt;
889 xmac_kstatsp->rx_viol_err_cnt.value.ul =
890 statsp->rx_viol_err_cnt;
891 xmac_kstatsp->rx_byte_cnt.value.ul = statsp->rx_byte_cnt;
892 xmac_kstatsp->rx_frame_cnt.value.ul = statsp->rx_frame_cnt;
893 xmac_kstatsp->rx_hist1_cnt.value.ul = statsp->rx_hist1_cnt;
894 xmac_kstatsp->rx_hist2_cnt.value.ul = statsp->rx_hist2_cnt;
895 xmac_kstatsp->rx_hist3_cnt.value.ul = statsp->rx_hist3_cnt;
896 xmac_kstatsp->rx_hist4_cnt.value.ul = statsp->rx_hist4_cnt;
897 xmac_kstatsp->rx_hist5_cnt.value.ul = statsp->rx_hist5_cnt;
898 xmac_kstatsp->rx_hist6_cnt.value.ul = statsp->rx_hist6_cnt;
899 xmac_kstatsp->rx_hist7_cnt.value.ul = statsp->rx_hist7_cnt;
900 xmac_kstatsp->rx_mult_cnt.value.ul = statsp->rx_mult_cnt;
901 xmac_kstatsp->rx_frag_cnt.value.ul = statsp->rx_frag_cnt;
902 xmac_kstatsp->rx_frame_align_err_cnt.value.ul =
903 statsp->rx_frame_align_err_cnt;
904 xmac_kstatsp->rx_linkfault_err_cnt.value.ul =
905 statsp->rx_linkfault_err_cnt;
906 xmac_kstatsp->rx_local_fault_err_cnt.value.ul =
907 statsp->rx_localfault_err;
908 xmac_kstatsp->rx_remote_fault_err_cnt.value.ul =
909 statsp->rx_remotefault_err;
910 xmac_kstatsp->xpcs_deskew_err_cnt.value.ul =
911 statsp->xpcs_deskew_err_cnt;
912 #ifdef NXGE_DEBUG_SYMBOL_ERR
913 xmac_kstatsp->xpcs_ln0_symbol_err_cnt.value.ul =
914 statsp->xpcs_ln0_symbol_err_cnt;
915 xmac_kstatsp->xpcs_ln1_symbol_err_cnt.value.ul =
916 statsp->xpcs_ln1_symbol_err_cnt;
917 xmac_kstatsp->xpcs_ln2_symbol_err_cnt.value.ul =
918 statsp->xpcs_ln2_symbol_err_cnt;
919 xmac_kstatsp->xpcs_ln3_symbol_err_cnt.value.ul =
920 statsp->xpcs_ln3_symbol_err_cnt;
921 #endif
922 }
923 NXGE_DEBUG_MSG((nxgep, KST_CTL, "<== nxge_xmac_stat_update"));
924 return (0);
925 }
926
927 /* ARGSUSED */
928 int
nxge_bmac_stat_update(kstat_t * ksp,int rw)929 nxge_bmac_stat_update(kstat_t *ksp, int rw)
930 {
931 p_nxge_t nxgep;
932 p_nxge_bmac_kstat_t bmac_kstatsp;
933 p_nxge_bmac_stats_t statsp;
934
935 nxgep = (p_nxge_t)ksp->ks_private;
936 if (nxgep == NULL)
937 return (-1);
938
939 NXGE_DEBUG_MSG((nxgep, KST_CTL, "==> nxge_bmac_stat_update"));
940
941 bmac_kstatsp = (p_nxge_bmac_kstat_t)ksp->ks_data;
942 statsp = (p_nxge_bmac_stats_t)&nxgep->statsp->bmac_stats;
943
944 if (rw == KSTAT_WRITE) {
945 statsp->tx_frame_cnt = bmac_kstatsp->tx_frame_cnt.value.ul;
946 statsp->tx_underrun_err =
947 bmac_kstatsp->tx_underrun_err.value.ul;
948 statsp->tx_max_pkt_err = bmac_kstatsp->tx_max_pkt_err.value.ul;
949 statsp->tx_byte_cnt = bmac_kstatsp->tx_byte_cnt.value.ul;
950 statsp->rx_frame_cnt = bmac_kstatsp->rx_frame_cnt.value.ul;
951 statsp->rx_byte_cnt = bmac_kstatsp->rx_byte_cnt.value.ul;
952 statsp->rx_overflow_err =
953 bmac_kstatsp->rx_overflow_err.value.ul;
954 statsp->rx_align_err_cnt =
955 bmac_kstatsp->rx_align_err_cnt.value.ul;
956 statsp->rx_crc_err_cnt = bmac_kstatsp->rx_crc_err_cnt.value.ul;
957 statsp->rx_len_err_cnt = bmac_kstatsp->rx_len_err_cnt.value.ul;
958 statsp->rx_viol_err_cnt =
959 bmac_kstatsp->rx_viol_err_cnt.value.ul;
960 } else {
961 bmac_kstatsp->tx_frame_cnt.value.ul = statsp->tx_frame_cnt;
962 bmac_kstatsp->tx_underrun_err.value.ul =
963 statsp->tx_underrun_err;
964 bmac_kstatsp->tx_max_pkt_err.value.ul = statsp->tx_max_pkt_err;
965 bmac_kstatsp->tx_byte_cnt.value.ul = statsp->tx_byte_cnt;
966 bmac_kstatsp->rx_frame_cnt.value.ul = statsp->rx_frame_cnt;
967 bmac_kstatsp->rx_byte_cnt.value.ul = statsp->rx_byte_cnt;
968 bmac_kstatsp->rx_overflow_err.value.ul =
969 statsp->rx_overflow_err;
970 bmac_kstatsp->rx_align_err_cnt.value.ul =
971 statsp->rx_align_err_cnt;
972 bmac_kstatsp->rx_crc_err_cnt.value.ul = statsp->rx_crc_err_cnt;
973 bmac_kstatsp->rx_len_err_cnt.value.ul = statsp->rx_len_err_cnt;
974 bmac_kstatsp->rx_viol_err_cnt.value.ul =
975 statsp->rx_viol_err_cnt;
976 }
977 NXGE_DEBUG_MSG((nxgep, KST_CTL, "<== nxge_bmac_stat_update"));
978 return (0);
979 }
980
981 /* ARGSUSED */
982 int
nxge_zcp_stat_update(kstat_t * ksp,int rw)983 nxge_zcp_stat_update(kstat_t *ksp, int rw)
984 {
985 p_nxge_t nxgep;
986 p_nxge_zcp_kstat_t zcp_kstatsp;
987 p_nxge_zcp_stats_t statsp;
988
989 nxgep = (p_nxge_t)ksp->ks_private;
990 if (nxgep == NULL)
991 return (-1);
992
993 NXGE_DEBUG_MSG((nxgep, KST_CTL, "==> nxge_zcp_stat_update"));
994
995 zcp_kstatsp = (p_nxge_zcp_kstat_t)ksp->ks_data;
996 statsp = (p_nxge_zcp_stats_t)&nxgep->statsp->zcp_stats;
997
998 if (rw == KSTAT_WRITE) {
999 statsp->rrfifo_underrun = zcp_kstatsp->rrfifo_underrun.value.ul;
1000 statsp->rrfifo_overrun = zcp_kstatsp->rrfifo_overrun.value.ul;
1001 statsp->rspfifo_uncorr_err =
1002 zcp_kstatsp->rspfifo_uncorr_err.value.ul;
1003 statsp->buffer_overflow = zcp_kstatsp->buffer_overflow.value.ul;
1004 statsp->stat_tbl_perr = zcp_kstatsp->stat_tbl_perr.value.ul;
1005 statsp->dyn_tbl_perr = zcp_kstatsp->dyn_tbl_perr.value.ul;
1006 statsp->buf_tbl_perr = zcp_kstatsp->buf_tbl_perr.value.ul;
1007 statsp->tt_program_err = zcp_kstatsp->tt_program_err.value.ul;
1008 statsp->rsp_tt_index_err =
1009 zcp_kstatsp->rsp_tt_index_err.value.ul;
1010 statsp->slv_tt_index_err =
1011 zcp_kstatsp->slv_tt_index_err.value.ul;
1012 statsp->zcp_tt_index_err =
1013 zcp_kstatsp->zcp_tt_index_err.value.ul;
1014 statsp->cfifo_ecc = zcp_kstatsp->cfifo_ecc.value.ul;
1015 } else {
1016 zcp_kstatsp->rrfifo_underrun.value.ul = statsp->rrfifo_underrun;
1017 zcp_kstatsp->rrfifo_overrun.value.ul = statsp->rrfifo_overrun;
1018 zcp_kstatsp->rspfifo_uncorr_err.value.ul =
1019 statsp->rspfifo_uncorr_err;
1020 zcp_kstatsp->buffer_overflow.value.ul =
1021 statsp->buffer_overflow;
1022 zcp_kstatsp->stat_tbl_perr.value.ul = statsp->stat_tbl_perr;
1023 zcp_kstatsp->dyn_tbl_perr.value.ul = statsp->dyn_tbl_perr;
1024 zcp_kstatsp->buf_tbl_perr.value.ul = statsp->buf_tbl_perr;
1025 zcp_kstatsp->tt_program_err.value.ul = statsp->tt_program_err;
1026 zcp_kstatsp->rsp_tt_index_err.value.ul =
1027 statsp->rsp_tt_index_err;
1028 zcp_kstatsp->slv_tt_index_err.value.ul =
1029 statsp->slv_tt_index_err;
1030 zcp_kstatsp->zcp_tt_index_err.value.ul =
1031 statsp->zcp_tt_index_err;
1032 zcp_kstatsp->cfifo_ecc.value.ul = statsp->cfifo_ecc;
1033 }
1034 NXGE_DEBUG_MSG((nxgep, KST_CTL, "<== nxge_zcp_stat_update"));
1035 return (0);
1036 }
1037
1038 /* ARGSUSED */
1039 int
nxge_fflp_stat_update(kstat_t * ksp,int rw)1040 nxge_fflp_stat_update(kstat_t *ksp, int rw)
1041 {
1042 p_nxge_t nxgep;
1043 p_nxge_fflp_kstat_t fflp_kstatsp;
1044 p_nxge_fflp_stats_t statsp;
1045 int ldc_grp;
1046
1047 nxgep = (p_nxge_t)ksp->ks_private;
1048 if (nxgep == NULL)
1049 return (-1);
1050
1051 NXGE_DEBUG_MSG((nxgep, KST_CTL, "==> nxge_fflp_stat_update"));
1052
1053 fflp_kstatsp = (p_nxge_fflp_kstat_t)ksp->ks_data;
1054 statsp = (p_nxge_fflp_stats_t)&nxgep->statsp->fflp_stats;
1055
1056 if (rw == KSTAT_WRITE) {
1057 statsp->tcam_parity_err = fflp_kstatsp->fflp_tcam_perr.value.ul;
1058 statsp->tcam_ecc_err = fflp_kstatsp->fflp_tcam_ecc_err.value.ul;
1059 statsp->vlan_parity_err = fflp_kstatsp->fflp_vlan_perr.value.ul;
1060 statsp->hash_lookup_err =
1061 fflp_kstatsp->fflp_hasht_lookup_err.value.ul;
1062 for (ldc_grp = 0; ldc_grp < MAX_PARTITION; ldc_grp++) {
1063 statsp->hash_pio_err[ldc_grp] =
1064 fflp_kstatsp->fflp_hasht_data_err[ldc_grp].
1065 value.ul;
1066 }
1067 } else {
1068 fflp_kstatsp->fflp_tcam_perr.value.ul =
1069 fflp_kstatsp->fflp_tcam_perr.value.ul;
1070 fflp_kstatsp->fflp_tcam_ecc_err.value.ul = statsp->tcam_ecc_err;
1071 fflp_kstatsp->fflp_vlan_perr.value.ul = statsp->vlan_parity_err;
1072 fflp_kstatsp->fflp_hasht_lookup_err.value.ul =
1073 statsp->hash_lookup_err;
1074 for (ldc_grp = 0; ldc_grp < MAX_PARTITION; ldc_grp++) {
1075 fflp_kstatsp->fflp_hasht_data_err[ldc_grp].value.ul =
1076 statsp->hash_pio_err[ldc_grp];
1077 }
1078 }
1079 NXGE_DEBUG_MSG((nxgep, KST_CTL, "<== nxge_fflp_stat_update"));
1080 return (0);
1081 }
1082
1083 /* ARGSUSED */
1084 static uint64_t
nxge_mac_octet_to_u64(struct ether_addr addr)1085 nxge_mac_octet_to_u64(struct ether_addr addr)
1086 {
1087 int i;
1088 uint64_t addr64 = 0;
1089
1090 for (i = ETHERADDRL - 1; i >= 0; i--) {
1091 addr64 <<= 8;
1092 addr64 |= addr.ether_addr_octet[i];
1093 }
1094 return (addr64);
1095 }
1096
1097 /* ARGSUSED */
1098 int
nxge_mmac_stat_update(kstat_t * ksp,int rw)1099 nxge_mmac_stat_update(kstat_t *ksp, int rw)
1100 {
1101 p_nxge_t nxgep;
1102 p_nxge_mmac_kstat_t mmac_kstatsp;
1103 p_nxge_mmac_stats_t statsp;
1104
1105 nxgep = (p_nxge_t)ksp->ks_private;
1106 if (nxgep == NULL)
1107 return (-1);
1108
1109 NXGE_DEBUG_MSG((nxgep, KST_CTL, "==> nxge_mmac_stat_update"));
1110
1111 mmac_kstatsp = (p_nxge_mmac_kstat_t)ksp->ks_data;
1112 statsp = (p_nxge_mmac_stats_t)&nxgep->statsp->mmac_stats;
1113
1114 if (rw == KSTAT_WRITE) {
1115 cmn_err(CE_WARN, "Can not write mmac stats");
1116 } else {
1117 mmac_kstatsp->mmac_max_addr_cnt.value.ul =
1118 statsp->mmac_max_cnt;
1119 mmac_kstatsp->mmac_avail_addr_cnt.value.ul =
1120 statsp->mmac_avail_cnt;
1121 mmac_kstatsp->mmac_addr1.value.ul =
1122 nxge_mac_octet_to_u64(statsp->mmac_avail_pool[0]);
1123 mmac_kstatsp->mmac_addr2.value.ul =
1124 nxge_mac_octet_to_u64(statsp->mmac_avail_pool[1]);
1125 mmac_kstatsp->mmac_addr3.value.ul =
1126 nxge_mac_octet_to_u64(statsp->mmac_avail_pool[2]);
1127 mmac_kstatsp->mmac_addr4.value.ul =
1128 nxge_mac_octet_to_u64(statsp->mmac_avail_pool[3]);
1129 mmac_kstatsp->mmac_addr5.value.ul =
1130 nxge_mac_octet_to_u64(statsp->mmac_avail_pool[4]);
1131 mmac_kstatsp->mmac_addr6.value.ul =
1132 nxge_mac_octet_to_u64(statsp->mmac_avail_pool[5]);
1133 mmac_kstatsp->mmac_addr7.value.ul =
1134 nxge_mac_octet_to_u64(statsp->mmac_avail_pool[6]);
1135 mmac_kstatsp->mmac_addr8.value.ul =
1136 nxge_mac_octet_to_u64(statsp->mmac_avail_pool[7]);
1137 mmac_kstatsp->mmac_addr9.value.ul =
1138 nxge_mac_octet_to_u64(statsp->mmac_avail_pool[8]);
1139 mmac_kstatsp->mmac_addr10.value.ul =
1140 nxge_mac_octet_to_u64(statsp->mmac_avail_pool[9]);
1141 mmac_kstatsp->mmac_addr11.value.ul =
1142 nxge_mac_octet_to_u64(statsp->mmac_avail_pool[10]);
1143 mmac_kstatsp->mmac_addr12.value.ul =
1144 nxge_mac_octet_to_u64(statsp->mmac_avail_pool[11]);
1145 mmac_kstatsp->mmac_addr13.value.ul =
1146 nxge_mac_octet_to_u64(statsp->mmac_avail_pool[12]);
1147 mmac_kstatsp->mmac_addr14.value.ul =
1148 nxge_mac_octet_to_u64(statsp->mmac_avail_pool[13]);
1149 mmac_kstatsp->mmac_addr15.value.ul =
1150 nxge_mac_octet_to_u64(statsp->mmac_avail_pool[14]);
1151 mmac_kstatsp->mmac_addr16.value.ul =
1152 nxge_mac_octet_to_u64(statsp->mmac_avail_pool[15]);
1153 }
1154 NXGE_DEBUG_MSG((nxgep, KST_CTL, "<== nxge_mmac_stat_update"));
1155 return (0);
1156 }
1157
1158 /* ARGSUSED */
1159 static kstat_t *
nxge_setup_local_kstat(p_nxge_t nxgep,int instance,char * name,const nxge_kstat_index_t * ksip,size_t count,int (* update)(kstat_t *,int))1160 nxge_setup_local_kstat(p_nxge_t nxgep, int instance, char *name,
1161 const nxge_kstat_index_t *ksip, size_t count,
1162 int (*update) (kstat_t *, int))
1163 {
1164 kstat_t *ksp;
1165 kstat_named_t *knp;
1166 int i;
1167
1168 ksp = kstat_create(NXGE_DRIVER_NAME, instance, name, "net",
1169 KSTAT_TYPE_NAMED, count, 0);
1170 if (ksp == NULL)
1171 return (NULL);
1172
1173 ksp->ks_private = (void *)nxgep;
1174 ksp->ks_update = update;
1175 knp = ksp->ks_data;
1176
1177 for (i = 0; ksip[i].name != NULL; i++) {
1178 kstat_named_init(&knp[i], ksip[i].name, ksip[i].type);
1179 }
1180
1181 kstat_install(ksp);
1182 return (ksp);
1183 }
1184
1185 /* ARGSUSED */
1186 void
nxge_setup_rdc_kstats(p_nxge_t nxgep,int channel)1187 nxge_setup_rdc_kstats(p_nxge_t nxgep, int channel)
1188 {
1189 char stat_name[64];
1190
1191 /* Setup RDC statistics */
1192 (void) sprintf(stat_name, "%s" CH_NAME_FORMAT,
1193 RDC_NAME_FORMAT1, channel);
1194 nxgep->statsp->rdc_ksp[channel] = nxge_setup_local_kstat(nxgep,
1195 nxgep->instance,
1196 stat_name,
1197 nxge_rdc_stats,
1198 RDC_STAT_END,
1199 nxge_rdc_stat_update);
1200 #ifdef NXGE_DEBUG_ERROR
1201 if (nxgep->statsp->rdc_ksp[channel] == NULL)
1202 NXGE_DEBUG_MSG((nxgep, KST_CTL,
1203 "kstat_create failed for rdc channel %d", channel));
1204 #endif
1205 }
1206
1207 void
nxge_setup_tdc_kstats(p_nxge_t nxgep,int channel)1208 nxge_setup_tdc_kstats(p_nxge_t nxgep, int channel)
1209 {
1210 char stat_name[64];
1211
1212 /* Setup TDC statistics */
1213 (void) sprintf(stat_name, "%s" CH_NAME_FORMAT,
1214 TDC_NAME_FORMAT1, channel);
1215 nxgep->statsp->tdc_ksp[channel] = nxge_setup_local_kstat(nxgep,
1216 nxgep->instance,
1217 stat_name,
1218 nxge_tdc_stats,
1219 TDC_STAT_END,
1220 nxge_tdc_stat_update);
1221 #ifdef NXGE_DEBUG_ERROR
1222 if (nxgep->statsp->tdc_ksp[channel] == NULL) {
1223 NXGE_DEBUG_MSG((nxgep, KST_CTL,
1224 "kstat_create failed for tdc channel %d", channel));
1225 }
1226 #endif
1227 }
1228
1229 void
nxge_setup_kstats(p_nxge_t nxgep)1230 nxge_setup_kstats(p_nxge_t nxgep)
1231 {
1232 struct kstat *ksp;
1233 p_nxge_port_kstat_t nxgekp;
1234 size_t nxge_kstat_sz;
1235 char mmac_name[64];
1236
1237 NXGE_DEBUG_MSG((nxgep, KST_CTL, "==> nxge_setup_kstats"));
1238
1239 /* Setup RDC System statistics */
1240 nxgep->statsp->rdc_sys_ksp = nxge_setup_local_kstat(nxgep,
1241 nxgep->instance,
1242 "RDC System Stats",
1243 &nxge_rdc_sys_stats[0],
1244 RDC_SYS_STAT_END,
1245 nxge_rdc_sys_stat_update);
1246
1247 /* Setup IPP statistics */
1248 nxgep->statsp->ipp_ksp = nxge_setup_local_kstat(nxgep,
1249 nxgep->instance,
1250 "IPP Stats",
1251 &nxge_ipp_stats[0],
1252 IPP_STAT_END,
1253 nxge_ipp_stat_update);
1254 #ifdef NXGE_DEBUG_ERROR
1255 if (nxgep->istatsp->pp_ksp == NULL)
1256 NXGE_DEBUG_MSG((nxgep, KST_CTL, "kstat_create failed for ipp"));
1257 #endif
1258
1259 /* Setup TXC statistics */
1260 nxgep->statsp->txc_ksp = nxge_setup_local_kstat(nxgep,
1261 nxgep->instance, "TXC Stats", &nxge_txc_stats[0],
1262 TXC_STAT_END, nxge_txc_stat_update);
1263 #ifdef NXGE_DEBUG_ERROR
1264 if (nxgep->statsp->txc_ksp == NULL)
1265 NXGE_DEBUG_MSG((nxgep, KST_CTL, "kstat_create failed for txc"));
1266 #endif
1267
1268 /* Setup ZCP statistics */
1269 nxgep->statsp->zcp_ksp = nxge_setup_local_kstat(nxgep,
1270 nxgep->instance, "ZCP Stats", &nxge_zcp_stats[0],
1271 ZCP_STAT_END, nxge_zcp_stat_update);
1272 #ifdef NXGE_DEBUG_ERROR
1273 if (nxgep->statsp->zcp_ksp == NULL)
1274 NXGE_DEBUG_MSG((nxgep, KST_CTL, "kstat_create failed for zcp"));
1275 #endif
1276
1277 /* Setup FFLP statistics */
1278 nxgep->statsp->fflp_ksp[0] = nxge_setup_local_kstat(nxgep,
1279 nxgep->instance, "FFLP Stats", &nxge_fflp_stats[0],
1280 FFLP_STAT_END, nxge_fflp_stat_update);
1281
1282 #ifdef NXGE_DEBUG_ERROR
1283 if (nxgep->statsp->fflp_ksp == NULL)
1284 NXGE_DEBUG_MSG((nxgep, KST_CTL,
1285 "kstat_create failed for fflp"));
1286 #endif
1287
1288 (void) sprintf(mmac_name, "MMAC Stats%d", nxgep->instance);
1289 nxgep->statsp->mmac_ksp = nxge_setup_local_kstat(nxgep,
1290 nxgep->instance, "MMAC Stats", &nxge_mmac_stats[0],
1291 MMAC_STATS_END, nxge_mmac_stat_update);
1292
1293 nxge_kstat_sz = sizeof (nxge_port_kstat_t) +
1294 sizeof (nxge_mac_kstat_t) - sizeof (kstat_named_t);
1295
1296 if ((ksp = kstat_create(NXGE_DRIVER_NAME, nxgep->instance,
1297 "Port Stats", "net", KSTAT_TYPE_NAMED,
1298 nxge_kstat_sz / sizeof (kstat_named_t), 0)) == NULL) {
1299 NXGE_DEBUG_MSG((nxgep, KST_CTL, "kstat_create failed"));
1300 NXGE_DEBUG_MSG((nxgep, KST_CTL, "<== nxge_setup_kstats"));
1301 return;
1302 }
1303
1304 /*
1305 * kstats
1306 */
1307 nxgekp = (p_nxge_port_kstat_t)ksp->ks_data;
1308
1309 /*
1310 * transceiver state informations.
1311 */
1312 kstat_named_init(&nxgekp->xcvr_inits, "xcvr_inits",
1313 KSTAT_DATA_ULONG);
1314 kstat_named_init(&nxgekp->xcvr_inuse, "xcvr_inuse",
1315 KSTAT_DATA_ULONG);
1316 kstat_named_init(&nxgekp->xcvr_addr, "xcvr_addr",
1317 KSTAT_DATA_ULONG);
1318 kstat_named_init(&nxgekp->xcvr_id, "xcvr_id",
1319 KSTAT_DATA_ULONG);
1320 kstat_named_init(&nxgekp->cap_autoneg, "cap_autoneg",
1321 KSTAT_DATA_ULONG);
1322 kstat_named_init(&nxgekp->cap_10gfdx, "cap_10gfdx",
1323 KSTAT_DATA_ULONG);
1324 kstat_named_init(&nxgekp->cap_10ghdx, "cap_10ghdx",
1325 KSTAT_DATA_ULONG);
1326 kstat_named_init(&nxgekp->cap_1000fdx, "cap_1000fdx",
1327 KSTAT_DATA_ULONG);
1328 kstat_named_init(&nxgekp->cap_1000hdx, "cap_1000hdx",
1329 KSTAT_DATA_ULONG);
1330 kstat_named_init(&nxgekp->cap_100T4, "cap_100T4",
1331 KSTAT_DATA_ULONG);
1332 kstat_named_init(&nxgekp->cap_100fdx, "cap_100fdx",
1333 KSTAT_DATA_ULONG);
1334 kstat_named_init(&nxgekp->cap_100hdx, "cap_100hdx",
1335 KSTAT_DATA_ULONG);
1336 kstat_named_init(&nxgekp->cap_10fdx, "cap_10fdx",
1337 KSTAT_DATA_ULONG);
1338 kstat_named_init(&nxgekp->cap_10hdx, "cap_10hdx",
1339 KSTAT_DATA_ULONG);
1340 kstat_named_init(&nxgekp->cap_asmpause, "cap_asmpause",
1341 KSTAT_DATA_ULONG);
1342 kstat_named_init(&nxgekp->cap_pause, "cap_pause",
1343 KSTAT_DATA_ULONG);
1344
1345 /*
1346 * Link partner capabilities.
1347 */
1348 kstat_named_init(&nxgekp->lp_cap_autoneg, "lp_cap_autoneg",
1349 KSTAT_DATA_ULONG);
1350 kstat_named_init(&nxgekp->lp_cap_10gfdx, "lp_cap_10gfdx",
1351 KSTAT_DATA_ULONG);
1352 kstat_named_init(&nxgekp->lp_cap_10ghdx, "lp_cap_10ghdx",
1353 KSTAT_DATA_ULONG);
1354 kstat_named_init(&nxgekp->lp_cap_1000fdx, "lp_cap_1000fdx",
1355 KSTAT_DATA_ULONG);
1356 kstat_named_init(&nxgekp->lp_cap_1000hdx, "lp_cap_1000hdx",
1357 KSTAT_DATA_ULONG);
1358 kstat_named_init(&nxgekp->lp_cap_100T4, "lp_cap_100T4",
1359 KSTAT_DATA_ULONG);
1360 kstat_named_init(&nxgekp->lp_cap_100fdx, "lp_cap_100fdx",
1361 KSTAT_DATA_ULONG);
1362 kstat_named_init(&nxgekp->lp_cap_100hdx, "lp_cap_100hdx",
1363 KSTAT_DATA_ULONG);
1364 kstat_named_init(&nxgekp->lp_cap_10fdx, "lp_cap_10fdx",
1365 KSTAT_DATA_ULONG);
1366 kstat_named_init(&nxgekp->lp_cap_10hdx, "lp_cap_10hdx",
1367 KSTAT_DATA_ULONG);
1368 kstat_named_init(&nxgekp->lp_cap_asmpause, "lp_cap_asmpause",
1369 KSTAT_DATA_ULONG);
1370 kstat_named_init(&nxgekp->lp_cap_pause, "lp_cap_pause",
1371 KSTAT_DATA_ULONG);
1372 /*
1373 * Shared link setup.
1374 */
1375 kstat_named_init(&nxgekp->link_T4, "link_T4",
1376 KSTAT_DATA_ULONG);
1377 kstat_named_init(&nxgekp->link_speed, "link_speed",
1378 KSTAT_DATA_ULONG);
1379 kstat_named_init(&nxgekp->link_duplex, "link_duplex",
1380 KSTAT_DATA_CHAR);
1381 kstat_named_init(&nxgekp->link_asmpause, "link_asmpause",
1382 KSTAT_DATA_ULONG);
1383 kstat_named_init(&nxgekp->link_pause, "link_pause",
1384 KSTAT_DATA_ULONG);
1385 kstat_named_init(&nxgekp->link_up, "link_up",
1386 KSTAT_DATA_ULONG);
1387
1388 /*
1389 * Let the user know the MTU currently in use by the physical MAC
1390 * port.
1391 */
1392 kstat_named_init(&nxgekp->mac_mtu, "mac_mtu",
1393 KSTAT_DATA_ULONG);
1394
1395 /*
1396 * Loopback statistics.
1397 */
1398 kstat_named_init(&nxgekp->lb_mode, "lb_mode",
1399 KSTAT_DATA_ULONG);
1400
1401 /*
1402 * This tells the user whether the driver is in QOS mode or not.
1403 */
1404 kstat_named_init(&nxgekp->qos_mode, "qos_mode",
1405 KSTAT_DATA_ULONG);
1406
1407 /*
1408 * This tells whether the instance is trunked or not
1409 */
1410 kstat_named_init(&nxgekp->trunk_mode, "trunk_mode",
1411 KSTAT_DATA_ULONG);
1412
1413 #if defined MULTI_DATA_TX || defined MULTI_DATA_TXV2
1414 kstat_named_init(&nxgekp->mdt_reqs, "mdt_reqs",
1415 KSTAT_DATA_ULONG);
1416 kstat_named_init(&nxgekp->mdt_hdr_bufs, "mdt_hdr_bufs",
1417 KSTAT_DATA_ULONG);
1418 kstat_named_init(&nxgekp->mdt_pld_bufs, "mdt_pld_bufs",
1419 KSTAT_DATA_ULONG);
1420 kstat_named_init(&nxgekp->mdt_pkts, "mdt_pkts",
1421 KSTAT_DATA_ULONG);
1422 kstat_named_init(&nxgekp->mdt_hdrs, "mdt_hdrs",
1423 KSTAT_DATA_ULONG);
1424 kstat_named_init(&nxgekp->mdt_plds, "mdt_plds",
1425 KSTAT_DATA_ULONG);
1426 kstat_named_init(&nxgekp->mdt_hdr_bind_fail, "mdt_hdr_bind_fail",
1427 KSTAT_DATA_ULONG);
1428 kstat_named_init(&nxgekp->mdt_pld_bind_fail, "mdt_pld_bind_fail",
1429 KSTAT_DATA_ULONG);
1430 #endif
1431 #ifdef ACCEPT_JUMBO
1432 kstat_named_init(&nxgekp->tx_jumbo_pkts, "tx_jumbo_pkts",
1433 KSTAT_DATA_ULONG);
1434 #endif
1435
1436 /*
1437 * Rx Statistics.
1438 */
1439 #ifdef ACCEPT_JUMBO
1440 kstat_named_init(&nxgekp->rx_jumbo_pkts, "rx_jumbo_pkts",
1441 KSTAT_DATA_ULONG);
1442 #endif
1443 /* General MAC statistics */
1444 kstat_named_init(&nxgekp->ifspeed, "ifspeed",
1445 KSTAT_DATA_UINT64);
1446 kstat_named_init(&nxgekp->promisc, "promisc",
1447 KSTAT_DATA_CHAR);
1448 kstat_named_init(&nxgekp->rev_id, "rev_id",
1449 KSTAT_DATA_ULONG);
1450
1451 ksp->ks_update = nxge_port_kstat_update;
1452 ksp->ks_private = (void *) nxgep;
1453 if (nxgep->mac.porttype == PORT_TYPE_XMAC)
1454 nxge_xmac_init_kstats(ksp);
1455 else
1456 nxge_bmac_init_kstats(ksp);
1457 kstat_install(ksp);
1458 nxgep->statsp->port_ksp = ksp;
1459 NXGE_DEBUG_MSG((nxgep, KST_CTL, "<== nxge_setup_kstats"));
1460 }
1461
1462 /* ARGSUSED */
1463 void
nxge_xmac_init_kstats(struct kstat * ksp)1464 nxge_xmac_init_kstats(struct kstat *ksp)
1465 {
1466 p_nxge_xmac_kstat_t nxgekp;
1467
1468 nxgekp = (p_nxge_xmac_kstat_t)ksp->ks_data;
1469
1470 /*
1471 * Transmit MAC statistics.
1472 */
1473 kstat_named_init(&nxgekp->tx_frame_cnt, "txmac_frame_cnt",
1474 KSTAT_DATA_ULONG);
1475 kstat_named_init(&nxgekp->tx_underflow_err, "txmac_underflow_err",
1476 KSTAT_DATA_ULONG);
1477 kstat_named_init(&nxgekp->tx_overflow_err, "txmac_overflow_err",
1478 KSTAT_DATA_ULONG);
1479 kstat_named_init(&nxgekp->tx_maxpktsize_err, "txmac_maxpktsize_err",
1480 KSTAT_DATA_ULONG);
1481 kstat_named_init(&nxgekp->tx_fifo_xfr_err, "txmac_fifo_xfr_err",
1482 KSTAT_DATA_ULONG);
1483 kstat_named_init(&nxgekp->tx_byte_cnt, "txmac_byte_cnt",
1484 KSTAT_DATA_ULONG);
1485
1486 /* Receive MAC statistics */
1487 kstat_named_init(&nxgekp->rx_frame_cnt, "rxmac_frame_cnt",
1488 KSTAT_DATA_ULONG);
1489 kstat_named_init(&nxgekp->rx_overflow_err, "rxmac_overflow_err",
1490 KSTAT_DATA_ULONG);
1491 kstat_named_init(&nxgekp->rx_underflow_err, "rxmac_underflow_err",
1492 KSTAT_DATA_ULONG);
1493 kstat_named_init(&nxgekp->rx_crc_err_cnt, "rxmac_crc_err",
1494 KSTAT_DATA_ULONG);
1495 kstat_named_init(&nxgekp->rx_len_err_cnt, "rxmac_length_err",
1496 KSTAT_DATA_ULONG);
1497 kstat_named_init(&nxgekp->rx_viol_err_cnt, "rxmac_code_violations",
1498 KSTAT_DATA_ULONG);
1499 kstat_named_init(&nxgekp->rx_byte_cnt, "rxmac_byte_cnt",
1500 KSTAT_DATA_ULONG);
1501 kstat_named_init(&nxgekp->rx_frame_align_err_cnt,
1502 "rxmac_alignment_err",
1503 KSTAT_DATA_ULONG);
1504 kstat_named_init(&nxgekp->rx_hist1_cnt, "rxmac_64_cnt",
1505 KSTAT_DATA_ULONG);
1506 kstat_named_init(&nxgekp->rx_hist2_cnt, "rxmac_65_127_cnt",
1507 KSTAT_DATA_ULONG);
1508 kstat_named_init(&nxgekp->rx_hist3_cnt, "rxmac_128_255_cnt",
1509 KSTAT_DATA_ULONG);
1510 kstat_named_init(&nxgekp->rx_hist4_cnt, "rxmac_256_511_cnt",
1511 KSTAT_DATA_ULONG);
1512 kstat_named_init(&nxgekp->rx_hist5_cnt, "rxmac_512_1023_cnt",
1513 KSTAT_DATA_ULONG);
1514 kstat_named_init(&nxgekp->rx_hist6_cnt, "rxmac_1024_1522_cnt",
1515 KSTAT_DATA_ULONG);
1516 kstat_named_init(&nxgekp->rx_hist7_cnt, "rxmac_jumbo_cnt",
1517 KSTAT_DATA_ULONG);
1518 kstat_named_init(&nxgekp->rx_broadcast_cnt, "rxmac_broadcast_cnt",
1519 KSTAT_DATA_ULONG);
1520 kstat_named_init(&nxgekp->rx_mult_cnt, "rxmac_multicast_cnt",
1521 KSTAT_DATA_ULONG);
1522 kstat_named_init(&nxgekp->rx_frag_cnt, "rxmac_fragment_cnt",
1523 KSTAT_DATA_ULONG);
1524 kstat_named_init(&nxgekp->rx_linkfault_err_cnt, "rxmac_linkfault_errs",
1525 KSTAT_DATA_ULONG);
1526 kstat_named_init(&nxgekp->rx_remote_fault_err_cnt,
1527 "rxmac_remote_faults",
1528 KSTAT_DATA_ULONG);
1529 kstat_named_init(&nxgekp->rx_local_fault_err_cnt, "rxmac_local_faults",
1530 KSTAT_DATA_ULONG);
1531
1532 /* XPCS statistics */
1533
1534 kstat_named_init(&nxgekp->xpcs_deskew_err_cnt, "xpcs_deskew_err_cnt",
1535 KSTAT_DATA_ULONG);
1536 #ifdef NXGE_DEBUG_SYMBOL_ERR
1537 kstat_named_init(&nxgekp->xpcs_ln0_symbol_err_cnt,
1538 "xpcs_ln0_symbol_err_cnt",
1539 KSTAT_DATA_ULONG);
1540 kstat_named_init(&nxgekp->xpcs_ln1_symbol_err_cnt,
1541 "xpcs_ln1_symbol_err_cnt",
1542 KSTAT_DATA_ULONG);
1543 kstat_named_init(&nxgekp->xpcs_ln2_symbol_err_cnt,
1544 "xpcs_ln2_symbol_err_cnt",
1545 KSTAT_DATA_ULONG);
1546 kstat_named_init(&nxgekp->xpcs_ln3_symbol_err_cnt,
1547 "xpcs_ln3_symbol_err_cnt",
1548 KSTAT_DATA_ULONG);
1549 #endif
1550 }
1551
1552 /* ARGSUSED */
1553 void
nxge_bmac_init_kstats(struct kstat * ksp)1554 nxge_bmac_init_kstats(struct kstat *ksp)
1555 {
1556 p_nxge_bmac_kstat_t nxgekp;
1557
1558 nxgekp = (p_nxge_bmac_kstat_t)ksp->ks_data;
1559
1560 /*
1561 * Transmit MAC statistics.
1562 */
1563 kstat_named_init(&nxgekp->tx_frame_cnt, "txmac_frame_cnt",
1564 KSTAT_DATA_ULONG);
1565 kstat_named_init(&nxgekp->tx_underrun_err, "txmac_underflow_err",
1566 KSTAT_DATA_ULONG);
1567 kstat_named_init(&nxgekp->tx_max_pkt_err, "txmac_maxpktsize_err",
1568 KSTAT_DATA_ULONG);
1569 kstat_named_init(&nxgekp->tx_byte_cnt, "txmac_byte_cnt",
1570 KSTAT_DATA_ULONG);
1571
1572 /* Receive MAC statistics */
1573 kstat_named_init(&nxgekp->rx_overflow_err, "rxmac_overflow_err",
1574 KSTAT_DATA_ULONG);
1575 kstat_named_init(&nxgekp->rx_crc_err_cnt, "rxmac_crc_err",
1576 KSTAT_DATA_ULONG);
1577 kstat_named_init(&nxgekp->rx_len_err_cnt, "rxmac_length_err",
1578 KSTAT_DATA_ULONG);
1579 kstat_named_init(&nxgekp->rx_viol_err_cnt, "rxmac_code_violations",
1580 KSTAT_DATA_ULONG);
1581 kstat_named_init(&nxgekp->rx_byte_cnt, "rxmac_byte_cnt",
1582 KSTAT_DATA_ULONG);
1583 kstat_named_init(&nxgekp->rx_align_err_cnt, "rxmac_alignment_err",
1584 KSTAT_DATA_ULONG);
1585 kstat_named_init(&nxgekp->rx_frame_cnt, "rxmac_frame_cnt",
1586 KSTAT_DATA_ULONG);
1587 }
1588
1589 /* ARGSUSED */
1590 void
nxge_mac_init_kstats(p_nxge_t nxgep,struct kstat * ksp)1591 nxge_mac_init_kstats(p_nxge_t nxgep, struct kstat *ksp)
1592 {
1593 p_nxge_mac_kstat_t nxgekp;
1594
1595 nxgekp = (p_nxge_mac_kstat_t)ksp->ks_data;
1596
1597 /*
1598 * Transmit MAC statistics.
1599 */
1600 kstat_named_init(&nxgekp->tx_frame_cnt, "txmac_frame_cnt",
1601 KSTAT_DATA_ULONG);
1602 kstat_named_init(&nxgekp->tx_underflow_err, "txmac_underflow_err",
1603 KSTAT_DATA_ULONG);
1604 kstat_named_init(&nxgekp->tx_overflow_err, "txmac_overflow_err",
1605 KSTAT_DATA_ULONG);
1606 kstat_named_init(&nxgekp->tx_maxpktsize_err, "txmac_maxpktsize_err",
1607 KSTAT_DATA_ULONG);
1608 kstat_named_init(&nxgekp->tx_fifo_xfr_err, "txmac_fifo_xfr_err",
1609 KSTAT_DATA_ULONG);
1610 kstat_named_init(&nxgekp->tx_byte_cnt, "txmac_byte_cnt",
1611 KSTAT_DATA_ULONG);
1612
1613 /*
1614 * Receive MAC statistics
1615 */
1616 kstat_named_init(&nxgekp->rx_overflow_err, "rxmac_overflow_err",
1617 KSTAT_DATA_ULONG);
1618 kstat_named_init(&nxgekp->rx_underflow_err, "rxmac_underflow_err",
1619 KSTAT_DATA_ULONG);
1620 kstat_named_init(&nxgekp->rx_crc_err_cnt, "rxmac_crc_err",
1621 KSTAT_DATA_ULONG);
1622 kstat_named_init(&nxgekp->rx_len_err_cnt, "rxmac_length_err",
1623 KSTAT_DATA_ULONG);
1624 kstat_named_init(&nxgekp->rx_viol_err_cnt, "rxmac_code_violations",
1625 KSTAT_DATA_ULONG);
1626 kstat_named_init(&nxgekp->rx_byte_cnt, "rxmac_byte_cnt",
1627 KSTAT_DATA_ULONG);
1628 kstat_named_init(&nxgekp->rx_frame_align_err_cnt,
1629 "rxmac_alignment_err",
1630 KSTAT_DATA_ULONG);
1631 kstat_named_init(&nxgekp->rx_frame_cnt, "rxmac_frame_cnt",
1632 KSTAT_DATA_ULONG);
1633 if (nxgep->mac.porttype == PORT_TYPE_XMAC) {
1634 kstat_named_init(&nxgekp->rx_hist1_cnt, "rxmac_64_cnt",
1635 KSTAT_DATA_ULONG);
1636 kstat_named_init(&nxgekp->rx_hist2_cnt, "rxmac_65_127_cnt",
1637 KSTAT_DATA_ULONG);
1638 kstat_named_init(&nxgekp->rx_hist3_cnt, "rxmac_128_255_cnt",
1639 KSTAT_DATA_ULONG);
1640 kstat_named_init(&nxgekp->rx_hist4_cnt, "rxmac_256_511_cnt",
1641 KSTAT_DATA_ULONG);
1642 kstat_named_init(&nxgekp->rx_hist5_cnt, "rxmac_512_1023_cnt",
1643 KSTAT_DATA_ULONG);
1644 kstat_named_init(&nxgekp->rx_hist6_cnt, "rxmac_1024_1522_cnt",
1645 KSTAT_DATA_ULONG);
1646 kstat_named_init(&nxgekp->rx_hist7_cnt, "rxmac_jumbo_cnt",
1647 KSTAT_DATA_ULONG);
1648 kstat_named_init(&nxgekp->rx_broadcast_cnt,
1649 "rxmac_broadcast_cnt",
1650 KSTAT_DATA_ULONG);
1651 kstat_named_init(&nxgekp->rx_mult_cnt, "rxmac_multicast_cnt",
1652 KSTAT_DATA_ULONG);
1653 kstat_named_init(&nxgekp->rx_frag_cnt, "rxmac_fragment_cnt",
1654 KSTAT_DATA_ULONG);
1655 kstat_named_init(&nxgekp->rx_linkfault_err_cnt,
1656 "rxmac_linkfault_errs",
1657 KSTAT_DATA_ULONG);
1658 kstat_named_init(&nxgekp->rx_remote_fault_err_cnt,
1659 "rxmac_remote_faults",
1660 KSTAT_DATA_ULONG);
1661 kstat_named_init(&nxgekp->rx_local_fault_err_cnt,
1662 "rxmac_local_faults",
1663 KSTAT_DATA_ULONG);
1664 }
1665 }
1666
1667 /* ARGSUSED */
1668 void
nxge_destroy_kstats(p_nxge_t nxgep)1669 nxge_destroy_kstats(p_nxge_t nxgep)
1670 {
1671 NXGE_DEBUG_MSG((nxgep, KST_CTL, "==> nxge_destroy_kstats"));
1672
1673 if (nxgep->statsp == NULL)
1674 return;
1675 if (nxgep->statsp->ksp)
1676 kstat_delete(nxgep->statsp->ksp);
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
nxge_port_kstat_update(kstat_t * ksp,int rw)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 ACCEPT_JUMBO
1746 statsp->port_stats.rx_jumbo_pkts =
1747 nxgekp->rx_jumbo_pkts.value.ul;
1748 #endif
1749 if (nxgep->mac.porttype == PORT_TYPE_XMAC) {
1750 (void) nxge_xmac_stat_update(ksp, KSTAT_WRITE);
1751 } else {
1752 (void) nxge_bmac_stat_update(ksp, KSTAT_WRITE);
1753 }
1754 return (0);
1755 } else {
1756 if (nxgep->filter.all_phys_cnt)
1757 (void) strcpy(nxgekp->promisc.value.c, "phys");
1758 else if (nxgep->filter.all_multicast_cnt)
1759 (void) strcpy(nxgekp->promisc.value.c, "multi");
1760 else
1761 (void) strcpy(nxgekp->promisc.value.c, "off");
1762 nxgekp->ifspeed.value.ul =
1763 statsp->mac_stats.link_speed * 1000000ULL;
1764 nxgekp->rev_id.value.ul = statsp->mac_stats.rev_id;
1765
1766 /*
1767 * transceiver state informations.
1768 */
1769 nxgekp->xcvr_inits.value.ul = statsp->mac_stats.xcvr_inits;
1770 nxgekp->xcvr_inuse.value.ul = statsp->mac_stats.xcvr_inuse;
1771 nxgekp->xcvr_addr.value.ul = statsp->mac_stats.xcvr_portn;
1772 nxgekp->xcvr_id.value.ul = statsp->mac_stats.xcvr_id;
1773 nxgekp->cap_autoneg.value.ul = statsp->mac_stats.cap_autoneg;
1774 nxgekp->cap_10gfdx.value.ul = statsp->mac_stats.cap_10gfdx;
1775 nxgekp->cap_10ghdx.value.ul = statsp->mac_stats.cap_10ghdx;
1776 nxgekp->cap_1000fdx.value.ul = statsp->mac_stats.cap_1000fdx;
1777 nxgekp->cap_1000hdx.value.ul = statsp->mac_stats.cap_1000hdx;
1778 nxgekp->cap_100T4.value.ul = statsp->mac_stats.cap_100T4;
1779 nxgekp->cap_100fdx.value.ul = statsp->mac_stats.cap_100fdx;
1780 nxgekp->cap_100hdx.value.ul = statsp->mac_stats.cap_100hdx;
1781 nxgekp->cap_10fdx.value.ul = statsp->mac_stats.cap_10fdx;
1782 nxgekp->cap_10hdx.value.ul = statsp->mac_stats.cap_10hdx;
1783 nxgekp->cap_asmpause.value.ul =
1784 statsp->mac_stats.cap_asmpause;
1785 nxgekp->cap_pause.value.ul = statsp->mac_stats.cap_pause;
1786
1787 /*
1788 * Link partner capabilities.
1789 */
1790 nxgekp->lp_cap_autoneg.value.ul =
1791 statsp->mac_stats.lp_cap_autoneg;
1792 nxgekp->lp_cap_10gfdx.value.ul =
1793 statsp->mac_stats.lp_cap_10gfdx;
1794 nxgekp->lp_cap_10ghdx.value.ul =
1795 statsp->mac_stats.lp_cap_10ghdx;
1796 nxgekp->lp_cap_1000fdx.value.ul =
1797 statsp->mac_stats.lp_cap_1000fdx;
1798 nxgekp->lp_cap_1000hdx.value.ul =
1799 statsp->mac_stats.lp_cap_1000hdx;
1800 nxgekp->lp_cap_100T4.value.ul =
1801 statsp->mac_stats.lp_cap_100T4;
1802 nxgekp->lp_cap_100fdx.value.ul =
1803 statsp->mac_stats.lp_cap_100fdx;
1804 nxgekp->lp_cap_100hdx.value.ul =
1805 statsp->mac_stats.lp_cap_100hdx;
1806 nxgekp->lp_cap_10fdx.value.ul =
1807 statsp->mac_stats.lp_cap_10fdx;
1808 nxgekp->lp_cap_10hdx.value.ul =
1809 statsp->mac_stats.lp_cap_10hdx;
1810 nxgekp->lp_cap_asmpause.value.ul =
1811 statsp->mac_stats.lp_cap_asmpause;
1812 nxgekp->lp_cap_pause.value.ul =
1813 statsp->mac_stats.lp_cap_pause;
1814
1815 /*
1816 * Physical link statistics.
1817 */
1818 nxgekp->link_T4.value.ul = statsp->mac_stats.link_T4;
1819 nxgekp->link_speed.value.ul = statsp->mac_stats.link_speed;
1820 if (statsp->mac_stats.link_duplex == 2)
1821 (void) strcpy(nxgekp->link_duplex.value.c, "full");
1822 else if (statsp->mac_stats.link_duplex == 1)
1823 (void) strcpy(nxgekp->link_duplex.value.c, "half");
1824 else
1825 (void) strcpy(nxgekp->link_duplex.value.c, "unknown");
1826 nxgekp->link_asmpause.value.ul =
1827 statsp->mac_stats.link_asmpause;
1828 nxgekp->link_pause.value.ul = statsp->mac_stats.link_pause;
1829 nxgekp->link_up.value.ul = statsp->mac_stats.link_up;
1830
1831 /*
1832 * Lets the user know the MTU currently in use by the physical
1833 * MAC port.
1834 */
1835 nxgekp->mac_mtu.value.ul = statsp->mac_stats.mac_mtu;
1836
1837 /*
1838 * Loopback statistics.
1839 */
1840 nxgekp->lb_mode.value.ul = statsp->port_stats.lb_mode;
1841
1842 /*
1843 * This tells the user whether the driver is in QOS mode or
1844 * not.
1845 */
1846 nxgekp->qos_mode.value.ul = statsp->port_stats.qos_mode;
1847
1848 /*
1849 * This tells whether the instance is trunked or not
1850 */
1851 nxgekp->trunk_mode.value.ul = statsp->port_stats.trunk_mode;
1852
1853 #if defined MULTI_DATA_TX || defined MULTI_DATA_TXV2
1854 nxgekp->mdt_reqs.value.ul = statsp->port_stats.mdt_reqs;
1855 nxgekp->mdt_hdr_bufs.value.ul =
1856 statsp->port_stats.mdt_hdr_bufs;
1857 nxgekp->mdt_pld_bufs.value.ul =
1858 statsp->port_stats.mdt_pld_bufs;
1859 nxgekp->mdt_pkts.value.ul = statsp->port_stats.mdt_pkts;
1860 nxgekp->mdt_hdrs.value.ul = statsp->port_stats.mdt_hdrs;
1861 nxgekp->mdt_plds.value.ul = statsp->port_stats.mdt_plds;
1862 nxgekp->mdt_hdr_bind_fail.value.ul =
1863 statsp->port_stats.mdt_hdr_bind_fail;
1864 nxgekp->mdt_pld_bind_fail.value.ul =
1865 statsp->port_stats.mdt_pld_bind_fail;
1866 #endif
1867 #ifdef ACCEPT_JUMBO
1868 nxgekp->tx_jumbo_pkts.value.ul =
1869 statsp->port_stats.tx_jumbo_pkts;
1870 #endif
1871 #ifdef TX_MBLK_DEST
1872 nxgekp->tx_1_desc.value.ul = statsp->port_stats.tx_1_desc;
1873 nxgekp->tx_2_desc.value.ul = statsp->port_stats.tx_2_desc;
1874 nxgekp->tx_3_desc.value.ul = statsp->port_stats.tx_3_desc;
1875 nxgekp->tx_4_desc.value.ul = statsp->port_stats.tx_4_desc;
1876 nxgekp->tx_5_desc.value.ul = statsp->port_stats.tx_5_desc;
1877 nxgekp->tx_6_desc.value.ul = statsp->port_stats.tx_6_desc;
1878 nxgekp->tx_7_desc.value.ul = statsp->port_stats.tx_7_desc;
1879 nxgekp->tx_8_desc.value.ul = statsp->port_stats.tx_8_desc;
1880 nxgekp->tx_max_desc.value.ul =
1881 statsp->port_stats.tx_max_desc;
1882 #endif
1883 /*
1884 * Rx Statistics.
1885 */
1886 #ifdef ACCEPT_JUMBO
1887 nxgekp->rx_jumbo_pkts.value.ul =
1888 statsp->port_stats.rx_jumbo_pkts;
1889 #endif
1890 if (nxgep->mac.porttype == PORT_TYPE_XMAC) {
1891 (void) nxge_xmac_stat_update(ksp, KSTAT_READ);
1892 } else {
1893 (void) nxge_bmac_stat_update(ksp, KSTAT_READ);
1894 }
1895 }
1896
1897 NXGE_DEBUG_MSG((nxgep, KST_CTL, "<== nxge_port_kstat_update"));
1898 return (0);
1899 }
1900
1901 /*
1902 * if this is the first init do not bother to save the
1903 * counters.
1904 */
1905 /* ARGSUSED */
1906 void
nxge_save_cntrs(p_nxge_t nxgep)1907 nxge_save_cntrs(p_nxge_t nxgep)
1908 {
1909 p_nxge_stats_t statsp;
1910 uint64_t val;
1911 npi_handle_t handle;
1912 uint8_t portn;
1913 uint8_t cnt8;
1914 uint16_t cnt16;
1915 uint32_t cnt32;
1916
1917 NXGE_DEBUG_MSG((nxgep, DDI_CTL, "==> nxge_save_cntrs"));
1918
1919 statsp = (p_nxge_stats_t)nxgep->statsp;
1920 handle = nxgep->npi_handle;
1921 portn = nxgep->mac.portnum;
1922
1923 MUTEX_ENTER(&nxgep->ouraddr_lock);
1924
1925 if (nxgep->mac.porttype == PORT_TYPE_XMAC) {
1926 /*
1927 * Transmit MAC statistics.
1928 */
1929 XMAC_REG_RD(handle, portn, XTXMAC_FRM_CNT_REG, &val);
1930 statsp->xmac_stats.tx_frame_cnt += (val & XTXMAC_FRM_CNT_MASK);
1931 XMAC_REG_RD(handle, portn, XTXMAC_BYTE_CNT_REG, &val);
1932 statsp->xmac_stats.tx_byte_cnt += (val & XTXMAC_BYTE_CNT_MASK);
1933 /*
1934 * Receive XMAC statistics.
1935 */
1936 XMAC_REG_RD(handle, portn, XRXMAC_CRC_ER_CNT_REG, &val);
1937 statsp->xmac_stats.rx_crc_err_cnt +=
1938 (val & XRXMAC_CRC_ER_CNT_MASK);
1939
1940 XMAC_REG_RD(handle, portn, XRXMAC_MPSZER_CNT_REG, &val);
1941 statsp->xmac_stats.rx_len_err_cnt +=
1942 (val & XRXMAC_MPSZER_CNT_MASK);
1943
1944 XMAC_REG_RD(handle, portn, XRXMAC_CD_VIO_CNT_REG, &val);
1945 statsp->xmac_stats.rx_viol_err_cnt +=
1946 (val & XRXMAC_CD_VIO_CNT_MASK);
1947
1948 XMAC_REG_RD(handle, portn, XRXMAC_BT_CNT_REG, &val);
1949 statsp->xmac_stats.rx_byte_cnt += (val & XRXMAC_BT_CNT_MASK);
1950
1951 XMAC_REG_RD(handle, portn, XRXMAC_HIST_CNT1_REG, &val);
1952 statsp->xmac_stats.rx_hist1_cnt +=
1953 (val & XRXMAC_HIST_CNT1_MASK);
1954 statsp->xmac_stats.rx_frame_cnt +=
1955 (val & XRXMAC_HIST_CNT1_MASK);
1956
1957 XMAC_REG_RD(handle, portn, XRXMAC_HIST_CNT2_REG, &val);
1958 statsp->xmac_stats.rx_hist2_cnt +=
1959 (val & XRXMAC_HIST_CNT2_MASK);
1960 statsp->xmac_stats.rx_frame_cnt +=
1961 (val & XRXMAC_HIST_CNT2_MASK);
1962
1963 XMAC_REG_RD(handle, portn, XRXMAC_HIST_CNT3_REG, &val);
1964 statsp->xmac_stats.rx_hist3_cnt +=
1965 (val & XRXMAC_HIST_CNT3_MASK);
1966 statsp->xmac_stats.rx_frame_cnt +=
1967 (val & XRXMAC_HIST_CNT3_MASK);
1968
1969 XMAC_REG_RD(handle, portn, XRXMAC_HIST_CNT4_REG, &val);
1970 statsp->xmac_stats.rx_hist4_cnt +=
1971 (val & XRXMAC_HIST_CNT4_MASK);
1972 statsp->xmac_stats.rx_frame_cnt +=
1973 (val & XRXMAC_HIST_CNT4_MASK);
1974
1975 XMAC_REG_RD(handle, portn, XRXMAC_HIST_CNT5_REG, &val);
1976 statsp->xmac_stats.rx_hist5_cnt +=
1977 (val & XRXMAC_HIST_CNT5_MASK);
1978 statsp->xmac_stats.rx_frame_cnt +=
1979 (val & XRXMAC_HIST_CNT5_MASK);
1980
1981 XMAC_REG_RD(handle, portn, XRXMAC_HIST_CNT6_REG, &val);
1982 statsp->xmac_stats.rx_hist6_cnt +=
1983 (val & XRXMAC_HIST_CNT6_MASK);
1984 statsp->xmac_stats.rx_frame_cnt +=
1985 (val & XRXMAC_HIST_CNT6_MASK);
1986
1987 XMAC_REG_RD(handle, portn, XRXMAC_HIST_CNT7_REG, &val);
1988 statsp->xmac_stats.rx_hist7_cnt +=
1989 (val & XRXMAC_HIST_CNT7_MASK);
1990 statsp->xmac_stats.rx_frame_cnt +=
1991 (val & XRXMAC_HIST_CNT7_MASK);
1992
1993 XMAC_REG_RD(handle, portn, XRXMAC_BC_FRM_CNT_REG, &val);
1994 statsp->xmac_stats.rx_broadcast_cnt +=
1995 (val & XRXMAC_BC_FRM_CNT_MASK);
1996
1997 XMAC_REG_RD(handle, portn, XRXMAC_MC_FRM_CNT_REG, &val);
1998 statsp->xmac_stats.rx_mult_cnt +=
1999 (val & XRXMAC_MC_FRM_CNT_MASK);
2000
2001 XMAC_REG_RD(handle, portn, XRXMAC_FRAG_CNT_REG, &val);
2002 statsp->xmac_stats.rx_frag_cnt += (val & XRXMAC_FRAG_CNT_MASK);
2003
2004 XMAC_REG_RD(handle, portn, XRXMAC_AL_ER_CNT_REG, &val);
2005 statsp->xmac_stats.rx_frame_align_err_cnt +=
2006 (val & XRXMAC_AL_ER_CNT_MASK);
2007
2008 XMAC_REG_RD(handle, portn, XMAC_LINK_FLT_CNT_REG, &val);
2009 statsp->xmac_stats.rx_linkfault_err_cnt +=
2010 (val & XMAC_LINK_FLT_CNT_MASK);
2011
2012 (void) npi_xmac_xpcs_read(handle, portn,
2013 XPCS_REG_DESCWERR_COUNTER, &cnt32);
2014 statsp->xmac_stats.xpcs_deskew_err_cnt +=
2015 (val & XMAC_XPCS_DESKEW_ERR_CNT_MASK);
2016
2017 #ifdef NXGE_DEBUG_SYMBOL_ERR
2018 (void) npi_xmac_xpcs_read(handle, portn,
2019 XPCS_REG_SYMBOL_ERR_L0_1_COUNTER, &cnt32);
2020 statsp->xmac_stats.xpcs_ln0_symbol_err_cnt +=
2021 (cnt32 & XMAC_XPCS_SYM_ERR_CNT_L0_MASK);
2022 statsp->xmac_stats.xpcs_ln1_symbol_err_cnt +=
2023 ((cnt32 & XMAC_XPCS_SYM_ERR_CNT_L1_MASK) >>
2024 XMAC_XPCS_SYM_ERR_CNT_L1_SHIFT);
2025 (void) npi_xmac_xpcs_read(handle, portn,
2026 XPCS_REG_SYMBOL_ERR_L2_3_COUNTER, &cnt32);
2027 statsp->xmac_stats.xpcs_ln2_symbol_err_cnt +=
2028 (cnt32 & XMAC_XPCS_SYM_ERR_CNT_L2_MASK);
2029 statsp->xmac_stats.xpcs_ln3_symbol_err_cnt +=
2030 ((cnt32 & XMAC_XPCS_SYM_ERR_CNT_L3_MASK) >>
2031 XMAC_XPCS_SYM_ERR_CNT_L3_SHIFT);
2032 #endif
2033 } else if (nxgep->mac.porttype == PORT_TYPE_BMAC) {
2034 /*
2035 * Transmit MAC statistics.
2036 */
2037 BMAC_REG_RD(handle, portn, BTXMAC_FRM_CNT_REG, &val);
2038 statsp->bmac_stats.tx_frame_cnt += (val & BTXMAC_FRM_CNT_MASK);
2039 /* Clear register as it is not auto clear on read */
2040 BMAC_REG_WR(handle, portn, BTXMAC_FRM_CNT_REG, 0);
2041
2042 BMAC_REG_RD(handle, portn, BTXMAC_BYTE_CNT_REG, &val);
2043 statsp->bmac_stats.tx_byte_cnt += (val & BTXMAC_BYTE_CNT_MASK);
2044 /* Clear register as it is not auto clear on read */
2045 BMAC_REG_WR(handle, portn, BTXMAC_BYTE_CNT_REG, 0);
2046
2047 /*
2048 * Receive MAC statistics.
2049 */
2050 BMAC_REG_RD(handle, portn, RXMAC_FRM_CNT_REG, &val);
2051 statsp->bmac_stats.rx_frame_cnt += (val & RXMAC_FRM_CNT_MASK);
2052 /* Clear register as it is not auto clear on read */
2053 BMAC_REG_WR(handle, portn, RXMAC_FRM_CNT_REG, 0);
2054
2055 BMAC_REG_RD(handle, portn, BRXMAC_BYTE_CNT_REG, &val);
2056 statsp->bmac_stats.rx_byte_cnt += (val & BRXMAC_BYTE_CNT_MASK);
2057 /* Clear register as it is not auto clear on read */
2058 BMAC_REG_WR(handle, portn, BRXMAC_BYTE_CNT_REG, 0);
2059
2060 BMAC_REG_RD(handle, portn, BMAC_AL_ER_CNT_REG, &val);
2061 statsp->bmac_stats.rx_align_err_cnt +=
2062 (val & BMAC_AL_ER_CNT_MASK);
2063 /* Clear register as it is not auto clear on read */
2064 BMAC_REG_WR(handle, portn, BMAC_AL_ER_CNT_REG, 0);
2065
2066 BMAC_REG_RD(handle, portn, MAC_LEN_ER_CNT_REG, &val);
2067 statsp->bmac_stats.rx_len_err_cnt +=
2068 (val & MAC_LEN_ER_CNT_MASK);
2069 /* Clear register as it is not auto clear on read */
2070 BMAC_REG_WR(handle, portn, MAC_LEN_ER_CNT_REG, 0);
2071
2072 BMAC_REG_RD(handle, portn, BMAC_CRC_ER_CNT_REG, &val);
2073 statsp->bmac_stats.rx_crc_err_cnt +=
2074 (val & BMAC_CRC_ER_CNT_MASK);
2075 /* Clear register as it is not auto clear on read */
2076 BMAC_REG_WR(handle, portn, BMAC_CRC_ER_CNT_REG, 0);
2077
2078 BMAC_REG_RD(handle, portn, BMAC_CD_VIO_CNT_REG, &val);
2079 statsp->bmac_stats.rx_viol_err_cnt +=
2080 (val & BMAC_CD_VIO_CNT_MASK);
2081 /* Clear register as it is not auto clear on read */
2082 BMAC_REG_WR(handle, portn, BMAC_CD_VIO_CNT_REG, 0);
2083 }
2084 if (isLDOMguest(nxgep)) {
2085 MUTEX_EXIT(&nxgep->ouraddr_lock);
2086 goto nxge_save_cntrs_exit;
2087 }
2088 /* Update IPP counters */
2089 (void) npi_ipp_get_ecc_err_count(handle, portn, &cnt8);
2090 statsp->ipp_stats.ecc_err_cnt += cnt8;
2091 (void) npi_ipp_get_pkt_dis_count(handle, portn, &cnt16);
2092 statsp->ipp_stats.pkt_dis_cnt += cnt16;
2093 (void) npi_ipp_get_cs_err_count(handle, portn, &cnt16);
2094 statsp->ipp_stats.bad_cs_cnt += cnt16;
2095
2096 MUTEX_EXIT(&nxgep->ouraddr_lock);
2097
2098 nxge_save_cntrs_exit:
2099 NXGE_DEBUG_MSG((nxgep, DDI_CTL, "<== nxge_save_cntrs"));
2100 }
2101
2102 uint64_t
nxge_m_rx_stat(nxge_t * nxgep,uint_t stat)2103 nxge_m_rx_stat(
2104 nxge_t *nxgep,
2105 uint_t stat)
2106 {
2107 p_nxge_stats_t statsp;
2108 nxge_grp_set_t *rx_set;
2109 int8_t set[NXGE_MAX_RDCS];
2110 int i, cursor;
2111
2112 uint64_t val = 0;
2113
2114 NXGE_DEBUG_MSG((nxgep, KST_CTL, "==> nxge_m_rx_stat"));
2115 statsp = (p_nxge_stats_t)nxgep->statsp;
2116
2117 rx_set = &nxgep->rx_set;
2118 for (i = 0, cursor = 0; i < NXGE_MAX_RDCS; i++) {
2119 if ((1 << i) & rx_set->owned.map) {
2120 set[cursor++] = (uint8_t)i;
2121 }
2122 }
2123
2124 for (i = 0; i < cursor; i++) {
2125 int rdc = set[i];
2126 switch (stat) {
2127 case MAC_STAT_IERRORS:
2128 case ETHER_STAT_MACRCV_ERRORS:
2129 val += statsp->rdc_stats[rdc].ierrors;
2130 break;
2131
2132 case MAC_STAT_RBYTES:
2133 val += statsp->rdc_stats[rdc].ibytes;
2134 break;
2135
2136 case MAC_STAT_IPACKETS:
2137 val += statsp->rdc_stats[rdc].ipackets;
2138 break;
2139
2140 default:
2141 break;
2142 }
2143 }
2144
2145 return (val);
2146 }
2147
2148 uint64_t
nxge_m_tx_stat(nxge_t * nxgep,uint_t stat)2149 nxge_m_tx_stat(
2150 nxge_t *nxgep,
2151 uint_t stat)
2152 {
2153 p_nxge_stats_t statsp;
2154 nxge_grp_set_t *tx_set;
2155 int8_t set[NXGE_MAX_TDCS];
2156 int i, cursor;
2157
2158 uint64_t val = 0;
2159
2160 NXGE_DEBUG_MSG((nxgep, KST_CTL, "==> nxge_m_tx_stat"));
2161 statsp = (p_nxge_stats_t)nxgep->statsp;
2162
2163 tx_set = &nxgep->tx_set;
2164 for (i = 0, cursor = 0; i < NXGE_MAX_TDCS; i++) {
2165 if ((1 << i) & tx_set->owned.map) {
2166 set[cursor++] = (uint8_t)i;
2167 }
2168 }
2169
2170 for (i = 0; i < cursor; i++) {
2171 int tdc = set[i];
2172 switch (stat) {
2173 case MAC_STAT_OERRORS:
2174 val += statsp->tdc_stats[tdc].oerrors;
2175 break;
2176
2177 case MAC_STAT_OBYTES:
2178 val += statsp->tdc_stats[tdc].obytes;
2179 break;
2180
2181 case MAC_STAT_OPACKETS:
2182 val += statsp->tdc_stats[tdc].opackets;
2183 break;
2184
2185 default:
2186 break;
2187 }
2188 }
2189
2190 return (val);
2191 }
2192
2193 /*
2194 * Retrieve a value for one of the statistics for a particular rx ring
2195 */
2196 int
nxge_rx_ring_stat(mac_ring_driver_t rdriver,uint_t stat,uint64_t * val)2197 nxge_rx_ring_stat(mac_ring_driver_t rdriver, uint_t stat, uint64_t *val)
2198 {
2199 p_nxge_ring_handle_t rhp = (p_nxge_ring_handle_t)rdriver;
2200 p_nxge_t nxgep = rhp->nxgep;
2201 int r_index;
2202 p_nxge_stats_t statsp;
2203
2204 ASSERT(nxgep != NULL);
2205 statsp = (p_nxge_stats_t)nxgep->statsp;
2206 ASSERT(statsp != NULL);
2207 r_index = rhp->index + nxgep->pt_config.hw_config.start_rdc;
2208
2209 if (statsp->rdc_ksp[r_index] == NULL)
2210 return (0);
2211
2212 switch (stat) {
2213 case MAC_STAT_IERRORS:
2214 *val = statsp->rdc_stats[r_index].ierrors;
2215 break;
2216
2217 case MAC_STAT_RBYTES:
2218 *val = statsp->rdc_stats[r_index].ibytes;
2219 break;
2220
2221 case MAC_STAT_IPACKETS:
2222 *val = statsp->rdc_stats[r_index].ipackets;
2223 break;
2224
2225 default:
2226 *val = 0;
2227 return (ENOTSUP);
2228 }
2229
2230 return (0);
2231 }
2232
2233 /*
2234 * Retrieve a value for one of the statistics for a particular tx ring
2235 */
2236 int
nxge_tx_ring_stat(mac_ring_driver_t rdriver,uint_t stat,uint64_t * val)2237 nxge_tx_ring_stat(mac_ring_driver_t rdriver, uint_t stat, uint64_t *val)
2238 {
2239 p_nxge_ring_handle_t rhp = (p_nxge_ring_handle_t)rdriver;
2240 p_nxge_t nxgep = rhp->nxgep;
2241 int r_index;
2242 p_nxge_stats_t statsp;
2243
2244 ASSERT(nxgep != NULL);
2245 statsp = (p_nxge_stats_t)nxgep->statsp;
2246 ASSERT(statsp != NULL);
2247 r_index = nxgep->pt_config.hw_config.tdc.start + rhp->index;
2248
2249 if (statsp->tdc_ksp[r_index] == NULL)
2250 return (0);
2251
2252 switch (stat) {
2253 case MAC_STAT_OERRORS:
2254 *val = statsp->tdc_stats[r_index].oerrors;
2255 break;
2256
2257 case MAC_STAT_OBYTES:
2258 *val = statsp->tdc_stats[r_index].obytes;
2259 break;
2260
2261 case MAC_STAT_OPACKETS:
2262 *val = statsp->tdc_stats[r_index].opackets;
2263 break;
2264
2265 default:
2266 *val = 0;
2267 return (ENOTSUP);
2268 }
2269
2270 return (0);
2271 }
2272
2273 /* ARGSUSED */
2274 int
nxge_m_stat(void * arg,uint_t stat,uint64_t * value)2275 nxge_m_stat(void *arg, uint_t stat, uint64_t *value)
2276 {
2277 p_nxge_t nxgep = (p_nxge_t)arg;
2278 p_nxge_stats_t statsp;
2279 uint64_t val = 0;
2280
2281 NXGE_DEBUG_MSG((nxgep, KST_CTL, "==> nxge_m_stat"));
2282 statsp = (p_nxge_stats_t)nxgep->statsp;
2283
2284 switch (stat) {
2285 case MAC_STAT_IFSPEED:
2286 val = statsp->mac_stats.link_speed * 1000000ull;
2287 break;
2288
2289 case MAC_STAT_MULTIRCV:
2290 val = statsp->port_stats.multircv;
2291 break;
2292
2293 case MAC_STAT_BRDCSTRCV:
2294 val = statsp->port_stats.brdcstrcv;
2295 break;
2296
2297 case MAC_STAT_MULTIXMT:
2298 val = statsp->port_stats.multixmt;
2299 break;
2300
2301 case MAC_STAT_BRDCSTXMT:
2302 val = statsp->port_stats.brdcstxmt;
2303 break;
2304
2305 case MAC_STAT_NORCVBUF:
2306 val = statsp->port_stats.norcvbuf;
2307 break;
2308
2309 case MAC_STAT_IERRORS:
2310 case ETHER_STAT_MACRCV_ERRORS:
2311 val = nxge_m_rx_stat(nxgep, stat);
2312 break;
2313
2314 case MAC_STAT_OERRORS:
2315 val = nxge_m_tx_stat(nxgep, stat);
2316 break;
2317
2318 case MAC_STAT_NOXMTBUF:
2319 val = statsp->port_stats.noxmtbuf;
2320 break;
2321
2322 case MAC_STAT_COLLISIONS:
2323 val = 0;
2324 break;
2325
2326 case MAC_STAT_RBYTES:
2327 val = nxge_m_rx_stat(nxgep, stat);
2328 break;
2329
2330 case MAC_STAT_IPACKETS:
2331 val = nxge_m_rx_stat(nxgep, stat);
2332 break;
2333
2334 case MAC_STAT_OBYTES:
2335 val = nxge_m_tx_stat(nxgep, stat);
2336 break;
2337
2338 case MAC_STAT_OPACKETS:
2339 val = nxge_m_tx_stat(nxgep, stat);
2340 break;
2341 case MAC_STAT_LINK_STATE:
2342 val = statsp->mac_stats.link_duplex;
2343 break;
2344 case MAC_STAT_LINK_UP:
2345 val = statsp->mac_stats.link_up;
2346 break;
2347 case MAC_STAT_PROMISC:
2348 val = statsp->mac_stats.promisc;
2349 break;
2350 case ETHER_STAT_SQE_ERRORS:
2351 val = 0;
2352 break;
2353
2354 case ETHER_STAT_ALIGN_ERRORS:
2355 if (nxgep->mac.porttype == PORT_TYPE_XMAC)
2356 val = statsp->xmac_stats.rx_frame_align_err_cnt;
2357 else if (nxgep->mac.porttype == PORT_TYPE_BMAC)
2358 val = statsp->bmac_stats.rx_align_err_cnt;
2359 else
2360 val = 0;
2361 break;
2362
2363 case ETHER_STAT_FCS_ERRORS:
2364 if (nxgep->mac.porttype == PORT_TYPE_XMAC)
2365 val = statsp->xmac_stats.rx_crc_err_cnt;
2366 else if (nxgep->mac.porttype == PORT_TYPE_BMAC)
2367 val = statsp->bmac_stats.rx_crc_err_cnt;
2368 else
2369 val = 0;
2370 break;
2371
2372 case ETHER_STAT_FIRST_COLLISIONS:
2373 val = 0;
2374 break;
2375
2376 case ETHER_STAT_MULTI_COLLISIONS:
2377 val = 0;
2378 break;
2379
2380 case ETHER_STAT_TX_LATE_COLLISIONS:
2381 val = 0;
2382 break;
2383
2384 case ETHER_STAT_EX_COLLISIONS:
2385 val = 0;
2386 break;
2387
2388 case ETHER_STAT_DEFER_XMTS:
2389 val = 0;
2390 break;
2391
2392 case ETHER_STAT_MACXMT_ERRORS:
2393 if (nxgep->mac.porttype == PORT_TYPE_XMAC) {
2394 val = statsp->xmac_stats.tx_underflow_err +
2395 statsp->xmac_stats.tx_maxpktsize_err +
2396 statsp->xmac_stats.tx_overflow_err +
2397 statsp->xmac_stats.tx_fifo_xfr_err;
2398 } else {
2399 val = statsp->bmac_stats.tx_underrun_err +
2400 statsp->bmac_stats.tx_max_pkt_err;
2401 }
2402 break;
2403
2404 case ETHER_STAT_CARRIER_ERRORS:
2405 if (nxgep->mac.porttype == PORT_TYPE_XMAC) {
2406 val = statsp->xmac_stats.rx_linkfault_err_cnt;
2407 } else {
2408 val = statsp->mac_stats.xcvr_inits +
2409 statsp->mac_stats.serdes_inits;
2410 }
2411 break;
2412
2413 case ETHER_STAT_TOOLONG_ERRORS:
2414 if (nxgep->mac.porttype == PORT_TYPE_XMAC) {
2415 val = statsp->xmac_stats.tx_maxpktsize_err +
2416 statsp->xmac_stats.rx_len_err_cnt;
2417
2418 } else {
2419 val = statsp->bmac_stats.rx_len_err_cnt +
2420 statsp->bmac_stats.tx_max_pkt_err;
2421 }
2422 break;
2423
2424
2425 case ETHER_STAT_XCVR_ADDR:
2426 val = statsp->mac_stats.xcvr_portn;
2427 break;
2428 case ETHER_STAT_XCVR_ID:
2429 val = statsp->mac_stats.xcvr_id;
2430 break;
2431
2432 case ETHER_STAT_XCVR_INUSE:
2433 val = statsp->mac_stats.xcvr_inuse;
2434 break;
2435
2436 case ETHER_STAT_CAP_1000FDX:
2437 val = statsp->mac_stats.cap_1000fdx;
2438 break;
2439
2440 case ETHER_STAT_CAP_1000HDX:
2441 val = statsp->mac_stats.cap_1000hdx;
2442 break;
2443
2444 case ETHER_STAT_CAP_100FDX:
2445 val = statsp->mac_stats.cap_100fdx;
2446 break;
2447
2448 case ETHER_STAT_CAP_100HDX:
2449 val = statsp->mac_stats.cap_100hdx;
2450 break;
2451
2452 case ETHER_STAT_CAP_10FDX:
2453 val = statsp->mac_stats.cap_10fdx;
2454 break;
2455
2456 case ETHER_STAT_CAP_10HDX:
2457 val = statsp->mac_stats.cap_10hdx;
2458 break;
2459
2460 case ETHER_STAT_CAP_ASMPAUSE:
2461 val = statsp->mac_stats.cap_asmpause;
2462 val = 1;
2463 break;
2464
2465 case ETHER_STAT_CAP_PAUSE:
2466 val = statsp->mac_stats.cap_pause;
2467 break;
2468
2469 case ETHER_STAT_CAP_AUTONEG:
2470 val = statsp->mac_stats.cap_autoneg;
2471 break;
2472
2473 case ETHER_STAT_ADV_CAP_1000FDX:
2474 val = statsp->mac_stats.adv_cap_1000fdx;
2475 break;
2476
2477 case ETHER_STAT_ADV_CAP_1000HDX:
2478 val = statsp->mac_stats.adv_cap_1000hdx;
2479 break;
2480
2481 case ETHER_STAT_ADV_CAP_100FDX:
2482 val = statsp->mac_stats.adv_cap_100fdx;
2483 break;
2484
2485 case ETHER_STAT_ADV_CAP_100HDX:
2486 val = statsp->mac_stats.adv_cap_100hdx;
2487 break;
2488
2489 case ETHER_STAT_ADV_CAP_10FDX:
2490 val = statsp->mac_stats.adv_cap_10fdx;
2491 break;
2492
2493 case ETHER_STAT_ADV_CAP_10HDX:
2494 val = statsp->mac_stats.adv_cap_10hdx;
2495 break;
2496
2497 case ETHER_STAT_ADV_CAP_ASMPAUSE:
2498 val = statsp->mac_stats.adv_cap_asmpause;
2499 break;
2500
2501 case ETHER_STAT_ADV_CAP_PAUSE:
2502 val = statsp->mac_stats.adv_cap_pause;
2503 break;
2504
2505 case ETHER_STAT_ADV_CAP_AUTONEG:
2506 val = statsp->mac_stats.adv_cap_autoneg;
2507 break;
2508
2509 case ETHER_STAT_LP_CAP_1000FDX:
2510 val = statsp->mac_stats.lp_cap_1000fdx;
2511 break;
2512
2513 case ETHER_STAT_LP_CAP_1000HDX:
2514 val = statsp->mac_stats.lp_cap_1000hdx;
2515 break;
2516
2517 case ETHER_STAT_LP_CAP_100FDX:
2518 val = statsp->mac_stats.lp_cap_100fdx;
2519 break;
2520
2521 case ETHER_STAT_LP_CAP_100HDX:
2522 val = statsp->mac_stats.lp_cap_100hdx;
2523 break;
2524
2525 case ETHER_STAT_LP_CAP_10FDX:
2526 val = statsp->mac_stats.lp_cap_10fdx;
2527 break;
2528
2529 case ETHER_STAT_LP_CAP_10HDX:
2530 val = statsp->mac_stats.lp_cap_10hdx;
2531 break;
2532
2533 case ETHER_STAT_LP_CAP_ASMPAUSE:
2534 val = statsp->mac_stats.lp_cap_asmpause;
2535 break;
2536
2537 case ETHER_STAT_LP_CAP_PAUSE:
2538 val = statsp->mac_stats.lp_cap_pause;
2539 break;
2540
2541 case ETHER_STAT_LP_CAP_AUTONEG:
2542 val = statsp->mac_stats.lp_cap_autoneg;
2543 break;
2544
2545 case ETHER_STAT_LINK_ASMPAUSE:
2546 val = statsp->mac_stats.link_asmpause;
2547 break;
2548
2549 case ETHER_STAT_LINK_PAUSE:
2550 val = statsp->mac_stats.link_pause;
2551 break;
2552
2553 case ETHER_STAT_LINK_AUTONEG:
2554 val = statsp->mac_stats.cap_autoneg;
2555 break;
2556
2557 case ETHER_STAT_LINK_DUPLEX:
2558 val = statsp->mac_stats.link_duplex;
2559 break;
2560
2561 default:
2562 /*
2563 * Shouldn't reach here...
2564 */
2565 #ifdef NXGE_DEBUG
2566 NXGE_ERROR_MSG((nxgep, KST_CTL,
2567 "nxge_m_stat: unrecognized parameter value = 0x%x",
2568 stat));
2569 #endif
2570
2571 return (ENOTSUP);
2572 }
2573 *value = val;
2574 return (0);
2575 }
2576