Skip to contentSkip to conversation

net/iavf: fix shared local data in multi-process

PATCH Applied [email protected] 2 participants 2 messages Oct 27, 2021 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/iavf: fix shared local data in multi-process

From: Dapeng Yu <[email protected]>

The shared pointer is initialized to a static local array defined in the primary process and it shall not be accessed in the secondary process.

This patch copies the local data to shared data, to avoid data access violation.

Fixes 040b44551f77 ("net/iavf: unify Rx packet type table")
---
 drivers/net/iavf/iavf.h        |  2 +-
 drivers/net/iavf/iavf_ethdev.c |  2 +-
 drivers/net/iavf/iavf_rxtx.c   | 17 ++++++++++++++---
 drivers/net/iavf/iavf_rxtx.h   |  2 +-
 4 files changed, 17 insertions(+), 6 deletions(-)
drivers/net/iavf/iavf.h +1 -1
index 12f541f539..8f795f2bed 100644
@@ -265,7 +265,7 @@ struct iavf_adapter {
 	/* For vector PMD */
 	bool rx_vec_allowed;
 	bool tx_vec_allowed;
-	const uint32_t *ptype_tbl;
+	uint32_t ptype_tbl[IAVF_MAX_PKT_TYPE] __rte_cache_min_aligned;
 	bool stopped;
 	uint16_t fdir_ref_cnt;
 	struct iavf_devargs devargs;
drivers/net/iavf/iavf_ethdev.c +1 -1
index f892306f18..7a151975dc 100644
@@ -2332,7 +2332,7 @@ iavf_dev_init(struct rte_eth_dev *eth_dev)
 	}
 
 	/* set default ptype table */
-	adapter->ptype_tbl = iavf_get_default_ptype_table();
+	iavf_set_default_ptype_table(eth_dev);
 
 	/* copy mac addr */
 	eth_dev->data->mac_addrs = rte_zmalloc(
drivers/net/iavf/iavf_rxtx.c +14 -3
index 52d919ca1b..a8ad7a0977 100644
@@ -2885,8 +2885,8 @@ iavf_dev_tx_desc_status(void *tx_queue, uint16_t offset)
 	return RTE_ETH_TX_DESC_FULL;
 }
 
-const uint32_t *
-iavf_get_default_ptype_table(void)
+static inline uint32_t
+iavf_get_default_ptype(uint16_t ptype)
 {
 	static const uint32_t ptype_tbl[IAVF_MAX_PKT_TYPE]
 		__rte_cache_aligned = {
@@ -3465,5 +3465,16 @@ iavf_get_default_ptype_table(void)
 		/* All others reserved */
 	};
 
-	return ptype_tbl;
+	return ptype_tbl[ptype];
+}
+
+void __rte_cold
+iavf_set_default_ptype_table(struct rte_eth_dev *dev)
+{
+	struct iavf_adapter *ad =
+		IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
+	int i;
+
+	for (i = 0; i < IAVF_MAX_PKT_TYPE; i++)
+		ad->ptype_tbl[i] = iavf_get_default_ptype(i);
 }
drivers/net/iavf/iavf_rxtx.h +1 -1
index 84351011f1..6d1429081d 100644
@@ -519,7 +519,7 @@ int iavf_txq_vec_setup_avx512(struct iavf_tx_queue *txq);
 
 uint8_t iavf_proto_xtr_type_to_rxdid(uint8_t xtr_type);
 
-const uint32_t *iavf_get_default_ptype_table(void);
+void iavf_set_default_ptype_table(struct rte_eth_dev *dev);
 
 static inline
 void iavf_dump_rx_descriptor(struct iavf_rx_queue *rxq,
Signature · 1 line
2.27.0
Acked-by on v1 1/1 Applied
#1 lore raw
Quoted 14 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of [email protected]
Sent: Wednesday, October 27, 2021 4:29 PM
To: Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>
Cc: [email protected]; Yu, DapengX <[email protected]>; [email protected]
Subject: [dpdk-dev] [PATCH] net/iavf: fix shared local data in multi-process

From: Dapeng Yu <[email protected]>

The shared pointer is initialized to a static local array defined in the primary process and it shall not be accessed in the secondary process.

Quoted 6 lines

This patch copies the local data to shared data, to avoid data access violation.

Fixes 040b44551f77 ("net/iavf: unify Rx packet type table")

Applied to dpdk-next-net-intel.

Thanks
Qi