[dpdk-dev,v3] app/testpmd: add parameter to start forwarding TX first

Message ID 20170615040403.78712-1-pablo.de.lara.guarch@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail Compilation issues

Commit Message

De Lara Guarch, Pablo June 15, 2017, 4:04 a.m. UTC
  Add parameter to start forwarding sending first
a burst of packets, which is useful when testing
a loopback connection.

This was already implemented as an internal command,
but adding it as a parameter is interesting, as it
allows the user to test a loopback connection without
entering in the internal command line.

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---

Changes in v3:

-Added tx-first in long parameter list
-Reworded informational message when tx-first is enabled

Changes in v2:

- Added check to prevent user from using --tx-first in interactive mode,
  to avoid confusion
- Added extra information in testpmd help about the new parameter

 app/test-pmd/parameters.c             | 9 +++++++++
 app/test-pmd/testpmd.c                | 6 +++++-
 app/test-pmd/testpmd.h                | 1 +
 doc/guides/testpmd_app_ug/run_app.rst | 8 ++++++++
 4 files changed, 23 insertions(+), 1 deletion(-)
  

Comments

De Lara Guarch, Pablo June 15, 2017, 12:05 p.m. UTC | #1
Sending to right Jingjing mail address.

> -----Original Message-----
> From: De Lara Guarch, Pablo
> Sent: Thursday, June 15, 2017 5:04 AM
> To: jingjing.wu@dpdk.org
> Cc: dev@dpdk.org; De Lara Guarch, Pablo
> Subject: [PATCH v3] app/testpmd: add parameter to start forwarding TX
> first
> 
> Add parameter to start forwarding sending first
> a burst of packets, which is useful when testing
> a loopback connection.
> 
> This was already implemented as an internal command,
> but adding it as a parameter is interesting, as it
> allows the user to test a loopback connection without
> entering in the internal command line.
> 
> Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
> ---
> 
> Changes in v3:
> 
> -Added tx-first in long parameter list
> -Reworded informational message when tx-first is enabled
> 
> Changes in v2:
> 
> - Added check to prevent user from using --tx-first in interactive mode,
>   to avoid confusion
> - Added extra information in testpmd help about the new parameter
> 
>  app/test-pmd/parameters.c             | 9 +++++++++
>  app/test-pmd/testpmd.c                | 6 +++++-
>  app/test-pmd/testpmd.h                | 1 +
>  doc/guides/testpmd_app_ug/run_app.rst | 8 ++++++++
>  4 files changed, 23 insertions(+), 1 deletion(-)
> 
> diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c
> index fbe6284..0a88844 100644
> --- a/app/test-pmd/parameters.c
> +++ b/app/test-pmd/parameters.c
> @@ -89,6 +89,7 @@ usage(char* progname)
>  	       "[--cmdline-file=FILENAME] "
>  #endif
>  	       "[--help|-h] | [--auto-start|-a] | ["
> +	       "--tx-first | "
>  	       "--coremask=COREMASK --portmask=PORTMASK --numa "
>  	       "--mbuf-size= | --total-num-mbufs= | "
>  	       "--nb-cores= | --nb-ports= | "
> @@ -109,6 +110,8 @@ usage(char* progname)
>  	printf("  --auto-start: start forwarding on init "
>  	       "[always when non-interactive].\n");
>  	printf("  --help: display this message and quit.\n");
> +	printf("  --tx-first: start forwarding sending a burst first "
> +	       "(only if interactive is disabled).\n");
>  	printf("  --nb-cores=N: set the number of forwarding cores "
>  	       "(1 <= N <= %d).\n", nb_lcores);
>  	printf("  --nb-ports=N: set the number of forwarding ports "
> @@ -566,6 +569,7 @@ launch_args_parse(int argc, char** argv)
>  		{ "eth-peers-configfile",	1, 0, 0 },
>  		{ "eth-peer",			1, 0, 0 },
>  #endif
> +		{ "tx-first",			0, 0, 0 },
>  		{ "ports",			1, 0, 0 },
>  		{ "nb-cores",			1, 0, 0 },
>  		{ "nb-ports",			1, 0, 0 },
> @@ -674,6 +678,11 @@ launch_args_parse(int argc, char** argv)
>  				printf("Auto-start selected\n");
>  				auto_start = 1;
>  			}
> +			if (!strcmp(lgopts[opt_idx].name, "tx-first")) {
> +				printf("Ports to start sending a burst of "
> +						"packets first\n");
> +				tx_first = 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 d32cbb9..6001283 100644
> --- a/app/test-pmd/testpmd.c
> +++ b/app/test-pmd/testpmd.c
> @@ -98,6 +98,7 @@ uint16_t verbose_level = 0; /**< Silent by default. */
>  /* use master core for command line ? */
>  uint8_t interactive = 0;
>  uint8_t auto_start = 0;
> +uint8_t tx_first;
>  char cmdline_filename[PATH_MAX] = {0};
> 
>  /*
> @@ -2294,6 +2295,9 @@ main(int argc, char** argv)
>  	if (argc > 1)
>  		launch_args_parse(argc, argv);
> 
> +	if (tx_first && interactive)
> +		rte_exit(EXIT_FAILURE, "--tx-first cannot be used on "
> +				"interactive mode.\n");
>  	if (!nb_rxq && !nb_txq)
>  		printf("Warning: Either rx or tx queues should be non-
> zero\n");
> 
> @@ -2353,7 +2357,7 @@ main(int argc, char** argv)
>  		int rc;
> 
>  		printf("No commandline core given, start packet
> forwarding\n");
> -		start_packet_forwarding(0);
> +		start_packet_forwarding(tx_first);
>  		printf("Press enter to exit\n");
>  		rc = read(0, &c, 1);
>  		pmd_test_exit();
> diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
> index 364502d..5cabeef 100644
> --- a/app/test-pmd/testpmd.h
> +++ b/app/test-pmd/testpmd.h
> @@ -299,6 +299,7 @@ extern uint16_t nb_rx_queue_stats_mappings;
>  extern uint16_t verbose_level; /**< Drives messages being displayed, if
> any. */
>  extern uint8_t  interactive;
>  extern uint8_t  auto_start;
> +extern uint8_t  tx_first;
>  extern char cmdline_filename[PATH_MAX]; /**< offline commands file */
>  extern uint8_t  numa_support; /**< set by "--numa" parameter */
>  extern uint16_t port_topology; /**< set by "--port-topology" parameter */
> diff --git a/doc/guides/testpmd_app_ug/run_app.rst
> b/doc/guides/testpmd_app_ug/run_app.rst
> index 2a43214..3159398 100644
> --- a/doc/guides/testpmd_app_ug/run_app.rst
> +++ b/doc/guides/testpmd_app_ug/run_app.rst
> @@ -188,6 +188,14 @@ The commandline options are:
> 
>      Start forwarding on initialization.
> 
> +*   ``--tx-first``
> +
> +    Start forwarding, after sending a burst of packets first.
> +
> +.. Note::
> +
> +   This flag should be only used in non-interactive mode.
> +
>  *   ``--nb-cores=N``
> 
>      Set the number of forwarding cores,
> --
> 2.9.4
  
Jingjing Wu June 19, 2017, 1:05 a.m. UTC | #2
> -----Original Message-----
> From: De Lara Guarch, Pablo
> Sent: Thursday, June 15, 2017 8:05 PM
> To: Wu, Jingjing <jingjing.wu@intel.com>
> Cc: dev@dpdk.org
> Subject: RE: [PATCH v3] app/testpmd: add parameter to start forwarding TX
> first
> 
> Sending to right Jingjing mail address.
> 
> > -----Original Message-----
> > From: De Lara Guarch, Pablo
> > Sent: Thursday, June 15, 2017 5:04 AM
> > To: jingjing.wu@dpdk.org
> > Cc: dev@dpdk.org; De Lara Guarch, Pablo
> > Subject: [PATCH v3] app/testpmd: add parameter to start forwarding TX
> > first
> >
> > Add parameter to start forwarding sending first a burst of packets,
> > which is useful when testing a loopback connection.
> >
> > This was already implemented as an internal command, but adding it as
> > a parameter is interesting, as it allows the user to test a loopback
> > connection without entering in the internal command line.
> >
> > Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
> > ---
> >
> > Changes in v3:
> >
> > -Added tx-first in long parameter list -Reworded informational message
> > when tx-first is enabled

Acked-by: Jingjing Wu <jingjing.wu@intel.com>
  
Thomas Monjalon June 19, 2017, 9:12 p.m. UTC | #3
15/06/2017 14:05, De Lara Guarch, Pablo:
> > Add parameter to start forwarding sending first
> > a burst of packets, which is useful when testing
> > a loopback connection.
> > 
> > This was already implemented as an internal command,
> > but adding it as a parameter is interesting, as it
> > allows the user to test a loopback connection without
> > entering in the internal command line.
> > 
> > Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
> > ---
> > --- a/doc/guides/testpmd_app_ug/run_app.rst
> > +++ b/doc/guides/testpmd_app_ug/run_app.rst
> > @@ -188,6 +188,14 @@ The commandline options are:
> > 
> >      Start forwarding on initialization.
> > 
> > +*   ``--tx-first``
> > +
> > +    Start forwarding, after sending a burst of packets first.
> > +
> > +.. Note::
> > +
> > +   This flag should be only used in non-interactive mode.

I don't really understand the benefit of this option.
Why is it better than
	echo start tx_first | testpmd -i
?
  
De Lara Guarch, Pablo June 20, 2017, 8:03 a.m. UTC | #4
> -----Original Message-----
> From: Thomas Monjalon [mailto:thomas@monjalon.net]
> Sent: Monday, June 19, 2017 10:13 PM
> To: De Lara Guarch, Pablo
> Cc: dev@dpdk.org; Wu, Jingjing
> Subject: Re: [dpdk-dev] [PATCH v3] app/testpmd: add parameter to start
> forwarding TX first
> 
> 15/06/2017 14:05, De Lara Guarch, Pablo:
> > > Add parameter to start forwarding sending first
> > > a burst of packets, which is useful when testing
> > > a loopback connection.
> > >
> > > This was already implemented as an internal command,
> > > but adding it as a parameter is interesting, as it
> > > allows the user to test a loopback connection without
> > > entering in the internal command line.
> > >
> > > Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
> > > ---
> > > --- a/doc/guides/testpmd_app_ug/run_app.rst
> > > +++ b/doc/guides/testpmd_app_ug/run_app.rst
> > > @@ -188,6 +188,14 @@ The commandline options are:
> > >
> > >      Start forwarding on initialization.
> > >
> > > +*   ``--tx-first``
> > > +
> > > +    Start forwarding, after sending a burst of packets first.
> > > +
> > > +.. Note::
> > > +
> > > +   This flag should be only used in non-interactive mode.
> 
> I don't really understand the benefit of this option.
> Why is it better than
> 	echo start tx_first | testpmd -i
> ?

This is a good way to test a loopback connection without having to get into interactive mode.
With the other patch that I sent, to show port statistics periodically
(http://dpdk.org/dev/patchwork/patch/25344/), the app can show how traffic is forwarded
having a simple loopback connection, without anything else required by the user.

Thanks,
Pablo
  
Bruce Richardson June 20, 2017, 9:22 a.m. UTC | #5
On Mon, Jun 19, 2017 at 11:12:53PM +0200, Thomas Monjalon wrote:
> 15/06/2017 14:05, De Lara Guarch, Pablo:
> > > Add parameter to start forwarding sending first
> > > a burst of packets, which is useful when testing
> > > a loopback connection.
> > > 
> > > This was already implemented as an internal command,
> > > but adding it as a parameter is interesting, as it
> > > allows the user to test a loopback connection without
> > > entering in the internal command line.
> > > 
> > > Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
> > > ---
> > > --- a/doc/guides/testpmd_app_ug/run_app.rst
> > > +++ b/doc/guides/testpmd_app_ug/run_app.rst
> > > @@ -188,6 +188,14 @@ The commandline options are:
> > > 
> > >      Start forwarding on initialization.
> > > 
> > > +*   ``--tx-first``
> > > +
> > > +    Start forwarding, after sending a burst of packets first.
> > > +
> > > +.. Note::
> > > +
> > > +   This flag should be only used in non-interactive mode.
> 
> I don't really understand the benefit of this option.
> Why is it better than
> 	echo start tx_first | testpmd -i
> ?

The one big difference I see is normal vs abnormal termination. With the
echo command you suggest, the only way to terminate testpmd is to kill
it via signal. With the extra cmdline option, it will cleanly exit via
enter as with non-interactive mode right now. Not a huge difference, but
I think having the extra argument to enable tx-first is useful.

/Bruce
  
Thomas Monjalon June 20, 2017, 9:58 a.m. UTC | #6
20/06/2017 11:22, Bruce Richardson:
> On Mon, Jun 19, 2017 at 11:12:53PM +0200, Thomas Monjalon wrote:
> > 15/06/2017 14:05, De Lara Guarch, Pablo:
> > > > Add parameter to start forwarding sending first
> > > > a burst of packets, which is useful when testing
> > > > a loopback connection.
> > > > 
> > > > This was already implemented as an internal command,
> > > > but adding it as a parameter is interesting, as it
> > > > allows the user to test a loopback connection without
> > > > entering in the internal command line.
> > > > 
> > > > Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
> > > > ---
> > > > --- a/doc/guides/testpmd_app_ug/run_app.rst
> > > > +++ b/doc/guides/testpmd_app_ug/run_app.rst
> > > > @@ -188,6 +188,14 @@ The commandline options are:
> > > > 
> > > >      Start forwarding on initialization.
> > > > 
> > > > +*   ``--tx-first``
> > > > +
> > > > +    Start forwarding, after sending a burst of packets first.
> > > > +
> > > > +.. Note::
> > > > +
> > > > +   This flag should be only used in non-interactive mode.
> > 
> > I don't really understand the benefit of this option.
> > Why is it better than
> > 	echo start tx_first | testpmd -i
> > ?
> 
> The one big difference I see is normal vs abnormal termination. With the
> echo command you suggest, the only way to terminate testpmd is to kill
> it via signal. With the extra cmdline option, it will cleanly exit via
> enter as with non-interactive mode right now. Not a huge difference, but
> I think having the extra argument to enable tx-first is useful.

I do not see a big difference between "enter" and "ctrl+c".

I think it is more flexible to pipe commands instead of options.
We could combine the proposed options --tx-first and -T into this command:
( echo 'start tx_first' ; while true ; do echo 'show port stats all' ; sleep 1 ; done ) | testpmd -i 

It is even possible to add more actions in the loop, so it is less
limited than the -T options.

It is a matter of deciding whether we prefer to implement more restricted
options or leverage the shell to freely program non-interactive testpmd.
  
Gaëtan Rivet June 20, 2017, 10:19 a.m. UTC | #7
On Tue, Jun 20, 2017 at 11:58:54AM +0200, Thomas Monjalon wrote:
> 20/06/2017 11:22, Bruce Richardson:
> > On Mon, Jun 19, 2017 at 11:12:53PM +0200, Thomas Monjalon wrote:
> > > 15/06/2017 14:05, De Lara Guarch, Pablo:
> > > > > Add parameter to start forwarding sending first
> > > > > a burst of packets, which is useful when testing
> > > > > a loopback connection.
> > > > > 
> > > > > This was already implemented as an internal command,
> > > > > but adding it as a parameter is interesting, as it
> > > > > allows the user to test a loopback connection without
> > > > > entering in the internal command line.
> > > > > 
> > > > > Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
> > > > > ---
> > > > > --- a/doc/guides/testpmd_app_ug/run_app.rst
> > > > > +++ b/doc/guides/testpmd_app_ug/run_app.rst
> > > > > @@ -188,6 +188,14 @@ The commandline options are:
> > > > > 
> > > > >      Start forwarding on initialization.
> > > > > 
> > > > > +*   ``--tx-first``
> > > > > +
> > > > > +    Start forwarding, after sending a burst of packets first.
> > > > > +
> > > > > +.. Note::
> > > > > +
> > > > > +   This flag should be only used in non-interactive mode.
> > > 
> > > I don't really understand the benefit of this option.
> > > Why is it better than
> > > 	echo start tx_first | testpmd -i
> > > ?
> > 
> > The one big difference I see is normal vs abnormal termination. With the
> > echo command you suggest, the only way to terminate testpmd is to kill
> > it via signal. With the extra cmdline option, it will cleanly exit via
> > enter as with non-interactive mode right now. Not a huge difference, but
> > I think having the extra argument to enable tx-first is useful.

Side note, one can:

(trap 'echo quit' SIGUSR1; echo 'start'; while true; do sleep 1; done) |testpmd -i &

and issue a SIGUSR1 to the subshell to cleanly quit testpmd.
Or:

(trap 'echo show port stats all' SIGUSR1; \
 trap 'echo quit' SIGUSR2; \
 echo 'start'; \
 while true; do :; done) |\
testpmd -i &

It's a little contrived, but it does the job and is easy enough to put
in scripts.

For automated testing, what I did was open a pipe to testpmd to issue
commands from wherever, allowing to keep testpmd running in the
background and dispatch commands when needed from other terminals. No
need to issue signals at all then.

> 
> I do not see a big difference between "enter" and "ctrl+c".
> 
> I think it is more flexible to pipe commands instead of options.
> We could combine the proposed options --tx-first and -T into this command:
> ( echo 'start tx_first' ; while true ; do echo 'show port stats all' ; sleep 1 ; done ) | testpmd -i 
> 
> It is even possible to add more actions in the loop, so it is less
> limited than the -T options.
> 
> It is a matter of deciding whether we prefer to implement more restricted
> options or leverage the shell to freely program non-interactive testpmd.
  
Van Haaren, Harry June 20, 2017, 10:27 a.m. UTC | #8
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Gaëtan Rivet
> Sent: Tuesday, June 20, 2017 11:19 AM
> To: Thomas Monjalon <thomas@monjalon.net>
> Cc: Richardson, Bruce <bruce.richardson@intel.com>; De Lara Guarch, Pablo
> <pablo.de.lara.guarch@intel.com>; dev@dpdk.org; Wu, Jingjing <jingjing.wu@intel.com>
> Subject: Re: [dpdk-dev] [PATCH v3] app/testpmd: add parameter to start forwarding TX first
> 
> On Tue, Jun 20, 2017 at 11:58:54AM +0200, Thomas Monjalon wrote:
> > 20/06/2017 11:22, Bruce Richardson:
> > > On Mon, Jun 19, 2017 at 11:12:53PM +0200, Thomas Monjalon wrote:
> > > > 15/06/2017 14:05, De Lara Guarch, Pablo:
> > > > > > Add parameter to start forwarding sending first
> > > > > > a burst of packets, which is useful when testing
> > > > > > a loopback connection.
> > > > > >
> > > > > > This was already implemented as an internal command,
> > > > > > but adding it as a parameter is interesting, as it
> > > > > > allows the user to test a loopback connection without
> > > > > > entering in the internal command line.
> > > > > >
> > > > > > Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
> > > > > > ---
> > > > > > --- a/doc/guides/testpmd_app_ug/run_app.rst
> > > > > > +++ b/doc/guides/testpmd_app_ug/run_app.rst
> > > > > > @@ -188,6 +188,14 @@ The commandline options are:
> > > > > >
> > > > > >      Start forwarding on initialization.
> > > > > >
> > > > > > +*   ``--tx-first``
> > > > > > +
> > > > > > +    Start forwarding, after sending a burst of packets first.
> > > > > > +
> > > > > > +.. Note::
> > > > > > +
> > > > > > +   This flag should be only used in non-interactive mode.
> > > >
> > > > I don't really understand the benefit of this option.
> > > > Why is it better than
> > > > 	echo start tx_first | testpmd -i
> > > > ?
> > >
> > > The one big difference I see is normal vs abnormal termination. With the
> > > echo command you suggest, the only way to terminate testpmd is to kill
> > > it via signal. With the extra cmdline option, it will cleanly exit via
> > > enter as with non-interactive mode right now. Not a huge difference, but
> > > I think having the extra argument to enable tx-first is useful.
> 
> Side note, one can:
> 
> (trap 'echo quit' SIGUSR1; echo 'start'; while true; do sleep 1; done) |testpmd -i &
> 
> and issue a SIGUSR1 to the subshell to cleanly quit testpmd.
> Or:
> 
> (trap 'echo show port stats all' SIGUSR1; \
>  trap 'echo quit' SIGUSR2; \
>  echo 'start'; \
>  while true; do :; done) |\
> testpmd -i &
> 
> It's a little contrived, but it does the job and is easy enough to put
> in scripts.
> 
> For automated testing, what I did was open a pipe to testpmd to issue
> commands from wherever, allowing to keep testpmd running in the
> background and dispatch commands when needed from other terminals. No
> need to issue signals at all then.

In an expert-user automated testing environment this is a solution yes..


> > I do not see a big difference between "enter" and "ctrl+c".
> >
> > I think it is more flexible to pipe commands instead of options.
> > We could combine the proposed options --tx-first and -T into this command:
> > ( echo 'start tx_first' ; while true ; do echo 'show port stats all' ; sleep 1 ; done ) |
> testpmd -i
> >
> > It is even possible to add more actions in the loop, so it is less
> > limited than the -T options.
> >
> > It is a matter of deciding whether we prefer to implement more restricted
> > options or leverage the shell to freely program non-interactive testpmd.


Lets keep in mind the beginner users, who probably don't have a traffic generator machine, perhaps just 2 ports and a loopback cable. IMO running   ./testpmd -- --tx-first   is the easiest way to learn to run traffic using testpmd, instead of various shell tricks to work-around a missing CLI flag?

A +1 from me to add   --tx-first  to the CLI, -Harry
  
Bruce Richardson June 20, 2017, 11:20 a.m. UTC | #9
On Tue, Jun 20, 2017 at 12:19:01PM +0200, Gaëtan Rivet wrote:
> On Tue, Jun 20, 2017 at 11:58:54AM +0200, Thomas Monjalon wrote:
> > 20/06/2017 11:22, Bruce Richardson:
> > > On Mon, Jun 19, 2017 at 11:12:53PM +0200, Thomas Monjalon wrote:
> > > > 15/06/2017 14:05, De Lara Guarch, Pablo:
> > > > > > Add parameter to start forwarding sending first
> > > > > > a burst of packets, which is useful when testing
> > > > > > a loopback connection.
> > > > > > 
> > > > > > This was already implemented as an internal command,
> > > > > > but adding it as a parameter is interesting, as it
> > > > > > allows the user to test a loopback connection without
> > > > > > entering in the internal command line.
> > > > > > 
> > > > > > Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
> > > > > > ---
> > > > > > --- a/doc/guides/testpmd_app_ug/run_app.rst
> > > > > > +++ b/doc/guides/testpmd_app_ug/run_app.rst
> > > > > > @@ -188,6 +188,14 @@ The commandline options are:
> > > > > > 
> > > > > >      Start forwarding on initialization.
> > > > > > 
> > > > > > +*   ``--tx-first``
> > > > > > +
> > > > > > +    Start forwarding, after sending a burst of packets first.
> > > > > > +
> > > > > > +.. Note::
> > > > > > +
> > > > > > +   This flag should be only used in non-interactive mode.
> > > > 
> > > > I don't really understand the benefit of this option.
> > > > Why is it better than
> > > > 	echo start tx_first | testpmd -i
> > > > ?
> > > 
> > > The one big difference I see is normal vs abnormal termination. With the
> > > echo command you suggest, the only way to terminate testpmd is to kill
> > > it via signal. With the extra cmdline option, it will cleanly exit via
> > > enter as with non-interactive mode right now. Not a huge difference, but
> > > I think having the extra argument to enable tx-first is useful.
> 
> Side note, one can:
> 
> (trap 'echo quit' SIGUSR1; echo 'start'; while true; do sleep 1; done) |testpmd -i &
> 
> and issue a SIGUSR1 to the subshell to cleanly quit testpmd.
> Or:
> 
> (trap 'echo show port stats all' SIGUSR1; \
>  trap 'echo quit' SIGUSR2; \
>  echo 'start'; \
>  while true; do :; done) |\
> testpmd -i &
> 
> It's a little contrived, but it does the job and is easy enough to put
> in scripts.
> 
Or we can just put in a --tx-first flag and save the user the pain of
doing multi-line bash commands. Usability is a constant complaint about
DPDK that we hear e.g. at userspace every year, so we need to stop
assuming everyone looking to play with DPDK is a shell power-user.

/Bruce
  
Gaëtan Rivet June 20, 2017, 12:30 p.m. UTC | #10
On Tue, Jun 20, 2017 at 12:20:34PM +0100, Bruce Richardson wrote:
> On Tue, Jun 20, 2017 at 12:19:01PM +0200, Gaëtan Rivet wrote:
> > On Tue, Jun 20, 2017 at 11:58:54AM +0200, Thomas Monjalon wrote:
> > > 20/06/2017 11:22, Bruce Richardson:
> > > > On Mon, Jun 19, 2017 at 11:12:53PM +0200, Thomas Monjalon wrote:
> > > > > 15/06/2017 14:05, De Lara Guarch, Pablo:
> > > > > > > Add parameter to start forwarding sending first
> > > > > > > a burst of packets, which is useful when testing
> > > > > > > a loopback connection.
> > > > > > > 
> > > > > > > This was already implemented as an internal command,
> > > > > > > but adding it as a parameter is interesting, as it
> > > > > > > allows the user to test a loopback connection without
> > > > > > > entering in the internal command line.
> > > > > > > 
> > > > > > > Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
> > > > > > > ---
> > > > > > > --- a/doc/guides/testpmd_app_ug/run_app.rst
> > > > > > > +++ b/doc/guides/testpmd_app_ug/run_app.rst
> > > > > > > @@ -188,6 +188,14 @@ The commandline options are:
> > > > > > > 
> > > > > > >      Start forwarding on initialization.
> > > > > > > 
> > > > > > > +*   ``--tx-first``
> > > > > > > +
> > > > > > > +    Start forwarding, after sending a burst of packets first.
> > > > > > > +
> > > > > > > +.. Note::
> > > > > > > +
> > > > > > > +   This flag should be only used in non-interactive mode.
> > > > > 
> > > > > I don't really understand the benefit of this option.
> > > > > Why is it better than
> > > > > 	echo start tx_first | testpmd -i
> > > > > ?
> > > > 
> > > > The one big difference I see is normal vs abnormal termination. With the
> > > > echo command you suggest, the only way to terminate testpmd is to kill
> > > > it via signal. With the extra cmdline option, it will cleanly exit via
> > > > enter as with non-interactive mode right now. Not a huge difference, but
> > > > I think having the extra argument to enable tx-first is useful.
> > 
> > Side note, one can:
> > 
> > (trap 'echo quit' SIGUSR1; echo 'start'; while true; do sleep 1; done) |testpmd -i &
> > 
> > and issue a SIGUSR1 to the subshell to cleanly quit testpmd.
> > Or:
> > 
> > (trap 'echo show port stats all' SIGUSR1; \
> >  trap 'echo quit' SIGUSR2; \
> >  echo 'start'; \
> >  while true; do :; done) |\
> > testpmd -i &
> > 
> > It's a little contrived, but it does the job and is easy enough to put
> > in scripts.
> > 
> Or we can just put in a --tx-first flag and save the user the pain of
> doing multi-line bash commands. Usability is a constant complaint about
> DPDK that we hear e.g. at userspace every year, so we need to stop
> assuming everyone looking to play with DPDK is a shell power-user.
> 
> /Bruce

Sure, but who are the users of testpmd, beside DPDK developers and
integration bots?

This fix IMO may be useful but it is a crutch for this usability
problem. The aimed functionality would result in the end in adding one
by one all interactive commands as parameters to have feature-parity
between interactive and non-interactive mode.

A better solution could be to open the cmdline from testpmd to a pipe
when not in interactive mode, instead of relying on the user to do it
artificially (as I was doing with my multiline shell command).
Then the parameters could be restricted to configuration items that ought
to be set before probing any device, instead of each possible elements
being added twice in the cmdline and in the parameters.

A kind of daemon / background mode if you want.
Anyway, that's just my limited experience with integrating testpmd to a
CI and using it, I reckon that it may not be the most common use, and I
have no opinion regarding this parameter ; I only wanted to give my PoV.
  
Thomas Monjalon July 5, 2017, 11:48 p.m. UTC | #11
> > > Add parameter to start forwarding sending first a burst of packets,
> > > which is useful when testing a loopback connection.
> > >
> > > This was already implemented as an internal command, but adding it as
> > > a parameter is interesting, as it allows the user to test a loopback
> > > connection without entering in the internal command line.
> > >
> > > Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
> > > ---
> > >
> > > Changes in v3:
> > >
> > > -Added tx-first in long parameter list -Reworded informational message
> > > when tx-first is enabled
> 
> Acked-by: Jingjing Wu <jingjing.wu@intel.com>

It is said to be useful for beginners, so it is accepted.
However we are not going to copy every CLI commands in parameters.

Applied, thanks
  

Patch

diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c
index fbe6284..0a88844 100644
--- a/app/test-pmd/parameters.c
+++ b/app/test-pmd/parameters.c
@@ -89,6 +89,7 @@  usage(char* progname)
 	       "[--cmdline-file=FILENAME] "
 #endif
 	       "[--help|-h] | [--auto-start|-a] | ["
+	       "--tx-first | "
 	       "--coremask=COREMASK --portmask=PORTMASK --numa "
 	       "--mbuf-size= | --total-num-mbufs= | "
 	       "--nb-cores= | --nb-ports= | "
@@ -109,6 +110,8 @@  usage(char* progname)
 	printf("  --auto-start: start forwarding on init "
 	       "[always when non-interactive].\n");
 	printf("  --help: display this message and quit.\n");
+	printf("  --tx-first: start forwarding sending a burst first "
+	       "(only if interactive is disabled).\n");
 	printf("  --nb-cores=N: set the number of forwarding cores "
 	       "(1 <= N <= %d).\n", nb_lcores);
 	printf("  --nb-ports=N: set the number of forwarding ports "
@@ -566,6 +569,7 @@  launch_args_parse(int argc, char** argv)
 		{ "eth-peers-configfile",	1, 0, 0 },
 		{ "eth-peer",			1, 0, 0 },
 #endif
+		{ "tx-first",			0, 0, 0 },
 		{ "ports",			1, 0, 0 },
 		{ "nb-cores",			1, 0, 0 },
 		{ "nb-ports",			1, 0, 0 },
@@ -674,6 +678,11 @@  launch_args_parse(int argc, char** argv)
 				printf("Auto-start selected\n");
 				auto_start = 1;
 			}
+			if (!strcmp(lgopts[opt_idx].name, "tx-first")) {
+				printf("Ports to start sending a burst of "
+						"packets first\n");
+				tx_first = 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 d32cbb9..6001283 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -98,6 +98,7 @@  uint16_t verbose_level = 0; /**< Silent by default. */
 /* use master core for command line ? */
 uint8_t interactive = 0;
 uint8_t auto_start = 0;
+uint8_t tx_first;
 char cmdline_filename[PATH_MAX] = {0};
 
 /*
@@ -2294,6 +2295,9 @@  main(int argc, char** argv)
 	if (argc > 1)
 		launch_args_parse(argc, argv);
 
+	if (tx_first && interactive)
+		rte_exit(EXIT_FAILURE, "--tx-first cannot be used on "
+				"interactive mode.\n");
 	if (!nb_rxq && !nb_txq)
 		printf("Warning: Either rx or tx queues should be non-zero\n");
 
@@ -2353,7 +2357,7 @@  main(int argc, char** argv)
 		int rc;
 
 		printf("No commandline core given, start packet forwarding\n");
-		start_packet_forwarding(0);
+		start_packet_forwarding(tx_first);
 		printf("Press enter to exit\n");
 		rc = read(0, &c, 1);
 		pmd_test_exit();
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index 364502d..5cabeef 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -299,6 +299,7 @@  extern uint16_t nb_rx_queue_stats_mappings;
 extern uint16_t verbose_level; /**< Drives messages being displayed, if any. */
 extern uint8_t  interactive;
 extern uint8_t  auto_start;
+extern uint8_t  tx_first;
 extern char cmdline_filename[PATH_MAX]; /**< offline commands file */
 extern uint8_t  numa_support; /**< set by "--numa" parameter */
 extern uint16_t port_topology; /**< set by "--port-topology" parameter */
diff --git a/doc/guides/testpmd_app_ug/run_app.rst b/doc/guides/testpmd_app_ug/run_app.rst
index 2a43214..3159398 100644
--- a/doc/guides/testpmd_app_ug/run_app.rst
+++ b/doc/guides/testpmd_app_ug/run_app.rst
@@ -188,6 +188,14 @@  The commandline options are:
 
     Start forwarding on initialization.
 
+*   ``--tx-first``
+
+    Start forwarding, after sending a burst of packets first.
+
+.. Note::
+
+   This flag should be only used in non-interactive mode.
+
 *   ``--nb-cores=N``
 
     Set the number of forwarding cores,