From patchwork Tue Feb 21 09:26:25 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: 59826 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1770740wrn; Tue, 21 Feb 2023 01:44:02 -0800 (PST) X-Google-Smtp-Source: AK7set8B91S/Py7SL4QrzXsUiCuBdNQbEeCzskm3OXIWxua2ycNQ74ZG22ndMrhb4WIFGTwUac1I X-Received: by 2002:a17:907:6e8f:b0:878:4d11:f868 with SMTP id sh15-20020a1709076e8f00b008784d11f868mr18227684ejc.2.1676972642455; Tue, 21 Feb 2023 01:44:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676972642; cv=none; d=google.com; s=arc-20160816; b=W0lhfgPSBwS4/j46sWzRDNuS1fqThYV3WDgVeZ7ZnsGVYj84RQoHGPyXiLlJOL+0Pd +gPry56yulwhLQoD09mEE5SgdsaC6mE3eN7Pm1v7rWVp0LOcZp8Ehn3myw6vbZAZnm82 Y/b3INvHm/ToA8rHUe8qbHSawJEafuFLiUrrR7sUO4xoJ5CoNo+m3rnYcYu7u5sVGDTY Yz9qWwsVk4tDIlbRDue8n8YgxvlyGhFaefXdgYyzDAR4Rqno12bUQ5wsPpntN94q/3Y7 YiUTXTJNcrsbApJfMX3UQb/iRfAdfAaap+EHVkUt5w239IDenbbRMOlB+bvVs96abWz1 0lig== 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=Ib/mOXHYH3Do6zNpWmBQIKneKPV3vlWtkcbraPhLrAg=; b=kV89aWiHYiaSN+Z9AYP2JIXkxzxUWBT498ChXsExu104x5+NUNkpacLrWgmbGgxKJ0 9EvqAR0hftk6+TJcIafsChGRZOXQuSNZZcWH12V3RdTrSptI1pb/hHVEwdvBfuV06nax tFPOWWDftA6QSOAUACNkcV6oRzEHJpK07bIcZ1+x/6jc64BREtrZRtVF5ap7qe5fhX2t ptQKpVqi18hu2NxbHNM8+wBeO9OE+gFTBakSAb/8d4Voo20dxMKPbfEZbvuScBBcSMHN bbWv0YsAUgJ0YoPkFIamKj/Xw5nQ0zK9nGiNsfBrnjS4jXLpWexzcZvQ5evrLBrlvKRP rPzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=Pj2jAJUo; 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 y8-20020a170906518800b008b17891459fsi18902168ejk.298.2023.02.21.01.43.39; Tue, 21 Feb 2023 01:44:02 -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=Pj2jAJUo; 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 S233946AbjBUJZg (ORCPT + 99 others); Tue, 21 Feb 2023 04:25:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233949AbjBUJZb (ORCPT ); Tue, 21 Feb 2023 04:25:31 -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 B39A51CF54; Tue, 21 Feb 2023 01:25:05 -0800 (PST) Received: (Authenticated sender: clement.leger@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id 10D27C0002; Tue, 21 Feb 2023 09:24:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1676971504; 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=Ib/mOXHYH3Do6zNpWmBQIKneKPV3vlWtkcbraPhLrAg=; b=Pj2jAJUo2YXxLUY4UscS/z4J7Z4XFxK0ep8G397cJWLT/rfcDaeskbeisNyyPFvkAt+7Td kWJrVHI8iMB7YO02U5yey5b/WiigxF9gs4p/zzoASvXiQYAYExBlme6Ac3SOMaHXDwJqsJ R3OxQi5Qs5MURLUMFUYsPFh+Hi8ri13r78+z3KbhHPolqBJChbH/sR+n4Y6L9n9gww8GnU Mk5sl9HN4FDspuBjF+c5CVZaqqNiqCICMoaWBmIVUWo1QT2GAVjCBO0+zRUpNU6J5hrQIx XhXOlHp1Bl7E9NFPYzhOs65J5Jx3PqDDKM48LQFbAEvX1QEQShKjk4zYXBKWYw== 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 net-next v4 2/3] net: dsa: rzn1-a5psw: add support for .port_bridge_flags Date: Tue, 21 Feb 2023 10:26:25 +0100 Message-Id: <20230221092626.57019-3-clement.leger@bootlin.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230221092626.57019-1-clement.leger@bootlin.com> References: <20230221092626.57019-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,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?1758433265797624193?= X-GMAIL-MSGID: =?utf-8?q?1758433265797624193?= 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 Reviewed-by: Florian Fainelli --- 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 7dcca15e0b11..5059b2814cdd 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,