From patchwork Fri Sep 3 05:41:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yu, DapengX" X-Patchwork-Id: 97863 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 430F3A0C53; Fri, 3 Sep 2021 07:41:56 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F21FC4013F; Fri, 3 Sep 2021 07:41:55 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mails.dpdk.org (Postfix) with ESMTP id 393B440041; Fri, 3 Sep 2021 07:41:54 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10095"; a="216192964" X-IronPort-AV: E=Sophos;i="5.85,264,1624345200"; d="scan'208";a="216192964" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Sep 2021 22:41:53 -0700 X-IronPort-AV: E=Sophos;i="5.85,264,1624345200"; d="scan'208";a="543340521" Received: from unknown (HELO localhost.localdomain) ([10.240.183.93]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Sep 2021 22:41:48 -0700 From: dapengx.yu@intel.com To: Qiming Yang , Qi Zhang Cc: dev@dpdk.org, haiyue.wang@intel.com, Dapeng Yu , stable@dpdk.org Date: Fri, 3 Sep 2021 13:41:40 +0800 Message-Id: <20210903054140.1530911-1-dapengx.yu@intel.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210902094408.1294361-1-dapengx.yu@intel.com> References: <20210902094408.1294361-1-dapengx.yu@intel.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2] net/ice: fix representor port segmentation fault 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 If DCF representor port is closed after DCF port is closed, there will be segmentation fault because representor accesses the released resource of DCF port. This patch makes DCF representor port is always closed before DCF port is closed. Fixes: 5674465a32c8 ("net/ice: add DCF VLAN handling") Cc: stable@dpdk.org Signed-off-by: Dapeng Yu --- V2: * Remove (void) to make code clean --- drivers/net/ice/ice_dcf_ethdev.c | 1 + drivers/net/ice/ice_dcf_ethdev.h | 1 + drivers/net/ice/ice_dcf_vf_representor.c | 26 ++++++++++++++++++++---- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/drivers/net/ice/ice_dcf_ethdev.c b/drivers/net/ice/ice_dcf_ethdev.c index cab7c4da87..b837f69fd4 100644 --- a/drivers/net/ice/ice_dcf_ethdev.c +++ b/drivers/net/ice/ice_dcf_ethdev.c @@ -874,6 +874,7 @@ ice_dcf_dev_close(struct rte_eth_dev *dev) if (rte_eal_process_type() != RTE_PROC_PRIMARY) return 0; + ice_dcf_vf_repr_close_all(adapter); ice_dcf_free_repr_info(adapter); ice_dcf_uninit_parent_adapter(dev); ice_dcf_uninit_hw(dev, &adapter->real_hw); diff --git a/drivers/net/ice/ice_dcf_ethdev.h b/drivers/net/ice/ice_dcf_ethdev.h index 8510e37119..9e8d3ef0c5 100644 --- a/drivers/net/ice/ice_dcf_ethdev.h +++ b/drivers/net/ice/ice_dcf_ethdev.h @@ -64,5 +64,6 @@ int ice_dcf_vf_repr_init(struct rte_eth_dev *vf_rep_eth_dev, void *init_param); int ice_dcf_vf_repr_uninit(struct rte_eth_dev *vf_rep_eth_dev); int ice_dcf_vf_repr_init_vlan(struct rte_eth_dev *vf_rep_eth_dev); void ice_dcf_vf_repr_stop_all(struct ice_dcf_adapter *dcf_adapter); +void ice_dcf_vf_repr_close_all(struct ice_dcf_adapter *dcf_adapter); #endif /* _ICE_DCF_ETHDEV_H_ */ diff --git a/drivers/net/ice/ice_dcf_vf_representor.c b/drivers/net/ice/ice_dcf_vf_representor.c index 970461f3e9..fd9af06c82 100644 --- a/drivers/net/ice/ice_dcf_vf_representor.c +++ b/drivers/net/ice/ice_dcf_vf_representor.c @@ -46,6 +46,7 @@ static int ice_dcf_vf_repr_dev_stop(struct rte_eth_dev *dev) { dev->data->dev_link.link_status = ETH_LINK_DOWN; + dev->data->dev_started = 0; return 0; } @@ -53,6 +54,7 @@ ice_dcf_vf_repr_dev_stop(struct rte_eth_dev *dev) static int ice_dcf_vf_repr_dev_close(struct rte_eth_dev *dev) { + ice_dcf_vf_repr_dev_stop(dev); return ice_dcf_vf_repr_uninit(dev); } @@ -464,7 +466,6 @@ void ice_dcf_vf_repr_stop_all(struct ice_dcf_adapter *dcf_adapter) { uint16_t vf_id; - int ret; if (!dcf_adapter->repr_infos) return; @@ -475,8 +476,25 @@ ice_dcf_vf_repr_stop_all(struct ice_dcf_adapter *dcf_adapter) if (!vf_rep_eth_dev || vf_rep_eth_dev->data->dev_started == 0) continue; - ret = ice_dcf_vf_repr_dev_stop(vf_rep_eth_dev); - if (!ret) - vf_rep_eth_dev->data->dev_started = 0; + ice_dcf_vf_repr_dev_stop(vf_rep_eth_dev); + } +} + +void +ice_dcf_vf_repr_close_all(struct ice_dcf_adapter *dcf_adapter) +{ + uint16_t vf_id; + + if (!dcf_adapter->repr_infos) + return; + + for (vf_id = 0; vf_id < dcf_adapter->real_hw.num_vfs; vf_id++) { + struct rte_eth_dev *vf_rep_eth_dev = + dcf_adapter->repr_infos[vf_id].vf_rep_eth_dev; + if (!vf_rep_eth_dev) + continue; + + ice_dcf_vf_repr_dev_close(vf_rep_eth_dev); + rte_eth_dev_release_port(vf_rep_eth_dev); } }