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,
	o.rempel@pengutronix.de
Subject: Re: [PATCH net-next v16 07/15] net: dsa: realtek: rtl8365mb: set and get VLAN 4k for family D
Date: Mon, 30 Nov 2026 15:12:44 +0000	[thread overview]
Message-ID: <179605156446.3146.2067251065745661227@kernel.org> (raw)
In-Reply-To: <388e3024-0731-4113-a25a-1e739d6a0c39@yahoo.com>

Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] In rtl8365mb_d_vlan_4k_set_ivl()
  (drivers/net/dsa/realtek/rtl8365mb_vlan.c), nothing guarantees the LUT…
- [Low] The comment above rtl8365mb_d_want_ivl()
  (drivers/net/dsa/realtek/rtl8365mb_vlan.c) says "@port/@filtering…

--

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

This adds two-word CVLAN pack/unpack helpers for family D. It also makes
IVL_EN follow a switch-wide policy: IVL while any user port is VLAN
filtering, SVL otherwise. When a vlan_filtering change flips that policy,
IVL_EN is rewritten on the entries tracked in the new vlan_4k_used bitmap,
and the dynamically learned L2 entries are then flushed on all user ports.

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

[ ... ]

> @@ -277,6 +325,131 @@ int rtl8365mb_c_vlan_4k_write(struct realtek_priv *priv,
>  				     data, ARRAY_SIZE(data));
>  }
>  

[ ... ]

> +/* Family D has no EFID. Use IVL while at least one user port is VLAN
> + * filtering and SVL otherwise. The family D L2 helpers added later in the
> + * series use the matching key for static FDB/MDB entries. @port/@filtering
> + * override the state of the port currently being changed, as DSA updates
> + * dp->vlan_filtering only after the driver callback returns. The result is

[Severity: Low]
Does this describe the DSA ordering correctly for every call of
.port_vlan_filtering?

In dsa_port_vlan_filtering(), the restore path calls the driver a second
time after dp->vlan_filtering already holds the new value:

net/dsa/port.c:dsa_port_vlan_filtering() {
    ...
	} else {
		dp->vlan_filtering = vlan_filtering;

		err = dsa_user_manage_vlan_filtering(dp->user,
						     vlan_filtering);
		if (err)
			goto restore;
	}
    ...
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 code still seems to work in that case.
rtl8365mb_d_vlan_4k_refresh_ivl() reads the current state through
rtl8365mb_d_want_ivl(ds, -1, false). That value comes from the
already-updated dp->vlan_filtering, so it matches what the forward call
left in hardware.

This only works because the ordering is the reverse of what the comment
says. Could the comment be corrected so that later changes do not rely on
it? One example would be caching the IVL state in the driver.

The later commit "net: dsa: realtek: rtl8365mb: make L2/LUT access work
on family D" repeats the same claim in the undo_refresh_ivl comment in
rtl8365mb_port_vlan_filtering():

    DSA updates dp->vlan_filtering only after this callback
    returns, so old_ivl is the state before the change.

In the DSA restore call, old_ivl is the state left by the forward call.
It is not the state from before the original change.

> + * switch-wide: a VLAN-unaware bridge that shares the switch with a
> + * VLAN-aware one also gets IVL (known limitation).
> + */

[ ... ]

> +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);
> +
> +	return 0;

[Severity: Low]
Can a failed flush go unnoticed here? The commit message says:

    After a successful switch-wide IVL_EN change, flush the dynamically
    learned L2 entries on every user port, so that none learned with the
    previous SVL/IVL key remains ... Such entries must not occupy LUT
    slots or become visible again after a later toggle.

rtl83xx_port_fast_age() returns void. When l2_flush fails, it only logs
the error:

drivers/net/dsa/realtek/rtl83xx.c:rtl83xx_port_fast_age() {
    ...
	ret = priv->ops->l2_flush(priv, port, 0);
	mutex_unlock(&priv->l2_lock);
	if (ret)
		dev_err(priv->dev, "failed to fast age on port %d: %d\n", port,
			ret);
}

rtl8365mb_l2_flush() can fail on a regmap write or on a busy-poll
timeout. In that case rtl8365mb_d_vlan_4k_set_ivl() still returns 0, and
rtl8365mb_port_vlan_filtering() reports success. The dynamic entries
learned under the old key then stay in the LUT until hardware aging
removes them.

> +
> +rollback:
> +	/* Best effort: restore the entries rewritten so far. 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))
> +			continue;
> +		if (!vlan4k.member || vlan4k.ivl_en != want_ivl)
> +			continue;
> +		vlan4k.ivl_en = !want_ivl;
> +		fi->vlan_4k_write(priv, &vlan4k);
> +	}
> +	return ret;

The rollback path has a similar gap. It returns IVL_EN to !want_ivl on
the VIDs that were already rewritten, but it never flushes. Entries the
chip learned under the temporary want_ivl key on those VLANs would stay
in the LUT.

Should this path also flush the user ports? And should a flush failure
be returned to the caller rather than only logged?

The outer undo_refresh_ivl path added in "net: dsa: realtek: rtl8365mb:
make L2/LUT access work on family D" calls set_ivl() again. That does not
cover the internal rollback here or a failed flush.

> +}

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/aebcc7f6-d5f8-4157-b63a-e2e707d9859b%40yahoo.com

  parent reply	other threads:[~2026-11-30 15:12 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <aebcc7f6-d5f8-4157-b63a-e2e707d9859b.ref@yahoo.com>
2026-11-29 15:02 ` [PATCH net-next v16 00/15] net: dsa: realtek: rtl8365mb: add support for RTL8367S-VB Mieczyslaw Nalewaj
2026-11-29 15:06   ` [PATCH net-next v16 01/15] dt-bindings: net: dsa: realtek: add RTL8367S-VB Mieczyslaw Nalewaj
2026-11-29 15:06   ` [PATCH net-next v16 02/15] net: dsa: realtek: rtl8365mb: add chip family infrastructure Mieczyslaw Nalewaj
2026-11-29 15:06   ` [PATCH net-next v16 03/15] net: dsa: realtek: rtl8365mb: refactor forcemode handling Mieczyslaw Nalewaj
2026-11-29 15:07   ` [PATCH net-next v16 04/15] net: dsa: realtek: rtl8365mb: set speed for family D Mieczyslaw Nalewaj
2026-11-29 15:07   ` [PATCH net-next v16 05/15] net: dsa: realtek: rtl8365mb: set RGMII mode " Mieczyslaw Nalewaj
2026-11-29 22:47     ` Linus Walleij
2026-11-30 15:12     ` netdev-bot+sashiko
2026-11-29 15:07   ` [PATCH net-next v16 06/15] net: dsa: realtek: rtl8365mb: refactor VLAN 4k handling Mieczyslaw Nalewaj
2026-11-29 15:07   ` [PATCH net-next v16 07/15] net: dsa: realtek: rtl8365mb: set and get VLAN 4k for family D Mieczyslaw Nalewaj
2026-11-29 22:48     ` Linus Walleij
2026-11-30 15:12     ` netdev-bot+sashiko [this message]
2026-11-29 15:07   ` [PATCH net-next v16 08/15] net: dsa: realtek: rtl8365mb: refactor PVID handling Mieczyslaw Nalewaj
2026-11-29 15:11   ` [PATCH net-next v16 09/15] net: dsa: realtek: rtl8365mb: use raw VID for PVID on family D Mieczyslaw Nalewaj
2026-11-29 15:11   ` [PATCH net-next v16 10/15] net: dsa: realtek: rtl8365mb: add family D SDS13 PCS support Mieczyslaw Nalewaj
2026-11-30 15:12     ` netdev-bot+sashiko
2026-11-29 15:11   ` [PATCH net-next v16 11/15] net: dsa: realtek: rtl8365mb: refactor L2 MAC handling Mieczyslaw Nalewaj
2026-11-29 15:11   ` [PATCH net-next v16 12/15] net: dsa: realtek: rtl8365mb: make L2/LUT access work on family D Mieczyslaw Nalewaj
2026-11-30 15:12     ` netdev-bot+sashiko
2026-11-29 15:12   ` [PATCH net-next v16 13/15] net: dsa: realtek: rtl8365mb: refactor QoS priority handling Mieczyslaw Nalewaj
2026-11-29 22:51     ` Linus Walleij
2026-11-29 15:12   ` [PATCH net-next v16 14/15] net: dsa: realtek: rtl8365mb: use PCP numbering on family D Mieczyslaw Nalewaj
2026-11-29 22:52     ` Linus Walleij
2026-11-30 15:12     ` netdev-bot+sashiko
2026-11-29 15:12   ` [PATCH net-next v16 15/15] net: dsa: realtek: rtl8365mb: add support for RTL8367S-VB 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=179605156446.3146.2067251065745661227@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