]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
net: ethtool: require drivers to opt into the per-RSS ctx RXFH
authorJakub Kicinski <kuba@kernel.org>
Wed, 11 Jun 2025 14:59:43 +0000 (07:59 -0700)
committerJakub Kicinski <kuba@kernel.org>
Fri, 13 Jun 2025 00:16:19 +0000 (17:16 -0700)
RX Flow Hashing supports using different configuration for different
RSS contexts. Only two drivers seem to support it. Make sure we
uniformly error out for drivers which don't.

Reviewed-by: Joe Damato <joe@dama.to>
Link: https://patch.msgid.link/20250611145949.2674086-4-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
drivers/net/ethernet/sfc/ethtool.c
include/linux/ethtool.h
net/ethtool/ioctl.c

index 3cb8d3bf9044ca7e4baa358f3e15260b73e184e3..8b9ee8bac67412a8f1d36efdbe24da2be3281fd9 100644 (file)
@@ -2616,6 +2616,7 @@ static void mlx5e_get_ts_stats(struct net_device *netdev,
 const struct ethtool_ops mlx5e_ethtool_ops = {
        .cap_link_lanes_supported = true,
        .cap_rss_ctx_supported  = true,
+       .rxfh_per_ctx_fields    = true,
        .rxfh_per_ctx_key       = true,
        .supported_coalesce_params = ETHTOOL_COALESCE_USECS |
                                     ETHTOOL_COALESCE_MAX_FRAMES |
index 83d715544f7fb238c573687f9af235fe3a311f5e..afbedca63b29e05b21950cca8f79bc52ee9b64ac 100644 (file)
@@ -262,6 +262,7 @@ const struct ethtool_ops efx_ethtool_ops = {
        .set_rxnfc              = efx_ethtool_set_rxnfc,
        .get_rxfh_indir_size    = efx_ethtool_get_rxfh_indir_size,
        .get_rxfh_key_size      = efx_ethtool_get_rxfh_key_size,
+       .rxfh_per_ctx_fields    = true,
        .rxfh_per_ctx_key       = true,
        .cap_rss_rxnfc_adds     = true,
        .rxfh_priv_size         = sizeof(struct efx_rss_context_priv),
index 90da1aee6e5692dadd8bd55da14699e007588c5e..1a6737721d7fe24b47199ab8c8e6c73ea813fe30 100644 (file)
@@ -855,6 +855,8 @@ struct kernel_ethtool_ts_info {
  * @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
  *     additional context. Netlink API should report hfunc, key, and input_xfrm
  *     for every context, not just context 0.
@@ -1084,6 +1086,7 @@ 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;
        u32     rxfh_indir_space;
index 33892099cdad23e20b85f9e897f582af635d9f6d..1a1705e900b3f503e28b2aa2a3552fb62ce113bb 100644 (file)
@@ -1075,6 +1075,10 @@ ethtool_set_rxfh_fields(struct net_device *dev, u32 cmd, void __user *useraddr)
        if (rc)
                return rc;
 
+       if (info.flow_type & FLOW_RSS && info.rss_context &&
+           !ops->rxfh_per_ctx_fields)
+               return -EINVAL;
+
        if (ops->get_rxfh) {
                struct ethtool_rxfh_param rxfh = {};
 
@@ -1105,6 +1109,10 @@ ethtool_get_rxfh_fields(struct net_device *dev, u32 cmd, void __user *useraddr)
        if (ret)
                return ret;
 
+       if (info.flow_type & FLOW_RSS && info.rss_context &&
+           !ops->rxfh_per_ctx_fields)
+               return -EINVAL;
+
        ret = ops->get_rxnfc(dev, &info, NULL);
        if (ret < 0)
                return ret;