public inbox for dev@dpdk.org
 help / color / mirror / Atom feed
From: spinler@cesnet.cz
To: dev@dpdk.org
Cc: Martin Spinler <spinler@cesnet.cz>
Subject: [PATCH v2 6/6] net/nfb: read total stats from macs
Date: Tue, 17 Feb 2026 12:03:24 +0100	[thread overview]
Message-ID: <20260217110324.3344310-7-spinler@cesnet.cz> (raw)
In-Reply-To: <20260217110324.3344310-1-spinler@cesnet.cz>

From: Martin Spinler <spinler@cesnet.cz>

Both the Rx and Tx MAC components in firmware provide basic statistics.
Use these statistics instead of the sum of the per-queue counters.

Signed-off-by: Martin Spinler <spinler@cesnet.cz>
---
 drivers/net/nfb/nfb_stats.c | 40 +++++++++++++++++++++++--------------
 1 file changed, 25 insertions(+), 15 deletions(-)

diff --git a/drivers/net/nfb/nfb_stats.c b/drivers/net/nfb/nfb_stats.c
index 27a01c3160..f0a1c8a7e0 100644
--- a/drivers/net/nfb/nfb_stats.c
+++ b/drivers/net/nfb/nfb_stats.c
@@ -14,11 +14,11 @@ nfb_eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats,
 	uint16_t i;
 	uint16_t nb_rx = dev->data->nb_rx_queues;
 	uint16_t nb_tx = dev->data->nb_tx_queues;
-	uint64_t rx_total = 0;
-	uint64_t tx_total = 0;
-	uint64_t tx_err_total = 0;
-	uint64_t rx_total_bytes = 0;
-	uint64_t tx_total_bytes = 0;
+
+	int ret;
+	struct pmd_internals *internals = dev->process_private;
+	struct nc_rxmac_counters rx_cntrs;
+	struct nc_txmac_counters tx_cntrs;
 
 	struct ndp_rx_queue *rx_queue;
 	struct ndp_tx_queue *tx_queue;
@@ -29,8 +29,6 @@ nfb_eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats,
 			qstats->q_ipackets[i] = rx_queue->rx_pkts;
 			qstats->q_ibytes[i] = rx_queue->rx_bytes;
 		}
-		rx_total += rx_queue->rx_pkts;
-		rx_total_bytes += rx_queue->rx_bytes;
 	}
 
 	for (i = 0; i < nb_tx; i++) {
@@ -39,16 +37,28 @@ nfb_eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats,
 			qstats->q_opackets[i] = tx_queue->tx_pkts;
 			qstats->q_obytes[i] = tx_queue->tx_bytes;
 		}
-		tx_total += tx_queue->tx_pkts;
-		tx_total_bytes += tx_queue->tx_bytes;
-		tx_err_total += tx_queue->err_pkts;
 	}
 
-	stats->ipackets = rx_total;
-	stats->opackets = tx_total;
-	stats->ibytes = rx_total_bytes;
-	stats->obytes = tx_total_bytes;
-	stats->oerrors = tx_err_total;
+	for (i = 0; i < internals->max_rxmac; i++) {
+		ret = nc_rxmac_read_counters(internals->rxmac[i], &rx_cntrs, NULL);
+		if (ret)
+			return -EIO;
+
+		stats->ipackets += rx_cntrs.cnt_received;
+		stats->ibytes += rx_cntrs.cnt_octets;
+		stats->ierrors += rx_cntrs.cnt_erroneous;
+		stats->imissed += rx_cntrs.cnt_overflowed;
+	}
+
+	for (i = 0; i < internals->max_txmac; i++) {
+		ret = nc_txmac_read_counters(internals->txmac[i], &tx_cntrs);
+		if (ret)
+			return -EIO;
+
+		stats->opackets += tx_cntrs.cnt_sent;
+		stats->obytes += tx_cntrs.cnt_octets;
+		stats->oerrors += tx_cntrs.cnt_drop;
+	}
 	return 0;
 }
 
-- 
2.53.0


  parent reply	other threads:[~2026-02-17 11:04 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-06 17:04 [PATCH 0/7] net/nfb: ethernet enhancements spinler
2026-02-06 17:04 ` [PATCH 1/7] net/nfb: use MAC address assigned to card spinler
2026-02-06 17:04 ` [PATCH 2/7] net/nfb: get correct link speed spinler
2026-02-06 17:04 ` [PATCH 3/7] net/nfb: support real link-up/down config spinler
2026-02-06 17:04 ` [PATCH 4/7] net/nfb: support setting RS-FEC mode spinler
2026-02-06 17:04 ` [PATCH 5/7] net/nfb: support setting Rx MTU spinler
2026-02-18 18:20   ` Stephen Hemminger
2026-02-19  6:20     ` Martin Spinler
2026-02-06 17:04 ` [PATCH 6/7] net/nfb: read total stats from macs spinler
2026-02-06 17:04 ` [PATCH 7/7] doc/nfb: update release notes for nfb driver spinler
2026-02-17  4:37   ` Stephen Hemminger
2026-02-10  0:33 ` [PATCH 0/7] net/nfb: ethernet enhancements Stephen Hemminger
2026-02-12 18:52 ` Stephen Hemminger
2026-02-17 11:03 ` [PATCH v2 0/6] " spinler
2026-02-17 11:03   ` [PATCH v2 1/6] net/nfb: use MAC address assigned to card spinler
2026-02-17 11:03   ` [PATCH v2 2/6] net/nfb: get correct link speed spinler
2026-02-17 11:03   ` [PATCH v2 3/6] net/nfb: support real link-up/down config spinler
2026-02-17 11:03   ` [PATCH v2 4/6] net/nfb: support setting RS-FEC mode spinler
2026-02-17 11:03   ` [PATCH v2 5/6] net/nfb: support setting Rx MTU spinler
2026-02-17 11:03   ` spinler [this message]
2026-02-18 18:21   ` [PATCH v2 0/6] net/nfb: ethernet enhancements Stephen Hemminger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260217110324.3344310-7-spinler@cesnet.cz \
    --to=spinler@cesnet.cz \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox