From: Jakub Kicinski <kuba@kernel.org>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com,
andrew+netdev@lunn.ch, horms@kernel.org, andrew@lunn.ch,
donald.hunter@gmail.com, shuah@kernel.org,
kory.maincent@bootlin.com, gal@nvidia.com,
ecree.xilinx@gmail.com, Jakub Kicinski <kuba@kernel.org>
Subject: [PATCH net-next 4/8] ethtool: rss: factor out populating response from context
Date: Thu, 17 Jul 2025 16:43:39 -0700 [thread overview]
Message-ID: <20250717234343.2328602-5-kuba@kernel.org> (raw)
In-Reply-To: <20250717234343.2328602-1-kuba@kernel.org>
Similarly to previous change, factor out populating the response.
We will use this after the context was allocated to send a notification
so this time factor out from the additional context handling, rather
than context 0 handling (for request context didn't exist, for response
it does).
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
| 32 ++++++++++++++++++++++----------
1 file changed, 22 insertions(+), 10 deletions(-)
--git a/net/ethtool/rss.c b/net/ethtool/rss.c
index 07a9d89e1c6b..e5516e529b4a 100644
--- a/net/ethtool/rss.c
+++ b/net/ethtool/rss.c
@@ -179,6 +179,25 @@ rss_prepare_get(const struct rss_req_info *request, struct net_device *dev,
return ret;
}
+static void
+__rss_prepare_ctx(struct net_device *dev, struct rss_reply_data *data,
+ struct ethtool_rxfh_context *ctx)
+{
+ if (WARN_ON_ONCE(data->indir_size != ctx->indir_size ||
+ data->hkey_size != ctx->key_size))
+ return;
+
+ data->no_key_fields = !dev->ethtool_ops->rxfh_per_ctx_key;
+
+ data->hfunc = ctx->hfunc;
+ data->input_xfrm = ctx->input_xfrm;
+ memcpy(data->indir_table, ethtool_rxfh_context_indir(ctx),
+ data->indir_size * sizeof(u32));
+ if (data->hkey_size)
+ memcpy(data->hkey, ethtool_rxfh_context_key(ctx),
+ data->hkey_size);
+}
+
static int
rss_prepare_ctx(const struct rss_req_info *request, struct net_device *dev,
struct rss_reply_data *data, const struct genl_info *info)
@@ -188,8 +207,6 @@ rss_prepare_ctx(const struct rss_req_info *request, struct net_device *dev,
u8 *rss_config;
int ret;
- data->no_key_fields = !dev->ethtool_ops->rxfh_per_ctx_key;
-
mutex_lock(&dev->ethtool->rss_lock);
ctx = xa_load(&dev->ethtool->rss_ctx, request->rss_context);
if (!ctx) {
@@ -199,8 +216,6 @@ rss_prepare_ctx(const struct rss_req_info *request, struct net_device *dev,
data->indir_size = ctx->indir_size;
data->hkey_size = ctx->key_size;
- data->hfunc = ctx->hfunc;
- data->input_xfrm = ctx->input_xfrm;
indir_bytes = data->indir_size * sizeof(u32);
total_size = indir_bytes + data->hkey_size;
@@ -211,13 +226,10 @@ rss_prepare_ctx(const struct rss_req_info *request, struct net_device *dev,
}
data->indir_table = (u32 *)rss_config;
- memcpy(data->indir_table, ethtool_rxfh_context_indir(ctx), indir_bytes);
-
- if (data->hkey_size) {
+ if (data->hkey_size)
data->hkey = rss_config + indir_bytes;
- memcpy(data->hkey, ethtool_rxfh_context_key(ctx),
- data->hkey_size);
- }
+
+ __rss_prepare_ctx(dev, data, ctx);
ret = 0;
out_unlock:
--
2.50.1
next prev parent reply other threads:[~2025-07-17 23:44 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-17 23:43 [PATCH net-next 0/8] ethtool: rss: support creating and removing contexts via Netlink Jakub Kicinski
2025-07-17 23:43 ` [PATCH net-next 1/8] ethtool: assert that drivers with sym hash are consistent for RSS contexts Jakub Kicinski
2025-07-17 23:43 ` [PATCH net-next 2/8] ethtool: rejig the RSS notification machinery for more types Jakub Kicinski
2025-07-20 11:09 ` Gal Pressman
2025-07-17 23:43 ` [PATCH net-next 3/8] ethtool: rss: factor out allocating memory for response Jakub Kicinski
2025-07-17 23:43 ` Jakub Kicinski [this message]
2025-07-20 11:12 ` [PATCH net-next 4/8] ethtool: rss: factor out populating response from context Gal Pressman
2025-07-17 23:43 ` [PATCH net-next 5/8] ethtool: move ethtool_rxfh_ctx_alloc() to common code Jakub Kicinski
2025-07-20 11:15 ` Gal Pressman
2025-07-17 23:43 ` [PATCH net-next 6/8] ethtool: rss: support creating contexts via Netlink Jakub Kicinski
2025-07-20 11:42 ` Gal Pressman
2025-07-21 15:21 ` Jakub Kicinski
2025-07-21 18:35 ` Gal Pressman
2025-07-17 23:43 ` [PATCH net-next 7/8] ethtool: rss: support removing " Jakub Kicinski
2025-07-17 23:43 ` [PATCH net-next 8/8] selftests: drv-net: rss_api: context create and delete tests Jakub Kicinski
2025-07-22 1:40 ` [PATCH net-next 0/8] ethtool: rss: support creating and removing contexts via Netlink patchwork-bot+netdevbpf
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=20250717234343.2328602-5-kuba@kernel.org \
--to=kuba@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=donald.hunter@gmail.com \
--cc=ecree.xilinx@gmail.com \
--cc=edumazet@google.com \
--cc=gal@nvidia.com \
--cc=horms@kernel.org \
--cc=kory.maincent@bootlin.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=shuah@kernel.org \
/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.