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;