Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp2952040rwb; Mon, 16 Jan 2023 01:29:14 -0800 (PST) X-Google-Smtp-Source: AMrXdXvHH2XK+non8/Nvo+7Alp7R8JbohtBLXCwnuV3m6p6vH7vuCQvzSH17Q2neQuChGx3O5nEh X-Received: by 2002:a17:90a:a011:b0:226:f1b9:bb37 with SMTP id q17-20020a17090aa01100b00226f1b9bb37mr32066302pjp.40.1673861354429; Mon, 16 Jan 2023 01:29:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673861354; cv=none; d=google.com; s=arc-20160816; b=fUVmZzOPoPw5zNEc3GOrNQywIbhV5gxGEM23c9yxEBwC5eyiS7NHUFIu93YcHkR88N nnL5ZF2xeT0ictjKbDlTvBEiYbW4mXb4ycwL4DVudYUa64OPSTVWoWpuQhht+5qYZ4g0 GSvh/+CupcoTKyY7dOQ5847Ge6o0yu5s1h/+2BfzfkxBtogBrITq8JK0UMWn/aLtHMhc EmzgueVl3v9vRusVr+r6GJQVfFoD+0D6SkbV7UQQkT68X8U0gON9tugWbxa91WzlY3Ia uIS9tFFruWJI66yNHgZwoc2InpfNI6Jr0buDJ9H0gQhgk7cahbLfhP07UAAG3JxtO1Or kwNA== 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 :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature; bh=n/b403PRq8EYGPXwjQ32wy0AeZyf2Q6Ii5wKNkPIYQs=; b=kvd8tapNAGfLJAEZGqojfoPei0Uf4gS3zyFV4Rz5zxtSW1BTkgygjUq3A1iBuulcal NLSV9mIh5Dv0oLROVMwRrPQfiDYoXgEZ1G/xFBJqhXTAmoyvrp4Xbm7/Fb87SuVaEdZG pqpuZGDjDICOLsVhGH50WPqzw3Q/WSb9K68izFMRfQIEmcA73rJjJfh4ut5fGX3cxpLV NlYhlVbYKEZd40SP72rEQeYtYcCtagwUP5MM1OJhUD36DRzhjeC5+yrTVrUh0IdiF6LR GySLzXiEKoCITYtg1q1Xkcp0f04eIoJwA2potMYlUfnWe/TdGcuZ3gY6KnEuFNLMx7S7 Tpig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=PWlMcI1w; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mi18-20020a17090b4b5200b002295008799bsi6352055pjb.159.2023.01.16.01.29.08; Mon, 16 Jan 2023 01:29: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=PWlMcI1w; 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 S231951AbjAPIp5 (ORCPT + 51 others); Mon, 16 Jan 2023 03:45:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231996AbjAPIpy (ORCPT ); Mon, 16 Jan 2023 03:45:54 -0500 Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [IPv6:2001:4b98:dc4:8::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87ADB1206D; Mon, 16 Jan 2023 00:45:51 -0800 (PST) Received: (Authenticated sender: clement.leger@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id E682C100002; Mon, 16 Jan 2023 08:45:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1673858749; 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=n/b403PRq8EYGPXwjQ32wy0AeZyf2Q6Ii5wKNkPIYQs=; b=PWlMcI1wVuALAcPFRY/9LfptlImGujZpLQaWGHOGuocEpoLSlZfDNIW9OEuA5O7ui7v7v5 gFQUTshslMyQdyHmnM1bNTju8GYm8R5hRI4RWaHgS8NPQsFhCl3TeoEN0m6xz5NwP1YFCP b8hwqtUk6J29k/1JoQVyKwpvCDpY++k0wCsJ7XY42CmxbUG0kg0xCeGltMpfxS+9Je1fzB gki9k3EofdqyGxnOIxaFXzL+0H0Ualk9fmTvdWPV2eVTpBopIY+HxxafTPO8DZ3BvY8nd3 UUKp8d1Rsh6j9o3/mZs3BVvxtXQxZ75a4ZFEam+k+ZPr5dJ6M+o6WcNQnKs7yg== Date: Mon, 16 Jan 2023 09:48:01 +0100 From: =?UTF-8?B?Q2zDqW1lbnQgTMOpZ2Vy?= To: Cc: , , , , , , , , , , , , , , , , Subject: Re: [PATCH net-next] net: dsa: rzn1-a5psw: Add vlan support Message-ID: <20230116094801.348018de@fixe.home> In-Reply-To: References: <20230111115607.1146502-1-clement.leger@bootlin.com> Organization: Bootlin X-Mailer: Claws Mail 4.1.1 (GTK 3.24.36; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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 Le Fri, 13 Jan 2023 14:40:26 +0000, a =C3=A9crit : > Hi Clement, > On Wed, 2023-01-11 at 12:56 +0100, Cl=C3=A9ment L=C3=A9ger wrote: > > Add support for vlan operation (add, del, filtering) on the RZN1 > > driver. The a5psw switch supports up to 32 VLAN IDs with filtering, > > tagged/untagged VLANs and PVID for each ports. > >=20 > > Signed-off-by: Cl=C3=A9ment L=C3=A9ger > > --- > > drivers/net/dsa/rzn1_a5psw.c | 182 > > +++++++++++++++++++++++++++++++++++ > > drivers/net/dsa/rzn1_a5psw.h | 10 +- > > 2 files changed, 189 insertions(+), 3 deletions(-) > >=20 > > diff --git a/drivers/net/dsa/rzn1_a5psw.c > > b/drivers/net/dsa/rzn1_a5psw.c > > index ed413d555bec..8ecb9214b5e6 100644 > > --- a/drivers/net/dsa/rzn1_a5psw.c > > +++ b/drivers/net/dsa/rzn1_a5psw.c > > @@ -540,6 +540,161 @@ static int a5psw_port_fdb_dump(struct > > dsa_switch *ds, int port, > > return ret; > > } > > =20 > > +static int a5psw_port_vlan_filtering(struct dsa_switch *ds, int > > port, > > + bool vlan_filtering, > > + struct netlink_ext_ack *extack) > > +{ > > + u32 mask =3D BIT(port + A5PSW_VLAN_VERI_SHIFT) > > + | BIT(port + A5PSW_VLAN_DISC_SHIFT); =20 >=20 > Operator | at the end of line >=20 > > + struct a5psw *a5psw =3D ds->priv; > > + u32 val =3D 0; > > + > > + if (vlan_filtering) > > + val =3D BIT(port + A5PSW_VLAN_VERI_SHIFT) > > + | BIT(port + A5PSW_VLAN_DISC_SHIFT); =20 >=20 > Operator | at the end of line Hi Arun, I'll fix that. >=20 > > + > > + a5psw_reg_rmw(a5psw, A5PSW_VLAN_VERIFY, mask, val); > > + > > + return 0; > > +} > > + > > +static int a5psw_port_vlan_add(struct dsa_switch *ds, int port, > > + const struct switchdev_obj_port_vlan > > *vlan, > > + struct netlink_ext_ack *extack) > > +{ > > + bool tagged =3D !(vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED); > > + bool pvid =3D vlan->flags & BRIDGE_VLAN_INFO_PVID; > > + struct a5psw *a5psw =3D ds->priv; > > + u16 vid =3D vlan->vid; > > + int ret =3D -EINVAL; > > + int vlan_res_id; > > + > > + dev_dbg(a5psw->dev, "Add VLAN %d on port %d, %s, %s\n", > > + vid, port, tagged ? "tagged" : "untagged", > > + pvid ? "PVID" : "no PVID"); > > + > > + mutex_lock(&a5psw->vlan_lock); > > + > > + vlan_res_id =3D a5psw_find_vlan_entry(a5psw, vid); > > + if (vlan_res_id < 0) { > > + vlan_res_id =3D a5psw_get_vlan_res_entry(a5psw, vid); > > + if (vlan_res_id < 0) =20 >=20 > nit: We can initialize ret =3D 0 initially, and assign ret =3D -EINVAL he= re > & remove ret =3D 0 at end of function. >=20 > > + goto out; > > + } > > + > > + a5psw_port_vlan_cfg(a5psw, vlan_res_id, port, true); > > + if (tagged) > > + a5psw_port_vlan_tagged_cfg(a5psw, vlan_res_id, port, > > true); > > + > > + if (pvid) { > > + a5psw_reg_rmw(a5psw, A5PSW_VLAN_IN_MODE_ENA, BIT(port), > > + BIT(port)); > > + a5psw_reg_writel(a5psw, A5PSW_SYSTEM_TAGINFO(port), > > vid); > > + } > > + > > + ret =3D 0; > > +out: > > + mutex_unlock(&a5psw->vlan_lock); > > + > > + return ret; > > +} > > + > > +static int a5psw_port_vlan_del(struct dsa_switch *ds, int port, > > + const struct switchdev_obj_port_vlan > > *vlan) > > +{ > > + struct a5psw *a5psw =3D ds->priv; > > + u16 vid =3D vlan->vid; > > + int ret =3D -EINVAL; =20 >=20 > Simillarly here. Since I removed the mutex thanks to the previous comments, I have removed all the "ret" usage. Thanks, --=20 Cl=C3=A9ment L=C3=A9ger, Embedded Linux and Kernel engineer at Bootlin https://bootlin.com