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_align_err_frames", offsetof(struct rx_port_stats,
59 rx_align_err_frames)},
60 {"rx_ovrsz_frames", offsetof(struct rx_port_stats,
62 {"rx_jbr_frames", offsetof(struct rx_port_stats,
64 {"rx_mtu_err_frames", offsetof(struct rx_port_stats,
66 {"rx_tagged_frames", offsetof(struct rx_port_stats,
68 {"rx_double_tagged_frames", offsetof(struct rx_port_stats,
69 rx_double_tagged_frames)},
70 {"rx_good_frames", offsetof(struct rx_port_stats,
72 {"rx_undrsz_frames", offsetof(struct rx_port_stats,
74 {"rx_eee_lpi_events", offsetof(struct rx_port_stats,
76 {"rx_eee_lpi_duration", offsetof(struct rx_port_stats,
77 rx_eee_lpi_duration)},
78 {"rx_bytes", offsetof(struct rx_port_stats,
80 {"rx_runt_bytes", offsetof(struct rx_port_stats,
82 {"rx_runt_frames", offsetof(struct rx_port_stats,
84 {"rx_pfc_ena_frames_pri0", offsetof(struct rx_port_stats,
85 rx_pfc_ena_frames_pri0)},
86 {"rx_pfc_ena_frames_pri1", offsetof(struct rx_port_stats,
87 rx_pfc_ena_frames_pri1)},
88 {"rx_pfc_ena_frames_pri2", offsetof(struct rx_port_stats,
89 rx_pfc_ena_frames_pri2)},
90 {"rx_pfc_ena_frames_pri3", offsetof(struct rx_port_stats,
91 rx_pfc_ena_frames_pri3)},
92 {"rx_pfc_ena_frames_pri4", offsetof(struct rx_port_stats,
93 rx_pfc_ena_frames_pri4)},
94 {"rx_pfc_ena_frames_pri5", offsetof(struct rx_port_stats,
95 rx_pfc_ena_frames_pri5)},
96 {"rx_pfc_ena_frames_pri6", offsetof(struct rx_port_stats,
97 rx_pfc_ena_frames_pri6)},
98 {"rx_pfc_ena_frames_pri7", offsetof(struct rx_port_stats,
99 rx_pfc_ena_frames_pri7)},
102 static const struct bnxt_xstats_name_off bnxt_tx_stats_strings[] = {
103 {"tx_64b_frames", offsetof(struct tx_port_stats,
105 {"tx_65b_127b_frames", offsetof(struct tx_port_stats,
106 tx_65b_127b_frames)},
107 {"tx_128b_255b_frames", offsetof(struct tx_port_stats,
108 tx_128b_255b_frames)},
109 {"tx_256b_511b_frames", offsetof(struct tx_port_stats,
110 tx_256b_511b_frames)},
111 {"tx_512b_1023b_frames", offsetof(struct tx_port_stats,
112 tx_512b_1023b_frames)},
113 {"tx_1024b_1518b_frames", offsetof(struct tx_port_stats,
114 tx_1024b_1518b_frames)},
115 {"tx_good_vlan_frames", offsetof(struct tx_port_stats,
116 tx_good_vlan_frames)},
117 {"tx_1519b_2047b_frames", offsetof(struct tx_port_stats,
118 tx_1519b_2047b_frames)},
119 {"tx_2048b_4095b_frames", offsetof(struct tx_port_stats,
120 tx_2048b_4095b_frames)},
121 {"tx_4096b_9216b_frames", offsetof(struct tx_port_stats,
122 tx_4096b_9216b_frames)},
123 {"tx_9217b_16383b_frames", offsetof(struct tx_port_stats,
124 tx_9217b_16383b_frames)},
125 {"tx_good_frames", offsetof(struct tx_port_stats,
127 {"tx_total_frames", offsetof(struct tx_port_stats,
129 {"tx_ucast_frames", offsetof(struct tx_port_stats,
131 {"tx_mcast_frames", offsetof(struct tx_port_stats,
133 {"tx_bcast_frames", offsetof(struct tx_port_stats,
135 {"tx_pause_frames", offsetof(struct tx_port_stats,
137 {"tx_pfc_frames", offsetof(struct tx_port_stats,
139 {"tx_jabber_frames", offsetof(struct tx_port_stats,
141 {"tx_fcs_err_frames", offsetof(struct tx_port_stats,
143 {"tx_err", offsetof(struct tx_port_stats,
145 {"tx_fifo_underruns", offsetof(struct tx_port_stats,
147 {"tx_eee_lpi_events", offsetof(struct tx_port_stats,
149 {"tx_eee_lpi_duration", offsetof(struct tx_port_stats,
150 tx_eee_lpi_duration)},
151 {"tx_total_collisions", offsetof(struct tx_port_stats,
152 tx_total_collisions)},
153 {"tx_bytes", offsetof(struct tx_port_stats,
155 {"tx_pfc_ena_frames_pri0", offsetof(struct tx_port_stats,
156 tx_pfc_ena_frames_pri0)},
157 {"tx_pfc_ena_frames_pri1", offsetof(struct tx_port_stats,
158 tx_pfc_ena_frames_pri1)},
159 {"tx_pfc_ena_frames_pri2", offsetof(struct tx_port_stats,
160 tx_pfc_ena_frames_pri2)},
161 {"tx_pfc_ena_frames_pri3", offsetof(struct tx_port_stats,
162 tx_pfc_ena_frames_pri3)},
163 {"tx_pfc_ena_frames_pri4", offsetof(struct tx_port_stats,
164 tx_pfc_ena_frames_pri4)},
165 {"tx_pfc_ena_frames_pri5", offsetof(struct tx_port_stats,
166 tx_pfc_ena_frames_pri5)},
167 {"tx_pfc_ena_frames_pri6", offsetof(struct tx_port_stats,
168 tx_pfc_ena_frames_pri6)},
169 {"tx_pfc_ena_frames_pri7", offsetof(struct tx_port_stats,
170 tx_pfc_ena_frames_pri7)},
173 static const struct bnxt_xstats_name_off bnxt_func_stats_strings[] = {
174 {"tx_ucast_pkts", offsetof(struct hwrm_func_qstats_output,
176 {"tx_mcast_pkts", offsetof(struct hwrm_func_qstats_output,
178 {"tx_bcast_pkts", offsetof(struct hwrm_func_qstats_output,
180 {"tx_discard_pkts", offsetof(struct hwrm_func_qstats_output,
182 {"tx_drop_pkts", offsetof(struct hwrm_func_qstats_output,
184 {"tx_ucast_bytes", offsetof(struct hwrm_func_qstats_output,
186 {"tx_mcast_bytes", offsetof(struct hwrm_func_qstats_output,
188 {"tx_bcast_bytes", offsetof(struct hwrm_func_qstats_output,
190 {"rx_ucast_pkts", offsetof(struct hwrm_func_qstats_output,
192 {"rx_mcast_pkts", offsetof(struct hwrm_func_qstats_output,
194 {"rx_bcast_pkts", offsetof(struct hwrm_func_qstats_output,
196 {"rx_discard_pkts", offsetof(struct hwrm_func_qstats_output,
198 {"rx_drop_pkts", offsetof(struct hwrm_func_qstats_output,
200 {"rx_ucast_bytes", offsetof(struct hwrm_func_qstats_output,
202 {"rx_mcast_bytes", offsetof(struct hwrm_func_qstats_output,
204 {"rx_bcast_bytes", offsetof(struct hwrm_func_qstats_output,
206 {"rx_agg_pkts", offsetof(struct hwrm_func_qstats_output,
208 {"rx_agg_bytes", offsetof(struct hwrm_func_qstats_output,
210 {"rx_agg_events", offsetof(struct hwrm_func_qstats_output,
212 {"rx_agg_aborts", offsetof(struct hwrm_func_qstats_output,
216 static const struct bnxt_xstats_name_off bnxt_rx_ext_stats_strings[] = {
217 {"link_down_events", offsetof(struct rx_port_stats_ext,
219 {"continuous_pause_events", offsetof(struct rx_port_stats_ext,
220 continuous_pause_events)},
221 {"resume_pause_events", offsetof(struct rx_port_stats_ext,
222 resume_pause_events)},
223 {"continuous_roce_pause_events", offsetof(struct rx_port_stats_ext,
224 continuous_roce_pause_events)},
225 {"resume_roce_pause_events", offsetof(struct rx_port_stats_ext,
226 resume_roce_pause_events)},
227 {"rx_bytes_cos0", offsetof(struct rx_port_stats_ext,
229 {"rx_bytes_cos1", offsetof(struct rx_port_stats_ext,
231 {"rx_bytes_cos2", offsetof(struct rx_port_stats_ext,
233 {"rx_bytes_cos3", offsetof(struct rx_port_stats_ext,
235 {"rx_bytes_cos4", offsetof(struct rx_port_stats_ext,
237 {"rx_bytes_cos5", offsetof(struct rx_port_stats_ext,
239 {"rx_bytes_cos6", offsetof(struct rx_port_stats_ext,
241 {"rx_bytes_cos7", offsetof(struct rx_port_stats_ext,
243 {"rx_packets_cos0", offsetof(struct rx_port_stats_ext,
245 {"rx_packets_cos1", offsetof(struct rx_port_stats_ext,
247 {"rx_packets_cos2", offsetof(struct rx_port_stats_ext,
249 {"rx_packets_cos3", offsetof(struct rx_port_stats_ext,
251 {"rx_packets_cos4", offsetof(struct rx_port_stats_ext,
253 {"rx_packets_cos5", offsetof(struct rx_port_stats_ext,
255 {"rx_packets_cos6", offsetof(struct rx_port_stats_ext,
257 {"rx_packets_cos7", offsetof(struct rx_port_stats_ext,
259 {"pfc_pri0_rx_duration_us", offsetof(struct rx_port_stats_ext,
260 pfc_pri0_rx_duration_us)},
261 {"pfc_pri0_rx_transitions", offsetof(struct rx_port_stats_ext,
262 pfc_pri0_rx_transitions)},
263 {"pfc_pri1_rx_duration_us", offsetof(struct rx_port_stats_ext,
264 pfc_pri1_rx_duration_us)},
265 {"pfc_pri1_rx_transitions", offsetof(struct rx_port_stats_ext,
266 pfc_pri1_rx_transitions)},
267 {"pfc_pri2_rx_duration_us", offsetof(struct rx_port_stats_ext,
268 pfc_pri2_rx_duration_us)},
269 {"pfc_pri2_rx_transitions", offsetof(struct rx_port_stats_ext,
270 pfc_pri2_rx_transitions)},
271 {"pfc_pri3_rx_duration_us", offsetof(struct rx_port_stats_ext,
272 pfc_pri3_rx_duration_us)},
273 {"pfc_pri3_rx_transitions", offsetof(struct rx_port_stats_ext,
274 pfc_pri3_rx_transitions)},
275 {"pfc_pri4_rx_duration_us", offsetof(struct rx_port_stats_ext,
276 pfc_pri4_rx_duration_us)},
277 {"pfc_pri4_rx_transitions", offsetof(struct rx_port_stats_ext,
278 pfc_pri4_rx_transitions)},
279 {"pfc_pri5_rx_duration_us", offsetof(struct rx_port_stats_ext,
280 pfc_pri5_rx_duration_us)},
281 {"pfc_pri5_rx_transitions", offsetof(struct rx_port_stats_ext,
282 pfc_pri5_rx_transitions)},
283 {"pfc_pri6_rx_duration_us", offsetof(struct rx_port_stats_ext,
284 pfc_pri6_rx_duration_us)},
285 {"pfc_pri6_rx_transitions", offsetof(struct rx_port_stats_ext,
286 pfc_pri6_rx_transitions)},
287 {"pfc_pri7_rx_duration_us", offsetof(struct rx_port_stats_ext,
288 pfc_pri7_rx_duration_us)},
289 {"pfc_pri7_rx_transitions", offsetof(struct rx_port_stats_ext,
290 pfc_pri7_rx_transitions)},
293 static const struct bnxt_xstats_name_off bnxt_tx_ext_stats_strings[] = {
294 {"tx_bytes_cos0", offsetof(struct tx_port_stats_ext,
296 {"tx_bytes_cos1", offsetof(struct tx_port_stats_ext,
298 {"tx_bytes_cos2", offsetof(struct tx_port_stats_ext,
300 {"tx_bytes_cos3", offsetof(struct tx_port_stats_ext,
302 {"tx_bytes_cos4", offsetof(struct tx_port_stats_ext,
304 {"tx_bytes_cos5", offsetof(struct tx_port_stats_ext,
306 {"tx_bytes_cos6", offsetof(struct tx_port_stats_ext,
308 {"tx_bytes_cos7", offsetof(struct tx_port_stats_ext,
310 {"tx_packets_cos0", offsetof(struct tx_port_stats_ext,
312 {"tx_packets_cos1", offsetof(struct tx_port_stats_ext,
314 {"tx_packets_cos2", offsetof(struct tx_port_stats_ext,
316 {"tx_packets_cos3", offsetof(struct tx_port_stats_ext,
318 {"tx_packets_cos4", offsetof(struct tx_port_stats_ext,
320 {"tx_packets_cos5", offsetof(struct tx_port_stats_ext,
322 {"tx_packets_cos6", offsetof(struct tx_port_stats_ext,
324 {"tx_packets_cos7", offsetof(struct tx_port_stats_ext,
326 {"pfc_pri0_tx_duration_us", offsetof(struct tx_port_stats_ext,
327 pfc_pri0_tx_duration_us)},
328 {"pfc_pri0_tx_transitions", offsetof(struct tx_port_stats_ext,
329 pfc_pri0_tx_transitions)},
330 {"pfc_pri1_tx_duration_us", offsetof(struct tx_port_stats_ext,
331 pfc_pri1_tx_duration_us)},
332 {"pfc_pri1_tx_transitions", offsetof(struct tx_port_stats_ext,
333 pfc_pri1_tx_transitions)},
334 {"pfc_pri2_tx_duration_us", offsetof(struct tx_port_stats_ext,
335 pfc_pri2_tx_duration_us)},
336 {"pfc_pri2_tx_transitions", offsetof(struct tx_port_stats_ext,
337 pfc_pri2_tx_transitions)},
338 {"pfc_pri3_tx_duration_us", offsetof(struct tx_port_stats_ext,
339 pfc_pri3_tx_duration_us)},
340 {"pfc_pri3_tx_transitions", offsetof(struct tx_port_stats_ext,
341 pfc_pri3_tx_transitions)},
342 {"pfc_pri4_tx_duration_us", offsetof(struct tx_port_stats_ext,
343 pfc_pri4_tx_duration_us)},
344 {"pfc_pri4_tx_transitions", offsetof(struct tx_port_stats_ext,
345 pfc_pri4_tx_transitions)},
346 {"pfc_pri5_tx_duration_us", offsetof(struct tx_port_stats_ext,
347 pfc_pri5_tx_duration_us)},
348 {"pfc_pri5_tx_transitions", offsetof(struct tx_port_stats_ext,
349 pfc_pri5_tx_transitions)},
350 {"pfc_pri6_tx_duration_us", offsetof(struct tx_port_stats_ext,
351 pfc_pri6_tx_duration_us)},
352 {"pfc_pri6_tx_transitions", offsetof(struct tx_port_stats_ext,
353 pfc_pri6_tx_transitions)},
354 {"pfc_pri7_tx_duration_us", offsetof(struct tx_port_stats_ext,
355 pfc_pri7_tx_duration_us)},
356 {"pfc_pri7_tx_transitions", offsetof(struct tx_port_stats_ext,
357 pfc_pri7_tx_transitions)},
361 * Statistics functions
364 void bnxt_free_stats(struct bnxt *bp)
368 for (i = 0; i < (int)bp->tx_cp_nr_rings; i++) {
369 struct bnxt_tx_queue *txq = bp->tx_queues[i];
371 bnxt_free_txq_stats(txq);
373 for (i = 0; i < (int)bp->rx_cp_nr_rings; i++) {
374 struct bnxt_rx_queue *rxq = bp->rx_queues[i];
376 bnxt_free_rxq_stats(rxq);
380 int bnxt_stats_get_op(struct rte_eth_dev *eth_dev,
381 struct rte_eth_stats *bnxt_stats)
385 struct bnxt *bp = eth_dev->data->dev_private;
386 unsigned int num_q_stats;
388 rc = is_bnxt_in_error(bp);
392 if (!eth_dev->data->dev_started)
395 num_q_stats = RTE_MIN(bp->rx_cp_nr_rings,
396 (unsigned int)RTE_ETHDEV_QUEUE_STAT_CNTRS);
398 for (i = 0; i < num_q_stats; i++) {
399 struct bnxt_rx_queue *rxq = bp->rx_queues[i];
400 struct bnxt_cp_ring_info *cpr = rxq->cp_ring;
402 rc = bnxt_hwrm_ctx_qstats(bp, cpr->hw_stats_ctx_id, i,
406 bnxt_stats->rx_nombuf +=
407 rte_atomic64_read(&rxq->rx_mbuf_alloc_fail);
410 num_q_stats = RTE_MIN(bp->tx_cp_nr_rings,
411 (unsigned int)RTE_ETHDEV_QUEUE_STAT_CNTRS);
413 for (i = 0; i < num_q_stats; i++) {
414 struct bnxt_tx_queue *txq = bp->tx_queues[i];
415 struct bnxt_cp_ring_info *cpr = txq->cp_ring;
417 rc = bnxt_hwrm_ctx_qstats(bp, cpr->hw_stats_ctx_id, i,
423 rc = bnxt_hwrm_func_qstats(bp, 0xffff, bnxt_stats);
427 int bnxt_stats_reset_op(struct rte_eth_dev *eth_dev)
429 struct bnxt *bp = eth_dev->data->dev_private;
433 ret = is_bnxt_in_error(bp);
437 if (!eth_dev->data->dev_started) {
438 PMD_DRV_LOG(ERR, "Device Initialization not complete!\n");
442 ret = bnxt_clear_all_hwrm_stat_ctxs(bp);
443 for (i = 0; i < bp->rx_cp_nr_rings; i++) {
444 struct bnxt_rx_queue *rxq = bp->rx_queues[i];
446 rte_atomic64_clear(&rxq->rx_mbuf_alloc_fail);
452 int bnxt_dev_xstats_get_op(struct rte_eth_dev *eth_dev,
453 struct rte_eth_xstat *xstats, unsigned int n)
455 struct bnxt *bp = eth_dev->data->dev_private;
456 unsigned int count, i;
457 uint64_t tx_drop_pkts;
458 unsigned int rx_port_stats_ext_cnt;
459 unsigned int tx_port_stats_ext_cnt;
460 unsigned int stat_size = sizeof(uint64_t);
461 unsigned int stat_count;
464 rc = is_bnxt_in_error(bp);
471 memset(xstats, 0, sizeof(*xstats));
473 bnxt_hwrm_port_qstats(bp);
474 bnxt_hwrm_func_qstats_tx_drop(bp, 0xffff, &tx_drop_pkts);
475 bnxt_hwrm_ext_port_qstats(bp);
476 rx_port_stats_ext_cnt = RTE_MIN(RTE_DIM(bnxt_rx_ext_stats_strings),
477 (bp->fw_rx_port_stats_ext_size /
479 tx_port_stats_ext_cnt = RTE_MIN(RTE_DIM(bnxt_tx_ext_stats_strings),
480 (bp->fw_tx_port_stats_ext_size /
483 count = RTE_DIM(bnxt_rx_stats_strings) +
484 RTE_DIM(bnxt_tx_stats_strings) + 1/* For tx_drop_pkts */ +
485 RTE_DIM(bnxt_rx_ext_stats_strings) +
486 RTE_DIM(bnxt_tx_ext_stats_strings);
493 for (i = 0; i < RTE_DIM(bnxt_rx_stats_strings); i++) {
494 uint64_t *rx_stats = (uint64_t *)bp->hw_rx_port_stats;
495 xstats[count].id = count;
496 xstats[count].value = rte_le_to_cpu_64(
497 *(uint64_t *)((char *)rx_stats +
498 bnxt_rx_stats_strings[i].offset));
502 for (i = 0; i < RTE_DIM(bnxt_tx_stats_strings); i++) {
503 uint64_t *tx_stats = (uint64_t *)bp->hw_tx_port_stats;
504 xstats[count].id = count;
505 xstats[count].value = rte_le_to_cpu_64(
506 *(uint64_t *)((char *)tx_stats +
507 bnxt_tx_stats_strings[i].offset));
511 /* The Tx drop pkts aka the Anti spoof coounter */
512 xstats[count].id = count;
513 xstats[count].value = rte_le_to_cpu_64(tx_drop_pkts);
516 for (i = 0; i < rx_port_stats_ext_cnt; i++) {
517 uint64_t *rx_stats_ext = (uint64_t *)bp->hw_rx_port_stats_ext;
519 xstats[count].value = rte_le_to_cpu_64
520 (*(uint64_t *)((char *)rx_stats_ext +
521 bnxt_rx_ext_stats_strings[i].offset));
526 for (i = 0; i < tx_port_stats_ext_cnt; i++) {
527 uint64_t *tx_stats_ext = (uint64_t *)bp->hw_tx_port_stats_ext;
529 xstats[count].value = rte_le_to_cpu_64
530 (*(uint64_t *)((char *)tx_stats_ext +
531 bnxt_tx_ext_stats_strings[i].offset));
539 int bnxt_dev_xstats_get_names_op(struct rte_eth_dev *eth_dev,
540 struct rte_eth_xstat_name *xstats_names,
541 __rte_unused unsigned int limit)
543 /* Account for the Tx drop pkts aka the Anti spoof counter */
544 const unsigned int stat_cnt = RTE_DIM(bnxt_rx_stats_strings) +
545 RTE_DIM(bnxt_tx_stats_strings) + 1 +
546 RTE_DIM(bnxt_rx_ext_stats_strings) +
547 RTE_DIM(bnxt_tx_ext_stats_strings);
548 struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private;
549 unsigned int i, count;
552 rc = is_bnxt_in_error(bp);
556 if (xstats_names != NULL) {
559 for (i = 0; i < RTE_DIM(bnxt_rx_stats_strings); i++) {
560 strlcpy(xstats_names[count].name,
561 bnxt_rx_stats_strings[i].name,
562 sizeof(xstats_names[count].name));
566 for (i = 0; i < RTE_DIM(bnxt_tx_stats_strings); i++) {
567 strlcpy(xstats_names[count].name,
568 bnxt_tx_stats_strings[i].name,
569 sizeof(xstats_names[count].name));
573 strlcpy(xstats_names[count].name,
574 bnxt_func_stats_strings[4].name,
575 sizeof(xstats_names[count].name));
578 for (i = 0; i < RTE_DIM(bnxt_rx_ext_stats_strings); i++) {
579 strlcpy(xstats_names[count].name,
580 bnxt_rx_ext_stats_strings[i].name,
581 sizeof(xstats_names[count].name));
586 for (i = 0; i < RTE_DIM(bnxt_tx_ext_stats_strings); i++) {
587 strlcpy(xstats_names[count].name,
588 bnxt_tx_ext_stats_strings[i].name,
589 sizeof(xstats_names[count].name));
598 int bnxt_dev_xstats_reset_op(struct rte_eth_dev *eth_dev)
600 struct bnxt *bp = eth_dev->data->dev_private;
603 ret = is_bnxt_in_error(bp);
607 if (BNXT_VF(bp) || !BNXT_SINGLE_PF(bp) ||
608 !(bp->flags & BNXT_FLAG_PORT_STATS)) {
609 PMD_DRV_LOG(ERR, "Operation not supported\n");
613 ret = bnxt_hwrm_port_clr_stats(bp);
615 PMD_DRV_LOG(ERR, "Failed to reset xstats: %s\n",
621 int bnxt_dev_xstats_get_by_id_op(struct rte_eth_dev *dev, const uint64_t *ids,
622 uint64_t *values, unsigned int limit)
624 /* Account for the Tx drop pkts aka the Anti spoof counter */
625 const unsigned int stat_cnt = RTE_DIM(bnxt_rx_stats_strings) +
626 RTE_DIM(bnxt_tx_stats_strings) + 1 +
627 RTE_DIM(bnxt_rx_ext_stats_strings) +
628 RTE_DIM(bnxt_tx_ext_stats_strings);
629 struct bnxt *bp = dev->data->dev_private;
630 struct rte_eth_xstat xstats[stat_cnt];
631 uint64_t values_copy[stat_cnt];
635 rc = is_bnxt_in_error(bp);
640 return bnxt_dev_xstats_get_op(dev, xstats, stat_cnt);
642 bnxt_dev_xstats_get_by_id_op(dev, NULL, values_copy, stat_cnt);
643 for (i = 0; i < limit; i++) {
644 if (ids[i] >= stat_cnt) {
645 PMD_DRV_LOG(ERR, "id value isn't valid");
648 values[i] = values_copy[ids[i]];
653 int bnxt_dev_xstats_get_names_by_id_op(struct rte_eth_dev *dev,
654 struct rte_eth_xstat_name *xstats_names,
655 const uint64_t *ids, unsigned int limit)
657 /* Account for the Tx drop pkts aka the Anti spoof counter */
658 const unsigned int stat_cnt = RTE_DIM(bnxt_rx_stats_strings) +
659 RTE_DIM(bnxt_tx_stats_strings) + 1 +
660 RTE_DIM(bnxt_rx_ext_stats_strings) +
661 RTE_DIM(bnxt_tx_ext_stats_strings);
662 struct rte_eth_xstat_name xstats_names_copy[stat_cnt];
663 struct bnxt *bp = dev->data->dev_private;
667 rc = is_bnxt_in_error(bp);
672 return bnxt_dev_xstats_get_names_op(dev, xstats_names,
674 bnxt_dev_xstats_get_names_by_id_op(dev, xstats_names_copy, NULL,
677 for (i = 0; i < limit; i++) {
678 if (ids[i] >= stat_cnt) {
679 PMD_DRV_LOG(ERR, "id value isn't valid");
682 strcpy(xstats_names[i].name,
683 xstats_names_copy[ids[i]].name);