Use the newly introduced .get_rx_ring_count ethtool ops callback instead
of handling ETHTOOL_GRXRINGS directly in .get_rxnfc().
Since ETHTOOL_GRXRINGS was the only command handled by be_get_rxnfc(),
remove the function entirely.
Signed-off-by: Breno Leitao <leitao@debian.org>
---
drivers/net/ethernet/emulex/benet/be_ethtool.c | 31 +++++++-------------------
1 file changed, 8 insertions(+), 23 deletions(-)
diff --git a/drivers/net/ethernet/emulex/benet/be_ethtool.c b/drivers/net/ethernet/emulex/benet/be_ethtool.c
index f9216326bdfe..4717a1dacbe2 100644
--- a/drivers/net/ethernet/emulex/benet/be_ethtool.c
+++ b/drivers/net/ethernet/emulex/benet/be_ethtool.c
@@ -1073,6 +1073,13 @@ static void be_set_msg_level(struct net_device *netdev, u32 level)
adapter->msg_enable = level;
}
+static u32 be_get_rx_ring_count(struct net_device *netdev)
+{
+ struct be_adapter *adapter = netdev_priv(netdev);
+
+ return adapter->num_rx_qs;
+}
+
static int be_get_rxfh_fields(struct net_device *netdev,
struct ethtool_rxfh_fields *cmd)
{
@@ -1117,28 +1124,6 @@ static int be_get_rxfh_fields(struct net_device *netdev,
return 0;
}
-static int be_get_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd,
- u32 *rule_locs)
-{
- struct be_adapter *adapter = netdev_priv(netdev);
-
- if (!be_multi_rxq(adapter)) {
- dev_info(&adapter->pdev->dev,
- "ethtool::get_rxnfc: RX flow hashing is disabled\n");
- return -EINVAL;
- }
-
- switch (cmd->cmd) {
- case ETHTOOL_GRXRINGS:
- cmd->data = adapter->num_rx_qs;
- break;
- default:
- return -EINVAL;
- }
-
- return 0;
-}
-
static int be_set_rxfh_fields(struct net_device *netdev,
const struct ethtool_rxfh_fields *cmd,
struct netlink_ext_ack *extack)
@@ -1441,7 +1426,7 @@ const struct ethtool_ops be_ethtool_ops = {
.get_ethtool_stats = be_get_ethtool_stats,
.flash_device = be_do_flash,
.self_test = be_self_test,
- .get_rxnfc = be_get_rxnfc,
+ .get_rx_ring_count = be_get_rx_ring_count,
.get_rxfh_fields = be_get_rxfh_fields,
.set_rxfh_fields = be_set_rxfh_fields,
.get_rxfh_indir_size = be_get_rxfh_indir_size,
--
2.47.3
On Thu, 15 Jan 2026 06:37:48 -0800 Breno Leitao wrote:
> -static int be_get_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd,
> - u32 *rule_locs)
> -{
> - struct be_adapter *adapter = netdev_priv(netdev);
> -
> - if (!be_multi_rxq(adapter)) {
> - dev_info(&adapter->pdev->dev,
> - "ethtool::get_rxnfc: RX flow hashing is disabled\n");
> - return -EINVAL;
> - }
I think we need to add this check to set_rxfh now. The error coming
from get_rxnfc/GRXRINGS effectively shielded the driver from set_rxfh
calls ever happening when there's only 1 ring. Now they will happen.
Applied the rest
Hello Jakub,
On Sat, Jan 17, 2026 at 06:15:51PM -0800, Jakub Kicinski wrote:
> On Thu, 15 Jan 2026 06:37:48 -0800 Breno Leitao wrote:
> > -static int be_get_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd,
> > - u32 *rule_locs)
> > -{
> > - struct be_adapter *adapter = netdev_priv(netdev);
> > -
> > - if (!be_multi_rxq(adapter)) {
> > - dev_info(&adapter->pdev->dev,
> > - "ethtool::get_rxnfc: RX flow hashing is disabled\n");
> > - return -EINVAL;
> > - }
>
> I think we need to add this check to set_rxfh now. The error coming
> from get_rxnfc/GRXRINGS effectively shielded the driver from set_rxfh
> calls ever happening when there's only 1 ring. Now they will happen.
You are absolutely correct. The ethtool core calls
get_rxnfc(ETHTOOL_GRXRINGS) _before_ allowing RSS configuration via
set_rxfh, and if it fails, ethtool_set_rxfh() will fail as well. And
with the current change, ethtool_set_rxfh() will not fail if the adapter
is not multi-queue.
Thanks for the heads-up. I will send a v2 shortly.
--breno
On Mon, Jan 19, 2026 at 03:07:12AM -0800, Breno Leitao wrote:
> Hello Jakub,
>
> On Sat, Jan 17, 2026 at 06:15:51PM -0800, Jakub Kicinski wrote:
> > On Thu, 15 Jan 2026 06:37:48 -0800 Breno Leitao wrote:
> > > -static int be_get_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd,
> > > - u32 *rule_locs)
> > > -{
> > > - struct be_adapter *adapter = netdev_priv(netdev);
> > > -
> > > - if (!be_multi_rxq(adapter)) {
> > > - dev_info(&adapter->pdev->dev,
> > > - "ethtool::get_rxnfc: RX flow hashing is disabled\n");
> > > - return -EINVAL;
> > > - }
> >
> > I think we need to add this check to set_rxfh now. The error coming
> > from get_rxnfc/GRXRINGS effectively shielded the driver from set_rxfh
> > calls ever happening when there's only 1 ring. Now they will happen.
>
> You are absolutely correct. The ethtool core calls
> get_rxnfc(ETHTOOL_GRXRINGS) _before_ allowing RSS configuration via
> set_rxfh, and if it fails, ethtool_set_rxfh() will fail as well. And
> with the current change, ethtool_set_rxfh() will not fail if the adapter
> is not multi-queue.
Upon further consideration, should we implement this limitation directly within
the ethtool infrastructure?
Something as:
Author: Breno Leitao <leitao@debian.org>
Date: Mon Jan 19 03:25:05 2026 -0800
ethtool: reject RSS configuration on single-queue devices
Configuring RSS (Receive Side Scaling) makes no sense when the device
only has a single RX queue - there is nothing to distribute traffic
across. The indirection table would just map everything to queue 0.
Add explicit checks in ethtool_set_rxfh_indir() and ethtool_set_rxfh()
to reject RSS configuration when the device reports fewer than 2 RX rings.
This protects all drivers uniformly at the core level.
Signed-off-by: Breno Leitao <leitao@debian.org>
diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c
index 9431e305b233..899864e96aab 100644
--- a/net/ethtool/ioctl.c
+++ b/net/ethtool/ioctl.c
@@ -1380,6 +1380,10 @@ static noinline_for_stack int ethtool_set_rxfh_indir(struct net_device *dev,
ret = num_rx_rings;
goto out;
}
+ if (num_rx_rings < 2) {
+ ret = -EOPNOTSUPP;
+ goto out;
+ }
if (user_size == 0) {
u32 *indir = rxfh_dev.indir;
@@ -1599,6 +1603,10 @@ static noinline_for_stack int ethtool_set_rxfh(struct net_device *dev,
ret = num_rx_rings;
goto out_free;
}
+ if (num_rx_rings < 2) {
+ ret = -EOPNOTSUPP;
+ goto out_free;
+ }
On Mon, 19 Jan 2026 04:56:49 -0800 Breno Leitao wrote: > > > I think we need to add this check to set_rxfh now. The error coming > > > from get_rxnfc/GRXRINGS effectively shielded the driver from set_rxfh > > > calls ever happening when there's only 1 ring. Now they will happen. > > > > You are absolutely correct. The ethtool core calls > > get_rxnfc(ETHTOOL_GRXRINGS) _before_ allowing RSS configuration via > > set_rxfh, and if it fails, ethtool_set_rxfh() will fail as well. And > > with the current change, ethtool_set_rxfh() will not fail if the adapter > > is not multi-queue. > > Upon further consideration, should we implement this limitation directly within > the ethtool infrastructure? That may cause some regressions, we're getting the number of currently configured Rx rings. If we were to check how many Rx rings the device has that'd make sense. But since we can only access currently configured rings, in theory, if the device has multiple rings, just only one is active now - changing config for the RSS key or function should work just fine. IOW # change key # increase ring count to make they key meaningful Used to work.
© 2016 - 2026 Red Hat, Inc.