hc
2024-05-10 748e4f3d702def1a4bff191e0cf93b6a05340f01
kernel/include/uapi/linux/virtio_net.h
....@@ -57,6 +57,9 @@
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 */
61
+#define VIRTIO_NET_F_RSS 60 /* Supports RSS RX steering */
62
+#define VIRTIO_NET_F_RSC_EXT 61 /* extended coalescing info */
6063 #define VIRTIO_NET_F_STANDBY 62 /* Act as standby for another device
6164 * with the same MAC.
6265 */
....@@ -69,29 +72,46 @@
6972 #define VIRTIO_NET_S_LINK_UP 1 /* Link is up */
7073 #define VIRTIO_NET_S_ANNOUNCE 2 /* Announcement is needed */
7174
75
+/* supported/enabled hash types */
76
+#define VIRTIO_NET_RSS_HASH_TYPE_IPv4 (1 << 0)
77
+#define VIRTIO_NET_RSS_HASH_TYPE_TCPv4 (1 << 1)
78
+#define VIRTIO_NET_RSS_HASH_TYPE_UDPv4 (1 << 2)
79
+#define VIRTIO_NET_RSS_HASH_TYPE_IPv6 (1 << 3)
80
+#define VIRTIO_NET_RSS_HASH_TYPE_TCPv6 (1 << 4)
81
+#define VIRTIO_NET_RSS_HASH_TYPE_UDPv6 (1 << 5)
82
+#define VIRTIO_NET_RSS_HASH_TYPE_IP_EX (1 << 6)
83
+#define VIRTIO_NET_RSS_HASH_TYPE_TCP_EX (1 << 7)
84
+#define VIRTIO_NET_RSS_HASH_TYPE_UDP_EX (1 << 8)
85
+
7286 struct virtio_net_config {
7387 /* The config defining mac address (if VIRTIO_NET_F_MAC) */
7488 __u8 mac[ETH_ALEN];
7589 /* See VIRTIO_NET_F_STATUS and VIRTIO_NET_S_* above */
76
- __u16 status;
90
+ __virtio16 status;
7791 /* Maximum number of each of transmit and receive queues;
7892 * see VIRTIO_NET_F_MQ and VIRTIO_NET_CTRL_MQ.
7993 * Legal values are between 1 and 0x8000
8094 */
81
- __u16 max_virtqueue_pairs;
95
+ __virtio16 max_virtqueue_pairs;
8296 /* Default maximum transmit unit advice */
83
- __u16 mtu;
97
+ __virtio16 mtu;
8498 /*
8599 * speed, in units of 1Mb. All values 0 to INT_MAX are legal.
86100 * Any other value stands for unknown.
87101 */
88
- __u32 speed;
102
+ __le32 speed;
89103 /*
90104 * 0x00 - half duplex
91105 * 0x01 - full duplex
92106 * Any other value stands for unknown.
93107 */
94108 __u8 duplex;
109
+ /* maximum size of RSS key */
110
+ __u8 rss_max_key_size;
111
+ /* maximum number of indirection table entries */
112
+ __le16 rss_max_indirection_table_length;
113
+ /* bitmask of supported VIRTIO_NET_RSS_HASH_ types */
114
+ __le32 supported_hash_types;
95115 } __attribute__((packed));
96116
97117 /*
....@@ -104,6 +124,7 @@
104124 struct virtio_net_hdr_v1 {
105125 #define VIRTIO_NET_HDR_F_NEEDS_CSUM 1 /* Use csum_start, csum_offset */
106126 #define VIRTIO_NET_HDR_F_DATA_VALID 2 /* Csum is valid */
127
+#define VIRTIO_NET_HDR_F_RSC_INFO 4 /* rsc info in csum_ fields */
107128 __u8 flags;
108129 #define VIRTIO_NET_HDR_GSO_NONE 0 /* Not a GSO frame */
109130 #define VIRTIO_NET_HDR_GSO_TCPV4 1 /* GSO frame, IPv4 TCP (TSO) */
....@@ -113,9 +134,44 @@
113134 __u8 gso_type;
114135 __virtio16 hdr_len; /* Ethernet + IP + tcp/udp hdrs */
115136 __virtio16 gso_size; /* Bytes to append to hdr_len per frame */
116
- __virtio16 csum_start; /* Position to start checksumming from */
117
- __virtio16 csum_offset; /* Offset after that to place checksum */
137
+ union {
138
+ struct {
139
+ __virtio16 csum_start;
140
+ __virtio16 csum_offset;
141
+ };
142
+ /* Checksum calculation */
143
+ struct {
144
+ /* Position to start checksumming from */
145
+ __virtio16 start;
146
+ /* Offset after that to place checksum */
147
+ __virtio16 offset;
148
+ } csum;
149
+ /* Receive Segment Coalescing */
150
+ struct {
151
+ /* Number of coalesced segments */
152
+ __le16 segments;
153
+ /* Number of duplicated acks */
154
+ __le16 dup_acks;
155
+ } rsc;
156
+ };
118157 __virtio16 num_buffers; /* Number of merged rx buffers */
158
+};
159
+
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;
119175 };
120176
121177 #ifndef VIRTIO_NET_NO_LEGACY
....@@ -228,7 +284,9 @@
228284
229285 /*
230286 * Control Receive Flow Steering
231
- *
287
+ */
288
+#define VIRTIO_NET_CTRL_MQ 4
289
+/*
232290 * The command VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET
233291 * enables Receive Flow Steering, specifying the number of the transmit and
234292 * receive queues that will be used. After the command is consumed and acked by
....@@ -241,12 +299,48 @@
241299 __virtio16 virtqueue_pairs;
242300 };
243301
244
-#define VIRTIO_NET_CTRL_MQ 4
245302 #define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET 0
246303 #define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MIN 1
247304 #define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MAX 0x8000
248305
249306 /*
307
+ * The command VIRTIO_NET_CTRL_MQ_RSS_CONFIG has the same effect as
308
+ * VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET does and additionally configures
309
+ * the receive steering to use a hash calculated for incoming packet
310
+ * to decide on receive virtqueue to place the packet. The command
311
+ * also provides parameters to calculate a hash and receive virtqueue.
312
+ */
313
+struct virtio_net_rss_config {
314
+ __le32 hash_types;
315
+ __le16 indirection_table_mask;
316
+ __le16 unclassified_queue;
317
+ __le16 indirection_table[1/* + indirection_table_mask */];
318
+ __le16 max_tx_vq;
319
+ __u8 hash_key_length;
320
+ __u8 hash_key_data[/* hash_key_length */];
321
+};
322
+
323
+ #define VIRTIO_NET_CTRL_MQ_RSS_CONFIG 1
324
+
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
+
343
+/*
250344 * Control network offloads
251345 *
252346 * Reconfigures the network offloads that Guest can handle.