]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
eth: sfc: migrate to new RXFH callbacks
authorJakub Kicinski <kuba@kernel.org>
Wed, 18 Jun 2025 20:38:16 +0000 (13:38 -0700)
committerJakub Kicinski <kuba@kernel.org>
Sat, 21 Jun 2025 14:53:39 +0000 (07:53 -0700)
Migrate to new callbacks added by commit 9bb00786fc61 ("net: ethtool:
add dedicated callbacks for getting and setting rxfh fields").

This driver's RXFH config is read only / fixed so the conversion
is purely factoring out the handling into a helper. One thing of
note that this is one of the two drivers which pays attention to
rss_context.

Reviewed-by: Edward Cree <ecree.xilinx@gmail.com>
Link: https://patch.msgid.link/20250618203823.1336156-4-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/sfc/ethtool.c
drivers/net/ethernet/sfc/ethtool_common.c
drivers/net/ethernet/sfc/ethtool_common.h

index afbedca63b29e05b21950cca8f79bc52ee9b64ac..23c6a7df78d03894e217ac78968e7d69a01f6ce7 100644 (file)
@@ -268,6 +268,7 @@ const struct ethtool_ops efx_ethtool_ops = {
        .rxfh_priv_size         = sizeof(struct efx_rss_context_priv),
        .get_rxfh               = efx_ethtool_get_rxfh,
        .set_rxfh               = efx_ethtool_set_rxfh,
+       .get_rxfh_fields        = efx_ethtool_get_rxfh_fields,
        .create_rxfh_context    = efx_ethtool_create_rxfh_context,
        .modify_rxfh_context    = efx_ethtool_modify_rxfh_context,
        .remove_rxfh_context    = efx_ethtool_remove_rxfh_context,
index 2d734496733fad04d38aa9b467c9393cc3878c3d..823263969f92a25bc29d96c88f46701f696838dd 100644 (file)
@@ -800,66 +800,72 @@ static int efx_ethtool_get_class_rule(struct efx_nic *efx,
        return rc;
 }
 
-int efx_ethtool_get_rxnfc(struct net_device *net_dev,
-                         struct ethtool_rxnfc *info, u32 *rule_locs)
+int efx_ethtool_get_rxfh_fields(struct net_device *net_dev,
+                               struct ethtool_rxfh_fields *info)
 {
        struct efx_nic *efx = efx_netdev_priv(net_dev);
-       u32 rss_context = 0;
-       s32 rc = 0;
-
-       switch (info->cmd) {
-       case ETHTOOL_GRXRINGS:
-               info->data = efx->n_rx_channels;
-               return 0;
+       struct efx_rss_context_priv *ctx;
+       __u64 data;
+       int rc = 0;
 
-       case ETHTOOL_GRXFH: {
-               struct efx_rss_context_priv *ctx = &efx->rss_context.priv;
-               __u64 data;
+       ctx = &efx->rss_context.priv;
 
-               mutex_lock(&net_dev->ethtool->rss_lock);
-               if (info->flow_type & FLOW_RSS && info->rss_context) {
-                       ctx = efx_find_rss_context_entry(efx, info->rss_context);
-                       if (!ctx) {
-                               rc = -ENOENT;
-                               goto out_unlock;
-                       }
+       mutex_lock(&net_dev->ethtool->rss_lock);
+       if (info->rss_context) {
+               ctx = efx_find_rss_context_entry(efx, info->rss_context);
+               if (!ctx) {
+                       rc = -ENOENT;
+                       goto out_unlock;
                }
+       }
 
-               data = 0;
-               if (!efx_rss_active(ctx)) /* No RSS */
-                       goto out_setdata_unlock;
+       data = 0;
+       if (!efx_rss_active(ctx)) /* No RSS */
+               goto out_setdata_unlock;
 
-               switch (info->flow_type & ~FLOW_RSS) {
-               case UDP_V4_FLOW:
-               case UDP_V6_FLOW:
-                       if (ctx->rx_hash_udp_4tuple)
-                               data = (RXH_L4_B_0_1 | RXH_L4_B_2_3 |
-                                       RXH_IP_SRC | RXH_IP_DST);
-                       else
-                               data = RXH_IP_SRC | RXH_IP_DST;
-                       break;
-               case TCP_V4_FLOW:
-               case TCP_V6_FLOW:
+       switch (info->flow_type) {
+       case UDP_V4_FLOW:
+       case UDP_V6_FLOW:
+               if (ctx->rx_hash_udp_4tuple)
                        data = (RXH_L4_B_0_1 | RXH_L4_B_2_3 |
                                RXH_IP_SRC | RXH_IP_DST);
-                       break;
-               case SCTP_V4_FLOW:
-               case SCTP_V6_FLOW:
-               case AH_ESP_V4_FLOW:
-               case AH_ESP_V6_FLOW:
-               case IPV4_FLOW:
-               case IPV6_FLOW:
+               else
                        data = RXH_IP_SRC | RXH_IP_DST;
-                       break;
-               default:
-                       break;
-               }
+               break;
+       case TCP_V4_FLOW:
+       case TCP_V6_FLOW:
+               data = (RXH_L4_B_0_1 | RXH_L4_B_2_3 |
+                       RXH_IP_SRC | RXH_IP_DST);
+               break;
+       case SCTP_V4_FLOW:
+       case SCTP_V6_FLOW:
+       case AH_ESP_V4_FLOW:
+       case AH_ESP_V6_FLOW:
+       case IPV4_FLOW:
+       case IPV6_FLOW:
+               data = RXH_IP_SRC | RXH_IP_DST;
+               break;
+       default:
+               break;
+       }
 out_setdata_unlock:
-               info->data = data;
+       info->data = data;
 out_unlock:
-               mutex_unlock(&net_dev->ethtool->rss_lock);
-               return rc;
-       }
+       mutex_unlock(&net_dev->ethtool->rss_lock);
+       return rc;
+}
+
+int efx_ethtool_get_rxnfc(struct net_device *net_dev,
+                         struct ethtool_rxnfc *info, u32 *rule_locs)
+{
+       struct efx_nic *efx = efx_netdev_priv(net_dev);
+       u32 rss_context = 0;
+       s32 rc = 0;
+
+       switch (info->cmd) {
+       case ETHTOOL_GRXRINGS:
+               info->data = efx->n_rx_channels;
+               return 0;
 
        case ETHTOOL_GRXCLSRLCNT:
                info->data = efx_filter_get_rx_id_limit(efx);
index fc52e891637d30cd6a05f86ef5a08dd3b5341867..24db4fccbe78ade9a5c1169887b572f4b87f7c54 100644 (file)
@@ -49,6 +49,8 @@ int efx_ethtool_get_rxfh(struct net_device *net_dev,
 int efx_ethtool_set_rxfh(struct net_device *net_dev,
                         struct ethtool_rxfh_param *rxfh,
                         struct netlink_ext_ack *extack);
+int efx_ethtool_get_rxfh_fields(struct net_device *net_dev,
+                               struct ethtool_rxfh_fields *info);
 int efx_ethtool_create_rxfh_context(struct net_device *net_dev,
                                    struct ethtool_rxfh_context *ctx,
                                    const struct ethtool_rxfh_param *rxfh,