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 v20 07/15] net: dsa: realtek: rtl8365mb: add VLAN 4k/IVL for family D
Date: Sat, 05 Dec 2026 22:19:41 +0000 [thread overview]
Message-ID: <179650918127.3148.1881403400668275590@kernel.org> (raw)
In-Reply-To: <71391a28-8df8-45a8-9705-07f2c5454e85@yahoo.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · 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] On family D the driver infers the switch-wide IVL state
actually programmed in the 4K table from software flags:…
- [Low] Concern: after the switch-wide IVL_EN flip in
rtl8365mb_d_vlan_4k_set_ivl(), only dynamic entries are flushed…
--
net: dsa: realtek: rtl8365mb: add VLAN 4k/IVL for family D
This adds two-word CVLAN pack/unpack helpers for the family D chips. It
also makes IVL_EN in the 4K VLAN table follow a switch-wide policy: IVL
while any user port is VLAN filtering, SVL otherwise. A vlan_filtering
change that flips the policy rewrites IVL_EN on the VIDs tracked in a new
vlan_4k_used bitmap, then flushes dynamic L2 entries on all user ports.
> diff --git a/drivers/net/dsa/realtek/rtl8365mb_vlan.c b/drivers/net/dsa/realtek/rtl8365mb_vlan.c
> index 566c6bc1449af..ca2815bc42bbd 100644
> --- a/drivers/net/dsa/realtek/rtl8365mb_vlan.c
> +++ b/drivers/net/dsa/realtek/rtl8365mb_vlan.c
[ ... ]
> +/* Set IVL_EN of every 4K entry in use to @want_ivl. Callers must use it only
> + * for a change of the switch-wide state (see
> + * rtl8365mb_d_vlan_4k_refresh_ivl()), so that every entry in use holds
> + * !@want_ivl on entry. Must be called with &priv->vlan_lock held.
> + */
> +static int rtl8365mb_d_vlan_4k_set_ivl(struct dsa_switch *ds, bool want_ivl)
> +{
[ ... ]
> + for_each_set_bit(vid, priv->vlan_4k_used, VLAN_N_VID) {
> + ret = fi->vlan_4k_read(priv, vid, &vlan4k);
> + if (ret)
> + goto rollback;
> + if (!vlan4k.member || vlan4k.ivl_en == want_ivl)
> + continue;
> +
> + vlan4k.ivl_en = want_ivl;
> + ret = fi->vlan_4k_write(priv, &vlan4k);
> + if (ret)
> + goto rollback;
> + }
> +
> + dsa_switch_for_each_user_port(dp, ds)
> + rtl83xx_port_fast_age(ds, dp->index);
[Severity: Low]
This isn't a bug, but rtl83xx_port_fast_age() goes through
rtl8365mb_l2_flush(), which only removes dynamic entries
(RTL8365MB_L2_FLUSH_CTRL2_TYPE_DYNAMIC). Static FDB/MDB entries survive
the IVL_EN flip.
In the family D L2 helpers later in the series, the static key comes from
the VID and not from the switch-wide policy:
rtl8365mb_d_l2_uc_to_data() {
...
bool ivl = uc->key.ivl && uc->key.vid;
...
}
So VID 0 entries stay SVL with FID 1, VID N entries stay IVL, and this
matches the software bridge lookup across a toggle.
Someone reading this code could take it for a missing static flush.
Could a short comment here say that static entries are kept on purpose?
> +
> + return 0;
> +
> +rollback:
> + /* Best effort: restore IVL_EN on the entries rewritten so far (without
> + * flushing L2 entries). IVL_EN is switch-wide, so before the scan
> + * every entry in use had the old value (!want_ivl) and every entry
> + * below @failed that now has want_ivl was rewritten above. The entry
> + * that failed is included: its write may have reached the chip before
> + * the error was reported.
> + */
> + failed = vid + 1;
> + for_each_set_bit(vid, priv->vlan_4k_used, failed) {
> + if (fi->vlan_4k_read(priv, vid, &vlan4k)) {
> + dev_warn(priv->dev, "VID %u: IVL_EN rollback read failed\n",
> + vid);
> + continue;
> + }
> + if (!vlan4k.member || vlan4k.ivl_en != want_ivl)
> + continue;
> + vlan4k.ivl_en = !want_ivl;
> + if (fi->vlan_4k_write(priv, &vlan4k))
> + dev_warn(priv->dev, "VID %u: IVL_EN rollback failed\n",
> + vid);
> + }
> + return ret;
> +}
> +
> +/* Must be called with &priv->vlan_lock held. */
> +int rtl8365mb_d_vlan_4k_refresh_ivl(struct dsa_switch *ds, int port,
> + bool filtering)
> +{
> + bool want_ivl = rtl8365mb_d_want_ivl(ds, port, filtering);
> +
> + /* The scan visits every entry in use, so do it only if this
> + * change flips the switch-wide state, not for each port of a bridge.
> + */
> + if (want_ivl == rtl8365mb_d_want_ivl(ds, -1, false))
> + return 0;
[Severity: Medium]
Can the IVL_EN state in the 4K table drift away from what
rtl8365mb_d_want_ivl(ds, -1, false) reports here?
The current state is derived from dsa_port_is_vlan_filtering() on each
user port. It is not taken from what was actually written to the table.
dsa_port_vlan_filtering() in net/dsa/port.c can succeed in
port_vlan_filtering(new), which flips all used entries, and then fail in
dsa_user_manage_vlan_filtering(). When that happens it does:
restore:
ds->ops->port_vlan_filtering(ds, dp->index, old_vlan_filtering, NULL);
if (ds->vlan_filtering_is_global)
ds->vlan_filtering = old_vlan_filtering;
else
dp->vlan_filtering = old_vlan_filtering;
The return value of the restore call is ignored. The restore call can
fail in two ways:
- rtl8365mb_port_vlan_filtering(old) fails before it reaches
rtl8365mb_d_vlan_4k_refresh_ivl(), for example on the framefilter,
PVID or egress mode register accesses.
- set_ivl(old) fails part way and its rollback puts the entries back to
the new value.
In both cases the table keeps the new IVL_EN while dp->vlan_filtering
goes back to the old value.
The rollback loop above can also leave single entries at want_ivl when
one of its reads or writes fails. It only warns in that case.
After that, rtl8365mb_vlan_4k_port_set() writes new and changed entries
with:
vlan4k.ivl_en = vlan4k.member &&
rtl8365mb_d_want_ivl(ds, -1, false);
Wouldn't the table then hold a mix of SVL and IVL entries? For some
VLANs, the key the chip learns with would no longer match the VID-derived
static FDB/MDB key that the family D L2 helpers use.
The invariant in the rtl8365mb_d_vlan_4k_set_ivl() comment, "every entry
in use holds !@want_ivl on entry", would also stop holding. The table
seems to recover only after a later successful toggle in the same
direction flips the remaining entries.
Would it make sense to record the IVL_EN state that was last programmed
successfully, and compare against that instead?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/9efcb80a-517c-4413-8261-4f9380e0eb83%40yahoo.com
next prev parent reply other threads:[~2026-12-05 22:19 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <9efcb80a-517c-4413-8261-4f9380e0eb83.ref@yahoo.com>
2026-12-04 22:01 ` [PATCH net-next v20 00/15] net: dsa: realtek: rtl8365mb: add support for RTL8367S-VB Mieczyslaw Nalewaj
2026-12-04 22:03 ` [PATCH net-next v20 01/15] dt-bindings: net: dsa: realtek: add RTL8367S-VB Mieczyslaw Nalewaj
2026-12-04 22:03 ` [PATCH net-next v20 02/15] net: dsa: realtek: rtl8365mb: add chip family infrastructure Mieczyslaw Nalewaj
2026-12-04 22:04 ` [PATCH net-next v20 03/15] net: dsa: realtek: rtl8365mb: refactor forcemode handling Mieczyslaw Nalewaj
2026-12-04 22:04 ` [PATCH net-next v20 04/15] net: dsa: realtek: rtl8365mb: set speed for family D Mieczyslaw Nalewaj
2026-12-04 22:04 ` [PATCH net-next v20 05/15] net: dsa: realtek: rtl8365mb: set RGMII mode " Mieczyslaw Nalewaj
2026-12-04 22:04 ` [PATCH net-next v20 06/15] net: dsa: realtek: rtl8365mb: refactor VLAN 4k handling Mieczyslaw Nalewaj
2026-12-04 22:04 ` [PATCH net-next v20 07/15] net: dsa: realtek: rtl8365mb: add VLAN 4k/IVL for family D Mieczyslaw Nalewaj
2026-12-05 22:19 ` netdev-bot+sashiko [this message]
2026-12-04 22:06 ` [PATCH net-next v20 08/15] net: dsa: realtek: rtl8365mb: refactor PVID handling Mieczyslaw Nalewaj
2026-12-04 22:07 ` [PATCH net-next v20 09/15] net: dsa: realtek: rtl8365mb: use raw VID for PVID on family D Mieczyslaw Nalewaj
2026-12-05 22:19 ` netdev-bot+sashiko
2026-12-04 22:07 ` [PATCH net-next v20 10/15] net: dsa: realtek: rtl8365mb: add family D SDS13 PCS support Mieczyslaw Nalewaj
2026-12-04 22:07 ` [PATCH net-next v20 11/15] net: dsa: realtek: rtl8365mb: refactor L2 MAC handling Mieczyslaw Nalewaj
2026-12-04 22:07 ` [PATCH net-next v20 13/15] net: dsa: realtek: rtl8365mb: refactor QoS priority handling Mieczyslaw Nalewaj
2026-12-04 22:07 ` [PATCH net-next v20 12/15] net: dsa: realtek: rtl8365mb: make L2/LUT access work on family D Mieczyslaw Nalewaj
2026-12-05 22:19 ` netdev-bot+sashiko
2026-12-04 22:07 ` [PATCH net-next v20 15/15] net: dsa: realtek: rtl8365mb: add support for RTL8367S-VB Mieczyslaw Nalewaj
2026-12-04 22:08 ` [PATCH net-next v20 14/15] net: dsa: realtek: rtl8365mb: use PCP numbering on family D Mieczyslaw Nalewaj
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=179650918127.3148.1881403400668275590@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