From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 374554322C; Mon, 30 Oct 2023 03:45:29 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B57F3402E6; Mon, 30 Oct 2023 03:45:28 +0100 (CET) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.8]) by mails.dpdk.org (Postfix) with ESMTP id A86F3402B4; Mon, 30 Oct 2023 03:45:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1698633928; x=1730169928; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Z8XJ6laWzzWlsIvNHXytyAGnVH5s41Q4Zf2SuNypuRo=; b=WwbM87295qVmrYC9onro3oOEqAyr+1kFJD5+F9BvG/h4WXyMkHN9AS/O PwMq+/fJfMjtYCdPgxieAq+peSWHDzhsKpwPIheMxNuV9aDyWLqKj7+G6 biexHYli1qZSW4sa/kod5S8NmPI38Y5Bn7XXvZDVvI0pLsXdI/2ETE7ea nz5b9U75KlyzAq2aKjsJvLPG2EHYSFZu19bUc6h+/DkYoGttunLj/ChRS nNkJI/y8gcmk7w2OYQVzyNKpFCuX6swEXxtgF99bmpgJPiq0XilSx0Ba1 B6a1aDAQfuxSySiIpDRZvao6VP/3ugxFJYuJAFGOp3b92KFe1oh5OOlAk A==; X-IronPort-AV: E=McAfee;i="6600,9927,10878"; a="837000" X-IronPort-AV: E=Sophos;i="6.03,262,1694761200"; d="scan'208";a="837000" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Oct 2023 19:45:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10878"; a="903852891" X-IronPort-AV: E=Sophos;i="6.03,262,1694761200"; d="scan'208";a="903852891" Received: from unknown (HELO localhost.localdomain) ([10.239.252.253]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Oct 2023 19:42:49 -0700 From: Mingjin Ye To: dev@dpdk.org Cc: qiming.yang@intel.com, yidingx.zhou@intel.com, Mingjin Ye , stable@dpdk.org, Qi Zhang Subject: [PATCH v2] net/iavf: fix crash on closing representor ports Date: Mon, 30 Oct 2023 02:35:21 +0000 Message-Id: <20231030023521.3466175-1-mingjinx.ye@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231026095112.3053582-1-mingjinx.ye@intel.com> References: <20231026095112.3053582-1-mingjinx.ye@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Since the representor port needs to access the resources of the associated DCF when it is closed. Therefore, the correct close port operation is to close all the representor ports first, and then close the associated DCF port. If the DCF port is closed before the representor port on pmd exit. This will result in accessing freed resources and eventually a core dump will occur. This patch fixes this issue by notifying all presentor ports that DCF is not accessible when the DCF port is closed. And when the presentor port is closed, it determines if the DCF resources are accessible. If it can't be accessed, it will report an error and return. Fixes: 5674465a32c8 ("net/ice: add DCF VLAN handling") Fixes: da9cdcd1f372 ("net/ice: fix crash on representor port closing") Cc: stable@dpdk.org Signed-off-by: Mingjin Ye --- v2: Reformat code to remove unneeded fixlines. --- drivers/net/ice/ice_dcf_ethdev.h | 1 + drivers/net/ice/ice_dcf_vf_representor.c | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/net/ice/ice_dcf_ethdev.h b/drivers/net/ice/ice_dcf_ethdev.h index 4baaec4b8b..d94ef10244 100644 --- a/drivers/net/ice/ice_dcf_ethdev.h +++ b/drivers/net/ice/ice_dcf_ethdev.h @@ -60,6 +60,7 @@ struct ice_dcf_vf_repr { struct rte_ether_addr mac_addr; uint16_t switch_domain_id; uint16_t vf_id; + bool dcf_valid; struct ice_dcf_vlan outer_vlan_info; /* DCF always handle outer VLAN */ }; diff --git a/drivers/net/ice/ice_dcf_vf_representor.c b/drivers/net/ice/ice_dcf_vf_representor.c index b9fcfc80ad..eb49eae4e4 100644 --- a/drivers/net/ice/ice_dcf_vf_representor.c +++ b/drivers/net/ice/ice_dcf_vf_representor.c @@ -45,6 +45,9 @@ ice_dcf_vf_repr_dev_start(struct rte_eth_dev *dev) static int ice_dcf_vf_repr_dev_stop(struct rte_eth_dev *dev) { + struct ice_dcf_vf_repr *repr = dev->data->dev_private; + + repr->dcf_valid = false; dev->data->dev_link.link_status = RTE_ETH_LINK_DOWN; return 0; @@ -111,14 +114,15 @@ ice_dcf_vf_repr_link_update(__rte_unused struct rte_eth_dev *ethdev, static __rte_always_inline struct ice_dcf_hw * ice_dcf_vf_repr_hw(struct ice_dcf_vf_repr *repr) { - struct ice_dcf_adapter *dcf_adapter = - repr->dcf_eth_dev->data->dev_private; + struct ice_dcf_adapter *dcf_adapter; - if (!dcf_adapter) { + if (!repr->dcf_valid) { PMD_DRV_LOG(ERR, "DCF for VF representor has been released\n"); return NULL; } + dcf_adapter = repr->dcf_eth_dev->data->dev_private; + return &dcf_adapter->real_hw; } @@ -414,6 +418,7 @@ ice_dcf_vf_repr_init(struct rte_eth_dev *vf_rep_eth_dev, void *init_param) repr->dcf_eth_dev = param->dcf_eth_dev; repr->switch_domain_id = param->switch_domain_id; repr->vf_id = param->vf_id; + repr->dcf_valid = true; repr->outer_vlan_info.port_vlan_ena = false; repr->outer_vlan_info.stripping_ena = false; repr->outer_vlan_info.tpid = RTE_ETHER_TYPE_VLAN; -- 2.25.1