From patchwork Fri May 12 07:27:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alexis_Lothor=C3=A9?= X-Patchwork-Id: 92984 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp4921753vqo; Fri, 12 May 2023 00:54:04 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4Z82qHBmNEQ1QQyiffINQSs2Fe4loWvU/UV+QS/gHT2ZEpcuC2g3/OAFavnYVlKT0iHdt3 X-Received: by 2002:a05:6a20:8f15:b0:103:b073:7a57 with SMTP id b21-20020a056a208f1500b00103b0737a57mr8120803pzk.23.1683878044389; Fri, 12 May 2023 00:54:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683878044; cv=none; d=google.com; s=arc-20160816; b=rFB4AtYH03phGDsLYS0wZ1+RowT1mOXjhQOB1DnCamrAgEifQae7EZTxtvi4INPSCB tCSFwt9HB4Pwm6BfdEt1y8TLakRpUqemE02i1ymGOopHRjh46p1I6SA6AMMJGy3tSjve ln2shG+YY1YR4oZCd1RssZ7EgMDHq45Jo7M1GmZyEsLUV52diXIgMTA0qU24Uyg53aL5 avH8H7N0qAQjBmOWqwTvzll1XZLTIT131uuDVSJLqzvx1p/3oCXUZZ/dp6G6CbcTnQ6h OWZfsm401Z3W3Jf9iwrgxkHWREJ2Ss1mIjay1sFAbQMDEH93fUxPExOgvcgj07JSEzm2 5/sw== 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=S6O6XHXGaPQp8FhdtCIzdi0IiRWPnFwN+hdXiZOfHu8=; b=PBhTac/+8iWEatMa2pAepUiYoM/rWMXRVOEgHImOaWlaGqSjiPeU+rCPNstEm9utmT bA5/rKMwjzfYwl1LAV/hPGvGvkfJQwAEGsjLNzzb5y6S3fYzgOJi24Q2ZFJ5R+uqSLqR yIAIhkTSNKy/WkGhL+q3afGb4j9u2M+9yVuc8VoAZtQtvfXcZu0MEQpg8tvZGkq6nBTG he0aPPbayv7KrBXeiA29jADV9Mzh4bHxnZC+VIPR+UAkSSo7ZzQaa29xNSVksC0v854r mFiLlDZoP/dOElUsyFv3maFeFah+e4HC2ppzbh1V5uCXEgriw3fqIiLU3vK99bH6AGOJ +aYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=KxyvAbq0; 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=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 20-20020a17090a199400b00250bbca6fdfsi7917221pji.105.2023.05.12.00.53.51; Fri, 12 May 2023 00:54:04 -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=@bootlin.com header.s=gm1 header.b=KxyvAbq0; 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=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240224AbjELH1I (ORCPT + 99 others); Fri, 12 May 2023 03:27:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240168AbjELH1D (ORCPT ); Fri, 12 May 2023 03:27:03 -0400 Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::222]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5427E1FD4; Fri, 12 May 2023 00:26:59 -0700 (PDT) Received: (Authenticated sender: alexis.lothore@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id 225884000A; Fri, 12 May 2023 07:26:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1683876418; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=S6O6XHXGaPQp8FhdtCIzdi0IiRWPnFwN+hdXiZOfHu8=; b=KxyvAbq0qWquWrLLwZW0T1Qb1kS7X4uEX5m8UuleodbIqLG5sE+Eg/oAfw2ot0xOJWBCFu 1qp9jjhi7q0J2KkZ5VoJBxsI5rXp7pZ6eOvwup6rhHhvJj5F/RyOznMRtzykfGgh+aKufE v0q5Oq/n7eu4A6XYq5aiDcfsBVyPr/6f1ps8J6hLt7clc+yEKy+j3KzWwMw57euKT0KIfd EDyMweb/TBLONwViuJkxv72vuzyqr4gKns4grC+nr5qlXRf2FXCxzoRF1YnmBY5C5O2ZnD aBkj4nO8Zm1R33K7T3eiCm89vYwCEgMZJOQqP0cRyc2cdNmTZ1WnSxj8MApJDA== From: alexis.lothore@bootlin.com To: andrew@lunn.ch, f.fainelli@gmail.com, olteanv@gmail.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: linux-renesas-soc@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com, herve.codina@bootlin.com, miquel.raynal@bootlin.com, milan.stevanovic@se.com, jimmy.lalande@se.com, pascal.eberhard@se.com Subject: [PATCH net v3 1/3] net: dsa: rzn1-a5psw: enable management frames for CPU port Date: Fri, 12 May 2023 09:27:10 +0200 Message-Id: <20230512072712.82694-2-alexis.lothore@bootlin.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230512072712.82694-1-alexis.lothore@bootlin.com> References: <20230512072712.82694-1-alexis.lothore@bootlin.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765674104280402215?= X-GMAIL-MSGID: =?utf-8?q?1765674104280402215?= From: Clément Léger Currently, management frame were discarded before reaching the CPU port due to a misconfiguration of the MGMT_CONFIG register. Enable them by setting the correct value in this register in order to correctly receive management frame and handle STP. Fixes: 888cdb892b61 ("net: dsa: rzn1-a5psw: add Renesas RZ/N1 advanced 5 port switch driver") Signed-off-by: Clément Léger Signed-off-by: Alexis Lothoré Reviewed-by: Piotr Raczynski --- Changes since v2: - move A5PSW_MGMT_CFG_ENABLE definition in this commit --- drivers/net/dsa/rzn1_a5psw.c | 2 +- drivers/net/dsa/rzn1_a5psw.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/dsa/rzn1_a5psw.c b/drivers/net/dsa/rzn1_a5psw.c index 919027cf2012..8a419e2ffe2a 100644 --- a/drivers/net/dsa/rzn1_a5psw.c +++ b/drivers/net/dsa/rzn1_a5psw.c @@ -673,7 +673,7 @@ static int a5psw_setup(struct dsa_switch *ds) } /* Configure management port */ - reg = A5PSW_CPU_PORT | A5PSW_MGMT_CFG_DISCARD; + reg = A5PSW_CPU_PORT | A5PSW_MGMT_CFG_ENABLE; a5psw_reg_writel(a5psw, A5PSW_MGMT_CFG, reg); /* Set pattern 0 to forward all frame to mgmt port */ diff --git a/drivers/net/dsa/rzn1_a5psw.h b/drivers/net/dsa/rzn1_a5psw.h index c67abd49c013..b4fbf453ff74 100644 --- a/drivers/net/dsa/rzn1_a5psw.h +++ b/drivers/net/dsa/rzn1_a5psw.h @@ -36,7 +36,7 @@ #define A5PSW_INPUT_LEARN_BLOCK(p) BIT(p) #define A5PSW_MGMT_CFG 0x20 -#define A5PSW_MGMT_CFG_DISCARD BIT(7) +#define A5PSW_MGMT_CFG_ENABLE BIT(6) #define A5PSW_MODE_CFG 0x24 #define A5PSW_MODE_STATS_RESET BIT(31) From patchwork Fri May 12 07:27:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alexis_Lothor=C3=A9?= X-Patchwork-Id: 92983 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp4921679vqo; Fri, 12 May 2023 00:53:53 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7pye+6DiihfE5+s/N6HqCSzUUzYJlxsDC2sHVaTcmYhWlNRTxv+7vhcXooLpYwjHu1qoXq X-Received: by 2002:a05:6a00:2d0b:b0:5a8:9858:750a with SMTP id fa11-20020a056a002d0b00b005a89858750amr26325228pfb.13.1683878032902; Fri, 12 May 2023 00:53:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683878032; cv=none; d=google.com; s=arc-20160816; b=xk8hREUFTxpf+J60/vFV4+eJ/EVvnVQ00FRmrdJuXaAF+Nl8l2GWQSpoTF4KvM464a XqttI+bmTS5f7fkyKZP5H+pMk2f0U7XloN6tmjYWsGZ0UhpB5OAYWeQMYSZcWrOz7Fyl 6fsDbguVmD0ipoaOlQ08MYlWJvzdzOFwf22mgNhsB75rXclP1X2FG11kVKuBxmiKz7gr /K+NYYTezMx7xqlhBy8x6EIUwm3GmNX4BdyMP7GcmMDlbjF5G0NnZYuLB6jBzec78hj1 Xgqh9s9X9t+rM9wGVC47QqVrLRaYonVOSMolTOv3Kf2aX443bb+qojzB6Tr9+lzfN0Eu rBdQ== 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=e7DWsb2bbWPMA2AP2i+pXEq6IQCsDHi3ExOEOjVPOZU=; b=QoK5A0q9p8KYJcBMEA/JoHxIXdpSJL/yLp3h+vIwxCexe8qUhd3VKw4VdXBCR0zLgN KqfOcH2lTj34zWtrI7PQpPO3xYAAYvFVw8y92TJ6be0suYxCDD1xztgh9j1ByyaPM/GB Q0LiALsYckywoB9HOR8JfTD+6Lj16Yda1pl8NnFFKzZdNaJL7viw1917zEla7uT+p+D3 vNtUy2Ih+16Qscaubf8fUTv7Z1StL8w8ap7+DUnrLhy8YzoujXmptbdQjjVi/Vxtv5ao Gw+kVESPLHLpQ4ryikOK7oTXoCfrIelJhwfBrrErUDNXd8eWNu+HypodvLrySSZz95+b zRfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=m9n5tt+Z; 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=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z6-20020aa79586000000b006432e218a1csi9578617pfj.152.2023.05.12.00.53.40; Fri, 12 May 2023 00:53:52 -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=@bootlin.com header.s=gm1 header.b=m9n5tt+Z; 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=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240241AbjELH1L (ORCPT + 99 others); Fri, 12 May 2023 03:27:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240188AbjELH1E (ORCPT ); Fri, 12 May 2023 03:27:04 -0400 Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::222]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9019C2100; Fri, 12 May 2023 00:27:01 -0700 (PDT) Received: (Authenticated sender: alexis.lothore@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id BC13440009; Fri, 12 May 2023 07:26:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1683876420; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=e7DWsb2bbWPMA2AP2i+pXEq6IQCsDHi3ExOEOjVPOZU=; b=m9n5tt+Z/tF7gWxhHI4SmPyVa6WagQF81cpc1jEOVqQnXKKO0WgHUSQUfAIRK4Jvw0hu5C aEFk9C97Jp1zY84PruTHMMrZx68A200kguRtwslh5ydoig3SoqYwXaOVwSJSprD40tVkPR AkCBsJBRH0h1tWG7Rd+ZJ8Y5j3Bk+yDbkOJJuMyyPny7VVrphRVGUKrDLhFEGj2TB2UB00 3qdPyz11LwyqcsUPtLA3ZAOTyafCldhn/la5zPHJFZjM6ms5+DclCsg2fnn/z+w/NF1GU0 5m2Ngj5ryEH6NDSU9nNtbc80j04NgI+7JrxcsEHKKlqOJSMameJuOa3KO5Aa5A== From: alexis.lothore@bootlin.com To: andrew@lunn.ch, f.fainelli@gmail.com, olteanv@gmail.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: linux-renesas-soc@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com, herve.codina@bootlin.com, miquel.raynal@bootlin.com, milan.stevanovic@se.com, jimmy.lalande@se.com, pascal.eberhard@se.com Subject: [PATCH net v3 2/3] net: dsa: rzn1-a5psw: fix STP states handling Date: Fri, 12 May 2023 09:27:11 +0200 Message-Id: <20230512072712.82694-3-alexis.lothore@bootlin.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230512072712.82694-1-alexis.lothore@bootlin.com> References: <20230512072712.82694-1-alexis.lothore@bootlin.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765674091795441315?= X-GMAIL-MSGID: =?utf-8?q?1765674091795441315?= From: Alexis Lothoré stp_set_state() should actually allow receiving BPDU while in LEARNING mode which is not the case. Additionally, the BLOCKEN bit does not actually forbid sending forwarded frames from that port. To fix this, add a5psw_port_tx_enable() function which allows to disable TX. However, while its name suggest that TX is totally disabled, it is not and can still allow to send BPDUs even if disabled. This can be done by using forced forwarding with the switch tagging mechanism but keeping "filtering" disabled (which is already the case in the rzn1-a5sw tag driver). With these fixes, STP support is now functional. Fixes: 888cdb892b61 ("net: dsa: rzn1-a5psw: add Renesas RZ/N1 advanced 5 port switch driver") Signed-off-by: Clément Léger Signed-off-by: Alexis Lothoré --- Changes since v2: - move A5PSW_MGMT_CFG_ENABLE definition to previous commit - fix reverse christmas tree ordering in a5psw_port_stp_state_set --- drivers/net/dsa/rzn1_a5psw.c | 57 ++++++++++++++++++++++++++++++------ drivers/net/dsa/rzn1_a5psw.h | 1 + 2 files changed, 49 insertions(+), 9 deletions(-) diff --git a/drivers/net/dsa/rzn1_a5psw.c b/drivers/net/dsa/rzn1_a5psw.c index 8a419e2ffe2a..e2549cb31d00 100644 --- a/drivers/net/dsa/rzn1_a5psw.c +++ b/drivers/net/dsa/rzn1_a5psw.c @@ -120,6 +120,22 @@ static void a5psw_port_mgmtfwd_set(struct a5psw *a5psw, int port, bool enable) a5psw_port_pattern_set(a5psw, port, A5PSW_PATTERN_MGMTFWD, enable); } +static void a5psw_port_tx_enable(struct a5psw *a5psw, int port, bool enable) +{ + u32 mask = A5PSW_PORT_ENA_TX(port); + u32 reg = enable ? mask : 0; + + /* Even though the port TX is disabled through TXENA bit in the + * PORT_ENA register, it can still send BPDUs. This depends on the tag + * configuration added when sending packets from the CPU port to the + * switch port. Indeed, when using forced forwarding without filtering, + * even disabled ports will be able to send packets that are tagged. + * This allows to implement STP support when ports are in a state where + * forwarding traffic should be stopped but BPDUs should still be sent. + */ + a5psw_reg_rmw(a5psw, A5PSW_PORT_ENA, mask, reg); +} + static void a5psw_port_enable_set(struct a5psw *a5psw, int port, bool enable) { u32 port_ena = 0; @@ -292,6 +308,22 @@ static int a5psw_set_ageing_time(struct dsa_switch *ds, unsigned int msecs) return 0; } +static void a5psw_port_learning_set(struct a5psw *a5psw, int port, bool learn) +{ + u32 mask = A5PSW_INPUT_LEARN_DIS(port); + u32 reg = !learn ? mask : 0; + + a5psw_reg_rmw(a5psw, A5PSW_INPUT_LEARN, mask, reg); +} + +static void a5psw_port_rx_block_set(struct a5psw *a5psw, int port, bool block) +{ + u32 mask = A5PSW_INPUT_LEARN_BLOCK(port); + u32 reg = block ? mask : 0; + + a5psw_reg_rmw(a5psw, A5PSW_INPUT_LEARN, mask, reg); +} + static void a5psw_flooding_set_resolution(struct a5psw *a5psw, int port, bool set) { @@ -344,28 +376,35 @@ static void a5psw_port_bridge_leave(struct dsa_switch *ds, int port, static void a5psw_port_stp_state_set(struct dsa_switch *ds, int port, u8 state) { - u32 mask = A5PSW_INPUT_LEARN_DIS(port) | A5PSW_INPUT_LEARN_BLOCK(port); + bool learning_enabled, rx_enabled, tx_enabled; struct a5psw *a5psw = ds->priv; - u32 reg = 0; switch (state) { case BR_STATE_DISABLED: case BR_STATE_BLOCKING: - reg |= A5PSW_INPUT_LEARN_DIS(port); - reg |= A5PSW_INPUT_LEARN_BLOCK(port); - break; case BR_STATE_LISTENING: - reg |= A5PSW_INPUT_LEARN_DIS(port); + rx_enabled = false; + tx_enabled = false; + learning_enabled = false; break; case BR_STATE_LEARNING: - reg |= A5PSW_INPUT_LEARN_BLOCK(port); + rx_enabled = false; + tx_enabled = false; + learning_enabled = true; break; case BR_STATE_FORWARDING: - default: + rx_enabled = true; + tx_enabled = true; + learning_enabled = true; break; + default: + dev_err(ds->dev, "invalid STP state: %d\n", state); + return; } - a5psw_reg_rmw(a5psw, A5PSW_INPUT_LEARN, mask, reg); + a5psw_port_learning_set(a5psw, port, learning_enabled); + a5psw_port_rx_block_set(a5psw, port, !rx_enabled); + a5psw_port_tx_enable(a5psw, port, tx_enabled); } static void a5psw_port_fast_age(struct dsa_switch *ds, int port) diff --git a/drivers/net/dsa/rzn1_a5psw.h b/drivers/net/dsa/rzn1_a5psw.h index b4fbf453ff74..b869192eef3f 100644 --- a/drivers/net/dsa/rzn1_a5psw.h +++ b/drivers/net/dsa/rzn1_a5psw.h @@ -19,6 +19,7 @@ #define A5PSW_PORT_OFFSET(port) (0x400 * (port)) #define A5PSW_PORT_ENA 0x8 +#define A5PSW_PORT_ENA_TX(port) BIT(port) #define A5PSW_PORT_ENA_RX_SHIFT 16 #define A5PSW_PORT_ENA_TX_RX(port) (BIT((port) + A5PSW_PORT_ENA_RX_SHIFT) | \ BIT(port)) From patchwork Fri May 12 07:27:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alexis_Lothor=C3=A9?= X-Patchwork-Id: 92981 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp4916805vqo; Fri, 12 May 2023 00:40:37 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6PzSaWKiFCL41Xi8xgruBF5MkxgcMkOG0avjOZNTwFSx59j01Ea51Mku32C6NGAScJ9Iw0 X-Received: by 2002:a17:903:1d1:b0:1a6:9762:6eee with SMTP id e17-20020a17090301d100b001a697626eeemr28151033plh.40.1683877236906; Fri, 12 May 2023 00:40:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683877236; cv=none; d=google.com; s=arc-20160816; b=LNo1tp/ZriyJnhafvg8ZdG6DXCakLso2VEuaTDydIDhCeKB66zf0Q7S9KPsFgen0+t eYneBl1vFm83uFjgR7QnM6YFNq8+uH8/4aCAZKcBFtGoC75/N3QooFd61KljjqXImA6L gPjLlmXOASxwEW5i6eMkAHtjWYF+x6dBajcgvlLn/hxMU4u+vwRl+Cco0P5636O/enu2 Py/vIPnYZY3KvBQlDvhh+X/CzrsE1hwD6qs0uKG+KXlKtBh3ZnBb5u5aHWmd0QOk0oUw uPeFCmnQRdHACOZ+qCf/bPA4PXNm0uKyFKOzT+Dzv5NYRhQ84G36Cas/1gBXLnSKkeY1 sZRg== 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=bmtlXGdOHO94cG8DR+uqpMutmdfZo2YRa5/V158ipOc=; b=EQdK69UxCR2s+O1sa9PyGUmz1Q2n0vTXlnPm5lZ6KzYVnu6oIjnHP2SwfHvf7jUwBH zZQ87G3IM25H+QZoyiWjuUBB43jbXRGX398QQc8RUsqrmrKPlc5YCCPzfnQo+EgS8Qxj gd+/NnXk2Y0SP3j1r79v18V4uFNjzDbNT5qyxR/4BntgBz/PdJagoqQQEwdDGg1l1v6F IySpPV4GLXbMVdbUf6Rzh94CDv8PPr//2pAz+8fnjdKMufKkA295mqDMZipTAipJPw94 i7DJ6bKaJ8D1tkJ5Y4Hs94rifn/Z7aJQQZl/mbQt7Unjb3ZSIObbOq4nIL6georXoK5b VRMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=kh1zoRLI; 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=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b18-20020a170902d51200b001a988a09b6esi9618638plg.252.2023.05.12.00.40.22; Fri, 12 May 2023 00:40:36 -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=@bootlin.com header.s=gm1 header.b=kh1zoRLI; 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=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240254AbjELH1P (ORCPT + 99 others); Fri, 12 May 2023 03:27:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240187AbjELH1F (ORCPT ); Fri, 12 May 2023 03:27:05 -0400 Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::222]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C74D2682; Fri, 12 May 2023 00:27:02 -0700 (PDT) Received: (Authenticated sender: alexis.lothore@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id 6704E40002; Fri, 12 May 2023 07:27:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1683876421; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bmtlXGdOHO94cG8DR+uqpMutmdfZo2YRa5/V158ipOc=; b=kh1zoRLIESw6azS6mRfebl2H/asab2IUPYPzLteUPSLmVbNQHJzq+19sKJnmSAUSlQTBNu Vut7EfG/vubT8cqUR/PGe6D4UXolPu7n7S2hi3wv6GW5zF/B60u1T0NL9TqrloiL/7SenW Me45ijs5oGj78RV3Hcpa97edYcUIVB2zYQ1UMZfObSHSqIBer4hkZtEEg1H0ZO6vG0R7U2 K/H7MD7vHu5H6FcAxHq/JcLcycUa39b4qEUyaimvCqpOTW/RgtZWYzeVfWsxU/nHYsUaXQ EPsU9s3YFufVPS8xnoYH+kiMKBa7xgdpe2DhJYWobKEXwkHGyCt6Oq5VOn42bQ== From: alexis.lothore@bootlin.com To: andrew@lunn.ch, f.fainelli@gmail.com, olteanv@gmail.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: linux-renesas-soc@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com, herve.codina@bootlin.com, miquel.raynal@bootlin.com, milan.stevanovic@se.com, jimmy.lalande@se.com, pascal.eberhard@se.com Subject: [PATCH net v3 3/3] net: dsa: rzn1-a5psw: disable learning for standalone ports Date: Fri, 12 May 2023 09:27:12 +0200 Message-Id: <20230512072712.82694-4-alexis.lothore@bootlin.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230512072712.82694-1-alexis.lothore@bootlin.com> References: <20230512072712.82694-1-alexis.lothore@bootlin.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765673257761031342?= X-GMAIL-MSGID: =?utf-8?q?1765673257761031342?= From: Clément Léger When ports are in standalone mode, they should have learning disabled to avoid adding new entries in the MAC lookup table which might be used by other bridge ports to forward packets. While adding that, also make sure learning is enabled for CPU port. Fixes: 888cdb892b61 ("net: dsa: rzn1-a5psw: add Renesas RZ/N1 advanced 5 port switch driver") Signed-off-by: Clément Léger Signed-off-by: Alexis Lothoré Reviewed-by: Piotr Raczynski --- drivers/net/dsa/rzn1_a5psw.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/drivers/net/dsa/rzn1_a5psw.c b/drivers/net/dsa/rzn1_a5psw.c index e2549cb31d00..c37d2e537230 100644 --- a/drivers/net/dsa/rzn1_a5psw.c +++ b/drivers/net/dsa/rzn1_a5psw.c @@ -340,6 +340,14 @@ static void a5psw_flooding_set_resolution(struct a5psw *a5psw, int port, a5psw_reg_writel(a5psw, offsets[i], a5psw->bridged_ports); } +static void a5psw_port_set_standalone(struct a5psw *a5psw, int port, + bool standalone) +{ + a5psw_port_learning_set(a5psw, port, !standalone); + a5psw_flooding_set_resolution(a5psw, port, !standalone); + a5psw_port_mgmtfwd_set(a5psw, port, standalone); +} + static int a5psw_port_bridge_join(struct dsa_switch *ds, int port, struct dsa_bridge bridge, bool *tx_fwd_offload, @@ -355,8 +363,7 @@ static int a5psw_port_bridge_join(struct dsa_switch *ds, int port, } a5psw->br_dev = bridge.dev; - a5psw_flooding_set_resolution(a5psw, port, true); - a5psw_port_mgmtfwd_set(a5psw, port, false); + a5psw_port_set_standalone(a5psw, port, false); return 0; } @@ -366,8 +373,7 @@ static void a5psw_port_bridge_leave(struct dsa_switch *ds, int port, { struct a5psw *a5psw = ds->priv; - a5psw_flooding_set_resolution(a5psw, port, false); - a5psw_port_mgmtfwd_set(a5psw, port, true); + a5psw_port_set_standalone(a5psw, port, true); /* No more ports bridged */ if (a5psw->bridged_ports == BIT(A5PSW_CPU_PORT)) @@ -761,13 +767,15 @@ static int a5psw_setup(struct dsa_switch *ds) if (dsa_port_is_unused(dp)) continue; - /* Enable egress flooding for CPU port */ - if (dsa_port_is_cpu(dp)) + /* Enable egress flooding and learning for CPU port */ + if (dsa_port_is_cpu(dp)) { a5psw_flooding_set_resolution(a5psw, port, true); + a5psw_port_learning_set(a5psw, port, true); + } - /* Enable management forward only for user ports */ + /* Enable standalone mode for user ports */ if (dsa_port_is_user(dp)) - a5psw_port_mgmtfwd_set(a5psw, port, true); + a5psw_port_set_standalone(a5psw, port, true); } return 0;