Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2523569lqp; Mon, 25 Mar 2024 01:03:38 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX+QntgJ7nrBhbg+YmBo/+oZDTvzbbzB8WK5AO+rcXgb/GbT+gyOhyDYQbSXwsrjTAY13jmS9jVGTOrkJh3LUGwwslA+aR+fwYWjlLaRA== X-Google-Smtp-Source: AGHT+IFQqsMO4GfaZO0jwlTTNJ7CHhhO2OGnrLTkD2KTPxnlKnruoBtxj+0lfW1EvMvksjPd/fS7 X-Received: by 2002:a50:9e44:0:b0:568:d19e:7ab0 with SMTP id z62-20020a509e44000000b00568d19e7ab0mr5255305ede.36.1711353818142; Mon, 25 Mar 2024 01:03:38 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711353818; cv=pass; d=google.com; s=arc-20160816; b=Okf7jlDl/MUJRrPJx2E/uKQKIdljQ3lEbKTB3NkQPcUd56ZdC7MNlA1oRdPsT5pML7 Yvvgi2aoHRlZdBo4VLXpGvdDYG7TXXhl7f3Yv/ADRWQ7WDMtXHEEru0NJfKyAxsyAw4o SHIhV75eeDBAQO0rzv0I7+z3K/bg2UMODuRv1lyLJ8xQ5geBC60VYmFJcPwbW3wXmXPt iQF/c7/r398TEpntTR7WbM/Dnn1z2hfOxggq/e+U1KbnoeKubcUF5e7UnGmayJEn4wGp VXcvIiOpmihrR5maTtdGqAoAi64CiKkTfihUp1yIma9dlNBRrVOnFiuzjY4S72pYEBr+ VJag== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=P+I26BUMPKVVSrKom5vaPQbJGGUf52vFfXdufs/dHr0=; fh=97RcxFkIVLEa4VPm/iQgMvbMS6+S562KGM9xPrpQmaA=; b=lfRIexy6LamecLdHq0o9hjbWWEcU8/DxdEShqm/yX2oUKObOFE7hVHv3ophdXzkEJx JZz3qaHz6gcPWxKgwUVkKOzTw91s3VLWWbYA80oY9m6WcJPnJb/jjOJ5hR3dhGlza0wt NDQEDr+X0y7H8nmoAPRAjzqbW+go34AebTWiGmvqfTDcm5adjyTYjuaLZ5UducHbxxBR USs2pBIfnq5AMtqesBMq9/6pcwq/M1iygv8FIDkEifASOJxvDKytzks8cYbmi52cauow 0iedkT9I/pPboNy5rI7hl/idV0GkZ33nImwZ0V4rrDRIIkx0sbxi4dTuxU1/sLhp8IB1 pVdQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GvGmjcqc; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-115746-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-115746-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id er13-20020a056402448d00b0056c06e3883csi1370060edb.393.2024.03.25.01.03.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 01:03:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-115746-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GvGmjcqc; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-115746-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-115746-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 am.mirrors.kernel.org (Postfix) with ESMTPS id AD64C1F33A68 for ; Mon, 25 Mar 2024 08:03:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 20304368293; Mon, 25 Mar 2024 02:58:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="GvGmjcqc" 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 A5B1D22286A; Sun, 24 Mar 2024 23:11:41 +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=1711321901; cv=none; b=NMTxDUnoCi/0N0h3CVaSfjy32jupKEY6C7tfWD7VPhQqmXqhUuaVnyYQzVjkw0Ua/o4hHoIKsmnUHpkCSHQsM72PLuZOBlIzupv/ytO/xqj3HnXlNEJFW3ZQll8+oMGQdifxE05P3e7FFpujLqD+PvvNIz96hoWuKkvmtjojlEg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711321901; c=relaxed/simple; bh=LU5RtrVwv6oDNllBQy66uXZDs7SmEFvrcluDBbhrrOQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=AbdHQ3+CiWlj2iftMQhLNwR4jhXei9UU0XpmVdPiQA+yDHg4z6oR5rB6+57JZYcdK5btqlvdCnbCeTop6QXM45ITx79DWHoOE3Ig8RcdI73wBo7VOkSFAHqs6tZ7g3m4gqXywvga+WogeEm0nOajgJae/SOHhqbpFBz0d7wmC/0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=GvGmjcqc; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 93576C433C7; Sun, 24 Mar 2024 23:11:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711321901; bh=LU5RtrVwv6oDNllBQy66uXZDs7SmEFvrcluDBbhrrOQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GvGmjcqcsJ8t5oOFanSF9+3AHoiViDX4PFA1kiyP31whUr2VszsjlCoNhXPZRUOVs sT040LHeIVqXZ1Jz5+XmRh32V12Si8bC8LXwWy7IpE1ndGGFVRVAGf3aGK/UZurmjH JEAWzsTiHLumE1atv9YA/FOgvXHufX3eZFf2GQVc36hf1QBMU7PZK5qnDfOacZa7+Q nQIPBbDITq1LWG+BXn0kJ71Tpn4oF2rXUoghwsYGGr1WM2N1mGJswgKLcVFtGcTffq Kjhhezt5XrSF5f/S71fswIWCF7hYBM+ImqFmPq9DbrWNyTKOkXPeH776zehdMP5tRf pSn1yeCAFJbSA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: =?UTF-8?q?Ar=C4=B1n=C3=A7=20=C3=9CNAL?= , Paolo Abeni , Sasha Levin Subject: [PATCH 6.6 630/638] net: dsa: mt7530: fix handling of all link-local frames Date: Sun, 24 Mar 2024 19:01:07 -0400 Message-ID: <20240324230116.1348576-631-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324230116.1348576-1-sashal@kernel.org> References: <20240324230116.1348576-1-sashal@kernel.org> 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 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Arınç ÜNAL [ Upstream commit 69ddba9d170bdaee1dc0eb4ced38d7e4bb7b92af ] 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 Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin --- 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 d46025a63b696..f529bc6f56801 100644 --- a/drivers/net/dsa/mt7530.c +++ b/drivers/net/dsa/mt7530.c @@ -999,6 +999,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) { @@ -1013,13 +1028,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 int diff --git a/drivers/net/dsa/mt7530.h b/drivers/net/dsa/mt7530.h index cef2af3f24d58..75bc9043c8c0a 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.43.0