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 (c) 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 ixgbe_ks
->tx_break_tbd_limit
.value
.ui64
= 0;
80 ixgbe_ks
->tx_lso_header_fail
.value
.ui64
= 0;
81 for (i
= 0; i
< ixgbe
->num_tx_rings
; i
++) {
82 ixgbe_ks
->tx_overload
.value
.ui64
+=
83 ixgbe
->tx_rings
[i
].stat_overload
;
84 ixgbe_ks
->tx_fail_no_tbd
.value
.ui64
+=
85 ixgbe
->tx_rings
[i
].stat_fail_no_tbd
;
86 ixgbe_ks
->tx_fail_no_tcb
.value
.ui64
+=
87 ixgbe
->tx_rings
[i
].stat_fail_no_tcb
;
88 ixgbe_ks
->tx_fail_dma_bind
.value
.ui64
+=
89 ixgbe
->tx_rings
[i
].stat_fail_dma_bind
;
90 ixgbe_ks
->tx_reschedule
.value
.ui64
+=
91 ixgbe
->tx_rings
[i
].stat_reschedule
;
92 ixgbe_ks
->tx_break_tbd_limit
.value
.ui64
+=
93 ixgbe
->tx_rings
[i
].stat_break_tbd_limit
;
94 ixgbe_ks
->tx_lso_header_fail
.value
.ui64
+=
95 ixgbe
->tx_rings
[i
].stat_lso_header_fail
;
99 * Hardware calculated statistics.
101 ixgbe_ks
->gprc
.value
.ui64
= 0;
102 ixgbe_ks
->gptc
.value
.ui64
= 0;
103 ixgbe_ks
->tor
.value
.ui64
= 0;
104 ixgbe_ks
->tot
.value
.ui64
= 0;
105 for (i
= 0; i
< 16; i
++) {
106 ixgbe_ks
->qprc
[i
].value
.ui64
+=
107 IXGBE_READ_REG(hw
, IXGBE_QPRC(i
));
108 ixgbe_ks
->gprc
.value
.ui64
+= ixgbe_ks
->qprc
[i
].value
.ui64
;
109 ixgbe_ks
->qptc
[i
].value
.ui64
+=
110 IXGBE_READ_REG(hw
, IXGBE_QPTC(i
));
111 ixgbe_ks
->gptc
.value
.ui64
+= ixgbe_ks
->qptc
[i
].value
.ui64
;
112 ixgbe_ks
->qbrc
[i
].value
.ui64
+=
113 IXGBE_READ_REG(hw
, IXGBE_QBRC(i
));
114 ixgbe_ks
->tor
.value
.ui64
+= ixgbe_ks
->qbrc
[i
].value
.ui64
;
115 switch (hw
->mac
.type
) {
116 case ixgbe_mac_82598EB
:
117 ixgbe_ks
->qbtc
[i
].value
.ui64
+=
118 IXGBE_READ_REG(hw
, IXGBE_QBTC(i
));
121 case ixgbe_mac_82599EB
:
124 case ixgbe_mac_X550EM_x
:
125 ixgbe_ks
->qbtc
[i
].value
.ui64
+=
126 IXGBE_READ_REG(hw
, IXGBE_QBTC_L(i
));
127 ixgbe_ks
->qbtc
[i
].value
.ui64
+=
128 ((uint64_t)((IXGBE_READ_REG(hw
,
129 IXGBE_QBTC_H(i
))) & 0xF) << 32);
135 ixgbe_ks
->tot
.value
.ui64
+= ixgbe_ks
->qbtc
[i
].value
.ui64
;
138 * This is a Workaround:
139 * Currently h/w GORCH, GOTCH, TORH registers are not
140 * correctly implemented. We found that the values in
141 * these registers are same as those in corresponding
142 * *L registers (i.e. GORCL, GOTCL, and TORL). Here the
143 * gor and got stat data will not be retrieved through
144 * GORC{H/L} and GOTC{H/L} registers but be obtained by
145 * simply assigning tor/tot stat data, so the gor/got
146 * stat data will not be accurate.
148 ixgbe_ks
->gor
.value
.ui64
= ixgbe_ks
->tor
.value
.ui64
;
149 ixgbe_ks
->got
.value
.ui64
= ixgbe_ks
->tot
.value
.ui64
;
151 ixgbe_ks
->prc64
.value
.ul
+= IXGBE_READ_REG(hw
, IXGBE_PRC64
);
152 ixgbe_ks
->prc127
.value
.ul
+= IXGBE_READ_REG(hw
, IXGBE_PRC127
);
153 ixgbe_ks
->prc255
.value
.ul
+= IXGBE_READ_REG(hw
, IXGBE_PRC255
);
154 ixgbe_ks
->prc511
.value
.ul
+= IXGBE_READ_REG(hw
, IXGBE_PRC511
);
155 ixgbe_ks
->prc1023
.value
.ul
+= IXGBE_READ_REG(hw
, IXGBE_PRC1023
);
156 ixgbe_ks
->prc1522
.value
.ul
+= IXGBE_READ_REG(hw
, IXGBE_PRC1522
);
157 ixgbe_ks
->ptc64
.value
.ul
+= IXGBE_READ_REG(hw
, IXGBE_PTC64
);
158 ixgbe_ks
->ptc127
.value
.ul
+= IXGBE_READ_REG(hw
, IXGBE_PTC127
);
159 ixgbe_ks
->ptc255
.value
.ul
+= IXGBE_READ_REG(hw
, IXGBE_PTC255
);
160 ixgbe_ks
->ptc511
.value
.ul
+= IXGBE_READ_REG(hw
, IXGBE_PTC511
);
161 ixgbe_ks
->ptc1023
.value
.ul
+= IXGBE_READ_REG(hw
, IXGBE_PTC1023
);
162 ixgbe_ks
->ptc1522
.value
.ul
+= IXGBE_READ_REG(hw
, IXGBE_PTC1522
);
164 ixgbe_ks
->mspdc
.value
.ui64
+= IXGBE_READ_REG(hw
, IXGBE_MSPDC
);
165 for (i
= 0; i
< 8; i
++)
166 ixgbe_ks
->mpc
.value
.ui64
+= IXGBE_READ_REG(hw
, IXGBE_MPC(i
));
167 ixgbe_ks
->mlfc
.value
.ui64
+= IXGBE_READ_REG(hw
, IXGBE_MLFC
);
168 ixgbe_ks
->mrfc
.value
.ui64
+= IXGBE_READ_REG(hw
, IXGBE_MRFC
);
169 ixgbe_ks
->rlec
.value
.ui64
+= IXGBE_READ_REG(hw
, IXGBE_RLEC
);
170 ixgbe_ks
->lxontxc
.value
.ui64
+= IXGBE_READ_REG(hw
, IXGBE_LXONTXC
);
171 switch (hw
->mac
.type
) {
172 case ixgbe_mac_82598EB
:
173 ixgbe_ks
->lxonrxc
.value
.ui64
+= IXGBE_READ_REG(hw
,
177 case ixgbe_mac_82599EB
:
180 case ixgbe_mac_X550EM_x
:
181 ixgbe_ks
->lxonrxc
.value
.ui64
+= IXGBE_READ_REG(hw
,
188 ixgbe_ks
->lxofftxc
.value
.ui64
+= IXGBE_READ_REG(hw
, IXGBE_LXOFFTXC
);
189 switch (hw
->mac
.type
) {
190 case ixgbe_mac_82598EB
:
191 ixgbe_ks
->lxoffrxc
.value
.ui64
+= IXGBE_READ_REG(hw
,
195 case ixgbe_mac_82599EB
:
198 case ixgbe_mac_X550EM_x
:
199 ixgbe_ks
->lxoffrxc
.value
.ui64
+= IXGBE_READ_REG(hw
,
206 ixgbe_ks
->ruc
.value
.ui64
+= IXGBE_READ_REG(hw
, IXGBE_RUC
);
207 ixgbe_ks
->rfc
.value
.ui64
+= IXGBE_READ_REG(hw
, IXGBE_RFC
);
208 ixgbe_ks
->roc
.value
.ui64
+= IXGBE_READ_REG(hw
, IXGBE_ROC
);
209 ixgbe_ks
->rjc
.value
.ui64
+= IXGBE_READ_REG(hw
, IXGBE_RJC
);
211 mutex_exit(&ixgbe
->gen_lock
);
213 if (ixgbe_check_acc_handle(ixgbe
->osdep
.reg_handle
) != DDI_FM_OK
)
214 ddi_fm_service_impact(ixgbe
->dip
, DDI_SERVICE_UNAFFECTED
);
220 * Create and initialize the driver private statistics.
223 ixgbe_init_stats(ixgbe_t
*ixgbe
)
226 ixgbe_stat_t
*ixgbe_ks
;
229 * Create and init kstat
231 ks
= kstat_create(MODULE_NAME
, ddi_get_instance(ixgbe
->dip
),
232 "statistics", "net", KSTAT_TYPE_NAMED
,
233 sizeof (ixgbe_stat_t
) / sizeof (kstat_named_t
), 0);
237 "Could not create kernel statistics");
238 return (IXGBE_FAILURE
);
241 ixgbe
->ixgbe_ks
= ks
;
243 ixgbe_ks
= (ixgbe_stat_t
*)ks
->ks_data
;
246 * Initialize all the statistics.
248 kstat_named_init(&ixgbe_ks
->link_speed
, "link_speed",
250 kstat_named_init(&ixgbe_ks
->reset_count
, "reset_count",
253 kstat_named_init(&ixgbe_ks
->rx_frame_error
, "rx_frame_error",
255 kstat_named_init(&ixgbe_ks
->rx_cksum_error
, "rx_cksum_error",
257 kstat_named_init(&ixgbe_ks
->rx_exceed_pkt
, "rx_exceed_pkt",
259 kstat_named_init(&ixgbe_ks
->tx_overload
, "tx_overload",
261 kstat_named_init(&ixgbe_ks
->tx_fail_no_tbd
, "tx_fail_no_tbd",
263 kstat_named_init(&ixgbe_ks
->tx_fail_no_tcb
, "tx_fail_no_tcb",
265 kstat_named_init(&ixgbe_ks
->tx_fail_dma_bind
, "tx_fail_dma_bind",
267 kstat_named_init(&ixgbe_ks
->tx_reschedule
, "tx_reschedule",
269 kstat_named_init(&ixgbe_ks
->tx_break_tbd_limit
, "tx_break_tbd_limit",
271 kstat_named_init(&ixgbe_ks
->tx_lso_header_fail
, "tx_lso_header_fail",
274 kstat_named_init(&ixgbe_ks
->gprc
, "good_pkts_recvd",
276 kstat_named_init(&ixgbe_ks
->gptc
, "good_pkts_xmitd",
278 kstat_named_init(&ixgbe_ks
->gor
, "good_octets_recvd",
280 kstat_named_init(&ixgbe_ks
->got
, "good_octets_xmitd",
282 kstat_named_init(&ixgbe_ks
->prc64
, "pkts_recvd_( 64b)",
284 kstat_named_init(&ixgbe_ks
->prc127
, "pkts_recvd_( 65- 127b)",
286 kstat_named_init(&ixgbe_ks
->prc255
, "pkts_recvd_( 127- 255b)",
288 kstat_named_init(&ixgbe_ks
->prc511
, "pkts_recvd_( 256- 511b)",
290 kstat_named_init(&ixgbe_ks
->prc1023
, "pkts_recvd_( 511-1023b)",
292 kstat_named_init(&ixgbe_ks
->prc1522
, "pkts_recvd_(1024-1522b)",
294 kstat_named_init(&ixgbe_ks
->ptc64
, "pkts_xmitd_( 64b)",
296 kstat_named_init(&ixgbe_ks
->ptc127
, "pkts_xmitd_( 65- 127b)",
298 kstat_named_init(&ixgbe_ks
->ptc255
, "pkts_xmitd_( 128- 255b)",
300 kstat_named_init(&ixgbe_ks
->ptc511
, "pkts_xmitd_( 255- 511b)",
302 kstat_named_init(&ixgbe_ks
->ptc1023
, "pkts_xmitd_( 512-1023b)",
304 kstat_named_init(&ixgbe_ks
->ptc1522
, "pkts_xmitd_(1024-1522b)",
307 kstat_named_init(&ixgbe_ks
->qprc
[0], "queue_pkts_recvd [ 0]",
309 kstat_named_init(&ixgbe_ks
->qprc
[1], "queue_pkts_recvd [ 1]",
311 kstat_named_init(&ixgbe_ks
->qprc
[2], "queue_pkts_recvd [ 2]",
313 kstat_named_init(&ixgbe_ks
->qprc
[3], "queue_pkts_recvd [ 3]",
315 kstat_named_init(&ixgbe_ks
->qprc
[4], "queue_pkts_recvd [ 4]",
317 kstat_named_init(&ixgbe_ks
->qprc
[5], "queue_pkts_recvd [ 5]",
319 kstat_named_init(&ixgbe_ks
->qprc
[6], "queue_pkts_recvd [ 6]",
321 kstat_named_init(&ixgbe_ks
->qprc
[7], "queue_pkts_recvd [ 7]",
323 kstat_named_init(&ixgbe_ks
->qprc
[8], "queue_pkts_recvd [ 8]",
325 kstat_named_init(&ixgbe_ks
->qprc
[9], "queue_pkts_recvd [ 9]",
327 kstat_named_init(&ixgbe_ks
->qprc
[10], "queue_pkts_recvd [10]",
329 kstat_named_init(&ixgbe_ks
->qprc
[11], "queue_pkts_recvd [11]",
331 kstat_named_init(&ixgbe_ks
->qprc
[12], "queue_pkts_recvd [12]",
333 kstat_named_init(&ixgbe_ks
->qprc
[13], "queue_pkts_recvd [13]",
335 kstat_named_init(&ixgbe_ks
->qprc
[14], "queue_pkts_recvd [14]",
337 kstat_named_init(&ixgbe_ks
->qprc
[15], "queue_pkts_recvd [15]",
340 kstat_named_init(&ixgbe_ks
->qptc
[0], "queue_pkts_xmitd [ 0]",
342 kstat_named_init(&ixgbe_ks
->qptc
[1], "queue_pkts_xmitd [ 1]",
344 kstat_named_init(&ixgbe_ks
->qptc
[2], "queue_pkts_xmitd [ 2]",
346 kstat_named_init(&ixgbe_ks
->qptc
[3], "queue_pkts_xmitd [ 3]",
348 kstat_named_init(&ixgbe_ks
->qptc
[4], "queue_pkts_xmitd [ 4]",
350 kstat_named_init(&ixgbe_ks
->qptc
[5], "queue_pkts_xmitd [ 5]",
352 kstat_named_init(&ixgbe_ks
->qptc
[6], "queue_pkts_xmitd [ 6]",
354 kstat_named_init(&ixgbe_ks
->qptc
[7], "queue_pkts_xmitd [ 7]",
356 kstat_named_init(&ixgbe_ks
->qptc
[8], "queue_pkts_xmitd [ 8]",
358 kstat_named_init(&ixgbe_ks
->qptc
[9], "queue_pkts_xmitd [ 9]",
360 kstat_named_init(&ixgbe_ks
->qptc
[10], "queue_pkts_xmitd [10]",
362 kstat_named_init(&ixgbe_ks
->qptc
[11], "queue_pkts_xmitd [11]",
364 kstat_named_init(&ixgbe_ks
->qptc
[12], "queue_pkts_xmitd [12]",
366 kstat_named_init(&ixgbe_ks
->qptc
[13], "queue_pkts_xmitd [13]",
368 kstat_named_init(&ixgbe_ks
->qptc
[14], "queue_pkts_xmitd [14]",
370 kstat_named_init(&ixgbe_ks
->qptc
[15], "queue_pkts_xmitd [15]",
373 kstat_named_init(&ixgbe_ks
->qbrc
[0], "queue_bytes_recvd [ 0]",
375 kstat_named_init(&ixgbe_ks
->qbrc
[1], "queue_bytes_recvd [ 1]",
377 kstat_named_init(&ixgbe_ks
->qbrc
[2], "queue_bytes_recvd [ 2]",
379 kstat_named_init(&ixgbe_ks
->qbrc
[3], "queue_bytes_recvd [ 3]",
381 kstat_named_init(&ixgbe_ks
->qbrc
[4], "queue_bytes_recvd [ 4]",
383 kstat_named_init(&ixgbe_ks
->qbrc
[5], "queue_bytes_recvd [ 5]",
385 kstat_named_init(&ixgbe_ks
->qbrc
[6], "queue_bytes_recvd [ 6]",
387 kstat_named_init(&ixgbe_ks
->qbrc
[7], "queue_bytes_recvd [ 7]",
389 kstat_named_init(&ixgbe_ks
->qbrc
[8], "queue_bytes_recvd [ 8]",
391 kstat_named_init(&ixgbe_ks
->qbrc
[9], "queue_bytes_recvd [ 9]",
393 kstat_named_init(&ixgbe_ks
->qbrc
[10], "queue_bytes_recvd [10]",
395 kstat_named_init(&ixgbe_ks
->qbrc
[11], "queue_bytes_recvd [11]",
397 kstat_named_init(&ixgbe_ks
->qbrc
[12], "queue_bytes_recvd [12]",
399 kstat_named_init(&ixgbe_ks
->qbrc
[13], "queue_bytes_recvd [13]",
401 kstat_named_init(&ixgbe_ks
->qbrc
[14], "queue_bytes_recvd [14]",
403 kstat_named_init(&ixgbe_ks
->qbrc
[15], "queue_bytes_recvd [15]",
406 kstat_named_init(&ixgbe_ks
->qbtc
[0], "queue_bytes_xmitd [ 0]",
408 kstat_named_init(&ixgbe_ks
->qbtc
[1], "queue_bytes_xmitd [ 1]",
410 kstat_named_init(&ixgbe_ks
->qbtc
[2], "queue_bytes_xmitd [ 2]",
412 kstat_named_init(&ixgbe_ks
->qbtc
[3], "queue_bytes_xmitd [ 3]",
414 kstat_named_init(&ixgbe_ks
->qbtc
[4], "queue_bytes_xmitd [ 4]",
416 kstat_named_init(&ixgbe_ks
->qbtc
[5], "queue_bytes_xmitd [ 5]",
418 kstat_named_init(&ixgbe_ks
->qbtc
[6], "queue_bytes_xmitd [ 6]",
420 kstat_named_init(&ixgbe_ks
->qbtc
[7], "queue_bytes_xmitd [ 7]",
422 kstat_named_init(&ixgbe_ks
->qbtc
[8], "queue_bytes_xmitd [ 8]",
424 kstat_named_init(&ixgbe_ks
->qbtc
[9], "queue_bytes_xmitd [ 9]",
426 kstat_named_init(&ixgbe_ks
->qbtc
[10], "queue_bytes_xmitd [10]",
428 kstat_named_init(&ixgbe_ks
->qbtc
[11], "queue_bytes_xmitd [11]",
430 kstat_named_init(&ixgbe_ks
->qbtc
[12], "queue_bytes_xmitd [12]",
432 kstat_named_init(&ixgbe_ks
->qbtc
[13], "queue_bytes_xmitd [13]",
434 kstat_named_init(&ixgbe_ks
->qbtc
[14], "queue_bytes_xmitd [14]",
436 kstat_named_init(&ixgbe_ks
->qbtc
[15], "queue_bytes_xmitd [15]",
439 kstat_named_init(&ixgbe_ks
->mspdc
, "mac_short_packet_discard",
441 kstat_named_init(&ixgbe_ks
->mpc
, "missed_packets",
443 kstat_named_init(&ixgbe_ks
->mlfc
, "mac_local_fault",
445 kstat_named_init(&ixgbe_ks
->mrfc
, "mac_remote_fault",
447 kstat_named_init(&ixgbe_ks
->rlec
, "recv_length_err",
449 kstat_named_init(&ixgbe_ks
->lxontxc
, "link_xon_xmitd",
451 kstat_named_init(&ixgbe_ks
->lxonrxc
, "link_xon_recvd",
453 kstat_named_init(&ixgbe_ks
->lxofftxc
, "link_xoff_xmitd",
455 kstat_named_init(&ixgbe_ks
->lxoffrxc
, "link_xoff_recvd",
457 kstat_named_init(&ixgbe_ks
->ruc
, "recv_undersize",
459 kstat_named_init(&ixgbe_ks
->rfc
, "recv_fragment",
461 kstat_named_init(&ixgbe_ks
->roc
, "recv_oversize",
463 kstat_named_init(&ixgbe_ks
->rjc
, "recv_jabber",
465 kstat_named_init(&ixgbe_ks
->rnbc
, "recv_no_buffer",
467 kstat_named_init(&ixgbe_ks
->lroc
, "lro_pkt_count",
470 kstat_named_init(&ixgbe_ks
->dev_gone
, "device_gone",
473 * Function to provide kernel stat update on demand
475 ks
->ks_update
= ixgbe_update_stats
;
477 ks
->ks_private
= (void *)ixgbe
;
480 * Add kstat to systems kstat chain
484 return (IXGBE_SUCCESS
);
488 * Retrieve a value for one of the statistics.
491 ixgbe_m_stat(void *arg
, uint_t stat
, uint64_t *val
)
493 ixgbe_t
*ixgbe
= (ixgbe_t
*)arg
;
494 struct ixgbe_hw
*hw
= &ixgbe
->hw
;
495 ixgbe_stat_t
*ixgbe_ks
;
497 ixgbe_link_speed speeds
= 0;
499 ixgbe_ks
= (ixgbe_stat_t
*)ixgbe
->ixgbe_ks
->ks_data
;
501 mutex_enter(&ixgbe
->gen_lock
);
504 * We cannot always rely on the common code maintaining
505 * hw->phy.speeds_supported, therefore we fall back to use the recorded
506 * supported speeds which were obtained during instance init in
507 * ixgbe_init_params().
509 speeds
= hw
->phy
.speeds_supported
;
511 speeds
= ixgbe
->speeds_supported
;
513 if (ixgbe
->ixgbe_state
& IXGBE_SUSPENDED
) {
514 mutex_exit(&ixgbe
->gen_lock
);
519 case MAC_STAT_IFSPEED
:
520 *val
= ixgbe
->link_speed
* 1000000ull;
523 case MAC_STAT_MULTIRCV
:
524 ixgbe_ks
->mprc
.value
.ui64
+=
525 IXGBE_READ_REG(hw
, IXGBE_MPRC
);
526 *val
= ixgbe_ks
->mprc
.value
.ui64
;
529 case MAC_STAT_BRDCSTRCV
:
530 ixgbe_ks
->bprc
.value
.ui64
+=
531 IXGBE_READ_REG(hw
, IXGBE_BPRC
);
532 *val
= ixgbe_ks
->bprc
.value
.ui64
;
535 case MAC_STAT_MULTIXMT
:
536 ixgbe_ks
->mptc
.value
.ui64
+=
537 IXGBE_READ_REG(hw
, IXGBE_MPTC
);
538 *val
= ixgbe_ks
->mptc
.value
.ui64
;
541 case MAC_STAT_BRDCSTXMT
:
542 ixgbe_ks
->bptc
.value
.ui64
+=
543 IXGBE_READ_REG(hw
, IXGBE_BPTC
);
544 *val
= ixgbe_ks
->bptc
.value
.ui64
;
547 case MAC_STAT_NORCVBUF
:
548 for (i
= 0; i
< 8; i
++) {
549 ixgbe_ks
->rnbc
.value
.ui64
+=
550 IXGBE_READ_REG(hw
, IXGBE_RNBC(i
));
552 *val
= ixgbe_ks
->rnbc
.value
.ui64
;
555 case MAC_STAT_IERRORS
:
556 ixgbe_ks
->crcerrs
.value
.ui64
+=
557 IXGBE_READ_REG(hw
, IXGBE_CRCERRS
);
558 ixgbe_ks
->illerrc
.value
.ui64
+=
559 IXGBE_READ_REG(hw
, IXGBE_ILLERRC
);
560 ixgbe_ks
->errbc
.value
.ui64
+=
561 IXGBE_READ_REG(hw
, IXGBE_ERRBC
);
562 ixgbe_ks
->rlec
.value
.ui64
+=
563 IXGBE_READ_REG(hw
, IXGBE_RLEC
);
564 *val
= ixgbe_ks
->crcerrs
.value
.ui64
+
565 ixgbe_ks
->illerrc
.value
.ui64
+
566 ixgbe_ks
->errbc
.value
.ui64
+
567 ixgbe_ks
->rlec
.value
.ui64
;
570 case MAC_STAT_RBYTES
:
571 ixgbe_ks
->tor
.value
.ui64
= 0;
572 for (i
= 0; i
< 16; i
++) {
573 ixgbe_ks
->qbrc
[i
].value
.ui64
+=
574 IXGBE_READ_REG(hw
, IXGBE_QBRC(i
));
575 ixgbe_ks
->tor
.value
.ui64
+=
576 ixgbe_ks
->qbrc
[i
].value
.ui64
;
578 *val
= ixgbe_ks
->tor
.value
.ui64
;
581 case MAC_STAT_OBYTES
:
582 ixgbe_ks
->tot
.value
.ui64
= 0;
583 for (i
= 0; i
< 16; i
++) {
584 switch (hw
->mac
.type
) {
585 case ixgbe_mac_82598EB
:
586 ixgbe_ks
->qbtc
[i
].value
.ui64
+=
587 IXGBE_READ_REG(hw
, IXGBE_QBTC(i
));
590 case ixgbe_mac_82599EB
:
593 case ixgbe_mac_X550EM_x
:
594 ixgbe_ks
->qbtc
[i
].value
.ui64
+=
595 IXGBE_READ_REG(hw
, IXGBE_QBTC_L(i
));
596 ixgbe_ks
->qbtc
[i
].value
.ui64
+=
597 ((uint64_t)((IXGBE_READ_REG(hw
,
598 IXGBE_QBTC_H(i
))) & 0xF) << 32);
604 ixgbe_ks
->tot
.value
.ui64
+=
605 ixgbe_ks
->qbtc
[i
].value
.ui64
;
607 *val
= ixgbe_ks
->tot
.value
.ui64
;
610 case MAC_STAT_IPACKETS
:
611 ixgbe_ks
->tpr
.value
.ui64
+=
612 IXGBE_READ_REG(hw
, IXGBE_TPR
);
613 *val
= ixgbe_ks
->tpr
.value
.ui64
;
616 case MAC_STAT_OPACKETS
:
617 ixgbe_ks
->tpt
.value
.ui64
+=
618 IXGBE_READ_REG(hw
, IXGBE_TPT
);
619 *val
= ixgbe_ks
->tpt
.value
.ui64
;
623 case ETHER_STAT_FCS_ERRORS
:
624 ixgbe_ks
->crcerrs
.value
.ui64
+=
625 IXGBE_READ_REG(hw
, IXGBE_CRCERRS
);
626 *val
= ixgbe_ks
->crcerrs
.value
.ui64
;
629 case ETHER_STAT_TOOLONG_ERRORS
:
630 ixgbe_ks
->roc
.value
.ui64
+=
631 IXGBE_READ_REG(hw
, IXGBE_ROC
);
632 *val
= ixgbe_ks
->roc
.value
.ui64
;
635 case ETHER_STAT_MACRCV_ERRORS
:
636 ixgbe_ks
->crcerrs
.value
.ui64
+=
637 IXGBE_READ_REG(hw
, IXGBE_CRCERRS
);
638 ixgbe_ks
->illerrc
.value
.ui64
+=
639 IXGBE_READ_REG(hw
, IXGBE_ILLERRC
);
640 ixgbe_ks
->errbc
.value
.ui64
+=
641 IXGBE_READ_REG(hw
, IXGBE_ERRBC
);
642 ixgbe_ks
->rlec
.value
.ui64
+=
643 IXGBE_READ_REG(hw
, IXGBE_RLEC
);
644 *val
= ixgbe_ks
->crcerrs
.value
.ui64
+
645 ixgbe_ks
->illerrc
.value
.ui64
+
646 ixgbe_ks
->errbc
.value
.ui64
+
647 ixgbe_ks
->rlec
.value
.ui64
;
651 case ETHER_STAT_XCVR_ADDR
:
652 /* The Internal PHY's MDI address for each MAC is 1 */
656 case ETHER_STAT_XCVR_ID
:
660 case ETHER_STAT_XCVR_INUSE
:
661 switch (ixgbe
->link_speed
) {
662 case IXGBE_LINK_SPEED_1GB_FULL
:
664 (hw
->phy
.media_type
== ixgbe_media_type_copper
) ?
665 XCVR_1000T
: XCVR_1000X
;
667 case IXGBE_LINK_SPEED_100_FULL
:
668 *val
= (hw
->phy
.media_type
== ixgbe_media_type_copper
) ?
669 XCVR_100T2
: XCVR_100X
;
677 case ETHER_STAT_CAP_10GFDX
:
678 *val
= (speeds
& IXGBE_LINK_SPEED_10GB_FULL
) ? 1 : 0;
681 case ETHER_STAT_CAP_5000FDX
:
682 *val
= (speeds
& IXGBE_LINK_SPEED_5GB_FULL
) ? 1 : 0;
685 case ETHER_STAT_CAP_2500FDX
:
686 *val
= (speeds
& IXGBE_LINK_SPEED_2_5GB_FULL
) ? 1 : 0;
689 case ETHER_STAT_CAP_1000FDX
:
690 *val
= (speeds
& IXGBE_LINK_SPEED_1GB_FULL
) ? 1 : 0;
693 case ETHER_STAT_CAP_100FDX
:
694 *val
= (speeds
& IXGBE_LINK_SPEED_100_FULL
) ? 1 : 0;
697 case ETHER_STAT_CAP_ASMPAUSE
:
698 *val
= ixgbe
->param_asym_pause_cap
;
701 case ETHER_STAT_CAP_PAUSE
:
702 *val
= ixgbe
->param_pause_cap
;
705 case ETHER_STAT_CAP_AUTONEG
:
709 case ETHER_STAT_ADV_CAP_10GFDX
:
710 *val
= ixgbe
->param_adv_10000fdx_cap
;
713 case ETHER_STAT_ADV_CAP_5000FDX
:
714 *val
= ixgbe
->param_adv_5000fdx_cap
;
717 case ETHER_STAT_ADV_CAP_2500FDX
:
718 *val
= ixgbe
->param_adv_2500fdx_cap
;
721 case ETHER_STAT_ADV_CAP_1000FDX
:
722 *val
= ixgbe
->param_adv_1000fdx_cap
;
725 case ETHER_STAT_ADV_CAP_100FDX
:
726 *val
= ixgbe
->param_adv_100fdx_cap
;
729 case ETHER_STAT_ADV_CAP_ASMPAUSE
:
730 *val
= ixgbe
->param_adv_asym_pause_cap
;
733 case ETHER_STAT_ADV_CAP_PAUSE
:
734 *val
= ixgbe
->param_adv_pause_cap
;
737 case ETHER_STAT_ADV_CAP_AUTONEG
:
738 *val
= ixgbe
->param_adv_autoneg_cap
;
741 case ETHER_STAT_LP_CAP_10GFDX
:
742 *val
= ixgbe
->param_lp_10000fdx_cap
;
745 case ETHER_STAT_LP_CAP_5000FDX
:
746 *val
= ixgbe
->param_lp_5000fdx_cap
;
749 case ETHER_STAT_LP_CAP_2500FDX
:
750 *val
= ixgbe
->param_lp_2500fdx_cap
;
753 case ETHER_STAT_LP_CAP_1000FDX
:
754 *val
= ixgbe
->param_lp_1000fdx_cap
;
757 case ETHER_STAT_LP_CAP_100FDX
:
758 *val
= ixgbe
->param_lp_100fdx_cap
;
761 case ETHER_STAT_LP_CAP_ASMPAUSE
:
762 *val
= ixgbe
->param_lp_asym_pause_cap
;
765 case ETHER_STAT_LP_CAP_PAUSE
:
766 *val
= ixgbe
->param_lp_pause_cap
;
769 case ETHER_STAT_LP_CAP_AUTONEG
:
770 *val
= ixgbe
->param_lp_autoneg_cap
;
773 case ETHER_STAT_LINK_ASMPAUSE
:
774 *val
= ixgbe
->param_asym_pause_cap
;
777 case ETHER_STAT_LINK_PAUSE
:
778 *val
= ixgbe
->param_pause_cap
;
781 case ETHER_STAT_LINK_AUTONEG
:
782 *val
= ixgbe
->param_adv_autoneg_cap
;
785 case ETHER_STAT_LINK_DUPLEX
:
786 *val
= ixgbe
->link_duplex
;
789 case ETHER_STAT_TOOSHORT_ERRORS
:
790 ixgbe_ks
->ruc
.value
.ui64
+=
791 IXGBE_READ_REG(hw
, IXGBE_RUC
);
792 *val
= ixgbe_ks
->ruc
.value
.ui64
;
795 case ETHER_STAT_CAP_REMFAULT
:
796 *val
= ixgbe
->param_rem_fault
;
799 case ETHER_STAT_ADV_REMFAULT
:
800 *val
= ixgbe
->param_adv_rem_fault
;
803 case ETHER_STAT_LP_REMFAULT
:
804 *val
= ixgbe
->param_lp_rem_fault
;
807 case ETHER_STAT_JABBER_ERRORS
:
808 ixgbe_ks
->rjc
.value
.ui64
+=
809 IXGBE_READ_REG(hw
, IXGBE_RJC
);
810 *val
= ixgbe_ks
->rjc
.value
.ui64
;
814 mutex_exit(&ixgbe
->gen_lock
);
818 mutex_exit(&ixgbe
->gen_lock
);
820 if (ixgbe_check_acc_handle(ixgbe
->osdep
.reg_handle
) != DDI_FM_OK
) {
821 ddi_fm_service_impact(ixgbe
->dip
, DDI_SERVICE_DEGRADED
);
829 * Retrieve a value for one of the statistics for a particular rx ring
832 ixgbe_rx_ring_stat(mac_ring_driver_t rh
, uint_t stat
, uint64_t *val
)
834 ixgbe_rx_ring_t
*rx_ring
= (ixgbe_rx_ring_t
*)rh
;
835 ixgbe_t
*ixgbe
= rx_ring
->ixgbe
;
837 if (ixgbe
->ixgbe_state
& IXGBE_SUSPENDED
) {
842 case MAC_STAT_RBYTES
:
843 *val
= rx_ring
->stat_rbytes
;
846 case MAC_STAT_IPACKETS
:
847 *val
= rx_ring
->stat_ipackets
;
859 * Retrieve a value for one of the statistics for a particular tx ring
862 ixgbe_tx_ring_stat(mac_ring_driver_t rh
, uint_t stat
, uint64_t *val
)
864 ixgbe_tx_ring_t
*tx_ring
= (ixgbe_tx_ring_t
*)rh
;
865 ixgbe_t
*ixgbe
= tx_ring
->ixgbe
;
867 if (ixgbe
->ixgbe_state
& IXGBE_SUSPENDED
) {
872 case MAC_STAT_OBYTES
:
873 *val
= tx_ring
->stat_obytes
;
876 case MAC_STAT_OPACKETS
:
877 *val
= tx_ring
->stat_opackets
;