Re: [PATCH net-next 3/5] net: dsa: microchip: ksz9477: do not learn addresses on the CPU port

From
netdev-bot+sashiko@kernel.org
Date
2026-11-27 08:24:35
Also in
bridge
Reply to
Oleksij Rempel, 2026-11-26
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.
quoted hunk ↗ jump to hunk
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
[ ... ]
quoted hunk ↗ jump to hunk
@@ -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
Thread (14 messages) 14 messages, 4 authors, last reply 5d ago
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help