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 9BFE4A0540 for ; Thu, 7 Jul 2022 09:57:08 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9103A406B4; Thu, 7 Jul 2022 09:57:08 +0200 (CEST) Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) by mails.dpdk.org (Postfix) with ESMTP id 64B6F406B4 for ; Thu, 7 Jul 2022 09:57:06 +0200 (CEST) Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 28E483F6F9 for ; Thu, 7 Jul 2022 07:57:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1657180626; bh=0HKiNPzCb4lU89NdZH1cs3acP5zgZMqWWQxb0kTywME=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=hwj8/mug7dx7PirptvMRqyLZw/8V35SFMazapCwqVEruabRS9LT/+4GNC6hd/dbR+ JBgDZCaA+RfWjoPavfxtC1yB3U3VFAVlEXmMs939+SNNvj0aTaEZcaBg60uBt7qah3 MhfD93QNSJ6gFx4fnp9+OdjP8hz3OvADkZTB9HUPlgoUIkjmKvXOhaoMSjbeoHQnVB XsyWKL7uiITf5BJbQFGS4soAq2YXOsM65EuTO9Oc6ULNT8KZNAxemj6z/go28r6YGW rmKANW1Ycx0+nARsLXF98FXdolxUnv7nOR/8W+lEQVU3sA3ZP+OEI/D8Ny2VQq7bzF hDXu91cMWD5mg== Received: by mail-ed1-f72.google.com with SMTP id b7-20020a056402350700b00435bd1c4523so13364886edd.5 for ; Thu, 07 Jul 2022 00:57:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0HKiNPzCb4lU89NdZH1cs3acP5zgZMqWWQxb0kTywME=; b=jDWuykEbDpf88bt4ZcEXQR4cRnPNbF3IU83aaPjPg2LweA/BisMvigxigmEzJ3GuJg BuS5Nbz+3O+udyEStBRPOQ0/KBL2rdW7kXz/J0R/4hcAxaVMZS3G1jxV0z/qR5k1uuMp LGSGHyqqKWhMCVVA65oDUUY4GN0cRcqbmGDQAU6aJ8wo892xYEX75ke+CaB0PQ413wkX gtscRkCovJ2OyPz/B4bOAjETkd30EJAwQZB+gJKoSo5JpjZDiWMtkG98d2T7ms5CVTRE ACfoIrItGEg5Wv1NLGOdaHjC9lcRiiwBjml+Fx6KbC3uds2ICRAUJytYmxsuuvcmcXVM KeRg== X-Gm-Message-State: AJIora8ZL/rSMVSv4nFynWqa1ZEczfcmtd06tjqnN7slb+q0l+CLMOwX yAmVcdxwh3FYxAK+vImnwabqEuPgZk0cozNYHwhNFKrOcQ4tM99JPL87Fzm51uFGrv6d2+mvREr O7gvhm72g7TXOwWvkY/w1XB10 X-Received: by 2002:aa7:df12:0:b0:43a:4991:1725 with SMTP id c18-20020aa7df12000000b0043a49911725mr30458336edy.55.1657180625649; Thu, 07 Jul 2022 00:57:05 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uWkrp+T+YgALYUpynlr2u1fQXhGh0cV/o3hSqbf+wKrFY2dBfqdfQeL7fb8n/sqUUecnC5qg== X-Received: by 2002:aa7:df12:0:b0:43a:4991:1725 with SMTP id c18-20020aa7df12000000b0043a49911725mr30458272edy.55.1657180625353; Thu, 07 Jul 2022 00:57:05 -0700 (PDT) Received: from Keschdeichel.fritz.box ([2a02:6d40:3a4f:7b00:c19b:938e:7c97:afe2]) by smtp.gmail.com with ESMTPSA id u5-20020a170906068500b00703671ebe65sm18360271ejb.198.2022.07.07.00.57.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jul 2022 00:57:04 -0700 (PDT) From: christian.ehrhardt@canonical.com To: Chengwen Feng Cc: =?UTF-8?q?Morten=20Br=C3=B8rup?= , Andrew Rybchenko , dpdk stable Subject: patch 'ethdev: clarify null location case in xstats get' has been queued to stable release 19.11.13 Date: Thu, 7 Jul 2022 09:54:29 +0200 Message-Id: <20220707075522.194223-34-christian.ehrhardt@canonical.com> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220707075522.194223-1-christian.ehrhardt@canonical.com> References: <20220707075522.194223-1-christian.ehrhardt@canonical.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Hi, FYI, your patch has been queued to stable release 19.11.13 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 07/09/22. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/cpaelzer/dpdk-stable-queue This queued commit can be viewed at: https://github.com/cpaelzer/dpdk-stable-queue/commit/530d754e63a4d9c5a5f9d55e8df57fca0c1e6d45 Thanks. Christian Ehrhardt --- >From 530d754e63a4d9c5a5f9d55e8df57fca0c1e6d45 Mon Sep 17 00:00:00 2001 From: Chengwen Feng Date: Fri, 13 May 2022 10:53:49 +0800 Subject: [PATCH] ethdev: clarify null location case in xstats get MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [ upstream commit 485df8847a2c0ecf947a514f634b8180b725b827 ] When xstats location is null in rte_eth_xstats_get() the return value is not clearly specified. Some PMDs (eg. hns3/ipn3ke/mvpp2/axgbe) return zero while others return the required number of elements. In this patch, special parameter combinations are restricted: 1. highlight that xstats location may be null if and only if n is 0. 2. amend n parameter description to specify that if n is lower than the required number of elements, the function returns the required number of elements. 3. specify that if n is zero, the xstats must be NULL, the function returns the required number of elements (a duplicate which should help to not very attentive readers). Add sanity check for null xstats and non-zero n case on API level to make it unnecessary to care about it in drivers. Fixes: ce757f5c9a4d ("ethdev: new method to retrieve extended statistics") Signed-off-by: Chengwen Feng Acked-by: Morten Brørup Reviewed-by: Andrew Rybchenko --- lib/librte_ethdev/rte_ethdev.c | 5 +++-- lib/librte_ethdev/rte_ethdev.h | 6 +++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index abcc31c19e..76699cc10f 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -2862,7 +2862,8 @@ rte_eth_xstats_get(uint16_t port_id, struct rte_eth_xstat *xstats, int ret; RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL); - + if (xstats == NULL && n > 0) + return -EINVAL; dev = &rte_eth_devices[port_id]; nb_rxqs = RTE_MIN(dev->data->nb_rx_queues, RTE_ETHDEV_QUEUE_STAT_CNTRS); @@ -2878,7 +2879,7 @@ rte_eth_xstats_get(uint16_t port_id, struct rte_eth_xstat *xstats, * xstats struct. */ xcount = (*dev->dev_ops->xstats_get)(dev, - xstats ? xstats + count : NULL, + (n > count) ? xstats + count : NULL, (n > count) ? n - count : 0); if (xcount < 0) diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h index 9cc12ef97e..826339009b 100644 --- a/lib/librte_ethdev/rte_ethdev.h +++ b/lib/librte_ethdev/rte_ethdev.h @@ -2363,9 +2363,13 @@ int rte_eth_xstats_get_names(uint16_t port_id, * @param 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. + * This parameter can be set to NULL if and only if n is 0. * @param n * The size of the xstats array (number of elements). + * If lower than the required number of elements, the function returns + * the required number of elements. + * If equal to zero, the xstats must be NULL, the function returns the + * required number of elements. * @return * - A positive value lower or equal to n: success. The return value * is the number of entries filled in the stats table. -- 2.37.0 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2022-07-07 09:54:12.654871176 +0200 +++ 0034-ethdev-clarify-null-location-case-in-xstats-get.patch 2022-07-07 09:54:10.873824049 +0200 @@ -1 +1 @@ -From 485df8847a2c0ecf947a514f634b8180b725b827 Mon Sep 17 00:00:00 2001 +From 530d754e63a4d9c5a5f9d55e8df57fca0c1e6d45 Mon Sep 17 00:00:00 2001 @@ -8,0 +9,2 @@ +[ upstream commit 485df8847a2c0ecf947a514f634b8180b725b827 ] + @@ -26 +27,0 @@ -Cc: stable@dpdk.org @@ -32,9 +33,9 @@ - lib/ethdev/rte_ethdev.c | 4 +++- - lib/ethdev/rte_ethdev.h | 6 +++++- - 2 files changed, 8 insertions(+), 2 deletions(-) - -diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c -index 8520aec561..af55edb6b9 100644 ---- a/lib/ethdev/rte_ethdev.c -+++ b/lib/ethdev/rte_ethdev.c -@@ -2973,6 +2973,8 @@ rte_eth_xstats_get(uint16_t port_id, struct rte_eth_xstat *xstats, + lib/librte_ethdev/rte_ethdev.c | 5 +++-- + lib/librte_ethdev/rte_ethdev.h | 6 +++++- + 2 files changed, 8 insertions(+), 3 deletions(-) + +diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c +index abcc31c19e..76699cc10f 100644 +--- a/lib/librte_ethdev/rte_ethdev.c ++++ b/lib/librte_ethdev/rte_ethdev.c +@@ -2862,7 +2862,8 @@ rte_eth_xstats_get(uint16_t port_id, struct rte_eth_xstat *xstats, @@ -43 +44,2 @@ - RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL); +- @@ -49 +51 @@ -@@ -2989,7 +2991,7 @@ rte_eth_xstats_get(uint16_t port_id, struct rte_eth_xstat *xstats, +@@ -2878,7 +2879,7 @@ rte_eth_xstats_get(uint16_t port_id, struct rte_eth_xstat *xstats, @@ -58,5 +60,5 @@ -diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h -index 04cff8ee10..04225bba4d 100644 ---- a/lib/ethdev/rte_ethdev.h -+++ b/lib/ethdev/rte_ethdev.h -@@ -3174,9 +3174,13 @@ int rte_eth_xstats_get_names(uint16_t port_id, +diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h +index 9cc12ef97e..826339009b 100644 +--- a/lib/librte_ethdev/rte_ethdev.h ++++ b/lib/librte_ethdev/rte_ethdev.h +@@ -2363,9 +2363,13 @@ int rte_eth_xstats_get_names(uint16_t port_id,