From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 0F4EA5677 for ; Wed, 25 Mar 2015 11:48:25 +0100 (CET) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga102.fm.intel.com with ESMTP; 25 Mar 2015 03:48:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.11,465,1422950400"; d="scan'208";a="546034832" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by orsmga003.jf.intel.com with ESMTP; 25 Mar 2015 03:48:24 -0700 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id t2PAmMaB009890; Wed, 25 Mar 2015 18:48:22 +0800 Received: from shecgisg004.sh.intel.com (localhost [127.0.0.1]) by shecgisg004.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id t2PAmJnd013711; Wed, 25 Mar 2015 18:48:21 +0800 Received: (from dayuqiu@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id t2PAmJm9013707; Wed, 25 Mar 2015 18:48:19 +0800 From: Michael Qiu To: dev@dpdk.org Date: Wed, 25 Mar 2015 18:48:18 +0800 Message-Id: <1427280498-13677-1-git-send-email-michael.qiu@intel.com> X-Mailer: git-send-email 1.7.4.1 Subject: [dpdk-dev] [PATCH] fm10k: Fix queue start twice failed 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, 25 Mar 2015 10:48:26 -0000 When use "port 0 rxq 0 start" in testpmd twice, the rx queue 0 on port 0 will failed to work. The root casue is the rxqctl enable bit need to reset if already enabled. Signed-off-by: Michael Qiu --- lib/librte_pmd_fm10k/fm10k_ethdev.c | 56 +++++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 24 deletions(-) diff --git a/lib/librte_pmd_fm10k/fm10k_ethdev.c b/lib/librte_pmd_fm10k/fm10k_ethdev.c index 0c7a80c..0312fad 100644 --- a/lib/librte_pmd_fm10k/fm10k_ethdev.c +++ b/lib/librte_pmd_fm10k/fm10k_ethdev.c @@ -72,6 +72,30 @@ fm10k_mbx_unlock(struct fm10k_hw *hw) } /* + * clean queue, descriptor rings, free software buffers used when stopping + * device. + */ +static inline void +rx_queue_clean(struct fm10k_rx_queue *q) +{ + union fm10k_rx_desc zero = {.q = {0, 0, 0, 0} }; + uint32_t i; + PMD_INIT_FUNC_TRACE(); + + /* zero descriptor rings */ + for (i = 0; i < q->nb_desc; ++i) + q->hw_ring[i] = zero; + + /* free software buffers */ + for (i = 0; i < q->nb_desc; ++i) { + if (q->sw_ring[i]) { + rte_pktmbuf_free_seg(q->sw_ring[i]); + q->sw_ring[i] = NULL; + } + } +} + +/* * reset queue to initial state, allocate software buffers used when starting * device. * return 0 on success @@ -85,6 +109,9 @@ rx_queue_reset(struct fm10k_rx_queue *q) int i, diag; PMD_INIT_FUNC_TRACE(); + /* clean the memory before allocate */ + rx_queue_clean(q); + diag = rte_mempool_get_bulk(q->mp, (void **)q->sw_ring, q->nb_desc); if (diag != 0) return -ENOMEM; @@ -109,30 +136,6 @@ rx_queue_reset(struct fm10k_rx_queue *q) } /* - * clean queue, descriptor rings, free software buffers used when stopping - * device. - */ -static inline void -rx_queue_clean(struct fm10k_rx_queue *q) -{ - union fm10k_rx_desc zero = {.q = {0, 0, 0, 0} }; - uint32_t i; - PMD_INIT_FUNC_TRACE(); - - /* zero descriptor rings */ - for (i = 0; i < q->nb_desc; ++i) - q->hw_ring[i] = zero; - - /* free software buffers */ - for (i = 0; i < q->nb_desc; ++i) { - if (q->sw_ring[i]) { - rte_pktmbuf_free_seg(q->sw_ring[i]); - q->sw_ring[i] = NULL; - } - } -} - -/* * free all queue memory used when releasing the queue (i.e. configure) */ static inline void @@ -492,6 +495,11 @@ fm10k_dev_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id) reg = FM10K_READ_REG(hw, FM10K_RXQCTL(rx_queue_id)); if (hw->mac.type == fm10k_mac_pf) reg |= FM10K_RXQCTL_PF; + + /* already enable? need reset to 0 */ + if ((reg & FM10K_RXQCTL_ENABLE) == 1) + FM10K_WRITE_REG(hw, FM10K_RXQCTL(rx_queue_id), (reg & ~FM10K_RXQCTL_ENABLE)); + reg |= FM10K_RXQCTL_ENABLE; /* enable RX queue */ FM10K_WRITE_REG(hw, FM10K_RXQCTL(rx_queue_id), reg); -- 1.9.3