From patchwork Tue Aug 3 12:40:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qingfang Deng X-Patchwork-Id: 12416251 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A5527C4338F for ; Tue, 3 Aug 2021 13:00:27 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 74E5D60F38 for ; Tue, 3 Aug 2021 13:00:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 74E5D60F38 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=fv/3JnsaKoeSd+TcGKPI+s+JruSpTStl6NVYD2EQiDM=; b=y2Mei8wePL4Nhp D2yiw67ItA1qTdgdVZkJGQEXdIHCrfawxl2E27kE65md/JsZku1Nsbz59YNGpwMUONhNjVWBGyUL/ IBY8mdFxq6g5gSKcNlKBo7hd3oWtxUizFdFo93gygtluzDpczcjzCyMEwAmpHih5OJrKfAUVHZevr pSnVj78Pv0I0CfWt+Ck9YYGr3KFTBv4qPi2pLuQL+UB+1MvhXVZX85oFQB69AYUo8UjFgPMhK92rH jZd8OB25HZPmBqzhB7Mx2BDEB0lbHet3Yuux0I3VmKVLZL1B702ADoYHBeSRKLoHB27Y+tn1mbmvT pErzkTXRbZu+Ne01C5UQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mAu1k-002oZC-1O; Tue, 03 Aug 2021 13:00:12 +0000 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mAtio-002hP1-Tx; Tue, 03 Aug 2021 12:40:40 +0000 Received: by mail-pj1-x102a.google.com with SMTP id e2-20020a17090a4a02b029016f3020d867so4479856pjh.3; Tue, 03 Aug 2021 05:40:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=v/4BONrSOBizGoNEGmYr7gQHytyhSTdcu/YS8W1W0Yg=; b=U60ASrWzo2CxTUtUrtkvxqko0p3rw+Jy1Teurnr9z2qocwfsOEBT3f2k7yBm+wLiFx hpiOHGhKD1gf0hYyjTROX6BTyLZtPUwqolhfPx7QsjvADx6fdkUFI6cPyIxTqpseGq7L jS1h0tN574jRu5UrQ6O1mx7nzWOLGMS1ol+MubKsz2J/ScQqA6I38ffK11oHbx5OqIIO VN1YZ0GoirNjVqx1cgPifmafdJS6E2sDoyrm2aRf0fS8oawhKqrzkfslLglkNdJDdI+/ ZWiT0Bjn+MTtQreRt5cSii6xVze2XjXCHzs+d0oy1O4CI+w7+s0FVb781S1YVVcunP7V exwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=v/4BONrSOBizGoNEGmYr7gQHytyhSTdcu/YS8W1W0Yg=; b=E8Ohh0ErVdr8Nh4xccnXPO/GeRCyWUhzmSmimFYlzTBYkS9Kz6bFTenJcMulPetFE5 UWDFhSPpGuN4KMZfgXDNYZg+iXc53wQjiUKYkOx3lXkIVMKlfz9VfWJuaS4EcAaeJNl8 YjChjP3s1IkgayncNj9wvc1jdEUE+R8ETHvVKtpdgw3crNZlwi/z6wzd9JNOiDJbBZvm rZm9UucTjGy1iEeKW3+c+mBoznKQ3WD4dOigavEs0uk57PJv0kpsA4fvDUQwisFH+lSO hhxxOsqQlahU/jy1JXtdtK2yf1kYuTTGgrWmvnw59yazrTwlhPZR4jNFqVVZ1F430WBr rAvQ== X-Gm-Message-State: AOAM530/9xVCDtBPNIL2yBPDzGI8LJbzTmiDs+9YPrZj5dE91bFpbLR7 zKC2RhFaa9KA3B/vnf98QWo= X-Google-Smtp-Source: ABdhPJzlRZxiHjRaX626SWcK6s9kRrCmhBb+zkxzEUKrSeaS4rwpEg1Bhk0nwO0PvGjvX0uIxk7T3w== X-Received: by 2002:a17:90a:2f62:: with SMTP id s89mr4341247pjd.33.1627994437637; Tue, 03 Aug 2021 05:40:37 -0700 (PDT) Received: from haswell-ubuntu20.lan ([138.197.212.246]) by smtp.gmail.com with ESMTPSA id g25sm15747499pfk.138.2021.08.03.05.40.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Aug 2021 05:40:37 -0700 (PDT) From: DENG Qingfang To: Sean Wang , Landen Chao , Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Jakub Kicinski , Matthias Brugger , netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Eric Woudstra , =?utf-8?q?Ren=C3=A9_van_Dorst?= , Frank Wunderlich , Ilya Lipnitskiy , Vladimir Oltean Subject: [PATCH net-next 1/4] net: dsa: mt7530: enable assisted learning on CPU port Date: Tue, 3 Aug 2021 20:40:19 +0800 Message-Id: <20210803124022.2912298-2-dqfext@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210803124022.2912298-1-dqfext@gmail.com> References: <20210803124022.2912298-1-dqfext@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210803_054039_025805_468377A7 X-CRM114-Status: GOOD ( 14.26 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org Consider the following bridge configuration, where bond0 is not offloaded: +-- br0 --+ / / | \ / / | \ / | | bond0 / | | / \ swp0 swp1 swp2 swp3 swp4 . . . . . . A B C Address learning is enabled on offloaded ports (swp0~2) and the CPU port, so when client A sends a packet to C, the following will happen: 1. The switch learns that client A can be reached at swp0. 2. The switch probably already knows that client C can be reached at the CPU port, so it forwards the packet to the CPU. 3. The bridge core knows client C can be reached at bond0, so it forwards the packet back to the switch. 4. The switch learns that client A can be reached at the CPU port. 5. The switch forwards the packet to either swp3 or swp4, according to the packet's tag. That makes client A's MAC address flap between swp0 and the CPU port. If client B sends a packet to A, it is possible that the packet is forwarded to the CPU. With offload_fwd_mark = 1, the bridge core won't forward it back to the switch, resulting in packet loss. As we have the assisted_learning_on_cpu_port in DSA core now, enable that and disable hardware learning on the CPU port. Signed-off-by: DENG Qingfang Reviewed-by: Vladimir Oltean --- RFC -> v1: no changes. drivers/net/dsa/mt7530.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c index b6e0b347947e..abe57b04fc39 100644 --- a/drivers/net/dsa/mt7530.c +++ b/drivers/net/dsa/mt7530.c @@ -2046,6 +2046,7 @@ mt7530_setup(struct dsa_switch *ds) * as two netdev instances. */ dn = dsa_to_port(ds, MT7530_CPU_PORT)->master->dev.of_node->parent; + ds->assisted_learning_on_cpu_port = true; ds->mtu_enforcement_ingress = true; if (priv->id == ID_MT7530) { @@ -2116,15 +2117,15 @@ mt7530_setup(struct dsa_switch *ds) mt7530_rmw(priv, MT7530_PCR_P(i), PCR_MATRIX_MASK, PCR_MATRIX_CLR); + /* Disable learning by default on all ports */ + mt7530_set(priv, MT7530_PSC_P(i), SA_DIS); + if (dsa_is_cpu_port(ds, i)) { ret = mt753x_cpu_port_enable(ds, i); if (ret) return ret; } else { mt7530_port_disable(ds, i); - - /* Disable learning by default on all user ports */ - mt7530_set(priv, MT7530_PSC_P(i), SA_DIS); } /* Enable consistent egress tag */ mt7530_rmw(priv, MT7530_PVC_P(i), PVC_EG_TAG_MASK, @@ -2281,6 +2282,9 @@ mt7531_setup(struct dsa_switch *ds) mt7530_rmw(priv, MT7530_PCR_P(i), PCR_MATRIX_MASK, PCR_MATRIX_CLR); + /* Disable learning by default on all ports */ + mt7530_set(priv, MT7530_PSC_P(i), SA_DIS); + mt7530_set(priv, MT7531_DBG_CNT(i), MT7531_DIS_CLR); if (dsa_is_cpu_port(ds, i)) { @@ -2289,9 +2293,6 @@ mt7531_setup(struct dsa_switch *ds) return ret; } else { mt7530_port_disable(ds, i); - - /* Disable learning by default on all user ports */ - mt7530_set(priv, MT7530_PSC_P(i), SA_DIS); } /* Enable consistent egress tag */ @@ -2299,6 +2300,7 @@ mt7531_setup(struct dsa_switch *ds) PVC_EG_TAG(MT7530_VLAN_EG_CONSISTENT)); } + ds->assisted_learning_on_cpu_port = true; ds->mtu_enforcement_ingress = true; /* Flush the FDB table */ From patchwork Tue Aug 3 12:40:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qingfang Deng X-Patchwork-Id: 12416307 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3FC7BC4338F for ; Tue, 3 Aug 2021 13:01:31 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0C45B60F38 for ; Tue, 3 Aug 2021 13:01:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 0C45B60F38 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=SJAXYNrQdvtYUVELAxCkQId4ISTexgouSeIaNnFFjuI=; b=Wk1Q9YOaKblLol cmOhIgB8oljiiIjC76I2XLAJpIHXJI8uRUeVrESocTqtr0g6JVUXqJPkSRPl4b8TGgRUt3ZNNK8yC 4sFe9/NglxDO2jXsiyZekIJMGT0oVgzrcTD81eKDlKFmUaLXvSDcbBBLQ1ePeN4zxlWnSvxaSvK9m xzDdAXOnbVp5xFjbLmXiPNp1SQLWhAsFdUDeKlpNIBA4+gFL1gY6MUYeRhbSO9xeO6biE/DbFOOX9 iiTVQuDxT3AbVf6Ul+Qj2jrgJ6vkHSLiK7cWWjiWrIh5W5f8YmOdCz5vkOBB+no7kqx6vdWSvD3WH byu7GnJw/Cuc1BLh2icA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mAu2j-002ozv-Rw; Tue, 03 Aug 2021 13:01:13 +0000 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mAtiv-002hR9-3H; Tue, 03 Aug 2021 12:40:47 +0000 Received: by mail-pl1-x636.google.com with SMTP id d1so23584044pll.1; Tue, 03 Aug 2021 05:40:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZQTX4V0WI9LBN/VZo8OFXaMLg13qufw0P/K3DmG+Ljw=; b=Xua6Fqi4ODcDy6SGOIKu+7JuzGas9cDjMsfmoMKiWm5Vme1IxquAcePzNj0e3oIsfV oCyWoP1iWeEia1yKUqehdMmzCa/TkvUGdhr+okxoTwCYX0neO1BmfOi21zfmTQCyGjpy Qoh/aApzIN+6O/2z8QaAV92Nv/qCHyZkdbfm9yas6HRFvpqOMLDkzCi/WFqJKLnZHW1X zPwVWsdHWjL9coN/2ddVQmxKQri66mj4vafQsLxZJOOCEjBxOxS+CV7tA2/bSTudXG7e VwM3PGH3xxdeCResdYk5I1SMHrCjgwjbZM3GiZ7CfPfndUSYbyGybRGrBjlFuodPt6Vh 5eaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZQTX4V0WI9LBN/VZo8OFXaMLg13qufw0P/K3DmG+Ljw=; b=Btv4EX9MvEVJuylp8qhxotPF9p5ZWsLss9OB4i2O+iLgYB7PCrdudPe8+AmNyb0MGD /TKKpo7qlXtObKjTlHcK+xSFHiSbSGowWzlioWsHKKMrNJs6alQg/+7Q8k4G2aPwcygl 9+jSEyTOa92s9Omn5zt3DYGzgownqkhA7+HKq3B5ifXg3F+SssRyHNAnt7I7QCwamOCj QIUC0X1R8VItSBpa3lEaFV+LiyEU4Jft31kZY2OsOdNa891FNO4Zb6mYirQTVWCKYzMV IGp/nfWiDi0JuuU2pFzhNNo7W5LsjxaoqAKqOTdqKe3LsMdNxSE/kDcZivK/ONXfucLW cCsw== X-Gm-Message-State: AOAM530Lz9m7FHgjB1ObKczinE5RWPchXzFFmLL5pUR70g9zqeHtHc9S wIxYz1QL6m32LCFaiaOK1pg= X-Google-Smtp-Source: ABdhPJy4rBS3jmbjSutstBBXQ91ohz1aTA16uYC4mz5muRIHNHx3NfcRLnbYX5N5X7VVBVwA82CSFw== X-Received: by 2002:a63:2585:: with SMTP id l127mr1687390pgl.318.1627994443525; Tue, 03 Aug 2021 05:40:43 -0700 (PDT) Received: from haswell-ubuntu20.lan ([138.197.212.246]) by smtp.gmail.com with ESMTPSA id g25sm15747499pfk.138.2021.08.03.05.40.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Aug 2021 05:40:43 -0700 (PDT) From: DENG Qingfang To: Sean Wang , Landen Chao , Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Jakub Kicinski , Matthias Brugger , netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Eric Woudstra , =?utf-8?q?Ren=C3=A9_van_Dorst?= , Frank Wunderlich , Ilya Lipnitskiy Subject: [PATCH net-next 2/4] net: dsa: mt7530: use independent VLAN learning on VLAN-unaware bridges Date: Tue, 3 Aug 2021 20:40:20 +0800 Message-Id: <20210803124022.2912298-3-dqfext@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210803124022.2912298-1-dqfext@gmail.com> References: <20210803124022.2912298-1-dqfext@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210803_054045_256950_4F2FB776 X-CRM114-Status: GOOD ( 30.42 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org Consider the following bridge configuration, where bond0 is not offloaded: +-- br0 --+ / / | \ / / | \ / | | bond0 / | | / \ swp0 swp1 swp2 swp3 swp4 . . . . . . A B C Ideally, when the switch receives a packet from swp3 or swp4, it should forward the packet to the CPU, according to the port matrix and unknown unicast flood settings. But packet loss will happen if the destination address is at one of the offloaded ports (swp0~2). For example, when client C sends a packet to A, the FDB lookup will indicate that it should be forwarded to swp0, but the port matrix of swp3 and swp4 is configured to only allow the CPU to be its destination, so it is dropped. However, this issue does not happen if the bridge is VLAN-aware. That is because VLAN-aware bridges use independent VLAN learning, i.e. use VID for FDB lookup, on offloaded ports. As swp3 and swp4 are not offloaded, shared VLAN learning with default filter ID of 0 is used instead. So the lookup for A with filter ID 0 never hits and the packet can be forwarded to the CPU. In the current code, only two combinations were used to toggle user ports' VLAN awareness: one is PCR.PORT_VLAN set to port matrix mode with PVC.VLAN_ATTR set to transparent port, the other is PCR.PORT_VLAN set to security mode with PVC.VLAN_ATTR set to user port. It turns out that only PVC.VLAN_ATTR contributes to VLAN awareness, and port matrix mode just skips the VLAN table lookup. The reference manual is somehow misleading when describing PORT_VLAN modes. It states that PORT_MEM (VLAN port member) is used for destination if the VLAN table lookup hits, but actually **PORT_MEM & PORT_MATRIX** (bitwise AND of VLAN port member and port matrix) is used instead, which means we can have two or more separate VLAN-aware bridges with the same PVID and traffic won't leak between them. Therefore, to solve this, enable independent VLAN learning with PVID 0 on VLAN-unaware bridges, by setting their PCR.PORT_VLAN to fallback mode, while leaving standalone ports in port matrix mode. The CPU port is always set to fallback mode to serve those bridges. During testing, it is found that FDB lookup with filter ID of 0 will also hit entries with VID 0 even with independent VLAN learning. To avoid that, install all VLANs with filter ID of 1. Signed-off-by: DENG Qingfang Reviewed-by: Vladimir Oltean --- RFC -> v1: no changes. drivers/net/dsa/mt7530.c | 70 ++++++++++++++++++++++++++++------------ drivers/net/dsa/mt7530.h | 4 ++- 2 files changed, 53 insertions(+), 21 deletions(-) diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c index abe57b04fc39..12f449a54833 100644 --- a/drivers/net/dsa/mt7530.c +++ b/drivers/net/dsa/mt7530.c @@ -1021,6 +1021,10 @@ mt753x_cpu_port_enable(struct dsa_switch *ds, int port) mt7530_write(priv, MT7530_PCR_P(port), PCR_MATRIX(dsa_user_ports(priv->ds))); + /* Set to fallback mode for independent VLAN learning */ + mt7530_rmw(priv, MT7530_PCR_P(port), PCR_PORT_VLAN_MASK, + MT7530_PORT_FALLBACK_MODE); + return 0; } @@ -1229,6 +1233,10 @@ mt7530_port_bridge_join(struct dsa_switch *ds, int port, PCR_MATRIX_MASK, PCR_MATRIX(port_bitmap)); priv->ports[port].pm |= PCR_MATRIX(port_bitmap); + /* Set to fallback mode for independent VLAN learning */ + mt7530_rmw(priv, MT7530_PCR_P(port), PCR_PORT_VLAN_MASK, + MT7530_PORT_FALLBACK_MODE); + mutex_unlock(&priv->reg_mutex); return 0; @@ -1241,16 +1249,21 @@ mt7530_port_set_vlan_unaware(struct dsa_switch *ds, int port) bool all_user_ports_removed = true; int i; - /* When a port is removed from the bridge, the port would be set up - * back to the default as is at initial boot which is a VLAN-unaware - * port. + /* This is called after .port_bridge_leave when leaving a VLAN-aware + * bridge. Don't set standalone ports to fallback mode. */ - mt7530_rmw(priv, MT7530_PCR_P(port), PCR_PORT_VLAN_MASK, - MT7530_PORT_MATRIX_MODE); + if (dsa_to_port(ds, port)->bridge_dev) + mt7530_rmw(priv, MT7530_PCR_P(port), PCR_PORT_VLAN_MASK, + MT7530_PORT_FALLBACK_MODE); + mt7530_rmw(priv, MT7530_PVC_P(port), VLAN_ATTR_MASK | PVC_EG_TAG_MASK, VLAN_ATTR(MT7530_VLAN_TRANSPARENT) | PVC_EG_TAG(MT7530_VLAN_EG_CONSISTENT)); + /* Set PVID to 0 */ + mt7530_rmw(priv, MT7530_PPBV1_P(port), G0_PORT_VID_MASK, + G0_PORT_VID_DEF); + for (i = 0; i < MT7530_NUM_PORTS; i++) { if (dsa_is_user_port(ds, i) && dsa_port_is_vlan_filtering(dsa_to_port(ds, i))) { @@ -1276,15 +1289,14 @@ mt7530_port_set_vlan_aware(struct dsa_switch *ds, int port) struct mt7530_priv *priv = ds->priv; /* Trapped into security mode allows packet forwarding through VLAN - * table lookup. CPU port is set to fallback mode to let untagged - * frames pass through. + * table lookup. */ - if (dsa_is_cpu_port(ds, port)) - mt7530_rmw(priv, MT7530_PCR_P(port), PCR_PORT_VLAN_MASK, - MT7530_PORT_FALLBACK_MODE); - else + if (dsa_is_user_port(ds, port)) { mt7530_rmw(priv, MT7530_PCR_P(port), PCR_PORT_VLAN_MASK, MT7530_PORT_SECURITY_MODE); + mt7530_rmw(priv, MT7530_PPBV1_P(port), G0_PORT_VID_MASK, + G0_PORT_VID(priv->ports[port].pvid)); + } /* Set the port as a user port which is to be able to recognize VID * from incoming packets before fetching entry within the VLAN table. @@ -1329,6 +1341,13 @@ mt7530_port_bridge_leave(struct dsa_switch *ds, int port, PCR_MATRIX(BIT(MT7530_CPU_PORT))); priv->ports[port].pm = PCR_MATRIX(BIT(MT7530_CPU_PORT)); + /* When a port is removed from the bridge, the port would be set up + * back to the default as is at initial boot which is a VLAN-unaware + * port. + */ + mt7530_rmw(priv, MT7530_PCR_P(port), PCR_PORT_VLAN_MASK, + MT7530_PORT_MATRIX_MODE); + mutex_unlock(&priv->reg_mutex); } @@ -1511,7 +1530,7 @@ mt7530_hw_vlan_add(struct mt7530_priv *priv, /* Validate the entry with independent learning, create egress tag per * VLAN and joining the port as one of the port members. */ - val = IVL_MAC | VTAG_EN | PORT_MEM(new_members) | VLAN_VALID; + val = IVL_MAC | VTAG_EN | PORT_MEM(new_members) | FID(1) | VLAN_VALID; mt7530_write(priv, MT7530_VAWD1, val); /* Decide whether adding tag or not for those outgoing packets from the @@ -1601,9 +1620,13 @@ mt7530_port_vlan_add(struct dsa_switch *ds, int port, mt7530_hw_vlan_update(priv, vlan->vid, &new_entry, mt7530_hw_vlan_add); if (pvid) { - mt7530_rmw(priv, MT7530_PPBV1_P(port), G0_PORT_VID_MASK, - G0_PORT_VID(vlan->vid)); priv->ports[port].pvid = vlan->vid; + + /* Only configure PVID if VLAN filtering is enabled */ + if (dsa_port_is_vlan_filtering(dsa_to_port(ds, port))) + mt7530_rmw(priv, MT7530_PPBV1_P(port), + G0_PORT_VID_MASK, + G0_PORT_VID(vlan->vid)); } mutex_unlock(&priv->reg_mutex); @@ -1617,11 +1640,9 @@ mt7530_port_vlan_del(struct dsa_switch *ds, int port, { struct mt7530_hw_vlan_entry target_entry; struct mt7530_priv *priv = ds->priv; - u16 pvid; mutex_lock(&priv->reg_mutex); - pvid = priv->ports[port].pvid; mt7530_hw_vlan_entry_init(&target_entry, port, 0); mt7530_hw_vlan_update(priv, vlan->vid, &target_entry, mt7530_hw_vlan_del); @@ -1629,11 +1650,12 @@ mt7530_port_vlan_del(struct dsa_switch *ds, int port, /* PVID is being restored to the default whenever the PVID port * is being removed from the VLAN. */ - if (pvid == vlan->vid) - pvid = G0_PORT_VID_DEF; + if (priv->ports[port].pvid == vlan->vid) { + priv->ports[port].pvid = G0_PORT_VID_DEF; + mt7530_rmw(priv, MT7530_PPBV1_P(port), G0_PORT_VID_MASK, + G0_PORT_VID_DEF); + } - mt7530_rmw(priv, MT7530_PPBV1_P(port), G0_PORT_VID_MASK, pvid); - priv->ports[port].pvid = pvid; mutex_unlock(&priv->reg_mutex); @@ -2126,6 +2148,10 @@ mt7530_setup(struct dsa_switch *ds) return ret; } else { mt7530_port_disable(ds, i); + + /* Set default PVID to 0 on all user ports */ + mt7530_rmw(priv, MT7530_PPBV1_P(i), G0_PORT_VID_MASK, + G0_PORT_VID_DEF); } /* Enable consistent egress tag */ mt7530_rmw(priv, MT7530_PVC_P(i), PVC_EG_TAG_MASK, @@ -2293,6 +2319,10 @@ mt7531_setup(struct dsa_switch *ds) return ret; } else { mt7530_port_disable(ds, i); + + /* Set default PVID to 0 on all user ports */ + mt7530_rmw(priv, MT7530_PPBV1_P(i), G0_PORT_VID_MASK, + G0_PORT_VID_DEF); } /* Enable consistent egress tag */ diff --git a/drivers/net/dsa/mt7530.h b/drivers/net/dsa/mt7530.h index b19b389ff10a..a308886fdebc 100644 --- a/drivers/net/dsa/mt7530.h +++ b/drivers/net/dsa/mt7530.h @@ -148,6 +148,8 @@ enum mt7530_vlan_cmd { #define VTAG_EN BIT(28) /* VLAN Member Control */ #define PORT_MEM(x) (((x) & 0xff) << 16) +/* Filter ID */ +#define FID(x) (((x) & 0x7) << 1) /* VLAN Entry Valid */ #define VLAN_VALID BIT(0) #define PORT_MEM_SHFT 16 @@ -247,7 +249,7 @@ enum mt7530_vlan_port_attr { #define MT7530_PPBV1_P(x) (0x2014 + ((x) * 0x100)) #define G0_PORT_VID(x) (((x) & 0xfff) << 0) #define G0_PORT_VID_MASK G0_PORT_VID(0xfff) -#define G0_PORT_VID_DEF G0_PORT_VID(1) +#define G0_PORT_VID_DEF G0_PORT_VID(0) /* Register for port MAC control register */ #define MT7530_PMCR_P(x) (0x3000 + ((x) * 0x100)) From patchwork Tue Aug 3 12:40:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qingfang Deng X-Patchwork-Id: 12416309 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F2CCCC4338F for ; Tue, 3 Aug 2021 13:02:55 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B35F760F38 for ; Tue, 3 Aug 2021 13:02:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org B35F760F38 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=KCWfeElSz597AoTjTecUcJjBJKoanMs+hcJDVJ+rmJM=; b=RQs5xCFiOCm2wh Fgjqd1WQjsDnV6NSYMfbqGN/UUz6S79H38ngkYlIAfWaPRa54/e1U54h+VTwEXS9eabWOTRpj7gIr qPdMJ1fRwdhZYr2jvgPJEXX7XzPQVimkwfsvq1PLFbkV9P/kOlAT+2BAHKetS/AIhKGVI7lYiKUKk kEITjuYVNT/Radj3Maodrb1iXJiGzDfEu2S9HujpNyqnGAhKmnWImjyL6FI/hm6AnXqL37plCL0g/ cTXExbzUd48ZkC0U9dkoPtu3LqgldFNDL/DczOkighICxWvg8dKY05vV1pTHqepnmmTsd29yvmgq2 rTi3oOPIajRJQi2sJGWA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mAu49-002pWD-AQ; Tue, 03 Aug 2021 13:02:41 +0000 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mAtj1-002hT7-A3; Tue, 03 Aug 2021 12:40:52 +0000 Received: by mail-pl1-x633.google.com with SMTP id d17so1581610plr.12; Tue, 03 Aug 2021 05:40:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=IghreoH0EV+JzcXbJzyg8ag9UQhB8aBaKVtS7Rb1A+E=; b=tZPIOGHtyiSJSaC1x9erQ0KSW4TgYQvx7WTuNUjv4yE42XcuCl9Euzn+SPJT/Gv+/x LXgYMJUpYz9QFXL4lBXg/DT+gYh6E/NO4Tmbmo4VlANCI7aKmF4Gfic+j+vN5IBKSXCd N3D/7L2yCDmi0FSc3amZE+946RSZphpDT0ubzA8P+sd9IdEjwD1Os8/2iFfFJSNTKYu0 yA8Pm1j5/2HZ19udQxVYMKlGdOzMiHZdlCVj2pZ2T8vsH78rKUPBrjTQ0nYD+b7GTfjU 7tZPk0Wk7/ALw6wWOVX0FlahMUq5KI1HKKi8W1+uFpUBosO2ffwjMmq87TIiiDMKEgvK uwNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=IghreoH0EV+JzcXbJzyg8ag9UQhB8aBaKVtS7Rb1A+E=; b=I5mejSjPQahVQYjr0AkFCO7EIcSPWVEUh+bhE7mc3NWDgZ/u4u8CZxNY+tO4uqGTkY EQoHn2enfzY4tzZg7ZWXHl+jm2d56+xBh7aBw3c7otEcNq5TQeEc4OheLnj8BrHTr83J kRnRCroeuM7oXRZgy2N7iQ7cXAqBuVko331AE5xhXAMeho9c4263Jw857BRmzeNxTlhD MGJmgEFS9aKmEARj6doN/0M6XxcksL/ouEzzAD83pws56QrA/GzORx6OLFxdz65w+axw wcgcqgljIfHdwTfmWbZl0URHliecvJ3MPXrqM22jH8bUTVDRzsxedqEHOQdFYaaY6xnU OuAw== X-Gm-Message-State: AOAM531qzkWUgEzNbWZwwaS0lpKncA/0Jk36xCh8GhHWbiHp3Ni/KGui ORas9SFifN9qycY7UHLRDnk= X-Google-Smtp-Source: ABdhPJzipk/rEXZOBgGQv1DnquIjRxhiFr8GQzLr+KoPcpuPmQflWsm+Bt6zcvyGvQr451BVfZ3oBQ== X-Received: by 2002:a17:902:c202:b029:12c:9970:bdf9 with SMTP id 2-20020a170902c202b029012c9970bdf9mr16524134pll.30.1627994449277; Tue, 03 Aug 2021 05:40:49 -0700 (PDT) Received: from haswell-ubuntu20.lan ([138.197.212.246]) by smtp.gmail.com with ESMTPSA id g25sm15747499pfk.138.2021.08.03.05.40.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Aug 2021 05:40:48 -0700 (PDT) From: DENG Qingfang To: Sean Wang , Landen Chao , Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Jakub Kicinski , Matthias Brugger , netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Eric Woudstra , =?utf-8?q?Ren=C3=A9_van_Dorst?= , Frank Wunderlich , Ilya Lipnitskiy Subject: [PATCH net-next 3/4] net: dsa: mt7530: set STP state on filter ID 1 Date: Tue, 3 Aug 2021 20:40:21 +0800 Message-Id: <20210803124022.2912298-4-dqfext@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210803124022.2912298-1-dqfext@gmail.com> References: <20210803124022.2912298-1-dqfext@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210803_054051_403403_7EB62ACD X-CRM114-Status: GOOD ( 12.41 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org As filter ID 1 is the only one used for bridges, set STP state on it. Signed-off-by: DENG Qingfang Reviewed-by: Vladimir Oltean --- RFC -> v1: only set FID 1's state drivers/net/dsa/mt7530.c | 3 ++- drivers/net/dsa/mt7530.h | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c index 12f449a54833..8d84d7ddad38 100644 --- a/drivers/net/dsa/mt7530.c +++ b/drivers/net/dsa/mt7530.c @@ -1147,7 +1147,8 @@ mt7530_stp_state_set(struct dsa_switch *ds, int port, u8 state) break; } - mt7530_rmw(priv, MT7530_SSP_P(port), FID_PST_MASK, stp_state); + mt7530_rmw(priv, MT7530_SSP_P(port), FID1_PST_MASK, + FID1_PST(stp_state)); } static int diff --git a/drivers/net/dsa/mt7530.h b/drivers/net/dsa/mt7530.h index a308886fdebc..53b7bb1f5368 100644 --- a/drivers/net/dsa/mt7530.h +++ b/drivers/net/dsa/mt7530.h @@ -181,8 +181,8 @@ enum mt7530_vlan_egress_attr { /* Register for port STP state control */ #define MT7530_SSP_P(x) (0x2000 + ((x) * 0x100)) -#define FID_PST(x) ((x) & 0x3) -#define FID_PST_MASK FID_PST(0x3) +#define FID1_PST(x) (((x) & 0x3) << 2) +#define FID1_PST_MASK FID1_PST(0x3) enum mt7530_stp_state { MT7530_STP_DISABLED = 0, From patchwork Tue Aug 3 12:40:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qingfang Deng X-Patchwork-Id: 12416311 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AEC51C4338F for ; Tue, 3 Aug 2021 13:04:04 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 76AC960F8F for ; Tue, 3 Aug 2021 13:04:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 76AC960F8F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Xfl8ojbZ71okjEv4k3AGTf7A1lSgvQUVIF34JVaubDs=; b=XG9Zo8kA+8Twfr JAqjp/K2RY5eJpN7Fz2yEep8lyTmslpAo5ryna4foFDAFablVJKJtN53OcxuqAO2AGWpp5c+IjZUO eYbcLsYHG8dTb0pEeUOQ4OUUsUvQcvbFHIn83SfUoHXxaVqMyhyYXMtO3vgutoIQ8JnDYERfDFlpE XR6F9XLsYj8/FydS0HDblthA1DO31LflFufWK9/ix7qptO+P1XIdWFGP1zGkUFjD3gBmaECU60yH0 Tl+711tey/a555QkTX9ZRr+g7q0H7uGqucNTva2W4QaekCWFk1W/P7bRHWJheQ5uts/eoScXVfTCX 5Z+CCj6sRZGbM+jeWVFQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mAu5I-002q07-Gn; Tue, 03 Aug 2021 13:03:52 +0000 Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mAtj5-002hVY-R3; Tue, 03 Aug 2021 12:40:57 +0000 Received: by mail-pj1-x102b.google.com with SMTP id g23-20020a17090a5797b02901765d605e14so4466466pji.5; Tue, 03 Aug 2021 05:40:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=w7Kn6QXEQelFeTJ7+s8dsrUhrZSrqjRMDTa6894wxts=; b=BvH79tKxT+NJ46lxOpJ274QfCECXsRyYzb2ZSo1cZj+WIVl03lsEbe9ERzMM0qz978 dJuZx6U0MV27iFEllkqn5XGMgtEYcyQhGUiqU1M8I6SqqAuYfSrI+TRQnpziyRJNVhhV Wp4O20eq8LfUYXWHIaNvopHWaZsFURti6KuVJmJoSrkF+bpvVpv9yGiUg54YLTMfLnR+ qVXxKLXUG4Msr3wMowoGKN8SlIrrfoS6VtO50LHf/iN1tUEn5/QA6Hk4VDcf8LUvecl6 PI/Mwimzj40c6bFOqckTw8McfFMMDSSEIf/FAVaMrVXNvlIy64n8tS4dkezRsl1lc5on QGCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=w7Kn6QXEQelFeTJ7+s8dsrUhrZSrqjRMDTa6894wxts=; b=L9/YvHPBXWPOvtixVJzKBxLU82gbwcYs0BAZF8hYgpUuiEs4ger5ookfW5/1lkQ2Xn NorOYOEI8PaQwAGZev1TQn8vUP2rBh9pl3izU9gES5yBwgunweVT0b2EUKBQdbKB3ani 05CTaK8pESTtuICDarK/euFXklTdaAqO6wUBlp0tEsri0qFSfFc/XklF17l09YZhIEzI 3NZLOAfZCVGRaQK6ImUchNANOJiAqqGMRjNaLkZ5jfXsVsHNCAwtaTlPSC7yI20y2aSC c24ymM9j1oxjGMDjbl5Q6AJ5bgxOxu9PZq6IPuRvWlh5ekIQkIPidc+cJbLGZ6KmWBam LCrg== X-Gm-Message-State: AOAM530+ELhAipq0mqMwSTvb4eB7I3HgvWCeGjFckBmF7G9VmKidRp2P N6PVuDoSw5F/VhSHKkKVb0E= X-Google-Smtp-Source: ABdhPJxp9gFg7/j3CDtrOHNrsfB9FqVBSArVmrXgyH3SowyPhAc2Fu3mBv6qHFQ34Iwgo+eYhe7SHA== X-Received: by 2002:a17:902:7b8b:b029:12b:8d3e:70e7 with SMTP id w11-20020a1709027b8bb029012b8d3e70e7mr18389531pll.76.1627994455018; Tue, 03 Aug 2021 05:40:55 -0700 (PDT) Received: from haswell-ubuntu20.lan ([138.197.212.246]) by smtp.gmail.com with ESMTPSA id g25sm15747499pfk.138.2021.08.03.05.40.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Aug 2021 05:40:54 -0700 (PDT) From: DENG Qingfang To: Sean Wang , Landen Chao , Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Jakub Kicinski , Matthias Brugger , netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Eric Woudstra , =?utf-8?q?Ren=C3=A9_van_Dorst?= , Frank Wunderlich , Ilya Lipnitskiy Subject: [PATCH net-next 4/4] net: dsa: mt7530: always install FDB entries with IVL and FID 1 Date: Tue, 3 Aug 2021 20:40:22 +0800 Message-Id: <20210803124022.2912298-5-dqfext@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210803124022.2912298-1-dqfext@gmail.com> References: <20210803124022.2912298-1-dqfext@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210803_054055_942921_DDA24F96 X-CRM114-Status: GOOD ( 15.11 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org This reverts commit 7e777021780e ("mt7530 mt7530_fdb_write only set ivl bit vid larger than 1"). Before this series, the default value of all ports' PVID is 1, which is copied into the FDB entry, even if the ports are VLAN unaware. So `bridge fdb show` will show entries like `dev swp0 vlan 1 self` even on a VLAN-unaware bridge. The blamed commit does not solve that issue completely, instead it may cause a new issue that FDB is inaccessible in a VLAN-aware bridge with PVID 1. This series sets PVID to 0 on VLAN-unaware ports, so `bridge fdb show` will no longer print `vlan 1` on VLAN-unaware bridges, and that special case in fdb_write is not required anymore. Set FDB entries' filter ID to 1 to match the VLAN table. Signed-off-by: DENG Qingfang --- RFC -> v1: Detailed commit message. Also set FDB entries' FID to 1. drivers/net/dsa/mt7530.c | 4 ++-- drivers/net/dsa/mt7530.h | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c index 8d84d7ddad38..ac2b45e472bd 100644 --- a/drivers/net/dsa/mt7530.c +++ b/drivers/net/dsa/mt7530.c @@ -366,8 +366,8 @@ mt7530_fdb_write(struct mt7530_priv *priv, u16 vid, int i; reg[1] |= vid & CVID_MASK; - if (vid > 1) - reg[1] |= ATA2_IVL; + reg[1] |= ATA2_IVL; + reg[1] |= ATA2_FID(1); reg[2] |= (aging & AGE_TIMER_MASK) << AGE_TIMER; reg[2] |= (port_mask & PORT_MAP_MASK) << PORT_MAP; /* STATIC_ENT indicate that entry is static wouldn't diff --git a/drivers/net/dsa/mt7530.h b/drivers/net/dsa/mt7530.h index 53b7bb1f5368..73b0e0eb8f2f 100644 --- a/drivers/net/dsa/mt7530.h +++ b/drivers/net/dsa/mt7530.h @@ -80,6 +80,7 @@ enum mt753x_bpdu_port_fw { #define STATIC_ENT 3 #define MT7530_ATA2 0x78 #define ATA2_IVL BIT(15) +#define ATA2_FID(x) (((x) & 0x7) << 12) /* Register for address table write data */ #define MT7530_ATWD 0x7c