app/testpmd: unify RSS types display
authorHuisong Li <lihuisong@huawei.com>
Wed, 29 Jun 2022 08:34:48 +0000 (16:34 +0800)
committerFerruh Yigit <ferruh.yigit@xilinx.com>
Wed, 29 Jun 2022 19:40:50 +0000 (21:40 +0200)
The 'rss_type_table[]' maintains the name and value of RSS types. This
patch unifies a common interface to display RSS types.

Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Ferruh Yigit <ferruh.yigit@xilinx.com>
app/test-pmd/config.c

index a8fd844..823699c 100644 (file)
@@ -1569,6 +1569,23 @@ port_flow_complain(struct rte_flow_error *error)
        return -err;
 }
 
+static void
+rss_types_display(uint64_t rss_types)
+{
+       uint16_t i;
+
+       if (rss_types == 0)
+               return;
+
+       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)
+                       printf("  %s", rss_type_table[i].str);
+       }
+}
+
 static void
 rss_config_display(struct rte_flow_action_rss *rss_conf)
 {
@@ -1611,13 +1628,7 @@ rss_config_display(struct rte_flow_action_rss *rss_conf)
                printf("  none\n");
                return;
        }
-       for (i = 0; rss_type_table[i].str; i++) {
-               if ((rss_conf->types &
-                   rss_type_table[i].rss_type) ==
-                   rss_type_table[i].rss_type &&
-                   rss_type_table[i].rss_type != 0)
-                       printf("  %s\n", rss_type_table[i].str);
-       }
+       rss_types_display(rss_conf->types);
 }
 
 static struct port_indirect_action *
@@ -3847,13 +3858,8 @@ port_rss_hash_conf_show(portid_t port_id, int show_rss_key)
                printf("RSS disabled\n");
                return;
        }
-       printf("RSS functions:\n ");
-       for (i = 0; rss_type_table[i].str; i++) {
-               if (rss_type_table[i].rss_type == 0)
-                       continue;
-               if ((rss_hf & rss_type_table[i].rss_type) == rss_type_table[i].rss_type)
-                       printf("%s ", rss_type_table[i].str);
-       }
+       printf("RSS functions:\n");
+       rss_types_display(rss_hf);
        printf("\n");
        if (!show_rss_key)
                return;