Skip to contentSkip to conversation

net/iavf: fix duplicate VF reset during PF reset recovery

PATCH Superseded Anurag Mandal 3 participants 13 messages Jun 5 – Jun 11 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/iavf: fix duplicate VF reset during PF reset recovery

During PF initiated reset recovery, iavf_dev_close() sending an extra VIRTCHNL_OP_RESET_VF while recovery is already in progress. That second reset can leave PF/VF virtchnl state inconsistent and cause VIRTCHNL_OP_CONFIG_VSI_QUEUES to fail with ERR_PARAM after ToR link flap, leaving the VF unable to recover.
This results in connection loss.

Skipped close-time VF reset and related close-time virtchnl operations when PF triggered reset recovery is set. This is done to avoid a duplicate VF reset, and keep normal behavior for application-driven close.
Handled link-change events through a common static function that reads the correct advanced & legacy link fields properly and updates no-poll/watchdog/LSC state consistently.
Also added IAVF_ERR_ADMIN_QUEUE_NO_WORK in virtchnl message drain as a normal empty-queue condition and avoid logging it as an misleading AQ failure.

Fixes 675a104e2e94 ("net/iavf: fix abnormal disable HW interrupt")
Fixes b34fe66ea893 ("net/iavf: delay VF reset command")
Fixes 5e03e316c753 ("net/iavf: handle virtchnl event message without interrupt")
Fixes 5c8ca9f13c78 ("net/iavf: fix no polling mode switching")
Fixes 48de41ca11f0 ("net/avf: enable link status update")
Fixes 02d212ca3125 ("net/iavf: rename remaining avf strings")
---
 drivers/net/intel/iavf/iavf_ethdev.c |  36 ++++----
 drivers/net/intel/iavf/iavf_vchnl.c  | 130 +++++++++++++++------------
 2 files changed, 95 insertions(+), 71 deletions(-)
drivers/net/intel/iavf/iavf_ethdev.c +20 -16
index bdf650b822..a936748397 100644
@@ -3166,24 +3166,26 @@ iavf_dev_close(struct rte_eth_dev *dev)
 
 	ret = iavf_dev_stop(dev);
 
-	/*
-	 * Release redundant queue resource when close the dev
-	 * so that other vfs can re-use the queues.
-	 */
-	if (vf->lv_enabled) {
-		ret = iavf_request_queues(dev, IAVF_MAX_NUM_QUEUES_DFLT);
-		if (ret)
-			PMD_DRV_LOG(ERR, "Reset the num of queues failed");
+	/* Skip RESET_VF on a PF-initiated reset */
+	if (!vf->in_reset_recovery) {
+		/*
+		 * Release redundant queue resource when close the dev
+		 * so that other vfs can re-use the queues.
+		 */
+		if (vf->lv_enabled) {
+			ret = iavf_request_queues(dev, IAVF_MAX_NUM_QUEUES_DFLT);
+			if (ret)
+				PMD_DRV_LOG(ERR, "Reset the num of queues failed");
+			vf->max_rss_qregion = IAVF_MAX_NUM_QUEUES_DFLT;
+		}
 
-		vf->max_rss_qregion = IAVF_MAX_NUM_QUEUES_DFLT;
+		/* Disable promiscuous mode before resetting the VF. This is to avoid
+		 * potential issues when the PF is bound to the kernel driver.
+		 */
+		if (vf->promisc_unicast_enabled || vf->promisc_multicast_enabled)
+			iavf_config_promisc(adapter, false, false);
 	}
 
-	/* Disable promiscuous mode before resetting the VF. This is to avoid
-	 * potential issues when the PF is bound to the kernel driver.
-	 */
-	if (vf->promisc_unicast_enabled || vf->promisc_multicast_enabled)
-		iavf_config_promisc(adapter, false, false);
-
 	adapter->closed = true;
 
 	/* free iAVF security device context all related resources */
@@ -3195,7 +3197,9 @@ iavf_dev_close(struct rte_eth_dev *dev)
 	iavf_flow_flush(dev, NULL);
 	iavf_flow_uninit(adapter);
 
-	iavf_vf_reset(hw);
+	/* Skip RESET_VF on a PF-initiated reset */
+	if (!vf->in_reset_recovery)
+		iavf_vf_reset(hw);
 	vf->aq_intr_enabled = false;
 	iavf_shutdown_adminq(hw);
 	if (vf->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_WB_ON_ITR) {
drivers/net/intel/iavf/iavf_vchnl.c +75 -55

156 lines not on this page · raw message

Signature · 1 line
2.34.1
#1 lore raw

PATCH v2 1/1 net/iavf: fix duplicate VF reset during PF reset recovery

During PF initiated reset recovery, iavf_dev_close() sending an extra VIRTCHNL_OP_RESET_VF while recovery is already in progress. That second reset can leave PF/VF virtchnl state inconsistent and cause VIRTCHNL_OP_CONFIG_VSI_QUEUES to fail with ERR_PARAM after ToR link flap, leaving the VF unable to recover.
This results in connection loss.

Skipped close-time VF reset and related close-time virtchnl operations when PF triggered reset recovery is set. This is done to avoid a duplicate VF reset, and keep normal behavior for application-driven close.
Handled link-change events through a common static function that reads the correct advanced & legacy link fields properly and updates no-poll/watchdog/LSC state consistently.
Also added IAVF_ERR_ADMIN_QUEUE_NO_WORK in virtchnl message drain as a normal empty-queue condition and avoid logging it as an misleading AQ failure.

Fixes 675a104e2e94 ("net/iavf: fix abnormal disable HW interrupt")
Fixes b34fe66ea893 ("net/iavf: delay VF reset command")
Fixes 5e03e316c753 ("net/iavf: handle virtchnl event message without interrupt")
Fixes 5c8ca9f13c78 ("net/iavf: fix no polling mode switching")
Fixes 48de41ca11f0 ("net/avf: enable link status update")
Fixes 02d212ca3125 ("net/iavf: rename remaining avf strings")

---
V2: Addressed ai-code-review comments

 doc/guides/rel_notes/release_26_07.rst |   3 +
 drivers/net/intel/iavf/iavf_ethdev.c   |  37 ++++---
 drivers/net/intel/iavf/iavf_vchnl.c    | 146 +++++++++++++++----------
 3 files changed, 115 insertions(+), 71 deletions(-)
doc/guides/rel_notes/release_26_07.rst +3 -0
index b8a3e2ced9..914b61629b 100644
@@ -89,6 +89,9 @@ New Features
 
   * Added support for transmitting LLDP packets based on mbuf packet type.
   * Implemented AVX2 context descriptor transmit paths.
+  * Fixed duplicate 'VIRTCHNL_OP_RESET_VF' received during a PF-initiated
+    reset recovery resulting connection loss after a top-of-rack (ToR)
+    link flap/power-cycle.
 
 * **Updated PCAP ethernet driver.**
 
drivers/net/intel/iavf/iavf_ethdev.c +21 -16
index bdf650b822..fb6f287d3c 100644
@@ -3166,24 +3166,27 @@ iavf_dev_close(struct rte_eth_dev *dev)
 
 	ret = iavf_dev_stop(dev);
 
-	/*
-	 * Release redundant queue resource when close the dev
-	 * so that other vfs can re-use the queues.
-	 */
-	if (vf->lv_enabled) {
-		ret = iavf_request_queues(dev, IAVF_MAX_NUM_QUEUES_DFLT);
-		if (ret)
-			PMD_DRV_LOG(ERR, "Reset the num of queues failed");
+	/* Skip RESET_VF on a PF-initiated reset */
+	if (!adapter->closed && !vf->in_reset_recovery) {
+		/*
+		 * Release redundant queue resource when close the dev
+		 * so that other vfs can re-use the queues.
+		 */
+		if (vf->lv_enabled) {
+			ret = iavf_request_queues(dev, IAVF_MAX_NUM_QUEUES_DFLT);
+			if (ret)
+				PMD_DRV_LOG(ERR, "Reset the num of queues failed");
+			vf->max_rss_qregion = IAVF_MAX_NUM_QUEUES_DFLT;
+		}
 
-		vf->max_rss_qregion = IAVF_MAX_NUM_QUEUES_DFLT;
+		/*
+		 * Disable promiscuous mode before resetting the VF. This is to avoid
+		 * potential issues when the PF is bound to the kernel driver.
+		 */
+		if (vf->promisc_unicast_enabled || vf->promisc_multicast_enabled)
+			iavf_config_promisc(adapter, false, false);
 	}
 
-	/* Disable promiscuous mode before resetting the VF. This is to avoid
-	 * potential issues when the PF is bound to the kernel driver.
-	 */
-	if (vf->promisc_unicast_enabled || vf->promisc_multicast_enabled)
-		iavf_config_promisc(adapter, false, false);
-
 	adapter->closed = true;
 
 	/* free iAVF security device context all related resources */
@@ -3195,7 +3198,9 @@ iavf_dev_close(struct rte_eth_dev *dev)
 	iavf_flow_flush(dev, NULL);
 	iavf_flow_uninit(adapter);
 
-	iavf_vf_reset(hw);
+	/* Skip RESET_VF on a PF-initiated reset */
+	if (!vf->in_reset_recovery)
+		iavf_vf_reset(hw);
 	vf->aq_intr_enabled = false;
 	iavf_shutdown_adminq(hw);
 	if (vf->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_WB_ON_ITR) {
drivers/net/intel/iavf/iavf_vchnl.c +91 -55

172 lines not on this page · raw message

Signature · 1 line
2.34.1
#2 lore raw

PATCH v3 1/1 net/iavf: fix duplicate VF reset during PF reset recovery

In reply to Anurag Mandal

During PF initiated reset recovery, iavf_dev_close() sending an extra VIRTCHNL_OP_RESET_VF while recovery is already in progress. That second reset can leave PF/VF virtchnl state inconsistent and cause VIRTCHNL_OP_CONFIG_VSI_QUEUES to fail with ERR_PARAM after ToR link flap/power-cycle, leaving the VF unable to recover. This results in connection loss.

Skipped close-time VF reset and related close-time virtchnl operations when PF triggered reset recovery is set. This is done to avoid a duplicate VF reset, and keep normal behavior for application-driven close.
Handled link-change events through a common static function that reads the correct advanced & legacy link fields properly and updates no-poll/watchdog/LSC state consistently.
Also added IAVF_ERR_ADMIN_QUEUE_NO_WORK in virtchnl message drain as a normal empty-queue condition and avoid logging it as an misleading AQ failure.

Fixes 675a104e2e94 ("net/iavf: fix abnormal disable HW interrupt")
Fixes b34fe66ea893 ("net/iavf: delay VF reset command")
Fixes 5e03e316c753 ("net/iavf: handle virtchnl event message without interrupt")
Fixes 5c8ca9f13c78 ("net/iavf: fix no polling mode switching")
Fixes 48de41ca11f0 ("net/avf: enable link status update")
Fixes 02d212ca3125 ("net/iavf: rename remaining avf strings")

---
V3: Addressed latest ai-code-review comments
V2: Addressed ai-code-review comments

 doc/guides/rel_notes/release_26_07.rst |   3 +
 drivers/net/intel/iavf/iavf_ethdev.c   |  37 +++---
 drivers/net/intel/iavf/iavf_vchnl.c    | 155 ++++++++++++++++---------
 3 files changed, 123 insertions(+), 72 deletions(-)
doc/guides/rel_notes/release_26_07.rst +3 -0
index b8a3e2ced9..e7ac730369 100644
@@ -89,6 +89,9 @@ New Features
 
   * Added support for transmitting LLDP packets based on mbuf packet type.
   * Implemented AVX2 context descriptor transmit paths.
+  * Prevented duplicate 'VIRTCHNL_OP_RESET_VF' during a PF-initiated
+    reset recovery, which earlier caused virtchnl state corruption
+    and connection loss after a top-of-rack (ToR) link flap/power-cycle.
 
 * **Updated PCAP ethernet driver.**
 
drivers/net/intel/iavf/iavf_ethdev.c +21 -16
index bdf650b822..fb6f287d3c 100644
@@ -3166,24 +3166,27 @@ iavf_dev_close(struct rte_eth_dev *dev)
 
 	ret = iavf_dev_stop(dev);
 
-	/*
-	 * Release redundant queue resource when close the dev
-	 * so that other vfs can re-use the queues.
-	 */
-	if (vf->lv_enabled) {
-		ret = iavf_request_queues(dev, IAVF_MAX_NUM_QUEUES_DFLT);
-		if (ret)
-			PMD_DRV_LOG(ERR, "Reset the num of queues failed");
+	/* Skip RESET_VF on a PF-initiated reset */
+	if (!adapter->closed && !vf->in_reset_recovery) {
+		/*
+		 * Release redundant queue resource when close the dev
+		 * so that other vfs can re-use the queues.
+		 */
+		if (vf->lv_enabled) {
+			ret = iavf_request_queues(dev, IAVF_MAX_NUM_QUEUES_DFLT);
+			if (ret)
+				PMD_DRV_LOG(ERR, "Reset the num of queues failed");
+			vf->max_rss_qregion = IAVF_MAX_NUM_QUEUES_DFLT;
+		}
 
-		vf->max_rss_qregion = IAVF_MAX_NUM_QUEUES_DFLT;
+		/*
+		 * Disable promiscuous mode before resetting the VF. This is to avoid
+		 * potential issues when the PF is bound to the kernel driver.
+		 */
+		if (vf->promisc_unicast_enabled || vf->promisc_multicast_enabled)
+			iavf_config_promisc(adapter, false, false);
 	}
 
-	/* Disable promiscuous mode before resetting the VF. This is to avoid
-	 * potential issues when the PF is bound to the kernel driver.
-	 */
-	if (vf->promisc_unicast_enabled || vf->promisc_multicast_enabled)
-		iavf_config_promisc(adapter, false, false);
-
 	adapter->closed = true;
 
 	/* free iAVF security device context all related resources */
@@ -3195,7 +3198,9 @@ iavf_dev_close(struct rte_eth_dev *dev)
 	iavf_flow_flush(dev, NULL);
 	iavf_flow_uninit(adapter);
 
-	iavf_vf_reset(hw);
+	/* Skip RESET_VF on a PF-initiated reset */
+	if (!vf->in_reset_recovery)
+		iavf_vf_reset(hw);
 	vf->aq_intr_enabled = false;
 	iavf_shutdown_adminq(hw);
 	if (vf->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_WB_ON_ITR) {
drivers/net/intel/iavf/iavf_vchnl.c +99 -56

185 lines not on this page · raw message

Signature · 1 line
2.34.1
#3 lore raw
Quoted 20 lines

Subject: [PATCH v3] net/iavf: fix duplicate VF reset during PF reset recovery

During PF initiated reset recovery, iavf_dev_close() sending an extra VIRTCHNL_OP_RESET_VF while recovery is already in progress. That second reset can leave PF/VF virtchnl state inconsistent and cause VIRTCHNL_OP_CONFIG_VSI_QUEUES to fail with ERR_PARAM after ToR link flap/power-cycle, leaving the VF unable to recover. This results in connection loss.

Skipped close-time VF reset and related close-time virtchnl operations when PF triggered reset recovery is set. This is done to avoid a duplicate VF reset, and keep normal behavior for application-driven close.
Handled link-change events through a common static function that reads the correct advanced & legacy link fields properly and updates no-poll/watchdog/LSC state consistently.
Also added IAVF_ERR_ADMIN_QUEUE_NO_WORK in virtchnl message drain as a normal empty-queue condition and avoid logging it as an misleading AQ failure.

Quoted 8 lines
Fixes 675a104e2e94 ("net/iavf: fix abnormal disable HW interrupt")
Fixes b34fe66ea893 ("net/iavf: delay VF reset command")
Fixes 5e03e316c753 ("net/iavf: handle virtchnl event message without

interrupt")

Fixes 5c8ca9f13c78 ("net/iavf: fix no polling mode switching")
Fixes 48de41ca11f0 ("net/avf: enable link status update")
Fixes 02d212ca3125 ("net/iavf: rename remaining avf strings")

Hi Anurag,

Thanks for the patch. There seems to be multiple logical fixes/changes in here and I think it would be good to split them into individual patches, each with their own Fixes tag where relevant. Having multiple fixes in one patch with multiple Fixes tags makes backporting tricky. I think at least logic which prevents the RESET_VF during a PF initiated reset should be split out from the link-change logic.

Thanks,
Ciara

Quoted 37 lines

---
V3: Addressed latest ai-code-review comments
V2: Addressed ai-code-review comments

 doc/guides/rel_notes/release_26_07.rst |   3 +
 drivers/net/intel/iavf/iavf_ethdev.c   |  37 +++---
 drivers/net/intel/iavf/iavf_vchnl.c    | 155 ++++++++++++++++---------
 3 files changed, 123 insertions(+), 72 deletions(-)
doc/guides/rel_notes/release_26_07.rst +3 -0
index b8a3e2ced9..e7ac730369 100644
@@ -89,6 +89,9 @@ New Features
 
   * Added support for transmitting LLDP packets based on mbuf packet type.
   * Implemented AVX2 context descriptor transmit paths.
+  * Prevented duplicate 'VIRTCHNL_OP_RESET_VF' during a PF-initiated
+    reset recovery, which earlier caused virtchnl state corruption
+    and connection loss after a top-of-rack (ToR) link flap/power-cycle.
 
 * **Updated PCAP ethernet driver.**
 
drivers/net/intel/iavf/iavf_ethdev.c +0 -2
index bdf650b822..fb6f287d3c 100644
@@ -3166,24 +3166,27 @@ iavf_dev_close(struct rte_eth_dev *dev)
 
 	ret = iavf_dev_stop(dev);
 
-	/*
-	 * Release redundant queue resource when close the dev

drivers/net/intel/iavf/iavf_ethdev.c iavf_dev_close(struct rte_eth_dev *dev) · line 3172

Quoted 10 lines
drivers/net/intel/iavf/iavf_ethdev.c +2 -6
-	 * so that other vfs can re-use the queues.
-	 */
-	if (vf->lv_enabled) {
-		ret = iavf_request_queues(dev,
 IAVF_MAX_NUM_QUEUES_DFLT);
-		if (ret)
-			PMD_DRV_LOG(ERR, "Reset the num of queues
 failed");
+	/* Skip RESET_VF on a PF-initiated reset */
+	if (!adapter->closed && !vf->in_reset_recovery) {

adapter->closed will always be false here so the check is redundant.

Quoted 14 lines
drivers/net/intel/iavf/iavf_ethdev.c +10 -0
+		/*
+		 * Release redundant queue resource when close the dev
+		 * so that other vfs can re-use the queues.
+		 */
+		if (vf->lv_enabled) {
+			ret = iavf_request_queues(dev,
 IAVF_MAX_NUM_QUEUES_DFLT);
+			if (ret)
+				PMD_DRV_LOG(ERR, "Reset the num of
 queues failed");
+			vf->max_rss_qregion =
 IAVF_MAX_NUM_QUEUES_DFLT;
+		}
 
#4 lore raw
Quoted 49 lines

-----Original Message-----
From: Loftus, Ciara <[email protected]>
Sent: 08 June 2026 15:29
To: Mandal, Anurag <[email protected]>; [email protected]
Cc: Richardson, Bruce <[email protected]>; Medvedkin, Vladimir <[email protected]>; Mandal, Anurag <[email protected]>; [email protected]
Subject: RE: [PATCH v3] net/iavf: fix duplicate VF reset during PF reset recovery

Quoted 10 lines

Subject: [PATCH v3] net/iavf: fix duplicate VF reset during PF reset recovery

During PF initiated reset recovery, iavf_dev_close() sending an extra VIRTCHNL_OP_RESET_VF while recovery is already in progress. That second reset can leave PF/VF virtchnl state inconsistent and cause VIRTCHNL_OP_CONFIG_VSI_QUEUES to fail with ERR_PARAM after ToR link flap/power-cycle, leaving the VF unable to recover. This results in connection loss.

Quoted 8 lines

Skipped close-time VF reset and related close-time virtchnl operations when PF triggered reset recovery is set. This is done to avoid a duplicate VF reset, and keep normal behavior for application-driven close.
Handled link-change events through a common static function that reads the correct advanced & legacy link fields properly and updates no-poll/watchdog/LSC state consistently.
Also added IAVF_ERR_ADMIN_QUEUE_NO_WORK in virtchnl message drain

as a

Quoted 11 lines

normal empty-queue condition and avoid logging it as an misleading AQ failure.

Fixes 675a104e2e94 ("net/iavf: fix abnormal disable HW interrupt")
Fixes b34fe66ea893 ("net/iavf: delay VF reset command")
Fixes 5e03e316c753 ("net/iavf: handle virtchnl event message without

interrupt")

Fixes 5c8ca9f13c78 ("net/iavf: fix no polling mode switching")
Fixes 48de41ca11f0 ("net/avf: enable link status update")
Fixes 02d212ca3125 ("net/iavf: rename remaining avf strings")

Hi Anurag,

Thanks for the patch. There seems to be multiple logical fixes/changes in here and I think it would be good to split them into individual patches, each with their own Fixes tag where relevant. Having multiple fixes in one patch with multiple Fixes tags makes backporting tricky.
I think at least logic which prevents the RESET_VF during a PF initiated reset should be split out from the link-change logic.

Quoted 3 lines

Thanks,
Ciara

Hi Ciara,

Thank you for your review comment. I have split the VF reset changes and sent patch v4 for the same. Others, I will put fresh patch.

Kindly review.

Thanks,
Anurag

Quoted 65 lines
Quoted 37 lines

---
V3: Addressed latest ai-code-review comments
V2: Addressed ai-code-review comments

 doc/guides/rel_notes/release_26_07.rst |   3 +
 drivers/net/intel/iavf/iavf_ethdev.c   |  37 +++---
 drivers/net/intel/iavf/iavf_vchnl.c    | 155 ++++++++++++++++---------
 3 files changed, 123 insertions(+), 72 deletions(-)
doc/guides/rel_notes/release_26_07.rst +3 -0
index b8a3e2ced9..e7ac730369 100644
@@ -89,6 +89,9 @@ New Features
 
   * Added support for transmitting LLDP packets based on mbuf packet type.
   * Implemented AVX2 context descriptor transmit paths.
+  * Prevented duplicate 'VIRTCHNL_OP_RESET_VF' during a PF-initiated
+    reset recovery, which earlier caused virtchnl state corruption
+    and connection loss after a top-of-rack (ToR) link flap/power-cycle.
 
 * **Updated PCAP ethernet driver.**
 
drivers/net/intel/iavf/iavf_ethdev.c +0 -2
index bdf650b822..fb6f287d3c 100644
@@ -3166,24 +3166,27 @@ iavf_dev_close(struct rte_eth_dev *dev)
 
 	ret = iavf_dev_stop(dev);
 
-	/*
-	 * Release redundant queue resource when close the dev

drivers/net/intel/iavf/iavf_ethdev.c iavf_dev_close(struct rte_eth_dev *dev) · line 3172

Quoted 10 lines
drivers/net/intel/iavf/iavf_ethdev.c +2 -6
-	 * so that other vfs can re-use the queues.
-	 */
-	if (vf->lv_enabled) {
-		ret = iavf_request_queues(dev,
 IAVF_MAX_NUM_QUEUES_DFLT);
-		if (ret)
-			PMD_DRV_LOG(ERR, "Reset the num of queues
 failed");
+	/* Skip RESET_VF on a PF-initiated reset */
+	if (!adapter->closed && !vf->in_reset_recovery) {

adapter->closed will always be false here so the check is redundant.

Quoted 14 lines
drivers/net/intel/iavf/iavf_ethdev.c +10 -0
+		/*
+		 * Release redundant queue resource when close the dev
+		 * so that other vfs can re-use the queues.
+		 */
+		if (vf->lv_enabled) {
+			ret = iavf_request_queues(dev,
 IAVF_MAX_NUM_QUEUES_DFLT);
+			if (ret)
+				PMD_DRV_LOG(ERR, "Reset the num of
 queues failed");
+			vf->max_rss_qregion =
 IAVF_MAX_NUM_QUEUES_DFLT;
+		}
 
#5 lore raw

PATCH v4 1/1 net/iavf: fix duplicate VF reset during PF reset recovery

In reply to Anurag Mandal

During PF initiated reset recovery, iavf_dev_close() sending an extra VIRTCHNL_OP_RESET_VF while recovery is already in progress. That second reset can leave PF/VF virtchnl state inconsistent and cause VIRTCHNL_OP_CONFIG_VSI_QUEUES to fail with ERR_PARAM after ToR link flap/power-cycle, leaving the VF unable to recover. This results in connection loss.

This patch skipped close-time VF reset and related close-time virtchnl operations when PF triggered reset recovery is set. This is done to avoid a duplicate VF reset, and keep normal behavior for application-driven close.

Fixes 675a104e2e94 ("net/iavf: fix abnormal disable HW interrupt")
Fixes b34fe66ea893 ("net/iavf: delay VF reset command")
Fixes 5e03e316c753 ("net/iavf: handle virtchnl event message without interrupt")

---
V4: Addressed Ciara Loftus comments
- split VF reset from other code changes
V3: Addressed latest ai-code-review comments
V2: Addressed ai-code-review comments

 doc/guides/rel_notes/release_26_07.rst |  3 +++
 drivers/net/intel/iavf/iavf_ethdev.c   | 37 +++++++++++++++-----------
 drivers/net/intel/iavf/iavf_vchnl.c    | 18 ++++++++++---
 3 files changed, 39 insertions(+), 19 deletions(-)
doc/guides/rel_notes/release_26_07.rst +3 -0
index d2563ac503..f6899a78c3 100644
@@ -95,6 +95,9 @@ New Features
 
   * Added support for transmitting LLDP packets based on mbuf packet type.
   * Implemented AVX2 context descriptor transmit paths.
+  * Prevented duplicate 'VIRTCHNL_OP_RESET_VF' during a PF-initiated
+    reset recovery, which earlier caused virtchnl state corruption
+    and connection loss after a top-of-rack (ToR) link flap/power-cycle.
 
 * **Updated PCAP ethernet driver.**
 
drivers/net/intel/iavf/iavf_ethdev.c +21 -16
index a8031e23a5..99457ae510 100644
@@ -3166,24 +3166,27 @@ iavf_dev_close(struct rte_eth_dev *dev)
 
 	ret = iavf_dev_stop(dev);
 
-	/*
-	 * Release redundant queue resource when close the dev
-	 * so that other vfs can re-use the queues.
-	 */
-	if (vf->lv_enabled) {
-		ret = iavf_request_queues(dev, IAVF_MAX_NUM_QUEUES_DFLT);
-		if (ret)
-			PMD_DRV_LOG(ERR, "Reset the num of queues failed");
+	/* Skip RESET_VF on a PF-initiated reset */
+	if (!adapter->closed && !vf->in_reset_recovery) {
+		/*
+		 * Release redundant queue resource when close the dev
+		 * so that other vfs can re-use the queues.
+		 */
+		if (vf->lv_enabled) {
+			ret = iavf_request_queues(dev, IAVF_MAX_NUM_QUEUES_DFLT);
+			if (ret)
+				PMD_DRV_LOG(ERR, "Reset the num of queues failed");
+			vf->max_rss_qregion = IAVF_MAX_NUM_QUEUES_DFLT;
+		}
 
-		vf->max_rss_qregion = IAVF_MAX_NUM_QUEUES_DFLT;
+		/*
+		 * Disable promiscuous mode before resetting the VF. This is to avoid
+		 * potential issues when the PF is bound to the kernel driver.
+		 */
+		if (vf->promisc_unicast_enabled || vf->promisc_multicast_enabled)
+			iavf_config_promisc(adapter, false, false);
 	}
 
-	/* Disable promiscuous mode before resetting the VF. This is to avoid
-	 * potential issues when the PF is bound to the kernel driver.
-	 */
-	if (vf->promisc_unicast_enabled || vf->promisc_multicast_enabled)
-		iavf_config_promisc(adapter, false, false);
-
 	adapter->closed = true;
 
 	/* free iAVF security device context all related resources */
@@ -3195,7 +3198,9 @@ iavf_dev_close(struct rte_eth_dev *dev)
 	iavf_flow_flush(dev, NULL);
 	iavf_flow_uninit(adapter);
 
-	iavf_vf_reset(hw);
+	/* Skip RESET_VF on a PF-initiated reset */
+	if (!vf->in_reset_recovery)
+		iavf_vf_reset(hw);
 	vf->aq_intr_enabled = false;
 	iavf_shutdown_adminq(hw);
 	if (vf->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_WB_ON_ITR) {
drivers/net/intel/iavf/iavf_vchnl.c +15 -3
index 94ccfb5d6e..cf3513ef94 100644
@@ -283,9 +283,21 @@ 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;
-			iavf_set_no_poll(adapter, false);
-			PMD_DRV_LOG(INFO, "VF is resetting");
+			/*
+			 * Force link down on impending reset to drop
+			 * the cached link-up state; a fresh LSC up
+			 * event will be re-issued by the PF once the
+			 * VF is reinitialised.
+			 */
+			vf->link_up = false;
+			if (!vf->vf_reset) {
+				vf->vf_reset = true;
+				iavf_set_no_poll(adapter, false);
+				iavf_dev_event_post(vf->eth_dev,
+					RTE_ETH_EVENT_INTR_RESET,
+					NULL, 0);
+			}
+			PMD_DRV_LOG(DEBUG, "VF is resetting");
 			break;
 		case VIRTCHNL_EVENT_PF_DRIVER_CLOSE:
 			vf->dev_closed = true;
Signature · 1 line
2.34.1
#6 lore raw
Quoted 58 lines

Subject: [PATCH v4] net/iavf: fix duplicate VF reset during PF reset recovery

During PF initiated reset recovery, iavf_dev_close() sending an extra VIRTCHNL_OP_RESET_VF while recovery is already in progress. That second reset can leave PF/VF virtchnl state inconsistent and cause VIRTCHNL_OP_CONFIG_VSI_QUEUES to fail with ERR_PARAM after ToR link flap/power-cycle, leaving the VF unable to recover. This results in connection loss.

This patch skipped close-time VF reset and related close-time virtchnl operations when PF triggered reset recovery is set. This is done to avoid a duplicate VF reset, and keep normal behavior for application-driven close.

Fixes 675a104e2e94 ("net/iavf: fix abnormal disable HW interrupt")
Fixes b34fe66ea893 ("net/iavf: delay VF reset command")
Fixes 5e03e316c753 ("net/iavf: handle virtchnl event message without

interrupt")
Cc: [email protected]

---
V4: Addressed Ciara Loftus comments
- split VF reset from other code changes
V3: Addressed latest ai-code-review comments
V2: Addressed ai-code-review comments

 doc/guides/rel_notes/release_26_07.rst |  3 +++
 drivers/net/intel/iavf/iavf_ethdev.c   | 37 +++++++++++++++-----------
 drivers/net/intel/iavf/iavf_vchnl.c    | 18 ++++++++++---
 3 files changed, 39 insertions(+), 19 deletions(-)
doc/guides/rel_notes/release_26_07.rst +3 -0
index d2563ac503..f6899a78c3 100644
@@ -95,6 +95,9 @@ New Features
 
   * Added support for transmitting LLDP packets based on mbuf packet type.
   * Implemented AVX2 context descriptor transmit paths.
+  * Prevented duplicate 'VIRTCHNL_OP_RESET_VF' during a PF-initiated
+    reset recovery, which earlier caused virtchnl state corruption
+    and connection loss after a top-of-rack (ToR) link flap/power-cycle.
 
 * **Updated PCAP ethernet driver.**
 
drivers/net/intel/iavf/iavf_ethdev.c +0 -2
index a8031e23a5..99457ae510 100644
@@ -3166,24 +3166,27 @@ iavf_dev_close(struct rte_eth_dev *dev)
 
 	ret = iavf_dev_stop(dev);
 
-	/*
-	 * Release redundant queue resource when close the dev

drivers/net/intel/iavf/iavf_ethdev.c iavf_dev_close(struct rte_eth_dev *dev) · line 3172

Quoted 10 lines
drivers/net/intel/iavf/iavf_ethdev.c +2 -6
-	 * so that other vfs can re-use the queues.
-	 */
-	if (vf->lv_enabled) {
-		ret = iavf_request_queues(dev,
 IAVF_MAX_NUM_QUEUES_DFLT);
-		if (ret)
-			PMD_DRV_LOG(ERR, "Reset the num of queues
 failed");
+	/* Skip RESET_VF on a PF-initiated reset */
+	if (!adapter->closed && !vf->in_reset_recovery) {

adapter->closed will always be false here so no need to check it.

vf->in_reset_recovery is set for a VF initiated reset as well which does require sending VIRTCHNL_OP_RESET_VF because that kicks off the reset. (rte_pmd_iavf_reinit -> handle_hw_reset is the vf initiated reset path.)

We need some way to know if we are currently handling a PF initiated reset here. Another adapter flag, or else make in_reset_recovery tri-state eg. 0 (no reset) 1 (pf initiated) 2 (vf initiated) Then skip the OP_RESET_VF if pf initiated.

Quoted 79 lines
drivers/net/intel/iavf/iavf_ethdev.c +12 -1
+		/*
+		 * Release redundant queue resource when close the dev
+		 * so that other vfs can re-use the queues.
+		 */
+		if (vf->lv_enabled) {
+			ret = iavf_request_queues(dev,
 IAVF_MAX_NUM_QUEUES_DFLT);
+			if (ret)
+				PMD_DRV_LOG(ERR, "Reset the num of
 queues failed");
+			vf->max_rss_qregion =
 IAVF_MAX_NUM_QUEUES_DFLT;
+		}
 
-		vf->max_rss_qregion = IAVF_MAX_NUM_QUEUES_DFLT;
+		/*
+		 * Disable promiscuous mode before resetting the VF. This is to

avoid

drivers/net/intel/iavf/iavf_ethdev.c +3 -0
+		 * potential issues when the PF is bound to the kernel driver.
+		 */
+		if (vf->promisc_unicast_enabled || vf-
Quoted 1 line

promisc_multicast_enabled)

drivers/net/intel/iavf/iavf_ethdev.c +4 -7
+			iavf_config_promisc(adapter, false, false);
 	}
 
-	/* Disable promiscuous mode before resetting the VF. This is to avoid
-	 * potential issues when the PF is bound to the kernel driver.
-	 */
-	if (vf->promisc_unicast_enabled || vf->promisc_multicast_enabled)
-		iavf_config_promisc(adapter, false, false);
-
 	adapter->closed = true;
 
 	/* free iAVF security device context all related resources */
@@ -3195,7 +3198,9 @@ iavf_dev_close(struct rte_eth_dev *dev)
 	iavf_flow_flush(dev, NULL);
 	iavf_flow_uninit(adapter);
 
-	iavf_vf_reset(hw);
+	/* Skip RESET_VF on a PF-initiated reset */
+	if (!vf->in_reset_recovery)
+		iavf_vf_reset(hw);
 	vf->aq_intr_enabled = false;
 	iavf_shutdown_adminq(hw);
 	if (vf->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_WB_ON_ITR)

{

drivers/net/intel/iavf/iavf_vchnl.c +15 -3
index 94ccfb5d6e..cf3513ef94 100644
@@ -283,9 +283,21 @@ 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;
-			iavf_set_no_poll(adapter, false);
-			PMD_DRV_LOG(INFO, "VF is resetting");
+			/*
+			 * Force link down on impending reset to drop
+			 * the cached link-up state; a fresh LSC up
+			 * event will be re-issued by the PF once the
+			 * VF is reinitialised.
+			 */
+			vf->link_up = false;
+			if (!vf->vf_reset) {
+				vf->vf_reset = true;
+				iavf_set_no_poll(adapter, false);
+				iavf_dev_event_post(vf->eth_dev,
+					RTE_ETH_EVENT_INTR_RESET,
+					NULL, 0);
+			}
+			PMD_DRV_LOG(DEBUG, "VF is resetting");
 			break;
 		case VIRTCHNL_EVENT_PF_DRIVER_CLOSE:

vf->dev_closed = true;
--
2.34.1

#7 lore raw

PATCH v5 1/1 net/iavf: fix duplicate VF reset during PF reset recovery

In reply to Anurag Mandal

During PF initiated reset recovery, iavf_dev_close() sending an extra VIRTCHNL_OP_RESET_VF while recovery is already in progress. That second reset can leave PF/VF virtchnl state inconsistent and cause VIRTCHNL_OP_CONFIG_VSI_QUEUES to fail with ERR_PARAM after ToR link flap/power-cycle, leaving the VF unable to recover. This results in connection loss.

This patch introduces a new flag 'pf_reset_in_progress', that is set only when iavf_handle_hw_reset() is entered with vf_initiated_reset as false and is cleared on exit. Also, close-time VF reset and related close-time virtchnl operations are skipped when PF triggered reset recovery is set. This is done to avoid a duplicate VF reset, and keep normal behavior for application-driven close or VF-initiated reinit.

Fixes 675a104e2e94 ("net/iavf: fix abnormal disable HW interrupt")
Fixes b34fe66ea893 ("net/iavf: delay VF reset command")
Fixes 5e03e316c753 ("net/iavf: handle virtchnl event message without interrupt")

---
V5: Addressed Ciara Loftus's comments
- added separate flag for PF initiated reset recovery
V4: Addressed Ciara Loftus's comments
- split VF reset from other code changes
V3: Addressed latest ai-code-review comments
V2: Addressed ai-code-review comments

 doc/guides/rel_notes/release_26_07.rst |  3 ++
 drivers/net/intel/iavf/iavf.h          |  7 +++++
 drivers/net/intel/iavf/iavf_ethdev.c   | 40 +++++++++++++++-----------
 drivers/net/intel/iavf/iavf_vchnl.c    | 18 ++++++++++--
 4 files changed, 49 insertions(+), 19 deletions(-)
doc/guides/rel_notes/release_26_07.rst +3 -0
index d2563ac503..f6899a78c3 100644
@@ -95,6 +95,9 @@ New Features
 
   * Added support for transmitting LLDP packets based on mbuf packet type.
   * Implemented AVX2 context descriptor transmit paths.
+  * Prevented duplicate 'VIRTCHNL_OP_RESET_VF' during a PF-initiated
+    reset recovery, which earlier caused virtchnl state corruption
+    and connection loss after a top-of-rack (ToR) link flap/power-cycle.
 
 * **Updated PCAP ethernet driver.**
 
drivers/net/intel/iavf/iavf.h +7 -0
index 2615b6f034..67aacbe7a6 100644
@@ -292,6 +292,13 @@ struct iavf_info {
 
 	bool in_reset_recovery;
 
+	/*
+	 * Set only while iavf_handle_hw_reset()
+	 * is processing a PF-initiated reset
+	 * (vf_initiated_reset == false).
+	 */
+	bool pf_reset_in_progress;
+
 	uint32_t ptp_caps;
 	rte_spinlock_t phc_time_aq_lock;
 };
drivers/net/intel/iavf/iavf_ethdev.c +24 -16
index a8031e23a5..2b6f4daa99 100644
@@ -3166,23 +3166,27 @@ iavf_dev_close(struct rte_eth_dev *dev)
 
 	ret = iavf_dev_stop(dev);
 
-	/*
-	 * Release redundant queue resource when close the dev
-	 * so that other vfs can re-use the queues.
-	 */
-	if (vf->lv_enabled) {
-		ret = iavf_request_queues(dev, IAVF_MAX_NUM_QUEUES_DFLT);
-		if (ret)
-			PMD_DRV_LOG(ERR, "Reset the num of queues failed");
+	/* Skip RESET_VF on a PF-initiated reset */
+	if (!vf->pf_reset_in_progress) {
 
-		vf->max_rss_qregion = IAVF_MAX_NUM_QUEUES_DFLT;
-	}
+		/*
+		 * Release redundant queue resource when close the dev
+		 * so that other vfs can re-use the queues.
+		 */
+		if (vf->lv_enabled) {
+			ret = iavf_request_queues(dev, IAVF_MAX_NUM_QUEUES_DFLT);
+			if (ret)
+				PMD_DRV_LOG(ERR, "Reset the num of queues failed");
+			vf->max_rss_qregion = IAVF_MAX_NUM_QUEUES_DFLT;
+		}
 
-	/* Disable promiscuous mode before resetting the VF. This is to avoid
-	 * potential issues when the PF is bound to the kernel driver.
-	 */
-	if (vf->promisc_unicast_enabled || vf->promisc_multicast_enabled)
-		iavf_config_promisc(adapter, false, false);
+		/*
+		 * Disable promiscuous mode before resetting the VF. This is to avoid
+		 * potential issues when the PF is bound to the kernel driver.
+		 */
+		if (vf->promisc_unicast_enabled || vf->promisc_multicast_enabled)
+			iavf_config_promisc(adapter, false, false);
+	}
 
 	adapter->closed = true;
 
@@ -3195,7 +3199,9 @@ iavf_dev_close(struct rte_eth_dev *dev)
 	iavf_flow_flush(dev, NULL);
 	iavf_flow_uninit(adapter);
 
-	iavf_vf_reset(hw);
+	/* Skip RESET_VF on a PF-initiated reset */
+	if (!vf->pf_reset_in_progress)
+		iavf_vf_reset(hw);
 	vf->aq_intr_enabled = false;
 	iavf_shutdown_adminq(hw);
 	if (vf->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_WB_ON_ITR) {
@@ -3368,6 +3374,7 @@ iavf_handle_hw_reset(struct rte_eth_dev *dev, bool vf_initiated_reset)
 	}
 
 	vf->in_reset_recovery = true;
+	vf->pf_reset_in_progress = !vf_initiated_reset;
 	iavf_set_no_poll(adapter, false);
 
 	/* Call the pre reset callback */
@@ -3418,6 +3425,7 @@ iavf_handle_hw_reset(struct rte_eth_dev *dev, bool vf_initiated_reset)
 		vf->post_reset_cb(dev->data->port_id, ret, vf->post_reset_cb_arg);
 
 	vf->in_reset_recovery = false;
+	vf->pf_reset_in_progress = false;
 	iavf_set_no_poll(adapter, false);
 
 	return;
drivers/net/intel/iavf/iavf_vchnl.c +15 -3
index 94ccfb5d6e..cf3513ef94 100644
@@ -283,9 +283,21 @@ 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;
-			iavf_set_no_poll(adapter, false);
-			PMD_DRV_LOG(INFO, "VF is resetting");
+			/*
+			 * Force link down on impending reset to drop
+			 * the cached link-up state; a fresh LSC up
+			 * event will be re-issued by the PF once the
+			 * VF is reinitialised.
+			 */
+			vf->link_up = false;
+			if (!vf->vf_reset) {
+				vf->vf_reset = true;
+				iavf_set_no_poll(adapter, false);
+				iavf_dev_event_post(vf->eth_dev,
+					RTE_ETH_EVENT_INTR_RESET,
+					NULL, 0);
+			}
+			PMD_DRV_LOG(DEBUG, "VF is resetting");
 			break;
 		case VIRTCHNL_EVENT_PF_DRIVER_CLOSE:
 			vf->dev_closed = true;
Signature · 1 line
2.34.1
Acked-by on v5 1/1
#8 lore raw
Quoted 17 lines

Subject: [PATCH v5] net/iavf: fix duplicate VF reset during PF reset recovery

During PF initiated reset recovery, iavf_dev_close() sending an extra VIRTCHNL_OP_RESET_VF while recovery is already in progress. That second reset can leave PF/VF virtchnl state inconsistent and cause VIRTCHNL_OP_CONFIG_VSI_QUEUES to fail with ERR_PARAM after ToR link flap/power-cycle, leaving the VF unable to recover. This results in connection loss.

This patch introduces a new flag 'pf_reset_in_progress', that is set only when iavf_handle_hw_reset() is entered with vf_initiated_reset as false and is cleared on exit. Also, close-time VF reset and related close-time virtchnl operations are skipped when PF triggered reset recovery is set. This is done to avoid a duplicate VF reset, and keep normal behavior for application-driven close or VF-initiated reinit.

Quoted 7 lines
Fixes 675a104e2e94 ("net/iavf: fix abnormal disable HW interrupt")
Fixes b34fe66ea893 ("net/iavf: delay VF reset command")
Fixes 5e03e316c753 ("net/iavf: handle virtchnl event message without

interrupt")
Cc: [email protected]

I think you may need to respin due to patch application failure. I have some suggestions for improving the comments/release notes that you could include in the next version. Code looks good to me.

Quoted 20 lines

---
V5: Addressed Ciara Loftus's comments
- added separate flag for PF initiated reset recovery
V4: Addressed Ciara Loftus's comments
- split VF reset from other code changes
V3: Addressed latest ai-code-review comments
V2: Addressed ai-code-review comments

 doc/guides/rel_notes/release_26_07.rst |  3 ++
 drivers/net/intel/iavf/iavf.h          |  7 +++++
 drivers/net/intel/iavf/iavf_ethdev.c   | 40 +++++++++++++++-----------
 drivers/net/intel/iavf/iavf_vchnl.c    | 18 ++++++++++--
 4 files changed, 49 insertions(+), 19 deletions(-)
doc/guides/rel_notes/release_26_07.rst +0 -0
index d2563ac503..f6899a78c3 100644

doc/guides/rel_notes/release_26_07.rst New Features · line 100

Quoted 6 lines
doc/guides/rel_notes/release_26_07.rst +3 -0
@@ -95,6 +95,9 @@ New Features
 
   * Added support for transmitting LLDP packets based on mbuf packet type.
   * Implemented AVX2 context descriptor transmit paths.
+  * Prevented duplicate 'VIRTCHNL_OP_RESET_VF' during a PF-initiated
+    reset recovery, which earlier caused virtchnl state corruption
+    and connection loss after a top-of-rack (ToR) link flap/power-cycle.

I think something more concise here would be better.
eg. "Fixed duplicate send of 'VIRTCHNL_OP_RESET_VF' during PF reset recovery which could cause virtchnl state corruption"

Quoted 8 lines
doc/guides/rel_notes/release_26_07.rst +0 -0
 * **Updated PCAP ethernet driver.**
 
drivers/net/intel/iavf/iavf.h +0 -0
index 2615b6f034..67aacbe7a6 100644

drivers/net/intel/iavf/iavf.h struct iavf_info { · line 299

Quoted 8 lines
drivers/net/intel/iavf/iavf.h +5 -0
@@ -292,6 +292,13 @@ struct iavf_info {
 
 	bool in_reset_recovery;
 
+	/*
+	 * Set only while iavf_handle_hw_reset()
+	 * is processing a PF-initiated reset
+	 * (vf_initiated_reset == false).
+	 */

I don't think a comment is warranted here, the variable name is self-explanatory.

Quoted 15 lines
drivers/net/intel/iavf/iavf.h +2 -0
+	bool pf_reset_in_progress;
+
 	uint32_t ptp_caps;
 	rte_spinlock_t phc_time_aq_lock;
 };
drivers/net/intel/iavf/iavf_ethdev.c +0 -1
index a8031e23a5..2b6f4daa99 100644
@@ -3166,23 +3166,27 @@ iavf_dev_close(struct rte_eth_dev *dev)
 
 	ret = iavf_dev_stop(dev);
 
-	/*

drivers/net/intel/iavf/iavf_ethdev.c iavf_dev_close(struct rte_eth_dev *dev) · line 3171

Quoted 10 lines
drivers/net/intel/iavf/iavf_ethdev.c +1 -7
-	 * Release redundant queue resource when close the dev
-	 * so that other vfs can re-use the queues.
-	 */
-	if (vf->lv_enabled) {
-		ret = iavf_request_queues(dev,
 IAVF_MAX_NUM_QUEUES_DFLT);
-		if (ret)
-			PMD_DRV_LOG(ERR, "Reset the num of queues
 failed");
+	/* Skip RESET_VF on a PF-initiated reset */

Regarding the comment above, here we're not skipping RESET_VF rather preventing sending virtchnl messages to the adminq during the PF-initiated reset. I suggest rewording the comment to reflect that.

Quoted 15 lines
drivers/net/intel/iavf/iavf_ethdev.c +10 -2
+	if (!vf->pf_reset_in_progress) {
 
-		vf->max_rss_qregion = IAVF_MAX_NUM_QUEUES_DFLT;
-	}
+		/*
+		 * Release redundant queue resource when close the dev
+		 * so that other vfs can re-use the queues.
+		 */
+		if (vf->lv_enabled) {
+			ret = iavf_request_queues(dev,
 IAVF_MAX_NUM_QUEUES_DFLT);
+			if (ret)
+				PMD_DRV_LOG(ERR, "Reset the num of
 queues failed");
+			vf->max_rss_qregion =
#9 lore raw
Quoted 123 lines

-----Original Message-----
From: Loftus, Ciara <[email protected]>
Sent: 10 June 2026 16:20
To: Mandal, Anurag <[email protected]>; [email protected]
Cc: Richardson, Bruce <[email protected]>; Medvedkin, Vladimir <[email protected]>; [email protected]
Subject: RE: [PATCH v5] net/iavf: fix duplicate VF reset during PF reset recovery

Quoted 18 lines

Subject: [PATCH v5] net/iavf: fix duplicate VF reset during PF reset recovery

During PF initiated reset recovery, iavf_dev_close() sending an extra VIRTCHNL_OP_RESET_VF while recovery is already in progress. That second reset can leave PF/VF virtchnl state inconsistent and cause VIRTCHNL_OP_CONFIG_VSI_QUEUES to fail with ERR_PARAM after ToR link flap/power-cycle, leaving the VF unable to recover. This results in connection loss.

This patch introduces a new flag 'pf_reset_in_progress', that is set only when iavf_handle_hw_reset() is entered with vf_initiated_reset as false and is cleared on exit.
Also, close-time VF reset and related close-time virtchnl operations are skipped when PF triggered reset recovery is set.
This is done to avoid a duplicate VF reset, and keep normal behavior for application-driven close or VF-initiated reinit.

Quoted 7 lines
Fixes 675a104e2e94 ("net/iavf: fix abnormal disable HW interrupt")
Fixes b34fe66ea893 ("net/iavf: delay VF reset command")
Fixes 5e03e316c753 ("net/iavf: handle virtchnl event message without

interrupt")
Cc: [email protected]

I think you may need to respin due to patch application failure. I have some suggestions for improving the comments/release notes that you could include in the next version. Code looks good to me.

Quoted 20 lines

---
V5: Addressed Ciara Loftus's comments
- added separate flag for PF initiated reset recovery
V4: Addressed Ciara Loftus's comments
- split VF reset from other code changes
V3: Addressed latest ai-code-review comments
V2: Addressed ai-code-review comments

 doc/guides/rel_notes/release_26_07.rst |  3 ++
 drivers/net/intel/iavf/iavf.h          |  7 +++++
 drivers/net/intel/iavf/iavf_ethdev.c   | 40 +++++++++++++++-----------
 drivers/net/intel/iavf/iavf_vchnl.c    | 18 ++++++++++--
 4 files changed, 49 insertions(+), 19 deletions(-)
doc/guides/rel_notes/release_26_07.rst +0 -0
index d2563ac503..f6899a78c3 100644

doc/guides/rel_notes/release_26_07.rst New Features · line 100

Quoted 6 lines
doc/guides/rel_notes/release_26_07.rst +3 -0
@@ -95,6 +95,9 @@ New Features
 
   * Added support for transmitting LLDP packets based on mbuf packet type.
   * Implemented AVX2 context descriptor transmit paths.
+  * Prevented duplicate 'VIRTCHNL_OP_RESET_VF' during a PF-initiated
+    reset recovery, which earlier caused virtchnl state corruption
+    and connection loss after a top-of-rack (ToR) link flap/power-cycle.

I think something more concise here would be better.
eg. "Fixed duplicate send of 'VIRTCHNL_OP_RESET_VF' during PF reset recovery which could cause virtchnl state corruption"

Quoted 8 lines
doc/guides/rel_notes/release_26_07.rst +0 -0
 * **Updated PCAP ethernet driver.**
 
(quoted diff) +0 -0

b/drivers/net/intel/iavf/iavf.h index 2615b6f034..67aacbe7a6 100644

drivers/net/intel/iavf/iavf.h struct iavf_info { · line 299

Quoted 8 lines
drivers/net/intel/iavf/iavf.h +5 -0
@@ -292,6 +292,13 @@ struct iavf_info {
 
 	bool in_reset_recovery;
 
+	/*
+	 * Set only while iavf_handle_hw_reset()
+	 * is processing a PF-initiated reset
+	 * (vf_initiated_reset == false).
+	 */

I don't think a comment is warranted here, the variable name is self- explanatory.

Quoted 15 lines
drivers/net/intel/iavf/iavf.h +2 -0
+	bool pf_reset_in_progress;
+
 	uint32_t ptp_caps;
 	rte_spinlock_t phc_time_aq_lock;
 };
drivers/net/intel/iavf/iavf_ethdev.c +0 -1
index a8031e23a5..2b6f4daa99 100644
@@ -3166,23 +3166,27 @@ iavf_dev_close(struct rte_eth_dev *dev)
 
 	ret = iavf_dev_stop(dev);
 
-	/*

drivers/net/intel/iavf/iavf_ethdev.c iavf_dev_close(struct rte_eth_dev *dev) · line 3171

Quoted 10 lines
drivers/net/intel/iavf/iavf_ethdev.c +1 -7
-	 * Release redundant queue resource when close the dev
-	 * so that other vfs can re-use the queues.
-	 */
-	if (vf->lv_enabled) {
-		ret = iavf_request_queues(dev,
 IAVF_MAX_NUM_QUEUES_DFLT);
-		if (ret)
-			PMD_DRV_LOG(ERR, "Reset the num of queues
 failed");
+	/* Skip RESET_VF on a PF-initiated reset */

Regarding the comment above, here we're not skipping RESET_VF rather preventing sending virtchnl messages to the adminq during the PF-initiated reset. I suggest rewording the comment to reflect that.

Quoted 2 lines
drivers/net/intel/iavf/iavf_ethdev.c +1 -0
+	if (!vf->pf_reset_in_progress) {
 
Quoted 13 lines

drivers/net/intel/iavf/iavf_ethdev.c iavf_dev_close(struct rte_eth_dev *dev)

Quoted 13 lines
drivers/net/intel/iavf/iavf_ethdev.c +9 -2
-		vf->max_rss_qregion = IAVF_MAX_NUM_QUEUES_DFLT;
-	}
+		/*
+		 * Release redundant queue resource when close the dev
+		 * so that other vfs can re-use the queues.
+		 */
+		if (vf->lv_enabled) {
+			ret = iavf_request_queues(dev,
 IAVF_MAX_NUM_QUEUES_DFLT);
+			if (ret)
+				PMD_DRV_LOG(ERR, "Reset the num of
 queues failed");
+			vf->max_rss_qregion =

Hi Ciara,

Thank you for the detailed review. I have addresses all the review comments. Sent v6. Kindly review.

Thanks,
Anurag M

#10 lore raw

PATCH v6 1/1 net/iavf: fix duplicate VF reset during PF reset recovery

In reply to Anurag Mandal

During PF initiated reset recovery, iavf_dev_close() sends an extra 'VIRTCHNL_OP_RESET_VF' while recovery is already in progress. That second reset can leave PF/VF virtchnl state inconsistent and cause 'VIRTCHNL_OP_CONFIG_VSI_QUEUES' to fail with 'ERR_PARAM' after ToR link flap/power-cycle, leaving the VF unable to recover. This results in connection loss.

This patch introduces a new flag 'pf_reset_in_progress', which is set only when iavf_handle_hw_reset() is entered for a PF-initiated reset (vf_initiated_reset is false), and
it is cleared on exit.
The aforesaid flag is used to prevent sending close-time VF reset and related close-time virtchnl operation messages to the AdminQ when PF triggered reset recovery is set.
This is done to avoid duplicate VF reset requests while preserving normal behavior for application-driven close or VF-initiated reinit.

Fixes 675a104e2e94 ("net/iavf: fix abnormal disable HW interrupt")
Fixes b34fe66ea893 ("net/iavf: delay VF reset command")
Fixes 5e03e316c753 ("net/iavf: handle virtchnl event message without interrupt")

---
V6: Addressed Ciara Loftus's review comments
- changed to concise relase note
- removed unwarranted comment
- added proper comments in two places
- aligned commits with latest 'next-net-intel-for-next-net' branch
V5: Addressed Ciara Loftus's review comments
- added separate flag for PF initiated reset recovery
V4: Addressed Ciara Loftus's review comments
- split VF reset from other code changes
V3: Addressed latest ai-code-review comments
V2: Addressed ai-code-review comments

 doc/guides/rel_notes/release_26_07.rst |  2 ++
 drivers/net/intel/iavf/iavf.h          |  1 +
 drivers/net/intel/iavf/iavf_ethdev.c   | 42 +++++++++++++++++---------
 drivers/net/intel/iavf/iavf_vchnl.c    | 18 +++++++++--
 4 files changed, 46 insertions(+), 17 deletions(-)
doc/guides/rel_notes/release_26_07.rst +2 -0
index b5285af5fe..3832410363 100644
@@ -121,6 +121,8 @@ New Features
 
   * Added support for transmitting LLDP packets based on mbuf packet type.
   * Implemented AVX2 context descriptor transmit paths.
+  * Fixed duplicate send of 'VIRTCHNL_OP_RESET_VF' during PF reset recovery
+    which could cause virtchnl state corruption.
 
 * **Updated NVIDIA mlx5 ethernet driver.**
 
drivers/net/intel/iavf/iavf.h +1 -0
index 4444602a30..293adaf6c9 100644
@@ -292,6 +292,7 @@ struct iavf_info {
 
 	bool in_reset_recovery;
 	bool reset_pending;
+	bool pf_reset_in_progress;
 
 	uint32_t ptp_caps;
 	rte_spinlock_t phc_time_aq_lock;
drivers/net/intel/iavf/iavf_ethdev.c +28 -14

69 lines not on this page · raw message

drivers/net/intel/iavf/iavf_vchnl.c +15 -3
index 0643a835d5..08ab11ccf1 100644
@@ -283,9 +283,21 @@ 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;
-			iavf_set_no_poll(adapter, false);
-			PMD_DRV_LOG(INFO, "VF is resetting");
+			/*
+			 * Force link down on impending reset to drop
+			 * the cached link-up state; a fresh LSC up
+			 * event will be re-issued by the PF once the
+			 * VF is reinitialised.
+			 */
+			vf->link_up = false;
+			if (!vf->vf_reset) {
+				vf->vf_reset = true;
+				iavf_set_no_poll(adapter, false);
+				iavf_dev_event_post(vf->eth_dev,
+					RTE_ETH_EVENT_INTR_RESET,
+					NULL, 0);
+			}
+			PMD_DRV_LOG(DEBUG, "VF is resetting");
 			break;
 		case VIRTCHNL_EVENT_PF_DRIVER_CLOSE:
 			vf->dev_closed = true;
Signature · 1 line
2.34.1
Acked-by on v6 1/1
#11 lore raw
Quoted 19 lines

Subject: [PATCH v6] net/iavf: fix duplicate VF reset during PF reset recovery

During PF initiated reset recovery, iavf_dev_close() sends an extra 'VIRTCHNL_OP_RESET_VF' while recovery is already in progress. That second reset can leave PF/VF virtchnl state inconsistent and cause 'VIRTCHNL_OP_CONFIG_VSI_QUEUES' to fail with 'ERR_PARAM' after ToR link flap/power-cycle, leaving the VF unable to recover. This results in connection loss.

This patch introduces a new flag 'pf_reset_in_progress', which is set only when iavf_handle_hw_reset() is entered for a PF-initiated reset (vf_initiated_reset is false), and
it is cleared on exit.
The aforesaid flag is used to prevent sending close-time VF reset and related close-time virtchnl operation messages to the AdminQ when PF triggered reset recovery is set.
This is done to avoid duplicate VF reset requests while preserving normal behavior for application-driven close or VF-initiated reinit.

Quoted 7 lines
Fixes 675a104e2e94 ("net/iavf: fix abnormal disable HW interrupt")
Fixes b34fe66ea893 ("net/iavf: delay VF reset command")
Fixes 5e03e316c753 ("net/iavf: handle virtchnl event message without

interrupt")
Cc: [email protected]

Thanks Anurag.

Quoted 13 lines

---
V6: Addressed Ciara Loftus's review comments
- changed to concise relase note
- removed unwarranted comment
- added proper comments in two places
- aligned commits with latest 'next-net-intel-for-next-net' branch
V5: Addressed Ciara Loftus's review comments
- added separate flag for PF initiated reset recovery
V4: Addressed Ciara Loftus's review comments
- split VF reset from other code changes
V3: Addressed latest ai-code-review comments
V2: Addressed ai-code-review comments

#12 lore raw
Quoted 25 lines · Ciara
Quoted 25 lines

Subject: [PATCH v6] net/iavf: fix duplicate VF reset during PF reset recovery

During PF initiated reset recovery, iavf_dev_close() sends an extra 'VIRTCHNL_OP_RESET_VF' while recovery is already in progress. That second reset can leave PF/VF virtchnl state inconsistent and cause 'VIRTCHNL_OP_CONFIG_VSI_QUEUES' to fail with 'ERR_PARAM' after ToR link flap/power-cycle, leaving the VF unable to recover. This results in connection loss.

This patch introduces a new flag 'pf_reset_in_progress', which is set only when iavf_handle_hw_reset() is entered for a PF-initiated reset (vf_initiated_reset is false), and
it is cleared on exit.
The aforesaid flag is used to prevent sending close-time VF reset and related close-time virtchnl operation messages to the AdminQ when PF triggered reset recovery is set.
This is done to avoid duplicate VF reset requests while preserving normal behavior for application-driven close or VF-initiated reinit.

Fixes 675a104e2e94 ("net/iavf: fix abnormal disable HW interrupt")
Fixes b34fe66ea893 ("net/iavf: delay VF reset command")
Fixes 5e03e316c753 ("net/iavf: handle virtchnl event message without

interrupt")
Cc: [email protected]

Quoted 6 lines
Quoted 1 line

Thanks Anurag.

Applied to dpdk-next-net-intel.
Thanks,
/Bruce