1e5390783SAndre Przywara #ifndef _UAPI_LINUX_VIRTIO_NET_H 2e5390783SAndre Przywara #define _UAPI_LINUX_VIRTIO_NET_H 3a08bb43aSAndre Przywara /* This header is BSD licensed so anyone can use the definitions to implement 4a08bb43aSAndre Przywara * compatible drivers/servers. 5a08bb43aSAndre Przywara * 6a08bb43aSAndre Przywara * Redistribution and use in source and binary forms, with or without 7a08bb43aSAndre Przywara * modification, are permitted provided that the following conditions 8a08bb43aSAndre Przywara * are met: 9a08bb43aSAndre Przywara * 1. Redistributions of source code must retain the above copyright 10a08bb43aSAndre Przywara * notice, this list of conditions and the following disclaimer. 11a08bb43aSAndre Przywara * 2. Redistributions in binary form must reproduce the above copyright 12a08bb43aSAndre Przywara * notice, this list of conditions and the following disclaimer in the 13a08bb43aSAndre Przywara * documentation and/or other materials provided with the distribution. 14a08bb43aSAndre Przywara * 3. Neither the name of IBM nor the names of its contributors 15a08bb43aSAndre Przywara * may be used to endorse or promote products derived from this software 16a08bb43aSAndre Przywara * without specific prior written permission. 17a08bb43aSAndre Przywara * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND 18a08bb43aSAndre Przywara * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19a08bb43aSAndre Przywara * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20a08bb43aSAndre Przywara * ARE DISCLAIMED. IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE 21a08bb43aSAndre Przywara * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22a08bb43aSAndre Przywara * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23a08bb43aSAndre Przywara * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24a08bb43aSAndre Przywara * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25a08bb43aSAndre Przywara * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26a08bb43aSAndre Przywara * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27a08bb43aSAndre Przywara * SUCH DAMAGE. */ 28a08bb43aSAndre Przywara #include <linux/types.h> 29a08bb43aSAndre Przywara #include <linux/virtio_ids.h> 30a08bb43aSAndre Przywara #include <linux/virtio_config.h> 31e5390783SAndre Przywara #include <linux/virtio_types.h> 32a08bb43aSAndre Przywara #include <linux/if_ether.h> 33a08bb43aSAndre Przywara 34a08bb43aSAndre Przywara /* The feature bitmap for virtio net */ 35a08bb43aSAndre Przywara #define VIRTIO_NET_F_CSUM 0 /* Host handles pkts w/ partial csum */ 36a08bb43aSAndre Przywara #define VIRTIO_NET_F_GUEST_CSUM 1 /* Guest handles pkts w/ partial csum */ 37e5390783SAndre Przywara #define VIRTIO_NET_F_CTRL_GUEST_OFFLOADS 2 /* Dynamic offload configuration. */ 38e5390783SAndre Przywara #define VIRTIO_NET_F_MTU 3 /* Initial MTU advice */ 39a08bb43aSAndre Przywara #define VIRTIO_NET_F_MAC 5 /* Host has given MAC address. */ 40a08bb43aSAndre Przywara #define VIRTIO_NET_F_GUEST_TSO4 7 /* Guest can handle TSOv4 in. */ 41a08bb43aSAndre Przywara #define VIRTIO_NET_F_GUEST_TSO6 8 /* Guest can handle TSOv6 in. */ 42a08bb43aSAndre Przywara #define VIRTIO_NET_F_GUEST_ECN 9 /* Guest can handle TSO[6] w/ ECN in. */ 43a08bb43aSAndre Przywara #define VIRTIO_NET_F_GUEST_UFO 10 /* Guest can handle UFO in. */ 44a08bb43aSAndre Przywara #define VIRTIO_NET_F_HOST_TSO4 11 /* Host can handle TSOv4 in. */ 45a08bb43aSAndre Przywara #define VIRTIO_NET_F_HOST_TSO6 12 /* Host can handle TSOv6 in. */ 46a08bb43aSAndre Przywara #define VIRTIO_NET_F_HOST_ECN 13 /* Host can handle TSO[6] w/ ECN in. */ 47a08bb43aSAndre Przywara #define VIRTIO_NET_F_HOST_UFO 14 /* Host can handle UFO in. */ 48a08bb43aSAndre Przywara #define VIRTIO_NET_F_MRG_RXBUF 15 /* Host can merge receive buffers. */ 49a08bb43aSAndre Przywara #define VIRTIO_NET_F_STATUS 16 /* virtio_net_config.status available */ 50a08bb43aSAndre Przywara #define VIRTIO_NET_F_CTRL_VQ 17 /* Control channel available */ 51a08bb43aSAndre Przywara #define VIRTIO_NET_F_CTRL_RX 18 /* Control channel RX mode support */ 52a08bb43aSAndre Przywara #define VIRTIO_NET_F_CTRL_VLAN 19 /* Control channel VLAN filtering */ 53a08bb43aSAndre Przywara #define VIRTIO_NET_F_CTRL_RX_EXTRA 20 /* Extra RX mode control support */ 54a08bb43aSAndre Przywara #define VIRTIO_NET_F_GUEST_ANNOUNCE 21 /* Guest can announce device on the 55a08bb43aSAndre Przywara * network */ 56a08bb43aSAndre Przywara #define VIRTIO_NET_F_MQ 22 /* Device supports Receive Flow 57a08bb43aSAndre Przywara * Steering */ 58a08bb43aSAndre Przywara #define VIRTIO_NET_F_CTRL_MAC_ADDR 23 /* Set MAC address */ 5976dfc0cfSAnup Patel #define VIRTIO_NET_F_NOTF_COAL 53 /* Device supports notifications coalescing */ 60*be986824SAnup Patel #define VIRTIO_NET_F_GUEST_USO4 54 /* Guest can handle USOv4 in. */ 61*be986824SAnup Patel #define VIRTIO_NET_F_GUEST_USO6 55 /* Guest can handle USOv6 in. */ 62*be986824SAnup Patel #define VIRTIO_NET_F_HOST_USO 56 /* Host can handle USO in. */ 63e5390783SAndre Przywara #define VIRTIO_NET_F_HASH_REPORT 57 /* Supports hash report */ 64*be986824SAnup Patel #define VIRTIO_NET_F_GUEST_HDRLEN 59 /* Guest provides the exact hdr_len value. */ 65e5390783SAndre Przywara #define VIRTIO_NET_F_RSS 60 /* Supports RSS RX steering */ 66e5390783SAndre Przywara #define VIRTIO_NET_F_RSC_EXT 61 /* extended coalescing info */ 67e5390783SAndre Przywara #define VIRTIO_NET_F_STANDBY 62 /* Act as standby for another device 68e5390783SAndre Przywara * with the same MAC. 69e5390783SAndre Przywara */ 70e5390783SAndre Przywara #define VIRTIO_NET_F_SPEED_DUPLEX 63 /* Device set linkspeed and duplex */ 71e5390783SAndre Przywara 72e5390783SAndre Przywara #ifndef VIRTIO_NET_NO_LEGACY 73e5390783SAndre Przywara #define VIRTIO_NET_F_GSO 6 /* Host handles pkts w/ any GSO type */ 74e5390783SAndre Przywara #endif /* VIRTIO_NET_NO_LEGACY */ 75e5390783SAndre Przywara 76a08bb43aSAndre Przywara #define VIRTIO_NET_S_LINK_UP 1 /* Link is up */ 77a08bb43aSAndre Przywara #define VIRTIO_NET_S_ANNOUNCE 2 /* Announcement is needed */ 78a08bb43aSAndre Przywara 79e5390783SAndre Przywara /* supported/enabled hash types */ 80e5390783SAndre Przywara #define VIRTIO_NET_RSS_HASH_TYPE_IPv4 (1 << 0) 81e5390783SAndre Przywara #define VIRTIO_NET_RSS_HASH_TYPE_TCPv4 (1 << 1) 82e5390783SAndre Przywara #define VIRTIO_NET_RSS_HASH_TYPE_UDPv4 (1 << 2) 83e5390783SAndre Przywara #define VIRTIO_NET_RSS_HASH_TYPE_IPv6 (1 << 3) 84e5390783SAndre Przywara #define VIRTIO_NET_RSS_HASH_TYPE_TCPv6 (1 << 4) 85e5390783SAndre Przywara #define VIRTIO_NET_RSS_HASH_TYPE_UDPv6 (1 << 5) 86e5390783SAndre Przywara #define VIRTIO_NET_RSS_HASH_TYPE_IP_EX (1 << 6) 87e5390783SAndre Przywara #define VIRTIO_NET_RSS_HASH_TYPE_TCP_EX (1 << 7) 88e5390783SAndre Przywara #define VIRTIO_NET_RSS_HASH_TYPE_UDP_EX (1 << 8) 89e5390783SAndre Przywara 90a08bb43aSAndre Przywara struct virtio_net_config { 91a08bb43aSAndre Przywara /* The config defining mac address (if VIRTIO_NET_F_MAC) */ 92a08bb43aSAndre Przywara __u8 mac[ETH_ALEN]; 93a08bb43aSAndre Przywara /* See VIRTIO_NET_F_STATUS and VIRTIO_NET_S_* above */ 94e5390783SAndre Przywara __virtio16 status; 95a08bb43aSAndre Przywara /* Maximum number of each of transmit and receive queues; 96a08bb43aSAndre Przywara * see VIRTIO_NET_F_MQ and VIRTIO_NET_CTRL_MQ. 97a08bb43aSAndre Przywara * Legal values are between 1 and 0x8000 98a08bb43aSAndre Przywara */ 99e5390783SAndre Przywara __virtio16 max_virtqueue_pairs; 100e5390783SAndre Przywara /* Default maximum transmit unit advice */ 101e5390783SAndre Przywara __virtio16 mtu; 102e5390783SAndre Przywara /* 103e5390783SAndre Przywara * speed, in units of 1Mb. All values 0 to INT_MAX are legal. 104e5390783SAndre Przywara * Any other value stands for unknown. 105e5390783SAndre Przywara */ 106e5390783SAndre Przywara __le32 speed; 107e5390783SAndre Przywara /* 108e5390783SAndre Przywara * 0x00 - half duplex 109e5390783SAndre Przywara * 0x01 - full duplex 110e5390783SAndre Przywara * Any other value stands for unknown. 111e5390783SAndre Przywara */ 112e5390783SAndre Przywara __u8 duplex; 113e5390783SAndre Przywara /* maximum size of RSS key */ 114e5390783SAndre Przywara __u8 rss_max_key_size; 115e5390783SAndre Przywara /* maximum number of indirection table entries */ 116e5390783SAndre Przywara __le16 rss_max_indirection_table_length; 117e5390783SAndre Przywara /* bitmask of supported VIRTIO_NET_RSS_HASH_ types */ 118e5390783SAndre Przywara __le32 supported_hash_types; 119a08bb43aSAndre Przywara } __attribute__((packed)); 120a08bb43aSAndre Przywara 121e5390783SAndre Przywara /* 122e5390783SAndre Przywara * This header comes first in the scatter-gather list. If you don't 123e5390783SAndre Przywara * specify GSO or CSUM features, you can simply ignore the header. 124e5390783SAndre Przywara * 125e5390783SAndre Przywara * This is bitwise-equivalent to the legacy struct virtio_net_hdr_mrg_rxbuf, 126e5390783SAndre Przywara * only flattened. 127e5390783SAndre Przywara */ 128e5390783SAndre Przywara struct virtio_net_hdr_v1 { 129e5390783SAndre Przywara #define VIRTIO_NET_HDR_F_NEEDS_CSUM 1 /* Use csum_start, csum_offset */ 130e5390783SAndre Przywara #define VIRTIO_NET_HDR_F_DATA_VALID 2 /* Csum is valid */ 131e5390783SAndre Przywara #define VIRTIO_NET_HDR_F_RSC_INFO 4 /* rsc info in csum_ fields */ 132e5390783SAndre Przywara __u8 flags; 133e5390783SAndre Przywara #define VIRTIO_NET_HDR_GSO_NONE 0 /* Not a GSO frame */ 134e5390783SAndre Przywara #define VIRTIO_NET_HDR_GSO_TCPV4 1 /* GSO frame, IPv4 TCP (TSO) */ 135e5390783SAndre Przywara #define VIRTIO_NET_HDR_GSO_UDP 3 /* GSO frame, IPv4 UDP (UFO) */ 136e5390783SAndre Przywara #define VIRTIO_NET_HDR_GSO_TCPV6 4 /* GSO frame, IPv6 TCP */ 137*be986824SAnup Patel #define VIRTIO_NET_HDR_GSO_UDP_L4 5 /* GSO frame, IPv4& IPv6 UDP (USO) */ 138e5390783SAndre Przywara #define VIRTIO_NET_HDR_GSO_ECN 0x80 /* TCP has ECN set */ 139e5390783SAndre Przywara __u8 gso_type; 140e5390783SAndre Przywara __virtio16 hdr_len; /* Ethernet + IP + tcp/udp hdrs */ 141e5390783SAndre Przywara __virtio16 gso_size; /* Bytes to append to hdr_len per frame */ 142e5390783SAndre Przywara union { 143e5390783SAndre Przywara struct { 144e5390783SAndre Przywara __virtio16 csum_start; 145e5390783SAndre Przywara __virtio16 csum_offset; 146e5390783SAndre Przywara }; 147e5390783SAndre Przywara /* Checksum calculation */ 148e5390783SAndre Przywara struct { 149e5390783SAndre Przywara /* Position to start checksumming from */ 150e5390783SAndre Przywara __virtio16 start; 151e5390783SAndre Przywara /* Offset after that to place checksum */ 152e5390783SAndre Przywara __virtio16 offset; 153e5390783SAndre Przywara } csum; 154e5390783SAndre Przywara /* Receive Segment Coalescing */ 155e5390783SAndre Przywara struct { 156e5390783SAndre Przywara /* Number of coalesced segments */ 157e5390783SAndre Przywara __le16 segments; 158e5390783SAndre Przywara /* Number of duplicated acks */ 159e5390783SAndre Przywara __le16 dup_acks; 160e5390783SAndre Przywara } rsc; 161e5390783SAndre Przywara }; 162e5390783SAndre Przywara __virtio16 num_buffers; /* Number of merged rx buffers */ 163e5390783SAndre Przywara }; 164e5390783SAndre Przywara 165e5390783SAndre Przywara struct virtio_net_hdr_v1_hash { 166e5390783SAndre Przywara struct virtio_net_hdr_v1 hdr; 167e5390783SAndre Przywara __le32 hash_value; 168e5390783SAndre Przywara #define VIRTIO_NET_HASH_REPORT_NONE 0 169e5390783SAndre Przywara #define VIRTIO_NET_HASH_REPORT_IPv4 1 170e5390783SAndre Przywara #define VIRTIO_NET_HASH_REPORT_TCPv4 2 171e5390783SAndre Przywara #define VIRTIO_NET_HASH_REPORT_UDPv4 3 172e5390783SAndre Przywara #define VIRTIO_NET_HASH_REPORT_IPv6 4 173e5390783SAndre Przywara #define VIRTIO_NET_HASH_REPORT_TCPv6 5 174e5390783SAndre Przywara #define VIRTIO_NET_HASH_REPORT_UDPv6 6 175e5390783SAndre Przywara #define VIRTIO_NET_HASH_REPORT_IPv6_EX 7 176e5390783SAndre Przywara #define VIRTIO_NET_HASH_REPORT_TCPv6_EX 8 177e5390783SAndre Przywara #define VIRTIO_NET_HASH_REPORT_UDPv6_EX 9 178e5390783SAndre Przywara __le16 hash_report; 179e5390783SAndre Przywara __le16 padding; 180e5390783SAndre Przywara }; 181e5390783SAndre Przywara 182e5390783SAndre Przywara #ifndef VIRTIO_NET_NO_LEGACY 183a08bb43aSAndre Przywara /* This header comes first in the scatter-gather list. 184e5390783SAndre Przywara * For legacy virtio, if VIRTIO_F_ANY_LAYOUT is not negotiated, it must 185a08bb43aSAndre Przywara * be the first element of the scatter-gather list. If you don't 186a08bb43aSAndre Przywara * specify GSO or CSUM features, you can simply ignore the header. */ 187a08bb43aSAndre Przywara struct virtio_net_hdr { 188e5390783SAndre Przywara /* See VIRTIO_NET_HDR_F_* */ 189a08bb43aSAndre Przywara __u8 flags; 190e5390783SAndre Przywara /* See VIRTIO_NET_HDR_GSO_* */ 191a08bb43aSAndre Przywara __u8 gso_type; 192e5390783SAndre Przywara __virtio16 hdr_len; /* Ethernet + IP + tcp/udp hdrs */ 193e5390783SAndre Przywara __virtio16 gso_size; /* Bytes to append to hdr_len per frame */ 194e5390783SAndre Przywara __virtio16 csum_start; /* Position to start checksumming from */ 195e5390783SAndre Przywara __virtio16 csum_offset; /* Offset after that to place checksum */ 196a08bb43aSAndre Przywara }; 197a08bb43aSAndre Przywara 198a08bb43aSAndre Przywara /* This is the version of the header to use when the MRG_RXBUF 199a08bb43aSAndre Przywara * feature has been negotiated. */ 200a08bb43aSAndre Przywara struct virtio_net_hdr_mrg_rxbuf { 201a08bb43aSAndre Przywara struct virtio_net_hdr hdr; 202e5390783SAndre Przywara __virtio16 num_buffers; /* Number of merged rx buffers */ 203a08bb43aSAndre Przywara }; 204e5390783SAndre Przywara #endif /* ...VIRTIO_NET_NO_LEGACY */ 205a08bb43aSAndre Przywara 206a08bb43aSAndre Przywara /* 207a08bb43aSAndre Przywara * Control virtqueue data structures 208a08bb43aSAndre Przywara * 209a08bb43aSAndre Przywara * The control virtqueue expects a header in the first sg entry 210a08bb43aSAndre Przywara * and an ack/status response in the last entry. Data for the 211a08bb43aSAndre Przywara * command goes in between. 212a08bb43aSAndre Przywara */ 213a08bb43aSAndre Przywara struct virtio_net_ctrl_hdr { 214a08bb43aSAndre Przywara __u8 class; 215a08bb43aSAndre Przywara __u8 cmd; 216a08bb43aSAndre Przywara } __attribute__((packed)); 217a08bb43aSAndre Przywara 218a08bb43aSAndre Przywara typedef __u8 virtio_net_ctrl_ack; 219a08bb43aSAndre Przywara 220a08bb43aSAndre Przywara #define VIRTIO_NET_OK 0 221a08bb43aSAndre Przywara #define VIRTIO_NET_ERR 1 222a08bb43aSAndre Przywara 223a08bb43aSAndre Przywara /* 224a08bb43aSAndre Przywara * Control the RX mode, ie. promisucous, allmulti, etc... 225a08bb43aSAndre Przywara * All commands require an "out" sg entry containing a 1 byte 226a08bb43aSAndre Przywara * state value, zero = disable, non-zero = enable. Commands 227a08bb43aSAndre Przywara * 0 and 1 are supported with the VIRTIO_NET_F_CTRL_RX feature. 228a08bb43aSAndre Przywara * Commands 2-5 are added with VIRTIO_NET_F_CTRL_RX_EXTRA. 229a08bb43aSAndre Przywara */ 230a08bb43aSAndre Przywara #define VIRTIO_NET_CTRL_RX 0 231a08bb43aSAndre Przywara #define VIRTIO_NET_CTRL_RX_PROMISC 0 232a08bb43aSAndre Przywara #define VIRTIO_NET_CTRL_RX_ALLMULTI 1 233a08bb43aSAndre Przywara #define VIRTIO_NET_CTRL_RX_ALLUNI 2 234a08bb43aSAndre Przywara #define VIRTIO_NET_CTRL_RX_NOMULTI 3 235a08bb43aSAndre Przywara #define VIRTIO_NET_CTRL_RX_NOUNI 4 236a08bb43aSAndre Przywara #define VIRTIO_NET_CTRL_RX_NOBCAST 5 237a08bb43aSAndre Przywara 238a08bb43aSAndre Przywara /* 239a08bb43aSAndre Przywara * Control the MAC 240a08bb43aSAndre Przywara * 241a08bb43aSAndre Przywara * The MAC filter table is managed by the hypervisor, the guest should 242a08bb43aSAndre Przywara * assume the size is infinite. Filtering should be considered 243a08bb43aSAndre Przywara * non-perfect, ie. based on hypervisor resources, the guest may 244a08bb43aSAndre Przywara * received packets from sources not specified in the filter list. 245a08bb43aSAndre Przywara * 246a08bb43aSAndre Przywara * In addition to the class/cmd header, the TABLE_SET command requires 247a08bb43aSAndre Przywara * two out scatterlists. Each contains a 4 byte count of entries followed 248a08bb43aSAndre Przywara * by a concatenated byte stream of the ETH_ALEN MAC addresses. The 249a08bb43aSAndre Przywara * first sg list contains unicast addresses, the second is for multicast. 250a08bb43aSAndre Przywara * This functionality is present if the VIRTIO_NET_F_CTRL_RX feature 251a08bb43aSAndre Przywara * is available. 252a08bb43aSAndre Przywara * 253a08bb43aSAndre Przywara * The ADDR_SET command requests one out scatterlist, it contains a 254a08bb43aSAndre Przywara * 6 bytes MAC address. This functionality is present if the 255a08bb43aSAndre Przywara * VIRTIO_NET_F_CTRL_MAC_ADDR feature is available. 256a08bb43aSAndre Przywara */ 257a08bb43aSAndre Przywara struct virtio_net_ctrl_mac { 258e5390783SAndre Przywara __virtio32 entries; 259a08bb43aSAndre Przywara __u8 macs[][ETH_ALEN]; 260a08bb43aSAndre Przywara } __attribute__((packed)); 261a08bb43aSAndre Przywara 262a08bb43aSAndre Przywara #define VIRTIO_NET_CTRL_MAC 1 263a08bb43aSAndre Przywara #define VIRTIO_NET_CTRL_MAC_TABLE_SET 0 264a08bb43aSAndre Przywara #define VIRTIO_NET_CTRL_MAC_ADDR_SET 1 265a08bb43aSAndre Przywara 266a08bb43aSAndre Przywara /* 267a08bb43aSAndre Przywara * Control VLAN filtering 268a08bb43aSAndre Przywara * 269a08bb43aSAndre Przywara * The VLAN filter table is controlled via a simple ADD/DEL interface. 270a08bb43aSAndre Przywara * VLAN IDs not added may be filterd by the hypervisor. Del is the 271a08bb43aSAndre Przywara * opposite of add. Both commands expect an out entry containing a 2 272a08bb43aSAndre Przywara * byte VLAN ID. VLAN filterting is available with the 273a08bb43aSAndre Przywara * VIRTIO_NET_F_CTRL_VLAN feature bit. 274a08bb43aSAndre Przywara */ 275a08bb43aSAndre Przywara #define VIRTIO_NET_CTRL_VLAN 2 276a08bb43aSAndre Przywara #define VIRTIO_NET_CTRL_VLAN_ADD 0 277a08bb43aSAndre Przywara #define VIRTIO_NET_CTRL_VLAN_DEL 1 278a08bb43aSAndre Przywara 279a08bb43aSAndre Przywara /* 280a08bb43aSAndre Przywara * Control link announce acknowledgement 281a08bb43aSAndre Przywara * 282a08bb43aSAndre Przywara * The command VIRTIO_NET_CTRL_ANNOUNCE_ACK is used to indicate that 283a08bb43aSAndre Przywara * driver has recevied the notification; device would clear the 284a08bb43aSAndre Przywara * VIRTIO_NET_S_ANNOUNCE bit in the status field after it receives 285a08bb43aSAndre Przywara * this command. 286a08bb43aSAndre Przywara */ 287a08bb43aSAndre Przywara #define VIRTIO_NET_CTRL_ANNOUNCE 3 288a08bb43aSAndre Przywara #define VIRTIO_NET_CTRL_ANNOUNCE_ACK 0 289a08bb43aSAndre Przywara 290a08bb43aSAndre Przywara /* 291a08bb43aSAndre Przywara * Control Receive Flow Steering 292e5390783SAndre Przywara */ 293e5390783SAndre Przywara #define VIRTIO_NET_CTRL_MQ 4 294e5390783SAndre Przywara /* 295a08bb43aSAndre Przywara * The command VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET 296a08bb43aSAndre Przywara * enables Receive Flow Steering, specifying the number of the transmit and 297a08bb43aSAndre Przywara * receive queues that will be used. After the command is consumed and acked by 298a08bb43aSAndre Przywara * the device, the device will not steer new packets on receive virtqueues 299a08bb43aSAndre Przywara * other than specified nor read from transmit virtqueues other than specified. 300a08bb43aSAndre Przywara * Accordingly, driver should not transmit new packets on virtqueues other than 301a08bb43aSAndre Przywara * specified. 302a08bb43aSAndre Przywara */ 303a08bb43aSAndre Przywara struct virtio_net_ctrl_mq { 304e5390783SAndre Przywara __virtio16 virtqueue_pairs; 305a08bb43aSAndre Przywara }; 306a08bb43aSAndre Przywara 307a08bb43aSAndre Przywara #define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET 0 308a08bb43aSAndre Przywara #define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MIN 1 309a08bb43aSAndre Przywara #define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MAX 0x8000 310a08bb43aSAndre Przywara 311e5390783SAndre Przywara /* 312e5390783SAndre Przywara * The command VIRTIO_NET_CTRL_MQ_RSS_CONFIG has the same effect as 313e5390783SAndre Przywara * VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET does and additionally configures 314e5390783SAndre Przywara * the receive steering to use a hash calculated for incoming packet 315e5390783SAndre Przywara * to decide on receive virtqueue to place the packet. The command 316e5390783SAndre Przywara * also provides parameters to calculate a hash and receive virtqueue. 317e5390783SAndre Przywara */ 318e5390783SAndre Przywara struct virtio_net_rss_config { 319e5390783SAndre Przywara __le32 hash_types; 320e5390783SAndre Przywara __le16 indirection_table_mask; 321e5390783SAndre Przywara __le16 unclassified_queue; 322e5390783SAndre Przywara __le16 indirection_table[1/* + indirection_table_mask */]; 323e5390783SAndre Przywara __le16 max_tx_vq; 324e5390783SAndre Przywara __u8 hash_key_length; 325e5390783SAndre Przywara __u8 hash_key_data[/* hash_key_length */]; 326e5390783SAndre Przywara }; 327e5390783SAndre Przywara 328e5390783SAndre Przywara #define VIRTIO_NET_CTRL_MQ_RSS_CONFIG 1 329e5390783SAndre Przywara 330e5390783SAndre Przywara /* 331e5390783SAndre Przywara * The command VIRTIO_NET_CTRL_MQ_HASH_CONFIG requests the device 332e5390783SAndre Przywara * to include in the virtio header of the packet the value of the 333e5390783SAndre Przywara * calculated hash and the report type of hash. It also provides 334e5390783SAndre Przywara * parameters for hash calculation. The command requires feature 335e5390783SAndre Przywara * VIRTIO_NET_F_HASH_REPORT to be negotiated to extend the 336e5390783SAndre Przywara * layout of virtio header as defined in virtio_net_hdr_v1_hash. 337e5390783SAndre Przywara */ 338e5390783SAndre Przywara struct virtio_net_hash_config { 339e5390783SAndre Przywara __le32 hash_types; 340e5390783SAndre Przywara /* for compatibility with virtio_net_rss_config */ 341e5390783SAndre Przywara __le16 reserved[4]; 342e5390783SAndre Przywara __u8 hash_key_length; 343e5390783SAndre Przywara __u8 hash_key_data[/* hash_key_length */]; 344e5390783SAndre Przywara }; 345e5390783SAndre Przywara 346e5390783SAndre Przywara #define VIRTIO_NET_CTRL_MQ_HASH_CONFIG 2 347e5390783SAndre Przywara 348e5390783SAndre Przywara /* 349e5390783SAndre Przywara * Control network offloads 350e5390783SAndre Przywara * 351e5390783SAndre Przywara * Reconfigures the network offloads that Guest can handle. 352e5390783SAndre Przywara * 353e5390783SAndre Przywara * Available with the VIRTIO_NET_F_CTRL_GUEST_OFFLOADS feature bit. 354e5390783SAndre Przywara * 355e5390783SAndre Przywara * Command data format matches the feature bit mask exactly. 356e5390783SAndre Przywara * 357e5390783SAndre Przywara * See VIRTIO_NET_F_GUEST_* for the list of offloads 358e5390783SAndre Przywara * that can be enabled/disabled. 359e5390783SAndre Przywara */ 360e5390783SAndre Przywara #define VIRTIO_NET_CTRL_GUEST_OFFLOADS 5 361e5390783SAndre Przywara #define VIRTIO_NET_CTRL_GUEST_OFFLOADS_SET 0 362e5390783SAndre Przywara 3638d0facecSAnup Patel /* 3648d0facecSAnup Patel * Control notifications coalescing. 3658d0facecSAnup Patel * 3668d0facecSAnup Patel * Request the device to change the notifications coalescing parameters. 3678d0facecSAnup Patel * 3688d0facecSAnup Patel * Available with the VIRTIO_NET_F_NOTF_COAL feature bit. 3698d0facecSAnup Patel */ 3708d0facecSAnup Patel #define VIRTIO_NET_CTRL_NOTF_COAL 6 3718d0facecSAnup Patel /* 37276dfc0cfSAnup Patel * Set the tx-usecs/tx-max-packets parameters. 3738d0facecSAnup Patel */ 3748d0facecSAnup Patel struct virtio_net_ctrl_coal_tx { 37576dfc0cfSAnup Patel /* Maximum number of packets to send before a TX notification */ 3768d0facecSAnup Patel __le32 tx_max_packets; 37776dfc0cfSAnup Patel /* Maximum number of usecs to delay a TX notification */ 3788d0facecSAnup Patel __le32 tx_usecs; 3798d0facecSAnup Patel }; 3808d0facecSAnup Patel 3818d0facecSAnup Patel #define VIRTIO_NET_CTRL_NOTF_COAL_TX_SET 0 3828d0facecSAnup Patel 3838d0facecSAnup Patel /* 38476dfc0cfSAnup Patel * Set the rx-usecs/rx-max-packets parameters. 3858d0facecSAnup Patel */ 3868d0facecSAnup Patel struct virtio_net_ctrl_coal_rx { 38776dfc0cfSAnup Patel /* Maximum number of packets to receive before a RX notification */ 3888d0facecSAnup Patel __le32 rx_max_packets; 38976dfc0cfSAnup Patel /* Maximum number of usecs to delay a RX notification */ 3908d0facecSAnup Patel __le32 rx_usecs; 3918d0facecSAnup Patel }; 3928d0facecSAnup Patel 3938d0facecSAnup Patel #define VIRTIO_NET_CTRL_NOTF_COAL_RX_SET 1 3948d0facecSAnup Patel 395e5390783SAndre Przywara #endif /* _UAPI_LINUX_VIRTIO_NET_H */ 396