]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
net: ethtool: remove the compat code for _rxfh_context ops
authorJakub Kicinski <kuba@kernel.org>
Mon, 7 Jul 2025 18:41:14 +0000 (11:41 -0700)
committerJakub Kicinski <kuba@kernel.org>
Tue, 8 Jul 2025 18:56:40 +0000 (11:56 -0700)
All drivers are now converted to dedicated _rxfh_context ops.
Remove the use of >set_rxfh() to manage additional contexts.

Reviewed-by: Gal Pressman <gal@nvidia.com>
Reviewed-by: Edward Cree <ecree.xilinx@gmail.com>
Link: https://patch.msgid.link/20250707184115.2285277-5-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
include/linux/ethtool.h
net/core/dev.c
net/ethtool/ioctl.c
net/ethtool/rss.c

index 59877fd2a1d384cfe5207b2ea7b6a3bca5df80ed..de5bd76a400ca191ea2c9125586ac8e0c07f23fa 100644 (file)
@@ -865,9 +865,6 @@ struct kernel_ethtool_ts_info {
  * @supported_input_xfrm: supported types of input xfrm from %RXH_XFRM_*.
  * @cap_link_lanes_supported: indicates if the driver supports lanes
  *     parameter.
- * @cap_rss_ctx_supported: indicates if the driver supports RSS
- *     contexts via legacy API, drivers implementing @create_rxfh_context
- *     do not have to set this bit.
  * @rxfh_per_ctx_fields: device supports selecting different header fields
  *     for Rx hash calculation and RSS for each additional context.
  * @rxfh_per_ctx_key: device supports setting different RSS key for each
@@ -1100,7 +1097,6 @@ struct kernel_ethtool_ts_info {
 struct ethtool_ops {
        u32     supported_input_xfrm:8;
        u32     cap_link_lanes_supported:1;
-       u32     cap_rss_ctx_supported:1;
        u32     rxfh_per_ctx_fields:1;
        u32     rxfh_per_ctx_key:1;
        u32     cap_rss_rxnfc_adds:1;
index ea129aa083179b6853e99c3750ee5a1c2f135de2..fe677ccec5b03567b9c4ef89ea881651af468fbe 100644 (file)
@@ -11979,21 +11979,8 @@ static void netdev_rss_contexts_free(struct net_device *dev)
 
        mutex_lock(&dev->ethtool->rss_lock);
        xa_for_each(&dev->ethtool->rss_ctx, context, ctx) {
-               struct ethtool_rxfh_param rxfh;
-
-               rxfh.indir = ethtool_rxfh_context_indir(ctx);
-               rxfh.key = ethtool_rxfh_context_key(ctx);
-               rxfh.hfunc = ctx->hfunc;
-               rxfh.input_xfrm = ctx->input_xfrm;
-               rxfh.rss_context = context;
-               rxfh.rss_delete = true;
-
                xa_erase(&dev->ethtool->rss_ctx, context);
-               if (dev->ethtool_ops->create_rxfh_context)
-                       dev->ethtool_ops->remove_rxfh_context(dev, ctx,
-                                                             context, NULL);
-               else
-                       dev->ethtool_ops->set_rxfh(dev, &rxfh, NULL);
+               dev->ethtool_ops->remove_rxfh_context(dev, ctx, context, NULL);
                kfree(ctx);
        }
        xa_destroy(&dev->ethtool->rss_ctx);
index b6d96e562c9a7b3663dd885c2b6db501166646ef..d8a17350d3e8cda211d79275f7a9642450274984 100644 (file)
@@ -1391,8 +1391,7 @@ static noinline_for_stack int ethtool_get_rxfh(struct net_device *dev,
        if (rxfh.rsvd8[0] || rxfh.rsvd8[1] || rxfh.rsvd32)
                return -EINVAL;
        /* Most drivers don't handle rss_context, check it's 0 as well */
-       if (rxfh.rss_context && !(ops->cap_rss_ctx_supported ||
-                                 ops->create_rxfh_context))
+       if (rxfh.rss_context && !ops->create_rxfh_context)
                return -EOPNOTSUPP;
 
        rxfh.indir_size = rxfh_dev.indir_size;
@@ -1534,8 +1533,7 @@ static noinline_for_stack int ethtool_set_rxfh(struct net_device *dev,
        if (rxfh.rsvd8[0] || rxfh.rsvd8[1] || rxfh.rsvd32)
                return -EINVAL;
        /* Most drivers don't handle rss_context, check it's 0 as well */
-       if (rxfh.rss_context && !(ops->cap_rss_ctx_supported ||
-                                 ops->create_rxfh_context))
+       if (rxfh.rss_context && !ops->create_rxfh_context)
                return -EOPNOTSUPP;
        /* Check input data transformation capabilities */
        if (rxfh.input_xfrm && rxfh.input_xfrm != RXH_XFRM_SYM_XOR &&
@@ -1634,6 +1632,8 @@ static noinline_for_stack int ethtool_set_rxfh(struct net_device *dev,
        }
 
        if (create) {
+               u32 limit, ctx_id;
+
                if (rxfh_dev.rss_delete) {
                        ret = -EINVAL;
                        goto out_unlock;
@@ -1644,21 +1644,15 @@ static noinline_for_stack int ethtool_set_rxfh(struct net_device *dev,
                        goto out_unlock;
                }
 
-               if (ops->create_rxfh_context) {
-                       u32 limit = ops->rxfh_max_num_contexts ?: U32_MAX;
-                       u32 ctx_id;
-
-                       /* driver uses new API, core allocates ID */
-                       ret = xa_alloc(&dev->ethtool->rss_ctx, &ctx_id, ctx,
-                                      XA_LIMIT(1, limit - 1),
-                                      GFP_KERNEL_ACCOUNT);
-                       if (ret < 0) {
-                               kfree(ctx);
-                               goto out_unlock;
-                       }
-                       WARN_ON(!ctx_id); /* can't happen */
-                       rxfh.rss_context = ctx_id;
+               limit = ops->rxfh_max_num_contexts ?: U32_MAX;
+               ret = xa_alloc(&dev->ethtool->rss_ctx, &ctx_id, ctx,
+                              XA_LIMIT(1, limit - 1), GFP_KERNEL_ACCOUNT);
+               if (ret < 0) {
+                       kfree(ctx);
+                       goto out_unlock;
                }
+               WARN_ON(!ctx_id); /* can't happen */
+               rxfh.rss_context = ctx_id;
        } else if (rxfh.rss_context) {
                ctx = xa_load(&dev->ethtool->rss_ctx, rxfh.rss_context);
                if (!ctx) {
@@ -1670,7 +1664,7 @@ static noinline_for_stack int ethtool_set_rxfh(struct net_device *dev,
        rxfh_dev.rss_context = rxfh.rss_context;
        rxfh_dev.input_xfrm = rxfh.input_xfrm;
 
-       if (rxfh.rss_context && ops->create_rxfh_context) {
+       if (rxfh.rss_context) {
                if (create) {
                        ret = ops->create_rxfh_context(dev, ctx, &rxfh_dev,
                                                       extack);
@@ -1693,8 +1687,7 @@ static noinline_for_stack int ethtool_set_rxfh(struct net_device *dev,
        if (ret) {
                if (create) {
                        /* failed to create, free our new tracking entry */
-                       if (ops->create_rxfh_context)
-                               xa_erase(&dev->ethtool->rss_ctx, rxfh.rss_context);
+                       xa_erase(&dev->ethtool->rss_ctx, rxfh.rss_context);
                        kfree(ctx);
                }
                goto out_unlock;
@@ -1713,36 +1706,6 @@ static noinline_for_stack int ethtool_set_rxfh(struct net_device *dev,
                        dev->priv_flags |= IFF_RXFH_CONFIGURED;
        }
        /* Update rss_ctx tracking */
-       if (create && !ops->create_rxfh_context) {
-               /* driver uses old API, it chose context ID */
-               if (WARN_ON(xa_load(&dev->ethtool->rss_ctx, rxfh_dev.rss_context))) {
-                       /* context ID reused, our tracking is screwed */
-                       kfree(ctx);
-                       goto out_unlock;
-               }
-               /* Allocate the exact ID the driver gave us */
-               if (xa_is_err(xa_store(&dev->ethtool->rss_ctx, rxfh_dev.rss_context,
-                                      ctx, GFP_KERNEL))) {
-                       kfree(ctx);
-                       goto out_unlock;
-               }
-
-               /* Fetch the defaults for the old API, in the new API drivers
-                * should write defaults into ctx themselves.
-                */
-               rxfh_dev.indir = (u32 *)rss_config;
-               rxfh_dev.indir_size = dev_indir_size;
-
-               rxfh_dev.key = rss_config + indir_bytes;
-               rxfh_dev.key_size = dev_key_size;
-
-               ret = ops->get_rxfh(dev, &rxfh_dev);
-               if (WARN_ON(ret)) {
-                       xa_erase(&dev->ethtool->rss_ctx, rxfh.rss_context);
-                       kfree(ctx);
-                       goto out_unlock;
-               }
-       }
        if (rxfh_dev.rss_delete) {
                WARN_ON(xa_erase(&dev->ethtool->rss_ctx, rxfh.rss_context) != ctx);
                kfree(ctx);
index e717f23cbc1061152c115331d33d57f86b34d831..4e8ca2c3817508cda8aaedf28dfea89284a36a06 100644 (file)
@@ -163,8 +163,7 @@ rss_prepare_data(const struct ethnl_req_info *req_base,
                return -EOPNOTSUPP;
 
        /* Some drivers don't handle rss_context */
-       if (request->rss_context &&
-           !ops->cap_rss_ctx_supported && !ops->create_rxfh_context)
+       if (request->rss_context && !ops->create_rxfh_context)
                return -EOPNOTSUPP;
 
        mutex_lock(&dev->ethtool->rss_lock);