Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ethtool: rss: factor out populating response from context

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).

Reviewed-by: Gal Pressman <gal@nvidia.com>
Link: https://patch.msgid.link/20250717234343.2328602-5-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+22 -10
+22 -10
net/ethtool/rss.c
··· 179 179 return ret; 180 180 } 181 181 182 + static void 183 + __rss_prepare_ctx(struct net_device *dev, struct rss_reply_data *data, 184 + struct ethtool_rxfh_context *ctx) 185 + { 186 + if (WARN_ON_ONCE(data->indir_size != ctx->indir_size || 187 + data->hkey_size != ctx->key_size)) 188 + return; 189 + 190 + data->no_key_fields = !dev->ethtool_ops->rxfh_per_ctx_key; 191 + 192 + data->hfunc = ctx->hfunc; 193 + data->input_xfrm = ctx->input_xfrm; 194 + memcpy(data->indir_table, ethtool_rxfh_context_indir(ctx), 195 + data->indir_size * sizeof(u32)); 196 + if (data->hkey_size) 197 + memcpy(data->hkey, ethtool_rxfh_context_key(ctx), 198 + data->hkey_size); 199 + } 200 + 182 201 static int 183 202 rss_prepare_ctx(const struct rss_req_info *request, struct net_device *dev, 184 203 struct rss_reply_data *data, const struct genl_info *info) ··· 206 187 u32 total_size, indir_bytes; 207 188 u8 *rss_config; 208 189 int ret; 209 - 210 - data->no_key_fields = !dev->ethtool_ops->rxfh_per_ctx_key; 211 190 212 191 mutex_lock(&dev->ethtool->rss_lock); 213 192 ctx = xa_load(&dev->ethtool->rss_ctx, request->rss_context); ··· 216 199 217 200 data->indir_size = ctx->indir_size; 218 201 data->hkey_size = ctx->key_size; 219 - data->hfunc = ctx->hfunc; 220 - data->input_xfrm = ctx->input_xfrm; 221 202 222 203 indir_bytes = data->indir_size * sizeof(u32); 223 204 total_size = indir_bytes + data->hkey_size; ··· 226 211 } 227 212 228 213 data->indir_table = (u32 *)rss_config; 229 - memcpy(data->indir_table, ethtool_rxfh_context_indir(ctx), indir_bytes); 230 - 231 - if (data->hkey_size) { 214 + if (data->hkey_size) 232 215 data->hkey = rss_config + indir_bytes; 233 - memcpy(data->hkey, ethtool_rxfh_context_key(ctx), 234 - data->hkey_size); 235 - } 216 + 217 + __rss_prepare_ctx(dev, data, ctx); 236 218 237 219 ret = 0; 238 220 out_unlock: