mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH net-next v3 0/3] net: rss: Consider RSS not supported when key and indir sizes are 0
@ 2026-10-02 14:28 Maxime Chevallier
  2026-10-02 14:28 ` [PATCH net-next v3 1/3] net: rss: Require indir table size or hash key size to support RSS Maxime Chevallier
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Maxime Chevallier @ 2026-10-02 14:28 UTC (permalink / raw)
  To: Andrew Lunn, Jakub Kicinski, davem, Eric Dumazet, Paolo Abeni,
	Simon Horman, Maxime Coquelin, Alexandre Torgue, Russell King,
	Lorenzo Bianconi, Nicolai Buchwitz, Jitendra Vegiraju
  Cc: Maxime Chevallier, thomas.petazzoni, Alexis Lothoré,
	netdev, linux-kernel, linux-arm-kernel, linux-stm32,
	Peter Robinson, Joe Damato

Hi,

This series follows what used to be an stmmac-only series to handle
devices that don't support RSS but still provice the associated ethtool
ops.

There are a few drivers out there that populate the RSS ethtool ops, but
don't always support RSS. stmmac and mvpp2 are such examples.

Following discussions with Jakub on V2, patch 1 makes so that returning
a 0-length key and a 0-size indirection table means "we don't do RSS".

Patch 2 introduces a helper to check for RSS support in stmmac, and
Patch 3 uses it. Patch 3 has been reworked so I haven't applied the
review tags, sorry about that Joe, Lorenzo and Nicolai :( I've drop the
-EOPNOTSUPP return from the rxfh ops as we return 0 on the sizes.

V3:
 - Add patch 1,
 - No changes on patch 2
 - Removed the -EOPNOTSUPP returns on patch 3

V2:
https://lore.kernel.org/r/20260928145043.1228968-1-maxime.chevallier@bootlin.com
 - target net-next
 - Add a dedicated helper, following Nicolai's review.

V1: https://lore.kernel.org/netdev/20260926093343.292181-1-maxime.chevallier@bootlin.com/#t

Maxime Chevallier (3):
  net: rss: Require indir table size or hash key size to support RSS
  net: stmmac: Introduce a helper to check RSS support
  net: stmmac: Don't set or get RSS parameters when not supported

 drivers/net/ethernet/stmicro/stmmac/stmmac.h         | 5 +++++
 drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c | 6 ++++++
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c    | 4 ++--
 net/ethtool/ioctl.c                                  | 6 ++++++
 net/ethtool/rss.c                                    | 7 +++++--
 5 files changed, 24 insertions(+), 4 deletions(-)

-- 
2.55.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH net-next v3 1/3] net: rss: Require indir table size or hash key size to support RSS
  2026-10-02 14:28 [PATCH net-next v3 0/3] net: rss: Consider RSS not supported when key and indir sizes are 0 Maxime Chevallier
@ 2026-10-02 14:28 ` Maxime Chevallier
  2026-10-02 14:59   ` Nicolai Buchwitz
  2026-10-02 14:28 ` [PATCH net-next v3 2/3] net: stmmac: Introduce a helper to check RSS support Maxime Chevallier
  2026-10-02 14:28 ` [PATCH net-next v3 3/3] net: stmmac: Don't set or get RSS parameters when not supported Maxime Chevallier
  2 siblings, 1 reply; 7+ messages in thread
From: Maxime Chevallier @ 2026-10-02 14:28 UTC (permalink / raw)
  To: Andrew Lunn, Jakub Kicinski, davem, Eric Dumazet, Paolo Abeni,
	Simon Horman, Maxime Coquelin, Alexandre Torgue, Russell King,
	Lorenzo Bianconi, Nicolai Buchwitz, Jitendra Vegiraju
  Cc: Maxime Chevallier, thomas.petazzoni, Alexis Lothoré,
	netdev, linux-kernel, linux-arm-kernel, linux-stm32,
	Peter Robinson, Joe Damato

A point can be made that devices that report a 0-size indirection table
and 0-length key size don't really support RSS. Let's return -EOPNOTSUPP
in that case, and skip these devices during DUMP requests.

This however also reports -ENOTSUPP for devices that only supports flow
hash fields ops now.

Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
---
 net/ethtool/ioctl.c | 6 ++++++
 net/ethtool/rss.c   | 7 +++++--
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c
index 27b0e2e275dc..d32b403c8d3a 100644
--- a/net/ethtool/ioctl.c
+++ b/net/ethtool/ioctl.c
@@ -1444,6 +1444,9 @@ static noinline_for_stack int ethtool_get_rxfh(struct net_device *dev,
 	if (ops->get_rxfh_key_size)
 		rxfh_dev.key_size = ops->get_rxfh_key_size(dev);
 
+	if (!rxfh_dev.indir_size && !rxfh_dev.key_size)
+		return -EOPNOTSUPP;
+
 	if (copy_from_user(&rxfh, useraddr, sizeof(rxfh)))
 		return -EFAULT;
 	user_indir_size = rxfh.indir_size;
@@ -1554,6 +1557,9 @@ static noinline_for_stack int ethtool_set_rxfh(struct net_device *dev,
 	if (ops->get_rxfh_key_size)
 		dev_key_size = ops->get_rxfh_key_size(dev);
 
+	if (!dev_indir_size && !dev_key_size)
+		return -EOPNOTSUPP;
+
 	if (copy_from_user(&rxfh, useraddr, sizeof(rxfh)))
 		return -EFAULT;
 
diff --git a/net/ethtool/rss.c b/net/ethtool/rss.c
index d4a1a4724b67..cb9bead0cedd 100644
--- a/net/ethtool/rss.c
+++ b/net/ethtool/rss.c
@@ -129,6 +129,9 @@ rss_get_data_alloc(struct net_device *dev, struct rss_reply_data *data)
 	if (ops->get_rxfh_key_size)
 		data->hkey_size = ops->get_rxfh_key_size(dev);
 
+	if (!data->indir_size && !data->hkey_size)
+		return -EOPNOTSUPP;
+
 	indir_bytes = data->indir_size * sizeof(u32);
 	total_size = indir_bytes + data->hkey_size;
 	rss_config = kzalloc(total_size, GFP_KERNEL);
@@ -449,7 +452,7 @@ rss_dump_one_dev(struct sk_buff *skb, struct netlink_callback *cb,
 
 	if (!ctx->ctx_idx) {
 		ret = rss_dump_one_ctx(skb, cb, dev, 0);
-		if (ret)
+		if (ret && ret != -EOPNOTSUPP)
 			return ret;
 		ctx->ctx_idx++;
 	}
@@ -457,7 +460,7 @@ rss_dump_one_dev(struct sk_buff *skb, struct netlink_callback *cb,
 	for (; xa_find(&dev->ethtool->rss_ctx, &ctx->ctx_idx,
 		       ULONG_MAX, XA_PRESENT); ctx->ctx_idx++) {
 		ret = rss_dump_one_ctx(skb, cb, dev, ctx->ctx_idx);
-		if (ret)
+		if (ret && ret != -EOPNOTSUPP)
 			return ret;
 	}
 	ctx->ctx_idx = ctx->start_ctx;
-- 
2.55.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH net-next v3 2/3] net: stmmac: Introduce a helper to check RSS support
  2026-10-02 14:28 [PATCH net-next v3 0/3] net: rss: Consider RSS not supported when key and indir sizes are 0 Maxime Chevallier
  2026-10-02 14:28 ` [PATCH net-next v3 1/3] net: rss: Require indir table size or hash key size to support RSS Maxime Chevallier
@ 2026-10-02 14:28 ` Maxime Chevallier
  2026-10-02 15:00   ` Nicolai Buchwitz
  2026-10-02 14:28 ` [PATCH net-next v3 3/3] net: stmmac: Don't set or get RSS parameters when not supported Maxime Chevallier
  2 siblings, 1 reply; 7+ messages in thread
From: Maxime Chevallier @ 2026-10-02 14:28 UTC (permalink / raw)
  To: Andrew Lunn, Jakub Kicinski, davem, Eric Dumazet, Paolo Abeni,
	Simon Horman, Maxime Coquelin, Alexandre Torgue, Russell King,
	Lorenzo Bianconi, Nicolai Buchwitz, Jitendra Vegiraju
  Cc: Maxime Chevallier, thomas.petazzoni, Alexis Lothoré,
	netdev, linux-kernel, linux-arm-kernel, linux-stm32,
	Peter Robinson, Joe Damato

The RSS feature is only available in stmmac if the hardware reports it
through the DMA caps and if the platform glue sets rss_en.

Introduce a helper that checks both.

For now, no platform sets rss_en, but there's interest in the topic so
leave the door open instead of dropping the feature altogether.

No functional changes intended.

Suggested-by: Nicolai Buchwitz <nb@tipi-net.de>
Acked-by: Lorenzo Bianconi <lorenzo.bianconi@oss.qualcomm.com>
Reviewed-by: Joe Damato <joe@dama.to>
Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac.h      | 5 +++++
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 4 ++--
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
index 4fc96b317d79..17991572fd2d 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
@@ -440,6 +440,11 @@ struct timespec64 stmmac_calc_tas_basetime(ktime_t old_base_time,
 					   ktime_t current_time,
 					   u64 cycle_time);
 
+static inline bool stmmac_rss_is_supported(const struct stmmac_priv *priv)
+{
+	return priv->dma_cap.rssen && priv->plat->rss_en;
+}
+
 #if IS_ENABLED(CONFIG_STMMAC_SELFTESTS)
 void stmmac_selftest_run(struct net_device *dev,
 			 struct ethtool_test *etest, u64 *buf);
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 0c381ae0d0ff..76f9f5d35253 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -3571,7 +3571,7 @@ static void stmmac_mac_config_rx_queues_routing(struct stmmac_priv *priv)
 
 static void stmmac_mac_config_rss(struct stmmac_priv *priv)
 {
-	if (!priv->dma_cap.rssen || !priv->plat->rss_en) {
+	if (!stmmac_rss_is_supported(priv)) {
 		priv->rss.enable = false;
 		return;
 	}
@@ -8100,7 +8100,7 @@ static int __stmmac_dvr_probe(struct device *device,
 	for (i = 0; i < ARRAY_SIZE(priv->rss.table); i++)
 		priv->rss.table[i] = ethtool_rxfh_indir_default(i, rxq);
 
-	if (priv->dma_cap.rssen && priv->plat->rss_en)
+	if (stmmac_rss_is_supported(priv))
 		ndev->features |= NETIF_F_RXHASH;
 
 	ndev->vlan_features |= ndev->features;
-- 
2.55.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH net-next v3 3/3] net: stmmac: Don't set or get RSS parameters when not supported
  2026-10-02 14:28 [PATCH net-next v3 0/3] net: rss: Consider RSS not supported when key and indir sizes are 0 Maxime Chevallier
  2026-10-02 14:28 ` [PATCH net-next v3 1/3] net: rss: Require indir table size or hash key size to support RSS Maxime Chevallier
  2026-10-02 14:28 ` [PATCH net-next v3 2/3] net: stmmac: Introduce a helper to check RSS support Maxime Chevallier
@ 2026-10-02 14:28 ` Maxime Chevallier
  2026-10-02 15:00   ` Nicolai Buchwitz
  2 siblings, 1 reply; 7+ messages in thread
From: Maxime Chevallier @ 2026-10-02 14:28 UTC (permalink / raw)
  To: Andrew Lunn, Jakub Kicinski, davem, Eric Dumazet, Paolo Abeni,
	Simon Horman, Maxime Coquelin, Alexandre Torgue, Russell King,
	Lorenzo Bianconi, Nicolai Buchwitz, Jitendra Vegiraju
  Cc: Maxime Chevallier, thomas.petazzoni, Alexis Lothoré,
	netdev, linux-kernel, linux-arm-kernel, linux-stm32,
	Peter Robinson, Joe Damato

The RSS kselftests fail on stmmac, and this is partly due to the driver
reporting bogus data for the RSS ops :

 - ethtool -x reports an indirection table and a key while the hardware
   doesn't have any of that
 - ethtool -X fails with -EINVAL.

Return a 0 indir size and key size when rss isn't supported, effectively
meaning we don't support RSS here.

Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
index 1cf0f8820b33..7f2a70575b83 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
@@ -927,6 +927,9 @@ static u32 stmmac_get_rxfh_key_size(struct net_device *dev)
 {
 	struct stmmac_priv *priv = netdev_priv(dev);
 
+	if (!stmmac_rss_is_supported(priv))
+		return 0;
+
 	return sizeof(priv->rss.key);
 }
 
@@ -934,6 +937,9 @@ static u32 stmmac_get_rxfh_indir_size(struct net_device *dev)
 {
 	struct stmmac_priv *priv = netdev_priv(dev);
 
+	if (!stmmac_rss_is_supported(priv))
+		return 0;
+
 	return ARRAY_SIZE(priv->rss.table);
 }
 
-- 
2.55.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH net-next v3 1/3] net: rss: Require indir table size or hash key size to support RSS
  2026-10-02 14:28 ` [PATCH net-next v3 1/3] net: rss: Require indir table size or hash key size to support RSS Maxime Chevallier
@ 2026-10-02 14:59   ` Nicolai Buchwitz
  0 siblings, 0 replies; 7+ messages in thread
From: Nicolai Buchwitz @ 2026-10-02 14:59 UTC (permalink / raw)
  To: Maxime Chevallier
  Cc: Andrew Lunn, Jakub Kicinski, davem, Eric Dumazet, Paolo Abeni,
	Simon Horman, Maxime Coquelin, Alexandre Torgue, Russell King,
	Lorenzo Bianconi, Jitendra Vegiraju, thomas.petazzoni,
	Alexis Lothoré,
	netdev, linux-kernel, linux-arm-kernel, linux-stm32,
	Peter Robinson, Joe Damato

Hi Maxime

On 2.10.2026 16:28, Maxime Chevallier wrote:
> A point can be made that devices that report a 0-size indirection table
> and 0-length key size don't really support RSS. Let's return 
> -EOPNOTSUPP
> in that case, and skip these devices during DUMP requests.
> 
> This however also reports -ENOTSUPP for devices that only supports flow
> hash fields ops now.

nit: -EOPNOTSUPP

> 
> Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
> ---
>  net/ethtool/ioctl.c | 6 ++++++
>  net/ethtool/rss.c   | 7 +++++--
>  2 files changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c
> index 27b0e2e275dc..d32b403c8d3a 100644
> --- a/net/ethtool/ioctl.c
> +++ b/net/ethtool/ioctl.c
> @@ -1444,6 +1444,9 @@ static noinline_for_stack int 
> ethtool_get_rxfh(struct net_device *dev,
>  	if (ops->get_rxfh_key_size)
>  		rxfh_dev.key_size = ops->get_rxfh_key_size(dev);
> 
> +	if (!rxfh_dev.indir_size && !rxfh_dev.key_size)
> +		return -EOPNOTSUPP;
> +
>  	if (copy_from_user(&rxfh, useraddr, sizeof(rxfh)))
>  		return -EFAULT;
>  	user_indir_size = rxfh.indir_size;
> @@ -1554,6 +1557,9 @@ static noinline_for_stack int 
> ethtool_set_rxfh(struct net_device *dev,
>  	if (ops->get_rxfh_key_size)
>  		dev_key_size = ops->get_rxfh_key_size(dev);
> 
> +	if (!dev_indir_size && !dev_key_size)
> +		return -EOPNOTSUPP;
> +
>  	if (copy_from_user(&rxfh, useraddr, sizeof(rxfh)))
>  		return -EFAULT;
> 
> diff --git a/net/ethtool/rss.c b/net/ethtool/rss.c
> index d4a1a4724b67..cb9bead0cedd 100644
> --- a/net/ethtool/rss.c
> +++ b/net/ethtool/rss.c
> @@ -129,6 +129,9 @@ rss_get_data_alloc(struct net_device *dev, struct 
> rss_reply_data *data)
>  	if (ops->get_rxfh_key_size)
>  		data->hkey_size = ops->get_rxfh_key_size(dev);
> 
> +	if (!data->indir_size && !data->hkey_size)
> +		return -EOPNOTSUPP;
> +
>  	indir_bytes = data->indir_size * sizeof(u32);
>  	total_size = indir_bytes + data->hkey_size;
>  	rss_config = kzalloc(total_size, GFP_KERNEL);
> @@ -449,7 +452,7 @@ rss_dump_one_dev(struct sk_buff *skb, struct 
> netlink_callback *cb,
> 
>  	if (!ctx->ctx_idx) {
>  		ret = rss_dump_one_ctx(skb, cb, dev, 0);
> -		if (ret)
> +		if (ret && ret != -EOPNOTSUPP)
>  			return ret;
>  		ctx->ctx_idx++;
>  	}
> @@ -457,7 +460,7 @@ rss_dump_one_dev(struct sk_buff *skb, struct 
> netlink_callback *cb,
>  	for (; xa_find(&dev->ethtool->rss_ctx, &ctx->ctx_idx,
>  		       ULONG_MAX, XA_PRESENT); ctx->ctx_idx++) {
>  		ret = rss_dump_one_ctx(skb, cb, dev, ctx->ctx_idx);
> -		if (ret)
> +		if (ret && ret != -EOPNOTSUPP)
>  			return ret;
>  	}
>  	ctx->ctx_idx = ctx->start_ctx;

Reviewed-by: Nicolai Buchwitz <nb@tipi-net.de>

Thanks,
Nicolai

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH net-next v3 2/3] net: stmmac: Introduce a helper to check RSS support
  2026-10-02 14:28 ` [PATCH net-next v3 2/3] net: stmmac: Introduce a helper to check RSS support Maxime Chevallier
@ 2026-10-02 15:00   ` Nicolai Buchwitz
  0 siblings, 0 replies; 7+ messages in thread
From: Nicolai Buchwitz @ 2026-10-02 15:00 UTC (permalink / raw)
  To: Maxime Chevallier
  Cc: Andrew Lunn, Jakub Kicinski, davem, Eric Dumazet, Paolo Abeni,
	Simon Horman, Maxime Coquelin, Alexandre Torgue, Russell King,
	Lorenzo Bianconi, Jitendra Vegiraju, thomas.petazzoni,
	Alexis Lothoré,
	netdev, linux-kernel, linux-arm-kernel, linux-stm32,
	Peter Robinson, Joe Damato

On 2.10.2026 16:28, Maxime Chevallier wrote:
> The RSS feature is only available in stmmac if the hardware reports it
> through the DMA caps and if the platform glue sets rss_en.
> 
> Introduce a helper that checks both.
> 
> For now, no platform sets rss_en, but there's interest in the topic so
> leave the door open instead of dropping the feature altogether.
> 
> No functional changes intended.
> 
> Suggested-by: Nicolai Buchwitz <nb@tipi-net.de>
> Acked-by: Lorenzo Bianconi <lorenzo.bianconi@oss.qualcomm.com>
> Reviewed-by: Joe Damato <joe@dama.to>
> Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
> ---

> [...]

Reviewed-by: Nicolai Buchwitz <nb@tipi-net.de>

Thanks,
Nicolai

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH net-next v3 3/3] net: stmmac: Don't set or get RSS parameters when not supported
  2026-10-02 14:28 ` [PATCH net-next v3 3/3] net: stmmac: Don't set or get RSS parameters when not supported Maxime Chevallier
@ 2026-10-02 15:00   ` Nicolai Buchwitz
  0 siblings, 0 replies; 7+ messages in thread
From: Nicolai Buchwitz @ 2026-10-02 15:00 UTC (permalink / raw)
  To: Maxime Chevallier
  Cc: Andrew Lunn, Jakub Kicinski, davem, Eric Dumazet, Paolo Abeni,
	Simon Horman, Maxime Coquelin, Alexandre Torgue, Russell King,
	Lorenzo Bianconi, Jitendra Vegiraju, thomas.petazzoni,
	Alexis Lothoré,
	netdev, linux-kernel, linux-arm-kernel, linux-stm32,
	Peter Robinson, Joe Damato

On 2.10.2026 16:28, Maxime Chevallier wrote:
> The RSS kselftests fail on stmmac, and this is partly due to the driver
> reporting bogus data for the RSS ops :
> 
>  - ethtool -x reports an indirection table and a key while the hardware
>    doesn't have any of that
>  - ethtool -X fails with -EINVAL.
> 
> Return a 0 indir size and key size when rss isn't supported, 
> effectively
> meaning we don't support RSS here.
> 
> Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
> ---

> [...]

Reviewed-by: Nicolai Buchwitz <nb@tipi-net.de>

Thanks,
Nicolai

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-10-02 15:01 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-02 14:28 [PATCH net-next v3 0/3] net: rss: Consider RSS not supported when key and indir sizes are 0 Maxime Chevallier
2026-10-02 14:28 ` [PATCH net-next v3 1/3] net: rss: Require indir table size or hash key size to support RSS Maxime Chevallier
2026-10-02 14:59   ` Nicolai Buchwitz
2026-10-02 14:28 ` [PATCH net-next v3 2/3] net: stmmac: Introduce a helper to check RSS support Maxime Chevallier
2026-10-02 15:00   ` Nicolai Buchwitz
2026-10-02 14:28 ` [PATCH net-next v3 3/3] net: stmmac: Don't set or get RSS parameters when not supported Maxime Chevallier
2026-10-02 15:00   ` Nicolai Buchwitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®