From patchwork Wed Feb 8 16:04:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Q2zDqW1lbnQgTMOpZ2Vy?= X-Patchwork-Id: 54478 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp3539641wrn; Wed, 8 Feb 2023 08:06:29 -0800 (PST) X-Google-Smtp-Source: AK7set/viQ9dPG30Q2cLSn2Eye/aIjj6fqqyiIJJJ0p/7g4xbN7+cNWDatGCbuPlex0WHSPX/+gd X-Received: by 2002:a05:6402:34cc:b0:4a2:5b11:1a51 with SMTP id w12-20020a05640234cc00b004a25b111a51mr8671766edc.2.1675872389178; Wed, 08 Feb 2023 08:06:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675872389; cv=none; d=google.com; s=arc-20160816; b=upIUbjF51G1+rJ/TLOR65RI4nJEWkgYST7zZDUcApAMzxhMhNrfNtJAzYbUijexcGx X2+iIPzJ3o3ym4OTM/vlhLs0W80Uw8XEem6bq+1fj71Zpw594VzBVM5j63YB9QmIVxoy 5crnh0x8Mjh1RpUhNgY5euyYwqs/VD93fE9DbEXH1+/IrZqOzZ20S5d9Jk+L5SVeAHhd sK2Eeu4gWwqVXGoymByuXf+0TIHQXyiSCBBMebR1hv016EEZfWKScGYt2j/lA9INcCTk qQ2CqtZwU3lFMVmINZ+CadX5rKk1QuMs7BijEmo71JSIY1CEfB01++LrabrZit1pfdmu rBsA== 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=b9a0BUOmJvO4NqAYLgTOEStjmY5WJ4dpiZkzCdgTveY=; b=tix7elaBnAv+w64o4Csu2CK0xetm5GAK32+7jysfjDobPoS8nlLn/ZUWDyM1sRsbO7 JdeuqXwf+SbAOMvxb8IPryr+fCTWbVBjbrZGl83KgYC3xX2eapPZDyEjBUYMz/fSIZO8 0VGJ4FUl8yDGQPR7wDilDoEi2CtUWeF+agfRrs0evijSu9i62/XWGOVk/g6KJWhh01bC cn9U4t2xv/NyM3dLfc2nLPPf7b3GMJJrgy9ZiixK1WRJM9H90vmyojvJX3N43WZI9xWR HhiGSe5Mhegwb2pTIjQXRf/B7+qdL3KJA+X5RiI9UZsLmnxwkJHtIHNx9Zk/bQr8vweu 6aiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=ekAfGjsk; 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 ev16-20020a056402541000b0049e1788de1fsi20093655edb.236.2023.02.08.08.06.05; Wed, 08 Feb 2023 08:06:29 -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=ekAfGjsk; 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 S231433AbjBHQDA (ORCPT + 99 others); Wed, 8 Feb 2023 11:03:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231304AbjBHQCv (ORCPT ); Wed, 8 Feb 2023 11:02:51 -0500 Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 058774ABF7; Wed, 8 Feb 2023 08:02:47 -0800 (PST) Received: (Authenticated sender: clement.leger@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id 78332E0015; Wed, 8 Feb 2023 16:02:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1675872166; 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=b9a0BUOmJvO4NqAYLgTOEStjmY5WJ4dpiZkzCdgTveY=; b=ekAfGjskqcSD7+zDBb4fFzrJLi9eUis376tTpCOL0n2cg/W7Mg2w7xeakjc27Pr4NZySQ5 vqdOO3TG9YB1+/4xluXiwyowTTTWEjKUev+Ilv63EMJ/qKK6Zb0M0eDqLkgCkDyuFkEfQA +rFApDBMSA74xJN+Q6NWnzMtyFYw9Q39jSGH27mB0mdbrMp2YtaukIoFXvE8CyTi4/KNvX 2d8bQ8nt9YJsO3Gu45RyLhp7IJ+h3HL/69A28kxM7hG5bo4rtXFOiZMc0DC/mHL5cQ7Dkf 3nEK7o/4h9xFQa9xbSx+3tT+jqK48jk3A1rWkGn+sB/01Lkmz5xvjibtKDHECQ== From: =?utf-8?b?Q2zDqW1lbnQgTMOpZ2Vy?= To: Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: =?utf-8?b?Q2zDqW1lbnQgTMOpZ2Vy?= , Thomas Petazzoni , Herve Codina , =?utf-8?q?Miqu=C3=A8l_Raynal?= , Milan Stevanovic , Jimmy Lalande , Pascal Eberhard , Arun Ramadoss , linux-renesas-soc@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/3] net: dsa: rzn1-a5psw: add support for .port_bridge_flags Date: Wed, 8 Feb 2023 17:04:52 +0100 Message-Id: <20230208160453.325783-3-clement.leger@bootlin.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230208160453.325783-1-clement.leger@bootlin.com> References: <20230208160453.325783-1-clement.leger@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 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?1757279566715690606?= X-GMAIL-MSGID: =?utf-8?q?1757279566715690606?= When running vlan test (bridge_vlan_aware/unaware.sh), there were some failure due to the lack .port_bridge_flag function to disable port flooding. Implement this operation for BR_LEARNING, BR_FLOOD, BR_MCAST_FLOOD and BR_BCAST_FLOOD. Signed-off-by: Clément Léger --- drivers/net/dsa/rzn1_a5psw.c | 45 ++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/drivers/net/dsa/rzn1_a5psw.c b/drivers/net/dsa/rzn1_a5psw.c index 8b7d4a371f8b..0ce3948952db 100644 --- a/drivers/net/dsa/rzn1_a5psw.c +++ b/drivers/net/dsa/rzn1_a5psw.c @@ -342,6 +342,49 @@ static void a5psw_port_bridge_leave(struct dsa_switch *ds, int port, a5psw->br_dev = NULL; } +static int a5psw_port_pre_bridge_flags(struct dsa_switch *ds, int port, + struct switchdev_brport_flags flags, + struct netlink_ext_ack *extack) +{ + if (flags.mask & ~(BR_LEARNING | BR_FLOOD | BR_MCAST_FLOOD | + BR_BCAST_FLOOD)) + return -EINVAL; + + return 0; +} + +static int +a5psw_port_bridge_flags(struct dsa_switch *ds, int port, + struct switchdev_brport_flags flags, + struct netlink_ext_ack *extack) +{ + struct a5psw *a5psw = ds->priv; + u32 val; + + if (flags.mask & BR_LEARNING) { + val = flags.val & BR_LEARNING ? 0 : A5PSW_INPUT_LEARN_DIS(port); + a5psw_reg_rmw(a5psw, A5PSW_INPUT_LEARN, + A5PSW_INPUT_LEARN_DIS(port), val); + } + + if (flags.mask & BR_FLOOD) { + val = flags.val & BR_FLOOD ? BIT(port) : 0; + a5psw_reg_rmw(a5psw, A5PSW_UCAST_DEF_MASK, BIT(port), val); + } + + if (flags.mask & BR_MCAST_FLOOD) { + val = flags.val & BR_MCAST_FLOOD ? BIT(port) : 0; + a5psw_reg_rmw(a5psw, A5PSW_MCAST_DEF_MASK, BIT(port), val); + } + + if (flags.mask & BR_BCAST_FLOOD) { + val = flags.val & BR_BCAST_FLOOD ? BIT(port) : 0; + a5psw_reg_rmw(a5psw, A5PSW_BCAST_DEF_MASK, BIT(port), val); + } + + return 0; +} + 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); @@ -754,6 +797,8 @@ static const struct dsa_switch_ops a5psw_switch_ops = { .set_ageing_time = a5psw_set_ageing_time, .port_bridge_join = a5psw_port_bridge_join, .port_bridge_leave = a5psw_port_bridge_leave, + .port_pre_bridge_flags = a5psw_port_pre_bridge_flags, + .port_bridge_flags = a5psw_port_bridge_flags, .port_stp_state_set = a5psw_port_stp_state_set, .port_fast_age = a5psw_port_fast_age, .port_fdb_add = a5psw_port_fdb_add,