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 982C8A0543 for ; Tue, 21 Jun 2022 10:09:41 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 04EEE42BA5; Tue, 21 Jun 2022 10:09:28 +0200 (CEST) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2064.outbound.protection.outlook.com [40.107.236.64]) by mails.dpdk.org (Postfix) with ESMTP id 2534542B8E for ; Tue, 21 Jun 2022 10:09:25 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BAOk91D/gXx11Px2VxgyorFmnxKH3SF0FO6VCt94zp8sIbSm0fPwEDNx5K+OnLFKeSfaiwQiWmJT1zKjTpvS0A42zJjrOSUn1JIWpNxlNmTDZhzbYrIARRyXDmBzfThEcwTWSIkjWXE0HfbNCoklUUI6AmuhRcO7+RuS7rFgJ6wFBYDX1f8+7m+5PEqkarvjON+vvPnCvr8sngH/9qjp8GPN5qHXfk1fQlOO3X7asUBPwi6BW1IQFQME83hmMT2EwL710p/werhaVPTCLIpSeM0k/iY+boAqHZcSzaRrq2lFWDbLnNuNl+C8weym3p3Z1UEJB4BxTENTqCt9IAThbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=+gAnMYr0C4bjUrnQtPycYBD2pNzze2StkpnKLoRvalw=; b=UUKQ0FQKoz9AYhJvepWiJ7Ct9ADVz5zJ56nN8LAizPYHfrz5KLGLCuNVgrGC9ddAznF1Sw8tkAmb8B2vKWY1wdaFqFLLSosnviSGMRBpGTICeMDPtamIygtIjKDf0CoTq0ziBKv9mG18Y5xKBuiRqPrKk04RJzdo27iW7mMKfVFfe/MLvb68URvKdgFeAT8Hmm/yZo9xUGOZheKzhYwrVbUIgY6R8TtNPCaM6vemdYHtVFHN4EJHFvUvBNQs3G0rMdHSpSSdhl2bvnxOP4ehBbcJUT+/2+Qx3RSqLg/S8JEPUByiWtAni10n8RIiUj4urBunAI0iVW9g2UnoVCIB1w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.234) smtp.rcpttodomain=oktetlabs.ru smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+gAnMYr0C4bjUrnQtPycYBD2pNzze2StkpnKLoRvalw=; b=HbBhF8wk6Eegg84BsufvXJCMXQLgtfoYzsPba0uzxGoDlSbugLz3TyaWPf9eQEsR5XUsqMAZR7ZxOqVVghzQ2ll+D+jieF6x8MKNeR7+JQAVcECgmt/GDT2sMCvZu4syVu6sFZbvoYXEEJ4Vh+mEanqNk/wcu7qsPQ6G2CvXUMuJl4to2lmPSyHlQGLXnDs92WD9dGPq7Kg3Mk/l1cYiIaaPPONJIzyJog7ZAZFJgpa/vDZiZuf48kezd251OSM1FWkvqimfgJjUQXirmI8jSGOYI0g2gjrhRwTp3zXbumeaq+D6/AI3qOkwxhnXn7MAJQ2pUu1G2dS3dsKNuNq5PA== Received: from BN6PR13CA0009.namprd13.prod.outlook.com (2603:10b6:404:10a::19) by PH7PR12MB5594.namprd12.prod.outlook.com (2603:10b6:510:134::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5353.22; Tue, 21 Jun 2022 08:09:23 +0000 Received: from BN8NAM11FT032.eop-nam11.prod.protection.outlook.com (2603:10b6:404:10a:cafe::51) by BN6PR13CA0009.outlook.office365.com (2603:10b6:404:10a::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5373.15 via Frontend Transport; Tue, 21 Jun 2022 08:09:23 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.234) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 12.22.5.234 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.234; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (12.22.5.234) by BN8NAM11FT032.mail.protection.outlook.com (10.13.177.88) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.5353.14 via Frontend Transport; Tue, 21 Jun 2022 08:09:22 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by DRHQMAIL101.nvidia.com (10.27.9.10) with Microsoft SMTP Server (TLS) id 15.0.1497.32; Tue, 21 Jun 2022 08:09:21 +0000 Received: from nvidia.com (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Tue, 21 Jun 2022 01:09:19 -0700 From: Xueming Li 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 20.11.6 Date: Tue, 21 Jun 2022 11:02:16 +0300 Message-ID: <20220621080301.2315720-71-xuemingl@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220621080301.2315720-1-xuemingl@nvidia.com> References: <20220621080301.2315720-1-xuemingl@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 607482bf-f0aa-4e59-22ca-08da535d598d X-MS-TrafficTypeDiagnostic: PH7PR12MB5594:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DHucdWbFexBbsmlPBOQP1OwlpTwkPz5ca1Q3y1gBuoKyn1TDXdTt9uDiJxHyoLuv87JI5pWMKSRw4fHMg+h5e1DFSlx6zUMWGmC/SmT9JhZBFgpL8kXyv0+WzQ9guN7XbeZ1Q6khV3fekfmdigfsmho4fCWWtwrjAORjJqJDzkOZctnOITn+WcdQ9Q9BNbltUodWNtI6KnXbHm1gjOn47m1wyDLE8g09tR2VdmKyKG5J4Vxg4/5HWPn/TO35xzH2eA6UqxW1L1IY6qkjB8ZRyuiCds+nQ8+RYEeDxm+KHx28jzPOE0sF/shZe1D1aQPCA46YoE05Cmp2CwIyr1z9f9q9wL9DoqSJEhPef34wyeUtSHyObjTdnq7t3pvPDItM18IMy1Y/yoJb6eGXsT1LZnJEV1V+XLRRfU94sRJdz8MCOlgirpPFoH056p4dJp7/GWlWXDfK1ZCVIixLGR38BgjApU3NQTAQR6BEx1hDd9hY+PT4aCfk01dVVl/HUSdE++GFNztSZFg26C6i5ZQdj7z9Gc0LWvpY9vixuUNbH6YujkE0Pn+fMYsbxGo0HU05NQL8Mcc9V5dTWdHKGbWP47qSXg+PJh8RQiUcZiQGR2RHrGVTIe6jV7NvQ/jkJNxPM8NDBMSNapJaBWqjztIwHuCd3OZ4GMe2bO3HTwkBD+izdZ1VL1EsJqlkgaylsX1mMyH+VyP/dhGTgnw8vtzPjbuVSjebOl+5XJeFlA7aQn9m++n+7LlC+QZr7oC7UYoZBwHsUi1f8/eC2V1WQ3FKdy3xM+99dI2vAF6MUgImt4gLmRAkqAsjYZM+9C1GABm4vszzp2xS9obmYkFinxht0cDtNfrhBsOGCIxsIk17QLo= X-Forefront-Antispam-Report: CIP:12.22.5.234; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:InfoNoRecords; CAT:NONE; SFS:(13230016)(4636009)(346002)(396003)(39860400002)(376002)(136003)(46966006)(40470700004)(36840700001)(41300700001)(53546011)(7696005)(6666004)(26005)(6286002)(316002)(54906003)(6916009)(70586007)(70206006)(966005)(2616005)(478600001)(86362001)(82310400005)(36860700001)(81166007)(82740400003)(40460700003)(66574015)(47076005)(426003)(336012)(1076003)(186003)(16526019)(8676002)(356005)(83380400001)(2906002)(40480700001)(36756003)(55016003)(4326008)(8936002)(5660300002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jun 2022 08:09:22.3957 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 607482bf-f0aa-4e59-22ca-08da535d598d X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[12.22.5.234]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT032.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB5594 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 20.11.6 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 06/23/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/steevenlee/dpdk This queued commit can be viewed at: https://github.com/steevenlee/dpdk/commit/eb7b05b5de570be7a4bb62ec3e878df6f4a7811e Thanks. Xueming Li --- >From eb7b05b5de570be7a4bb62ec3e878df6f4a7811e 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 Cc: Xueming Li [ 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 24eb0d1197..028d16f99e 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -3170,7 +3170,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, -ENODEV); - + 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); @@ -3187,7 +3188,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 899f152a83..7da58d3fd1 100644 --- a/lib/librte_ethdev/rte_ethdev.h +++ b/lib/librte_ethdev/rte_ethdev.h @@ -2814,9 +2814,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.35.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2022-06-21 15:37:52.466881894 +0800 +++ 0070-ethdev-clarify-null-location-case-in-xstats-get.patch 2022-06-21 15:37:49.107784833 +0800 @@ -1 +1 @@ -From 485df8847a2c0ecf947a514f634b8180b725b827 Mon Sep 17 00:00:00 2001 +From eb7b05b5de570be7a4bb62ec3e878df6f4a7811e Mon Sep 17 00:00:00 2001 @@ -7,0 +8,3 @@ +Cc: Xueming Li + +[ upstream commit 485df8847a2c0ecf947a514f634b8180b725b827 ] @@ -26 +28,0 @@ -Cc: stable@dpdk.org @@ -32,9 +34,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 24eb0d1197..028d16f99e 100644 +--- a/lib/librte_ethdev/rte_ethdev.c ++++ b/lib/librte_ethdev/rte_ethdev.c +@@ -3170,7 +3170,8 @@ rte_eth_xstats_get(uint16_t port_id, struct rte_eth_xstat *xstats, @@ -43,0 +46 @@ +- @@ -49 +52 @@ -@@ -2989,7 +2991,7 @@ rte_eth_xstats_get(uint16_t port_id, struct rte_eth_xstat *xstats, +@@ -3187,7 +3188,7 @@ rte_eth_xstats_get(uint16_t port_id, struct rte_eth_xstat *xstats, @@ -58,5 +61,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 899f152a83..7da58d3fd1 100644 +--- a/lib/librte_ethdev/rte_ethdev.h ++++ b/lib/librte_ethdev/rte_ethdev.h +@@ -2814,9 +2814,13 @@ int rte_eth_xstats_get_names(uint16_t port_id,