Netdev List
 help / color / mirror / Atom feed
* [PATCH net-next V5] net: dsa: b53: prefer CPU port 8 when available
@ 2026-12-03  7:46 Rafał Miłecki
  2026-12-03  9:03 ` Jonas Gorski
  2026-12-04  7:47 ` netdev-bot+sashiko
  0 siblings, 2 replies; 3+ messages in thread
From: Rafał Miłecki @ 2026-12-03  7:46 UTC (permalink / raw)
  To: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Andrew Lunn, Vladimir Oltean, Florian Fainelli, Jonas Gorski
  Cc: netdev, Rosen Penev, Rafał Miłecki

From: Rafał Miłecki <rafal@milecki.pl>

Port 8 allows using all switch features as in opposite to ports 5 and 7.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
---
V5: Prefer port 8 for all devices except BCM5325/5365 (not just Northstar)
V4: Add check for NULL pointer
 
 drivers/net/dsa/b53/b53_common.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c
index ee2d27732c0c..da78185fec11 100644
--- a/drivers/net/dsa/b53/b53_common.c
+++ b/drivers/net/dsa/b53/b53_common.c
@@ -758,6 +758,34 @@ void b53_disable_port(struct dsa_switch *ds, int port)
 }
 EXPORT_SYMBOL(b53_disable_port);
 
+static struct dsa_port *b53_preferred_default_local_cpu_port(struct dsa_switch *ds)
+{
+	struct b53_device *dev = ds->priv;
+	struct dsa_port *cpu_dp;
+
+	/* BCM5325/5365 only have CPU port 5 (port 8 is an alias) */
+	if (is5325(dev) || is5365(dev))
+		return NULL;
+
+	/*
+	 * Most devices have 3 CPU ports: 5 (IMP1), 7, 8 (IMP0). They are
+	 * connected to separated Ethernet controllers. This design allows e.g.
+	 * dual IMP setups where WAN traffic goes to port 5 and LAN traffic goes
+	 * to port 8.
+	 *
+	 * Port 8 (IMP0) is the fully featured CPU port. Ports 5 and 7 support
+	 * Broadcom header but don't support features that relay on trapping to
+	 * CPU (e.g. EAP, STP).
+	 *
+	 * Prefer CPU port 8 if available.
+	 */
+	cpu_dp = dsa_to_port(ds, B53_CPU_PORT);
+	if (cpu_dp && dsa_port_is_cpu(cpu_dp))
+		return cpu_dp;
+
+	return NULL;
+}
+
 void b53_brcm_hdr_setup(struct dsa_switch *ds, int port)
 {
 	struct b53_device *dev = ds->priv;
@@ -2903,6 +2931,7 @@ static const struct dsa_switch_ops b53_switch_ops = {
 	.port_setup		= b53_setup_port,
 	.port_enable		= b53_enable_port,
 	.port_disable		= b53_disable_port,
+	.preferred_default_local_cpu_port = b53_preferred_default_local_cpu_port,
 	.support_eee		= b53_support_eee,
 	.set_mac_eee		= b53_set_mac_eee,
 	.set_ageing_time	= b53_set_ageing_time,
-- 
2.51.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next V5] net: dsa: b53: prefer CPU port 8 when available
  2026-12-03  7:46 [PATCH net-next V5] net: dsa: b53: prefer CPU port 8 when available Rafał Miłecki
@ 2026-12-03  9:03 ` Jonas Gorski
  2026-12-04  7:47 ` netdev-bot+sashiko
  1 sibling, 0 replies; 3+ messages in thread
From: Jonas Gorski @ 2026-12-03  9:03 UTC (permalink / raw)
  To: Rafał Miłecki
  Cc: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Andrew Lunn, Vladimir Oltean, Florian Fainelli, netdev,
	Rosen Penev, Rafał Miłecki

On Thu, Dec 3, 2026 at 8:46 AM Rafał Miłecki <zajec5@gmail.com> wrote:
>
> From: Rafał Miłecki <rafal@milecki.pl>
>
> Port 8 allows using all switch features as in opposite to ports 5 and 7.
>
> Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
> ---
> V5: Prefer port 8 for all devices except BCM5325/5365 (not just Northstar)
> V4: Add check for NULL pointer
>
>  drivers/net/dsa/b53/b53_common.c | 29 +++++++++++++++++++++++++++++
>  1 file changed, 29 insertions(+)
>
> diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c
> index ee2d27732c0c..da78185fec11 100644
> --- a/drivers/net/dsa/b53/b53_common.c
> +++ b/drivers/net/dsa/b53/b53_common.c
> @@ -758,6 +758,34 @@ void b53_disable_port(struct dsa_switch *ds, int port)
>  }
>  EXPORT_SYMBOL(b53_disable_port);
>
> +static struct dsa_port *b53_preferred_default_local_cpu_port(struct dsa_switch *ds)
> +{
> +       struct b53_device *dev = ds->priv;
> +       struct dsa_port *cpu_dp;
> +
> +       /* BCM5325/5365 only have CPU port 5 (port 8 is an alias) */
> +       if (is5325(dev) || is5365(dev))
> +               return NULL;
> +
> +       /*
> +        * Most devices have 3 CPU ports: 5 (IMP1), 7, 8 (IMP0). They are

This comment only makes sense for embedded switches in NSP and
similar; external switch chips have only two CPU ports (IMP0 and
IMP1).

> +        * connected to separated Ethernet controllers. This design allows e.g.
> +        * dual IMP setups where WAN traffic goes to port 5 and LAN traffic goes
> +        * to port 8.
> +        *
> +        * Port 8 (IMP0) is the fully featured CPU port. Ports 5 and 7 support
> +        * Broadcom header but don't support features that relay on trapping to

relay -> rely

> +        * CPU (e.g. EAP, STP).
> +        *
> +        * Prefer CPU port 8 if available.
> +        */
> +       cpu_dp = dsa_to_port(ds, B53_CPU_PORT);
> +       if (cpu_dp && dsa_port_is_cpu(cpu_dp))
> +               return cpu_dp;
> +
> +       return NULL;

Is this enough to make sure that everything works as expected even if
both CPU ports (5 and 8) are defined and we enable dual IMP mode? I'm
thinking about the WAN_PORT_SEL register, where the bootloader may
have configured one as wan, which AFAIU would send its (non-trapped)
traffic to IMP1 as well as isolate it from the other ports, so I
wonder what happens if you bridge it.

> +}
> +
>  void b53_brcm_hdr_setup(struct dsa_switch *ds, int port)
>  {
>         struct b53_device *dev = ds->priv;
> @@ -2903,6 +2931,7 @@ static const struct dsa_switch_ops b53_switch_ops = {
>         .port_setup             = b53_setup_port,
>         .port_enable            = b53_enable_port,
>         .port_disable           = b53_disable_port,
> +       .preferred_default_local_cpu_port = b53_preferred_default_local_cpu_port,

More a random thought than a request for change, I wonder if we also
should explicitly initialize .port_change_conduit to NULL along with a
comment that secondary CPU ports aren't supported, so it's obvious
this wasn't just forgotten.

I first considered a stub that just returns -EOPNOTSUPP, but that
would make dsa do a lot of work before calling .port_change_conduit
(and then undo it again) instead of failing directly.

Best regards,
Jonas

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next V5] net: dsa: b53: prefer CPU port 8 when available
  2026-12-03  7:46 [PATCH net-next V5] net: dsa: b53: prefer CPU port 8 when available Rafał Miłecki
  2026-12-03  9:03 ` Jonas Gorski
@ 2026-12-04  7:47 ` netdev-bot+sashiko
  1 sibling, 0 replies; 3+ messages in thread
From: netdev-bot+sashiko @ 2026-12-04  7:47 UTC (permalink / raw)
  To: zajec5
  Cc: davem, edumazet, kuba, pabeni, andrew, olteanv, florian.fainelli,
	jonas.gorski, netdev, rosenp, rafal

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

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

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 doesn't mention that existing upstream
  boards will move to a different conduit.
- [Low] The comment in b53_preferred_default_local_cpu_port() was written
  for Northstar but the code covers far more chips.

--

net: dsa: b53: prefer CPU port 8 when available

This adds a preferred_default_local_cpu_port callback to the b53 driver.
On every chip except BCM5325/5365, it returns port 8 when that port is
declared as a CPU port. DSA then uses port 8 as the default CPU port for
user ports instead of the first CPU port in the list.

> diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c
> index ee2d27732c0c8..da78185fec11d 100644
> --- a/drivers/net/dsa/b53/b53_common.c
> +++ b/drivers/net/dsa/b53/b53_common.c
> @@ -758,6 +758,34 @@ void b53_disable_port(struct dsa_switch *ds, int port)
>  }
>  EXPORT_SYMBOL(b53_disable_port);
>  
> +static struct dsa_port *b53_preferred_default_local_cpu_port(struct dsa_switch *ds)
> +{
> +	struct b53_device *dev = ds->priv;
> +	struct dsa_port *cpu_dp;
> +
> +	/* BCM5325/5365 only have CPU port 5 (port 8 is an alias) */
> +	if (is5325(dev) || is5365(dev))
> +		return NULL;
> +
> +	/*
> +	 * Most devices have 3 CPU ports: 5 (IMP1), 7, 8 (IMP0). They are
> +	 * connected to separated Ethernet controllers. This design allows e.g.
> +	 * dual IMP setups where WAN traffic goes to port 5 and LAN traffic goes
> +	 * to port 8.
> +	 *
> +	 * Port 8 (IMP0) is the fully featured CPU port. Ports 5 and 7 support
> +	 * Broadcom header but don't support features that relay on trapping to
> +	 * CPU (e.g. EAP, STP).

[Severity: Low]
Does this comment hold for all the chips the callback now covers? Since
V5 it applies to every chip except BCM5325/5365. However, several entries
in b53_switch_chips[] have no port 5 or port 7, for example:

	.chip_id = BCM53115_DEVICE_ID,
	.dev_name = "BCM53115",
	.vlans = 4096,
	.enabled_ports = 0x11f,

BCM5389/5395/5397/53101/53115 use enabled_ports = 0x11f, and BCM583xx
uses 0x103. BCM53134 (0x12f) and BCM5398 (0x17f) have no port 7. Only
the Northstar/4908/58xx-class chips seem to match "Most devices have 3
CPU ports".

The comment says ports 5 and 7 can't trap to the CPU. Has that been
checked for the non-Northstar families now included, such as the
BCM53125?

There are also a few typos. In the comment, "relay" should be "rely" and
"separated" should be "separate". In the commit message, "as in opposite
to" probably should be "as opposed to".

> +	 *
> +	 * Prefer CPU port 8 if available.
> +	 */
> +	cpu_dp = dsa_to_port(ds, B53_CPU_PORT);
> +	if (cpu_dp && dsa_port_is_cpu(cpu_dp))
> +		return cpu_dp;

[Severity: Medium]
Will existing boards switch to a different conduit after a kernel
upgrade? In dsa_tree_setup_cpu_ports(), every CPU port other than the
preferred one is skipped:

net/dsa/dsa.c:dsa_tree_setup_cpu_ports() {
    ...
		preferred_cpu_dp = dsa_switch_preferred_default_local_cpu_port(cpu_dp->ds);
		if (preferred_cpu_dp && preferred_cpu_dp != cpu_dp)
			continue;
    ...
}

Before this patch, user ports took the first CPU port in dst->ports
order, which is port 5.

Two upstream boards declare port 8 together with port 5 and/or port 7.

bcm47094-asus-rt-ac3100.dtsi marks ports 5, 7 and 8 as "cpu". In
bcm-ns.dtsi these map to gmac0, gmac1 and gmac2, so the default conduit
moves from gmac0 to gmac2.

bcm47189-tenda-ac9.dts uses the BCM53125 switch from bcm53573.dtsi:

	port@5 {
		reg = <5>;
		ethernet = <&gmac1>;
	...
	port@8 {
		reg = <8>;
		ethernet = <&gmac0>;
	};

Here the conduit moves from gmac1 to gmac0. This board is affected only
because V5 extended the callback to all chips except BCM5325/5365.

Anything tied to the old conduit, such as MTU or offload settings, VLANs
on the conduit, network scripts or monitoring, could change without
notice.

Could the commit message say that existing multi-CPU-port setups get a
new default conduit? Could it also explain why non-Northstar chips like
the BCM53125 are included?

> +
> +	return NULL;
> +}

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261203074627.15461-1-zajec5%40gmail.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-12-04  7:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-03  7:46 [PATCH net-next V5] net: dsa: b53: prefer CPU port 8 when available Rafał Miłecki
2026-12-03  9:03 ` Jonas Gorski
2026-12-04  7:47 ` 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