[dpdk-dev,1/5] app/test-pmd: fix nb_rxq and np_txq checks

Message ID 1454073052-27025-2-git-send-email-reshma.pattan@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers

Commit Message

Pattan, Reshma Jan. 29, 2016, 1:10 p.m. UTC
  Made testpmd changes to validate nb_rxq/nb_txq zero
value changes of librte_ether.

Signed-off-by: Reshma Pattan <reshma.pattan@intel.com>
---
 app/test-pmd/cmdline.c    |   11 +++++------
 app/test-pmd/parameters.c |   14 +++++++++-----
 app/test-pmd/testpmd.c    |   19 +++++++++++++++++--
 3 files changed, 31 insertions(+), 13 deletions(-)
  

Comments

De Lara Guarch, Pablo Feb. 5, 2016, 8:48 a.m. UTC | #1
Hi Reshma,

> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Reshma Pattan
> Sent: Friday, January 29, 2016 1:11 PM
> To: dev@dpdk.org
> Subject: [dpdk-dev] [PATCH 1/5] app/test-pmd: fix nb_rxq and np_txq checks
> 
> Made testpmd changes to validate nb_rxq/nb_txq zero
> value changes of librte_ether.
> 
> Signed-off-by: Reshma Pattan <reshma.pattan@intel.com>
> ---
>  app/test-pmd/cmdline.c    |   11 +++++------
>  app/test-pmd/parameters.c |   14 +++++++++-----
>  app/test-pmd/testpmd.c    |   19 +++++++++++++++++--
>  3 files changed, 31 insertions(+), 13 deletions(-)
> 
> diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
> index 6d28c1b..fa666d2 100644
> --- a/app/test-pmd/cmdline.c
> +++ b/app/test-pmd/cmdline.c
> @@ -1,7 +1,7 @@
>  /*-
>   *   BSD LICENSE
>   *
> - *   Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
> + *   Copyright(c) 2010-2016 Intel Corporation. All rights reserved.
>   *   Copyright(c) 2014 6WIND S.A.
>   *   All rights reserved.
>   *
> @@ -1163,17 +1163,16 @@ cmd_config_rx_tx_parsed(void *parsed_result,
>  		printf("Please stop all ports first\n");
>  		return;
>  	}
> -
>  	if (!strcmp(res->name, "rxq")) {
> -		if (res->value <= 0) {
> -			printf("rxq %d invalid - must be > 0\n", res->value);
> +		if (!res->value && !nb_txq) {
> +			printf("Warning: Either rx or tx queues should non be
> zero\n");

Typo: Either "should be non-zero" or "should not be zero". Same below.

>  			return;
>  		}
>  		nb_rxq = res->value;
>  	}
>  	else if (!strcmp(res->name, "txq")) {
> -		if (res->value <= 0) {
> -			printf("txq %d invalid - must be > 0\n", res->value);
> +		if (!res->value && !nb_rxq) {
> +			printf("Warning: Either rx or tx queues should non be
> zero\n");
>  			return;
>  		}
>  		nb_txq = res->value;

[...]

> diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
> index 1319917..4c8afba 100644
> --- a/app/test-pmd/testpmd.c
> +++ b/app/test-pmd/testpmd.c
> @@ -1,7 +1,7 @@
>  /*-
>   *   BSD LICENSE
>   *
> - *   Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
> + *   Copyright(c) 2010-2016 Intel Corporation. All rights reserved.
>   *   All rights reserved.
>   *
>   *   Redistribution and use in source and binary forms, with or without
> @@ -608,6 +608,7 @@ init_fwd_streams(void)
>  	portid_t pid;
>  	struct rte_port *port;
>  	streamid_t sm_id, nb_fwd_streams_new;
> +	queueid_t q;
> 
>  	/* set socket id according to numa or not */
>  	FOREACH_PORT(pid, ports) {
> @@ -643,7 +644,12 @@ init_fwd_streams(void)
>  		}
>  	}
> 
> -	nb_fwd_streams_new = (streamid_t)(nb_ports * nb_rxq);
> +	q = RTE_MAX(nb_rxq, nb_txq);
> +	if (q == 0) {
> +		printf("Fail:Cannot allocate fwd streams as number of
> queues is 0\n");
> +		return -1;
> +	}
> +	nb_fwd_streams_new = (streamid_t)(nb_ports * q);
>  	if (nb_fwd_streams_new == nb_fwd_streams)
>  		return 0;
>  	/* clear the old */
> @@ -955,6 +961,12 @@ start_packet_forwarding(int with_tx_first)
>  	portid_t   pt_id;
>  	streamid_t sm_id;
> 
> +	if (strcmp(cur_fwd_eng->fwd_mode_name, "rxonly") == 0 &&
> !nb_rxq)
> +		rte_exit(EXIT_FAILURE, "rxq are 0, cannot use rxonly fwd
> mode\n");
> +
> +	if (strcmp(cur_fwd_eng->fwd_mode_name, "txonly") == 0 &&
> !nb_txq)
> +		rte_exit(EXIT_FAILURE, "txq are 0, cannot use txonly fwd
> mode\n");
> +

Should we check if we have both rxq and txq > 0 when running
the other forwarding modes that need both RX/TX queues?

>  	if (all_ports_started() == 0) {
>  		printf("Not all ports were started\n");
>  		return;
> @@ -2037,6 +2049,9 @@ main(int argc, char** argv)
>  	if (argc > 1)
>  		launch_args_parse(argc, argv);
> 
> +	if (!nb_rxq && !nb_txq)
> +		printf("Warning: Either rx or tx queues should be non-
> zero\n");
> +
>  	if (nb_rxq > nb_txq)
>  		printf("Warning: nb_rxq=%d enables RSS configuration, "
>  		       "but nb_txq=%d will prevent to fully test it.\n",

Since we are allowing testpmd to run with nb_txq = 0, if nb_rxq = 1 and nb_txq = 0,
this warning above will be showed, because before if nb_rxq > nb_txq,
it would mean that nb_rxq is at least 2, so RSS is enabled, but now it might not be,
so this message has to be changed.

> --
> 1.7.4.1
  

Patch

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 6d28c1b..fa666d2 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -1,7 +1,7 @@ 
 /*-
  *   BSD LICENSE
  *
- *   Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
+ *   Copyright(c) 2010-2016 Intel Corporation. All rights reserved.
  *   Copyright(c) 2014 6WIND S.A.
  *   All rights reserved.
  *
@@ -1163,17 +1163,16 @@  cmd_config_rx_tx_parsed(void *parsed_result,
 		printf("Please stop all ports first\n");
 		return;
 	}
-
 	if (!strcmp(res->name, "rxq")) {
-		if (res->value <= 0) {
-			printf("rxq %d invalid - must be > 0\n", res->value);
+		if (!res->value && !nb_txq) {
+			printf("Warning: Either rx or tx queues should non be zero\n");
 			return;
 		}
 		nb_rxq = res->value;
 	}
 	else if (!strcmp(res->name, "txq")) {
-		if (res->value <= 0) {
-			printf("txq %d invalid - must be > 0\n", res->value);
+		if (!res->value && !nb_rxq) {
+			printf("Warning: Either rx or tx queues should non be zero\n");
 			return;
 		}
 		nb_txq = res->value;
diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c
index 4b421c8..55572eb 100644
--- a/app/test-pmd/parameters.c
+++ b/app/test-pmd/parameters.c
@@ -1,7 +1,7 @@ 
 /*-
  *   BSD LICENSE
  *
- *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+ *   Copyright(c) 2010-2016 Intel Corporation. All rights reserved.
  *   All rights reserved.
  *
  *   Redistribution and use in source and binary forms, with or without
@@ -810,22 +810,26 @@  launch_args_parse(int argc, char** argv)
 				rss_hf = ETH_RSS_UDP;
 			if (!strcmp(lgopts[opt_idx].name, "rxq")) {
 				n = atoi(optarg);
-				if (n >= 1 && n <= (int) MAX_QUEUE_ID)
+				if (n >= 0 && n <= (int) MAX_QUEUE_ID)
 					nb_rxq = (queueid_t) n;
 				else
 					rte_exit(EXIT_FAILURE, "rxq %d invalid - must be"
-						  " >= 1 && <= %d\n", n,
+						  " >= 0 && <= %d\n", n,
 						  (int) MAX_QUEUE_ID);
 			}
 			if (!strcmp(lgopts[opt_idx].name, "txq")) {
 				n = atoi(optarg);
-				if (n >= 1 && n <= (int) MAX_QUEUE_ID)
+				if (n >= 0 && n <= (int) MAX_QUEUE_ID)
 					nb_txq = (queueid_t) n;
 				else
 					rte_exit(EXIT_FAILURE, "txq %d invalid - must be"
-						  " >= 1 && <= %d\n", n,
+						  " >= 0 && <= %d\n", n,
 						  (int) MAX_QUEUE_ID);
 			}
+			if (!nb_rxq && !nb_txq) {
+				rte_exit(EXIT_FAILURE, "Either rx or tx queues should "
+						"be non-zero\n");
+			}
 			if (!strcmp(lgopts[opt_idx].name, "burst")) {
 				n = atoi(optarg);
 				if ((n >= 1) && (n <= MAX_PKT_BURST))
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 1319917..4c8afba 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -1,7 +1,7 @@ 
 /*-
  *   BSD LICENSE
  *
- *   Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
+ *   Copyright(c) 2010-2016 Intel Corporation. All rights reserved.
  *   All rights reserved.
  *
  *   Redistribution and use in source and binary forms, with or without
@@ -608,6 +608,7 @@  init_fwd_streams(void)
 	portid_t pid;
 	struct rte_port *port;
 	streamid_t sm_id, nb_fwd_streams_new;
+	queueid_t q;
 
 	/* set socket id according to numa or not */
 	FOREACH_PORT(pid, ports) {
@@ -643,7 +644,12 @@  init_fwd_streams(void)
 		}
 	}
 
-	nb_fwd_streams_new = (streamid_t)(nb_ports * nb_rxq);
+	q = RTE_MAX(nb_rxq, nb_txq);
+	if (q == 0) {
+		printf("Fail:Cannot allocate fwd streams as number of queues is 0\n");
+		return -1;
+	}
+	nb_fwd_streams_new = (streamid_t)(nb_ports * q);
 	if (nb_fwd_streams_new == nb_fwd_streams)
 		return 0;
 	/* clear the old */
@@ -955,6 +961,12 @@  start_packet_forwarding(int with_tx_first)
 	portid_t   pt_id;
 	streamid_t sm_id;
 
+	if (strcmp(cur_fwd_eng->fwd_mode_name, "rxonly") == 0 && !nb_rxq)
+		rte_exit(EXIT_FAILURE, "rxq are 0, cannot use rxonly fwd mode\n");
+
+	if (strcmp(cur_fwd_eng->fwd_mode_name, "txonly") == 0 && !nb_txq)
+		rte_exit(EXIT_FAILURE, "txq are 0, cannot use txonly fwd mode\n");
+
 	if (all_ports_started() == 0) {
 		printf("Not all ports were started\n");
 		return;
@@ -2037,6 +2049,9 @@  main(int argc, char** argv)
 	if (argc > 1)
 		launch_args_parse(argc, argv);
 
+	if (!nb_rxq && !nb_txq)
+		printf("Warning: Either rx or tx queues should be non-zero\n");
+
 	if (nb_rxq > nb_txq)
 		printf("Warning: nb_rxq=%d enables RSS configuration, "
 		       "but nb_txq=%d will prevent to fully test it.\n",