net: dsa: b53: deal with Northstar devices using CPU port 5 or 7
Subsystems (6)
Rafał Miłecki
maintainerPATCH v3 1/4 net: dsa: b53: deal with Northstar devices using CPU port 5 or 7
From: Rafał Miłecki <[email protected]>
Northstar devices have 3 CPU ports. Ports 5 and 7 may be used but have their limitations. Warn user when CPU port 8 isn't used and add EAP setup workaround to avoid non-functional standalone ports.
---
This fixes a regression so it's a net.git material
V2: Print warning on switch setup instead of on actual EAP mode change
V3: Proper subject prefix & shorter comments (long one comes with 2/2)
drivers/net/dsa/b53/b53_common.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/net/dsa/b53/b53_common.c +12 -0
@@ -332,6 +332,14 @@ static void b53_set_eap_mode(struct b53_device *dev, int port, int mode) {u64 eap_conf; +/* +* On Northstar setting EAP_MODE_SIMPLIFIED with CPU port 5/7 breaks +* standalone ports, see: +* https://lore.kernel.org/netdev/[email protected]/ +*/ +if (is5301x (dev) && !dsa_is_cpu_port (dev->ds,B53_CPU_PORT )) +return ; +if (is5325 (dev) ||is5365 (dev) || dev->chip_id ==BCM5389_DEVICE_ID )return ;
@@ -1281,6 +1289,10 @@ static int b53_setup(struct dsa_switch *ds)u16 pvid;int ret; +/* Discourage users from using port 5 or 7 due to limited features */ +if (is5301x (dev) && !dsa_is_cpu_port (dev->ds,B53_CPU_PORT )) +dev_warn (dev->dev,"switch to CPU port 8 to use all switch features\n" ); +/* Request bridge PVID untagged when DSA_TAG_PROTO_NONE is set * which forces the CPU port to be tagged in all VLANs. */
Signature · 1 line
2.51.0
Rafał Miłecki
maintainerPATCH v3 2/4 net: dsa: b53: prefer CPU port 8 for Northstar devices
From: Rafał Miłecki <[email protected]>
It allows using all switch features in opposite to ports 5 and 7.
---
I think this can be net-next but I was asked to send a complete patchset Can you pick those 2 patches to different trees?
drivers/net/dsa/b53/b53_common.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)
drivers/net/dsa/b53/b53_common.c +27 -0
@@ -766,6 +766,32 @@ 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; + +/* +* Northstar SoCs devices have 3 Ethernet controllers and 3 CPU ports: +* 5 (IMP1), 7, 8 (IMP0). This design was meant for dual IMP setups when +* WAN traffic goes to port 5 and LAN traffic goes to port 8. +* +* While all 3 ports support Broadcom header, ports 5 and 7 have their +* limitations. Features that relay on trapping to CPU (e.g. EAP, STP) +* won't work when using those as CPU ones. +* +* Prefer CPU port 8 if available. +*/ +if (is5301x (dev)) { + cpu_dp =dsa_to_port (ds,B53_CPU_PORT ); + +if (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;
@@ -2724,6 +2750,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,
Signature · 1 line
2.51.0
[email protected]
AI reviewRe: [PATCH V3 2/4 net-next?] net: dsa: b53: prefer CPU port 8 for Northstar devices
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] Missing NULL pointer check on the result of `dsa_to_port()` before passing it to…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Missing NULL pointer check on the result of dsa_to_port() before passing it to dsa_port_is_cpu(), leading to a potential NULL pointer dereference. --
--- Patch [2]: [PATCH V3 2/4 net-next?] net: dsa: b53: prefer CPU port 8 for Northstar devices --- commit 2ae0d011f243e38dabfab275559b868d62bf66f6
Author: Rafał Miłecki <[email protected]>
net: dsa: b53: prefer CPU port 8 for Northstar devices
This patch prefers CPU port 8 if available for Northstar devices. Ports 5 and 7 have limitations with CPU trapping features compared to port 8.
Quoted 4 lines
drivers/net/dsa/b53/b53_common.c +0
-0
[ ... ]
Quoted 4 lines
drivers/net/dsa/b53/b53_common.c +4
-0+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;
[ ... ]
drivers/net/dsa/b53/b53_common.c void b53_disable_port(struct dsa_switch *ds, int port) · line 788
Quoted 4 lines
drivers/net/dsa/b53/b53_common.c +4
-0+if (is5301x (dev)) { + cpu_dp =dsa_to_port (ds,B53_CPU_PORT ); + +if (dsa_port_is_cpu (cpu_dp))
[Severity: High]
Does this code risk a NULL pointer dereference during device probe?
If a Northstar SoC is configured without port 8 (for example, in setups using only port 5 or 7 as the CPU port), dsa_to_port() will return NULL. The dsa_port_is_cpu() function dereferences the passed port pointer directly:
include/net/dsa.h:dsa_port_is_cpu() {
return port->type == DSA_PORT_TYPE_CPU;
}Passing NULL to dsa_port_is_cpu() would cause a panic. Could cpu_dp be checked for NULL before calling dsa_port_is_cpu()?
Quoted 5 lines
drivers/net/dsa/b53/b53_common.c +5
-0+return cpu_dp; + } + +return NULL ; +}
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
Rafał Miłecki
maintainerPATCH v3 3/4 ARM: dts: BCM5301X: drop pointless "cpu" labels from switch CPU ports
In reply to Rafał MiłeckiFrom: Rafał Miłecki <[email protected]>
Those labels don't really have any use.
--- .../broadcom/bcm4708-buffalo-wzr-1166dhp-common.dtsi | 4 ---- .../arm/boot/dts/broadcom/bcm4708-luxul-xap-1510.dts | 4 ---- .../arm/boot/dts/broadcom/bcm4708-luxul-xwc-1000.dts | 4 ---- arch/arm/boot/dts/broadcom/bcm4708-netgear-r6250.dts | 4 ---- .../boot/dts/broadcom/bcm4708-smartrg-sr400ac.dts | 4 ---- .../dts/broadcom/bcm47081-buffalo-wzr-600dhp2.dts | 4 ---- .../boot/dts/broadcom/bcm47081-luxul-xap-1410.dts | 4 ---- .../boot/dts/broadcom/bcm47081-luxul-xwr-1200.dts | 4 ---- .../arm/boot/dts/broadcom/bcm4709-linksys-ea9200.dts | 4 ---- arch/arm/boot/dts/broadcom/bcm4709-netgear-r8000.dts | 4 ---- .../boot/dts/broadcom/bcm47094-asus-rt-ac3100.dtsi | 12 ------------ .../boot/dts/broadcom/bcm47094-dlink-dir-885l.dts | 4 ---- .../boot/dts/broadcom/bcm47094-dlink-dir-890l.dts | 1 - .../boot/dts/broadcom/bcm47094-linksys-panamera.dts | 6 ------ .../boot/dts/broadcom/bcm47094-luxul-abr-4500.dts | 4 ---- .../boot/dts/broadcom/bcm47094-luxul-xap-1610.dts | 4 ---- .../boot/dts/broadcom/bcm47094-luxul-xbr-4500.dts | 4 ---- .../boot/dts/broadcom/bcm47094-luxul-xwc-2000.dts | 4 ---- .../boot/dts/broadcom/bcm47094-luxul-xwr-3100.dts | 4 ---- .../boot/dts/broadcom/bcm47094-luxul-xwr-3150-v1.dts | 4 ---- arch/arm/boot/dts/broadcom/bcm53015-meraki-mr26.dts | 2 -- arch/arm/boot/dts/broadcom/bcm53016-meraki-mr32.dts | 2 -- 22 files changed, 91 deletions(-)
arch/arm/boot/dts/broadcom/bcm4708-buffalo-wzr-1166dhp-common.dtsi +0 -4
@@ -178,10 +178,6 @@ port@4 { label = "wan"; }; - port@5 { - label = "cpu"; - }; - port@7 { status = "disabled"; };
arch/arm/boot/dts/broadcom/bcm4708-luxul-xap-1510.dts +0 -4
@@ -82,10 +82,6 @@ port@4 { label = "lan"; }; - port@5 { - label = "cpu"; - }; - port@7 { status = "disabled"; };
arch/arm/boot/dts/broadcom/bcm4708-luxul-xwc-1000.dts +0 -4
@@ -85,10 +85,6 @@ port@4 { label = "lan"; }; - port@5 { - label = "cpu"; - }; - port@7 { status = "disabled"; };
arch/arm/boot/dts/broadcom/bcm4708-netgear-r6250.dts +0 -4
@@ -119,10 +119,6 @@ port@4 { label = "wan"; }; - port@5 { - label = "cpu"; - }; - port@7 { status = "disabled"; };
arch/arm/boot/dts/broadcom/bcm4708-smartrg-sr400ac.dts +0 -4
@@ -160,10 +160,6 @@ port@4 { nvmem-cell-names = "mac-address"; }; - port@5 { - label = "cpu"; - }; - port@7 { status = "disabled"; };
arch/arm/boot/dts/broadcom/bcm47081-buffalo-wzr-600dhp2.dts +0 -4
@@ -142,10 +142,6 @@ port@4 { label = "wan"; }; - port@5 { - label = "cpu"; - }; - port@7 { status = "disabled"; };
arch/arm/boot/dts/broadcom/bcm47081-luxul-xap-1410.dts +0 -4
@@ -78,10 +78,6 @@ port@4 { label = "poe"; }; - port@5 { - label = "cpu"; - }; - port@7 { status = "disabled"; };
arch/arm/boot/dts/broadcom/bcm47081-luxul-xwr-1200.dts +0 -4
@@ -145,10 +145,6 @@ port@4 { nvmem-cell-names = "mac-address"; }; - port@5 { - label = "cpu"; - }; - port@7 { status = "disabled"; };
arch/arm/boot/dts/broadcom/bcm4709-linksys-ea9200.dts +0 -4
@@ -196,10 +196,6 @@ port@5 { port@7 { status = "disabled"; }; - - port@8 { - label = "cpu"; - }; }; };
arch/arm/boot/dts/broadcom/bcm4709-netgear-r8000.dts +0 -4
@@ -242,9 +242,5 @@ fixed-link { full-duplex; }; }; - - port@8 { - label = "cpu"; - }; }; };
arch/arm/boot/dts/broadcom/bcm47094-asus-rt-ac3100.dtsi +0 -12
@@ -151,18 +151,6 @@ port@4 { nvmem-cells = <&et0macaddr 1>; nvmem-cell-names = "mac-address"; }; - - port@5 { - label = "cpu"; - }; - - port@7 { - label = "cpu"; - }; - - port@8 { - label = "cpu"; - }; }; };
arch/arm/boot/dts/broadcom/bcm47094-dlink-dir-885l.dts +0 -4
@@ -167,9 +167,5 @@ port@5 { port@7 { status = "disabled"; }; - - port@8 { - label = "cpu"; - }; }; };
arch/arm/boot/dts/broadcom/bcm47094-dlink-dir-890l.dts +0 -1
@@ -205,7 +205,6 @@ port@7 { }; port@8 { - label = "cpu"; phy-mode = "rgmii"; }; };
arch/arm/boot/dts/broadcom/bcm47094-linksys-panamera.dts +0 -6
@@ -241,7 +241,6 @@ port@4 { }; port@5 { - label = "cpu"; status = "disabled"; fixed-link {
@@ -251,7 +250,6 @@ fixed-link { }; port@7 { - label = "cpu"; status = "disabled"; fixed-link {
@@ -259,10 +257,6 @@ fixed-link { full-duplex; }; }; - - port@8 { - label = "cpu"; - }; }; };
arch/arm/boot/dts/broadcom/bcm47094-luxul-abr-4500.dts +0 -4
@@ -104,10 +104,6 @@ port@4 { label = "lan1"; }; - port@5 { - label = "cpu"; - }; - port@7 { status = "disabled"; };
arch/arm/boot/dts/broadcom/bcm47094-luxul-xap-1610.dts +0 -4
@@ -97,10 +97,6 @@ port@1 { label = "lan"; }; - port@5 { - label = "cpu"; - }; - port@7 { status = "disabled"; };
arch/arm/boot/dts/broadcom/bcm47094-luxul-xbr-4500.dts +0 -4
@@ -104,10 +104,6 @@ port@4 { label = "lan1"; }; - port@5 { - label = "cpu"; - }; - port@7 { status = "disabled"; };
arch/arm/boot/dts/broadcom/bcm47094-luxul-xwc-2000.dts +0 -4
@@ -72,10 +72,6 @@ port@0 { label = "lan"; }; - port@5 { - label = "cpu"; - }; - port@7 { status = "disabled"; };
arch/arm/boot/dts/broadcom/bcm47094-luxul-xwr-3100.dts +0 -4
@@ -144,10 +144,6 @@ port@4 { nvmem-cell-names = "mac-address"; }; - port@5 { - label = "cpu"; - }; - port@7 { status = "disabled"; };
arch/arm/boot/dts/broadcom/bcm47094-luxul-xwr-3150-v1.dts +0 -4
@@ -135,10 +135,6 @@ port@4 { nvmem-cell-names = "mac-address"; }; - port@5 { - label = "cpu"; - }; - port@7 { status = "disabled"; };
arch/arm/boot/dts/broadcom/bcm53015-meraki-mr26.dts +0 -2
@@ -137,8 +137,6 @@ port@0 { }; port@5 { - label = "cpu"; - fixed-link { speed = <1000>; full-duplex;
arch/arm/boot/dts/broadcom/bcm53016-meraki-mr32.dts +0 -2
@@ -178,8 +178,6 @@ port@0 { }; port@5 { - label = "cpu"; - fixed-link { speed = <1000>; full-duplex;
Signature · 1 line
2.51.0
Rafał Miłecki
maintainerPATCH v3 4/4 ARM: dts: BCM5301X: Enable extra CPU ports for Netgear R8000
In reply to Rafał MiłeckiFrom: Rafał Miłecki <[email protected]>
Just because port 8 is a preferred CPU port (because it provides a full switch functionality) it doesn't mean other ones can't be used. Let software decide which CPU port to use.
---
After some extra research I discovered we can't blindly update all BCM5301X (Northstar) devices enabling all 3 ports (5, 7 and 8). Sometimes extra ports require fixed link but it seems to be device specific.
arch/arm/boot/dts/broadcom/bcm4709-netgear-r8000.dts | 4 ---- 1 file changed, 4 deletions(-)
arch/arm/boot/dts/broadcom/bcm4709-netgear-r8000.dts +0 -4
@@ -226,8 +226,6 @@ port@4 { }; port@5 { - status = "disabled"; - fixed-link { speed = <1000>; full-duplex;
@@ -235,8 +233,6 @@ fixed-link { }; port@7 { - status = "disabled"; - fixed-link { speed = <1000>; full-duplex;
Signature · 1 line
2.51.0
Hi Rafał,
Tested on an Asus RT-N18U (BCM47081 + BCM53011 rev 5), with a local DTS change enabling ports 7 and 8 like your 4/4 does for the R8000 (the in-tree bcm-ns.dtsi state). With patches 1 and 2 applied:
- The op works as designed: DSA picks port 8, the conduit is gmac2, the 1/4 warning stays silent, and management over the bridged LAN ports runs through the port 8 path with no issues.
- Trap delivery is restored: 20 of 20 BPDUs injected into a front port reach the CPU. On the port 5 topology the same probe measured 0 across every front port.
With all three CPU ports enabled, GMNGCFG ends up in dual IMP mode (0xc2 read back). In that mode a tagged frame whose VID is missing from the VLAN table is delivered to no CPU port at all: an 8021q upper on a standalone port receives 0 of 7 tagged probes, whether the port 5 conduit is up or down. With port 8 as the only enabled CPU port in the DT, where GMNGCFG reads 0b10, the same frames were delivered. So the preferred CPU port alone does not revive standalone 8021q uppers on DTs that enable all three ports.
The same effect touches 4/4: the R8000 today has ports 5 and 7 disabled, the single IMP configuration, and enabling them lands the switch in dual IMP mode through the same driver path. If its switch behaves like this BCM53011, standalone 8021q uppers on the R8000 stop receiving with 4/4 applied.
On the RT-N18U the boot firmware provisions a MAC only for gmac0, so gmac2 comes up with a random MAC and the bridge inherits it, changing per boot.
Best regards,
Semih
Vladimir Oltean
maintainerQuoted 9 lines · Semih Baskan
With all three CPU ports enabled, GMNGCFG ends up in dual IMP mode (
0xc2read back). In that mode a tagged frame whose VID is missing from the VLAN table is delivered to no CPU port at all: an 8021q upper on a standalone port receives 0 of 7 tagged probes, whether the port 5 conduit is up or down. With port 8 as the only enabled CPU port in the DT, where GMNGCFG reads 0b10, the same frames were delivered. So the preferred CPU port alone does not revive standalone 8021q uppers on DTs that enable all three ports.
Quoted 5 lines
The same effect touches 4/4: the R8000 today has ports 5 and 7 disabled, the single IMP configuration, and enabling them lands the switch in dual IMP mode through the same driver path. If its switch behaves like this BCM53011, standalone 8021q uppers on the R8000 stop receiving with 4/4 applied.
Where is the code that configures this GMNGCFG register?
Quoted 3 lines
On the RT-N18U the boot firmware provisions a MAC only for gmac0, so gmac2 comes up with a random MAC and the bridge inherits it, changing per boot.
In the previous version, Rafał included a patch so that gmac2 uses the same MAC address as gmac0. Is this better?
https://lore.kernel.org/netdev/[email protected]/
Hi Vladimir,
Quoted 1 line · Vladimir Oltean
Where is the code that configures this GMNGCFG register?
b53_brcm_hdr_setup(). Setting up port 8 ORs the 0b10 value into the GMNGCFG management port field. Setting up port 5 ORs the whole field mask, which sets 0b11, dual IMP mode. The chip has no IMP1 only encoding (0b01 is reserved), so there was no single port value to use there. Nothing clears the field. That gives 0xc2 whenever port 5 is a CPU port, and 0x82 with port 8 alone.
Quoted 3 lines
In the previous version, Rafal included a patch so that gmac2 uses the same MAC address as gmac0. Is this better?
https://lore.kernel.org/netdev/[email protected]/
Yes. The IMPs never learn: b53_setup_port() disables learning everywhere and only bridged user ports re-enable it, DIS_LEARNING reads 0x01e1 on both conduit configurations, and the ARL holds the host MAC only as the driver's static entry. So one MAC across gmac0 and gmac2 cannot flap anything, and the bridge MAC stops changing every boot.
Best regards,
Semih
Jakub Kicinski
maintainerQuoted 5 lines · On Wed, 12 Aug 2026 15:27:52 +0200 Rafał Miłecki wrote:
From: Rafał Miłecki <[email protected]>
Northstar devices have 3 CPU ports. Ports 5 and 7 may be used but have their limitations. Warn user when CPU port 8 isn't used and add EAP setup workaround to avoid non-functional standalone ports.
FTR this needs to apply to the tree tagged in the first patch, according to the CI it did not apply to net so repost will be needed.
Jonas Gorski
maintainerHi,
Quoted 25 lines · Rafał Miłecki
From: Rafał Miłecki <[email protected]>
Northstar devices have 3 CPU ports. Ports 5 and 7 may be used but have their limitations. Warn user when CPU port 8 isn't used and add EAP setup workaround to avoid non-functional standalone ports.
Fixes 4227ea91e265 ("net: dsa: b53: prevent standalone from trying to forward to other ports")Cc Semih Baskan <[email protected]>Signed-off-by Rafał Miłecki <[email protected]>Tested-by Semih Baskan <[email protected]>---
This fixes a regression so it's a net.git materialV2: Print warning on switch setup instead of on actual EAP mode change
V3: Proper subject prefix & shorter comments (long one comes with 2/2)drivers/net/dsa/b53/b53_common.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)drivers/net/dsa/b53/b53_common.c +0
-0
drivers/net/dsa/b53/b53_common.c static void b53_set_eap_mode(struct b53_device *dev, int port, int mode) · line 336
Quoted 5 lines
drivers/net/dsa/b53/b53_common.c +2
-0@@ -332,6 +332,14 @@ static void b53_set_eap_mode(struct b53_device *dev, int port, int mode) {u64 eap_conf; +/* +* On Northstar setting EAP_MODE_SIMPLIFIED with CPU port 5/7 breaks
This isn't just northstar, this is any dual IMP capable switch
drivers/net/dsa/b53/b53_common.c static void b53_set_eap_mode(struct b53_device *dev, int port, int mode) · line 341
Quoted 5 lines
drivers/net/dsa/b53/b53_common.c +5
-0+* standalone ports, see: +* https://lore.kernel.org/netdev/[email protected]/ +*/ +if (is5301x (dev) && !dsa_is_cpu_port (dev->ds,B53_CPU_PORT )) +return ;
This should be moved below the 5325/5365 check and just !dsa_is_cpu_port(dev->ds, B53_CPU_PORT))
drivers/net/dsa/b53/b53_common.c static int b53_setup(struct dsa_switch *ds) · line 1293
Quoted 10 lines
drivers/net/dsa/b53/b53_common.c +3
-0+if (is5325 (dev) ||is5365 (dev) || dev->chip_id ==BCM5389_DEVICE_ID )return ;@@ -1281,6 +1289,10 @@ static int b53_setup(struct dsa_switch *ds)u16 pvid;int ret; +/* Discourage users from using port 5 or 7 due to limited features */ +if (is5301x (dev) && !dsa_is_cpu_port (dev->ds,B53_CPU_PORT ))
This should be
if (!is5325(dev) && !is5365(dev) && !dsa_is_cpu_port(dev->ds, B53_CPU_PORT))
dual IMP mode is also supported by external switches (e.g. bcm53115 and bcm53125), and if for some reason someone would try to use port 5 only on these you will have the same issues.
drivers/net/dsa/b53/b53_common.c static int b53_setup(struct dsa_switch *ds) · line 1294
Quoted 1 line
drivers/net/dsa/b53/b53_common.c +1
-0+dev_warn (dev->dev,"switch to CPU port 8 to use all switch features\n" );
I think this warning is too mild; it should be something like
"Using port 5 or 7 as CPU port is not a valid configuration and will prevent the switch from working properly..\n"
Best regards,
Jonas