🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #24655

Re: [PATCH net-next v16 07/15] net: dsa: realtek: rtl8365mb: set and get VLAN 4k for family D

#24655
From: netdev-bot+sashiko
Date: Mon, 30 Nov 2026 15:12
182 lines
14344 bytes
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
Technical Details
Message-ID: <179605156446.3146.2067251065745661227@kernel.org>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374264-linux-kernel-netdev=dewy.ru
References: <388e3024-0731-4113-a25a-1e739d6a0c39@yahoo.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374264-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
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
Organization: Usenet Network
Message-ID: <179605156446.3146.2067251065745661227@kernel.org>
References: <388e3024-0731-4113-a25a-1e739d6a0c39@yahoo.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1453679"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:qIrLSpqkoYsN+lNcKQJ6kcNh4jU= sha256:CalRa7dTnMYi4MYlshF/7At90GPPOnpUaIlDtvcdK+I=
	sha1:EOALedmlml9Z1xfh4JsuA6p6CBk= sha256:wi0UVifqG0ccZJD9slnRpP9CYMeivDAsa5mdM7Jj5zk=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 56F99125FF1; Mon, 30 Nov 2026 18:13:00 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.501
X-Spam-Status: No, score=-3.501 tagged_above=-9999 required=6.31
	tests=[DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1,
	RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001]
	autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id H-OcCNPDhnip;
	Mon, 30 Nov 2026 18:12:56 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-374264-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
	by mail.dewy.ru (Postfix) with ESMTPS id B1113125FF0; Mon, 30 Nov 2026 18:12:48 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sto.lore.kernel.org (Postfix) with ESMTP id 5110B602545; Mon, 30 Nov 2026 15:12:48 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1796051567;
	b=LGoB/Uth1xSpUcOcRUP40zHrEidb4Dtx08bxhXY23K8SwsuGpBVzw4rouErHWXZ4QHOW
	 ZQN/nBx6A2NE8J5LHOiLOa5SPQhHFATHO5i2JdoC3yiM7GvaVMSRfi+KTSGjbBLscZJyu
	 rIYl/85C0EoLFjkBWF+mPNDbo+yluwwJwxyv5ZZ+OefalFKzV0luFSXkRP58/f9HbXnkg
	 6wf6bNO7Y7XziEdKIQIH9EVhfwJt97p/uSCJfDkg0J5bg9TUv//VvrljWZc6vBl3XBc2q
	 gKutiQiZS7Mmc94HYB9JWykIi6WWZldVghfOcsSpJ1nwRbmhQhWa3ijCO6zSzAJFJmg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796051567;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=JRYUi31wR+P/vOfP920/RFQ+pGiXW1it1lYMWtw5yO8=;
	b=PUE2zl7gI+V+0IlwWESQyjrD6HOE+98/BjBriETZpEA4mbowDecjleSPUcDsuujA9A+I
	 AwORirVunBQxXPg217EqlMejGDn/oVOhEM7kUyhmSfVPlW7WjzR4zKHuVcP6irx3Vs2xC
	 nJZF7xi3yqknXaqvjDZ+OFG93mHK15Z2i+tCQko8MZqo3ATOvW6zRO3w+S+yj153Jka0z
	 TQWUiZLfaQvxKsqbag2Nm1oeASnq7J4+XLFAP4dXu/m/DrZaT5ZNAZNwiuL0V/7Q1LTxS
	 cCJhidFGj4sYGYokuN6XXj0tRzMVIMndsNRn5bAz8tlkv61V4lClZbGNrYX7w0R0Cdg==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=PBW4Fzdl;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 689D5606A32C;
	Mon, 30 Nov 2026 15:12:47 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=PBW4Fzdl
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796051566;
	b=Hdch+eeUqNNeTuH5R13twcBOmihEp0U0E5ktU+qhzU5DPU3kkpCbchGI78chkXdQY/lg
	 /CPvud0pINU3Sj6upnuRfp3OJ6OlMF5llp6vsIXWNF2H3ds34GyuHPtttiS55xA4iczeB
	 Fmhz1q6qTCqJnkWKK1ugaHmXLOUru0cW+6yuP4jeVP5AhWG5tBbj7DC91+/zAu2+PMt4x
	 U5ntrTPiqnj0/4bUO00bdh+SvSTzoPWfTE2fQb2njVlO79PQLZJaHksdl1hj9y3wBG3RD
	 Zoq+f3e/fq5k6JUIe74fz4DRIgrdVEMTdSQjkxM/zmrPlinl3feXeMv6PTwfGylP8JA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796051566;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=JRYUi31wR+P/vOfP920/RFQ+pGiXW1it1lYMWtw5yO8=;
	b=ecUo6wWk/WgRLbiz25jXBb6h7qm1Xl4ak6XzcsvVWZdka2RvnRco2H56CczrizTZhgqc
	 oRyXa5uSx1yOQIG9QWm2ufP7agQT8n0pswv1t9JGkP0LaO+qtCdifC9Hmymis2u+AfEHE
	 lvcbqJjjjO15DmbrYrNUiLQDWTVfDDP7qARnmIvy/6XMQSNTdxTuJ5juN93/DPi5czmXX
	 5NRkQzXN9oAL6NeDgwYKLOguR+dViFPbJtL31EDuVlNQrSJEHFGldyKG1ML6IXz4QtjVR
	 6xRFNgCyzSfah9X2qTjFaCxd5pG+BrxxAikJHDfc/kTogBfbLZX5D9SXCTrnzkNBNaw==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=PBW4Fzdl;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 89458606A685;
	Mon, 30 Nov 2026 15:12:46 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id D6C271F000C1;
	Mon, 30 Nov 2026 15:12:44 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1796051565;
	bh=JRYUi31wR+P/vOfP920/RFQ+pGiXW1it1lYMWtw5yO8=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=PBW4FzdlPASyHgrm8y5sNpuMFYFtM6AOVY1Mm3GgstC+YVceJ31eNu37f7Ko8ODqV
	 rjby5CWm6qq2cjonHmjKuCn71SKIuJICwZV0uRCk2YhZyf0smXTf0T4eaEadke7/EF
	 v2EU8EZlALtlj9GQryBbVojcJAPwcaG1tPxuMn7Kam10rn2vzHNtsImY01AG4O80G9
	 VjedGfB8ilpAHOKXEiSXd3rwysol704XkQEslcW5zIKU4sgbLZSzKQPyYt3jo0G+zE
	 amqufeqqXZnU0B0egTDrkEbiYzZt345E3zDfpMPXjtnEa7q72El2qdYmsvoEd15dkb
	 ai0sCQ5p6Tozw==
X-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
X-In-Reply-To: <388e3024-0731-4113-a25a-1e739d6a0c39@yahoo.com>
X-sashiko-severity: Low
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list