app/testpmd: fix command token
[dpdk.git] / app / test-pmd / cmdline.c
index 3e9006c..a0c1905 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"
@@ -1418,7 +1418,7 @@ cmdline_parse_inst_t cmd_config_speed_all = {
 struct cmd_config_speed_specific {
        cmdline_fixed_string_t port;
        cmdline_fixed_string_t keyword;
-       uint8_t id;
+       portid_t id;
        cmdline_fixed_string_t item1;
        cmdline_fixed_string_t item2;
        cmdline_fixed_string_t value1;
@@ -1458,7 +1458,7 @@ cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
        TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
                                                                "config");
 cmdline_parse_token_num_t cmd_config_speed_specific_id =
-       TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
+       TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT16);
 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
        TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
                                                                "speed");
@@ -1998,6 +1998,7 @@ 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;
        uint16_t i;
 
@@ -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;
+       /* 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,
@@ -2271,7 +2278,7 @@ cmdline_parse_inst_t cmd_config_rxtx_queue = {
        .data = NULL,
        .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
        .tokens = {
-               (void *)&cmd_config_speed_all_port,
+               (void *)&cmd_config_rxtx_queue_port,
                (void *)&cmd_config_rxtx_queue_portid,
                (void *)&cmd_config_rxtx_queue_rxtxq,
                (void *)&cmd_config_rxtx_queue_qid,
@@ -4157,6 +4164,12 @@ check_tunnel_tso_nic_support(portid_t port_id)
        if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
                printf("Warning: GENEVE TUNNEL TSO not supported therefore "
                       "not enabled for port %d\n", port_id);
+       if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
+               printf("Warning: IP TUNNEL TSO not supported therefore "
+                      "not enabled for port %d\n", port_id);
+       if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
+               printf("Warning: UDP TUNNEL TSO not supported therefore "
+                      "not enabled for port %d\n", port_id);
        return dev_info;
 }
 
@@ -4184,13 +4197,17 @@ cmd_tunnel_tso_set_parsed(void *parsed_result,
                        ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
                          DEV_TX_OFFLOAD_GRE_TNL_TSO |
                          DEV_TX_OFFLOAD_IPIP_TNL_TSO |
-                         DEV_TX_OFFLOAD_GENEVE_TNL_TSO);
+                         DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
+                         DEV_TX_OFFLOAD_IP_TNL_TSO |
+                         DEV_TX_OFFLOAD_UDP_TNL_TSO);
                printf("TSO for tunneled packets is disabled\n");
        } else {
                uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
                                         DEV_TX_OFFLOAD_GRE_TNL_TSO |
                                         DEV_TX_OFFLOAD_IPIP_TNL_TSO |
-                                        DEV_TX_OFFLOAD_GENEVE_TNL_TSO);
+                                        DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
+                                        DEV_TX_OFFLOAD_IP_TNL_TSO |
+                                        DEV_TX_OFFLOAD_UDP_TNL_TSO);
 
                ports[res->port_id].dev_conf.txmode.offloads |=
                        (tso_offloads & dev_info.tx_offload_capa);
@@ -5546,7 +5563,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);
        }
@@ -5655,11 +5672,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 */
@@ -5716,12 +5728,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"))
@@ -8765,7 +8771,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);
 }
@@ -10869,11 +10875,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) {
@@ -11070,11 +11071,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) {
@@ -11226,11 +11222,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) {
@@ -11872,7 +11863,7 @@ struct cmd_config_l2_tunnel_eth_type_result {
        cmdline_fixed_string_t port;
        cmdline_fixed_string_t config;
        cmdline_fixed_string_t all;
-       uint8_t id;
+       portid_t id;
        cmdline_fixed_string_t l2_tunnel;
        cmdline_fixed_string_t l2_tunnel_type;
        cmdline_fixed_string_t eth_type;
@@ -11894,7 +11885,7 @@ cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
        TOKEN_NUM_INITIALIZER
                (struct cmd_config_l2_tunnel_eth_type_result,
-                id, UINT8);
+                id, UINT16);
 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
        TOKEN_STRING_INITIALIZER
                (struct cmd_config_l2_tunnel_eth_type_result,
@@ -12007,7 +11998,7 @@ struct cmd_config_l2_tunnel_en_dis_result {
        cmdline_fixed_string_t port;
        cmdline_fixed_string_t config;
        cmdline_fixed_string_t all;
-       uint8_t id;
+       portid_t id;
        cmdline_fixed_string_t l2_tunnel;
        cmdline_fixed_string_t l2_tunnel_type;
        cmdline_fixed_string_t en_dis;
@@ -12028,7 +12019,7 @@ cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
        TOKEN_NUM_INITIALIZER
                (struct cmd_config_l2_tunnel_en_dis_result,
-                id, UINT8);
+                id, UINT16);
 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
        TOKEN_STRING_INITIALIZER
                (struct cmd_config_l2_tunnel_en_dis_result,
@@ -14611,11 +14602,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;
@@ -14693,11 +14679,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;
@@ -14994,12 +14975,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;
@@ -15008,11 +14989,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);
@@ -15075,22 +15051,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;
@@ -15203,22 +15174,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;