app/testpmd: new parameter for port config all RSS command
[dpdk.git] / app / test-pmd / cmdline.c
index 92ef7e1..2a10278 100644 (file)
@@ -821,8 +821,8 @@ static void cmd_help_long_parsed(void *parsed_result,
                        "    Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
                        " for ports.\n\n"
 
-                       "port config all rss (all|ip|tcp|udp|sctp|ether|port|vxlan|"
-                       "geneve|nvgre|none|<flowtype_id>)\n"
+                       "port config all rss (all|default|ip|tcp|udp|sctp|"
+                       "ether|port|vxlan|geneve|nvgre|none|<flowtype_id>)\n"
                        "    Set the RSS mode.\n\n"
 
                        "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
@@ -1998,8 +1998,9 @@ cmd_config_rss_parsed(void *parsed_result,
 {
        struct cmd_config_rss *res = parsed_result;
        struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
+       struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
        int diag;
-       uint8_t i;
+       uint16_t i;
 
        if (!strcmp(res->value, "all"))
                rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
@@ -2023,7 +2024,7 @@ cmd_config_rss_parsed(void *parsed_result,
                rss_conf.rss_hf = ETH_RSS_GENEVE;
        else if (!strcmp(res->value, "nvgre"))
                rss_conf.rss_hf = ETH_RSS_NVGRE;
-       else if (!strcmp(res->value, "none"))
+       else if (!strcmp(res->value, "none") || !strcmp(res->value, "default"))
                rss_conf.rss_hf = 0;
        else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
                                                atoi(res->value) < 64)
@@ -2033,7 +2034,13 @@ cmd_config_rss_parsed(void *parsed_result,
                return;
        }
        rss_conf.rss_key = NULL;
-       for (i = 0; i < rte_eth_dev_count(); i++) {
+       /* Update global configuration for RSS types. */
+       rss_hf = rss_conf.rss_hf;
+       RTE_ETH_FOREACH_DEV(i) {
+               if (!strcmp(res->value, "default")) {
+                       rte_eth_dev_info_get(i, &dev_info);
+                       rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
+               }
                diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
                if (diag < 0)
                        printf("Configuration of RSS hash at ethernet port %d "
@@ -2057,7 +2064,7 @@ cmdline_parse_inst_t cmd_config_rss = {
        .f = cmd_config_rss_parsed,
        .data = NULL,
        .help_str = "port config all rss "
-               "all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none|<flowtype_id>",
+               "all|default|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none|<flowtype_id>",
        .tokens = {
                (void *)&cmd_config_rss_port,
                (void *)&cmd_config_rss_keyword,
@@ -2718,6 +2725,8 @@ cmd_config_burst_parsed(void *parsed_result,
                        __attribute__((unused)) void *data)
 {
        struct cmd_config_burst *res = parsed_result;
+       struct rte_eth_dev_info dev_info;
+       uint16_t rec_nb_pkts;
 
        if (!all_ports_stopped()) {
                printf("Please stop all ports first\n");
@@ -2725,11 +2734,34 @@ cmd_config_burst_parsed(void *parsed_result,
        }
 
        if (!strcmp(res->name, "burst")) {
-               if (res->value < 1 || res->value > MAX_PKT_BURST) {
+               if (res->value == 0) {
+                       /* If user gives a value of zero, query the PMD for
+                        * its recommended Rx burst size. Testpmd uses a single
+                        * size for all ports, so assume all ports are the same
+                        * NIC model and use the values from Port 0.
+                        */
+                       rte_eth_dev_info_get(0, &dev_info);
+                       rec_nb_pkts = dev_info.default_rxportconf.burst_size;
+
+                       if (rec_nb_pkts == 0) {
+                               printf("PMD does not recommend a burst size.\n"
+                                       "User provided value must be between"
+                                       " 1 and %d\n", MAX_PKT_BURST);
+                               return;
+                       } else if (rec_nb_pkts > MAX_PKT_BURST) {
+                               printf("PMD recommended burst size of %d"
+                                       " exceeds maximum value of %d\n",
+                                       rec_nb_pkts, MAX_PKT_BURST);
+                               return;
+                       }
+                       printf("Using PMD-provided burst value of %d\n",
+                               rec_nb_pkts);
+                       nb_pkt_per_burst = rec_nb_pkts;
+               } else if (res->value > MAX_PKT_BURST) {
                        printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
                        return;
-               }
-               nb_pkt_per_burst = res->value;
+               } else
+                       nb_pkt_per_burst = res->value;
        } else {
                printf("Unknown parameter\n");
                return;
@@ -5521,7 +5553,7 @@ static void cmd_create_bonded_device_parsed(void *parsed_result,
                                port_id);
 
                /* Update number of ports */
-               nb_ports = rte_eth_dev_count();
+               nb_ports = rte_eth_dev_count_avail();
                reconfig(port_id, res->socket);
                rte_eth_promiscuous_enable(port_id);
        }
@@ -5630,11 +5662,6 @@ static void cmd_set_bond_mon_period_parsed(void *parsed_result,
        struct cmd_set_bond_mon_period_result *res = parsed_result;
        int ret;
 
-       if (res->port_num >= nb_ports) {
-               printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
-               return;
-       }
-
        ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
 
        /* check the return value and print it if is < 0 */
@@ -5691,12 +5718,6 @@ cmd_set_bonding_agg_mode(void *parsed_result,
        struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
        uint8_t policy = AGG_BANDWIDTH;
 
-       if (res->port_num >= nb_ports) {
-               printf("Port id %d must be less than %d\n",
-                               res->port_num, nb_ports);
-               return;
-       }
-
        if (!strcmp(res->policy, "bandwidth"))
                policy = AGG_BANDWIDTH;
        else if (!strcmp(res->policy, "stable"))
@@ -8740,7 +8761,7 @@ static void cmd_dump_parsed(void *parsed_result,
        else if (!strcmp(res->dump, "dump_mempool"))
                rte_mempool_list_dump(stdout);
        else if (!strcmp(res->dump, "dump_devargs"))
-               rte_eal_devargs_dump(stdout);
+               rte_devargs_dump(stdout);
        else if (!strcmp(res->dump, "dump_log_types"))
                rte_log_dump(stdout);
 }
@@ -10844,11 +10865,6 @@ cmd_flow_director_mask_parsed(void *parsed_result,
        struct rte_eth_fdir_masks *mask;
        struct rte_port *port;
 
-       if (res->port_id > nb_ports) {
-               printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
-               return;
-       }
-
        port = &ports[res->port_id];
        /** Check if the port is not started **/
        if (port->port_status != RTE_PORT_STOPPED) {
@@ -11045,11 +11061,6 @@ cmd_flow_director_flex_mask_parsed(void *parsed_result,
        uint16_t i;
        int ret;
 
-       if (res->port_id > nb_ports) {
-               printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
-               return;
-       }
-
        port = &ports[res->port_id];
        /** Check if the port is not started **/
        if (port->port_status != RTE_PORT_STOPPED) {
@@ -11201,11 +11212,6 @@ cmd_flow_director_flxpld_parsed(void *parsed_result,
        struct rte_port *port;
        int ret = 0;
 
-       if (res->port_id > nb_ports) {
-               printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
-               return;
-       }
-
        port = &ports[res->port_id];
        /** Check if the port is not started **/
        if (port->port_status != RTE_PORT_STOPPED) {
@@ -14586,11 +14592,6 @@ cmd_ddp_add_parsed(
        int file_num;
        int ret = -ENOTSUP;
 
-       if (res->port_id > nb_ports) {
-               printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
-               return;
-       }
-
        if (!all_ports_stopped()) {
                printf("Please stop all ports first\n");
                return;
@@ -14668,11 +14669,6 @@ cmd_ddp_del_parsed(
        uint32_t size;
        int ret = -ENOTSUP;
 
-       if (res->port_id > nb_ports) {
-               printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
-               return;
-       }
-
        if (!all_ports_stopped()) {
                printf("Please stop all ports first\n");
                return;
@@ -14969,12 +14965,12 @@ cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
 
 static void
 cmd_ddp_get_list_parsed(
-       void *parsed_result,
+       __attribute__((unused)) void *parsed_result,
        __attribute__((unused)) struct cmdline *cl,
        __attribute__((unused)) void *data)
 {
-       struct cmd_ddp_get_list_result *res = parsed_result;
 #ifdef RTE_LIBRTE_I40E_PMD
+       struct cmd_ddp_get_list_result *res = parsed_result;
        struct rte_pmd_i40e_profile_list *p_list;
        struct rte_pmd_i40e_profile_info *p_info;
        uint32_t p_num;
@@ -14983,11 +14979,6 @@ cmd_ddp_get_list_parsed(
 #endif
        int ret = -ENOTSUP;
 
-       if (res->port_id > nb_ports) {
-               printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
-               return;
-       }
-
 #ifdef RTE_LIBRTE_I40E_PMD
        size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
        p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
@@ -15050,22 +15041,17 @@ struct cmd_cfg_input_set_result {
 
 static void
 cmd_cfg_input_set_parsed(
-       void *parsed_result,
+       __attribute__((unused)) void *parsed_result,
        __attribute__((unused)) struct cmdline *cl,
        __attribute__((unused)) void *data)
 {
-       struct cmd_cfg_input_set_result *res = parsed_result;
 #ifdef RTE_LIBRTE_I40E_PMD
+       struct cmd_cfg_input_set_result *res = parsed_result;
        enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
        struct rte_pmd_i40e_inset inset;
 #endif
        int ret = -ENOTSUP;
 
-       if (res->port_id > nb_ports) {
-               printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
-               return;
-       }
-
        if (!all_ports_stopped()) {
                printf("Please stop all ports first\n");
                return;
@@ -15178,22 +15164,17 @@ struct cmd_clear_input_set_result {
 
 static void
 cmd_clear_input_set_parsed(
-       void *parsed_result,
+       __attribute__((unused)) void *parsed_result,
        __attribute__((unused)) struct cmdline *cl,
        __attribute__((unused)) void *data)
 {
-       struct cmd_clear_input_set_result *res = parsed_result;
 #ifdef RTE_LIBRTE_I40E_PMD
+       struct cmd_clear_input_set_result *res = parsed_result;
        enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
        struct rte_pmd_i40e_inset inset;
 #endif
        int ret = -ENOTSUP;
 
-       if (res->port_id > nb_ports) {
-               printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
-               return;
-       }
-
        if (!all_ports_stopped()) {
                printf("Please stop all ports first\n");
                return;