[PATCH V5 3/7] app/testpmd: refactor config all RSS command
Ferruh Yigit
ferruh.yigit at xilinx.com
Fri Jun 24 15:55:00 CEST 2022
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 <port_id> rss-hash-key" and "show port <port_id> 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 <ferruh.yigit at xilinx.com>
> Signed-off-by: Huisong Li <lihuisong at huawei.com>
> ---
> 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|<flowtype_id>)\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|<rsstype_id>)\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()'?
> + } 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|<flowtype_id>",
> + "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|<rsstype_id>",
> .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|<rsstype_id>)
>
> RSS is on by default.
>
> --
> 2.33.0
>
More information about the dev
mailing list