🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #9830

[PATCH net-next 2/6] net: dsa: motorcomm: Rely on port isolation for CPU port

#9830
From: David Yang
Date: Mon, 02 Nov 2026 15:56
112 lines
14611 bytes
With every port fully isolated during chip setup, the CPU port already
gets its one-way isolation (drop all packets without tag) there, so the
dedicated handling in port_setup() is redundant. Skip the isolation
write for CPU ports in yt921x_userport_standalone(), which port_setup()
also runs for CPU ports, to keep it intact.

Consequently the CPU ports no longer need to be excluded from the
unknown unicast filtering: frames entering a CPU port without a tag are
now dropped by the port isolation instead of the ACT_UNK action.

Signed-off-by: David Yang <mmyangfl@gmail.com>
---
 drivers/net/dsa/motorcomm/chip.c | 46 ++++++--------------------------
 1 file changed, 8 insertions(+), 38 deletions(-)

diff --git a/drivers/net/dsa/motorcomm/chip.c b/drivers/net/dsa/motorcomm/chip.c
index e1fa82c6db95..fb993cc9607c 100644
--- a/drivers/net/dsa/motorcomm/chip.c
+++ b/drivers/net/dsa/motorcomm/chip.c
@@ -1164,10 +1164,13 @@ static int yt921x_userport_standalone(struct yt921x_priv *priv, int port)
 	u32 ctrl;
 	int res;
 
-	ctrl = ~priv->cpu_ports_mask;
-	res = yt921x_reg_write(priv, YT921X_PORTn_ISOLATION(port), ctrl);
-	if (res)
-		return res;
+	if (!(BIT(port) & priv->cpu_ports_mask)) {
+		ctrl = ~priv->cpu_ports_mask;
+		res = yt921x_reg_write(priv, YT921X_PORTn_ISOLATION(port),
+				       ctrl);
+		if (res)
+			return res;
+	}
 
 	/* Turn off FDB learning to prevent FDB pollution */
 	mask = YT921X_PORT_LEARN_DIS;
@@ -1942,8 +1945,6 @@ yt921x_dsa_phylink_get_caps(struct dsa_switch *ds, int port,
 
 static int yt921x_port_setup(struct yt921x_priv *priv, int port)
 {
-	struct dsa_switch *ds = &priv->ds;
-	u32 ctrl;
 	int res;
 
 	res = yt921x_userport_standalone(priv, port);
@@ -1957,27 +1958,6 @@ static int yt921x_port_setup(struct yt921x_priv *priv, int port)
 	if (res)
 		return res;
 
-	if (dsa_is_cpu_port(ds, port)) {
-		/* Egress of CPU port is supposed to be completely controlled
-		 * via tagging, so set to oneway isolated (drop all packets
-		 * without tag).
-		 */
-		ctrl = ~(u32)0;
-		res = yt921x_reg_write(priv, YT921X_PORTn_ISOLATION(port),
-				       ctrl);
-		if (res)
-			return res;
-
-		/* To simplify FDB "isolation" simulation, we also disable
-		 * learning on the CPU port, and let software identify packets
-		 * towarding CPU (either trapped or a static FDB entry is
-		 * matched, no matter which bridge that entry is for), which is
-		 * already done by yt921x_userport_standalone(). As a result,
-		 * VLAN-awareness becomes unrelated on the CPU port (set to
-		 * VLAN-unaware by the way).
-		 */
-	}
-
 	return 0;
 }
 
@@ -2276,10 +2256,8 @@ static int yt921x_chip_reset(struct yt921x_priv *priv)
 static int yt921x_chip_setup_dsa(struct yt921x_priv *priv)
 {
 	struct dsa_switch *ds = &priv->ds;
-	unsigned long cpu_ports_mask;
 	u32 ctrls[2];
 	u32 ctrl;
-	int port;
 	int res;
 
 	/* Enable DSA */
@@ -2297,7 +2275,7 @@ static int yt921x_chip_setup_dsa(struct yt921x_priv *priv)
 	if (res)
 		return res;
 
-	ctrl = GENMASK(10, 0);
+	ctrl = GENMASK(10, 0) & ~priv->cpu_ports_mask;
 	res = yt921x_reg_write(priv, YT921X_FILTER_UNK_UCAST, ctrl);
 	if (res)
 		return res;
@@ -2320,14 +2298,6 @@ static int yt921x_chip_setup_dsa(struct yt921x_priv *priv)
 	ctrl = 0;
 	for (int i = 0; i < YT921X_PORT_NUM; i++)
 		ctrl |= YT921X_ACT_UNK_ACTn_TRAP(i);
-	/* Except for CPU ports, if any packets are sent via CPU ports without
-	 * tag, they should be dropped.
-	 */
-	cpu_ports_mask = priv->cpu_ports_mask;
-	for_each_set_bit(port, &cpu_ports_mask, YT921X_PORT_NUM) {
-		ctrl &= ~YT921X_ACT_UNK_ACTn_M(port);
-		ctrl |= YT921X_ACT_UNK_ACTn_DROP(port);
-	}
 	res = yt921x_reg_write(priv, YT921X_ACT_UNK_UCAST, ctrl);
 	if (res)
 		return res;
-- 
2.53.0
Technical Details
Message-ID: <20261102155641.3682626-3-mmyangfl@gmail.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-354924-linux-kernel-netdev=dewy.ru
References: <20261102155641.3682626-1-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-354924-linux-kernel-netdev=dewy.ru
From: mmyangfl@gmail.com (David Yang)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net-next 2/6] net: dsa: motorcomm: Rely on port isolation for CPU port
Date: Mon,  2 Nov 2026 23:56:34 +0800
Organization: Usenet Network
Message-ID: <20261102155641.3682626-3-mmyangfl@gmail.com>
References: <20261102155641.3682626-1-mmyangfl@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2991290"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:4H7gEd74CaLg9WSxJ1a4Ql7Vc64= sha256:lP11uIXGuI7H/yuLRcZ0H6KzvobfUc8HJAeyq/VBKXs=
	sha1:SJ3OYs9DexdEHu32ExIjZuZ8e7M= sha256:08wlK5UTmSntOAbCWoV6NNq//NjqZpDycwqikbZcLLI=
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 8050E1125EA; Mon,  2 Nov 2026 21:05:51 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.049
X-Spam-Status: No, score=-3.049 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001,
	FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
	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=gmail.com
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 kKKj800rfR7G;
	Mon,  2 Nov 2026 21:05:49 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-354924-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id D2109112591; Mon,  2 Nov 2026 21:05:36 +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 CB995184F4C; Mon,  2 Nov 2026 16:59:36 +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=1793635117;
	b=TQtVrDblQephBObWSW3f5zmwHaM2ChMDOhV8/3OcdCIeWqgBVsW2o8bDz56gut2VLQed
	 Yo+cn0mvkKGiM6YwS8efZD6TsR2d5es4d0GsEjPeun3/o2SXm/OId1iavdp2snyaMxxLV
	 EozuwhOByvOgoKE7wd/lIBii+ORSyG95O/aycoCj6GKNZVFhiYvGpqQi3jG5ffwVF3xPA
	 WYuoQBxI+RayLZI0tNSLpMfSsokWHrzwOY/Kng+qHR1ErVC+ZrKI5zguMsoFW2hB3piM+
	 wRCI6jdZELC4HO+7Cz67tfqWBTdw/kBRepzH7Li/z6BY/58vahFhlwylfyr0FtqcEEw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793635117;
	h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
	 X-Google-DKIM-Signature:X-Gm-Message-State:X-Gm-Gg:X-Received:
	 Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:
	 References:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:MIME-Version:
	 Content-Transfer-Encoding;
	bh=4eUqzqxgaskgzb2volApOaC2VlmYkG23yLlDeBP9Vhg=;
	b=LSSLcpfapFMBXFOJQLQ/FUCUhC81cIlxRuFGj1WJAL227akTVkUfX9CKe2yMPWTmm0gr
	 2ihLyDkrCIrozAWulHAcQUwHVosEVfhrRB8Lsjsd8BhBLmb4fLJDv6r8vN/hDDM/mMRyi
	 YqWPZ9FFkvJSVRg9J5xMynUADOYmPu59REiXLP0bwTPnEXdIo2/rT6GqxUFrxTbnhAIsi
	 8kXiJt8RgM5NZjsCceq/9+Q5GAQQAFwYOMJx2eb38J3d/pYdynpvktwWryyCrbYI6Ej6l
	 kF//nq+vr4ZM/eIxHl2ovtVppCTtQVnod73y1jeE9/AElJlraMm8WGFGBYlXWsDC5vA==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=s93cnhjh;
	dmarc=pass header.from=gmail.com;
	spf=pass smtp.mailfrom=gmail.com;
	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 C9A8660752BC;
	Mon,  2 Nov 2026 15:58:37 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=s93cnhjh
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.216.41
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1793635117;
	b=gFCyHXuB2q3baHpsHlKLLaEHI94iwLrUofz17JT4Q7eSs7WmWaJo5HI+fBg22VZjg9y5
	 pthliFDlPWPSVdozmLa9jgQYkq8SKBaUXcivgSkxvttXP8+qFXFMzJwcd9mNGZ89uG7F7
	 z9Xv/5J8tvUX2Lh/f81frS/JQlVsW6iuNvkaRvEo5ZGKTXrXD2OurABtYWUWZqSJQPaW0
	 XuQzg3m4aZyjzP/yFhHiyFjsJhG17W3FJLdHLN9HHGxrRt8sI/fmUomExFTy+uhMX2Ddd
	 94KtMPNUZD6QVra0llF2QEJt9HNREg+I7UFs7pfsOoBEiVg7qFvFAGN+Vxtjf8oHdKg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793635117;
	h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
	 X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject:
	 Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version:
	 Content-Transfer-Encoding;
	bh=4eUqzqxgaskgzb2volApOaC2VlmYkG23yLlDeBP9Vhg=;
	b=tD8/GNbq+E8KhCjfH8j3rMnEn1UENrR/9e/PmlNSlN+clwliMHH/B2hh1lA3ryIXrYlG
	 nb4sfXawiCrA8LLSauWb/7z/FRWUmW5KHhhZ0wKQhWquu6tU6DYaCt+IxPNJmJzPtZrrY
	 at8Rv9Uf3EKMeoSV5Y/2cpSvnsldIngTMujTMlVNg/SwjCM07jbtIpsnaHB5kQTM/us8v
	 ZC02sbqrLylcjrf3MVuQBJ9lalLfToZJ2NcR5vff4lyHViI21wDHLv+gftiSOg04+flo9
	 Y7YL9I3wiLCA1Q9DwXt2dSJYX5Hy3fCoEaeTongQbV3gT7zlBetgvYuAxxvjhn0YjPA==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=gmail.com;
	spf=pass smtp.mailfrom=gmail.com;
	dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=s93cnhjh;
	arc=none smtp.remote-ip=209.85.216.41
X-Received: from mail-pj1-f41.google.com (mail-pj1-f41.google.com [209.85.216.41])
	(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 97CAE60AC6FB
	for <netdev@vger.kernel.org>; Mon,  2 Nov 2026 15:58:36 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 97CAE60AC6FB
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-pj1-f41.google.com with SMTP id 98e67ed59e1d1-3adc4590de4so2528355a91.2
        for <netdev@vger.kernel.org>; Mon, 02 Nov 2026 07:58:36 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20260707; t=1793635116; x=1794239916; darn=vger.kernel.org;
        h=content-transfer-encoding:mime-version:references:in-reply-to
         :message-id:date:subject:cc:to:from:from:to:cc:subject:date
         :message-id:reply-to:content-type;
        bh=4eUqzqxgaskgzb2volApOaC2VlmYkG23yLlDeBP9Vhg=;
        b=s93cnhjhLER8VVXRcDFSD6Yn5w+jsBgTSIebxNT0GtGyLiKJgkKnc05IXZMvrYQDCY
         hslIby5aGenm3Nk21M2EchnwDKxc1TwJ+KbZq5C+EcvnVnwvTVemqb+dsuESLmkmhZCs
         ktiowN4nSFalA7G6CV7IDn2yrePEtDMYRuuFdj4rXKse7OBpkj5Gx0a6278AgHLEwBIH
         x4veqgxF9oHfRLGmA+Y7VOOu7yjNDfZV+vpv0AC9KMYMmbWJf1u32PvPRHg7ecki3pBA
         Yaj1yB827Fk52MAr5oCOnkj/4f36x7VrHQzcnAedd5LktIL7yVM3dSPiHmTkzOudOnxm
         tHVg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1793635116; x=1794239916;
        h=content-transfer-encoding:mime-version:references:in-reply-to
         :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from
         :to:cc:subject:date:message-id:reply-to:content-type;
        bh=4eUqzqxgaskgzb2volApOaC2VlmYkG23yLlDeBP9Vhg=;
        b=ZEXtl6ZNf9UoiUJyjJbynu1RX2hj270eLvte+4q1GP4/huFDO03eNdkg6W6XdIYZ0x
         BNkbJZABKHHuBPRUN9K/i0aTAuWXX1S20204yrlDdBMFZAMqI+pXH7Y8IMfFirOx010b
         Z2wXTXdTccQsE2lBG0uY/8lv47ghPRiiW0iYoJHnMYTyOuLulwMFYUEur+3hdfGu4Qe4
         HqDEIdw0WHIDF/Rz+UFWMIli2bLtWPJ83dHeKlHfO61uhLvtlUoK29ANUYwXLD/cmEpH
         AQ8ESXX7UAc62obOOJpHLMUBjW11ld2g1sMB65me8NDLMqzTwkHR+CpbfcIbZ+4us95Y
         VTgg==
X-Gm-Message-State: APuU4Z9HtO4RXdlADdNCFc9SJZZNzuWhQcFtbP3xqvzk2NGlZR2v8vN1
	j8DrRn2zjDjCU1/g7BD6YOIdbw1GnersFdvC+HBUbqgywVee+gXs5sW91+0Lsg==
X-Gm-Gg: AYBFou2WMTPI2vKh4RURM3c3PARUlUXvWKNJIcYOvrkvQAK3gp0xxxiaUhDUbdms++8
	cfEkjP9sVA1ueVkH+vvFIhi+PvjDRo0oMaf02WlzMQ0VeaExiGnEEt0jq8JRrxPuZU2mtliFci5
	RfOuAft9IErObJAuXlY86Ki0412o16nSxfUWVpTo/xNTPrM4b2kkrDCU6QJjYLhZM4VInCsox7m
	bzCh1kQb29a/b9+B9BmBebujm17iXpgzcXQwASGxRmZTpaxVG1a+jwlQmcy1A2gyLevtjjiefcu
	I8Qixr1ppCfDwGvynuRR8f47zrWbCTW2GtVJ2Y/iwFbjCM7sD3XFVa6TmNLEomTaRFmidhutnZW
	GoP+GlNC+HfcqTyjdgnmVVEKcWsKF+s2yLOlDOZ5bBjmR28bNqy7D7xX+8SuZUd/6UwtXKhxad4
	oa2P42h8E5WCy+Jmxpsh9xe4Hu0PZWqzzYFXwFHqcPWjg0KU/sjZk4fYrV2so7bVv/jXITCW0N+
	DfARYSKd9d1iJVksXrUjtIwq9HQ7H2JhpmrqdBmWdGhX7tnJUJFpi1tbtbN/hw3wS0BT70cXOj+
	2BcrKIo8wjrygtdeMbv6vnP4gayNLhX19qcvXKrpELrBD8vjyHxl
X-Received: by 2002:a17:90b:2252:b0:3a7:8c68:6446 with SMTP id 98e67ed59e1d1-3ae8987d10amr8883371a91.63.1793635115807;
        Mon, 02 Nov 2026 07:58:35 -0800 (PST)
X-Received: from d.home.yangfl.dn42 ([2a09:bac1:7680:28::4:396])
        by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3ae6e7d429fsm19183949a91.2.2026.11.02.07.58.31
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Mon, 02 Nov 2026 07:58:35 -0800 (PST)
X-Cc: David Yang <mmyangfl@gmail.com>,
	Andrew Lunn <andrew@lunn.ch>,
	Vladimir Oltean <olteanv@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>,
	Paolo Abeni <pabeni@redhat.com>,
	Simon Horman <horms@kernel.org>,
	linux-kernel@vger.kernel.org
X-Mailer: git-send-email 2.53.0
X-In-Reply-To: <20261102155641.3682626-1-mmyangfl@gmail.com>
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