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 */ 59*8d0facecSAnup Patel #define VIRTIO_NET_F_NOTF_COAL 53 /* Guest can handle notifications coalescing */ 60e5390783SAndre Przywara #define VIRTIO_NET_F_HASH_REPORT 57 /* Supports hash report */ 61e5390783SAndre Przywara #define VIRTIO_NET_F_RSS 60 /* Supports RSS RX steering */ 62e5390783SAndre Przywara #define VIRTIO_NET_F_RSC_EXT 61 /* extended coalescing info */ 63e5390783SAndre Przywara #define VIRTIO_NET_F_STANDBY 62 /* Act as standby for another device 64e5390783SAndre Przywara * with the same MAC. 65e5390783SAndre Przywara */ 66e5390783SAndre Przywara #define VIRTIO_NET_F_SPEED_DUPLEX 63 /* Device set linkspeed and duplex */ 67e5390783SAndre Przywara 68e5390783SAndre Przywara #ifndef VIRTIO_NET_NO_LEGACY 69e5390783SAndre Przywara #define VIRTIO_NET_F_GSO 6 /* Host handles pkts w/ any GSO type */ 70e5390783SAndre Przywara #endif /* VIRTIO_NET_NO_LEGACY */ 71e5390783SAndre Przywara 72a08bb43aSAndre Przywara #define VIRTIO_NET_S_LINK_UP 1 /* Link is up */ 73a08bb43aSAndre Przywara #define VIRTIO_NET_S_ANNOUNCE 2 /* Announcement is needed */ 74a08bb43aSAndre Przywara 75e5390783SAndre Przywara /* supported/enabled hash types */ 76e5390783SAndre Przywara #define VIRTIO_NET_RSS_HASH_TYPE_IPv4 (1 << 0) 77e5390783SAndre Przywara #define VIRTIO_NET_RSS_HASH_TYPE_TCPv4 (1 << 1) 78e5390783SAndre Przywara #define VIRTIO_NET_RSS_HASH_TYPE_UDPv4 (1 << 2) 79e5390783SAndre Przywara #define VIRTIO_NET_RSS_HASH_TYPE_IPv6 (1 << 3) 80e5390783SAndre Przywara #define VIRTIO_NET_RSS_HASH_TYPE_TCPv6 (1 << 4) 81e5390783SAndre Przywara #define VIRTIO_NET_RSS_HASH_TYPE_UDPv6 (1 << 5) 82e5390783SAndre Przywara #define VIRTIO_NET_RSS_HASH_TYPE_IP_EX (1 << 6) 83e5390783SAndre Przywara #define VIRTIO_NET_RSS_HASH_TYPE_TCP_EX (1 << 7) 84e5390783SAndre Przywara #define VIRTIO_NET_RSS_HASH_TYPE_UDP_EX (1 << 8) 85e5390783SAndre Przywara 86a08bb43aSAndre Przywara struct virtio_net_config { 87a08bb43aSAndre Przywara /* The config defining mac address (if VIRTIO_NET_F_MAC) */ 88a08bb43aSAndre Przywara __u8 mac[ETH_ALEN]; 89a08bb43aSAndre Przywara /* See VIRTIO_NET_F_STATUS and VIRTIO_NET_S_* above */ 90e5390783SAndre Przywara __virtio16 status; 91a08bb43aSAndre Przywara /* Maximum number of each of transmit and receive queues; 92a08bb43aSAndre Przywara * see VIRTIO_NET_F_MQ and VIRTIO_NET_CTRL_MQ. 93a08bb43aSAndre Przywara * Legal values are between 1 and 0x8000 94a08bb43aSAndre Przywara */ 95e5390783SAndre Przywara __virtio16 max_virtqueue_pairs; 96e5390783SAndre Przywara /* Default maximum transmit unit advice */ 97e5390783SAndre Przywara __virtio16 mtu; 98e5390783SAndre Przywara /* 99e5390783SAndre Przywara * speed, in units of 1Mb. All values 0 to INT_MAX are legal. 100e5390783SAndre Przywara * Any other value stands for unknown. 101e5390783SAndre Przywara */ 102e5390783SAndre Przywara __le32 speed; 103e5390783SAndre Przywara /* 104e5390783SAndre Przywara * 0x00 - half duplex 105e5390783SAndre Przywara * 0x01 - full duplex 106e5390783SAndre Przywara * Any other value stands for unknown. 107e5390783SAndre Przywara */ 108e5390783SAndre Przywara __u8 duplex; 109e5390783SAndre Przywara /* maximum size of RSS key */ 110e5390783SAndre Przywara __u8 rss_max_key_size; 111e5390783SAndre Przywara /* maximum number of indirection table entries */ 112e5390783SAndre Przywara __le16 rss_max_indirection_table_length; 113e5390783SAndre Przywara /* bitmask of supported VIRTIO_NET_RSS_HASH_ types */ 114e5390783SAndre Przywara __le32 supported_hash_types; 115a08bb43aSAndre Przywara } __attribute__((packed)); 116a08bb43aSAndre Przywara 117e5390783SAndre Przywara /* 118e5390783SAndre Przywara * This header comes first in the scatter-gather list. If you don't 119e5390783SAndre Przywara * specify GSO or CSUM features, you can simply ignore the header. 120e5390783SAndre Przywara * 121e5390783SAndre Przywara * This is bitwise-equivalent to the legacy struct virtio_net_hdr_mrg_rxbuf, 122e5390783SAndre Przywara * only flattened. 123e5390783SAndre Przywara */ 124e5390783SAndre Przywara struct virtio_net_hdr_v1 { 125e5390783SAndre Przywara #define VIRTIO_NET_HDR_F_NEEDS_CSUM 1 /* Use csum_start, csum_offset */ 126e5390783SAndre Przywara #define VIRTIO_NET_HDR_F_DATA_VALID 2 /* Csum is valid */ 127e5390783SAndre Przywara #define VIRTIO_NET_HDR_F_RSC_INFO 4 /* rsc info in csum_ fields */ 128e5390783SAndre Przywara __u8 flags; 129e5390783SAndre Przywara #define VIRTIO_NET_HDR_GSO_NONE 0 /* Not a GSO frame */ 130e5390783SAndre Przywara #define VIRTIO_NET_HDR_GSO_TCPV4 1 /* GSO frame, IPv4 TCP (TSO) */ 131e5390783SAndre Przywara #define VIRTIO_NET_HDR_GSO_UDP 3 /* GSO frame, IPv4 UDP (UFO) */ 132e5390783SAndre Przywara #define VIRTIO_NET_HDR_GSO_TCPV6 4 /* GSO frame, IPv6 TCP */ 133e5390783SAndre Przywara #define VIRTIO_NET_HDR_GSO_ECN 0x80 /* TCP has ECN set */ 134e5390783SAndre Przywara __u8 gso_type; 135e5390783SAndre Przywara __virtio16 hdr_len; /* Ethernet + IP + tcp/udp hdrs */ 136e5390783SAndre Przywara __virtio16 gso_size; /* Bytes to append to hdr_len per frame */ 137e5390783SAndre Przywara union { 138e5390783SAndre Przywara struct { 139e5390783SAndre Przywara __virtio16 csum_start; 140e5390783SAndre Przywara __virtio16 csum_offset; 141e5390783SAndre Przywara }; 142e5390783SAndre Przywara /* Checksum calculation */ 143e5390783SAndre Przywara struct { 144e5390783SAndre Przywara /* Position to start checksumming from */ 145e5390783SAndre Przywara __virtio16 start; 146e5390783SAndre Przywara /* Offset after that to place checksum */ 147e5390783SAndre Przywara __virtio16 offset; 148e5390783SAndre Przywara } csum; 149e5390783SAndre Przywara /* Receive Segment Coalescing */ 150e5390783SAndre Przywara struct { 151e5390783SAndre Przywara /* Number of coalesced segments */ 152e5390783SAndre Przywara __le16 segments; 153e5390783SAndre Przywara /* Number of duplicated acks */ 154e5390783SAndre Przywara __le16 dup_acks; 155e5390783SAndre Przywara } rsc; 156e5390783SAndre Przywara }; 157e5390783SAndre Przywara __virtio16 num_buffers; /* Number of merged rx buffers */ 158e5390783SAndre Przywara }; 159e5390783SAndre Przywara 160e5390783SAndre Przywara struct virtio_net_hdr_v1_hash { 161e5390783SAndre Przywara struct virtio_net_hdr_v1 hdr; 162e5390783SAndre Przywara __le32 hash_value; 163e5390783SAndre Przywara #define VIRTIO_NET_HASH_REPORT_NONE 0 164e5390783SAndre Przywara #define VIRTIO_NET_HASH_REPORT_IPv4 1 165e5390783SAndre Przywara #define VIRTIO_NET_HASH_REPORT_TCPv4 2 166e5390783SAndre Przywara #define VIRTIO_NET_HASH_REPORT_UDPv4 3 167e5390783SAndre Przywara #define VIRTIO_NET_HASH_REPORT_IPv6 4 168e5390783SAndre Przywara #define VIRTIO_NET_HASH_REPORT_TCPv6 5 169e5390783SAndre Przywara #define VIRTIO_NET_HASH_REPORT_UDPv6 6 170e5390783SAndre Przywara #define VIRTIO_NET_HASH_REPORT_IPv6_EX 7 171e5390783SAndre Przywara #define VIRTIO_NET_HASH_REPORT_TCPv6_EX 8 172e5390783SAndre Przywara #define VIRTIO_NET_HASH_REPORT_UDPv6_EX 9 173e5390783SAndre Przywara __le16 hash_report; 174e5390783SAndre Przywara __le16 padding; 175e5390783SAndre Przywara }; 176e5390783SAndre Przywara 177e5390783SAndre Przywara #ifndef VIRTIO_NET_NO_LEGACY 178a08bb43aSAndre Przywara /* This header comes first in the scatter-gather list. 179e5390783SAndre Przywara * For legacy virtio, if VIRTIO_F_ANY_LAYOUT is not negotiated, it must 180a08bb43aSAndre Przywara * be the first element of the scatter-gather list. If you don't 181a08bb43aSAndre Przywara * specify GSO or CSUM features, you can simply ignore the header. */ 182a08bb43aSAndre Przywara struct virtio_net_hdr { 183e5390783SAndre Przywara /* See VIRTIO_NET_HDR_F_* */ 184a08bb43aSAndre Przywara __u8 flags; 185e5390783SAndre Przywara /* See VIRTIO_NET_HDR_GSO_* */ 186a08bb43aSAndre Przywara __u8 gso_type; 187e5390783SAndre Przywara __virtio16 hdr_len; /* Ethernet + IP + tcp/udp hdrs */ 188e5390783SAndre Przywara __virtio16 gso_size; /* Bytes to append to hdr_len per frame */ 189e5390783SAndre Przywara __virtio16 csum_start; /* Position to start checksumming from */ 190e5390783SAndre Przywara __virtio16 csum_offset; /* Offset after that to place checksum */ 191a08bb43aSAndre Przywara }; 192a08bb43aSAndre Przywara 193a08bb43aSAndre Przywara /* This is the version of the header to use when the MRG_RXBUF 194a08bb43aSAndre Przywara * feature has been negotiated. */ 195a08bb43aSAndre Przywara struct virtio_net_hdr_mrg_rxbuf { 196a08bb43aSAndre Przywara struct virtio_net_hdr hdr; 197e5390783SAndre Przywara __virtio16 num_buffers; /* Number of merged rx buffers */ 198a08bb43aSAndre Przywara }; 199e5390783SAndre Przywara #endif /* ...VIRTIO_NET_NO_LEGACY */ 200a08bb43aSAndre Przywara 201a08bb43aSAndre Przywara /* 202a08bb43aSAndre Przywara * Control virtqueue data structures 203a08bb43aSAndre Przywara * 204a08bb43aSAndre Przywara * The control virtqueue expects a header in the first sg entry 205a08bb43aSAndre Przywara * and an ack/status response in the last entry. Data for the 206a08bb43aSAndre Przywara * command goes in between. 207a08bb43aSAndre Przywara */ 208a08bb43aSAndre Przywara struct virtio_net_ctrl_hdr { 209a08bb43aSAndre Przywara __u8 class; 210a08bb43aSAndre Przywara __u8 cmd; 211a08bb43aSAndre Przywara } __attribute__((packed)); 212a08bb43aSAndre Przywara 213a08bb43aSAndre Przywara typedef __u8 virtio_net_ctrl_ack; 214a08bb43aSAndre Przywara 215a08bb43aSAndre Przywara #define VIRTIO_NET_OK 0 216a08bb43aSAndre Przywara #define VIRTIO_NET_ERR 1 217a08bb43aSAndre Przywara 218a08bb43aSAndre Przywara /* 219a08bb43aSAndre Przywara * Control the RX mode, ie. promisucous, allmulti, etc... 220a08bb43aSAndre Przywara * All commands require an "out" sg entry containing a 1 byte 221a08bb43aSAndre Przywara * state value, zero = disable, non-zero = enable. Commands 222a08bb43aSAndre Przywara * 0 and 1 are supported with the VIRTIO_NET_F_CTRL_RX feature. 223a08bb43aSAndre Przywara * Commands 2-5 are added with VIRTIO_NET_F_CTRL_RX_EXTRA. 224a08bb43aSAndre Przywara */ 225a08bb43aSAndre Przywara #define VIRTIO_NET_CTRL_RX 0 226a08bb43aSAndre Przywara #define VIRTIO_NET_CTRL_RX_PROMISC 0 227a08bb43aSAndre Przywara #define VIRTIO_NET_CTRL_RX_ALLMULTI 1 228a08bb43aSAndre Przywara #define VIRTIO_NET_CTRL_RX_ALLUNI 2 229a08bb43aSAndre Przywara #define VIRTIO_NET_CTRL_RX_NOMULTI 3 230a08bb43aSAndre Przywara #define VIRTIO_NET_CTRL_RX_NOUNI 4 231a08bb43aSAndre Przywara #define VIRTIO_NET_CTRL_RX_NOBCAST 5 232a08bb43aSAndre Przywara 233a08bb43aSAndre Przywara /* 234a08bb43aSAndre Przywara * Control the MAC 235a08bb43aSAndre Przywara * 236a08bb43aSAndre Przywara * The MAC filter table is managed by the hypervisor, the guest should 237a08bb43aSAndre Przywara * assume the size is infinite. Filtering should be considered 238a08bb43aSAndre Przywara * non-perfect, ie. based on hypervisor resources, the guest may 239a08bb43aSAndre Przywara * received packets from sources not specified in the filter list. 240a08bb43aSAndre Przywara * 241a08bb43aSAndre Przywara * In addition to the class/cmd header, the TABLE_SET command requires 242a08bb43aSAndre Przywara * two out scatterlists. Each contains a 4 byte count of entries followed 243a08bb43aSAndre Przywara * by a concatenated byte stream of the ETH_ALEN MAC addresses. The 244a08bb43aSAndre Przywara * first sg list contains unicast addresses, the second is for multicast. 245a08bb43aSAndre Przywara * This functionality is present if the VIRTIO_NET_F_CTRL_RX feature 246a08bb43aSAndre Przywara * is available. 247a08bb43aSAndre Przywara * 248a08bb43aSAndre Przywara * The ADDR_SET command requests one out scatterlist, it contains a 249a08bb43aSAndre Przywara * 6 bytes MAC address. This functionality is present if the 250a08bb43aSAndre Przywara * VIRTIO_NET_F_CTRL_MAC_ADDR feature is available. 251a08bb43aSAndre Przywara */ 252a08bb43aSAndre Przywara struct virtio_net_ctrl_mac { 253e5390783SAndre Przywara __virtio32 entries; 254a08bb43aSAndre Przywara __u8 macs[][ETH_ALEN]; 255a08bb43aSAndre Przywara } __attribute__((packed)); 256a08bb43aSAndre Przywara 257a08bb43aSAndre Przywara #define VIRTIO_NET_CTRL_MAC 1 258a08bb43aSAndre Przywara #define VIRTIO_NET_CTRL_MAC_TABLE_SET 0 259a08bb43aSAndre Przywara #define VIRTIO_NET_CTRL_MAC_ADDR_SET 1 260a08bb43aSAndre Przywara 261a08bb43aSAndre Przywara /* 262a08bb43aSAndre Przywara * Control VLAN filtering 263a08bb43aSAndre Przywara * 264a08bb43aSAndre Przywara * The VLAN filter table is controlled via a simple ADD/DEL interface. 265a08bb43aSAndre Przywara * VLAN IDs not added may be filterd by the hypervisor. Del is the 266a08bb43aSAndre Przywara * opposite of add. Both commands expect an out entry containing a 2 267a08bb43aSAndre Przywara * byte VLAN ID. VLAN filterting is available with the 268a08bb43aSAndre Przywara * VIRTIO_NET_F_CTRL_VLAN feature bit. 269a08bb43aSAndre Przywara */ 270a08bb43aSAndre Przywara #define VIRTIO_NET_CTRL_VLAN 2 271a08bb43aSAndre Przywara #define VIRTIO_NET_CTRL_VLAN_ADD 0 272a08bb43aSAndre Przywara #define VIRTIO_NET_CTRL_VLAN_DEL 1 273a08bb43aSAndre Przywara 274a08bb43aSAndre Przywara /* 275a08bb43aSAndre Przywara * Control link announce acknowledgement 276a08bb43aSAndre Przywara * 277a08bb43aSAndre Przywara * The command VIRTIO_NET_CTRL_ANNOUNCE_ACK is used to indicate that 278a08bb43aSAndre Przywara * driver has recevied the notification; device would clear the 279a08bb43aSAndre Przywara * VIRTIO_NET_S_ANNOUNCE bit in the status field after it receives 280a08bb43aSAndre Przywara * this command. 281a08bb43aSAndre Przywara */ 282a08bb43aSAndre Przywara #define VIRTIO_NET_CTRL_ANNOUNCE 3 283a08bb43aSAndre Przywara #define VIRTIO_NET_CTRL_ANNOUNCE_ACK 0 284a08bb43aSAndre Przywara 285a08bb43aSAndre Przywara /* 286a08bb43aSAndre Przywara * Control Receive Flow Steering 287e5390783SAndre Przywara */ 288e5390783SAndre Przywara #define VIRTIO_NET_CTRL_MQ 4 289e5390783SAndre Przywara /* 290a08bb43aSAndre Przywara * The command VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET 291a08bb43aSAndre Przywara * enables Receive Flow Steering, specifying the number of the transmit and 292a08bb43aSAndre Przywara * receive queues that will be used. After the command is consumed and acked by 293a08bb43aSAndre Przywara * the device, the device will not steer new packets on receive virtqueues 294a08bb43aSAndre Przywara * other than specified nor read from transmit virtqueues other than specified. 295a08bb43aSAndre Przywara * Accordingly, driver should not transmit new packets on virtqueues other than 296a08bb43aSAndre Przywara * specified. 297a08bb43aSAndre Przywara */ 298a08bb43aSAndre Przywara struct virtio_net_ctrl_mq { 299e5390783SAndre Przywara __virtio16 virtqueue_pairs; 300a08bb43aSAndre Przywara }; 301a08bb43aSAndre Przywara 302a08bb43aSAndre Przywara #define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET 0 303a08bb43aSAndre Przywara #define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MIN 1 304a08bb43aSAndre Przywara #define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MAX 0x8000 305a08bb43aSAndre Przywara 306e5390783SAndre Przywara /* 307e5390783SAndre Przywara * The command VIRTIO_NET_CTRL_MQ_RSS_CONFIG has the same effect as 308e5390783SAndre Przywara * VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET does and additionally configures 309e5390783SAndre Przywara * the receive steering to use a hash calculated for incoming packet 310e5390783SAndre Przywara * to decide on receive virtqueue to place the packet. The command 311e5390783SAndre Przywara * also provides parameters to calculate a hash and receive virtqueue. 312e5390783SAndre Przywara */ 313e5390783SAndre Przywara struct virtio_net_rss_config { 314e5390783SAndre Przywara __le32 hash_types; 315e5390783SAndre Przywara __le16 indirection_table_mask; 316e5390783SAndre Przywara __le16 unclassified_queue; 317e5390783SAndre Przywara __le16 indirection_table[1/* + indirection_table_mask */]; 318e5390783SAndre Przywara __le16 max_tx_vq; 319e5390783SAndre Przywara __u8 hash_key_length; 320e5390783SAndre Przywara __u8 hash_key_data[/* hash_key_length */]; 321e5390783SAndre Przywara }; 322e5390783SAndre Przywara 323e5390783SAndre Przywara #define VIRTIO_NET_CTRL_MQ_RSS_CONFIG 1 324e5390783SAndre Przywara 325e5390783SAndre Przywara /* 326e5390783SAndre Przywara * The command VIRTIO_NET_CTRL_MQ_HASH_CONFIG requests the device 327e5390783SAndre Przywara * to include in the virtio header of the packet the value of the 328e5390783SAndre Przywara * calculated hash and the report type of hash. It also provides 329e5390783SAndre Przywara * parameters for hash calculation. The command requires feature 330e5390783SAndre Przywara * VIRTIO_NET_F_HASH_REPORT to be negotiated to extend the 331e5390783SAndre Przywara * layout of virtio header as defined in virtio_net_hdr_v1_hash. 332e5390783SAndre Przywara */ 333e5390783SAndre Przywara struct virtio_net_hash_config { 334e5390783SAndre Przywara __le32 hash_types; 335e5390783SAndre Przywara /* for compatibility with virtio_net_rss_config */ 336e5390783SAndre Przywara __le16 reserved[4]; 337e5390783SAndre Przywara __u8 hash_key_length; 338e5390783SAndre Przywara __u8 hash_key_data[/* hash_key_length */]; 339e5390783SAndre Przywara }; 340e5390783SAndre Przywara 341e5390783SAndre Przywara #define VIRTIO_NET_CTRL_MQ_HASH_CONFIG 2 342e5390783SAndre Przywara 343e5390783SAndre Przywara /* 344e5390783SAndre Przywara * Control network offloads 345e5390783SAndre Przywara * 346e5390783SAndre Przywara * Reconfigures the network offloads that Guest can handle. 347e5390783SAndre Przywara * 348e5390783SAndre Przywara * Available with the VIRTIO_NET_F_CTRL_GUEST_OFFLOADS feature bit. 349e5390783SAndre Przywara * 350e5390783SAndre Przywara * Command data format matches the feature bit mask exactly. 351e5390783SAndre Przywara * 352e5390783SAndre Przywara * See VIRTIO_NET_F_GUEST_* for the list of offloads 353e5390783SAndre Przywara * that can be enabled/disabled. 354e5390783SAndre Przywara */ 355e5390783SAndre Przywara #define VIRTIO_NET_CTRL_GUEST_OFFLOADS 5 356e5390783SAndre Przywara #define VIRTIO_NET_CTRL_GUEST_OFFLOADS_SET 0 357e5390783SAndre Przywara 358*8d0facecSAnup Patel /* 359*8d0facecSAnup Patel * Control notifications coalescing. 360*8d0facecSAnup Patel * 361*8d0facecSAnup Patel * Request the device to change the notifications coalescing parameters. 362*8d0facecSAnup Patel * 363*8d0facecSAnup Patel * Available with the VIRTIO_NET_F_NOTF_COAL feature bit. 364*8d0facecSAnup Patel */ 365*8d0facecSAnup Patel #define VIRTIO_NET_CTRL_NOTF_COAL 6 366*8d0facecSAnup Patel /* 367*8d0facecSAnup Patel * Set the tx-usecs/tx-max-packets patameters. 368*8d0facecSAnup Patel * tx-usecs - Maximum number of usecs to delay a TX notification. 369*8d0facecSAnup Patel * tx-max-packets - Maximum number of packets to send before a TX notification. 370*8d0facecSAnup Patel */ 371*8d0facecSAnup Patel struct virtio_net_ctrl_coal_tx { 372*8d0facecSAnup Patel __le32 tx_max_packets; 373*8d0facecSAnup Patel __le32 tx_usecs; 374*8d0facecSAnup Patel }; 375*8d0facecSAnup Patel 376*8d0facecSAnup Patel #define VIRTIO_NET_CTRL_NOTF_COAL_TX_SET 0 377*8d0facecSAnup Patel 378*8d0facecSAnup Patel /* 379*8d0facecSAnup Patel * Set the rx-usecs/rx-max-packets patameters. 380*8d0facecSAnup Patel * rx-usecs - Maximum number of usecs to delay a RX notification. 381*8d0facecSAnup Patel * rx-max-frames - Maximum number of packets to receive before a RX notification. 382*8d0facecSAnup Patel */ 383*8d0facecSAnup Patel struct virtio_net_ctrl_coal_rx { 384*8d0facecSAnup Patel __le32 rx_max_packets; 385*8d0facecSAnup Patel __le32 rx_usecs; 386*8d0facecSAnup Patel }; 387*8d0facecSAnup Patel 388*8d0facecSAnup Patel #define VIRTIO_NET_CTRL_NOTF_COAL_RX_SET 1 389*8d0facecSAnup Patel 390e5390783SAndre Przywara #endif /* _UAPI_LINUX_VIRTIO_NET_H */ 391