Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: namiltd@yahoo.com
Cc: linusw@kernel.org, andrew@lunn.ch, olteanv@gmail.com,
	kuba@kernel.org, davem@davemloft.net, edumazet@google.com,
	pabeni@redhat.com, linux@armlinux.org.uk, luizluca@gmail.com,
	maxime.chevallier@bootlin.com, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, alvin.sipraga@analog.com,
	gusfmora@gmail.com, kuncy7@gmail.com, fabianotassotti@gmail.com,
	gabonpivovich@gmail.com, contact@c127.dev
Subject: Re: [PATCH net-next v12 12/13] net: dsa: realtek: rtl8365mb: make L2/LUT access work on family D
Date: Tue, 24 Nov 2026 01:24:42 +0000	[thread overview]
Message-ID: <179548348297.3135.11750610960946672439@kernel.org> (raw)
In-Reply-To: <ca39376d-37b6-43e0-9dd5-7d431d335e63@yahoo.com>

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

Critical: 0 · High: 0 · Medium: 4 · Low: 0

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] Family D sets `ds->max_num_bridges = 1` in rtl8365mb_setup()
  (drivers/net/dsa/realtek/rtl8365mb_main.c:3728), but DSA hands out…
- [Medium] The comment in rtl8365mb_d_l2_uc_to_data()
  (drivers/net/dsa/realtek/rtl8365mb_l2.c:278-284) says that IVL_EN…
- [Medium] rtl8365mb_d_l2_mc_to_data() (rtl8365mb_l2.c:318) writes VID-0
  MDB entries of a VLAN-unaware bridge with IVL=0, FID 0.
- [Medium] The family D serializers pick IVL from the VID alone (`ivl =
  key.ivl && key.vid`, rtl8365mb_d_l2_uc_to_data() at…

--

net: dsa: realtek: rtl8365mb: make L2/LUT access work on family D

This patch adds L2 entry (de)serializers for family D (RTL8367S-VB). It
also adjusts table access for the narrower SPA and address fields, and
adds a LUT init step. EFID handling becomes a no-op on family D,
fdb_isolation is not advertised, and max_num_bridges is set to 1.

Closes: https://github.com/openwrt/openwrt/pull/19644#issuecomment-6708118180

> diff --git a/drivers/net/dsa/realtek/rtl8365mb_l2.c b/drivers/net/dsa/realtek/rtl8365mb_l2.c
> index cd5b333932bee..e98ba5c5f9193 100644
> --- a/drivers/net/dsa/realtek/rtl8365mb_l2.c
> +++ b/drivers/net/dsa/realtek/rtl8365mb_l2.c

[ ... ]

> @@ -240,6 +255,78 @@ void rtl8365mb_c_l2_mc_to_data(const struct rtl8365mb_l2_mc *mc,
>  	data[5] |= FIELD_PREP(RTL8365MB_L2_MC_D5_MBR_HI2_MSK, val);
>  }
>  

[ ... ]

> +void rtl8365mb_d_l2_uc_to_data(const struct rtl8365mb_l2_uc *uc,
> +			       u16 *data)
> +{
> +	/* A VLAN-unaware bridge reaches us with VID 0. The chip learns such
> +	 * traffic in SVL (IVL=0, FID=0), so use the same key here, otherwise
> +	 * the static entry never matches the learned one. Only a real VID
> +	 * selects IVL. IVL_EN of the VLANs follows the VLAN filtering state
> +	 * (see rtl8365mb_d_vlan_4k_refresh_ivl()), so this matches the key
> +	 * the chip learns with.
> +	 */
> +	bool ivl = uc->key.ivl && uc->key.vid;

[Severity: Medium]
Does this comment still hold when one family D switch offloads two
bridges with different vlan_filtering settings?

IVL_EN is decided once for the whole switch, not per bridge. In
rtl8365mb_d_want_ivl(), a single filtering user port is enough:

    dsa_switch_for_each_user_port(dp, ds) {
        if (dp->index == port ? filtering :
                    dsa_port_is_vlan_filtering(dp))
            return true;
    }

rtl8365mb_d_vlan_4k_refresh_ivl() then writes that value to every used
VID, including the default PVID VLAN:

    vlan4k.ivl_en = want_ivl;

The comment in rtl8365mb_setup() says a bridge that already has a number
from another switch can still be offloaded here. So a VLAN-aware bridge
and a VLAN-unaware bridge can both be offloaded on this switch.

With configure_vlan_while_not_filtering set, the VLAN-unaware bridge's
ports keep PVID 1. Would the chip then learn them in IVL with VID 1,
while DSA still passes their FDB/MDB entries with VID 0 and this code
writes IVL=0/FID=0?

If so, it looks like the duplicate key problem from the commit message
comes back for static FDB entries, and MDB entries would stop limiting
the flood. How the chip learns on non-filtering ports is a hardware
assumption here.

> +	u16 id = ivl ? uc->key.vid : uc->key.fid;

[Severity: Medium]
IVL is chosen here from the VID alone, not from whether the bridge is
VLAN-aware. Can a VLAN-aware bridge put a static entry into the shared
FID 0 domain this way?

A VLAN-aware bridge still produces VID-0 FDB entries. For example,
"bridge fdb add MAC dev swpX master static" without a vlan argument
makes br_fdb_add() add a VID-0 entry next to the per-VLAN ones. DSA
passes the VID through unchanged, so the path is:

    rtl83xx_port_fdb_add(vid 0)
      -> rtl8365mb_l2_add_uc()
        -> rtl8365mb_d_l2_uc_to_data()

and it writes a static (age 6) entry with IVL=0/FID 0.

The commit message says standalone and software-bridged ports look up
in that same FID 0. Would unicast to MAC arriving on a standalone port
then hit the swpX entry and be dropped by the isolation mask? The entry
is static, so it would never age out.

In VLAN-aware mode the bridge treats VID-0 entries as matching nothing,
so the software FDB and the hardware LUT would disagree. On family C
the same entry was written with IVL=1, VID 0 and EFID separation, so it
did not affect other ports.

The commit message notes that with a VLAN-aware bridge the drop "did not
happen". Does that observation cover only learned entries, not static
VID-0 ones like this?

> +
> +	memset(data, 0, RTL8365MB_D_L2_ENTRY_SIZE * 2);
> +	rtl8365mb_l2_mac_to_data(uc->key.mac_addr, data);
> +	data[3] = FIELD_PREP(RTL8365MB_D_L2_UC_D3_VID_MSK, id) |
> +		  FIELD_PREP(RTL8365MB_D_L2_UC_D3_IVL_MSK, ivl) |
> +		  FIELD_PREP(RTL8365MB_D_L2_UC_D3_PORT_LO_MSK, uc->port & 0x3);

[ ... ]

> +void rtl8365mb_d_l2_mc_to_data(const struct rtl8365mb_l2_mc *mc,
> +			       u16 *data)
> +{
> +	/* Same as for unicast: VID 0 means a VLAN-unaware bridge, use SVL. */
> +	bool ivl = mc->key.ivl && mc->key.vid;

[Severity: Medium]
VID-0 MDB entries end up in the shared FID 0 SVL key, and
rtl8365mb_l2_add_mc() makes them static:

    mc.member |= BIT(port);
    mc.is_static = 1;

Family D has no EFID, since rtl8365mb_port_set_efid() returns 0. It also
does not set fdb_isolation, so standalone ports get no host MDB entries
and share FID 0 with the VLAN-unaware bridge. Normal IGMP/MLD snooping on
the bridge would then install non-aging entries {G -> bridge ports}.

Would multicast for G arriving on a standalone port (for example a WAN
stream used by igmpproxy) hit that entry and go to the bridge ports?
The standalone port's CPU-only isolation mask would then drop it
instead of delivering it to the CPU.

Any LAN host could trigger this just by sending membership reports, and
it would last as long as the membership is refreshed.

The commit message calls the unicast case "bounded by the aging time"
and "a known limitation of the chip", and only says the same "may apply"
to static multicast entries. These entries do not age, and they come
from the choice to offload VID-0 MDB entries into the shared key.

Could family D avoid offloading VID-0 MDB entries instead, for example
by returning -EOPNOTSUPP for them?

> +
> +	memset(data, 0, RTL8365MB_D_L2_ENTRY_SIZE * 2);

[ ... ]

> diff --git a/drivers/net/dsa/realtek/rtl8365mb_main.c b/drivers/net/dsa/realtek/rtl8365mb_main.c
> index b83e39314708f..bfd7e303ca254 100644
> --- a/drivers/net/dsa/realtek/rtl8365mb_main.c
> +++ b/drivers/net/dsa/realtek/rtl8365mb_main.c

[ ... ]

> @@ -3672,9 +3714,19 @@ static int rtl8365mb_setup(struct dsa_switch *ds)
>  		goto out_teardown_irq;
>  
>  	ds->assisted_learning_on_cpu_port = true;
> -	ds->fdb_isolation = true;
> -	/* The EFID is 3 bits, but EFID 0 is reserved for standalone ports */
> -	ds->max_num_bridges = FIELD_MAX(RTL8365MB_EFID_MASK);
> +	if (!rtl8365mb_is_d(priv)) {
> +		ds->fdb_isolation = true;
> +		/* The EFID is 3 bits, but EFID 0 is reserved for standalone */
> +		ds->max_num_bridges = FIELD_MAX(RTL8365MB_EFID_MASK);
> +	} else {
> +		/* No EFID, so bridges cannot be told apart in the LUT: allow
> +		 * at most one offloaded bridge. Bridge numbers are allocated
> +		 * system-wide by DSA, so this does not stop a bridge that
> +		 * already has a number from another switch from being
> +		 * offloaded here as well.
> +		 */
> +		ds->max_num_bridges = 1;

[Severity: Medium]
Can this block bridge offload on this switch completely if another DSA
switch in the system already holds bridge number 1?

For a new bridge, dsa_bridge_num_get() in net/dsa/dsa.c picks the next
free number from one global bitmap:

    bridge_num = find_next_zero_bit(&dsa_fwd_offloading_bridges,
                                    DSA_MAX_NUM_OFFLOADING_BRIDGES,
                                    1);
    if (bridge_num > max)
        return 0;

If bit 1 is taken, for example by a family C rtl8365mb, mv88e6xxx,
felix, sja1105 or a second RTL8367S-VB, this returns 2 or more and is
rejected with max = 1. dsa_port_bridge_create() then fails:

    bridge->num = dsa_bridge_num_get(br, ds->max_num_bridges);
    if (ds->max_num_bridges && !bridge->num) {
        NL_SET_ERR_MSG_MOD(extack,
                           "Range of offloadable bridges exceeded");
        kfree(bridge);
        return -EOPNOTSUPP;
    }

The bridge then falls back to software, even if it would be the only
bridge on this switch.

The comment and commit message cover only the other direction, where
this limit is not an upper bound. Whether offload works here then
depends on the order in which bridges were created on other switches.

Would a driver-side check in port_bridge_join that tracks the single
bridge offloaded on this switch be a better fit? Family D ignores the
EFID, so max_num_bridges could then stay 0.

> +	}
>  
>  	ds->configure_vlan_while_not_filtering = true;
>

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/bc42ae96-dc7e-4b6e-b9cc-64cde5dc51ce%40yahoo.com

  parent reply	other threads:[~2026-11-24  1:24 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bc42ae96-dc7e-4b6e-b9cc-64cde5dc51ce.ref@yahoo.com>
2026-11-19 23:57 ` [PATCH net-next v12 00/13] net: dsa: realtek: rtl8365mb: add support for RTL8367S-VB Mieczyslaw Nalewaj
2026-11-19 23:58   ` [PATCH net-next v12 01/13] dt-bindings: net: dsa: realtek: add RTL8367S-VB Mieczyslaw Nalewaj
2026-11-19 23:59   ` [PATCH net-next v12 02/13] net: dsa: realtek: rtl8365mb: add chip family infrastructure Mieczyslaw Nalewaj
2026-11-20  0:00   ` [PATCH net-next v12 03/13] net: dsa: realtek: rtl8365mb: refactor forcemode handling Mieczyslaw Nalewaj
2026-11-20  0:01   ` [PATCH net-next v12 04/13] net: dsa: realtek: rtl8365mb: set speed for family D Mieczyslaw Nalewaj
2026-11-20  0:02   ` [PATCH net-next v12 05/13] net: dsa: realtek: rtl8365mb: set RGMII mode " Mieczyslaw Nalewaj
2026-11-20  0:03   ` [PATCH net-next v12 06/13] net: dsa: realtek: rtl8365mb: refactor VLAN 4k handling Mieczyslaw Nalewaj
2026-11-20  0:04   ` [PATCH net-next v12 07/13] net: dsa: realtek: rtl8365mb: set and get vlan 4k for family D Mieczyslaw Nalewaj
2026-11-20 14:17     ` Gustavo Foletto Mora
2026-11-21  1:30       ` Mieczyslaw Nalewaj
2026-11-21 18:24         ` Gustavo Foletto Mora
2026-11-24  1:24     ` netdev-bot+sashiko
2026-11-20  0:05   ` [PATCH net-next v12 08/13] net: dsa: realtek: rtl8365mb: refactor PVID handling Mieczyslaw Nalewaj
2026-11-20 14:18     ` Gustavo Foletto Mora
2026-11-20  0:06   ` [PATCH net-next v12 09/13] net: dsa: realtek: rtl8365mb: use raw VID for PVID on family D Mieczyslaw Nalewaj
2026-11-20 14:26     ` Gustavo Foletto Mora
2026-11-24  1:24     ` netdev-bot+sashiko
2026-11-20  0:07   ` [PATCH net-next v12 10/13] net: dsa: realtek: rtl8365mb: add family D SDS13 PCS support Mieczyslaw Nalewaj
2026-11-24  1:24     ` netdev-bot+sashiko
2026-11-20  0:07   ` [PATCH net-next v12 11/13] net: dsa: realtek: rtl8365mb: refactor L2 MAC handling Mieczyslaw Nalewaj
2026-11-20  0:08   ` [PATCH net-next v12 12/13] net: dsa: realtek: rtl8365mb: make L2/LUT access work on family D Mieczyslaw Nalewaj
2026-11-21  9:33     ` Mieczyslaw Nalewaj
2026-11-21 18:26       ` Gustavo Foletto Mora
2026-11-24  1:24     ` netdev-bot+sashiko [this message]
2026-11-20  0:09   ` [PATCH net-next v12 13/13] net: dsa: realtek: rtl8365mb: add support for RTL8367S-VB Mieczyslaw Nalewaj
2026-11-20 20:56     ` Gustavo Foletto Mora
2026-11-21  1:46       ` Mieczyslaw Nalewaj
2026-11-21 18:29         ` Gustavo Foletto Mora
2026-11-23  8:01           ` Oleksij Rempel
2026-11-23 12:47             ` Mieczyslaw Nalewaj
2026-11-24  1:24     ` netdev-bot+sashiko

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=179548348297.3135.11750610960946672439@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=alvin.sipraga@analog.com \
    --cc=andrew@lunn.ch \
    --cc=contact@c127.dev \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=fabianotassotti@gmail.com \
    --cc=gabonpivovich@gmail.com \
    --cc=gusfmora@gmail.com \
    --cc=kuba@kernel.org \
    --cc=kuncy7@gmail.com \
    --cc=linusw@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=luizluca@gmail.com \
    --cc=maxime.chevallier@bootlin.com \
    --cc=namiltd@yahoo.com \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.com \
    --cc=pabeni@redhat.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