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 9E281A0503; Fri, 6 May 2022 09:56:35 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 44AE140395; Fri, 6 May 2022 09:56:35 +0200 (CEST) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mails.dpdk.org (Postfix) with ESMTP id 77CED4014F for ; Fri, 6 May 2022 09:56:33 +0200 (CEST) Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4KvjYh0rqhzhYWn; Fri, 6 May 2022 15:56:08 +0800 (CST) Received: from [10.67.103.128] (10.67.103.128) by kwepemi500012.china.huawei.com (7.221.188.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 6 May 2022 15:56:30 +0800 Subject: Re: [PATCH v2 2/9] net/hns3: adjust retval when xstats is null of get xstats To: Chengwen Feng , , , , , , , CC: References: <20220416010747.40714-1-fengchengwen@huawei.com> <20220428131600.41032-1-fengchengwen@huawei.com> <20220428131600.41032-3-fengchengwen@huawei.com> From: "Min Hu (Connor)" Message-ID: Date: Fri, 6 May 2022 15:56:29 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.3.1 MIME-Version: 1.0 In-Reply-To: <20220428131600.41032-3-fengchengwen@huawei.com> Content-Type: text/plain; charset="gbk"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.67.103.128] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemi500012.china.huawei.com (7.221.188.12) X-CFilter-Loop: Reflected 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 Acked-by: Min Hu (Connor) ÔÚ 2022/4/28 21:15, Chengwen Feng дµÀ: > Many user (e.g. telemetry) invokes rte_eth_xstats_get(port_id, NULL, 0) > to retrieve the required number of elements, but currently hns3 PMD > returns zero when xstats is NULL. > > This patch adjusts that the return value was the required number of > elements when stats is NULL. > > Fixes: 8839c5e202f3 ("net/hns3: support device stats") > Cc: stable@dpdk.org > > Signed-off-by: Chengwen Feng > --- > drivers/net/hns3/hns3_stats.c | 7 ++----- > 1 file changed, 2 insertions(+), 5 deletions(-) > > diff --git a/drivers/net/hns3/hns3_stats.c b/drivers/net/hns3/hns3_stats.c > index 806720faff..4165e22f7f 100644 > --- a/drivers/net/hns3/hns3_stats.c > +++ b/drivers/net/hns3/hns3_stats.c > @@ -1020,7 +1020,7 @@ hns3_imissed_stats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, > * @praram xstats > * A pointer to a table of structure of type *rte_eth_xstat* > * to be filled with device statistics ids and values. > - * This parameter can be set to NULL if n is 0. > + * If set to NULL, the function returns the required number of elements. > * @param n > * The size of the xstats array (number of elements). > * @return > @@ -1041,11 +1041,8 @@ hns3_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, > int count; > int ret; > > - if (xstats == NULL) > - return 0; > - > count = hns3_xstats_calc_num(dev); > - if ((int)n < count) > + if (xstats == NULL || (int)n < count) > return count; > > count = 0; >