File Index
Files and directories
Sign in
FILE

virtio_net.h

File preview with syntax highlighting.

linux-6.19.14/include/uapi/linux/virtio_net.h C
  1#ifndef _UAPI_LINUX_VIRTIO_NET_H
  2#define _UAPI_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 <linux/types.h>
 29#include <linux/virtio_ids.h>
 30#include <linux/virtio_config.h>
 31#include <linux/virtio_types.h>
 32#include <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
114struct virtio_net_config {
115	/* The config defining mac address (if VIRTIO_NET_F_MAC) */
116	__u8 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	__le32 speed;
131	/*
132	 * 0x00 - half duplex
133	 * 0x01 - full duplex
134	 * Any other value stands for unknown.
135	 */
136	__u8 duplex;
137	/* maximum size of RSS key */
138	__u8 rss_max_key_size;
139	/* maximum number of indirection table entries */
140	__le16 rss_max_indirection_table_length;
141	/* bitmask of supported VIRTIO_NET_RSS_HASH_ types */
142	__le32 supported_hash_types;
143} __attribute__((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 */
152struct 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	__u8 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	__u8 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			__le16 segments;
187			/* Number of duplicated acks */
188			__le16 dup_acks;
189		} rsc;
190	};
191	__virtio16 num_buffers;	/* Number of merged rx buffers */
192};
193
194struct virtio_net_hdr_v1_hash {
195	struct virtio_net_hdr_v1 hdr;
196	__le16 hash_value_lo;
197	__le16 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	__le16 hash_report;
209	__le16 padding;
210};
211
212struct virtio_net_hdr_v1_hash_tunnel {
213	struct virtio_net_hdr_v1_hash hash_hdr;
214	__le16 outer_th_offset;
215	__le16 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. */
223struct virtio_net_hdr {
224	/* See VIRTIO_NET_HDR_F_* */
225	__u8 flags;
226	/* See VIRTIO_NET_HDR_GSO_* */
227	__u8 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. */
236struct 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 */
249struct virtio_net_ctrl_hdr {
250	__u8 class;
251	__u8 cmd;
252} __attribute__((packed));
253
254typedef __u8 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 */
293struct virtio_net_ctrl_mac {
294	__virtio32 entries;
295	__u8 macs[][ETH_ALEN];
296} __attribute__((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 */
339struct 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 */
354struct virtio_net_rss_config {
355	__le32 hash_types;
356	__le16 indirection_table_mask;
357	__le16 unclassified_queue;
358	__le16 indirection_table[1/* + indirection_table_mask */];
359	__le16 max_tx_vq;
360	__u8 hash_key_length;
361	__u8 hash_key_data[/* hash_key_length */];
362};
363
364struct virtio_net_rss_config_hdr {
365	__le32 hash_types;
366	__le16 indirection_table_mask;
367	__le16 unclassified_queue;
368	__le16 indirection_table[/* 1 + indirection_table_mask */];
369};
370
371struct virtio_net_rss_config_trailer {
372	__le16 max_tx_vq;
373	__u8 hash_key_length;
374	__u8 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 */
387struct virtio_net_hash_config {
388	__le32 hash_types;
389	/* for compatibility with virtio_net_rss_config */
390	__le16 reserved[4];
391	__u8 hash_key_length;
392	__u8 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 */
423struct virtio_net_ctrl_coal_tx {
424	/* Maximum number of packets to send before a TX notification */
425	__le32 tx_max_packets;
426	/* Maximum number of usecs to delay a TX notification */
427	__le32 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 */
435struct virtio_net_ctrl_coal_rx {
436	/* Maximum number of packets to receive before a RX notification */
437	__le32 rx_max_packets;
438	/* Maximum number of usecs to delay a RX notification */
439	__le32 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
446struct virtio_net_ctrl_coal {
447	__le32 max_packets;
448	__le32 max_usecs;
449};
450
451struct  virtio_net_ctrl_coal_vq {
452	__le16 vqn;
453	__le16 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
464struct 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	__le64 supported_stats_types[1];
479};
480
481struct virtio_net_ctrl_queue_stats {
482	struct {
483		__le16 vq_index;
484		__le16 reserved[3];
485		__le64 types_bitmap[1];
486	} stats[1];
487};
488
489struct 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	__u8 type;
502	__u8 reserved;
503	__le16 vq_index;
504	__le16 reserved1;
505	__le16 size;
506};
507
508struct virtio_net_stats_cvq {
509	struct virtio_net_stats_reply_hdr hdr;
510
511	__le64 command_num;
512	__le64 ok_num;
513};
514
515struct virtio_net_stats_rx_basic {
516	struct virtio_net_stats_reply_hdr hdr;
517
518	__le64 rx_notifications;
519
520	__le64 rx_packets;
521	__le64 rx_bytes;
522
523	__le64 rx_interrupts;
524
525	__le64 rx_drops;
526	__le64 rx_drop_overruns;
527};
528
529struct virtio_net_stats_tx_basic {
530	struct virtio_net_stats_reply_hdr hdr;
531
532	__le64 tx_notifications;
533
534	__le64 tx_packets;
535	__le64 tx_bytes;
536
537	__le64 tx_interrupts;
538
539	__le64 tx_drops;
540	__le64 tx_drop_malformed;
541};
542
543struct virtio_net_stats_rx_csum {
544	struct virtio_net_stats_reply_hdr hdr;
545
546	__le64 rx_csum_valid;
547	__le64 rx_needs_csum;
548	__le64 rx_csum_none;
549	__le64 rx_csum_bad;
550};
551
552struct virtio_net_stats_tx_csum {
553	struct virtio_net_stats_reply_hdr hdr;
554
555	__le64 tx_csum_none;
556	__le64 tx_needs_csum;
557};
558
559struct virtio_net_stats_rx_gso {
560	struct virtio_net_stats_reply_hdr hdr;
561
562	__le64 rx_gso_packets;
563	__le64 rx_gso_bytes;
564	__le64 rx_gso_packets_coalesced;
565	__le64 rx_gso_bytes_coalesced;
566};
567
568struct virtio_net_stats_tx_gso {
569	struct virtio_net_stats_reply_hdr hdr;
570
571	__le64 tx_gso_packets;
572	__le64 tx_gso_bytes;
573	__le64 tx_gso_segments;
574	__le64 tx_gso_segments_bytes;
575	__le64 tx_gso_packets_noseg;
576	__le64 tx_gso_bytes_noseg;
577};
578
579struct 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	__le64 rx_ratelimit_packets;
586	__le64 rx_ratelimit_bytes;
587};
588
589struct 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	__le64 tx_ratelimit_packets;
596	__le64 tx_ratelimit_bytes;
597};
598
599#endif /* _UAPI_LINUX_VIRTIO_NET_H */
~/ Read-only file preview.