app/testpmd: new command to get extended statistics
[dpdk.git] / app / test-pmd / cmdline.c
index 345be11..225f669 100644 (file)
@@ -183,14 +183,14 @@ static void cmd_help_long_parsed(void *parsed_result,
                        "Display:\n"
                        "--------\n\n"
 
-                       "show port (info|stats|fdir|stat_qmap) (port_id|all)\n"
+                       "show port (info|stats|xstats|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 port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
                        "    Clear information for port_id, or all.\n\n"
 
                        "show config (rxtx|cores|fwd)\n"
@@ -527,7 +527,8 @@ static void cmd_help_long_parsed(void *parsed_result,
                        "port close (port_id|all)\n"
                        "    Close all ports or port_id.\n\n"
 
-                       "port config (port_id|all) speed (10|100|1000|10000|auto)"
+                       "port config (port_id|all)"
+                       " speed (10|100|1000|10000|40000|auto)"
                        " duplex (half|full|auto)\n"
                        "    Set speed and duplex for all ports or port_id\n\n"
 
@@ -565,6 +566,10 @@ static void cmd_help_long_parsed(void *parsed_result,
                        " tx rs bit threshold.\n\n"
                        "port config mtu X value\n"
                        "    Set the MTU of port X to a given value\n\n"
+
+                       "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
+                       "    Start/stop a rx/tx queue of port X. Only take effect"
+                       " when port X is started\n"
                );
        }
 
@@ -801,7 +806,9 @@ cmd_config_speed_all_parsed(void *parsed_result,
        else if (!strcmp(res->value1, "1000"))
                link_speed = ETH_LINK_SPEED_1000;
        else if (!strcmp(res->value1, "10000"))
-               link_speed = ETH_LINK_SPEED_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 {
@@ -839,7 +846,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#auto");
+                                               "10#100#1000#10000#40000#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 =
@@ -849,7 +856,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|auto duplex "
+       .help_str = "port config all speed 10|100|1000|10000|40000|auto duplex "
                                                        "half|full|auto",
        .tokens = {
                (void *)&cmd_config_speed_all_port,
@@ -901,6 +908,8 @@ cmd_config_speed_specific_parsed(void *parsed_result,
                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 {
@@ -939,7 +948,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#auto");
+                                               "10#100#1000#10000#40000#auto");
 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
        TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
                                                                "duplex");
@@ -950,7 +959,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|auto duplex "
+       .help_str = "port config X speed 10|100|1000|10000|40000|auto duplex "
                                                        "half|full|auto",
        .tokens = {
                (void *)&cmd_config_speed_specific_port,
@@ -1425,6 +1434,96 @@ cmdline_parse_inst_t cmd_config_rss_hash_key = {
        },
 };
 
+/* *** configure port rxq/txq start/stop *** */
+struct cmd_config_rxtx_queue {
+       cmdline_fixed_string_t port;
+       uint8_t portid;
+       cmdline_fixed_string_t rxtxq;
+       uint16_t qid;
+       cmdline_fixed_string_t opname;
+};
+
+static void
+cmd_config_rxtx_queue_parsed(void *parsed_result,
+                       __attribute__((unused)) struct cmdline *cl,
+                       __attribute__((unused)) void *data)
+{
+       struct cmd_config_rxtx_queue *res = parsed_result;
+       uint8_t isrx;
+       uint8_t isstart;
+
+       if (test_done == 0) {
+               printf("Please stop forwarding first\n");
+               return;
+       }
+
+       if (port_id_is_invalid(res->portid))
+               return;
+
+       if (port_is_started(res->portid) != 1) {
+               printf("Please start port %u first\n", res->portid);
+               return;
+       }
+
+       if (!strcmp(res->rxtxq, "rxq"))
+               isrx = 1;
+       else if (!strcmp(res->rxtxq, "txq"))
+               isrx = 0;
+       else {
+               printf("Unknown parameter\n");
+               return;
+       }
+
+       if (isrx && rx_queue_id_is_invalid(res->qid))
+               return;
+       else if (!isrx && tx_queue_id_is_invalid(res->qid))
+               return;
+
+       if (!strcmp(res->opname, "start"))
+               isstart = 1;
+       else if (!strcmp(res->opname, "stop"))
+               isstart = 0;
+       else {
+               printf("Unknown parameter\n");
+               return;
+       }
+
+       if (isstart && isrx)
+               rte_eth_dev_rx_queue_start(res->portid, res->qid);
+       else if (!isstart && isrx)
+               rte_eth_dev_rx_queue_stop(res->portid, res->qid);
+       else if (isstart && !isrx)
+               rte_eth_dev_tx_queue_start(res->portid, res->qid);
+       else
+               rte_eth_dev_tx_queue_stop(res->portid, res->qid);
+}
+
+cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
+       TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
+cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
+       TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT8);
+cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
+       TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
+cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
+       TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
+cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
+       TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
+                                               "start#stop");
+
+cmdline_parse_inst_t cmd_config_rxtx_queue = {
+       .f = cmd_config_rxtx_queue_parsed,
+       .data = NULL,
+       .help_str = "port X rxq|txq ID start|stop",
+       .tokens = {
+               (void *)&cmd_config_speed_all_port,
+               (void *)&cmd_config_rxtx_queue_portid,
+               (void *)&cmd_config_rxtx_queue_rxtxq,
+               (void *)&cmd_config_rxtx_queue_qid,
+               (void *)&cmd_config_rxtx_queue_opname,
+               NULL,
+       },
+};
+
 /* *** Configure RSS RETA *** */
 struct cmd_config_rss_reta {
        cmdline_fixed_string_t port;
@@ -5015,12 +5114,18 @@ static void cmd_showportall_parsed(void *parsed_result,
                if (!strcmp(res->what, "stats"))
                        for (i = 0; i < nb_ports; i++)
                                nic_stats_clear(i);
+               else if (!strcmp(res->what, "xstats"))
+                       for (i = 0; i < nb_ports; i++)
+                               nic_xstats_clear(i);
        } else if (!strcmp(res->what, "info"))
                for (i = 0; i < nb_ports; i++)
                        port_infos_display(i);
        else if (!strcmp(res->what, "stats"))
                for (i = 0; i < nb_ports; i++)
                        nic_stats_display(i);
+       else if (!strcmp(res->what, "xstats"))
+               for (i = 0; i < nb_ports; i++)
+                       nic_xstats_display(i);
        else if (!strcmp(res->what, "fdir"))
                for (i = 0; i < nb_ports; i++)
                        fdir_get_infos(i);
@@ -5036,13 +5141,13 @@ cmdline_parse_token_string_t cmd_showportall_port =
        TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
 cmdline_parse_token_string_t cmd_showportall_what =
        TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
-                                "info#stats#fdir#stat_qmap");
+                                "info#stats#xstats#fdir#stat_qmap");
 cmdline_parse_token_string_t cmd_showportall_all =
        TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
 cmdline_parse_inst_t cmd_showportall = {
        .f = cmd_showportall_parsed,
        .data = NULL,
-       .help_str = "show|clear port info|stats|fdir|stat_qmap all",
+       .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap all",
        .tokens = {
                (void *)&cmd_showportall_show,
                (void *)&cmd_showportall_port,
@@ -5068,10 +5173,14 @@ static void cmd_showport_parsed(void *parsed_result,
        if (!strcmp(res->show, "clear")) {
                if (!strcmp(res->what, "stats"))
                        nic_stats_clear(res->portnum);
+               else if (!strcmp(res->what, "xstats"))
+                       nic_xstats_clear(res->portnum);
        } else if (!strcmp(res->what, "info"))
                port_infos_display(res->portnum);
        else if (!strcmp(res->what, "stats"))
                nic_stats_display(res->portnum);
+       else if (!strcmp(res->what, "xstats"))
+               nic_xstats_display(res->portnum);
        else if (!strcmp(res->what, "fdir"))
                 fdir_get_infos(res->portnum);
        else if (!strcmp(res->what, "stat_qmap"))
@@ -5085,14 +5194,14 @@ cmdline_parse_token_string_t cmd_showport_port =
        TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
 cmdline_parse_token_string_t cmd_showport_what =
        TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
-                                "info#stats#fdir#stat_qmap");
+                                "info#stats#xstats#fdir#stat_qmap");
 cmdline_parse_token_num_t cmd_showport_portnum =
        TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, INT32);
 
 cmdline_parse_inst_t cmd_showport = {
        .f = cmd_showport_parsed,
        .data = NULL,
-       .help_str = "show|clear port info|stats|fdir|stat_qmap X (X = port number)",
+       .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap X (X = port number)",
        .tokens = {
                (void *)&cmd_showport_show,
                (void *)&cmd_showport_port,
@@ -6376,8 +6485,6 @@ dump_struct_sizes(void)
 {
 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
        DUMP_SIZE(struct rte_mbuf);
-       DUMP_SIZE(struct rte_pktmbuf);
-       DUMP_SIZE(struct rte_ctrlmbuf);
        DUMP_SIZE(struct rte_mempool);
        DUMP_SIZE(struct rte_ring);
 #undef DUMP_SIZE
@@ -7393,6 +7500,7 @@ cmdline_parse_ctx_t main_ctx[] = {
        (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
        (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_rss_reta,
        (cmdline_parse_inst_t *)&cmd_showport_reta,
        (cmdline_parse_inst_t *)&cmd_config_burst,