dev.dpdk.org archive mirror
 help / color / mirror / Atom feed
From: Reshma Pattan <reshma.pattan@intel.com>
To: dev@dpdk.org
Cc: Reshma Pattan <reshma.pattan@intel.com>
Subject: [PATCH] app/testpmd: add timer based fwd Rx queue flushing
Date: Fri,  1 Jul 2016 11:28:16 +0100	[thread overview]
Message-ID: <1467368896-15633-1-git-send-email-reshma.pattan@intel.com> (raw)

Testpmd can stuck inside do while loop of the flush_fwd_rx_queues()
function. As non-zero packets are returned always by rte_eth_rx_burst()
function when compiled with no optimizations and if input line rate is
high. "do while" loop must exit at one stage to proceed further to
enable packet forwarding and forward the packets. So timer is set to
exit the do while loop after 1 second.

Fixes: af75078f ("first public release")

Signed-off-by: Reshma Pattan <reshma.pattan@intel.com>
---
 app/test-pmd/testpmd.c | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 06885ce..b7f28e9 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -272,6 +272,9 @@ uint32_t bypass_timeout = RTE_BYPASS_TMT_OFF;
 
 #endif
 
+/* default period is 1 second */
+static uint64_t timer_period = 1;
+
 /*
  * Ethernet device configuration.
  */
@@ -877,17 +880,35 @@ flush_fwd_rx_queues(void)
 	uint16_t  nb_rx;
 	uint16_t  i;
 	uint8_t   j;
+	uint64_t prev_tsc = 0, diff_tsc, cur_tsc, timer_tsc = 0;
+
+	/* convert to number of cycles */
+	timer_period *= rte_get_timer_hz();
 
 	for (j = 0; j < 2; j++) {
 		for (rxp = 0; rxp < cur_fwd_config.nb_fwd_ports; rxp++) {
 			for (rxq = 0; rxq < nb_rxq; rxq++) {
 				port_id = fwd_ports_ids[rxp];
+				/**
+				* testpmd can stuck in the below do while loop
+				* if rte_eth_rx_burst() always returns nonzero
+				* packets. So timer is added to exit this loop
+				* after 1sec timer expiry.
+				*/
+				prev_tsc = rte_rdtsc();
 				do {
 					nb_rx = rte_eth_rx_burst(port_id, rxq,
 						pkts_burst, MAX_PKT_BURST);
 					for (i = 0; i < nb_rx; i++)
 						rte_pktmbuf_free(pkts_burst[i]);
-				} while (nb_rx > 0);
+
+					cur_tsc = rte_rdtsc();
+					diff_tsc = cur_tsc - prev_tsc;
+					timer_tsc += diff_tsc;
+				} while ((nb_rx > 0) &&
+					(timer_tsc < timer_period));
+				prev_tsc = cur_tsc;
+				timer_tsc = 0;
 			}
 		}
 		rte_delay_ms(10); /* wait 10 milli-seconds before retrying */
-- 
2.5.0

             reply	other threads:[~2016-07-01 10:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-01 10:28 Reshma Pattan [this message]
2016-07-01 15:53 ` [PATCH] app/testpmd: add timer based fwd Rx queue flushing De Lara Guarch, Pablo
2016-07-11 13:35   ` 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=1467368896-15633-1-git-send-email-reshma.pattan@intel.com \
    --to=reshma.pattan@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).