xref: /linux/include/uapi/linux/virtio_config.h (revision f0b7a0d1d46625db5b0e631c05ae96d78eda6c70)
1607ca46eSDavid Howells #ifndef _UAPI_LINUX_VIRTIO_CONFIG_H
2607ca46eSDavid Howells #define _UAPI_LINUX_VIRTIO_CONFIG_H
3607ca46eSDavid Howells /* This header, excluding the #ifdef __KERNEL__ part, is BSD licensed so
4607ca46eSDavid Howells  * anyone can use the definitions to implement 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 
29607ca46eSDavid Howells /* Virtio devices use a standardized configuration space to define their
30607ca46eSDavid Howells  * features and pass configuration information, but each implementation can
31607ca46eSDavid Howells  * store and access that space differently. */
32607ca46eSDavid Howells #include <linux/types.h>
33607ca46eSDavid Howells 
34607ca46eSDavid Howells /* Status byte for guest to report progress, and synchronize features. */
35607ca46eSDavid Howells /* We have seen device and processed generic fields (VIRTIO_CONFIG_F_VIRTIO) */
36607ca46eSDavid Howells #define VIRTIO_CONFIG_S_ACKNOWLEDGE	1
37607ca46eSDavid Howells /* We have found a driver for the device. */
38607ca46eSDavid Howells #define VIRTIO_CONFIG_S_DRIVER		2
39607ca46eSDavid Howells /* Driver has used its parts of the config, and is happy */
40607ca46eSDavid Howells #define VIRTIO_CONFIG_S_DRIVER_OK	4
41cb3f6d9dSMichael S. Tsirkin /* Driver has finished configuring features */
42cb3f6d9dSMichael S. Tsirkin #define VIRTIO_CONFIG_S_FEATURES_OK	8
43c00bbcf8SStefan Hajnoczi /* Device entered invalid state, driver must reset it */
44c00bbcf8SStefan Hajnoczi #define VIRTIO_CONFIG_S_NEEDS_RESET	0x40
45607ca46eSDavid Howells /* We've given up on this device. */
46607ca46eSDavid Howells #define VIRTIO_CONFIG_S_FAILED		0x80
47607ca46eSDavid Howells 
482eb98105STiwei Bie /*
492eb98105STiwei Bie  * Virtio feature bits VIRTIO_TRANSPORT_F_START through
502eb98105STiwei Bie  * VIRTIO_TRANSPORT_F_END are reserved for the transport
512eb98105STiwei Bie  * being used (e.g. virtio_ring, virtio_pci etc.), the
522eb98105STiwei Bie  * rest are per-device feature bits.
532eb98105STiwei Bie  */
54607ca46eSDavid Howells #define VIRTIO_TRANSPORT_F_START	28
55*838bebb4SFeng Liu #define VIRTIO_TRANSPORT_F_END		42
56607ca46eSDavid Howells 
576d96ee98SRusty Russell #ifndef VIRTIO_CONFIG_NO_LEGACY
58607ca46eSDavid Howells /* Do we get callbacks when the ring is completely used, even if we've
59607ca46eSDavid Howells  * suppressed them? */
60607ca46eSDavid Howells #define VIRTIO_F_NOTIFY_ON_EMPTY	24
61607ca46eSDavid Howells 
6262525a00SRusty Russell /* Can the device handle any descriptor layout? */
6362525a00SRusty Russell #define VIRTIO_F_ANY_LAYOUT		27
646d96ee98SRusty Russell #endif /* VIRTIO_CONFIG_NO_LEGACY */
6562525a00SRusty Russell 
664ec22faeSMichael S. Tsirkin /* v1.0 compliant. */
674ec22faeSMichael S. Tsirkin #define VIRTIO_F_VERSION_1		32
684ec22faeSMichael S. Tsirkin 
691a937693SMichael S. Tsirkin /*
70321bd212SMichael S. Tsirkin  * If clear - device has the platform DMA (e.g. IOMMU) bypass quirk feature.
71321bd212SMichael S. Tsirkin  * If set - use platform DMA tools to access the memory.
721a937693SMichael S. Tsirkin  *
731a937693SMichael S. Tsirkin  * Note the reverse polarity (compared to most other features),
741a937693SMichael S. Tsirkin  * this is for compatibility with legacy systems.
751a937693SMichael S. Tsirkin  */
76321bd212SMichael S. Tsirkin #define VIRTIO_F_ACCESS_PLATFORM	33
77321bd212SMichael S. Tsirkin #ifndef __KERNEL__
78321bd212SMichael S. Tsirkin /* Legacy name for VIRTIO_F_ACCESS_PLATFORM (for compatibility with old userspace) */
79321bd212SMichael S. Tsirkin #define VIRTIO_F_IOMMU_PLATFORM		VIRTIO_F_ACCESS_PLATFORM
80321bd212SMichael S. Tsirkin #endif /* __KERNEL__ */
81cfecc291STiwei Bie 
8289a9157eSTiwei Bie /* This feature indicates support for the packed virtqueue layout. */
8389a9157eSTiwei Bie #define VIRTIO_F_RING_PACKED		34
8489a9157eSTiwei Bie 
85cfecc291STiwei Bie /*
8690a6951bSGautam Dawar  * Inorder feature indicates that all buffers are used by the device
8790a6951bSGautam Dawar  * in the same order in which they have been made available.
8890a6951bSGautam Dawar  */
8990a6951bSGautam Dawar #define VIRTIO_F_IN_ORDER		35
9090a6951bSGautam Dawar 
9190a6951bSGautam Dawar /*
9245383fb0STiwei Bie  * This feature indicates that memory accesses by the driver and the
9345383fb0STiwei Bie  * device are ordered in a way described by the platform.
9445383fb0STiwei Bie  */
9545383fb0STiwei Bie #define VIRTIO_F_ORDER_PLATFORM		36
9645383fb0STiwei Bie 
9745383fb0STiwei Bie /*
98cfecc291STiwei Bie  * Does the device support Single Root I/O Virtualization?
99cfecc291STiwei Bie  */
100cfecc291STiwei Bie #define VIRTIO_F_SR_IOV			37
101d94587b5SXuan Zhuo 
102d94587b5SXuan Zhuo /*
103af8ececdSViktor Prutyanov  * This feature indicates that the driver passes extra data (besides
104af8ececdSViktor Prutyanov  * identifying the virtqueue) in its device notifications.
105af8ececdSViktor Prutyanov  */
106af8ececdSViktor Prutyanov #define VIRTIO_F_NOTIFICATION_DATA	38
107af8ececdSViktor Prutyanov 
10870e16c90SXuan Zhuo /* This feature indicates that the driver uses the data provided by the device
10970e16c90SXuan Zhuo  * as a virtqueue identifier in available buffer notifications.
11070e16c90SXuan Zhuo  */
11170e16c90SXuan Zhuo #define VIRTIO_F_NOTIF_CONFIG_DATA	39
11270e16c90SXuan Zhuo 
113af8ececdSViktor Prutyanov /*
114d94587b5SXuan Zhuo  * This feature indicates that the driver can reset a queue individually.
115d94587b5SXuan Zhuo  */
116d94587b5SXuan Zhuo #define VIRTIO_F_RING_RESET		40
117*838bebb4SFeng Liu 
118*838bebb4SFeng Liu /*
119*838bebb4SFeng Liu  * This feature indicates that the device support administration virtqueues.
120*838bebb4SFeng Liu  */
121*838bebb4SFeng Liu #define VIRTIO_F_ADMIN_VQ		41
122*838bebb4SFeng Liu 
123607ca46eSDavid Howells #endif /* _UAPI_LINUX_VIRTIO_CONFIG_H */
124