[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAG-FcCNN18PGVaRXysnOBk75vQDOq2g1LzEcBAMq2cpa_M85Ow@mail.gmail.com>
Date: Mon, 5 Aug 2024 17:07:03 -0700
From: Ziwei Xiao <ziweixiao@...gle.com>
To: Jakub Kicinski <kuba@...nel.org>
Cc: Praveen Kaligineedi <pkaligineedi@...gle.com>, netdev@...r.kernel.org, davem@...emloft.net,
edumazet@...gle.com, pabeni@...hat.com, willemb@...gle.com,
jeroendb@...gle.com, shailend@...gle.com, hramamurthy@...gle.com,
jfraker@...gle.com
Subject: Re: [PATCH net-next 2/2] gve: Add RSS adminq commands and ethtool support
On Fri, Aug 2, 2024 at 4:21 PM Jakub Kicinski <kuba@...nel.org> wrote:
>
> On Thu, 1 Aug 2024 18:28:34 -0700 Praveen Kaligineedi wrote:
> > +static int gve_set_rxfh(struct net_device *netdev, struct ethtool_rxfh_param *rxfh,
> > + struct netlink_ext_ack *extack)
> > +{
> > + struct gve_priv *priv = netdev_priv(netdev);
> > + struct gve_rss_config rss_config = {0};
>
> I never remember the exact rules, are you sure this is the one that
> is guaranteed per standard to zero all the fields?
>
I didn't find specific rules for standards older than C99, but looks
like this should be supported for all standards.
https://stackoverflow.com/a/63356270. Also there are multiple drivers
using {0} to zero the struct now, so I think it should be good?
> > + u32 *indir = rxfh->indir;
> > + u8 hfunc = rxfh->hfunc;
> > + u8 *key = rxfh->key;
> > + int err = 0;
> > +
> > + if (!priv->rss_key_size || !priv->rss_lut_size)
> > + return -EOPNOTSUPP;
> > +
> > + switch (hfunc) {
> > + case ETH_RSS_HASH_NO_CHANGE:
> > + break;
> > + case ETH_RSS_HASH_TOP:
> > + rss_config.hash_alg = ETH_RSS_HASH_TOP;
> > + break;
> > + default:
> > + return -EOPNOTSUPP;
> > + }
> > +
> > + if (key) {
> > + rss_config.hash_key = kvcalloc(priv->rss_key_size,
> > + sizeof(*rss_config.hash_key), GFP_KERNEL);
>
> key is a bitstream...
> IOW this code is like allocating a string with
> calloc(length, sizeof(char))
> :S
>
> But what is the point of the allocations in this function in the first
> place? You kvcalloc here, copy, call gve_adminq_configure_rss()
> which dma_alloc_coherent() and copies into that, again.
>
Thanks for pointing it out. I will send a V2 to avoid the extra copy.
Powered by blists - more mailing lists