🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #27530

Re: [PATCH net-next v20 07/15] net: dsa: realtek: rtl8365mb: add VLAN 4k/IVL for family D

#27530
From: netdev-bot+sashiko
Date: Sat, 05 Dec 2026 22:19
175 lines
14545 bytes
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
Technical Details
Message-ID: <179650918127.3148.1881403400668275590@kernel.org>
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-mo.newsdeef.eu!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-378159-linux-kernel-netdev=dewy.ru
References: <71391a28-8df8-45a8-9705-07f2c5454e85@yahoo.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-mo.newsdeef.eu!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-378159-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
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
Organization: Usenet Network
Message-ID: <179650918127.3148.1881403400668275590@kernel.org>
References: <71391a28-8df8-45a8-9705-07f2c5454e85@yahoo.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3132198"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:gls5N/jv4xuzobY20GN5lspHRb4= sha256:dGP6lM74tMOs8NSa9XRaGcYNVIwj+gIkV1mPWEnwIfg=
	sha1:5C6M7htAXN97eK/Be/ujeIzx9Oo= sha256:c772V8lJPu99v1Qq59U/AzPTk3i77weUB9WEbL3L0Hc=
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 2D36E117EDB; Sun,  6 Dec 2026 01:20:07 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.539
X-Spam-Status: No, score=-3.539 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.14, 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, URIBL_BLOCKED=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 HDADbkfxa2ni;
	Sun,  6 Dec 2026 01:19:59 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-378159-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 sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4])
	by mail.dewy.ru (Postfix) with ESMTPS id 5A28D117ED8; Sun,  6 Dec 2026 01:19:48 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sin.lore.kernel.org (Postfix) with ESMTP id BB6C12920F; Sat,  5 Dec 2026 22:19:44 +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=1796509183;
	b=hbBV17x3FFwMTiOg9fNHNt3roBzykkwvfnKBZGTbApi3FvRD9Z81+OrHcSwfP3//tI8Y
	 Jdpysgtu7cNQicsDaoKZRi9unW3chvN+QNKCBZKR9lK36tu8DJJRl1MlRPv6Yp8cJGLeE
	 U5EwDjQzv8XLWZ79m4FWal0URjxGMssYBIVIgjkIJzvms4Tuci22ng0a8U2i22GJJB1ll
	 M5odyaxJCqfab2ptWXqUQqCzt/DyQ/Rrz+xgN4PAaV7bGRS0QqrY6NtdB/PRdLAhnHCYM
	 5usHnFPzzMZ2MwbF8u2hCF6RZit4RJbllGbTlyvIVDOTVjpAgug15LeMiYVHljwD6ew==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796509183;
	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=9vjvp3Ubj7BzUvmX/wcP+SEm/4Lule5SRIw/keZP6yo=;
	b=wUAejdOAuX1kSphxsPfLMCmUTPRjXrxqtbqvbeRqnmrW9a2rrOCizAdPMvyxRszoLEG8
	 xE7mEX/pU9eYrNZ3zGw6l/QPJso2Yy1cfoIogjHioz/jAYew59oc+XcTlJM8cEIW4/EMm
	 qsW3HCKG6mkHGbAUSfzOMHwdRF1HKJFrYBJWTbH/kXHDvkk2eCyHK4/MARwaP8fIQjquc
	 C4Np+GVSBPS+08L1wEVANyR60LktJurIeR5g+B16SpQyM45d3OFrIclq798IeJgNSVVZz
	 VrJQgliMoy2AebXo847neFecvLsBA5jxQyUptuFkxGMDWPPJDtwAWzIU9Lrj5+R3Eeg==
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=MjCN8CfU;
	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 D1FAE606A33A;
	Sat,  5 Dec 2026 22:19:43 +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=MjCN8CfU
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=1796509183;
	b=OyFjzxm8pSXyccBHASG+hI9wx5sBMCAgxGYgx1BM6fZQGXSYVH/1T7sbydgcnHvWnR9m
	 j4/u3Z7xLchmvJn54AR1u8LoHomck1+N3px26G4EQbeVTd67p/OUmYdpIWJ5nTZrHBNyx
	 FiRwmnj0l26hPwnalz0BQ5T0MgR7TaFpyRxdmc+E5Mc3iccx4jOGJ8ennMqoYARk8Q690
	 DKNDMbWRMY2iZyrjgG3w5KVVCUeczV685zzsZwn04PW+7RsncZ8/P6fPlWlX6BIxe1f5m
	 mOqJMpWG4Q6IRpREycwPr2splfYRDOxuwZ6BXUVzCYGZdqVicQnBjNRInCsETogKnJA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796509183;
	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=9vjvp3Ubj7BzUvmX/wcP+SEm/4Lule5SRIw/keZP6yo=;
	b=gTLFtp8zdDmWsF6bFJHtK12ZX7IABfEakF0G0/uDUwd5/VU/0r61ELjjw7djMAMQZloT
	 Wcs26MYGv2NEFYucBv20pQZy+nR+PNZwEyIr1K4IH/By5dOj1TFbEcDbr6YUao2VC86Fd
	 1VJkfCpQqTHr0PL7xKYaO8Mc2X7ii3FCdDG4xlihypN5/DTX7LwfkvBYYj1hcJnuxSc9l
	 Cf+iZJz7YrWSOltinzn+1BPk3H7uhy7h2E2uPJy4QDPOjERKRVJ9+G+WdjyoAIp9K4YJr
	 xUbAOox2gMaXzi39WLnOeWXskVFFAHCUl+r6rGMrX8yuTN52VNjf+Dfw2HA3CXDkAbQ==
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=MjCN8CfU;
	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 F0C41606A31F;
	Sat,  5 Dec 2026 22:19:42 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id BD21A1F0092B;
	Sat,  5 Dec 2026 22:19:41 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1796509182;
	bh=9vjvp3Ubj7BzUvmX/wcP+SEm/4Lule5SRIw/keZP6yo=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=MjCN8CfUFNcB2UwLEXmypqYkGi3bI8bIUafrqi2fi7OAQdWs7+vnNWQiHtEfJ8Uzv
	 GmlxAHwMzIb1epjklnoQg9kpusE2W0MZMxxAe/x8z5atRMSfkhGzTVRTKv+9w23cL5
	 acporOwHwAQP/ZP/YpruUvi8hNMsu+94VDKbvUhD1uMpLCV1sE3nMa+tpSbEeGNx5R
	 Rqyix6K4iAyKwMX98k54Rf3RE+M3I+R9t81Yv6rgx8vhyBM18M1vpYDfu83uRYkoaA
	 TlNhcjSQFRTt9mP9sjJuUmr2gT69WZDEJ7tT7Buw7W9mlxrM4G9WLesMW93dR6K0M8
	 rrpanrXgr7QhQ==
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: <71391a28-8df8-45a8-9705-07f2c5454e85@yahoo.com>
X-sashiko-severity: Medium
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