* [PATCH net-next 0/5] net: dsa: microchip: let the bridge decide about link-local frames
@ 2026-11-26 8:07 Oleksij Rempel
2026-11-26 8:07 ` [PATCH net-next 1/5] net: dsa: tag_ksz: do not mark trapped link-local frames as forwarded Oleksij Rempel
` (5 more replies)
0 siblings, 6 replies; 13+ messages in thread
From: Oleksij Rempel @ 2026-11-26 8:07 UTC (permalink / raw)
To: Woojung Huh, UNGLinuxDriver, Andrew Lunn, Vladimir Oltean,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: Simon Horman, Florian Fainelli, Nikolay Aleksandrov, Ido Schimmel,
netdev, bridge, kernel, Oleksij Rempel
Let the bridge decide about the link-local frames that the KSZ9477
family and LAN937x trap to the CPU. These switches trap most link-local
groups (01:80:C2:00:00:0X, for example STP BPDUs and LLDP), but the
tagger marks the frames as forwarded in hardware. So the bridge never
forwards them to the other ports of the switch, whatever group_fwd_mask
says. An FDB or MDB entry for such a group can also make the switch
forward these frames on its own.
The tagger now leaves these frames unmarked, and the driver keeps FDB
and MDB entries for them out of the hardware. As the bridge then sends
some link-local frames back out through the CPU port, the switch no
longer learns addresses there; DSA adds the addresses that the bridge
learns on its other ports, such as Wi-Fi, as static entries instead. An
old FDB bug hits these entries often, so one patch fixes it; without the
series it needs a static entry added over a learned one, so that patch
goes to net-next with the series. The series goes to net-next as it
changes how the bridge handles link-local frames.
To reproduce on a KSZ9893, with link partners on lan1 and lan2:
ip link add br0 type bridge
ip link set lan1 master br0 up; ip link set lan2 master br0 up
ip link set br0 up
# 0x4000: forward 01:80:C2:00:00:0E
ip link set br0 type bridge group_fwd_mask 0x4000
# Send frames to 01:80:C2:00:00:0E into lan1. Without the series
# none reach lan2; with it, all do.
With STP off, the bridge now also forwards BPDUs between the ports of
the switch. IEEE 802.1Q says a bridge filters frames to the reserved
addresses, including the BPDU address 01:80:C2:00:00:00. The Linux
bridge forwards BPDUs when STP is off, so that other bridges can still
detect a loop through it; see commit a598f6aebea2 ("bridge: relay
bridge multicast pkgs if !STP"). DSA switches whose tagger leaves
trapped or link-local frames unmarked, such as mv88e6xxx and b53,
already behave this way.
The switches driven by ksz8.c (KSZ8463, KSZ87xx, KSZ88x3, KSZ8864,
KSZ8895, KSZ8995XA) keep their behaviour; KSZ8563 and KSZ8567 use the
KSZ9477 code and are covered. The ksz8.c switches have one static MAC
table. It holds the trap entries, the FDB and MDB entries and the local
addresses of the bridge, and on the KSZ88x3 it has only 8 entries, so a
change on the KSZ88x3 can run out of space. Of these switches I can test
only a KSZ8873, so I left them unchanged. Their taggers still mark all
frames as forwarded.
Tested on a KSZ9893.
---
Oleksij Rempel (5):
net: dsa: tag_ksz: do not mark trapped link-local frames as forwarded
net: dsa: microchip: ksz9477: do not keep the learned port in FDB entries
net: dsa: microchip: ksz9477: do not learn addresses on the CPU port
net: dsa: microchip: ksz9477: refuse FDB/MDB entries for trapped groups
net: dsa: microchip: ksz9477: report the trapped link-local groups
drivers/net/dsa/microchip/ksz9477.c | 81 +++++++++++++++++++++++++++++---
drivers/net/dsa/microchip/ksz_common.h | 14 ++++++
drivers/net/dsa/microchip/lan937x_main.c | 16 ++++---
include/linux/dsa/ksz_common.h | 8 ++++
net/dsa/tag_ksz.c | 42 ++++++++++++++++-
5 files changed, 145 insertions(+), 16 deletions(-)
---
base-commit: c2621b518b38ed38e280e008aa33e6c2d302f8cc
change-id: 20261125-ksz-stp-link-local-5c53396cc960
Best regards,
--
Oleksij Rempel <o.rempel@pengutronix.de>
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH net-next 1/5] net: dsa: tag_ksz: do not mark trapped link-local frames as forwarded
2026-11-26 8:07 [PATCH net-next 0/5] net: dsa: microchip: let the bridge decide about link-local frames Oleksij Rempel
@ 2026-11-26 8:07 ` Oleksij Rempel
2026-11-26 14:47 ` Andrew Lunn
2026-11-26 8:07 ` [PATCH net-next 2/5] net: dsa: microchip: ksz9477: do not keep the learned port in FDB entries Oleksij Rempel
` (4 subsequent siblings)
5 siblings, 1 reply; 13+ messages in thread
From: Oleksij Rempel @ 2026-11-26 8:07 UTC (permalink / raw)
To: Woojung Huh, UNGLinuxDriver, Andrew Lunn, Vladimir Oltean,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: Simon Horman, Florian Fainelli, Nikolay Aleksandrov, Ido Schimmel,
netdev, bridge, kernel, Oleksij Rempel
Do not mark trapped link-local frames as forwarded in hardware. The
switch did not forward them, so the mark would be wrong. Whether such a
frame is forwarded is policy, and that belongs to the bridge, not to the
driver.
The switch traps frames to some of the reserved addresses
01:80:C2:00:00:00 to :0F, that is, sends them only to the CPU. For
example:
- 01:80:C2:00:00:00: STP BPDUs
- 01:80:C2:00:00:02: LACP and other slow protocols
- 01:80:C2:00:00:03: 802.1X (EAPOL)
- 01:80:C2:00:00:0E: LLDP, PTP
Some link-local frames must still be marked as forwarded. The KSZ8873,
which uses the same tag as the KSZ9893, traps only 01:80:C2:00:00:00
and floods LLDP frames (01:80:C2:00:00:0E) like normal multicast.
Without the forwarding mark, the bridge could forward such a frame a
second time, if group_fwd_mask allows it. The tail tag does not say
whether a frame was trapped, so the switch driver gives the tagger a
bitmap of the groups the switch traps. No driver fills the bitmap yet,
so frame handling does not change with this patch alone.
Give the KSZ8795 tag a connect callback that allocates the tagger data,
as the tagger now reads it for every KSZ tag protocol.
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
include/linux/dsa/ksz_common.h | 8 ++++++++
net/dsa/tag_ksz.c | 42 ++++++++++++++++++++++++++++++++++++++++--
2 files changed, 48 insertions(+), 2 deletions(-)
diff --git a/include/linux/dsa/ksz_common.h b/include/linux/dsa/ksz_common.h
index 576a99ca698d13cc3debd41a310502b29fc85c63..66d480c435c2f98b5a77bc64422b43414946f143 100644
--- a/include/linux/dsa/ksz_common.h
+++ b/include/linux/dsa/ksz_common.h
@@ -32,6 +32,14 @@ struct ksz_deferred_xmit_work {
struct ksz_tagger_data {
void (*xmit_work_fn)(struct kthread_work *work);
void (*hwtstamp_set_state)(struct dsa_switch *ds, bool on);
+ /* Bit N is set if the switch traps frames to 01:80:C2:00:00:0N
+ * (N = 0x0 to 0xf), that is, sends them to the CPU only. The tagger
+ * does not mark these frames as forwarded, so the bridge, not the
+ * switch, decides whether to forward them. Only the switch driver
+ * writes this bitmap, from .connect_tag_protocol, before the tagger
+ * receives any frame.
+ */
+ u16 link_local_to_cpu;
};
struct ksz_skb_cb {
diff --git a/net/dsa/tag_ksz.c b/net/dsa/tag_ksz.c
index b0340a7be8c9a6dcd52a64117e10fe3e134026e6..16da9daf774904222bd92f771086aa74e1bc390b 100644
--- a/net/dsa/tag_ksz.c
+++ b/net/dsa/tag_ksz.c
@@ -48,11 +48,28 @@ static void ksz_disconnect(struct dsa_switch *ds)
{
struct ksz_tagger_private *priv = ds->tagger_data;
- kthread_destroy_worker(priv->xmit_worker);
+ /* Tags without deferred xmit have no worker */
+ if (priv->xmit_worker)
+ kthread_destroy_worker(priv->xmit_worker);
+
kfree(priv);
ds->tagger_data = NULL;
}
+/* Allocate the tagger data, without a deferred xmit worker */
+static int ksz8795_connect(struct dsa_switch *ds)
+{
+ struct ksz_tagger_private *priv;
+
+ priv = kzalloc_obj(*priv);
+ if (!priv)
+ return -ENOMEM;
+
+ ds->tagger_data = priv;
+
+ return 0;
+}
+
static int ksz_connect(struct dsa_switch *ds)
{
struct ksz_tagger_data *tagger_data;
@@ -81,6 +98,19 @@ static int ksz_connect(struct dsa_switch *ds)
return 0;
}
+static bool ksz_link_local_trapped(struct net_device *user, const u8 *addr)
+{
+ struct ksz_tagger_data *tagger_data;
+
+ if (!is_link_local_ether_addr(addr))
+ return false;
+
+ tagger_data = ksz_tagger_data(dsa_user_to_port(user)->ds);
+
+ /* is_link_local_ether_addr() limits addr[5] to 0x00..0x0f */
+ return tagger_data->link_local_to_cpu & BIT(addr[5]);
+}
+
static struct sk_buff *ksz_common_rcv(struct sk_buff *skb,
struct net_device *dev,
unsigned int port, unsigned int len)
@@ -96,7 +126,13 @@ static struct sk_buff *ksz_common_rcv(struct sk_buff *skb,
return NULL;
}
- dsa_default_offload_fwd_mark(skb);
+ /* The switch driver reports which link-local groups the switch sends
+ * to the CPU only. The switch did not forward frames to these groups,
+ * so do not mark them, and let the bridge apply its own rules
+ * (group_fwd_mask, STP state).
+ */
+ if (!ksz_link_local_trapped(skb->dev, eth_hdr(skb)->h_dest))
+ dsa_default_offload_fwd_mark(skb);
return skb;
}
@@ -360,6 +396,8 @@ static const struct dsa_device_ops ksz8795_netdev_ops = {
.proto = DSA_TAG_PROTO_KSZ8795,
.xmit = ksz8795_xmit,
.rcv = ksz8795_rcv,
+ .connect = ksz8795_connect,
+ .disconnect = ksz_disconnect,
.needed_tailroom = KSZ_INGRESS_TAG_LEN,
};
--
2.47.3
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH net-next 2/5] net: dsa: microchip: ksz9477: do not keep the learned port in FDB entries
2026-11-26 8:07 [PATCH net-next 0/5] net: dsa: microchip: let the bridge decide about link-local frames Oleksij Rempel
2026-11-26 8:07 ` [PATCH net-next 1/5] net: dsa: tag_ksz: do not mark trapped link-local frames as forwarded Oleksij Rempel
@ 2026-11-26 8:07 ` Oleksij Rempel
2026-11-27 8:24 ` netdev-bot+sashiko
2026-11-26 8:07 ` [PATCH net-next 3/5] net: dsa: microchip: ksz9477: do not learn addresses on the CPU port Oleksij Rempel
` (3 subsequent siblings)
5 siblings, 1 reply; 13+ messages in thread
From: Oleksij Rempel @ 2026-11-26 8:07 UTC (permalink / raw)
To: Woojung Huh, UNGLinuxDriver, Andrew Lunn, Vladimir Oltean,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: Simon Horman, Florian Fainelli, Nikolay Aleksandrov, Ido Schimmel,
netdev, bridge, kernel, Oleksij Rempel
Do not keep the learned port when adding a static FDB entry.
The ALU table of the switch keeps learned (dynamic) and static
entries, one entry per address. An example: the switch has learned
host H on lan1. Then a static FDB entry for H is added on lan2. The
driver does not add a new entry. It finds the learned entry, makes it
static and adds lan2 to its ports. The entry is now static and points
to lan1 and lan2.
When the FDB entry is deleted, the driver removes only lan2. The entry
stays static and still points to lan1. Static entries never age out.
So the switch keeps sending frames for H to lan1, even after H has
moved.
The bug is hit much more often once the driver sets
ds->assisted_learning_on_cpu_port, which the next ksz9477 change does.
DSA then adds a static entry on the CPU port for each address the
bridge learns on ports outside the switch, such as Wi-Fi. If H was
learned on lan1 and then moved to Wi-Fi, the entry for the CPU port
still points to lan1 too.
LAN937x uses the same code.
Found in code review. Confirmed on a KSZ9893; with H learned on lan1,
run:
bridge fdb replace <H> dev lan2 master static
bridge fdb del <H> dev lan2 master static
bridge fdb show # still shows "<H> dev lan1 self static"
Tested on a KSZ9893 with the commands above and with our labgrid
switch tests: with this patch, no static entry for <H> is left.
Fixes: b987e98e50ab ("dsa: add DSA switch driver for Microchip KSZ9477")
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
If bridge fdb replace moves an existing static entry to another port,
the entry still keeps the old port. This patch does not change that.
---
drivers/net/dsa/microchip/ksz9477.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchip/ksz9477.c
index 972703fe7454f2892b98dc507a1cba0a5c91dabd..98211d9835734c52f25dcbf7494df45166bcc8da 100644
--- a/drivers/net/dsa/microchip/ksz9477.c
+++ b/drivers/net/dsa/microchip/ksz9477.c
@@ -800,6 +800,13 @@ int ksz9477_fdb_add(struct dsa_switch *ds, int port,
/* read ALU entry */
ksz9477_read_table(dev, alu_table);
+ /* The ALU table holds learned and static entries. If the entry is
+ * not static (learned, or none found), clear its port map, so that
+ * the static entry lists only this port.
+ */
+ if (!(alu_table[0] & ALU_V_STATIC_VALID))
+ alu_table[1] &= ~ALU_V_PORT_MAP;
+
/* update ALU entry */
alu_table[0] = ALU_V_STATIC_VALID;
alu_table[1] |= BIT(port);
--
2.47.3
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH net-next 3/5] net: dsa: microchip: ksz9477: do not learn addresses on the CPU port
2026-11-26 8:07 [PATCH net-next 0/5] net: dsa: microchip: let the bridge decide about link-local frames Oleksij Rempel
2026-11-26 8:07 ` [PATCH net-next 1/5] net: dsa: tag_ksz: do not mark trapped link-local frames as forwarded Oleksij Rempel
2026-11-26 8:07 ` [PATCH net-next 2/5] net: dsa: microchip: ksz9477: do not keep the learned port in FDB entries Oleksij Rempel
@ 2026-11-26 8:07 ` Oleksij Rempel
2026-11-27 8:24 ` netdev-bot+sashiko
2026-11-26 8:07 ` [PATCH net-next 4/5] net: dsa: microchip: ksz9477: refuse FDB/MDB entries for trapped groups Oleksij Rempel
` (2 subsequent siblings)
5 siblings, 1 reply; 13+ messages in thread
From: Oleksij Rempel @ 2026-11-26 8:07 UTC (permalink / raw)
To: Woojung Huh, UNGLinuxDriver, Andrew Lunn, Vladimir Oltean,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: Simon Horman, Florian Fainelli, Nikolay Aleksandrov, Ido Schimmel,
netdev, bridge, kernel, Oleksij Rempel
Do not learn addresses on the CPU port of the KSZ9477 family (including
KSZ8563 and KSZ8567) and LAN937x. The bridge also learns addresses on
ports outside the switch, for example on Wi-Fi. DSA adds these as
static entries on the CPU port, so the switch does not need to learn
them there. DSA already adds the bridge's own addresses there.
This prepares for reporting the trapped link-local groups to the
tagger. The switch sends trapped frames only to the CPU. Once the
groups are reported, the bridge can forward such frames, for example
BPDUs, in software. It sends them back to the switch through the CPU
port, with the sender's source address, and a learning CPU port then
records the sender there. Frames from the other switch ports to the
sender go to the CPU, and the bridge does not send them back out. This
repeats with every such frame the bridge forwards. I saw this on a
KSZ9893 with the report patch applied.
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
HSR: the HSR ports are in no bridge, so DSA adds no host entry for the
HSR MAC address. From the code, unicast to the node is now also flooded
to the other ring port, where the CPU port used to learn the address.
---
drivers/net/dsa/microchip/ksz9477.c | 15 ++++++++-------
drivers/net/dsa/microchip/lan937x_main.c | 15 ++++++++-------
2 files changed, 16 insertions(+), 14 deletions(-)
diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchip/ksz9477.c
index 98211d9835734c52f25dcbf7494df45166bcc8da..8271bc742ddc5c92b925b01bedfcf876cfa14078 100644
--- a/drivers/net/dsa/microchip/ksz9477.c
+++ b/drivers/net/dsa/microchip/ksz9477.c
@@ -1710,7 +1710,6 @@ static int ksz9477_setup(struct dsa_switch *ds)
struct ksz_device *dev = ds->priv;
u16 storm_mask, storm_rate;
struct dsa_port *dp;
- struct ksz_port *p;
const u16 *regs;
int ret;
@@ -1792,13 +1791,15 @@ static int ksz9477_setup(struct dsa_switch *ds)
if (ret < 0)
return ret;
- /* Start with learning disabled on standalone user ports, and enabled
- * on the CPU port. In lack of other finer mechanisms, learning on the
- * CPU port will avoid flooding bridge local addresses on the network
- * in some cases.
+ /* Ask DSA to add the addresses that the bridge learns on ports
+ * outside the switch as static entries on the CPU port. The CPU
+ * port itself does not learn: when the bridge forwards a frame in
+ * software between two ports of the switch, the switch would learn
+ * the sender on the CPU port. p->learning is never set for the CPU
+ * port, so ksz_port_stp_state_set() disables learning when DSA sets
+ * the port to forwarding.
*/
- p = &dev->ports[dev->cpu_port];
- p->learning = true;
+ ds->assisted_learning_on_cpu_port = true;
if (dev->irq > 0) {
ret = ksz_girq_setup(dev);
diff --git a/drivers/net/dsa/microchip/lan937x_main.c b/drivers/net/dsa/microchip/lan937x_main.c
index f0fb9498026120b3069b31d01bd0252be6f15403..7971d120630d173a1bbed6fb98683cee27d8fe89 100644
--- a/drivers/net/dsa/microchip/lan937x_main.c
+++ b/drivers/net/dsa/microchip/lan937x_main.c
@@ -770,7 +770,6 @@ static int lan937x_setup(struct dsa_switch *ds)
struct ksz_device *dev = ds->priv;
u16 storm_mask, storm_rate;
struct dsa_port *dp;
- struct ksz_port *p;
const u16 *regs;
int ret;
@@ -843,13 +842,15 @@ static int lan937x_setup(struct dsa_switch *ds)
if (ret < 0)
return ret;
- /* Start with learning disabled on standalone user ports, and enabled
- * on the CPU port. In lack of other finer mechanisms, learning on the
- * CPU port will avoid flooding bridge local addresses on the network
- * in some cases.
+ /* Ask DSA to add the addresses that the bridge learns on ports
+ * outside the switch as static entries on the CPU port. The CPU
+ * port itself does not learn: when the bridge forwards a frame in
+ * software between two ports of the switch, the switch would learn
+ * the sender on the CPU port. p->learning is never set for the CPU
+ * port, so ksz_port_stp_state_set() disables learning when DSA sets
+ * the port to forwarding.
*/
- p = &dev->ports[dev->cpu_port];
- p->learning = true;
+ ds->assisted_learning_on_cpu_port = true;
if (dev->irq > 0) {
ret = ksz_girq_setup(dev);
--
2.47.3
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH net-next 4/5] net: dsa: microchip: ksz9477: refuse FDB/MDB entries for trapped groups
2026-11-26 8:07 [PATCH net-next 0/5] net: dsa: microchip: let the bridge decide about link-local frames Oleksij Rempel
` (2 preceding siblings ...)
2026-11-26 8:07 ` [PATCH net-next 3/5] net: dsa: microchip: ksz9477: do not learn addresses on the CPU port Oleksij Rempel
@ 2026-11-26 8:07 ` Oleksij Rempel
2026-11-27 8:24 ` netdev-bot+sashiko
2026-11-26 8:07 ` [PATCH net-next 5/5] net: dsa: microchip: ksz9477: report the trapped link-local groups Oleksij Rempel
2026-11-26 10:23 ` [PATCH net-next 0/5] net: dsa: microchip: let the bridge decide about link-local frames Vladimir Oltean
5 siblings, 1 reply; 13+ messages in thread
From: Oleksij Rempel @ 2026-11-26 8:07 UTC (permalink / raw)
To: Woojung Huh, UNGLinuxDriver, Andrew Lunn, Vladimir Oltean,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: Simon Horman, Florian Fainelli, Nikolay Aleksandrov, Ido Schimmel,
netdev, bridge, kernel, Oleksij Rempel
Refuse FDB and MDB entries for trapped link-local groups on user ports,
so that they cannot bypass the trap.
The KSZ9477 family looks up a destination address in the address
lookup table (learned and static FDB entries), the static address table
(MDB entries) and the reserved multicast table. The driver traps the
link-local groups with the reserved multicast table: it sends
01:80:C2:00:00:00 to :0F to the CPU only, except :01 (PAUSE frames),
which it drops. On a KSZ9893, an FDB or MDB entry for a trapped group
overrides that rule. The switch then forwards such frames by its own
lookup, while the bridge decides in software whether to forward these
groups:
- with an MDB entry for 01:80:C2:00:00:0E on lan2, the switch forwarded
these frames from lan1 to lan2, although group_fwd_mask did not allow
it.
- with a host FDB entry for 01:80:C2:00:00:00, a Blocking port stopped
passing BPDUs to the CPU, so the bridge moved the port to Listening.
Record the trapped groups when the driver sets up the reserved multicast
table, and refuse to offload such entries on user ports with
-EOPNOTSUPP. bridge fdb add and bridge mdb add still succeed, and the
bridge keeps the entries without the offload flag. In software the
bridge uses only the MDB entries for these groups, so an FDB entry for
such a group has no effect. DSA logs an error for a refused FDB entry,
not for an MDB entry. Accept the entries on the CPU and DSA ports
without a write. Entries for :01 are accepted as before.
A later patch makes the tagger stop marking these frames as already
forwarded by the switch. This patch comes first, so that the switch and
the bridge never both forward such a frame. Until then, frames to a
group with a refused MDB entry are not forwarded between switch ports
at all.
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
drivers/net/dsa/microchip/ksz9477.c | 58 ++++++++++++++++++++++++++++++++++
drivers/net/dsa/microchip/ksz_common.h | 2 ++
2 files changed, 60 insertions(+)
diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchip/ksz9477.c
index 8271bc742ddc5c92b925b01bedfcf876cfa14078..b972c9fab55c170758dac97bda026e1f29e487f2 100644
--- a/drivers/net/dsa/microchip/ksz9477.c
+++ b/drivers/net/dsa/microchip/ksz9477.c
@@ -768,6 +768,27 @@ int ksz9477_port_vlan_del(struct dsa_switch *ds, int port,
return 0;
}
+/* True if @addr is a link-local group that the switch sends to the CPU only.
+ * An FDB or MDB entry for such a group would override the trap.
+ */
+static bool ksz9477_link_local_is_trapped(struct ksz_device *dev,
+ const unsigned char *addr)
+{
+ /* is_link_local_ether_addr() limits addr[5] to 0x00..0x0f */
+ return is_link_local_ether_addr(addr) &&
+ dev->link_local_to_cpu & BIT(addr[5]);
+}
+
+/* Return -EOPNOTSUPP on a user port, so that the bridge keeps the entry in
+ * software and does not mark it offloaded. Return 0 on the CPU and DSA ports
+ * and write nothing: the bridge adds its host entries there, and they must
+ * not fail.
+ */
+static int ksz9477_link_local_entry_err(struct dsa_switch *ds, int port)
+{
+ return dsa_is_user_port(ds, port) ? -EOPNOTSUPP : 0;
+}
+
int ksz9477_fdb_add(struct dsa_switch *ds, int port,
const unsigned char *addr, u16 vid, struct dsa_db db)
{
@@ -776,6 +797,9 @@ int ksz9477_fdb_add(struct dsa_switch *ds, int port,
u32 data;
int ret = 0;
+ if (ksz9477_link_local_is_trapped(dev, addr))
+ return ksz9477_link_local_entry_err(ds, port);
+
mutex_lock(&dev->alu_mutex);
/* find any entry with mac & vid */
@@ -840,6 +864,10 @@ int ksz9477_fdb_del(struct dsa_switch *ds, int port,
u32 data;
int ret = 0;
+ /* never written, see ksz9477_link_local_entry_err() */
+ if (ksz9477_link_local_is_trapped(dev, addr))
+ return 0;
+
mutex_lock(&dev->alu_mutex);
/* read any entry with mac & vid */
@@ -989,6 +1017,9 @@ int ksz9477_mdb_add(struct dsa_switch *ds, int port,
u32 mac_hi, mac_lo;
int err = 0;
+ if (ksz9477_link_local_is_trapped(dev, mdb->addr))
+ return ksz9477_link_local_entry_err(ds, port);
+
shifts = dev->info->shifts;
masks = dev->info->masks;
@@ -1069,6 +1100,10 @@ int ksz9477_mdb_del(struct dsa_switch *ds, int port,
int index;
u32 data;
+ /* never written, see ksz9477_link_local_entry_err() */
+ if (ksz9477_link_local_is_trapped(dev, mdb->addr))
+ return 0;
+
shifts = dev->info->shifts;
masks = dev->info->masks;
@@ -1554,8 +1589,21 @@ static void ksz9477_config_cpu_port(struct dsa_switch *ds)
static u8 reserved_mcast_map[RESV_MCAST_CNT] = { 0, 1, 3, 16, 32, 33, 2, 17 };
+/* Index: group number in the datasheet's Reserved Multicast Address Table,
+ * the same index as reserved_mcast_map. Value: the link-local addresses the
+ * group covers, bit X for 01:80:C2:00:00:0X. The other groups cover
+ * addresses above :0F.
+ */
+static const u16 ksz9477_resv_mcast_link_local[RESV_MCAST_CNT] = {
+ [0] = BIT(0), /* STP BPDUs */
+ [1] = BIT(1), /* MAC control (e.g. PAUSE), dropped */
+ [2] = BIT(3), /* 802.1X (EAPOL) */
+ [6] = BIT(2) | GENMASK(15, 4), /* LACP, LLDP and others */
+};
+
int ksz9477_enable_stp_addr(struct ksz_device *dev)
{
+ u16 link_local_to_cpu = 0;
u8 i, ports, update;
const u32 *masks;
bool override;
@@ -1621,6 +1669,14 @@ int ksz9477_enable_stp_addr(struct ksz_device *dev)
update = ports;
break;
}
+
+ /* Record the link-local addresses of group i if the switch
+ * sends it to the CPU only. Group 1 keeps its drop default and
+ * does not match.
+ */
+ if (update == BIT(dev->cpu_port))
+ link_local_to_cpu |= ksz9477_resv_mcast_link_local[i];
+
if (update != ports || override) {
data &= ~dev->port_mask;
data |= update;
@@ -1650,6 +1706,8 @@ int ksz9477_enable_stp_addr(struct ksz_device *dev)
}
}
+ dev->link_local_to_cpu = link_local_to_cpu;
+
return 0;
}
diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h
index 8819670cbb053eeb73ea4a7685303d9849bd6efb..7b96d110b1f64f4226ee7a371da38cd7e5b3767a 100644
--- a/drivers/net/dsa/microchip/ksz_common.h
+++ b/drivers/net/dsa/microchip/ksz_common.h
@@ -243,6 +243,8 @@ struct ksz_device {
u16 mirror_rx;
u16 mirror_tx;
u16 port_mask;
+ /* link-local groups sent to the CPU only, bit X: 01:80:C2:00:00:0X */
+ u16 link_local_to_cpu;
struct mutex lock_irq; /* IRQ Access */
struct ksz_irq girq;
struct ksz_ptp_data ptp_data;
--
2.47.3
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH net-next 5/5] net: dsa: microchip: ksz9477: report the trapped link-local groups
2026-11-26 8:07 [PATCH net-next 0/5] net: dsa: microchip: let the bridge decide about link-local frames Oleksij Rempel
` (3 preceding siblings ...)
2026-11-26 8:07 ` [PATCH net-next 4/5] net: dsa: microchip: ksz9477: refuse FDB/MDB entries for trapped groups Oleksij Rempel
@ 2026-11-26 8:07 ` Oleksij Rempel
2026-11-27 8:24 ` netdev-bot+sashiko
2026-11-26 10:23 ` [PATCH net-next 0/5] net: dsa: microchip: let the bridge decide about link-local frames Vladimir Oltean
5 siblings, 1 reply; 13+ messages in thread
From: Oleksij Rempel @ 2026-11-26 8:07 UTC (permalink / raw)
To: Woojung Huh, UNGLinuxDriver, Andrew Lunn, Vladimir Oltean,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: Simon Horman, Florian Fainelli, Nikolay Aleksandrov, Ido Schimmel,
netdev, bridge, kernel, Oleksij Rempel
Tell the tagger which link-local groups the KSZ9477 family and LAN937x
trap to the CPU. The tagger then no longer marks these frames as
forwarded in hardware (offload_fwd_mark). The bridge applies
group_fwd_mask and the STP state to them and can forward them to the
other ports of the switch.
Tested on a KSZ9893: with the group_fwd_mask bit for 01:80:C2:00:00:0E
set, the bridge relayed 20 of 20 frames to that group from lan1 to lan2
with this change, and 0 of 20 without it.
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
drivers/net/dsa/microchip/ksz9477.c | 1 +
drivers/net/dsa/microchip/ksz_common.h | 12 ++++++++++++
drivers/net/dsa/microchip/lan937x_main.c | 1 +
3 files changed, 14 insertions(+)
diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchip/ksz9477.c
index b972c9fab55c170758dac97bda026e1f29e487f2..3dee81d89c1d7e64314a073980fb648431126a09 100644
--- a/drivers/net/dsa/microchip/ksz9477.c
+++ b/drivers/net/dsa/microchip/ksz9477.c
@@ -2109,6 +2109,7 @@ static int ksz9477_connect_tag_protocol(struct dsa_switch *ds,
tagger_data = ksz_tagger_data(ds);
tagger_data->xmit_work_fn = ksz_port_deferred_xmit;
+ ksz_tagger_set_link_local_to_cpu(ds);
return 0;
}
diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h
index 7b96d110b1f64f4226ee7a371da38cd7e5b3767a..1f96b91016fcfa20f99599c10d4095d7f384f7f6 100644
--- a/drivers/net/dsa/microchip/ksz_common.h
+++ b/drivers/net/dsa/microchip/ksz_common.h
@@ -7,6 +7,7 @@
#ifndef __KSZ_COMMON_H
#define __KSZ_COMMON_H
+#include <linux/dsa/ksz_common.h>
#include <linux/etherdevice.h>
#include <linux/irqdomain.h>
#include <linux/kernel.h>
@@ -836,6 +837,17 @@ static inline bool is_lan937x_tx_phy(struct ksz_device *dev, int port)
dev->chip_id == LAN9372_CHIP_ID) && port == KSZ_PORT_4;
}
+/* Copy dev->link_local_to_cpu to the tagger. Call this from
+ * connect_tag_protocol: ksz9477_enable_stp_addr() fills the bitmap during
+ * ->setup(), and DSA connects the tagger only after ->setup().
+ */
+static inline void ksz_tagger_set_link_local_to_cpu(struct dsa_switch *ds)
+{
+ struct ksz_device *dev = ds->priv;
+
+ ksz_tagger_data(ds)->link_local_to_cpu = dev->link_local_to_cpu;
+}
+
static inline int ksz_get_sgmii_port(struct ksz_device *dev)
{
return dev->info->sgmii_port - 1;
diff --git a/drivers/net/dsa/microchip/lan937x_main.c b/drivers/net/dsa/microchip/lan937x_main.c
index 7971d120630d173a1bbed6fb98683cee27d8fe89..7452b8c6a73552d9ae4f410dead3b968f22124e5 100644
--- a/drivers/net/dsa/microchip/lan937x_main.c
+++ b/drivers/net/dsa/microchip/lan937x_main.c
@@ -924,6 +924,7 @@ static int lan937x_connect_tag_protocol(struct dsa_switch *ds,
tagger_data = ksz_tagger_data(ds);
tagger_data->xmit_work_fn = ksz_port_deferred_xmit;
+ ksz_tagger_set_link_local_to_cpu(ds);
return 0;
}
--
2.47.3
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH net-next 0/5] net: dsa: microchip: let the bridge decide about link-local frames
2026-11-26 8:07 [PATCH net-next 0/5] net: dsa: microchip: let the bridge decide about link-local frames Oleksij Rempel
` (4 preceding siblings ...)
2026-11-26 8:07 ` [PATCH net-next 5/5] net: dsa: microchip: ksz9477: report the trapped link-local groups Oleksij Rempel
@ 2026-11-26 10:23 ` Vladimir Oltean
2026-11-27 5:53 ` Oleksij Rempel
5 siblings, 1 reply; 13+ messages in thread
From: Vladimir Oltean @ 2026-11-26 10:23 UTC (permalink / raw)
To: Oleksij Rempel
Cc: Woojung Huh, UNGLinuxDriver, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman,
Florian Fainelli, Nikolay Aleksandrov, Ido Schimmel, netdev,
bridge, kernel
Hi Oleksij,
On Thu, Nov 26, 2026 at 09:07:47AM +0100, Oleksij Rempel wrote:
> Let the bridge decide about the link-local frames that the KSZ9477
> family and LAN937x trap to the CPU. These switches trap most link-local
> groups (01:80:C2:00:00:0X, for example STP BPDUs and LLDP), but the
> tagger marks the frames as forwarded in hardware. So the bridge never
> forwards them to the other ports of the switch, whatever group_fwd_mask
> says. An FDB or MDB entry for such a group can also make the switch
> forward these frames on its own.
>
> The tagger now leaves these frames unmarked, and the driver keeps FDB
> and MDB entries for them out of the hardware. As the bridge then sends
> some link-local frames back out through the CPU port, the switch no
> longer learns addresses there; DSA adds the addresses that the bridge
> learns on its other ports, such as Wi-Fi, as static entries instead. An
> old FDB bug hits these entries often, so one patch fixes it; without the
> series it needs a static entry added over a learned one, so that patch
> goes to net-next with the series. The series goes to net-next as it
> changes how the bridge handles link-local frames.
>
> To reproduce on a KSZ9893, with link partners on lan1 and lan2:
>
> ip link add br0 type bridge
> ip link set lan1 master br0 up; ip link set lan2 master br0 up
> ip link set br0 up
> # 0x4000: forward 01:80:C2:00:00:0E
> ip link set br0 type bridge group_fwd_mask 0x4000
> # Send frames to 01:80:C2:00:00:0E into lan1. Without the series
> # none reach lan2; with it, all do.
>
> With STP off, the bridge now also forwards BPDUs between the ports of
> the switch. IEEE 802.1Q says a bridge filters frames to the reserved
> addresses, including the BPDU address 01:80:C2:00:00:00. The Linux
> bridge forwards BPDUs when STP is off, so that other bridges can still
> detect a loop through it; see commit a598f6aebea2 ("bridge: relay
> bridge multicast pkgs if !STP"). DSA switches whose tagger leaves
> trapped or link-local frames unmarked, such as mv88e6xxx and b53,
> already behave this way.
>
> The switches driven by ksz8.c (KSZ8463, KSZ87xx, KSZ88x3, KSZ8864,
> KSZ8895, KSZ8995XA) keep their behaviour; KSZ8563 and KSZ8567 use the
> KSZ9477 code and are covered. The ksz8.c switches have one static MAC
> table. It holds the trap entries, the FDB and MDB entries and the local
> addresses of the bridge, and on the KSZ88x3 it has only 8 entries, so a
> change on the KSZ88x3 can run out of space. Of these switches I can test
> only a KSZ8873, so I left them unchanged. Their taggers still mark all
> frames as forwarded.
>
> Tested on a KSZ9893.
>
> ---
> Oleksij Rempel (5):
> net: dsa: tag_ksz: do not mark trapped link-local frames as forwarded
> net: dsa: microchip: ksz9477: do not keep the learned port in FDB entries
> net: dsa: microchip: ksz9477: do not learn addresses on the CPU port
> net: dsa: microchip: ksz9477: refuse FDB/MDB entries for trapped groups
> net: dsa: microchip: ksz9477: report the trapped link-local groups
>
> drivers/net/dsa/microchip/ksz9477.c | 81 +++++++++++++++++++++++++++++---
> drivers/net/dsa/microchip/ksz_common.h | 14 ++++++
> drivers/net/dsa/microchip/lan937x_main.c | 16 ++++---
> include/linux/dsa/ksz_common.h | 8 ++++
> net/dsa/tag_ksz.c | 42 ++++++++++++++++-
> 5 files changed, 145 insertions(+), 16 deletions(-)
> ---
> base-commit: c2621b518b38ed38e280e008aa33e6c2d302f8cc
> change-id: 20261125-ksz-stp-link-local-5c53396cc960
>
> Best regards,
> --
> Oleksij Rempel <o.rempel@pengutronix.de>
>
I didn't go into any sort of detail in these patches yet, but they
reminded me of this thread:
https://lore.kernel.org/netdev/20250127125426.3b7cdkb75o5dbcr5@skbuf/
IIRC Tim's problem there still wasn't resolved (he tried to use the
reserved multicast address tables). Does your series address his issue
too?
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH net-next 1/5] net: dsa: tag_ksz: do not mark trapped link-local frames as forwarded
2026-11-26 8:07 ` [PATCH net-next 1/5] net: dsa: tag_ksz: do not mark trapped link-local frames as forwarded Oleksij Rempel
@ 2026-11-26 14:47 ` Andrew Lunn
0 siblings, 0 replies; 13+ messages in thread
From: Andrew Lunn @ 2026-11-26 14:47 UTC (permalink / raw)
To: Oleksij Rempel
Cc: Woojung Huh, UNGLinuxDriver, Vladimir Oltean, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman,
Florian Fainelli, Nikolay Aleksandrov, Ido Schimmel, netdev,
bridge, kernel
> + /* The switch driver reports which link-local groups the switch sends
> + * to the CPU only. The switch did not forward frames to these groups,
> + * so do not mark them, and let the bridge apply its own rules
> + * (group_fwd_mask, STP state).
> + */
> + if (!ksz_link_local_trapped(skb->dev, eth_hdr(skb)->h_dest))
> + dsa_default_offload_fwd_mark(skb);
There is a bit of a common pattern in tag drivers:
if (likely(!is_link_local_ether_addr(eth_hdr(skb)->h_dest)))
dsa_default_offload_fwd_mark(skb);
Your variant is more specific, but does it need to be?
Should we consider adding a variant of dsa_default_offload_fwd_mark()
which combines this into one? And then change the tag drivers to use
it?
Andrew
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH net-next 0/5] net: dsa: microchip: let the bridge decide about link-local frames
2026-11-26 10:23 ` [PATCH net-next 0/5] net: dsa: microchip: let the bridge decide about link-local frames Vladimir Oltean
@ 2026-11-27 5:53 ` Oleksij Rempel
0 siblings, 0 replies; 13+ messages in thread
From: Oleksij Rempel @ 2026-11-27 5:53 UTC (permalink / raw)
To: Vladimir Oltean
Cc: Woojung Huh, UNGLinuxDriver, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman,
Florian Fainelli, Nikolay Aleksandrov, Ido Schimmel, netdev,
bridge, kernel
Hi Vladimir,
On Thu, Nov 26, 2026 at 12:23:55PM +0200, Vladimir Oltean wrote:
> I didn't go into any sort of detail in these patches yet, but they
> reminded me of this thread:
> https://lore.kernel.org/netdev/20250127125426.3b7cdkb75o5dbcr5@skbuf/
>
> IIRC Tim's problem there still wasn't resolved (he tried to use the
> reserved multicast address tables). Does your series address his issue
> too?
If I see it correctly, Tim had two concerns:
- the reserved multicast table assumed that the CPU is the last port,
- and 01:80:C2:00:00:0E was not forwarded.
The first one is handled by 96baf482ca1f ("net: dsa: microchip: Fix
reserved multicast address table programming")
This series addresses the second one. :0E is trapped to the CPU, the
tagger no longer sets offload_fwd_mark for it
Best Regards,
Oleksij
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH net-next 2/5] net: dsa: microchip: ksz9477: do not keep the learned port in FDB entries
2026-11-26 8:07 ` [PATCH net-next 2/5] net: dsa: microchip: ksz9477: do not keep the learned port in FDB entries Oleksij Rempel
@ 2026-11-27 8:24 ` netdev-bot+sashiko
0 siblings, 0 replies; 13+ messages in thread
From: netdev-bot+sashiko @ 2026-11-27 8:24 UTC (permalink / raw)
To: o.rempel
Cc: woojung.huh, UNGLinuxDriver, andrew, olteanv, davem, edumazet,
kuba, pabeni, horms, f.fainelli, razor, idosch, netdev, bridge,
kernel
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 1 · Medium: 0 · Low: 0
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] The fix covers only part of the bug its commit message
describes.
--
net: dsa: microchip: ksz9477: do not keep the learned port in FDB entries
This patch changes ksz9477_fdb_add() so that a static FDB entry no longer
inherits the port map of a learned ALU entry for the same address. If the
ALU entry found for the address is not already static, its port map is
cleared before the requested port is set.
> diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchip/ksz9477.c
> index 972703fe7454f..98211d9835734 100644
> --- a/drivers/net/dsa/microchip/ksz9477.c
> +++ b/drivers/net/dsa/microchip/ksz9477.c
> @@ -800,6 +800,13 @@ int ksz9477_fdb_add(struct dsa_switch *ds, int port,
> /* read ALU entry */
> ksz9477_read_table(dev, alu_table);
>
> + /* The ALU table holds learned and static entries. If the entry is
> + * not static (learned, or none found), clear its port map, so that
> + * the static entry lists only this port.
> + */
> + if (!(alu_table[0] & ALU_V_STATIC_VALID))
> + alu_table[1] &= ~ALU_V_PORT_MAP;
> +
> /* update ALU entry */
> alu_table[0] = ALU_V_STATIC_VALID;
> alu_table[1] |= BIT(port);
[Severity: High]
Can the stale static entry from the commit message still be created when
the existing ALU entry is already static?
When ALU_V_STATIC_VALID is set, the port map is kept, and the
alu_table[1] |= BIT(port) adds the new port to the old one.
For a user replace, the bridge does not tell the driver about the old
port. fdb_add_entry()->fdb_update_dst() in net/bridge/br_fdb.c only
rewrites the destination:
net/bridge/br_fdb.c:fdb_update_dst() {
...
br_fdb_dst_write(fdb, dst);
return true;
}
Only RTM_NEWNEIGH is then sent for the new port. That differs from learned
migration in br_fdb_update(), which first sends a delete for the old
port:
if (source != old_port) {
br_switchdev_fdb_notify(br, fdb, RTM_DELNEIGH);
br_fdb_dst_write(fdb, dst);
So in the replace case, port_fdb_add is the only notice the driver gets
that the address moved. Take this sequence:
bridge fdb add H dev lan1 master static -> ALU static {lan1}
bridge fdb replace H dev lan2 master static -> ALU static {lan1, lan2}
bridge fdb del H dev lan2 master static
After the replace, the bridge has H only on lan2. ksz9477_fdb_del() then
clears only the deleted port:
/* clear forwarding port */
alu_table[1] &= ~BIT(port);
That leaves a static {lan1} entry. The bridge no longer tracks it, and it
never ages out. This is the same result the commit message describes:
"The entry stays static and still points to lan1. Static entries never
age out. So the switch keeps sending frames for H to lan1, even after H
has moved."
Would it be better to always set the unicast port map to exactly BIT(port),
by clearing ALU_V_PORT_MAP unconditionally instead of only for non-static
entries? mv88e6xxx_port_db_load_purge() already does this for unicast
static entries:
if (state == MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC)
entry.portvec = BIT(port);
Multicast uses the separate static table in ksz9477_mdb_add(), so it does
not seem to go through this path.
The note below the --- line already mentions this gap:
"If bridge fdb replace moves an existing static entry to another port,
the entry still keeps the old port. This patch does not change that."
That text does not end up in git history, though. The commit carries a
Fixes: tag, so the commit log does not show that the bug is only partly
fixed. The following ksz9477 change sets ds->assisted_learning_on_cpu_port,
which creates more static entries on the CPU port that this OR-merge can
act on.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261126-ksz-stp-link-local-v1-0-39aed15f6271%40pengutronix.de
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH net-next 3/5] net: dsa: microchip: ksz9477: do not learn addresses on the CPU port
2026-11-26 8:07 ` [PATCH net-next 3/5] net: dsa: microchip: ksz9477: do not learn addresses on the CPU port Oleksij Rempel
@ 2026-11-27 8:24 ` netdev-bot+sashiko
0 siblings, 0 replies; 13+ messages in thread
From: netdev-bot+sashiko @ 2026-11-27 8:24 UTC (permalink / raw)
To: o.rempel
Cc: woojung.huh, UNGLinuxDriver, andrew, olteanv, davem, edumazet,
kuba, pabeni, horms, f.fainelli, razor, idosch, netdev, bridge,
kernel
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 0
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).
- [Medium] This patch causes an HSR offload regression on KSZ9477.
--
net: dsa: microchip: ksz9477: do not learn addresses on the CPU port
This patch turns off address learning on the CPU port of the KSZ9477
family and LAN937x. It sets ds->assisted_learning_on_cpu_port instead, so
DSA installs the addresses the bridge learns outside the switch as static
entries on the CPU port. This prepares for software forwarding of trapped
link-local frames.
> diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchip/ksz9477.c
> index 98211d9835734..8271bc742ddc5 100644
> --- a/drivers/net/dsa/microchip/ksz9477.c
> +++ b/drivers/net/dsa/microchip/ksz9477.c
[ ... ]
> @@ -1792,13 +1791,15 @@ static int ksz9477_setup(struct dsa_switch *ds)
> if (ret < 0)
> return ret;
>
> - /* Start with learning disabled on standalone user ports, and enabled
> - * on the CPU port. In lack of other finer mechanisms, learning on the
> - * CPU port will avoid flooding bridge local addresses on the network
> - * in some cases.
> + /* Ask DSA to add the addresses that the bridge learns on ports
> + * outside the switch as static entries on the CPU port. The CPU
> + * port itself does not learn: when the bridge forwards a frame in
> + * software between two ports of the switch, the switch would learn
> + * the sender on the CPU port. p->learning is never set for the CPU
> + * port, so ksz_port_stp_state_set() disables learning when DSA sets
> + * the port to forwarding.
> */
> - p = &dev->ports[dev->cpu_port];
> - p->learning = true;
> + ds->assisted_learning_on_cpu_port = true;
[Severity: Medium]
Does this cause a regression for HSR offload on KSZ9477? Unicast frames
addressed to the local HSR node now seem to be forwarded to the other ring
port as well.
Before this change, the CPU port learned the HSR MAC from frames the host
sent. That learned entry sent unicast with DA == HSR MAC to the CPU only.
Now dsa_port_enable_rt() moves the CPU port to BR_STATE_FORWARDING, and
p->learning is false, so ksz_port_stp_state_set() disables learning there:
ksz_port_stp_state_set() {
...
case BR_STATE_FORWARDING:
data |= (PORT_TX_ENABLE | PORT_RX_ENABLE);
if (!p->learning)
data |= PORT_LEARN_DISABLE;
...
}
The replacement doesn't seem to cover HSR, because HSR ports are not in a
bridge:
dsa_user_fdb_event() {
...
if (!dp->bridge)
return 0;
...
}
dsa_switch_supports_uc_filtering() needs ds->fdb_isolation, which the
microchip drivers don't set, so standalone host address filtering doesn't
add the entry either.
ksz9477_hsr_join() doesn't install a static ALU entry for the HSR MAC.
ksz_switch_macaddr_get() only programs the self-address filter register.
ksz9477_hsr_join() also makes the two ring ports and the CPU members of
each other's forwarding set:
ksz9477_hsr_join() {
...
hsr_ports |= BIT(dsa_upstream_port(ds, port));
dsa_hsr_foreach_port(hsr_dp, ds, hsr)
ksz9477_cfg_port_member(dev, hsr_dp->index, hsr_ports);
...
data |= HSR_DUPLICATE_DISCARD;
data &= ~HSR_NODE_UNICAST;
...
}
ksz9477 never programs unknown unicast control (REG_SW_LUE_UNK_UCAST_CTRL__4
is unused). Unicast to this node would then miss in the ALU and flood to
the other ring port and the CPU. It would keep going around the ring until
the sender's self-address filter drops it.
The hardware meaning of HSR_NODE_UNICAST is not documented in the tree.
If clearing that bit made the switch deliver node-addressed unicast only
to the host, this flooding would not happen. The note below the --- line
reaches the same conclusion, that the frames are flooded.
That note is dropped when the patch is applied. The commit message doesn't
mention this behavior change, and nothing in the series changes the HSR
join/leave path.
Could ksz9477_hsr_join() add a static ALU entry for hsr->dev_addr on the
CPU port, with ksz9477_hsr_leave() removing it? Another option is to keep
CPU port learning enabled while dev->hsr_ports is non-zero.
>
> if (dev->irq > 0) {
> ret = ksz_girq_setup(dev);
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261126-ksz-stp-link-local-v1-0-39aed15f6271%40pengutronix.de
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH net-next 4/5] net: dsa: microchip: ksz9477: refuse FDB/MDB entries for trapped groups
2026-11-26 8:07 ` [PATCH net-next 4/5] net: dsa: microchip: ksz9477: refuse FDB/MDB entries for trapped groups Oleksij Rempel
@ 2026-11-27 8:24 ` netdev-bot+sashiko
0 siblings, 0 replies; 13+ messages in thread
From: netdev-bot+sashiko @ 2026-11-27 8:24 UTC (permalink / raw)
To: o.rempel
Cc: woojung.huh, UNGLinuxDriver, andrew, olteanv, davem, edumazet,
kuba, pabeni, horms, f.fainelli, razor, idosch, netdev, bridge,
kernel
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] The commit message describes user-visible failures that this
patch fixes, but the patch has no Fixes: tag and does not say whether…
- [Low] The subject and body describe the change as KSZ9477-family only,
and the test results are for KSZ9893 only.
- [Low] ksz9477_enable_stp_addr() collects the trapped-group bitmap in a
local variable and only copies it to dev->link_local_to_cpu after all…
--
net: dsa: microchip: ksz9477: refuse FDB/MDB entries for trapped groups
The reserved multicast table traps some link-local groups to the CPU.
This patch makes ksz9477_fdb_add() and ksz9477_mdb_add() refuse entries
for those groups: they return -EOPNOTSUPP on user ports and 0 on CPU and
DSA ports. A new dev->link_local_to_cpu bitmap, filled in by
ksz9477_enable_stp_addr(), records which groups are trapped.
> The KSZ9477 family looks up a destination address in the address
> lookup table (learned and static FDB entries), the static address table
> (MDB entries) and the reserved multicast table. The driver traps the
> link-local groups with the reserved multicast table: it sends
> 01:80:C2:00:00:00 to :0F to the CPU only, except :01 (PAUSE frames),
> which it drops. On a KSZ9893, an FDB or MDB entry for a trapped group
> overrides that rule.
[Severity: Low]
This change also applies to LAN937x, but the message doesn't mention it.
Is that intended? And has the override been seen on LAN937x hardware?
lan937x_switch_ops in lan937x_main.c uses the same handlers:
.port_fdb_add = ksz9477_fdb_add,
.port_fdb_del = ksz9477_fdb_del,
.port_mdb_add = ksz9477_mdb_add,
.port_mdb_del = ksz9477_mdb_del,
Also, lan937x_setup() calls ksz9477_enable_stp_addr(dev), which now fills
dev->link_local_to_cpu.
So on LAN937x, FDB and MDB entries for trapped link-local groups on user
ports are now refused with -EOPNOTSUPP too. Until the later tagger patch,
LAN937x also gets the gap where frames to a group with a refused MDB entry
are not forwarded between switch ports.
Other patches in this series name LAN937x explicitly. One example is
"LAN937x uses the same code" in "net: dsa: microchip: ksz9477: do not keep
the learned port in FDB entries". Could this commit message do the same?
> A later patch makes the tagger stop marking these frames as already
> forwarded by the switch. This patch comes first, so that the switch and
> the bridge never both forward such a frame. Until then, frames to a
> group with a refused MDB entry are not forwarded between switch ports
> at all.
[Severity: Low]
The commit message describes failures that users can see. In one of them,
a Blocking port stops passing BPDUs to the CPU and the bridge moves it to
Listening. There is no Fixes: tag and nothing about stable, though. Is a
backport intended?
The earlier patch in this series, "net: dsa: microchip: ksz9477: do not
keep the learned port in FDB entries", carries a Fixes tag, so this patch
is handled differently.
The right Fixes target is not clear. The group 0 (STP) trap in
ksz9477_enable_stp_addr() goes back to 331d64f752bb. The 8-entry
reprogramming loop came from 96baf482ca1f.
Before 96baf482ca1f only entry 0 was written. The hardware default for
group 6 forwards to the last port, and on KSZ9893 the last port is the
CPU port. So the :0E trap likely existed there before that commit too.
What happens if this is backported alone, without "net: dsa: microchip:
ksz9477: report the trapped link-local groups"? Wouldn't stable kernels
get the gap described above, where frames to a group with a refused MDB
entry are not forwarded between switch ports at all?
Could the message name the commit that introduced the problem and the
series dependency, or say explicitly that no backport is intended?
> diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchip/ksz9477.c
> index 8271bc742ddc5..b972c9fab55c1 100644
> --- a/drivers/net/dsa/microchip/ksz9477.c
> +++ b/drivers/net/dsa/microchip/ksz9477.c
[ ... ]
> @@ -1621,6 +1669,14 @@ int ksz9477_enable_stp_addr(struct ksz_device *dev)
> update = ports;
> break;
> }
> +
> + /* Record the link-local addresses of group i if the switch
> + * sends it to the CPU only. Group 1 keeps its drop default and
> + * does not match.
> + */
> + if (update == BIT(dev->cpu_port))
> + link_local_to_cpu |= ksz9477_resv_mcast_link_local[i];
> +
> if (update != ports || override) {
> data &= ~dev->port_mask;
> data |= update;
> @@ -1650,6 +1706,8 @@ int ksz9477_enable_stp_addr(struct ksz_device *dev)
> }
> }
>
> + dev->link_local_to_cpu = link_local_to_cpu;
> +
[Severity: Low]
Can dev->link_local_to_cpu get out of sync with the hardware here?
The first iteration of the loop writes group 0 (01:80:C2:00:00:00, CPU
only, with override). If a later iteration fails, the function returns
before this assignment and dev->link_local_to_cpu stays 0. This early
return in the loop is one example:
ret = ksz_write32(dev, REG_SW_ALU_STAT_CTRL__4, data);
if (ret < 0)
return ret;
A ksz_read32() or ksz9477_wait_alu_sta_ready() failure returns early in
the same way.
Both callers ignore the return value:
ksz9477_setup()
ksz9477_enable_stp_addr(dev);
lan937x_setup()
ksz9477_enable_stp_addr(dev);
So setup completes while the hardware already traps :00 to the CPU.
>From then on, ksz9477_link_local_is_trapped() returns false for :00. Then
ksz9477_fdb_add() and ksz9477_mdb_add() write an entry that overrides the
STP trap. That is the bypass this patch is meant to block.
The callers ignored the return value before this patch, but the new
bitmap is what can now disagree with the hardware. Should the bitmap be
updated as each group is programmed, so that it matches what has already
been written?
> return 0;
> }
>
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261126-ksz-stp-link-local-v1-0-39aed15f6271%40pengutronix.de
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH net-next 5/5] net: dsa: microchip: ksz9477: report the trapped link-local groups
2026-11-26 8:07 ` [PATCH net-next 5/5] net: dsa: microchip: ksz9477: report the trapped link-local groups Oleksij Rempel
@ 2026-11-27 8:24 ` netdev-bot+sashiko
0 siblings, 0 replies; 13+ messages in thread
From: netdev-bot+sashiko @ 2026-11-27 8:24 UTC (permalink / raw)
To: o.rempel
Cc: woojung.huh, UNGLinuxDriver, andrew, olteanv, davem, edumazet,
kuba, pabeni, horms, f.fainelli, razor, idosch, netdev, bridge,
kernel
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] On a bridge with STP disabled, which is the default for a new
Linux bridge, this patch changes how STP BPDUs are handled.
--
net: dsa: microchip: ksz9477: report the trapped link-local groups
The KSZ9477 family and LAN937x drivers now copy dev->link_local_to_cpu
into the tagger data from their connect_tag_protocol callbacks. As a
result, the tagger stops setting offload_fwd_mark on link-local frames
that the switch traps to the CPU, and the bridge can forward those frames
in software.
> The tagger then no longer marks these frames as
> forwarded in hardware (offload_fwd_mark). The bridge applies
> group_fwd_mask and the STP state to them and can forward them to the
> other ports of the switch.
>
> Tested on a KSZ9893: with the group_fwd_mask bit for 01:80:C2:00:00:0E
> set, the bridge relayed 20 of 20 frames to that group from lan1 to lan2
> with this change, and 0 of 20 without it.
[ ... ]
> diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h
> index 7b96d110b1f64..1f96b91016fcf 100644
> --- a/drivers/net/dsa/microchip/ksz_common.h
> +++ b/drivers/net/dsa/microchip/ksz_common.h
[ ... ]
> +static inline void ksz_tagger_set_link_local_to_cpu(struct dsa_switch *ds)
> +{
> + struct ksz_device *dev = ds->priv;
> +
> + ksz_tagger_data(ds)->link_local_to_cpu = dev->link_local_to_cpu;
[Severity: Low]
This isn't a bug, but should the commit message mention what this does to
STP BPDUs on a bridge with STP disabled? That is the default for a new
Linux bridge.
ksz9477_enable_stp_addr() programs group 0 (01:80:C2:00:00:00) as
CPU-only, so BIT(0) is always set in the bitmap copied here:
drivers/net/dsa/microchip/ksz9477.c:ksz9477_enable_stp_addr() {
...
if (update == BIT(dev->cpu_port))
link_local_to_cpu |= ksz9477_resv_mcast_link_local[i];
...
}
Once the bitmap reaches the tagger, ksz_common_rcv() skips
dsa_default_offload_fwd_mark() for BPDUs:
net/dsa/tag_ksz.c:ksz_common_rcv() {
...
if (!ksz_link_local_trapped(skb->dev, eth_hdr(skb)->h_dest))
dsa_default_offload_fwd_mark(skb);
...
}
br_handle_frame() then forwards group 0 frames when STP is off:
net/bridge/br_input.c:br_handle_frame() {
...
case 0x00: /* Bridge Group Address */
/* If STP is turned off,
then must forward to keep loop detection */
if (p->br->stp_enabled == BR_NO_STP ||
fwd_mask & (1u << dest[5]))
goto forward;
...
}
Without offload_fwd_mark, nbp_switchdev_allowed_egress() no longer stops
these frames from egressing the other ports of the same switch.
So a KSZ9477/KSZ9893/LAN937x bridge with stp_state 0 now relays BPDUs
received on one switch port to every other switch port. Before this
change they were dropped between those ports.
External STP switches attached to different KSZ ports will now see each
other's BPDUs. That can change root election and cause ports to be
blocked.
The new behaviour matches the software bridge and the br_input.c comment,
so it looks intended. It is still a visible change in the default
configuration. The message only says "The bridge applies group_fwd_mask
and the STP state to them and can forward them to the other ports of the
switch", and the reported test covers only 01:80:C2:00:00:0E.
Could the message state that BPDUs are now forwarded on bridges with STP
disabled?
> +}
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261126-ksz-stp-link-local-v1-0-39aed15f6271%40pengutronix.de
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2026-11-27 8:24 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-26 8:07 [PATCH net-next 0/5] net: dsa: microchip: let the bridge decide about link-local frames Oleksij Rempel
2026-11-26 8:07 ` [PATCH net-next 1/5] net: dsa: tag_ksz: do not mark trapped link-local frames as forwarded Oleksij Rempel
2026-11-26 14:47 ` Andrew Lunn
2026-11-26 8:07 ` [PATCH net-next 2/5] net: dsa: microchip: ksz9477: do not keep the learned port in FDB entries Oleksij Rempel
2026-11-27 8:24 ` netdev-bot+sashiko
2026-11-26 8:07 ` [PATCH net-next 3/5] net: dsa: microchip: ksz9477: do not learn addresses on the CPU port Oleksij Rempel
2026-11-27 8:24 ` netdev-bot+sashiko
2026-11-26 8:07 ` [PATCH net-next 4/5] net: dsa: microchip: ksz9477: refuse FDB/MDB entries for trapped groups Oleksij Rempel
2026-11-27 8:24 ` netdev-bot+sashiko
2026-11-26 8:07 ` [PATCH net-next 5/5] net: dsa: microchip: ksz9477: report the trapped link-local groups Oleksij Rempel
2026-11-27 8:24 ` netdev-bot+sashiko
2026-11-26 10:23 ` [PATCH net-next 0/5] net: dsa: microchip: let the bridge decide about link-local frames Vladimir Oltean
2026-11-27 5:53 ` Oleksij Rempel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox