[v5,1/2] net/iavf: fix Tx path error in multi-process
Checks
Commit Message
In a multi-process environment, a secondary process operates on shared
memory and changes the PMD transmit function pointer of the primary
process, causing the primary process to send pkts without being able
to find the function address, resulting in a crash.
Fixes: 5b3124a0a6ef ("net/iavf: support no polling when link down")
Cc: stable@dpdk.org
Signed-off-by: Mingjin Ye <mingjinx.ye@intel.com>
---
drivers/net/iavf/iavf.h | 12 +++++++++++-
drivers/net/iavf/iavf_rxtx.c | 34 +++++++++++++++++++++++++++++++---
drivers/net/iavf/iavf_rxtx.h | 3 +++
3 files changed, 45 insertions(+), 4 deletions(-)
Comments
> -----Original Message-----
> From: Mingjin Ye <mingjinx.ye@intel.com>
> Sent: Thursday, December 28, 2023 6:26 PM
> To: dev@dpdk.org
> Cc: Yang, Qiming <qiming.yang@intel.com>; Ye, MingjinX
> <mingjinx.ye@intel.com>; stable@dpdk.org; Wu, Jingjing
> <jingjing.wu@intel.com>; Xing, Beilei <beilei.xing@intel.com>
> Subject: [PATCH v5 1/2] net/iavf: fix Tx path error in multi-process
>
> In a multi-process environment, a secondary process operates on shared
> memory and changes the PMD transmit function pointer of the primary
> process, causing the primary process to send pkts without being able to find
> the function address, resulting in a crash.
>
> Fixes: 5b3124a0a6ef ("net/iavf: support no polling when link down")
> Cc: stable@dpdk.org
Should Rx also need to be fixed? please make a complete fix.
>
> Signed-off-by: Mingjin Ye <mingjinx.ye@intel.com>
> ---
> drivers/net/iavf/iavf.h | 12 +++++++++++-
> drivers/net/iavf/iavf_rxtx.c | 34 +++++++++++++++++++++++++++++++---
> drivers/net/iavf/iavf_rxtx.h | 3 +++
> 3 files changed, 45 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/iavf/iavf.h b/drivers/net/iavf/iavf.h index
> 10868f2c30..4cd5bea167 100644
> --- a/drivers/net/iavf/iavf.h
> +++ b/drivers/net/iavf/iavf.h
> @@ -313,6 +313,16 @@ struct iavf_devargs {
>
> struct iavf_security_ctx;
>
> +enum iavf_tx_pkt_burst_type {
> + IAVF_PKT_BURST_DEFAULT = 0,
> + IAVF_PKT_BURST_VEC = 1,
Better to rename with xxx_VEC_SSE
@@ -313,6 +313,16 @@ struct iavf_devargs {
struct iavf_security_ctx;
+enum iavf_tx_pkt_burst_type {
+ IAVF_PKT_BURST_DEFAULT = 0,
+ IAVF_PKT_BURST_VEC = 1,
+ IAVF_PKT_BURST_VEC_AVX2 = 2,
+ IAVF_PKT_BURST_VEC_AVX2_OFFLOAD = 3,
+ IAVF_PKT_BURST_VEC_AVX512 = 4,
+ IAVF_PKT_BURST_VEC_AVX512_OFFLOAD = 5,
+ IAVF_PKT_BURST_VEC_AVX512_CTX_OFFLOAD = 6,
+};
+
/* Structure to store private data for each VF instance. */
struct iavf_adapter {
struct iavf_hw hw;
@@ -329,7 +339,7 @@ struct iavf_adapter {
bool closed;
bool no_poll;
eth_rx_burst_t rx_pkt_burst;
- eth_tx_burst_t tx_pkt_burst;
+ enum iavf_tx_pkt_burst_type tx_burst_type;
uint16_t fdir_ref_cnt;
struct iavf_devargs devargs;
};
@@ -425,6 +425,23 @@ struct iavf_txq_ops iavf_txq_release_mbufs_ops[] = {
};
+static const
+struct iavf_tx_burst_ops iavf_tx_pkt_burst_ops[] = {
+ [IAVF_PKT_BURST_DEFAULT].tx_pkt_burst = iavf_xmit_pkts,
+#ifdef RTE_ARCH_X86
+ [IAVF_PKT_BURST_VEC].tx_pkt_burst = iavf_xmit_pkts_vec,
+ [IAVF_PKT_BURST_VEC_AVX2].tx_pkt_burst = iavf_xmit_pkts_vec_avx2,
+ [IAVF_PKT_BURST_VEC_AVX2_OFFLOAD].tx_pkt_burst = iavf_xmit_pkts_vec_avx2_offload,
+#ifdef CC_AVX512_SUPPORT
+ [IAVF_PKT_BURST_VEC_AVX512].tx_pkt_burst = iavf_xmit_pkts_vec_avx512,
+ [IAVF_PKT_BURST_VEC_AVX512_OFFLOAD].tx_pkt_burst =
+ iavf_xmit_pkts_vec_avx512_offload,
+ [IAVF_PKT_BURST_VEC_AVX512_CTX_OFFLOAD].tx_pkt_burst =
+ iavf_xmit_pkts_vec_avx512_ctx_offload,
+#endif
+#endif
+};
+
static inline void
iavf_rxd_to_pkt_fields_by_comms_ovs(__rte_unused struct iavf_rx_queue *rxq,
struct rte_mbuf *mb,
@@ -3724,10 +3741,13 @@ iavf_xmit_pkts_no_poll(void *tx_queue, struct rte_mbuf **tx_pkts,
uint16_t nb_pkts)
{
struct iavf_tx_queue *txq = tx_queue;
+ enum iavf_tx_pkt_burst_type tx_burst_type =
+ txq->vsi->adapter->tx_burst_type;
+
if (!txq->vsi || txq->vsi->adapter->no_poll)
return 0;
- return txq->vsi->adapter->tx_pkt_burst(tx_queue,
+ return iavf_tx_pkt_burst_ops[tx_burst_type].tx_pkt_burst(tx_queue,
tx_pkts, nb_pkts);
}
@@ -3975,6 +3995,7 @@ iavf_set_tx_function(struct rte_eth_dev *dev)
{
struct iavf_adapter *adapter =
IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
+ enum iavf_tx_pkt_burst_type tx_burst_type;
int no_poll_on_link_down = adapter->devargs.no_poll_on_link_down;
#ifdef RTE_ARCH_X86
struct iavf_tx_queue *txq;
@@ -4011,10 +4032,12 @@ iavf_set_tx_function(struct rte_eth_dev *dev)
PMD_DRV_LOG(DEBUG, "Using Vector Tx (port %d).",
dev->data->port_id);
dev->tx_pkt_burst = iavf_xmit_pkts_vec;
+ tx_burst_type = IAVF_PKT_BURST_VEC;
}
if (use_avx2) {
if (check_ret == IAVF_VECTOR_PATH) {
dev->tx_pkt_burst = iavf_xmit_pkts_vec_avx2;
+ tx_burst_type = IAVF_PKT_BURST_VEC_AVX2;
PMD_DRV_LOG(DEBUG, "Using AVX2 Vector Tx (port %d).",
dev->data->port_id);
} else if (check_ret == IAVF_VECTOR_CTX_OFFLOAD_PATH) {
@@ -4023,6 +4046,7 @@ iavf_set_tx_function(struct rte_eth_dev *dev)
goto normal;
} else {
dev->tx_pkt_burst = iavf_xmit_pkts_vec_avx2_offload;
+ tx_burst_type = IAVF_PKT_BURST_VEC_AVX2_OFFLOAD;
dev->tx_pkt_prepare = iavf_prep_pkts;
PMD_DRV_LOG(DEBUG, "Using AVX2 OFFLOAD Vector Tx (port %d).",
dev->data->port_id);
@@ -4032,15 +4056,18 @@ iavf_set_tx_function(struct rte_eth_dev *dev)
if (use_avx512) {
if (check_ret == IAVF_VECTOR_PATH) {
dev->tx_pkt_burst = iavf_xmit_pkts_vec_avx512;
+ tx_burst_type = IAVF_PKT_BURST_VEC_AVX512;
PMD_DRV_LOG(DEBUG, "Using AVX512 Vector Tx (port %d).",
dev->data->port_id);
} else if (check_ret == IAVF_VECTOR_OFFLOAD_PATH) {
dev->tx_pkt_burst = iavf_xmit_pkts_vec_avx512_offload;
+ tx_burst_type = IAVF_PKT_BURST_VEC_AVX512_OFFLOAD;
dev->tx_pkt_prepare = iavf_prep_pkts;
PMD_DRV_LOG(DEBUG, "Using AVX512 OFFLOAD Vector Tx (port %d).",
dev->data->port_id);
} else {
dev->tx_pkt_burst = iavf_xmit_pkts_vec_avx512_ctx_offload;
+ tx_burst_type = IAVF_PKT_BURST_VEC_AVX512_CTX_OFFLOAD;
dev->tx_pkt_prepare = iavf_prep_pkts;
PMD_DRV_LOG(DEBUG, "Using AVX512 CONTEXT OFFLOAD Vector Tx (port %d).",
dev->data->port_id);
@@ -4063,7 +4090,7 @@ iavf_set_tx_function(struct rte_eth_dev *dev)
}
if (no_poll_on_link_down) {
- adapter->tx_pkt_burst = dev->tx_pkt_burst;
+ adapter->tx_burst_type = tx_burst_type;
dev->tx_pkt_burst = iavf_xmit_pkts_no_poll;
}
return;
@@ -4074,10 +4101,11 @@ iavf_set_tx_function(struct rte_eth_dev *dev)
PMD_DRV_LOG(DEBUG, "Using Basic Tx callback (port=%d).",
dev->data->port_id);
dev->tx_pkt_burst = iavf_xmit_pkts;
+ tx_burst_type = IAVF_PKT_BURST_DEFAULT;
dev->tx_pkt_prepare = iavf_prep_pkts;
if (no_poll_on_link_down) {
- adapter->tx_pkt_burst = dev->tx_pkt_burst;
+ adapter->tx_burst_type = tx_burst_type;
dev->tx_pkt_burst = iavf_xmit_pkts_no_poll;
}
}
@@ -203,6 +203,9 @@ struct iavf_txq_ops {
void (*release_mbufs)(struct iavf_tx_queue *txq);
};
+struct iavf_tx_burst_ops {
+ eth_tx_burst_t tx_pkt_burst;
+};
struct iavf_rx_queue_stats {
uint64_t reserved;