Skip to content

Commit 7964e78

Browse files
Edward Creekuba-moo
authored andcommitted
net: ethtool: use the tracking array for get_rxfh on custom RSS contexts
On 'ethtool -x' with rss_context != 0, instead of calling the driver to read the RSS settings for the context, just get the settings from the rss_ctx xarray, and return them to the user with no driver involvement. Signed-off-by: Edward Cree <[email protected]> Reviewed-by: Przemek Kitszel <[email protected]> Link: https://patch.msgid.link/2d0190fa29638f307ea720f882ebd41f6f867694.1719502240.git.ecree.xilinx@gmail.com Signed-off-by: Jakub Kicinski <[email protected]>
1 parent a9ee8d4 commit 7964e78

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

net/ethtool/ioctl.c

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,6 +1202,7 @@ static noinline_for_stack int ethtool_get_rxfh(struct net_device *dev,
12021202
const struct ethtool_ops *ops = dev->ethtool_ops;
12031203
struct ethtool_rxfh_param rxfh_dev = {};
12041204
u32 user_indir_size, user_key_size;
1205+
struct ethtool_rxfh_context *ctx;
12051206
struct ethtool_rxfh rxfh;
12061207
u32 indir_bytes;
12071208
u8 *rss_config;
@@ -1249,11 +1250,26 @@ static noinline_for_stack int ethtool_get_rxfh(struct net_device *dev,
12491250
if (user_key_size)
12501251
rxfh_dev.key = rss_config + indir_bytes;
12511252

1252-
rxfh_dev.rss_context = rxfh.rss_context;
1253-
1254-
ret = dev->ethtool_ops->get_rxfh(dev, &rxfh_dev);
1255-
if (ret)
1256-
goto out;
1253+
if (rxfh.rss_context) {
1254+
ctx = xa_load(&dev->ethtool->rss_ctx, rxfh.rss_context);
1255+
if (!ctx) {
1256+
ret = -ENOENT;
1257+
goto out;
1258+
}
1259+
if (rxfh_dev.indir)
1260+
memcpy(rxfh_dev.indir, ethtool_rxfh_context_indir(ctx),
1261+
indir_bytes);
1262+
if (rxfh_dev.key)
1263+
memcpy(rxfh_dev.key, ethtool_rxfh_context_key(ctx),
1264+
user_key_size);
1265+
rxfh_dev.hfunc = ctx->hfunc;
1266+
rxfh_dev.input_xfrm = ctx->input_xfrm;
1267+
ret = 0;
1268+
} else {
1269+
ret = dev->ethtool_ops->get_rxfh(dev, &rxfh_dev);
1270+
if (ret)
1271+
goto out;
1272+
}
12571273

12581274
if (copy_to_user(useraddr + offsetof(struct ethtool_rxfh, hfunc),
12591275
&rxfh_dev.hfunc, sizeof(rxfh.hfunc))) {

0 commit comments

Comments
 (0)