virtio_net: Increase RSS max key size to match NETDEV_RSS_KEY_LEN
Subsystems (4)
PATCH 1/1 virtio_net: Increase RSS max key size to match NETDEV_RSS_KEY_LEN
Increase VIRTIO_NET_RSS_MAX_KEY_SIZE from 40 to 52 bytes to align with the kernel's standard RSS key length defined by NETDEV_RSS_KEY_LEN.
The virtio specification requires devices to support at least 40 bytes for the RSS key size. However, devices may support larger key sizes up to 52 bytes (as reported by the device's rss_max_key_size config field). This change allows such devices to work properly. Previously, devices reporting rss_max_key_size > 40 would fail with an error during initialization.
The driver already handles variable key sizes dynamically through vi->rss_key_size, so increasing the maximum limit is safe and maintains backward compatibility with devices that support smaller key sizes.
--- drivers/net/virtio_net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/virtio_net.c +1 -1
@@ -381,7 +381,7 @@ struct receive_queue {struct xdp_buff **xsk_buffs; }; -#define VIRTIO_NET_RSS_MAX_KEY_SIZE 40 +#define VIRTIO_NET_RSS_MAX_KEY_SIZE 52/* Control VQ buffers: protected by the rtnl lock */ struct control_buf {
Signature · 1 line
2.25.1
Michael S. Tsirkin
maintainerQuoted 5 lines · Srujana Challa
Increase
VIRTIO_NET_RSS_MAX_KEY_SIZEfrom 40 to 52 bytes to align with the kernel's standard RSS key length defined byNETDEV_RSS_KEY_LEN.The virtio specification requires devices to support at least 40 bytes for the RSS key size.
Indeed:
The device MUST set \field{rss_max_key_size} to at least 40, if it offers VIRTIO_NET_F_RSS or VIRTIO_NET_F_HASH_REPORT.
Quoted 5 lines
However, devices may support larger key sizes
up to 52 bytes (as reported by the device'srss_max_key_sizeconfig field). This change allows such devices to work properly. Previously, devices reportingrss_max_key_size> 40 would fail with an error during initialization.
This one, yes?
if (vi->rss_key_size > VIRTIO_NET_RSS_MAX_KEY_SIZE) {
dev_err(&vdev->dev, "rss_max_key_size=%u exceeds the limit %u.\n",
vi->rss_key_size, VIRTIO_NET_RSS_MAX_KEY_SIZE);
err = -EINVAL;
goto free;
}Hmm but why do we do it like this? I suspect we just got confused with the spec: > vs <.
Can't we just do:min(vi->rss_key_size, VIRTIO_NET_RSS_MAX_KEY_SIZE)
If yes I'd like that fix in addition to the increase.
If we are validating rss_key_size against 40, I think we should clear the feature rather than failing init completely.
Quoted 25 lines
The driver already handles variable key sizes dynamically through
vi->rss_key_size, so increasing the maximum limit is safe and maintains backward compatibility with devices that support smaller key sizes.Signed-off-by Srujana Challa <[email protected]>--- drivers/net/virtio_net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/virtio_net.c +1
-1@@ -381,7 +381,7 @@ struct receive_queue {struct xdp_buff **xsk_buffs; }; -#define VIRTIO_NET_RSS_MAX_KEY_SIZE 40 +#define VIRTIO_NET_RSS_MAX_KEY_SIZE 52/* Control VQ buffers: protected by the rtnl lock */ struct control_buf {Signature · 1 line
2.25.1
Quoted 30 lines · Srujana Challa
Quoted 5 lines
Increase
VIRTIO_NET_RSS_MAX_KEY_SIZEfrom 40 to 52 bytes to align with the kernel's standard RSS key length defined byNETDEV_RSS_KEY_LEN.The virtio specification requires devices to support at least 40 bytes for the RSS key size.
Indeed:
The device MUST set \field{rss_max_key_size} to at least 40, if it offersVIRTIO_NET_F_RSSorVIRTIO_NET_F_HASH_REPORT.Quoted 5 lines
However, devices may support larger key sizes up to 52 bytes (as reported by the device's
rss_max_key_sizeconfig field). This change allows such devices to work properly.
Previously, devices reportingrss_max_key_size> 40 would fail with an error during initialization.This one, yes?
if (vi->rss_key_size > VIRTIO_NET_RSS_MAX_KEY_SIZE) { dev_err(&vdev->dev, "rss_max_key_size=%u exceeds the limit %u.\n", vi->rss_key_size, VIRTIO_NET_RSS_MAX_KEY_SIZE); err = -EINVAL; goto free; }
Quoted 2 lines
Hmm but why do we do it like this? I suspect we just got confused with the
spec: > vs <.
I believe the check was added to prevent out-of-bounds errors when accessing the hash key buffer.
Quoted 4 lines
Can't we just do:
min(vi->rss_key_size, VIRTIO_NET_RSS_MAX_KEY_SIZE)
Our device requires hash_key_length to exactly match rss_max_key_size for symmetric bidirectional flow hashing. When rss_max_key_size > VIRTIO_NET_RSS_MAX_KEY_SIZE, clamping isn't possible. Should we disable RSS instead of failing initialization?
Thanks.
Quoted 39 lines
If yes I'd like that fix in addition to the increase.
If we are validating
rss_key_sizeagainst 40, I think we should clear the feature rather than failing init completely.Quoted 25 lines
The driver already handles variable key sizes dynamically through
vi->rss_key_size, so increasing the maximum limit is safe and maintains backward compatibility with devices that support smaller key sizes.Signed-off-by Srujana Challa <[email protected]>--- drivers/net/virtio_net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/virtio_net.c index renamed from drivers/net/virtio_net.c +0
-0
db88dcaefb20..5f06cbc058d7100644drivers/net/virtio_net.c +1
-2@@ -381,7 +381,7 @@ struct receive_queue {struct xdp_buff **xsk_buffs; }; -#define VIRTIO_NET_RSS_MAX_KEY_SIZE 40 +#define VIRTIO_NET_RSS_MAX_KEY_SIZE 52/* Control VQ buffers: protected by the rtnl lock */ struct control_buf { --2.25.1
Jakub Kicinski
maintainerQuoted 2 lines · On Thu, 22 Jan 2026 14:45:27 +0530 Srujana Challa wrote:
Increase
VIRTIO_NET_RSS_MAX_KEY_SIZEfrom 40 to 52 bytes to align with the kernel's standard RSS key length defined byNETDEV_RSS_KEY_LEN.
I've been meaning to bump NETDEV_RSS_KEY_LEN to 128 or some such. Most modern drivers can't use netdev_rss_key_fill() either because core generates a tiny key. And the devices support hashing over two layers of IPv6 for tunnels.
Willem, WDYT? Is there a reason to keep the core key small? Or deprecate netdev_rss_key_fill()?
Quoted 14 lines
The virtio specification requires devices to support at least 40 bytes for the RSS key size. However, devices may support larger key sizes up to 52 bytes (as reported by the device's
rss_max_key_sizeconfig field). This change allows such devices to work properly. Previously, devices reportingrss_max_key_size> 40 would fail with an error during initialization.The driver already handles variable key sizes dynamically through
vi->rss_key_size, so increasing the maximum limit is safe and maintains backward compatibility with devices that support smaller key sizes.drivers/net/virtio_net.c +1
-1-#define VIRTIO_NET_RSS_MAX_KEY_SIZE 40 +#define VIRTIO_NET_RSS_MAX_KEY_SIZE 52
Quoted 9 lines · Jakub Kicinski
Quoted 2 lines · On Thu, 22 Jan 2026 14:45:27 +0530 Srujana Challa wrote:
Increase
VIRTIO_NET_RSS_MAX_KEY_SIZEfrom 40 to 52 bytes to align with the kernel's standard RSS key length defined byNETDEV_RSS_KEY_LEN.I've been meaning to bump
NETDEV_RSS_KEY_LENto 128 or some such. Most modern drivers can't usenetdev_rss_key_fill()either because core generates a tiny key. And the devices support hashing over two layers of IPv6 for tunnels.
Seems fine to me. Back in 2014, RSS was limited to 52 bytes on all known NIC.
Quoted 3 lines
Willem, WDYT? Is there a reason to keep the core key small? Or deprecate
netdev_rss_key_fill()?
What do you mean by deprecating it ?
One of the ideas was to make sure multiple NIC would share the same key, for some bonding setups.
commit 960fb622f85180f36d3aff82af53e2be3db2f888 net: provide a per
host RSS key generic infrastructure
Quoted 15 lines
Quoted 15 lines
The virtio specification requires devices to support at least 40 bytes for the RSS key size. However, devices may support larger key sizes up to 52 bytes (as reported by the device's
rss_max_key_sizeconfig field). This change allows such devices to work properly. Previously, devices reportingrss_max_key_size> 40 would fail with an error during initialization.The driver already handles variable key sizes dynamically through
vi->rss_key_size, so increasing the maximum limit is safe and maintains backward compatibility with devices that support smaller key sizes.drivers/net/virtio_net.c +1
-1-#define VIRTIO_NET_RSS_MAX_KEY_SIZE 40 +#define VIRTIO_NET_RSS_MAX_KEY_SIZE 52
Quoted 7 lines · Eric Dumazet
Quoted 5 lines · Jakub Kicinski
Quoted 2 lines · On Thu, 22 Jan 2026 14:45:27 +0530 Srujana Challa wrote:
Increase
VIRTIO_NET_RSS_MAX_KEY_SIZEfrom 40 to 52 bytes to align with the kernel's standard RSS key length defined byNETDEV_RSS_KEY_LEN.
Quoted 7 lines
Quoted 4 lines
I've been meaning to bump
NETDEV_RSS_KEY_LENto 128 or some such. Most modern drivers can't usenetdev_rss_key_fill()either because core generates a tiny key. And the devices support hashing over two layers of IPv6 for tunnels.Seems fine to me. Back in 2014, RSS was limited to 52 bytes on all known NIC.
BTW make it 256 bytes. 128 is already too small.
Quoted 29 lines
Quoted 3 lines
Willem, WDYT? Is there a reason to keep the core key small? Or deprecate
netdev_rss_key_fill()?What do you mean by deprecating it ?
One of the ideas was to make sure multiple NIC would share the same key, for some bonding setups.
commit
960fb622f85180f36d3aff82af53e2be3db2f888net: provide a per
host RSS key generic infrastructureQuoted 15 lines
Quoted 15 lines
The virtio specification requires devices to support at least 40 bytes for the RSS key size. However, devices may support larger key sizes up to 52 bytes (as reported by the device's
rss_max_key_sizeconfig field). This change allows such devices to work properly. Previously, devices reportingrss_max_key_size> 40 would fail with an error during initialization.The driver already handles variable key sizes dynamically through
vi->rss_key_size, so increasing the maximum limit is safe and maintains backward compatibility with devices that support smaller key sizes.drivers/net/virtio_net.c +1
-1-#define VIRTIO_NET_RSS_MAX_KEY_SIZE 40 +#define VIRTIO_NET_RSS_MAX_KEY_SIZE 52
Jakub Kicinski
maintainerQuoted 10 lines · On Thu, 22 Jan 2026 17:13:55 +0100 Eric Dumazet wrote:
Quoted 2 lines
Willem, WDYT? Is there a reason to keep the core key small? Or deprecate
netdev_rss_key_fill()?What do you mean by deprecating it ?
One of the ideas was to make sure multiple NIC would share the same key, for some bonding setups.
commit
960fb622f85180f36d3aff82af53e2be3db2f888net: provide a per
host RSS key generic infrastructure
Just wanted to put that option on the table, it wasn't clear to me what the exact use case for the sysfs file was. Good to know that someone cares :) thanks for the reference!
Quoted 6 lines · Eric Dumazet
Quoted 5 lines · Jakub Kicinski
Quoted 2 lines · On Thu, 22 Jan 2026 14:45:27 +0530 Srujana Challa wrote:
Increase
VIRTIO_NET_RSS_MAX_KEY_SIZEfrom 40 to 52 bytes to align with the kernel's standard RSS key length defined byNETDEV_RSS_KEY_LEN.
Quoted 6 lines
Quoted 4 lines
I've been meaning to bump
NETDEV_RSS_KEY_LENto 128 or some such. Most modern drivers can't usenetdev_rss_key_fill()either because core generates a tiny key. And the devices support hashing over two layers of IPv6 for tunnels.Seems fine to me. Back in 2014, RSS was limited to 52 bytes on all known NIC.
What is the purpose of extending?
The current length is sufficient for standard Toeplitz 4-tuple hashing.
Quoted 12 lines · Willem de Bruijn
Quoted 11 lines · Eric Dumazet
Quoted 9 lines · Jakub Kicinski
Quoted 2 lines · On Thu, 22 Jan 2026 14:45:27 +0530 Srujana Challa wrote:
Increase
VIRTIO_NET_RSS_MAX_KEY_SIZEfrom 40 to 52 bytes to align with the kernel's standard RSS key length defined byNETDEV_RSS_KEY_LEN.I've been meaning to bump
NETDEV_RSS_KEY_LENto 128 or some such. Most modern drivers can't usenetdev_rss_key_fill()either because core generates a tiny key. And the devices support hashing over two layers of IPv6 for tunnels.
Quoted 5 lines
Quoted 1 line
Seems fine to me. Back in 2014, RSS was limited to 52 bytes on all known NIC.
What is the purpose of extending?
The current length is sufficient for standard Toeplitz 4-tuple hashing.
Never mind, I should read better:
Quoted 1 line
And the devices support hashing over two layers of IPv6 for tunnels.
I'm hard pressed to see over 128 B of entropy. But if extending, might as well go to 256 B right away.
Quoted 8 lines · On Thu, 22 Jan 2026 14:45:27 +0530 Srujana Challa wrote:
Quoted 2 lines
Increase
VIRTIO_NET_RSS_MAX_KEY_SIZEfrom 40 to 52 bytes to align with the kernel's standard RSS key length defined byNETDEV_RSS_KEY_LEN.I've been meaning to bump
NETDEV_RSS_KEY_LENto 128 or some such. Most modern drivers can't usenetdev_rss_key_fill()either because core generates a tiny key. And the devices support hashing over two layers of IPv6 for tunnels.
Instead of hardcoding 52, we can use:
#define VIRTIO_NET_RSS_MAX_KEY_SIZE NETDEV_RSS_KEY_LEN
This automatically stays in sync with NETDEV_RSS_KEY_LEN and will adapt when it's increased to 128+. Please confirm.
Thanks.
Quoted 18 lines
Willem, WDYT? Is there a reason to keep the core key small? Or deprecate
netdev_rss_key_fill()?Quoted 14 lines
The virtio specification requires devices to support at least 40 bytes for the RSS key size. However, devices may support larger key sizes up to 52 bytes (as reported by the device's
rss_max_key_sizeconfig field). This change allows such devices to work properly. Previously, devices reportingrss_max_key_size> 40 would fail with an error during initialization.The driver already handles variable key sizes dynamically through
vi->rss_key_size, so increasing the maximum limit is safe and maintains backward compatibility with devices that support smaller key sizes.drivers/net/virtio_net.c +1
-1-#define VIRTIO_NET_RSS_MAX_KEY_SIZE 40 +#define VIRTIO_NET_RSS_MAX_KEY_SIZE 52