From patchwork Wed Feb 8 16:17:48 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: 54487 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp3557324wrn; Wed, 8 Feb 2023 08:37:14 -0800 (PST) X-Google-Smtp-Source: AK7set+X1pzW8LsoZz2lzrjKffE0IXDMR3hgJUZlgyjcMAhC7CC4Zmo58g4oTj/A8ZhNACGGeKnd X-Received: by 2002:a05:6a20:a024:b0:be:f5f3:a195 with SMTP id p36-20020a056a20a02400b000bef5f3a195mr10238007pzj.3.1675874234184; Wed, 08 Feb 2023 08:37:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675874234; cv=none; d=google.com; s=arc-20160816; b=t7J6jtBPOS6gnUs9BFPQVyJO/57ov6mxEK6t3xIFKwaaa6qaBZPzoCBmzyQDX9r3pI fzZD/hWgIYwt5HY+KJF+p4P4qPfJXxpP3FJCF611mP1eq6v9ci8ARr/BHf4A+0+kQsvM vjr46NR/E6pF6EuvDKmjQeRVtav+10vjzjrSggXCJmmhkHQfXQEPyzM6Cy2i0j6S+Hbn Nu3TYpfd1tpcMqht5+ipobxHUGHzXsSIDPnoS7GnmzNl1PYMNf8gS/TilfZbKv6c6bne xFqa0I70STxYx/gDlTBivVvR3bCh57EK661FFHzBcEybQURd2pEB72ClaXrLMry3bWi3 RSxw== 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=T/r+8WdvWgePENEO9IumyJ6tx3sZyAKDfoFFP5mDZkGAlralSro1odGUEHInqHlwh9 J5atTobRC6S7k+NgIk/YBH5kKyE+XVJ6aZoGJds2i81LTgRIGBzBAhlzRS35MOzxsueH 8SBSrKbJWYgxBinKh2ugcM9PYeCpzCgDBiLoFsmm6utwgDldJUw5+SeGJ6ZwTleNcy9z GbJJiaO9spqSAaxN8n3pmYsJVtdFlv00zoubygFX5RTH2KH0FcGYbFYZo+mTTPToUf2V 2E7KvYxwWBZU2ZkEahheryijiPJVpX8FmDVnE339eAfAPYC+I2R9riOk0ZtFS9TIg9Wc 32yQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=BAzdbG4I; 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 d17-20020a637351000000b004fab273942asi15776370pgn.675.2023.02.08.08.37.01; Wed, 08 Feb 2023 08:37:14 -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=BAzdbG4I; 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 S231345AbjBHQQW (ORCPT + 99 others); Wed, 8 Feb 2023 11:16:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231341AbjBHQQP (ORCPT ); Wed, 8 Feb 2023 11:16:15 -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 188134C6D7; Wed, 8 Feb 2023 08:16:13 -0800 (PST) Received: (Authenticated sender: clement.leger@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id 9D82CC0003; Wed, 8 Feb 2023 16:16:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1675872972; 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=BAzdbG4INcRb0mvSn9AhLsD7dI6qI2r5u6n35QdYtZMp3cy9q4rsd1xVlnt23xCxuZNkZg aSXgCXm5MB+PU7YVlSghVuNGtzkP3jJFGzVPYI7iXboJsRSlUQcIHdQUboEXBJJGmfG690 uylXR7KhxzgOmnCy7YN+ZA9xTr7PYUJb7A4DKrjGpShZlpKPr5p9XMzRIqzQ3LBAC0U5K8 BavMYRNOhIY9XJnAhZFKa8lkWyPXCBL3mKwAKLiPCp+pFKWHmj70j636lklG8IZD/zlwXS gyj+sFTVednbBBkDzEEIZa+bGT8pr7zS39h7FE/NNDZ7K6Pf4erkkRY9F05Ksg== 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 v3 2/3] net: dsa: rzn1-a5psw: add support for .port_bridge_flags Date: Wed, 8 Feb 2023 17:17:48 +0100 Message-Id: <20230208161749.331965-3-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 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?1757281501136553689?= X-GMAIL-MSGID: =?utf-8?q?1757281501136553689?= 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 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,