~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/virtio/linux/virtio_config.h

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0 */
  2 #ifndef LINUX_VIRTIO_CONFIG_H
  3 #define LINUX_VIRTIO_CONFIG_H
  4 #include <linux/virtio_byteorder.h>
  5 #include <linux/virtio.h>
  6 #include <uapi/linux/virtio_config.h>
  7 
  8 struct virtio_config_ops {
  9         int (*disable_vq_and_reset)(struct virtqueue *vq);
 10         int (*enable_vq_after_reset)(struct virtqueue *vq);
 11 };
 12 
 13 /*
 14  * __virtio_test_bit - helper to test feature bits. For use by transports.
 15  *                     Devices should normally use virtio_has_feature,
 16  *                     which includes more checks.
 17  * @vdev: the device
 18  * @fbit: the feature bit
 19  */
 20 static inline bool __virtio_test_bit(const struct virtio_device *vdev,
 21                                      unsigned int fbit)
 22 {
 23         return vdev->features & (1ULL << fbit);
 24 }
 25 
 26 /**
 27  * __virtio_set_bit - helper to set feature bits. For use by transports.
 28  * @vdev: the device
 29  * @fbit: the feature bit
 30  */
 31 static inline void __virtio_set_bit(struct virtio_device *vdev,
 32                                     unsigned int fbit)
 33 {
 34         vdev->features |= (1ULL << fbit);
 35 }
 36 
 37 /**
 38  * __virtio_clear_bit - helper to clear feature bits. For use by transports.
 39  * @vdev: the device
 40  * @fbit: the feature bit
 41  */
 42 static inline void __virtio_clear_bit(struct virtio_device *vdev,
 43                                       unsigned int fbit)
 44 {
 45         vdev->features &= ~(1ULL << fbit);
 46 }
 47 
 48 #define virtio_has_feature(dev, feature) \
 49         (__virtio_test_bit((dev), feature))
 50 
 51 /**
 52  * virtio_has_dma_quirk - determine whether this device has the DMA quirk
 53  * @vdev: the device
 54  */
 55 static inline bool virtio_has_dma_quirk(const struct virtio_device *vdev)
 56 {
 57         /*
 58          * Note the reverse polarity of the quirk feature (compared to most
 59          * other features), this is for compatibility with legacy systems.
 60          */
 61         return !virtio_has_feature(vdev, VIRTIO_F_ACCESS_PLATFORM);
 62 }
 63 
 64 static inline bool virtio_is_little_endian(struct virtio_device *vdev)
 65 {
 66         return virtio_has_feature(vdev, VIRTIO_F_VERSION_1) ||
 67                 virtio_legacy_is_little_endian();
 68 }
 69 
 70 /* Memory accessors */
 71 static inline u16 virtio16_to_cpu(struct virtio_device *vdev, __virtio16 val)
 72 {
 73         return __virtio16_to_cpu(virtio_is_little_endian(vdev), val);
 74 }
 75 
 76 static inline __virtio16 cpu_to_virtio16(struct virtio_device *vdev, u16 val)
 77 {
 78         return __cpu_to_virtio16(virtio_is_little_endian(vdev), val);
 79 }
 80 
 81 static inline u32 virtio32_to_cpu(struct virtio_device *vdev, __virtio32 val)
 82 {
 83         return __virtio32_to_cpu(virtio_is_little_endian(vdev), val);
 84 }
 85 
 86 static inline __virtio32 cpu_to_virtio32(struct virtio_device *vdev, u32 val)
 87 {
 88         return __cpu_to_virtio32(virtio_is_little_endian(vdev), val);
 89 }
 90 
 91 static inline u64 virtio64_to_cpu(struct virtio_device *vdev, __virtio64 val)
 92 {
 93         return __virtio64_to_cpu(virtio_is_little_endian(vdev), val);
 94 }
 95 
 96 static inline __virtio64 cpu_to_virtio64(struct virtio_device *vdev, u64 val)
 97 {
 98         return __cpu_to_virtio64(virtio_is_little_endian(vdev), val);
 99 }
100 
101 #endif
102 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php