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?
quoted hunk ↗ jump to hunk
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
[ ... ]
quoted hunk ↗ jump to hunk
@@ -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