🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
5 messages
5 total messages Started by Meghana Malladi Thu, 12 Nov 2026 10:21
[PATCH net v3 RESEND 0/3] Fix switch mode for offload and non-offload cases
#15076
Author: Meghana Malladi
Date: Thu, 12 Nov 2026 10:21
25 lines
21682 bytes
Non-offloaded switch mode is failing to forward packets. This patch series
introduces fixes to ensure smooth operation of switch mode in both offload
and non-offload cases.

patch(1/3): Fix TX timestamp cleanup crash (ERR_PTR slot handling)
patch(2/3): Fix phylib stop/start in emac_restart (R30 command race)
patch(3/3): Fix bridge port_vlan and flooding state (multicast/unicast forwarding)

v2: https://lore.kernel.org/all/20261027131732.3411403-1-m-malladi@ti.com/

Meghana Malladi (3):
  net: ti: icssg-prueth: Fix TX timestamp cleanup crash
  net: ti: icssg-prueth: Fix phylib stop/start in emac_restart
  net: ti: icssg-prueth: Fix bridge port_vlan and flooding state

 drivers/net/ethernet/ti/icssg/icssg_common.c |  9 ++--
 drivers/net/ethernet/ti/icssg/icssg_prueth.c | 46 ++++++++++++++++++--
 drivers/net/ethernet/ti/icssg/icssg_prueth.h |  4 ++
 3 files changed, 52 insertions(+), 7 deletions(-)


base-commit: af6f95c3300e3d234c813b80f831dd7b80b3eaf2
-- 
2.43.0
[PATCH net v3 RESEND 3/3] net: ti: icssg-prueth: Fix bridge port_vlan and flooding state
#15088
Author: Meghana Malladi
Date: Thu, 12 Nov 2026 10:21
128 lines
26062 bytes
Bridge formation only set port_vlan on the second emac, leaving the first
without VLAN configuration; fixed by setting port_vlan on both emacs.

Firmware restart in non-offload bridge mode cleared IFF_PROMISC-driven
UC/MC flooding state, breaking unicast forwarding; fixed by tracking
flooding state and restoring it after every firmware restart, including
the switch-to-EMAC and HSR-to-EMAC transitions in
prueth_netdevice_port_unlink() and prueth_hsr_port_unlink().

Store the flood-enable flags before issuing the firmware commands so that
a concurrent icssg_enable_fw_offload() call cannot read a stale false
value if it runs between the command and the flag update.

Add a NULL check for emac slots in icssg_enable_fw_offload() to handle
single-port DT configurations where one prueth->emac[] slot is unused.

Fixes: 161087db66d6b ("net: ti: icssg-prueth: Add Support for Multicast filtering with VLAN in HSR mode")
Signed-off-by: Meghana Malladi <m-malladi@ti.com>
---

Changes from v2(v3-v2):
- Fixed race: uc/mc_flooding_enabled flags set BEFORE firmware commands
- Added icssg_enable_fw_offload() after restart in bridge unlink path
- Added icssg_enable_fw_offload() after restart in HSR unlink path

 drivers/net/ethernet/ti/icssg/icssg_prueth.c | 25 +++++++++++++++++++-
 drivers/net/ethernet/ti/icssg/icssg_prueth.h |  4 ++++
 2 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/ti/icssg/icssg_prueth.c b/drivers/net/ethernet/ti/icssg/icssg_prueth.c
index ef5dce595f68..48539460ee49 100644
--- a/drivers/net/ethernet/ti/icssg/icssg_prueth.c
+++ b/drivers/net/ethernet/ti/icssg/icssg_prueth.c
@@ -213,6 +213,8 @@ static void icssg_enable_fw_offload(struct prueth *prueth)
 
 	for (mac = PRUETH_MAC0; mac < PRUETH_NUM_MACS; mac++) {
 		emac = prueth->emac[mac];
+		if (!emac)
+			continue;
 		if (prueth->is_hsr_offload_mode) {
 			if (emac->ndev->features & NETIF_F_HW_HSR_TAG_RM)
 				icssg_set_port_state(emac, ICSSG_EMAC_HSR_RX_OFFLOAD_ENABLE);
@@ -241,6 +243,17 @@ static void icssg_enable_fw_offload(struct prueth *prueth)
 					icssg_set_port_state(emac, ICSSG_EMAC_PORT_VLAN_AWARE_ENABLE);
 			}
 		}
+
+		/* Re-apply flooding state cleared by firmware restart.
+		 * In switch mode, flooding is managed by the bridge via
+		 * switchdev callbacks, not tracked by these flags.
+		 */
+		if (!prueth->is_switch_mode && netif_running(emac->ndev)) {
+			if (emac->uc_flooding_enabled)
+				icssg_set_port_state(emac, ICSSG_EMAC_PORT_UC_FLOODING_ENABLE);
+			if (emac->mc_flooding_enabled)
+				icssg_set_port_state(emac, ICSSG_EMAC_PORT_MC_FLOODING_ENABLE);
+		}
 	}
 }
 
@@ -1286,16 +1299,23 @@ static void emac_ndo_set_rx_mode_work(struct work_struct *work)
 	icssg_set_port_state(emac, ICSSG_EMAC_PORT_MC_FLOODING_DISABLE);
 
 	if (promisc) {
+		emac->uc_flooding_enabled = true;
+		emac->mc_flooding_enabled = true;
 		icssg_set_port_state(emac, ICSSG_EMAC_PORT_UC_FLOODING_ENABLE);
 		icssg_set_port_state(emac, ICSSG_EMAC_PORT_MC_FLOODING_ENABLE);
 		return;
 	}
 
 	if (allmulti) {
+		emac->mc_flooding_enabled = true;
+		emac->uc_flooding_enabled = false;
 		icssg_set_port_state(emac, ICSSG_EMAC_PORT_MC_FLOODING_ENABLE);
 		return;
 	}
 
+	emac->uc_flooding_enabled = false;
+	emac->mc_flooding_enabled = false;
+
 	if (emac->prueth->is_hsr_offload_mode) {
 		/* Track basic add/delete via callbacks */
 		__dev_mc_sync(ndev, icssg_prueth_hsr_add_mcast,
@@ -1934,7 +1954,8 @@ static int prueth_netdevice_port_link(struct net_device *ndev,
 		    prueth->br_members & BIT(PRUETH_PORT_MII1)) {
 			prueth->is_switch_mode = true;
 			prueth->default_vlan = PRUETH_DFLT_VLAN_SW;
-			emac->port_vlan = prueth->default_vlan;
+			prueth->emac[PRUETH_MAC0]->port_vlan = prueth->default_vlan;
+			prueth->emac[PRUETH_MAC1]->port_vlan = prueth->default_vlan;
 			icssg_change_mode(prueth);
 		}
 	}
@@ -1960,6 +1981,7 @@ static void prueth_netdevice_port_unlink(struct net_device *ndev)
 			dev_err(prueth->dev, "Failed to restart the firmwares, aborting the process");
 			return;
 		}
+		icssg_enable_fw_offload(prueth);
 	}
 
 	prueth_offload_fwd_mark_update(prueth);
@@ -2024,6 +2046,7 @@ static void prueth_hsr_port_unlink(struct net_device *ndev)
 			dev_err(prueth->dev, "Failed to restart the firmwares, aborting the process");
 			return;
 		}
+		icssg_enable_fw_offload(prueth);
 		netdev_dbg(ndev, "Disabling HSR Offload mode\n");
 	}
 }
diff --git a/drivers/net/ethernet/ti/icssg/icssg_prueth.h b/drivers/net/ethernet/ti/icssg/icssg_prueth.h
index df93d15c5b78..832e654a102c 100644
--- a/drivers/net/ethernet/ti/icssg/icssg_prueth.h
+++ b/drivers/net/ethernet/ti/icssg/icssg_prueth.h
@@ -242,6 +242,10 @@ struct prueth_emac {
 	bool offload_fwd_mark;
 	int port_vlan;
 
+	/* UC/MC flooding state - preserved across firmware restarts */
+	unsigned int uc_flooding_enabled : 1;
+	unsigned int mc_flooding_enabled : 1;
+
 	struct delayed_work stats_work;
 	u64 stats[ICSSG_NUM_MIIG_STATS];
 	u64 pa_stats[ICSSG_NUM_PA_STATS];
-- 
2.43.0
Re: [PATCH net v3 RESEND 3/3] net: ti: icssg-prueth: Fix bridge port_vlan and flooding state
#17220
Author: netdev-bot+sashiko
Date: Mon, 16 Nov 2026 13:54
234 lines
17039 bytes
Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.

Critical: 0 · High: 1 (1) · Medium: 1 · Low: 1

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [High] icssg_enable_fw_offload() (lines 247-256) skips the new flood-
  restore block whenever prueth->is_switch_mode is set.
- [Medium] The new uc/mc_flooding_enabled bitfields are written by
  emac_ndo_set_rx_mode_work(), which runs from schedule_work() (line…
- [Low] The Fixes: tag names the wrong commit.

Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but
  emac_ndo_set_rx_mode_work() has a check-then-use race that can lead to…

--

net: ti: icssg-prueth: Fix bridge port_vlan and flooding state

This patch sets port_vlan on both emacs when a bridge is formed. It also
records the UC/MC flooding state set from IFF_PROMISC/IFF_ALLMULTI so that
icssg_enable_fw_offload() can re-apply it after firmware restarts, and adds
a NULL check for unused emac slots in icssg_enable_fw_offload().

> Fixes: 161087db66d6b ("net: ti: icssg-prueth: Add Support for Multicast filtering with VLAN in HSR mode")

[Severity: Low]
Is this the right commit for the Fixes: tag?

In prueth_netdevice_port_link(), 161087db66d6b only replaced the hardcoded
default_vlan of 1 with PRUETH_DFLT_VLAN_SW. It did not touch the port_vlan
assignment, the restart paths or the flooding logic.

This patch fixes the single-emac assignment:

    emac->port_vlan = prueth->default_vlan;

That assignment and the switch mode unlink logic appear to come from
abd5576b9c57 ("net: ti: icssg-prueth: Add support for ICSSG switch
firmware"). The restart in prueth_netdevice_port_unlink() with no re-apply
step afterwards was reworked in 9facce84f406 ("net: ti: icssg-prueth: Fix
firmware load sequence.").

With the current tag, stable tooling would not pick up trees that have
abd5576b9c57 (v6.11 and later) but not 161087db66d6b (v6.14).

The patch also combines three fixes with different origins: port_vlan on
both emacs, the flood state restore, and the NULL check in
icssg_enable_fw_offload(). Could they be split, each with its own Fixes:
tag?

> diff --git a/drivers/net/ethernet/ti/icssg/icssg_prueth.c b/drivers/net/ethernet/ti/icssg/icssg_prueth.c
> index ef5dce595f68a..48539460ee499 100644
> --- a/drivers/net/ethernet/ti/icssg/icssg_prueth.c
> +++ b/drivers/net/ethernet/ti/icssg/icssg_prueth.c

[ ... ]

> @@ -241,6 +243,17 @@ static void icssg_enable_fw_offload(struct prueth *prueth)
>  					icssg_set_port_state(emac, ICSSG_EMAC_PORT_VLAN_AWARE_ENABLE);
>  			}
>  		}
> +
> +		/* Re-apply flooding state cleared by firmware restart.
> +		 * In switch mode, flooding is managed by the bridge via
> +		 * switchdev callbacks, not tracked by these flags.
> +		 */
> +		if (!prueth->is_switch_mode && netif_running(emac->ndev)) {

[Severity: High]
Is the comment above accurate? In icssg_switchdev.c, UC flooding is never
handled through switchdev, because BR_FLOOD is rejected:

prueth_switchdev_attr_br_flags_pre_set() {
	if (brport_flags.mask & ~(BR_LEARNING | BR_MCAST_FLOOD))
		return -EINVAL;
}

prueth_switchdev_attr_br_flags_set() handles only BR_MCAST_FLOOD, and only
when a brport flag changes. Nothing replays it after the driver restarts
the firmware.

Also, emac_ndo_set_rx_mode_work() has no is_switch_mode check. It drives
UC/MC flooding from IFF_PROMISC/IFF_ALLMULTI and updates these flags in
switch mode too.

Does the EMAC to switch restart then still lose the flooding state? Take
this sequence:

    ip link set ethA master br0
    ip link set ethB master br0

When ethA joins, br_add_if()->br_manage_promisc() puts it in promisc.
rx_mode_work then sets uc/mc_flooding_enabled and enables flooding.

When ethB joins:

prueth_netdevice_port_link()
    prueth->is_switch_mode = true;
    icssg_change_mode()
        prueth_emac_restart()        <- firmware flooding state lost
        icssg_enable_fw_offload()    <- restore skipped, is_switch_mode

br_port_set_promisc() returns early for ethA because it is already
BR_PROMISC, so no new rx_mode_work runs for ethA.

ethB is put into promisc only after the upper link, in
nbp_update_port_count(). Its rx_mode_work runs after the restart and
re-enables flooding on ethB only.

ethA would then be in switch mode with UC/MC flooding off in firmware,
while its flags still say true. The commit message says flooding is
restored "after every firmware restart", but this restart path does not
seem to be covered.

> +			if (emac->uc_flooding_enabled)
> +				icssg_set_port_state(emac, ICSSG_EMAC_PORT_UC_FLOODING_ENABLE);
> +			if (emac->mc_flooding_enabled)
> +				icssg_set_port_state(emac, ICSSG_EMAC_PORT_MC_FLOODING_ENABLE);
> +		}
>  	}
>  }
>  
> @@ -1286,16 +1299,23 @@ static void emac_ndo_set_rx_mode_work(struct work_struct *work)
>  	icssg_set_port_state(emac, ICSSG_EMAC_PORT_MC_FLOODING_DISABLE);
>  
>  	if (promisc) {
> +		emac->uc_flooding_enabled = true;
> +		emac->mc_flooding_enabled = true;
>  		icssg_set_port_state(emac, ICSSG_EMAC_PORT_UC_FLOODING_ENABLE);
>  		icssg_set_port_state(emac, ICSSG_EMAC_PORT_MC_FLOODING_ENABLE);
>  		return;
>  	}
>  
>  	if (allmulti) {
> +		emac->mc_flooding_enabled = true;
> +		emac->uc_flooding_enabled = false;
>  		icssg_set_port_state(emac, ICSSG_EMAC_PORT_MC_FLOODING_ENABLE);
>  		return;
>  	}
>  
> +	emac->uc_flooding_enabled = false;
> +	emac->mc_flooding_enabled = false;
> +

[Severity: Medium]
Setting the flags before the ENABLE commands handles the stale false case.
Is the matching stale true case on the disable side still open?

The work writes these flags without rtnl or any driver lock.
icssg_enable_fw_offload() reads them without a lock, under rtnl, from the
netdevice notifier. prueth_emac_restart() does not flush or cancel
rx_mode_work.

The DISABLE commands go out at the top of emac_ndo_set_rx_mode_work(), but
the flags are only cleared here. Suppose promisc was on and IFF_PROMISC has
just been cleared:

rx_mode_work                          prueth_netdevice_port_unlink()
                                          prueth_emac_restart()
UC_FLOODING_DISABLE
MC_FLOODING_DISABLE
                                          icssg_enable_fw_offload()
                                              reads uc/mc_flooding_enabled
                                              == true (stale)
                                              UC_FLOODING_ENABLE
                                              MC_FLOODING_ENABLE
uc_flooding_enabled = false
mc_flooding_enabled = false

Would the firmware then keep flooding, with IFF_PROMISC off and the flags
false, until the next rx mode change? The allmulti branch above has the
same ordering for uc_flooding_enabled.

This window opens on every bridge unlink.
del_nbp()->nbp_delete_promisc() calls dev_set_promiscuity(-1), which queues
rx_mode_work right before netdev_upper_dev_unlink() triggers the unlink
restart.

prueth_hsr_port_unlink() and icssg_change_mode() can race in the same way.
Each R30 command the work sends while the firmware is stopped can also wait
for its 10 ms timeout, which widens the window.

>  	if (emac->prueth->is_hsr_offload_mode) {

[Severity: High]
This isn't a bug introduced by this patch, but can this check-then-use
cause a NULL pointer dereference of prueth->hsr_dev? It appears to date
from 161087db66d6b.

The work reads is_hsr_offload_mode here without rtnl. It then issues
sleeping FDB commands through __dev_mc_sync() and
icssg_hsr_handle_multicast_sync(); icssg_send_fdb_msg() polls for up to 20
seconds per command. Only after that does it run:

		if (rtnl_trylock()) {
			vlan_for_each(emac->prueth->hsr_dev,
				      icssg_update_vlan_mcast, emac);
			rtnl_unlock();
		}

Meanwhile, prueth_hsr_port_unlink() can run under rtnl:

	prueth->is_hsr_offload_mode = false;
	...
	prueth->hsr_dev = NULL;
	ret = prueth_emac_restart(prueth);

The work's FDB commands can stall while the firmware is stopped, so it can
stay between the check and the trylock for the whole unlink. The trylock
then succeeds, and vlan_for_each(NULL, ...) dereferences dev->vlan_info on
a NULL dev.

Separately, if rtnl is held when rtnl_trylock() runs (for example by the
notifier doing the restart), the VLAN multicast sync is silently skipped
and never retried.

Should is_hsr_offload_mode and hsr_dev be re-checked under rtnl, and the
sync be deferred rather than skipped?

>  		/* Track basic add/delete via callbacks */
>  		__dev_mc_sync(ndev, icssg_prueth_hsr_add_mcast,

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261112102140.2744508-1-m-malladi%40ti.com
Re: [PATCH net v3 RESEND 0/3] Fix switch mode for offload and non-offload cases
#19521
Author: Jakub Kicinski
Date: Fri, 20 Nov 2026 00:44
9 lines
8143 bytes
On Thu, 12 Nov 2026 15:51:37 +0530 Meghana Malladi wrote:
> v2: https://lore.kernel.org/all/20261027131732.3411403-1-m-malladi@ti.com/

What changed in v3? When was v3 posted (since this is a repost?)
You are expected to reply to the sashiko review, even if just
to confirm that it's correct.
-- 
pw-bot: cr
Re: [PATCH net v3 RESEND 0/3] Fix switch mode for offload and non-offload cases
#20147
Author: Meghana Malladi
Date: Sat, 21 Nov 2026 15:07
47 lines
22566 bytes
Hi Jakub,

On 11/20/26 06:14, Jakub Kicinski wrote:
> On Thu, 12 Nov 2026 15:51:37 +0530 Meghana Malladi wrote:
>> v2: https://lore.kernel.org/all/20261027131732.3411403-1-m-malladi@ti.com/
> 
> What changed in v3? When was v3 posted (since this is a repost?)

I first posted v3 on November 10 and resent the full series on

November 12. Here's the original cover letter:



https://lore.kernel.org/all/20261110122700.1849634-1-m-malladi@ti.com/

I reposted because I lately realized patch 3/3 was missing (could me 
mail server glitch)

I included the v2-to-v3 changes in the individual patch notes. Here's 
the summary for the series:
* Patch 1/3 adds a TX timestamp cleanup fix so reserved ERR_PTR(-EBUSY)

   slots are cleared without attempting to free them as skbs.

* Patch 2/3 changes the R30 race fix to stop and restart phylib around

   the PRU firmware restart, so emac_adjust_link() cannot issue R30

   commands while the firmware is stopped.

* Patch 3/3 records the UC/MC flooding flags before issuing the firmware

   commands and restores the flooding state after firmware restarts on

   bridge and HSR unlink. It also carries the NULL emac check from v2.

> You are expected to reply to the sashiko review, even if just
> to confirm that it's correct.

Yes, got it. Some series specifically ask for it and some don't. So it 
slipped my mind while posting. I will keep that in mind for my upcoming 
patches.

Thanks,
Meghana
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads