* [PATCH net-next v3] net: dsa: b53: mirror CPU-bound frames to port 5 when port 8 is unused
@ 2026-12-01 0:13 Joseph Telaak
2026-12-02 22:51 ` Florian Fainelli
2026-12-03 12:14 ` netdev-bot+sashiko
0 siblings, 2 replies; 3+ messages in thread
From: Joseph Telaak @ 2026-12-01 0:13 UTC (permalink / raw)
To: Florian Fainelli, Jonas Gorski, Andrew Lunn, Vladimir Oltean,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: Florian Fainelli, netdev, linux-kernel, Joseph Telaak
With port 5 as the CPU port and Broadcom tags, b53_brcm_hdr_setup() puts
the switch in dual-IMP mode, in which frames for the CPU from the user
ports still go to port 8: BPDUs, the IGMP/MLD copies
b53_enable_mcast_snooping() enables, and most traffic of standalone
ports. On an external switch whose port 8 is not connected these are
lost, so STP never sees its peers and a loop between two user ports
takes the host off the network.
Mirror them to port 5: everything that leaves port 8, and frames to the
bridge group address as they enter a user port, which the port 8 mirror
does not deliver from a bridged port. Port 8 is enabled with its link
forced up, in the disabled STP state and without flood receive, so that
only frames for the CPU leave it; this relies on port 8 transmitting
with nothing attached, as it does on the test board. The switch has one
mirror, so tc mirror offload is refused. Frames to 01:80:c2:00:00:02, 03
and 0d still do not reach the CPU from a bridged port. The mirror is set
up only on the 531x5 switches: in a switch inside a SoC, port 8 is wired
to a SoC MAC, and the external 539x, which has the same mode, is
untested.
Observed on a BCM53125 board in real use, with both user ports cabled
into the same LAN. Tested there with a host sending test frames into a
user port: bridged, BPDUs, broadcast and flooded multicast reached the
CPU once each and forwarding kept working; standalone, all but EAPOL to
01:80:c2:00:00:03 did, once each. The IGMP/MLD copies were not tested,
as the test kernel lacks b53_enable_mcast_snooping(). No selftests were
run.
Fixes: 8fab459e69ab ("net: dsa: b53: Enable Broadcom tags for 531x5/539x families")
Fixes: 4227ea91e265 ("net: dsa: b53: prevent standalone from trying to forward to other ports")
Signed-off-by: Joseph Telaak <joseph@telaak.dev>
---
Tested on a BCM53125 with this patch and Florian's mirror fixes on a
7.3-based kernel, which only lacks b53_enable_mcast_snooping(). Still
net-next despite Fixes:, as it enables port 8 and takes the switch's
only mirror, so tc mirror offload stops working on these boards; I can
resend to net if preferred.
---
Changes in v3:
- Only on 531x5: on 5301x and 58xx, port 8 is wired to a SoC MAC even
when disabled in DT (Sashiko); 539x, untested, is left out
- Add Fixes: 4227ea91e265, where the standalone traffic loss comes from
(Sashiko)
- Rebased onto net-next with Florian's mirror fixes: the setup checks
every register write and fails b53_setup() on error, and selects the
destination before enabling the sources, as b53_mirror_add() does
- Retested on the BCM53125 board on top of those fixes: frames to the
bridge group address reach the CPU once each, bridged and standalone,
and standalone all test frames but EAPOL do; tc mirroring is refused
- Link to v2: https://patch.msgid.link/20261116-b53-bpdu-mirror-v2-1-c39ab745730f@telaak.dev
Changes in v2:
- Also mirror what the switch sends to port 8 to port 5 (Jonas's egress
mirror), with port 8 enabled, its link forced and in the disabled STP
state, on all dual-IMP chips
- tc mirroring refused with -EOPNOTSUPP (not run on hardware: no clsact
in the test image)
- Check that port 8 exists and is unused; add Fixes:
- A CFP redirect to port 8, where the chip has a CFP, is left for a
follow-up
- Link to v1: https://patch.msgid.link/20261111-b53-bpdu-mirror-v1-1-f9f32e9d25db@telaak.dev
---
drivers/net/dsa/b53/b53_common.c | 73 ++++++++++++++++++++++++++++++++++++++++
drivers/net/dsa/b53/b53_priv.h | 1 +
2 files changed, 74 insertions(+)
diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c
index ee2d27732c0c..2b51036d5675 100644
--- a/drivers/net/dsa/b53/b53_common.c
+++ b/drivers/net/dsa/b53/b53_common.c
@@ -745,6 +745,10 @@ void b53_disable_port(struct dsa_switch *ds, int port)
struct b53_device *dev = ds->priv;
u8 reg;
+ /* Port 8 carries frames for the CPU to the mirror */
+ if (port == B53_CPU_PORT && dev->cpu_mirror)
+ return;
+
/* Disable Tx/Rx for the port */
b53_read8(dev, B53_CTRL_PAGE, B53_PORT_CTRL(port), ®);
reg |= PORT_CTRL_RX_DISABLE | PORT_CTRL_TX_DISABLE;
@@ -1326,6 +1330,65 @@ int b53_setup_devlink_resources(struct dsa_switch *ds)
}
EXPORT_SYMBOL(b53_setup_devlink_resources);
+/* With port 5 as the CPU port and port 8 unused, the switch runs in dual-IMP
+ * mode and still traps frames for the CPU from the user ports to port 8.
+ * Mirror them to port 5: frames to the bridge group address as they enter a
+ * user port, everything else as it leaves port 8, which needs Rx/Tx enabled
+ * and its link forced up for that, so b53_disable_port() leaves it alone.
+ * This takes the switch's only mirror.
+ */
+static int b53_setup_cpu_mirror(struct dsa_switch *ds)
+{
+ struct b53_device *dev = ds->priv;
+ int ret;
+
+ dev->cpu_mirror = false;
+ /* 531x5 only: SoC switches wire port 8 to a MAC, 539x is untested */
+ if (!is531x5(dev) || dev->tag_protocol == DSA_TAG_PROTO_NONE ||
+ ds->num_ports <= B53_CPU_PORT ||
+ !dsa_is_cpu_port(ds, B53_CPU_PORT_25) ||
+ !dsa_is_unused_port(ds, B53_CPU_PORT))
+ return 0;
+
+ /* Rx/Tx on, STP disabled, no flood Rx: only trapped frames leave it */
+ ret = b53_write8(dev, B53_CTRL_PAGE, B53_PORT_CTRL(B53_CPU_PORT),
+ PORT_CTRL_DIS_STATE);
+ if (ret)
+ return ret;
+
+ ret = b53_write8(dev, B53_CTRL_PAGE, B53_PORT_OVERRIDE_CTRL,
+ PORT_OVERRIDE_EN | PORT_OVERRIDE_SPEED_1000M |
+ PORT_OVERRIDE_FULL_DUPLEX | PORT_OVERRIDE_LINK);
+ if (ret)
+ return ret;
+
+ /* Select the destination before enabling the sources */
+ ret = b53_write16(dev, B53_MGMT_PAGE, B53_MIR_CAP_CTL,
+ MIRROR_EN | B53_CPU_PORT_25);
+ if (ret)
+ return ret;
+
+ ret = b53_write48(dev, B53_MGMT_PAGE, B53_IG_MIR_MAC,
+ ether_addr_to_u64(eth_stp_addr));
+ if (ret)
+ return ret;
+
+ ret = b53_write16(dev, B53_MGMT_PAGE, B53_IG_MIR_CTL,
+ (MIRROR_DA << MIRROR_FILTER_SHIFT) |
+ (dsa_user_ports(ds) & MIRROR_MASK));
+ if (ret)
+ return ret;
+
+ ret = b53_write16(dev, B53_MGMT_PAGE, B53_EG_MIR_CTL,
+ BIT(B53_CPU_PORT));
+ if (ret)
+ return ret;
+
+ dev->cpu_mirror = true;
+
+ return 0;
+}
+
static int b53_setup(struct dsa_switch *ds)
{
struct b53_device *dev = ds->priv;
@@ -1391,6 +1454,10 @@ static int b53_setup(struct dsa_switch *ds)
b53_disable_port(ds, port);
}
+ ret = b53_setup_cpu_mirror(ds);
+ if (ret)
+ return ret;
+
ret = b53_enable_mcast_snooping(dev);
if (ret)
return ret;
@@ -2688,6 +2755,12 @@ int b53_mirror_add(struct dsa_switch *ds, int port,
u16 cap_port = b53_mirror_capture_port(dev, mirror->to_local_port);
int ret;
+ if (dev->cpu_mirror) {
+ NL_SET_ERR_MSG_MOD(extack,
+ "The mirror carries CPU traffic to port 5");
+ return -EOPNOTSUPP;
+ }
+
loc = ingress ? B53_IG_MIR_CTL : B53_EG_MIR_CTL;
other_loc = ingress ? B53_EG_MIR_CTL : B53_IG_MIR_CTL;
diff --git a/drivers/net/dsa/b53/b53_priv.h b/drivers/net/dsa/b53/b53_priv.h
index df00a5ae46c9..82128f52b063 100644
--- a/drivers/net/dsa/b53/b53_priv.h
+++ b/drivers/net/dsa/b53/b53_priv.h
@@ -173,6 +173,7 @@ struct b53_device {
/* run time configuration */
bool enable_jumbo;
unsigned int mirror_port;
+ bool cpu_mirror;
unsigned int num_vlans;
struct b53_vlan *vlans;
---
base-commit: d35a725a7c96504f7deece4dfaa83bee6a98fe0e
change-id: 20261109-b53-bpdu-mirror-d3f66c7a7fd2
Best regards,
--
Joseph Telaak <joseph@telaak.dev>
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH net-next v3] net: dsa: b53: mirror CPU-bound frames to port 5 when port 8 is unused
2026-12-01 0:13 [PATCH net-next v3] net: dsa: b53: mirror CPU-bound frames to port 5 when port 8 is unused Joseph Telaak
@ 2026-12-02 22:51 ` Florian Fainelli
2026-12-03 12:14 ` netdev-bot+sashiko
1 sibling, 0 replies; 3+ messages in thread
From: Florian Fainelli @ 2026-12-02 22:51 UTC (permalink / raw)
To: Joseph Telaak, Jonas Gorski, Andrew Lunn, Vladimir Oltean,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: Florian Fainelli, netdev, linux-kernel
On 11/30/26 16:13, Joseph Telaak wrote:
> With port 5 as the CPU port and Broadcom tags, b53_brcm_hdr_setup() puts
> the switch in dual-IMP mode, in which frames for the CPU from the user
> ports still go to port 8: BPDUs, the IGMP/MLD copies
> b53_enable_mcast_snooping() enables, and most traffic of standalone
> ports. On an external switch whose port 8 is not connected these are
> lost, so STP never sees its peers and a loop between two user ports
> takes the host off the network.
>
> Mirror them to port 5: everything that leaves port 8, and frames to the
> bridge group address as they enter a user port, which the port 8 mirror
> does not deliver from a bridged port. Port 8 is enabled with its link
> forced up, in the disabled STP state and without flood receive, so that
> only frames for the CPU leave it; this relies on port 8 transmitting
> with nothing attached, as it does on the test board. The switch has one
> mirror, so tc mirror offload is refused. Frames to 01:80:c2:00:00:02, 03
> and 0d still do not reach the CPU from a bridged port. The mirror is set
> up only on the 531x5 switches: in a switch inside a SoC, port 8 is wired
> to a SoC MAC, and the external 539x, which has the same mode, is
> untested.
>
> Observed on a BCM53125 board in real use, with both user ports cabled
> into the same LAN. Tested there with a host sending test frames into a
> user port: bridged, BPDUs, broadcast and flooded multicast reached the
> CPU once each and forwarding kept working; standalone, all but EAPOL to
> 01:80:c2:00:00:03 did, once each. The IGMP/MLD copies were not tested,
> as the test kernel lacks b53_enable_mcast_snooping(). No selftests were
> run.
>
> Fixes: 8fab459e69ab ("net: dsa: b53: Enable Broadcom tags for 531x5/539x families")
> Fixes: 4227ea91e265 ("net: dsa: b53: prevent standalone from trying to forward to other ports")
> Signed-off-by: Joseph Telaak <joseph@telaak.dev>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Thanks Joseph!
--
Florian
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH net-next v3] net: dsa: b53: mirror CPU-bound frames to port 5 when port 8 is unused
2026-12-01 0:13 [PATCH net-next v3] net: dsa: b53: mirror CPU-bound frames to port 5 when port 8 is unused Joseph Telaak
2026-12-02 22:51 ` Florian Fainelli
@ 2026-12-03 12:14 ` netdev-bot+sashiko
1 sibling, 0 replies; 3+ messages in thread
From: netdev-bot+sashiko @ 2026-12-03 12:14 UTC (permalink / raw)
To: joseph
Cc: florian.fainelli, jonas.gorski, andrew, olteanv, davem, edumazet,
kuba, pabeni, f.fainelli, netdev, linux-kernel
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 2 · 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] b53_setup_cpu_mirror() changes the hardware on every 531x5
part (BCM53101/53115/53125/53128/53134) whenever the CPU port is 5,…
- [Medium] The egress mirror only needs port 8 to transmit, but
b53_setup_cpu_mirror() writes PORT_CTRL(8) = PORT_CTRL_DIS_STATE,…
--
net: dsa: b53: mirror CPU-bound frames to port 5 when port 8 is unused
This sets up a CPU mirror on 531x5 switches when port 5 is the CPU port,
Broadcom tags are enabled and port 8 is unused in DT. Port 8 is enabled
with a forced link and its egress is mirrored to port 5. Frames to the
bridge group address entering user ports are also mirrored to port 5, and
tc mirror offload is refused while this is active.
> diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c
> index ee2d27732c0c8..2b51036d5675f 100644
> --- a/drivers/net/dsa/b53/b53_common.c
> +++ b/drivers/net/dsa/b53/b53_common.c
> @@ -745,6 +745,10 @@ void b53_disable_port(struct dsa_switch *ds, int port)
> struct b53_device *dev = ds->priv;
> u8 reg;
>
> + /* Port 8 carries frames for the CPU to the mirror */
> + if (port == B53_CPU_PORT && dev->cpu_mirror)
> + return;
> +
> /* Disable Tx/Rx for the port */
> b53_read8(dev, B53_CTRL_PAGE, B53_PORT_CTRL(port), ®);
> reg |= PORT_CTRL_RX_DISABLE | PORT_CTRL_TX_DISABLE;
[ ... ]
> @@ -1326,6 +1330,65 @@ int b53_setup_devlink_resources(struct dsa_switch *ds)
[ ... ]
> +static int b53_setup_cpu_mirror(struct dsa_switch *ds)
> +{
> + struct b53_device *dev = ds->priv;
> + int ret;
> +
> + dev->cpu_mirror = false;
> + /* 531x5 only: SoC switches wire port 8 to a MAC, 539x is untested */
> + if (!is531x5(dev) || dev->tag_protocol == DSA_TAG_PROTO_NONE ||
> + ds->num_ports <= B53_CPU_PORT ||
> + !dsa_is_cpu_port(ds, B53_CPU_PORT_25) ||
> + !dsa_is_unused_port(ds, B53_CPU_PORT))
> + return 0;
[Severity: Medium]
This check covers every 531x5 part (BCM53101, 53115, 53125, 53128,
53134) whenever port 5 is the CPU port, tags are on and port 8 is not in
DT. Does "unused in DT" reliably mean that port 8 is physically
unconnected and can transmit with a forced link?
The commit message says this "relies on port 8 transmitting with nothing
attached, as it does on the test board", and that board is a single
BCM53125.
Further down, the link is forced to 1000M full duplex:
ret = b53_write8(dev, B53_CTRL_PAGE, B53_PORT_OVERRIDE_CTRL,
PORT_OVERRIDE_EN | PORT_OVERRIDE_SPEED_1000M |
PORT_OVERRIDE_FULL_DUPLEX | PORT_OVERRIDE_LINK);
Nothing here checks or programs the IMP interface mode or the
B53_RGMII_CTRL_IMP clocking. The only code that programs them is
b53_adjust_531x5_rgmii(), and phylink only calls it for a port that is in
use. On an unused port 8 they keep their strap or reset values.
Take a board where port 8 cannot transmit in that configuration, for
example an MII/RvMII-strapped IMP or one with no TX clock. Would any
mirror copy reach port 5 there, or would the trapped frames still be
lost?
On such a board, b53_mirror_add() still refuses every tc matchall mirror
with -EOPNOTSUPP. Hardware mirroring would be gone and nothing gained.
Now take a board where port 8 is wired to a MAC that the DT does not
describe. Would trapped frames now go out to that MAC?
Before this patch, b53_setup() disabled port 8 through
b53_disable_port(). Now b53_disable_port() returns early for port 8
whenever cpu_mirror is set.
Would an explicit opt-in or opt-out be better than turning this on for
the whole family?
> +
> + /* Rx/Tx on, STP disabled, no flood Rx: only trapped frames leave it */
> + ret = b53_write8(dev, B53_CTRL_PAGE, B53_PORT_CTRL(B53_CPU_PORT),
> + PORT_CTRL_DIS_STATE);
[Severity: Medium]
The egress mirror only needs port 8 to transmit. This write also clears
PORT_CTRL_RX_DISABLE, and the link is forced up just after it. Does that
leave port 8 receiving as well?
Port 8's own PVLAN mask is never narrowed. b53_imp_vlan_setup() only ORs
BIT(cpu_port) into each port's mask:
b53_for_each_port(dev, i) {
b53_read16(dev, B53_PVLAN_PAGE, B53_PVLAN_PORT_MASK(i), &pvlan);
pvlan |= BIT(cpu_port);
b53_write16(dev, B53_PVLAN_PAGE, B53_PVLAN_PORT_MASK(i), pvlan);
}
As a result, port 8 keeps its reset default mask.
Port 8 is also in enabled_ports on 531x5: 0x1ff on 53125/53128 and 0x11f
on 53101/53115. So b53_setup() adds it to the default VLAN as an
untagged member:
b53_for_each_port(dev, port) {
vl->members |= BIT(port);
if (!b53_vlan_port_needs_forced_tagged(ds, port))
vl->untag |= BIT(port);
}
Suppose a device the DT does not describe is attached to port 8, and the
disabled STP state does not drop ingress on this port. Could frames from
that device be switched to the user ports? That would bypass standalone
isolation, where user port masks are only {self, CPU}.
That device would also receive copies of all CPU-trapped traffic from the
user ports.
Before this patch, b53_disable_port() set both RX and TX disable on port
8. Would it be enough for the egress mirror to keep PORT_CTRL_RX_DISABLE
set here along with PORT_CTRL_DIS_STATE?
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261130-b53-bpdu-mirror-v3-1-3d82c0e0571f%40telaak.dev
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-12-03 12:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-01 0:13 [PATCH net-next v3] net: dsa: b53: mirror CPU-bound frames to port 5 when port 8 is unused Joseph Telaak
2026-12-02 22:51 ` Florian Fainelli
2026-12-03 12:14 ` netdev-bot+sashiko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox