#ifndef _UAPI_LINUX_VIRTIO_NET_H #define _UAPI_LINUX_VIRTIO_NET_H /* This header is BSD licensed so anyone can use the definitions to implement * compatible drivers/servers. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of IBM nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include <linux/types.h> #include <linux/virtio_ids.h> #include <linux/virtio_config.h> #include <linux/virtio_types.h> #include <linux/if_ether.h> /* The feature bitmap for virtio net */ #define VIRTIO_NET_F_CSUM … #define VIRTIO_NET_F_GUEST_CSUM … #define VIRTIO_NET_F_CTRL_GUEST_OFFLOADS … #define VIRTIO_NET_F_MTU … #define VIRTIO_NET_F_MAC … #define VIRTIO_NET_F_GUEST_TSO4 … #define VIRTIO_NET_F_GUEST_TSO6 … #define VIRTIO_NET_F_GUEST_ECN … #define VIRTIO_NET_F_GUEST_UFO … #define VIRTIO_NET_F_HOST_TSO4 … #define VIRTIO_NET_F_HOST_TSO6 … #define VIRTIO_NET_F_HOST_ECN … #define VIRTIO_NET_F_HOST_UFO … #define VIRTIO_NET_F_MRG_RXBUF … #define VIRTIO_NET_F_STATUS … #define VIRTIO_NET_F_CTRL_VQ … #define VIRTIO_NET_F_CTRL_RX … #define VIRTIO_NET_F_CTRL_VLAN … #define VIRTIO_NET_F_CTRL_RX_EXTRA … #define VIRTIO_NET_F_GUEST_ANNOUNCE … #define VIRTIO_NET_F_MQ … #define VIRTIO_NET_F_CTRL_MAC_ADDR … #define VIRTIO_NET_F_DEVICE_STATS … #define VIRTIO_NET_F_VQ_NOTF_COAL … #define VIRTIO_NET_F_NOTF_COAL … #define VIRTIO_NET_F_GUEST_USO4 … #define VIRTIO_NET_F_GUEST_USO6 … #define VIRTIO_NET_F_HOST_USO … #define VIRTIO_NET_F_HASH_REPORT … #define VIRTIO_NET_F_GUEST_HDRLEN … #define VIRTIO_NET_F_RSS … #define VIRTIO_NET_F_RSC_EXT … #define VIRTIO_NET_F_STANDBY … #define VIRTIO_NET_F_SPEED_DUPLEX … #ifndef VIRTIO_NET_NO_LEGACY #define VIRTIO_NET_F_GSO … #endif /* VIRTIO_NET_NO_LEGACY */ #define VIRTIO_NET_S_LINK_UP … #define VIRTIO_NET_S_ANNOUNCE … /* supported/enabled hash types */ #define VIRTIO_NET_RSS_HASH_TYPE_IPv4 … #define VIRTIO_NET_RSS_HASH_TYPE_TCPv4 … #define VIRTIO_NET_RSS_HASH_TYPE_UDPv4 … #define VIRTIO_NET_RSS_HASH_TYPE_IPv6 … #define VIRTIO_NET_RSS_HASH_TYPE_TCPv6 … #define VIRTIO_NET_RSS_HASH_TYPE_UDPv6 … #define VIRTIO_NET_RSS_HASH_TYPE_IP_EX … #define VIRTIO_NET_RSS_HASH_TYPE_TCP_EX … #define VIRTIO_NET_RSS_HASH_TYPE_UDP_EX … struct virtio_net_config { … } __attribute__((packed)); /* * This header comes first in the scatter-gather list. If you don't * specify GSO or CSUM features, you can simply ignore the header. * * This is bitwise-equivalent to the legacy struct virtio_net_hdr_mrg_rxbuf, * only flattened. */ struct virtio_net_hdr_v1 { … }; struct virtio_net_hdr_v1_hash { … }; #ifndef VIRTIO_NET_NO_LEGACY /* This header comes first in the scatter-gather list. * For legacy virtio, if VIRTIO_F_ANY_LAYOUT is not negotiated, it must * be the first element of the scatter-gather list. If you don't * specify GSO or CSUM features, you can simply ignore the header. */ struct virtio_net_hdr { … }; /* This is the version of the header to use when the MRG_RXBUF * feature has been negotiated. */ struct virtio_net_hdr_mrg_rxbuf { … }; #endif /* ...VIRTIO_NET_NO_LEGACY */ /* * Control virtqueue data structures * * The control virtqueue expects a header in the first sg entry * and an ack/status response in the last entry. Data for the * command goes in between. */ struct virtio_net_ctrl_hdr { … } __attribute__((packed)); virtio_net_ctrl_ack; #define VIRTIO_NET_OK … #define VIRTIO_NET_ERR … /* * Control the RX mode, ie. promisucous, allmulti, etc... * All commands require an "out" sg entry containing a 1 byte * state value, zero = disable, non-zero = enable. Commands * 0 and 1 are supported with the VIRTIO_NET_F_CTRL_RX feature. * Commands 2-5 are added with VIRTIO_NET_F_CTRL_RX_EXTRA. */ #define VIRTIO_NET_CTRL_RX … #define VIRTIO_NET_CTRL_RX_PROMISC … #define VIRTIO_NET_CTRL_RX_ALLMULTI … #define VIRTIO_NET_CTRL_RX_ALLUNI … #define VIRTIO_NET_CTRL_RX_NOMULTI … #define VIRTIO_NET_CTRL_RX_NOUNI … #define VIRTIO_NET_CTRL_RX_NOBCAST … /* * Control the MAC * * The MAC filter table is managed by the hypervisor, the guest should * assume the size is infinite. Filtering should be considered * non-perfect, ie. based on hypervisor resources, the guest may * received packets from sources not specified in the filter list. * * In addition to the class/cmd header, the TABLE_SET command requires * two out scatterlists. Each contains a 4 byte count of entries followed * by a concatenated byte stream of the ETH_ALEN MAC addresses. The * first sg list contains unicast addresses, the second is for multicast. * This functionality is present if the VIRTIO_NET_F_CTRL_RX feature * is available. * * The ADDR_SET command requests one out scatterlist, it contains a * 6 bytes MAC address. This functionality is present if the * VIRTIO_NET_F_CTRL_MAC_ADDR feature is available. */ struct virtio_net_ctrl_mac { … } __attribute__((packed)); #define VIRTIO_NET_CTRL_MAC … #define VIRTIO_NET_CTRL_MAC_TABLE_SET … #define VIRTIO_NET_CTRL_MAC_ADDR_SET … /* * Control VLAN filtering * * The VLAN filter table is controlled via a simple ADD/DEL interface. * VLAN IDs not added may be filterd by the hypervisor. Del is the * opposite of add. Both commands expect an out entry containing a 2 * byte VLAN ID. VLAN filterting is available with the * VIRTIO_NET_F_CTRL_VLAN feature bit. */ #define VIRTIO_NET_CTRL_VLAN … #define VIRTIO_NET_CTRL_VLAN_ADD … #define VIRTIO_NET_CTRL_VLAN_DEL … /* * Control link announce acknowledgement * * The command VIRTIO_NET_CTRL_ANNOUNCE_ACK is used to indicate that * driver has recevied the notification; device would clear the * VIRTIO_NET_S_ANNOUNCE bit in the status field after it receives * this command. */ #define VIRTIO_NET_CTRL_ANNOUNCE … #define VIRTIO_NET_CTRL_ANNOUNCE_ACK … /* * Control Receive Flow Steering */ #define VIRTIO_NET_CTRL_MQ … /* * The command VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET * enables Receive Flow Steering, specifying the number of the transmit and * receive queues that will be used. After the command is consumed and acked by * the device, the device will not steer new packets on receive virtqueues * other than specified nor read from transmit virtqueues other than specified. * Accordingly, driver should not transmit new packets on virtqueues other than * specified. */ struct virtio_net_ctrl_mq { … }; #define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET … #define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MIN … #define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MAX … /* * The command VIRTIO_NET_CTRL_MQ_RSS_CONFIG has the same effect as * VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET does and additionally configures * the receive steering to use a hash calculated for incoming packet * to decide on receive virtqueue to place the packet. The command * also provides parameters to calculate a hash and receive virtqueue. */ struct virtio_net_rss_config { … }; #define VIRTIO_NET_CTRL_MQ_RSS_CONFIG … /* * The command VIRTIO_NET_CTRL_MQ_HASH_CONFIG requests the device * to include in the virtio header of the packet the value of the * calculated hash and the report type of hash. It also provides * parameters for hash calculation. The command requires feature * VIRTIO_NET_F_HASH_REPORT to be negotiated to extend the * layout of virtio header as defined in virtio_net_hdr_v1_hash. */ struct virtio_net_hash_config { … }; #define VIRTIO_NET_CTRL_MQ_HASH_CONFIG … /* * Control network offloads * * Reconfigures the network offloads that Guest can handle. * * Available with the VIRTIO_NET_F_CTRL_GUEST_OFFLOADS feature bit. * * Command data format matches the feature bit mask exactly. * * See VIRTIO_NET_F_GUEST_* for the list of offloads * that can be enabled/disabled. */ #define VIRTIO_NET_CTRL_GUEST_OFFLOADS … #define VIRTIO_NET_CTRL_GUEST_OFFLOADS_SET … /* * Control notifications coalescing. * * Request the device to change the notifications coalescing parameters. * * Available with the VIRTIO_NET_F_NOTF_COAL feature bit. */ #define VIRTIO_NET_CTRL_NOTF_COAL … /* * Set the tx-usecs/tx-max-packets parameters. */ struct virtio_net_ctrl_coal_tx { … }; #define VIRTIO_NET_CTRL_NOTF_COAL_TX_SET … /* * Set the rx-usecs/rx-max-packets parameters. */ struct virtio_net_ctrl_coal_rx { … }; #define VIRTIO_NET_CTRL_NOTF_COAL_RX_SET … #define VIRTIO_NET_CTRL_NOTF_COAL_VQ_SET … #define VIRTIO_NET_CTRL_NOTF_COAL_VQ_GET … struct virtio_net_ctrl_coal { … }; struct virtio_net_ctrl_coal_vq { … }; /* * Device Statistics */ #define VIRTIO_NET_CTRL_STATS … #define VIRTIO_NET_CTRL_STATS_QUERY … #define VIRTIO_NET_CTRL_STATS_GET … struct virtio_net_stats_capabilities { … }; struct virtio_net_ctrl_queue_stats { … }; struct virtio_net_stats_reply_hdr { … }; struct virtio_net_stats_cvq { … }; struct virtio_net_stats_rx_basic { … }; struct virtio_net_stats_tx_basic { … }; struct virtio_net_stats_rx_csum { … }; struct virtio_net_stats_tx_csum { … }; struct virtio_net_stats_rx_gso { … }; struct virtio_net_stats_tx_gso { … }; struct virtio_net_stats_rx_speed { … }; struct virtio_net_stats_tx_speed { … }; #endif /* _UAPI_LINUX_VIRTIO_NET_H */