[net-next PATCH v10 2/9] net: dsa: realtek: rtl8365mb: reject unsupported topologies

From: Luiz Angelo Daros de Luca

Date: Sat May 30 2026 - 06:55:42 EST


Explicitly enforce the presence of a CPU port (-EINVAL) and reject DSA
cascade links (-EOPNOTSUPP) during setup to prevent silent failures.

These topologies were already non-functional. Without a CPU port, the
driver does not activate CPU tagging. Additionally, the switch hardware
was not designed to be cascaded, and DSA links never worked because
CPU tagging is not enabled for them.

Signed-off-by: Luiz Angelo Daros de Luca <luizluca@xxxxxxxxx>
---
drivers/net/dsa/realtek/rtl8365mb.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)

diff --git a/drivers/net/dsa/realtek/rtl8365mb.c b/drivers/net/dsa/realtek/rtl8365mb.c
index 2637884fe472..a1641378fcbb 100644
--- a/drivers/net/dsa/realtek/rtl8365mb.c
+++ b/drivers/net/dsa/realtek/rtl8365mb.c
@@ -1999,6 +1999,13 @@ static int rtl8365mb_setup(struct dsa_switch *ds)
cpu->trap_port = cpu_dp->index;
}
cpu->enable = cpu->mask > 0;
+
+ if (!cpu->enable) {
+ dev_err(priv->dev, "no upstream (CPU, Link) port defined\n");
+ ret = -EINVAL;
+ goto out_teardown_irq;
+ }
+
ret = rtl8365mb_cpu_config(priv);
if (ret)
goto out_teardown_irq;
@@ -2010,6 +2017,18 @@ static int rtl8365mb_setup(struct dsa_switch *ds)
if (dsa_is_unused_port(ds, i))
continue;

+ if (dsa_is_dsa_port(ds, i)) {
+ /* Cascading (DSA links) is not supported yet.
+ * Historically, the driver has always been broken
+ * without a dedicated CPU port because CPU tagging
+ * would be disabled, rendering the switch entirely
+ * non-functional for DSA operations.
+ */
+ dev_err(ds->dev, "Cascading (DSA link) not supported\n");
+ ret = -EOPNOTSUPP;
+ goto out_teardown_irq;
+ }
+
/* Forward only to the CPU */
ret = rtl8365mb_port_set_isolation(priv, i, cpu->mask);
if (ret)

--
2.54.0