]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
net: dsa: realtek: rtl8365mb: reject unsupported topologies
authorLuiz Angelo Daros de Luca <luizluca@gmail.com>
Sat, 6 Jun 2026 08:29:26 +0000 (05:29 -0300)
committerJakub Kicinski <kuba@kernel.org>
Wed, 10 Jun 2026 02:35:41 +0000 (19:35 -0700)
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.

Reviewed-by: Mieczyslaw Nalewaj <namiltd@yahoo.com>
Reviewed-by: Linus Walleij <linusw@kernel.org>
Signed-off-by: Luiz Angelo Daros de Luca <luizluca@gmail.com>
Link: https://patch.msgid.link/20260606-realtek_forward-v13-2-b9e409687cbe@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/dsa/realtek/rtl8365mb.c

index 2637884fe4725b55a2fef6e81f53a867b806158c..37e1d7654b1d63156581881c3c931e4e8b04358b 100644 (file)
@@ -1991,6 +1991,20 @@ static int rtl8365mb_setup(struct dsa_switch *ds)
        else if (ret)
                dev_info(priv->dev, "no interrupt support\n");
 
+       for (i = 0; i < priv->num_ports; 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.
+                */
+               if (dsa_is_dsa_port(ds, i)) {
+                       dev_err(priv->dev, "Cascading (DSA link) not supported\n");
+                       ret = -EOPNOTSUPP;
+                       goto out_teardown_irq;
+               }
+       }
+
        /* Configure CPU tagging */
        dsa_switch_for_each_cpu_port(cpu_dp, ds) {
                cpu->mask |= BIT(cpu_dp->index);
@@ -1999,6 +2013,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 CPU port defined\n");
+               ret = -EINVAL;
+               goto out_teardown_irq;
+       }
+
        ret = rtl8365mb_cpu_config(priv);
        if (ret)
                goto out_teardown_irq;