Received: by 2002:ab2:5c0e:0:b0:1ef:a325:1205 with SMTP id i14csp269906lqk; Thu, 14 Mar 2024 02:34:37 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXWdo9ojOuBRZcIdAK7Iyhjap6Ga5eX2lWO96T+CPu7M4mIBBCRQ5PpSnwqQa5MdHIBFGqND2ZuGqdCfUq5Vt8PPiqJQ/8ZJoypcEqhaA== X-Google-Smtp-Source: AGHT+IECt9R+QXvp3+jB3B7Y5RL/QJVCVNaLL8WXyquZiQyF4cOPgMmmSKfax7DeHhFTFL3NbAi1 X-Received: by 2002:a05:620a:40d3:b0:788:137c:1246 with SMTP id g19-20020a05620a40d300b00788137c1246mr1791464qko.47.1710408876879; Thu, 14 Mar 2024 02:34:36 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710408876; cv=pass; d=google.com; s=arc-20160816; b=rKrkivQA9h8rUqK8+JHls7CIUk6Vvm4NyujjFWbUk+cg4kMo/nKOtknyhChoJxdD+e 6XC+WJN2nv5B7TTk1dZXr+dGUy+phIk9FDUz3Nmq0cBMaI6/CYUGM9E0g1hKiBz2vyoo 5hHdo8DTWmBlLMiMVaIacJFeS4xpUt7AHj/5A/iE91vkNVjn396gbdBrlSdk8FFlO+nQ L1Q8M8mDSL/hAIp1B+ZpDkbPI1Z6Q99zvZQdldkmQlexALqZIR4Qg567RFaGC2SaDZ20 +GEZTLdHBtK1HH1o0lyu0FF0++x2ewehc9036aZIPTrRE4yiExN31jc0HKgcSHmI7Xec tBtw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=reply-to:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:subject:date:from:dkim-signature; bh=7eHmDdEbiTV3tUV7fsE5w+uZWYri5VIgDjUyeZMK8g8=; fh=NT5zZTbyTu5J9hHc27b95Aul0UAA4S6d//tt8LQK4Uo=; b=igx8tedK8Eohkna/WkEdgPFiUYA3hjMAiNgtLxyRldv+njrEEKzU2xwzxdWuRneczU J7idGCLRMKDWxQZ9xc9uHo/v605fsTnNyePkIrVwqFBBVG+obo3F0fF0xHmAzI/iFJE0 uIJwRlXhwrWO/zeb+0ZYJndOtAvg/3q5GeraEKnCZPtM9u9odPzf4zqRzpQVUAyrHpzC SSDlYJyzs7u/m8ET9yCUUal+oJGoyYd2+Vj3b4HmoCOP6+vL9NSYcdt/aCmuz0QuM2r0 zC7uG7mQ3yE7VAEt+LanXn7bFeC0rLKxfT6FDI1+SPo4ZYYCqeW3TzVvq+D0G8pXCgAO NGEg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=agzF8KOW; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-103061-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-103061-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id w13-20020a05620a444d00b00789da17f204si468874qkp.455.2024.03.14.02.34.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Mar 2024 02:34:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-103061-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=agzF8KOW; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-103061-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-103061-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 602461C224EF for ; Thu, 14 Mar 2024 09:34:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D4D066DD0A; Thu, 14 Mar 2024 09:34:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="agzF8KOW" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B60FE6CDBC; Thu, 14 Mar 2024 09:34:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710408841; cv=none; b=TXVXpf3sDnWofY6kvqlOEKEhW1WbdFtIQbJ+d2aursMVS7efMySXu+HQoEGo1b2AcsZ2++rzmu38XPwSNRz6KogC0NT1cgUKOw83GsG3o0NlZJdDmYekhRY8w0cvZmvTEuSr7KPI4i8TFH/+xL+eZe5Ty1gz/DGV/7b2dwb4pnA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710408841; c=relaxed/simple; bh=i5CIz4hgP3QPef4sef2s5Axx7pKoL13aQBXLUXtXudI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=gjJzHzz+mHRxGJ+Jk4QADRo+hGw8PhL1ZuSZ4swT7DGwGfh3RhVR6Z4gPxKDMKjfUFXtDLyb0KW96hjXkYh7t2F68TKjLlU5FTCyaRL6e4rbGta6Ir5m9GkguDONR9NHbzUc0SJ7fiyG7wfEEXHYPPvVVGzP+7EzKDDqAsvWXGE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=agzF8KOW; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPS id 4F427C433F1; Thu, 14 Mar 2024 09:34:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710408841; bh=i5CIz4hgP3QPef4sef2s5Axx7pKoL13aQBXLUXtXudI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=agzF8KOWISR9Ng4Q8iPJ9BsDOJdL7a3EAdi2jbPbF9i1GfdZ+Awhqy3ej8L7Ro7QJ zO6lzK13pSyDI6eFG+VuQDw2j0kg1MND0GhIqh2pzSZXhN8I3gjV8c0msUB9EdUeLZ fxXJ58DKiOEKu42TgdAjtVE8tp1VWSBnwSeukHFTE5XCMlRAsb/uv6oVLsdpbSaTqC 77dWQwcAe04i2AkJdfm05kPQUVRaBJxhq0lm3/u8jlr6MSKg8pjbTyynMD8nyob52/ jBI/Ciy9UTjkZUSXXymwcLc0kDC8BslKhgiNn+hNXSyq1XFBVvRg7WZ5rI3+UA/xnz dyht2X+zDxBMA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3B398C54E69; Thu, 14 Mar 2024 09:34:01 +0000 (UTC) From: =?utf-8?b?QXLEsW7DpyDDnE5BTA==?= via B4 Relay Date: Thu, 14 Mar 2024 12:33:42 +0300 Subject: [PATCH net v2 2/2] net: dsa: mt7530: fix handling of all link-local frames Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Message-Id: <20240314-b4-for-net-mt7530-fix-link-local-vlan-v2-2-7dbcf6429ba0@arinc9.com> References: <20240314-b4-for-net-mt7530-fix-link-local-vlan-v2-0-7dbcf6429ba0@arinc9.com> In-Reply-To: <20240314-b4-for-net-mt7530-fix-link-local-vlan-v2-0-7dbcf6429ba0@arinc9.com> To: Daniel Golle , DENG Qingfang , Sean Wang , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , AngeloGioacchino Del Regno Cc: Frank Wunderlich , Bartel Eerdekens , mithat.guner@xeront.com, erkin.bozoglu@xeront.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, =?utf-8?q?Ar=C4=B1n=C3=A7_=C3=9CNAL?= X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1710408826; l=5986; i=arinc.unal@arinc9.com; s=arinc9-patatt; h=from:subject:message-id; bh=LH1TidipD/5+ZNBthGK5IdT2X6g90y55ra+trYcBraE=; b=KXLWVQM9pPnDDZIDufrF5WFcklMA2Vn5HAGgnKA3VM/o3/PlbAEOiMHXkNe021aClZCE2k2Hx vnw4blunoF5Aw6T8BIE2dqgmUXeCh+zZUzTTAu6FirUTqwYZ3J6WNrO X-Developer-Key: i=arinc.unal@arinc9.com; a=ed25519; pk=VmvgMWwm73yVIrlyJYvGtnXkQJy9CvbaeEqPQO9Z4kA= X-Endpoint-Received: by B4 Relay for arinc.unal@arinc9.com/arinc9-patatt with auth_id=115 X-Original-From: =?utf-8?b?QXLEsW7DpyDDnE5BTA==?= Reply-To: From: Arınç ÜNAL Currently, the MT753X switches treat frames with :01-0D and :0F MAC DAs as regular multicast frames, therefore flooding them to user ports. On page 205, section "8.6.3 Frame filtering" of the active standard, IEEE Std 802.1Q™-2022, it is stated that frames with 01:80:C2:00:00:00-0F as MAC DA must only be propagated to C-VLAN and MAC Bridge components. That means VLAN-aware and VLAN-unaware bridges. On the switch designs with CPU ports, these frames are supposed to be processed by the CPU (software). So we make the switch only forward them to the CPU port. And if received from a CPU port, forward to a single port. The software is responsible of making the switch conform to the latter by setting a single port as destination port on the special tag. This switch intellectual property cannot conform to this part of the standard fully. Whilst the REV_UN frame tag covers the remaining :04-0D and :0F MAC DAs, it also includes :22-FF which the scope of propagation is not supposed to be restricted for these MAC DAs. Set frames with :01-03 MAC DAs to be trapped to the CPU port(s). Add a comment for the remaining MAC DAs. Note that the ingress port must have a PVID assigned to it for the switch to forward untagged frames. A PVID is set by default on VLAN-aware and VLAN-unaware ports. However, when the network interface that pertains to the ingress port is attached to a vlan_filtering enabled bridge, the user can remove the PVID assignment from it which would prevent the link-local frames from being trapped to the CPU port. I am yet to see a way to forward link-local frames while preventing other untagged frames from being forwarded too. Fixes: b8f126a8d543 ("net-next: dsa: add dsa support for Mediatek MT7530 switch") Signed-off-by: Arınç ÜNAL --- drivers/net/dsa/mt7530.c | 37 +++++++++++++++++++++++++++++++++---- drivers/net/dsa/mt7530.h | 13 +++++++++++++ 2 files changed, 46 insertions(+), 4 deletions(-) diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c index ac887e929c79..0d3d328f757a 100644 --- a/drivers/net/dsa/mt7530.c +++ b/drivers/net/dsa/mt7530.c @@ -950,6 +950,21 @@ static void mt7530_setup_port5(struct dsa_switch *ds, phy_interface_t interface) mutex_unlock(&priv->reg_mutex); } +/* On page 205, section "8.6.3 Frame filtering" of the active standard, IEEE Std + * 802.1Q™-2022, it is stated that frames with 01:80:C2:00:00:00-0F as MAC DA + * must only be propagated to C-VLAN and MAC Bridge components. That means + * VLAN-aware and VLAN-unaware bridges. On the switch designs with CPU ports, + * these frames are supposed to be processed by the CPU (software). So we make + * the switch only forward them to the CPU port. And if received from a CPU + * port, forward to a single port. The software is responsible of making the + * switch conform to the latter by setting a single port as destination port on + * the special tag. + * + * This switch intellectual property cannot conform to this part of the standard + * fully. Whilst the REV_UN frame tag covers the remaining :04-0D and :0F MAC + * DAs, it also includes :22-FF which the scope of propagation is not supposed + * to be restricted for these MAC DAs. + */ static void mt753x_trap_frames(struct mt7530_priv *priv) { @@ -964,13 +979,27 @@ mt753x_trap_frames(struct mt7530_priv *priv) MT753X_BPDU_EG_TAG(MT7530_VLAN_EG_UNTAGGED) | MT753X_BPDU_CPU_ONLY); - /* Trap LLDP frames with :0E MAC DA to the CPU port(s) and egress them - * VLAN-untagged. + /* Trap frames with :01 and :02 MAC DAs to the CPU port(s) and egress + * them VLAN-untagged. + */ + mt7530_rmw(priv, MT753X_RGAC1, MT753X_R02_EG_TAG_MASK | + MT753X_R02_PORT_FW_MASK | MT753X_R01_EG_TAG_MASK | + MT753X_R01_PORT_FW_MASK, + MT753X_R02_EG_TAG(MT7530_VLAN_EG_UNTAGGED) | + MT753X_R02_PORT_FW(MT753X_BPDU_CPU_ONLY) | + MT753X_R01_EG_TAG(MT7530_VLAN_EG_UNTAGGED) | + MT753X_BPDU_CPU_ONLY); + + /* Trap frames with :03 and :0E MAC DAs to the CPU port(s) and egress + * them VLAN-untagged. */ mt7530_rmw(priv, MT753X_RGAC2, MT753X_R0E_EG_TAG_MASK | - MT753X_R0E_PORT_FW_MASK, + MT753X_R0E_PORT_FW_MASK | MT753X_R03_EG_TAG_MASK | + MT753X_R03_PORT_FW_MASK, MT753X_R0E_EG_TAG(MT7530_VLAN_EG_UNTAGGED) | - MT753X_R0E_PORT_FW(MT753X_BPDU_CPU_ONLY)); + MT753X_R0E_PORT_FW(MT753X_BPDU_CPU_ONLY) | + MT753X_R03_EG_TAG(MT7530_VLAN_EG_UNTAGGED) | + MT753X_BPDU_CPU_ONLY); } static void diff --git a/drivers/net/dsa/mt7530.h b/drivers/net/dsa/mt7530.h index 5566c905a415..d17b318e6ee4 100644 --- a/drivers/net/dsa/mt7530.h +++ b/drivers/net/dsa/mt7530.h @@ -73,12 +73,25 @@ enum mt753x_id { #define MT753X_BPDU_EG_TAG(x) FIELD_PREP(MT753X_BPDU_EG_TAG_MASK, x) #define MT753X_BPDU_PORT_FW_MASK GENMASK(2, 0) +/* Register for :01 and :02 MAC DA frame control */ +#define MT753X_RGAC1 0x28 +#define MT753X_R02_EG_TAG_MASK GENMASK(24, 22) +#define MT753X_R02_EG_TAG(x) FIELD_PREP(MT753X_R02_EG_TAG_MASK, x) +#define MT753X_R02_PORT_FW_MASK GENMASK(18, 16) +#define MT753X_R02_PORT_FW(x) FIELD_PREP(MT753X_R02_PORT_FW_MASK, x) +#define MT753X_R01_EG_TAG_MASK GENMASK(8, 6) +#define MT753X_R01_EG_TAG(x) FIELD_PREP(MT753X_R01_EG_TAG_MASK, x) +#define MT753X_R01_PORT_FW_MASK GENMASK(2, 0) + /* Register for :03 and :0E MAC DA frame control */ #define MT753X_RGAC2 0x2c #define MT753X_R0E_EG_TAG_MASK GENMASK(24, 22) #define MT753X_R0E_EG_TAG(x) FIELD_PREP(MT753X_R0E_EG_TAG_MASK, x) #define MT753X_R0E_PORT_FW_MASK GENMASK(18, 16) #define MT753X_R0E_PORT_FW(x) FIELD_PREP(MT753X_R0E_PORT_FW_MASK, x) +#define MT753X_R03_EG_TAG_MASK GENMASK(8, 6) +#define MT753X_R03_EG_TAG(x) FIELD_PREP(MT753X_R03_EG_TAG_MASK, x) +#define MT753X_R03_PORT_FW_MASK GENMASK(2, 0) enum mt753x_bpdu_port_fw { MT753X_BPDU_FOLLOW_MFC, -- 2.40.1