From patchwork Thu May 11 17:02:00 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: 92745 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp4538372vqo; Thu, 11 May 2023 10:13:59 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5kqs00J1hmMl6dR07LeE1M4PM8Ge/RQ/2Zq165XT6PEq27J0O8mJOEMf2uHqtB0HsK4HYJ X-Received: by 2002:a17:90a:2d6:b0:252:a2e5:4c3f with SMTP id d22-20020a17090a02d600b00252a2e54c3fmr1072169pjd.25.1683825239305; Thu, 11 May 2023 10:13:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683825239; cv=none; d=google.com; s=arc-20160816; b=hdFrOgb8btK+fv2lzG2uSHLczDA5pwmbXmTwBj9BMboIfVIqiA6cPsO3nAyaRLkq9H I2zw3yoIo/SzhAszvsT7P/uRfndFdzgDmeRlBL1O0ILljc4ZBnFr+g6YzScqv4TXOkZL 2TJgfc6JQvoJpQWtpy67KSECJFX+MkAvITfA9bfdr2n8B5W9xUHRIJZ4MBMWD2jrQimD gs8xkT1wCSzEFt7107fWQ14koAx70hwhBATXV3yaP/ow0AxF8yv96z1jnFvwIhiIE63w JIzL/FSGjKDD8RV3Bp3XtOw9tXUNRhhk9xB62ekJ2JuLCB0Xj/PFOqKqQm7CrKot/YX7 YHfw== 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=xDcai/HHLRGOgXUWow6VVexAi1qET6F32H65gRi8ZmI=; b=hyCI+g16w8PzFrt9x3RU9ULYSApymUYi6EMDIFsj/Rrs+K3GSvT9ZskJUofSfsLGxj 0x9uLwAaz+UUMMSV8ZMVldMZHTvmx0FotRQqDNJGmQXoLJVjTi+ng3O2tKkB7roAbpsJ h4vm20XXsrio7c70nPeCia2v2vPLNu3moa2SYVeDjxwWDHjEjNqRZXQVuUcmz0iXuZVH 2Dn7Cr7XSNkuQFTsVviaGxtMFZwYY0TJ4g3qOSgs6LgoA0yKldq4ZQIPKu+7cnwvYy7U Af2kW/gZub8jPs4Mdo5kNPZlIUsGqAokCZcAhT4BFMcFyEmNNOmgB+GL9F6iS6h2rpLe eHew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b="mX9/fYWV"; 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 l7-20020a17090a72c700b00246d164fd7asi19077692pjk.159.2023.05.11.10.13.45; Thu, 11 May 2023 10:13:59 -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="mX9/fYWV"; 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 S238819AbjEKRCE (ORCPT + 99 others); Thu, 11 May 2023 13:02:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238774AbjEKRB5 (ORCPT ); Thu, 11 May 2023 13:01:57 -0400 Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 74E645247; Thu, 11 May 2023 10:01:50 -0700 (PDT) Received: (Authenticated sender: alexis.lothore@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id E59EE240012; Thu, 11 May 2023 17:01:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1683824509; 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=xDcai/HHLRGOgXUWow6VVexAi1qET6F32H65gRi8ZmI=; b=mX9/fYWVNQ5B9b3iFail4YJVJZDs63Rx1BOyexOB01aClpU5KQv8hSRsSRsyvo57inXtgZ FgU+hlWQBJn5AjjMQV1U5jivNFI88KViXmIhZs6DEUwGFffWL1IFLUI1n8nwKR0uKWlgni KYTrxYxA8ZQHkjnVDVw5j9vpnZs820BxWLJu1+vk6BSQHpBJtLk4bJnMiEe/xyjv+3gIys tq8KjAZ/cwltpri0ENDT8yVDMHJ6c21yskPoJbkM1Q0i46dYcGD36geb2IaONiGOYanE3s h5fWw21CKIX/TYXtwhRBT/SeoB82CZtRh3gTTlZ1tVXcoVYKvl9lixsOxiOBOg== 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 v2 1/3] net: dsa: rzn1-a5psw: enable management frames for CPU port Date: Thu, 11 May 2023 19:02:00 +0200 Message-Id: <20230511170202.742087-2-alexis.lothore@bootlin.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230511170202.742087-1-alexis.lothore@bootlin.com> References: <20230511170202.742087-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, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765618734022190907?= X-GMAIL-MSGID: =?utf-8?q?1765618734022190907?= 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: Vladimir Oltean --- drivers/net/dsa/rzn1_a5psw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 */ From patchwork Thu May 11 17:02:01 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: 92746 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp4541154vqo; Thu, 11 May 2023 10:18:05 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6UrCA8mDZwSrNq2J9nVW+Fa+xSkHHlEGPfxzCSMeAY7Z+tGcJYiLNdEh4lpYlSMAQuEDng X-Received: by 2002:a05:6a20:3ca9:b0:100:1044:9ce2 with SMTP id b41-20020a056a203ca900b0010010449ce2mr21732024pzj.56.1683825485312; Thu, 11 May 2023 10:18:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683825485; cv=none; d=google.com; s=arc-20160816; b=sDH21CX68u5UC9KJdqqdXO12xgTPzs6OXDxnwMPj9Cp5/i+1QkV6/JeWlVT2Shcv0v NTpkCGj5kTCJkSZJA6TiABfZiFwtjqYvFXOJdlNvDIJntHH8COmH9JN6j4bstt2QpD37 EVZCicK93K6gbUlg6ZlkRxJzRgQRlEopEGMEbQg7XDmcEB42wMBVXlbJuuKNGp8zot0i Rcvl1Rwwr8S58kOCIzZJyBdK+8k/6lVOxJYp+jYDiXHQXwZyyQCn+QvR0MCre8i/2278 5NvT9ccbA6zg+G8qJHkulAih4IzQfhubh+5fVW3D1ZbkzyJbj6pgG4UK47sO/I93o2tT qLHQ== 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=jPPu0Mcd9hZUGp1NAlXsFoC+MT+VaaNrumecD7Cr9Q8=; b=JpljuKdjHCJ3RscwLncvO0Kv9rzYElehL9gYCe/sMOsc0aEelWmaaQxXpM5loGk4pB bTG2D4GDTjckErBWtNZw/yjt+OdcL/0r1e4cGIRMMMoBo/GwHSVD83cbmGgyUTZ6LCMK do7zZCAOYzyirarzeoVlnnVEoO0To0KVZOnoU3t9A+IbGs7t25R15BXH5P5Xz1Gp1MR6 +N8xN1NVpqVazPLx9GoDv4qxHVWRIHERE1eQmf7XvzEs2LwRiARybL2DV63Py+nZQ1Yi 0a+XiKgW0B6XYST8LRuXpkVV/TdsYSMH9R3QavYfDQdujAAlLZNdgmSPpo09dygWKyyj dNAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=QG61Lw2B; 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 p22-20020a639516000000b005300293ab4asi7157523pgd.842.2023.05.11.10.17.51; Thu, 11 May 2023 10:18:05 -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=QG61Lw2B; 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 S238841AbjEKRCG (ORCPT + 99 others); Thu, 11 May 2023 13:02:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39798 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238777AbjEKRB5 (ORCPT ); Thu, 11 May 2023 13:01:57 -0400 Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D2A3A59D0; Thu, 11 May 2023 10:01:51 -0700 (PDT) Received: (Authenticated sender: alexis.lothore@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id 4500E24000F; Thu, 11 May 2023 17:01:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1683824510; 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=jPPu0Mcd9hZUGp1NAlXsFoC+MT+VaaNrumecD7Cr9Q8=; b=QG61Lw2BtW+QewFGk/QEqkCEKaR+mOEeRWDuq2Xo+bXutnxnZvsWMYqauaq1bStSCO8wBa pyVUnsIByjljyqRUPQkxKpHgUKGNMBEf5dIwnJ1D+bbJAwM50dBVWyk6/UyI3wKuZ41e9y 25OMI8YpUfiFJPi785OXuGeP8bN7CQGpsql+IoogdfTGFkFa3ux/Wn6KHU91vJQUsyc61w gUzbFcGkHmyLDgBZ4HBLb/KnoibK8Fn6MAiiVpV1DpILB+pyJJiQ/0EtBJFwRXgNWO36N9 gnvzu4Q7R3pLk6wSHEAtVleSzLuEnuyEY80rt5J/AyX5FjrqPPJuULhH5PCtLg== 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 v2 2/3] net: dsa: rzn1-a5psw: fix STP states handling Date: Thu, 11 May 2023 19:02:01 +0200 Message-Id: <20230511170202.742087-3-alexis.lothore@bootlin.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230511170202.742087-1-alexis.lothore@bootlin.com> References: <20230511170202.742087-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, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765618991550133952?= X-GMAIL-MSGID: =?utf-8?q?1765618991550133952?= From: Clément Léger 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é Reviewed-by: Vladimir Oltean --- drivers/net/dsa/rzn1_a5psw.c | 57 ++++++++++++++++++++++++++++++------ drivers/net/dsa/rzn1_a5psw.h | 3 +- 2 files changed, 50 insertions(+), 10 deletions(-) diff --git a/drivers/net/dsa/rzn1_a5psw.c b/drivers/net/dsa/rzn1_a5psw.c index 8a419e2ffe2a..a3acac29ffa6 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); struct a5psw *a5psw = ds->priv; - u32 reg = 0; + bool learning_enabled, rx_enabled, tx_enabled; 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 c67abd49c013..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)) @@ -36,7 +37,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 Thu May 11 17:02:02 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: 92744 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp4535930vqo; Thu, 11 May 2023 10:10:33 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ56p5viDTyXYAEpv3u8MRhJbIhvsRvGPf3Nq6gpjJhQt+CMk4g2UwRzudmzPpRy33oXuUeH X-Received: by 2002:a05:6a20:1614:b0:103:d7da:bfc5 with SMTP id l20-20020a056a20161400b00103d7dabfc5mr3976726pzj.8.1683825033458; Thu, 11 May 2023 10:10:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683825033; cv=none; d=google.com; s=arc-20160816; b=hKBV9AXJivMKSjh6CXcFNz1/o14p0Lu/sKQxGWLlg5K55cscZSFhsOTYjfBcHTVe9o wz3QNVI/f2H/bnnLLyzcHc+3T2+4hhLs7zl9rzQyt+Y6ny7pcGYSr9ipA+3+pt0YGLVR FII005JqrJJm3szdq9PWK+eGHxfmyDLGJj01Kl3V4254KyFnaagS7YAziy0Z4cU2IhzC t3//yyQxqtY8WBrWJ9Fjo9Y3BF3OWzVmdigg5rQhf9J8TtzRMLJfZ54PA+gnW74hDiY8 v0L8LRvoMBWqIMHzHfd0ALIevidIkEGyZH+nbXXGl2zIwqIM4xRDoSy7SQ5hiD15/rCZ DpaQ== 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=fTuxrkB0duNmVfHAcGEfV5u3kO9O3f4gRWtdWgludoU=; b=uRq635SwLnWhyIZkyRhUusAVijoQQ8V0tPNX7HpsVnuHBk3XW/8Fs4/mOW2xmrunqw Jcg9Piv0+V2+zpWt4iUFn3of8pVxQAJWIxYlLlqSLJIhNlbyM4ThV1QkbpSgZoT/HhtQ 5eG3cl9QIwyUQeT0q9NPZpgiQR88g42GQDp4IuUNC9NeU+xo7QPbpFwS95PDPjdvOo6E 6iI/FZMSAyfL2hVSxvb//Vb+HL3jbff1iKXN2OVn+STEb1c+r1S+Mx9X46ywSIfiyMvA FYsuw+sF9g9vATbQkIUSJVV4ZqnDxqs65FKzdXF2D6OBJrjCU+q6FYFkdnOw6N7bkQmW 8fcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b="iWg/Ncqq"; 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 s4-20020a63b404000000b0053009ff9f39si7055952pgf.713.2023.05.11.10.10.16; Thu, 11 May 2023 10:10:33 -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="iWg/Ncqq"; 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 S238869AbjEKRCL (ORCPT + 99 others); Thu, 11 May 2023 13:02:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238781AbjEKRB6 (ORCPT ); Thu, 11 May 2023 13:01:58 -0400 Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A2CC83FE; Thu, 11 May 2023 10:01:53 -0700 (PDT) Received: (Authenticated sender: alexis.lothore@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id C075024000D; Thu, 11 May 2023 17:01:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1683824512; 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=fTuxrkB0duNmVfHAcGEfV5u3kO9O3f4gRWtdWgludoU=; b=iWg/NcqqdHtC6BCNcZ7lAWCV96pFe+ZyOj5lUcCFqV/a6ZtBtz2bG7y0ySja8nMkfNb9+Z HgKqFe1q93Gf9xi+f2yHYY94Ul8JpltYdBKfn/yyxPhxKJPwIduIZmyiTtqNO0iNXISxvy BZ3nUVqFxwLTIqUh6RtTSbmcAAB6eHpdHtKBw3OJNLXiUFoNOpk8Lt4kniBEoJwlbDcO7M zYQOhvw0IluxU5u3RE9uASQf+v6rU9KCRh6To/GXc+1QURxe3Q+csCE6Gl6GQBODHM854y FcCuTjxHoA1zDsrz+XeS4QFq5h/nNWQs+OiCZ4Zi3cPVbkTLDlps9VBXEF1XHg== 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 v2 3/3] net: dsa: rzn1-a5psw: disable learning for standalone ports Date: Thu, 11 May 2023 19:02:02 +0200 Message-Id: <20230511170202.742087-4-alexis.lothore@bootlin.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230511170202.742087-1-alexis.lothore@bootlin.com> References: <20230511170202.742087-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, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765618518183786705?= X-GMAIL-MSGID: =?utf-8?q?1765618518183786705?= 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: Vladimir Oltean --- 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 a3acac29ffa6..02f83d19656a 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;