master
h 599 lines 20 KB
Raw
1 #ifndef _LINUX_VIRTIO_NET_H
2 #define _LINUX_VIRTIO_NET_H
3 /* This header is BSD licensed so anyone can use the definitions to implement
4 * compatible drivers/servers.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. Neither the name of IBM nor the names of its contributors
15 * may be used to endorse or promote products derived from this software
16 * without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE. */
28 #include "standard-headers/linux/types.h"
29 #include "standard-headers/linux/virtio_ids.h"
30 #include "standard-headers/linux/virtio_config.h"
31 #include "standard-headers/linux/virtio_types.h"
32 #include "standard-headers/linux/if_ether.h"
33
34 /* The feature bitmap for virtio net */
35 #define VIRTIO_NET_F_CSUM 0 /* Host handles pkts w/ partial csum */
36 #define VIRTIO_NET_F_GUEST_CSUM 1 /* Guest handles pkts w/ partial csum */
37 #define VIRTIO_NET_F_CTRL_GUEST_OFFLOADS 2 /* Dynamic offload configuration. */
38 #define VIRTIO_NET_F_MTU 3 /* Initial MTU advice */
39 #define VIRTIO_NET_F_MAC 5 /* Host has given MAC address. */
40 #define VIRTIO_NET_F_GUEST_TSO4 7 /* Guest can handle TSOv4 in. */
41 #define VIRTIO_NET_F_GUEST_TSO6 8 /* Guest can handle TSOv6 in. */
42 #define VIRTIO_NET_F_GUEST_ECN 9 /* Guest can handle TSO[6] w/ ECN in. */
43 #define VIRTIO_NET_F_GUEST_UFO 10 /* Guest can handle UFO in. */
44 #define VIRTIO_NET_F_HOST_TSO4 11 /* Host can handle TSOv4 in. */
45 #define VIRTIO_NET_F_HOST_TSO6 12 /* Host can handle TSOv6 in. */
46 #define VIRTIO_NET_F_HOST_ECN 13 /* Host can handle TSO[6] w/ ECN in. */
47 #define VIRTIO_NET_F_HOST_UFO 14 /* Host can handle UFO in. */
48 #define VIRTIO_NET_F_MRG_RXBUF 15 /* Host can merge receive buffers. */
49 #define VIRTIO_NET_F_STATUS 16 /* virtio_net_config.status available */
50 #define VIRTIO_NET_F_CTRL_VQ 17 /* Control channel available */
51 #define VIRTIO_NET_F_CTRL_RX 18 /* Control channel RX mode support */
52 #define VIRTIO_NET_F_CTRL_VLAN 19 /* Control channel VLAN filtering */
53 #define VIRTIO_NET_F_CTRL_RX_EXTRA 20 /* Extra RX mode control support */
54 #define VIRTIO_NET_F_GUEST_ANNOUNCE 21 /* Guest can announce device on the
55 * network */
56 #define VIRTIO_NET_F_MQ 22 /* Device supports Receive Flow
57 * Steering */
58 #define VIRTIO_NET_F_CTRL_MAC_ADDR 23 /* Set MAC address */
59 #define VIRTIO_NET_F_DEVICE_STATS 50 /* Device can provide device-level statistics. */
60 #define VIRTIO_NET_F_VQ_NOTF_COAL 52 /* Device supports virtqueue notification coalescing */
61 #define VIRTIO_NET_F_NOTF_COAL 53 /* Device supports notifications coalescing */
62 #define VIRTIO_NET_F_GUEST_USO4 54 /* Guest can handle USOv4 in. */
63 #define VIRTIO_NET_F_GUEST_USO6 55 /* Guest can handle USOv6 in. */
64 #define VIRTIO_NET_F_HOST_USO 56 /* Host can handle USO in. */
65 #define VIRTIO_NET_F_HASH_REPORT 57 /* Supports hash report */
66 #define VIRTIO_NET_F_GUEST_HDRLEN 59 /* Guest provides the exact hdr_len value. */
67 #define VIRTIO_NET_F_RSS 60 /* Supports RSS RX steering */
68 #define VIRTIO_NET_F_RSC_EXT 61 /* extended coalescing info */
69 #define VIRTIO_NET_F_STANDBY 62 /* Act as standby for another device
70 * with the same MAC.
71 */
72 #define VIRTIO_NET_F_SPEED_DUPLEX 63 /* Device set linkspeed and duplex */
73 #define VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO 65 /* Driver can receive
74 * GSO-over-UDP-tunnel packets
75 */
76 #define VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO_CSUM 66 /* Driver handles
77 * GSO-over-UDP-tunnel
78 * packets with partial csum
79 * for the outer header
80 */
81 #define VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO 67 /* Device can receive
82 * GSO-over-UDP-tunnel packets
83 */
84 #define VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO_CSUM 68 /* Device handles
85 * GSO-over-UDP-tunnel
86 * packets with partial csum
87 * for the outer header
88 */
89
90 /* Offloads bits corresponding to VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO{,_CSUM}
91 * features
92 */
93 #define VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO_MAPPED 46
94 #define VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO_CSUM_MAPPED 47
95
96 #ifndef VIRTIO_NET_NO_LEGACY
97 #define VIRTIO_NET_F_GSO 6 /* Host handles pkts w/ any GSO type */
98 #endif /* VIRTIO_NET_NO_LEGACY */
99
100 #define VIRTIO_NET_S_LINK_UP 1 /* Link is up */
101 #define VIRTIO_NET_S_ANNOUNCE 2 /* Announcement is needed */
102
103 /* supported/enabled hash types */
104 #define VIRTIO_NET_RSS_HASH_TYPE_IPv4 (1 << 0)
105 #define VIRTIO_NET_RSS_HASH_TYPE_TCPv4 (1 << 1)
106 #define VIRTIO_NET_RSS_HASH_TYPE_UDPv4 (1 << 2)
107 #define VIRTIO_NET_RSS_HASH_TYPE_IPv6 (1 << 3)
108 #define VIRTIO_NET_RSS_HASH_TYPE_TCPv6 (1 << 4)
109 #define VIRTIO_NET_RSS_HASH_TYPE_UDPv6 (1 << 5)
110 #define VIRTIO_NET_RSS_HASH_TYPE_IP_EX (1 << 6)
111 #define VIRTIO_NET_RSS_HASH_TYPE_TCP_EX (1 << 7)
112 #define VIRTIO_NET_RSS_HASH_TYPE_UDP_EX (1 << 8)
113
114 struct virtio_net_config {
115 /* The config defining mac address (if VIRTIO_NET_F_MAC) */
116 uint8_t mac[ETH_ALEN];
117 /* See VIRTIO_NET_F_STATUS and VIRTIO_NET_S_* above */
118 __virtio16 status;
119 /* Maximum number of each of transmit and receive queues;
120 * see VIRTIO_NET_F_MQ and VIRTIO_NET_CTRL_MQ.
121 * Legal values are between 1 and 0x8000
122 */
123 __virtio16 max_virtqueue_pairs;
124 /* Default maximum transmit unit advice */
125 __virtio16 mtu;
126 /*
127 * speed, in units of 1Mb. All values 0 to INT_MAX are legal.
128 * Any other value stands for unknown.
129 */
130 uint32_t speed;
131 /*
132 * 0x00 - half duplex
133 * 0x01 - full duplex
134 * Any other value stands for unknown.
135 */
136 uint8_t duplex;
137 /* maximum size of RSS key */
138 uint8_t rss_max_key_size;
139 /* maximum number of indirection table entries */
140 uint16_t rss_max_indirection_table_length;
141 /* bitmask of supported VIRTIO_NET_RSS_HASH_ types */
142 uint32_t supported_hash_types;
143 } QEMU_PACKED;
144
145 /*
146 * This header comes first in the scatter-gather list. If you don't
147 * specify GSO or CSUM features, you can simply ignore the header.
148 *
149 * This is bitwise-equivalent to the legacy struct virtio_net_hdr_mrg_rxbuf,
150 * only flattened.
151 */
152 struct virtio_net_hdr_v1 {
153 #define VIRTIO_NET_HDR_F_NEEDS_CSUM 1 /* Use csum_start, csum_offset */
154 #define VIRTIO_NET_HDR_F_DATA_VALID 2 /* Csum is valid */
155 #define VIRTIO_NET_HDR_F_RSC_INFO 4 /* rsc info in csum_ fields */
156 #define VIRTIO_NET_HDR_F_UDP_TUNNEL_CSUM 8 /* UDP tunnel csum offload */
157 uint8_t flags;
158 #define VIRTIO_NET_HDR_GSO_NONE 0 /* Not a GSO frame */
159 #define VIRTIO_NET_HDR_GSO_TCPV4 1 /* GSO frame, IPv4 TCP (TSO) */
160 #define VIRTIO_NET_HDR_GSO_UDP 3 /* GSO frame, IPv4 UDP (UFO) */
161 #define VIRTIO_NET_HDR_GSO_TCPV6 4 /* GSO frame, IPv6 TCP */
162 #define VIRTIO_NET_HDR_GSO_UDP_L4 5 /* GSO frame, IPv4& IPv6 UDP (USO) */
163 #define VIRTIO_NET_HDR_GSO_UDP_TUNNEL_IPV4 0x20 /* UDPv4 tunnel present */
164 #define VIRTIO_NET_HDR_GSO_UDP_TUNNEL_IPV6 0x40 /* UDPv6 tunnel present */
165 #define VIRTIO_NET_HDR_GSO_UDP_TUNNEL (VIRTIO_NET_HDR_GSO_UDP_TUNNEL_IPV4 | \
166 VIRTIO_NET_HDR_GSO_UDP_TUNNEL_IPV6)
167 #define VIRTIO_NET_HDR_GSO_ECN 0x80 /* TCP has ECN set */
168 uint8_t gso_type;
169 __virtio16 hdr_len; /* Ethernet + IP + tcp/udp hdrs */
170 __virtio16 gso_size; /* Bytes to append to hdr_len per frame */
171 union {
172 struct {
173 __virtio16 csum_start;
174 __virtio16 csum_offset;
175 };
176 /* Checksum calculation */
177 struct {
178 /* Position to start checksumming from */
179 __virtio16 start;
180 /* Offset after that to place checksum */
181 __virtio16 offset;
182 } csum;
183 /* Receive Segment Coalescing */
184 struct {
185 /* Number of coalesced segments */
186 uint16_t segments;
187 /* Number of duplicated acks */
188 uint16_t dup_acks;
189 } rsc;
190 };
191 __virtio16 num_buffers; /* Number of merged rx buffers */
192 };
193
194 struct virtio_net_hdr_v1_hash {
195 struct virtio_net_hdr_v1 hdr;
196 uint16_t hash_value_lo;
197 uint16_t hash_value_hi;
198 #define VIRTIO_NET_HASH_REPORT_NONE 0
199 #define VIRTIO_NET_HASH_REPORT_IPv4 1
200 #define VIRTIO_NET_HASH_REPORT_TCPv4 2
201 #define VIRTIO_NET_HASH_REPORT_UDPv4 3
202 #define VIRTIO_NET_HASH_REPORT_IPv6 4
203 #define VIRTIO_NET_HASH_REPORT_TCPv6 5
204 #define VIRTIO_NET_HASH_REPORT_UDPv6 6
205 #define VIRTIO_NET_HASH_REPORT_IPv6_EX 7
206 #define VIRTIO_NET_HASH_REPORT_TCPv6_EX 8
207 #define VIRTIO_NET_HASH_REPORT_UDPv6_EX 9
208 uint16_t hash_report;
209 uint16_t padding;
210 };
211
212 struct virtio_net_hdr_v1_hash_tunnel {
213 struct virtio_net_hdr_v1_hash hash_hdr;
214 uint16_t outer_th_offset;
215 uint16_t inner_nh_offset;
216 };
217
218 #ifndef VIRTIO_NET_NO_LEGACY
219 /* This header comes first in the scatter-gather list.
220 * For legacy virtio, if VIRTIO_F_ANY_LAYOUT is not negotiated, it must
221 * be the first element of the scatter-gather list. If you don't
222 * specify GSO or CSUM features, you can simply ignore the header. */
223 struct virtio_net_hdr {
224 /* See VIRTIO_NET_HDR_F_* */
225 uint8_t flags;
226 /* See VIRTIO_NET_HDR_GSO_* */
227 uint8_t gso_type;
228 __virtio16 hdr_len; /* Ethernet + IP + tcp/udp hdrs */
229 __virtio16 gso_size; /* Bytes to append to hdr_len per frame */
230 __virtio16 csum_start; /* Position to start checksumming from */
231 __virtio16 csum_offset; /* Offset after that to place checksum */
232 };
233
234 /* This is the version of the header to use when the MRG_RXBUF
235 * feature has been negotiated. */
236 struct virtio_net_hdr_mrg_rxbuf {
237 struct virtio_net_hdr hdr;
238 __virtio16 num_buffers; /* Number of merged rx buffers */
239 };
240 #endif /* ...VIRTIO_NET_NO_LEGACY */
241
242 /*
243 * Control virtqueue data structures
244 *
245 * The control virtqueue expects a header in the first sg entry
246 * and an ack/status response in the last entry. Data for the
247 * command goes in between.
248 */
249 struct virtio_net_ctrl_hdr {
250 uint8_t class;
251 uint8_t cmd;
252 } QEMU_PACKED;
253
254 typedef uint8_t virtio_net_ctrl_ack;
255
256 #define VIRTIO_NET_OK 0
257 #define VIRTIO_NET_ERR 1
258
259 /*
260 * Control the RX mode, ie. promisucous, allmulti, etc...
261 * All commands require an "out" sg entry containing a 1 byte
262 * state value, zero = disable, non-zero = enable. Commands
263 * 0 and 1 are supported with the VIRTIO_NET_F_CTRL_RX feature.
264 * Commands 2-5 are added with VIRTIO_NET_F_CTRL_RX_EXTRA.
265 */
266 #define VIRTIO_NET_CTRL_RX 0
267 #define VIRTIO_NET_CTRL_RX_PROMISC 0
268 #define VIRTIO_NET_CTRL_RX_ALLMULTI 1
269 #define VIRTIO_NET_CTRL_RX_ALLUNI 2
270 #define VIRTIO_NET_CTRL_RX_NOMULTI 3
271 #define VIRTIO_NET_CTRL_RX_NOUNI 4
272 #define VIRTIO_NET_CTRL_RX_NOBCAST 5
273
274 /*
275 * Control the MAC
276 *
277 * The MAC filter table is managed by the hypervisor, the guest should
278 * assume the size is infinite. Filtering should be considered
279 * non-perfect, ie. based on hypervisor resources, the guest may
280 * received packets from sources not specified in the filter list.
281 *
282 * In addition to the class/cmd header, the TABLE_SET command requires
283 * two out scatterlists. Each contains a 4 byte count of entries followed
284 * by a concatenated byte stream of the ETH_ALEN MAC addresses. The
285 * first sg list contains unicast addresses, the second is for multicast.
286 * This functionality is present if the VIRTIO_NET_F_CTRL_RX feature
287 * is available.
288 *
289 * The ADDR_SET command requests one out scatterlist, it contains a
290 * 6 bytes MAC address. This functionality is present if the
291 * VIRTIO_NET_F_CTRL_MAC_ADDR feature is available.
292 */
293 struct virtio_net_ctrl_mac {
294 __virtio32 entries;
295 uint8_t macs[][ETH_ALEN];
296 } QEMU_PACKED;
297
298 #define VIRTIO_NET_CTRL_MAC 1
299 #define VIRTIO_NET_CTRL_MAC_TABLE_SET 0
300 #define VIRTIO_NET_CTRL_MAC_ADDR_SET 1
301
302 /*
303 * Control VLAN filtering
304 *
305 * The VLAN filter table is controlled via a simple ADD/DEL interface.
306 * VLAN IDs not added may be filterd by the hypervisor. Del is the
307 * opposite of add. Both commands expect an out entry containing a 2
308 * byte VLAN ID. VLAN filterting is available with the
309 * VIRTIO_NET_F_CTRL_VLAN feature bit.
310 */
311 #define VIRTIO_NET_CTRL_VLAN 2
312 #define VIRTIO_NET_CTRL_VLAN_ADD 0
313 #define VIRTIO_NET_CTRL_VLAN_DEL 1
314
315 /*
316 * Control link announce acknowledgement
317 *
318 * The command VIRTIO_NET_CTRL_ANNOUNCE_ACK is used to indicate that
319 * driver has recevied the notification; device would clear the
320 * VIRTIO_NET_S_ANNOUNCE bit in the status field after it receives
321 * this command.
322 */
323 #define VIRTIO_NET_CTRL_ANNOUNCE 3
324 #define VIRTIO_NET_CTRL_ANNOUNCE_ACK 0
325
326 /*
327 * Control Receive Flow Steering
328 */
329 #define VIRTIO_NET_CTRL_MQ 4
330 /*
331 * The command VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET
332 * enables Receive Flow Steering, specifying the number of the transmit and
333 * receive queues that will be used. After the command is consumed and acked by
334 * the device, the device will not steer new packets on receive virtqueues
335 * other than specified nor read from transmit virtqueues other than specified.
336 * Accordingly, driver should not transmit new packets on virtqueues other than
337 * specified.
338 */
339 struct virtio_net_ctrl_mq {
340 __virtio16 virtqueue_pairs;
341 };
342
343 #define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET 0
344 #define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MIN 1
345 #define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MAX 0x8000
346
347 /*
348 * The command VIRTIO_NET_CTRL_MQ_RSS_CONFIG has the same effect as
349 * VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET does and additionally configures
350 * the receive steering to use a hash calculated for incoming packet
351 * to decide on receive virtqueue to place the packet. The command
352 * also provides parameters to calculate a hash and receive virtqueue.
353 */
354 struct virtio_net_rss_config {
355 uint32_t hash_types;
356 uint16_t indirection_table_mask;
357 uint16_t unclassified_queue;
358 uint16_t indirection_table[1/* + indirection_table_mask */];
359 uint16_t max_tx_vq;
360 uint8_t hash_key_length;
361 uint8_t hash_key_data[/* hash_key_length */];
362 };
363
364 struct virtio_net_rss_config_hdr {
365 uint32_t hash_types;
366 uint16_t indirection_table_mask;
367 uint16_t unclassified_queue;
368 uint16_t indirection_table[/* 1 + indirection_table_mask */];
369 };
370
371 struct virtio_net_rss_config_trailer {
372 uint16_t max_tx_vq;
373 uint8_t hash_key_length;
374 uint8_t hash_key_data[/* hash_key_length */];
375 };
376
377 #define VIRTIO_NET_CTRL_MQ_RSS_CONFIG 1
378
379 /*
380 * The command VIRTIO_NET_CTRL_MQ_HASH_CONFIG requests the device
381 * to include in the virtio header of the packet the value of the
382 * calculated hash and the report type of hash. It also provides
383 * parameters for hash calculation. The command requires feature
384 * VIRTIO_NET_F_HASH_REPORT to be negotiated to extend the
385 * layout of virtio header as defined in virtio_net_hdr_v1_hash.
386 */
387 struct virtio_net_hash_config {
388 uint32_t hash_types;
389 /* for compatibility with virtio_net_rss_config */
390 uint16_t reserved[4];
391 uint8_t hash_key_length;
392 uint8_t hash_key_data[/* hash_key_length */];
393 };
394
395 #define VIRTIO_NET_CTRL_MQ_HASH_CONFIG 2
396
397 /*
398 * Control network offloads
399 *
400 * Reconfigures the network offloads that Guest can handle.
401 *
402 * Available with the VIRTIO_NET_F_CTRL_GUEST_OFFLOADS feature bit.
403 *
404 * Command data format matches the feature bit mask exactly.
405 *
406 * See VIRTIO_NET_F_GUEST_* for the list of offloads
407 * that can be enabled/disabled.
408 */
409 #define VIRTIO_NET_CTRL_GUEST_OFFLOADS 5
410 #define VIRTIO_NET_CTRL_GUEST_OFFLOADS_SET 0
411
412 /*
413 * Control notifications coalescing.
414 *
415 * Request the device to change the notifications coalescing parameters.
416 *
417 * Available with the VIRTIO_NET_F_NOTF_COAL feature bit.
418 */
419 #define VIRTIO_NET_CTRL_NOTF_COAL 6
420 /*
421 * Set the tx-usecs/tx-max-packets parameters.
422 */
423 struct virtio_net_ctrl_coal_tx {
424 /* Maximum number of packets to send before a TX notification */
425 uint32_t tx_max_packets;
426 /* Maximum number of usecs to delay a TX notification */
427 uint32_t tx_usecs;
428 };
429
430 #define VIRTIO_NET_CTRL_NOTF_COAL_TX_SET 0
431
432 /*
433 * Set the rx-usecs/rx-max-packets parameters.
434 */
435 struct virtio_net_ctrl_coal_rx {
436 /* Maximum number of packets to receive before a RX notification */
437 uint32_t rx_max_packets;
438 /* Maximum number of usecs to delay a RX notification */
439 uint32_t rx_usecs;
440 };
441
442 #define VIRTIO_NET_CTRL_NOTF_COAL_RX_SET 1
443 #define VIRTIO_NET_CTRL_NOTF_COAL_VQ_SET 2
444 #define VIRTIO_NET_CTRL_NOTF_COAL_VQ_GET 3
445
446 struct virtio_net_ctrl_coal {
447 uint32_t max_packets;
448 uint32_t max_usecs;
449 };
450
451 struct virtio_net_ctrl_coal_vq {
452 uint16_t vqn;
453 uint16_t reserved;
454 struct virtio_net_ctrl_coal coal;
455 };
456
457 /*
458 * Device Statistics
459 */
460 #define VIRTIO_NET_CTRL_STATS 8
461 #define VIRTIO_NET_CTRL_STATS_QUERY 0
462 #define VIRTIO_NET_CTRL_STATS_GET 1
463
464 struct virtio_net_stats_capabilities {
465
466 #define VIRTIO_NET_STATS_TYPE_CVQ (1ULL << 32)
467
468 #define VIRTIO_NET_STATS_TYPE_RX_BASIC (1ULL << 0)
469 #define VIRTIO_NET_STATS_TYPE_RX_CSUM (1ULL << 1)
470 #define VIRTIO_NET_STATS_TYPE_RX_GSO (1ULL << 2)
471 #define VIRTIO_NET_STATS_TYPE_RX_SPEED (1ULL << 3)
472
473 #define VIRTIO_NET_STATS_TYPE_TX_BASIC (1ULL << 16)
474 #define VIRTIO_NET_STATS_TYPE_TX_CSUM (1ULL << 17)
475 #define VIRTIO_NET_STATS_TYPE_TX_GSO (1ULL << 18)
476 #define VIRTIO_NET_STATS_TYPE_TX_SPEED (1ULL << 19)
477
478 uint64_t supported_stats_types[1];
479 };
480
481 struct virtio_net_ctrl_queue_stats {
482 struct {
483 uint16_t vq_index;
484 uint16_t reserved[3];
485 uint64_t types_bitmap[1];
486 } stats[1];
487 };
488
489 struct virtio_net_stats_reply_hdr {
490 #define VIRTIO_NET_STATS_TYPE_REPLY_CVQ 32
491
492 #define VIRTIO_NET_STATS_TYPE_REPLY_RX_BASIC 0
493 #define VIRTIO_NET_STATS_TYPE_REPLY_RX_CSUM 1
494 #define VIRTIO_NET_STATS_TYPE_REPLY_RX_GSO 2
495 #define VIRTIO_NET_STATS_TYPE_REPLY_RX_SPEED 3
496
497 #define VIRTIO_NET_STATS_TYPE_REPLY_TX_BASIC 16
498 #define VIRTIO_NET_STATS_TYPE_REPLY_TX_CSUM 17
499 #define VIRTIO_NET_STATS_TYPE_REPLY_TX_GSO 18
500 #define VIRTIO_NET_STATS_TYPE_REPLY_TX_SPEED 19
501 uint8_t type;
502 uint8_t reserved;
503 uint16_t vq_index;
504 uint16_t reserved1;
505 uint16_t size;
506 };
507
508 struct virtio_net_stats_cvq {
509 struct virtio_net_stats_reply_hdr hdr;
510
511 uint64_t command_num;
512 uint64_t ok_num;
513 };
514
515 struct virtio_net_stats_rx_basic {
516 struct virtio_net_stats_reply_hdr hdr;
517
518 uint64_t rx_notifications;
519
520 uint64_t rx_packets;
521 uint64_t rx_bytes;
522
523 uint64_t rx_interrupts;
524
525 uint64_t rx_drops;
526 uint64_t rx_drop_overruns;
527 };
528
529 struct virtio_net_stats_tx_basic {
530 struct virtio_net_stats_reply_hdr hdr;
531
532 uint64_t tx_notifications;
533
534 uint64_t tx_packets;
535 uint64_t tx_bytes;
536
537 uint64_t tx_interrupts;
538
539 uint64_t tx_drops;
540 uint64_t tx_drop_malformed;
541 };
542
543 struct virtio_net_stats_rx_csum {
544 struct virtio_net_stats_reply_hdr hdr;
545
546 uint64_t rx_csum_valid;
547 uint64_t rx_needs_csum;
548 uint64_t rx_csum_none;
549 uint64_t rx_csum_bad;
550 };
551
552 struct virtio_net_stats_tx_csum {
553 struct virtio_net_stats_reply_hdr hdr;
554
555 uint64_t tx_csum_none;
556 uint64_t tx_needs_csum;
557 };
558
559 struct virtio_net_stats_rx_gso {
560 struct virtio_net_stats_reply_hdr hdr;
561
562 uint64_t rx_gso_packets;
563 uint64_t rx_gso_bytes;
564 uint64_t rx_gso_packets_coalesced;
565 uint64_t rx_gso_bytes_coalesced;
566 };
567
568 struct virtio_net_stats_tx_gso {
569 struct virtio_net_stats_reply_hdr hdr;
570
571 uint64_t tx_gso_packets;
572 uint64_t tx_gso_bytes;
573 uint64_t tx_gso_segments;
574 uint64_t tx_gso_segments_bytes;
575 uint64_t tx_gso_packets_noseg;
576 uint64_t tx_gso_bytes_noseg;
577 };
578
579 struct virtio_net_stats_rx_speed {
580 struct virtio_net_stats_reply_hdr hdr;
581
582 /* rx_{packets,bytes}_allowance_exceeded are too long. So rename to
583 * short name.
584 */
585 uint64_t rx_ratelimit_packets;
586 uint64_t rx_ratelimit_bytes;
587 };
588
589 struct virtio_net_stats_tx_speed {
590 struct virtio_net_stats_reply_hdr hdr;
591
592 /* tx_{packets,bytes}_allowance_exceeded are too long. So rename to
593 * short name.
594 */
595 uint64_t tx_ratelimit_packets;
596 uint64_t tx_ratelimit_bytes;
597 };
598
599 #endif /* _LINUX_VIRTIO_NET_H */