X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=app%2Ftest-pmd%2Fcmdline.c;h=d4ff6089ad0143292e8fe81dc7e142abe81405bc;hb=b40f8d782ba18e97ca4270823320dfe3242d8684;hp=d66e9c81587d6ba6ea2d11de7ec78d0306a8346c;hpb=0d2cbe59b719a1f9d728d26622905e15ec6ff471;p=dpdk.git diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index d66e9c8158..d4ff6089ad 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -76,6 +76,7 @@ #include #include #include +#include #include #include @@ -423,6 +424,14 @@ static void cmd_help_long_parsed(void *parsed_result, "tso show (portid)" " Display the status of TCP Segmentation Offload.\n\n" + "gro (on|off) (port_id)" + " Enable or disable Generic Receive Offload in io" + " forward engine.\n\n" + + "gro set (max_flow_num) (max_item_num_per_flow) (port_id)\n" + " Set max flow number and max packet number per-flow" + " for GRO.\n\n" + "set fwd (%s)\n" " Set packet forwarding mode.\n\n" @@ -3838,6 +3847,120 @@ cmdline_parse_inst_t cmd_tunnel_tso_show = { }, }; +/* *** SET GRO FOR A PORT *** */ +struct cmd_gro_result { + cmdline_fixed_string_t cmd_keyword; + cmdline_fixed_string_t mode; + uint8_t port_id; +}; + +static void +cmd_enable_gro_parsed(void *parsed_result, + __attribute__((unused)) struct cmdline *cl, + __attribute__((unused)) void *data) +{ + struct cmd_gro_result *res; + + res = parsed_result; + setup_gro(res->mode, res->port_id); +} + +cmdline_parse_token_string_t cmd_gro_keyword = + TOKEN_STRING_INITIALIZER(struct cmd_gro_result, + cmd_keyword, "gro"); +cmdline_parse_token_string_t cmd_gro_mode = + TOKEN_STRING_INITIALIZER(struct cmd_gro_result, + mode, "on#off"); +cmdline_parse_token_num_t cmd_gro_pid = + TOKEN_NUM_INITIALIZER(struct cmd_gro_result, + port_id, UINT8); + +cmdline_parse_inst_t cmd_enable_gro = { + .f = cmd_enable_gro_parsed, + .data = NULL, + .help_str = "gro (on|off) (port_id)", + .tokens = { + (void *)&cmd_gro_keyword, + (void *)&cmd_gro_mode, + (void *)&cmd_gro_pid, + NULL, + }, +}; + +/* *** SET MAX FLOW NUMBER AND ITEM NUM PER FLOW FOR GRO *** */ +struct cmd_gro_set_result { + cmdline_fixed_string_t gro; + cmdline_fixed_string_t mode; + uint16_t flow_num; + uint16_t item_num_per_flow; + uint8_t port_id; +}; + +static void +cmd_gro_set_parsed(void *parsed_result, + __attribute__((unused)) struct cmdline *cl, + __attribute__((unused)) void *data) +{ + struct cmd_gro_set_result *res = parsed_result; + + if (port_id_is_invalid(res->port_id, ENABLED_WARN)) + return; + if (test_done == 0) { + printf("Before set GRO flow_num and item_num_per_flow," + " please stop forwarding first\n"); + return; + } + + if (!strcmp(res->mode, "set")) { + if (res->flow_num == 0) + printf("Invalid flow number. Revert to default value:" + " %u.\n", GRO_DEFAULT_FLOW_NUM); + else + gro_ports[res->port_id].param.max_flow_num = + res->flow_num; + + if (res->item_num_per_flow == 0) + printf("Invalid item number per-flow. Revert" + " to default value:%u.\n", + GRO_DEFAULT_ITEM_NUM_PER_FLOW); + else + gro_ports[res->port_id].param.max_item_per_flow = + res->item_num_per_flow; + } +} + +cmdline_parse_token_string_t cmd_gro_set_gro = + TOKEN_STRING_INITIALIZER(struct cmd_gro_set_result, + gro, "gro"); +cmdline_parse_token_string_t cmd_gro_set_mode = + TOKEN_STRING_INITIALIZER(struct cmd_gro_set_result, + mode, "set"); +cmdline_parse_token_num_t cmd_gro_set_flow_num = + TOKEN_NUM_INITIALIZER(struct cmd_gro_set_result, + flow_num, UINT16); +cmdline_parse_token_num_t cmd_gro_set_item_num_per_flow = + TOKEN_NUM_INITIALIZER(struct cmd_gro_set_result, + item_num_per_flow, UINT16); +cmdline_parse_token_num_t cmd_gro_set_portid = + TOKEN_NUM_INITIALIZER(struct cmd_gro_set_result, + port_id, UINT8); + +cmdline_parse_inst_t cmd_gro_set = { + .f = cmd_gro_set_parsed, + .data = NULL, + .help_str = "gro set " + ": set max flow number and max packet number per-flow " + "for GRO", + .tokens = { + (void *)&cmd_gro_set_gro, + (void *)&cmd_gro_set_mode, + (void *)&cmd_gro_set_flow_num, + (void *)&cmd_gro_set_item_num_per_flow, + (void *)&cmd_gro_set_portid, + NULL, + }, +}; + /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */ struct cmd_set_flush_rx { cmdline_fixed_string_t set; @@ -14035,6 +14158,8 @@ cmdline_parse_ctx_t main_ctx[] = { (cmdline_parse_inst_t *)&cmd_tso_show, (cmdline_parse_inst_t *)&cmd_tunnel_tso_set, (cmdline_parse_inst_t *)&cmd_tunnel_tso_show, + (cmdline_parse_inst_t *)&cmd_enable_gro, + (cmdline_parse_inst_t *)&cmd_gro_set, (cmdline_parse_inst_t *)&cmd_link_flow_control_set, (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx, (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,