xref: /spdk/include/linux/virtio_config.h (revision e9a783111092bdc275f540e4ad574b1f051f9968)
1aee263dfSDariusz Stojaczyk #ifndef _LINUX_VIRTIO_CONFIG_H
2aee263dfSDariusz Stojaczyk #define _LINUX_VIRTIO_CONFIG_H
3aee263dfSDariusz Stojaczyk /* This header, excluding the #ifdef __KERNEL__ part, is BSD licensed so
4aee263dfSDariusz Stojaczyk  * anyone can use the definitions to implement compatible drivers/servers.
5aee263dfSDariusz Stojaczyk  *
6aee263dfSDariusz Stojaczyk  * Redistribution and use in source and binary forms, with or without
7aee263dfSDariusz Stojaczyk  * modification, are permitted provided that the following conditions
8aee263dfSDariusz Stojaczyk  * are met:
9aee263dfSDariusz Stojaczyk  * 1. Redistributions of source code must retain the above copyright
10aee263dfSDariusz Stojaczyk  *    notice, this list of conditions and the following disclaimer.
11aee263dfSDariusz Stojaczyk  * 2. Redistributions in binary form must reproduce the above copyright
12aee263dfSDariusz Stojaczyk  *    notice, this list of conditions and the following disclaimer in the
13aee263dfSDariusz Stojaczyk  *    documentation and/or other materials provided with the distribution.
14aee263dfSDariusz Stojaczyk  * 3. Neither the name of IBM nor the names of its contributors
15aee263dfSDariusz Stojaczyk  *    may be used to endorse or promote products derived from this software
16aee263dfSDariusz Stojaczyk  *    without specific prior written permission.
17aee263dfSDariusz Stojaczyk  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND
18aee263dfSDariusz Stojaczyk  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19aee263dfSDariusz Stojaczyk  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20aee263dfSDariusz Stojaczyk  * ARE DISCLAIMED.  IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE
21aee263dfSDariusz Stojaczyk  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22aee263dfSDariusz Stojaczyk  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23aee263dfSDariusz Stojaczyk  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24aee263dfSDariusz Stojaczyk  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25aee263dfSDariusz Stojaczyk  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26aee263dfSDariusz Stojaczyk  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27aee263dfSDariusz Stojaczyk  * SUCH DAMAGE. */
28aee263dfSDariusz Stojaczyk 
29aee263dfSDariusz Stojaczyk /* Virtio devices use a standardized configuration space to define their
30aee263dfSDariusz Stojaczyk  * features and pass configuration information, but each implementation can
31aee263dfSDariusz Stojaczyk  * store and access that space differently. */
32aee263dfSDariusz Stojaczyk #include <linux/types.h>
33aee263dfSDariusz Stojaczyk 
34aee263dfSDariusz Stojaczyk /* Status byte for guest to report progress, and synchronize features. */
35aee263dfSDariusz Stojaczyk /* We have seen device and processed generic fields (VIRTIO_CONFIG_F_VIRTIO) */
36aee263dfSDariusz Stojaczyk #define VIRTIO_CONFIG_S_ACKNOWLEDGE	1
37aee263dfSDariusz Stojaczyk /* We have found a driver for the device. */
38aee263dfSDariusz Stojaczyk #define VIRTIO_CONFIG_S_DRIVER		2
39aee263dfSDariusz Stojaczyk /* Driver has used its parts of the config, and is happy */
40aee263dfSDariusz Stojaczyk #define VIRTIO_CONFIG_S_DRIVER_OK	4
41aee263dfSDariusz Stojaczyk /* Driver has finished configuring features */
42aee263dfSDariusz Stojaczyk #define VIRTIO_CONFIG_S_FEATURES_OK	8
43afd264b3SDariusz Stojaczyk /* Device entered invalid state, driver must reset it */
44afd264b3SDariusz Stojaczyk #define VIRTIO_CONFIG_S_NEEDS_RESET	0x40
45aee263dfSDariusz Stojaczyk /* We've given up on this device. */
46aee263dfSDariusz Stojaczyk #define VIRTIO_CONFIG_S_FAILED		0x80
47aee263dfSDariusz Stojaczyk 
48*e9a78311SJin Yu /*
49*e9a78311SJin Yu  * Virtio feature bits VIRTIO_TRANSPORT_F_START through
50*e9a78311SJin Yu  * VIRTIO_TRANSPORT_F_END are reserved for the transport
51*e9a78311SJin Yu  * being used (e.g. virtio_ring, virtio_pci etc.), the
52*e9a78311SJin Yu  * rest are per-device feature bits.
53*e9a78311SJin Yu  */
54aee263dfSDariusz Stojaczyk #define VIRTIO_TRANSPORT_F_START	28
55*e9a78311SJin Yu #define VIRTIO_TRANSPORT_F_END		38
56aee263dfSDariusz Stojaczyk 
57aee263dfSDariusz Stojaczyk #ifndef VIRTIO_CONFIG_NO_LEGACY
58aee263dfSDariusz Stojaczyk /* Do we get callbacks when the ring is completely used, even if we've
59aee263dfSDariusz Stojaczyk  * suppressed them? */
60aee263dfSDariusz Stojaczyk #define VIRTIO_F_NOTIFY_ON_EMPTY	24
61aee263dfSDariusz Stojaczyk 
62aee263dfSDariusz Stojaczyk /* Can the device handle any descriptor layout? */
63aee263dfSDariusz Stojaczyk #define VIRTIO_F_ANY_LAYOUT		27
64aee263dfSDariusz Stojaczyk #endif /* VIRTIO_CONFIG_NO_LEGACY */
65aee263dfSDariusz Stojaczyk 
66aee263dfSDariusz Stojaczyk /* v1.0 compliant. */
67aee263dfSDariusz Stojaczyk #define VIRTIO_F_VERSION_1		32
68aee263dfSDariusz Stojaczyk 
69afd264b3SDariusz Stojaczyk /*
70afd264b3SDariusz Stojaczyk  * If clear - device has the IOMMU bypass quirk feature.
71afd264b3SDariusz Stojaczyk  * If set - use platform tools to detect the IOMMU.
72afd264b3SDariusz Stojaczyk  *
73afd264b3SDariusz Stojaczyk  * Note the reverse polarity (compared to most other features),
74afd264b3SDariusz Stojaczyk  * this is for compatibility with legacy systems.
75afd264b3SDariusz Stojaczyk  */
76afd264b3SDariusz Stojaczyk #define VIRTIO_F_IOMMU_PLATFORM		33
77*e9a78311SJin Yu 
78*e9a78311SJin Yu /* This feature indicates support for the packed virtqueue layout. */
79*e9a78311SJin Yu #define VIRTIO_F_RING_PACKED		34
80*e9a78311SJin Yu 
81*e9a78311SJin Yu /*
82*e9a78311SJin Yu  * This feature indicates that memory accesses by the driver and the
83*e9a78311SJin Yu  * device are ordered in a way described by the platform.
84*e9a78311SJin Yu  */
85*e9a78311SJin Yu #define VIRTIO_F_ORDER_PLATFORM		36
86*e9a78311SJin Yu 
87*e9a78311SJin Yu /*
88*e9a78311SJin Yu  * Does the device support Single Root I/O Virtualization?
89*e9a78311SJin Yu  */
90*e9a78311SJin Yu #define VIRTIO_F_SR_IOV			37
91aee263dfSDariusz Stojaczyk #endif /* _LINUX_VIRTIO_CONFIG_H */
92