net/ice: clean input set macro definition
[dpdk.git] / app / test-pmd / cmdline.c
index 0d2d6aa..14110eb 100644 (file)
@@ -163,7 +163,7 @@ static void cmd_help_long_parsed(void *parsed_result,
                        "Display:\n"
                        "--------\n\n"
 
-                       "show port (info|stats|summary|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)\n"
+                       "show port (info|stats|summary|xstats|fdir|dcb_tc) (port_id|all)\n"
                        "    Display information for port_id, or all.\n\n"
 
                        "show port port_id (module_eeprom|eeprom)\n"
@@ -177,7 +177,7 @@ static void cmd_help_long_parsed(void *parsed_result,
                        "show port (port_id) rss-hash [key]\n"
                        "    Display the RSS hash functions and RSS hash key of port\n\n"
 
-                       "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
+                       "clear port (info|stats|xstats|fdir) (port_id|all)\n"
                        "    Clear information for port_id, or all.\n\n"
 
                        "show (rxq|txq) info (port_id) (queue_id)\n"
@@ -246,6 +246,10 @@ static void cmd_help_long_parsed(void *parsed_result,
                        "show port (port_id) rxq|txq (queue_id) desc (desc_id) status"
                        "       Show status of rx|tx descriptor.\n\n"
 
+                       "show port (port_id) rxq (queue_id) desc used count\n"
+                       "    Show current number of filled receive"
+                       " packet descriptors.\n\n"
+
                        "show port (port_id) macs|mcast_macs"
                        "       Display list of mac addresses added to port.\n\n"
 
@@ -788,7 +792,7 @@ static void cmd_help_long_parsed(void *parsed_result,
                        "receive buffers available.\n\n"
 
                        "port config all rss (all|default|ip|tcp|udp|sctp|"
-                       "ether|port|vxlan|geneve|nvgre|vxlan-gpe|ecpri|none|level-default|"
+                       "ether|port|vxlan|geneve|nvgre|vxlan-gpe|ecpri|mpls|none|level-default|"
                        "level-outer|level-inner|<flowtype_id>)\n"
                        "    Set the RSS mode.\n\n"
 
@@ -845,7 +849,7 @@ static void cmd_help_long_parsed(void *parsed_result,
                        "fdir_inset|fdir_flx_inset clear all"
                        "    Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
 
-                       "port config (port_id) udp_tunnel_port add|rm vxlan|geneve (udp_port)\n\n"
+                       "port config (port_id) udp_tunnel_port add|rm vxlan|geneve|ecpri (udp_port)\n\n"
                        "    Add/remove UDP tunnel port for tunneling offload\n\n"
 
                        "port config <port_id> rx_offload vlan_strip|"
@@ -1877,7 +1881,9 @@ cmd_config_max_pkt_len_parsed(void *parsed_result,
                                __rte_unused void *data)
 {
        struct cmd_config_max_pkt_len_result *res = parsed_result;
+       uint32_t max_rx_pkt_len_backup = 0;
        portid_t pid;
+       int ret;
 
        if (!all_ports_stopped()) {
                printf("Please stop all ports first\n");
@@ -1886,7 +1892,6 @@ cmd_config_max_pkt_len_parsed(void *parsed_result,
 
        RTE_ETH_FOREACH_DEV(pid) {
                struct rte_port *port = &ports[pid];
-               uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
 
                if (!strcmp(res->name, "max-pkt-len")) {
                        if (res->value < RTE_ETHER_MIN_LEN) {
@@ -1897,12 +1902,18 @@ cmd_config_max_pkt_len_parsed(void *parsed_result,
                        if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
                                return;
 
+                       ret = eth_dev_info_get_print_err(pid, &port->dev_info);
+                       if (ret != 0) {
+                               printf("rte_eth_dev_info_get() failed for port %u\n",
+                                       pid);
+                               return;
+                       }
+
+                       max_rx_pkt_len_backup = port->dev_conf.rxmode.max_rx_pkt_len;
+
                        port->dev_conf.rxmode.max_rx_pkt_len = res->value;
-                       if (res->value > RTE_ETHER_MAX_LEN)
-                               rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
-                       else
-                               rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
-                       port->dev_conf.rxmode.offloads = rx_offloads;
+                       if (update_jumbo_frame_offload(pid) != 0)
+                               port->dev_conf.rxmode.max_rx_pkt_len = max_rx_pkt_len_backup;
                } else {
                        printf("Unknown parameter\n");
                        return;
@@ -2226,6 +2237,8 @@ cmd_config_rss_parsed(void *parsed_result,
                rss_conf.rss_hf = ETH_RSS_GTPU;
        else if (!strcmp(res->value, "ecpri"))
                rss_conf.rss_hf = ETH_RSS_ECPRI;
+       else if (!strcmp(res->value, "mpls"))
+               rss_conf.rss_hf = ETH_RSS_MPLS;
        else if (!strcmp(res->value, "none"))
                rss_conf.rss_hf = 0;
        else if (!strcmp(res->value, "level-default")) {
@@ -2296,7 +2309,7 @@ cmdline_parse_inst_t cmd_config_rss = {
        .data = NULL,
        .help_str = "port config all rss "
                "all|default|eth|vlan|ip|tcp|udp|sctp|ether|port|vxlan|geneve|"
-               "nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|ecpri|none|level-default|"
+               "nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|ecpri|mpls|none|level-default|"
                "level-outer|level-inner|<flowtype_id>",
        .tokens = {
                (void *)&cmd_config_rss_port,
@@ -3782,6 +3795,7 @@ cmd_set_rxoffs_parsed(void *parsed_result,
                                  MAX_SEGS_BUFFER_SPLIT, seg_offsets, 0);
        if (nb_segs > 0)
                set_rx_pkt_offsets(seg_offsets, nb_segs);
+       cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
 }
 
 cmdline_parse_token_string_t cmd_set_rxoffs_keyword =
@@ -3828,6 +3842,7 @@ cmd_set_rxpkts_parsed(void *parsed_result,
                                  MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0);
        if (nb_segs > 0)
                set_rx_pkt_segments(seg_lengths, nb_segs);
+       cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
 }
 
 cmdline_parse_token_string_t cmd_set_rxpkts_keyword =
@@ -7555,15 +7570,9 @@ static void cmd_showportall_parsed(void *parsed_result,
                RTE_ETH_FOREACH_DEV(i)
                        fdir_get_infos(i);
 #endif
-       else if (!strcmp(res->what, "stat_qmap"))
-               RTE_ETH_FOREACH_DEV(i)
-                       nic_stats_mapping_display(i);
        else if (!strcmp(res->what, "dcb_tc"))
                RTE_ETH_FOREACH_DEV(i)
                        port_dcb_info_display(i);
-       else if (!strcmp(res->what, "cap"))
-               RTE_ETH_FOREACH_DEV(i)
-                       port_offload_cap_display(i);
 }
 
 cmdline_parse_token_string_t cmd_showportall_show =
@@ -7573,14 +7582,14 @@ 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#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
+                                "info#summary#stats#xstats#fdir#dcb_tc");
 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|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
+               "info|summary|stats|xstats|fdir|dcb_tc all",
        .tokens = {
                (void *)&cmd_showportall_show,
                (void *)&cmd_showportall_port,
@@ -7622,12 +7631,8 @@ static void cmd_showport_parsed(void *parsed_result,
        else if (!strcmp(res->what, "fdir"))
                 fdir_get_infos(res->portnum);
 #endif
-       else if (!strcmp(res->what, "stat_qmap"))
-               nic_stats_mapping_display(res->portnum);
        else if (!strcmp(res->what, "dcb_tc"))
                port_dcb_info_display(res->portnum);
-       else if (!strcmp(res->what, "cap"))
-               port_offload_cap_display(res->portnum);
 }
 
 cmdline_parse_token_string_t cmd_showport_show =
@@ -7637,7 +7642,7 @@ 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#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
+                                "info#summary#stats#xstats#fdir#dcb_tc");
 cmdline_parse_token_num_t cmd_showport_portnum =
        TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, RTE_UINT16);
 
@@ -7645,7 +7650,7 @@ cmdline_parse_inst_t cmd_showport = {
        .f = cmd_showport_parsed,
        .data = NULL,
        .help_str = "show|clear port "
-               "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
+               "info|summary|stats|xstats|fdir|dcb_tc "
                "<port_id>",
        .tokens = {
                (void *)&cmd_showport_show,
@@ -9092,7 +9097,7 @@ cmdline_parse_inst_t cmd_vf_rate_limit = {
 
 /* *** CONFIGURE TUNNEL UDP PORT *** */
 struct cmd_tunnel_udp_config {
-       cmdline_fixed_string_t cmd;
+       cmdline_fixed_string_t rx_vxlan_port;
        cmdline_fixed_string_t what;
        uint16_t udp_port;
        portid_t port_id;
@@ -9108,9 +9113,7 @@ cmd_tunnel_udp_config_parsed(void *parsed_result,
        int ret;
 
        tunnel_udp.udp_port = res->udp_port;
-
-       if (!strcmp(res->cmd, "rx_vxlan_port"))
-               tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
+       tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
 
        if (!strcmp(res->what, "add"))
                ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
@@ -9123,9 +9126,9 @@ cmd_tunnel_udp_config_parsed(void *parsed_result,
                printf("udp tunneling add error: (%s)\n", strerror(-ret));
 }
 
-cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
+cmdline_parse_token_string_t cmd_tunnel_udp_config_rx_vxlan_port =
        TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
-                               cmd, "rx_vxlan_port");
+                               rx_vxlan_port, "rx_vxlan_port");
 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
        TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
                                what, "add#rm");
@@ -9142,7 +9145,7 @@ cmdline_parse_inst_t cmd_tunnel_udp_config = {
        .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
                "Add/Remove a tunneling UDP port filter",
        .tokens = {
-               (void *)&cmd_tunnel_udp_config_cmd,
+               (void *)&cmd_tunnel_udp_config_rx_vxlan_port,
                (void *)&cmd_tunnel_udp_config_what,
                (void *)&cmd_tunnel_udp_config_udp_port,
                (void *)&cmd_tunnel_udp_config_port_id,
@@ -9180,6 +9183,8 @@ cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
                tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
        } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
                tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
+       } else if (!strcmp(res->tunnel_type, "ecpri")) {
+               tunnel_udp.prot_type = RTE_TUNNEL_TYPE_ECPRI;
        } else {
                printf("Invalid tunnel type\n");
                return;
@@ -9214,7 +9219,7 @@ cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
                                 "add#rm");
 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
        TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
-                                "vxlan#geneve#vxlan-gpe");
+                                "vxlan#geneve#vxlan-gpe#ecpri");
 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
        TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
                              RTE_UINT16);
@@ -9222,7 +9227,8 @@ cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
        .f = cmd_cfg_tunnel_udp_port_parsed,
        .data = NULL,
-       .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve|vxlan-gpe <udp_port>",
+       .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|"
+               "geneve|vxlan-gpe|ecpri <udp_port>",
        .tokens = {
                (void *)&cmd_config_tunnel_udp_port_port,
                (void *)&cmd_config_tunnel_udp_port_config,
@@ -16268,11 +16274,9 @@ cmd_show_fec_capability_parsed(void *parsed_result,
                __rte_unused struct cmdline *cl,
                __rte_unused void *data)
 {
-#define FEC_CAP_NUM 2
        struct cmd_show_fec_capability_result *res = parsed_result;
-       struct rte_eth_fec_capa speed_fec_capa[FEC_CAP_NUM];
-       unsigned int num = FEC_CAP_NUM;
-       unsigned int ret_num;
+       struct rte_eth_fec_capa *speed_fec_capa;
+       unsigned int num;
        int ret;
 
        if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
@@ -16280,17 +16284,31 @@ cmd_show_fec_capability_parsed(void *parsed_result,
                return;
        }
 
-       ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num);
+       ret = rte_eth_fec_get_capability(res->cmd_pid, NULL, 0);
        if (ret == -ENOTSUP) {
                printf("Function not implemented\n");
                return;
        } else if (ret < 0) {
-               printf("Get FEC capability failed\n");
+               printf("Get FEC capability failed: %d\n", ret);
                return;
        }
 
-       ret_num = (unsigned int)ret;
-       show_fec_capability(ret_num, speed_fec_capa);
+       num = (unsigned int)ret;
+       speed_fec_capa = calloc(num, sizeof(*speed_fec_capa));
+       if (speed_fec_capa == NULL) {
+               printf("Failed to alloc FEC capability buffer\n");
+               return;
+       }
+
+       ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num);
+       if (ret < 0) {
+               printf("Error getting FEC capability: %d\n", ret);
+               goto out;
+       }
+
+       show_fec_capability(num, speed_fec_capa);
+out:
+       free(speed_fec_capa);
 }
 
 cmdline_parse_token_string_t cmd_show_fec_capability_show =
@@ -16678,6 +16696,88 @@ cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
        },
 };
 
+/* *** display rx queue desc used count *** */
+struct cmd_show_rx_queue_desc_used_count_result {
+       cmdline_fixed_string_t cmd_show;
+       cmdline_fixed_string_t cmd_port;
+       cmdline_fixed_string_t cmd_rxq;
+       cmdline_fixed_string_t cmd_desc;
+       cmdline_fixed_string_t cmd_used;
+       cmdline_fixed_string_t cmd_count;
+       portid_t cmd_pid;
+       portid_t cmd_qid;
+};
+
+static void
+cmd_show_rx_queue_desc_used_count_parsed(void *parsed_result,
+               __rte_unused struct cmdline *cl,
+               __rte_unused void *data)
+{
+       struct cmd_show_rx_queue_desc_used_count_result *res = parsed_result;
+       int rc;
+
+       if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
+               printf("invalid port id %u\n", res->cmd_pid);
+               return;
+       }
+
+       rc = rte_eth_rx_queue_count(res->cmd_pid, res->cmd_qid);
+       if (rc < 0) {
+               printf("Invalid queueid = %d\n", res->cmd_qid);
+               return;
+       }
+       printf("Used desc count = %d\n", rc);
+}
+
+cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_show =
+       TOKEN_STRING_INITIALIZER
+               (struct cmd_show_rx_queue_desc_used_count_result,
+                cmd_show, "show");
+cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_port =
+       TOKEN_STRING_INITIALIZER
+               (struct cmd_show_rx_queue_desc_used_count_result,
+                cmd_port, "port");
+cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_pid =
+       TOKEN_NUM_INITIALIZER
+               (struct cmd_show_rx_queue_desc_used_count_result,
+                cmd_pid, RTE_UINT16);
+cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_rxq =
+       TOKEN_STRING_INITIALIZER
+               (struct cmd_show_rx_queue_desc_used_count_result,
+                cmd_rxq, "rxq");
+cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_qid =
+       TOKEN_NUM_INITIALIZER
+               (struct cmd_show_rx_queue_desc_used_count_result,
+                cmd_qid, RTE_UINT16);
+cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_desc =
+       TOKEN_STRING_INITIALIZER
+               (struct cmd_show_rx_queue_desc_used_count_result,
+                cmd_count, "desc");
+cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_used =
+       TOKEN_STRING_INITIALIZER
+               (struct cmd_show_rx_queue_desc_used_count_result,
+                cmd_count, "used");
+cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_count =
+       TOKEN_STRING_INITIALIZER
+               (struct cmd_show_rx_queue_desc_used_count_result,
+                cmd_count, "count");
+cmdline_parse_inst_t cmd_show_rx_queue_desc_used_count = {
+       .f = cmd_show_rx_queue_desc_used_count_parsed,
+       .data = NULL,
+       .help_str = "show port <port_id> rxq <queue_id> desc used count",
+       .tokens = {
+               (void *)&cmd_show_rx_queue_desc_used_count_show,
+               (void *)&cmd_show_rx_queue_desc_used_count_port,
+               (void *)&cmd_show_rx_queue_desc_used_count_pid,
+               (void *)&cmd_show_rx_queue_desc_used_count_rxq,
+               (void *)&cmd_show_rx_queue_desc_used_count_qid,
+               (void *)&cmd_show_rx_queue_desc_used_count_desc,
+               (void *)&cmd_show_rx_queue_desc_used_count_used,
+               (void *)&cmd_show_rx_queue_desc_used_count_count,
+               NULL,
+       },
+};
+
 /* Common result structure for set port ptypes */
 struct cmd_set_port_ptypes_result {
        cmdline_fixed_string_t set;
@@ -17077,6 +17177,7 @@ cmdline_parse_ctx_t main_ctx[] = {
        (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
        (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
        (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
+       (cmdline_parse_inst_t *)&cmd_show_rx_queue_desc_used_count,
        (cmdline_parse_inst_t *)&cmd_set_raw,
        (cmdline_parse_inst_t *)&cmd_show_set_raw,
        (cmdline_parse_inst_t *)&cmd_show_set_raw_all,
@@ -17112,6 +17213,7 @@ cmdline_read_from_file(const char *filename)
 void
 prompt(void)
 {
+       int ret;
        /* initialize non-constant commands */
        cmd_set_fwd_mode_init();
        cmd_set_fwd_retry_mode_init();
@@ -17119,15 +17221,23 @@ prompt(void)
        testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
        if (testpmd_cl == NULL)
                return;
+
+       ret = atexit(prompt_exit);
+       if (ret != 0)
+               printf("Cannot set exit function for cmdline\n");
+
        cmdline_interact(testpmd_cl);
-       cmdline_stdin_exit(testpmd_cl);
+       if (ret != 0)
+               cmdline_stdin_exit(testpmd_cl);
 }
 
 void
 prompt_exit(void)
 {
-       if (testpmd_cl != NULL)
+       if (testpmd_cl != NULL) {
                cmdline_quit(testpmd_cl);
+               cmdline_stdin_exit(testpmd_cl);
+       }
 }
 
 static void