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 7AE1B437F7; Tue, 2 Jan 2024 03:05:22 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 61425402BE; Tue, 2 Jan 2024 03:05:22 +0100 (CET) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) by mails.dpdk.org (Postfix) with ESMTP id AC9C1402BD for ; Tue, 2 Jan 2024 03:05:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1704161121; x=1735697121; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ku0teOzZzuQhI6weOll3W8eumDttKYiOuG3DEsVzC/U=; b=cuMSqPs3QXvPxbVoIk4j3fpNGVIgm9WwGs/eoYRvL+JL9yekKaYvEAto JgMdDxfz9ZH9X9OKC9XtPxxC/OXXCAnef6DOKEl/SV8yXxGAazSz0KQWM wgxii49Bz0EH4Dw+gvCO4iSn6oyXFQqoZ3AdwhWkSK3Qd7QKfnUAt6X+x /Nw3skdQC3yMxYkACbt2PUZ+u8NgtAxi+I837wu2gz42cDyC9eMQEit5h 1yQE6ojN/JZF/Vw1U5zOf4P5t9q4Dhex6GMeEr1emLwniaXecCbM4D4Y4 ah5zkr8VxlicfBApH/x3rtB3P+sYoSKfePy3eF2rzmXCTERx33y+69hBv g==; X-IronPort-AV: E=McAfee;i="6600,9927,10940"; a="4160971" X-IronPort-AV: E=Sophos;i="6.04,323,1695711600"; d="scan'208";a="4160971" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jan 2024 18:05:20 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.04,324,1695711600"; d="scan'208";a="21334382" Received: from unknown (HELO dpdk..) ([10.239.252.115]) by orviesa002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jan 2024 18:05:17 -0800 From: Shiyang He To: dev@dpdk.org Cc: yidingx.zhou@intel.com, Shiyang He , Jingjing Wu , Beilei Xing Subject: [PATCH v2] net/iavf: fix vf startup coredump Date: Tue, 2 Jan 2024 09:27:59 +0000 Message-Id: <20240102092759.8712-1-shiyangx.he@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231204140940.3166836-1-shiyangx.he@intel.com> References: <20231204140940.3166836-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 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