From: Jakub Kicinski <kuba@kernel.org>
To: luizluca@gmail.com
Cc: Jakub Kicinski <kuba@kernel.org>,
andrew@lunn.ch, olteanv@gmail.com, davem@davemloft.net,
edumazet@google.com, pabeni@redhat.com, horms@kernel.org,
linusw@kernel.org, alsi@bang-olufsen.dk, yury.norov@gmail.com,
linux@rasmusvillemoes.dk, linux@armlinux.org.uk,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [net-next PATCH v3 2/8] net: dsa: realtek: rtl8365mb: use dsa helpers for port iteration
Date: Sun, 10 May 2026 10:34:45 -0700 [thread overview]
Message-ID: <20260510173445.3919786-1-kuba@kernel.org> (raw)
In-Reply-To: <20260506-realtek_forward-v3-2-1d87c5f85a3b@gmail.com>
This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.
---
net: dsa: realtek: rtl8365mb: use dsa helpers for port iteration
This commit refactors rtl8365mb port iteration to use the
dsa_switch_for_each_*() helpers, adds a blocking setup phase for all
ports up front, and extends CPU-port isolation to include all user
ports.
> diff --git a/drivers/net/dsa/realtek/rtl8365mb.c b/drivers/net/dsa/realtek/rtl8365mb.c
> index edbc16345d0d..7ddb82fcd026 100644
> --- a/drivers/net/dsa/realtek/rtl8365mb.c
> +++ b/drivers/net/dsa/realtek/rtl8365mb.c
[ ... ]
> @@ -1943,11 +1946,11 @@ static int rtl8365mb_reset_chip(struct realtek_priv *priv)
> static int rtl8365mb_setup(struct dsa_switch *ds)
> {
> struct realtek_priv *priv = ds->priv;
> + struct dsa_port *cpu_dp, *dp;
> struct rtl8365mb_cpu *cpu;
> - struct dsa_port *cpu_dp;
> struct rtl8365mb *mb;
> + u32 userports_mask;
> int ret;
> - int i;
>
> mb = priv->chip_data;
> cpu = &mb->cpu;
[ ... ]
> + /* Start with all ports blocked, including unused ports */
> + dsa_switch_for_each_port(dp, ds) {
> + struct rtl8365mb_port *p = &mb->ports[dp->index];
> +
> + /* Set the initial STP state of all ports to DISABLED, otherwise
> + * ports will still forward frames to the CPU despite being
> + * administratively down by default.
> + */
> + rtl8365mb_port_stp_state_set(ds, dp->index, BR_STATE_DISABLED);
> +
> + /* Start with all port completely isolated */
> + ret = rtl8365mb_port_set_isolation(priv, dp->index, 0);
> + if (ret)
> + goto out_teardown_irq;
> +
> + /* Disable learning */
> + ret = rtl8365mb_port_set_learning(priv, dp->index, false);
> + if (ret)
> + goto out_teardown_irq;
> +
> + /* Set up per-port private data */
> + p->priv = priv;
> + p->index = dp->index;
> + }
> +
> + userports_mask = dsa_user_ports(ds);
> +
> /* Configure CPU tagging */
> dsa_switch_for_each_cpu_port(cpu_dp, ds) {
> - cpu->mask |= BIT(cpu_dp->index);
> -
> + /* Use the first CPU port as trap_port */
> if (cpu->trap_port == RTL8365MB_MAX_NUM_PORTS)
> cpu->trap_port = cpu_dp->index;
> +
> + /* Forward to all user ports */
> + ret = rtl8365mb_port_set_isolation(priv, cpu_dp->index,
> + userports_mask);
> + if (ret)
> + goto out_teardown_irq;
> }
> +
> + cpu->mask = dsa_cpu_ports(ds);
> cpu->enable = cpu->mask > 0;
> ret = rtl8365mb_cpu_config(priv);
> if (ret)
> goto out_teardown_irq;
>
> - /* Configure ports */
> - for (i = 0; i < priv->num_ports; i++) {
> - struct rtl8365mb_port *p = &mb->ports[i];
> -
> - if (dsa_is_unused_port(ds, i))
> - continue;
> -
> + /* Configure user ports */
> + dsa_switch_for_each_user_port(dp, ds) {
> /* Forward only to the CPU */
> - ret = rtl8365mb_port_set_isolation(priv, i, cpu->mask);
> + ret = rtl8365mb_port_set_isolation(priv, dp->index, cpu->mask);
> if (ret)
> goto out_teardown_irq;
[Medium]
Does this refactor change behaviour for DSA-type ports (DSA_PORT_TYPE_DSA)?
Before the patch, the configuration loop iterated every non-unused port
and applied cpu->mask as the isolation mask, which included DSA-type
ports:
for (i = 0; i < priv->num_ports; i++) {
...
if (dsa_is_unused_port(ds, i))
continue;
/* Forward only to the CPU */
ret = rtl8365mb_port_set_isolation(priv, i, cpu->mask);
...
}
After the patch, the first pass sets isolation to 0 for every port, and
the subsequent passes only match CPU ports and user ports:
#define dsa_switch_for_each_cpu_port(_dp, _ds) \
dsa_switch_for_each_port((_dp), (_ds)) \
if (dsa_port_is_cpu((_dp)))
#define dsa_switch_for_each_user_port(_dp, _ds) \
dsa_switch_for_each_port((_dp), (_ds)) \
if (dsa_port_is_user((_dp)))
So a DSA-type port keeps isolation=0 from the initial pass and is never
reconfigured.
In addition, the masks derived from dsa_user_ports() and dsa_cpu_ports()
exclude DSA-type ports, so CPU and user ports will not include DSA link
ports in their isolation masks either, which looks like it would block
forwarding across cascaded switches in both directions.
The commit message describes the behaviour change only as "CPU isolation
now includes all user ports"; is the loss of DSA-port configuration
intentional, and if so should it be called out in the commit message?
--
pw-bot: cr
next prev parent reply other threads:[~2026-05-10 17:34 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-07 2:58 [net-next PATCH v3 0/8] net: dsa: realtek: rtl8365mb: bridge offloading and VLAN support Luiz Angelo Daros de Luca
2026-05-07 2:58 ` [net-next PATCH v3 1/8] net: dsa: realtek: rtl8365mb: use ERR_PTR Luiz Angelo Daros de Luca
2026-05-10 15:23 ` Mieczyslaw Nalewaj
2026-05-07 2:58 ` [net-next PATCH v3 2/8] net: dsa: realtek: rtl8365mb: use dsa helpers for port iteration Luiz Angelo Daros de Luca
2026-05-10 15:23 ` Mieczyslaw Nalewaj
2026-05-10 17:34 ` Jakub Kicinski [this message]
2026-05-10 17:35 ` Jakub Kicinski
2026-05-07 2:58 ` [net-next PATCH v3 3/8] net: dsa: realtek: rtl8365mb: prepare for multiple source files Luiz Angelo Daros de Luca
2026-05-10 15:23 ` Mieczyslaw Nalewaj
2026-05-07 2:58 ` [net-next PATCH v3 4/8] net: dsa: realtek: rtl8365mb: add table lookup interface Luiz Angelo Daros de Luca
2026-05-10 15:24 ` Mieczyslaw Nalewaj
2026-05-10 17:34 ` Jakub Kicinski
2026-05-07 2:58 ` [net-next PATCH v3 5/8] net: dsa: realtek: rtl8365mb: add VLAN support Luiz Angelo Daros de Luca
2026-05-10 15:24 ` Mieczyslaw Nalewaj
2026-05-10 17:34 ` Jakub Kicinski
2026-05-10 17:35 ` Jakub Kicinski
2026-05-07 2:58 ` [net-next PATCH v3 6/8] net: dsa: realtek: rtl8365mb: add port_bridge_{join,leave} Luiz Angelo Daros de Luca
2026-05-10 15:25 ` Mieczyslaw Nalewaj
2026-05-10 17:34 ` Jakub Kicinski
2026-05-10 17:35 ` Jakub Kicinski
2026-05-07 2:58 ` [net-next PATCH v3 7/8] net: dsa: realtek: rtl8365mb: add FDB support Luiz Angelo Daros de Luca
2026-05-10 15:25 ` Mieczyslaw Nalewaj
2026-05-10 17:34 ` Jakub Kicinski
2026-05-10 17:35 ` Jakub Kicinski
2026-05-11 15:00 ` Mieczyslaw Nalewaj
2026-05-07 2:58 ` [net-next PATCH v3 8/8] net: dsa: realtek: rtl8365mb: add bridge port flags Luiz Angelo Daros de Luca
2026-05-10 15:26 ` Mieczyslaw Nalewaj
2026-05-10 17:34 ` Jakub Kicinski
2026-05-10 17:34 ` [net-next PATCH v3 0/8] net: dsa: realtek: rtl8365mb: bridge offloading and VLAN support Jakub Kicinski
2026-05-11 4:58 ` Luiz Angelo Daros de Luca
2026-05-11 9:31 ` Linus Walleij
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260510173445.3919786-1-kuba@kernel.org \
--to=kuba@kernel.org \
--cc=alsi@bang-olufsen.dk \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=linusw@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=linux@rasmusvillemoes.dk \
--cc=luizluca@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.com \
--cc=yury.norov@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox