🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #25472

Re: [PATCH net-next v17 12/15] net: dsa: realtek: rtl8365mb: make L2/LUT access work on family D

#25472
From: netdev-bot+sashiko
Date: Tue, 01 Dec 2026 21:22
209 lines
15956 bytes
Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 2 · 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, rtl8365mb_port_set_efid() changes
  mb->bridge_ports only at the out_update_bridge label, after all…
- [Medium] net: dsa: realtek: stale vlan_filtering check in
  rtl8365mb_port_set_efid()
- [Low] In rtl8365mb_setup() (drivers/net/dsa/realtek/rtl8365mb_main.c),
  the family D comment next to `ds->max_num_bridges = 1` says that "a…

--

net: dsa: realtek: rtl8365mb: make L2/LUT access work on family D

This commit teaches the rtl8365mb table and L2 code about the family D
(RTL8367S-VB) LUT layout, table access field widths and the missing EFID.
On family D it uses port-based FID 1 for an offloaded VLAN-unaware bridge,
enables the lookup-hit isolation fallback and sets max_num_bridges to 1.
rtl8365mb_port_set_efid() now tracks the active bridge number and port
count.

Closes: https://github.com/openwrt/openwrt/pull/19644#issuecomment-6708118180

> diff --git a/drivers/net/dsa/realtek/rtl8365mb_main.c b/drivers/net/dsa/realtek/rtl8365mb_main.c
> index f860f36df7147..05e0d5803b58a 100644
> --- a/drivers/net/dsa/realtek/rtl8365mb_main.c
> +++ b/drivers/net/dsa/realtek/rtl8365mb_main.c

[ ... ]

> @@ -2742,6 +2828,69 @@ static int rtl8365mb_port_pre_bridge_flags(struct dsa_switch *ds, int port,
>  static int rtl8365mb_port_set_efid(struct realtek_priv *priv, int port,
>  				   u32 efid)
>  {

[ ... ]

> +	if (rtl8365mb_is_d(priv)) {
> +		struct dsa_port *dp = dsa_to_port(&priv->ds, port);
> +		struct rtl8365mb *mb = priv->chip_data;
> +		bool enable;
> +		u8 fid;
> +		int ret;
> +
> +		if (efid && mb->bridge_ports && mb->bridge_num != efid)
> +			return -EOPNOTSUPP;

[ ... ]

> +		ret = regmap_update_bits(priv->map,
> +					 RTL8365MB_D_PORT_PBFIDEN_REG,
> +					 BIT(port), 0);
> +		if (ret)
> +			return ret;
> +
> +		ret = regmap_update_bits(priv->map,
> +					 RTL8365MB_D_PORT_PBFID_REG(port),
> +					 RTL8365MB_D_PORT_PBFID_MASK, 0);
> +		if (ret)
> +			return ret;
> +
> +out_update_bridge:
> +		if (efid) {
> +			mb->bridge_num = efid;
> +			mb->bridge_ports++;
> +		} else if (mb->bridge_ports) {
> +			mb->bridge_ports--;
> +		}

[Severity: Medium]
Is dp->vlan_filtering already up to date when this runs on bridge
join?

rtl8365mb_port_set_efid() is only called with a non-zero efid from
rtl83xx_port_bridge_join(), which runs from DSA_NOTIFIER_BRIDGE_JOIN
in dsa_port_bridge_join(). DSA syncs the bridge's VLAN awareness
later, in dsa_port_switchdev_sync_attrs(), which runs after
switchdev_bridge_port_offload().

This driver sets neither needs_standalone_vlan_filtering nor
vlan_filtering_is_global. A standalone port therefore always arrives
here with dp->vlan_filtering false.

So when a port joins a VLAN-aware bridge, enable is still computed as
true. PBFID is set to 1 and PBFIDEN is enabled, and
rtl83xx_port_bridge_join() then enables learning on the port. Until
rtl8365mb_port_vlan_filtering() is called with vlan_filtering true
and clears PBFIDEN again, the port learns in SVL (IVL=0, FID 1).

If another port of this switch is already in a VLAN-aware bridge,
rtl8365mb_d_vlan_4k_refresh_ivl() sees no change in the switch-wide
IVL state and does nothing. Nothing else flushes the entries learned
in that window either. They stay in the LUT as FID 1 SVL entries
until they age out, although the port now does IVL lookups.

Could the decision here use the bridge device instead? For example,
br_vlan_enabled(dsa_port_bridge_dev_get(dp)) could work, since
dp->bridge is already set when the join notifier runs.

Alternatively, should the port's dynamic entries be fast-aged when
rtl8365mb_port_vlan_filtering() turns port-based FID off?

[Severity: Medium]
Can mb->bridge_ports stay too high forever here? If either
regmap_update_bits() in the efid == 0 path fails, the function returns
before it reaches out_update_bridge, so the count is never decremented.

Neither efid == 0 caller retries. rtl83xx_port_bridge_leave() only logs
the error:

	ret = priv->ops->port_set_efid(priv, port, 0);
	if (ret)
		dev_err(priv->dev,
			"failed to clear EFID on port %d: %pe\n",
			port, ERR_PTR(ret));

By that point, dsa_port_bridge_leave() has already cleared dp->bridge
through dsa_port_bridge_destroy(), and it only logs the notifier error.

The undo_efid rollback in rtl83xx_port_bridge_join() ignores the return
value:

undo_efid:
	if (priv->ops->port_set_efid)
		priv->ops->port_set_efid(priv, port, 0);

DSA does not send DSA_NOTIFIER_BRIDGE_LEAVE after a failed BRIDGE_JOIN, so
this undo is the only chance to lower the count.

After a single failed write, bridge_num keeps its old value and
bridge_ports stays non-zero, even when no port is in that bridge any more.
Any later bridge with a different number then hits:

	if (efid && mb->bridge_ports && mb->bridge_num != efid)
		return -EOPNOTSUPP;

That bridge is then software-forwarded until the driver is rebound.

If the PBFIDEN write succeeds and the PBFID write fails, the port is
already standalone in hardware but is still counted as a bridge member.

bridge_ports is a plain u8 counter, not a per-port mask, so later calls
cannot detect or correct the imbalance. Would a per-port bitmask of bridge
members avoid this? The same code is still there at the end of the series.

> +
> +		return 0;
> +	}

[ ... ]

> @@ -3711,9 +3907,23 @@ static int rtl8365mb_setup(struct dsa_switch *ds)
>  		goto out_teardown_irq;
>  
>  	ds->assisted_learning_on_cpu_port = true;
> -	ds->fdb_isolation = true;
> -	/* The EFID is 3 bits, but EFID 0 is reserved for standalone ports */
> -	ds->max_num_bridges = FIELD_MAX(RTL8365MB_EFID_MASK);
> +	if (!rtl8365mb_is_d(priv)) {
> +		ds->fdb_isolation = true;
> +		/* The EFID is 3 bits, but EFID 0 is reserved for standalone */
> +		ds->max_num_bridges = FIELD_MAX(RTL8365MB_EFID_MASK);
> +	} else {
> +		/* No EFID; FID 0 is used by standalone ports and FID 1 by the
> +		 * offloaded VLAN-unaware bridge via port-based FID, so allow
> +		 * at most one offloaded bridge. The bridge number it gets is
> +		 * what rtl8365mb_port_set_efid() takes as "offloaded" to
> +		 * enable port-based FID, so max_num_bridges must not be 0.
> +		 * Bridge numbers are allocated system-wide by DSA, so a bridge
> +		 * that already has a number from another switch is rejected
> +		 * with -EOPNOTSUPP in rtl8365mb_port_set_efid() and remains
> +		 * software-forwarded.
> +		 */

[Severity: Low]
This isn't a bug, but does this comment match the code?
rtl8365mb_port_set_efid() only rejects a bridge number when a different
bridge is already offloaded on this switch:

	if (efid && mb->bridge_ports && mb->bridge_num != efid)
		return -EOPNOTSUPP;

When dsa_bridge_num_get() in net/dsa/dsa.c finds a number in another tree
through dsa_bridge_num_find(), it returns that number without comparing it
to max. Only newly allocated numbers are checked with
"if (bridge_num > max)".

So a cross-tree bridge that already has a number in 2..N is accepted and
offloaded with FID 1 when it is the first bridge on this switch.

The comment in rtl8365mb_port_set_efid() and the commit message ("returns
-EOPNOTSUPP for any different bridge number") match the code. Only this
comment in rtl8365mb_setup() says such bridges are always rejected. The
comment is unchanged at the end of the series.

> +		ds->max_num_bridges = 1;
> +	}

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/236d002f-5ca5-4f12-bf5b-0ed6442e5c9a%40yahoo.com
Technical Details
Message-ID: <179616013922.3146.10969022930919746599@kernel.org>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.endofthelinebbs.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-375361-linux-kernel-netdev=dewy.ru
References: <6e1e7c6b-383d-48fa-ad72-b69ce9620f76@yahoo.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.endofthelinebbs.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-375361-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v17 12/15] net: dsa: realtek: rtl8365mb: make
 L2/LUT access work on family D
Date: Tue, 01 Dec 2026 21:22:19 +0000
Organization: Usenet Network
Message-ID: <179616013922.3146.10969022930919746599@kernel.org>
References: <6e1e7c6b-383d-48fa-ad72-b69ce9620f76@yahoo.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1822313"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:YyzteX1M3AHbqfjCxbpSpWZy5a4= sha256:NxZCzgUsfAFKXnvmVj6qICp63uC9bpd+f0hk1fleuzs=
	sha1:QVY1X9x/lyZbbVxUnVbYwTRpEAo= sha256:VIQ4hUdwtm+2wCBZHyfXZ86TnhE3Bk43Y5j7gKxFatY=
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 BDBA51174A5; Wed,  2 Dec 2026 00:22:59 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.5
X-Spam-Status: No, score=-3.5 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,
	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 8F6jxb4jIesI;
	Wed,  2 Dec 2026 00:22:56 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-375361-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 tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id C59DB1174AA; Wed,  2 Dec 2026 00:22:47 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id 3DCA727D0C; Tue,  1 Dec 2026 21:22:42 +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=1796160146;
	b=L2r7UrIQkiNlVww7yjwuoMmpvtRNoAWcC5UiTvjFT5kHxYQUBzQMw+aiw0I0eK9jSiPr
	 gpvXWOxc26lWmGNX7iNEHOstx3RxMOJyl4c/gU4raCrNy18Ff0I3EHwFo8jrCWEp/dfBo
	 JoO3cMoy3//1WovjwEB9r0+uQNKrlm3drXrC+jRA+QJpraKew1qD8bPcjgv9rYP+Tv7t7
	 /1g6G2ZGW0iqt8Twbmpqw4Zm86/mObYd1l+X10F5Nmp7hA4uWg02xUwdR4hjARkEci+rJ
	 v+TlFTuRaVmtx5LMcUTIqg6Be8Vg6cu4PYRka0/3JRVikyLF0DnY7n98bdhhctOLkzQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796160146;
	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=7f4iaZ+PPXUISIo5+vV3/rO6o0jGoC/5UbQ+uV8MHPc=;
	b=R881Zw/lZbELNTidbWeLXLnkeey2tFd3F7Yevq2rQn3wJkmfCh3hY9McNQcerjphBsuB
	 aOv7t4naDL/Uer41960DPqM9MHYY5aAqOv3+An+SKWOG3MJaEaPstdItVkzDCqQzVn7sg
	 mdvxjDWidbqXysLuUxTw1RpAHRKNExz8i8xTTtnWbPzbF17Uzdoggyo6GSh6a6hiEQ9gq
	 vmq/3TFaE74ihGe14LJk3NCtR8TryGl5iKjOC21Et9ts8TofnayHk6L20TrGthL+jQTQU
	 ir8TNp8asNnM6RU7fQVNcpEgHyi1QHfXhgNG9VQ4XMMLcHQApi+7TtkFzp83Ob4uT2A==
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=feZOnMqA;
	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 D13A4606A329;
	Tue,  1 Dec 2026 21:22:26 +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=feZOnMqA
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=1796160141;
	b=0nqV7PYeazVNSihdwDaWgfLC6BwLdQ9RGf5+hnOSYmDBKkSDTI+KgJSBUEHJ5atK7pqi
	 58hTa3TwndtAZ48nKPL3FEFgN3FInU0qv/TfESYR80OXzxSpi028G1SS2gxTIzuJd1m45
	 SGgjDIO1OqT9MJIPY2unR/zjNRcYCstn+q2U4WBE/6uTcQb3mOxJNaC7x/h2baws2Z2j6
	 LwDrtBQgcPUezd50oTaM43VV2zdqiP92imd1LvwHF0BMGBxate39dNQFtYToZ5pATy3W3
	 DWOzUQa+2YzFLp48+ntZkd9qh2U3BXAtgMigzARO8nmDyAxWDUFbcFKqpYX7QdXd0Ig==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796160141;
	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=7f4iaZ+PPXUISIo5+vV3/rO6o0jGoC/5UbQ+uV8MHPc=;
	b=0qHqxQDuKxHpCyfJOaeJL2mc3dgnO+l+oMLRhnM5SQoo9EhWypjmb25LxfufRh6H96Zd
	 VDbl4/b6pTlJk9aAZAgKactkn6sXltYn4uIoykjAwVZ+Q7pK77HmcgU0cOtyFY8nidqP0
	 skpjPhPn6lAYLtvCF+vKNGgqjXz0j9u+4Hb0ZQ60Cyf3Jb8TtO3ZCPgwN1o3VoHRbK6WX
	 DDFR+laqxIj1NpHGHBC+4wDlNNzrCNn7aFi9pNeLUH/1sQiXQxI8iCFOLI/EvJ+WRDhCu
	 4gcHVs5FUTs5LPRDd06PAejw8hPJojjKMWhh/pN4L7p6fTdX7cEi505KxIo1DiLjydA==
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=feZOnMqA;
	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 ED054606A332;
	Tue,  1 Dec 2026 21:22:20 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9CB601F00893;
	Tue,  1 Dec 2026 21:22:19 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1796160140;
	bh=7f4iaZ+PPXUISIo5+vV3/rO6o0jGoC/5UbQ+uV8MHPc=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=feZOnMqA+2xIwqLWZTx5nU5cbKm4ONQFD/h88Cz4N2dmlDqVpCweg81dsz6Cp7Bto
	 2SKa4FDNcksNiM7xBa95VQeqkScb36TPh5DgXiphYABv1RHnkQRyfcZIYEhOxM/Ahn
	 vKgbicM1d33uQ2aQdzp5QqWpGIREZg31BCWPHgmJNOH4ecdFBCpI9GO/Qx8n8QBE+d
	 NNHMwfKA6s2WEt9gkNQKqvzV1ZCr9jBz3tqSmDZqETGFk8efrWQ5QCaBga3kB89pNE
	 UOgq/V4A4MPYpIflciNAYMn4AayPmbPv7o5xuhaJgzwN/4e1DrKUT2uflgT0bem+b9
	 ilPfUWXx7DJHQ==
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: <6e1e7c6b-383d-48fa-ad72-b69ce9620f76@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