DPDK patches and discussions
 help / color / mirror / Atom feed
From: Declan Doherty <declan.doherty@intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH] l2fwd-crypto: fix behaviour of -t option
Date: Wed,  2 Dec 2015 17:16:44 +0000	[thread overview]
Message-ID: <1449076604-26628-1-git-send-email-declan.doherty@intel.com> (raw)

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

             reply	other threads:[~2015-12-02 17:18 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-02 17:16 Declan Doherty [this message]
2015-12-02 17:39 ` Declan Doherty
2015-12-07  1:59   ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1449076604-26628-1-git-send-email-declan.doherty@intel.com \
    --to=declan.doherty@intel.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).