patches for DPDK stable branches
 help / color / mirror / Atom feed
* [PATCH] examples/l2fwd-crypto: fix stats refresh rate
@ 2022-04-07 11:42 Raja Zidane
  2022-04-29 10:04 ` [EXT] " Akhil Goyal
  0 siblings, 1 reply; 2+ messages in thread
From: Raja Zidane @ 2022-04-07 11:42 UTC (permalink / raw)
  To: dev; +Cc: matan, stable

TIMER_MILLISECOND is defined as the number of cpu cycles per millisecond,
current definition is correct for cores with frequency of 2GHZ, for cores
with different frequency, it caused different periods between refresh,
(i.e. the definition is about 14ms on ARM cores).
The devarg that stated the period between stats print was not used,
instead, it was always defaulted to 10 seconds (on 2GHZ core).

Use dpdk API to get CPU frequency, to define TIMER_MILLISECOND.
Use the refresh period devarg instead of defaulting to 10s always.

Fixes: 387259bd6c67 ("examples/l2fwd-crypto: add sample application")
Cc: stable@dpdk.org

Signed-off-by: Raja Zidane <rzidane@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
---
 examples/l2fwd-crypto/main.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/examples/l2fwd-crypto/main.c b/examples/l2fwd-crypto/main.c
index bbdb263143..b1e2613ccf 100644
--- a/examples/l2fwd-crypto/main.c
+++ b/examples/l2fwd-crypto/main.c
@@ -252,11 +252,9 @@ struct l2fwd_port_statistics port_statistics[RTE_MAX_ETHPORTS];
 struct l2fwd_crypto_statistics crypto_statistics[RTE_CRYPTO_MAX_DEVS];
 
 /* A tsc-based timer responsible for triggering statistics printout */
-#define TIMER_MILLISECOND 2000000ULL /* around 1ms at 2 Ghz */
+#define TIMER_MILLISECOND (rte_get_tsc_hz() / 1000)
 #define MAX_TIMER_PERIOD 86400UL /* 1 day max */
-
-/* default period is 10 seconds */
-static int64_t timer_period = 10 * TIMER_MILLISECOND * 1000;
+#define DEFAULT_TIMER_PERIOD 10UL
 
 /* Print out statistics on packets dropped */
 static void
@@ -894,18 +892,17 @@ l2fwd_main_loop(struct l2fwd_crypto_options *options)
 			}
 
 			/* if timer is enabled */
-			if (timer_period > 0) {
+			if (options->refresh_period > 0) {
 
 				/* advance the timer */
 				timer_tsc += diff_tsc;
 
 				/* if timer has reached its timeout */
 				if (unlikely(timer_tsc >=
-						(uint64_t)timer_period)) {
+						options->refresh_period)) {
 
 					/* do this only on main core */
-					if (lcore_id == rte_get_main_lcore()
-						&& options->refresh_period) {
+					if (lcore_id == rte_get_main_lcore()) {
 						print_stats();
 						timer_tsc = 0;
 					}
@@ -1481,7 +1478,8 @@ l2fwd_crypto_default_options(struct l2fwd_crypto_options *options)
 {
 	options->portmask = 0xffffffff;
 	options->nb_ports_per_lcore = 1;
-	options->refresh_period = 10000;
+	options->refresh_period = DEFAULT_TIMER_PERIOD *
+					TIMER_MILLISECOND * 1000;
 	options->single_lcore = 0;
 	options->sessionless = 0;
 
-- 
2.21.0


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

* RE: [EXT] [PATCH] examples/l2fwd-crypto: fix stats refresh rate
  2022-04-07 11:42 [PATCH] examples/l2fwd-crypto: fix stats refresh rate Raja Zidane
@ 2022-04-29 10:04 ` Akhil Goyal
  0 siblings, 0 replies; 2+ messages in thread
From: Akhil Goyal @ 2022-04-29 10:04 UTC (permalink / raw)
  To: Raja Zidane, dev; +Cc: matan, stable

> TIMER_MILLISECOND is defined as the number of cpu cycles per millisecond,
> current definition is correct for cores with frequency of 2GHZ, for cores
> with different frequency, it caused different periods between refresh,
> (i.e. the definition is about 14ms on ARM cores).
> The devarg that stated the period between stats print was not used,
> instead, it was always defaulted to 10 seconds (on 2GHZ core).
> 
> Use dpdk API to get CPU frequency, to define TIMER_MILLISECOND.
> Use the refresh period devarg instead of defaulting to 10s always.
> 
> Fixes: 387259bd6c67 ("examples/l2fwd-crypto: add sample application")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Raja Zidane <rzidane@nvidia.com>
> Acked-by: Matan Azrad <matan@nvidia.com>
Acked-by: Akhil Goyal <gakhil@marvell.com>

Applied to dpdk-next-crypto

Thanks.

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

end of thread, other threads:[~2022-04-29 10:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-07 11:42 [PATCH] examples/l2fwd-crypto: fix stats refresh rate Raja Zidane
2022-04-29 10:04 ` [EXT] " Akhil Goyal

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).