DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] l2fwd-crypto: fix behaviour of -t option
@ 2015-12-02 17:16 Declan Doherty
  2015-12-02 17:39 ` Declan Doherty
  0 siblings, 1 reply; 3+ messages in thread
From: Declan Doherty @ 2015-12-02 17:16 UTC (permalink / raw)
  To: dev

passing -t 0 as a command line argument causes the application
to exit with an "invalid refresh period specified" error  which is
contrary to applications help text.

This patch removes the unnecessary option "--no-stats" and fixes the
behaviour of the -t parameter.

Reported-by: Min Cao <min.cao@intel.com>
Signed-off-by: Declan Doherty <declan.doherty@intel.com>
---
 examples/l2fwd-crypto/main.c | 29 ++++++++++-------------------
 1 file changed, 10 insertions(+), 19 deletions(-)

diff --git a/examples/l2fwd-crypto/main.c b/examples/l2fwd-crypto/main.c
index 0b4414b..d70fc9a 100644
--- a/examples/l2fwd-crypto/main.c
+++ b/examples/l2fwd-crypto/main.c
@@ -118,7 +118,6 @@ struct l2fwd_crypto_options {
 	unsigned nb_ports_per_lcore;
 	unsigned refresh_period;
 	unsigned single_lcore:1;
-	unsigned no_stats_printing:1;
 
 	enum rte_cryptodev_type cdev_type;
 	unsigned sessionless:1;
@@ -575,10 +574,9 @@ l2fwd_main_loop(struct l2fwd_crypto_options *options)
 						(uint64_t)timer_period)) {
 
 					/* do this only on master core */
-					if (lcore_id == rte_get_master_lcore() &&
-							!options->no_stats_printing) {
+					if (lcore_id == rte_get_master_lcore()
+						&& options->refresh_period) {
 						print_stats();
-						/* reset the timer */
 						timer_tsc = 0;
 					}
 				}
@@ -802,11 +800,6 @@ static int
 l2fwd_crypto_parse_args_long_options(struct l2fwd_crypto_options *options,
 		struct option *lgopts, int option_index)
 {
-	if (strcmp(lgopts[option_index].name, "no_stats") == 0) {
-		options->no_stats_printing = 1;
-		return 0;
-	}
-
 	if (strcmp(lgopts[option_index].name, "cdev_type") == 0)
 		return parse_cryptodev_type(&options->cdev_type, optarg);
 
@@ -903,21 +896,21 @@ l2fwd_crypto_parse_timer_period(struct l2fwd_crypto_options *options,
 		const char *q_arg)
 {
 	char *end = NULL;
-	int n;
+	long int n;
 
 	/* parse number string */
 	n = strtol(q_arg, &end, 10);
 	if ((q_arg[0] == '\0') || (end == NULL) || (*end != '\0'))
 		n = 0;
 
-	if (n >= MAX_TIMER_PERIOD)
-		n = 0;
+	if (n >= MAX_TIMER_PERIOD) {
+		printf("Warning refresh period specified %ld is greater than "
+				"max value %d! using max value",
+				n, MAX_TIMER_PERIOD);
+		n = MAX_TIMER_PERIOD;
+	}
 
 	options->refresh_period = n * 1000 * TIMER_MILLISECOND;
-	if (options->refresh_period == 0) {
-		printf("invalid refresh period specified\n");
-		return -1;
-	}
 
 	return 0;
 }
@@ -932,7 +925,6 @@ l2fwd_crypto_default_options(struct l2fwd_crypto_options *options)
 	options->nb_ports_per_lcore = 1;
 	options->refresh_period = 10000;
 	options->single_lcore = 0;
-	options->no_stats_printing = 0;
 
 	options->cdev_type = RTE_CRYPTODEV_AESNI_MB_PMD;
 	options->sessionless = 0;
@@ -979,7 +971,7 @@ l2fwd_crypto_options_print(struct l2fwd_crypto_options *options)
 	printf("single lcore mode: %s\n",
 			options->single_lcore ? "enabled" : "disabled");
 	printf("stats_printing: %s\n",
-			options->no_stats_printing ? "disabled" : "enabled");
+			options->refresh_period == 0 ? "disabled" : "enabled");
 
 	switch (options->cdev_type) {
 	case RTE_CRYPTODEV_AESNI_MB_PMD:
@@ -1036,7 +1028,6 @@ l2fwd_crypto_parse_args(struct l2fwd_crypto_options *options,
 	char **argvopt = argv, *prgname = argv[0];
 
 	static struct option lgopts[] = {
-			{ "no_stats", no_argument, 0, 0 },
 			{ "sessionless", no_argument, 0, 0 },
 
 			{ "cdev_type", required_argument, 0, 0 },
-- 
2.5.0

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-dev] [PATCH] l2fwd-crypto: fix behaviour of -t option
  2015-12-02 17:16 [dpdk-dev] [PATCH] l2fwd-crypto: fix behaviour of -t option Declan Doherty
@ 2015-12-02 17:39 ` Declan Doherty
  2015-12-07  1:59   ` Thomas Monjalon
  0 siblings, 1 reply; 3+ messages in thread
From: Declan Doherty @ 2015-12-02 17:39 UTC (permalink / raw)
  To: dev

On 02/12/15 17:16, Declan Doherty wrote:
> passing -t 0 as a command line argument causes the application
> to exit with an "invalid refresh period specified" error  which is
> contrary to applications help text.
>
> This patch removes the unnecessary option "--no-stats" and fixes the
> behaviour of the -t parameter.
>
> Reported-by: Min Cao <min.cao@intel.com>
> Signed-off-by: Declan Doherty <declan.doherty@intel.com>
> ---
>   examples/l2fwd-crypto/main.c | 29 ++++++++++-------------------
>   1 file changed, 10 insertions(+), 19 deletions(-)
>
> diff --git a/examples/l2fwd-crypto/main.c b/examples/l2fwd-crypto/main.c
> index 0b4414b..d70fc9a 100644
> --- a/examples/l2fwd-crypto/main.c
> +++ b/examples/l2fwd-crypto/main.c
> @@ -118,7 +118,6 @@ struct l2fwd_crypto_options {
>   	unsigned nb_ports_per_lcore;
>   	unsigned refresh_period;
>   	unsigned single_lcore:1;
> -	unsigned no_stats_printing:1;
>
>   	enum rte_cryptodev_type cdev_type;
>   	unsigned sessionless:1;
> @@ -575,10 +574,9 @@ l2fwd_main_loop(struct l2fwd_crypto_options *options)
>   						(uint64_t)timer_period)) {
>
>   					/* do this only on master core */
> -					if (lcore_id == rte_get_master_lcore() &&
> -							!options->no_stats_printing) {
> +					if (lcore_id == rte_get_master_lcore()
> +						&& options->refresh_period) {
>   						print_stats();
> -						/* reset the timer */
>   						timer_tsc = 0;
>   					}
>   				}
> @@ -802,11 +800,6 @@ static int
>   l2fwd_crypto_parse_args_long_options(struct l2fwd_crypto_options *options,
>   		struct option *lgopts, int option_index)
>   {
> -	if (strcmp(lgopts[option_index].name, "no_stats") == 0) {
> -		options->no_stats_printing = 1;
> -		return 0;
> -	}
> -
>   	if (strcmp(lgopts[option_index].name, "cdev_type") == 0)
>   		return parse_cryptodev_type(&options->cdev_type, optarg);
>
> @@ -903,21 +896,21 @@ l2fwd_crypto_parse_timer_period(struct l2fwd_crypto_options *options,
>   		const char *q_arg)
>   {
>   	char *end = NULL;
> -	int n;
> +	long int n;
>
>   	/* parse number string */
>   	n = strtol(q_arg, &end, 10);
>   	if ((q_arg[0] == '\0') || (end == NULL) || (*end != '\0'))
>   		n = 0;
>
> -	if (n >= MAX_TIMER_PERIOD)
> -		n = 0;
> +	if (n >= MAX_TIMER_PERIOD) {
> +		printf("Warning refresh period specified %ld is greater than "
> +				"max value %d! using max value",
> +				n, MAX_TIMER_PERIOD);
> +		n = MAX_TIMER_PERIOD;
> +	}
>
>   	options->refresh_period = n * 1000 * TIMER_MILLISECOND;
> -	if (options->refresh_period == 0) {
> -		printf("invalid refresh period specified\n");
> -		return -1;
> -	}
>
>   	return 0;
>   }
> @@ -932,7 +925,6 @@ l2fwd_crypto_default_options(struct l2fwd_crypto_options *options)
>   	options->nb_ports_per_lcore = 1;
>   	options->refresh_period = 10000;
>   	options->single_lcore = 0;
> -	options->no_stats_printing = 0;
>
>   	options->cdev_type = RTE_CRYPTODEV_AESNI_MB_PMD;
>   	options->sessionless = 0;
> @@ -979,7 +971,7 @@ l2fwd_crypto_options_print(struct l2fwd_crypto_options *options)
>   	printf("single lcore mode: %s\n",
>   			options->single_lcore ? "enabled" : "disabled");
>   	printf("stats_printing: %s\n",
> -			options->no_stats_printing ? "disabled" : "enabled");
> +			options->refresh_period == 0 ? "disabled" : "enabled");
>
>   	switch (options->cdev_type) {
>   	case RTE_CRYPTODEV_AESNI_MB_PMD:
> @@ -1036,7 +1028,6 @@ l2fwd_crypto_parse_args(struct l2fwd_crypto_options *options,
>   	char **argvopt = argv, *prgname = argv[0];
>
>   	static struct option lgopts[] = {
> -			{ "no_stats", no_argument, 0, 0 },
>   			{ "sessionless", no_argument, 0, 0 },
>
>   			{ "cdev_type", required_argument, 0, 0 },
>

I forgot to specify the commit this patch fixes in the commit message.

"fixes: 387259bd6c6733ec0ff8dfead0b555dc57402aa1"

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-dev] [PATCH] l2fwd-crypto: fix behaviour of -t option
  2015-12-02 17:39 ` Declan Doherty
@ 2015-12-07  1:59   ` Thomas Monjalon
  0 siblings, 0 replies; 3+ messages in thread
From: Thomas Monjalon @ 2015-12-07  1:59 UTC (permalink / raw)
  To: Declan Doherty; +Cc: dev

2015-12-02 17:39, Declan Doherty:
> On 02/12/15 17:16, Declan Doherty wrote:
> > passing -t 0 as a command line argument causes the application
> > to exit with an "invalid refresh period specified" error  which is
> > contrary to applications help text.
> >
> > This patch removes the unnecessary option "--no-stats" and fixes the
> > behaviour of the -t parameter.
> >
> > Reported-by: Min Cao <min.cao@intel.com>
> > Signed-off-by: Declan Doherty <declan.doherty@intel.com>

Applied, thanks

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-12-07  2:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-02 17:16 [dpdk-dev] [PATCH] l2fwd-crypto: fix behaviour of -t option Declan Doherty
2015-12-02 17:39 ` Declan Doherty
2015-12-07  1:59   ` Thomas Monjalon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).