diff options
author | Steven Luong <sluong@cisco.com> | 2023-12-14 08:54:55 -0800 |
---|---|---|
committer | Beno�t Ganne <bganne@cisco.com> | 2024-08-29 12:41:30 +0000 |
commit | e9bc3320192d72f817379aa4621c1dff15bdee29 (patch) | |
tree | 4eecbe14e7505f5349cb0d805814d68d8c044327 /src/vnet/devices/virtio/pci.h | |
parent | fc49c63e7426d5c254b4c38f2e74a9a6d75f11ba (diff) |
virtio: RSS support
Add RSS support to make use of multiple queues.
With 4 RX queues and RSS enabled
ping from host to guest vm ip queue use
192.168.2.3 192.168.2.1 2
'' 192.168.2.10 0
'' 192.168.2.5 1
'' 192.168.2.105 3
With 4 RX queues and RSS disabled, queue 0 is always used for all of the above cases
Type: improvement
Change-Id: I3ca78fd83fce26cbe8f23fee0a9034cb572bacb7
Signed-off-by: Steven Luong <sluong@cisco.com>
Diffstat (limited to 'src/vnet/devices/virtio/pci.h')
-rw-r--r-- | src/vnet/devices/virtio/pci.h | 82 |
1 files changed, 75 insertions, 7 deletions
diff --git a/src/vnet/devices/virtio/pci.h b/src/vnet/devices/virtio/pci.h index 5eb80f823be..745ad6fce87 100644 --- a/src/vnet/devices/virtio/pci.h +++ b/src/vnet/devices/virtio/pci.h @@ -60,6 +60,9 @@ typedef enum /* If multiqueue is provided by host, then we support it. */ #define VIRTIO_NET_CTRL_MQ 4 #define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET 0 +#define VIRTIO_NET_CTRL_MQ_RSS_CONFIG 1 +#define VIRTIO_NET_CTRL_MQ_HASH_CONFIG 2 + #define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MIN 1 #define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MAX 0x8000 @@ -139,14 +142,77 @@ typedef struct u64 queue_device; /* read-write */ } virtio_pci_common_cfg_t; +#define foreach_virtio_net_hash_report_type \ + _ (NONE, 0) \ + _ (IPV4, 1) \ + _ (TCPV4, 2) \ + _ (UDPV4, 3) \ + _ (IPV6, 4) \ + _ (TCPV6, 5) \ + _ (UDPV6, 6) \ + _ (IPV6_EX, 7) \ + _ (TCPV6_EX, 8) \ + _ (UDPV6_EX, 9) + +typedef enum +{ +#define _(n, i) VIRTIO_NET_HASH_REPORT_##n = i, + foreach_virtio_net_hash_report_type +#undef _ +} virtio_net_hash_report_type_t; + typedef struct { u8 mac[6]; u16 status; u16 max_virtqueue_pairs; u16 mtu; + u32 speed; + u8 duplex; + u8 rss_max_key_size; + u16 rss_max_indirection_table_length; + u32 supported_hash_types; } virtio_net_config_t; +#define VIRTIO_NET_RSS_MAX_TABLE_LEN 128 +#define VIRTIO_NET_RSS_MAX_KEY_SIZE 40 + +#define foreach_virtio_net_hash_type \ + _ (IPV4, 0) \ + _ (TCPV4, 1) \ + _ (UDPV4, 2) \ + _ (IPV6, 3) \ + _ (TCPV6, 4) \ + _ (UDPV6, 5) \ + _ (IPV6_EX, 6) \ + _ (TCPV6_EX, 7) \ + _ (UDPV6_EX, 8) + +typedef enum +{ +#define _(n, i) VIRTIO_NET_HASH_TYPE_##n = (1 << i), + foreach_virtio_net_hash_type +#undef _ +} virtio_net_hash_type_t; + +#define VIRTIO_NET_HASH_TYPE_SUPPORTED \ + (VIRTIO_NET_HASH_TYPE_IPV4 | VIRTIO_NET_HASH_TYPE_TCPV4 | \ + VIRTIO_NET_HASH_TYPE_UDPV4 | VIRTIO_NET_HASH_TYPE_IPV6 | \ + VIRTIO_NET_HASH_TYPE_TCPV6 | VIRTIO_NET_HASH_TYPE_UDPV6 | \ + VIRTIO_NET_HASH_TYPE_IPV6_EX | VIRTIO_NET_HASH_TYPE_TCPV6_EX | \ + VIRTIO_NET_HASH_TYPE_UDPV6_EX) + +typedef struct +{ + u32 hash_types; + u16 indirection_table_mask; + u16 unclassified_queue; + u16 indirection_table[VIRTIO_NET_RSS_MAX_TABLE_LEN]; + u16 max_tx_vq; + u8 hash_key_length; + u8 hash_key_data[VIRTIO_NET_RSS_MAX_KEY_SIZE]; +} virtio_net_rss_config; + /* * Control virtqueue data structures * @@ -210,13 +276,14 @@ typedef struct _virtio_pci_func void (*device_debug_config_space) (vlib_main_t * vm, virtio_if_t * vif); } virtio_pci_func_t; -#define foreach_virtio_flags \ - _ (GSO, 0) \ - _ (CSUM_OFFLOAD, 1) \ - _ (GRO_COALESCE, 2) \ - _ (PACKED, 3) \ - _ (IN_ORDER, 4) \ - _ (BUFFERING, 5) +#define foreach_virtio_flags \ + _ (GSO, 0) \ + _ (CSUM_OFFLOAD, 1) \ + _ (GRO_COALESCE, 2) \ + _ (PACKED, 3) \ + _ (IN_ORDER, 4) \ + _ (BUFFERING, 5) \ + _ (RSS, 6) typedef enum { @@ -243,6 +310,7 @@ typedef struct u64 features; u8 gso_enabled; u8 checksum_offload_enabled; + u8 rss_enabled; u32 tx_queue_size; virtio_bind_t bind; u32 buffering_size; |