1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2014-2018 Broadcom
8 #include <rte_string_fns.h>
9 #include <rte_byteorder.h>
13 #include "bnxt_hwrm.h"
15 #include "bnxt_stats.h"
17 #include "hsi_struct_def_dpdk.h"
19 static const struct bnxt_xstats_name_off bnxt_rx_stats_strings[] = {
20 {"rx_64b_frames", offsetof(struct rx_port_stats,
22 {"rx_65b_127b_frames", offsetof(struct rx_port_stats,
24 {"rx_128b_255b_frames", offsetof(struct rx_port_stats,
25 rx_128b_255b_frames)},
26 {"rx_256b_511b_frames", offsetof(struct rx_port_stats,
27 rx_256b_511b_frames)},
28 {"rx_512b_1023b_frames", offsetof(struct rx_port_stats,
29 rx_512b_1023b_frames)},
30 {"rx_1024b_1518b_frames", offsetof(struct rx_port_stats,
31 rx_1024b_1518b_frames)},
32 {"rx_good_vlan_frames", offsetof(struct rx_port_stats,
33 rx_good_vlan_frames)},
34 {"rx_1519b_2047b_frames", offsetof(struct rx_port_stats,
35 rx_1519b_2047b_frames)},
36 {"rx_2048b_4095b_frames", offsetof(struct rx_port_stats,
37 rx_2048b_4095b_frames)},
38 {"rx_4096b_9216b_frames", offsetof(struct rx_port_stats,
39 rx_4096b_9216b_frames)},
40 {"rx_9217b_16383b_frames", offsetof(struct rx_port_stats,
41 rx_9217b_16383b_frames)},
42 {"rx_total_frames", offsetof(struct rx_port_stats,
44 {"rx_ucast_frames", offsetof(struct rx_port_stats,
46 {"rx_mcast_frames", offsetof(struct rx_port_stats,
48 {"rx_bcast_frames", offsetof(struct rx_port_stats,
50 {"rx_fcs_err_frames", offsetof(struct rx_port_stats,
52 {"rx_ctrl_frames", offsetof(struct rx_port_stats,
54 {"rx_pause_frames", offsetof(struct rx_port_stats,
56 {"rx_pfc_frames", offsetof(struct rx_port_stats,
58 {"rx_unsupported_opcode_frames", offsetof(struct rx_port_stats,
59 rx_unsupported_opcode_frames)},
60 {"rx_unsupported_da_pausepfc_frames", offsetof(struct rx_port_stats,
61 rx_unsupported_da_pausepfc_frames)},
62 {"rx_wrong_sa_frames", offsetof(struct rx_port_stats,
64 {"rx_align_err_frames", offsetof(struct rx_port_stats,
65 rx_align_err_frames)},
66 {"rx_oor_len_frames", offsetof(struct rx_port_stats,
68 {"rx_code_err_frames", offsetof(struct rx_port_stats,
70 {"rx_false_carrier_frames", offsetof(struct rx_port_stats,
71 rx_false_carrier_frames)},
72 {"rx_ovrsz_frames", offsetof(struct rx_port_stats,
74 {"rx_jbr_frames", offsetof(struct rx_port_stats,
76 {"rx_mtu_err_frames", offsetof(struct rx_port_stats,
78 {"rx_match_crc_frames", offsetof(struct rx_port_stats,
79 rx_match_crc_frames)},
80 {"rx_promiscuous_frames", offsetof(struct rx_port_stats,
81 rx_promiscuous_frames)},
82 {"rx_tagged_frames", offsetof(struct rx_port_stats,
84 {"rx_double_tagged_frames", offsetof(struct rx_port_stats,
85 rx_double_tagged_frames)},
86 {"rx_trunc_frames", offsetof(struct rx_port_stats,
88 {"rx_good_frames", offsetof(struct rx_port_stats,
90 {"rx_sch_crc_err_frames", offsetof(struct rx_port_stats,
91 rx_sch_crc_err_frames)},
92 {"rx_undrsz_frames", offsetof(struct rx_port_stats,
94 {"rx_frag_frames", offsetof(struct rx_port_stats,
96 {"rx_eee_lpi_events", offsetof(struct rx_port_stats,
98 {"rx_eee_lpi_duration", offsetof(struct rx_port_stats,
99 rx_eee_lpi_duration)},
100 {"rx_llfc_physical_msgs", offsetof(struct rx_port_stats,
101 rx_llfc_physical_msgs)},
102 {"rx_llfc_logical_msgs", offsetof(struct rx_port_stats,
103 rx_llfc_logical_msgs)},
104 {"rx_llfc_msgs_with_crc_err", offsetof(struct rx_port_stats,
105 rx_llfc_msgs_with_crc_err)},
106 {"rx_hcfc_msgs", offsetof(struct rx_port_stats,
108 {"rx_hcfc_msgs_with_crc_err", offsetof(struct rx_port_stats,
109 rx_hcfc_msgs_with_crc_err)},
110 {"rx_bytes", offsetof(struct rx_port_stats,
112 {"rx_runt_bytes", offsetof(struct rx_port_stats,
114 {"rx_runt_frames", offsetof(struct rx_port_stats,
116 {"rx_pfc_xon2xoff_frames_pri0", offsetof(struct rx_port_stats,
117 rx_pfc_xon2xoff_frames_pri0)},
118 {"rx_pfc_xon2xoff_frames_pri1", offsetof(struct rx_port_stats,
119 rx_pfc_xon2xoff_frames_pri1)},
120 {"rx_pfc_xon2xoff_frames_pri2", offsetof(struct rx_port_stats,
121 rx_pfc_xon2xoff_frames_pri2)},
122 {"rx_pfc_xon2xoff_frames_pri3", offsetof(struct rx_port_stats,
123 rx_pfc_xon2xoff_frames_pri3)},
124 {"rx_pfc_xon2xoff_frames_pri4", offsetof(struct rx_port_stats,
125 rx_pfc_xon2xoff_frames_pri4)},
126 {"rx_pfc_xon2xoff_frames_pri5", offsetof(struct rx_port_stats,
127 rx_pfc_xon2xoff_frames_pri5)},
128 {"rx_pfc_xon2xoff_frames_pri6", offsetof(struct rx_port_stats,
129 rx_pfc_xon2xoff_frames_pri6)},
130 {"rx_pfc_xon2xoff_frames_pri7", offsetof(struct rx_port_stats,
131 rx_pfc_xon2xoff_frames_pri7)},
132 {"rx_pfc_ena_frames_pri0", offsetof(struct rx_port_stats,
133 rx_pfc_ena_frames_pri0)},
134 {"rx_pfc_ena_frames_pri1", offsetof(struct rx_port_stats,
135 rx_pfc_ena_frames_pri1)},
136 {"rx_pfc_ena_frames_pri2", offsetof(struct rx_port_stats,
137 rx_pfc_ena_frames_pri2)},
138 {"rx_pfc_ena_frames_pri3", offsetof(struct rx_port_stats,
139 rx_pfc_ena_frames_pri3)},
140 {"rx_pfc_ena_frames_pri4", offsetof(struct rx_port_stats,
141 rx_pfc_ena_frames_pri4)},
142 {"rx_pfc_ena_frames_pri5", offsetof(struct rx_port_stats,
143 rx_pfc_ena_frames_pri5)},
144 {"rx_pfc_ena_frames_pri6", offsetof(struct rx_port_stats,
145 rx_pfc_ena_frames_pri6)},
146 {"rx_pfc_ena_frames_pri7", offsetof(struct rx_port_stats,
147 rx_pfc_ena_frames_pri7)},
148 {"rx_stat_discard", offsetof(struct rx_port_stats,
150 {"rx_stat_err", offsetof(struct rx_port_stats,
154 static const struct bnxt_xstats_name_off bnxt_tx_stats_strings[] = {
155 {"tx_64b_frames", offsetof(struct tx_port_stats,
157 {"tx_65b_127b_frames", offsetof(struct tx_port_stats,
158 tx_65b_127b_frames)},
159 {"tx_128b_255b_frames", offsetof(struct tx_port_stats,
160 tx_128b_255b_frames)},
161 {"tx_256b_511b_frames", offsetof(struct tx_port_stats,
162 tx_256b_511b_frames)},
163 {"tx_512b_1023b_frames", offsetof(struct tx_port_stats,
164 tx_512b_1023b_frames)},
165 {"tx_1024b_1518b_frames", offsetof(struct tx_port_stats,
166 tx_1024b_1518b_frames)},
167 {"tx_good_vlan_frames", offsetof(struct tx_port_stats,
168 tx_good_vlan_frames)},
169 {"tx_1519b_2047b_frames", offsetof(struct tx_port_stats,
170 tx_1519b_2047b_frames)},
171 {"tx_2048b_4095b_frames", offsetof(struct tx_port_stats,
172 tx_2048b_4095b_frames)},
173 {"tx_4096b_9216b_frames", offsetof(struct tx_port_stats,
174 tx_4096b_9216b_frames)},
175 {"tx_9217b_16383b_frames", offsetof(struct tx_port_stats,
176 tx_9217b_16383b_frames)},
177 {"tx_good_frames", offsetof(struct tx_port_stats,
179 {"tx_total_frames", offsetof(struct tx_port_stats,
181 {"tx_ucast_frames", offsetof(struct tx_port_stats,
183 {"tx_mcast_frames", offsetof(struct tx_port_stats,
185 {"tx_bcast_frames", offsetof(struct tx_port_stats,
187 {"tx_pause_frames", offsetof(struct tx_port_stats,
189 {"tx_pfc_frames", offsetof(struct tx_port_stats,
191 {"tx_jabber_frames", offsetof(struct tx_port_stats,
193 {"tx_fcs_err_frames", offsetof(struct tx_port_stats,
195 {"tx_control_frames", offsetof(struct tx_port_stats,
197 {"tx_oversz_frames", offsetof(struct tx_port_stats,
199 {"tx_single_dfrl_frames", offsetof(struct tx_port_stats,
200 tx_single_dfrl_frames)},
201 {"tx_multi_dfrl_frames", offsetof(struct tx_port_stats,
202 tx_multi_dfrl_frames)},
203 {"tx_single_coll_frames", offsetof(struct tx_port_stats,
204 tx_single_coll_frames)},
205 {"tx_multi_coll_frames", offsetof(struct tx_port_stats,
206 tx_multi_coll_frames)},
207 {"tx_late_coll_frames", offsetof(struct tx_port_stats,
208 tx_late_coll_frames)},
209 {"tx_excessive_coll_frames", offsetof(struct tx_port_stats,
210 tx_excessive_coll_frames)},
211 {"tx_frag_frames", offsetof(struct tx_port_stats,
213 {"tx_err", offsetof(struct tx_port_stats,
215 {"tx_tagged_frames", offsetof(struct tx_port_stats,
217 {"tx_dbl_tagged_frames", offsetof(struct tx_port_stats,
218 tx_dbl_tagged_frames)},
219 {"tx_runt_frames", offsetof(struct tx_port_stats,
221 {"tx_fifo_underruns", offsetof(struct tx_port_stats,
223 {"tx_eee_lpi_events", offsetof(struct tx_port_stats,
225 {"tx_eee_lpi_duration", offsetof(struct tx_port_stats,
226 tx_eee_lpi_duration)},
227 {"tx_total_collisions", offsetof(struct tx_port_stats,
228 tx_total_collisions)},
229 {"tx_bytes", offsetof(struct tx_port_stats,
231 {"tx_pfc_ena_frames_pri0", offsetof(struct tx_port_stats,
232 tx_pfc_ena_frames_pri0)},
233 {"tx_pfc_ena_frames_pri1", offsetof(struct tx_port_stats,
234 tx_pfc_ena_frames_pri1)},
235 {"tx_pfc_ena_frames_pri2", offsetof(struct tx_port_stats,
236 tx_pfc_ena_frames_pri2)},
237 {"tx_pfc_ena_frames_pri3", offsetof(struct tx_port_stats,
238 tx_pfc_ena_frames_pri3)},
239 {"tx_pfc_ena_frames_pri4", offsetof(struct tx_port_stats,
240 tx_pfc_ena_frames_pri4)},
241 {"tx_pfc_ena_frames_pri5", offsetof(struct tx_port_stats,
242 tx_pfc_ena_frames_pri5)},
243 {"tx_pfc_ena_frames_pri6", offsetof(struct tx_port_stats,
244 tx_pfc_ena_frames_pri6)},
245 {"tx_pfc_ena_frames_pri7", offsetof(struct tx_port_stats,
246 tx_pfc_ena_frames_pri7)},
247 {"tx_llfc_logical_msgs", offsetof(struct tx_port_stats,
248 tx_llfc_logical_msgs)},
249 {"tx_hcfc_msgs", offsetof(struct tx_port_stats,
251 {"tx_xthol_frames", offsetof(struct tx_port_stats,
253 {"tx_stat_discard", offsetof(struct tx_port_stats,
255 {"tx_stat_error", offsetof(struct tx_port_stats,
259 static const struct bnxt_xstats_name_off bnxt_func_stats_strings[] = {
260 {"tx_ucast_pkts", offsetof(struct hwrm_func_qstats_output,
262 {"tx_mcast_pkts", offsetof(struct hwrm_func_qstats_output,
264 {"tx_bcast_pkts", offsetof(struct hwrm_func_qstats_output,
266 {"tx_discard_pkts", offsetof(struct hwrm_func_qstats_output,
268 {"tx_drop_pkts", offsetof(struct hwrm_func_qstats_output,
270 {"tx_ucast_bytes", offsetof(struct hwrm_func_qstats_output,
272 {"tx_mcast_bytes", offsetof(struct hwrm_func_qstats_output,
274 {"tx_bcast_bytes", offsetof(struct hwrm_func_qstats_output,
276 {"rx_ucast_pkts", offsetof(struct hwrm_func_qstats_output,
278 {"rx_mcast_pkts", offsetof(struct hwrm_func_qstats_output,
280 {"rx_bcast_pkts", offsetof(struct hwrm_func_qstats_output,
282 {"rx_discard_pkts", offsetof(struct hwrm_func_qstats_output,
284 {"rx_drop_pkts", offsetof(struct hwrm_func_qstats_output,
286 {"rx_ucast_bytes", offsetof(struct hwrm_func_qstats_output,
288 {"rx_mcast_bytes", offsetof(struct hwrm_func_qstats_output,
290 {"rx_bcast_bytes", offsetof(struct hwrm_func_qstats_output,
292 {"rx_agg_pkts", offsetof(struct hwrm_func_qstats_output,
294 {"rx_agg_bytes", offsetof(struct hwrm_func_qstats_output,
296 {"rx_agg_events", offsetof(struct hwrm_func_qstats_output,
298 {"rx_agg_aborts", offsetof(struct hwrm_func_qstats_output,
303 static const struct bnxt_xstats_name_off bnxt_rx_ext_stats_strings[] = {
304 {"link_down_events", offsetof(struct rx_port_stats_ext,
306 {"continuous_pause_events", offsetof(struct rx_port_stats_ext,
307 continuous_pause_events)},
308 {"resume_pause_events", offsetof(struct rx_port_stats_ext,
309 resume_pause_events)},
310 {"continuous_roce_pause_events", offsetof(struct rx_port_stats_ext,
311 continuous_roce_pause_events)},
312 {"resume_roce_pause_events", offsetof(struct rx_port_stats_ext,
313 resume_roce_pause_events)},
314 {"rx_bytes_cos0", offsetof(struct rx_port_stats_ext,
316 {"rx_bytes_cos1", offsetof(struct rx_port_stats_ext,
318 {"rx_bytes_cos2", offsetof(struct rx_port_stats_ext,
320 {"rx_bytes_cos3", offsetof(struct rx_port_stats_ext,
322 {"rx_bytes_cos4", offsetof(struct rx_port_stats_ext,
324 {"rx_bytes_cos5", offsetof(struct rx_port_stats_ext,
326 {"rx_bytes_cos6", offsetof(struct rx_port_stats_ext,
328 {"rx_bytes_cos7", offsetof(struct rx_port_stats_ext,
330 {"rx_packets_cos0", offsetof(struct rx_port_stats_ext,
332 {"rx_packets_cos1", offsetof(struct rx_port_stats_ext,
334 {"rx_packets_cos2", offsetof(struct rx_port_stats_ext,
336 {"rx_packets_cos3", offsetof(struct rx_port_stats_ext,
338 {"rx_packets_cos4", offsetof(struct rx_port_stats_ext,
340 {"rx_packets_cos5", offsetof(struct rx_port_stats_ext,
342 {"rx_packets_cos6", offsetof(struct rx_port_stats_ext,
344 {"rx_packets_cos7", offsetof(struct rx_port_stats_ext,
346 {"pfc_pri0_rx_duration_us", offsetof(struct rx_port_stats_ext,
347 pfc_pri0_rx_duration_us)},
348 {"pfc_pri0_rx_transitions", offsetof(struct rx_port_stats_ext,
349 pfc_pri0_rx_transitions)},
350 {"pfc_pri1_rx_duration_us", offsetof(struct rx_port_stats_ext,
351 pfc_pri1_rx_duration_us)},
352 {"pfc_pri1_rx_transitions", offsetof(struct rx_port_stats_ext,
353 pfc_pri1_rx_transitions)},
354 {"pfc_pri2_rx_duration_us", offsetof(struct rx_port_stats_ext,
355 pfc_pri2_rx_duration_us)},
356 {"pfc_pri2_rx_transitions", offsetof(struct rx_port_stats_ext,
357 pfc_pri2_rx_transitions)},
358 {"pfc_pri3_rx_duration_us", offsetof(struct rx_port_stats_ext,
359 pfc_pri3_rx_duration_us)},
360 {"pfc_pri3_rx_transitions", offsetof(struct rx_port_stats_ext,
361 pfc_pri3_rx_transitions)},
362 {"pfc_pri4_rx_duration_us", offsetof(struct rx_port_stats_ext,
363 pfc_pri4_rx_duration_us)},
364 {"pfc_pri4_rx_transitions", offsetof(struct rx_port_stats_ext,
365 pfc_pri4_rx_transitions)},
366 {"pfc_pri5_rx_duration_us", offsetof(struct rx_port_stats_ext,
367 pfc_pri5_rx_duration_us)},
368 {"pfc_pri5_rx_transitions", offsetof(struct rx_port_stats_ext,
369 pfc_pri5_rx_transitions)},
370 {"pfc_pri6_rx_duration_us", offsetof(struct rx_port_stats_ext,
371 pfc_pri6_rx_duration_us)},
372 {"pfc_pri6_rx_transitions", offsetof(struct rx_port_stats_ext,
373 pfc_pri6_rx_transitions)},
374 {"pfc_pri7_rx_duration_us", offsetof(struct rx_port_stats_ext,
375 pfc_pri7_rx_duration_us)},
376 {"pfc_pri7_rx_transitions", offsetof(struct rx_port_stats_ext,
377 pfc_pri7_rx_transitions)},
378 {"rx_bits", offsetof(struct rx_port_stats_ext,
380 {"rx_buffer_passed_threshold", offsetof(struct rx_port_stats_ext,
381 rx_buffer_passed_threshold)},
382 {"rx_pcs_symbol_err", offsetof(struct rx_port_stats_ext,
384 {"rx_corrected_bits", offsetof(struct rx_port_stats_ext,
386 {"rx_discard_bytes_cos0", offsetof(struct rx_port_stats_ext,
387 rx_discard_bytes_cos0)},
388 {"rx_discard_bytes_cos1", offsetof(struct rx_port_stats_ext,
389 rx_discard_bytes_cos1)},
390 {"rx_discard_bytes_cos2", offsetof(struct rx_port_stats_ext,
391 rx_discard_bytes_cos2)},
392 {"rx_discard_bytes_cos3", offsetof(struct rx_port_stats_ext,
393 rx_discard_bytes_cos3)},
394 {"rx_discard_bytes_cos4", offsetof(struct rx_port_stats_ext,
395 rx_discard_bytes_cos4)},
396 {"rx_discard_bytes_cos5", offsetof(struct rx_port_stats_ext,
397 rx_discard_bytes_cos5)},
398 {"rx_discard_bytes_cos6", offsetof(struct rx_port_stats_ext,
399 rx_discard_bytes_cos6)},
400 {"rx_discard_bytes_cos7", offsetof(struct rx_port_stats_ext,
401 rx_discard_bytes_cos7)},
402 {"rx_discard_packets_cos0", offsetof(struct rx_port_stats_ext,
403 rx_discard_packets_cos0)},
404 {"rx_discard_packets_cos1", offsetof(struct rx_port_stats_ext,
405 rx_discard_packets_cos1)},
406 {"rx_discard_packets_cos2", offsetof(struct rx_port_stats_ext,
407 rx_discard_packets_cos2)},
408 {"rx_discard_packets_cos3", offsetof(struct rx_port_stats_ext,
409 rx_discard_packets_cos3)},
410 {"rx_discard_packets_cos4", offsetof(struct rx_port_stats_ext,
411 rx_discard_packets_cos4)},
412 {"rx_discard_packets_cos5", offsetof(struct rx_port_stats_ext,
413 rx_discard_packets_cos5)},
414 {"rx_discard_packets_cos6", offsetof(struct rx_port_stats_ext,
415 rx_discard_packets_cos6)},
416 {"rx_discard_packets_cos7", offsetof(struct rx_port_stats_ext,
417 rx_discard_packets_cos7)},
420 static const struct bnxt_xstats_name_off bnxt_tx_ext_stats_strings[] = {
421 {"tx_bytes_cos0", offsetof(struct tx_port_stats_ext,
423 {"tx_bytes_cos1", offsetof(struct tx_port_stats_ext,
425 {"tx_bytes_cos2", offsetof(struct tx_port_stats_ext,
427 {"tx_bytes_cos3", offsetof(struct tx_port_stats_ext,
429 {"tx_bytes_cos4", offsetof(struct tx_port_stats_ext,
431 {"tx_bytes_cos5", offsetof(struct tx_port_stats_ext,
433 {"tx_bytes_cos6", offsetof(struct tx_port_stats_ext,
435 {"tx_bytes_cos7", offsetof(struct tx_port_stats_ext,
437 {"tx_packets_cos0", offsetof(struct tx_port_stats_ext,
439 {"tx_packets_cos1", offsetof(struct tx_port_stats_ext,
441 {"tx_packets_cos2", offsetof(struct tx_port_stats_ext,
443 {"tx_packets_cos3", offsetof(struct tx_port_stats_ext,
445 {"tx_packets_cos4", offsetof(struct tx_port_stats_ext,
447 {"tx_packets_cos5", offsetof(struct tx_port_stats_ext,
449 {"tx_packets_cos6", offsetof(struct tx_port_stats_ext,
451 {"tx_packets_cos7", offsetof(struct tx_port_stats_ext,
453 {"pfc_pri0_tx_duration_us", offsetof(struct tx_port_stats_ext,
454 pfc_pri0_tx_duration_us)},
455 {"pfc_pri0_tx_transitions", offsetof(struct tx_port_stats_ext,
456 pfc_pri0_tx_transitions)},
457 {"pfc_pri1_tx_duration_us", offsetof(struct tx_port_stats_ext,
458 pfc_pri1_tx_duration_us)},
459 {"pfc_pri1_tx_transitions", offsetof(struct tx_port_stats_ext,
460 pfc_pri1_tx_transitions)},
461 {"pfc_pri2_tx_duration_us", offsetof(struct tx_port_stats_ext,
462 pfc_pri2_tx_duration_us)},
463 {"pfc_pri2_tx_transitions", offsetof(struct tx_port_stats_ext,
464 pfc_pri2_tx_transitions)},
465 {"pfc_pri3_tx_duration_us", offsetof(struct tx_port_stats_ext,
466 pfc_pri3_tx_duration_us)},
467 {"pfc_pri3_tx_transitions", offsetof(struct tx_port_stats_ext,
468 pfc_pri3_tx_transitions)},
469 {"pfc_pri4_tx_duration_us", offsetof(struct tx_port_stats_ext,
470 pfc_pri4_tx_duration_us)},
471 {"pfc_pri4_tx_transitions", offsetof(struct tx_port_stats_ext,
472 pfc_pri4_tx_transitions)},
473 {"pfc_pri5_tx_duration_us", offsetof(struct tx_port_stats_ext,
474 pfc_pri5_tx_duration_us)},
475 {"pfc_pri5_tx_transitions", offsetof(struct tx_port_stats_ext,
476 pfc_pri5_tx_transitions)},
477 {"pfc_pri6_tx_duration_us", offsetof(struct tx_port_stats_ext,
478 pfc_pri6_tx_duration_us)},
479 {"pfc_pri6_tx_transitions", offsetof(struct tx_port_stats_ext,
480 pfc_pri6_tx_transitions)},
481 {"pfc_pri7_tx_duration_us", offsetof(struct tx_port_stats_ext,
482 pfc_pri7_tx_duration_us)},
483 {"pfc_pri7_tx_transitions", offsetof(struct tx_port_stats_ext,
484 pfc_pri7_tx_transitions)},
488 * Statistics functions
491 void bnxt_free_stats(struct bnxt *bp)
495 for (i = 0; i < (int)bp->tx_cp_nr_rings; i++) {
496 struct bnxt_tx_queue *txq = bp->tx_queues[i];
498 bnxt_free_txq_stats(txq);
500 for (i = 0; i < (int)bp->rx_cp_nr_rings; i++) {
501 struct bnxt_rx_queue *rxq = bp->rx_queues[i];
503 bnxt_free_rxq_stats(rxq);
507 int bnxt_stats_get_op(struct rte_eth_dev *eth_dev,
508 struct rte_eth_stats *bnxt_stats)
512 struct bnxt *bp = eth_dev->data->dev_private;
513 unsigned int num_q_stats;
515 rc = is_bnxt_in_error(bp);
519 if (!eth_dev->data->dev_started)
522 num_q_stats = RTE_MIN(bp->rx_cp_nr_rings,
523 (unsigned int)RTE_ETHDEV_QUEUE_STAT_CNTRS);
525 for (i = 0; i < num_q_stats; i++) {
526 struct bnxt_rx_queue *rxq = bp->rx_queues[i];
527 struct bnxt_cp_ring_info *cpr = rxq->cp_ring;
529 rc = bnxt_hwrm_ctx_qstats(bp, cpr->hw_stats_ctx_id, i,
533 bnxt_stats->rx_nombuf +=
534 rte_atomic64_read(&rxq->rx_mbuf_alloc_fail);
537 num_q_stats = RTE_MIN(bp->tx_cp_nr_rings,
538 (unsigned int)RTE_ETHDEV_QUEUE_STAT_CNTRS);
540 for (i = 0; i < num_q_stats; i++) {
541 struct bnxt_tx_queue *txq = bp->tx_queues[i];
542 struct bnxt_cp_ring_info *cpr = txq->cp_ring;
544 rc = bnxt_hwrm_ctx_qstats(bp, cpr->hw_stats_ctx_id, i,
550 rc = bnxt_hwrm_func_qstats(bp, 0xffff, bnxt_stats, NULL);
554 int bnxt_stats_reset_op(struct rte_eth_dev *eth_dev)
556 struct bnxt *bp = eth_dev->data->dev_private;
560 ret = is_bnxt_in_error(bp);
564 if (!eth_dev->data->dev_started) {
565 PMD_DRV_LOG(ERR, "Device Initialization not complete!\n");
569 ret = bnxt_clear_all_hwrm_stat_ctxs(bp);
570 for (i = 0; i < bp->rx_cp_nr_rings; i++) {
571 struct bnxt_rx_queue *rxq = bp->rx_queues[i];
573 rte_atomic64_clear(&rxq->rx_mbuf_alloc_fail);
579 int bnxt_dev_xstats_get_op(struct rte_eth_dev *eth_dev,
580 struct rte_eth_xstat *xstats, unsigned int n)
582 struct bnxt *bp = eth_dev->data->dev_private;
583 unsigned int count, i;
584 unsigned int rx_port_stats_ext_cnt;
585 unsigned int tx_port_stats_ext_cnt;
586 unsigned int stat_size = sizeof(uint64_t);
587 struct hwrm_func_qstats_output func_qstats = {0};
588 unsigned int stat_count;
591 rc = is_bnxt_in_error(bp);
598 memset(xstats, 0, sizeof(*xstats));
600 bnxt_hwrm_func_qstats(bp, 0xffff, NULL, &func_qstats);
601 bnxt_hwrm_port_qstats(bp);
602 bnxt_hwrm_ext_port_qstats(bp);
603 rx_port_stats_ext_cnt = RTE_MIN(RTE_DIM(bnxt_rx_ext_stats_strings),
604 (bp->fw_rx_port_stats_ext_size /
606 tx_port_stats_ext_cnt = RTE_MIN(RTE_DIM(bnxt_tx_ext_stats_strings),
607 (bp->fw_tx_port_stats_ext_size /
610 count = RTE_DIM(bnxt_rx_stats_strings) +
611 RTE_DIM(bnxt_tx_stats_strings) +
612 RTE_DIM(bnxt_func_stats_strings) +
613 RTE_DIM(bnxt_rx_ext_stats_strings) +
614 RTE_DIM(bnxt_tx_ext_stats_strings);
621 for (i = 0; i < RTE_DIM(bnxt_rx_stats_strings); i++) {
622 uint64_t *rx_stats = (uint64_t *)bp->hw_rx_port_stats;
623 xstats[count].id = count;
624 xstats[count].value = rte_le_to_cpu_64(
625 *(uint64_t *)((char *)rx_stats +
626 bnxt_rx_stats_strings[i].offset));
630 for (i = 0; i < RTE_DIM(bnxt_tx_stats_strings); i++) {
631 uint64_t *tx_stats = (uint64_t *)bp->hw_tx_port_stats;
632 xstats[count].id = count;
633 xstats[count].value = rte_le_to_cpu_64(
634 *(uint64_t *)((char *)tx_stats +
635 bnxt_tx_stats_strings[i].offset));
639 for (i = 0; i < RTE_DIM(bnxt_func_stats_strings); i++) {
640 xstats[count].id = count;
641 xstats[count].value =
642 rte_le_to_cpu_64(((uint64_t *)&func_qstats)[i]);
647 for (i = 0; i < rx_port_stats_ext_cnt; i++) {
648 uint64_t *rx_stats_ext = (uint64_t *)bp->hw_rx_port_stats_ext;
650 xstats[count].value = rte_le_to_cpu_64
651 (*(uint64_t *)((char *)rx_stats_ext +
652 bnxt_rx_ext_stats_strings[i].offset));
657 for (i = 0; i < tx_port_stats_ext_cnt; i++) {
658 uint64_t *tx_stats_ext = (uint64_t *)bp->hw_tx_port_stats_ext;
660 xstats[count].value = rte_le_to_cpu_64
661 (*(uint64_t *)((char *)tx_stats_ext +
662 bnxt_tx_ext_stats_strings[i].offset));
670 int bnxt_dev_xstats_get_names_op(struct rte_eth_dev *eth_dev,
671 struct rte_eth_xstat_name *xstats_names,
672 __rte_unused unsigned int limit)
674 const unsigned int stat_cnt = RTE_DIM(bnxt_rx_stats_strings) +
675 RTE_DIM(bnxt_tx_stats_strings) +
676 RTE_DIM(bnxt_func_stats_strings) +
677 RTE_DIM(bnxt_rx_ext_stats_strings) +
678 RTE_DIM(bnxt_tx_ext_stats_strings);
679 struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private;
680 unsigned int i, count;
683 rc = is_bnxt_in_error(bp);
687 if (xstats_names != NULL) {
690 for (i = 0; i < RTE_DIM(bnxt_rx_stats_strings); i++) {
691 strlcpy(xstats_names[count].name,
692 bnxt_rx_stats_strings[i].name,
693 sizeof(xstats_names[count].name));
697 for (i = 0; i < RTE_DIM(bnxt_tx_stats_strings); i++) {
698 strlcpy(xstats_names[count].name,
699 bnxt_tx_stats_strings[i].name,
700 sizeof(xstats_names[count].name));
704 for (i = 0; i < RTE_DIM(bnxt_func_stats_strings); i++) {
705 strlcpy(xstats_names[count].name,
706 bnxt_func_stats_strings[i].name,
707 sizeof(xstats_names[count].name));
711 for (i = 0; i < RTE_DIM(bnxt_rx_ext_stats_strings); i++) {
712 strlcpy(xstats_names[count].name,
713 bnxt_rx_ext_stats_strings[i].name,
714 sizeof(xstats_names[count].name));
719 for (i = 0; i < RTE_DIM(bnxt_tx_ext_stats_strings); i++) {
720 strlcpy(xstats_names[count].name,
721 bnxt_tx_ext_stats_strings[i].name,
722 sizeof(xstats_names[count].name));
731 int bnxt_dev_xstats_reset_op(struct rte_eth_dev *eth_dev)
733 struct bnxt *bp = eth_dev->data->dev_private;
736 ret = is_bnxt_in_error(bp);
740 if (BNXT_VF(bp) || !BNXT_SINGLE_PF(bp) ||
741 !(bp->flags & BNXT_FLAG_PORT_STATS)) {
742 PMD_DRV_LOG(ERR, "Operation not supported\n");
746 ret = bnxt_hwrm_port_clr_stats(bp);
748 PMD_DRV_LOG(ERR, "Failed to reset xstats: %s\n",
754 int bnxt_dev_xstats_get_by_id_op(struct rte_eth_dev *dev, const uint64_t *ids,
755 uint64_t *values, unsigned int limit)
757 const unsigned int stat_cnt = RTE_DIM(bnxt_rx_stats_strings) +
758 RTE_DIM(bnxt_tx_stats_strings) +
759 RTE_DIM(bnxt_func_stats_strings) +
760 RTE_DIM(bnxt_rx_ext_stats_strings) +
761 RTE_DIM(bnxt_tx_ext_stats_strings);
762 struct bnxt *bp = dev->data->dev_private;
763 struct rte_eth_xstat xstats[stat_cnt];
764 uint64_t values_copy[stat_cnt];
768 rc = is_bnxt_in_error(bp);
773 return bnxt_dev_xstats_get_op(dev, xstats, stat_cnt);
775 bnxt_dev_xstats_get_by_id_op(dev, NULL, values_copy, stat_cnt);
776 for (i = 0; i < limit; i++) {
777 if (ids[i] >= stat_cnt) {
778 PMD_DRV_LOG(ERR, "id value isn't valid");
781 values[i] = values_copy[ids[i]];
786 int bnxt_dev_xstats_get_names_by_id_op(struct rte_eth_dev *dev,
787 struct rte_eth_xstat_name *xstats_names,
788 const uint64_t *ids, unsigned int limit)
790 const unsigned int stat_cnt = RTE_DIM(bnxt_rx_stats_strings) +
791 RTE_DIM(bnxt_tx_stats_strings) +
792 RTE_DIM(bnxt_func_stats_strings) +
793 RTE_DIM(bnxt_rx_ext_stats_strings) +
794 RTE_DIM(bnxt_tx_ext_stats_strings);
795 struct rte_eth_xstat_name xstats_names_copy[stat_cnt];
796 struct bnxt *bp = dev->data->dev_private;
800 rc = is_bnxt_in_error(bp);
805 return bnxt_dev_xstats_get_names_op(dev, xstats_names,
807 bnxt_dev_xstats_get_names_by_id_op(dev, xstats_names_copy, NULL,
810 for (i = 0; i < limit; i++) {
811 if (ids[i] >= stat_cnt) {
812 PMD_DRV_LOG(ERR, "id value isn't valid");
815 strcpy(xstats_names[i].name,
816 xstats_names_copy[ids[i]].name);