From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id E093058DB for ; Wed, 2 Dec 2015 18:18:10 +0100 (CET) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga103.fm.intel.com with ESMTP; 02 Dec 2015 09:18:01 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,374,1444719600"; d="scan'208";a="698887551" Received: from dwdohert-dpdk.ir.intel.com ([163.33.213.167]) by orsmga003.jf.intel.com with ESMTP; 02 Dec 2015 09:18:01 -0800 From: Declan Doherty To: dev@dpdk.org Date: Wed, 2 Dec 2015 17:16:44 +0000 Message-Id: <1449076604-26628-1-git-send-email-declan.doherty@intel.com> X-Mailer: git-send-email 2.5.0 Subject: [dpdk-dev] [PATCH] l2fwd-crypto: fix behaviour of -t option X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Dec 2015 17:18:11 -0000 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 Signed-off-by: Declan Doherty --- 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