Skip to contentSkip to conversation

ice: fix FDIR CTRL VSI resource leak in ice_reset_all_vfs()

PATCH In review Aleksandr Loktionov 7 participants 15 messages Mar 27 – Jun 4

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ice: fix FDIR CTRL VSI resource leak in ice_reset_all_vfs()

From: Dawid Osuchowski <[email protected]>

Resetting all VFs causes resource leak on VFs with FDIR filters enabled as CTRL VSIs are only invalidated and not freed. Fix by using ice_vf_ctrl_vsi_release() instead of ice_vf_ctrl_invalidate_vsi() which aligns behavior with the ice_reset_vf() function.

Reproduction:
echo 1 > /sys/class/net/$pf/device/sriov_numvfs ethtool -N $vf flow-type ether proto 0x9000 action 0 echo 1 > /sys/class/net/$pf/device/reset

Fixes da62c5ff9dcd ("ice: Add support for per VF ctrl VSI enabling")

---

 drivers/net/ethernet/intel/ice/ice_vf_lib.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/ice/ice_vf_lib.c +1 -1
index c8bc952f..7d33f09 100644
@@ -801,7 +801,7 @@ void ice_reset_all_vfs(struct ice_pf *pf)
 		 * setup only when VF creates its first FDIR rule.
 		 */
 		if (vf->ctrl_vsi_idx != ICE_NO_VSI)
-			ice_vf_ctrl_invalidate_vsi(vf);
+			ice_vf_ctrl_vsi_release(vf);
 
 		ice_vf_pre_vsi_rebuild(vf);
 		ice_vf_rebuild_vsi(vf);
Signature · 1 line
2.52.0
#1 lore raw

PATCH 1/1 ice: do not reset MDD counters on VF reset

From: Mark Rustad <[email protected]>

Do not clear MDD event counters on VF reset, to be consistent with how VF statistics are not reset either. This allows accumulation of MDD events across resets so that persistent misbehavior can be tracked and reported more accurately.

Fixes 12bb018c538c ("ice: Refactor VF reset")

---

 drivers/net/ethernet/intel/ice/ice_vf_lib.c | 2 --
 1 file changed, 2 deletions(-)
drivers/net/ethernet/intel/ice/ice_vf_lib.c +0 -2
index 7d33f09..9bcc739 100644
@@ -227,8 +227,6 @@ static void ice_vf_clear_counters(struct ice_vf *vf)
 
 	vf->num_mac = 0;
 	vf->num_mac_lldp = 0;
-	memset(&vf->mdd_tx_events, 0, sizeof(vf->mdd_tx_events));
-	memset(&vf->mdd_rx_events, 0, sizeof(vf->mdd_rx_events));
 }
 
 /**
Signature · 1 line
2.52.0
maintainer
#2 lore raw

Re: [PATCH iwl-next] ice: do not reset MDD counters on VF reset

Quoted 20 lines · Aleksandr Loktionov

From: Mark Rustad <[email protected]>

Do not clear MDD event counters on VF reset, to be consistent with how VF statistics are not reset either. This allows accumulation of MDD events across resets so that persistent misbehavior can be tracked and reported more accurately.

Fixes 12bb018c538c ("ice: Refactor VF reset")

---

  drivers/net/ethernet/intel/ice/ice_vf_lib.c | 2 --
  1 file changed, 2 deletions(-)
drivers/net/ethernet/intel/ice/ice_vf_lib.c +0 -0
index 7d33f09..9bcc739 100644

drivers/net/ethernet/intel/ice/ice_vf_lib.c static void ice_vf_clear_counters(struct ice_vf *vf) · line 232

Quoted 8 lines
drivers/net/ethernet/intel/ice/ice_vf_lib.c +0 -2
@@ -227,8 +227,6 @@ static void ice_vf_clear_counters(struct ice_vf *vf)
 
  	vf->num_mac = 0;
  	vf->num_mac_lldp = 0;
-	memset(&vf->mdd_tx_events, 0, sizeof(vf->mdd_tx_events));
-	memset(&vf->mdd_rx_events, 0, sizeof(vf->mdd_rx_events));
  }
 
  /**

AI Review says:

There's a documentation issue in drivers/net/ethernet/intel/ice/ice_main.c that should be addressed. The comment in ice_mdd_maybe_reset_vf() states:

Quoted 3 lines

/* VF MDD event counters will be cleared by reset, so print the event
* prior to reset.
*/

This comment contradicts the new behavior introduced by this patch. Since the memset calls are removed, MDD event counters now persist across VF resets rather than being cleared. The comment should be updated to reflect that counters are accumulated across resets to track persistent misbehavior, which is the intent documented in the commit message.

Also, the threading on your sends seems to be off. If you are going to send them together, please make them part of a series. If you are treating them individually, please send them that way.

The target trees also seem off; some 'net' and some 'iwl-next' patches with Fixes: that sound to be bug fixes. I'm working through and sorting what's been sent, but please try to tag things properly on future sends.

Thanks,
Tony

#3 lore raw

PATCH 1/1 ice: check cross-timestamp timeout bits

In reply to Aleksandr Loktionov

From: Karol Kolacinski <[email protected]>

Polling for cross-timestamp active bit depends on HW scheduling and actual timeout may happen before the driver finishes polling.

Check cross-timestamp timeout bits to ensure that the driver finishes the operation earlier when HW indicates timeout.

Fixes 92456e795ac6 ("ice: Add unified ice_capture_crosststamp")

---

 drivers/net/ethernet/intel/ice/ice_hw_autogen.h |  3 +++
 drivers/net/ethernet/intel/ice/ice_ptp.c        | 12 ++++++++++--
 2 files changed, 13 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/ice/ice_hw_autogen.h +3 -0
index 082ad33..8b4884e 100644
@@ -499,6 +499,8 @@
 #define PRTRPB_RDPC				0x000AC260
 #define GLHH_ART_CTL				0x000A41D4
 #define GLHH_ART_CTL_ACTIVE_M			BIT(0)
+#define GLHH_ART_CTL_TIME_OUT1_M		BIT(1)
+#define GLHH_ART_CTL_TIME_OUT2_M		BIT(2)
 #define GLHH_ART_TIME_H				0x000A41D8
 #define GLHH_ART_TIME_L				0x000A41DC
 #define GLTSYN_AUX_IN_0(_i)			(0x000889D8 + ((_i) * 4))
@@ -564,6 +566,7 @@
 #define E830_PRTTSYN_TXTIME_L(_i)		(0x001E5000 + ((_i) * 32))
 #define E830_GLPTM_ART_CTL			0x00088B50
 #define E830_GLPTM_ART_CTL_ACTIVE_M		BIT(0)
+#define E830_GLPTM_ART_CTL_TIME_OUT_M		BIT(1)
 #define E830_GLPTM_ART_TIME_H			0x00088B54
 #define E830_GLPTM_ART_TIME_L			0x00088B58
 #define E830_GLTSYN_PTMTIME_H(_i)		(0x00088B48 + ((_i) * 4))
drivers/net/ethernet/intel/ice/ice_ptp.c +10 -2
index 6848b1c..8b0530b 100644
@@ -2011,6 +2011,7 @@ static int ice_ptp_adjtime(struct ptp_clock_info *info, s64 delta)
  * @lock_busy: Bit in the semaphore lock indicating the lock is busy
  * @ctl_reg: The hardware register to request cross timestamp
  * @ctl_active: Bit in the control register to request cross timestamp
+ * @ctl_timeout: Bits in the control register to indicate HW timeout
  * @art_time_l: Lower 32-bits of ART system time
  * @art_time_h: Upper 32-bits of ART system time
  * @dev_time_l: Lower 32-bits of device time (per timer index)
@@ -2024,6 +2025,7 @@ struct ice_crosststamp_cfg {
 	/* Capture control register */
 	u32 ctl_reg;
 	u32 ctl_active;
+	u32 ctl_timeout;
 
 	/* Time storage */
 	u32 art_time_l;
@@ -2037,6 +2039,7 @@ static const struct ice_crosststamp_cfg ice_crosststamp_cfg_e82x = {
 	.lock_busy = PFHH_SEM_BUSY_M,
 	.ctl_reg = GLHH_ART_CTL,
 	.ctl_active = GLHH_ART_CTL_ACTIVE_M,
+	.ctl_timeout = GLHH_ART_CTL_TIME_OUT1_M | GLHH_ART_CTL_TIME_OUT2_M,
 	.art_time_l = GLHH_ART_TIME_L,
 	.art_time_h = GLHH_ART_TIME_H,
 	.dev_time_l[0] = GLTSYN_HHTIME_L(0),
@@ -2051,6 +2054,7 @@ static const struct ice_crosststamp_cfg ice_crosststamp_cfg_e830 = {
 	.lock_busy = E830_PFPTM_SEM_BUSY_M,
 	.ctl_reg = E830_GLPTM_ART_CTL,
 	.ctl_active = E830_GLPTM_ART_CTL_ACTIVE_M,
+	.ctl_timeout = E830_GLPTM_ART_CTL_TIME_OUT_M,
 	.art_time_l = E830_GLPTM_ART_TIME_L,
 	.art_time_h = E830_GLPTM_ART_TIME_H,
 	.dev_time_l[0] = E830_GLTSYN_PTMTIME_L(0),
@@ -2123,9 +2127,13 @@ static int ice_capture_crosststamp(ktime_t *device,
 	ctl |= cfg->ctl_active;
 	wr32(hw, cfg->ctl_reg, ctl);
 
-	/* Poll until hardware completes the capture */
-	err = rd32_poll_timeout(hw, cfg->ctl_reg, ctl, !(ctl & cfg->ctl_active),
+	/* Poll until hardware completes the capture or timeout occurs */
+	err = rd32_poll_timeout(hw, cfg->ctl_reg, ctl,
+				!(ctl & cfg->ctl_active) ||
+				(ctl & cfg->ctl_timeout),
 				5, 20 * USEC_PER_MSEC);
+	if (ctl & cfg->ctl_timeout)
+		err = -ETIMEDOUT;
 	if (err)
 		goto err_timeout;
 
Signature · 1 line
2.52.0
Acked-by on v1 1/1
#4 lore raw

Re: [Intel-wired-lan] [PATCH iwl-next] ice: check cross-timestamp timeout bits

Quoted 5 lines · Aleksandr Loktionov

From: Karol Kolacinski <[email protected]>

Polling for cross-timestamp active bit depends on HW scheduling and actual timeout may happen before the driver finishes polling.

Quoted 8 lines

Check cross-timestamp timeout bits to ensure that the driver finishes the operation earlier when HW indicates timeout.

Fixes 92456e795ac6 ("ice: Add unified ice_capture_crosststamp")

---

Waste less time once hardware gives up. Makes sense.

reviewer Reviewed-by on v1 1/1
#5 lore raw

Re: [PATCH iwl-next] ice: check cross-timestamp timeout bits

In reply to Aleksandr Loktionov
Quoted 11 lines · Aleksandr Loktionov

From: Karol Kolacinski <[email protected]>

Polling for cross-timestamp active bit depends on HW scheduling and actual timeout may happen before the driver finishes polling.

Check cross-timestamp timeout bits to ensure that the driver finishes the operation earlier when HW indicates timeout.

Fixes 92456e795ac6 ("ice: Add unified ice_capture_crosststamp")
Tested-by on v1 1/1
#6 lore raw

RE: [Intel-wired-lan] [PATCH iwl-next] ice: check cross-timestamp timeout bits

In reply to Aleksandr Loktionov
Quoted 13 lines

-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Aleksandr Loktionov
Sent: 27 March 2026 12:53
To: [email protected]; Nguyen, Anthony L <[email protected]>; Loktionov, Aleksandr <[email protected]>
Cc: [email protected]
Subject: [Intel-wired-lan] [PATCH iwl-next] ice: check cross-timestamp timeout bits

From: Karol Kolacinski <[email protected]>

Polling for cross-timestamp active bit depends on HW scheduling and actual timeout may happen before the driver finishes polling.

Check cross-timestamp timeout bits to ensure that the driver finishes the operation earlier when HW indicates timeout.

Quoted 9 lines
Fixes 92456e795ac6 ("ice: Add unified ice_capture_crosststamp")

---

drivers/net/ethernet/intel/ice/ice_hw_autogen.h | 3 +++
drivers/net/ethernet/intel/ice/ice_ptp.c | 12 ++++++++++--

2 files changed, 13 insertions(+), 2 deletions(-)
#7 lore raw

PATCH 1/1 ice: fix AQ error code comparison in ice_set_pauseparam()

In reply to Aleksandr Loktionov

From: Lukasz Czapnik <[email protected]>

Fix unreachable code: the conditionals in ice_set_pauseparam() used the bitwise-AND operator suggesting aq_failures is a bitmap, but it is actually an enum, making the third condition logically unreachable.

Replace the if-else ladder with a switch statement. Also move the aq_failures initialization to the variable declaration and remove the redundant zeroing from ice_set_fc().

Fixes fcea6f3da546 ("ice: Add stats and ethtool support")

---

 drivers/net/ethernet/intel/ice/ice_common.c  |  1 -
 drivers/net/ethernet/intel/ice/ice_ethtool.c | 12 ++++++++----
 2 files changed, 8 insertions(+), 5 deletions(-)
drivers/net/ethernet/intel/ice/ice_common.c +0 -1
index f1a6601..6dad7d4 100644
@@ -3883,7 +3883,6 @@ ice_set_fc(struct ice_port_info *pi, u8 *aq_failures, bool ena_auto_link_update)
 	if (!pi || !aq_failures)
 		return -EINVAL;
 
-	*aq_failures = 0;
 	hw = pi->hw;
 
 	pcaps = kzalloc_obj(*pcaps);
drivers/net/ethernet/intel/ice/ice_ethtool.c +8 -4
index 2a4f06f..0cf064c 100644
@@ -3501,7 +3501,7 @@ ice_set_pauseparam(struct net_device *netdev, struct ethtool_pauseparam *pause)
 	struct ice_vsi *vsi = np->vsi;
 	struct ice_hw *hw = &pf->hw;
 	struct ice_port_info *pi;
-	u8 aq_failures;
+	u8 aq_failures = 0;
 	bool link_up;
 	u32 is_an;
 	int err;
@@ -3572,18 +3572,22 @@ ice_set_pauseparam(struct net_device *netdev, struct ethtool_pauseparam *pause)
 	/* Set the FC mode and only restart AN if link is up */
 	err = ice_set_fc(pi, &aq_failures, link_up);
 
-	if (aq_failures & ICE_SET_FC_AQ_FAIL_GET) {
+	switch (aq_failures) {
+	case ICE_SET_FC_AQ_FAIL_GET:
 		netdev_info(netdev, "Set fc failed on the get_phy_capabilities call with err %d aq_err %s\n",
 			    err, libie_aq_str(hw->adminq.sq_last_status));
 		err = -EAGAIN;
-	} else if (aq_failures & ICE_SET_FC_AQ_FAIL_SET) {
+		break;
+	case ICE_SET_FC_AQ_FAIL_SET:
 		netdev_info(netdev, "Set fc failed on the set_phy_config call with err %d aq_err %s\n",
 			    err, libie_aq_str(hw->adminq.sq_last_status));
 		err = -EAGAIN;
-	} else if (aq_failures & ICE_SET_FC_AQ_FAIL_UPDATE) {
+		break;
+	case ICE_SET_FC_AQ_FAIL_UPDATE:
 		netdev_info(netdev, "Set fc failed on the get_link_info call with err %d aq_err %s\n",
 			    err, libie_aq_str(hw->adminq.sq_last_status));
 		err = -EAGAIN;
+		break;
 	}
 
 	return err;
Signature · 1 line
2.52.0
reviewer Reviewed-by on v1 1/1
#8 lore raw

Re: [PATCH iwl-next] ice: fix AQ error code comparison in ice_set_pauseparam()

Quoted 9 lines · Aleksandr Loktionov

From: Lukasz Czapnik <[email protected]>

Fix unreachable code: the conditionals in ice_set_pauseparam() used the bitwise-AND operator suggesting aq_failures is a bitmap, but it is actually an enum, making the third condition logically unreachable.

Replace the if-else ladder with a switch statement. Also move the aq_failures initialization to the variable declaration and remove the redundant zeroing from ice_set_fc().

I think that this second part feels more like a clean-up than part of the fix. But I don't feel strongly about it.

Quoted 3 lines
Fixes fcea6f3da546 ("ice: Add stats and ethtool support")

drivers/net/ethernet/intel/ice/ice_common.c ice_set_fc(struct ice_port_info *pi, u8 *aq_failures, bool ena_auto_link_update) · line 3884

Quoted 13 lines

---

 drivers/net/ethernet/intel/ice/ice_common.c  |  1 -
 drivers/net/ethernet/intel/ice/ice_ethtool.c | 12 ++++++++----
 2 files changed, 8 insertions(+), 5 deletions(-)
drivers/net/ethernet/intel/ice/ice_common.c +0 -0
index f1a6601..6dad7d4 100644
@@ -3883,7 +3883,6 @@ ice_set_fc(struct ice_port_info *pi, u8 *aq_failures, bool ena_auto_link_update)
 	if (!pi || !aq_failures)
 		return -EINVAL;

FWIIW, I think the defensive code above could also be removed at some point.

Quoted 5 lines
drivers/net/ethernet/intel/ice/ice_common.c +0 -1
-	*aq_failures = 0;
 	hw = pi->hw;
 
 	pcaps = kzalloc_obj(*pcaps);

...

Tested-by on v1 1/1
#9 lore raw

RE: [Intel-wired-lan] [PATCH iwl-next] ice: fix AQ error code comparison in ice_set_pauseparam()

In reply to Aleksandr Loktionov
Quoted 13 lines

-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Aleksandr Loktionov
Sent: 27 March 2026 12:53
To: [email protected]; Nguyen, Anthony L <[email protected]>; Loktionov, Aleksandr <[email protected]>
Cc: [email protected]; Czapnik, Lukasz <[email protected]>
Subject: [Intel-wired-lan] [PATCH iwl-next] ice: fix AQ error code comparison in ice_set_pauseparam()

From: Lukasz Czapnik <[email protected]>

Fix unreachable code: the conditionals in ice_set_pauseparam() used the bitwise-AND operator suggesting aq_failures is a bitmap, but it is actually an enum, making the third condition logically unreachable.

Replace the if-else ladder with a switch statement. Also move the aq_failures initialization to the variable declaration and remove the redundant zeroing from ice_set_fc().

Quoted 8 lines
Fixes fcea6f3da546 ("ice: Add stats and ethtool support")

---

drivers/net/ethernet/intel/ice/ice_common.c | 1 - drivers/net/ethernet/intel/ice/ice_ethtool.c | 12 ++++++++----

2 files changed, 8 insertions(+), 5 deletions(-)
#10 lore raw

PATCH 1/1 ice: call netif_keep_dst() once when entering switchdev mode

In reply to Aleksandr Loktionov

From: Marcin Szycik <[email protected]>

netif_keep_dst() only needs to be called once for the uplink VSI, not once for each port representor. Move it from ice_eswitch_setup_repr() to ice_eswitch_enable_switchdev().

Fixes defd52455aee ("ice: do Tx through PF netdev in slow-path")

---

 drivers/net/ethernet/intel/ice/ice_eswitch.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/ice/ice_eswitch.c +2 -2
index 2e4f096..c30e27b 100644
@@ -117,8 +117,6 @@ static int ice_eswitch_setup_repr(struct ice_pf *pf, struct ice_repr *repr)
 	if (!repr->dst)
 		return -ENOMEM;
 
-	netif_keep_dst(uplink_vsi->netdev);
-
 	dst = repr->dst;
 	dst->u.port_info.port_id = vsi->vsi_num;
 	dst->u.port_info.lower_dev = uplink_vsi->netdev;
@@ -312,6 +310,8 @@ static int ice_eswitch_enable_switchdev(struct ice_pf *pf)
 	if (ice_eswitch_br_offloads_init(pf))
 		goto err_br_offloads;
 
+	netif_keep_dst(uplink_vsi->netdev);
+
 	pf->eswitch.is_running = true;
 
 	return 0;
Signature · 1 line
2.52.0
reviewer
#11 lore raw

Re: [PATCH iwl-next] ice: call netif_keep_dst() once when entering switchdev mode

Quoted 7 lines · Aleksandr Loktionov

From: Marcin Szycik <[email protected]>

netif_keep_dst() only needs to be called once for the uplink VSI, not once for each port representor. Move it from ice_eswitch_setup_repr() to ice_eswitch_enable_switchdev().

Fixes defd52455aee ("ice: do Tx through PF netdev in slow-path")

This problem seems to predate the cited commit.

Quoted 2 lines
Tested-by
#12 lore raw

RE: [Intel-wired-lan] [PATCH iwl-next] ice: call netif_keep_dst() once when entering switchdev mode

Quoted 14 lines

-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Simon Horman
Sent: Friday, April 3, 2026 2:42 PM
To: Loktionov, Aleksandr <[email protected]>
Cc: [email protected]; Nguyen, Anthony L <[email protected]>; [email protected]; Szycik, Marcin <[email protected]>
Subject: Re: [Intel-wired-lan] [PATCH iwl-next] ice: call netif_keep_dst() once when entering switchdev mode

Quoted 2 lines · Aleksandr Loktionov

From: Marcin Szycik <[email protected]>

Quoted 10 lines
Quoted 5 lines

netif_keep_dst() only needs to be called once for the uplink VSI, not once for each port representor. Move it from ice_eswitch_setup_repr() to ice_eswitch_enable_switchdev().

Fixes defd52455aee ("ice: do Tx through PF netdev in slow-path")

This problem seems to predate the cited commit.

Quoted 2 lines
reviewer Reviewed-by on v1 1/1
#13 lore raw
In reply to Aleksandr Loktionov
Quoted 7 lines · Aleksandr Loktionov

From: Dawid Osuchowski <[email protected]>

Resetting all VFs causes resource leak on VFs with FDIR filters enabled as CTRL VSIs are only invalidated and not freed. Fix by using ice_vf_ctrl_vsi_release() instead of ice_vf_ctrl_invalidate_vsi() which aligns behavior with the ice_reset_vf() function.

Quoted 8 lines

Reproduction:
echo 1 > /sys/class/net/$pf/device/sriov_numvfs ethtool -N $vf flow-type ether proto 0x9000 action 0 echo 1 > /sys/class/net/$pf/device/reset

Fixes da62c5ff9dcd ("ice: Add support for per VF ctrl VSI enabling")
#14 lore raw
Quoted 24 lines

-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Simon Horman
Sent: Friday, April 3, 2026 1:57 PM
To: Loktionov, Aleksandr <[email protected]>
Cc: [email protected]; Nguyen, Anthony L <[email protected]>; [email protected]; Dawid Osuchowski <[email protected]>
Subject: Re: [Intel-wired-lan] [PATCH iwl-next] ice: fix FDIR CTRL VSI resource leak in ice_reset_all_vfs()

Quoted 12 lines · Aleksandr Loktionov

From: Dawid Osuchowski <[email protected]>

Resetting all VFs causes resource leak on VFs with FDIR filters enabled as CTRL VSIs are only invalidated and not freed. Fix by using ice_vf_ctrl_vsi_release() instead of ice_vf_ctrl_invalidate_vsi() which aligns behavior with the ice_reset_vf() function.

Reproduction:
echo 1 > /sys/class/net/$pf/device/sriov_numvfs ethtool -N $vf flow-type ether proto 0x9000 action 0 echo 1 > /sys/class/net/$pf/device/reset

Quoted 5 lines
Quoted 3 lines
Fixes da62c5ff9dcd ("ice: Add support for per VF ctrl VSI enabling")