From patchwork Fri Mar 17 09:55:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhichao Zeng X-Patchwork-Id: 125226 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 ECC4E41EBB; Fri, 17 Mar 2023 10:50:26 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CCD4042F98; Fri, 17 Mar 2023 10:50:26 +0100 (CET) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mails.dpdk.org (Postfix) with ESMTP id 374E240395; Fri, 17 Mar 2023 10:50:24 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1679046625; x=1710582625; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=pqxhOpmeY08j/RVkrctUWcHi1/LBtEIRYLAETa8Sg8I=; b=ZhAB1NE5TZXr/RBeVkdtO68rcsv75Il0XSkcockAr7TiNZN0A4O09chI 3+7Za/Kg9xH/tpuF1KWE1w9Rg7YX6ygQWglFALTvojvZUbNW0JTdoOC32 i9Ym/LDSZiwnqWwE7rpBHA15dAr7x11fudenMwk0AACuLmrtzspCmDRUr 2hWfoVhBNCLdjcZLhQB4vOuyHW9kT66ADJxNmKMFI7waHRZ1p5NWbTDzW j5dqdkNMUqYuTQPmRCIVZLPzZ/fjmo4B6i1FXaMx3iT+HYNuUqh66lOus aI7mWEAs4iv/BilCVUELSv3SUwZrQpewoIIst5xUz+G7IIuJ/s7ICUCyD Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10651"; a="322073455" X-IronPort-AV: E=Sophos;i="5.98,268,1673942400"; d="scan'208";a="322073455" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Mar 2023 02:50:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10651"; a="682623787" X-IronPort-AV: E=Sophos;i="5.98,268,1673942400"; d="scan'208";a="682623787" Received: from unknown (HELO localhost.localdomain) ([10.239.252.103]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Mar 2023 02:50:16 -0700 From: Zhichao Zeng To: dev@dpdk.org Cc: stable@dpdk.org, yidingx.zhou@intel.com, qi.z.zhang@intel.com, Zhichao Zeng , Jingjing Wu , Beilei Xing , Lunyuan Cui , Xiaolong Ye , Ting Xu Subject: [PATCH] net/iavf: fix handle VF reset Date: Fri, 17 Mar 2023 17:55:06 +0800 Message-Id: <20230317095506.757964-1-zhichaox.zeng@intel.com> X-Mailer: git-send-email 2.25.1 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 This patch adds detection to avoid repeated calls to dev_reset. And enables the iavf_dev_watchdog to detect some VF reset without PF event (VIRTCHNL_EVENT_RESET_IMPENDING), one of which is after an NVM update. Fixes: e74e1bb6280d ("net/iavf: enable port reset") Fixes: 5e03e316c753 ("net/iavf: handle virtchnl event message without interrupt") Cc: stable@dpdk.org Signed-off-by: Zhichao Zeng --- drivers/net/iavf/iavf.h | 2 +- drivers/net/iavf/iavf_ethdev.c | 9 +++++++++ drivers/net/iavf/iavf_vchnl.c | 17 ++++++++++++----- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/drivers/net/iavf/iavf.h b/drivers/net/iavf/iavf.h index aa18650ffa..309c1a50e4 100644 --- a/drivers/net/iavf/iavf.h +++ b/drivers/net/iavf/iavf.h @@ -31,7 +31,7 @@ #define IAVF_NUM_MACADDR_MAX 64 -#define IAVF_DEV_WATCHDOG_PERIOD 0 +#define IAVF_DEV_WATCHDOG_PERIOD 50000 /* 0 means disabled*/ #define IAVF_DEFAULT_RX_PTHRESH 8 #define IAVF_DEFAULT_RX_HTHRESH 8 diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c index f6d68403ce..8a5ac6b2f6 100644 --- a/drivers/net/iavf/iavf_ethdev.c +++ b/drivers/net/iavf/iavf_ethdev.c @@ -299,6 +299,7 @@ iavf_dev_watchdog(void *cb_arg) "VF \"%s\" reset event detected by watchdog", adapter->vf.eth_dev->data->name); + adapter->vf.link_up = false; /* enter reset state with VFLR event */ adapter->vf.vf_reset = true; @@ -2806,7 +2807,15 @@ 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); + + 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; diff --git a/drivers/net/iavf/iavf_vchnl.c b/drivers/net/iavf/iavf_vchnl.c index 9adaadb173..bea8d476dd 100644 --- a/drivers/net/iavf/iavf_vchnl.c +++ b/drivers/net/iavf/iavf_vchnl.c @@ -260,8 +260,12 @@ iavf_read_msg_from_pf(struct iavf_adapter *adapter, uint16_t buf_len, vf->link_up ? "up" : "down"); break; case VIRTCHNL_EVENT_RESET_IMPENDING: - vf->vf_reset = true; - PMD_DRV_LOG(INFO, "VF is resetting"); + vf->link_up = false; + if (!vf->vf_reset) { + vf->vf_reset = true; + iavf_dev_event_post(vf->eth_dev, RTE_ETH_EVENT_INTR_RESET, NULL, 0); + PMD_DRV_LOG(INFO, "VF is resetting"); + } break; case VIRTCHNL_EVENT_PF_DRIVER_CLOSE: vf->dev_closed = true; @@ -433,9 +437,12 @@ iavf_handle_pf_event_msg(struct rte_eth_dev *dev, uint8_t *msg, switch (pf_msg->event) { case VIRTCHNL_EVENT_RESET_IMPENDING: PMD_DRV_LOG(DEBUG, "VIRTCHNL_EVENT_RESET_IMPENDING event"); - vf->vf_reset = true; - iavf_dev_event_post(dev, RTE_ETH_EVENT_INTR_RESET, - NULL, 0); + vf->link_up = false; + if (!vf->vf_reset) { + vf->vf_reset = true; + iavf_dev_event_post(dev, RTE_ETH_EVENT_INTR_RESET, + NULL, 0); + } break; case VIRTCHNL_EVENT_LINK_CHANGE: PMD_DRV_LOG(DEBUG, "VIRTCHNL_EVENT_LINK_CHANGE event");