From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id EA3DCA04DB; Sat, 17 Oct 2020 01:43:22 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 8AE27E264; Sat, 17 Oct 2020 01:43:21 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 9E785E263; Sat, 17 Oct 2020 01:43:18 +0200 (CEST) IronPort-SDR: ar8mDFUjUF9A1ayErANgNpyFpMg0fn8RDhdhLMPuDdP2ddTf+ezpw06u0nnIYr6rPFWSqwouqm g3eLHT7mx9/w== X-IronPort-AV: E=McAfee;i="6000,8403,9776"; a="163238739" X-IronPort-AV: E=Sophos;i="5.77,384,1596524400"; d="scan'208";a="163238739" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2020 16:43:11 -0700 IronPort-SDR: PL37KEk7QA6ysdwVHmyhTSySBhfcTUfseEEqdwM5Hcx+pNrMhG9fob47mR3nRNNulcGHPPSxUL JGQHbTp48c+w== X-IronPort-AV: E=Sophos;i="5.77,384,1596524400"; d="scan'208";a="531917102" Received: from fyigit-mobl1.ger.corp.intel.com (HELO [10.252.19.66]) ([10.252.19.66]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2020 16:43:09 -0700 From: Ferruh Yigit To: Andrew Rybchenko , dev@dpdk.org Cc: Thomas Monjalon , Andrew Rybchenko , "techboard@dpdk.org" References: <1602600818-7473-1-git-send-email-arybchenko@solarflare.com> <8f8907cf-d905-c867-cf42-694d16b0a0cf@intel.com> <76f63a45-01a5-a3d1-2107-37fe8cf5ca2d@intel.com> <9dcbd6e0-265c-f520-d060-1ab494a9e53f@intel.com> Message-ID: <2abbae70-2e07-23f0-df4a-51d475d24164@intel.com> Date: Sat, 17 Oct 2020 00:43:05 +0100 MIME-Version: 1.0 In-Reply-To: <9dcbd6e0-265c-f520-d060-1ab494a9e53f@intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Subject: Re: [dpdk-dev] [PATCH] ethdev: unify error code if port ID is invalid X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On 10/16/2020 10:58 PM, Ferruh Yigit wrote: > On 10/16/2020 1:05 PM, Ferruh Yigit wrote: >> On 10/13/2020 4:32 PM, Ferruh Yigit wrote: >>> On 10/13/2020 3:53 PM, Andrew Rybchenko wrote: >>>> Use ENODEV as the error code if specified port ID is invalid. >>>> >>>> Signed-off-by: Andrew Rybchenko >>>> --- >>>>   lib/librte_ethdev/rte_ethdev.c | 44 ++++++++++++++++---------------- >>>>   lib/librte_ethdev/rte_ethdev.h | 46 +++++++++++++++++++++++----------- >>>>   2 files changed, 54 insertions(+), 36 deletions(-) >>>> >>>> diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c >>>> index 5b7979a3b8..1f862f918a 100644 >>>> --- a/lib/librte_ethdev/rte_ethdev.c >>>> +++ b/lib/librte_ethdev/rte_ethdev.c >>>> @@ -784,7 +784,7 @@ rte_eth_dev_get_name_by_port(uint16_t port_id, char *name) >>>>   { >>>>       char *tmp; >>>> -    RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL); >>>> +    RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); >>> >>> Thanks Andrew, +1 to this error unification. >>> >>> This will be API change without deprecation notice, cc'ed techboard for it. >>> >>> If this should (almost) always return '-ENODEV', does it make sense to make >>> another wrapper macro for it, to prevent later other error types used again. >>> >>> And there are a few instances returning '-1', are they left intentionally? >>> >> >> Reviewed-by: Ferruh Yigit > > > > Applied to dpdk-next-net/main, thanks. > There are some bitratestats unit tests, that checks APIs with invalid port_id. Unit tests checks return values as '-EINVAL', they also should be updated as '-ENODEV' with this patch. Adding following update to this patch in next-net diff --git a/app/test/test_bitratestats.c b/app/test/test_bitratestats.c index 39d7f734d4..fb4203c57b 100644 --- a/app/test/test_bitratestats.c +++ b/app/test/test_bitratestats.c @@ -99,8 +99,8 @@ test_stats_bitrate_calc_invalid_portid_1(void) int ret = 0; ret = rte_stats_bitrate_calc(bitrate_data, 33); - TEST_ASSERT(ret == -EINVAL, "Test Failed: Expected -%d for higher " - "portid rte_stats_bitrate_calc ret:%d", EINVAL, ret); + TEST_ASSERT(ret == -ENODEV, "Test Failed: Expected -%d for higher " + "portid rte_stats_bitrate_calc ret:%d", ENODEV, ret); return TEST_SUCCESS; } @@ -112,8 +112,8 @@ test_stats_bitrate_calc_invalid_portid_2(void) int ret = 0; ret = rte_stats_bitrate_calc(bitrate_data, -1); - TEST_ASSERT(ret == -EINVAL, "Test Failed: Expected -%d for invalid " - "portid rte_stats_bitrate_calc ret:%d", EINVAL, ret); + TEST_ASSERT(ret == -ENODEV, "Test Failed: Expected -%d for invalid " + "portid rte_stats_bitrate_calc ret:%d", ENODEV, ret); return TEST_SUCCESS; } @@ -125,9 +125,9 @@ test_stats_bitrate_calc_non_existing_portid(void) int ret = 0; ret = rte_stats_bitrate_calc(bitrate_data, 31); - TEST_ASSERT(ret == -EINVAL, "Test Failed: Expected -%d for " + TEST_ASSERT(ret == -ENODEV, "Test Failed: Expected -%d for " "non-existing portid rte_stats_bitrate_calc ret:%d", - EINVAL, ret); + ENODEV, ret); return TEST_SUCCESS; }