From: Cyril Chemparathy Date: Thu, 3 Apr 2014 17:30:12 +0000 (-0700) Subject: app/testpmd: add auto-start option in interactive mode X-Git-Tag: spdx-start~10838 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=ca7feb2273665ac7544979461f83dbde3ed69c22;p=dpdk.git app/testpmd: add auto-start option in interactive mode This patch adds support for a command-line argument --auto-start (-a). When running in interactive mode, this allows us to start traffic without user intervention before dropping to the prompt. Signed-off-by: Cyril Chemparathy Acked-by: Thomas Monjalon --- diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c index d47d0202ad..18b52cc0d0 100644 --- a/app/test-pmd/parameters.c +++ b/app/test-pmd/parameters.c @@ -85,7 +85,7 @@ usage(char* progname) #ifdef RTE_LIBRTE_CMDLINE "[--interactive|-i] " #endif - "[--help|-h] | [" + "[--help|-h] | [--auto-start|-a] | [" "--coremask=COREMASK --portmask=PORTMASK --numa " "--mbuf-size= | --total-num-mbufs= | " "--nb-cores= | --nb-ports= | " @@ -102,6 +102,8 @@ usage(char* progname) #ifdef RTE_LIBRTE_CMDLINE printf(" --interactive: run in interactive mode.\n"); #endif + printf(" --auto-start: start forwarding on init " + "[always when non-interactive].\n"); printf(" --help: display this message and quit.\n"); printf(" --nb-cores=N: set the number of forwarding cores " "(1 <= N <= %d).\n", nb_lcores); @@ -485,6 +487,7 @@ launch_args_parse(int argc, char** argv) { "help", 0, 0, 0 }, #ifdef RTE_LIBRTE_CMDLINE { "interactive", 0, 0, 0 }, + { "auto-start", 0, 0, 0 }, { "eth-peers-configfile", 1, 0, 0 }, { "eth-peer", 1, 0, 0 }, #endif @@ -539,11 +542,11 @@ launch_args_parse(int argc, char** argv) argvopt = argv; #ifdef RTE_LIBRTE_CMDLINE -#define SHORTOPTS "ih" +#define SHORTOPTS "i" #else -#define SHORTOPTS "h" +#define SHORTOPTS "" #endif - while ((opt = getopt_long(argc, argvopt, SHORTOPTS, + while ((opt = getopt_long(argc, argvopt, SHORTOPTS "ah", lgopts, &opt_idx)) != EOF) { switch (opt) { #ifdef RTE_LIBRTE_CMDLINE @@ -552,6 +555,11 @@ launch_args_parse(int argc, char** argv) interactive = 1; break; #endif + case 'a': + printf("Auto-start selected\n"); + auto_start = 1; + break; + case 0: /*long options */ if (!strcmp(lgopts[opt_idx].name, "help")) { usage(argv[0]); @@ -562,6 +570,10 @@ launch_args_parse(int argc, char** argv) printf("Interactive-mode selected\n"); interactive = 1; } + if (!strcmp(lgopts[opt_idx].name, "auto-start")) { + printf("Auto-start selected\n"); + auto_start = 1; + } if (!strcmp(lgopts[opt_idx].name, "eth-peers-configfile")) { if (init_peer_eth_addrs(optarg) != 0) diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 55a5ea1616..f643f1c459 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -83,6 +83,7 @@ uint16_t verbose_level = 0; /**< Silent by default. */ /* use master core for command line ? */ uint8_t interactive = 0; +uint8_t auto_start = 0; /* * NUMA support configuration. @@ -1830,9 +1831,13 @@ main(int argc, char** argv) rte_eth_promiscuous_enable(port_id); #ifdef RTE_LIBRTE_CMDLINE - if (interactive == 1) + if (interactive == 1) { + if (auto_start) { + printf("Start automatic packet forwarding\n"); + start_packet_forwarding(0); + } prompt(); - else + } else #endif { char c; diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index a4842ecdd1..52d35438ed 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -270,6 +270,7 @@ extern uint16_t nb_rx_queue_stats_mappings; /* globals used for configuration */ extern uint16_t verbose_level; /**< Drives messages being displayed, if any. */ extern uint8_t interactive; +extern uint8_t auto_start; 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; /**