From bc20240622bd7e88c4c8879c8e41ce8aca695433 Mon Sep 17 00:00:00 2001 From: David Marchand Date: Wed, 30 Apr 2014 15:30:02 +0200 Subject: [PATCH] app/testpmd: add --disable-link-check option When starting/stopping ports, a link status check on all available ports is done. This can be annoying when cables are not plugged at the time. Default behavior is untouched. Signed-off-by: David Marchand Acked-by: Thomas Monjalon --- app/test-pmd/cmdline.c | 41 +++++++++++++++++++++++++++++++++++++++ app/test-pmd/parameters.c | 5 +++++ app/test-pmd/testpmd.c | 9 +++++++-- app/test-pmd/testpmd.h | 1 + 4 files changed, 54 insertions(+), 2 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index c6a417a3f1..5f39281114 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -2328,6 +2328,46 @@ cmdline_parse_inst_t cmd_set_flush_rx = { }, }; +/* *** ENABLE/DISABLE LINK STATUS CHECK *** */ +struct cmd_set_link_check { + cmdline_fixed_string_t set; + cmdline_fixed_string_t link_check; + cmdline_fixed_string_t mode; +}; + +static void +cmd_set_link_check_parsed(void *parsed_result, + __attribute__((unused)) struct cmdline *cl, + __attribute__((unused)) void *data) +{ + struct cmd_set_link_check *res = parsed_result; + no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1); +} + +cmdline_parse_token_string_t cmd_setlinkcheck_set = + TOKEN_STRING_INITIALIZER(struct cmd_set_link_check, + set, "set"); +cmdline_parse_token_string_t cmd_setlinkcheck_link_check = + TOKEN_STRING_INITIALIZER(struct cmd_set_link_check, + link_check, "link_check"); +cmdline_parse_token_string_t cmd_setlinkcheck_mode = + TOKEN_STRING_INITIALIZER(struct cmd_set_link_check, + mode, "on#off"); + + +cmdline_parse_inst_t cmd_set_link_check = { + .f = cmd_set_link_check_parsed, + .help_str = "set link_check on|off: enable/disable link status check " + "when starting/stopping a port", + .data = NULL, + .tokens = { + (void *)&cmd_setlinkcheck_set, + (void *)&cmd_setlinkcheck_link_check, + (void *)&cmd_setlinkcheck_mode, + NULL, + }, +}; + #ifdef RTE_NIC_BYPASS /* *** SET NIC BYPASS MODE *** */ struct cmd_set_bypass_mode_result { @@ -5136,6 +5176,7 @@ cmdline_parse_ctx_t main_ctx[] = { (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one, (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all, (cmdline_parse_inst_t *)&cmd_set_flush_rx, + (cmdline_parse_inst_t *)&cmd_set_link_check, #ifdef RTE_NIC_BYPASS (cmdline_parse_inst_t *)&cmd_set_bypass_mode, (cmdline_parse_inst_t *)&cmd_set_bypass_event, diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c index d37e1b035f..7a60048617 100644 --- a/app/test-pmd/parameters.c +++ b/app/test-pmd/parameters.c @@ -197,6 +197,8 @@ usage(char* progname) printf(" --no-flush-rx: Don't flush RX streams before forwarding." " Used mainly with PCAP drivers.\n"); printf(" --txpkts=X[,Y]*: set TX segment sizes.\n"); + printf(" --disable-link-check: disable check on link status when " + "starting/stopping ports.\n"); } #ifdef RTE_LIBRTE_CMDLINE @@ -587,6 +589,7 @@ launch_args_parse(int argc, char** argv) { "rx-queue-stats-mapping", 1, 0, 0 }, { "no-flush-rx", 0, 0, 0 }, { "txpkts", 1, 0, 0 }, + { "disable-link-check", 0, 0, 0 }, { 0, 0, 0, 0 }, }; @@ -1044,6 +1047,8 @@ launch_args_parse(int argc, char** argv) } if (!strcmp(lgopts[opt_idx].name, "no-flush-rx")) no_flush_rx = 1; + if (!strcmp(lgopts[opt_idx].name, "disable-link-check")) + no_link_check = 1; break; case 'h': diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index a4a803223b..ded8cd336a 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -262,6 +262,11 @@ uint16_t port_topology = PORT_TOPOLOGY_PAIRED; /* Ports are paired by default */ */ uint8_t no_flush_rx = 0; /* flush by default */ +/* + * Avoids to check link status when starting/stopping a port. + */ +uint8_t no_link_check = 0; /* check by default */ + /* * NIC bypass mode configuration options. */ @@ -1364,7 +1369,7 @@ start_port(portid_t pid) need_check_link_status = 1; } - if (need_check_link_status) + if (need_check_link_status && !no_link_check) check_all_ports_link_status(nb_ports, RTE_PORT_ALL); else printf("Please stop the ports first\n"); @@ -1406,7 +1411,7 @@ stop_port(portid_t pid) printf("Port %d can not be set into stopped\n", pi); need_check_link_status = 1; } - if (need_check_link_status) + if (need_check_link_status && !no_link_check) check_all_ports_link_status(nb_ports, RTE_PORT_ALL); printf("Done\n"); diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index 83193ef1e4..2bdb1a206b 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -278,6 +278,7 @@ extern uint8_t numa_support; /**< set by "--numa" parameter */ extern uint16_t port_topology; /**< set by "--port-topology" parameter */ extern uint8_t no_flush_rx; /**