Skip to contentSkip to conversation

net: dsa: b53: prefer CPU port 8 for Northstar devices

PATCH In review Rafał Miłecki 3 participants 5 messages Dec 2 – Dec 3

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 net: dsa: b53: prefer CPU port 8 for Northstar devices

From: Rafał Miłecki <[email protected]>

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

---
V4: Add check for NULL pointer

 drivers/net/dsa/b53/b53_common.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
drivers/net/dsa/b53/b53_common.c +27 -0
index ee2d27732c0c..53625090131e 100644
@@ -758,6 +758,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 (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 +2929,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
maintainer
#1 lore raw
Quoted 22 lines · Rafał Miłecki

From: Rafał Miłecki <[email protected]>

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

---
V4: Add check for NULL pointer

  drivers/net/dsa/b53/b53_common.c | 27 +++++++++++++++++++++++++++
  1 file changed, 27 insertions(+)
drivers/net/dsa/b53/b53_common.c +3 -0
index ee2d27732c0c..53625090131e 100644
@@ -758,6 +758,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;

drivers/net/dsa/b53/b53_common.c void b53_disable_port(struct dsa_switch *ds, int port) · line 773

Quoted 10 lines
drivers/net/dsa/b53/b53_common.c +10 -0
+	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.

typo: s/relay/rely/

drivers/net/dsa/b53/b53_common.c void b53_disable_port(struct dsa_switch *ds, int port) · line 777

Quoted 4 lines
drivers/net/dsa/b53/b53_common.c +4 -0
+	 *
+	 * Prefer CPU port 8 if available.
+	 */
+	if (is5301x(dev)) {

Appreciate you want to be somewhat conservative here but the list is much longer, in fact, we should probably implement this by exception, the norm is to use port 8, and the exception is to use another one.

Signature · 1 line
Florian
#2 lore raw

W dniu 2.12.2026 o 21:13, Florian Fainelli pisze:

Quoted 35 lines · Rafał Miłecki
Quoted 21 lines

From: Rafał Miłecki <[email protected]>

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

---
V4: Add check for NULL pointer

  drivers/net/dsa/b53/b53_common.c | 27 +++++++++++++++++++++++++++

  1 file changed, 27 insertions(+)
drivers/net/dsa/b53/b53_common.c +3 -0
index ee2d27732c0c..53625090131e 100644
@@ -758,6 +758,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;

drivers/net/dsa/b53/b53_common.c void b53_disable_port(struct dsa_switch *ds, int port) · line 772

Quoted 10 lines
drivers/net/dsa/b53/b53_common.c +10 -0
+    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.

typo: s/relay/rely/

Quoted 6 lines

drivers/net/dsa/b53/b53_common.c void b53_disable_port(struct dsa_switch *ds, int port) · line 777

Quoted 4 lines
drivers/net/dsa/b53/b53_common.c +4 -0
+     *
+     * Prefer CPU port 8 if available.
+     */
+    if (is5301x(dev)) {

Appreciate you want to be somewhat conservative here but the list is much longer, in fact, we should probably implement this by exception, the norm is to use port 8, and the exception is to use another one.

I'm just not really familiar with other hardware supported by b53.

Are you aware of any devices that this logic shouldn't be applied to?

maintainer
#3 lore raw
Quoted 47 lines · Rafał Miłecki

W dniu 2.12.2026 o 21:13, Florian Fainelli pisze:

Quoted 46 lines · Rafał Miłecki
Quoted 29 lines

From: Rafał Miłecki <[email protected]>

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

---
V4: Add check for NULL pointer

  drivers/net/dsa/b53/b53_common.c | 27 +++++++++++++++++++++++++++

  1 file changed, 27 insertions(+)
drivers/net/dsa/b53/b53_common.c +7 -0
index ee2d27732c0c..53625090131e 100644
@@ -758,6 +758,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

Quoted 8 lines

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.

typo: s/relay/rely/

Quoted 4 lines

+     *
+     * Prefer CPU port 8 if available.
+     */
+    if (is5301x(dev)) {

Quoted 5 lines
Quoted 1 line

Appreciate you want to be somewhat conservative here but the list is much longer, in fact, we should probably implement this by exception, the norm is to use port 8, and the exception is to use another one.

I'm just not really familiar with other hardware supported by b53.

Are you aware of any devices that this logic shouldn't be applied to?

Except 5325 and 5365, and some odd combinations where there is an actual ned not to use port 8, see https://lore.kernel.org/all/[email protected] then I can't think of a configuration where it is not done. With that said, I would go with something like this:

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;

          /* Port 8 (IMP0) is the fully featured CPU port. Ports 5 and 
7 ... */
          cpu_dp = dsa_to_port(ds, B53_CPU_PORT);
          if (cpu_dp && dsa_port_is_cpu(cpu_dp))
                  return cpu_dp;

          return NULL;

}

Signature · 1 line
Florian
#4 lore raw
In reply to Rafał Miłecki
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider.

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

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

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] This finding is speculative: it depends on how the hardware decodes GLOBAL_CONFIG bits [7:6] on BCM5301x.
- [Low] On existing Northstar boards, the new b53_preferred_default_local_cpu_port()…
- [Low] The comment added in b53_preferred_default_local_cpu_port() (drivers/net/dsa/b53/b53_common.c:771-773) describes a functional…

--

net: dsa: b53: prefer CPU port 8 for Northstar devices

This adds a preferred_default_local_cpu_port callback to the b53 driver. On BCM5301x (Northstar) switches it returns port 8 when that port is configured as a CPU port. DSA then assigns all user ports to port 8 instead of the first CPU port listed in the device tree.

Quoted 11 lines
drivers/net/dsa/b53/b53_common.c +3 -0
index ee2d27732c0c8..53625090131e9 100644
@@ -758,6 +758,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;

drivers/net/dsa/b53/b53_common.c void b53_disable_port(struct dsa_switch *ds, int port) · line 773

Quoted 10 lines
drivers/net/dsa/b53/b53_common.c +10 -0
+	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.

[Severity: Low]
This comment says STP and EAP trapping don't work when port 5 or 7 is the CPU port. bcm-ns.dtsi lists port@5 first. That means boards such as rt-ac3100, rt-ac3200, rt-ac5300 and wxr-1750dhp currently get port 5 as the default CPU port, and rt-ac88u gets port 7.

If the comment is accurate, isn't this patch a fix for a functional regression rather than a preference change? The commit message only says "prefer" and has no Fixes: tag. That makes it hard to tell whether the patch belongs in net with a Fixes: tag or in net-next.

Could the commit message say what is broken and which change made port 5/7 the default? If there is no functional bug, does the comment overstate the problem?

This patch also doesn't help boards that enable only port 5 as a CPU port (most Luxul boards, Netgear R6250, Buffalo WZR-1166DHP, Meraki MR26/MR32, bcm953012er). Going by the comment, trapping would stay broken on them. Should the commit message mention that?

drivers/net/dsa/b53/b53_common.c void b53_disable_port(struct dsa_switch *ds, int port) · line 782

Quoted 9 lines
drivers/net/dsa/b53/b53_common.c +9 -0
+	 *
+	 * Prefer CPU port 8 if available.
+	 */
+	if (is5301x(dev)) {
+		cpu_dp = dsa_to_port(ds, B53_CPU_PORT);
+
+		if (cpu_dp && dsa_port_is_cpu(cpu_dp))
+			return cpu_dp;
+	}

[Severity: Low]
Does this change the conduit for user ports on existing boards?

dsa_tree_setup_cpu_ports() walks the ports in DT order and gives all user ports to the first local CPU port. In bcm-ns.dtsi that is port@5 (gmac0). With this callback in place, ports 5 and 7 are skipped:

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

As a result, every user port gets port 8 (gmac2) as its conduit.

These in-tree boards keep more than one CPU port enabled:

bcm47094-asus-rt-ac3100.dtsi (ports 5, 7 and 8; gmac0 -> gmac2) bcm4709-asus-rt-ac3200.dts bcm47094-asus-rt-ac5300.dts bcm4708-buffalo-wxr-1750dhp.dts bcm47094-asus-rt-ac88u.dts (port 7/gmac1 -> port 8/gmac2)

On these boards, user ports would appear as lan1@eth2 instead of lan1@eth0. Conduit-specific configuration (MTU, ethtool/tc on the conduit, distro network scripts) would then apply to a different interface.

b53 doesn't implement .port_change_conduit, so dsa_user_change_conduit() returns -EOPNOTSUPP. Users can't restore the previous conduit at runtime through IFLA_DSA_CONDUIT; the only way back is to edit the DT.

Could the commit message document this user-visible change?

[Severity: Medium]
This one is speculative and depends on how BCM5301x decodes bits [7:6] of B53_GLOBAL_CONFIG. Does the frame management port setting match the new default CPU port?

b53_setup() calls b53_enable_cpu_port()->b53_brcm_hdr_setup() for each CPU port in ascending order. b53_brcm_hdr_setup() only ORs bits in:

drivers/net/dsa/b53/b53_common.c:b53_brcm_hdr_setup() {
    ...
	b53_read8(dev, B53_MGMT_PAGE, B53_GLOBAL_CONFIG, &hdr_ctl);
	if (port == 8)
		hdr_ctl |= GC_FRM_MGMT_PORT_MII;
	else if (port == 5)
		hdr_ctl |= GC_FRM_MGMT_PORT_M;
	b53_write8(dev, B53_MGMT_PAGE, B53_GLOBAL_CONFIG, hdr_ctl);
    ...
}

GC_FRM_MGMT_PORT_M is 0xC0 and GC_FRM_MGMT_PORT_MII is 0x80. A switch with both port 5 and port 8 as CPU ports therefore ends up with 0xC0, which is the value the driver uses for port 5. No later code clears these bits.

If 0b11 selects port 5 as the frame management port on BCM5301x, wouldn't trapped BPDUs and EAP frames still go to port 5/gmac0, while DSA has bound all user ports to port 8? In that case, should b53_brcm_hdr_setup() clear GC_FRM_MGMT_PORT_M and then set the IMP0 value for the preferred CPU port?

There is evidence the other way. b53_srab.c names port 5 IMP1 and port 8 IMP0, and the comment above describes a dual IMP design. So 0b11 may mean dual IMP mode with port 8 still IMP0. Could someone with the BCM5301x datasheet confirm which encoding applies?

Quoted 3 lines
drivers/net/dsa/b53/b53_common.c +3 -0
+
+	return NULL;
+}

[ ... ]

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