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 BCEC5A054D; Tue, 7 Jun 2022 17:47:07 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B06DB4021D; Tue, 7 Jun 2022 17:47:07 +0200 (CEST) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2049.outbound.protection.outlook.com [40.107.236.49]) by mails.dpdk.org (Postfix) with ESMTP id BF06140156 for ; Tue, 7 Jun 2022 17:47:05 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TKBrncvhHJ9sSgDOlrVso51NuhN/RT0toj/o3pZjMZ2L/buRn679gmljEo1pj3nwutrl2E/zX9DcsIrxZvHX0g07zPPgTSqgRl4SChvG1ulVq97gBeLGnmFJbI5RB3iZXB6fGUQVC0A1DJOOwaQBo2qa/9+KG5fj1seXRR2aZFD9uFJdANpAgDiLWo0QUFWGdLurOutbC77xygVdDLcOa4dQt4SdRGzXL7bLkeRn2KY4QZ1RFFZdai062nlCyajYOJVOUy9EUsyAOBqqfpBeVfpqUWxKcU/MJhdHNo6WVH6bA+hAMAgbz/dYWhrLATPJ5x4LnarmbNCZD7QLHzWx1A== 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=uQgh7YIqIchjYKKmNngLc1Ohakuedo+gyYUS39sFk8M=; b=VsoW05bPGLM7rARRQt9kzH2IJQo4KsvILZjDF7fxKC/qb62D86okEm/m8TXkD+TPsLHzZjJaZjSGJTjxivrkIbE6Iob/knYfhXZXYIwrLEYngbsGqGGg8HaZQ5bP0FY7Yvflzts3Q6Nv5LlIzH7VqpGlZ0LjnlYFqSOokHjqC8J+e2NX4V9bTN7YPLH4EQPS+m93If50I5gA5klcNfKtdCalNlEf2gWAnV/iXK3g4AyHhaYBBJZvek+AbBqf0MYB7r6Z7f934MZuvy6fDIOvoP4qY6flzql0y1jl0PJL/fb4ws45+lHlv6LkRMkIFqlo9Jp3b6AGOXThpotHjwf92w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.80.198) smtp.rcpttodomain=huawei.com smtp.mailfrom=xilinx.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=uQgh7YIqIchjYKKmNngLc1Ohakuedo+gyYUS39sFk8M=; b=DFIpfO7ct4sx/nLwFdpmNeJ1DkUTx/nF7CorraQYxTdE6sh1NtoylfbnNNd+aX4XMgYiEF5h5aKzpUetAhOXuBzbNg3a3aqaykQRA7FXs8/BL6QKCa0dHdeumaAkfjO1+6+554P2rwE380Ye5qtF5CvYZicQUVU2jzdL3D+YgLc= Received: from SA0PR11CA0198.namprd11.prod.outlook.com (2603:10b6:806:1bc::23) by PH0PR02MB8487.namprd02.prod.outlook.com (2603:10b6:510:dd::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5314.12; Tue, 7 Jun 2022 15:47:03 +0000 Received: from SN1NAM02FT0058.eop-nam02.prod.protection.outlook.com (2603:10b6:806:1bc:cafe::b3) by SA0PR11CA0198.outlook.office365.com (2603:10b6:806:1bc::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5314.12 via Frontend Transport; Tue, 7 Jun 2022 15:47:03 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.80.198) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.80.198 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.80.198; helo=xir-pvapexch01.xlnx.xilinx.com; pr=C Received: from xir-pvapexch01.xlnx.xilinx.com (149.199.80.198) by SN1NAM02FT0058.mail.protection.outlook.com (10.97.5.116) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5314.12 via Frontend Transport; Tue, 7 Jun 2022 15:47:03 +0000 Received: from xir-pvapexch02.xlnx.xilinx.com (172.21.17.17) by xir-pvapexch01.xlnx.xilinx.com (172.21.17.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.14; Tue, 7 Jun 2022 16:47:01 +0100 Received: from smtp.xilinx.com (172.21.105.197) by xir-pvapexch02.xlnx.xilinx.com (172.21.17.17) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Tue, 7 Jun 2022 16:47:01 +0100 Envelope-to: lihuisong@huawei.com, xiaoyun.li@intel.com, aman.deep.singh@intel.com, yuying.zhang@intel.com, andrew.rybchenko@oktetlabs.ru, dev@dpdk.org, thomas@monjalon.net, huangdaode@huawei.com Received: from [10.71.117.191] (port=53793) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1nybQ5-0004fX-AG; Tue, 07 Jun 2022 16:47:01 +0100 Message-ID: Date: Tue, 7 Jun 2022 16:47:01 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 Subject: Re: [PATCH V3 app/testpmd 4/4] app/testpmd: remove duplicated flow type to string table Content-Language: en-US To: Huisong Li , , , , CC: , , References: <20220429102445.23711-1-lihuisong@huawei.com> <20220607083246.12259-1-lihuisong@huawei.com> <20220607083246.12259-5-lihuisong@huawei.com> From: Ferruh Yigit In-Reply-To: <20220607083246.12259-5-lihuisong@huawei.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: aab70dc2-90b6-4a2f-e4f7-08da489cf7a5 X-MS-TrafficTypeDiagnostic: PH0PR02MB8487: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: VYZiy8rA7QmNoJG8kVI3t4mu2ZPFoxomDSZPIGSPzNSwAnLjEoxn/tT9g7snk4dRSi9G94dYw9k13vCVwiMCT1HU6kz+swIPKMkaqny4+mbljE3UrcO5jp/UNjUvcvzmshirNHSpjdFEtamYW2mRJxR6algaDzm/MaSBSB98lhSCon42vX6GoEIhgWaZWajiEpczyiYXHFeeXfB3iepUuooRY4PtNOmfuWQVgcmQJf90Jbkr1THVRgQdrcqcBR8QZwt38xn5fCPsIbMm7NfZU2F6DfdmZ856mz/t6FZ0E9OAhOkt9/C+AsgHIqKsgdcYweSUmGlKO/LIFAwYG1VHoVjzl/RIzIkR63iWT6H1JrKHgdyZqHKeR9VuKbyr/IzgNskWV7jqU5mmqerfWCoQAWHX4h4AAXEypAVYsAT4MwwmkczC7yUvD7/D4Xrei0bk8pePvg49AV79570+hbiLtvDJDaZl9i7U86cT1UuIm0aK6t8mRKDUFA9o6w54k2iBlDDhSLoi+ziQVhXPWcVFNZrP4o4li1EruMAxSl0XTcv8GJK9bMJXvwMXKOiBWQ9qBPYWHfU6Mv3QTN+nhCaxpuL0gMomPZRytxE2qGIp26S7Pa1Pin2WNb9tOCz/MXSlpizZ+BYkk13okkQhdb/gOfF8SxviqrGsE6z+0+4pQk8acVJlHwNoaUFQRiOW1hL9sPCN3s9z0nhrk+U5mT80oNiF2Gv4ajUf2A9mBU6JX3I= X-Forefront-Antispam-Report: CIP:149.199.80.198; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:xir-pvapexch01.xlnx.xilinx.com; PTR:unknown-80-198.xilinx.com; CAT:NONE; SFS:(13230001)(4636009)(40470700004)(46966006)(36840700001)(53546011)(70206006)(31686004)(4326008)(426003)(70586007)(5660300002)(36756003)(8676002)(47076005)(7636003)(26005)(36860700001)(110136005)(54906003)(508600001)(40460700003)(8936002)(336012)(9786002)(82310400005)(316002)(83380400001)(44832011)(31696002)(186003)(2906002)(356005)(2616005)(50156003)(43740500002); DIR:OUT; SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jun 2022 15:47:03.0476 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: aab70dc2-90b6-4a2f-e4f7-08da489cf7a5 X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c; Ip=[149.199.80.198]; Helo=[xir-pvapexch01.xlnx.xilinx.com] X-MS-Exchange-CrossTenant-AuthSource: SN1NAM02FT0058.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR02MB8487 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 On 6/7/2022 9:32 AM, Huisong Li wrote: > > From: Ferruh Yigit > > Flow type table has two instance, one is used for flow type to string > conversion, and other is used for string to flow type conversion. > And tables are diverged by time. > > Unifying tables to prevent maintaining two different tables. > > Note: made 'flowtype_to_str()' non-static to prevent build error for the > case PMDs using it disables. Making function generic, not for some PMDs. > > Signed-off-by: Ferruh Yigit > Signed-off-by: Huisong Li > --- > app/test-pmd/cmdline.c | 41 +------------------ > app/test-pmd/config.c | 92 +++++++++++++++++++++++++++--------------- > app/test-pmd/testpmd.h | 5 +++ > 3 files changed, 65 insertions(+), 73 deletions(-) > > diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c > index fdd0cada3b..e44bb3f475 100644 > --- a/app/test-pmd/cmdline.c > +++ b/app/test-pmd/cmdline.c > @@ -10591,45 +10591,6 @@ do { \ > > #ifdef RTE_NET_I40E > > -static uint16_t > -str2flowtype(char *string) > -{ > - uint8_t i = 0; > - static const struct { > - char str[32]; > - uint16_t type; > - } flowtype_str[] = { > - {"raw", RTE_ETH_FLOW_RAW}, > - {"ipv4", RTE_ETH_FLOW_IPV4}, > - {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4}, > - {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP}, > - {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP}, > - {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP}, > - {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER}, > - {"ipv6", RTE_ETH_FLOW_IPV6}, > - {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6}, > - {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP}, > - {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP}, > - {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP}, > - {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER}, > - {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD}, > - {"ipv6-ex", RTE_ETH_FLOW_IPV6_EX}, > - {"ipv6-tcp-ex", RTE_ETH_FLOW_IPV6_TCP_EX}, > - {"ipv6-udp-ex", RTE_ETH_FLOW_IPV6_UDP_EX}, > - {"gtpu", RTE_ETH_FLOW_GTPU}, > - }; > - > - for (i = 0; i < RTE_DIM(flowtype_str); i++) { > - if (!strcmp(flowtype_str[i].str, string)) > - return flowtype_str[i].type; > - } > - > - if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64) > - return (uint16_t)atoi(string); > - > - return RTE_ETH_FLOW_UNKNOWN; > -} > - > /* *** deal with flow director filter *** */ > struct cmd_flow_director_result { > cmdline_fixed_string_t flow_director_filter; > @@ -10658,7 +10619,7 @@ cmd_flow_director_filter_parsed(void *parsed_result, > struct rte_pmd_i40e_flow_type_mapping > mapping[RTE_PMD_I40E_FLOW_TYPE_MAX]; > struct rte_pmd_i40e_pkt_template_conf conf; > - uint16_t flow_type = str2flowtype(res->flow_type); > + uint16_t flow_type = str_to_flowtype(res->flow_type); > uint16_t i, port = res->port_id; > uint8_t add; > > diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c > index 209cbcc514..ed0be8036b 100644 > --- a/app/test-pmd/config.c > +++ b/app/test-pmd/config.c > @@ -86,6 +86,38 @@ static const struct { > }, > }; > > +#if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE) > + Although right now 'flowtype_to_str()' & 'str_to_flowtype()' are used by code for above PMDs, the functionality is nothing special to any PMD. What about making above functions as non-static functions and get rid of all related #ifdef? > +static const struct { > + char str[32]; > + uint16_t ftype; > +} flowtype_str_table[] = { > + {"raw", RTE_ETH_FLOW_RAW}, > + {"ipv4", RTE_ETH_FLOW_IPV4}, > + {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4}, > + {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP}, > + {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP}, > + {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP}, > + {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER}, > + {"ipv6", RTE_ETH_FLOW_IPV6}, > + {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6}, > + {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP}, > + {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP}, > + {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP}, > + {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER}, > + {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD}, > + {"ipv6-ex", RTE_ETH_FLOW_IPV6_EX}, > + {"ipv6-tcp-ex", RTE_ETH_FLOW_IPV6_TCP_EX}, > + {"ipv6-udp-ex", RTE_ETH_FLOW_IPV6_UDP_EX}, > + {"port", RTE_ETH_FLOW_PORT}, > + {"vxlan", RTE_ETH_FLOW_VXLAN}, > + {"geneve", RTE_ETH_FLOW_GENEVE}, > + {"nvgre", RTE_ETH_FLOW_NVGRE}, > + {"vxlan-gpe", RTE_ETH_FLOW_VXLAN_GPE}, > + {"gtpu", RTE_ETH_FLOW_GTPU}, > +}; > +#endif > + > const struct rss_type_info rss_offload_table[] = { > {"ipv4", RTE_ETH_RSS_IPV4}, > {"ipv4-frag", RTE_ETH_RSS_FRAG_IPV4}, > @@ -5713,41 +5745,35 @@ set_record_burst_stats(uint8_t on_off) > record_burst_stats = on_off; > } > > +#ifdef RTE_NET_I40E > + > +uint16_t > +str_to_flowtype(const char *string) > +{ > + uint8_t i; > + > + for (i = 0; i < RTE_DIM(flowtype_str_table); i++) { > + if (!strcmp(flowtype_str_table[i].str, string)) > + return flowtype_str_table[i].ftype; > + } > + > + if (isdigit(string[0])) { > + int val = atoi(string); > + if (val > 0 && val < 64) > + return (uint16_t)val; > + } > + > + return RTE_ETH_FLOW_UNKNOWN; > +} > + > +#endif /* RTE_NET_I40E */ > + > #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE) > -static char* > + > +static const char* > flowtype_to_str(uint16_t flow_type) > { > - struct flow_type_info { > - char str[32]; > - uint16_t ftype; > - }; > - > uint8_t i; > - static struct flow_type_info flowtype_str_table[] = { > - {"raw", RTE_ETH_FLOW_RAW}, > - {"ipv4", RTE_ETH_FLOW_IPV4}, > - {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4}, > - {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP}, > - {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP}, > - {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP}, > - {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER}, > - {"ipv6", RTE_ETH_FLOW_IPV6}, > - {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6}, > - {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP}, > - {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP}, > - {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP}, > - {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER}, > - {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD}, > - {"ipv6-ex", RTE_ETH_FLOW_IPV6_EX}, > - {"ipv6-tcp-ex", RTE_ETH_FLOW_IPV6_TCP_EX}, > - {"ipv6-udp-ex", RTE_ETH_FLOW_IPV6_UDP_EX}, > - {"port", RTE_ETH_FLOW_PORT}, > - {"vxlan", RTE_ETH_FLOW_VXLAN}, > - {"geneve", RTE_ETH_FLOW_GENEVE}, > - {"nvgre", RTE_ETH_FLOW_NVGRE}, > - {"vxlan-gpe", RTE_ETH_FLOW_VXLAN_GPE}, > - {"gtpu", RTE_ETH_FLOW_GTPU}, > - }; > > for (i = 0; i < RTE_DIM(flowtype_str_table); i++) { > if (flowtype_str_table[i].ftype == flow_type) > @@ -5821,7 +5847,7 @@ print_fdir_flex_mask(struct rte_eth_fdir_flex_conf *flex_conf, uint32_t num) > { > struct rte_eth_fdir_flex_mask *mask; > uint32_t i, j; > - char *p; > + const char *p; > > for (i = 0; i < flex_conf->nb_flexmasks; i++) { > mask = &flex_conf->flex_mask[i]; > @@ -5837,7 +5863,7 @@ static inline void > print_fdir_flow_type(uint32_t flow_types_mask) > { > int i; > - char *p; > + const char *p; > > for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) { > if (!(flow_types_mask & (1 << i))) > diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h > index 6693813dda..b7931a2bee 100644 > --- a/app/test-pmd/testpmd.h > +++ b/app/test-pmd/testpmd.h > @@ -1086,6 +1086,11 @@ void pmd_test_exit(void); > #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE) > void fdir_get_infos(portid_t port_id); > #endif > + > +#ifdef RTE_NET_I40E > +uint16_t str_to_flowtype(const char *string); > +#endif > + > void fdir_set_flex_mask(portid_t port_id, > struct rte_eth_fdir_flex_mask *cfg); > void fdir_set_flex_payload(portid_t port_id, > -- > 2.33.0 >