mirror of https://lore.kernel.org/lkml/
 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,
	o.rempel@pengutronix.de
Subject: Re: [PATCH net-next v14 07/15] net: dsa: realtek: rtl8365mb: set and get vlan 4k for family D
Date: Fri, 27 Nov 2026 03:00:21 +0000	[thread overview]
Message-ID: <179574842117.3135.17941638650099220254@kernel.org> (raw)
In-Reply-To: <fe49b828-ee40-4cef-b969-536cc251f811@yahoo.com>

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

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

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 decides IVL once for the whole switch, and that
  decision is applied to every 4K VLAN entry.
- [Medium] When a vlan_filtering change flips the switch-wide IVL state,
  rtl8365mb_port_vlan_filtering() -> rtl8365mb_d_vlan_4k_refresh_ivl()…
- [Medium] rtl8365mb_vlan_4k_port_set() updates the vlan_4k_used bitmap
  only after fi->vlan_4k_write() succeeds.
- [Low] The comment on rtl8365mb_d_want_ivl() says SVL is needed to match
  static FDB/MDB entries programmed with VID 0.

--

net: dsa: realtek: rtl8365mb: set and get vlan 4k for family D

This adds two-word pack/unpack helpers for the family D 4K VLAN table.
On family D, IVL_EN now follows whether any user port is VLAN filtering.
A vlan_4k_used bitmap tracks the VIDs in use, so a vlan_filtering change
that flips the switch-wide state rewrites only the active entries.

> diff --git a/drivers/net/dsa/realtek/rtl8365mb_main.c b/drivers/net/dsa/realtek/rtl8365mb_main.c
> index 687939d6d9d8c..24635feafc67f 100644
> --- a/drivers/net/dsa/realtek/rtl8365mb_main.c
> +++ b/drivers/net/dsa/realtek/rtl8365mb_main.c
> @@ -2303,8 +2303,21 @@ static int rtl8365mb_port_vlan_filtering(struct dsa_switch *ds, int port,
>  	if (ret)
>  		goto undo_set_framefilter;
>  
> +	if (rtl8365mb_is_d(priv)) {
> +		mutex_lock(&priv->vlan_lock);
> +		ret = rtl8365mb_d_vlan_4k_refresh_ivl(ds, port, vlan_filtering);

[Severity: Medium]
When this call flips the switch-wide IVL state, what happens to the dynamic
L2 entries the chip learned under the old mode?

rtl8365mb_port_vlan_filtering()->rtl8365mb_d_vlan_4k_refresh_ivl()->
rtl8365mb_d_vlan_4k_set_ivl() rewrites IVL_EN in the 4K entries. Nothing
flushes the LUT afterwards.

A family D L2 entry stores its own IVL bit and a shared VID/FID field. You
can see this in the unpacker added later in the series:

rtl8365mb_d_l2_data_to_uc() {
    ...
	uc->key.ivl = FIELD_GET(RTL8365MB_D_L2_UC_D3_IVL_MSK, data[3]);
	uc->key.vid = uc->key.ivl ? id : 0;
	uc->key.fid = uc->key.ivl ? 0 : id;
    ...
}

So IVL (VID key) lookups would never hit entries learned in SVL (FID key),
and the reverse is also true. Until those entries age out after 300 s:

  - they take up hash and CAM slots
  - known destinations flood until they are learned again
  - toggling filtering back within the ageing time could make the old
    entries valid again, possibly pointing at outdated ports

The DSA core calls dsa_port_fast_age() only on STP state and learning flag
changes, not on vlan_filtering changes.

Should this path call the driver's existing rtl83xx_port_fast_age() or
l2_flush once the IVL state flips? The final series state behaves the same
way, and the PBFID toggle added later also changes the learning key.

> +		mutex_unlock(&priv->vlan_lock);
> +		if (ret)
> +			goto undo_egress_mode;
> +	}

[ ... ]

> diff --git a/drivers/net/dsa/realtek/rtl8365mb_vlan.c b/drivers/net/dsa/realtek/rtl8365mb_vlan.c
> index 566c6bc1449af..ff6f2baca631c 100644
> --- a/drivers/net/dsa/realtek/rtl8365mb_vlan.c
> +++ b/drivers/net/dsa/realtek/rtl8365mb_vlan.c

[ ... ]

> +/* Family D has no EFID, so a VLAN-unaware bridge must learn in SVL (IVL=0)
> + * to match static FDB/MDB entries programmed with VID 0. Use IVL only while
> + * at least one user port is VLAN-filtering. @port/@filtering override
> + * the state of the port currently being changed, as DSA updates
> + * dp->vlan_filtering only after the driver callback returns.
> + */

[Severity: Low]
This isn't a bug, but at this commit the comment doesn't match the L2 code.
These functions still always program key.ivl = true with the VID and use
the family C L2 layout:

  rtl8365mb_l2_add_uc()
  rtl8365mb_l2_del_uc()
  rtl8365mb_l2_add_mc()
  rtl8365mb_l2_del_mc()

So static entries would not use the SVL key yet.

This is fixed later in the series by "net: dsa: realtek: rtl8365mb: make
L2/LUT access work on family D". There, rtl8365mb_d_l2_uc_to_data() and
rtl8365mb_d_l2_mc_to_data() map VID 0 to the SVL key:

	bool ivl = uc->key.ivl && uc->key.vid;
	u16 id = ivl ? uc->key.vid :
		       (uc->key.fid ? uc->key.fid :
				      RTL8365MB_D_UNAWARE_BRIDGE_FID);

Family D can't be reached until the last patch, so this has no runtime
effect in between. Could the comment be reworded here, or moved to the L2
patch?

> +bool rtl8365mb_d_want_ivl(struct dsa_switch *ds, int port, bool filtering)
> +{
> +	struct dsa_port *dp;
> +
> +	dsa_switch_for_each_user_port(dp, ds) {
> +		if (dp->index == port ? filtering :
> +					dsa_port_is_vlan_filtering(dp))
> +			return true;
> +	}
> +
> +	return false;
> +}

[Severity: Medium]
The comment above says a VLAN-unaware bridge must learn in SVL. This
function returns true as soon as any user port is VLAN filtering, whichever
bridge that port belongs to. Can a VLAN-unaware bridge end up in IVL here?

The result is applied to every entry. rtl8365mb_vlan_4k_port_set() writes:

	vlan4k.ivl_en = vlan4k.member &&
			rtl8365mb_d_want_ivl(ds, -1, false);

and rtl8365mb_d_vlan_4k_set_ivl() rewrites every VID in vlan_4k_used to the
same value.

Suppose one VLAN-aware bridge and one VLAN-unaware bridge are offloaded on
the same switch. The unaware bridge's VLANs (its PVID 1, for example) would
move to IVL. Its learned entries would then be keyed on {MAC, VID}, while
its static and host FDB/MDB entries use the SVL/FID key. Unicast could then
flood, and static MDB filtering might stop applying.

The driver does not set ds->vlan_filtering_is_global, so DSA doesn't reject
mixed VLAN awareness.

Later in the series, "net: dsa: realtek: rtl8365mb: make L2/LUT access work
on family D" sets ds->max_num_bridges = 1 for family D, which narrows this.
That commit also notes that DSA allocates bridge numbers system-wide. A
bridge that already got a number from another switch can still be offloaded
here ("such bridges share FID 1, a known limitation"). In that case two
bridges with different VLAN awareness can still share a family D switch.

The rollback comment in rtl8365mb_d_vlan_4k_set_ivl() also says:

	/* Best effort: restore the entries rewritten so far. IVL_EN is
	 * switch-wide, so before the scan every entry in use had the old

IVL_EN is a per-entry field (RTL8365MB_D_CVLAN_ENTRY_D1_IVL_EN_MASK). Only
the driver's policy for it is switch-wide.

Should family D set ds->vlan_filtering_is_global? If not, could this
limitation be documented in the commit message and in the code?

[ ... ]

> @@ -314,7 +480,15 @@ rtl8365mb_vlan_4k_port_set(struct dsa_switch *ds, int port,
>  		vlan4k.untag |= BIT(port);
>  	else
>  		vlan4k.untag &= ~BIT(port);
> -	vlan4k.ivl_en = true; /* always use Independent VLAN Learning */
> +
> +	if (!rtl8365mb_is_d(priv))
> +		vlan4k.ivl_en = true;
> +	else
> +		/* An emptied entry goes back to its reset state, so that
> +		 * it is not left in IVL after it leaves vlan_4k_used.
> +		 */
> +		vlan4k.ivl_en = vlan4k.member &&
> +				rtl8365mb_d_want_ivl(ds, -1, false);
>  
>  	ret = fi->vlan_4k_write(priv, &vlan4k);
>  	if (ret) {
> @@ -322,6 +496,13 @@ rtl8365mb_vlan_4k_port_set(struct dsa_switch *ds, int port,
>  		return ret;
>  	}
>  
> +	if (rtl8365mb_is_d(priv)) {
> +		if (vlan4k.member)
> +			set_bit(vlan->vid, priv->vlan_4k_used);
> +		else
> +			clear_bit(vlan->vid, priv->vlan_4k_used);
> +	}
> +

[Severity: Medium]
Can vlan_4k_used miss a live entry if fi->vlan_4k_write() returns an error
after the write has actually reached the chip?

rtl8365mb_table_query() writes the data and CTRL registers, then calls
rtl8365mb_table_poll_busy():

	return regmap_read_poll_timeout(priv->map_nolock,
			RTL8365MB_TABLE_STATUS_REG, val,
			!FIELD_GET(RTL8365MB_TABLE_STATUS_BUSY_FLAG_MASK, val),
			10, 10000);

If that final poll times out, or a regmap error happens after the execute
write, the call returns an error even though the chip may have committed
the entry. For a VID getting its first member, rtl8365mb_vlan_4k_port_set()
then returns early and skips set_bit(vid, vlan_4k_used).

The rollback comment in rtl8365mb_d_vlan_4k_set_ivl() already assumes this
can happen ("its write may have reached the chip before the error was
reported").

The bridge treats the failed port_vlan_add as not applied and never sends a
matching delete, so the non-empty 4K entry stays untracked. Later IVL flips
in rtl8365mb_d_vlan_4k_set_ivl() would skip it. That VLAN would stay in the
old learning mode until the same VID is added again on some port.

Would it be safer to set the bit before the write for a newly populated
entry? rtl8365mb_d_vlan_4k_set_ivl() already skips entries with no members.

>  	return 0;
>  }

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/874b29a3-f47f-4bf2-a0f6-2f9fea712f4c%40yahoo.com

  reply	other threads:[~2026-11-27  3:00 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <874b29a3-f47f-4bf2-a0f6-2f9fea712f4c.ref@yahoo.com>
2026-11-24 23:59 ` [PATCH net-next v14 00/15] net: dsa: realtek: rtl8365mb: add support for RTL8367S-VB Mieczyslaw Nalewaj
2026-11-25  0:00   ` [PATCH net-next v14 01/15] dt-bindings: net: dsa: realtek: add RTL8367S-VB Mieczyslaw Nalewaj
2026-11-25  0:01   ` [PATCH net-next v14 02/15] net: dsa: realtek: rtl8365mb: add chip family infrastructure Mieczyslaw Nalewaj
2026-11-27  3:00     ` netdev-bot+sashiko
2026-11-25  0:02   ` [PATCH net-next v14 03/15] net: dsa: realtek: rtl8365mb: refactor forcemode handling Mieczyslaw Nalewaj
2026-11-25  0:03   ` [PATCH net-next v14 04/15] net: dsa: realtek: rtl8365mb: set speed for family D Mieczyslaw Nalewaj
2026-11-25  0:04   ` [PATCH net-next v14 05/15] net: dsa: realtek: rtl8365mb: set RGMII mode " Mieczyslaw Nalewaj
2026-11-25  0:05   ` [PATCH net-next v14 06/15] net: dsa: realtek: rtl8365mb: refactor VLAN 4k handling Mieczyslaw Nalewaj
2026-11-25  0:06   ` [PATCH net-next v14 07/15] net: dsa: realtek: rtl8365mb: set and get vlan 4k for family D Mieczyslaw Nalewaj
2026-11-27  3:00     ` netdev-bot+sashiko [this message]
2026-11-25  0:07   ` [PATCH net-next v14 08/15] net: dsa: realtek: rtl8365mb: refactor PVID handling Mieczyslaw Nalewaj
2026-11-25  0:08   ` [PATCH net-next v14 09/15] net: dsa: realtek: rtl8365mb: use raw VID for PVID on family D Mieczyslaw Nalewaj
2026-11-25  0:09   ` [PATCH net-next v14 10/15] net: dsa: realtek: rtl8365mb: add family D SDS13 PCS support Mieczyslaw Nalewaj
2026-11-27  3:00     ` netdev-bot+sashiko
2026-11-25  0:10   ` [PATCH net-next v14 11/15] net: dsa: realtek: rtl8365mb: refactor L2 MAC handling Mieczyslaw Nalewaj
2026-11-25  0:11   ` [PATCH net-next v14 12/15] net: dsa: realtek: rtl8365mb: make L2/LUT access work on family D Mieczyslaw Nalewaj
2026-11-27  3:00     ` netdev-bot+sashiko
2026-11-25  0:12   ` [PATCH net-next v14 13/15] net: dsa: realtek: rtl8365mb: refactor QoS priority handling Mieczyslaw Nalewaj
2026-11-27  3:00     ` netdev-bot+sashiko
2026-11-25  0:13   ` [PATCH net-next v14 14/15] net: dsa: realtek: rtl8365mb: use PCP numbering on family D Mieczyslaw Nalewaj
2026-11-27  3:00     ` netdev-bot+sashiko
2026-11-25  0:14   ` [PATCH net-next v14 15/15] net: dsa: realtek: rtl8365mb: add support for RTL8367S-VB Mieczyslaw Nalewaj
2026-11-27  3:00     ` 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=179574842117.3135.17941638650099220254@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=o.rempel@pengutronix.de \
    --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

all inboxes | Powered by JetHome®