Skip to content

Commit fac4b41

Browse files
committed
net: ethtool: require drivers to opt into the per-RSS ctx RXFH
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 <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 2a644c5 commit fac4b41

File tree

4 files changed

+13
-0
lines changed

4 files changed

+13
-0
lines changed

drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2616,6 +2616,7 @@ static void mlx5e_get_ts_stats(struct net_device *netdev,
26162616
const struct ethtool_ops mlx5e_ethtool_ops = {
26172617
.cap_link_lanes_supported = true,
26182618
.cap_rss_ctx_supported = true,
2619+
.rxfh_per_ctx_fields = true,
26192620
.rxfh_per_ctx_key = true,
26202621
.supported_coalesce_params = ETHTOOL_COALESCE_USECS |
26212622
ETHTOOL_COALESCE_MAX_FRAMES |

drivers/net/ethernet/sfc/ethtool.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ const struct ethtool_ops efx_ethtool_ops = {
262262
.set_rxnfc = efx_ethtool_set_rxnfc,
263263
.get_rxfh_indir_size = efx_ethtool_get_rxfh_indir_size,
264264
.get_rxfh_key_size = efx_ethtool_get_rxfh_key_size,
265+
.rxfh_per_ctx_fields = true,
265266
.rxfh_per_ctx_key = true,
266267
.cap_rss_rxnfc_adds = true,
267268
.rxfh_priv_size = sizeof(struct efx_rss_context_priv),

include/linux/ethtool.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -855,6 +855,8 @@ struct kernel_ethtool_ts_info {
855855
* @cap_rss_ctx_supported: indicates if the driver supports RSS
856856
* contexts via legacy API, drivers implementing @create_rxfh_context
857857
* do not have to set this bit.
858+
* @rxfh_per_ctx_fields: device supports selecting different header fields
859+
* for Rx hash calculation and RSS for each additional context.
858860
* @rxfh_per_ctx_key: device supports setting different RSS key for each
859861
* additional context. Netlink API should report hfunc, key, and input_xfrm
860862
* for every context, not just context 0.
@@ -1084,6 +1086,7 @@ struct ethtool_ops {
10841086
u32 supported_input_xfrm:8;
10851087
u32 cap_link_lanes_supported:1;
10861088
u32 cap_rss_ctx_supported:1;
1089+
u32 rxfh_per_ctx_fields:1;
10871090
u32 rxfh_per_ctx_key:1;
10881091
u32 cap_rss_rxnfc_adds:1;
10891092
u32 rxfh_indir_space;

net/ethtool/ioctl.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,6 +1075,10 @@ ethtool_set_rxfh_fields(struct net_device *dev, u32 cmd, void __user *useraddr)
10751075
if (rc)
10761076
return rc;
10771077

1078+
if (info.flow_type & FLOW_RSS && info.rss_context &&
1079+
!ops->rxfh_per_ctx_fields)
1080+
return -EINVAL;
1081+
10781082
if (ops->get_rxfh) {
10791083
struct ethtool_rxfh_param rxfh = {};
10801084

@@ -1105,6 +1109,10 @@ ethtool_get_rxfh_fields(struct net_device *dev, u32 cmd, void __user *useraddr)
11051109
if (ret)
11061110
return ret;
11071111

1112+
if (info.flow_type & FLOW_RSS && info.rss_context &&
1113+
!ops->rxfh_per_ctx_fields)
1114+
return -EINVAL;
1115+
11081116
ret = ops->get_rxnfc(dev, &info, NULL);
11091117
if (ret < 0)
11101118
return ret;

0 commit comments

Comments
 (0)