[dpdk-stable] [PATCH v3] net/ice: simplify the use of DCF device reset

dapengx.yu at intel.com dapengx.yu at intel.com
Tue Oct 26 10:18:45 CEST 2021


From: Dapeng Yu <dapengx.yu at intel.com>

After DCF is reset by PF, the DCF device un-initialization cannot
function normally since the resource is already invalidated. So
reset DCF twice is necessary, the first simplified reset
re-initializes the AdminQ of DCF, only then second reset can clean
the filters successfully.

This patch detects the reset flag, which is set by PF on DCF reset,
if the flag is true, do DCF reset twice automatically.

Fixes: 1a86f4dbdf42 ("net/ice: support DCF device reset")
Cc: stable at dpdk.org

Signed-off-by: Dapeng Yu <dapengx.yu at intel.com>
---
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
---
 drivers/net/ice/ice_dcf.c        |  2 ++
 drivers/net/ice/ice_dcf_ethdev.c | 32 ++++++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+)

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..f47219ee17 100644
--- a/drivers/net/ice/ice_dcf_ethdev.c
+++ b/drivers/net/ice/ice_dcf_ethdev.c
@@ -1025,11 +1025,43 @@ ice_dcf_tm_ops_get(struct rte_eth_dev *dev __rte_unused,
 	return 0;
 }
 
+static inline void
+ice_dcf_simple_reset(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
+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 (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");
+
+		/*
+		 * Do the simplified reset to make DCF get AdminQ resource.
+		 * Then the next uninit/init can clean filters successfully.
+		 */
+		ice_dcf_simple_reset(dev, hw);
+	}
+
 	ret = ice_dcf_dev_uninit(dev);
 	if (ret)
 		return ret;
-- 
2.27.0



More information about the stable mailing list