From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (xvm-189-124.dc0.ghst.net [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id CCAD2A09FF; Wed, 6 Jan 2021 04:47:33 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 335B61608C5; Wed, 6 Jan 2021 04:47:00 +0100 (CET) Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) by mails.dpdk.org (Postfix) with ESMTP id 06B32160887 for ; Wed, 6 Jan 2021 04:46:53 +0100 (CET) Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4D9Zyr17jkz7QyV for ; Wed, 6 Jan 2021 11:45:56 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.498.0; Wed, 6 Jan 2021 11:46:46 +0800 From: Lijun Ou To: CC: Date: Wed, 6 Jan 2021 11:46:31 +0800 Message-ID: <1609904792-63280-6-git-send-email-oulijun@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1609904792-63280-1-git-send-email-oulijun@huawei.com> References: <1607846585-2381-1-git-send-email-oulijun@huawei.com> <1609904792-63280-1-git-send-email-oulijun@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH v2 5/6] net/hns3: fix crash with 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: "Min Hu (Connor)" In current version, procedure of saving eth_dev in hns3 PMD init will be called more than twice, one for primary, the other for secondary. That will cause segmentation fault in Multi-process as eth_dev will be changed in secondary process, which is different from one in primary process. The initial problem was access to 'rte_eth_devices' global variable, which is wrong. But current approach can cause problem for the secondaries, moving 'eth_dev' to process private can work but before making things more complex. This patch deserted the procedure of saving eth_dev in hns3 PMD init. Instead, it creates an internal function that gets "struct hns3_hw" as parameter and it can be called internally without knowing 'eth_dev'and the .dev_ops can be wrapper to this. Fixes: 5e8d3de4ca36 ("net/hns3: fix FEC state query") Cc: stable@dpdk.org Signed-off-by: Min Hu (Connor) Signed-off-by: Lijun Ou --- drivers/net/hns3/hns3_ethdev.c | 16 ++++++++++------ drivers/net/hns3/hns3_ethdev.h | 2 -- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c index 7c34e38..90544fe 100644 --- a/drivers/net/hns3/hns3_ethdev.c +++ b/drivers/net/hns3/hns3_ethdev.c @@ -5821,10 +5821,9 @@ get_current_fec_auto_state(struct hns3_hw *hw, uint8_t *state) } static int -hns3_fec_get(struct rte_eth_dev *dev, uint32_t *fec_capa) +hns3_fec_get_internal(struct hns3_hw *hw, uint32_t *fec_capa) { #define QUERY_ACTIVE_SPEED 1 - struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); struct hns3_sfp_speed_cmd *resp; uint32_t tmp_fec_capa; uint8_t auto_state; @@ -5885,6 +5884,14 @@ hns3_fec_get(struct rte_eth_dev *dev, uint32_t *fec_capa) } static int +hns3_fec_get(struct rte_eth_dev *dev, uint32_t *fec_capa) +{ + struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); + + return hns3_fec_get_internal(hw, fec_capa); +} + +static int hns3_set_fec_hw(struct hns3_hw *hw, uint32_t mode) { struct hns3_config_fec_cmd *req; @@ -6017,10 +6024,9 @@ hns3_query_dev_fec_info(struct hns3_hw *hw) { struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw); struct hns3_pf *pf = HNS3_DEV_PRIVATE_TO_PF(hns); - struct rte_eth_dev *eth_dev = hns->eth_dev; int ret; - ret = hns3_fec_get(eth_dev, &pf->fec_mode); + ret = hns3_fec_get_internal(hw, &pf->fec_mode); if (ret) hns3_err(hw, "query device FEC info failed, ret = %d", ret); @@ -6106,8 +6112,6 @@ hns3_dev_init(struct rte_eth_dev *eth_dev) PMD_INIT_FUNC_TRACE(); - hns->eth_dev = eth_dev; - eth_dev->process_private = (struct hns3_process_private *) rte_zmalloc_socket("hns3_filter_list", sizeof(struct hns3_process_private), diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h index 8d6b8cd..31f78a1 100644 --- a/drivers/net/hns3/hns3_ethdev.h +++ b/drivers/net/hns3/hns3_ethdev.h @@ -743,8 +743,6 @@ struct hns3_adapter { struct hns3_vf vf; }; - struct rte_eth_dev *eth_dev; - bool rx_simple_allowed; bool rx_vec_allowed; bool tx_simple_allowed; -- 2.7.4