Skip to content

Commit fd58bf6

Browse files
ybenditomstsirkin
authored andcommitted
virtio-net: Introduce RSS receive steering feature
RSS (Receive-side scaling) defines hash calculation rules and decision on receive virtqueue according to the calculated hash, provided mask to apply and provided indirection table containing indices of receive virqueues. The driver sends the control command to enable multiqueue and provide parameters for receive steering. Signed-off-by: Yuri Benditovich <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Michael S. Tsirkin <[email protected]>
1 parent 22b436c commit fd58bf6

File tree

1 file changed

+40
-2
lines changed

1 file changed

+40
-2
lines changed

include/uapi/linux/virtio_net.h

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
* Steering */
5858
#define VIRTIO_NET_F_CTRL_MAC_ADDR 23 /* Set MAC address */
5959

60+
#define VIRTIO_NET_F_RSS 60 /* Supports RSS RX steering */
6061
#define VIRTIO_NET_F_RSC_EXT 61 /* extended coalescing info */
6162
#define VIRTIO_NET_F_STANDBY 62 /* Act as standby for another device
6263
* with the same MAC.
@@ -70,6 +71,17 @@
7071
#define VIRTIO_NET_S_LINK_UP 1 /* Link is up */
7172
#define VIRTIO_NET_S_ANNOUNCE 2 /* Announcement is needed */
7273

74+
/* supported/enabled hash types */
75+
#define VIRTIO_NET_RSS_HASH_TYPE_IPv4 (1 << 0)
76+
#define VIRTIO_NET_RSS_HASH_TYPE_TCPv4 (1 << 1)
77+
#define VIRTIO_NET_RSS_HASH_TYPE_UDPv4 (1 << 2)
78+
#define VIRTIO_NET_RSS_HASH_TYPE_IPv6 (1 << 3)
79+
#define VIRTIO_NET_RSS_HASH_TYPE_TCPv6 (1 << 4)
80+
#define VIRTIO_NET_RSS_HASH_TYPE_UDPv6 (1 << 5)
81+
#define VIRTIO_NET_RSS_HASH_TYPE_IP_EX (1 << 6)
82+
#define VIRTIO_NET_RSS_HASH_TYPE_TCP_EX (1 << 7)
83+
#define VIRTIO_NET_RSS_HASH_TYPE_UDP_EX (1 << 8)
84+
7385
struct virtio_net_config {
7486
/* The config defining mac address (if VIRTIO_NET_F_MAC) */
7587
__u8 mac[ETH_ALEN];
@@ -93,6 +105,12 @@ struct virtio_net_config {
93105
* Any other value stands for unknown.
94106
*/
95107
__u8 duplex;
108+
/* maximum size of RSS key */
109+
__u8 rss_max_key_size;
110+
/* maximum number of indirection table entries */
111+
__le16 rss_max_indirection_table_length;
112+
/* bitmask of supported VIRTIO_NET_RSS_HASH_ types */
113+
__le32 supported_hash_types;
96114
} __attribute__((packed));
97115

98116
/*
@@ -248,7 +266,9 @@ struct virtio_net_ctrl_mac {
248266

249267
/*
250268
* Control Receive Flow Steering
251-
*
269+
*/
270+
#define VIRTIO_NET_CTRL_MQ 4
271+
/*
252272
* The command VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET
253273
* enables Receive Flow Steering, specifying the number of the transmit and
254274
* receive queues that will be used. After the command is consumed and acked by
@@ -261,11 +281,29 @@ struct virtio_net_ctrl_mq {
261281
__virtio16 virtqueue_pairs;
262282
};
263283

264-
#define VIRTIO_NET_CTRL_MQ 4
265284
#define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET 0
266285
#define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MIN 1
267286
#define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MAX 0x8000
268287

288+
/*
289+
* The command VIRTIO_NET_CTRL_MQ_RSS_CONFIG has the same effect as
290+
* VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET does and additionally configures
291+
* the receive steering to use a hash calculated for incoming packet
292+
* to decide on receive virtqueue to place the packet. The command
293+
* also provides parameters to calculate a hash and receive virtqueue.
294+
*/
295+
struct virtio_net_rss_config {
296+
__le32 hash_types;
297+
__le16 indirection_table_mask;
298+
__le16 unclassified_queue;
299+
__le16 indirection_table[1/* + indirection_table_mask */];
300+
__le16 max_tx_vq;
301+
__u8 hash_key_length;
302+
__u8 hash_key_data[/* hash_key_length */];
303+
};
304+
305+
#define VIRTIO_NET_CTRL_MQ_RSS_CONFIG 1
306+
269307
/*
270308
* Control network offloads
271309
*

0 commit comments

Comments
 (0)