From: Jakub Kicinski <kuba@kernel.org>
To: Praveen Kaligineedi <pkaligineedi@google.com>
Cc: netdev@vger.kernel.org, davem@davemloft.net, edumazet@google.com,
pabeni@redhat.com, willemb@google.com, jeroendb@google.com,
shailend@google.com, hramamurthy@google.com, jfraker@google.com,
Ziwei Xiao <ziweixiao@google.com>
Subject: Re: [PATCH net-next 2/2] gve: Add RSS adminq commands and ethtool support
Date: Fri, 2 Aug 2024 16:21:31 -0700 [thread overview]
Message-ID: <20240802162131.0eb94666@kernel.org> (raw)
In-Reply-To: <20240802012834.1051452-3-pkaligineedi@google.com>
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?
> + 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.
> + if (!rss_config.hash_key)
> + return -ENOMEM;
> +
> + memcpy(rss_config.hash_key, key, priv->rss_key_size * sizeof(*key));
> + }
> +
> + if (indir) {
> + rss_config.hash_lut = kvcalloc(priv->rss_lut_size,
> + sizeof(*rss_config.hash_lut), GFP_KERNEL);
> + if (!rss_config.hash_lut) {
> + err = -ENOMEM;
> + goto out;
> + }
> +
> + memcpy(rss_config.hash_lut, indir, priv->rss_lut_size * sizeof(*indir));
> + }
> +
> + err = gve_adminq_configure_rss(priv, &rss_config);
> +
> +out:
> + kvfree(rss_config.hash_lut);
> + kvfree(rss_config.hash_key);
> + return err;
> +}
next prev parent reply other threads:[~2024-08-02 23:21 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-02 1:28 [PATCH net-next 0/2] gve: Add RSS config support Praveen Kaligineedi
2024-08-02 1:28 ` [PATCH net-next 1/2] gve: Add RSS device option Praveen Kaligineedi
2024-08-02 23:13 ` Jakub Kicinski
2024-08-06 0:08 ` Ziwei Xiao
2024-08-02 1:28 ` [PATCH net-next 2/2] gve: Add RSS adminq commands and ethtool support Praveen Kaligineedi
2024-08-02 23:21 ` Jakub Kicinski [this message]
2024-08-06 0:07 ` Ziwei Xiao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240802162131.0eb94666@kernel.org \
--to=kuba@kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hramamurthy@google.com \
--cc=jeroendb@google.com \
--cc=jfraker@google.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pkaligineedi@google.com \
--cc=shailend@google.com \
--cc=willemb@google.com \
--cc=ziweixiao@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.