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 6ED42A0032 for ; Wed, 20 Jul 2022 07:31:16 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 49EA340697; Wed, 20 Jul 2022 07:31:16 +0200 (CEST) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mails.dpdk.org (Postfix) with ESMTP id C44534003C for ; Wed, 20 Jul 2022 07:31:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658295074; x=1689831074; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=cqJ2R7jU09UdngdXnNL0DUvyqSdoZVMGt1EreW97inY=; b=DvmizO9kiQ/M95fMDSeBXFeP5CHlB/2LsM1DwRUQvN0EHomcjLF8S1lB 1vuGCy02RXUJKnl3ajmji32bBlmuZrj5MEFVP2xThlFJa9rhcSRhNoVoN 6fjw1qIeH0fAEXlDcCGyQyQKgeohVvlGmddWLPRe34gEvTZgym3i5cCpS EEcUNdeMB76E2y30TY0pPlpEqa3k6YFGxQW7ro/19Gi6CbnrWY7WhhAuu 57TrSVo6wuNUgUoktzrypAcFk8iG15/IYvEimzsVQ6TIZMnLa2jacpiRt ceIndcSFUBpfK2HHVYQZ2znJcWqjRkgFN90EUa/lrkp1+WGWhCKwrfOVN A==; X-IronPort-AV: E=McAfee;i="6400,9594,10413"; a="350675327" X-IronPort-AV: E=Sophos;i="5.92,286,1650956400"; d="scan'208";a="350675327" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jul 2022 22:31:13 -0700 X-IronPort-AV: E=Sophos;i="5.92,286,1650956400"; d="scan'208";a="625513064" Received: from unknown (HELO localhost.localdomain) ([10.239.252.104]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jul 2022 22:31:12 -0700 From: Ke Zhang To: stable@dpdk.org Cc: Ke Zhang Subject: [PATCH 19.11] net/iavf: net/iavf: fix mbuf release in multi-process Date: Wed, 20 Jul 2022 13:22:51 +0800 Message-Id: <20220720052251.272916-1-ke1x.zhang@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org [ upstream commit fced83c1229e0ad89f26d07fa7bd46b8767d9f5c ] In the multiple process environment, the subprocess operates on the shared memory and changes the function pointer of the main process, resulting in the failure to find the address of the function when main process releasing, resulting in crash. Fixes: 319c421f3890 ("net/avf: enable SSE Rx Tx") Cc: stable@dpdk.org Signed-off-by: Ke Zhang --- drivers/net/iavf/iavf_rxtx.c | 32 +++++++++++++++++----------- drivers/net/iavf/iavf_rxtx.h | 10 +++++++++ drivers/net/iavf/iavf_rxtx_vec_sse.c | 16 ++++---------- 3 files changed, 34 insertions(+), 24 deletions(-) diff --git a/drivers/net/iavf/iavf_rxtx.c b/drivers/net/iavf/iavf_rxtx.c index d406f0d99..eda102a5a 100644 --- a/drivers/net/iavf/iavf_rxtx.c +++ b/drivers/net/iavf/iavf_rxtx.c @@ -295,12 +295,20 @@ release_txq_mbufs(struct iavf_tx_queue *txq) } } -static const struct iavf_rxq_ops def_rxq_ops = { - .release_mbufs = release_rxq_mbufs, +static const +struct iavf_rxq_ops iavf_rxq_release_mbufs_ops[] = { + [IAVF_REL_MBUFS_DEFAULT].release_mbufs = release_rxq_mbufs, +#ifdef RTE_ARCH_X86 + [IAVF_REL_MBUFS_SSE_VEC].release_mbufs = iavf_rx_queue_release_mbufs_sse, +#endif }; -static const struct iavf_txq_ops def_txq_ops = { - .release_mbufs = release_txq_mbufs, +static const +struct iavf_txq_ops iavf_txq_release_mbufs_ops[] = { + [IAVF_REL_MBUFS_DEFAULT].release_mbufs = release_txq_mbufs, +#ifdef RTE_ARCH_X86 + [IAVF_REL_MBUFS_SSE_VEC].release_mbufs = iavf_tx_queue_release_mbufs_sse, +#endif }; int @@ -402,7 +410,7 @@ iavf_dev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx, rxq->q_set = TRUE; dev->data->rx_queues[queue_idx] = rxq; rxq->qrx_tail = hw->hw_addr + IAVF_QRX_TAIL1(rxq->queue_id); - rxq->ops = &def_rxq_ops; + rxq->rel_mbufs_type = IAVF_REL_MBUFS_DEFAULT; if (check_rx_bulk_allow(rxq) == TRUE) { PMD_INIT_LOG(DEBUG, "Rx Burst Bulk Alloc Preconditions are " @@ -513,7 +521,7 @@ iavf_dev_tx_queue_setup(struct rte_eth_dev *dev, txq->q_set = TRUE; dev->data->tx_queues[queue_idx] = txq; txq->qtx_tail = hw->hw_addr + IAVF_QTX_TAIL1(queue_idx); - txq->ops = &def_txq_ops; + txq->rel_mbufs_type = IAVF_REL_MBUFS_DEFAULT; if (check_tx_vec_allow(txq) == FALSE) { struct iavf_adapter *ad = @@ -618,7 +626,7 @@ iavf_dev_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id) } rxq = dev->data->rx_queues[rx_queue_id]; - rxq->ops->release_mbufs(rxq); + iavf_rxq_release_mbufs_ops[rxq->rel_mbufs_type].release_mbufs(rxq); reset_rx_queue(rxq); dev->data->rx_queue_state[rx_queue_id] = RTE_ETH_QUEUE_STATE_STOPPED; @@ -646,7 +654,7 @@ iavf_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id) } txq = dev->data->tx_queues[tx_queue_id]; - txq->ops->release_mbufs(txq); + iavf_txq_release_mbufs_ops[txq->rel_mbufs_type].release_mbufs(txq); reset_tx_queue(txq); dev->data->tx_queue_state[tx_queue_id] = RTE_ETH_QUEUE_STATE_STOPPED; @@ -661,7 +669,7 @@ iavf_dev_rx_queue_release(void *rxq) if (!q) return; - q->ops->release_mbufs(q); + iavf_rxq_release_mbufs_ops[q->rel_mbufs_type].release_mbufs(q); rte_free(q->sw_ring); rte_memzone_free(q->mz); rte_free(q); @@ -675,7 +683,7 @@ iavf_dev_tx_queue_release(void *txq) if (!q) return; - q->ops->release_mbufs(q); + iavf_txq_release_mbufs_ops[q->rel_mbufs_type].release_mbufs(q); rte_free(q->sw_ring); rte_memzone_free(q->mz); rte_free(q); @@ -699,7 +707,7 @@ iavf_stop_queues(struct rte_eth_dev *dev) txq = dev->data->tx_queues[i]; if (!txq) continue; - txq->ops->release_mbufs(txq); + iavf_txq_release_mbufs_ops[txq->rel_mbufs_type].release_mbufs(txq); reset_tx_queue(txq); dev->data->tx_queue_state[i] = RTE_ETH_QUEUE_STATE_STOPPED; } @@ -707,7 +715,7 @@ iavf_stop_queues(struct rte_eth_dev *dev) rxq = dev->data->rx_queues[i]; if (!rxq) continue; - rxq->ops->release_mbufs(rxq); + iavf_rxq_release_mbufs_ops[rxq->rel_mbufs_type].release_mbufs(rxq); reset_rx_queue(rxq); dev->data->rx_queue_state[i] = RTE_ETH_QUEUE_STATE_STOPPED; } diff --git a/drivers/net/iavf/iavf_rxtx.h b/drivers/net/iavf/iavf_rxtx.h index c3baf9386..6be05deb3 100644 --- a/drivers/net/iavf/iavf_rxtx.h +++ b/drivers/net/iavf/iavf_rxtx.h @@ -87,6 +87,7 @@ struct iavf_rx_queue { struct rte_mbuf *pkt_first_seg; /* first segment of current packet */ struct rte_mbuf *pkt_last_seg; /* last segment of current packet */ struct rte_mbuf fake_mbuf; /* dummy mbuf */ + uint8_t rel_mbufs_type; /* used for VPMD */ uint16_t rxrearm_nb; /* number of remaining to be re-armed */ @@ -132,6 +133,7 @@ struct iavf_tx_queue { uint16_t last_desc_cleaned; /* last desc have been cleaned*/ uint16_t free_thresh; uint16_t rs_thresh; + uint8_t rel_mbufs_type; uint16_t port_id; uint16_t queue_id; @@ -156,6 +158,12 @@ union iavf_tx_offload { }; }; +enum iavf_rxtx_rel_mbufs_type { + IAVF_REL_MBUFS_DEFAULT = 0, + IAVF_REL_MBUFS_SSE_VEC = 1, + IAVF_REL_MBUFS_AVX512_VEC = 2, +}; + int iavf_dev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx, uint16_t nb_desc, @@ -215,6 +223,8 @@ int iavf_rx_vec_dev_check(struct rte_eth_dev *dev); int iavf_tx_vec_dev_check(struct rte_eth_dev *dev); int iavf_rxq_vec_setup(struct iavf_rx_queue *rxq); int iavf_txq_vec_setup(struct iavf_tx_queue *txq); +void iavf_rx_queue_release_mbufs_sse(struct iavf_rx_queue *rxq); +void iavf_tx_queue_release_mbufs_sse(struct iavf_tx_queue *txq); static inline void iavf_dump_rx_descriptor(struct iavf_rx_queue *rxq, diff --git a/drivers/net/iavf/iavf_rxtx_vec_sse.c b/drivers/net/iavf/iavf_rxtx_vec_sse.c index aefa81ecd..3c2eed0cd 100644 --- a/drivers/net/iavf/iavf_rxtx_vec_sse.c +++ b/drivers/net/iavf/iavf_rxtx_vec_sse.c @@ -668,37 +668,29 @@ iavf_xmit_pkts_vec(void *tx_queue, struct rte_mbuf **tx_pkts, return nb_tx; } -static void __attribute__((cold)) +void iavf_rx_queue_release_mbufs_sse(struct iavf_rx_queue *rxq) { _iavf_rx_queue_release_mbufs_vec(rxq); } -static void __attribute__((cold)) +void iavf_tx_queue_release_mbufs_sse(struct iavf_tx_queue *txq) { _iavf_tx_queue_release_mbufs_vec(txq); } -static const struct iavf_rxq_ops sse_vec_rxq_ops = { - .release_mbufs = iavf_rx_queue_release_mbufs_sse, -}; - -static const struct iavf_txq_ops sse_vec_txq_ops = { - .release_mbufs = iavf_tx_queue_release_mbufs_sse, -}; - int __attribute__((cold)) iavf_txq_vec_setup(struct iavf_tx_queue *txq) { - txq->ops = &sse_vec_txq_ops; + txq->rel_mbufs_type = IAVF_REL_MBUFS_SSE_VEC; return 0; } int __attribute__((cold)) iavf_rxq_vec_setup(struct iavf_rx_queue *rxq) { - rxq->ops = &sse_vec_rxq_ops; + rxq->rel_mbufs_type = IAVF_REL_MBUFS_SSE_VEC; return iavf_rxq_vec_setup_default(rxq); } -- 2.25.1