mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH net v5 0/4] ice: fix DFLT Rx rule handling for promisc and switchdev
@ 2026-11-27  8:57 Petr Oros
  2026-11-27  8:57 ` [PATCH net v5 1/4] ice: stop the service task before the PF is unloaded Petr Oros
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Petr Oros @ 2026-11-27  8:57 UTC (permalink / raw)
  To: netdev
  Cc: Petr Oros, Tony Nguyen, Przemek Kitszel, Andrew Lunn,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Aleksandr Loktionov, Simon Horman, Michal Swiatkowski,
	Grzegorz Nitka, Paul Menzel, Wojciech Drewek, Marcin Szycik,
	Martyna Szapar-Mudlaw, Ivan Vecera, Alice Michael, Jacob Keller,
	Jesse Brandeburg, Patryk Holda, Rinitha S, Aaron Ma,
	intel-wired-lan, linux-kernel

Fixes for the promiscuous and allmulticast handling of the ice PF VSI,
and two fixes for the teardown paths they rely on.

Patch 1 stops the service task in ice_remove() before the PF is torn
down, where it was stopped before commit 8a37f9e2ff40 ("ice: move
ice_deinit_dev() to the end of deinit paths"). Patch 3 queues a filter
sync when a switchdev session ends, and a session that still runs when
the driver is removed ends in ice_remove().

Patch 2 refuses to leave switchdev mode while subfunction ports exist.
Leaving it then orphans the session, and patch 3 resyncs the uplink only
when a session ends.

Patch 3 lets the eswitch own the promiscuous configuration of the uplink
while a switchdev session runs and resyncs the uplink filters from the
netdev flags when the session ends, so the uplink no longer ends a
session without its catch-all Rx rule or with a stale promisc state.

Patch 4 subscribes PF VSIs to multicast with one VLAN agnostic promisc
rule pair instead of a pair per VID, so a wide VLAN trunk on several
bridge ports no longer exhausts the switch lookup table. A port with a
vid 2-4094 trunk goes from 12292 to 4104 FLU entries.

v1 to v4 were posted to iwl-net, and v4 went into the iwl pull request
of 2026-11-13, where the Sashiko review found real problems in both
patches [1][2]. This version reworks both and replaces v4. It is posted
directly to net, with intel-wired-lan in Cc, as discussed in the thread
on that pull request [3].

The final v5 also differs from what I described in my replies to that
review. Patch 4 no longer keeps per-VID rules for any PF VSI, so the
per-VID re-add, the rollback and the vid 0 recipe swap handling I
described there are gone, and ice_clear_promisc() clears only the VLAN
agnostic pair. Instead of skipping the allmulti branch for a promiscuous
VSI, the subscription is reconciled from both flags in one place, and
with patch 4 the resync of patch 3 no longer drops the multicast rules
or clears IFF_ALLMULTI. In patch 3 a new VSI state bit keeps every
filter sync away from the uplink promisc configuration while a session
runs, and patch 1 makes sure that the sync queued at the end of a
session cannot use a freed netdev when the PF goes away.

"ice: restore DDP state during PFR recovery", which Tony sent to net in
the pull request of 2026-11-25 [4], also stops the service task in
ice_remove(), but before ice_free_vfs(). Patch 1 keeps the place after
ice_free_vfs() that commit f844d5212cb0 ("ice: Fix removing driver while
bare-metal VFs pass traffic") chose, so that VF drivers in the host
still get answers from the PF while they are removed. The two apply
together without a conflict, and ice_remove() then stops the service
task both before and after ice_free_vfs(), so one of the two calls
should go.

Patch 4 builds on the ice_vsi_sync_fltr() changes of patch 3, which
needs the switchdev code from v6.10, so 6.6 and 6.1 need manual
backports of patches 3 and 4. The loss of the uplink VLAN filters across
a switchdev session that patch 3 mentions is older than this series, and
with patch 3 it also shows after a promiscuous session. I will send a
fix for it separately.

Changes since v4:
- Posted to net directly instead of iwl-net.
- New patches 1 and 2, found while reworking the switchdev fix.
- Patch order swapped, the switchdev fix goes before the multicast one.
- Patch 3, previously "ice: preserve uplink DFLT Rx rule on switchdev
  release", reworked as described above.
- Patch 4, previously "ice: skip per-VLAN promisc rules when default VSI
  Rx rule is set", reworked as described above. It now also keeps the
  multicast subscription of a promiscuous VSI when allmulti is cleared,
  unless another VSI holds the DFLT rule.
- Dropped the Reviewed-by and Tested-by tags of v4, both patches changed
  too much to keep them.
- All commit messages say how the problems were found and how the fixes
  were tested.

Link to v4:
https://lore.kernel.org/all/20260708125755.706263-1-poros@redhat.com/

Link to v3:
https://lore.kernel.org/all/20260701133601.2118382-1-poros@redhat.com/

Link to v2:
https://lore.kernel.org/all/20260622113428.2565255-1-poros@redhat.com/

Link to v1:
https://lore.kernel.org/all/cover.1781786935.git.poros@redhat.com/

[1] https://lore.kernel.org/all/179495967132.3136.6714105968141020753@kernel.org/
[2] https://lore.kernel.org/all/179495967304.3136.16113490698897758196@kernel.org/
[3] https://lore.kernel.org/all/20261125124652.3843638-1-poros@redhat.com/
[4] https://lore.kernel.org/all/20261125224428.4126195-1-anthony.l.nguyen@intel.com/

Petr Oros (4):
  ice: stop the service task before the PF is unloaded
  ice: do not leave switchdev mode while representors exist
  ice: resync uplink filters after a switchdev session
  ice: use a VLAN agnostic multicast promisc rule pair for PF VSIs

 drivers/net/ethernet/intel/ice/ice.h         |   1 +
 drivers/net/ethernet/intel/ice/ice_eswitch.c |  39 ++++
 drivers/net/ethernet/intel/ice/ice_main.c    | 233 +++++++------------
 3 files changed, 124 insertions(+), 149 deletions(-)


base-commit: aa40afa831ebfe45e40a23721711059f2ac584d4
-- 
2.56.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH net v5 1/4] ice: stop the service task before the PF is unloaded
  2026-11-27  8:57 [PATCH net v5 0/4] ice: fix DFLT Rx rule handling for promisc and switchdev Petr Oros
@ 2026-11-27  8:57 ` Petr Oros
  2026-11-27  8:57 ` [PATCH net v5 2/4] ice: do not leave switchdev mode while representors exist Petr Oros
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Petr Oros @ 2026-11-27  8:57 UTC (permalink / raw)
  To: netdev
  Cc: Petr Oros, Tony Nguyen, Przemek Kitszel, Andrew Lunn,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Aleksandr Loktionov, Simon Horman, Michal Swiatkowski,
	Grzegorz Nitka, Paul Menzel, Wojciech Drewek, Marcin Szycik,
	Martyna Szapar-Mudlaw, Ivan Vecera, Alice Michael, Jacob Keller,
	Jesse Brandeburg, Patryk Holda, Rinitha S, Aaron Ma,
	intel-wired-lan, linux-kernel

Commit 8a37f9e2ff40 ("ice: move ice_deinit_dev() to the end of deinit
paths") moved the service task stop and the cancel of the AdminQ event
waiters from after ice_free_vfs() to the end of ice_remove(). Since then
a queued or running service task can still walk pf->vsi[] while
ice_remove_arfs(), ice_unload() and ice_deinit() free the aRFS filters,
the netdev, the LAG and the VSIs. A last run that takes longer than a
timer period also arms the service timer again after the stop at the
end has deleted it, and the timer then fires after the PF is freed.

Stop the service task and cancel the waiters after ice_free_vfs() again.
The stop in ice_deinit_dev() stays and deletes a timer armed by the last
run. As before that commit, a devlink flash that is still running when
the driver is removed fails, at the latest when its next AdminQ wait
times out.

Found by AI code review. Validated on an E810-C (FW 8.1.1, ICE COMMS
package 1.3.55.0) with a test-only 12 s delay in ice_sync_fltr_subtask()
after it took the VSI pointer, armed right before a promisc change and
rmmod ice. Without this patch KASAN reports a slab-use-after-free in
ice_vsi_fltr_changed() on the freed main VSI, and the kernel then faults
in call_timer_fn() on the timer function of the unloaded module. With it
rmmod waits for the run and nothing is reported. Also tested by removing
the driver during switchdev sessions and with four VFs bound to iavf. No
kernel selftests cover this.

Fixes: 8a37f9e2ff40 ("ice: move ice_deinit_dev() to the end of deinit paths")
Signed-off-by: Petr Oros <poros@redhat.com>
---
v5:
- New patch. The uplink resync in patch 3 queues a filter sync when a
  switchdev session ends, and a session that still runs when the driver
  is removed ends in ice_remove().
---
 drivers/net/ethernet/intel/ice/ice_main.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c
index 47c6798c97e8f1..6dede87b78944f 100644
--- a/drivers/net/ethernet/intel/ice/ice_main.c
+++ b/drivers/net/ethernet/intel/ice/ice_main.c
@@ -5387,6 +5387,9 @@ static void ice_remove(struct pci_dev *pdev)
 		ice_free_vfs(pf);
 	}
 
+	ice_service_task_stop(pf);
+	ice_aq_cancel_waiting_tasks(pf);
+
 	if (!ice_is_safe_mode(pf))
 		ice_remove_arfs(pf);
 
@@ -5407,7 +5410,6 @@ static void ice_remove(struct pci_dev *pdev)
 	ice_deinit_hw(&pf->hw);
 
 	ice_deinit_dev(pf);
-	ice_aq_cancel_waiting_tasks(pf);
 	set_bit(ICE_DOWN, pf->state);
 }
 
-- 
2.56.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH net v5 2/4] ice: do not leave switchdev mode while representors exist
  2026-11-27  8:57 [PATCH net v5 0/4] ice: fix DFLT Rx rule handling for promisc and switchdev Petr Oros
  2026-11-27  8:57 ` [PATCH net v5 1/4] ice: stop the service task before the PF is unloaded Petr Oros
@ 2026-11-27  8:57 ` Petr Oros
  2026-11-27  8:57 ` [PATCH net v5 3/4] ice: resync uplink filters after a switchdev session Petr Oros
  2026-11-27  8:57 ` [PATCH net v5 4/4] ice: use a VLAN agnostic multicast promisc rule pair for PF VSIs Petr Oros
  3 siblings, 0 replies; 5+ messages in thread
From: Petr Oros @ 2026-11-27  8:57 UTC (permalink / raw)
  To: netdev
  Cc: Petr Oros, Tony Nguyen, Przemek Kitszel, Andrew Lunn,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Aleksandr Loktionov, Simon Horman, Michal Swiatkowski,
	Grzegorz Nitka, Paul Menzel, Wojciech Drewek, Marcin Szycik,
	Martyna Szapar-Mudlaw, Ivan Vecera, Alice Michael, Jacob Keller,
	Jesse Brandeburg, Patryk Holda, Rinitha S, Aaron Ma,
	intel-wired-lan, linux-kernel

ice_eswitch_mode_set() refuses a mode change only while VFs exist, but a
subfunction port has a representor and a switchdev session too. devlink
core usually refuses the change first, because of the devlink rate nodes
the representors export, but ice exports none while DCB is active. A
switch to legacy then destroys the representor xarray under the running
session, the representors leak, and the uplink stays in its switchdev
configuration.

Refuse the mode change while the representor xarray is not empty.

Found by AI code review. Reproduced on an E810-C (FW 8.1.1, ICE COMMS
package 1.3.55.0) with the firmware LLDP agent off, without kernel
changes:

  dcb ets set dev $PF tc-tsa all:ets tc-bw 0:50 1:50 prio-tc 1:1
  devlink dev eswitch set pci/$BDF mode switchdev
  devlink port add pci/$BDF flavour pcisf pfnum 0 sfnum 88
  devlink dev eswitch set pci/$BDF mode legacy

The last command succeeded, the representor netdev stayed registered
and promisc off no longer took effect on the PF. With this patch the
command fails with "Remove all subfunction ports before changing
eswitch mode". No kernel selftests cover this.

Fixes: 977514fb0fa8 ("ice: create port representor for SF")
Signed-off-by: Petr Oros <poros@redhat.com>
---
v5:
- New patch. Without it a switch to legacy can orphan a switchdev
  session, and patch 3 resyncs the uplink only when a session ends.
---
 drivers/net/ethernet/intel/ice/ice_eswitch.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/net/ethernet/intel/ice/ice_eswitch.c b/drivers/net/ethernet/intel/ice/ice_eswitch.c
index 6e7bba4738989b..c96b201901f48c 100644
--- a/drivers/net/ethernet/intel/ice/ice_eswitch.c
+++ b/drivers/net/ethernet/intel/ice/ice_eswitch.c
@@ -354,6 +354,13 @@ ice_eswitch_mode_set(struct devlink *devlink, u16 mode,
 		return -EOPNOTSUPP;
 	}
 
+	/* subfunction ports have representors too */
+	if (!xa_empty(&pf->eswitch.reprs)) {
+		NL_SET_ERR_MSG_MOD(extack,
+				   "Remove all subfunction ports before changing eswitch mode");
+		return -EOPNOTSUPP;
+	}
+
 	switch (mode) {
 	case DEVLINK_ESWITCH_MODE_LEGACY:
 		dev_info(ice_pf_to_dev(pf), "PF %d changed eswitch mode to legacy",
-- 
2.56.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH net v5 3/4] ice: resync uplink filters after a switchdev session
  2026-11-27  8:57 [PATCH net v5 0/4] ice: fix DFLT Rx rule handling for promisc and switchdev Petr Oros
  2026-11-27  8:57 ` [PATCH net v5 1/4] ice: stop the service task before the PF is unloaded Petr Oros
  2026-11-27  8:57 ` [PATCH net v5 2/4] ice: do not leave switchdev mode while representors exist Petr Oros
@ 2026-11-27  8:57 ` Petr Oros
  2026-11-27  8:57 ` [PATCH net v5 4/4] ice: use a VLAN agnostic multicast promisc rule pair for PF VSIs Petr Oros
  3 siblings, 0 replies; 5+ messages in thread
From: Petr Oros @ 2026-11-27  8:57 UTC (permalink / raw)
  To: netdev
  Cc: Petr Oros, Tony Nguyen, Przemek Kitszel, Andrew Lunn,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Aleksandr Loktionov, Simon Horman, Michal Swiatkowski,
	Grzegorz Nitka, Paul Menzel, Wojciech Drewek, Marcin Szycik,
	Martyna Szapar-Mudlaw, Ivan Vecera, Alice Michael, Jacob Keller,
	Jesse Brandeburg, Patryk Holda, Rinitha S, Aaron Ma,
	intel-wired-lan, linux-kernel

A switchdev session leaves the uplink filters out of sync with its
netdev. ice_eswitch_setup_env() removes the multicast promisc rules and
the address filters, and ice_eswitch_release_env() removes the default
VSI (DFLT) Rx rule that a promiscuous uplink needs. ice_set_rx_mode()
ignores the uplink during the session and nothing syncs it when the
session ends, so these are not installed again, and flag changes made
meanwhile are lost.

Let the eswitch own the uplink promisc configuration during a session.
While the new ICE_VSI_ESWITCH_UPLINK bit is set, ice_vsi_sync_fltr()
leaves it alone. When the session ends, after is_running is cleared,
ice_eswitch_resync_uplink() clears the bit and queues a full filter
sync, which programs the uplink from the netdev flags. Also subscribe a
promiscuous VSI to multicast when it already holds the DFLT rule, and
enable VLAN pruning on every promisc off, because it can be off without
our DFLT rule after a session or with LAG.

This does not restore the uplink VLAN filters that
ice_eswitch_setup_env() removes, a separate problem that now also shows
when promisc is cleared after a promiscuous session.

Found by AI code review, starting with the Sashiko review of v4, and
reproduced on an E810-C (FW 8.1.1, ICE COMMS package 1.3.55.0) without
kernel changes:

  ip link set $PF promisc on
  devlink dev eswitch set pci/$BDF mode switchdev
  echo 1 > /sys/class/net/$PF/device/sriov_numvfs
  echo 0 > /sys/class/net/$PF/device/sriov_numvfs

after which unknown unicast no longer reaches the PF, and with this
patch it does again. Also tested on that E810-C with promisc changed
before, during and after sessions, allmulti across a session, and PF
resets and driver removal during sessions. LAG and switchdev setup
errors were not tested. No kernel selftests cover this.

Fixes: 1a1c40df2e80 ("ice: set and release switchdev environment")
Fixes: 2571a3fa6251 ("ice: Prohibit rx mode change in switchdev mode")
Fixes: 5c07be96d8b3 ("ice: Avoid setting default Rx VSI twice in switchdev setup")
Fixes: 776fe19953b0 ("ice: block default rule setting on LAG interface")
Signed-off-by: Petr Oros <poros@redhat.com>
---
v5:
- Reworked after the Sashiko review of the v4 pull. Instead of keeping
  the Rx DFLT rule on release, the eswitch now owns the uplink promisc
  configuration during a session, and the uplink filters are resynced
  from the netdev flags when the session ends.
- A new VSI state bit keeps filter syncs away from the uplink promisc
  configuration during a session. The sync queued at the end of a
  session relies on patch 1 when the PF goes away.
- A promiscuous VSI that already holds the DFLT rule is subscribed to
  multicast, and VLAN pruning is re-enabled on every promisc off.
- New title, was "ice: preserve uplink DFLT Rx rule on switchdev
  release". Moved before the multicast patch.
- Added Fixes tags for 1a1c40df2e80, 2571a3fa6251 and 776fe19953b0.
- Dropped the Reviewed-by and Tested-by tags because of the rework.

v4: https://lore.kernel.org/all/20260708125755.706263-3-poros@redhat.com/
v3: https://lore.kernel.org/all/20260701133601.2118382-3-poros@redhat.com/
v2: https://lore.kernel.org/all/20260622113428.2565255-3-poros@redhat.com/
v1: https://lore.kernel.org/all/deef5756e534ef06c12d910c5305d3fd205d30a0.1781786935.git.poros@redhat.com/
---
 drivers/net/ethernet/intel/ice/ice.h         |  1 +
 drivers/net/ethernet/intel/ice/ice_eswitch.c | 40 ++++++++++++++++++++
 drivers/net/ethernet/intel/ice/ice_main.c    | 17 +++++++--
 3 files changed, 55 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice.h b/drivers/net/ethernet/intel/ice/ice.h
index 432da05c48c08a..a1b373e04bab30 100644
--- a/drivers/net/ethernet/intel/ice/ice.h
+++ b/drivers/net/ethernet/intel/ice/ice.h
@@ -321,6 +321,7 @@ enum ice_vsi_state {
 	ICE_VSI_MMAC_FLTR_CHANGED,
 	ICE_VSI_PROMISC_CHANGED,
 	ICE_VSI_REBUILD_PENDING,
+	ICE_VSI_ESWITCH_UPLINK,		/* eswitch owns the promisc config */
 	ICE_VSI_STATE_NBITS		/* must be last */
 };
 
diff --git a/drivers/net/ethernet/intel/ice/ice_eswitch.c b/drivers/net/ethernet/intel/ice/ice_eswitch.c
index c96b201901f48c..d55c70edb7f7f6 100644
--- a/drivers/net/ethernet/intel/ice/ice_eswitch.c
+++ b/drivers/net/ethernet/intel/ice/ice_eswitch.c
@@ -10,6 +10,34 @@
 #include "devlink/devlink.h"
 #include "ice_tc_lib.h"
 
+/**
+ * ice_eswitch_resync_uplink - hand the uplink filters back after switchdev
+ * @uplink_vsi: the uplink VSI
+ */
+static void ice_eswitch_resync_uplink(struct ice_vsi *uplink_vsi)
+{
+	struct ice_pf *pf = uplink_vsi->back;
+
+	while (test_and_set_bit(ICE_CFG_BUSY, uplink_vsi->state))
+		usleep_range(1000, 2000);
+
+	/* VLAN changes during the session may have added these */
+	ice_fltr_clear_vlan_vsi_promisc(&pf->hw, uplink_vsi,
+					ICE_MCAST_VLAN_PROMISC_BITS);
+	ice_fltr_clear_vsi_promisc(&pf->hw, uplink_vsi->idx,
+				   ICE_MCAST_PROMISC_BITS, 0);
+	uplink_vsi->current_netdev_flags &= ~IFF_ALLMULTI;
+
+	clear_bit(ICE_VSI_ESWITCH_UPLINK, uplink_vsi->state);
+	set_bit(ICE_VSI_PROMISC_CHANGED, uplink_vsi->state);
+	set_bit(ICE_VSI_UMAC_FLTR_CHANGED, uplink_vsi->state);
+	set_bit(ICE_VSI_MMAC_FLTR_CHANGED, uplink_vsi->state);
+	clear_bit_unlock(ICE_CFG_BUSY, uplink_vsi->state);
+
+	set_bit(ICE_FLAG_FLTR_SYNC, pf->flags);
+	ice_service_task_schedule(pf);
+}
+
 /**
  * ice_eswitch_setup_env - configure eswitch HW filters
  * @pf: pointer to PF struct
@@ -28,6 +56,12 @@ static int ice_eswitch_setup_env(struct ice_pf *pf)
 		if (ice_down(uplink_vsi))
 			return -ENODEV;
 
+	/* the eswitch owns the uplink promisc config until the resync */
+	while (test_and_set_bit(ICE_CFG_BUSY, uplink_vsi->state))
+		usleep_range(1000, 2000);
+	set_bit(ICE_VSI_ESWITCH_UPLINK, uplink_vsi->state);
+	clear_bit_unlock(ICE_CFG_BUSY, uplink_vsi->state);
+
 	ice_remove_vsi_fltr(&pf->hw, uplink_vsi->idx);
 	ice_vsi_cfg_sw_lldp(uplink_vsi, true, false);
 
@@ -77,6 +111,8 @@ static int ice_eswitch_setup_env(struct ice_pf *pf)
 	if (if_running)
 		ice_up(uplink_vsi);
 
+	ice_eswitch_resync_uplink(uplink_vsi);
+
 	return -ENODEV;
 }
 
@@ -318,6 +354,7 @@ static int ice_eswitch_enable_switchdev(struct ice_pf *pf)
 
 err_br_offloads:
 	ice_eswitch_release_env(pf);
+	ice_eswitch_resync_uplink(uplink_vsi);
 	return -ENODEV;
 }
 
@@ -331,6 +368,9 @@ static void ice_eswitch_disable_switchdev(struct ice_pf *pf)
 	ice_eswitch_release_env(pf);
 
 	pf->eswitch.is_running = false;
+
+	/* after is_running is cleared, so no rx mode change is lost */
+	ice_eswitch_resync_uplink(pf->eswitch.uplink_vsi);
 }
 
 /**
diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c
index 6dede87b78944f..2ce2b7138f6682 100644
--- a/drivers/net/ethernet/intel/ice/ice_main.c
+++ b/drivers/net/ethernet/intel/ice/ice_main.c
@@ -394,6 +394,10 @@ static int ice_vsi_sync_fltr(struct ice_vsi *vsi)
 		}
 	}
 	err = 0;
+	/* the eswitch owns the uplink promisc config during a session */
+	if (test_bit(ICE_VSI_ESWITCH_UPLINK, vsi->state))
+		goto exit;
+
 	/* check for changes in promiscuous modes */
 	if (changed_flags & IFF_ALLMULTI) {
 		if (vsi->current_netdev_flags & IFF_ALLMULTI) {
@@ -438,6 +442,12 @@ static int ice_vsi_sync_fltr(struct ice_vsi *vsi)
 						      ICE_MCAST_PROMISC_BITS);
 				if (err)
 					goto out_promisc;
+			} else if (ice_is_vsi_dflt_vsi(vsi)) {
+				/* still the default VSI, so subscribe it */
+				err = ice_set_promisc(vsi,
+						      ICE_MCAST_PROMISC_BITS);
+				if (err)
+					goto out_promisc;
 			}
 		} else {
 			/* Clear Rx filter to remove traffic from wire */
@@ -450,11 +460,12 @@ static int ice_vsi_sync_fltr(struct ice_vsi *vsi)
 						IFF_PROMISC;
 					goto out_promisc;
 				}
-				if (vsi->netdev->features &
-				    NETIF_F_HW_VLAN_CTAG_FILTER)
-					vlan_ops->ena_rx_filtering(vsi);
 			}
 
+			/* pruning can be off even without our DFLT rule */
+			if (vsi->netdev->features & NETIF_F_HW_VLAN_CTAG_FILTER)
+				vlan_ops->ena_rx_filtering(vsi);
+
 			/* disable allmulti here, but only if allmulti is not
 			 * still enabled for the netdev
 			 */
-- 
2.56.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH net v5 4/4] ice: use a VLAN agnostic multicast promisc rule pair for PF VSIs
  2026-11-27  8:57 [PATCH net v5 0/4] ice: fix DFLT Rx rule handling for promisc and switchdev Petr Oros
                   ` (2 preceding siblings ...)
  2026-11-27  8:57 ` [PATCH net v5 3/4] ice: resync uplink filters after a switchdev session Petr Oros
@ 2026-11-27  8:57 ` Petr Oros
  3 siblings, 0 replies; 5+ messages in thread
From: Petr Oros @ 2026-11-27  8:57 UTC (permalink / raw)
  To: netdev
  Cc: Petr Oros, Tony Nguyen, Przemek Kitszel, Andrew Lunn,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Aleksandr Loktionov, Simon Horman, Michal Swiatkowski,
	Grzegorz Nitka, Paul Menzel, Wojciech Drewek, Marcin Szycik,
	Martyna Szapar-Mudlaw, Ivan Vecera, Alice Michael, Jacob Keller,
	Jesse Brandeburg, Patryk Holda, Rinitha S, Aaron Ma,
	intel-wired-lan, linux-kernel

An allmulticast or promiscuous PF VSI with VLANs is subscribed to
multicast with an ICE_SW_LKUP_PROMISC_VLAN rule pair for every VID, and
each rule takes an entry of the switch lookup table (FLU), which has 32K
entries for all PFs of the device. A port of a vlan_filtering bridge is
allmulticast, so a wide trunk (vid 2-4094) over several such ports
overruns the table. Firmware then rejects Add Switch Rules with ENOSPC,
the trunk of the last port is only partly installed, and the default VSI
(DFLT) Rx rule fails to install when a port turns promiscuous:

  ice 0000:5c:00.1: Failed to set VSI 14 as the default forwarding
                    VSI, error -5
  ice 0000:5c:00.1 ens1f1: Error -5 setting default VSI 14 Rx rule

Subscribe PF VSIs with the VLAN agnostic pair (ICE_SW_LKUP_PROMISC, vid
0) only. Drop the per-VID handling from ice_vlan_rx_add_vid() and
ice_vlan_rx_kill_vid(), and stop clearing the multicast rules in
ice_eswitch_resync_uplink(), whose queued sync now reconciles them. The
pair matches multicast on every VLAN. VLAN pruning still limits what it
delivers to the VLANs of the VSI, and with pruning off, as for the DFLT
holder, it delivers on every VLAN. The subscription now follows
IFF_PROMISC and IFF_ALLMULTI in one place, so clearing allmulti no
longer unsubscribes a promiscuous VSI unless another VSI holds the DFLT
rule, and a failed DFLT install does not remove it before the retry.
ice_set_promisc() adds the Rx and the Tx rule one at a time, so a rule
left by an earlier failure does not keep the other one from being added.

A trusted VF that holds the DFLT rule no longer gets through it the
multicast on VLANs the PF is not a member of, because the promisc recipe
has a higher priority than the default one. It keeps what its own
multicast promisc rules match.

The overrun was observed on a machine in real use, and the allmulti
problem was found by the Sashiko review of v4. The overrun reproduces on
an E810-C (FW 8.1.1, ICE COMMS package 1.3.55.0) without kernel changes:

  for p in $P0 $P2 $P3; do
          ip link add br-$p type bridge vlan_filtering 1
          ip link set br-$p up
          ip link set $p master br-$p
          bridge vlan add vid 2-4094 dev $p
  done
  ip link set br-$P0 promisc on

With the per-VID pairs a trunked port took 12292 FLU entries, the third
bridge vlan add failed part way and the promisc on logged the errors
above. With this patch a trunked port takes 4104 entries, all three
trunks fit with 20387 of the 32768 entries free, and the DFLT rule
installs. The FLU numbers come from a test-only debugfs file that issues
Get Resource Allocation (AQ 0x0204). Also tested with multicast to
joined and unjoined groups on member and non-member VLANs, with promisc
and allmulti changed in every order, with VLANs added and removed while
allmulticast, with a trusted promiscuous VF, and with the DFLT install
made to fail by a test-only change. No kernel selftests cover this.

Fixes: 1273f89578f2 ("ice: Fix broken IFF_ALLMULTI handling")
Fixes: 43fbca02c2dd ("ice: fix lost multicast packets in promisc mode")
Signed-off-by: Petr Oros <poros@redhat.com>
---
v5:
- Reworked after the Sashiko review of the v4 pull. PF VSIs now always
  use the VLAN agnostic multicast pair, and the per-VID multicast rules
  and their handling in ice_vlan_rx_add_vid() and ice_vlan_rx_kill_vid()
  are gone.
- The multicast subscription is reconciled from IFF_PROMISC and
  IFF_ALLMULTI in one place, so clearing allmulti keeps the subscription
  of a promiscuous VSI unless another VSI holds the DFLT rule.
- ice_set_promisc() adds the Rx and the Tx rule separately.
- New title, was "ice: skip per-VLAN promisc rules when default VSI Rx
  rule is set".
- Added the Fixes tag for 43fbca02c2dd.
- Dropped the Reviewed-by and Tested-by tags because of the rework.

v4: https://lore.kernel.org/all/20260708125755.706263-2-poros@redhat.com/
v3: https://lore.kernel.org/all/20260701133601.2118382-2-poros@redhat.com/
v2: https://lore.kernel.org/all/20260622113428.2565255-2-poros@redhat.com/
v1: https://lore.kernel.org/all/89efbea9831175e6f57e9fe8557f7a0e48e050b7.1781786935.git.poros@redhat.com/
---
 drivers/net/ethernet/intel/ice/ice_eswitch.c |   8 -
 drivers/net/ethernet/intel/ice/ice_main.c    | 232 ++++++-------------
 2 files changed, 77 insertions(+), 163 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_eswitch.c b/drivers/net/ethernet/intel/ice/ice_eswitch.c
index d55c70edb7f7f6..5202c43fa969bd 100644
--- a/drivers/net/ethernet/intel/ice/ice_eswitch.c
+++ b/drivers/net/ethernet/intel/ice/ice_eswitch.c
@@ -20,14 +20,6 @@ static void ice_eswitch_resync_uplink(struct ice_vsi *uplink_vsi)
 
 	while (test_and_set_bit(ICE_CFG_BUSY, uplink_vsi->state))
 		usleep_range(1000, 2000);
-
-	/* VLAN changes during the session may have added these */
-	ice_fltr_clear_vlan_vsi_promisc(&pf->hw, uplink_vsi,
-					ICE_MCAST_VLAN_PROMISC_BITS);
-	ice_fltr_clear_vsi_promisc(&pf->hw, uplink_vsi->idx,
-				   ICE_MCAST_PROMISC_BITS, 0);
-	uplink_vsi->current_netdev_flags &= ~IFF_ALLMULTI;
-
 	clear_bit(ICE_VSI_ESWITCH_UPLINK, uplink_vsi->state);
 	set_bit(ICE_VSI_PROMISC_CHANGED, uplink_vsi->state);
 	set_bit(ICE_VSI_UMAC_FLTR_CHANGED, uplink_vsi->state);
diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c
index 2ce2b7138f6682..ea6da46bf7955b 100644
--- a/drivers/net/ethernet/intel/ice/ice_main.c
+++ b/drivers/net/ethernet/intel/ice/ice_main.c
@@ -269,21 +269,18 @@ static bool ice_vsi_fltr_changed(struct ice_vsi *vsi)
  */
 static int ice_set_promisc(struct ice_vsi *vsi, u8 promisc_m)
 {
-	int status;
+	unsigned long bits = promisc_m;
+	int status, bit;
 
 	if (vsi->type != ICE_VSI_PF)
 		return 0;
 
-	if (ice_vsi_has_non_zero_vlans(vsi)) {
-		promisc_m |= (ICE_PROMISC_VLAN_RX | ICE_PROMISC_VLAN_TX);
-		status = ice_fltr_set_vlan_vsi_promisc(&vsi->back->hw, vsi,
-						       promisc_m);
-	} else {
+	for_each_set_bit(bit, &bits, BITS_PER_BYTE) {
 		status = ice_fltr_set_vsi_promisc(&vsi->back->hw, vsi->idx,
-						  promisc_m, 0);
+						  BIT(bit), 0);
+		if (status && status != -EEXIST)
+			return status;
 	}
-	if (status && status != -EEXIST)
-		return status;
 
 	netdev_dbg(vsi->netdev, "set promisc filter bits for VSI %i: 0x%x\n",
 		   vsi->vsi_num, promisc_m);
@@ -303,20 +300,30 @@ static int ice_clear_promisc(struct ice_vsi *vsi, u8 promisc_m)
 	if (vsi->type != ICE_VSI_PF)
 		return 0;
 
-	if (ice_vsi_has_non_zero_vlans(vsi)) {
-		promisc_m |= (ICE_PROMISC_VLAN_RX | ICE_PROMISC_VLAN_TX);
-		status = ice_fltr_clear_vlan_vsi_promisc(&vsi->back->hw, vsi,
-							 promisc_m);
-	} else {
-		status = ice_fltr_clear_vsi_promisc(&vsi->back->hw, vsi->idx,
-						    promisc_m, 0);
-	}
+	status = ice_fltr_clear_vsi_promisc(&vsi->back->hw, vsi->idx,
+					    promisc_m, 0);
 
 	netdev_dbg(vsi->netdev, "clear promisc filter bits for VSI %i: 0x%x\n",
 		   vsi->vsi_num, promisc_m);
 	return status;
 }
 
+/**
+ * ice_vsi_wants_mc_promisc - check if the VSI needs the multicast promisc rules
+ * @vsi: the VSI
+ *
+ * Return: true if the VSI needs the multicast promisc rules.
+ */
+static bool ice_vsi_wants_mc_promisc(struct ice_vsi *vsi)
+{
+	if (vsi->current_netdev_flags & IFF_ALLMULTI)
+		return true;
+	if (!(vsi->current_netdev_flags & IFF_PROMISC))
+		return false;
+	return ice_is_vsi_dflt_vsi(vsi) ||
+	       !ice_is_dflt_vsi_in_use(vsi->port_info);
+}
+
 /**
  * ice_vsi_sync_fltr - Update the VSI filter list to the HW
  * @vsi: ptr to the VSI
@@ -332,6 +339,8 @@ static int ice_vsi_sync_fltr(struct ice_vsi *vsi)
 	struct ice_pf *pf = vsi->back;
 	struct ice_hw *hw = &pf->hw;
 	u32 changed_flags = 0;
+	bool dflt_err = false;
+	bool promisc_changed;
 	int err;
 
 	if (!vsi->netdev)
@@ -399,91 +408,65 @@ static int ice_vsi_sync_fltr(struct ice_vsi *vsi)
 		goto exit;
 
 	/* check for changes in promiscuous modes */
-	if (changed_flags & IFF_ALLMULTI) {
-		if (vsi->current_netdev_flags & IFF_ALLMULTI) {
-			err = ice_set_promisc(vsi, ICE_MCAST_PROMISC_BITS);
-			if (err) {
-				vsi->current_netdev_flags &= ~IFF_ALLMULTI;
-				goto out_promisc;
-			}
-		} else {
-			/* !(vsi->current_netdev_flags & IFF_ALLMULTI) */
-			err = ice_clear_promisc(vsi, ICE_MCAST_PROMISC_BITS);
-			if (err) {
-				vsi->current_netdev_flags |= IFF_ALLMULTI;
-				goto out_promisc;
-			}
-		}
-	}
-
-	if (((changed_flags & IFF_PROMISC) || promisc_forced_on) ||
-	    test_bit(ICE_VSI_PROMISC_CHANGED, vsi->state)) {
-		clear_bit(ICE_VSI_PROMISC_CHANGED, vsi->state);
-		if (vsi->current_netdev_flags & IFF_PROMISC) {
-			/* Apply Rx filter rule to get traffic from wire */
-			if (!ice_is_dflt_vsi_in_use(vsi->port_info)) {
-				err = ice_set_dflt_vsi(vsi);
-				if (err && err != -EEXIST) {
-					netdev_err(netdev, "Error %d setting default VSI %i Rx rule\n",
-						   err, vsi->vsi_num);
-					vsi->current_netdev_flags &=
-						~IFF_PROMISC;
-					goto out_promisc;
-				}
+	promisc_changed = test_and_clear_bit(ICE_VSI_PROMISC_CHANGED,
+					     vsi->state);
+	if ((changed_flags & IFF_PROMISC) || promisc_forced_on)
+		promisc_changed = true;
+
+	if (promisc_changed && (vsi->current_netdev_flags & IFF_PROMISC)) {
+		/* Apply Rx filter rule to get traffic from wire */
+		if (!ice_is_dflt_vsi_in_use(vsi->port_info)) {
+			err = ice_set_dflt_vsi(vsi);
+			if (err && err != -EEXIST) {
+				netdev_err(netdev, "Error %d setting default VSI %i Rx rule\n",
+					   err, vsi->vsi_num);
+				vsi->current_netdev_flags &= ~IFF_PROMISC;
+				set_bit(ICE_VSI_PROMISC_CHANGED, vsi->state);
+				dflt_err = true;
+			} else {
 				err = 0;
 				vlan_ops->dis_rx_filtering(vsi);
-
-				/* promiscuous mode implies allmulticast so
-				 * that VSIs that are in promiscuous mode are
-				 * subscribed to multicast packets coming to
-				 * the port
-				 */
-				err = ice_set_promisc(vsi,
-						      ICE_MCAST_PROMISC_BITS);
-				if (err)
-					goto out_promisc;
-			} else if (ice_is_vsi_dflt_vsi(vsi)) {
-				/* still the default VSI, so subscribe it */
-				err = ice_set_promisc(vsi,
-						      ICE_MCAST_PROMISC_BITS);
-				if (err)
-					goto out_promisc;
 			}
-		} else {
-			/* Clear Rx filter to remove traffic from wire */
-			if (ice_is_vsi_dflt_vsi(vsi)) {
-				err = ice_clear_dflt_vsi(vsi);
-				if (err) {
-					netdev_err(netdev, "Error %d clearing default VSI %i Rx rule\n",
-						   err, vsi->vsi_num);
-					vsi->current_netdev_flags |=
-						IFF_PROMISC;
-					goto out_promisc;
-				}
+		}
+	} else if (promisc_changed) {
+		/* Clear Rx filter to remove traffic from wire */
+		if (ice_is_vsi_dflt_vsi(vsi)) {
+			err = ice_clear_dflt_vsi(vsi);
+			if (err) {
+				netdev_err(netdev, "Error %d clearing default VSI %i Rx rule\n",
+					   err, vsi->vsi_num);
+				vsi->current_netdev_flags |= IFF_PROMISC;
+				set_bit(ICE_VSI_PROMISC_CHANGED, vsi->state);
 			}
+		}
 
-			/* pruning can be off even without our DFLT rule */
-			if (vsi->netdev->features & NETIF_F_HW_VLAN_CTAG_FILTER)
-				vlan_ops->ena_rx_filtering(vsi);
-
-			/* disable allmulti here, but only if allmulti is not
-			 * still enabled for the netdev
-			 */
-			if (!(vsi->current_netdev_flags & IFF_ALLMULTI)) {
-				err = ice_clear_promisc(vsi,
-							ICE_MCAST_PROMISC_BITS);
-				if (err) {
-					netdev_err(netdev, "Error %d clearing multicast promiscuous on VSI %i\n",
-						   err, vsi->vsi_num);
-				}
-			}
+		/* pruning can be off even without our DFLT rule */
+		if (!(vsi->current_netdev_flags & IFF_PROMISC) &&
+		    vsi->netdev->features & NETIF_F_HW_VLAN_CTAG_FILTER)
+			vlan_ops->ena_rx_filtering(vsi);
+	}
+
+	/* promiscuous mode implies allmulticast */
+	if (promisc_changed || (changed_flags & IFF_ALLMULTI)) {
+		int mc_err = 0;
+
+		/* a failed DFLT install leaves the netdev promiscuous */
+		if (ice_vsi_wants_mc_promisc(vsi))
+			mc_err = ice_set_promisc(vsi, ICE_MCAST_PROMISC_BITS);
+		else if (!dflt_err)
+			mc_err = ice_clear_promisc(vsi, ICE_MCAST_PROMISC_BITS);
+		if (mc_err) {
+			netdev_err(netdev, "Error %d syncing multicast promiscuous on VSI %i\n",
+				   mc_err, vsi->vsi_num);
+			/* retried by the next sync, with the allmulti change */
+			vsi->current_netdev_flags ^=
+				changed_flags & IFF_ALLMULTI;
+			set_bit(ICE_VSI_PROMISC_CHANGED, vsi->state);
+			if (!err)
+				err = mc_err;
 		}
 	}
 	goto exit;
-
-out_promisc:
-	set_bit(ICE_VSI_PROMISC_CHANGED, vsi->state);
-	goto exit;
 out:
 	/* if something went wrong then set the changed flag so we try again */
 	set_bit(ICE_VSI_UMAC_FLTR_CHANGED, vsi->state);
@@ -3686,17 +3669,6 @@ int ice_vlan_rx_add_vid(struct net_device *netdev, __be16 proto, u16 vid)
 	while (test_and_set_bit(ICE_CFG_BUSY, vsi->state))
 		usleep_range(1000, 2000);
 
-	/* Add multicast promisc rule for the VLAN ID to be added if
-	 * all-multicast is currently enabled.
-	 */
-	if (vsi->current_netdev_flags & IFF_ALLMULTI) {
-		ret = ice_fltr_set_vsi_promisc(&vsi->back->hw, vsi->idx,
-					       ICE_MCAST_VLAN_PROMISC_BITS,
-					       vid);
-		if (ret && ret != -EEXIST)
-			goto finish;
-	}
-
 	vlan_ops = ice_get_compat_vsi_vlan_ops(vsi);
 
 	/* Add a switch rule for this VLAN ID so its corresponding VLAN tagged
@@ -3704,22 +3676,7 @@ int ice_vlan_rx_add_vid(struct net_device *netdev, __be16 proto, u16 vid)
 	 */
 	vlan = ICE_VLAN(be16_to_cpu(proto), vid, 0);
 	ret = vlan_ops->add_vlan(vsi, &vlan);
-	if (ret)
-		goto finish;
-
-	/* If all-multicast is currently enabled and this VLAN ID is only one
-	 * besides VLAN-0 we have to update look-up type of multicast promisc
-	 * rule for VLAN-0 from ICE_SW_LKUP_PROMISC to ICE_SW_LKUP_PROMISC_VLAN.
-	 */
-	if ((vsi->current_netdev_flags & IFF_ALLMULTI) &&
-	    ice_vsi_num_non_zero_vlans(vsi) == 1) {
-		ice_fltr_clear_vsi_promisc(&vsi->back->hw, vsi->idx,
-					   ICE_MCAST_PROMISC_BITS, 0);
-		ice_fltr_set_vsi_promisc(&vsi->back->hw, vsi->idx,
-					 ICE_MCAST_VLAN_PROMISC_BITS, 0);
-	}
 
-finish:
 	clear_bit(ICE_CFG_BUSY, vsi->state);
 
 	return ret;
@@ -3748,46 +3705,11 @@ int ice_vlan_rx_kill_vid(struct net_device *netdev, __be16 proto, u16 vid)
 	while (test_and_set_bit(ICE_CFG_BUSY, vsi->state))
 		usleep_range(1000, 2000);
 
-	ret = ice_clear_vsi_promisc(&vsi->back->hw, vsi->idx,
-				    ICE_MCAST_VLAN_PROMISC_BITS, vid);
-	if (ret) {
-		netdev_err(netdev, "Error clearing multicast promiscuous mode on VSI %i\n",
-			   vsi->vsi_num);
-		vsi->current_netdev_flags |= IFF_ALLMULTI;
-	}
-
 	vlan_ops = ice_get_compat_vsi_vlan_ops(vsi);
 
-	/* Make sure VLAN delete is successful before updating VLAN
-	 * information
-	 */
 	vlan = ICE_VLAN(be16_to_cpu(proto), vid, 0);
 	ret = vlan_ops->del_vlan(vsi, &vlan);
-	if (ret)
-		goto finish;
-
-	/* Remove multicast promisc rule for the removed VLAN ID if
-	 * all-multicast is enabled.
-	 */
-	if (vsi->current_netdev_flags & IFF_ALLMULTI)
-		ice_fltr_clear_vsi_promisc(&vsi->back->hw, vsi->idx,
-					   ICE_MCAST_VLAN_PROMISC_BITS, vid);
-
-	if (!ice_vsi_has_non_zero_vlans(vsi)) {
-		/* Update look-up type of multicast promisc rule for VLAN 0
-		 * from ICE_SW_LKUP_PROMISC_VLAN to ICE_SW_LKUP_PROMISC when
-		 * all-multicast is enabled and VLAN 0 is the only VLAN rule.
-		 */
-		if (vsi->current_netdev_flags & IFF_ALLMULTI) {
-			ice_fltr_clear_vsi_promisc(&vsi->back->hw, vsi->idx,
-						   ICE_MCAST_VLAN_PROMISC_BITS,
-						   0);
-			ice_fltr_set_vsi_promisc(&vsi->back->hw, vsi->idx,
-						 ICE_MCAST_PROMISC_BITS, 0);
-		}
-	}
 
-finish:
 	clear_bit(ICE_CFG_BUSY, vsi->state);
 
 	return ret;
-- 
2.56.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-11-27  8:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-27  8:57 [PATCH net v5 0/4] ice: fix DFLT Rx rule handling for promisc and switchdev Petr Oros
2026-11-27  8:57 ` [PATCH net v5 1/4] ice: stop the service task before the PF is unloaded Petr Oros
2026-11-27  8:57 ` [PATCH net v5 2/4] ice: do not leave switchdev mode while representors exist Petr Oros
2026-11-27  8:57 ` [PATCH net v5 3/4] ice: resync uplink filters after a switchdev session Petr Oros
2026-11-27  8:57 ` [PATCH net v5 4/4] ice: use a VLAN agnostic multicast promisc rule pair for PF VSIs Petr Oros

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®