ethdev: allow to get RSS hash functions and key
[dpdk.git] / app / test-pmd / cmdline.c
index 5f39281..43c8ca0 100644 (file)
@@ -182,6 +182,10 @@ static void cmd_help_long_parsed(void *parsed_result,
                        "show port (info|stats|fdir|stat_qmap) (port_id|all)\n"
                        "    Display information for port_id, or all.\n\n"
 
+                       "show port rss-hash [key]\n"
+                       "    Display the RSS hash functions and RSS hash key"
+                       " of port X\n\n"
+
                        "clear port (info|stats|fdir|stat_qmap) (port_id|all)\n"
                        "    Clear information for port_id, or all.\n\n"
 
@@ -1124,26 +1128,22 @@ cmd_config_rss_parsed(void *parsed_result,
                        __attribute__((unused)) void *data)
 {
        struct cmd_config_rss *res = parsed_result;
-
-       if (!all_ports_stopped()) {
-               printf("Please stop all ports first\n");
-               return;
-       }
+       struct rte_eth_rss_conf rss_conf;
+       uint8_t i;
 
        if (!strcmp(res->value, "ip"))
-               rss_hf = ETH_RSS_IPV4 | ETH_RSS_IPV6;
+               rss_conf.rss_hf = ETH_RSS_IPV4 | ETH_RSS_IPV6;
        else if (!strcmp(res->value, "udp"))
-               rss_hf = ETH_RSS_IPV4 | ETH_RSS_IPV6 | ETH_RSS_IPV4_UDP;
+               rss_conf.rss_hf = ETH_RSS_IPV4_UDP | ETH_RSS_IPV6_UDP;
        else if (!strcmp(res->value, "none"))
-               rss_hf = 0;
+               rss_conf.rss_hf = 0;
        else {
                printf("Unknown parameter\n");
                return;
        }
-
-       init_port_config();
-
-       cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
+       rss_conf.rss_key = NULL;
+       for (i = 0; i < rte_eth_dev_count(); i++)
+               rte_eth_dev_rss_hash_update(i, &rss_conf);
 }
 
 cmdline_parse_token_string_t cmd_config_rss_port =
@@ -1347,6 +1347,63 @@ cmdline_parse_inst_t cmd_showport_reta = {
        },
 };
 
+/* *** Show RSS hash configuration *** */
+struct cmd_showport_rss_hash {
+       cmdline_fixed_string_t show;
+       cmdline_fixed_string_t port;
+       uint8_t port_id;
+       cmdline_fixed_string_t rss_hash;
+       cmdline_fixed_string_t key; /* optional argument */
+};
+
+static void cmd_showport_rss_hash_parsed(void *parsed_result,
+                               __attribute__((unused)) struct cmdline *cl,
+                               void *show_rss_key)
+{
+       struct cmd_showport_rss_hash *res = parsed_result;
+
+       port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
+}
+
+cmdline_parse_token_string_t cmd_showport_rss_hash_show =
+       TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
+cmdline_parse_token_string_t cmd_showport_rss_hash_port =
+       TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
+cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
+       TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8);
+cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
+       TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
+                                "rss-hash");
+cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
+       TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
+
+cmdline_parse_inst_t cmd_showport_rss_hash = {
+       .f = cmd_showport_rss_hash_parsed,
+       .data = NULL,
+       .help_str = "show port X rss-hash (X = port number)\n",
+       .tokens = {
+               (void *)&cmd_showport_rss_hash_show,
+               (void *)&cmd_showport_rss_hash_port,
+               (void *)&cmd_showport_rss_hash_port_id,
+               (void *)&cmd_showport_rss_hash_rss_hash,
+               NULL,
+       },
+};
+
+cmdline_parse_inst_t cmd_showport_rss_hash_key = {
+       .f = cmd_showport_rss_hash_parsed,
+       .data = "show_rss_key",
+       .help_str = "show port X rss-hash key (X = port number)\n",
+       .tokens = {
+               (void *)&cmd_showport_rss_hash_show,
+               (void *)&cmd_showport_rss_hash_port,
+               (void *)&cmd_showport_rss_hash_port_id,
+               (void *)&cmd_showport_rss_hash_rss_hash,
+               (void *)&cmd_showport_rss_hash_rss_key,
+               NULL,
+       },
+};
+
 /* *** Configure DCB *** */
 struct cmd_config_dcb {
        cmdline_fixed_string_t port;
@@ -5068,19 +5125,19 @@ static void cmd_dump_parsed(void *parsed_result,
        struct cmd_dump_result *res = parsed_result;
 
        if (!strcmp(res->dump, "dump_physmem"))
-               rte_dump_physmem_layout();
+               rte_dump_physmem_layout(stdout);
        else if (!strcmp(res->dump, "dump_memzone"))
-               rte_memzone_dump();
+               rte_memzone_dump(stdout);
        else if (!strcmp(res->dump, "dump_log_history"))
-               rte_log_dump_history();
+               rte_log_dump_history(stdout);
        else if (!strcmp(res->dump, "dump_struct_sizes"))
                dump_struct_sizes();
        else if (!strcmp(res->dump, "dump_ring"))
-               rte_ring_list_dump();
+               rte_ring_list_dump(stdout);
        else if (!strcmp(res->dump, "dump_mempool"))
-               rte_mempool_list_dump();
+               rte_mempool_list_dump(stdout);
        else if (!strcmp(res->dump, "dump_devargs"))
-               rte_eal_devargs_dump();
+               rte_eal_devargs_dump(stdout);
 }
 
 cmdline_parse_token_string_t cmd_dump_dump =
@@ -5122,7 +5179,7 @@ static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
                        cmdline_printf(cl, "Cannot find ring\n");
                        return;
                }
-               rte_ring_dump(r);
+               rte_ring_dump(stdout, r);
        } else if (!strcmp(res->dump, "dump_mempool")) {
                struct rte_mempool *mp;
                mp = rte_mempool_lookup(res->name);
@@ -5130,7 +5187,7 @@ static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
                        cmdline_printf(cl, "Cannot find mempool\n");
                        return;
                }
-               rte_mempool_dump(mp);
+               rte_mempool_dump(stdout, mp);
        }
 }
 
@@ -5233,6 +5290,8 @@ cmdline_parse_ctx_t main_ctx[] = {
        (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
        (cmdline_parse_inst_t *)&cmd_set_mirror_link,
        (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
+       (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
+       (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
        (cmdline_parse_inst_t *)&cmd_dump,
        (cmdline_parse_inst_t *)&cmd_dump_one,
        NULL,