1678ece30SMike Rapoport #ifndef _UAPI_LINUX_VIRTIO_NET_H 2678ece30SMike Rapoport #define _UAPI_LINUX_VIRTIO_NET_H 3607ca46eSDavid Howells /* This header is BSD licensed so anyone can use the definitions to implement 4607ca46eSDavid Howells * compatible drivers/servers. 5607ca46eSDavid Howells * 6607ca46eSDavid Howells * Redistribution and use in source and binary forms, with or without 7607ca46eSDavid Howells * modification, are permitted provided that the following conditions 8607ca46eSDavid Howells * are met: 9607ca46eSDavid Howells * 1. Redistributions of source code must retain the above copyright 10607ca46eSDavid Howells * notice, this list of conditions and the following disclaimer. 11607ca46eSDavid Howells * 2. Redistributions in binary form must reproduce the above copyright 12607ca46eSDavid Howells * notice, this list of conditions and the following disclaimer in the 13607ca46eSDavid Howells * documentation and/or other materials provided with the distribution. 14607ca46eSDavid Howells * 3. Neither the name of IBM nor the names of its contributors 15607ca46eSDavid Howells * may be used to endorse or promote products derived from this software 16607ca46eSDavid Howells * without specific prior written permission. 17607ca46eSDavid Howells * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND 18607ca46eSDavid Howells * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19607ca46eSDavid Howells * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20607ca46eSDavid Howells * ARE DISCLAIMED. IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE 21607ca46eSDavid Howells * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22607ca46eSDavid Howells * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23607ca46eSDavid Howells * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24607ca46eSDavid Howells * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25607ca46eSDavid Howells * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26607ca46eSDavid Howells * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27607ca46eSDavid Howells * SUCH DAMAGE. */ 28607ca46eSDavid Howells #include <linux/types.h> 29607ca46eSDavid Howells #include <linux/virtio_ids.h> 30607ca46eSDavid Howells #include <linux/virtio_config.h> 31fdd819b2SMichael S. Tsirkin #include <linux/virtio_types.h> 32607ca46eSDavid Howells #include <linux/if_ether.h> 33607ca46eSDavid Howells 34607ca46eSDavid Howells /* The feature bitmap for virtio net */ 35607ca46eSDavid Howells #define VIRTIO_NET_F_CSUM 0 /* Host handles pkts w/ partial csum */ 36607ca46eSDavid Howells #define VIRTIO_NET_F_GUEST_CSUM 1 /* Guest handles pkts w/ partial csum */ 378b0a9d42SMichael S. Tsirkin #define VIRTIO_NET_F_CTRL_GUEST_OFFLOADS 2 /* Dynamic offload configuration. */ 387d84e37eSAaron Conole #define VIRTIO_NET_F_MTU 3 /* Initial MTU advice */ 39607ca46eSDavid Howells #define VIRTIO_NET_F_MAC 5 /* Host has given MAC address. */ 40607ca46eSDavid Howells #define VIRTIO_NET_F_GUEST_TSO4 7 /* Guest can handle TSOv4 in. */ 41607ca46eSDavid Howells #define VIRTIO_NET_F_GUEST_TSO6 8 /* Guest can handle TSOv6 in. */ 42607ca46eSDavid Howells #define VIRTIO_NET_F_GUEST_ECN 9 /* Guest can handle TSO[6] w/ ECN in. */ 43607ca46eSDavid Howells #define VIRTIO_NET_F_GUEST_UFO 10 /* Guest can handle UFO in. */ 44607ca46eSDavid Howells #define VIRTIO_NET_F_HOST_TSO4 11 /* Host can handle TSOv4 in. */ 45607ca46eSDavid Howells #define VIRTIO_NET_F_HOST_TSO6 12 /* Host can handle TSOv6 in. */ 46607ca46eSDavid Howells #define VIRTIO_NET_F_HOST_ECN 13 /* Host can handle TSO[6] w/ ECN in. */ 47607ca46eSDavid Howells #define VIRTIO_NET_F_HOST_UFO 14 /* Host can handle UFO in. */ 48607ca46eSDavid Howells #define VIRTIO_NET_F_MRG_RXBUF 15 /* Host can merge receive buffers. */ 49607ca46eSDavid Howells #define VIRTIO_NET_F_STATUS 16 /* virtio_net_config.status available */ 50607ca46eSDavid Howells #define VIRTIO_NET_F_CTRL_VQ 17 /* Control channel available */ 51607ca46eSDavid Howells #define VIRTIO_NET_F_CTRL_RX 18 /* Control channel RX mode support */ 52607ca46eSDavid Howells #define VIRTIO_NET_F_CTRL_VLAN 19 /* Control channel VLAN filtering */ 53607ca46eSDavid Howells #define VIRTIO_NET_F_CTRL_RX_EXTRA 20 /* Extra RX mode control support */ 54607ca46eSDavid Howells #define VIRTIO_NET_F_GUEST_ANNOUNCE 21 /* Guest can announce device on the 55607ca46eSDavid Howells * network */ 56986a4f4dSJason Wang #define VIRTIO_NET_F_MQ 22 /* Device supports Receive Flow 57986a4f4dSJason Wang * Steering */ 587e58d5aeSAmos Kong #define VIRTIO_NET_F_CTRL_MAC_ADDR 23 /* Set MAC address */ 59*394bd877SGavin Li #define VIRTIO_NET_F_VQ_NOTF_COAL 52 /* Device supports virtqueue notification coalescing */ 60fce1c23fSAlvaro Karsz #define VIRTIO_NET_F_NOTF_COAL 53 /* Device supports notifications coalescing */ 6134061b34SAndrew Melnychenko #define VIRTIO_NET_F_GUEST_USO4 54 /* Guest can handle USOv4 in. */ 6234061b34SAndrew Melnychenko #define VIRTIO_NET_F_GUEST_USO6 55 /* Guest can handle USOv6 in. */ 6334061b34SAndrew Melnychenko #define VIRTIO_NET_F_HOST_USO 56 /* Host can handle USO in. */ 643024e209SYuri Benditovich #define VIRTIO_NET_F_HASH_REPORT 57 /* Supports hash report */ 65be50da3eSJiri Pirko #define VIRTIO_NET_F_GUEST_HDRLEN 59 /* Guest provides the exact hdr_len value. */ 66fd58bf67SYuri Benditovich #define VIRTIO_NET_F_RSS 60 /* Supports RSS RX steering */ 6722b436c9SYuri Benditovich #define VIRTIO_NET_F_RSC_EXT 61 /* extended coalescing info */ 689805069dSSridhar Samudrala #define VIRTIO_NET_F_STANDBY 62 /* Act as standby for another device 699805069dSSridhar Samudrala * with the same MAC. 709805069dSSridhar Samudrala */ 71faa9b39fSJason Baron #define VIRTIO_NET_F_SPEED_DUPLEX 63 /* Device set linkspeed and duplex */ 72faa9b39fSJason Baron 73ed9ecb04SRusty Russell #ifndef VIRTIO_NET_NO_LEGACY 74ed9ecb04SRusty Russell #define VIRTIO_NET_F_GSO 6 /* Host handles pkts w/ any GSO type */ 75ed9ecb04SRusty Russell #endif /* VIRTIO_NET_NO_LEGACY */ 76ed9ecb04SRusty Russell 77607ca46eSDavid Howells #define VIRTIO_NET_S_LINK_UP 1 /* Link is up */ 78607ca46eSDavid Howells #define VIRTIO_NET_S_ANNOUNCE 2 /* Announcement is needed */ 79607ca46eSDavid Howells 80fd58bf67SYuri Benditovich /* supported/enabled hash types */ 81fd58bf67SYuri Benditovich #define VIRTIO_NET_RSS_HASH_TYPE_IPv4 (1 << 0) 82fd58bf67SYuri Benditovich #define VIRTIO_NET_RSS_HASH_TYPE_TCPv4 (1 << 1) 83fd58bf67SYuri Benditovich #define VIRTIO_NET_RSS_HASH_TYPE_UDPv4 (1 << 2) 84fd58bf67SYuri Benditovich #define VIRTIO_NET_RSS_HASH_TYPE_IPv6 (1 << 3) 85fd58bf67SYuri Benditovich #define VIRTIO_NET_RSS_HASH_TYPE_TCPv6 (1 << 4) 86fd58bf67SYuri Benditovich #define VIRTIO_NET_RSS_HASH_TYPE_UDPv6 (1 << 5) 87fd58bf67SYuri Benditovich #define VIRTIO_NET_RSS_HASH_TYPE_IP_EX (1 << 6) 88fd58bf67SYuri Benditovich #define VIRTIO_NET_RSS_HASH_TYPE_TCP_EX (1 << 7) 89fd58bf67SYuri Benditovich #define VIRTIO_NET_RSS_HASH_TYPE_UDP_EX (1 << 8) 90fd58bf67SYuri Benditovich 91607ca46eSDavid Howells struct virtio_net_config { 92607ca46eSDavid Howells /* The config defining mac address (if VIRTIO_NET_F_MAC) */ 93e216975aSJoe Perches __u8 mac[ETH_ALEN]; 94607ca46eSDavid Howells /* See VIRTIO_NET_F_STATUS and VIRTIO_NET_S_* above */ 95577e677aSMichael S. Tsirkin __virtio16 status; 96986a4f4dSJason Wang /* Maximum number of each of transmit and receive queues; 97986a4f4dSJason Wang * see VIRTIO_NET_F_MQ and VIRTIO_NET_CTRL_MQ. 98986a4f4dSJason Wang * Legal values are between 1 and 0x8000 99986a4f4dSJason Wang */ 100577e677aSMichael S. Tsirkin __virtio16 max_virtqueue_pairs; 10114de9d11SAaron Conole /* Default maximum transmit unit advice */ 102577e677aSMichael S. Tsirkin __virtio16 mtu; 103faa9b39fSJason Baron /* 104faa9b39fSJason Baron * speed, in units of 1Mb. All values 0 to INT_MAX are legal. 105faa9b39fSJason Baron * Any other value stands for unknown. 106faa9b39fSJason Baron */ 10764ffa39dSMichael S. Tsirkin __le32 speed; 108faa9b39fSJason Baron /* 109faa9b39fSJason Baron * 0x00 - half duplex 110faa9b39fSJason Baron * 0x01 - full duplex 111faa9b39fSJason Baron * Any other value stands for unknown. 112faa9b39fSJason Baron */ 113faa9b39fSJason Baron __u8 duplex; 114fd58bf67SYuri Benditovich /* maximum size of RSS key */ 115fd58bf67SYuri Benditovich __u8 rss_max_key_size; 116fd58bf67SYuri Benditovich /* maximum number of indirection table entries */ 117fd58bf67SYuri Benditovich __le16 rss_max_indirection_table_length; 118fd58bf67SYuri Benditovich /* bitmask of supported VIRTIO_NET_RSS_HASH_ types */ 119fd58bf67SYuri Benditovich __le32 supported_hash_types; 120607ca46eSDavid Howells } __attribute__((packed)); 121607ca46eSDavid Howells 122ed9ecb04SRusty Russell /* 123ed9ecb04SRusty Russell * This header comes first in the scatter-gather list. If you don't 124ed9ecb04SRusty Russell * specify GSO or CSUM features, you can simply ignore the header. 125ed9ecb04SRusty Russell * 126e68c48f9SRusty Russell * This is bitwise-equivalent to the legacy struct virtio_net_hdr_mrg_rxbuf, 127e68c48f9SRusty Russell * only flattened. 128ed9ecb04SRusty Russell */ 129ed9ecb04SRusty Russell struct virtio_net_hdr_v1 { 130ed9ecb04SRusty Russell #define VIRTIO_NET_HDR_F_NEEDS_CSUM 1 /* Use csum_start, csum_offset */ 131ed9ecb04SRusty Russell #define VIRTIO_NET_HDR_F_DATA_VALID 2 /* Csum is valid */ 13222b436c9SYuri Benditovich #define VIRTIO_NET_HDR_F_RSC_INFO 4 /* rsc info in csum_ fields */ 133ed9ecb04SRusty Russell __u8 flags; 134ed9ecb04SRusty Russell #define VIRTIO_NET_HDR_GSO_NONE 0 /* Not a GSO frame */ 135ed9ecb04SRusty Russell #define VIRTIO_NET_HDR_GSO_TCPV4 1 /* GSO frame, IPv4 TCP (TSO) */ 136ed9ecb04SRusty Russell #define VIRTIO_NET_HDR_GSO_UDP 3 /* GSO frame, IPv4 UDP (UFO) */ 137ed9ecb04SRusty Russell #define VIRTIO_NET_HDR_GSO_TCPV6 4 /* GSO frame, IPv6 TCP */ 13834061b34SAndrew Melnychenko #define VIRTIO_NET_HDR_GSO_UDP_L4 5 /* GSO frame, IPv4& IPv6 UDP (USO) */ 139ed9ecb04SRusty Russell #define VIRTIO_NET_HDR_GSO_ECN 0x80 /* TCP has ECN set */ 140ed9ecb04SRusty Russell __u8 gso_type; 141ed9ecb04SRusty Russell __virtio16 hdr_len; /* Ethernet + IP + tcp/udp hdrs */ 142ed9ecb04SRusty Russell __virtio16 gso_size; /* Bytes to append to hdr_len per frame */ 14322b436c9SYuri Benditovich union { 14422b436c9SYuri Benditovich struct { 14522b436c9SYuri Benditovich __virtio16 csum_start; 14622b436c9SYuri Benditovich __virtio16 csum_offset; 14722b436c9SYuri Benditovich }; 14822b436c9SYuri Benditovich /* Checksum calculation */ 14922b436c9SYuri Benditovich struct { 15022b436c9SYuri Benditovich /* Position to start checksumming from */ 15122b436c9SYuri Benditovich __virtio16 start; 15222b436c9SYuri Benditovich /* Offset after that to place checksum */ 15322b436c9SYuri Benditovich __virtio16 offset; 15422b436c9SYuri Benditovich } csum; 15522b436c9SYuri Benditovich /* Receive Segment Coalescing */ 15622b436c9SYuri Benditovich struct { 15722b436c9SYuri Benditovich /* Number of coalesced segments */ 15822b436c9SYuri Benditovich __le16 segments; 15922b436c9SYuri Benditovich /* Number of duplicated acks */ 16022b436c9SYuri Benditovich __le16 dup_acks; 16122b436c9SYuri Benditovich } rsc; 16222b436c9SYuri Benditovich }; 163ed9ecb04SRusty Russell __virtio16 num_buffers; /* Number of merged rx buffers */ 164ed9ecb04SRusty Russell }; 165e68c48f9SRusty Russell 1663024e209SYuri Benditovich struct virtio_net_hdr_v1_hash { 1673024e209SYuri Benditovich struct virtio_net_hdr_v1 hdr; 1683024e209SYuri Benditovich __le32 hash_value; 1693024e209SYuri Benditovich #define VIRTIO_NET_HASH_REPORT_NONE 0 1703024e209SYuri Benditovich #define VIRTIO_NET_HASH_REPORT_IPv4 1 1713024e209SYuri Benditovich #define VIRTIO_NET_HASH_REPORT_TCPv4 2 1723024e209SYuri Benditovich #define VIRTIO_NET_HASH_REPORT_UDPv4 3 1733024e209SYuri Benditovich #define VIRTIO_NET_HASH_REPORT_IPv6 4 1743024e209SYuri Benditovich #define VIRTIO_NET_HASH_REPORT_TCPv6 5 1753024e209SYuri Benditovich #define VIRTIO_NET_HASH_REPORT_UDPv6 6 1763024e209SYuri Benditovich #define VIRTIO_NET_HASH_REPORT_IPv6_EX 7 1773024e209SYuri Benditovich #define VIRTIO_NET_HASH_REPORT_TCPv6_EX 8 1783024e209SYuri Benditovich #define VIRTIO_NET_HASH_REPORT_UDPv6_EX 9 1793024e209SYuri Benditovich __le16 hash_report; 1803024e209SYuri Benditovich __le16 padding; 1813024e209SYuri Benditovich }; 1823024e209SYuri Benditovich 183e68c48f9SRusty Russell #ifndef VIRTIO_NET_NO_LEGACY 184e68c48f9SRusty Russell /* This header comes first in the scatter-gather list. 185e68c48f9SRusty Russell * For legacy virtio, if VIRTIO_F_ANY_LAYOUT is not negotiated, it must 186e68c48f9SRusty Russell * be the first element of the scatter-gather list. If you don't 187e68c48f9SRusty Russell * specify GSO or CSUM features, you can simply ignore the header. */ 188e68c48f9SRusty Russell struct virtio_net_hdr { 189e68c48f9SRusty Russell /* See VIRTIO_NET_HDR_F_* */ 190e68c48f9SRusty Russell __u8 flags; 191e68c48f9SRusty Russell /* See VIRTIO_NET_HDR_GSO_* */ 192e68c48f9SRusty Russell __u8 gso_type; 193e68c48f9SRusty Russell __virtio16 hdr_len; /* Ethernet + IP + tcp/udp hdrs */ 194e68c48f9SRusty Russell __virtio16 gso_size; /* Bytes to append to hdr_len per frame */ 195e68c48f9SRusty Russell __virtio16 csum_start; /* Position to start checksumming from */ 196e68c48f9SRusty Russell __virtio16 csum_offset; /* Offset after that to place checksum */ 197e68c48f9SRusty Russell }; 198e68c48f9SRusty Russell 199e68c48f9SRusty Russell /* This is the version of the header to use when the MRG_RXBUF 200e68c48f9SRusty Russell * feature has been negotiated. */ 201e68c48f9SRusty Russell struct virtio_net_hdr_mrg_rxbuf { 202e68c48f9SRusty Russell struct virtio_net_hdr hdr; 203e68c48f9SRusty Russell __virtio16 num_buffers; /* Number of merged rx buffers */ 204e68c48f9SRusty Russell }; 205ed9ecb04SRusty Russell #endif /* ...VIRTIO_NET_NO_LEGACY */ 206607ca46eSDavid Howells 207607ca46eSDavid Howells /* 208607ca46eSDavid Howells * Control virtqueue data structures 209607ca46eSDavid Howells * 210607ca46eSDavid Howells * The control virtqueue expects a header in the first sg entry 211607ca46eSDavid Howells * and an ack/status response in the last entry. Data for the 212607ca46eSDavid Howells * command goes in between. 213607ca46eSDavid Howells */ 214607ca46eSDavid Howells struct virtio_net_ctrl_hdr { 215607ca46eSDavid Howells __u8 class; 216607ca46eSDavid Howells __u8 cmd; 217607ca46eSDavid Howells } __attribute__((packed)); 218607ca46eSDavid Howells 219607ca46eSDavid Howells typedef __u8 virtio_net_ctrl_ack; 220607ca46eSDavid Howells 221607ca46eSDavid Howells #define VIRTIO_NET_OK 0 222607ca46eSDavid Howells #define VIRTIO_NET_ERR 1 223607ca46eSDavid Howells 224607ca46eSDavid Howells /* 225607ca46eSDavid Howells * Control the RX mode, ie. promisucous, allmulti, etc... 226607ca46eSDavid Howells * All commands require an "out" sg entry containing a 1 byte 227607ca46eSDavid Howells * state value, zero = disable, non-zero = enable. Commands 228607ca46eSDavid Howells * 0 and 1 are supported with the VIRTIO_NET_F_CTRL_RX feature. 229607ca46eSDavid Howells * Commands 2-5 are added with VIRTIO_NET_F_CTRL_RX_EXTRA. 230607ca46eSDavid Howells */ 231607ca46eSDavid Howells #define VIRTIO_NET_CTRL_RX 0 232607ca46eSDavid Howells #define VIRTIO_NET_CTRL_RX_PROMISC 0 233607ca46eSDavid Howells #define VIRTIO_NET_CTRL_RX_ALLMULTI 1 234607ca46eSDavid Howells #define VIRTIO_NET_CTRL_RX_ALLUNI 2 235607ca46eSDavid Howells #define VIRTIO_NET_CTRL_RX_NOMULTI 3 236607ca46eSDavid Howells #define VIRTIO_NET_CTRL_RX_NOUNI 4 237607ca46eSDavid Howells #define VIRTIO_NET_CTRL_RX_NOBCAST 5 238607ca46eSDavid Howells 239607ca46eSDavid Howells /* 2407e58d5aeSAmos Kong * Control the MAC 241607ca46eSDavid Howells * 242607ca46eSDavid Howells * The MAC filter table is managed by the hypervisor, the guest should 243607ca46eSDavid Howells * assume the size is infinite. Filtering should be considered 244607ca46eSDavid Howells * non-perfect, ie. based on hypervisor resources, the guest may 245607ca46eSDavid Howells * received packets from sources not specified in the filter list. 246607ca46eSDavid Howells * 247607ca46eSDavid Howells * In addition to the class/cmd header, the TABLE_SET command requires 248607ca46eSDavid Howells * two out scatterlists. Each contains a 4 byte count of entries followed 249607ca46eSDavid Howells * by a concatenated byte stream of the ETH_ALEN MAC addresses. The 250607ca46eSDavid Howells * first sg list contains unicast addresses, the second is for multicast. 251607ca46eSDavid Howells * This functionality is present if the VIRTIO_NET_F_CTRL_RX feature 252607ca46eSDavid Howells * is available. 2537e58d5aeSAmos Kong * 2547e58d5aeSAmos Kong * The ADDR_SET command requests one out scatterlist, it contains a 2557e58d5aeSAmos Kong * 6 bytes MAC address. This functionality is present if the 2567e58d5aeSAmos Kong * VIRTIO_NET_F_CTRL_MAC_ADDR feature is available. 257607ca46eSDavid Howells */ 258607ca46eSDavid Howells struct virtio_net_ctrl_mac { 259fdd819b2SMichael S. Tsirkin __virtio32 entries; 260607ca46eSDavid Howells __u8 macs[][ETH_ALEN]; 261607ca46eSDavid Howells } __attribute__((packed)); 262607ca46eSDavid Howells 263607ca46eSDavid Howells #define VIRTIO_NET_CTRL_MAC 1 264607ca46eSDavid Howells #define VIRTIO_NET_CTRL_MAC_TABLE_SET 0 2657e58d5aeSAmos Kong #define VIRTIO_NET_CTRL_MAC_ADDR_SET 1 266607ca46eSDavid Howells 267607ca46eSDavid Howells /* 268607ca46eSDavid Howells * Control VLAN filtering 269607ca46eSDavid Howells * 270607ca46eSDavid Howells * The VLAN filter table is controlled via a simple ADD/DEL interface. 271607ca46eSDavid Howells * VLAN IDs not added may be filterd by the hypervisor. Del is the 272607ca46eSDavid Howells * opposite of add. Both commands expect an out entry containing a 2 273607ca46eSDavid Howells * byte VLAN ID. VLAN filterting is available with the 274607ca46eSDavid Howells * VIRTIO_NET_F_CTRL_VLAN feature bit. 275607ca46eSDavid Howells */ 276607ca46eSDavid Howells #define VIRTIO_NET_CTRL_VLAN 2 277607ca46eSDavid Howells #define VIRTIO_NET_CTRL_VLAN_ADD 0 278607ca46eSDavid Howells #define VIRTIO_NET_CTRL_VLAN_DEL 1 279607ca46eSDavid Howells 280607ca46eSDavid Howells /* 281607ca46eSDavid Howells * Control link announce acknowledgement 282607ca46eSDavid Howells * 283607ca46eSDavid Howells * The command VIRTIO_NET_CTRL_ANNOUNCE_ACK is used to indicate that 284607ca46eSDavid Howells * driver has recevied the notification; device would clear the 285607ca46eSDavid Howells * VIRTIO_NET_S_ANNOUNCE bit in the status field after it receives 286607ca46eSDavid Howells * this command. 287607ca46eSDavid Howells */ 288607ca46eSDavid Howells #define VIRTIO_NET_CTRL_ANNOUNCE 3 289607ca46eSDavid Howells #define VIRTIO_NET_CTRL_ANNOUNCE_ACK 0 290607ca46eSDavid Howells 291986a4f4dSJason Wang /* 292986a4f4dSJason Wang * Control Receive Flow Steering 293fd58bf67SYuri Benditovich */ 294fd58bf67SYuri Benditovich #define VIRTIO_NET_CTRL_MQ 4 295fd58bf67SYuri Benditovich /* 296986a4f4dSJason Wang * The command VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET 297986a4f4dSJason Wang * enables Receive Flow Steering, specifying the number of the transmit and 298986a4f4dSJason Wang * receive queues that will be used. After the command is consumed and acked by 299986a4f4dSJason Wang * the device, the device will not steer new packets on receive virtqueues 300986a4f4dSJason Wang * other than specified nor read from transmit virtqueues other than specified. 301986a4f4dSJason Wang * Accordingly, driver should not transmit new packets on virtqueues other than 302986a4f4dSJason Wang * specified. 303986a4f4dSJason Wang */ 304986a4f4dSJason Wang struct virtio_net_ctrl_mq { 305fdd819b2SMichael S. Tsirkin __virtio16 virtqueue_pairs; 306986a4f4dSJason Wang }; 307986a4f4dSJason Wang 308986a4f4dSJason Wang #define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET 0 309986a4f4dSJason Wang #define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MIN 1 310986a4f4dSJason Wang #define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MAX 0x8000 311986a4f4dSJason Wang 3128b0a9d42SMichael S. Tsirkin /* 313fd58bf67SYuri Benditovich * The command VIRTIO_NET_CTRL_MQ_RSS_CONFIG has the same effect as 314fd58bf67SYuri Benditovich * VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET does and additionally configures 315fd58bf67SYuri Benditovich * the receive steering to use a hash calculated for incoming packet 316fd58bf67SYuri Benditovich * to decide on receive virtqueue to place the packet. The command 317fd58bf67SYuri Benditovich * also provides parameters to calculate a hash and receive virtqueue. 318fd58bf67SYuri Benditovich */ 319fd58bf67SYuri Benditovich struct virtio_net_rss_config { 320fd58bf67SYuri Benditovich __le32 hash_types; 321fd58bf67SYuri Benditovich __le16 indirection_table_mask; 322fd58bf67SYuri Benditovich __le16 unclassified_queue; 323fd58bf67SYuri Benditovich __le16 indirection_table[1/* + indirection_table_mask */]; 324fd58bf67SYuri Benditovich __le16 max_tx_vq; 325fd58bf67SYuri Benditovich __u8 hash_key_length; 326fd58bf67SYuri Benditovich __u8 hash_key_data[/* hash_key_length */]; 327fd58bf67SYuri Benditovich }; 328fd58bf67SYuri Benditovich 329fd58bf67SYuri Benditovich #define VIRTIO_NET_CTRL_MQ_RSS_CONFIG 1 330fd58bf67SYuri Benditovich 331fd58bf67SYuri Benditovich /* 3323024e209SYuri Benditovich * The command VIRTIO_NET_CTRL_MQ_HASH_CONFIG requests the device 3333024e209SYuri Benditovich * to include in the virtio header of the packet the value of the 3343024e209SYuri Benditovich * calculated hash and the report type of hash. It also provides 3353024e209SYuri Benditovich * parameters for hash calculation. The command requires feature 3363024e209SYuri Benditovich * VIRTIO_NET_F_HASH_REPORT to be negotiated to extend the 3373024e209SYuri Benditovich * layout of virtio header as defined in virtio_net_hdr_v1_hash. 3383024e209SYuri Benditovich */ 3393024e209SYuri Benditovich struct virtio_net_hash_config { 3403024e209SYuri Benditovich __le32 hash_types; 3413024e209SYuri Benditovich /* for compatibility with virtio_net_rss_config */ 3423024e209SYuri Benditovich __le16 reserved[4]; 3433024e209SYuri Benditovich __u8 hash_key_length; 3443024e209SYuri Benditovich __u8 hash_key_data[/* hash_key_length */]; 3453024e209SYuri Benditovich }; 3463024e209SYuri Benditovich 3473024e209SYuri Benditovich #define VIRTIO_NET_CTRL_MQ_HASH_CONFIG 2 3483024e209SYuri Benditovich 3493024e209SYuri Benditovich /* 3508b0a9d42SMichael S. Tsirkin * Control network offloads 3518b0a9d42SMichael S. Tsirkin * 3528b0a9d42SMichael S. Tsirkin * Reconfigures the network offloads that Guest can handle. 3538b0a9d42SMichael S. Tsirkin * 3548b0a9d42SMichael S. Tsirkin * Available with the VIRTIO_NET_F_CTRL_GUEST_OFFLOADS feature bit. 3558b0a9d42SMichael S. Tsirkin * 3568b0a9d42SMichael S. Tsirkin * Command data format matches the feature bit mask exactly. 3578b0a9d42SMichael S. Tsirkin * 3588b0a9d42SMichael S. Tsirkin * See VIRTIO_NET_F_GUEST_* for the list of offloads 3598b0a9d42SMichael S. Tsirkin * that can be enabled/disabled. 3608b0a9d42SMichael S. Tsirkin */ 3618b0a9d42SMichael S. Tsirkin #define VIRTIO_NET_CTRL_GUEST_OFFLOADS 5 3628b0a9d42SMichael S. Tsirkin #define VIRTIO_NET_CTRL_GUEST_OFFLOADS_SET 0 3638b0a9d42SMichael S. Tsirkin 364699b045aSAlvaro Karsz /* 365699b045aSAlvaro Karsz * Control notifications coalescing. 366699b045aSAlvaro Karsz * 367699b045aSAlvaro Karsz * Request the device to change the notifications coalescing parameters. 368699b045aSAlvaro Karsz * 369699b045aSAlvaro Karsz * Available with the VIRTIO_NET_F_NOTF_COAL feature bit. 370699b045aSAlvaro Karsz */ 371699b045aSAlvaro Karsz #define VIRTIO_NET_CTRL_NOTF_COAL 6 372699b045aSAlvaro Karsz /* 373fce1c23fSAlvaro Karsz * Set the tx-usecs/tx-max-packets parameters. 374699b045aSAlvaro Karsz */ 375699b045aSAlvaro Karsz struct virtio_net_ctrl_coal_tx { 376fce1c23fSAlvaro Karsz /* Maximum number of packets to send before a TX notification */ 377699b045aSAlvaro Karsz __le32 tx_max_packets; 378fce1c23fSAlvaro Karsz /* Maximum number of usecs to delay a TX notification */ 379699b045aSAlvaro Karsz __le32 tx_usecs; 380699b045aSAlvaro Karsz }; 381699b045aSAlvaro Karsz 382699b045aSAlvaro Karsz #define VIRTIO_NET_CTRL_NOTF_COAL_TX_SET 0 383699b045aSAlvaro Karsz 384699b045aSAlvaro Karsz /* 385fce1c23fSAlvaro Karsz * Set the rx-usecs/rx-max-packets parameters. 386699b045aSAlvaro Karsz */ 387699b045aSAlvaro Karsz struct virtio_net_ctrl_coal_rx { 388fce1c23fSAlvaro Karsz /* Maximum number of packets to receive before a RX notification */ 389699b045aSAlvaro Karsz __le32 rx_max_packets; 390fce1c23fSAlvaro Karsz /* Maximum number of usecs to delay a RX notification */ 391699b045aSAlvaro Karsz __le32 rx_usecs; 392699b045aSAlvaro Karsz }; 393699b045aSAlvaro Karsz 394699b045aSAlvaro Karsz #define VIRTIO_NET_CTRL_NOTF_COAL_RX_SET 1 395*394bd877SGavin Li #define VIRTIO_NET_CTRL_NOTF_COAL_VQ_SET 2 396*394bd877SGavin Li #define VIRTIO_NET_CTRL_NOTF_COAL_VQ_GET 3 397*394bd877SGavin Li 398*394bd877SGavin Li struct virtio_net_ctrl_coal { 399*394bd877SGavin Li __le32 max_packets; 400*394bd877SGavin Li __le32 max_usecs; 401*394bd877SGavin Li }; 402*394bd877SGavin Li 403*394bd877SGavin Li struct virtio_net_ctrl_coal_vq { 404*394bd877SGavin Li __le16 vqn; 405*394bd877SGavin Li __le16 reserved; 406*394bd877SGavin Li struct virtio_net_ctrl_coal coal; 407*394bd877SGavin Li }; 408699b045aSAlvaro Karsz 409678ece30SMike Rapoport #endif /* _UAPI_LINUX_VIRTIO_NET_H */ 410