🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #12732

Re: [PATCH net-next v4 4/8] net: dsa: motorcomm: Remove local cpu_ports_mask

#12732
From: netdev-bot+sashiko
Date: Sun, 08 Nov 2026 12:39
123 lines
12150 bytes
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

Critical: 0 · High: 1 · Medium: 1 · Low: 0

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).

- [High] This commit was meant to be a pure refactor, but it reverses the
  target mask in yt921x_bridge() (drivers/net/dsa/motorcomm/chip.c).
- [Medium] In yt921x_isolate() (drivers/net/dsa/motorcomm/chip.c), the
  per-iteration check `(BIT(i) & priv->cpu_ports_mask)` was replaced…

--

net: dsa: motorcomm: Remove local cpu_ports_mask

This commit drops the cached cpu_ports_mask field from struct yt921x_priv.
Its users now call dsa_cpu_ports() or dsa_is_cpu_port() instead. The
commit describes this as a readability change.

> diff --git a/drivers/net/dsa/motorcomm/chip.c b/drivers/net/dsa/motorcomm/chip.c
> index c51491ef4dae5..8ab499611fbf7 100644
> --- a/drivers/net/dsa/motorcomm/chip.c
> +++ b/drivers/net/dsa/motorcomm/chip.c

[ ... ]

> @@ -1215,7 +1216,7 @@ static int yt921x_isolate(struct yt921x_priv *priv, int port)
>  
>  	mask = BIT(port);
>  	for (int i = 0; i < YT921X_PORT_NUM; i++) {
> -		if ((BIT(i) & priv->cpu_ports_mask) || i == port)
> +		if (dsa_is_cpu_port(&priv->ds, port) || i == port)
>  			continue;

[Severity: Medium]
Should this be dsa_is_cpu_port(&priv->ds, i) instead of port?

The old check tested the loop index i against the CPU port mask. The new
check tests the function argument port, which is the same on every
iteration.

The only caller path is:

yt921x_dsa_port_bridge_leave()
  yt921x_bridge_leave()
    yt921x_isolate()

yt921x_dsa_port_bridge_leave() already returns early for CPU ports:

	if (dsa_is_cpu_port(ds, port))
		return;

So the new condition is always false, and the loop no longer skips CPU
ports. On every bridge leave, BIT(port) now gets set in
YT921X_PORTn_ISOLATION() of each CPU port. The original code left those
registers alone, because port setup programs them.

If yt921x_isolate() were ever called with a CPU port, the condition would
be true on every iteration and no port would be updated.

>  
>  		res = yt921x_reg_set_bits(priv, YT921X_PORTn_ISOLATION(i),
> @@ -1232,7 +1233,7 @@ static int yt921x_isolate(struct yt921x_priv *priv, int port)
>   */
>  static int yt921x_bridge(struct yt921x_priv *priv, u16 ports_mask)
>  {
> -	unsigned long targets_mask = ports_mask & ~priv->cpu_ports_mask;
> +	unsigned long targets_mask = ports_mask & dsa_cpu_ports(&priv->ds);

[Severity: High]
Is a ~ missing here? The old code selected the bridge members that are
not CPU ports. The new code selects only the CPU ports.

Both callers add the CPU ports to ports_mask before calling
yt921x_bridge():

yt921x_dsa_port_bridge_join():
	ports_mask = dsa_bridge_ports(ds, bridge.dev);
	ports_mask |= dsa_cpu_ports(ds);

yt921x_bridge_flags():
	ports_mask = dsa_bridge_ports(ds, bdev);
	ports_mask |= dsa_cpu_ports(ds);

So targets_mask always ends up equal to dsa_cpu_ports(ds). The loops under
the "Block from non-cpu bridge ports" comment then write only the CPU
ports' YT921X_PORTn_ISOLATION() registers.

This has three effects:

The ~(u32)0 isolation value that yt921x_port_setup() installs on the CPU
port is overwritten with ~ports_mask | BIT(cpu).

The user ports in the bridge never have their isolation registers
rewritten. They keep the standalone value ~dsa_cpu_ports(ds) from
yt921x_userport_standalone(), so they stay blocked from each other.

BR_HAIRPIN_MODE and BR_ISOLATED updates from yt921x_bridge_flags() go to
the CPU port, not the user ports.

yt921x_userport_bridge() clears YT921X_PORT_LEARN_DIS on join, so the
switch learns FDB entries for bridge members. The comment in
yt921x_chip_setup_dsa() says port isolation is applied after FDB lookups.

Would known-unicast frames between two bridged user ports then be dropped
once their FDB entries are learned?

Should this be ports_mask & ~dsa_cpu_ports(&priv->ds)?

>  	u32 isolated_mask;
>  	u32 ctrl;
>  	int port;

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261107121631.1040612-1-mmyangfl%40gmail.com
Technical Details
Message-ID: <179414157457.994134.9293623336717341404@kernel.org>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-358721-linux-kernel-netdev=dewy.ru
References: <20261107121631.1040612-5-mmyangfl@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-358721-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v4 4/8] net: dsa: motorcomm: Remove local cpu_ports_mask
Date: Sun, 08 Nov 2026 12:39:34 +0000
Organization: Usenet Network
Message-ID: <179414157457.994134.9293623336717341404@kernel.org>
References: <20261107121631.1040612-5-mmyangfl@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="123925"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:HrkMPQwVdLCRJnuqT1HqFw4caVo= sha256:SoNHdq/sEWUMQ97uyunZxJOmi/eI0XcwAkO4HBJLSj4=
	sha1:cbjMpt32MGEXyzt2LJCxAzOUjWs= sha256:GOEVKqs5zhiHsr002sy3ZFZ3P2Kwfgia1r1mj91Inec=
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 A5D6A11357C; Sun,  8 Nov 2026 15:41:09 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.4
X-Spam-Status: No, score=-3.4 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, 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 Se1TT9wsP2-V;
	Sun,  8 Nov 2026 15:41:05 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-358721-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 5811D113577; Sun,  8 Nov 2026 15:40:57 +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 539B048C83; Sun,  8 Nov 2026 12:39:47 +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=1794141581;
	b=zVob2+ZDd14EQCcSCSzPN5o6bbwf384lds3kk4d2weS5Uy/mAeF2La7fUSPTdVl2nx6D
	 yfeFmMOEPFkKyPDuz+LD5vP/7ZPkIUFqQIh5JIqpxnuID/bvcb9MrkLvtjqZCdk9DCcTw
	 WplwLwaknde16du7cbAkfYBKC2pIUhkNNcI4IVg9bL5FGPKvp+8gz1/X6m4lDYGXv9uXz
	 WtnzhwVOBkI42iFe4kEqw1CvlsKNIxxV3SzBtjpiw/51dr5b+GyEnBRnlLFW0yH+NZnWu
	 bTRdJUdZ61jOnRPRxRnDqLkMzk4ZOXCjp0DmntDbWrvfCtDyqKu8uqxDVyyIUFx+zIw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794141581;
	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=/pLw2UrYqbKh1m0SK5YqZc3gcb89bZNzM43raVxaG1w=;
	b=K+MoKIf8NGQjRoXTUSSWERJ2uo+c6tv3tEalNSbHnJQhNy5VJ6kRENBS0CJb1SK/8Cmv
	 +CUPrdDZ9/6OnYIsvXmvW3wa6L2oinf5cl/xMz6tszss70hHJgcBBbiCi6GSeP/wbT6Hy
	 gX6DfEXZf8H3lQUHaV9O8HtoG0J0Nmot0/2cZlfpYkevsyd8Nhb+kkooad5Tfr7G0VPRZ
	 boirJCDhAWmTS7R9+iWAPi1SA+0w4pb4LRsYDDpDGs1mGPVBbuP1Xj5x2ZWJAKL7y06y/
	 1r97n1HB70AHyYEsDCk47uu2QOpHAlFcKe0Ro4I+rYBWQwkI7M4d6ehsuUOO9h9SBSQ==
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=Vx4EXMpy;
	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 A9CA4606D826;
	Sun,  8 Nov 2026 12:39:41 +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=Vx4EXMpy
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=1794141575;
	b=qhT3kN+IqOFFh7aX/OfZieAqiRhDH+KvAE5TBbmC7c7317nYRnqDbwzkh9DZvMdDx7b8
	 zbi5s/Ab5TnjM33pux9SUTv5zyk43CeEg8eI+ZXS3OZzWZA5PF3TCFjS6MO6OjZO/gmme
	 wM9NmbSkATTE5wutJtU2JgsmuEF6aeThMJeZcy5RxUvPTHmrCXhZ5alKf5JbjfhKSxpZd
	 uOvbFxOxYreaB1kkjCGDLJl8CdaWbeoeBW8f4HacgiUIeVJ0JF+3CLbwjMKraoWfn3M6I
	 9V55ruGTVlZTtEKP9wM7fvkbW1FQB4nJtmoj8FSaEgW6e/5ziPcivU2flgrwDz/UqLg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794141575;
	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=/pLw2UrYqbKh1m0SK5YqZc3gcb89bZNzM43raVxaG1w=;
	b=QeJ2w7cNgFQC2f6p1BSAiGnLIWZuPc2d/CvLVrcCrXLgk6NiMjKLSTZMxtnC6ILRldXy
	 WdEqFJNj3z7kb2+nKjY4AD0Wr63KTXeACalWrq7XCHrZiJFDDIBaCEVOxVdPwnBh/5wqS
	 H2JI5ZB/OTeru8OBX+1vCGMDXRYLNoaAbplMZxAtJd5FBPApqzblzy9og+DMO6S/uq2iz
	 44NG5eOujLwypEIPqsfQ7yG8s4LeB3JY3ahdiej0HxbPTPs/Gqn2cizK9jpSON623O0ID
	 kACcy4Kr+MQi0kyIVgxCi6Asyly3LfMUiTIQXvVaWan1aZkCmztYf+zi6FlrLX/D99A==
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=Vx4EXMpy;
	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 8CABE606D802;
	Sun,  8 Nov 2026 12:39:35 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id F28991F008A3;
	Sun,  8 Nov 2026 12:39:34 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1794141575;
	bh=/pLw2UrYqbKh1m0SK5YqZc3gcb89bZNzM43raVxaG1w=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=Vx4EXMpyqvtw2e8OqtpPRw2XyE+ku4ylCwfzvMAoHkhThlvZKL1kgC7XgLtTf1z/Y
	 ClEpNzWb/gW1YRiZgivwOpVoXgEIhO6nOOtiNcPp/djyCHkWo9++/cY87Vidj/Nnm1
	 X+oFOV2PWCEjagnpE+ci1RznSy6D/IoY5Hwv5Gtcn5csNFbi+DdV82jhMuLiUdSI04
	 RRENbr3Hg1evWWK2cNyL5bynWU2ObGvJF3/qSoMmBEd2miNPZHM5LaC80ZDPTUfpgO
	 TFyZbCQ13hr5RW8g3XnXr45g4ISZ59O9juhv+9nJhkCcCe2unujOoSKxNKL3dBHNYS
	 vTfyYsxF4GPlA==
X-Cc: netdev@vger.kernel.org, andrew@lunn.ch, olteanv@gmail.com,
 davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com,
 linux-kernel@vger.kernel.org
X-In-Reply-To: <20261107121631.1040612-5-mmyangfl@gmail.com>
X-sashiko-severity: High
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