1 /**************************************************************************** 2 **************************************************************************** 3 *** 4 *** This header was automatically generated from a Linux kernel header 5 *** of the same name, to make information necessary for userspace to 6 *** call into the kernel available to libc. It contains only constants, 7 *** structures, and macros generated from the original header, and thus, 8 *** contains no copyrightable information. 9 *** 10 *** To edit the content of this header, modify the corresponding 11 *** source file (e.g. under external/kernel-headers/original/) then 12 *** run bionic/libc/kernel/tools/update_all.py 13 *** 14 *** Any manual change here will be lost the next time this script will 15 *** be run. You've been warned! 16 *** 17 **************************************************************************** 18 ****************************************************************************/ 19 #ifndef _UAPI_LINUX_VIRTIO_NET_H 20 #define _UAPI_LINUX_VIRTIO_NET_H 21 #include <linux/types.h> 22 #include <linux/virtio_ids.h> 23 #include <linux/virtio_config.h> 24 #include <linux/virtio_types.h> 25 #include <linux/if_ether.h> 26 #define VIRTIO_NET_F_CSUM 0 27 #define VIRTIO_NET_F_GUEST_CSUM 1 28 #define VIRTIO_NET_F_CTRL_GUEST_OFFLOADS 2 29 #define VIRTIO_NET_F_MTU 3 30 #define VIRTIO_NET_F_MAC 5 31 #define VIRTIO_NET_F_GUEST_TSO4 7 32 #define VIRTIO_NET_F_GUEST_TSO6 8 33 #define VIRTIO_NET_F_GUEST_ECN 9 34 #define VIRTIO_NET_F_GUEST_UFO 10 35 #define VIRTIO_NET_F_HOST_TSO4 11 36 #define VIRTIO_NET_F_HOST_TSO6 12 37 #define VIRTIO_NET_F_HOST_ECN 13 38 #define VIRTIO_NET_F_HOST_UFO 14 39 #define VIRTIO_NET_F_MRG_RXBUF 15 40 #define VIRTIO_NET_F_STATUS 16 41 #define VIRTIO_NET_F_CTRL_VQ 17 42 #define VIRTIO_NET_F_CTRL_RX 18 43 #define VIRTIO_NET_F_CTRL_VLAN 19 44 #define VIRTIO_NET_F_CTRL_RX_EXTRA 20 45 #define VIRTIO_NET_F_GUEST_ANNOUNCE 21 46 #define VIRTIO_NET_F_MQ 22 47 #define VIRTIO_NET_F_CTRL_MAC_ADDR 23 48 #define VIRTIO_NET_F_HASH_REPORT 57 49 #define VIRTIO_NET_F_RSS 60 50 #define VIRTIO_NET_F_RSC_EXT 61 51 #define VIRTIO_NET_F_STANDBY 62 52 #define VIRTIO_NET_F_SPEED_DUPLEX 63 53 #ifndef VIRTIO_NET_NO_LEGACY 54 #define VIRTIO_NET_F_GSO 6 55 #endif 56 #define VIRTIO_NET_S_LINK_UP 1 57 #define VIRTIO_NET_S_ANNOUNCE 2 58 #define VIRTIO_NET_RSS_HASH_TYPE_IPv4 (1 << 0) 59 #define VIRTIO_NET_RSS_HASH_TYPE_TCPv4 (1 << 1) 60 #define VIRTIO_NET_RSS_HASH_TYPE_UDPv4 (1 << 2) 61 #define VIRTIO_NET_RSS_HASH_TYPE_IPv6 (1 << 3) 62 #define VIRTIO_NET_RSS_HASH_TYPE_TCPv6 (1 << 4) 63 #define VIRTIO_NET_RSS_HASH_TYPE_UDPv6 (1 << 5) 64 #define VIRTIO_NET_RSS_HASH_TYPE_IP_EX (1 << 6) 65 #define VIRTIO_NET_RSS_HASH_TYPE_TCP_EX (1 << 7) 66 #define VIRTIO_NET_RSS_HASH_TYPE_UDP_EX (1 << 8) 67 struct virtio_net_config { 68 __u8 mac[ETH_ALEN]; 69 __u16 status; 70 __u16 max_virtqueue_pairs; 71 __u16 mtu; 72 __u32 speed; 73 __u8 duplex; 74 __u8 rss_max_key_size; 75 __le16 rss_max_indirection_table_length; 76 __le32 supported_hash_types; 77 } __attribute__((packed)); 78 struct virtio_net_hdr_v1 { 79 #define VIRTIO_NET_HDR_F_NEEDS_CSUM 1 80 #define VIRTIO_NET_HDR_F_DATA_VALID 2 81 #define VIRTIO_NET_HDR_F_RSC_INFO 4 82 __u8 flags; 83 #define VIRTIO_NET_HDR_GSO_NONE 0 84 #define VIRTIO_NET_HDR_GSO_TCPV4 1 85 #define VIRTIO_NET_HDR_GSO_UDP 3 86 #define VIRTIO_NET_HDR_GSO_TCPV6 4 87 #define VIRTIO_NET_HDR_GSO_ECN 0x80 88 __u8 gso_type; 89 __virtio16 hdr_len; 90 __virtio16 gso_size; 91 union { 92 struct { 93 __virtio16 csum_start; 94 __virtio16 csum_offset; 95 }; 96 struct { 97 __virtio16 start; 98 __virtio16 offset; 99 } csum; 100 struct { 101 __le16 segments; 102 __le16 dup_acks; 103 } rsc; 104 }; 105 __virtio16 num_buffers; 106 }; 107 struct virtio_net_hdr_v1_hash { 108 struct virtio_net_hdr_v1 hdr; 109 __le32 hash_value; 110 #define VIRTIO_NET_HASH_REPORT_NONE 0 111 #define VIRTIO_NET_HASH_REPORT_IPv4 1 112 #define VIRTIO_NET_HASH_REPORT_TCPv4 2 113 #define VIRTIO_NET_HASH_REPORT_UDPv4 3 114 #define VIRTIO_NET_HASH_REPORT_IPv6 4 115 #define VIRTIO_NET_HASH_REPORT_TCPv6 5 116 #define VIRTIO_NET_HASH_REPORT_UDPv6 6 117 #define VIRTIO_NET_HASH_REPORT_IPv6_EX 7 118 #define VIRTIO_NET_HASH_REPORT_TCPv6_EX 8 119 #define VIRTIO_NET_HASH_REPORT_UDPv6_EX 9 120 __le16 hash_report; 121 __le16 padding; 122 }; 123 #ifndef VIRTIO_NET_NO_LEGACY 124 struct virtio_net_hdr { 125 __u8 flags; 126 __u8 gso_type; 127 __virtio16 hdr_len; 128 __virtio16 gso_size; 129 __virtio16 csum_start; 130 __virtio16 csum_offset; 131 }; 132 struct virtio_net_hdr_mrg_rxbuf { 133 struct virtio_net_hdr hdr; 134 __virtio16 num_buffers; 135 }; 136 #endif 137 struct virtio_net_ctrl_hdr { 138 __u8 class; 139 __u8 cmd; 140 } __attribute__((packed)); 141 typedef __u8 virtio_net_ctrl_ack; 142 #define VIRTIO_NET_OK 0 143 #define VIRTIO_NET_ERR 1 144 #define VIRTIO_NET_CTRL_RX 0 145 #define VIRTIO_NET_CTRL_RX_PROMISC 0 146 #define VIRTIO_NET_CTRL_RX_ALLMULTI 1 147 #define VIRTIO_NET_CTRL_RX_ALLUNI 2 148 #define VIRTIO_NET_CTRL_RX_NOMULTI 3 149 #define VIRTIO_NET_CTRL_RX_NOUNI 4 150 #define VIRTIO_NET_CTRL_RX_NOBCAST 5 151 struct virtio_net_ctrl_mac { 152 __virtio32 entries; 153 __u8 macs[][ETH_ALEN]; 154 } __attribute__((packed)); 155 #define VIRTIO_NET_CTRL_MAC 1 156 #define VIRTIO_NET_CTRL_MAC_TABLE_SET 0 157 #define VIRTIO_NET_CTRL_MAC_ADDR_SET 1 158 #define VIRTIO_NET_CTRL_VLAN 2 159 #define VIRTIO_NET_CTRL_VLAN_ADD 0 160 #define VIRTIO_NET_CTRL_VLAN_DEL 1 161 #define VIRTIO_NET_CTRL_ANNOUNCE 3 162 #define VIRTIO_NET_CTRL_ANNOUNCE_ACK 0 163 #define VIRTIO_NET_CTRL_MQ 4 164 struct virtio_net_ctrl_mq { 165 __virtio16 virtqueue_pairs; 166 }; 167 #define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET 0 168 #define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MIN 1 169 #define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MAX 0x8000 170 struct virtio_net_rss_config { 171 __le32 hash_types; 172 __le16 indirection_table_mask; 173 __le16 unclassified_queue; 174 __le16 indirection_table[1]; 175 __le16 max_tx_vq; 176 __u8 hash_key_length; 177 __u8 hash_key_data[]; 178 }; 179 #define VIRTIO_NET_CTRL_MQ_RSS_CONFIG 1 180 struct virtio_net_hash_config { 181 __le32 hash_types; 182 __le16 reserved[4]; 183 __u8 hash_key_length; 184 __u8 hash_key_data[]; 185 }; 186 #define VIRTIO_NET_CTRL_MQ_HASH_CONFIG 2 187 #define VIRTIO_NET_CTRL_GUEST_OFFLOADS 5 188 #define VIRTIO_NET_CTRL_GUEST_OFFLOADS_SET 0 189 #endif 190