[v2,2/2] examples/l3fwd: make RX and TX queue size configurable

Message ID 20220211002607.80058-2-honnappa.nagarahalli@arm.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series [v2,1/2] examples/l3fwd: use single set of variables throughout the code |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/github-robot: build success github build: passed
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS

Commit Message

Honnappa Nagarahalli Feb. 11, 2022, 12:26 a.m. UTC
  Make RX and TX queue sizes configurable from the command line.
This helps DTS write better test cases.

Signed-off-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
Reviewed-by: Kathleen Capella <kathleen.capella@arm.com>
Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
---
 examples/l3fwd/main.c | 56 ++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 55 insertions(+), 1 deletion(-)
  

Comments

Stephen Hemminger Feb. 11, 2022, 12:53 a.m. UTC | #1
On Fri, 11 Feb 2022 00:26:07 +0000
Honnappa Nagarahalli <honnappa.nagarahalli@arm.com> wrote:

> diff --git a/examples/l3fwd/main.c b/examples/l3fwd/main.c
> index acd186ab7d..afe94cd1d7 100644
> --- a/examples/l3fwd/main.c
> +++ b/examples/l3fwd/main.c
> @@ -341,6 +341,8 @@ print_usage(const char *prgname)
>  		" [-P]"
>  		" [--lookup]"
>  		" --config (port,queue,lcore)[,(port,queue,lcore)]"
> +		" [--rx-queue-size]"
> +		" [--tx-queue-size]"

Shouldn't there be a NPKTS after the arg?

                 " [--rx-queue-size NPKTS]"
  
Stephen Hemminger Feb. 11, 2022, 1:01 a.m. UTC | #2
On Fri, 11 Feb 2022 00:26:07 +0000
Honnappa Nagarahalli <honnappa.nagarahalli@arm.com> wrote:

> +static void
> +parse_rx_queue_size(const char *rx_queue_size_arg)
> +{
> +	char *end = NULL;
> +	uint32_t rx_queue_size;
> +
> +	/* parse decimal string */
> +	rx_queue_size = strtoul(rx_queue_size_arg, &end, 10);
> +	if ((rx_queue_size_arg[0] == '\0') || (end == NULL) || (*end != '\0'))
> +		return;
> +
> +	if (rx_queue_size == 0)
> +		return;
> +
> +	nb_rxd = rx_queue_size;
> +}
> +
> +static void
> +parse_tx_queue_size(const char *tx_queue_size_arg)
> +{
> +	char *end = NULL;
> +	uint32_t tx_queue_size;
> +
> +	/* parse decimal string */
> +	tx_queue_size = strtoul(tx_queue_size_arg, &end, 10);
> +	if ((tx_queue_size_arg[0] == '\0') || (end == NULL) || (*end != '\0'))
> +		return;
> +
> +	if (tx_queue_size == 0)
> +		return;
> +
> +	nb_txd = tx_queue_size;

These are duplications of the same function, just different result.
Also programs should test for invalid queue size which is currently
limited to 16 bits by rte_eth_dev_configure

static void
parse_queue_size(const char *size_arg, uint32_t *size_ret)
{
	unsigned long result;
	char *end;

	result = strtoul(size_arg, &end, 0);
	if (size_arg[0] == '\0' || *end != '\0' || result > UINT16_MAX)
		rte_exit(EXIT_FAILURE, "Invalid queue size '%s'\n", size_arg);
	*size_ret = result;
}
  
Honnappa Nagarahalli Feb. 11, 2022, 3:38 a.m. UTC | #3
<snip>

> 
> On Fri, 11 Feb 2022 00:26:07 +0000
> Honnappa Nagarahalli <honnappa.nagarahalli@arm.com> wrote:
> 
> > +static void
> > +parse_rx_queue_size(const char *rx_queue_size_arg) {
> > +	char *end = NULL;
> > +	uint32_t rx_queue_size;
> > +
> > +	/* parse decimal string */
> > +	rx_queue_size = strtoul(rx_queue_size_arg, &end, 10);
> > +	if ((rx_queue_size_arg[0] == '\0') || (end == NULL) || (*end != '\0'))
> > +		return;
> > +
> > +	if (rx_queue_size == 0)
> > +		return;
> > +
> > +	nb_rxd = rx_queue_size;
> > +}
> > +
> > +static void
> > +parse_tx_queue_size(const char *tx_queue_size_arg) {
> > +	char *end = NULL;
> > +	uint32_t tx_queue_size;
> > +
> > +	/* parse decimal string */
> > +	tx_queue_size = strtoul(tx_queue_size_arg, &end, 10);
> > +	if ((tx_queue_size_arg[0] == '\0') || (end == NULL) || (*end != '\0'))
> > +		return;
> > +
> > +	if (tx_queue_size == 0)
> > +		return;
> > +
> > +	nb_txd = tx_queue_size;
> 
> These are duplications of the same function, just different result.
Agreed, make sense to combine

> Also programs should test for invalid queue size which is currently limited to 16
> bits by rte_eth_dev_configure
> 
> static void
> parse_queue_size(const char *size_arg, uint32_t *size_ret) {
> 	unsigned long result;
> 	char *end;
> 
> 	result = strtoul(size_arg, &end, 0);
> 	if (size_arg[0] == '\0' || *end != '\0' || result > UINT16_MAX)
> 		rte_exit(EXIT_FAILURE, "Invalid queue size '%s'\n", size_arg);
> 	*size_ret = result;
> }
  
Honnappa Nagarahalli Feb. 11, 2022, 3:43 a.m. UTC | #4
<snip>

> 
> On Fri, 11 Feb 2022 00:26:07 +0000
> Honnappa Nagarahalli <honnappa.nagarahalli@arm.com> wrote:
> 
> > diff --git a/examples/l3fwd/main.c b/examples/l3fwd/main.c index
> > acd186ab7d..afe94cd1d7 100644
> > --- a/examples/l3fwd/main.c
> > +++ b/examples/l3fwd/main.c
> > @@ -341,6 +341,8 @@ print_usage(const char *prgname)
> >  		" [-P]"
> >  		" [--lookup]"
> >  		" --config (port,queue,lcore)[,(port,queue,lcore)]"
> > +		" [--rx-queue-size]"
> > +		" [--tx-queue-size]"
> 
> Shouldn't there be a NPKTS after the arg?
I guess it does not harm, makes it consistent with other options, though I don't see much value.

> 
>                  " [--rx-queue-size NPKTS]"
  

Patch

diff --git a/examples/l3fwd/main.c b/examples/l3fwd/main.c
index acd186ab7d..afe94cd1d7 100644
--- a/examples/l3fwd/main.c
+++ b/examples/l3fwd/main.c
@@ -341,6 +341,8 @@  print_usage(const char *prgname)
 		" [-P]"
 		" [--lookup]"
 		" --config (port,queue,lcore)[,(port,queue,lcore)]"
+		" [--rx-queue-size]"
+		" [--tx-queue-size]"
 		" [--eth-dest=X,MM:MM:MM:MM:MM:MM]"
 		" [--max-pkt-len PKTLEN]"
 		" [--no-numa]"
@@ -360,6 +362,10 @@  print_usage(const char *prgname)
 		"            Default: lpm\n"
 		"            Accepted: em (Exact Match), lpm (Longest Prefix Match), fib (Forwarding Information Base)\n"
 		"  --config (port,queue,lcore): Rx queue configuration\n"
+		"  --rx-queue-size: Rx queue size\n"
+		"            Default: %d\n"
+		"  --tx-queue-size: Tx queue size\n"
+		"            Default: %d\n"
 		"  --eth-dest=X,MM:MM:MM:MM:MM:MM: Ethernet destination for port X\n"
 		"  --max-pkt-len PKTLEN: maximum packet length in decimal (64-9600)\n"
 		"  --no-numa: Disable numa awareness\n"
@@ -381,7 +387,7 @@  print_usage(const char *prgname)
 		"  --event-vector-tmo: Max timeout to form vector in nanoseconds if event vectorization is enabled\n"
 		"  -E : Enable exact match, legacy flag please use --lookup=em instead\n"
 		"  -L : Enable longest prefix match, legacy flag please use --lookup=lpm instead\n\n",
-		prgname);
+		prgname, RTE_TEST_RX_DESC_DEFAULT, RTE_TEST_TX_DESC_DEFAULT);
 }
 
 static int
@@ -524,6 +530,40 @@  parse_mode(const char *optarg)
 		evt_rsrc->enabled = true;
 }
 
+static void
+parse_rx_queue_size(const char *rx_queue_size_arg)
+{
+	char *end = NULL;
+	uint32_t rx_queue_size;
+
+	/* parse decimal string */
+	rx_queue_size = strtoul(rx_queue_size_arg, &end, 10);
+	if ((rx_queue_size_arg[0] == '\0') || (end == NULL) || (*end != '\0'))
+		return;
+
+	if (rx_queue_size == 0)
+		return;
+
+	nb_rxd = rx_queue_size;
+}
+
+static void
+parse_tx_queue_size(const char *tx_queue_size_arg)
+{
+	char *end = NULL;
+	uint32_t tx_queue_size;
+
+	/* parse decimal string */
+	tx_queue_size = strtoul(tx_queue_size_arg, &end, 10);
+	if ((tx_queue_size_arg[0] == '\0') || (end == NULL) || (*end != '\0'))
+		return;
+
+	if (tx_queue_size == 0)
+		return;
+
+	nb_txd = tx_queue_size;
+}
+
 static void
 parse_eventq_sched(const char *optarg)
 {
@@ -581,6 +621,8 @@  static const char short_options[] =
 	;
 
 #define CMD_LINE_OPT_CONFIG "config"
+#define CMD_LINE_OPT_RX_QUEUE_SIZE "rx-queue-size"
+#define CMD_LINE_OPT_TX_QUEUE_SIZE "tx-queue-size"
 #define CMD_LINE_OPT_ETH_DEST "eth-dest"
 #define CMD_LINE_OPT_NO_NUMA "no-numa"
 #define CMD_LINE_OPT_IPV6 "ipv6"
@@ -603,6 +645,8 @@  enum {
 	 * conflict with short options */
 	CMD_LINE_OPT_MIN_NUM = 256,
 	CMD_LINE_OPT_CONFIG_NUM,
+	CMD_LINE_OPT_RX_QUEUE_SIZE_NUM,
+	CMD_LINE_OPT_TX_QUEUE_SIZE_NUM,
 	CMD_LINE_OPT_ETH_DEST_NUM,
 	CMD_LINE_OPT_NO_NUMA_NUM,
 	CMD_LINE_OPT_IPV6_NUM,
@@ -621,6 +665,8 @@  enum {
 
 static const struct option lgopts[] = {
 	{CMD_LINE_OPT_CONFIG, 1, 0, CMD_LINE_OPT_CONFIG_NUM},
+	{CMD_LINE_OPT_RX_QUEUE_SIZE, 1, 0, CMD_LINE_OPT_RX_QUEUE_SIZE_NUM},
+	{CMD_LINE_OPT_TX_QUEUE_SIZE, 1, 0, CMD_LINE_OPT_TX_QUEUE_SIZE_NUM},
 	{CMD_LINE_OPT_ETH_DEST, 1, 0, CMD_LINE_OPT_ETH_DEST_NUM},
 	{CMD_LINE_OPT_NO_NUMA, 0, 0, CMD_LINE_OPT_NO_NUMA_NUM},
 	{CMD_LINE_OPT_IPV6, 0, 0, CMD_LINE_OPT_IPV6_NUM},
@@ -714,6 +760,14 @@  parse_args(int argc, char **argv)
 			lcore_params = 1;
 			break;
 
+		case CMD_LINE_OPT_RX_QUEUE_SIZE_NUM:
+			parse_rx_queue_size(optarg);
+			break;
+
+		case CMD_LINE_OPT_TX_QUEUE_SIZE_NUM:
+			parse_tx_queue_size(optarg);
+			break;
+
 		case CMD_LINE_OPT_ETH_DEST_NUM:
 			parse_eth_dest(optarg);
 			break;