[v2,33/33] net/ice: fix DCF reset

Message ID 20220413160932.2074781-34-kevinx.liu@intel.com (mailing list archive)
State Superseded, archived
Headers
Series support full function of DCF |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/intel-Testing success Testing PASS

Commit Message

Kevin Liu April 13, 2022, 4:09 p.m. UTC
  After the PF triggers the VF reset, before the VF PMD can perform
any operations on the hardware, it must reinitialize the all resources.

This patch adds a flag to indicate whether the VF has been reset by
PF, and update the DCF resetting operations according to this flag.

Fixes: 1a86f4dbdf42 ("net/ice: support DCF device reset")

Signed-off-by: Alvin Zhang <alvinx.zhang@intel.com>
Signed-off-by: Kevin Liu <kevinx.liu@intel.com>
---
 drivers/net/ice/base/ice_common.c |  4 +++-
 drivers/net/ice/ice_dcf.c         |  2 +-
 drivers/net/ice/ice_dcf_ethdev.c  | 17 ++++++++++++++++-
 drivers/net/ice/ice_dcf_parent.c  |  3 +++
 4 files changed, 23 insertions(+), 3 deletions(-)
  

Patch

diff --git a/drivers/net/ice/base/ice_common.c b/drivers/net/ice/base/ice_common.c
index db87bacd97..13feb55469 100644
--- a/drivers/net/ice/base/ice_common.c
+++ b/drivers/net/ice/base/ice_common.c
@@ -755,6 +755,7 @@  enum ice_status ice_init_fltr_mgmt_struct(struct ice_hw *hw)
 	status = ice_init_def_sw_recp(hw, &hw->switch_info->recp_list);
 	if (status) {
 		ice_free(hw, hw->switch_info);
+		hw->switch_info = NULL;
 		return status;
 	}
 	return ICE_SUCCESS;
@@ -823,7 +824,6 @@  ice_cleanup_fltr_mgmt_single(struct ice_hw *hw, struct ice_switch_info *sw)
 	}
 	ice_rm_sw_replay_rule_info(hw, sw);
 	ice_free(hw, sw->recp_list);
-	ice_free(hw, sw);
 }
 
 /**
@@ -833,6 +833,8 @@  ice_cleanup_fltr_mgmt_single(struct ice_hw *hw, struct ice_switch_info *sw)
 void ice_cleanup_fltr_mgmt_struct(struct ice_hw *hw)
 {
 	ice_cleanup_fltr_mgmt_single(hw, hw->switch_info);
+	ice_free(hw, hw->switch_info);
+	hw->switch_info = NULL;
 }
 
 /**
diff --git a/drivers/net/ice/ice_dcf.c b/drivers/net/ice/ice_dcf.c
index 23edfd09b1..35773e2acd 100644
--- a/drivers/net/ice/ice_dcf.c
+++ b/drivers/net/ice/ice_dcf.c
@@ -1429,7 +1429,7 @@  ice_dcf_cap_reset(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw)
 	int ret;
 
 	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
-	struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
+	struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
 
 	ice_dcf_disable_irq0(hw);
 	rte_intr_disable(intr_handle);
diff --git a/drivers/net/ice/ice_dcf_ethdev.c b/drivers/net/ice/ice_dcf_ethdev.c
index e46c8405aa..0315e694d7 100644
--- a/drivers/net/ice/ice_dcf_ethdev.c
+++ b/drivers/net/ice/ice_dcf_ethdev.c
@@ -1004,6 +1004,15 @@  dcf_add_del_mc_addr_list(struct ice_dcf_hw *hw,
 	uint32_t i;
 	int len, err = 0;
 
+	if (hw->resetting) {
+		if (!add)
+			return 0;
+
+		PMD_DRV_LOG(ERR,
+			    "fail to add multicast MACs for VF resetting");
+		return -EIO;
+	}
+
 	len = sizeof(struct virtchnl_ether_addr_list);
 	len += sizeof(struct virtchnl_ether_addr) * mc_addrs_num;
 
@@ -1642,7 +1651,13 @@  ice_dcf_dev_close(struct rte_eth_dev *dev)
 	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
 		return 0;
 
-	(void)ice_dcf_dev_stop(dev);
+	if (adapter->parent.pf.adapter_stopped)
+		(void)ice_dcf_dev_stop(dev);
+
+	if (adapter->real_hw.resetting) {
+		ice_dcf_uninit_hw(dev, &adapter->real_hw);
+		ice_dcf_init_hw(dev, &adapter->real_hw);
+	}
 
 	ice_free_queues(dev);
 
diff --git a/drivers/net/ice/ice_dcf_parent.c b/drivers/net/ice/ice_dcf_parent.c
index 2f96dedcce..7f7ed796e2 100644
--- a/drivers/net/ice/ice_dcf_parent.c
+++ b/drivers/net/ice/ice_dcf_parent.c
@@ -240,6 +240,9 @@  ice_dcf_handle_pf_event_msg(struct ice_dcf_hw *dcf_hw,
 	case VIRTCHNL_EVENT_RESET_IMPENDING:
 		PMD_DRV_LOG(DEBUG, "VIRTCHNL_EVENT_RESET_IMPENDING event");
 		dcf_hw->resetting = true;
+		rte_eth_dev_callback_process(dcf_hw->eth_dev,
+					     RTE_ETH_EVENT_INTR_RESET,
+					     NULL);
 		break;
 	case VIRTCHNL_EVENT_LINK_CHANGE:
 		PMD_DRV_LOG(DEBUG, "VIRTCHNL_EVENT_LINK_CHANGE event");