xref: /kvmtool/include/linux/virtio_config.h (revision 9968468141fc441d2bc9891ea59ae09eb1e358bf)
11a992bbaSAndre Przywara #ifndef _UAPI_LINUX_VIRTIO_CONFIG_H
21a992bbaSAndre Przywara #define _UAPI_LINUX_VIRTIO_CONFIG_H
31a992bbaSAndre Przywara /* This header, excluding the #ifdef __KERNEL__ part, is BSD licensed so
41a992bbaSAndre Przywara  * anyone can use the definitions to implement compatible drivers/servers.
51a992bbaSAndre Przywara  *
61a992bbaSAndre Przywara  * Redistribution and use in source and binary forms, with or without
71a992bbaSAndre Przywara  * modification, are permitted provided that the following conditions
81a992bbaSAndre Przywara  * are met:
91a992bbaSAndre Przywara  * 1. Redistributions of source code must retain the above copyright
101a992bbaSAndre Przywara  *    notice, this list of conditions and the following disclaimer.
111a992bbaSAndre Przywara  * 2. Redistributions in binary form must reproduce the above copyright
121a992bbaSAndre Przywara  *    notice, this list of conditions and the following disclaimer in the
131a992bbaSAndre Przywara  *    documentation and/or other materials provided with the distribution.
141a992bbaSAndre Przywara  * 3. Neither the name of IBM nor the names of its contributors
151a992bbaSAndre Przywara  *    may be used to endorse or promote products derived from this software
161a992bbaSAndre Przywara  *    without specific prior written permission.
171a992bbaSAndre Przywara  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND
181a992bbaSAndre Przywara  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
191a992bbaSAndre Przywara  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
201a992bbaSAndre Przywara  * ARE DISCLAIMED.  IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE
211a992bbaSAndre Przywara  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
221a992bbaSAndre Przywara  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
231a992bbaSAndre Przywara  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
241a992bbaSAndre Przywara  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
251a992bbaSAndre Przywara  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
261a992bbaSAndre Przywara  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
271a992bbaSAndre Przywara  * SUCH DAMAGE. */
281a992bbaSAndre Przywara 
291a992bbaSAndre Przywara /* Virtio devices use a standardized configuration space to define their
301a992bbaSAndre Przywara  * features and pass configuration information, but each implementation can
311a992bbaSAndre Przywara  * store and access that space differently. */
321a992bbaSAndre Przywara #include <linux/types.h>
331a992bbaSAndre Przywara 
341a992bbaSAndre Przywara /* Status byte for guest to report progress, and synchronize features. */
351a992bbaSAndre Przywara /* We have seen device and processed generic fields (VIRTIO_CONFIG_F_VIRTIO) */
361a992bbaSAndre Przywara #define VIRTIO_CONFIG_S_ACKNOWLEDGE	1
371a992bbaSAndre Przywara /* We have found a driver for the device. */
381a992bbaSAndre Przywara #define VIRTIO_CONFIG_S_DRIVER		2
391a992bbaSAndre Przywara /* Driver has used its parts of the config, and is happy */
401a992bbaSAndre Przywara #define VIRTIO_CONFIG_S_DRIVER_OK	4
411a992bbaSAndre Przywara /* Driver has finished configuring features */
421a992bbaSAndre Przywara #define VIRTIO_CONFIG_S_FEATURES_OK	8
431a992bbaSAndre Przywara /* Device entered invalid state, driver must reset it */
441a992bbaSAndre Przywara #define VIRTIO_CONFIG_S_NEEDS_RESET	0x40
451a992bbaSAndre Przywara /* We've given up on this device. */
461a992bbaSAndre Przywara #define VIRTIO_CONFIG_S_FAILED		0x80
471a992bbaSAndre Przywara 
481a992bbaSAndre Przywara /*
491a992bbaSAndre Przywara  * Virtio feature bits VIRTIO_TRANSPORT_F_START through
501a992bbaSAndre Przywara  * VIRTIO_TRANSPORT_F_END are reserved for the transport
511a992bbaSAndre Przywara  * being used (e.g. virtio_ring, virtio_pci etc.), the
521a992bbaSAndre Przywara  * rest are per-device feature bits.
531a992bbaSAndre Przywara  */
541a992bbaSAndre Przywara #define VIRTIO_TRANSPORT_F_START	28
55*99684681SAnup Patel #define VIRTIO_TRANSPORT_F_END		42
561a992bbaSAndre Przywara 
571a992bbaSAndre Przywara #ifndef VIRTIO_CONFIG_NO_LEGACY
581a992bbaSAndre Przywara /* Do we get callbacks when the ring is completely used, even if we've
591a992bbaSAndre Przywara  * suppressed them? */
601a992bbaSAndre Przywara #define VIRTIO_F_NOTIFY_ON_EMPTY	24
611a992bbaSAndre Przywara 
621a992bbaSAndre Przywara /* Can the device handle any descriptor layout? */
631a992bbaSAndre Przywara #define VIRTIO_F_ANY_LAYOUT		27
641a992bbaSAndre Przywara #endif /* VIRTIO_CONFIG_NO_LEGACY */
651a992bbaSAndre Przywara 
661a992bbaSAndre Przywara /* v1.0 compliant. */
671a992bbaSAndre Przywara #define VIRTIO_F_VERSION_1		32
681a992bbaSAndre Przywara 
691a992bbaSAndre Przywara /*
701a992bbaSAndre Przywara  * If clear - device has the platform DMA (e.g. IOMMU) bypass quirk feature.
711a992bbaSAndre Przywara  * If set - use platform DMA tools to access the memory.
721a992bbaSAndre Przywara  *
731a992bbaSAndre Przywara  * Note the reverse polarity (compared to most other features),
741a992bbaSAndre Przywara  * this is for compatibility with legacy systems.
751a992bbaSAndre Przywara  */
761a992bbaSAndre Przywara #define VIRTIO_F_ACCESS_PLATFORM	33
771a992bbaSAndre Przywara #ifndef __KERNEL__
781a992bbaSAndre Przywara /* Legacy name for VIRTIO_F_ACCESS_PLATFORM (for compatibility with old userspace) */
791a992bbaSAndre Przywara #define VIRTIO_F_IOMMU_PLATFORM		VIRTIO_F_ACCESS_PLATFORM
801a992bbaSAndre Przywara #endif /* __KERNEL__ */
811a992bbaSAndre Przywara 
821a992bbaSAndre Przywara /* This feature indicates support for the packed virtqueue layout. */
831a992bbaSAndre Przywara #define VIRTIO_F_RING_PACKED		34
841a992bbaSAndre Przywara 
851a992bbaSAndre Przywara /*
861a992bbaSAndre Przywara  * Inorder feature indicates that all buffers are used by the device
871a992bbaSAndre Przywara  * in the same order in which they have been made available.
881a992bbaSAndre Przywara  */
891a992bbaSAndre Przywara #define VIRTIO_F_IN_ORDER		35
901a992bbaSAndre Przywara 
911a992bbaSAndre Przywara /*
921a992bbaSAndre Przywara  * This feature indicates that memory accesses by the driver and the
931a992bbaSAndre Przywara  * device are ordered in a way described by the platform.
941a992bbaSAndre Przywara  */
951a992bbaSAndre Przywara #define VIRTIO_F_ORDER_PLATFORM		36
961a992bbaSAndre Przywara 
971a992bbaSAndre Przywara /*
981a992bbaSAndre Przywara  * Does the device support Single Root I/O Virtualization?
991a992bbaSAndre Przywara  */
1001a992bbaSAndre Przywara #define VIRTIO_F_SR_IOV			37
1018d0facecSAnup Patel 
1028d0facecSAnup Patel /*
103be986824SAnup Patel  * This feature indicates that the driver passes extra data (besides
104be986824SAnup Patel  * identifying the virtqueue) in its device notifications.
105be986824SAnup Patel  */
106be986824SAnup Patel #define VIRTIO_F_NOTIFICATION_DATA	38
107be986824SAnup Patel 
10892ef2dcdSWill Deacon /* This feature indicates that the driver uses the data provided by the device
10992ef2dcdSWill Deacon  * as a virtqueue identifier in available buffer notifications.
11092ef2dcdSWill Deacon  */
11192ef2dcdSWill Deacon #define VIRTIO_F_NOTIF_CONFIG_DATA	39
11292ef2dcdSWill Deacon 
113be986824SAnup Patel /*
1148d0facecSAnup Patel  * This feature indicates that the driver can reset a queue individually.
1158d0facecSAnup Patel  */
1168d0facecSAnup Patel #define VIRTIO_F_RING_RESET		40
117*99684681SAnup Patel 
118*99684681SAnup Patel /*
119*99684681SAnup Patel  * This feature indicates that the device support administration virtqueues.
120*99684681SAnup Patel  */
121*99684681SAnup Patel #define VIRTIO_F_ADMIN_VQ		41
122*99684681SAnup Patel 
1231a992bbaSAndre Przywara #endif /* _UAPI_LINUX_VIRTIO_CONFIG_H */
124