[net-next,v3,1/3] net: dsa: rzn1-a5psw: use a5psw_reg_rmw() to modify flooding resolution
Message ID | 20230208161749.331965-2-clement.leger@bootlin.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp3557580wrn; Wed, 8 Feb 2023 08:37:47 -0800 (PST) X-Google-Smtp-Source: AK7set81xPqQdiKVLG9CqIPVhBdQoQIUCdYfaEchGl6Ue7nABHc2NGs94+FAcn7s6gHooVz0qIUL X-Received: by 2002:a05:6a20:a024:b0:be:f5f3:a195 with SMTP id p36-20020a056a20a02400b000bef5f3a195mr10239945pzj.3.1675874267331; Wed, 08 Feb 2023 08:37:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675874267; cv=none; d=google.com; s=arc-20160816; b=FVuEZnuO3eWMYIGQAMJyHLOxsz/DS1JpgW1C7GfZNxCbgpUdk8frW8cXEqdyqtguEM h5gXFEIt1WDeAawaH7O72yXp0YExsfJz/c9aP1IWmmG4y+qsFYXO9lJbxKC2hRl0FMMJ uvykK28n1di9uq4EuAipO4k4TmOE6J+FSLf8KAL85o75EExNovNcjRz/ipRP6GgxuNAF A0ylfpXMdnyMtvT147LlfjPQ2nTby1AcFoqULatN9Gyynl3sJbkGKRyDkz6cXasRK2Ko yv2oIGkdWIdFGYYJOy8p8j5GwzXyoqj/EpIBlT3vy+xZhWPEdzBXflc5/MVnzdvDppBW VyYg== 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=yID+HSZHZsFysNyH5E4J8FFNrJg4SULKzIRkEIsJkjo=; b=uxkcX1IKSIxAaV0PlVYtigcu+elt/ryXYjBx7fSRwq2MJjD0YK2jAT3S4gLfzGCZAm whY5pDtQeqZvm20kn487ostZGGCfw8I7yXaLUaQNQH8LBnPWsndFoLPF4O0+v3jdASV0 WvXbKvPuSJZpBz7itYfIXA5wAfgdBgbXJpvPRWUX2XBpg37V2fphXL9PGNKTeIVICgeM gZbx9eksT2W4XYdymBe0Dz9HL+muLhPv17WORiPUj/ct8ZGfRfl1Cro0B39wB6RrLuTA aztA2vVR589bKk/l3eNIjUH3+M/4TvN24g7sRidP5c27KvtTukp86tgxlMVT97x31k4O ycCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=V0dyJ6xV; 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 w3-20020a639343000000b004f1956b511dsi17522934pgm.219.2023.02.08.08.37.35; Wed, 08 Feb 2023 08:37:47 -0800 (PST) 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=V0dyJ6xV; 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 S231169AbjBHQQQ (ORCPT <rfc822;ivan.orlov0322@gmail.com> + 99 others); Wed, 8 Feb 2023 11:16:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231241AbjBHQQN (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 8 Feb 2023 11:16:13 -0500 Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::226]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 00ED34ABD3; Wed, 8 Feb 2023 08:16:11 -0800 (PST) Received: (Authenticated sender: clement.leger@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id 6A561C0015; Wed, 8 Feb 2023 16:16:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1675872970; 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=yID+HSZHZsFysNyH5E4J8FFNrJg4SULKzIRkEIsJkjo=; b=V0dyJ6xV95G4v8DK1kLp+o+f4nrm7+1Ri1yludU30jCCpU7AmInKwuhgiSbei+ynruqHfS x/fz5NFnRVJ4MT3OkJqw6h8sIuK6vMvvhOH4AJEOiKTcSumtnYlWYFyLR97SpbKj1kgxps Osu8Hvssd/K6RwN/c+oZKMKuQ9Rz+fs5L+NTXbwNEuJ872Y5QB28Im8mjNnu9MWu8UNQ/y no+h+GPc8nTy+9khqz8Y5lNQ7Rim+PFtvL2BftcekYVd6lGEUq1zKwblLqYligRy9QA5vb UlImIJoEv702TC1FC+gFLbX94PURE5Xvp3toAaLFDjhouANHzmyhl/MEqFma9Q== From: =?utf-8?b?Q2zDqW1lbnQgTMOpZ2Vy?= <clement.leger@bootlin.com> To: Andrew Lunn <andrew@lunn.ch>, Florian Fainelli <f.fainelli@gmail.com>, Vladimir Oltean <olteanv@gmail.com>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com> Cc: =?utf-8?b?Q2zDqW1lbnQgTMOpZ2Vy?= <clement.leger@bootlin.com>, Thomas Petazzoni <thomas.petazzoni@bootlin.com>, Herve Codina <herve.codina@bootlin.com>, =?utf-8?q?Miqu=C3=A8l_Raynal?= <miquel.raynal@bootlin.com>, Milan Stevanovic <milan.stevanovic@se.com>, Jimmy Lalande <jimmy.lalande@se.com>, Pascal Eberhard <pascal.eberhard@se.com>, Arun Ramadoss <Arun.Ramadoss@microchip.com>, linux-renesas-soc@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v3 1/3] net: dsa: rzn1-a5psw: use a5psw_reg_rmw() to modify flooding resolution Date: Wed, 8 Feb 2023 17:17:47 +0100 Message-Id: <20230208161749.331965-2-clement.leger@bootlin.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230208161749.331965-1-clement.leger@bootlin.com> References: <20230208161749.331965-1-clement.leger@bootlin.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757281535763889868?= X-GMAIL-MSGID: =?utf-8?q?1757281535763889868?= |
Series |
net: dsa: rzn1-a5psw: add support for vlan and .port_bridge_flags
|
|
Commit Message
Clément Léger
Feb. 8, 2023, 4:17 p.m. UTC
.port_bridge_flags will be added and allows to modify the flood mask
independently for each port. Keeping the existing bridged_ports write
in a5psw_flooding_set_resolution() would potentially messed up this.
Use a read-modify-write to set that value and move bridged_ports
handling in bridge_port_join/leave.
Signed-off-by: Clément Léger <clement.leger@bootlin.com>
---
drivers/net/dsa/rzn1_a5psw.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
Comments
On 2/8/23 08:17, Clément Léger wrote: > .port_bridge_flags will be added and allows to modify the flood mask > independently for each port. Keeping the existing bridged_ports write > in a5psw_flooding_set_resolution() would potentially messed up this. > Use a read-modify-write to set that value and move bridged_ports > handling in bridge_port_join/leave. > > Signed-off-by: Clément Léger <clement.leger@bootlin.com> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
On Wed, Feb 08, 2023 at 05:17:47PM +0100, Clément Léger wrote: > .port_bridge_flags will be added and allows to modify the flood mask > independently for each port. Keeping the existing bridged_ports write > in a5psw_flooding_set_resolution() would potentially messed up this. > Use a read-modify-write to set that value and move bridged_ports > handling in bridge_port_join/leave. > > Signed-off-by: Clément Léger <clement.leger@bootlin.com> > --- > drivers/net/dsa/rzn1_a5psw.c | 12 ++++++------ > 1 file changed, 6 insertions(+), 6 deletions(-) > > diff --git a/drivers/net/dsa/rzn1_a5psw.c b/drivers/net/dsa/rzn1_a5psw.c > index 919027cf2012..8b7d4a371f8b 100644 > --- a/drivers/net/dsa/rzn1_a5psw.c > +++ b/drivers/net/dsa/rzn1_a5psw.c > @@ -299,13 +299,9 @@ static void a5psw_flooding_set_resolution(struct a5psw *a5psw, int port, > A5PSW_MCAST_DEF_MASK}; > int i; > > - if (set) > - a5psw->bridged_ports |= BIT(port); > - else > - a5psw->bridged_ports &= ~BIT(port); > - > for (i = 0; i < ARRAY_SIZE(offsets); i++) > - a5psw_reg_writel(a5psw, offsets[i], a5psw->bridged_ports); > + a5psw_reg_rmw(a5psw, offsets[i], BIT(port), > + set ? BIT(port) : 0); > } > > static int a5psw_port_bridge_join(struct dsa_switch *ds, int port, > @@ -326,6 +322,8 @@ static int a5psw_port_bridge_join(struct dsa_switch *ds, int port, > a5psw_flooding_set_resolution(a5psw, port, true); > a5psw_port_mgmtfwd_set(a5psw, port, false); > > + a5psw->bridged_ports |= BIT(port); > + > return 0; > } > > @@ -334,6 +332,8 @@ static void a5psw_port_bridge_leave(struct dsa_switch *ds, int port, > { > struct a5psw *a5psw = ds->priv; > > + a5psw->bridged_ports &= ~BIT(port); > + > a5psw_flooding_set_resolution(a5psw, port, false); > a5psw_port_mgmtfwd_set(a5psw, port, true); > > -- > 2.39.0 > What about the a5psw_flooding_set_resolution() call for the CPU port, from a5psw_setup()? Isn't this an undocumented change? Does this logic in a5psw_port_bridge_leave() still work, now that bridged_ports will no longer contain BIT(A5PSW_CPU_PORT)? /* No more ports bridged */ if (a5psw->bridged_ports == BIT(A5PSW_CPU_PORT)) a5psw->br_dev = NULL;
Le Wed, 8 Feb 2023 23:37:57 +0200, Vladimir Oltean <olteanv@gmail.com> a écrit : > On Wed, Feb 08, 2023 at 05:17:47PM +0100, Clément Léger wrote: > > .port_bridge_flags will be added and allows to modify the flood mask > > independently for each port. Keeping the existing bridged_ports write > > in a5psw_flooding_set_resolution() would potentially messed up this. > > Use a read-modify-write to set that value and move bridged_ports > > handling in bridge_port_join/leave. > > > > Signed-off-by: Clément Léger <clement.leger@bootlin.com> > > --- > > drivers/net/dsa/rzn1_a5psw.c | 12 ++++++------ > > 1 file changed, 6 insertions(+), 6 deletions(-) > > > > diff --git a/drivers/net/dsa/rzn1_a5psw.c b/drivers/net/dsa/rzn1_a5psw.c > > index 919027cf2012..8b7d4a371f8b 100644 > > --- a/drivers/net/dsa/rzn1_a5psw.c > > +++ b/drivers/net/dsa/rzn1_a5psw.c > > @@ -299,13 +299,9 @@ static void a5psw_flooding_set_resolution(struct a5psw *a5psw, int port, > > A5PSW_MCAST_DEF_MASK}; > > int i; > > > > - if (set) > > - a5psw->bridged_ports |= BIT(port); > > - else > > - a5psw->bridged_ports &= ~BIT(port); > > - > > for (i = 0; i < ARRAY_SIZE(offsets); i++) > > - a5psw_reg_writel(a5psw, offsets[i], a5psw->bridged_ports); > > + a5psw_reg_rmw(a5psw, offsets[i], BIT(port), > > + set ? BIT(port) : 0); > > } > > > > static int a5psw_port_bridge_join(struct dsa_switch *ds, int port, > > @@ -326,6 +322,8 @@ static int a5psw_port_bridge_join(struct dsa_switch *ds, int port, > > a5psw_flooding_set_resolution(a5psw, port, true); > > a5psw_port_mgmtfwd_set(a5psw, port, false); > > > > + a5psw->bridged_ports |= BIT(port); > > + > > return 0; > > } > > > > @@ -334,6 +332,8 @@ static void a5psw_port_bridge_leave(struct dsa_switch *ds, int port, > > { > > struct a5psw *a5psw = ds->priv; > > > > + a5psw->bridged_ports &= ~BIT(port); > > + > > a5psw_flooding_set_resolution(a5psw, port, false); > > a5psw_port_mgmtfwd_set(a5psw, port, true); > > > > -- > > 2.39.0 > > > > What about the a5psw_flooding_set_resolution() call for the CPU port, from a5psw_setup()? > Isn't this an undocumented change? Does this logic in a5psw_port_bridge_leave() still work, > now that bridged_ports will no longer contain BIT(A5PSW_CPU_PORT)? > > /* No more ports bridged */ > if (a5psw->bridged_ports == BIT(A5PSW_CPU_PORT)) > a5psw->br_dev = NULL; You are right, this actually disallow to create a bridge multiple times. I'll fix that.
diff --git a/drivers/net/dsa/rzn1_a5psw.c b/drivers/net/dsa/rzn1_a5psw.c index 919027cf2012..8b7d4a371f8b 100644 --- a/drivers/net/dsa/rzn1_a5psw.c +++ b/drivers/net/dsa/rzn1_a5psw.c @@ -299,13 +299,9 @@ static void a5psw_flooding_set_resolution(struct a5psw *a5psw, int port, A5PSW_MCAST_DEF_MASK}; int i; - if (set) - a5psw->bridged_ports |= BIT(port); - else - a5psw->bridged_ports &= ~BIT(port); - for (i = 0; i < ARRAY_SIZE(offsets); i++) - a5psw_reg_writel(a5psw, offsets[i], a5psw->bridged_ports); + a5psw_reg_rmw(a5psw, offsets[i], BIT(port), + set ? BIT(port) : 0); } static int a5psw_port_bridge_join(struct dsa_switch *ds, int port, @@ -326,6 +322,8 @@ static int a5psw_port_bridge_join(struct dsa_switch *ds, int port, a5psw_flooding_set_resolution(a5psw, port, true); a5psw_port_mgmtfwd_set(a5psw, port, false); + a5psw->bridged_ports |= BIT(port); + return 0; } @@ -334,6 +332,8 @@ static void a5psw_port_bridge_leave(struct dsa_switch *ds, int port, { struct a5psw *a5psw = ds->priv; + a5psw->bridged_ports &= ~BIT(port); + a5psw_flooding_set_resolution(a5psw, port, false); a5psw_port_mgmtfwd_set(a5psw, port, true);