mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: joseph@telaak.dev
Cc: florian.fainelli@broadcom.com, jonas.gorski@gmail.com,
	andrew@lunn.ch, olteanv@gmail.com, davem@davemloft.net,
	edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com,
	f.fainelli@gmail.com, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v2] net: dsa: b53: mirror CPU-bound frames to port 5 when port 8 is unused
Date: Thu, 19 Nov 2026 21:30:46 +0000	[thread overview]
Message-ID: <179512384634.3136.13428964502385964682@kernel.org> (raw)
In-Reply-To: <20261116-b53-bpdu-mirror-v2-1-c39ab745730f@telaak.dev>

Thank you for your contribution! Sashiko AI review found 4 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · Low: 3

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] The commit message says the problem and the fix apply to
  "boards that leave port 8 unconnected".
- [Low] The Fixes: attribution is incomplete.
- [Low] `b53_setup_cpu_mirror()` programs global switch state that
  nothing ever restores: `B53_PORT_CTRL(8)` = `PORT_CTRL_DIS_STATE`, the…
- [Low] `b53_setup_cpu_mirror()` hard-codes the IMP state override for
  port 8 to `PORT_OVERRIDE_EN | PORT_OVERRIDE_SPEED_1000M |…

--

net: dsa: b53: mirror CPU-bound frames to port 5 when port 8 is unused

This patch applies when port 5 is the CPU port and port 8 is unused in
DT. In that case b53 uses the switch's single mirror to copy frames to
the bridge group address from user ports to port 5. It also copies all
port 8 egress to port 5, with port 8 enabled and its link forced up, and
refuses tc mirroring while this is active.

> to port 8: BPDUs, the IGMP/MLD copies b53_enable_mcast_snooping()
> enables, and most traffic of standalone ports. On boards that leave
> port 8 unconnected these are lost, so STP never sees its peers and a

[ ... ]

> Fixes: 8fab459e69ab ("net: dsa: b53: Enable Broadcom tags for 531x5/539x families")

[Severity: Low]
Is this Fixes: tag complete? The loss of "most traffic of standalone
ports" seems to come from commit 4227ea91e265 ("net: dsa: b53: prevent
standalone from trying to forward to other ports"). That commit added this
to b53_setup_port():

	if (dsa_is_user_port(ds, port))
		b53_set_eap_mode(dev, port, EAP_MODE_SIMPLIFIED);

Its commit message notes that "effectively this redirects all incoming
traffic to the CPU port". In dual-IMP mode (GC_FRM_MGMT_PORT_M, set by
b53_brcm_hdr_setup() for CPU port 5), that redirect target is port 8.

Before 4227ea91e265, standalone traffic followed the PVLAN/ARL path, which
b53_imp_vlan_setup() points at port 5.

8fab459e69ab is older, so this doesn't lose stable coverage. Would it
still help to also name 4227ea91e265, so that the standalone breakage on
these boards can be traced?

> diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c
> index b7aff5e238e85..f82139b0c501c 100644
> --- a/drivers/net/dsa/b53/b53_common.c
> +++ b/drivers/net/dsa/b53/b53_common.c

[ ... ]

> @@ -1326,6 +1330,42 @@ int b53_setup_devlink_resources(struct dsa_switch *ds)

[ ... ]

> +static void b53_setup_cpu_mirror(struct dsa_switch *ds)
> +{
> +	struct b53_device *dev = ds->priv;
> +	int cpu_port = 5;
> +
> +	dev->cpu_mirror = false;
> +	if (dev->tag_protocol == DSA_TAG_PROTO_NONE ||
> +	    dev->imp_port != B53_CPU_PORT || B53_CPU_PORT >= ds->num_ports ||
> +	    !dsa_is_cpu_port(ds, cpu_port) ||
> +	    !dsa_is_unused_port(ds, B53_CPU_PORT))
> +		return;

[Severity: Medium]
The commit message says this is for "boards that leave port 8
unconnected". Can dsa_is_unused_port() tell such a board apart from one
where port 8 is wired inside the SoC and only disabled in DT?

On Northstar (BCM5301x) and NSP (BCM58xx), port 8 is wired inside the SoC
to a GMAC. arch/arm/boot/dts/broadcom/bcm-ns.dtsi has:

	port@8 {
		reg = <8>;
		ethernet = <&gmac2>;

and gmac2 stays enabled. Boards such as bcm4708-netgear-r6250.dts and
bcm47094-luxul-xwr-3100.dts use port 5 as the CPU port and set port@8 to
status = "disabled", so they pass all of these checks.

On those boards, the code below clears RX/TX_DISABLE on port 8 and forces
its link up at 1000/full. Before this patch, b53_disable_port() left port
8 with RX/TX disabled.

Port 8 then transmits the frames the switch traps or redirects to the CPU
(BPDUs, IGMP/MLD copies and, with EAP simplified mode, all standalone
ingress). They go to an internal MAC that DSA does not own and that
bgmac may have probed as an ordinary netdev.

The early return added to b53_disable_port() keeps port 8 enabled for the
life of the switch, with no way to opt out. b53_mirror_add() now also
returns -EOPNOTSUPP on all of these boards.

Should this be limited to chips where port 8 can't be wired internally?
If not, should the commit message say that 5301x/58xx boards with port 8
disabled in DT are affected too? Because of the Fixes: tag, this may also
be picked up for stable.

> +
> +	/* Rx/Tx on, STP disabled: only trapped frames leave port 8 */
> +	b53_write8(dev, B53_CTRL_PAGE, B53_PORT_CTRL(B53_CPU_PORT),
> +		   PORT_CTRL_DIS_STATE);
> +	b53_write8(dev, B53_CTRL_PAGE, B53_PORT_OVERRIDE_CTRL,
> +		   PORT_OVERRIDE_EN | PORT_OVERRIDE_SPEED_1000M |
> +		   PORT_OVERRIDE_FULL_DUPLEX | PORT_OVERRIDE_LINK);

[Severity: Low]
Is a fixed 1000/full override valid for every chip and IMP strapping that
reaches this point? Everywhere else, the driver derives
B53_PORT_OVERRIDE_CTRL from phylink data in b53_force_link() and
b53_force_port_config().

Mirroring port 8 egress only works if port 8 actually transmits what is
queued for it. Suppose the IMP is strapped to a mode whose TX clock comes
from the missing link partner (MAC-mode MII), or the forced speed doesn't
match the strapped interface. Could port 8 then fail to drain, leaving
CPU-bound frames in its egress queue instead of being mirrored?

That depends on whether the mirror copy is taken at enqueue or at transmit
time, which I couldn't confirm from the driver. The patch covers all
dual-IMP chips, but it was only tested on one BCM53125 board.

> +
> +	b53_write48(dev, B53_MGMT_PAGE, B53_IG_MIR_MAC,
> +		    ether_addr_to_u64(eth_stp_addr));
> +	b53_write16(dev, B53_MGMT_PAGE, B53_IG_MIR_CTL,
> +		    (MIRROR_DA << MIRROR_FILTER_SHIFT) |
> +		    (dsa_user_ports(ds) & MIRROR_MASK));
> +	b53_write16(dev, B53_MGMT_PAGE, B53_EG_MIR_CTL, BIT(B53_CPU_PORT));
> +	b53_write16(dev, B53_MGMT_PAGE, B53_MIR_CAP_CTL, MIRROR_EN | cpu_port);
> +	dev->cpu_mirror = true;
> +}

[Severity: Low]
Is anything meant to undo this configuration? b53_teardown() only does
this:

static void b53_teardown(struct dsa_switch *ds)
{
	dsa_devlink_resources_unregister(ds);
}

b53_setup() doesn't roll it back if b53_enable_mcast_snooping() or
b53_setup_devlink_resources() fails afterwards. The early return above
also clears only dev->cpu_mirror and leaves the registers as they were.

On BCM531x5 parts without a reset GPIO, b53_switch_reset() issues no soft
reset; only is539x() and BCM58XX/BCM583XX get one. So this mirror and
port 8 override state can survive an unbind/rebind with a different DT,
or a kexec into another kernel.

Later, with cpu_mirror false, b53_mirror_add() only read-modify-writes
BIT(port) in the mirror control register and the capture port in
B53_MIR_CAP_CTL. Would a tc ingress mirror then inherit the MIRROR_DA
filter and the STP MAC, and copy only STP frames?

The stale BIT(8) in B53_EG_MIR_CTL would also copy all port 8 egress to
the user's capture port. And since B53_EG_MIR_CTL never becomes empty,
can b53_mirror_del() ever clear MIRROR_EN?

Separately, dev->cpu_mirror is set to true without checking any of the
b53_write*() return values. A failed bus write would leave the mirror
partly programmed, while tc mirroring is refused and port 8 stays enabled.
The rest of the driver also ignores b53_write*() errors, though.

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261116-b53-bpdu-mirror-v2-1-c39ab745730f%40telaak.dev

  reply	other threads:[~2026-11-19 21:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17  0:16 Joseph Telaak
2026-11-19 21:30 ` netdev-bot+sashiko [this message]
2026-11-19 21:37   ` Joseph Telaak

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=179512384634.3136.13428964502385964682@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=f.fainelli@gmail.com \
    --cc=florian.fainelli@broadcom.com \
    --cc=jonas.gorski@gmail.com \
    --cc=joseph@telaak.dev \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.com \
    --cc=pabeni@redhat.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®