DPDK patches and discussions
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>,
	Tetsuya Mukawa <mtetsuyah@gmail.com>
Subject: [PATCH 4/4] net/null: count all queues
Date: Wed, 26 Mar 2025 14:35:28 -0700	[thread overview]
Message-ID: <20250326213608.581345-5-stephen@networkplumber.org> (raw)
In-Reply-To: <20250326213608.581345-1-stephen@networkplumber.org>

If RTE_ETHDEV_QUEUE_STAT_CNTRS is less than the number of queues
in a device, the device should still count packets for all queues.

Remove the igb_ prefix which was inherited from other driver.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/null/rte_eth_null.c | 31 +++++++++++++------------------
 1 file changed, 13 insertions(+), 18 deletions(-)

diff --git a/drivers/net/null/rte_eth_null.c b/drivers/net/null/rte_eth_null.c
index 7ac29b3f81..82b49d471d 100644
--- a/drivers/net/null/rte_eth_null.c
+++ b/drivers/net/null/rte_eth_null.c
@@ -304,31 +304,26 @@ eth_dev_info(struct rte_eth_dev *dev,
 static int
 eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *igb_stats)
 {
-	unsigned int i, num_stats;
+	const struct pmd_internals *internal = dev->data->dev_private;
+	unsigned int i;
 	unsigned long rx_total = 0, tx_total = 0;
-	const struct pmd_internals *internal;
 
-	if ((dev == NULL) || (igb_stats == NULL))
-		return -EINVAL;
+	for (i = 0; i < dev->data->nb_rx_queues; i++) {
+		uint64_t pkts = internal->rx_null_queues[i].rx_pkts;
 
-	internal = dev->data->dev_private;
-	num_stats = RTE_MIN((unsigned int)RTE_ETHDEV_QUEUE_STAT_CNTRS,
-			RTE_MIN(dev->data->nb_rx_queues,
-				RTE_DIM(internal->rx_null_queues)));
-	for (i = 0; i < num_stats; i++) {
-		igb_stats->q_ipackets[i] =
-			internal->rx_null_queues[i].rx_pkts;
-		rx_total += igb_stats->q_ipackets[i];
+		if (i < RTE_ETHDEV_QUEUE_STAT_CNTRS)
+			igb_stats->q_ipackets[i] = pkts;
+
+		rx_total += pkts;
 	}
 
-	num_stats = RTE_MIN((unsigned int)RTE_ETHDEV_QUEUE_STAT_CNTRS,
-			RTE_MIN(dev->data->nb_tx_queues,
-				RTE_DIM(internal->tx_null_queues)));
-	for (i = 0; i < num_stats; i++) {
+	for (i = 0; i < dev->data->nb_tx_queues; i++) {
 		uint64_t pkts = rte_atomic_load_explicit(&internal->tx_null_queues[i].tx_pkts,
-						   rte_memory_order_relaxed);
+							 rte_memory_order_relaxed);
+
+		if (i < RTE_ETHDEV_QUEUE_STAT_CNTRS)
+			igb_stats->q_opackets[i] = pkts;
 
-		igb_stats->q_opackets[i] = pkts;
 		tx_total += pkts;
 	}
 
-- 
2.47.2


      parent reply	other threads:[~2025-03-26 21:36 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-26 21:35 [PATCH 0/4] net/null optimizations Stephen Hemminger
2025-03-26 21:35 ` [PATCH 1/4] net/null: Tx optimizations Stephen Hemminger
2025-03-26 21:35 ` [PATCH 2/4] net/null: fix packet copy Stephen Hemminger
2025-03-26 21:35 ` [PATCH 3/4] net/null: optimize Rx Stephen Hemminger
2025-03-26 21:35 ` Stephen Hemminger [this message]

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=20250326213608.581345-5-stephen@networkplumber.org \
    --to=stephen@networkplumber.org \
    --cc=dev@dpdk.org \
    --cc=mtetsuyah@gmail.com \
    /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;
as well as URLs for NNTP newsgroup(s).