app/testpmd: fix cmdline variable types
[dpdk.git] / app / test-pmd / cmdline.c
index f64f2df..3298360 100644 (file)
@@ -527,6 +527,8 @@ static void cmd_help_long_parsed(void *parsed_result,
                        "port config all (txfreet|txrst|rxfreet) (value)\n"
                        "    Set free threshold for rx/tx, or set"
                        " tx rs bit threshold.\n\n"
+                       "port config mtu X value\n"
+                       "    Set the MTU of port X to a given value\n\n"
                );
        }
 
@@ -1086,6 +1088,57 @@ cmdline_parse_inst_t cmd_config_max_pkt_len = {
        },
 };
 
+/* *** configure port MTU *** */
+struct cmd_config_mtu_result {
+       cmdline_fixed_string_t port;
+       cmdline_fixed_string_t keyword;
+       cmdline_fixed_string_t mtu;
+       uint8_t port_id;
+       uint16_t value;
+};
+
+static void
+cmd_config_mtu_parsed(void *parsed_result,
+                     __attribute__((unused)) struct cmdline *cl,
+                     __attribute__((unused)) void *data)
+{
+       struct cmd_config_mtu_result *res = parsed_result;
+
+       if (res->value < ETHER_MIN_LEN) {
+               printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
+               return;
+       }
+       port_mtu_set(res->port_id, res->value);
+}
+
+cmdline_parse_token_string_t cmd_config_mtu_port =
+       TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
+                                "port");
+cmdline_parse_token_string_t cmd_config_mtu_keyword =
+       TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
+                                "config");
+cmdline_parse_token_string_t cmd_config_mtu_mtu =
+       TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
+                                "mtu");
+cmdline_parse_token_num_t cmd_config_mtu_port_id =
+       TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
+cmdline_parse_token_num_t cmd_config_mtu_value =
+       TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
+
+cmdline_parse_inst_t cmd_config_mtu = {
+       .f = cmd_config_mtu_parsed,
+       .data = NULL,
+       .help_str = "port config mtu value",
+       .tokens = {
+               (void *)&cmd_config_mtu_port,
+               (void *)&cmd_config_mtu_keyword,
+               (void *)&cmd_config_mtu_mtu,
+               (void *)&cmd_config_mtu_port_id,
+               (void *)&cmd_config_mtu_value,
+               NULL,
+       },
+};
+
 /* *** configure rx mode *** */
 struct cmd_config_rx_mode_flag {
        cmdline_fixed_string_t port;
@@ -1314,7 +1367,7 @@ cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
        TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
                                 "config");
-cmdline_parse_token_string_t cmd_config_rss_hash_key_port_id =
+cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
        TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8);
 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
        TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
@@ -5314,7 +5367,7 @@ cmdline_parse_token_string_t cmd_mirror_mask_set =
 cmdline_parse_token_string_t cmd_mirror_mask_port =
        TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
                                port, "port");
-cmdline_parse_token_string_t cmd_mirror_mask_portid =
+cmdline_parse_token_num_t cmd_mirror_mask_portid =
        TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
                                port_id, UINT8);
 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
@@ -5424,7 +5477,7 @@ cmdline_parse_token_string_t cmd_mirror_link_set =
 cmdline_parse_token_string_t cmd_mirror_link_port =
        TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
                                port, "port");
-cmdline_parse_token_string_t cmd_mirror_link_portid =
+cmdline_parse_token_num_t cmd_mirror_link_portid =
        TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
                                port_id, UINT8);
 cmdline_parse_token_string_t cmd_mirror_link_mirror =
@@ -5510,7 +5563,7 @@ cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
        TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
                                port, "port");
-cmdline_parse_token_string_t cmd_rm_mirror_rule_portid =
+cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
        TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
                                port_id, UINT8);
 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
@@ -5819,7 +5872,7 @@ cmd_set_syn_filter_parsed(void *parsed_result,
                printf("syn filter setting error: (%s)\n", strerror(-ret));
 
 }
-cmdline_parse_token_string_t cmd_syn_filter_portid =
+cmdline_parse_token_num_t cmd_syn_filter_portid =
        TOKEN_NUM_INITIALIZER(struct cmd_set_syn_filter_result,
                                port_id, UINT8);
 cmdline_parse_token_string_t cmd_syn_filter_priority =
@@ -5937,7 +5990,7 @@ cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
        TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
                                 protocol, "protocol");
-cmdline_parse_token_string_t cmd_2tuple_filter_protocol_value =
+cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
        TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
                                 protocol_value, UINT8);
 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_mask =
@@ -5955,7 +6008,7 @@ cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_mask =
 cmdline_parse_token_string_t cmd_2tuple_filter_flags =
        TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
                                flags, "flags");
-cmdline_parse_token_string_t cmd_2tuple_filter_flags_value =
+cmdline_parse_token_num_t cmd_2tuple_filter_flags_value =
        TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
                                flags_value, UINT8);
 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
@@ -6149,7 +6202,7 @@ cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
        TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
                                protocol, "protocol");
-cmdline_parse_token_string_t cmd_5tuple_filter_protocol_value =
+cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
        TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
                                protocol_value, UINT8);
 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
@@ -6395,7 +6448,7 @@ cmdline_parse_token_num_t cmd_flex_filter_port_id =
 cmdline_parse_token_string_t cmd_flex_filter_len =
        TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
                                len, "len");
-cmdline_parse_token_string_t cmd_flex_filter_len_value =
+cmdline_parse_token_num_t cmd_flex_filter_len_value =
        TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
                                len_value, UINT8);
 cmdline_parse_token_string_t cmd_flex_filter_bytes =
@@ -6553,6 +6606,7 @@ cmdline_parse_ctx_t main_ctx[] = {
        (cmdline_parse_inst_t *)&cmd_config_speed_all,
        (cmdline_parse_inst_t *)&cmd_config_speed_specific,
        (cmdline_parse_inst_t *)&cmd_config_rx_tx,
+       (cmdline_parse_inst_t *)&cmd_config_mtu,
        (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,