From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 0ECAB45AE3;
	Tue,  8 Oct 2024 18:02:36 +0200 (CEST)
Received: from mails.dpdk.org (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id 8E1FB40A89;
	Tue,  8 Oct 2024 18:02:25 +0200 (CEST)
Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com
 [209.85.210.171])
 by mails.dpdk.org (Postfix) with ESMTP id B000440684
 for <dev@dpdk.org>; Tue,  8 Oct 2024 18:02:22 +0200 (CEST)
Received: by mail-pf1-f171.google.com with SMTP id
 d2e1a72fcca58-71e1a715c72so293784b3a.1
 for <dev@dpdk.org>; Tue, 08 Oct 2024 09:02:22 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1728403342;
 x=1729008142; 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=LBaCoXP6VsFEPqB2qCkumsQyzP8sgwVm+/rXHZVXFcU=;
 b=kdDckivtMiQ5eOZ11nz9fpJTA+aiVxxZ021wdxUlBDHRvKbx+vhSa635xJqK9W35ro
 1zAgwoz0dKUd8M1YecjeJUhN5CfZkp+sEu7kqHd8ZnNflKaw1JI1BDVYfQuk/T66tlyb
 CkxXHF6GFIUyhaodPF6V4VEhu+cxi7k93hMVXXBAM7ma/2YObMbnsGstoW1tZXEnUNNk
 JfSjsIu8tVK7og6KbLcZ9nE9kDfF86bDZgKsXDzh78GgpbrBC9n4ZCr8Ai0YAOvBbE7p
 eLqC2tzlGwVtY6QDUE5Ip6HIQ5woVSds/jY1EP1y1piS8j88oePjM/T3A5thEXCC6/mY
 wXeA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1728403342; x=1729008142;
 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=LBaCoXP6VsFEPqB2qCkumsQyzP8sgwVm+/rXHZVXFcU=;
 b=NajZvFX3hBKH5pi7EMNU2CWU2LvR9gF4u4I6+1bUkk6xkquXg39kJ6F65bxAZD3hPL
 zUn2GtMqHcMd2U2KAFsUFxpRVEa3YTUjUbgNH5ekabe3FxvMWwHDpojG3RSHIqrCOCjJ
 D5T8hZD1yQrjQMabpJj0zvCya2/76+E6CmNViJ2+qut5P19muH1GdaAOnKC2hoAzsvOu
 FX9QWlkzdEWocuTysy6tbPZEN8btoEA8mBzbSsaFSY4vhKpDVSZX/hmvnSj/yapnwo6L
 CEblkZz4CpIZ37WA2+Hkco+hrgVRFHNy7cLOlFnh5eQypz3vI3MEDHeD+fc5gJCjjgXw
 lSTg==
X-Gm-Message-State: AOJu0Yy0e/3U4t6B07fdS8obQwrgwpBB8SUyqM+rR7zY3OA1NW2TMAw7
 gHG2vG/cJJmeB5DHRWNaQJ4qMVpy1f/eb7D8OgJUzJVo4cIKa049GYDG1qx95J20Rzm+dSRBwuf
 HkPc7jQ==
X-Google-Smtp-Source: AGHT+IHr8ajjAHHRNKWlGoxXCjFWgjzj/qDfnS7IPr6XmVWb0NAKj9rLW+vXp3hXgDXGAikVB4e3GA==
X-Received: by 2002:a05:6a20:c890:b0:1d5:135b:4ace with SMTP id
 adf61e73a8af0-1d6dfa35da2mr22059983637.15.1728403341863; 
 Tue, 08 Oct 2024 09:02:21 -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.21
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Tue, 08 Oct 2024 09:02:21 -0700 (PDT)
From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>, pavel.belous@aquantia.com
Subject: [RFC 3/5] net/atlantic: fix handling of xstats_get
Date: Tue,  8 Oct 2024 08:59:57 -0700
Message-ID: <20241008160209.68000-4-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 <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=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.

Fixes: fbe059e87209 ("net/atlantic: implement device statistics")
Cc: pavel.belous@aquantia.com

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/atlantic/atl_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/atlantic/atl_ethdev.c b/drivers/net/atlantic/atl_ethdev.c
index 9cde935834..eac6f5a7b9 100644
--- a/drivers/net/atlantic/atl_ethdev.c
+++ b/drivers/net/atlantic/atl_ethdev.c
@@ -1029,7 +1029,7 @@ atl_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *stats,
 	unsigned int i;
 	unsigned int count = atl_dev_xstats_get_count(dev);
 
-	if (!stats)
+	if (n < count)
 		return count;
 
 	if (hw->aq_fw_ops->send_macsec_req != NULL) {
-- 
2.45.2