From patchwork Wed Oct 27 08:28:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yu, DapengX" X-Patchwork-Id: 103022 X-Patchwork-Delegate: qi.z.zhang@intel.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 007F3A0C45; Wed, 27 Oct 2021 10:28:56 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E322A410F1; Wed, 27 Oct 2021 10:28:55 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mails.dpdk.org (Postfix) with ESMTP id 043424003F; Wed, 27 Oct 2021 10:28:53 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10149"; a="230056874" X-IronPort-AV: E=Sophos;i="5.87,186,1631602800"; d="scan'208";a="230056874" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Oct 2021 01:28:51 -0700 X-IronPort-AV: E=Sophos;i="5.87,186,1631602800"; d="scan'208";a="497764063" Received: from unknown (HELO localhost.localdomain) ([10.240.183.93]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Oct 2021 01:28:49 -0700 From: dapengx.yu@intel.com To: Jingjing Wu , Beilei Xing Cc: dev@dpdk.org, Dapeng Yu , stable@dpdk.org Date: Wed, 27 Oct 2021 16:28:39 +0800 Message-Id: <20211027082839.2133291-1-dapengx.yu@intel.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH] net/iavf: fix shared local data in multi-process 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 Sender: "dev" From: Dapeng Yu 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") Cc: stable@dpdk.org Signed-off-by: Dapeng Yu Acked-by: Qi Zhang --- 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(-) diff --git a/drivers/net/iavf/iavf.h b/drivers/net/iavf/iavf.h index 12f541f539..8f795f2bed 100644 --- a/drivers/net/iavf/iavf.h +++ b/drivers/net/iavf/iavf.h @@ -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; diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c index f892306f18..7a151975dc 100644 --- a/drivers/net/iavf/iavf_ethdev.c +++ b/drivers/net/iavf/iavf_ethdev.c @@ -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( diff --git a/drivers/net/iavf/iavf_rxtx.c b/drivers/net/iavf/iavf_rxtx.c index 52d919ca1b..a8ad7a0977 100644 --- a/drivers/net/iavf/iavf_rxtx.c +++ b/drivers/net/iavf/iavf_rxtx.c @@ -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); } diff --git a/drivers/net/iavf/iavf_rxtx.h b/drivers/net/iavf/iavf_rxtx.h index 84351011f1..6d1429081d 100644 --- a/drivers/net/iavf/iavf_rxtx.h +++ b/drivers/net/iavf/iavf_rxtx.h @@ -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,