Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp4187694rwd; Sun, 11 Jun 2023 02:21:28 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4Kz67/0dOYZYmZnLWHrKC1T7xcERSJUTeJxj/DCgSOV+oiUZZ3VK5oCoKfLVtKJjGa/pRv X-Received: by 2002:a17:907:9484:b0:974:1c90:a097 with SMTP id dm4-20020a170907948400b009741c90a097mr6037740ejc.12.1686475288278; Sun, 11 Jun 2023 02:21:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686475288; cv=none; d=google.com; s=arc-20160816; b=Nn+6NrhGJvl8TaHjf1u19I+oBdzcvuaMgT7UdDilit01CHAm/pJOdfXxkQSgPmEafG IBljqqhgqL5O/7C5DGDfiIdsVRi/CJu3lbEEmjan6hDVggynfw7CJtEkD5yfTdITJ0A/ /wHACX4ciJtvQjXc53VrtIYHENHHWP+lGvZkVoUAGRf+LNGGn7ZfI5jMDWUsMG+jKvWW wQrInpI6nenLNd0u9fxrfcwl/aLaVLpDVx1ASclyGCA1TjvHU4VKnac/jfE+Owr4vR6p npGA9YxMamxXvJ4kY21qJzAKihRCvDMAAoConXR6SCluUFXdJPfXbKw6AuaHDIK+mweK T/cA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=MawcVePra1qezae3jM9kLNrcTxxlCRgwx7hsVh8Pm7k=; b=IoRaLv+BMjOs8sATqCYTkL4LX19dW+2qJB/VIxU9tk6QQEN2AzcN0EDQrJcg2HqwT8 MrfniAaAYSiijGm24Qs6TvbV1SJV9hhw+d2VNvkOcWjLPxmYFjCYAgVLQj1vrYBmbVfr 8LQBZVZ+7sNbfQ/PI9xT+6t0yVm+KZgmNtpuggjCuy+rh1asFNA3v7fcQGwlWO9Iyqlf /Xw2HMdPIfZ8d2J+Ra/FN7RemOQXJOJBPVMZS7wNKwVJuQeWPqWtXYsxXYeQbunze7Mk Cnuun8JPPE73yWHEDcahhyVHnQFH8duyP3hNPehQDioKc8DcGEW3m3OL8SD0A/4Onj7X lXSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=T6xo+Zdt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r11-20020aa7cfcb000000b0051456f61f7dsi4523892edy.457.2023.06.11.02.21.03; Sun, 11 Jun 2023 02:21:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=T6xo+Zdt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233572AbjFKIjt (ORCPT + 99 others); Sun, 11 Jun 2023 04:39:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233243AbjFKIjh (ORCPT ); Sun, 11 Jun 2023 04:39:37 -0400 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1ADD126B1; Sun, 11 Jun 2023 01:39:36 -0700 (PDT) Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-3f732d37d7cso32918305e9.2; Sun, 11 Jun 2023 01:39:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686472774; x=1689064774; 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=MawcVePra1qezae3jM9kLNrcTxxlCRgwx7hsVh8Pm7k=; b=T6xo+Zdt9hy/a3FOPQcorLiZmiUptS1PemQ75IHPcbz7eMZ5jRzmbVlKSvnohuHJmK 1dN5QBnhDNGdE5lR8ZPpwdBZ4uMOEN0OxRkZOdi0P1y5OEK3cxUzJvJrM3NnEwnyrOtX RDBNUhlBB3IvEhkaEZdGOwam1Or/F6Qf/MOAomKky00Lh9fT/jqbRBfnbtNacKK244eY G2m3RJ3cBUwJFg8tE5fniVAXFGE/qemMMgaCI0mFdNmiEl7PG/5yshtQZMdtw34XMo6R CHSvHw1kA97pN/B/si3VIR/ADUq3oP33KwEya9+AQGgNoStrV7hGuV0bG34zomOG6lTr BwtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686472774; x=1689064774; 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=MawcVePra1qezae3jM9kLNrcTxxlCRgwx7hsVh8Pm7k=; b=C1l3GcpyOB4x2mjyNXebf69+SAXH3M25xC0uTBngzVZOFs2+4Ainn5ONmJblge3aIg T9q/UafWFsKqU3PsKxFBguM0Tbs++8qqDPofz6yW0zV7mb5+tL0EILw5gDBHcuFIh3zZ S9RHPiqyv0RsEhKSrBuh8dxx22H3QVtg/H82gns7Y6SVXYFy65dkoi0TAjLTh6VTNI7v jrKkWPslsP+50FlLyvGvf/1mMa8y2TFcS+t6nOdOb6xjntVFhKQeTWLjtk7X5LmJsfYP IWr7joO1Lv8ebTJB2akAceAJEJgsJ8gvqnVU5Yj0Uo1MSmspscbnNeN9kLouSQCKbYLm pwaw== X-Gm-Message-State: AC+VfDy2pYjGybdf1HLnYirzpf370HXsB1OEjKm6QPBvkTSmazssoR+W PAojl438svJQ0o5N/zjNR0M= X-Received: by 2002:a05:600c:290:b0:3f7:f7d5:a07f with SMTP id 16-20020a05600c029000b003f7f7d5a07fmr5112604wmk.17.1686472774459; Sun, 11 Jun 2023 01:39:34 -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 17-20020a05600c22d100b003f8044b3436sm7394629wmg.23.2023.06.11.01.39.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Jun 2023 01:39:34 -0700 (PDT) From: arinc9.unal@gmail.com X-Google-Original-From: arinc.unal@arinc9.com 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 v3 5/7] net: dsa: mt7530: fix handling of LLDP frames Date: Sun, 11 Jun 2023 11:39:12 +0300 Message-Id: <20230611083914.28603-6-arinc.unal@arinc9.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230611083914.28603-1-arinc.unal@arinc9.com> References: <20230611083914.28603-1-arinc.unal@arinc9.com> 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arınç ÜNAL 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