Skip to content

Commit 3024e20

Browse files
ybenditomstsirkin
authored andcommitted
virtio-net: Introduce hash report feature
The feature VIRTIO_NET_F_HASH_REPORT extends the layout of the packet and requests the device to calculate hash on incoming packets and report it in the packet header. 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 fd58bf6 commit 3024e20

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

include/uapi/linux/virtio_net.h

Lines changed: 36 additions & 0 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_HASH_REPORT 57 /* Supports hash report */
6061
#define VIRTIO_NET_F_RSS 60 /* Supports RSS RX steering */
6162
#define VIRTIO_NET_F_RSC_EXT 61 /* extended coalescing info */
6263
#define VIRTIO_NET_F_STANDBY 62 /* Act as standby for another device
@@ -156,6 +157,23 @@ struct virtio_net_hdr_v1 {
156157
__virtio16 num_buffers; /* Number of merged rx buffers */
157158
};
158159

160+
struct virtio_net_hdr_v1_hash {
161+
struct virtio_net_hdr_v1 hdr;
162+
__le32 hash_value;
163+
#define VIRTIO_NET_HASH_REPORT_NONE 0
164+
#define VIRTIO_NET_HASH_REPORT_IPv4 1
165+
#define VIRTIO_NET_HASH_REPORT_TCPv4 2
166+
#define VIRTIO_NET_HASH_REPORT_UDPv4 3
167+
#define VIRTIO_NET_HASH_REPORT_IPv6 4
168+
#define VIRTIO_NET_HASH_REPORT_TCPv6 5
169+
#define VIRTIO_NET_HASH_REPORT_UDPv6 6
170+
#define VIRTIO_NET_HASH_REPORT_IPv6_EX 7
171+
#define VIRTIO_NET_HASH_REPORT_TCPv6_EX 8
172+
#define VIRTIO_NET_HASH_REPORT_UDPv6_EX 9
173+
__le16 hash_report;
174+
__le16 padding;
175+
};
176+
159177
#ifndef VIRTIO_NET_NO_LEGACY
160178
/* This header comes first in the scatter-gather list.
161179
* For legacy virtio, if VIRTIO_F_ANY_LAYOUT is not negotiated, it must
@@ -304,6 +322,24 @@ struct virtio_net_rss_config {
304322

305323
#define VIRTIO_NET_CTRL_MQ_RSS_CONFIG 1
306324

325+
/*
326+
* The command VIRTIO_NET_CTRL_MQ_HASH_CONFIG requests the device
327+
* to include in the virtio header of the packet the value of the
328+
* calculated hash and the report type of hash. It also provides
329+
* parameters for hash calculation. The command requires feature
330+
* VIRTIO_NET_F_HASH_REPORT to be negotiated to extend the
331+
* layout of virtio header as defined in virtio_net_hdr_v1_hash.
332+
*/
333+
struct virtio_net_hash_config {
334+
__le32 hash_types;
335+
/* for compatibility with virtio_net_rss_config */
336+
__le16 reserved[4];
337+
__u8 hash_key_length;
338+
__u8 hash_key_data[/* hash_key_length */];
339+
};
340+
341+
#define VIRTIO_NET_CTRL_MQ_HASH_CONFIG 2
342+
307343
/*
308344
* Control network offloads
309345
*

0 commit comments

Comments
 (0)