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: 491369 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 15F19C4320A for ; Tue, 3 Aug 2021 16:04:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E193261078 for ; Tue, 3 Aug 2021 16:04:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231410AbhHCQEg (ORCPT ); Tue, 3 Aug 2021 12:04:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231327AbhHCQEe (ORCPT ); Tue, 3 Aug 2021 12:04:34 -0400 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B948DC061757; Tue, 3 Aug 2021 09:04:23 -0700 (PDT) Received: by mail-pj1-x1033.google.com with SMTP id g23-20020a17090a5797b02901765d605e14so5326759pji.5; 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=hfnufSEen/6Um5vOAcKARGrbONq/kVGZLliORpVUSC0lx+junRDTh3tSYH1C1JzS2A JTVDXwHc1arH9pDgcZIoYVsB3Tfl/EZItEKg0dPYGB8oE08l+cAnV6JrSV2Lq9LKZygu UPOLjW28YMUgsVCUid3RbPvD4gp/IUH/+cz5WTi8MeVD6CutH8+nuv/ma7VkncEyReWC y6BSHtUichyY6JqKBoJh1yBmsMpYVn6l+JXyW8CMGDFNln/BQ0o1sj0yhneT96KPA6em 809jGHwlCmlyvk4Dudq7BK/gPDpnIuRt0QcZdoCoRshtVz1EhMxE62A750xaVmjYe85e QMRA== X-Gm-Message-State: AOAM533Jr4s0iAtItI12v0r/bk+Iici1CBSWTMX7B0QnVnSZpSHZmJPP SDvyfMet/5kSMtRXV136VHI= 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 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.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: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: 491368 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 B36C9C4320A for ; Tue, 3 Aug 2021 16:04:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9C64F61101 for ; Tue, 3 Aug 2021 16:04:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231523AbhHCQEy (ORCPT ); Tue, 3 Aug 2021 12:04:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231659AbhHCQEv (ORCPT ); Tue, 3 Aug 2021 12:04:51 -0400 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93DBEC061757; Tue, 3 Aug 2021 09:04:37 -0700 (PDT) Received: by mail-pj1-x102f.google.com with SMTP id mt6so30265084pjb.1; 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=Ez03jqJpsgo2pNeJfrrL7xJS55ucLBZrnbu3wknXD8ZX/OfgooQb2I8qBZSUkv/GeG zz35VR3UBMiD4zh7tQ7XzlFrfuck1dLZXOib2hhbz8F1f8vbgKbE2DZiASasVFCAJfk0 5GadMQjgIOm18SL2bbVsKDlkN6R3Z/7xAQ/3q+9ynmgbHNb2Ta8rzRdQIZfdfndG3VKa vc5jNLbE+wQZNHFXAYIHU8fDk0J7PrYHMMxoan6wBWXoPSvHg066GWXWeRHOQK993P4+ ANZM3IZgX3C78v6iMA3BY14FCEa5AgNSed1cH0GEhLyyd/R2NCeo+vJdG/cTcNpOtc+x hsbg== X-Gm-Message-State: AOAM532fjO6QCA2v2P9csPNMB71oR/kbrzHQov0+2qhFrGujIXgDwIIa s06FeL3h65IeGEvT8ZGGuvQ= 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 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.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,