From patchwork Wed May 25 17:37:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ferruh Yigit X-Patchwork-Id: 111857 X-Patchwork-Delegate: andrew.rybchenko@oktetlabs.ru Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A723CA0555; Wed, 25 May 2022 19:37:50 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E75C9427EC; Wed, 25 May 2022 19:37:45 +0200 (CEST) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2043.outbound.protection.outlook.com [40.107.223.43]) by mails.dpdk.org (Postfix) with ESMTP id A85DC4113D for ; Wed, 25 May 2022 19:37:43 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=l+9kxsCCgZk1rJ6/SkuTGfok/flxvIzvtwFlcUtQBWKTtXZknKP4olgQ2kfhJtwkmiLlu3aiIcN1YF23DqIpTi8BmkZVrPpACmdxuit6+lWJP7pDychCbIU4mQPOVw0fAyu8Bwj6fACjIZWgS/ewMvjd1/1RjIM/ZTihNmTGvBvirRrOad0vzRAZoAR8WCDCLtRiKlTZJdoXgCeSFp1b1Cf69wYGbND+teeAz4BKGPUMlWGwp/E0OhdpSds2CZcnvXlPY8pZwZm7VhnkiLLJBviiyNy2DDrHLgfQBdZPJKlayw7yqm7y4VhHOPmk6LCSsTMarswiDFv23Nps2jJcbw== 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=PcYryTrFbV4Q0DzvasU7KBhdco0DbBqc9Ncbw+dn73E=; b=ldWL0g9FJnyHPr3b0TL4Di1TAhXnG4hWkFr9c/J9RMjqb6Eu7ue4LbfzXdbVYz46OUelzAwuVQD9Tx3jS5n0U09ZaVJA2tRBEZYskAKYpPNo9kCpb04e2oZ4960Y3ogy1WqLTpOPRkT5O3VhJLNRSRMj15gE/DnF1DV4OaZDdfjJQ1fPt1EFuoo0+FsG1niE4F7Cq4qW9gD7NILJYOcNfjr/+a0VSERNTqOZ2Jh6MKdDGxgRGaTGaNQ2f2MqGYfT0WEjwvK2cbBnT76M3JhlLbxLrrgZkj8xztRwZfGAYVv5HA6U64Wy/QshEX7/nd3GlMdnPXRNotMy6X4Wcn/hfw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.80.198) smtp.rcpttodomain=intel.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=PcYryTrFbV4Q0DzvasU7KBhdco0DbBqc9Ncbw+dn73E=; b=ArwFmaT+P3IWTx+PUsA2D+WBSpoN5zXmYsew15Mvvaih1B8nV59bz1/QgsfWxEMna+ZouT2LXpkao1DiV1c2KLfggZV975948YbI6j34z7mqRJKP7fvYKA6XQ+3jMrrupPiJGa++lH/alTEy0CoEq3+nNrTMTDId/WuoUi0Tqmg= Received: from DM5PR2001CA0006.namprd20.prod.outlook.com (2603:10b6:4:16::16) by DM5PR02MB3669.namprd02.prod.outlook.com (2603:10b6:4:b9::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5293.13; Wed, 25 May 2022 17:37:41 +0000 Received: from DM3NAM02FT013.eop-nam02.prod.protection.outlook.com (2603:10b6:4:16:cafe::11) by DM5PR2001CA0006.outlook.office365.com (2603:10b6:4:16::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5293.13 via Frontend Transport; Wed, 25 May 2022 17:37:41 +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 DM3NAM02FT013.mail.protection.outlook.com (10.13.5.126) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5293.13 via Frontend Transport; Wed, 25 May 2022 17:37:41 +0000 Received: from xir-pvapexch01.xlnx.xilinx.com (172.21.17.15) 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; Wed, 25 May 2022 18:37:40 +0100 Received: from smtp.xilinx.com (172.21.105.198) by xir-pvapexch01.xlnx.xilinx.com (172.21.17.15) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Wed, 25 May 2022 18:37:39 +0100 Envelope-to: ferruh.yigit@xilinx.com, xiaoyun.li@intel.com, aman.deep.singh@intel.com, yuying.zhang@intel.com, dev@dpdk.org, thomas@monjalon.net, andrew.rybchenko@oktetlabs.ru, kirill.rybalchenko@intel.com Received: from [172.21.78.13] (port=42046 helo=xirdcglab01.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1ntux1-0006dh-DF; Wed, 25 May 2022 18:37:39 +0100 From: Ferruh Yigit To: Xiaoyun Li , Aman Singh , Yuying Zhang CC: , Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko , Kirill Rybalchenko Subject: [PATCH 2/3] app/testpmd: remove duplicated flow type to string table Date: Wed, 25 May 2022 18:37:35 +0100 Message-ID: <20220525173736.3394787-2-ferruh.yigit@xilinx.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220525173736.3394787-1-ferruh.yigit@xilinx.com> References: <20220525173736.3394787-1-ferruh.yigit@xilinx.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fcddd7e7-0342-46b3-1da3-08da3e7544e6 X-MS-TrafficTypeDiagnostic: DM5PR02MB3669: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: Q1gds+S4XTQUOZQ6umI3gA2M5DUtIwu1jOqxNcv4lB/4d5ig5sPcN8/Qy2wrubMk6MjjEO4mEVRimocXUPwPRupy17tXaBYnExORKAiw9Y4KKQBAvC5NUhNqslSL2UhapPpOhNG3lxcv8X8FurTLep0XSvu0WsQbz1SLGr0Ut4EnJmNta6I2AK2KS9ozQWvfD3KLRXpXlDb/588feaUoxgUtpkblL1pvw4ntjZmLVVVPeKpTZiLTtjWFZ7C/xJF61lCvfq6Cup2gJh6XYPziMmx53Hhl2lBwS4C3JYj/C4ll/4STA0t/lDPn1JwdkmIGdYq+t4nu+WnP8bX/8Fq1SJJR8twa8Q5cWp4TvpetDEPTAWmCU+lUIN487Qn8sGwK8828EK4W43Nbqu/FgnO/bVJJSeHE+nQwtP/rCqtIjdcazGKtCOc/X9TmwYEPs/0IuBYJ0MiT2qEZK4l44tcBHlMrdX5Q2kYhzL194/ZY79rBbOxzUQDdTCsdvTB7pLikCjuIQTKnAD8RNTshgJ/rp4/EeZ7zgxYKC9QA4EyRXKpYaX2W/i7gPsiWlIaCJgtrIZGrcw/7yCfjAxhLezM/heg6m/nGg7va1WOG7BMpQTArgtSYj2Jl445E2BmzZ35aiTFGw3lQHJLTlOAsih6kkTL+3u3UZIFz7/hfNsiZ5iwoaCp7SPh+AVQD7ija627LwkB3jOZ7GvteSo/CmiDhvA== 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)(46966006)(40470700004)(36840700001)(4326008)(36860700001)(7636003)(6666004)(70206006)(70586007)(8676002)(7696005)(2906002)(40460700003)(5660300002)(508600001)(8936002)(83380400001)(9786002)(44832011)(26005)(1076003)(36756003)(356005)(316002)(2616005)(47076005)(336012)(82310400005)(426003)(110136005)(186003)(54906003)(102446001); DIR:OUT; SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 May 2022 17:37:41.2186 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fcddd7e7-0342-46b3-1da3-08da3e7544e6 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: DM3NAM02FT013.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR02MB3669 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 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 --- Cc: Kirill Rybalchenko --- app/test-pmd/cmdline.c | 41 +------------------- app/test-pmd/config.c | 87 +++++++++++++++++++++++++----------------- app/test-pmd/testpmd.h | 2 + 3 files changed, 55 insertions(+), 75 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index d8900a0d0704..becb3d772fad 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -10572,45 +10572,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; @@ -10639,7 +10600,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 c353d224ef06..47de5b6d9458 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -66,8 +66,6 @@ #define NS_PER_SEC 1E9 -static char *flowtype_to_str(uint16_t flow_type); - static const struct { enum tx_pkt_split split; const char *name; @@ -5640,40 +5638,39 @@ set_record_burst_stats(uint8_t on_off) record_burst_stats = on_off; } -static char* +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}, +}; + +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) @@ -5683,6 +5680,26 @@ flowtype_to_str(uint16_t flow_type) return NULL; } +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; +} + #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE) static inline void @@ -5749,7 +5766,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]; @@ -5765,7 +5782,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 203311bcc29e..5ca297215514 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -1086,6 +1086,8 @@ void fdir_set_flex_payload(portid_t port_id, void port_rss_reta_info(portid_t port_id, struct rte_eth_rss_reta_entry64 *reta_conf, uint16_t nb_entries); +uint16_t str_to_flowtype(const char *string); +const char *flowtype_to_str(uint16_t flow_type); void set_vf_traffic(portid_t port_id, uint8_t is_rx, uint16_t vf, uint8_t on);