From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (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 E42F079F3 for ; Sun, 11 Jun 2023 08:16:21 +0000 (UTC) Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A6C930E6; Sun, 11 Jun 2023 01:16:19 -0700 (PDT) Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-3f6e1394060so22880465e9.3; Sun, 11 Jun 2023 01:16:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686471378; x=1689063378; 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; bh=UMmnTW6vfnMp79yuegpBgJKiMcf31rfT8bapddih3Ig=; b=rZwOZtBSliG8KRLdcxJNDpJOkRdM39rL67muP6AO0/LW8eghwVyMsjNvap51eh6sHt 7s5BWZaQ+GgvKV4HGn/tvZAewmFbJcdlPd8giWz9n8O/ExX7e4eWmShV4o1gNfiXEH4c YH2pTZMpc+z+S2oz7LbhLHqBH3FE7gxdb1QqRHgT0Xbrqi/2ksIA+KZGFK+cKp6cd8OM ySA64SDBACpuH7CFPtOW2OhwZ3n6MxGLczXf9g1kzQFifyTfjqrOwQjXKr5efpUnEkTH g2idI8AtGI9b3x5uuXwXBDPSL3b3EF7l7JYYXkVZsNCx+BYqygNB7xuIBcLCehaICjqj WOsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686471378; x=1689063378; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UMmnTW6vfnMp79yuegpBgJKiMcf31rfT8bapddih3Ig=; b=YDHI2zNcPstiQePUUtoPchPmm8oCHV8tdmKTYDRI0NR52G9ZDyqv33ghnTCxFsWoH+ zG0DFN2KAcEaQ0wlF0Src0W4B3nf4m50TpPQz48ITIUGAlfxzmhrsgomyel9hH859Q4K ATOg6EI0KR2BDEADfeOdL4Dw+sOMUUjBRRC7KoNvhylKc/Oz8dLYepRkdPSkbyRBhcDE wOnyU2Jsshd/2GREHFvkL1YYRwmC+1SFhx4kj7yYs49YQka08si4m2lfgX7h4a03zds5 a8O0410Lxw9yjz+nQEdMwi0ddolPKw8/sZO7JqVUA8gErxqN82febiAkiMmbPcNyCxym hr+w== X-Gm-Message-State: AC+VfDwtY7PrS+NvQo639h/UMSm0/UV6cuN9H923Scx+5EsL1MfaeXiJ cDfQjZ0bU0GawagOQrjR7jg= X-Google-Smtp-Source: ACHHUZ74BotKGO6LNp+U9VVf5CP5/GgQ2fN7FCyf09Nph5IYTWmjSTOJ98pBy8vhdXqB+L0ga9XVRw== X-Received: by 2002:a7b:cc83:0:b0:3f6:13f5:d1ea with SMTP id p3-20020a7bcc83000000b003f613f5d1eamr3641394wma.11.1686471377750; Sun, 11 Jun 2023 01:16:17 -0700 (PDT) Received: from arinc9-Xeront.lan (178-147-169-233.haap.dm.cosmote.net. [178.147.169.233]) by smtp.gmail.com with ESMTPSA id s5-20020a7bc385000000b003f6132f95e6sm7748979wmj.35.2023.06.11.01.16.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Jun 2023 01:16:17 -0700 (PDT) From: "=?UTF-8?q?Ar=C4=B1n=C3=A7=20=C3=9CNAL?=" X-Google-Original-From: =?UTF-8?q?Ar=C4=B1n=C3=A7=20=C3=9CNAL?= To: =?UTF-8?q?Ar=C4=B1n=C3=A7=20=C3=9CNAL?= , Daniel Golle , Landen Chao , DENG Qingfang , Sean Wang , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , AngeloGioacchino Del Regno , Russell King Cc: Landen Chao , Frank Wunderlich , Bartel Eerdekens , mithat.guner@xeront.com, erkin.bozoglu@xeront.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: [PATCH net v2 5/7] net: dsa: mt7530: fix handling of LLDP frames Date: Sun, 11 Jun 2023 11:15:45 +0300 Message-Id: <20230611081547.26747-5-arinc.unal@arinc9.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230611081547.26747-1-arinc.unal@arinc9.com> References: <20230611081547.26747-1-arinc.unal@arinc9.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net LLDP frames are link-local frames, therefore they must be trapped to the CPU port. Currently, the MT753X switches treat LLDP frames as regular multicast frames, therefore flooding them to user ports. To fix this, set LLDP frames to be trapped to the CPU port(s). The mt753x_bpdu_port_fw enum is universally used for trapping frames, therefore rename it and the values in it to mt753x_port_fw. For MT7530, LLDP frames received from a user port will be trapped to the numerically smallest CPU port which is affine to the DSA conduit interface that is up. For MT7531 and the switch on the MT7988 SoC, LLDP frames received from a user port will be trapped to the CPU port the user port is affine to. The bit for R0E_MANG_FR is 27. When set, the switch regards the frames with :0E MAC DA as management (LLDP) frames. This bit is set to 1 after reset on MT7530 and MT7531 according to the documents MT7620 Programming Guide v1.0 and MT7531 Reference Manual for Development Board v1.0, so there's no need to deal with this bit. Since there's currently no public document for the switch on the MT7988 SoC, I assume this is also the case for this switch. Fixes: b8f126a8d543 ("net-next: dsa: add dsa support for Mediatek MT7530 switch") Signed-off-by: Arınç ÜNAL --- v2: Add this patch. --- drivers/net/dsa/mt7530.c | 12 ++++++++++-- drivers/net/dsa/mt7530.h | 19 ++++++++++++------- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c index c2af23f2bc5d..97f389f8d6ea 100644 --- a/drivers/net/dsa/mt7530.c +++ b/drivers/net/dsa/mt7530.c @@ -2261,7 +2261,11 @@ mt7530_setup(struct dsa_switch *ds) /* Trap BPDUs to the CPU port */ mt7530_rmw(priv, MT753X_BPC, MT753X_BPDU_PORT_FW_MASK, - MT753X_BPDU_CPU_ONLY); + MT753X_PORT_FW_CPU_ONLY); + + /* Trap LLDP frames with :0E MAC DA to the CPU port */ + mt7530_rmw(priv, MT753X_RGAC2, MT753X_R0E_PORT_FW_MASK, + MT753X_R0E_PORT_FW(MT753X_PORT_FW_CPU_ONLY)); /* Enable and reset MIB counters */ mt7530_mib_reset(ds); @@ -2364,7 +2368,11 @@ mt7531_setup_common(struct dsa_switch *ds) /* Trap BPDUs to the CPU port(s) */ mt7530_rmw(priv, MT753X_BPC, MT753X_BPDU_PORT_FW_MASK, - MT753X_BPDU_CPU_ONLY); + MT753X_PORT_FW_CPU_ONLY); + + /* Trap LLDP frames with :0E MAC DA to the CPU port(s) */ + mt7530_rmw(priv, MT753X_RGAC2, MT753X_R0E_PORT_FW_MASK, + MT753X_R0E_PORT_FW(MT753X_PORT_FW_CPU_ONLY)); /* Enable and reset MIB counters */ mt7530_mib_reset(ds); diff --git a/drivers/net/dsa/mt7530.h b/drivers/net/dsa/mt7530.h index 28dbd131a535..5f048af2d89f 100644 --- a/drivers/net/dsa/mt7530.h +++ b/drivers/net/dsa/mt7530.h @@ -63,16 +63,21 @@ enum mt753x_id { #define MT753X_MIRROR_MASK(id) ((((id) == ID_MT7531) || ((id) == ID_MT7988)) ? \ MT7531_MIRROR_MASK : MIRROR_MASK) -/* Registers for BPDU and PAE frame control*/ +/* Register for BPDU and PAE frame control */ #define MT753X_BPC 0x24 #define MT753X_BPDU_PORT_FW_MASK GENMASK(2, 0) -enum mt753x_bpdu_port_fw { - MT753X_BPDU_FOLLOW_MFC, - MT753X_BPDU_CPU_EXCLUDE = 4, - MT753X_BPDU_CPU_INCLUDE = 5, - MT753X_BPDU_CPU_ONLY = 6, - MT753X_BPDU_DROP = 7, +/* Register for :03 and :0E MAC DA frame control */ +#define MT753X_RGAC2 0x2c +#define MT753X_R0E_PORT_FW_MASK GENMASK(18, 16) +#define MT753X_R0E_PORT_FW(x) FIELD_PREP(MT753X_R0E_PORT_FW_MASK, x) + +enum mt753x_port_fw { + MT753X_PORT_FW_FOLLOW_MFC, + MT753X_PORT_FW_CPU_EXCLUDE = 4, + MT753X_PORT_FW_CPU_INCLUDE = 5, + MT753X_PORT_FW_CPU_ONLY = 6, + MT753X_PORT_FW_DROP = 7, }; /* Registers for address table access */ -- 2.39.2