From patchwork Fri Jun 2 02:38:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhichao Zeng X-Patchwork-Id: 127944 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 E076742C0A; Fri, 2 Jun 2023 04:32:42 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D0C04406B8; Fri, 2 Jun 2023 04:32:42 +0200 (CEST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mails.dpdk.org (Postfix) with ESMTP id 458B440693 for ; Fri, 2 Jun 2023 04:32:41 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685673161; x=1717209161; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=LFzoKrx9vKZudj6kDVb99gvVw/DSFvNQ8qQVdjsQeRk=; b=N0VmNs3GJXR3avaBdaeNVktKZW5z60asKfexH2c0HdriOuTaBMWSDiub Hfy3qe/oANeGiCCP5sewkTZvMVCMkeMnmO8jUbSGmT15wwuGw/X7WuVXl wPStD69lMEy3uiqtRjLMLYMWYArxEutfmSCSYdsC8OL7FVmMrg388xAmj QecibbaaSLZ/ooHPBYjTzgrtvJ1JxHpcJfoSeCrzUE8M6x95zUYkZjVQ5 yqXWbgD+x7DiKzLdOs4PWpKhKLXCQZkVgtao9PpGl8npSAMeNlRQ4BurM +5Wt+egBTGwotjNJowSGNAADyqAQhndNGuomfJBh8S9U5fZWWNk2bnjc6 A==; X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="442120081" X-IronPort-AV: E=Sophos;i="6.00,211,1681196400"; d="scan'208";a="442120081" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 19:32:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="685114566" X-IronPort-AV: E=Sophos;i="6.00,211,1681196400"; d="scan'208";a="685114566" Received: from unknown (HELO zhichao-dpdk..) ([10.239.252.103]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 19:32:36 -0700 From: Zhichao Zeng To: dev@dpdk.org Cc: qi.z.zhang@intel.com, Zhichao Zeng , Liang-Min Larry Wang , Jingjing Wu , Beilei Xing Subject: [PATCH v2] net/iavf: add VF reset check Date: Fri, 2 Jun 2023 10:38:22 +0800 Message-Id: <20230602023822.2370902-1-zhichaox.zeng@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230525021737.1921818-1-zhichaox.zeng@intel.com> References: <20230525021737.1921818-1-zhichaox.zeng@intel.com> MIME-Version: 1.0 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 In the current implementation, after application calls rte_eth_dev_reset, it has no way to know if reset has been completed, and if the virtual channel command is called before it is completed, it may cause the dev to be abnormal. To avoid this issue, an uncertain delay need to be added. This commit adds a VF reset check before the dev_reset to inform the application not to invoke any virtual channel commands, to avoid making the device to be abnormal. Suggested-by: Liang-Min Larry Wang Signed-off-by: Zhichao Zeng Acked-by: Qi Zhang --- drivers/net/iavf/iavf_ethdev.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c index e6cf897293..96004220a1 100644 --- a/drivers/net/iavf/iavf_ethdev.c +++ b/drivers/net/iavf/iavf_ethdev.c @@ -2855,7 +2855,20 @@ static int iavf_dev_reset(struct rte_eth_dev *dev) { int ret; + struct iavf_hw *hw = IAVF_DEV_PRIVATE_TO_HW(dev->data->dev_private); + + /* + * Check whether the VF reset has been done and inform application, + * to avoid calling the virtual channel command, which may cause + * the device to be abnormal. + */ + ret = iavf_check_vf_reset_done(hw); + if (ret) { + PMD_DRV_LOG(ERR, "Wait too long for reset done!\n"); + return ret; + } + PMD_DRV_LOG(DEBUG, "Start dev_reset ...\n"); ret = iavf_dev_uninit(dev); if (ret) return ret;