1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2019 Cesnet
3 * Copyright(c) 2019 Netcope Technologies, a.s. <info@netcope.com>
11 nfb_eth_stats_get(struct rte_eth_dev *dev,
12 struct rte_eth_stats *stats)
15 uint16_t nb_rx = dev->data->nb_rx_queues;
16 uint16_t nb_tx = dev->data->nb_tx_queues;
17 uint64_t rx_total = 0;
18 uint64_t tx_total = 0;
19 uint64_t tx_err_total = 0;
20 uint64_t rx_total_bytes = 0;
21 uint64_t tx_total_bytes = 0;
23 struct ndp_rx_queue *rx_queue = *((struct ndp_rx_queue **)
24 dev->data->rx_queues);
25 struct ndp_tx_queue *tx_queue = *((struct ndp_tx_queue **)
26 dev->data->tx_queues);
28 for (i = 0; i < nb_rx; i++) {
29 if (i < RTE_ETHDEV_QUEUE_STAT_CNTRS) {
30 stats->q_ipackets[i] = rx_queue[i].rx_pkts;
31 stats->q_ibytes[i] = rx_queue[i].rx_bytes;
33 rx_total += rx_queue[i].rx_pkts;
34 rx_total_bytes += rx_queue[i].rx_bytes;
37 for (i = 0; i < nb_tx; i++) {
38 if (i < RTE_ETHDEV_QUEUE_STAT_CNTRS) {
39 stats->q_opackets[i] = tx_queue[i].tx_pkts;
40 stats->q_obytes[i] = tx_queue[i].tx_bytes;
42 tx_total += tx_queue[i].tx_pkts;
43 tx_total_bytes += tx_queue[i].tx_bytes;
44 tx_err_total += tx_queue[i].err_pkts;
47 stats->ipackets = rx_total;
48 stats->opackets = tx_total;
49 stats->ibytes = rx_total_bytes;
50 stats->obytes = tx_total_bytes;
51 stats->oerrors = tx_err_total;
56 nfb_eth_stats_reset(struct rte_eth_dev *dev)
59 uint16_t nb_rx = dev->data->nb_rx_queues;
60 uint16_t nb_tx = dev->data->nb_tx_queues;
62 struct ndp_rx_queue *rx_queue = *((struct ndp_rx_queue **)
63 dev->data->rx_queues);
64 struct ndp_tx_queue *tx_queue = *((struct ndp_tx_queue **)
65 dev->data->tx_queues);
67 for (i = 0; i < nb_rx; i++) {
68 rx_queue[i].rx_pkts = 0;
69 rx_queue[i].rx_bytes = 0;
70 rx_queue[i].err_pkts = 0;
72 for (i = 0; i < nb_tx; i++) {
73 tx_queue[i].tx_pkts = 0;
74 tx_queue[i].tx_bytes = 0;
75 tx_queue[i].err_pkts = 0;