From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 795F91DB1 for ; Fri, 4 Nov 2016 01:02:55 +0100 (CET) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga101.fm.intel.com with ESMTP; 03 Nov 2016 17:02:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,589,1473145200"; d="scan'208";a="187412802" Received: from sie-lab-214-036.ir.intel.com (HELO sie-lab-214-36.ir.intel.com) ([10.237.214.36]) by fmsmga004.fm.intel.com with ESMTP; 03 Nov 2016 17:02:43 -0700 From: Pablo de Lara To: dev@dpdk.org Cc: Pablo de Lara Date: Fri, 4 Nov 2016 00:04:10 +0000 Message-Id: <1478217850-77177-1-git-send-email-pablo.de.lara.guarch@intel.com> X-Mailer: git-send-email 2.5.5 Subject: [dpdk-dev] [PATCH] examples/l3fwd-power: fix inappropiate Rx queue count method 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: Fri, 04 Nov 2016 00:02:56 -0000 Since commit b4f3c136a179 ("net/ixgbe: support checksum flags in SSE vector Rx"), when HW IP Checksum is enabled, the RX vector function is available to use. In case of L3fwd-power, since it is enabled, the RX vector function was not used, but after this commit, it is. This has affected the way to calculate how full an RX queue is, using rte_eth_rx_descriptor done function, making the frequency to be at maximum, even when the frequency is very low. This commit reverts the way to know how full a queue is to the previous way, using rte_eth_rx_queue_count(), making it work for both vector and scalar RX functions. Fixes: b451aa39db31 ("examples/l3fwd-power: use DD bit rather than RX queue count") Signed-off-by: Pablo de Lara --- examples/l3fwd-power/main.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/examples/l3fwd-power/main.c b/examples/l3fwd-power/main.c index b65d683..74369bb 100644 --- a/examples/l3fwd-power/main.c +++ b/examples/l3fwd-power/main.c @@ -370,7 +370,7 @@ static struct rte_timer power_timers[RTE_MAX_LCORE]; static inline uint32_t power_idle_heuristic(uint32_t zero_rx_packet_count); static inline enum freq_scale_hint_t power_freq_scaleup_heuristic( \ - unsigned lcore_id, uint8_t port_id, uint16_t queue_id); + unsigned lcore_id, uint32_t rx_queue_count); /* exit signal handler */ static void @@ -705,9 +705,7 @@ power_idle_heuristic(uint32_t zero_rx_packet_count) } static inline enum freq_scale_hint_t -power_freq_scaleup_heuristic(unsigned lcore_id, - uint8_t port_id, - uint16_t queue_id) +power_freq_scaleup_heuristic(unsigned lcore_id, uint32_t rx_queue_count) { /** * HW Rx queue size is 128 by default, Rx burst read at maximum 32 entries @@ -720,15 +718,12 @@ power_freq_scaleup_heuristic(unsigned lcore_id, #define FREQ_UP_TREND2_ACC 100 #define FREQ_UP_THRESHOLD 10000 - if (likely(rte_eth_rx_descriptor_done(port_id, queue_id, - FREQ_GEAR3_RX_PACKET_THRESHOLD) > 0)) { + if (likely(rx_queue_count > FREQ_GEAR3_RX_PACKET_THRESHOLD)) { stats[lcore_id].trend = 0; return FREQ_HIGHEST; - } else if (likely(rte_eth_rx_descriptor_done(port_id, queue_id, - FREQ_GEAR2_RX_PACKET_THRESHOLD) > 0)) + } else if (likely(rx_queue_count > FREQ_GEAR2_RX_PACKET_THRESHOLD)) stats[lcore_id].trend += FREQ_UP_TREND2_ACC; - else if (likely(rte_eth_rx_descriptor_done(port_id, queue_id, - FREQ_GEAR1_RX_PACKET_THRESHOLD) > 0)) + else if (likely(rx_queue_count > FREQ_GEAR1_RX_PACKET_THRESHOLD)) stats[lcore_id].trend += FREQ_UP_TREND1_ACC; if (likely(stats[lcore_id].trend > FREQ_UP_THRESHOLD)) { @@ -833,6 +828,7 @@ main_loop(__attribute__((unused)) void *dummy) enum freq_scale_hint_t lcore_scaleup_hint; uint32_t lcore_rx_idle_count = 0; uint32_t lcore_idle_hint = 0; + uint32_t rx_ring_length; int intr_en = 0; const uint64_t drain_tsc = (rte_get_tsc_hz() + US_PER_S - 1) / US_PER_S * BURST_TX_DRAIN_US; @@ -923,6 +919,18 @@ start_rx: rx_queue->zero_rx_packet_count = 0; /** + * get available descriptor number via + * MMIO read is costly, so only do it when + * recent poll returns maximum number. + */ + if (nb_rx >= MAX_PKT_BURST) + rx_ring_length = + rte_eth_rx_queue_count(portid, + queueid); + else + rx_ring_length = 0; + + /** * do not scale up frequency immediately as * user to kernel space communication is costly * which might impact packet I/O for received @@ -930,7 +938,7 @@ start_rx: */ rx_queue->freq_up_hint = power_freq_scaleup_heuristic(lcore_id, - portid, queueid); + rx_ring_length); } /* Prefetch first packets */ -- 2.5.5