blob: 7573209cc8a309a650d8e7427af01cbffdd05795 [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 Ferris67d1e5e2023-10-31 13:36:37 -070036#define VIRTIO_NET_F_VQ_NOTF_COAL 52
Christopher Ferris7447a1c2022-10-04 18:24:44 -070037#define VIRTIO_NET_F_NOTF_COAL 53
Christopher Ferris8b7fdc92023-02-21 13:36:32 -080038#define VIRTIO_NET_F_GUEST_USO4 54
39#define VIRTIO_NET_F_GUEST_USO6 55
40#define VIRTIO_NET_F_HOST_USO 56
Christopher Ferrisaf09c702020-06-01 20:29:29 -070041#define VIRTIO_NET_F_HASH_REPORT 57
Christopher Ferris37c3f3c2023-07-10 10:59:05 -070042#define VIRTIO_NET_F_GUEST_HDRLEN 59
Christopher Ferrisaf09c702020-06-01 20:29:29 -070043#define VIRTIO_NET_F_RSS 60
44#define VIRTIO_NET_F_RSC_EXT 61
Christopher Ferris9ce28842018-10-25 12:11:39 -070045#define VIRTIO_NET_F_STANDBY 62
Christopher Ferris76a1d452018-06-27 14:12:29 -070046#define VIRTIO_NET_F_SPEED_DUPLEX 63
Christopher Ferris05d08e92016-02-04 13:16:38 -080047#ifndef VIRTIO_NET_NO_LEGACY
48#define VIRTIO_NET_F_GSO 6
49#endif
Christopher Ferris49f525c2016-12-12 14:55:36 -080050#define VIRTIO_NET_S_LINK_UP 1
Ben Cheng655a7c02013-10-16 16:09:24 -070051#define VIRTIO_NET_S_ANNOUNCE 2
Christopher Ferrisaf09c702020-06-01 20:29:29 -070052#define VIRTIO_NET_RSS_HASH_TYPE_IPv4 (1 << 0)
53#define VIRTIO_NET_RSS_HASH_TYPE_TCPv4 (1 << 1)
54#define VIRTIO_NET_RSS_HASH_TYPE_UDPv4 (1 << 2)
55#define VIRTIO_NET_RSS_HASH_TYPE_IPv6 (1 << 3)
56#define VIRTIO_NET_RSS_HASH_TYPE_TCPv6 (1 << 4)
57#define VIRTIO_NET_RSS_HASH_TYPE_UDPv6 (1 << 5)
58#define VIRTIO_NET_RSS_HASH_TYPE_IP_EX (1 << 6)
59#define VIRTIO_NET_RSS_HASH_TYPE_TCP_EX (1 << 7)
60#define VIRTIO_NET_RSS_HASH_TYPE_UDP_EX (1 << 8)
Ben Cheng655a7c02013-10-16 16:09:24 -070061struct virtio_net_config {
Tao Baod7db5942015-01-28 10:07:51 -080062 __u8 mac[ETH_ALEN];
Christopher Ferris25c18d42020-10-14 17:42:58 -070063 __virtio16 status;
64 __virtio16 max_virtqueue_pairs;
65 __virtio16 mtu;
66 __le32 speed;
Christopher Ferris76a1d452018-06-27 14:12:29 -070067 __u8 duplex;
Christopher Ferrisaf09c702020-06-01 20:29:29 -070068 __u8 rss_max_key_size;
69 __le16 rss_max_indirection_table_length;
70 __le32 supported_hash_types;
Ben Cheng655a7c02013-10-16 16:09:24 -070071} __attribute__((packed));
Christopher Ferris05d08e92016-02-04 13:16:38 -080072struct virtio_net_hdr_v1 {
Ben Cheng655a7c02013-10-16 16:09:24 -070073#define VIRTIO_NET_HDR_F_NEEDS_CSUM 1
Ben Cheng655a7c02013-10-16 16:09:24 -070074#define VIRTIO_NET_HDR_F_DATA_VALID 2
Christopher Ferrisaf09c702020-06-01 20:29:29 -070075#define VIRTIO_NET_HDR_F_RSC_INFO 4
Tao Baod7db5942015-01-28 10:07:51 -080076 __u8 flags;
Ben Cheng655a7c02013-10-16 16:09:24 -070077#define VIRTIO_NET_HDR_GSO_NONE 0
78#define VIRTIO_NET_HDR_GSO_TCPV4 1
Ben Cheng655a7c02013-10-16 16:09:24 -070079#define VIRTIO_NET_HDR_GSO_UDP 3
80#define VIRTIO_NET_HDR_GSO_TCPV6 4
Christopher Ferris8b7fdc92023-02-21 13:36:32 -080081#define VIRTIO_NET_HDR_GSO_UDP_L4 5
Ben Cheng655a7c02013-10-16 16:09:24 -070082#define VIRTIO_NET_HDR_GSO_ECN 0x80
Tao Baod7db5942015-01-28 10:07:51 -080083 __u8 gso_type;
Christopher Ferris05d08e92016-02-04 13:16:38 -080084 __virtio16 hdr_len;
85 __virtio16 gso_size;
Christopher Ferrisaf09c702020-06-01 20:29:29 -070086 union {
87 struct {
88 __virtio16 csum_start;
89 __virtio16 csum_offset;
90 };
91 struct {
92 __virtio16 start;
93 __virtio16 offset;
94 } csum;
95 struct {
96 __le16 segments;
97 __le16 dup_acks;
98 } rsc;
99 };
Christopher Ferris05d08e92016-02-04 13:16:38 -0800100 __virtio16 num_buffers;
101};
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700102struct virtio_net_hdr_v1_hash {
103 struct virtio_net_hdr_v1 hdr;
104 __le32 hash_value;
105#define VIRTIO_NET_HASH_REPORT_NONE 0
106#define VIRTIO_NET_HASH_REPORT_IPv4 1
107#define VIRTIO_NET_HASH_REPORT_TCPv4 2
108#define VIRTIO_NET_HASH_REPORT_UDPv4 3
109#define VIRTIO_NET_HASH_REPORT_IPv6 4
110#define VIRTIO_NET_HASH_REPORT_TCPv6 5
111#define VIRTIO_NET_HASH_REPORT_UDPv6 6
112#define VIRTIO_NET_HASH_REPORT_IPv6_EX 7
113#define VIRTIO_NET_HASH_REPORT_TCPv6_EX 8
114#define VIRTIO_NET_HASH_REPORT_UDPv6_EX 9
115 __le16 hash_report;
116 __le16 padding;
117};
Christopher Ferris05d08e92016-02-04 13:16:38 -0800118#ifndef VIRTIO_NET_NO_LEGACY
119struct virtio_net_hdr {
Christopher Ferris05d08e92016-02-04 13:16:38 -0800120 __u8 flags;
121 __u8 gso_type;
122 __virtio16 hdr_len;
123 __virtio16 gso_size;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800124 __virtio16 csum_start;
125 __virtio16 csum_offset;
Ben Cheng655a7c02013-10-16 16:09:24 -0700126};
127struct virtio_net_hdr_mrg_rxbuf {
Christopher Ferris05d08e92016-02-04 13:16:38 -0800128 struct virtio_net_hdr hdr;
129 __virtio16 num_buffers;
Ben Cheng655a7c02013-10-16 16:09:24 -0700130};
Christopher Ferris05d08e92016-02-04 13:16:38 -0800131#endif
Ben Cheng655a7c02013-10-16 16:09:24 -0700132struct virtio_net_ctrl_hdr {
Christopher Ferris67d1e5e2023-10-31 13:36:37 -0700133 __u8 __linux_class;
Tao Baod7db5942015-01-28 10:07:51 -0800134 __u8 cmd;
Ben Cheng655a7c02013-10-16 16:09:24 -0700135} __attribute__((packed));
136typedef __u8 virtio_net_ctrl_ack;
137#define VIRTIO_NET_OK 0
138#define VIRTIO_NET_ERR 1
Ben Cheng655a7c02013-10-16 16:09:24 -0700139#define VIRTIO_NET_CTRL_RX 0
140#define VIRTIO_NET_CTRL_RX_PROMISC 0
141#define VIRTIO_NET_CTRL_RX_ALLMULTI 1
142#define VIRTIO_NET_CTRL_RX_ALLUNI 2
Ben Cheng655a7c02013-10-16 16:09:24 -0700143#define VIRTIO_NET_CTRL_RX_NOMULTI 3
144#define VIRTIO_NET_CTRL_RX_NOUNI 4
145#define VIRTIO_NET_CTRL_RX_NOBCAST 5
146struct virtio_net_ctrl_mac {
Christopher Ferris05d08e92016-02-04 13:16:38 -0800147 __virtio32 entries;
Tao Baod7db5942015-01-28 10:07:51 -0800148 __u8 macs[][ETH_ALEN];
Ben Cheng655a7c02013-10-16 16:09:24 -0700149} __attribute__((packed));
150#define VIRTIO_NET_CTRL_MAC 1
Ben Cheng655a7c02013-10-16 16:09:24 -0700151#define VIRTIO_NET_CTRL_MAC_TABLE_SET 0
152#define VIRTIO_NET_CTRL_MAC_ADDR_SET 1
153#define VIRTIO_NET_CTRL_VLAN 2
154#define VIRTIO_NET_CTRL_VLAN_ADD 0
Ben Cheng655a7c02013-10-16 16:09:24 -0700155#define VIRTIO_NET_CTRL_VLAN_DEL 1
156#define VIRTIO_NET_CTRL_ANNOUNCE 3
157#define VIRTIO_NET_CTRL_ANNOUNCE_ACK 0
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700158#define VIRTIO_NET_CTRL_MQ 4
Ben Cheng655a7c02013-10-16 16:09:24 -0700159struct virtio_net_ctrl_mq {
Christopher Ferris05d08e92016-02-04 13:16:38 -0800160 __virtio16 virtqueue_pairs;
Ben Cheng655a7c02013-10-16 16:09:24 -0700161};
Ben Cheng655a7c02013-10-16 16:09:24 -0700162#define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET 0
Ben Cheng655a7c02013-10-16 16:09:24 -0700163#define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MIN 1
164#define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MAX 0x8000
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700165struct virtio_net_rss_config {
166 __le32 hash_types;
167 __le16 indirection_table_mask;
168 __le16 unclassified_queue;
169 __le16 indirection_table[1];
170 __le16 max_tx_vq;
171 __u8 hash_key_length;
172 __u8 hash_key_data[];
173};
174#define VIRTIO_NET_CTRL_MQ_RSS_CONFIG 1
175struct virtio_net_hash_config {
176 __le32 hash_types;
177 __le16 reserved[4];
178 __u8 hash_key_length;
179 __u8 hash_key_data[];
180};
181#define VIRTIO_NET_CTRL_MQ_HASH_CONFIG 2
Christopher Ferris05d08e92016-02-04 13:16:38 -0800182#define VIRTIO_NET_CTRL_GUEST_OFFLOADS 5
183#define VIRTIO_NET_CTRL_GUEST_OFFLOADS_SET 0
Christopher Ferris7447a1c2022-10-04 18:24:44 -0700184#define VIRTIO_NET_CTRL_NOTF_COAL 6
185struct virtio_net_ctrl_coal_tx {
186 __le32 tx_max_packets;
187 __le32 tx_usecs;
188};
189#define VIRTIO_NET_CTRL_NOTF_COAL_TX_SET 0
190struct virtio_net_ctrl_coal_rx {
191 __le32 rx_max_packets;
192 __le32 rx_usecs;
193};
194#define VIRTIO_NET_CTRL_NOTF_COAL_RX_SET 1
Christopher Ferris67d1e5e2023-10-31 13:36:37 -0700195#define VIRTIO_NET_CTRL_NOTF_COAL_VQ_SET 2
196#define VIRTIO_NET_CTRL_NOTF_COAL_VQ_GET 3
197struct virtio_net_ctrl_coal {
198 __le32 max_packets;
199 __le32 max_usecs;
200};
201struct virtio_net_ctrl_coal_vq {
202 __le16 vqn;
203 __le16 reserved;
204 struct virtio_net_ctrl_coal coal;
205};
Ben Cheng655a7c02013-10-16 16:09:24 -0700206#endif