From patchwork Tue Aug 3 16:04:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qingfang Deng X-Patchwork-Id: 12416709 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 10572C4338F for ; Tue, 3 Aug 2021 16:06:43 +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 CB90B60187 for ; Tue, 3 Aug 2021 16:06:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org CB90B60187 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=4VHnurJ52LD6oJH1EES2uYZoBzvrVljKQQnBs1oNukI=; b=EYllImA/3Xr1Qr 3GtB12mHm39THHIx+HnBiR9MxpYaONJXOGyfWRzHBGji/kN76YC0In0KePXWSl5+O21szx5motsD6 QYlH361LCEf4VmU6Ve7fcK7J9KXAsbdCcQvJ+aMv09L/rlwzHmwQmKSPnVFDpLDxzpdVtvdT2uxGk Zq5oRA+S8t0MZmnhxsLs81N428pN7Yqq1gVWaA5IgPQKk1Hf6AnXzSIwYNxaoOPL5a/Cr4Y8Plxhj betwUDiOn8auGKEMYOUCjW7I+VBR2vRcqY6+9hr3qqaRL0XcVJn0qBdqGamYOtJ2FaN5UfO/gUzQA UvsBbZVvmvg4R7oKaIvg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mAwu8-003WS7-Sl; Tue, 03 Aug 2021 16:04:33 +0000 Received: from mail-pj1-x1035.google.com ([2607:f8b0:4864:20::1035]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mAwu0-003WQf-C2; Tue, 03 Aug 2021 16:04:25 +0000 Received: by mail-pj1-x1035.google.com with SMTP id pj14-20020a17090b4f4eb029017786cf98f9so5357506pjb.2; Tue, 03 Aug 2021 09:04:23 -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=4DDzV8/Fk1hQnq24aZe35CXn12AVhJ1i/aTFMFKXbn4=; b=okNC+95eqklwvX4zzy4qD21U1kMduj63CtRXA06V5Amw8XOIBhmMIV94OVgWUE7CY8 DSisxbhuSmUI8zFKabPhDSo0SRLOmEn2I1ZI+JMVQZyW8fTOaK/JnSPBjvjxz64A2OUs 7vhlyD5d3InukEjdCv9uW9Z1zKdmIGdEnEIfUP7JKh+i3HM8Ir+KCn0JSJSWN+a+UcxR zhHMLBrXihkhTTLnw4Ul9Oym3uHDuhWwg3UtWxC53eOqCCpWBwWxRJ2D5WAY/Xosc74f x7w2eWKAyv+fjEeNurlAgsWi8juyXarv915JGKd6yeqwsVKSGSpgJgVtlV+kNdg3Wk83 sMPg== 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=4DDzV8/Fk1hQnq24aZe35CXn12AVhJ1i/aTFMFKXbn4=; b=Qoh8gRDlrtTiwtVMgMNYEYsodVKkLd0LY30gr1E5O8y7QJ1H9e0JR97fgybgJJ0pU3 KbLtKCexA72H/V0DU1Axd+3gptZC2/+2thWdyOv7nO3V8IJlHzpkHK2p56J1RtkQBrrn lf9GSJLfnXjuRHxJyzZBI7p3k0T5KhaWv3gJHKQdV8PUPAqMEsAKq87hj9Oj/Odg83ah fLTM8dZk0dd88KBi8ZC/6iB/0fng0EfMyAYSyGfrMLtCOwQ56JRMZcOdkNZX6JVoXmCV FXXBSrZEHAYrXzS63hxGXgwWeHK1Ky/NwXciZvXD6SnwRso0D74ja1gtcMZompysnhuC 3QZw== X-Gm-Message-State: AOAM532vaqXfAeuZkvM+LR5kBiHyfbSEPCBVu4ICH+Hc9WPymXgNbkgX KPekn+DZpaMfW/mU6ZalUG4= X-Google-Smtp-Source: ABdhPJwcMc7pBn9npc80n0nNmDQDDZpGDghJbvj7Xmc/kAG5aDm7AWrnBKfIYlEynAavc3DkERbqYw== X-Received: by 2002:aa7:9115:0:b029:359:69db:bc89 with SMTP id 21-20020aa791150000b029035969dbbc89mr22573713pfh.32.1628006663340; Tue, 03 Aug 2021 09:04:23 -0700 (PDT) Received: from haswell-ubuntu20.lan ([138.197.212.246]) by smtp.gmail.com with ESMTPSA id y6sm14390653pjr.48.2021.08.03.09.04.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Aug 2021 09:04:22 -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 v2 1/4] net: dsa: mt7530: enable assisted learning on CPU port Date: Wed, 4 Aug 2021 00:04:01 +0800 Message-Id: <20210803160405.3025624-2-dqfext@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210803160405.3025624-1-dqfext@gmail.com> References: <20210803160405.3025624-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_090424_458467_96620ECE X-CRM114-Status: GOOD ( 14.09 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=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 --- v1 -> v2: 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 16:04:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qingfang Deng X-Patchwork-Id: 12416711 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 9911EC4338F for ; Tue, 3 Aug 2021 16:06:50 +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 68F0960725 for ; Tue, 3 Aug 2021 16:06:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 68F0960725 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=M8gywX288jJCxPUlF/xzFxn5b903W2dqIWAQRmIv7T0=; b=ofJahVDpncUGlp JJauFWcn+SodXo3j8Bohxwnpg2QF2OSx+eDWNhQMTrUcFH7P3GvUsi7T3hA6DRvtapZFM6M/R76ll PtL9ePy7Fi6SA9yD0IYtVTUOXwm1TOKkNJ8Aoqux+n+UfMBsuzGipf6+ZyjwEc1inPq93gACce9yd tuzsvS91D1JEbQWZ7P27TCtUCXvTB1oNCQHRq4fcK58g8qakzZHiBWElFrSCmh0cLtWqnctHmf2Id h/qeZ3F55xjkx7QGsugRnqHKzil4QC8Y4vdjgxCWnqAg1QBowFpd5eYatHOb5AYi0z1MUGex+EHzo 6z794aFJyVvj7qriuQfA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mAwuL-003WVE-2G; Tue, 03 Aug 2021 16:04:45 +0000 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mAwu7-003WRk-Ce; Tue, 03 Aug 2021 16:04:33 +0000 Received: by mail-pl1-x62e.google.com with SMTP id t3so22186608plg.9; Tue, 03 Aug 2021 09:04:30 -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=trHX3dNNxUniX6odh5y30TfJPrJF2MKuXcijydie94Y=; b=NfG7+rxcLJmBodWpezqUR4cmNXccL1ppNPmGHayEAk1rKL2Q8lDgU/tydcniRSfz0q Hk1skwGADBUIDidM11A5sVl4FFhQcCqj233cmWTMxFu2hcUEWTOplAOfUClyo0yBgQmq 070yL3QqqflzfK3bdgq+jVNmVUwSBcoPYapIJWrxdb48iefYC9WFnpbebvXWSLVSCVAo oi8f+1BKSiXsBCXbN3NPtoaiANnWJpeDRTlCOzeLjkW6MZIjegCzy964C82SI1mlsdAT auy+W4K5YxemXFKjQ0NcjFtN2ztmpBdC5n9F6o5OUSy85rBByZBNt4tccS9lltvAfeEp AMbg== 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=trHX3dNNxUniX6odh5y30TfJPrJF2MKuXcijydie94Y=; b=WUw8Kk7f6rFu5E5zbwmCV8nVW5pZyPBxWnCEYVCw0aLs40kQZUKv8nuSvTgvsI1prZ Ze+9La4K9kCYFJdGaza564lgf7q6SsgEj2YMMdyJrNKxGg5IwqO5Ls0dbVtKTWRQ2ofc Q094Dw9+erRwN4Qg7FbS3oh3uCGzXL1aMKtM+dqhNub76JWRysDZsKxtub08D1nbCnne BpsvKabpa69zDq7CGv9UAdl8k+caLBjfgJW8Cjp8GywL5wd/vZbXrGy6XQuuA2SXf8Cb /NbMHK3gVzaNIKToPIwK7DCNbaLpM532fSlkw2IzvwkFKcU7APDsC6rZu4+Gu9UjAsTd lSIQ== X-Gm-Message-State: AOAM532ksrO94gVmbhB0m1Oz2UvdjuGnIQwJN/stpHrsqMbiIGbKpmEc lWA6gxmPPzhUGW6jpJzaq6g= X-Google-Smtp-Source: ABdhPJzsOMAtDWMmETjJ8Y08EB4KiUxjyEx0F7EmMrQAkkBaEy/ytg3ad8G1rlSQPG/nlvMV272UrA== X-Received: by 2002:a63:4a43:: with SMTP id j3mr696633pgl.302.1628006670264; Tue, 03 Aug 2021 09:04:30 -0700 (PDT) Received: from haswell-ubuntu20.lan ([138.197.212.246]) by smtp.gmail.com with ESMTPSA id y6sm14390653pjr.48.2021.08.03.09.04.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Aug 2021 09:04:29 -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 v2 2/4] net: dsa: mt7530: use independent VLAN learning on VLAN-unaware bridges Date: Wed, 4 Aug 2021 00:04:02 +0800 Message-Id: <20210803160405.3025624-3-dqfext@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210803160405.3025624-1-dqfext@gmail.com> References: <20210803160405.3025624-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_090431_483348_670D7FF7 X-CRM114-Status: GOOD ( 30.88 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=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 --- v1 -> v2: use FID enum instead of hardcoding. drivers/net/dsa/mt7530.c | 71 +++++++++++++++++++++++++++++----------- drivers/net/dsa/mt7530.h | 9 ++++- 2 files changed, 59 insertions(+), 21 deletions(-) diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c index abe57b04fc39..606a9f4db579 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,8 @@ 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(FID_BRIDGED) | + VLAN_VALID; mt7530_write(priv, MT7530_VAWD1, val); /* Decide whether adding tag or not for those outgoing packets from the @@ -1601,9 +1621,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 +1641,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 +1651,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 +2149,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 +2320,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..d44640bbd865 100644 --- a/drivers/net/dsa/mt7530.h +++ b/drivers/net/dsa/mt7530.h @@ -148,11 +148,18 @@ 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 #define PORT_MEM_MASK 0xff +enum mt7530_fid { + FID_STANDALONE = 0, + FID_BRIDGED = 1, +}; + #define MT7530_VAWD2 0x98 /* Egress Tag Control */ #define ETAG_CTRL_P(p, x) (((x) & 0x3) << ((p) << 1)) @@ -247,7 +254,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 16:04:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qingfang Deng X-Patchwork-Id: 12416713 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 4ED51C4338F for ; Tue, 3 Aug 2021 16:06:57 +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 17A0460725 for ; Tue, 3 Aug 2021 16:06:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 17A0460725 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=sBlpWQimzosLlkJwzwkqjfjWTIo3cWsvh9mWPuFSrsI=; b=RmFwugjKzwBrki Z6taB4zvpTDkv9wQkMqtQk/rcLxjJo8CFLZto7sxZUPU8tksgGM+QfiGjHAiLJI8GkylzHirI1+k/ eAyqnRVtFfIyEMw70Ds0qDFxhrf5ZPWg5f4I9nTQUcAIuppUH0zQnTQnV5/fLa1puDrbAJIyHANGQ u1sNVCR1vwfx3flTpjRb5pzg81GocHNkxXcWsMRt6/hUANFiRrG6lRhr6xovxdAuwhzJwMKKnh8yX YrRJapBzIhK6ZyeKv6XQr17yyjQDp89ZBMGHiB7xL7MIWvQ6jw3kuGgOPO8FgyObaGsnd1g8QGkoV txD5S0RLtg4buQyteIQw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mAwuZ-003Wbs-Lq; Tue, 03 Aug 2021 16:04:59 +0000 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mAwuE-003WSz-79; Tue, 03 Aug 2021 16:04:39 +0000 Received: by mail-pj1-x102c.google.com with SMTP id ca5so30181274pjb.5; Tue, 03 Aug 2021 09:04:37 -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=rFG+y2/f0kIS+1piSi01lqKfhQxPbZdynLRltnbgxiQ=; b=b4ukp4ubuRoZUf5QUsgGIX5Z8hvILnPKu2bruY8jXI93TywzIyFGzaosjq4ZjaNoAC OKdQZZJ06HFDVSEohb37uw6lIL88NyO5QjsVGO0KoSM/rbmyRPcvJzuP6Qh3bGN9zyul alerxWFjJxOIGbCUqIZGOXxcxx7QHqCQBazx/skeJLZLvZixB9/WZfmx7Wxi4RZpE/WS E3kmThx1F+PtgAXmLlYi4AsW3TzJoFxMLq4dkOsy+A6ym1ZMYGm+dns1Wgd73GlDasVH 7P5x9yiaipdWdfFRLVnsY9pdTOua3l35OpEPyzZdHquo5u6TBeWZa9zW9T1AgPjqBbgu VtUw== 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=rFG+y2/f0kIS+1piSi01lqKfhQxPbZdynLRltnbgxiQ=; b=KMRLGAAE4feaQZjAkJw0ZFE/QCfV4p8xe7cL0xxYIAaNebUefY1kuS3rxh6L+v+roK 4W4NQJEJuY6RqV0tRwqBH/uBcyFIheb7rIJHB8Y4etY68oUb4UJSMNPqz++EsGljOVwy /9J68BUNSkONRXS0+R8C5teEiuU/lNaIfAdKU/uQy89lFJ+KmmkWwplGYPQdW5f2tBsE Fo5+zne4GXAFKAk4+Mqgj21dbO6+xIkQAmQZaxvtzQNT0AmV0aCoguMb6WLwa+EWxJxD gxXuGqesJrnuiQNTezr3nV/9+MqD/ghXT+EEhBjmyYlG9PAAOhyRHAUEzPNgvMdfK5+U juQw== X-Gm-Message-State: AOAM533wG93u/KET3It7vjvT3rCad1USeTuJUdC6ea0LWRkAu71TKUuF I3s9oubqxSywGRzoyZRC1Gs= X-Google-Smtp-Source: ABdhPJx4BoskHpHIo9eH9vJqEQqPWI4dffs5KXtrUgvidGJ1BKKYoycFmaK2P+nodC/c528ekaPG3A== X-Received: by 2002:a63:62c7:: with SMTP id w190mr288455pgb.55.1628006677214; Tue, 03 Aug 2021 09:04:37 -0700 (PDT) Received: from haswell-ubuntu20.lan ([138.197.212.246]) by smtp.gmail.com with ESMTPSA id y6sm14390653pjr.48.2021.08.03.09.04.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Aug 2021 09:04:36 -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 v2 3/4] net: dsa: mt7530: set STP state on filter ID 1 Date: Wed, 4 Aug 2021 00:04:03 +0800 Message-Id: <20210803160405.3025624-4-dqfext@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210803160405.3025624-1-dqfext@gmail.com> References: <20210803160405.3025624-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_090438_310365_C753067B X-CRM114-Status: GOOD ( 12.72 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=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 --- v1 -> v2: use FID enum instead of hardcoding. 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 606a9f4db579..9b39ccd9dd4c 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), FID_PST_MASK(FID_BRIDGED), + FID_PST(FID_BRIDGED, stp_state)); } static int diff --git a/drivers/net/dsa/mt7530.h b/drivers/net/dsa/mt7530.h index d44640bbd865..5b70ccef9459 100644 --- a/drivers/net/dsa/mt7530.h +++ b/drivers/net/dsa/mt7530.h @@ -186,8 +186,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 FID_PST(fid, state) (((state) & 0x3) << ((fid) * 2)) +#define FID_PST_MASK(fid) FID_PST(fid, 0x3) enum mt7530_stp_state { MT7530_STP_DISABLED = 0, From patchwork Tue Aug 3 16:04:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qingfang Deng X-Patchwork-Id: 12416715 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 3BDF6C4338F for ; Tue, 3 Aug 2021 16:07:11 +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 0064F60725 for ; Tue, 3 Aug 2021 16:07:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 0064F60725 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=zG1/PJJ9ID4dJOWODJVDYUy7TJIMeiIuo/cGQ5c4Oms=; b=DJmweCqo9yRsUX ZgHlhI1WZuC6EEIkFtsFzUMoFWXzupTm5adIhxAZiyXrGEPJ038Ys4i4k3l9mHvkVY2BP7tHIbJt+ /pmMLg4MCB2fmtNPf4dRb/cTIUootNpaKwyF3R47kUQX50rPpEz9MydD/+ZksIs3mGzIMWpo9gQOK Hc8DpnoJlUKMUrqRZJu6MoRv6ykjfjHZizAQNppnUxsCS+hlMC7H1sfxMPvKrQOgD1FxgJmOHY2Sv yGoMaOXYjHPJjhv8+1ITYW8cG5ke5WvymbiFn7H1+65C8UTbeFlyF0ZF+TD6Dlf1XsqneCvLyphLp qfJM/pyLR8L+ulR0lUTg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mAwus-003Wkz-Bd; Tue, 03 Aug 2021 16:05:18 +0000 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mAwuL-003WVM-0L; Tue, 03 Aug 2021 16:04:46 +0000 Received: by mail-pl1-x630.google.com with SMTP id q2so24273085plr.11; Tue, 03 Aug 2021 09:04: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=8uiSeD2OkBp9zNpUDtNBLvudtMpehXughyaF6cE7kWE=; b=HI/RNgsTbqZEYCiV99s2NdnzjSSL+jfEFNFwt9FPZJ+Ru6ksZeQK6DBubeeiqi8Nul RmjCDvqRoFbmQfnMP5QlNwwFCceSlVwmwDF45xDsL5gR77eoei+zQMAFwg8umjkmZ7Hp zb4gX8VrzX0VQ1V8m1tnb0+3e10Nyt7N5WxyY8RzdQZFBtg0HMFSYKA6JRaP30Xx0VKU ZhYFitTn78WccAQOmO9Bp/vm4B1nspHMVV2m19O2sKs6Vn5sOuYoI3o0D3YuPrxGA0Tw 6MR2MQUmgaBq63GbpLiDQFYCEFxWj05lL12rhWQVKFz1cbvbieAg0cn+0rHw1RZE73AG 3hZw== 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=8uiSeD2OkBp9zNpUDtNBLvudtMpehXughyaF6cE7kWE=; b=O/VDcN8FPzCa7X3h1zZkV1YXn1tdF2TLnEqF3yGYM/OPY0/535flfHzaMAyQFY5pIl Ga34YUzVqyT+Qy+lSEXul2qrUTgov3gILIYDyR9MUj6Lf3ZResPZ88WUQRGynoNzYHuV F2VMjHAJTPgF070kSbAgk1MNbeWkB1cjbB9szSkNVp/w3FqvUKNrV9bGcCVSS+ZjHl94 71qqgez8JNFZiXS+7aIvyUZwQ/KHe3tO5yW3AMlU328rTdVV3WLbkpfbYzJz9wrJgjnr CjcIMNoi4qVaA4JbiGfQo+0wHe+/g2ZRbyxYBVin8TvGbgMRPzHtBVUQvvYxb0BDdgpE j9Ng== X-Gm-Message-State: AOAM530z2nbfHcYfWWZ55VRos/AP4LEQ97zJbnXlo+P7ze93nzSwEkix kd0RxdLJnAcs8e7o3nqjO7M= X-Google-Smtp-Source: ABdhPJw+fGGwGF0JHyEBaBOf/DvOOVRTxWlUrlvdTntEmvDFQ41cynm/vgr3kcX399C4DfTcv1ip5A== X-Received: by 2002:a17:90b:344d:: with SMTP id lj13mr4940643pjb.24.1628006683927; Tue, 03 Aug 2021 09:04:43 -0700 (PDT) Received: from haswell-ubuntu20.lan ([138.197.212.246]) by smtp.gmail.com with ESMTPSA id y6sm14390653pjr.48.2021.08.03.09.04.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Aug 2021 09:04: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 v2 4/4] net: dsa: mt7530: always install FDB entries with IVL and FID 1 Date: Wed, 4 Aug 2021 00:04:04 +0800 Message-Id: <20210803160405.3025624-5-dqfext@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210803160405.3025624-1-dqfext@gmail.com> References: <20210803160405.3025624-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_090445_095971_8FD9BB3A X-CRM114-Status: GOOD ( 15.14 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=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 Reviewed-by: Vladimir Oltean --- v1 -> v2: use FID enum instead of hardcoding. 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 9b39ccd9dd4c..385e169080d9 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(FID_BRIDGED); 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 5b70ccef9459..4a91d80f51bb 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