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>,
	ivan.ilchenko@oktetlabs.ru
Subject: [RFC 5/5] net/sfc: fix handling of xstats_get queries
Date: Tue,  8 Oct 2024 08:59:59 -0700	[thread overview]
Message-ID: <20241008160209.68000-6-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.

Fixes: fdd7719eb3c1 ("net/sfc: add xstats for Rx/Tx doorbells")
Cc: ivan.ilchenko@oktetlabs.ru
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/sfc/sfc_ethdev.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c
index 3480a51642..f0710dab5c 100644
--- a/drivers/net/sfc/sfc_ethdev.c
+++ b/drivers/net/sfc/sfc_ethdev.c
@@ -833,11 +833,12 @@ sfc_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats,
 {
 	struct sfc_adapter *sa = sfc_adapter_by_eth_dev(dev);
 	unsigned int nb_written = 0;
-	unsigned int nb_supported = 0;
+	unsigned int nb_supported;
 	int rc;
 
-	if (unlikely(xstats == NULL))
-		return sfc_xstats_get_nb_supported(sa);
+	nb_supported = sfc_xstats_get_nb_supported(sa);
+	if (xstats_count < nb_supported)
+		return nb_supported;
 
 	rc = sfc_port_get_mac_stats(sa, xstats, xstats_count, &nb_written);
 	if (rc < 0)
-- 
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 ` [RFC 2/5] net/ngbe: " Stephen Hemminger
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 ` 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=20241008160209.68000-6-stephen@networkplumber.org \
    --to=stephen@networkplumber.org \
    --cc=dev@dpdk.org \
    --cc=ivan.ilchenko@oktetlabs.ru \
    /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).