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 4975B43804; Wed, 3 Jan 2024 04:19:29 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1AE6A402BC; Wed, 3 Jan 2024 04:19:29 +0100 (CET) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by mails.dpdk.org (Postfix) with ESMTP id 94D69402A3; Wed, 3 Jan 2024 04:19: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=1704251969; x=1735787969; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=j+Da5iFAghsSKnvD+K1knzu5Wz/iCXqwxSg15OT8Mew=; b=XVK8R4lmBZyBv2786a17QEQsPNT3Vl5nSq65gP0NQB1yIES1Cts6MZvK bPztMCJnUqS6RmSlvW59tvQGMPXXKOZFxtatYHMwFVi17pUrQnJrHf7mO NC/EinPPfbF6wm4Im/J+z/wEOmYuNrrU9eddrbWO82Wse/uaYN1zoOstr UOLSvADLC17lky9FHYQrK9nffthzUYLnwBWrldTrWGggCp544/r9r4XFK 31qMaIxC8Y6CVOoFsbLug94Wv0bNoGCKJMW5Mctd6vp5EPXr8Cn/OClRP 42tdWzVb7MjD9jp/Svnh8hJHfmpfkVr6vtTpPYCFzYju1e/Ywdge8XTgu g==; X-IronPort-AV: E=McAfee;i="6600,9927,10941"; a="15593117" X-IronPort-AV: E=Sophos;i="6.04,326,1695711600"; d="scan'208";a="15593117" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jan 2024 19:19:27 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10941"; a="850308361" X-IronPort-AV: E=Sophos;i="6.04,326,1695711600"; d="scan'208";a="850308361" Received: from unknown (HELO dpdk..) ([10.239.252.115]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jan 2024 19:19:23 -0800 From: Shiyang He To: dev@dpdk.org Cc: qiming.yang@intel.com, Shiyang He , stable@dpdk.org, Jingjing Wu , Beilei Xing , Liang-Min Larry Wang , Qi Zhang Subject: [PATCH v3] net/iavf: fix VF startup coredump Date: Wed, 3 Jan 2024 10:42:07 +0000 Message-Id: <20240103104207.125714-1-shiyangx.he@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240102092759.8712-1-shiyangx.he@intel.com> References: <20240102092759.8712-1-shiyangx.he@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 When the vf starts to request multiple queues, the pf sends a reset command to the vf. During the reset process, adminq sends an abnormal message to pf for an unknown reason, and the resource request fails resulting in a coredump. This patch fixes the issue by checking the reset state before resetting. v2: fix windows compilation errors v3: add fix tag Fixes: 3e6a5d2d310a ("net/iavf: add devargs to enable VF auto-reset") Cc: stable@dpdk.org Signed-off-by: Shiyang He --- drivers/net/iavf/iavf.h | 3 ++- drivers/net/iavf/iavf_ethdev.c | 48 +++++++++++++++++++++++++++------- 2 files changed, 40 insertions(+), 11 deletions(-) diff --git a/drivers/net/iavf/iavf.h b/drivers/net/iavf/iavf.h index 10868f2c30..cdf60bd833 100644 --- a/drivers/net/iavf/iavf.h +++ b/drivers/net/iavf/iavf.h @@ -19,6 +19,7 @@ #define IAVF_AQ_LEN 32 #define IAVF_AQ_BUF_SZ 4096 #define IAVF_RESET_WAIT_CNT 500 +#define IAVF_RESET_DETECTED_CNT 500 #define IAVF_BUF_SIZE_MIN 1024 #define IAVF_FRAME_SIZE_MAX 9728 #define IAVF_QUEUE_BASE_ADDR_UNIT 128 @@ -511,5 +512,5 @@ int iavf_flow_sub_check(struct iavf_adapter *adapter, struct iavf_fsub_conf *filter); void iavf_dev_watchdog_enable(struct iavf_adapter *adapter); void iavf_dev_watchdog_disable(struct iavf_adapter *adapter); -int iavf_handle_hw_reset(struct rte_eth_dev *dev); +void iavf_handle_hw_reset(struct rte_eth_dev *dev); #endif /* _IAVF_ETHDEV_H_ */ diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c index d1edb0dd5c..06b18f2758 100644 --- a/drivers/net/iavf/iavf_ethdev.c +++ b/drivers/net/iavf/iavf_ethdev.c @@ -1086,9 +1086,6 @@ iavf_dev_stop(struct rte_eth_dev *dev) PMD_INIT_FUNC_TRACE(); - if (vf->vf_reset) - return 0; - if (adapter->closed) return -1; @@ -2949,7 +2946,6 @@ iavf_dev_reset(struct rte_eth_dev *dev) { int ret; struct iavf_hw *hw = IAVF_DEV_PRIVATE_TO_HW(dev->data->dev_private); - struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private); /* * Check whether the VF reset has been done and inform application, @@ -2961,7 +2957,6 @@ iavf_dev_reset(struct rte_eth_dev *dev) PMD_DRV_LOG(ERR, "Wait too long for reset done!\n"); return ret; } - vf->vf_reset = false; PMD_DRV_LOG(DEBUG, "Start dev_reset ...\n"); ret = iavf_dev_uninit(dev); @@ -2971,15 +2966,47 @@ iavf_dev_reset(struct rte_eth_dev *dev) return iavf_dev_init(dev); } +static inline bool +iavf_is_reset(struct iavf_hw *hw) +{ + return !(IAVF_READ_REG(hw, IAVF_VF_ARQLEN1) & + IAVF_VF_ARQLEN1_ARQENABLE_MASK); +} + +static bool +iavf_is_reset_detected(struct iavf_adapter *adapter) +{ + struct iavf_hw *hw = IAVF_DEV_PRIVATE_TO_HW(adapter); + int i; + + /* poll until we see the reset actually happen */ + for (i = 0; i < IAVF_RESET_DETECTED_CNT; i++) { + if (iavf_is_reset(hw)) + return true; + rte_delay_ms(20); + } + + return false; +} + /* * Handle hardware reset */ -int +void iavf_handle_hw_reset(struct rte_eth_dev *dev) { struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private); + struct iavf_adapter *adapter = dev->data->dev_private; int ret; + if (!dev->data->dev_started) + return; + + if (!iavf_is_reset_detected(adapter)) { + PMD_DRV_LOG(DEBUG, "reset not start\n"); + return; + } + vf->in_reset_recovery = true; ret = iavf_dev_reset(dev); @@ -2997,15 +3024,16 @@ iavf_handle_hw_reset(struct rte_eth_dev *dev) ret = iavf_dev_start(dev); if (ret) goto error; - dev->data->dev_started = 1; + dev->data->dev_started = 1; vf->in_reset_recovery = false; - return 0; + + return; error: - PMD_DRV_LOG(DEBUG, "RESET recover with error code=%d\n", ret); vf->in_reset_recovery = false; - return ret; + iavf_uninit_vf(dev); + PMD_DRV_LOG(DEBUG, "failed to reset port %d\n", dev->data->port_id); } static int -- 2.34.1