From patchwork Fri Jun 24 07:23:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "lihuisong (C)" X-Patchwork-Id: 113406 X-Patchwork-Delegate: ferruh.yigit@amd.com 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 CA95CA0032; Fri, 24 Jun 2022 09:25:47 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0FA51427EE; Fri, 24 Jun 2022 09:25:44 +0200 (CEST) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by mails.dpdk.org (Postfix) with ESMTP id 9D6C840A87 for ; Fri, 24 Jun 2022 09:25:41 +0200 (CEST) Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4LTpWv6qjZzkWTx; Fri, 24 Jun 2022 15:23:55 +0800 (CST) Received: from kwepemm600004.china.huawei.com (7.193.23.242) by dggemv711-chm.china.huawei.com (10.1.198.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 24 Jun 2022 15:25:37 +0800 Received: from localhost.localdomain (10.69.192.56) by kwepemm600004.china.huawei.com (7.193.23.242) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 24 Jun 2022 15:25:37 +0800 From: Huisong Li To: , , , CC: , , , , Subject: [PATCH V5 1/7] app/testpmd: fix supported RSS offload display Date: Fri, 24 Jun 2022 15:23:55 +0800 Message-ID: <20220624072401.21839-2-lihuisong@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220624072401.21839-1-lihuisong@huawei.com> References: <20220429102445.23711-1-lihuisong@huawei.com> <20220624072401.21839-1-lihuisong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.56] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemm600004.china.huawei.com (7.193.23.242) X-CFilter-Loop: Reflected 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 The rte_eth_dev_info.flow_type_rss_offloads is populated in terms of RTE_ETH_RSS_* bits. If PMD sets RTE_ETH_RSS_L3_SRC_ONLY to dev_info->flow_type_rss_offloads. testpmd will display "user defined 63" when run 'show port info 0'. Because testpmd use flowtype_to_str() to display the supported RSS offload of PMD. In fact, the function is used to display flow type in FDIR commands for i40e or ixgbe. This patch uses the RTE_ETH_RSS_* bits to display supported RSS offload of PMD. In addition, offloads that are not in rss_type_table[] should be displayed as "unknown offload xxx", instead of "user defined 63". So this patch fixes it. Fixes: b12964f621dc ("ethdev: unification of RSS offload types") Cc: stable@dpdk.org Signed-off-by: Huisong Li Signed-off-by: Ferruh Yigit --- app/test-pmd/config.c | 40 ++++++++++++++++++++++++++-------------- app/test-pmd/testpmd.h | 2 ++ 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 62833fe97c..36a828307c 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; @@ -675,6 +673,19 @@ print_dev_capabilities(uint64_t capabilities) } } +const char * +rsstypes_to_str(uint64_t rss_type) +{ + uint16_t i; + + for (i = 0; rss_type_table[i].str != NULL; i++) { + if (rss_type_table[i].rss_type == rss_type) + return rss_type_table[i].str; + } + + return NULL; +} + void port_infos_display(portid_t port_id) { @@ -779,19 +790,20 @@ port_infos_display(portid_t port_id) if (!dev_info.flow_type_rss_offloads) printf("No RSS offload flow type is supported.\n"); else { + uint64_t rss_offload_types = dev_info.flow_type_rss_offloads; uint16_t i; - char *p; printf("Supported RSS offload flow types:\n"); - for (i = RTE_ETH_FLOW_UNKNOWN + 1; - i < sizeof(dev_info.flow_type_rss_offloads) * CHAR_BIT; i++) { - if (!(dev_info.flow_type_rss_offloads & (1ULL << i))) - continue; - p = flowtype_to_str(i); - if (p) - printf(" %s\n", p); - else - printf(" user defined %d\n", i); + for (i = 0; i < sizeof(rss_offload_types) * CHAR_BIT; i++) { + uint64_t rss_offload = RTE_BIT64(i); + if ((rss_offload_types & rss_offload) != 0) { + const char *p = rsstypes_to_str(rss_offload); + if (p) + printf(" %s\n", p); + else + printf(" unknown_offload(BIT(%u))\n", + i); + } } } @@ -5604,6 +5616,8 @@ set_record_burst_stats(uint8_t on_off) record_burst_stats = on_off; } +#if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE) + static char* flowtype_to_str(uint16_t flow_type) { @@ -5647,8 +5661,6 @@ flowtype_to_str(uint16_t flow_type) return NULL; } -#if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE) - static inline void print_fdir_mask(struct rte_eth_fdir_masks *mask) { diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index eeefb5e70f..195488b602 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -1199,6 +1199,8 @@ extern int flow_parse(const char *src, void *result, unsigned int size, struct rte_flow_item **pattern, struct rte_flow_action **actions); +const char *rsstypes_to_str(uint64_t rss_type); + /* For registering driver specific testpmd commands. */ struct testpmd_driver_commands { TAILQ_ENTRY(testpmd_driver_commands) next; From patchwork Fri Jun 24 07:23:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "lihuisong (C)" X-Patchwork-Id: 113408 X-Patchwork-Delegate: ferruh.yigit@amd.com 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 9DA2AA0032; Fri, 24 Jun 2022 09:25:57 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 190B44281B; Fri, 24 Jun 2022 09:25:57 +0200 (CEST) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by mails.dpdk.org (Postfix) with ESMTP id 10B1F40A82 for ; Fri, 24 Jun 2022 09:25:55 +0200 (CEST) Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4LTpVC5dgMzSgrr; Fri, 24 Jun 2022 15:22:27 +0800 (CST) Received: from kwepemm600004.china.huawei.com (7.193.23.242) by dggemv711-chm.china.huawei.com (10.1.198.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 24 Jun 2022 15:25:38 +0800 Received: from localhost.localdomain (10.69.192.56) by kwepemm600004.china.huawei.com (7.193.23.242) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 24 Jun 2022 15:25:37 +0800 From: Huisong Li To: , , , CC: , , , , Subject: [PATCH V5 2/7] app/testpmd: unify the name of L2 payload offload Date: Fri, 24 Jun 2022 15:23:56 +0800 Message-ID: <20220624072401.21839-3-lihuisong@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220624072401.21839-1-lihuisong@huawei.com> References: <20220429102445.23711-1-lihuisong@huawei.com> <20220624072401.21839-1-lihuisong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.56] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemm600004.china.huawei.com (7.193.23.242) X-CFilter-Loop: Reflected 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 Currently, the "port config all rss xx" command uses 'ether' name to match and to set 'RTE_ETH_RSS_L2_PAYLOAD' offload. However, others RSS command, such as, "port config rss-hash-key" and "show port rss-hash key", use 'l2-payload' to represent this offload. So this patch unifies the name of 'RTE_ETH_RSS_L2_PAYLOAD' offload. Signed-off-by: Huisong Li --- app/test-pmd/cmdline.c | 6 +++--- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 9a7fd5fc35..a701bac953 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -694,7 +694,7 @@ static void cmd_help_long_parsed(void *parsed_result, "receive buffers available.\n\n" "port config all rss (all|default|ip|tcp|udp|sctp|" - "ether|port|vxlan|geneve|nvgre|vxlan-gpe|ecpri|mpls|ipv4-chksum|l2tpv2|" + "l2-payload|port|vxlan|geneve|nvgre|vxlan-gpe|ecpri|mpls|ipv4-chksum|l2tpv2|" "none|level-default|level-outer|level-inner|)\n" " Set the RSS mode.\n\n" @@ -2080,7 +2080,7 @@ cmd_config_rss_parsed(void *parsed_result, rss_conf.rss_hf = RTE_ETH_RSS_TCP; else if (!strcmp(res->value, "sctp")) rss_conf.rss_hf = RTE_ETH_RSS_SCTP; - else if (!strcmp(res->value, "ether")) + else if (!strcmp(res->value, "l2_payload")) rss_conf.rss_hf = RTE_ETH_RSS_L2_PAYLOAD; else if (!strcmp(res->value, "port")) rss_conf.rss_hf = RTE_ETH_RSS_PORT; @@ -2203,7 +2203,7 @@ static cmdline_parse_inst_t cmd_config_rss = { .f = cmd_config_rss_parsed, .data = NULL, .help_str = "port config all rss " - "all|default|eth|vlan|ip|tcp|udp|sctp|ether|port|vxlan|geneve|" + "all|default|eth|vlan|ip|tcp|udp|sctp|l2-payload|port|vxlan|geneve|" "nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|ecpri|mpls|ipv4-chksum|l2tpv2|" "none|level-default|level-outer|level-inner|", .tokens = { diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index 0b7a53fdf1..cc299cff6c 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -2144,7 +2144,7 @@ port config - RSS Set the RSS (Receive Side Scaling) mode on or off:: - testpmd> port config all rss (all|default|eth|vlan|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|ecpri|mpls|l2tpv2|none) + testpmd> port config all rss (all|default|eth|vlan|ip|tcp|udp|sctp|l2-payload|port|vxlan|geneve|nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|ecpri|mpls|l2tpv2|none) RSS is on by default. From patchwork Fri Jun 24 07:23:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "lihuisong (C)" X-Patchwork-Id: 113409 X-Patchwork-Delegate: ferruh.yigit@amd.com 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 E830AA0032; Fri, 24 Jun 2022 09:26:03 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 063C042824; Fri, 24 Jun 2022 09:25:59 +0200 (CEST) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by mails.dpdk.org (Postfix) with ESMTP id 860E240A82 for ; Fri, 24 Jun 2022 09:25:56 +0200 (CEST) Received: from dggemv704-chm.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4LTpV82vXszShF9; Fri, 24 Jun 2022 15:22:24 +0800 (CST) Received: from kwepemm600004.china.huawei.com (7.193.23.242) by dggemv704-chm.china.huawei.com (10.3.19.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 24 Jun 2022 15:25:38 +0800 Received: from localhost.localdomain (10.69.192.56) by kwepemm600004.china.huawei.com (7.193.23.242) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 24 Jun 2022 15:25:38 +0800 From: Huisong Li To: , , , CC: , , , , Subject: [PATCH V5 3/7] app/testpmd: refactor config all RSS command Date: Fri, 24 Jun 2022 15:23:57 +0800 Message-ID: <20220624072401.21839-4-lihuisong@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220624072401.21839-1-lihuisong@huawei.com> References: <20220429102445.23711-1-lihuisong@huawei.com> <20220624072401.21839-1-lihuisong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.56] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemm600004.china.huawei.com (7.193.23.242) X-CFilter-Loop: Reflected 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 The "port config rss-hash-key" and "show port rss-hash key" commands both use the 'rss_type_table[]' to get 'rss_types' or the RSS type name. So this patch uses the 'rss_type_table[]' to get the rss types. In this way, this command naturally supports more individual types. Suggested-by: Ferruh Yigit Signed-off-by: Huisong Li --- app/test-pmd/cmdline.c | 127 ++++++-------------- app/test-pmd/config.c | 20 ++- app/test-pmd/testpmd.h | 1 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 11 +- 4 files changed, 63 insertions(+), 96 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index a701bac953..bea869ce56 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -693,9 +693,14 @@ static void cmd_help_long_parsed(void *parsed_result, " Enable or disable packet drop on all RX queues of all ports when no " "receive buffers available.\n\n" - "port config all rss (all|default|ip|tcp|udp|sctp|" - "l2-payload|port|vxlan|geneve|nvgre|vxlan-gpe|ecpri|mpls|ipv4-chksum|l2tpv2|" - "none|level-default|level-outer|level-inner|)\n" + "port config all rss (all|default|level-default|level-outer|level-inner|" + "ip|tcp|udp|sctp|tunnel|vlan|none|" + "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" + "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|" + "l2_payload|port|vxlan|geneve|nvgre|gtpu|eth|s-vlan|c-vlan|" + "esp|ah|l2tpv3|pfcp|pppoe|ecpri|mpls|ipv4-chksum|l4-chksum|" + "l2tpv2|l3-pre96|l3-pre64|l3-pre56|l3-pre48|l3-pre40|l3-pre32|" + "l2-dst-only|l2-src-only|l4-dst-only|l4-src-only|l3-dst-only|l3-src-only|)\n" " Set the RSS mode.\n\n" "port config port-id rss reta (hash,queue)[,(hash,queue)]\n" @@ -2062,81 +2067,7 @@ cmd_config_rss_parsed(void *parsed_result, uint16_t i; int ret; - if (!strcmp(res->value, "all")) - rss_conf.rss_hf = RTE_ETH_RSS_ETH | RTE_ETH_RSS_VLAN | RTE_ETH_RSS_IP | - RTE_ETH_RSS_TCP | RTE_ETH_RSS_UDP | RTE_ETH_RSS_SCTP | - RTE_ETH_RSS_L2_PAYLOAD | RTE_ETH_RSS_L2TPV3 | RTE_ETH_RSS_ESP | - RTE_ETH_RSS_AH | RTE_ETH_RSS_PFCP | RTE_ETH_RSS_GTPU | - RTE_ETH_RSS_ECPRI | RTE_ETH_RSS_L2TPV2; - else if (!strcmp(res->value, "eth")) - rss_conf.rss_hf = RTE_ETH_RSS_ETH; - else if (!strcmp(res->value, "vlan")) - rss_conf.rss_hf = RTE_ETH_RSS_VLAN; - else if (!strcmp(res->value, "ip")) - rss_conf.rss_hf = RTE_ETH_RSS_IP; - else if (!strcmp(res->value, "udp")) - rss_conf.rss_hf = RTE_ETH_RSS_UDP; - else if (!strcmp(res->value, "tcp")) - rss_conf.rss_hf = RTE_ETH_RSS_TCP; - else if (!strcmp(res->value, "sctp")) - rss_conf.rss_hf = RTE_ETH_RSS_SCTP; - else if (!strcmp(res->value, "l2_payload")) - rss_conf.rss_hf = RTE_ETH_RSS_L2_PAYLOAD; - else if (!strcmp(res->value, "port")) - rss_conf.rss_hf = RTE_ETH_RSS_PORT; - else if (!strcmp(res->value, "vxlan")) - rss_conf.rss_hf = RTE_ETH_RSS_VXLAN; - else if (!strcmp(res->value, "geneve")) - rss_conf.rss_hf = RTE_ETH_RSS_GENEVE; - else if (!strcmp(res->value, "nvgre")) - rss_conf.rss_hf = RTE_ETH_RSS_NVGRE; - else if (!strcmp(res->value, "l3-pre32")) - rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE32; - else if (!strcmp(res->value, "l3-pre40")) - rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE40; - else if (!strcmp(res->value, "l3-pre48")) - rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE48; - else if (!strcmp(res->value, "l3-pre56")) - rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE56; - else if (!strcmp(res->value, "l3-pre64")) - rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE64; - else if (!strcmp(res->value, "l3-pre96")) - rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE96; - else if (!strcmp(res->value, "l3-src-only")) - rss_conf.rss_hf = RTE_ETH_RSS_L3_SRC_ONLY; - else if (!strcmp(res->value, "l3-dst-only")) - rss_conf.rss_hf = RTE_ETH_RSS_L3_DST_ONLY; - else if (!strcmp(res->value, "l4-src-only")) - rss_conf.rss_hf = RTE_ETH_RSS_L4_SRC_ONLY; - else if (!strcmp(res->value, "l4-dst-only")) - rss_conf.rss_hf = RTE_ETH_RSS_L4_DST_ONLY; - else if (!strcmp(res->value, "l2-src-only")) - rss_conf.rss_hf = RTE_ETH_RSS_L2_SRC_ONLY; - else if (!strcmp(res->value, "l2-dst-only")) - rss_conf.rss_hf = RTE_ETH_RSS_L2_DST_ONLY; - else if (!strcmp(res->value, "l2tpv3")) - rss_conf.rss_hf = RTE_ETH_RSS_L2TPV3; - else if (!strcmp(res->value, "esp")) - rss_conf.rss_hf = RTE_ETH_RSS_ESP; - else if (!strcmp(res->value, "ah")) - rss_conf.rss_hf = RTE_ETH_RSS_AH; - else if (!strcmp(res->value, "pfcp")) - rss_conf.rss_hf = RTE_ETH_RSS_PFCP; - else if (!strcmp(res->value, "pppoe")) - rss_conf.rss_hf = RTE_ETH_RSS_PPPOE; - else if (!strcmp(res->value, "gtpu")) - rss_conf.rss_hf = RTE_ETH_RSS_GTPU; - else if (!strcmp(res->value, "ecpri")) - rss_conf.rss_hf = RTE_ETH_RSS_ECPRI; - else if (!strcmp(res->value, "mpls")) - rss_conf.rss_hf = RTE_ETH_RSS_MPLS; - else if (!strcmp(res->value, "ipv4-chksum")) - rss_conf.rss_hf = RTE_ETH_RSS_IPV4_CHKSUM; - else if (!strcmp(res->value, "l2tpv2")) - rss_conf.rss_hf = RTE_ETH_RSS_L2TPV2; - else if (!strcmp(res->value, "none")) - rss_conf.rss_hf = 0; - else if (!strcmp(res->value, "level-default")) { + if (!strcmp(res->value, "level-default")) { rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK); rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_PMD_DEFAULT); } else if (!strcmp(res->value, "level-outer")) { @@ -2145,14 +2076,29 @@ cmd_config_rss_parsed(void *parsed_result, } else if (!strcmp(res->value, "level-inner")) { rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK); rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_INNERMOST); - } else if (!strcmp(res->value, "default")) + } else if (!strcmp(res->value, "default")) { use_default = 1; - else if (isdigit(res->value[0]) && atoi(res->value) > 0 && - atoi(res->value) < 64) - rss_conf.rss_hf = 1ULL << atoi(res->value); - else { - fprintf(stderr, "Unknown parameter\n"); - return; + } else if (isdigit(res->value[0])) { + int value = atoi(res->value); + if (value > 0 && value < 64) + rss_conf.rss_hf = 1ULL << (uint8_t)value; + else { + fprintf(stderr, "flowtype_id should be greater than 0 and less than 64.\n"); + return; + } + } else if (!strcmp(res->value, "all") || !strcmp(res->value, "ip") || + !strcmp(res->value, "udp") || !strcmp(res->value, "tcp") || + !strcmp(res->value, "sctp") || !strcmp(res->value, "vlan") || + !strcmp(res->value, "none")) { + /* Parse group types or none type */ + rss_conf.rss_hf = str_to_rsstypes(res->value); + } else { + /* Get individual type. */ + rss_conf.rss_hf = str_to_rsstypes(res->value); + if (rss_conf.rss_hf == 0) { + fprintf(stderr, "Unknown parameter\n"); + return; + } } rss_conf.rss_key = NULL; /* Update global configuration for RSS types. */ @@ -2203,9 +2149,14 @@ static cmdline_parse_inst_t cmd_config_rss = { .f = cmd_config_rss_parsed, .data = NULL, .help_str = "port config all rss " - "all|default|eth|vlan|ip|tcp|udp|sctp|l2-payload|port|vxlan|geneve|" - "nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|ecpri|mpls|ipv4-chksum|l2tpv2|" - "none|level-default|level-outer|level-inner|", + "all|default|level-default|level-outer|level-inner|" + "ip|tcp|udp|sctp|tunnel|vlan|none|" + "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" + "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|" + "l2_payload|port|vxlan|geneve|nvgre|gtpu|eth|s-vlan|c-vlan|" + "esp|ah|l2tpv3|pfcp|pppoe|ecpri|mpls|ipv4-chksum|l4-chksum|" + "l2tpv2|l3-pre96|l3-pre64|l3-pre56|l3-pre48|l3-pre40|l3-pre32|" + "l2-dst-only|l2-src-only|l4-dst-only|l4-src-only|l3-dst-only|l3-src-only|", .tokens = { (void *)&cmd_config_rss_port, (void *)&cmd_config_rss_keyword, diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 36a828307c..3bf03c0969 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -673,6 +673,19 @@ print_dev_capabilities(uint64_t capabilities) } } +uint64_t +str_to_rsstypes(const char *str) +{ + uint16_t i; + + for (i = 0; rss_type_table[i].str != NULL; i++) { + if (strcmp(rss_type_table[i].str, str) == 0) + return rss_type_table[i].rss_type; + } + + return 0; +} + const char * rsstypes_to_str(uint64_t rss_type) { @@ -3856,15 +3869,10 @@ port_rss_hash_key_update(portid_t port_id, char rss_type[], uint8_t *hash_key, { struct rte_eth_rss_conf rss_conf; int diag; - unsigned int i; rss_conf.rss_key = NULL; rss_conf.rss_key_len = 0; - rss_conf.rss_hf = 0; - for (i = 0; rss_type_table[i].str; i++) { - if (!strcmp(rss_type_table[i].str, rss_type)) - rss_conf.rss_hf = rss_type_table[i].rss_type; - } + rss_conf.rss_hf = str_to_rsstypes(rss_type); diag = rte_eth_dev_rss_hash_conf_get(port_id, &rss_conf); if (diag == 0) { rss_conf.rss_key = hash_key; diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index 195488b602..2e2987eb66 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -1199,6 +1199,7 @@ extern int flow_parse(const char *src, void *result, unsigned int size, struct rte_flow_item **pattern, struct rte_flow_action **actions); +uint64_t str_to_rsstypes(const char *str); const char *rsstypes_to_str(uint64_t rss_type); /* For registering driver specific testpmd commands. */ diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index cc299cff6c..63a9e26f33 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -2143,8 +2143,15 @@ port config - RSS ~~~~~~~~~~~~~~~~~ Set the RSS (Receive Side Scaling) mode on or off:: - - testpmd> port config all rss (all|default|eth|vlan|ip|tcp|udp|sctp|l2-payload|port|vxlan|geneve|nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|ecpri|mpls|l2tpv2|none) + testpmd> port config all rss (all|default|level-default|level-outer|level-inner| \ + ip|tcp|udp|sctp|tunnel|vlan|none| \ + ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other| \ + ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp| \ + ipv6-other|ipv6-ex|ipv6-tcp-ex|ipv6-udp-exl2_payload|port| \ + vxlan|geneve|nvgre|gtpu|eth|s-vlan|c-vlan| \ + esp|ah|l2tpv3|pfcp|pppoe|ecpri|mpls|ipv4-chksum|l4-chksum| \ + l2tpv2|l3-pre96|l3-pre64|l3-pre56|l3-pre48|l3-pre40|l3-pre32| \ + l2-dst-only|l2-src-only|l4-dst-only|l4-src-only|l3-dst-only|l3-src-only|) RSS is on by default. From patchwork Fri Jun 24 07:23:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "lihuisong (C)" X-Patchwork-Id: 113412 X-Patchwork-Delegate: ferruh.yigit@amd.com 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 74DC5A0032; Fri, 24 Jun 2022 09:27:40 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 680F6415D7; Fri, 24 Jun 2022 09:27:40 +0200 (CEST) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by mails.dpdk.org (Postfix) with ESMTP id C2C9140A82 for ; Fri, 24 Jun 2022 09:27:38 +0200 (CEST) Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4LTpX631SPzShK1; Fri, 24 Jun 2022 15:24:06 +0800 (CST) Received: from kwepemm600004.china.huawei.com (7.193.23.242) by dggemv703-chm.china.huawei.com (10.3.19.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 24 Jun 2022 15:25:39 +0800 Received: from localhost.localdomain (10.69.192.56) by kwepemm600004.china.huawei.com (7.193.23.242) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 24 Jun 2022 15:25:38 +0800 From: Huisong Li To: , , , CC: , , , , Subject: [PATCH V5 5/7] app/testpmd: compact RSS types output in some commands Date: Fri, 24 Jun 2022 15:23:59 +0800 Message-ID: <20220624072401.21839-6-lihuisong@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220624072401.21839-1-lihuisong@huawei.com> References: <20220429102445.23711-1-lihuisong@huawei.com> <20220624072401.21839-1-lihuisong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.56] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemm600004.china.huawei.com (7.193.23.242) X-CFilter-Loop: Reflected 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 From: Ferruh Yigit In port info command output, 'show port info all', supported RSS offload types printed one type per line, and although this information is not most important part of the command it takes big part of the command output. In port RSS hash and flow RSS command output, 'show port 0 rss-hash', and 'flow query 0 0 rss', all enabled RSS types are printed on one line. If there are many types, the print will be very long. Compacting these RSS offloads and types output by fixing the length of the character string printed on each line, instead of one per line or one line. Output becomes as following: Supported RSS offload flow types: ipv4-frag ipv4-tcp ipv4-udp ipv4-sctp ipv4-other ipv6-frag ipv6-tcp ipv6-udp ipv6-sctp ipv6-other l4-dst-only l4-src-only l3-dst-only l3-src-only Signed-off-by: Ferruh Yigit Signed-off-by: Huisong Li --- app/test-pmd/config.c | 68 +++++++++++++++++++++++++++++++----------- app/test-pmd/testpmd.h | 2 ++ 2 files changed, 52 insertions(+), 18 deletions(-) diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index a0a5f12c71..b3cb68003c 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -699,6 +699,38 @@ rsstypes_to_str(uint64_t rss_type) return NULL; } +static void +rss_offload_types_display(uint64_t offload_types, uint16_t char_num_per_line) +{ + uint16_t unknown_offload_str_len; + uint16_t total_len = 0; + uint16_t str_len = 0; + uint64_t rss_offload; + uint16_t i; + + for (i = 0; i < sizeof(offload_types) * CHAR_BIT; i++) { + rss_offload = RTE_BIT64(i); + if ((offload_types & rss_offload) != 0) { + const char *p = rsstypes_to_str(rss_offload); + + unknown_offload_str_len = + strlen("unknown_offload(BIT())") + (i / 10 + 1); + str_len = p ? strlen(p) : unknown_offload_str_len; + str_len += 2; /* add two spaces */ + if (total_len + str_len >= char_num_per_line) { + total_len = 0; + printf("\n"); + } + + if (p) + printf(" %s", p); + else + printf(" unknown_offload(BIT(%u))", i); + total_len += str_len; + } + } +} + void port_infos_display(portid_t port_id) { @@ -803,21 +835,10 @@ port_infos_display(portid_t port_id) if (!dev_info.flow_type_rss_offloads) printf("No RSS offload flow type is supported.\n"); else { - uint64_t rss_offload_types = dev_info.flow_type_rss_offloads; - uint16_t i; - printf("Supported RSS offload flow types:\n"); - for (i = 0; i < sizeof(rss_offload_types) * CHAR_BIT; i++) { - uint64_t rss_offload = RTE_BIT64(i); - if ((rss_offload_types & rss_offload) != 0) { - const char *p = rsstypes_to_str(rss_offload); - if (p) - printf(" %s\n", p); - else - printf(" unknown_offload(BIT(%u))\n", - i); - } - } + rss_offload_types_display(dev_info.flow_type_rss_offloads, + TESTPMD_RSS_TYPES_CHAR_NUM_PER_LINE); + printf("\n"); } printf("Minimum size of RX buffer: %u\n", dev_info.min_rx_bufsize); @@ -1570,8 +1591,10 @@ port_flow_complain(struct rte_flow_error *error) } static void -rss_types_display(uint64_t rss_types) +rss_types_display(uint64_t rss_types, uint16_t char_num_per_line) { + uint16_t total_len = 0; + uint16_t str_len; uint16_t i; if (rss_types == 0) @@ -1580,9 +1603,18 @@ rss_types_display(uint64_t rss_types) for (i = 0; rss_type_table[i].str; i++) { if (rss_type_table[i].rss_type == 0) continue; + if ((rss_types & rss_type_table[i].rss_type) == - rss_type_table[i].rss_type) + rss_type_table[i].rss_type) { + /* contain two spces */ + str_len = strlen(rss_type_table[i].str) + 2; + if (total_len + str_len > char_num_per_line) { + printf("\n"); + total_len = 0; + } printf(" %s", rss_type_table[i].str); + total_len += str_len; + } } } @@ -1628,7 +1660,7 @@ rss_config_display(struct rte_flow_action_rss *rss_conf) printf(" none\n"); return; } - rss_types_display(rss_conf->types); + rss_types_display(rss_conf->types, TESTPMD_RSS_TYPES_CHAR_NUM_PER_LINE); } static struct port_indirect_action * @@ -3859,7 +3891,7 @@ port_rss_hash_conf_show(portid_t port_id, int show_rss_key) return; } printf("RSS functions:\n"); - rss_types_display(rss_hf); + rss_types_display(rss_hf, TESTPMD_RSS_TYPES_CHAR_NUM_PER_LINE); printf("\n"); if (!show_rss_key) return; diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index 2e2987eb66..9cc5752f62 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -113,6 +113,8 @@ struct pkt_burst_stats { unsigned int pkt_burst_spread[MAX_PKT_BURST + 1]; }; + +#define TESTPMD_RSS_TYPES_CHAR_NUM_PER_LINE 64 /** Information for a given RSS type. */ struct rss_type_info { const char *str; /**< Type name. */ From patchwork Fri Jun 24 07:24:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "lihuisong (C)" X-Patchwork-Id: 113410 X-Patchwork-Delegate: ferruh.yigit@amd.com 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 BEF6CA0032; Fri, 24 Jun 2022 09:26:14 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B154E415D7; Fri, 24 Jun 2022 09:26:14 +0200 (CEST) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mails.dpdk.org (Postfix) with ESMTP id 5A3BD415D7 for ; Fri, 24 Jun 2022 09:26:13 +0200 (CEST) Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4LTpY528cszkWlf; Fri, 24 Jun 2022 15:24:57 +0800 (CST) Received: from kwepemm600004.china.huawei.com (7.193.23.242) by dggemv711-chm.china.huawei.com (10.1.198.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 24 Jun 2022 15:25:39 +0800 Received: from localhost.localdomain (10.69.192.56) by kwepemm600004.china.huawei.com (7.193.23.242) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 24 Jun 2022 15:25:39 +0800 From: Huisong Li To: , , , CC: , , , , Subject: [PATCH V5 6/7] app/testpmd: reorder elements in RSS type table array Date: Fri, 24 Jun 2022 15:24:00 +0800 Message-ID: <20220624072401.21839-7-lihuisong@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220624072401.21839-1-lihuisong@huawei.com> References: <20220429102445.23711-1-lihuisong@huawei.com> <20220624072401.21839-1-lihuisong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.56] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemm600004.china.huawei.com (7.193.23.242) X-CFilter-Loop: Reflected 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 There are group and individual types in rss_type_table[]. However, group types are very scattered, and individual types are not arranged based on the bit number order in 'RTE_ETH_RSS_xxx'. For a clear distribution of types and better maintenance, this patch reorders this table. Signed-off-by: Huisong Li --- app/test-pmd/config.c | 51 +++++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index b3cb68003c..cc97aaa0ce 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -85,17 +85,20 @@ static const struct { }; const struct rss_type_info rss_type_table[] = { + /* Group types */ { "all", RTE_ETH_RSS_ETH | RTE_ETH_RSS_VLAN | RTE_ETH_RSS_IP | RTE_ETH_RSS_TCP | RTE_ETH_RSS_UDP | RTE_ETH_RSS_SCTP | RTE_ETH_RSS_L2_PAYLOAD | RTE_ETH_RSS_L2TPV3 | RTE_ETH_RSS_ESP | RTE_ETH_RSS_AH | RTE_ETH_RSS_PFCP | RTE_ETH_RSS_GTPU | RTE_ETH_RSS_ECPRI | RTE_ETH_RSS_MPLS | RTE_ETH_RSS_L2TPV2}, { "none", 0 }, - { "eth", RTE_ETH_RSS_ETH }, - { "l2-src-only", RTE_ETH_RSS_L2_SRC_ONLY }, - { "l2-dst-only", RTE_ETH_RSS_L2_DST_ONLY }, + { "ip", RTE_ETH_RSS_IP }, + { "udp", RTE_ETH_RSS_UDP }, + { "tcp", RTE_ETH_RSS_TCP }, + { "sctp", RTE_ETH_RSS_SCTP }, + { "tunnel", RTE_ETH_RSS_TUNNEL }, { "vlan", RTE_ETH_RSS_VLAN }, - { "s-vlan", RTE_ETH_RSS_S_VLAN }, - { "c-vlan", RTE_ETH_RSS_C_VLAN }, + + /* Individual type */ { "ipv4", RTE_ETH_RSS_IPV4 }, { "ipv4-frag", RTE_ETH_RSS_FRAG_IPV4 }, { "ipv4-tcp", RTE_ETH_RSS_NONFRAG_IPV4_TCP }, @@ -108,7 +111,7 @@ const struct rss_type_info rss_type_table[] = { { "ipv6-udp", RTE_ETH_RSS_NONFRAG_IPV6_UDP }, { "ipv6-sctp", RTE_ETH_RSS_NONFRAG_IPV6_SCTP }, { "ipv6-other", RTE_ETH_RSS_NONFRAG_IPV6_OTHER }, - { "l2-payload", RTE_ETH_RSS_L2_PAYLOAD }, + { "l2_payload", RTE_ETH_RSS_L2_PAYLOAD }, { "ipv6-ex", RTE_ETH_RSS_IPV6_EX }, { "ipv6-tcp-ex", RTE_ETH_RSS_IPV6_TCP_EX }, { "ipv6-udp-ex", RTE_ETH_RSS_IPV6_UDP_EX }, @@ -116,33 +119,33 @@ const struct rss_type_info rss_type_table[] = { { "vxlan", RTE_ETH_RSS_VXLAN }, { "geneve", RTE_ETH_RSS_GENEVE }, { "nvgre", RTE_ETH_RSS_NVGRE }, - { "ip", RTE_ETH_RSS_IP }, - { "udp", RTE_ETH_RSS_UDP }, - { "tcp", RTE_ETH_RSS_TCP }, - { "sctp", RTE_ETH_RSS_SCTP }, - { "tunnel", RTE_ETH_RSS_TUNNEL }, - { "l3-pre32", RTE_ETH_RSS_L3_PRE32 }, - { "l3-pre40", RTE_ETH_RSS_L3_PRE40 }, - { "l3-pre48", RTE_ETH_RSS_L3_PRE48 }, - { "l3-pre56", RTE_ETH_RSS_L3_PRE56 }, - { "l3-pre64", RTE_ETH_RSS_L3_PRE64 }, - { "l3-pre96", RTE_ETH_RSS_L3_PRE96 }, - { "l3-src-only", RTE_ETH_RSS_L3_SRC_ONLY }, - { "l3-dst-only", RTE_ETH_RSS_L3_DST_ONLY }, - { "l4-src-only", RTE_ETH_RSS_L4_SRC_ONLY }, - { "l4-dst-only", RTE_ETH_RSS_L4_DST_ONLY }, + { "gtpu", RTE_ETH_RSS_GTPU }, + { "eth", RTE_ETH_RSS_ETH }, + { "s-vlan", RTE_ETH_RSS_S_VLAN }, + { "c-vlan", RTE_ETH_RSS_C_VLAN }, { "esp", RTE_ETH_RSS_ESP }, { "ah", RTE_ETH_RSS_AH }, { "l2tpv3", RTE_ETH_RSS_L2TPV3 }, { "pfcp", RTE_ETH_RSS_PFCP }, { "pppoe", RTE_ETH_RSS_PPPOE }, - { "gtpu", RTE_ETH_RSS_GTPU }, - { "ecpri", RTE_ETH_RSS_ECPRI }, + {"ecpri", RTE_ETH_RSS_ECPRI }, { "mpls", RTE_ETH_RSS_MPLS }, { "ipv4-chksum", RTE_ETH_RSS_IPV4_CHKSUM }, { "l4-chksum", RTE_ETH_RSS_L4_CHKSUM }, { "l2tpv2", RTE_ETH_RSS_L2TPV2 }, - { NULL, 0 }, + { "l3-pre96", RTE_ETH_RSS_L3_PRE96 }, + { "l3-pre64", RTE_ETH_RSS_L3_PRE64 }, + { "l3-pre56", RTE_ETH_RSS_L3_PRE56 }, + { "l3-pre48", RTE_ETH_RSS_L3_PRE48 }, + { "l3-pre40", RTE_ETH_RSS_L3_PRE40 }, + { "l3-pre32", RTE_ETH_RSS_L3_PRE32 }, + { "l2-dst-only", RTE_ETH_RSS_L2_DST_ONLY }, + { "l2-src-only", RTE_ETH_RSS_L2_SRC_ONLY }, + { "l4-dst-only", RTE_ETH_RSS_L4_DST_ONLY }, + { "l4-src-only", RTE_ETH_RSS_L4_SRC_ONLY }, + { "l3-dst-only", RTE_ETH_RSS_L3_DST_ONLY }, + { "l3-src-only", RTE_ETH_RSS_L3_SRC_ONLY }, + { NULL, 0}, }; static const struct { From patchwork Fri Jun 24 07:24:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "lihuisong (C)" X-Patchwork-Id: 113411 X-Patchwork-Delegate: ferruh.yigit@amd.com 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 D5458A0032; Fri, 24 Jun 2022 09:26:22 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CA75940E2D; Fri, 24 Jun 2022 09:26:22 +0200 (CEST) Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by mails.dpdk.org (Postfix) with ESMTP id DF10040E2D for ; Fri, 24 Jun 2022 09:26:20 +0200 (CEST) Received: from dggemv704-chm.china.huawei.com (unknown [172.30.72.55]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4LTpX93cGwz1KCBR; Fri, 24 Jun 2022 15:24:09 +0800 (CST) Received: from kwepemm600004.china.huawei.com (7.193.23.242) by dggemv704-chm.china.huawei.com (10.3.19.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 24 Jun 2022 15:25:40 +0800 Received: from localhost.localdomain (10.69.192.56) by kwepemm600004.china.huawei.com (7.193.23.242) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 24 Jun 2022 15:25:39 +0800 From: Huisong Li To: , , , CC: , , , , Subject: [PATCH V5 7/7] app/testpmd: remove duplicated flow type to string table Date: Fri, 24 Jun 2022 15:24:01 +0800 Message-ID: <20220624072401.21839-8-lihuisong@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220624072401.21839-1-lihuisong@huawei.com> References: <20220429102445.23711-1-lihuisong@huawei.com> <20220624072401.21839-1-lihuisong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.56] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemm600004.china.huawei.com (7.193.23.242) X-CFilter-Loop: Reflected 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 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()' and 'str_to_flowtype()' non-static to prevent build error for the case PMDs using it disables. Making the two functions generic, not for some PMDs. Signed-off-by: Ferruh Yigit Signed-off-by: Huisong Li --- app/test-pmd/config.c | 86 ++++++++++++++++++++------------- app/test-pmd/testpmd.h | 3 ++ drivers/net/i40e/i40e_testpmd.c | 41 +--------------- 3 files changed, 56 insertions(+), 74 deletions(-) diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index cc97aaa0ce..37797289f7 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -170,6 +170,35 @@ static const struct { }, }; +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}, +}; + static void print_ethaddr(const char *name, struct rte_ether_addr *eth_addr) { @@ -5665,42 +5694,29 @@ set_record_burst_stats(uint8_t on_off) record_burst_stats = on_off; } -#if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE) +uint16_t +str_to_flowtype(const char *string) +{ + uint8_t i; -static char* + 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; +} + +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) @@ -5710,6 +5726,8 @@ flowtype_to_str(uint16_t flow_type) return NULL; } +#if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE) + static inline void print_fdir_mask(struct rte_eth_fdir_masks *mask) { @@ -5774,7 +5792,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]; @@ -5790,7 +5808,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 9cc5752f62..fb2f5195d3 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -1204,6 +1204,9 @@ extern int flow_parse(const char *src, void *result, unsigned int size, uint64_t str_to_rsstypes(const char *str); const char *rsstypes_to_str(uint64_t rss_type); +uint16_t str_to_flowtype(const char *string); +const char *flowtype_to_str(uint16_t flow_type); + /* For registering driver specific testpmd commands. */ struct testpmd_driver_commands { TAILQ_ENTRY(testpmd_driver_commands) next; diff --git a/drivers/net/i40e/i40e_testpmd.c b/drivers/net/i40e/i40e_testpmd.c index 86159e5c1c..45f8da270d 100644 --- a/drivers/net/i40e/i40e_testpmd.c +++ b/drivers/net/i40e/i40e_testpmd.c @@ -461,45 +461,6 @@ static cmdline_parse_inst_t cmd_show_queue_region_info_all = { }, }; -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; @@ -527,7 +488,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;