app/testpmd: add device related commands
[dpdk.git] / app / test-pmd / cmdline.c
index d1e0d44..a28362d 100644 (file)
@@ -101,6 +101,7 @@ static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
                "    help registers                  : Reading and setting port registers.\n"
                "    help filters                    : Filters configuration help.\n"
                "    help traffic_management         : Traffic Management commmands.\n"
+               "    help devices                    : Device related cmds.\n"
                "    help all                        : All of the above sections.\n\n"
        );
 
@@ -236,6 +237,9 @@ static void cmd_help_long_parsed(void *parsed_result,
                        "show port (port_id) tx_metadata\n"
                        "    Show Tx metadata value set"
                        " for a specific port\n\n"
+
+                       "show device info (<identifier>|all)"
+                       "       Show general information about devices probed.\n\n"
                );
        }
 
@@ -733,33 +737,6 @@ static void cmd_help_long_parsed(void *parsed_result,
                        "show port (port_id) queue-region\n"
                        "    show all queue region related configuration info\n\n"
 
-                       "vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
-                       " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
-                       " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
-                       "       Configure the VXLAN encapsulation for flows.\n\n"
-
-                       "vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
-                       " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
-                       " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
-                       " eth-dst (eth-dst)\n"
-                       "       Configure the VXLAN encapsulation for flows.\n\n"
-
-                       "vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
-                       " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
-                       " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
-                       " eth-dst (eth-dst)\n"
-                       "       Configure the VXLAN encapsulation for flows.\n\n"
-
-                       "nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
-                       " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
-                       " (eth-dst)\n"
-                       "       Configure the NVGRE encapsulation for flows.\n\n"
-
-                       "nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
-                       " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
-                       " eth-src (eth-src) eth-dst (eth-dst)\n"
-                       "       Configure the NVGRE encapsulation for flows.\n\n"
-
                        , list_pkt_forwarding_modes()
                );
        }
@@ -1137,6 +1114,40 @@ static void cmd_help_long_parsed(void *parsed_result,
                        "flow isolate {port_id} {boolean}\n"
                        "    Restrict ingress traffic to the defined"
                        " flow rules\n\n"
+
+                       "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
+                       " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
+                       " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
+                       "       Configure the VXLAN encapsulation for flows.\n\n"
+
+                       "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
+                       " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
+                       " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
+                       " eth-dst (eth-dst)\n"
+                       "       Configure the VXLAN encapsulation for flows.\n\n"
+
+                       "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
+                       " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
+                       " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
+                       " eth-dst (eth-dst)\n"
+                       "       Configure the VXLAN encapsulation for flows.\n\n"
+
+                       "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
+                       " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
+                       " (eth-dst)\n"
+                       "       Configure the NVGRE encapsulation for flows.\n\n"
+
+                       "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
+                       " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
+                       " eth-src (eth-src) eth-dst (eth-dst)\n"
+                       "       Configure the NVGRE encapsulation for flows.\n\n"
+
+                       "set raw_encap {flow items}\n"
+                       "       Configure the encapsulation with raw data.\n\n"
+
+                       "set raw_decap {flow items}\n"
+                       "       Configure the decapsulation with raw data.\n\n"
+
                );
        }
 
@@ -1240,6 +1251,17 @@ static void cmd_help_long_parsed(void *parsed_result,
                );
        }
 
+       if (show_all || !strcmp(res->section, "devices")) {
+               cmdline_printf(
+                       cl,
+                       "\n"
+                       "Device Operations:\n"
+                       "--------------\n"
+                       "device detach (identifier)\n"
+                       "       Detach device by identifier.\n\n"
+               );
+       }
+
 }
 
 cmdline_parse_token_string_t cmd_help_long_help =
@@ -1248,13 +1270,13 @@ cmdline_parse_token_string_t cmd_help_long_help =
 cmdline_parse_token_string_t cmd_help_long_section =
        TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
                        "all#control#display#config#"
-                       "ports#registers#filters#traffic_management");
+                       "ports#registers#filters#traffic_management#devices");
 
 cmdline_parse_inst_t cmd_help_long = {
        .f = cmd_help_long_parsed,
        .data = NULL,
        .help_str = "help all|control|display|config|ports|register|"
-               "filters|traffic_management: "
+               "filters|traffic_management|devices: "
                "Show help",
        .tokens = {
                (void *)&cmd_help_long_help,
@@ -1493,6 +1515,47 @@ cmdline_parse_inst_t cmd_operate_detach_port = {
        },
 };
 
+/* *** detach device by identifier *** */
+struct cmd_operate_detach_device_result {
+       cmdline_fixed_string_t device;
+       cmdline_fixed_string_t keyword;
+       cmdline_fixed_string_t identifier;
+};
+
+static void cmd_operate_detach_device_parsed(void *parsed_result,
+                               __attribute__((unused)) struct cmdline *cl,
+                               __attribute__((unused)) void *data)
+{
+       struct cmd_operate_detach_device_result *res = parsed_result;
+
+       if (!strcmp(res->keyword, "detach"))
+               detach_device(res->identifier);
+       else
+               printf("Unknown parameter\n");
+}
+
+cmdline_parse_token_string_t cmd_operate_detach_device_device =
+       TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
+                       device, "device");
+cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
+       TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
+                       keyword, "detach");
+cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
+       TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
+                       identifier, NULL);
+
+cmdline_parse_inst_t cmd_operate_detach_device = {
+       .f = cmd_operate_detach_device_parsed,
+       .data = NULL,
+       .help_str = "device detach <identifier>:"
+               "(identifier: pci address or virtual dev name)",
+       .tokens = {
+               (void *)&cmd_operate_detach_device_device,
+               (void *)&cmd_operate_detach_device_keyword,
+               (void *)&cmd_operate_detach_device_identifier,
+               NULL,
+       },
+};
 /* *** configure speed for all ports *** */
 struct cmd_config_speed_all {
        cmdline_fixed_string_t port;
@@ -2047,6 +2110,7 @@ cmd_config_rx_mode_flag_parsed(void *parsed_result,
 {
        struct cmd_config_rx_mode_flag *res = parsed_result;
        portid_t pid;
+       int k;
 
        if (!all_ports_stopped()) {
                printf("Please stop all ports first\n");
@@ -2147,6 +2211,10 @@ cmd_config_rx_mode_flag_parsed(void *parsed_result,
                        return;
                }
                port->dev_conf.rxmode.offloads = rx_offloads;
+               /* Apply Rx offloads configuration */
+               for (k = 0; k < port->dev_info.max_rx_queues; k++)
+                       port->rx_conf[k].offloads =
+                               port->dev_conf.rxmode.offloads;
        }
 
        init_port_config();
@@ -4359,6 +4427,17 @@ csum_show(int port_id)
        }
 }
 
+static void
+cmd_config_queue_tx_offloads(struct rte_port *port)
+{
+       int k;
+
+       /* Apply queue tx offloads configuration */
+       for (k = 0; k < port->dev_info.max_rx_queues; k++)
+               port->tx_conf[k].offloads =
+                       port->dev_conf.txmode.offloads;
+}
+
 static void
 cmd_csum_parsed(void *parsed_result,
                       __attribute__((unused)) struct cmdline *cl,
@@ -4443,6 +4522,7 @@ cmd_csum_parsed(void *parsed_result,
                        ports[res->port_id].dev_conf.txmode.offloads &=
                                                        (~csum_offloads);
                }
+               cmd_config_queue_tx_offloads(&ports[res->port_id]);
        }
        csum_show(res->port_id);
 
@@ -4594,6 +4674,7 @@ cmd_tso_set_parsed(void *parsed_result,
                printf("TSO segment size for non-tunneled packets is %d\n",
                        ports[res->port_id].tso_segsz);
        }
+       cmd_config_queue_tx_offloads(&ports[res->port_id]);
 
        /* display warnings if configuration is not supported by the NIC */
        rte_eth_dev_info_get(res->port_id, &dev_info);
@@ -4749,6 +4830,7 @@ cmd_tunnel_tso_set_parsed(void *parsed_result,
                                "if outer L3 is IPv4; not necessary for IPv6\n");
        }
 
+       cmd_config_queue_tx_offloads(&ports[res->port_id]);
        cmd_reconfig_device_queue(res->port_id, 1, 1);
 }
 
@@ -7437,6 +7519,51 @@ cmdline_parse_inst_t cmd_showport = {
        },
 };
 
+/* *** SHOW DEVICE INFO *** */
+struct cmd_showdevice_result {
+       cmdline_fixed_string_t show;
+       cmdline_fixed_string_t device;
+       cmdline_fixed_string_t what;
+       cmdline_fixed_string_t identifier;
+};
+
+static void cmd_showdevice_parsed(void *parsed_result,
+                               __attribute__((unused)) struct cmdline *cl,
+                               __attribute__((unused)) void *data)
+{
+       struct cmd_showdevice_result *res = parsed_result;
+       if (!strcmp(res->what, "info")) {
+               if (!strcmp(res->identifier, "all"))
+                       device_infos_display(NULL);
+               else
+                       device_infos_display(res->identifier);
+       }
+}
+
+cmdline_parse_token_string_t cmd_showdevice_show =
+       TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
+                                "show");
+cmdline_parse_token_string_t cmd_showdevice_device =
+       TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
+cmdline_parse_token_string_t cmd_showdevice_what =
+       TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
+                                "info");
+cmdline_parse_token_string_t cmd_showdevice_identifier =
+       TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
+                       identifier, NULL);
+
+cmdline_parse_inst_t cmd_showdevice = {
+       .f = cmd_showdevice_parsed,
+       .data = NULL,
+       .help_str = "show device info <identifier>|all",
+       .tokens = {
+               (void *)&cmd_showdevice_show,
+               (void *)&cmd_showdevice_device,
+               (void *)&cmd_showdevice_what,
+               (void *)&cmd_showdevice_identifier,
+               NULL,
+       },
+};
 /* *** SHOW QUEUE INFO *** */
 struct cmd_showqueue_result {
        cmdline_fixed_string_t show;
@@ -10080,7 +10207,7 @@ cmd_2tuple_filter_parsed(void *parsed_result,
                        " when protocol is TCP.\n");
                return;
        }
-       if (res->tcp_flags_value > TCP_FLAG_ALL) {
+       if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
                printf("invalid TCP flags.\n");
                return;
        }
@@ -10238,7 +10365,7 @@ cmd_5tuple_filter_parsed(void *parsed_result,
                        " when protocol is TCP.\n");
                return;
        }
-       if (res->tcp_flags_value > TCP_FLAG_ALL) {
+       if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
                printf("invalid TCP flags.\n");
                return;
        }
@@ -18704,6 +18831,7 @@ cmdline_parse_ctx_t main_ctx[] = {
        (cmdline_parse_inst_t *)&cmd_showport,
        (cmdline_parse_inst_t *)&cmd_showqueue,
        (cmdline_parse_inst_t *)&cmd_showportall,
+       (cmdline_parse_inst_t *)&cmd_showdevice,
        (cmdline_parse_inst_t *)&cmd_showcfg,
        (cmdline_parse_inst_t *)&cmd_showfwdall,
        (cmdline_parse_inst_t *)&cmd_start,
@@ -18792,6 +18920,7 @@ cmdline_parse_ctx_t main_ctx[] = {
        (cmdline_parse_inst_t *)&cmd_operate_specific_port,
        (cmdline_parse_inst_t *)&cmd_operate_attach_port,
        (cmdline_parse_inst_t *)&cmd_operate_detach_port,
+       (cmdline_parse_inst_t *)&cmd_operate_detach_device,
        (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
        (cmdline_parse_inst_t *)&cmd_config_speed_all,
        (cmdline_parse_inst_t *)&cmd_config_speed_specific,
@@ -18979,6 +19108,7 @@ cmdline_parse_ctx_t main_ctx[] = {
 #endif
        (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
        (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
+       (cmdline_parse_inst_t *)&cmd_set_raw,
        NULL,
 };