mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Meghana Malladi <m-malladi@ti.com>
To: <diogo.ivo@siemens.com>, <haokexin@gmail.com>,
	<philippe.schenker@impulsing.ch>, <devnexen@gmail.com>,
	<horms@kernel.org>, <jacob.e.keller@intel.com>,
	<m-malladi@ti.com>, <pabeni@redhat.com>, <kuba@kernel.org>,
	<edumazet@kernel.org>, <davem@davemloft.net>,
	<andrew+netdev@lunn.ch>
Cc: <linux-kernel@vger.kernel.org>, <netdev@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>,
	Vignesh Raghavendra <vigneshr@ti.com>, <danishanwar@ti.com>
Subject: [PATCH net v3 RESEND 3/3] net: ti: icssg-prueth: Fix bridge port_vlan and flooding state
Date: Thu, 12 Nov 2026 15:51:40 +0530	[thread overview]
Message-ID: <20261112102140.2744508-4-m-malladi@ti.com> (raw)
In-Reply-To: <20261112102140.2744508-1-m-malladi@ti.com>

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


  parent reply	other threads:[~2026-11-12 10:22 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-12 10:21 [PATCH net v3 RESEND 0/3] Fix switch mode for offload and non-offload cases Meghana Malladi
2026-11-12 10:21 ` [PATCH net v3 RESEND 1/3] net: ti: icssg-prueth: Fix TX timestamp cleanup crash Meghana Malladi
2026-11-12 10:21 ` [PATCH net v3 RESEND 2/3] net: ti: icssg-prueth: Fix phylib stop/start in emac_restart Meghana Malladi
2026-11-12 10:21 ` Meghana Malladi [this message]
2026-11-12 10:26 ` [PATCH net v3 RESEND 0/3] Fix switch mode for offload and non-offload cases netdev-bot+sinfo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261112102140.2744508-4-m-malladi@ti.com \
    --to=m-malladi@ti.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=danishanwar@ti.com \
    --cc=davem@davemloft.net \
    --cc=devnexen@gmail.com \
    --cc=diogo.ivo@siemens.com \
    --cc=edumazet@kernel.org \
    --cc=haokexin@gmail.com \
    --cc=horms@kernel.org \
    --cc=jacob.e.keller@intel.com \
    --cc=kuba@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=philippe.schenker@impulsing.ch \
    --cc=vigneshr@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®