app/testpmd: separate forward config setup from display
[dpdk.git] / app / test-pmd / cmdline.c
index 95350de..73a5a47 100644 (file)
@@ -549,7 +549,7 @@ static void cmd_help_long_parsed(void *parsed_result,
                        "    Detach physical or virtual dev by port_id\n\n"
 
                        "port config (port_id|all)"
-                       " speed (10|100|1000|10000|40000|auto)"
+                       " speed (10|100|1000|10000|40000|100000|auto)"
                        " duplex (half|full|auto)\n"
                        "    Set speed and duplex for all ports or port_id\n\n"
 
@@ -559,10 +559,10 @@ static void cmd_help_long_parsed(void *parsed_result,
                        "port config all max-pkt-len (value)\n"
                        "    Set the max packet length.\n\n"
 
-                       "port config all (crc-strip|rx-cksum|hw-vlan|hw-vlan-filter|"
+                       "port config all (crc-strip|scatter|rx-cksum|hw-vlan|hw-vlan-filter|"
                        "hw-vlan-strip|hw-vlan-extend|drop-en)"
                        " (on|off)\n"
-                       "    Set crc-strip/rx-checksum/hardware-vlan/drop_en"
+                       "    Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
                        " for ports.\n\n"
 
                        "port config all rss (all|ip|tcp|udp|sctp|ether|none)\n"
@@ -774,7 +774,7 @@ static void cmd_help_long_parsed(void *parsed_result,
                        "set_fdir_input_set (port_id) "
                        "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
                        "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
-                       "l2_payload) (ethertype|src-ipv4|dst-ipv4|src-ipv6|"
+                       "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
                        "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
                        "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
                        "udp-dst-port|tcp-src-port|tcp-dst-port|"
@@ -988,14 +988,60 @@ struct cmd_config_speed_all {
        cmdline_fixed_string_t value2;
 };
 
+static int
+parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
+{
+
+       int duplex;
+
+       if (!strcmp(duplexstr, "half")) {
+               duplex = ETH_LINK_HALF_DUPLEX;
+       } else if (!strcmp(duplexstr, "full")) {
+               duplex = ETH_LINK_FULL_DUPLEX;
+       } else if (!strcmp(duplexstr, "auto")) {
+               duplex = ETH_LINK_FULL_DUPLEX;
+       } else {
+               printf("Unknown duplex parameter\n");
+               return -1;
+       }
+
+       if (!strcmp(speedstr, "10")) {
+               *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
+                               ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
+       } else if (!strcmp(speedstr, "100")) {
+               *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
+                               ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
+       } else {
+               if (duplex != ETH_LINK_FULL_DUPLEX) {
+                       printf("Invalid speed/duplex parameters\n");
+                       return -1;
+               }
+               if (!strcmp(speedstr, "1000")) {
+                       *speed = ETH_LINK_SPEED_1G;
+               } else if (!strcmp(speedstr, "10000")) {
+                       *speed = ETH_LINK_SPEED_10G;
+               } else if (!strcmp(speedstr, "40000")) {
+                       *speed = ETH_LINK_SPEED_40G;
+               } else if (!strcmp(speedstr, "100000")) {
+                       *speed = ETH_LINK_SPEED_100G;
+               } else if (!strcmp(speedstr, "auto")) {
+                       *speed = ETH_LINK_SPEED_AUTONEG;
+               } else {
+                       printf("Unknown speed parameter\n");
+                       return -1;
+               }
+       }
+
+       return 0;
+}
+
 static void
 cmd_config_speed_all_parsed(void *parsed_result,
                        __attribute__((unused)) struct cmdline *cl,
                        __attribute__((unused)) void *data)
 {
        struct cmd_config_speed_all *res = parsed_result;
-       uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
-       uint16_t link_duplex = 0;
+       uint32_t link_speed;
        portid_t pid;
 
        if (!all_ports_stopped()) {
@@ -1003,37 +1049,12 @@ cmd_config_speed_all_parsed(void *parsed_result,
                return;
        }
 
-       if (!strcmp(res->value1, "10"))
-               link_speed = ETH_LINK_SPEED_10;
-       else if (!strcmp(res->value1, "100"))
-               link_speed = ETH_LINK_SPEED_100;
-       else if (!strcmp(res->value1, "1000"))
-               link_speed = ETH_LINK_SPEED_1000;
-       else if (!strcmp(res->value1, "10000"))
-               link_speed = ETH_LINK_SPEED_10G;
-       else if (!strcmp(res->value1, "40000"))
-               link_speed = ETH_LINK_SPEED_40G;
-       else if (!strcmp(res->value1, "auto"))
-               link_speed = ETH_LINK_SPEED_AUTONEG;
-       else {
-               printf("Unknown parameter\n");
-               return;
-       }
-
-       if (!strcmp(res->value2, "half"))
-               link_duplex = ETH_LINK_HALF_DUPLEX;
-       else if (!strcmp(res->value2, "full"))
-               link_duplex = ETH_LINK_FULL_DUPLEX;
-       else if (!strcmp(res->value2, "auto"))
-               link_duplex = ETH_LINK_AUTONEG_DUPLEX;
-       else {
-               printf("Unknown parameter\n");
+       if (parse_and_check_speed_duplex(res->value1, res->value2,
+                       &link_speed) < 0)
                return;
-       }
 
        FOREACH_PORT(pid, ports) {
-               ports[pid].dev_conf.link_speed = link_speed;
-               ports[pid].dev_conf.link_duplex = link_duplex;
+               ports[pid].dev_conf.link_speeds = link_speed;
        }
 
        cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
@@ -1050,7 +1071,7 @@ cmdline_parse_token_string_t cmd_config_speed_all_item1 =
        TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
        TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
-                                               "10#100#1000#10000#40000#auto");
+                                               "10#100#1000#10000#40000#100000#auto");
 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
        TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
@@ -1060,7 +1081,7 @@ cmdline_parse_token_string_t cmd_config_speed_all_value2 =
 cmdline_parse_inst_t cmd_config_speed_all = {
        .f = cmd_config_speed_all_parsed,
        .data = NULL,
-       .help_str = "port config all speed 10|100|1000|10000|40000|auto duplex "
+       .help_str = "port config all speed 10|100|1000|10000|40000|100000|auto duplex "
                                                        "half|full|auto",
        .tokens = {
                (void *)&cmd_config_speed_all_port,
@@ -1091,8 +1112,7 @@ cmd_config_speed_specific_parsed(void *parsed_result,
                                __attribute__((unused)) void *data)
 {
        struct cmd_config_speed_specific *res = parsed_result;
-       uint16_t link_speed = ETH_LINK_SPEED_AUTONEG;
-       uint16_t link_duplex = 0;
+       uint32_t link_speed;
 
        if (!all_ports_stopped()) {
                printf("Please stop all ports first\n");
@@ -1102,36 +1122,11 @@ cmd_config_speed_specific_parsed(void *parsed_result,
        if (port_id_is_invalid(res->id, ENABLED_WARN))
                return;
 
-       if (!strcmp(res->value1, "10"))
-               link_speed = ETH_LINK_SPEED_10;
-       else if (!strcmp(res->value1, "100"))
-               link_speed = ETH_LINK_SPEED_100;
-       else if (!strcmp(res->value1, "1000"))
-               link_speed = ETH_LINK_SPEED_1000;
-       else if (!strcmp(res->value1, "10000"))
-               link_speed = ETH_LINK_SPEED_10000;
-       else if (!strcmp(res->value1, "40000"))
-               link_speed = ETH_LINK_SPEED_40G;
-       else if (!strcmp(res->value1, "auto"))
-               link_speed = ETH_LINK_SPEED_AUTONEG;
-       else {
-               printf("Unknown parameter\n");
+       if (parse_and_check_speed_duplex(res->value1, res->value2,
+                       &link_speed) < 0)
                return;
-       }
 
-       if (!strcmp(res->value2, "half"))
-               link_duplex = ETH_LINK_HALF_DUPLEX;
-       else if (!strcmp(res->value2, "full"))
-               link_duplex = ETH_LINK_FULL_DUPLEX;
-       else if (!strcmp(res->value2, "auto"))
-               link_duplex = ETH_LINK_AUTONEG_DUPLEX;
-       else {
-               printf("Unknown parameter\n");
-               return;
-       }
-
-       ports[res->id].dev_conf.link_speed = link_speed;
-       ports[res->id].dev_conf.link_duplex = link_duplex;
+       ports[res->id].dev_conf.link_speeds = link_speed;
 
        cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
 }
@@ -1150,7 +1145,7 @@ cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
                                                                "speed");
 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
        TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
-                                               "10#100#1000#10000#40000#auto");
+                                               "10#100#1000#10000#40000#100000#auto");
 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
        TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
                                                                "duplex");
@@ -1161,7 +1156,7 @@ cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
 cmdline_parse_inst_t cmd_config_speed_specific = {
        .f = cmd_config_speed_specific_parsed,
        .data = NULL,
-       .help_str = "port config X speed 10|100|1000|10000|40000|auto duplex "
+       .help_str = "port config X speed 10|100|1000|10000|40000|100000|auto duplex "
                                                        "half|full|auto",
        .tokens = {
                (void *)&cmd_config_speed_specific_port,
@@ -1228,6 +1223,8 @@ cmd_config_rx_tx_parsed(void *parsed_result,
                return;
        }
 
+       fwd_config_setup();
+
        init_port_config();
 
        cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
@@ -1415,6 +1412,15 @@ cmd_config_rx_mode_flag_parsed(void *parsed_result,
                        printf("Unknown parameter\n");
                        return;
                }
+       } else if (!strcmp(res->name, "scatter")) {
+               if (!strcmp(res->value, "on"))
+                       rx_mode.enable_scatter = 1;
+               else if (!strcmp(res->value, "off"))
+                       rx_mode.enable_scatter = 0;
+               else {
+                       printf("Unknown parameter\n");
+                       return;
+               }
        } else if (!strcmp(res->name, "rx-cksum")) {
                if (!strcmp(res->value, "on"))
                        rx_mode.hw_ip_checksum = 1;
@@ -1492,7 +1498,7 @@ cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
        TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
        TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
-                                       "crc-strip#rx-cksum#hw-vlan#"
+                                       "crc-strip#scatter#rx-cksum#hw-vlan#"
                                        "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
        TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
@@ -1501,7 +1507,7 @@ cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
        .f = cmd_config_rx_mode_flag_parsed,
        .data = NULL,
-       .help_str = "port config all crc-strip|rx-cksum|hw-vlan|"
+       .help_str = "port config all crc-strip|scatter|rx-cksum|hw-vlan|"
                "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
        .tokens = {
                (void *)&cmd_config_rx_mode_flag_port,
@@ -2516,16 +2522,20 @@ static void cmd_set_list_parsed(void *parsed_result,
                nb_item = parse_item_list(res->list_of_items, "core",
                                          RTE_MAX_LCORE,
                                          parsed_items.lcorelist, 1);
-               if (nb_item > 0)
+               if (nb_item > 0) {
                        set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
+                       fwd_config_setup();
+               }
                return;
        }
        if (!strcmp(res->list_name, "portlist")) {
                nb_item = parse_item_list(res->list_of_items, "port",
                                          RTE_MAX_ETHPORTS,
                                          parsed_items.portlist, 1);
-               if (nb_item > 0)
+               if (nb_item > 0) {
                        set_fwd_ports_list(parsed_items.portlist, nb_item);
+                       fwd_config_setup();
+               }
        }
 }
 
@@ -2569,10 +2579,13 @@ static void cmd_set_mask_parsed(void *parsed_result,
                printf("Please stop forwarding first\n");
                return;
        }
-       if (!strcmp(res->mask, "coremask"))
+       if (!strcmp(res->mask, "coremask")) {
                set_fwd_lcores_mask(res->hexavalue);
-       else if (!strcmp(res->mask, "portmask"))
+               fwd_config_setup();
+       } else if (!strcmp(res->mask, "portmask")) {
                set_fwd_ports_mask(res->hexavalue);
+               fwd_config_setup();
+       }
 }
 
 cmdline_parse_token_string_t cmd_setmask_set =
@@ -2609,11 +2622,13 @@ static void cmd_set_parsed(void *parsed_result,
                           __attribute__((unused)) void *data)
 {
        struct cmd_set_result *res = parsed_result;
-       if (!strcmp(res->what, "nbport"))
+       if (!strcmp(res->what, "nbport")) {
                set_fwd_ports_number(res->value);
-       else if (!strcmp(res->what, "nbcore"))
+               fwd_config_setup();
+       } else if (!strcmp(res->what, "nbcore")) {
                set_fwd_lcores_number(res->value);
-       else if (!strcmp(res->what, "burst"))
+               fwd_config_setup();
+       } else if (!strcmp(res->what, "burst"))
                set_nb_pkt_per_burst(res->value);
        else if (!strcmp(res->what, "verbose"))
                set_verbose_level(res->value);
@@ -2726,6 +2741,74 @@ cmdline_parse_inst_t cmd_set_txsplit = {
        },
 };
 
+/* *** CONFIG TX QUEUE FLAGS *** */
+
+struct cmd_config_txqflags_result {
+       cmdline_fixed_string_t port;
+       cmdline_fixed_string_t config;
+       cmdline_fixed_string_t all;
+       cmdline_fixed_string_t what;
+       int32_t hexvalue;
+};
+
+static void cmd_config_txqflags_parsed(void *parsed_result,
+                               __attribute__((unused)) struct cmdline *cl,
+                               __attribute__((unused)) void *data)
+{
+       struct cmd_config_txqflags_result *res = parsed_result;
+
+       if (!all_ports_stopped()) {
+               printf("Please stop all ports first\n");
+               return;
+       }
+
+       if (strcmp(res->what, "txqflags")) {
+               printf("Unknown parameter\n");
+               return;
+       }
+
+       if (res->hexvalue >= 0) {
+               txq_flags = res->hexvalue;
+       } else {
+               printf("txqflags must be >= 0\n");
+               return;
+       }
+
+       init_port_config();
+
+       cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
+}
+
+cmdline_parse_token_string_t cmd_config_txqflags_port =
+       TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, port,
+                                "port");
+cmdline_parse_token_string_t cmd_config_txqflags_config =
+       TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, config,
+                                "config");
+cmdline_parse_token_string_t cmd_config_txqflags_all =
+       TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, all,
+                                "all");
+cmdline_parse_token_string_t cmd_config_txqflags_what =
+       TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, what,
+                                "txqflags");
+cmdline_parse_token_num_t cmd_config_txqflags_value =
+       TOKEN_NUM_INITIALIZER(struct cmd_config_txqflags_result,
+                               hexvalue, INT32);
+
+cmdline_parse_inst_t cmd_config_txqflags = {
+       .f = cmd_config_txqflags_parsed,
+       .data = NULL,
+       .help_str = "port config all txqflags value",
+       .tokens = {
+               (void *)&cmd_config_txqflags_port,
+               (void *)&cmd_config_txqflags_config,
+               (void *)&cmd_config_txqflags_all,
+               (void *)&cmd_config_txqflags_what,
+               (void *)&cmd_config_txqflags_value,
+               NULL,
+       },
+};
+
 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
 struct cmd_rx_vlan_filter_all_result {
        cmdline_fixed_string_t rx_vlan;
@@ -5341,7 +5424,7 @@ static void cmd_showcfg_parsed(void *parsed_result,
        else if (!strcmp(res->what, "cores"))
                fwd_lcores_config_display();
        else if (!strcmp(res->what, "fwd"))
-               fwd_config_display();
+               pkt_fwd_config_display(&cur_fwd_config);
        else if (!strcmp(res->what, "txpkts"))
                show_tx_pkt_segments();
 }
@@ -6683,14 +6766,12 @@ cmd_tunnel_filter_parsed(void *parsed_result,
 
        if (res->ip_value.family == AF_INET) {
                tunnel_filter_conf.ip_addr.ipv4_addr =
-                       rte_be_to_cpu_32(res->ip_value.addr.ipv4.s_addr);
+                       res->ip_value.addr.ipv4.s_addr;
                tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
        } else {
-               int i;
-               for (i = 0; i < 4; i++) {
-                       tunnel_filter_conf.ip_addr.ipv6_addr[i] =
-                       rte_be_to_cpu_32(res->ip_value.addr.ipv6.s6_addr32[i]);
-               }
+               memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
+                       &(res->ip_value.addr.ipv6),
+                       sizeof(struct in6_addr));
                tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
        }
 
@@ -7198,8 +7279,6 @@ static void cmd_dump_parsed(void *parsed_result,
                rte_dump_physmem_layout(stdout);
        else if (!strcmp(res->dump, "dump_memzone"))
                rte_memzone_dump(stdout);
-       else if (!strcmp(res->dump, "dump_log_history"))
-               rte_log_dump_history(stdout);
        else if (!strcmp(res->dump, "dump_struct_sizes"))
                dump_struct_sizes();
        else if (!strcmp(res->dump, "dump_ring"))
@@ -7214,7 +7293,6 @@ cmdline_parse_token_string_t cmd_dump_dump =
        TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
                "dump_physmem#"
                "dump_memzone#"
-               "dump_log_history#"
                "dump_struct_sizes#"
                "dump_ring#"
                "dump_mempool#"
@@ -9651,7 +9729,7 @@ cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
        TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
        inset_field,
-       "ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
+       "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
        "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
        "ipv6-hop-limits#udp-src-port#udp-dst-port#"
        "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
@@ -9666,7 +9744,7 @@ cmdline_parse_inst_t cmd_set_fdir_input_set = {
        .help_str = "set_fdir_input_set <port_id> "
        "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
        "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
-       "ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
+       "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
        "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
        "ipv6-hop-limits|udp-src-port|udp-dst-port|"
        "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
@@ -10485,6 +10563,7 @@ cmdline_parse_ctx_t main_ctx[] = {
        (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
        (cmdline_parse_inst_t *)&cmd_config_rss,
        (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
+       (cmdline_parse_inst_t *)&cmd_config_txqflags,
        (cmdline_parse_inst_t *)&cmd_config_rss_reta,
        (cmdline_parse_inst_t *)&cmd_showport_reta,
        (cmdline_parse_inst_t *)&cmd_config_burst,