blob: 26ff30199fa1f41e3f44172480b97a47bddd21ab [file] [log] [blame]
Elliott Hughes180edef2023-11-02 00:08:05 +00001/*
2 * This file is auto-generated. Modifications will be lost.
3 *
4 * See https://android.googlesource.com/platform/bionic/+/master/libc/kernel/
5 * for more information.
6 */
Christopher Ferris49f525c2016-12-12 14:55:36 -08007#ifndef _UAPI_LINUX_VIRTIO_NET_H
8#define _UAPI_LINUX_VIRTIO_NET_H
Ben Cheng655a7c02013-10-16 16:09:24 -07009#include <linux/types.h>
10#include <linux/virtio_ids.h>
Ben Cheng655a7c02013-10-16 16:09:24 -070011#include <linux/virtio_config.h>
Christopher Ferris05d08e92016-02-04 13:16:38 -080012#include <linux/virtio_types.h>
Ben Cheng655a7c02013-10-16 16:09:24 -070013#include <linux/if_ether.h>
14#define VIRTIO_NET_F_CSUM 0
15#define VIRTIO_NET_F_GUEST_CSUM 1
Christopher Ferris05d08e92016-02-04 13:16:38 -080016#define VIRTIO_NET_F_CTRL_GUEST_OFFLOADS 2
Christopher Ferris49f525c2016-12-12 14:55:36 -080017#define VIRTIO_NET_F_MTU 3
Ben Cheng655a7c02013-10-16 16:09:24 -070018#define VIRTIO_NET_F_MAC 5
Christopher Ferris49f525c2016-12-12 14:55:36 -080019#define VIRTIO_NET_F_GUEST_TSO4 7
Christopher Ferris05d08e92016-02-04 13:16:38 -080020#define VIRTIO_NET_F_GUEST_TSO6 8
Ben Cheng655a7c02013-10-16 16:09:24 -070021#define VIRTIO_NET_F_GUEST_ECN 9
22#define VIRTIO_NET_F_GUEST_UFO 10
Christopher Ferris49f525c2016-12-12 14:55:36 -080023#define VIRTIO_NET_F_HOST_TSO4 11
Christopher Ferris05d08e92016-02-04 13:16:38 -080024#define VIRTIO_NET_F_HOST_TSO6 12
Ben Cheng655a7c02013-10-16 16:09:24 -070025#define VIRTIO_NET_F_HOST_ECN 13
26#define VIRTIO_NET_F_HOST_UFO 14
Christopher Ferris49f525c2016-12-12 14:55:36 -080027#define VIRTIO_NET_F_MRG_RXBUF 15
Christopher Ferris05d08e92016-02-04 13:16:38 -080028#define VIRTIO_NET_F_STATUS 16
Ben Cheng655a7c02013-10-16 16:09:24 -070029#define VIRTIO_NET_F_CTRL_VQ 17
30#define VIRTIO_NET_F_CTRL_RX 18
Christopher Ferris49f525c2016-12-12 14:55:36 -080031#define VIRTIO_NET_F_CTRL_VLAN 19
Christopher Ferris05d08e92016-02-04 13:16:38 -080032#define VIRTIO_NET_F_CTRL_RX_EXTRA 20
Ben Cheng655a7c02013-10-16 16:09:24 -070033#define VIRTIO_NET_F_GUEST_ANNOUNCE 21
34#define VIRTIO_NET_F_MQ 22
Christopher Ferris49f525c2016-12-12 14:55:36 -080035#define VIRTIO_NET_F_CTRL_MAC_ADDR 23
Christopher Ferris7ac54f52024-08-07 21:07:12 +000036#define VIRTIO_NET_F_DEVICE_STATS 50
Christopher Ferris67d1e5e2023-10-31 13:36:37 -070037#define VIRTIO_NET_F_VQ_NOTF_COAL 52
Christopher Ferris7447a1c2022-10-04 18:24:44 -070038#define VIRTIO_NET_F_NOTF_COAL 53
Christopher Ferris8b7fdc92023-02-21 13:36:32 -080039#define VIRTIO_NET_F_GUEST_USO4 54
40#define VIRTIO_NET_F_GUEST_USO6 55
41#define VIRTIO_NET_F_HOST_USO 56
Christopher Ferrisaf09c702020-06-01 20:29:29 -070042#define VIRTIO_NET_F_HASH_REPORT 57
Christopher Ferris37c3f3c2023-07-10 10:59:05 -070043#define VIRTIO_NET_F_GUEST_HDRLEN 59
Christopher Ferrisaf09c702020-06-01 20:29:29 -070044#define VIRTIO_NET_F_RSS 60
45#define VIRTIO_NET_F_RSC_EXT 61
Christopher Ferris9ce28842018-10-25 12:11:39 -070046#define VIRTIO_NET_F_STANDBY 62
Christopher Ferris76a1d452018-06-27 14:12:29 -070047#define VIRTIO_NET_F_SPEED_DUPLEX 63
Christopher Ferris05d08e92016-02-04 13:16:38 -080048#ifndef VIRTIO_NET_NO_LEGACY
49#define VIRTIO_NET_F_GSO 6
50#endif
Christopher Ferris49f525c2016-12-12 14:55:36 -080051#define VIRTIO_NET_S_LINK_UP 1
Ben Cheng655a7c02013-10-16 16:09:24 -070052#define VIRTIO_NET_S_ANNOUNCE 2
Christopher Ferrisaf09c702020-06-01 20:29:29 -070053#define VIRTIO_NET_RSS_HASH_TYPE_IPv4 (1 << 0)
54#define VIRTIO_NET_RSS_HASH_TYPE_TCPv4 (1 << 1)
55#define VIRTIO_NET_RSS_HASH_TYPE_UDPv4 (1 << 2)
56#define VIRTIO_NET_RSS_HASH_TYPE_IPv6 (1 << 3)
57#define VIRTIO_NET_RSS_HASH_TYPE_TCPv6 (1 << 4)
58#define VIRTIO_NET_RSS_HASH_TYPE_UDPv6 (1 << 5)
59#define VIRTIO_NET_RSS_HASH_TYPE_IP_EX (1 << 6)
60#define VIRTIO_NET_RSS_HASH_TYPE_TCP_EX (1 << 7)
61#define VIRTIO_NET_RSS_HASH_TYPE_UDP_EX (1 << 8)
Ben Cheng655a7c02013-10-16 16:09:24 -070062struct virtio_net_config {
Tao Baod7db5942015-01-28 10:07:51 -080063 __u8 mac[ETH_ALEN];
Christopher Ferris25c18d42020-10-14 17:42:58 -070064 __virtio16 status;
65 __virtio16 max_virtqueue_pairs;
66 __virtio16 mtu;
67 __le32 speed;
Christopher Ferris76a1d452018-06-27 14:12:29 -070068 __u8 duplex;
Christopher Ferrisaf09c702020-06-01 20:29:29 -070069 __u8 rss_max_key_size;
70 __le16 rss_max_indirection_table_length;
71 __le32 supported_hash_types;
Ben Cheng655a7c02013-10-16 16:09:24 -070072} __attribute__((packed));
Christopher Ferris05d08e92016-02-04 13:16:38 -080073struct virtio_net_hdr_v1 {
Ben Cheng655a7c02013-10-16 16:09:24 -070074#define VIRTIO_NET_HDR_F_NEEDS_CSUM 1
Ben Cheng655a7c02013-10-16 16:09:24 -070075#define VIRTIO_NET_HDR_F_DATA_VALID 2
Christopher Ferrisaf09c702020-06-01 20:29:29 -070076#define VIRTIO_NET_HDR_F_RSC_INFO 4
Tao Baod7db5942015-01-28 10:07:51 -080077 __u8 flags;
Ben Cheng655a7c02013-10-16 16:09:24 -070078#define VIRTIO_NET_HDR_GSO_NONE 0
79#define VIRTIO_NET_HDR_GSO_TCPV4 1
Ben Cheng655a7c02013-10-16 16:09:24 -070080#define VIRTIO_NET_HDR_GSO_UDP 3
81#define VIRTIO_NET_HDR_GSO_TCPV6 4
Christopher Ferris8b7fdc92023-02-21 13:36:32 -080082#define VIRTIO_NET_HDR_GSO_UDP_L4 5
Ben Cheng655a7c02013-10-16 16:09:24 -070083#define VIRTIO_NET_HDR_GSO_ECN 0x80
Tao Baod7db5942015-01-28 10:07:51 -080084 __u8 gso_type;
Christopher Ferris05d08e92016-02-04 13:16:38 -080085 __virtio16 hdr_len;
86 __virtio16 gso_size;
Christopher Ferrisaf09c702020-06-01 20:29:29 -070087 union {
88 struct {
89 __virtio16 csum_start;
90 __virtio16 csum_offset;
91 };
92 struct {
93 __virtio16 start;
94 __virtio16 offset;
95 } csum;
96 struct {
97 __le16 segments;
98 __le16 dup_acks;
99 } rsc;
100 };
Christopher Ferris05d08e92016-02-04 13:16:38 -0800101 __virtio16 num_buffers;
102};
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700103struct virtio_net_hdr_v1_hash {
104 struct virtio_net_hdr_v1 hdr;
105 __le32 hash_value;
106#define VIRTIO_NET_HASH_REPORT_NONE 0
107#define VIRTIO_NET_HASH_REPORT_IPv4 1
108#define VIRTIO_NET_HASH_REPORT_TCPv4 2
109#define VIRTIO_NET_HASH_REPORT_UDPv4 3
110#define VIRTIO_NET_HASH_REPORT_IPv6 4
111#define VIRTIO_NET_HASH_REPORT_TCPv6 5
112#define VIRTIO_NET_HASH_REPORT_UDPv6 6
113#define VIRTIO_NET_HASH_REPORT_IPv6_EX 7
114#define VIRTIO_NET_HASH_REPORT_TCPv6_EX 8
115#define VIRTIO_NET_HASH_REPORT_UDPv6_EX 9
116 __le16 hash_report;
117 __le16 padding;
118};
Christopher Ferris05d08e92016-02-04 13:16:38 -0800119#ifndef VIRTIO_NET_NO_LEGACY
120struct virtio_net_hdr {
Christopher Ferris05d08e92016-02-04 13:16:38 -0800121 __u8 flags;
122 __u8 gso_type;
123 __virtio16 hdr_len;
124 __virtio16 gso_size;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800125 __virtio16 csum_start;
126 __virtio16 csum_offset;
Ben Cheng655a7c02013-10-16 16:09:24 -0700127};
128struct virtio_net_hdr_mrg_rxbuf {
Christopher Ferris05d08e92016-02-04 13:16:38 -0800129 struct virtio_net_hdr hdr;
130 __virtio16 num_buffers;
Ben Cheng655a7c02013-10-16 16:09:24 -0700131};
Christopher Ferris05d08e92016-02-04 13:16:38 -0800132#endif
Ben Cheng655a7c02013-10-16 16:09:24 -0700133struct virtio_net_ctrl_hdr {
Christopher Ferris67d1e5e2023-10-31 13:36:37 -0700134 __u8 __linux_class;
Tao Baod7db5942015-01-28 10:07:51 -0800135 __u8 cmd;
Ben Cheng655a7c02013-10-16 16:09:24 -0700136} __attribute__((packed));
137typedef __u8 virtio_net_ctrl_ack;
138#define VIRTIO_NET_OK 0
139#define VIRTIO_NET_ERR 1
Ben Cheng655a7c02013-10-16 16:09:24 -0700140#define VIRTIO_NET_CTRL_RX 0
141#define VIRTIO_NET_CTRL_RX_PROMISC 0
142#define VIRTIO_NET_CTRL_RX_ALLMULTI 1
143#define VIRTIO_NET_CTRL_RX_ALLUNI 2
Ben Cheng655a7c02013-10-16 16:09:24 -0700144#define VIRTIO_NET_CTRL_RX_NOMULTI 3
145#define VIRTIO_NET_CTRL_RX_NOUNI 4
146#define VIRTIO_NET_CTRL_RX_NOBCAST 5
147struct virtio_net_ctrl_mac {
Christopher Ferris05d08e92016-02-04 13:16:38 -0800148 __virtio32 entries;
Tao Baod7db5942015-01-28 10:07:51 -0800149 __u8 macs[][ETH_ALEN];
Ben Cheng655a7c02013-10-16 16:09:24 -0700150} __attribute__((packed));
151#define VIRTIO_NET_CTRL_MAC 1
Ben Cheng655a7c02013-10-16 16:09:24 -0700152#define VIRTIO_NET_CTRL_MAC_TABLE_SET 0
153#define VIRTIO_NET_CTRL_MAC_ADDR_SET 1
154#define VIRTIO_NET_CTRL_VLAN 2
155#define VIRTIO_NET_CTRL_VLAN_ADD 0
Ben Cheng655a7c02013-10-16 16:09:24 -0700156#define VIRTIO_NET_CTRL_VLAN_DEL 1
157#define VIRTIO_NET_CTRL_ANNOUNCE 3
158#define VIRTIO_NET_CTRL_ANNOUNCE_ACK 0
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700159#define VIRTIO_NET_CTRL_MQ 4
Ben Cheng655a7c02013-10-16 16:09:24 -0700160struct virtio_net_ctrl_mq {
Christopher Ferris05d08e92016-02-04 13:16:38 -0800161 __virtio16 virtqueue_pairs;
Ben Cheng655a7c02013-10-16 16:09:24 -0700162};
Ben Cheng655a7c02013-10-16 16:09:24 -0700163#define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET 0
Ben Cheng655a7c02013-10-16 16:09:24 -0700164#define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MIN 1
165#define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MAX 0x8000
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700166struct virtio_net_rss_config {
167 __le32 hash_types;
168 __le16 indirection_table_mask;
169 __le16 unclassified_queue;
170 __le16 indirection_table[1];
171 __le16 max_tx_vq;
172 __u8 hash_key_length;
173 __u8 hash_key_data[];
174};
175#define VIRTIO_NET_CTRL_MQ_RSS_CONFIG 1
176struct virtio_net_hash_config {
177 __le32 hash_types;
178 __le16 reserved[4];
179 __u8 hash_key_length;
180 __u8 hash_key_data[];
181};
182#define VIRTIO_NET_CTRL_MQ_HASH_CONFIG 2
Christopher Ferris05d08e92016-02-04 13:16:38 -0800183#define VIRTIO_NET_CTRL_GUEST_OFFLOADS 5
184#define VIRTIO_NET_CTRL_GUEST_OFFLOADS_SET 0
Christopher Ferris7447a1c2022-10-04 18:24:44 -0700185#define VIRTIO_NET_CTRL_NOTF_COAL 6
186struct virtio_net_ctrl_coal_tx {
187 __le32 tx_max_packets;
188 __le32 tx_usecs;
189};
190#define VIRTIO_NET_CTRL_NOTF_COAL_TX_SET 0
191struct virtio_net_ctrl_coal_rx {
192 __le32 rx_max_packets;
193 __le32 rx_usecs;
194};
195#define VIRTIO_NET_CTRL_NOTF_COAL_RX_SET 1
Christopher Ferris67d1e5e2023-10-31 13:36:37 -0700196#define VIRTIO_NET_CTRL_NOTF_COAL_VQ_SET 2
197#define VIRTIO_NET_CTRL_NOTF_COAL_VQ_GET 3
198struct virtio_net_ctrl_coal {
199 __le32 max_packets;
200 __le32 max_usecs;
201};
202struct virtio_net_ctrl_coal_vq {
203 __le16 vqn;
204 __le16 reserved;
205 struct virtio_net_ctrl_coal coal;
206};
Christopher Ferris7ac54f52024-08-07 21:07:12 +0000207#define VIRTIO_NET_CTRL_STATS 8
208#define VIRTIO_NET_CTRL_STATS_QUERY 0
209#define VIRTIO_NET_CTRL_STATS_GET 1
210struct virtio_net_stats_capabilities {
211#define VIRTIO_NET_STATS_TYPE_CVQ (1ULL << 32)
212#define VIRTIO_NET_STATS_TYPE_RX_BASIC (1ULL << 0)
213#define VIRTIO_NET_STATS_TYPE_RX_CSUM (1ULL << 1)
214#define VIRTIO_NET_STATS_TYPE_RX_GSO (1ULL << 2)
215#define VIRTIO_NET_STATS_TYPE_RX_SPEED (1ULL << 3)
216#define VIRTIO_NET_STATS_TYPE_TX_BASIC (1ULL << 16)
217#define VIRTIO_NET_STATS_TYPE_TX_CSUM (1ULL << 17)
218#define VIRTIO_NET_STATS_TYPE_TX_GSO (1ULL << 18)
219#define VIRTIO_NET_STATS_TYPE_TX_SPEED (1ULL << 19)
220 __le64 supported_stats_types[1];
221};
222struct virtio_net_ctrl_queue_stats {
223 struct {
224 __le16 vq_index;
225 __le16 reserved[3];
226 __le64 types_bitmap[1];
227 } stats[1];
228};
229struct virtio_net_stats_reply_hdr {
230#define VIRTIO_NET_STATS_TYPE_REPLY_CVQ 32
231#define VIRTIO_NET_STATS_TYPE_REPLY_RX_BASIC 0
232#define VIRTIO_NET_STATS_TYPE_REPLY_RX_CSUM 1
233#define VIRTIO_NET_STATS_TYPE_REPLY_RX_GSO 2
234#define VIRTIO_NET_STATS_TYPE_REPLY_RX_SPEED 3
235#define VIRTIO_NET_STATS_TYPE_REPLY_TX_BASIC 16
236#define VIRTIO_NET_STATS_TYPE_REPLY_TX_CSUM 17
237#define VIRTIO_NET_STATS_TYPE_REPLY_TX_GSO 18
238#define VIRTIO_NET_STATS_TYPE_REPLY_TX_SPEED 19
239 __u8 type;
240 __u8 reserved;
241 __le16 vq_index;
242 __le16 reserved1;
243 __le16 size;
244};
245struct virtio_net_stats_cvq {
246 struct virtio_net_stats_reply_hdr hdr;
247 __le64 command_num;
248 __le64 ok_num;
249};
250struct virtio_net_stats_rx_basic {
251 struct virtio_net_stats_reply_hdr hdr;
252 __le64 rx_notifications;
253 __le64 rx_packets;
254 __le64 rx_bytes;
255 __le64 rx_interrupts;
256 __le64 rx_drops;
257 __le64 rx_drop_overruns;
258};
259struct virtio_net_stats_tx_basic {
260 struct virtio_net_stats_reply_hdr hdr;
261 __le64 tx_notifications;
262 __le64 tx_packets;
263 __le64 tx_bytes;
264 __le64 tx_interrupts;
265 __le64 tx_drops;
266 __le64 tx_drop_malformed;
267};
268struct virtio_net_stats_rx_csum {
269 struct virtio_net_stats_reply_hdr hdr;
270 __le64 rx_csum_valid;
271 __le64 rx_needs_csum;
272 __le64 rx_csum_none;
273 __le64 rx_csum_bad;
274};
275struct virtio_net_stats_tx_csum {
276 struct virtio_net_stats_reply_hdr hdr;
277 __le64 tx_csum_none;
278 __le64 tx_needs_csum;
279};
280struct virtio_net_stats_rx_gso {
281 struct virtio_net_stats_reply_hdr hdr;
282 __le64 rx_gso_packets;
283 __le64 rx_gso_bytes;
284 __le64 rx_gso_packets_coalesced;
285 __le64 rx_gso_bytes_coalesced;
286};
287struct virtio_net_stats_tx_gso {
288 struct virtio_net_stats_reply_hdr hdr;
289 __le64 tx_gso_packets;
290 __le64 tx_gso_bytes;
291 __le64 tx_gso_segments;
292 __le64 tx_gso_segments_bytes;
293 __le64 tx_gso_packets_noseg;
294 __le64 tx_gso_bytes_noseg;
295};
296struct virtio_net_stats_rx_speed {
297 struct virtio_net_stats_reply_hdr hdr;
298 __le64 rx_ratelimit_packets;
299 __le64 rx_ratelimit_bytes;
300};
301struct virtio_net_stats_tx_speed {
302 struct virtio_net_stats_reply_hdr hdr;
303 __le64 tx_ratelimit_packets;
304 __le64 tx_ratelimit_bytes;
305};
Ben Cheng655a7c02013-10-16 16:09:24 -0700306#endif