All of lore.kernel.org
 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 1/5] net/txgbe: fix query handling in xstats_get
Date: Tue,  8 Oct 2024 08:59:55 -0700	[thread overview]
Message-ID: <20241008160209.68000-2-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: 91fe49c87d76 ("net/txgbe: support device xstats")
Cc: jiawenwu@trustnetic.com

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/txgbe/txgbe_ethdev.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/drivers/net/txgbe/txgbe_ethdev.c b/drivers/net/txgbe/txgbe_ethdev.c
index 2834468764..ee829d9120 100644
--- a/drivers/net/txgbe/txgbe_ethdev.c
+++ b/drivers/net/txgbe/txgbe_ethdev.c
@@ -2547,19 +2547,13 @@ txgbe_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats,
 	struct txgbe_hw_stats *hw_stats = TXGBE_DEV_STATS(dev);
 	unsigned int i, count;
 
-	txgbe_read_stats_registers(hw, hw_stats);
-
-	/* If this is a reset xstats is NULL, and we have cleared the
-	 * registers by reading them.
-	 */
 	count = txgbe_xstats_calc_num(dev);
-	if (xstats == NULL)
+	if (limit < count)
 		return count;
 
-	limit = min(limit, txgbe_xstats_calc_num(dev));
-
+	txgbe_read_stats_registers(hw, hw_stats);
 	/* Extended stats from txgbe_hw_stats */
-	for (i = 0; i < limit; i++) {
+	for (i = 0; i < count; i++) {
 		uint32_t offset = 0;
 
 		if (txgbe_get_offset_by_id(i, &offset)) {
-- 
2.45.2


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

Thread overview: 12+ 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 ` Stephen Hemminger [this message]
2024-10-09  8:00   ` [RFC 1/5] net/txgbe: fix query handling in xstats_get Jiawen Wu
2024-10-08 15:59 ` [RFC 2/5] net/ngbe: " Stephen Hemminger
2024-12-04 22:19   ` Stephen Hemminger
2024-12-25  8:52     ` Jiawen Wu
2024-12-25 11:33       ` Zaiyu Wang
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-12-04 22:19   ` Stephen Hemminger
2024-10-08 15:59 ` [RFC 5/5] net/sfc: fix handling of xstats_get queries Stephen Hemminger
2024-12-04 22:18   ` 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-2-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.