Skip to contentSkip to conversation

ethtool: Fix set RXFH for drivers without RXFH fields support

PATCH In review Gal Pressman 2 participants 4 messages Jul 9, 2025 – Jul 10, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ethtool: Fix set RXFH for drivers without RXFH fields support

Some drivers (e.g., mlx4_en) support ->set_rxfh() functionality (such as setting hash function), but not setting the RXFH fields.

The requirement of ->get_rxfh_fields() in ethtool_set_rxfh() is there to verify that we have no conflict with the RSS fields options, if it doesn't exist then there is no point in doing the check. Soften the check in ethtool_set_rxfh() so it doesn't fail when ->get_rxfh_fields() doesn't exist.

This fixes the following error:

$ ethtool --set-rxfh-indir eth2 hfunc xor
Cannot set RX flow hash configuration: Operation not supported
Fixes 72792461c8e8 ("net: ethtool: don't mux RXFH via rxnfc callbacks")
---
 net/ethtool/ioctl.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
net/ethtool/ioctl.c +6 -4
index b6d96e562c9a..4bb8bf20a0eb 100644
@@ -1519,7 +1519,7 @@ static noinline_for_stack int ethtool_set_rxfh(struct net_device *dev,
 	u8 *rss_config;
 	int ret;
 
-	if (!ops->get_rxnfc || !ops->get_rxfh_fields || !ops->set_rxfh)
+	if (!ops->get_rxnfc || !ops->set_rxfh)
 		return -EOPNOTSUPP;
 
 	if (ops->get_rxfh_indir_size)
@@ -1623,9 +1623,11 @@ static noinline_for_stack int ethtool_set_rxfh(struct net_device *dev,
 
 	mutex_lock(&dev->ethtool->rss_lock);
 
-	ret = ethtool_check_flow_types(dev, rxfh.input_xfrm);
-	if (ret)
-		goto out_unlock;
+	if (ops->get_rxfh_fields) {
+		ret = ethtool_check_flow_types(dev, rxfh.input_xfrm);
+		if (ret)
+			goto out_unlock;
+	}
 
 	if (rxfh.rss_context && rxfh_dev.rss_delete) {
 		ret = ethtool_check_rss_ctx_busy(dev, rxfh.rss_context);
Signature · 1 line
2.40.1
maintainer
#1 lore raw
Quoted 9 lines · On Wed, 9 Jul 2025 18:32:51 +0300 Gal Pressman wrote:

Some drivers (e.g., mlx4_en) support ->set_rxfh() functionality (such as setting hash function), but not setting the RXFH fields.

The requirement of ->get_rxfh_fields() in ethtool_set_rxfh() is there to verify that we have no conflict with the RSS fields options, if it doesn't exist then there is no point in doing the check. Soften the check in ethtool_set_rxfh() so it doesn't fail when ->get_rxfh_fields() doesn't exist.

Quoted 3 lines

This fixes the following error:

$ ethtool --set-rxfh-indir eth2 hfunc xor
Cannot set RX flow hash configuration: Operation not supported

Ah, thanks for the fix!

In this case I wonder if we wouldn't be better off returning early in ethtool_check_flow_types() if input_xfrm is 0 or NO_CHANGE. Most drivers will have get_rxfh_fields - still there's no point in doing the check if they have empty ops->supported_input_xfrm

We could add a:

	if (WARN_ON(ops->supported_input_xfrm && !ops->get_rxfh_fields))
		return -EINVAL;

into ethtool_check_ops() and we'd be both safe and slightly faster.

WDYT?

#2 lore raw
Quoted 14 lines · Jakub Kicinski
Quoted 9 lines · On Wed, 9 Jul 2025 18:32:51 +0300 Gal Pressman wrote:

Some drivers (e.g., mlx4_en) support ->set_rxfh() functionality (such as setting hash function), but not setting the RXFH fields.

The requirement of ->get_rxfh_fields() in ethtool_set_rxfh() is there to verify that we have no conflict with the RSS fields options, if it doesn't exist then there is no point in doing the check. Soften the check in ethtool_set_rxfh() so it doesn't fail when ->get_rxfh_fields() doesn't exist.

Quoted 3 lines

This fixes the following error:

$ ethtool --set-rxfh-indir eth2 hfunc xor
Cannot set RX flow hash configuration: Operation not supported
Quoted 6 lines

Ah, thanks for the fix!

In this case I wonder if we wouldn't be better off returning early in ethtool_check_flow_types() if input_xfrm is 0 or NO_CHANGE. Most drivers will have get_rxfh_fields - still there's no point in doing the check if they have empty ops->supported_input_xfrm

Makes sense.

Quoted 7 lines

We could add a:

	if (WARN_ON(ops->supported_input_xfrm && !ops->get_rxfh_fields))
		return -EINVAL;

into ethtool_check_ops() and we'd be both safe and slightly faster.

This is a step further.

There could be a driver that allows setting of input xfrm but not rxfh fields. Failing the netdevice registration is different than skipping ethtool_check_flow_types().

Maybe there are no such devices and we shouldn't care?

maintainer
#3 lore raw
Quoted 7 lines · On Thu, 10 Jul 2025 14:17:11 +0300 Gal Pressman wrote:
Quoted 6 lines

We could add a:

	if (WARN_ON(ops->supported_input_xfrm && !ops->get_rxfh_fields))
		return -EINVAL;

into ethtool_check_ops() and we'd be both safe and slightly faster.

Quoted 7 lines

This is a step further.

There could be a driver that allows setting of input xfrm but not rxfh fields. Failing the netdevice registration is different than skipping ethtool_check_flow_types().

Maybe there are no such devices and we shouldn't care?

Note that we're talking about the get. It's still perfectly fine for the hypothetical driver to not support _changing_ the fields, the fields be hardwired. But we need to know what fields the device is using to validate the xfrm is correct.