From patchwork Fri Jul 1 10:28:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Pattan, Reshma" X-Patchwork-Id: 14490 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id A88342C2C; Fri, 1 Jul 2016 12:28:23 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 514422BAB for ; Fri, 1 Jul 2016 12:28:22 +0200 (CEST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga102.fm.intel.com with ESMTP; 01 Jul 2016 03:28:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,556,1459839600"; d="scan'208";a="727855549" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by FMSMGA003.fm.intel.com with ESMTP; 01 Jul 2016 03:28:20 -0700 Received: from sivswdev02.ir.intel.com (sivswdev02.ir.intel.com [10.237.217.46]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id u61ASJ0L009191; Fri, 1 Jul 2016 11:28:20 +0100 Received: from sivswdev02.ir.intel.com (localhost [127.0.0.1]) by sivswdev02.ir.intel.com with ESMTP id u61ASJlo015671; Fri, 1 Jul 2016 11:28:19 +0100 Received: (from reshmapa@localhost) by sivswdev02.ir.intel.com with id u61ASJDj015667; Fri, 1 Jul 2016 11:28:19 +0100 From: Reshma Pattan To: dev@dpdk.org Cc: Reshma Pattan Date: Fri, 1 Jul 2016 11:28:16 +0100 Message-Id: <1467368896-15633-1-git-send-email-reshma.pattan@intel.com> X-Mailer: git-send-email 1.7.4.1 Subject: [dpdk-dev] [PATCH] app/testpmd: add timer based fwd Rx queue flushing 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 Acked-by: Pablo de Lara --- 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 */