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.
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.
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]
23 * Copyright(c) 2007-2010 Intel Corporation. All rights reserved.
27 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
28 * Copyright 2012 Nexenta Systems, Inc. All rights reserved.
29 * Copyright 2016 OmniTI Computer Consulting, Inc. All rights reserved.
30 * Copyright 2017 Joyent, Inc.
36 * Update driver private statistics.
39 ixgbe_update_stats(kstat_t
*ks
, int rw
)
43 ixgbe_stat_t
*ixgbe_ks
;
46 if (rw
== KSTAT_WRITE
)
49 ixgbe
= (ixgbe_t
*)ks
->ks_private
;
50 ixgbe_ks
= (ixgbe_stat_t
*)ks
->ks_data
;
53 mutex_enter(&ixgbe
->gen_lock
);
58 ixgbe_ks
->link_speed
.value
.ui64
= ixgbe
->link_speed
;
59 ixgbe_ks
->reset_count
.value
.ui64
= ixgbe
->reset_count
;
60 ixgbe_ks
->lroc
.value
.ui64
= ixgbe
->lro_pkt_count
;
62 ixgbe_ks
->rx_frame_error
.value
.ui64
= 0;
63 ixgbe_ks
->rx_cksum_error
.value
.ui64
= 0;
64 ixgbe_ks
->rx_exceed_pkt
.value
.ui64
= 0;
65 for (i
= 0; i
< ixgbe
->num_rx_rings
; i
++) {
66 ixgbe_ks
->rx_frame_error
.value
.ui64
+=
67 ixgbe
->rx_rings
[i
].stat_frame_error
;
68 ixgbe_ks
->rx_cksum_error
.value
.ui64
+=
69 ixgbe
->rx_rings
[i
].stat_cksum_error
;
70 ixgbe_ks
->rx_exceed_pkt
.value
.ui64
+=
71 ixgbe
->rx_rings
[i
].stat_exceed_pkt
;
74 ixgbe_ks
->tx_overload
.value
.ui64
= 0;
75 ixgbe_ks
->tx_fail_no_tbd
.value
.ui64
= 0;
76 ixgbe_ks
->tx_fail_no_tcb
.value
.ui64
= 0;
77 ixgbe_ks
->tx_fail_dma_bind
.value
.ui64
= 0;
78 ixgbe_ks
->tx_reschedule
.value
.ui64
= 0;
79 for (i
= 0; i
< ixgbe
->num_tx_rings
; i
++) {
80 ixgbe_ks
->tx_overload
.value
.ui64
+=
81 ixgbe
->tx_rings
[i
].stat_overload
;
82 ixgbe_ks
->tx_fail_no_tbd
.value
.ui64
+=
83 ixgbe
->tx_rings
[i
].stat_fail_no_tbd
;
84 ixgbe_ks
->tx_fail_no_tcb
.value
.ui64
+=
85 ixgbe
->tx_rings
[i
].stat_fail_no_tcb
;
86 ixgbe_ks
->tx_fail_dma_bind
.value
.ui64
+=
87 ixgbe
->tx_rings
[i
].stat_fail_dma_bind
;
88 ixgbe_ks
->tx_reschedule
.value
.ui64
+=
89 ixgbe
->tx_rings
[i
].stat_reschedule
;
93 * Hardware calculated statistics.
95 ixgbe_ks
->gprc
.value
.ui64
= 0;
96 ixgbe_ks
->gptc
.value
.ui64
= 0;
97 ixgbe_ks
->tor
.value
.ui64
= 0;
98 ixgbe_ks
->tot
.value
.ui64
= 0;
99 for (i
= 0; i
< 16; i
++) {
100 ixgbe_ks
->qprc
[i
].value
.ui64
+=
101 IXGBE_READ_REG(hw
, IXGBE_QPRC(i
));
102 ixgbe_ks
->gprc
.value
.ui64
+= ixgbe_ks
->qprc
[i
].value
.ui64
;
103 ixgbe_ks
->qptc
[i
].value
.ui64
+=
104 IXGBE_READ_REG(hw
, IXGBE_QPTC(i
));
105 ixgbe_ks
->gptc
.value
.ui64
+= ixgbe_ks
->qptc
[i
].value
.ui64
;
106 ixgbe_ks
->qbrc
[i
].value
.ui64
+=
107 IXGBE_READ_REG(hw
, IXGBE_QBRC(i
));
108 ixgbe_ks
->tor
.value
.ui64
+= ixgbe_ks
->qbrc
[i
].value
.ui64
;
109 switch (hw
->mac
.type
) {
110 case ixgbe_mac_82598EB
:
111 ixgbe_ks
->qbtc
[i
].value
.ui64
+=
112 IXGBE_READ_REG(hw
, IXGBE_QBTC(i
));
115 case ixgbe_mac_82599EB
:
118 case ixgbe_mac_X550EM_x
:
119 ixgbe_ks
->qbtc
[i
].value
.ui64
+=
120 IXGBE_READ_REG(hw
, IXGBE_QBTC_L(i
));
121 ixgbe_ks
->qbtc
[i
].value
.ui64
+=
122 ((uint64_t)((IXGBE_READ_REG(hw
,
123 IXGBE_QBTC_H(i
))) & 0xF) << 32);
129 ixgbe_ks
->tot
.value
.ui64
+= ixgbe_ks
->qbtc
[i
].value
.ui64
;
132 * This is a Workaround:
133 * Currently h/w GORCH, GOTCH, TORH registers are not
134 * correctly implemented. We found that the values in
135 * these registers are same as those in corresponding
136 * *L registers (i.e. GORCL, GOTCL, and TORL). Here the
137 * gor and got stat data will not be retrieved through
138 * GORC{H/L} and GOTC{H/L} registers but be obtained by
139 * simply assigning tor/tot stat data, so the gor/got
140 * stat data will not be accurate.
142 ixgbe_ks
->gor
.value
.ui64
= ixgbe_ks
->tor
.value
.ui64
;
143 ixgbe_ks
->got
.value
.ui64
= ixgbe_ks
->tot
.value
.ui64
;
145 ixgbe_ks
->prc64
.value
.ul
+= IXGBE_READ_REG(hw
, IXGBE_PRC64
);
146 ixgbe_ks
->prc127
.value
.ul
+= IXGBE_READ_REG(hw
, IXGBE_PRC127
);
147 ixgbe_ks
->prc255
.value
.ul
+= IXGBE_READ_REG(hw
, IXGBE_PRC255
);
148 ixgbe_ks
->prc511
.value
.ul
+= IXGBE_READ_REG(hw
, IXGBE_PRC511
);
149 ixgbe_ks
->prc1023
.value
.ul
+= IXGBE_READ_REG(hw
, IXGBE_PRC1023
);
150 ixgbe_ks
->prc1522
.value
.ul
+= IXGBE_READ_REG(hw
, IXGBE_PRC1522
);
151 ixgbe_ks
->ptc64
.value
.ul
+= IXGBE_READ_REG(hw
, IXGBE_PTC64
);
152 ixgbe_ks
->ptc127
.value
.ul
+= IXGBE_READ_REG(hw
, IXGBE_PTC127
);
153 ixgbe_ks
->ptc255
.value
.ul
+= IXGBE_READ_REG(hw
, IXGBE_PTC255
);
154 ixgbe_ks
->ptc511
.value
.ul
+= IXGBE_READ_REG(hw
, IXGBE_PTC511
);
155 ixgbe_ks
->ptc1023
.value
.ul
+= IXGBE_READ_REG(hw
, IXGBE_PTC1023
);
156 ixgbe_ks
->ptc1522
.value
.ul
+= IXGBE_READ_REG(hw
, IXGBE_PTC1522
);
158 ixgbe_ks
->mspdc
.value
.ui64
+= IXGBE_READ_REG(hw
, IXGBE_MSPDC
);
159 for (i
= 0; i
< 8; i
++)
160 ixgbe_ks
->mpc
.value
.ui64
+= IXGBE_READ_REG(hw
, IXGBE_MPC(i
));
161 ixgbe_ks
->mlfc
.value
.ui64
+= IXGBE_READ_REG(hw
, IXGBE_MLFC
);
162 ixgbe_ks
->mrfc
.value
.ui64
+= IXGBE_READ_REG(hw
, IXGBE_MRFC
);
163 ixgbe_ks
->rlec
.value
.ui64
+= IXGBE_READ_REG(hw
, IXGBE_RLEC
);
164 ixgbe_ks
->lxontxc
.value
.ui64
+= IXGBE_READ_REG(hw
, IXGBE_LXONTXC
);
165 switch (hw
->mac
.type
) {
166 case ixgbe_mac_82598EB
:
167 ixgbe_ks
->lxonrxc
.value
.ui64
+= IXGBE_READ_REG(hw
,
171 case ixgbe_mac_82599EB
:
174 case ixgbe_mac_X550EM_x
:
175 ixgbe_ks
->lxonrxc
.value
.ui64
+= IXGBE_READ_REG(hw
,
182 ixgbe_ks
->lxofftxc
.value
.ui64
+= IXGBE_READ_REG(hw
, IXGBE_LXOFFTXC
);
183 switch (hw
->mac
.type
) {
184 case ixgbe_mac_82598EB
:
185 ixgbe_ks
->lxoffrxc
.value
.ui64
+= IXGBE_READ_REG(hw
,
189 case ixgbe_mac_82599EB
:
192 case ixgbe_mac_X550EM_x
:
193 ixgbe_ks
->lxoffrxc
.value
.ui64
+= IXGBE_READ_REG(hw
,
200 ixgbe_ks
->ruc
.value
.ui64
+= IXGBE_READ_REG(hw
, IXGBE_RUC
);
201 ixgbe_ks
->rfc
.value
.ui64
+= IXGBE_READ_REG(hw
, IXGBE_RFC
);
202 ixgbe_ks
->roc
.value
.ui64
+= IXGBE_READ_REG(hw
, IXGBE_ROC
);
203 ixgbe_ks
->rjc
.value
.ui64
+= IXGBE_READ_REG(hw
, IXGBE_RJC
);
205 mutex_exit(&ixgbe
->gen_lock
);
207 if (ixgbe_check_acc_handle(ixgbe
->osdep
.reg_handle
) != DDI_FM_OK
)
208 ddi_fm_service_impact(ixgbe
->dip
, DDI_SERVICE_UNAFFECTED
);
214 * Create and initialize the driver private statistics.
217 ixgbe_init_stats(ixgbe_t
*ixgbe
)
220 ixgbe_stat_t
*ixgbe_ks
;
223 * Create and init kstat
225 ks
= kstat_create(MODULE_NAME
, ddi_get_instance(ixgbe
->dip
),
226 "statistics", "net", KSTAT_TYPE_NAMED
,
227 sizeof (ixgbe_stat_t
) / sizeof (kstat_named_t
), 0);
231 "Could not create kernel statistics");
232 return (IXGBE_FAILURE
);
235 ixgbe
->ixgbe_ks
= ks
;
237 ixgbe_ks
= (ixgbe_stat_t
*)ks
->ks_data
;
240 * Initialize all the statistics.
242 kstat_named_init(&ixgbe_ks
->link_speed
, "link_speed",
244 kstat_named_init(&ixgbe_ks
->reset_count
, "reset_count",
247 kstat_named_init(&ixgbe_ks
->rx_frame_error
, "rx_frame_error",
249 kstat_named_init(&ixgbe_ks
->rx_cksum_error
, "rx_cksum_error",
251 kstat_named_init(&ixgbe_ks
->rx_exceed_pkt
, "rx_exceed_pkt",
253 kstat_named_init(&ixgbe_ks
->tx_overload
, "tx_overload",
255 kstat_named_init(&ixgbe_ks
->tx_fail_no_tbd
, "tx_fail_no_tbd",
257 kstat_named_init(&ixgbe_ks
->tx_fail_no_tcb
, "tx_fail_no_tcb",
259 kstat_named_init(&ixgbe_ks
->tx_fail_dma_bind
, "tx_fail_dma_bind",
261 kstat_named_init(&ixgbe_ks
->tx_reschedule
, "tx_reschedule",
264 kstat_named_init(&ixgbe_ks
->gprc
, "good_pkts_recvd",
266 kstat_named_init(&ixgbe_ks
->gptc
, "good_pkts_xmitd",
268 kstat_named_init(&ixgbe_ks
->gor
, "good_octets_recvd",
270 kstat_named_init(&ixgbe_ks
->got
, "good_octets_xmitd",
272 kstat_named_init(&ixgbe_ks
->prc64
, "pkts_recvd_( 64b)",
274 kstat_named_init(&ixgbe_ks
->prc127
, "pkts_recvd_( 65- 127b)",
276 kstat_named_init(&ixgbe_ks
->prc255
, "pkts_recvd_( 127- 255b)",
278 kstat_named_init(&ixgbe_ks
->prc511
, "pkts_recvd_( 256- 511b)",
280 kstat_named_init(&ixgbe_ks
->prc1023
, "pkts_recvd_( 511-1023b)",
282 kstat_named_init(&ixgbe_ks
->prc1522
, "pkts_recvd_(1024-1522b)",
284 kstat_named_init(&ixgbe_ks
->ptc64
, "pkts_xmitd_( 64b)",
286 kstat_named_init(&ixgbe_ks
->ptc127
, "pkts_xmitd_( 65- 127b)",
288 kstat_named_init(&ixgbe_ks
->ptc255
, "pkts_xmitd_( 128- 255b)",
290 kstat_named_init(&ixgbe_ks
->ptc511
, "pkts_xmitd_( 255- 511b)",
292 kstat_named_init(&ixgbe_ks
->ptc1023
, "pkts_xmitd_( 512-1023b)",
294 kstat_named_init(&ixgbe_ks
->ptc1522
, "pkts_xmitd_(1024-1522b)",
297 kstat_named_init(&ixgbe_ks
->qprc
[0], "queue_pkts_recvd [ 0]",
299 kstat_named_init(&ixgbe_ks
->qprc
[1], "queue_pkts_recvd [ 1]",
301 kstat_named_init(&ixgbe_ks
->qprc
[2], "queue_pkts_recvd [ 2]",
303 kstat_named_init(&ixgbe_ks
->qprc
[3], "queue_pkts_recvd [ 3]",
305 kstat_named_init(&ixgbe_ks
->qprc
[4], "queue_pkts_recvd [ 4]",
307 kstat_named_init(&ixgbe_ks
->qprc
[5], "queue_pkts_recvd [ 5]",
309 kstat_named_init(&ixgbe_ks
->qprc
[6], "queue_pkts_recvd [ 6]",
311 kstat_named_init(&ixgbe_ks
->qprc
[7], "queue_pkts_recvd [ 7]",
313 kstat_named_init(&ixgbe_ks
->qprc
[8], "queue_pkts_recvd [ 8]",
315 kstat_named_init(&ixgbe_ks
->qprc
[9], "queue_pkts_recvd [ 9]",
317 kstat_named_init(&ixgbe_ks
->qprc
[10], "queue_pkts_recvd [10]",
319 kstat_named_init(&ixgbe_ks
->qprc
[11], "queue_pkts_recvd [11]",
321 kstat_named_init(&ixgbe_ks
->qprc
[12], "queue_pkts_recvd [12]",
323 kstat_named_init(&ixgbe_ks
->qprc
[13], "queue_pkts_recvd [13]",
325 kstat_named_init(&ixgbe_ks
->qprc
[14], "queue_pkts_recvd [14]",
327 kstat_named_init(&ixgbe_ks
->qprc
[15], "queue_pkts_recvd [15]",
330 kstat_named_init(&ixgbe_ks
->qptc
[0], "queue_pkts_xmitd [ 0]",
332 kstat_named_init(&ixgbe_ks
->qptc
[1], "queue_pkts_xmitd [ 1]",
334 kstat_named_init(&ixgbe_ks
->qptc
[2], "queue_pkts_xmitd [ 2]",
336 kstat_named_init(&ixgbe_ks
->qptc
[3], "queue_pkts_xmitd [ 3]",
338 kstat_named_init(&ixgbe_ks
->qptc
[4], "queue_pkts_xmitd [ 4]",
340 kstat_named_init(&ixgbe_ks
->qptc
[5], "queue_pkts_xmitd [ 5]",
342 kstat_named_init(&ixgbe_ks
->qptc
[6], "queue_pkts_xmitd [ 6]",
344 kstat_named_init(&ixgbe_ks
->qptc
[7], "queue_pkts_xmitd [ 7]",
346 kstat_named_init(&ixgbe_ks
->qptc
[8], "queue_pkts_xmitd [ 8]",
348 kstat_named_init(&ixgbe_ks
->qptc
[9], "queue_pkts_xmitd [ 9]",
350 kstat_named_init(&ixgbe_ks
->qptc
[10], "queue_pkts_xmitd [10]",
352 kstat_named_init(&ixgbe_ks
->qptc
[11], "queue_pkts_xmitd [11]",
354 kstat_named_init(&ixgbe_ks
->qptc
[12], "queue_pkts_xmitd [12]",
356 kstat_named_init(&ixgbe_ks
->qptc
[13], "queue_pkts_xmitd [13]",
358 kstat_named_init(&ixgbe_ks
->qptc
[14], "queue_pkts_xmitd [14]",
360 kstat_named_init(&ixgbe_ks
->qptc
[15], "queue_pkts_xmitd [15]",
363 kstat_named_init(&ixgbe_ks
->qbrc
[0], "queue_bytes_recvd [ 0]",
365 kstat_named_init(&ixgbe_ks
->qbrc
[1], "queue_bytes_recvd [ 1]",
367 kstat_named_init(&ixgbe_ks
->qbrc
[2], "queue_bytes_recvd [ 2]",
369 kstat_named_init(&ixgbe_ks
->qbrc
[3], "queue_bytes_recvd [ 3]",
371 kstat_named_init(&ixgbe_ks
->qbrc
[4], "queue_bytes_recvd [ 4]",
373 kstat_named_init(&ixgbe_ks
->qbrc
[5], "queue_bytes_recvd [ 5]",
375 kstat_named_init(&ixgbe_ks
->qbrc
[6], "queue_bytes_recvd [ 6]",
377 kstat_named_init(&ixgbe_ks
->qbrc
[7], "queue_bytes_recvd [ 7]",
379 kstat_named_init(&ixgbe_ks
->qbrc
[8], "queue_bytes_recvd [ 8]",
381 kstat_named_init(&ixgbe_ks
->qbrc
[9], "queue_bytes_recvd [ 9]",
383 kstat_named_init(&ixgbe_ks
->qbrc
[10], "queue_bytes_recvd [10]",
385 kstat_named_init(&ixgbe_ks
->qbrc
[11], "queue_bytes_recvd [11]",
387 kstat_named_init(&ixgbe_ks
->qbrc
[12], "queue_bytes_recvd [12]",
389 kstat_named_init(&ixgbe_ks
->qbrc
[13], "queue_bytes_recvd [13]",
391 kstat_named_init(&ixgbe_ks
->qbrc
[14], "queue_bytes_recvd [14]",
393 kstat_named_init(&ixgbe_ks
->qbrc
[15], "queue_bytes_recvd [15]",
396 kstat_named_init(&ixgbe_ks
->qbtc
[0], "queue_bytes_xmitd [ 0]",
398 kstat_named_init(&ixgbe_ks
->qbtc
[1], "queue_bytes_xmitd [ 1]",
400 kstat_named_init(&ixgbe_ks
->qbtc
[2], "queue_bytes_xmitd [ 2]",
402 kstat_named_init(&ixgbe_ks
->qbtc
[3], "queue_bytes_xmitd [ 3]",
404 kstat_named_init(&ixgbe_ks
->qbtc
[4], "queue_bytes_xmitd [ 4]",
406 kstat_named_init(&ixgbe_ks
->qbtc
[5], "queue_bytes_xmitd [ 5]",
408 kstat_named_init(&ixgbe_ks
->qbtc
[6], "queue_bytes_xmitd [ 6]",
410 kstat_named_init(&ixgbe_ks
->qbtc
[7], "queue_bytes_xmitd [ 7]",
412 kstat_named_init(&ixgbe_ks
->qbtc
[8], "queue_bytes_xmitd [ 8]",
414 kstat_named_init(&ixgbe_ks
->qbtc
[9], "queue_bytes_xmitd [ 9]",
416 kstat_named_init(&ixgbe_ks
->qbtc
[10], "queue_bytes_xmitd [10]",
418 kstat_named_init(&ixgbe_ks
->qbtc
[11], "queue_bytes_xmitd [11]",
420 kstat_named_init(&ixgbe_ks
->qbtc
[12], "queue_bytes_xmitd [12]",
422 kstat_named_init(&ixgbe_ks
->qbtc
[13], "queue_bytes_xmitd [13]",
424 kstat_named_init(&ixgbe_ks
->qbtc
[14], "queue_bytes_xmitd [14]",
426 kstat_named_init(&ixgbe_ks
->qbtc
[15], "queue_bytes_xmitd [15]",
429 kstat_named_init(&ixgbe_ks
->mspdc
, "mac_short_packet_discard",
431 kstat_named_init(&ixgbe_ks
->mpc
, "missed_packets",
433 kstat_named_init(&ixgbe_ks
->mlfc
, "mac_local_fault",
435 kstat_named_init(&ixgbe_ks
->mrfc
, "mac_remote_fault",
437 kstat_named_init(&ixgbe_ks
->rlec
, "recv_length_err",
439 kstat_named_init(&ixgbe_ks
->lxontxc
, "link_xon_xmitd",
441 kstat_named_init(&ixgbe_ks
->lxonrxc
, "link_xon_recvd",
443 kstat_named_init(&ixgbe_ks
->lxofftxc
, "link_xoff_xmitd",
445 kstat_named_init(&ixgbe_ks
->lxoffrxc
, "link_xoff_recvd",
447 kstat_named_init(&ixgbe_ks
->ruc
, "recv_undersize",
449 kstat_named_init(&ixgbe_ks
->rfc
, "recv_fragment",
451 kstat_named_init(&ixgbe_ks
->roc
, "recv_oversize",
453 kstat_named_init(&ixgbe_ks
->rjc
, "recv_jabber",
455 kstat_named_init(&ixgbe_ks
->rnbc
, "recv_no_buffer",
457 kstat_named_init(&ixgbe_ks
->lroc
, "lro_pkt_count",
460 * Function to provide kernel stat update on demand
462 ks
->ks_update
= ixgbe_update_stats
;
464 ks
->ks_private
= (void *)ixgbe
;
467 * Add kstat to systems kstat chain
471 return (IXGBE_SUCCESS
);
475 * Retrieve a value for one of the statistics.
478 ixgbe_m_stat(void *arg
, uint_t stat
, uint64_t *val
)
480 ixgbe_t
*ixgbe
= (ixgbe_t
*)arg
;
481 struct ixgbe_hw
*hw
= &ixgbe
->hw
;
482 ixgbe_stat_t
*ixgbe_ks
;
484 ixgbe_link_speed speeds
= 0;
486 ixgbe_ks
= (ixgbe_stat_t
*)ixgbe
->ixgbe_ks
->ks_data
;
488 mutex_enter(&ixgbe
->gen_lock
);
491 * We cannot always rely on the common code maintaining
492 * hw->phy.speeds_supported, therefore we fall back to use the recorded
493 * supported speeds which were obtained during instance init in
494 * ixgbe_init_params().
496 speeds
= hw
->phy
.speeds_supported
;
498 speeds
= ixgbe
->speeds_supported
;
500 if (ixgbe
->ixgbe_state
& IXGBE_SUSPENDED
) {
501 mutex_exit(&ixgbe
->gen_lock
);
506 case MAC_STAT_IFSPEED
:
507 *val
= ixgbe
->link_speed
* 1000000ull;
510 case MAC_STAT_MULTIRCV
:
511 ixgbe_ks
->mprc
.value
.ui64
+=
512 IXGBE_READ_REG(hw
, IXGBE_MPRC
);
513 *val
= ixgbe_ks
->mprc
.value
.ui64
;
516 case MAC_STAT_BRDCSTRCV
:
517 ixgbe_ks
->bprc
.value
.ui64
+=
518 IXGBE_READ_REG(hw
, IXGBE_BPRC
);
519 *val
= ixgbe_ks
->bprc
.value
.ui64
;
522 case MAC_STAT_MULTIXMT
:
523 ixgbe_ks
->mptc
.value
.ui64
+=
524 IXGBE_READ_REG(hw
, IXGBE_MPTC
);
525 *val
= ixgbe_ks
->mptc
.value
.ui64
;
528 case MAC_STAT_BRDCSTXMT
:
529 ixgbe_ks
->bptc
.value
.ui64
+=
530 IXGBE_READ_REG(hw
, IXGBE_BPTC
);
531 *val
= ixgbe_ks
->bptc
.value
.ui64
;
534 case MAC_STAT_NORCVBUF
:
535 for (i
= 0; i
< 8; i
++) {
536 ixgbe_ks
->rnbc
.value
.ui64
+=
537 IXGBE_READ_REG(hw
, IXGBE_RNBC(i
));
539 *val
= ixgbe_ks
->rnbc
.value
.ui64
;
542 case MAC_STAT_IERRORS
:
543 ixgbe_ks
->crcerrs
.value
.ui64
+=
544 IXGBE_READ_REG(hw
, IXGBE_CRCERRS
);
545 ixgbe_ks
->illerrc
.value
.ui64
+=
546 IXGBE_READ_REG(hw
, IXGBE_ILLERRC
);
547 ixgbe_ks
->errbc
.value
.ui64
+=
548 IXGBE_READ_REG(hw
, IXGBE_ERRBC
);
549 ixgbe_ks
->rlec
.value
.ui64
+=
550 IXGBE_READ_REG(hw
, IXGBE_RLEC
);
551 *val
= ixgbe_ks
->crcerrs
.value
.ui64
+
552 ixgbe_ks
->illerrc
.value
.ui64
+
553 ixgbe_ks
->errbc
.value
.ui64
+
554 ixgbe_ks
->rlec
.value
.ui64
;
557 case MAC_STAT_RBYTES
:
558 ixgbe_ks
->tor
.value
.ui64
= 0;
559 for (i
= 0; i
< 16; i
++) {
560 ixgbe_ks
->qbrc
[i
].value
.ui64
+=
561 IXGBE_READ_REG(hw
, IXGBE_QBRC(i
));
562 ixgbe_ks
->tor
.value
.ui64
+=
563 ixgbe_ks
->qbrc
[i
].value
.ui64
;
565 *val
= ixgbe_ks
->tor
.value
.ui64
;
568 case MAC_STAT_OBYTES
:
569 ixgbe_ks
->tot
.value
.ui64
= 0;
570 for (i
= 0; i
< 16; i
++) {
571 switch (hw
->mac
.type
) {
572 case ixgbe_mac_82598EB
:
573 ixgbe_ks
->qbtc
[i
].value
.ui64
+=
574 IXGBE_READ_REG(hw
, IXGBE_QBTC(i
));
577 case ixgbe_mac_82599EB
:
580 case ixgbe_mac_X550EM_x
:
581 ixgbe_ks
->qbtc
[i
].value
.ui64
+=
582 IXGBE_READ_REG(hw
, IXGBE_QBTC_L(i
));
583 ixgbe_ks
->qbtc
[i
].value
.ui64
+=
584 ((uint64_t)((IXGBE_READ_REG(hw
,
585 IXGBE_QBTC_H(i
))) & 0xF) << 32);
591 ixgbe_ks
->tot
.value
.ui64
+=
592 ixgbe_ks
->qbtc
[i
].value
.ui64
;
594 *val
= ixgbe_ks
->tot
.value
.ui64
;
597 case MAC_STAT_IPACKETS
:
598 ixgbe_ks
->tpr
.value
.ui64
+=
599 IXGBE_READ_REG(hw
, IXGBE_TPR
);
600 *val
= ixgbe_ks
->tpr
.value
.ui64
;
603 case MAC_STAT_OPACKETS
:
604 ixgbe_ks
->tpt
.value
.ui64
+=
605 IXGBE_READ_REG(hw
, IXGBE_TPT
);
606 *val
= ixgbe_ks
->tpt
.value
.ui64
;
610 case ETHER_STAT_FCS_ERRORS
:
611 ixgbe_ks
->crcerrs
.value
.ui64
+=
612 IXGBE_READ_REG(hw
, IXGBE_CRCERRS
);
613 *val
= ixgbe_ks
->crcerrs
.value
.ui64
;
616 case ETHER_STAT_TOOLONG_ERRORS
:
617 ixgbe_ks
->roc
.value
.ui64
+=
618 IXGBE_READ_REG(hw
, IXGBE_ROC
);
619 *val
= ixgbe_ks
->roc
.value
.ui64
;
622 case ETHER_STAT_MACRCV_ERRORS
:
623 ixgbe_ks
->crcerrs
.value
.ui64
+=
624 IXGBE_READ_REG(hw
, IXGBE_CRCERRS
);
625 ixgbe_ks
->illerrc
.value
.ui64
+=
626 IXGBE_READ_REG(hw
, IXGBE_ILLERRC
);
627 ixgbe_ks
->errbc
.value
.ui64
+=
628 IXGBE_READ_REG(hw
, IXGBE_ERRBC
);
629 ixgbe_ks
->rlec
.value
.ui64
+=
630 IXGBE_READ_REG(hw
, IXGBE_RLEC
);
631 *val
= ixgbe_ks
->crcerrs
.value
.ui64
+
632 ixgbe_ks
->illerrc
.value
.ui64
+
633 ixgbe_ks
->errbc
.value
.ui64
+
634 ixgbe_ks
->rlec
.value
.ui64
;
638 case ETHER_STAT_XCVR_ADDR
:
639 /* The Internal PHY's MDI address for each MAC is 1 */
643 case ETHER_STAT_XCVR_ID
:
647 case ETHER_STAT_XCVR_INUSE
:
648 switch (ixgbe
->link_speed
) {
649 case IXGBE_LINK_SPEED_1GB_FULL
:
651 (hw
->phy
.media_type
== ixgbe_media_type_copper
) ?
652 XCVR_1000T
: XCVR_1000X
;
654 case IXGBE_LINK_SPEED_100_FULL
:
655 *val
= (hw
->phy
.media_type
== ixgbe_media_type_copper
) ?
656 XCVR_100T2
: XCVR_100X
;
664 case ETHER_STAT_CAP_10GFDX
:
665 *val
= (speeds
& IXGBE_LINK_SPEED_10GB_FULL
) ? 1 : 0;
668 case ETHER_STAT_CAP_5000FDX
:
669 *val
= (speeds
& IXGBE_LINK_SPEED_5GB_FULL
) ? 1 : 0;
672 case ETHER_STAT_CAP_2500FDX
:
673 *val
= (speeds
& IXGBE_LINK_SPEED_2_5GB_FULL
) ? 1 : 0;
676 case ETHER_STAT_CAP_1000FDX
:
677 *val
= (speeds
& IXGBE_LINK_SPEED_1GB_FULL
) ? 1 : 0;
680 case ETHER_STAT_CAP_100FDX
:
681 *val
= (speeds
& IXGBE_LINK_SPEED_100_FULL
) ? 1 : 0;
684 case ETHER_STAT_CAP_ASMPAUSE
:
685 *val
= ixgbe
->param_asym_pause_cap
;
688 case ETHER_STAT_CAP_PAUSE
:
689 *val
= ixgbe
->param_pause_cap
;
692 case ETHER_STAT_CAP_AUTONEG
:
696 case ETHER_STAT_ADV_CAP_10GFDX
:
697 *val
= ixgbe
->param_adv_10000fdx_cap
;
700 case ETHER_STAT_ADV_CAP_5000FDX
:
701 *val
= ixgbe
->param_adv_5000fdx_cap
;
704 case ETHER_STAT_ADV_CAP_2500FDX
:
705 *val
= ixgbe
->param_adv_2500fdx_cap
;
708 case ETHER_STAT_ADV_CAP_1000FDX
:
709 *val
= ixgbe
->param_adv_1000fdx_cap
;
712 case ETHER_STAT_ADV_CAP_100FDX
:
713 *val
= ixgbe
->param_adv_100fdx_cap
;
716 case ETHER_STAT_ADV_CAP_ASMPAUSE
:
717 *val
= ixgbe
->param_adv_asym_pause_cap
;
720 case ETHER_STAT_ADV_CAP_PAUSE
:
721 *val
= ixgbe
->param_adv_pause_cap
;
724 case ETHER_STAT_ADV_CAP_AUTONEG
:
725 *val
= ixgbe
->param_adv_autoneg_cap
;
728 case ETHER_STAT_LP_CAP_10GFDX
:
729 *val
= ixgbe
->param_lp_10000fdx_cap
;
732 case ETHER_STAT_LP_CAP_5000FDX
:
733 *val
= ixgbe
->param_lp_5000fdx_cap
;
736 case ETHER_STAT_LP_CAP_2500FDX
:
737 *val
= ixgbe
->param_lp_2500fdx_cap
;
740 case ETHER_STAT_LP_CAP_1000FDX
:
741 *val
= ixgbe
->param_lp_1000fdx_cap
;
744 case ETHER_STAT_LP_CAP_100FDX
:
745 *val
= ixgbe
->param_lp_100fdx_cap
;
748 case ETHER_STAT_LP_CAP_ASMPAUSE
:
749 *val
= ixgbe
->param_lp_asym_pause_cap
;
752 case ETHER_STAT_LP_CAP_PAUSE
:
753 *val
= ixgbe
->param_lp_pause_cap
;
756 case ETHER_STAT_LP_CAP_AUTONEG
:
757 *val
= ixgbe
->param_lp_autoneg_cap
;
760 case ETHER_STAT_LINK_ASMPAUSE
:
761 *val
= ixgbe
->param_asym_pause_cap
;
764 case ETHER_STAT_LINK_PAUSE
:
765 *val
= ixgbe
->param_pause_cap
;
768 case ETHER_STAT_LINK_AUTONEG
:
769 *val
= ixgbe
->param_adv_autoneg_cap
;
772 case ETHER_STAT_LINK_DUPLEX
:
773 *val
= ixgbe
->link_duplex
;
776 case ETHER_STAT_TOOSHORT_ERRORS
:
777 ixgbe_ks
->ruc
.value
.ui64
+=
778 IXGBE_READ_REG(hw
, IXGBE_RUC
);
779 *val
= ixgbe_ks
->ruc
.value
.ui64
;
782 case ETHER_STAT_CAP_REMFAULT
:
783 *val
= ixgbe
->param_rem_fault
;
786 case ETHER_STAT_ADV_REMFAULT
:
787 *val
= ixgbe
->param_adv_rem_fault
;
790 case ETHER_STAT_LP_REMFAULT
:
791 *val
= ixgbe
->param_lp_rem_fault
;
794 case ETHER_STAT_JABBER_ERRORS
:
795 ixgbe_ks
->rjc
.value
.ui64
+=
796 IXGBE_READ_REG(hw
, IXGBE_RJC
);
797 *val
= ixgbe_ks
->rjc
.value
.ui64
;
801 mutex_exit(&ixgbe
->gen_lock
);
805 mutex_exit(&ixgbe
->gen_lock
);
807 if (ixgbe_check_acc_handle(ixgbe
->osdep
.reg_handle
) != DDI_FM_OK
) {
808 ddi_fm_service_impact(ixgbe
->dip
, DDI_SERVICE_DEGRADED
);
816 * Retrieve a value for one of the statistics for a particular rx ring
819 ixgbe_rx_ring_stat(mac_ring_driver_t rh
, uint_t stat
, uint64_t *val
)
821 ixgbe_rx_ring_t
*rx_ring
= (ixgbe_rx_ring_t
*)rh
;
822 ixgbe_t
*ixgbe
= rx_ring
->ixgbe
;
824 if (ixgbe
->ixgbe_state
& IXGBE_SUSPENDED
) {
829 case MAC_STAT_RBYTES
:
830 *val
= rx_ring
->stat_rbytes
;
833 case MAC_STAT_IPACKETS
:
834 *val
= rx_ring
->stat_ipackets
;
846 * Retrieve a value for one of the statistics for a particular tx ring
849 ixgbe_tx_ring_stat(mac_ring_driver_t rh
, uint_t stat
, uint64_t *val
)
851 ixgbe_tx_ring_t
*tx_ring
= (ixgbe_tx_ring_t
*)rh
;
852 ixgbe_t
*ixgbe
= tx_ring
->ixgbe
;
854 if (ixgbe
->ixgbe_state
& IXGBE_SUSPENDED
) {
859 case MAC_STAT_OBYTES
:
860 *val
= tx_ring
->stat_obytes
;
863 case MAC_STAT_OPACKETS
:
864 *val
= tx_ring
->stat_opackets
;