From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B99C74612D; Fri, 24 Jan 2025 17:31:47 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7A46E42DC9; Fri, 24 Jan 2025 17:30:10 +0100 (CET) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by mails.dpdk.org (Postfix) with ESMTP id BCFDF42DCA for ; Fri, 24 Jan 2025 17:30:08 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1737736209; x=1769272209; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=R+pDuMySvuWPi3ITMU6aRQ3SkIHq70yXDpVB9WT+XUs=; b=T01wPCXKyaGOjlemIT1CQLPcDETkLp9IP117+HVr/L0SN2KJJcQeCB4T LR2Bw9fR4liWD2RvsYuxJOIJd1rhjJ6S5F1iiWkKVVWYCdKBXAmrnmtJG iVHUC1Vnakeeug/klmtGNP9WUx39RKYnw0nS2SKH04gSK/Je25XskhM8N xCPDMs42xelX0GtUTypJk+Bsr029s9xxECRFiie+6qfoiH7qvDo1C07Hu Lxo0nQNI9AQzEefx6pHGTMMQfFQ9FlNiN1mTtGk4A10XoXyIxYIWzRhfL CJfJ8eiIcziK2LEI51n3xK4J0FmyaaipgkXyGKtXNfvzu8KY1Dqhpmttm A==; X-CSE-ConnectionGUID: MMik5UPsTtmrRRIms82mBA== X-CSE-MsgGUID: FLGv3tBxQ12v2O9MjCC8+w== X-IronPort-AV: E=McAfee;i="6700,10204,11325"; a="60740258" X-IronPort-AV: E=Sophos;i="6.13,231,1732608000"; d="scan'208";a="60740258" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jan 2025 08:30:08 -0800 X-CSE-ConnectionGUID: 9IN2oT2fTuWDWFelw8Ejmw== X-CSE-MsgGUID: zNBYiPYEQkmL4Tv57txekw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.13,231,1732608000"; d="scan'208";a="108352650" Received: from silpixa00401197coob.ir.intel.com (HELO silpixa00401385.ir.intel.com) ([10.237.214.45]) by fmviesa010.fm.intel.com with ESMTP; 24 Jan 2025 08:30:06 -0800 From: Bruce Richardson To: dev@dpdk.org Cc: david.marchand@redhat.com, anatoly.burakov@intel.com, vladimir.medvedkin@intel.com, ian.stokes@intel.com, praveen.shetty@intel.com, Bruce Richardson Subject: [PATCH v6 16/25] net/i40e: use common Tx queue mbuf cleanup fn Date: Fri, 24 Jan 2025 16:29:11 +0000 Message-ID: <20250124162921.1406103-17-bruce.richardson@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250124162921.1406103-1-bruce.richardson@intel.com> References: <20241122125418.2857301-1-bruce.richardson@intel.com> <20250124162921.1406103-1-bruce.richardson@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Update driver to be similar to the "ice" driver and use the common mbuf ring cleanup code on shutdown of a Tx queue. Signed-off-by: Bruce Richardson --- drivers/net/intel/i40e/i40e_ethdev.h | 4 +- drivers/net/intel/i40e/i40e_rxtx.c | 70 +++------------------------- drivers/net/intel/i40e/i40e_rxtx.h | 1 - 3 files changed, 9 insertions(+), 66 deletions(-) diff --git a/drivers/net/intel/i40e/i40e_ethdev.h b/drivers/net/intel/i40e/i40e_ethdev.h index d351193ed9..ccc8732d7d 100644 --- a/drivers/net/intel/i40e/i40e_ethdev.h +++ b/drivers/net/intel/i40e/i40e_ethdev.h @@ -1260,12 +1260,12 @@ struct i40e_adapter { /* For RSS reta table update */ uint8_t rss_reta_updated; -#ifdef RTE_ARCH_X86 + + /* used only on x86, zero on other architectures */ bool rx_use_avx2; bool rx_use_avx512; bool tx_use_avx2; bool tx_use_avx512; -#endif }; /** diff --git a/drivers/net/intel/i40e/i40e_rxtx.c b/drivers/net/intel/i40e/i40e_rxtx.c index 539b170266..b70919c5dc 100644 --- a/drivers/net/intel/i40e/i40e_rxtx.c +++ b/drivers/net/intel/i40e/i40e_rxtx.c @@ -1875,6 +1875,7 @@ i40e_dev_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id) int err; struct ci_tx_queue *txq; struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private); + const struct i40e_adapter *ad = I40E_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private); PMD_INIT_FUNC_TRACE(); @@ -1889,6 +1890,9 @@ i40e_dev_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id) PMD_DRV_LOG(WARNING, "TX queue %u is deferred start", tx_queue_id); + txq->vector_tx = ad->tx_vec_allowed; + txq->vector_sw_ring = ad->tx_use_avx512; + /* * tx_queue_id is queue id application refers to, while * rxq->reg_idx is the real queue index. @@ -1929,7 +1933,7 @@ i40e_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id) return err; } - i40e_tx_queue_release_mbufs(txq); + ci_txq_release_all_mbufs(txq); i40e_reset_tx_queue(txq); dev->data->tx_queue_state[tx_queue_id] = RTE_ETH_QUEUE_STATE_STOPPED; @@ -2604,7 +2608,7 @@ i40e_tx_queue_release(void *txq) return; } - i40e_tx_queue_release_mbufs(q); + ci_txq_release_all_mbufs(q); rte_free(q->sw_ring); rte_memzone_free(q->mz); rte_free(q); @@ -2701,66 +2705,6 @@ i40e_reset_rx_queue(struct i40e_rx_queue *rxq) rxq->rxrearm_nb = 0; } -void -i40e_tx_queue_release_mbufs(struct ci_tx_queue *txq) -{ - struct rte_eth_dev *dev; - uint16_t i; - - if (!txq || !txq->sw_ring) { - PMD_DRV_LOG(DEBUG, "Pointer to txq or sw_ring is NULL"); - return; - } - - dev = &rte_eth_devices[txq->port_id]; - - /** - * vPMD tx will not set sw_ring's mbuf to NULL after free, - * so need to free remains more carefully. - */ -#ifdef CC_AVX512_SUPPORT - if (dev->tx_pkt_burst == i40e_xmit_pkts_vec_avx512) { - struct ci_tx_entry_vec *swr = (void *)txq->sw_ring; - - i = txq->tx_next_dd - txq->tx_rs_thresh + 1; - if (txq->tx_tail < i) { - for (; i < txq->nb_tx_desc; i++) { - rte_pktmbuf_free_seg(swr[i].mbuf); - swr[i].mbuf = NULL; - } - i = 0; - } - for (; i < txq->tx_tail; i++) { - rte_pktmbuf_free_seg(swr[i].mbuf); - swr[i].mbuf = NULL; - } - return; - } -#endif - if (dev->tx_pkt_burst == i40e_xmit_pkts_vec_avx2 || - dev->tx_pkt_burst == i40e_xmit_pkts_vec) { - i = txq->tx_next_dd - txq->tx_rs_thresh + 1; - if (txq->tx_tail < i) { - for (; i < txq->nb_tx_desc; i++) { - rte_pktmbuf_free_seg(txq->sw_ring[i].mbuf); - txq->sw_ring[i].mbuf = NULL; - } - i = 0; - } - for (; i < txq->tx_tail; i++) { - rte_pktmbuf_free_seg(txq->sw_ring[i].mbuf); - txq->sw_ring[i].mbuf = NULL; - } - } else { - for (i = 0; i < txq->nb_tx_desc; i++) { - if (txq->sw_ring[i].mbuf) { - rte_pktmbuf_free_seg(txq->sw_ring[i].mbuf); - txq->sw_ring[i].mbuf = NULL; - } - } - } -} - static int i40e_tx_done_cleanup_full(struct ci_tx_queue *txq, uint32_t free_cnt) @@ -3127,7 +3071,7 @@ i40e_dev_clear_queues(struct rte_eth_dev *dev) for (i = 0; i < dev->data->nb_tx_queues; i++) { if (!dev->data->tx_queues[i]) continue; - i40e_tx_queue_release_mbufs(dev->data->tx_queues[i]); + ci_txq_release_all_mbufs(dev->data->tx_queues[i]); i40e_reset_tx_queue(dev->data->tx_queues[i]); } diff --git a/drivers/net/intel/i40e/i40e_rxtx.h b/drivers/net/intel/i40e/i40e_rxtx.h index c6d1bb53d0..2f32fc5686 100644 --- a/drivers/net/intel/i40e/i40e_rxtx.h +++ b/drivers/net/intel/i40e/i40e_rxtx.h @@ -179,7 +179,6 @@ void i40e_dev_clear_queues(struct rte_eth_dev *dev); void i40e_dev_free_queues(struct rte_eth_dev *dev); void i40e_reset_rx_queue(struct i40e_rx_queue *rxq); void i40e_reset_tx_queue(struct ci_tx_queue *txq); -void i40e_tx_queue_release_mbufs(struct ci_tx_queue *txq); int i40e_tx_done_cleanup(void *txq, uint32_t free_cnt); int i40e_alloc_rx_queue_mbufs(struct i40e_rx_queue *rxq); void i40e_rx_queue_release_mbufs(struct i40e_rx_queue *rxq); -- 2.43.0