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 9DABDA0C4B for ; Tue, 26 Oct 2021 11:53:22 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9393241C3B; Tue, 26 Oct 2021 11:53:22 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mails.dpdk.org (Postfix) with ESMTP id 76558407FF; Tue, 26 Oct 2021 11:53:20 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10148"; a="209951967" X-IronPort-AV: E=Sophos;i="5.87,182,1631602800"; d="scan'208";a="209951967" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Oct 2021 02:53:18 -0700 X-IronPort-AV: E=Sophos;i="5.87,182,1631602800"; d="scan'208";a="497246839" Received: from unknown (HELO localhost.localdomain) ([10.240.183.93]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Oct 2021 02:53:16 -0700 From: dapengx.yu@intel.com To: Qiming Yang , Qi Zhang Cc: dev@dpdk.org, Dapeng Yu , stable@dpdk.org Date: Tue, 26 Oct 2021 17:53:07 +0800 Message-Id: <20211026095308.1759784-1-dapengx.yu@intel.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20211026084401.1681489-1-dapengx.yu@intel.com> References: <20211026084401.1681489-1-dapengx.yu@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] [PATCH v5] net/ice: simplify the use of DCF device reset X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" From: Dapeng Yu After DCF is reset by PF, the DCF device un-initialization cannot function normally since the kernel may not clean up resource. This patch detects the reset flag, which is set by PF on DCF reset, if the flag is true, reset hw to trigger an additional DCF enable/disable cycle which helps to work around the issue that kernel driver may not clean up resource during previous reset. Fixes: 1a86f4dbdf42 ("net/ice: support DCF device reset") Cc: stable@dpdk.org Signed-off-by: Dapeng Yu --- V2: * Ignore the returned error of dev_uninit when DCF is reset by PF V3: * Add a reset function to re-initialize AdminQ resource * Add a function to check the reset flag V4: * Remove redundant reset flag setting V5: * Rename function and modify comments --- drivers/net/ice/ice_dcf.c | 2 ++ drivers/net/ice/ice_dcf_ethdev.c | 34 +++++++++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/drivers/net/ice/ice_dcf.c b/drivers/net/ice/ice_dcf.c index 084f7a53db..366ff0a907 100644 --- a/drivers/net/ice/ice_dcf.c +++ b/drivers/net/ice/ice_dcf.c @@ -593,6 +593,8 @@ ice_dcf_init_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw) struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev); int ret, size; + hw->resetting = false; + hw->avf.hw_addr = pci_dev->mem_resource[0].addr; hw->avf.back = hw; diff --git a/drivers/net/ice/ice_dcf_ethdev.c b/drivers/net/ice/ice_dcf_ethdev.c index 7c71a48010..4d9484e994 100644 --- a/drivers/net/ice/ice_dcf_ethdev.c +++ b/drivers/net/ice/ice_dcf_ethdev.c @@ -1025,11 +1025,44 @@ ice_dcf_tm_ops_get(struct rte_eth_dev *dev __rte_unused, return 0; } +static inline void +ice_dcf_reset_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw) +{ + ice_dcf_uninit_hw(eth_dev, hw); + ice_dcf_init_hw(eth_dev, hw); +} + +/* Check if reset has been triggered by PF */ +static inline bool +ice_dcf_is_reset(struct rte_eth_dev *dev) +{ + struct ice_dcf_adapter *ad = dev->data->dev_private; + struct iavf_hw *hw = &ad->real_hw.avf; + + return !(IAVF_READ_REG(hw, IAVF_VF_ARQLEN1) & + IAVF_VF_ARQLEN1_ARQENABLE_MASK); +} + static int ice_dcf_dev_reset(struct rte_eth_dev *dev) { + struct ice_dcf_adapter *ad = dev->data->dev_private; + struct ice_dcf_hw *hw = &ad->real_hw; int ret; + if (ice_dcf_is_reset(dev)) { + if (!ad->real_hw.resetting) + ad->real_hw.resetting = true; + PMD_DRV_LOG(ERR, "The DCF has been reset by PF"); + + /* + * Simply reset hw to trigger an additional DCF enable/disable + * cycle which help to workaround the issue that kernel driver + * may not clean up resource during previous reset. + */ + ice_dcf_reset_hw(dev, hw); + } + ret = ice_dcf_dev_uninit(dev); if (ret) return ret; @@ -1072,7 +1105,6 @@ ice_dcf_dev_init(struct rte_eth_dev *eth_dev) { struct ice_dcf_adapter *adapter = eth_dev->data->dev_private; - adapter->real_hw.resetting = false; eth_dev->dev_ops = &ice_dcf_eth_dev_ops; eth_dev->rx_pkt_burst = ice_dcf_recv_pkts; eth_dev->tx_pkt_burst = ice_dcf_xmit_pkts; -- 2.27.0