Add the rt linux 4.1.3-rt3 as base
[kvmfornfv.git] / kernel / tools / virtio / linux / virtio_config.h
1 #include <linux/virtio_byteorder.h>
2 #include <linux/virtio.h>
3 #include <uapi/linux/virtio_config.h>
4
5 /*
6  * __virtio_test_bit - helper to test feature bits. For use by transports.
7  *                     Devices should normally use virtio_has_feature,
8  *                     which includes more checks.
9  * @vdev: the device
10  * @fbit: the feature bit
11  */
12 static inline bool __virtio_test_bit(const struct virtio_device *vdev,
13                                      unsigned int fbit)
14 {
15         return vdev->features & (1ULL << fbit);
16 }
17
18 /**
19  * __virtio_set_bit - helper to set feature bits. For use by transports.
20  * @vdev: the device
21  * @fbit: the feature bit
22  */
23 static inline void __virtio_set_bit(struct virtio_device *vdev,
24                                     unsigned int fbit)
25 {
26         vdev->features |= (1ULL << fbit);
27 }
28
29 /**
30  * __virtio_clear_bit - helper to clear feature bits. For use by transports.
31  * @vdev: the device
32  * @fbit: the feature bit
33  */
34 static inline void __virtio_clear_bit(struct virtio_device *vdev,
35                                       unsigned int fbit)
36 {
37         vdev->features &= ~(1ULL << fbit);
38 }
39
40 #define virtio_has_feature(dev, feature) \
41         (__virtio_test_bit((dev), feature))
42
43 static inline u16 virtio16_to_cpu(struct virtio_device *vdev, __virtio16 val)
44 {
45         return __virtio16_to_cpu(virtio_has_feature(vdev, VIRTIO_F_VERSION_1), val);
46 }
47
48 static inline __virtio16 cpu_to_virtio16(struct virtio_device *vdev, u16 val)
49 {
50         return __cpu_to_virtio16(virtio_has_feature(vdev, VIRTIO_F_VERSION_1), val);
51 }
52
53 static inline u32 virtio32_to_cpu(struct virtio_device *vdev, __virtio32 val)
54 {
55         return __virtio32_to_cpu(virtio_has_feature(vdev, VIRTIO_F_VERSION_1), val);
56 }
57
58 static inline __virtio32 cpu_to_virtio32(struct virtio_device *vdev, u32 val)
59 {
60         return __cpu_to_virtio32(virtio_has_feature(vdev, VIRTIO_F_VERSION_1), val);
61 }
62
63 static inline u64 virtio64_to_cpu(struct virtio_device *vdev, __virtio64 val)
64 {
65         return __virtio64_to_cpu(virtio_has_feature(vdev, VIRTIO_F_VERSION_1), val);
66 }
67
68 static inline __virtio64 cpu_to_virtio64(struct virtio_device *vdev, u64 val)
69 {
70         return __cpu_to_virtio64(virtio_has_feature(vdev, VIRTIO_F_VERSION_1), val);
71 }
72