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>, jiawenwu@trustnetic.com
Subject: [RFC 2/5] net/ngbe: fix query handling in xstats_get
Date: Tue,  8 Oct 2024 08:59:56 -0700	[thread overview]
Message-ID: <20241008160209.68000-3-stephen@networkplumber.org> (raw)
In-Reply-To: <20241008160209.68000-1-stephen@networkplumber.org>

The xstats_get function in this driver did not act the same
as other drivers when queried. The correct check is to look
at the requested number of stats and compare it to the available
stats and if the request is too small, return the correct size.

Bugzilla ID: 1560
Fixes: 8b433d04adc9 ("net/ngbe: support device xstats")
Cc: jiawenwu@trustnetic.com

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/ngbe/ngbe_ethdev.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ngbe/ngbe_ethdev.c b/drivers/net/ngbe/ngbe_ethdev.c
index 6c45ffaad3..ee65829aa0 100644
--- a/drivers/net/ngbe/ngbe_ethdev.c
+++ b/drivers/net/ngbe/ngbe_ethdev.c
@@ -1693,19 +1693,16 @@ ngbe_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats,
 	struct ngbe_hw_stats *hw_stats = NGBE_DEV_STATS(dev);
 	unsigned int i, count;
 
-	ngbe_read_stats_registers(hw, hw_stats);
-
-	/* If this is a reset xstats is NULL, and we have cleared the
-	 * registers by reading them.
-	 */
 	count = ngbe_xstats_calc_num(dev);
-	if (xstats == NULL)
+	if (limit < count)
 		return count;
 
+	ngbe_read_stats_registers(hw, hw_stats);
+
 	limit = min(limit, ngbe_xstats_calc_num(dev));
 
 	/* Extended stats from ngbe_hw_stats */
-	for (i = 0; i < limit; i++) {
+	for (i = 0; i < count; i++) {
 		uint32_t offset = 0;
 
 		if (ngbe_get_offset_by_id(i, &offset)) {
-- 
2.45.2


  parent reply	other threads:[~2024-10-08 16:02 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-08 15:59 [RFC 0/5] make PMD xstat_get alike Stephen Hemminger
2024-10-08 15:59 ` [RFC 1/5] net/txgbe: fix query handling in xstats_get Stephen Hemminger
2024-10-09  8:00   ` Jiawen Wu
2024-10-08 15:59 ` Stephen Hemminger [this message]
2024-10-08 15:59 ` [RFC 3/5] net/atlantic: fix handling of xstats_get Stephen Hemminger
2024-10-08 15:59 ` [RFC 4/5] net/octeontx: " Stephen Hemminger
2024-10-08 15:59 ` [RFC 5/5] net/sfc: fix handling of xstats_get queries 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=20241008160209.68000-3-stephen@networkplumber.org \
    --to=stephen@networkplumber.org \
    --cc=dev@dpdk.org \
    --cc=jiawenwu@trustnetic.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).