From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 05D1245AE3; Tue, 8 Oct 2024 18:02:29 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 48EC040A6F; Tue, 8 Oct 2024 18:02:24 +0200 (CEST) Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) by mails.dpdk.org (Postfix) with ESMTP id 39EA84021E for ; Tue, 8 Oct 2024 18:02:21 +0200 (CEST) Received: by mail-pf1-f178.google.com with SMTP id d2e1a72fcca58-71e05198d1dso1549812b3a.1 for ; Tue, 08 Oct 2024 09:02:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1728403340; x=1729008140; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=IfIfrHi5x1eKVmVzy1inJTZSCn4e4xtFAZUkxl5ibgQ=; b=FUW7aJWY0tfYXb6PIn04xdhhPKZC9s/jnJZvzHzFG/DWhMysV+onkD8FZAfFC4s9we 5SbWU7Cn0wnHfTn0XJ2hXp1J0PsyoJ0sdST9L6cQAnrcHiAiRPQrXz5OCphS0UkXADH0 iDNpsTuf+Wr09HZLM33hcSlJNoa1BAfP4T+as+zG5H66sp9l4O5GvyWSS/xnVVthKOr9 idKQHc2lHZbimxUMp5tIdu9wC8aWzS6E58TcLKywUMXeXB+7/CJAAeBXGhBtUiF9nJRW XtemgqREocjT5gVskZVF5aRBhfVrfOBjYcqOpFz5kuVwYFQ9fTqvqifmYiBJa8VmF8HS pLyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728403340; x=1729008140; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IfIfrHi5x1eKVmVzy1inJTZSCn4e4xtFAZUkxl5ibgQ=; b=RpMn2X2YRPqtmzS2T7O3c6jw+TxARCBxAF8H7RAme1L/NRpkeVRe84kMlutDrvRWd6 ratpcIRQgQEEjfUJ/KSINAgW0TAA87FUgUgvOdh9mnz/hR7rzXGx6cRrD7G04rdOjG4B hKpf2pfod1G+D2kqWYCRx8DMxv1UaVdLfjhkj4iuDleUJV5djLVS3t47+8op/J2NIIKN 765qhZ6vaZVkVVgsxlSWbQLjFBcv4t48jMWCrSPdOOrpaqPI9Tbr2IT06pyAkod7oqAo ceXuvnnA6dhGFnaUNwCrEbM8JpzjoKMKfMquTm1dcaQRepKWpmxKC6IVENXtTgwzX4uF WBXQ== X-Gm-Message-State: AOJu0Yy9/ZgdcMzQUGoNRAsF70cL8rAWWJgq/Xaaw2XIaa0jCI4/QPrr 3eUNwajq7C1excGgJf11mBpC8LgcKHt9+AcgNKp2dcjPIZwitvcA9Gb7Cq4Kpr3kbsxTOZpH1uj dms9akg== X-Google-Smtp-Source: AGHT+IHnJBXSsAwG0i7jajMhZ/LPCK4wPyy2PKQ25ipjKh/VCAQAPvClkFImoz+U09czCjaiBRHarQ== X-Received: by 2002:a05:6a21:8cc4:b0:1cf:2a85:722d with SMTP id adf61e73a8af0-1d6dfa25a45mr22139545637.3.1728403340367; Tue, 08 Oct 2024 09:02:20 -0700 (PDT) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7e9f6c3758esm7028267a12.74.2024.10.08.09.02.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 09:02:20 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , jiawenwu@trustnetic.com Subject: [RFC 1/5] net/txgbe: fix query handling in xstats_get Date: Tue, 8 Oct 2024 08:59:55 -0700 Message-ID: <20241008160209.68000-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241008160209.68000-1-stephen@networkplumber.org> References: <20241008160209.68000-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.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 --- 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