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 430BEA0093; Sat, 25 Jun 2022 04:13:24 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 32E7940694; Sat, 25 Jun 2022 04:13:24 +0200 (CEST) Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by mails.dpdk.org (Postfix) with ESMTP id 0F4A4400EF for ; Sat, 25 Jun 2022 04:13:22 +0200 (CEST) Received: from dggemv704-chm.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4LVHXY6Wthz1KCCV; Sat, 25 Jun 2022 10:11: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; Sat, 25 Jun 2022 10:13:20 +0800 Received: from [10.67.103.231] (10.67.103.231) 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; Sat, 25 Jun 2022 10:13:19 +0800 Message-ID: <2c00f63d-09b0-c76b-ebc1-8ed69890ab91@huawei.com> Date: Sat, 25 Jun 2022 10:13:19 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.2.0 Subject: Re: [PATCH V5 3/7] app/testpmd: refactor config all RSS command To: Ferruh Yigit , , , CC: , , , References: <20220429102445.23711-1-lihuisong@huawei.com> <20220624072401.21839-1-lihuisong@huawei.com> <20220624072401.21839-4-lihuisong@huawei.com> <3c8eede2-dfe2-b8a6-1bf3-8fa80c713195@xilinx.com> From: "lihuisong (C)" In-Reply-To: <3c8eede2-dfe2-b8a6-1bf3-8fa80c713195@xilinx.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.67.103.231] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) 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 在 2022/6/24 21:55, Ferruh Yigit 写道: > On 6/24/2022 8:23 AM, Huisong Li wrote: >> CAUTION: This message has originated from an External Source. Please >> use proper judgment and caution when opening attachments, clicking >> links, or responding to this email. >> >> >> 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); > > Why need to have a specific 'if' for the above types, why not directly > use 'str_to_rsstypes()'? You are right. we can merge the switch of group types and individual type. > >> +       } 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. >> >> -- >> 2.33.0 >> > > .