]> git.droids-corp.org - dpdk.git/commitdiff
net/iavf: fix mbuf release in multi-process
authorKe Zhang <ke1x.zhang@intel.com>
Thu, 19 May 2022 07:36:04 +0000 (07:36 +0000)
committerQi Zhang <qi.z.zhang@intel.com>
Tue, 24 May 2022 02:53:37 +0000 (04:53 +0200)
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 <ke1x.zhang@intel.com>
Acked-by: Qi Zhang <qi.z.zhang@intel.com>
drivers/net/iavf/iavf_rxtx.c
drivers/net/iavf/iavf_rxtx.h
drivers/net/iavf/iavf_rxtx_vec_avx512.c
drivers/net/iavf/iavf_rxtx_vec_sse.c

index 73e49602574bfe16e4d9e65457bc40ad5f4bb4f0..ff0c98ffc367b866262f1f54a3948388bcb832fc 100644 (file)
@@ -362,12 +362,24 @@ 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,
+#ifdef CC_AVX512_SUPPORT
+       [IAVF_REL_MBUFS_AVX512_VEC].release_mbufs = iavf_tx_queue_release_mbufs_avx512,
+#endif
+#endif
+
 };
 
 static inline void
@@ -681,7 +693,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 "
@@ -821,7 +833,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 =
@@ -953,7 +965,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;
 
@@ -981,7 +993,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;
 
@@ -996,7 +1008,7 @@ iavf_dev_rx_queue_release(struct rte_eth_dev *dev, uint16_t qid)
        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);
@@ -1010,7 +1022,7 @@ iavf_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid)
        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);
@@ -1044,7 +1056,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;
        }
@@ -1052,7 +1064,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;
        }
index 642b9a700a822892833f47f3be58a0021e3aff1b..e8362bbd1d1912e476e6127bdc539e7fc773ed4a 100644 (file)
@@ -190,6 +190,7 @@ struct iavf_rx_queue {
        struct rte_mbuf *pkt_last_seg;  /* last segment of current packet */
        struct rte_mbuf fake_mbuf;      /* dummy mbuf */
        uint8_t rxdid;
+       uint8_t rel_mbufs_type;
 
        /* used for VPMD */
        uint16_t rxrearm_nb;       /* number of remaining to be re-armed */
@@ -249,6 +250,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;
@@ -392,6 +394,12 @@ struct iavf_32b_rx_flex_desc_comms_ipsec {
        __le32 ipsec_said;
 };
 
+enum iavf_rxtx_rel_mbufs_type {
+       IAVF_REL_MBUFS_DEFAULT          = 0,
+       IAVF_REL_MBUFS_SSE_VEC          = 1,
+       IAVF_REL_MBUFS_AVX512_VEC       = 2,
+};
+
 /* Receive Flex Descriptor profile IDs: There are a total
  * of 64 profiles where profile IDs 0/1 are for legacy; and
  * profiles 2-63 are flex profiles that can be programmed
@@ -695,6 +703,9 @@ int iavf_txq_vec_setup_avx512(struct iavf_tx_queue *txq);
 uint8_t iavf_proto_xtr_type_to_rxdid(uint8_t xtr_type);
 
 void iavf_set_default_ptype_table(struct rte_eth_dev *dev);
+void iavf_tx_queue_release_mbufs_avx512(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,
index 7319d4cb65ad24f8d7b33c715a8497c741ef8d56..3bfec638514bf14aec98fc8e9d73580937c12f4a 100644 (file)
@@ -1992,7 +1992,7 @@ iavf_xmit_pkts_vec_avx512(void *tx_queue, struct rte_mbuf **tx_pkts,
        return iavf_xmit_pkts_vec_avx512_cmn(tx_queue, tx_pkts, nb_pkts, false);
 }
 
-static inline void
+void __rte_cold
 iavf_tx_queue_release_mbufs_avx512(struct iavf_tx_queue *txq)
 {
        unsigned int i;
@@ -2012,14 +2012,10 @@ iavf_tx_queue_release_mbufs_avx512(struct iavf_tx_queue *txq)
        }
 }
 
-static const struct iavf_txq_ops avx512_vec_txq_ops = {
-       .release_mbufs = iavf_tx_queue_release_mbufs_avx512,
-};
-
 int __rte_cold
 iavf_txq_vec_setup_avx512(struct iavf_tx_queue *txq)
 {
-       txq->ops = &avx512_vec_txq_ops;
+       txq->rel_mbufs_type = IAVF_REL_MBUFS_AVX512_VEC;
        return 0;
 }
 
index 717a227b2c1dc6e5a0990bfd5e6b04c811a9f305..4a5232c1d20d5989662452c30dd1ed1fdacd8b50 100644 (file)
@@ -1198,37 +1198,29 @@ iavf_xmit_pkts_vec(void *tx_queue, struct rte_mbuf **tx_pkts,
        return nb_tx;
 }
 
-static void __rte_cold
+void __rte_cold
 iavf_rx_queue_release_mbufs_sse(struct iavf_rx_queue *rxq)
 {
        _iavf_rx_queue_release_mbufs_vec(rxq);
 }
 
-static void __rte_cold
+void __rte_cold
 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 __rte_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 __rte_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);
 }