[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <88bdaad0bb744dc401e94d97aba002431ac0b03b.camel@siemens.com>
Date: Thu, 21 Aug 2025 16:40:37 +0000
From: "Sverdlin, Alexander" <alexander.sverdlin@...mens.com>
To: "hauke@...ke-m.de" <hauke@...ke-m.de>, "olteanv@...il.com"
<olteanv@...il.com>, "davem@...emloft.net" <davem@...emloft.net>,
"andrew@...n.ch" <andrew@...n.ch>, "linux@...linux.org.uk"
<linux@...linux.org.uk>, "linux-kernel@...r.kernel.org"
<linux-kernel@...r.kernel.org>, "arkadis@...lanox.com"
<arkadis@...lanox.com>, "daniel@...rotopia.org" <daniel@...rotopia.org>,
"kuba@...nel.org" <kuba@...nel.org>, "pabeni@...hat.com" <pabeni@...hat.com>,
"edumazet@...gle.com" <edumazet@...gle.com>, "f.fainelli@...il.com"
<f.fainelli@...il.com>, "horms@...nel.org" <horms@...nel.org>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>
CC: "john@...ozen.org" <john@...ozen.org>, "Stockmann, Lukas"
<lukas.stockmann@...mens.com>, "yweng@...linear.com" <yweng@...linear.com>,
"fchan@...linear.com" <fchan@...linear.com>, "lxu@...linear.com"
<lxu@...linear.com>, "jpovazanec@...linear.com" <jpovazanec@...linear.com>,
"Schirm, Andreas" <andreas.schirm@...mens.com>, "Christen, Peter"
<peter.christen@...mens.com>, "ajayaraman@...linear.com"
<ajayaraman@...linear.com>, "bxu@...linear.com" <bxu@...linear.com>,
"lrosu@...linear.com" <lrosu@...linear.com>
Subject: Re: [PATCH RFC net-next 12/23] net: dsa: lantiq_gswip: support 4k
VLANs on API 2.2 or later
Hi Daniel,
On Sat, 2025-08-16 at 20:53 +0100, Daniel Golle wrote:
> Dynamically allocate vlans array depending on the switch API version.
> Versions less than 2.2 support 64 VLANs, versions 2.2 or later support
> 4096 VLANs.
...
> @@ -725,9 +730,9 @@ static int gswip_vlan_active_create(struct gswip_priv *priv,
> return err;
> }
>
> - priv->vlans[idx].bridge = bridge;
> - priv->vlans[idx].vid = vid;
> - priv->vlans[idx].fid = fid;
> + (*priv->vlans)[idx].bridge = bridge;
> + (*priv->vlans)[idx].vid = vid;
> + (*priv->vlans)[idx].fid = fid;
Would it be possible to leave this chunk unchanged (and all array
dereferencing in the driver as well)?
> @@ -1948,6 +1953,22 @@ static int gswip_validate_cpu_port(struct dsa_switch *ds)
> return 0;
> }
>
> +static int gswip_allocate_vlans(struct gswip_priv *priv)
> +{
> + if (GSWIP_VERSION_GE(priv, GSWIP_VERSION_2_2))
> + priv->num_vlans = 4096;
> + else
> + priv->num_vlans = 64;
> +
> + priv->vlans = devm_kcalloc(priv->dev, priv->num_vlans,
> + sizeof((*priv->vlans)[0]), GFP_KERNEL);
maybe sizeof(*priv->vlans) or sizeof(priv->vlans[0])?
> --- a/drivers/net/dsa/lantiq_gswip.h
> +++ b/drivers/net/dsa/lantiq_gswip.h
> @@ -269,7 +270,8 @@ struct gswip_priv {
> struct dsa_switch *ds;
> struct device *dev;
> struct regmap *rcu_regmap;
> - struct gswip_vlan vlans[64];
> + struct gswip_vlan (*vlans)[];
... if this would be just "struct gswip_vlan *vlans;"?
> + unsigned int num_vlans;
> int num_gphy_fw;
> struct gswip_gphy_fw *gphy_fw;
> u32 port_vlan_filter;
--
Alexander Sverdlin
Siemens AG
www.siemens.com
Powered by blists - more mailing lists