mirror of
https://github.com/torvalds/linux.git
synced 2024-12-05 02:23:16 +00:00
dbe449d8f8
Fix virtio test compilation failure caused by vq reset. ../../drivers/virtio/virtio_ring.c: In function ‘vring_create_virtqueue_packed’: ../../drivers/virtio/virtio_ring.c:1999:8: error: ‘struct virtqueue’ has no member named ‘reset’ 1999 | vq->vq.reset = false; | ^ ../../drivers/virtio/virtio_ring.c: In function ‘__vring_new_virtqueue’: ../../drivers/virtio/virtio_ring.c:2493:8: error: ‘struct virtqueue’ has no member named ‘reset’ 2493 | vq->vq.reset = false; | ^ ../../drivers/virtio/virtio_ring.c: In function ‘virtqueue_resize’: ../../drivers/virtio/virtio_ring.c:2587:18: error: ‘struct virtqueue’ has no member named ‘num_max’ 2587 | if (num > vq->vq.num_max) | ^ ../../drivers/virtio/virtio_ring.c:2596:11: error: ‘struct virtio_device’ has no member named ‘config’ 2596 | if (!vdev->config->disable_vq_and_reset) | ^~ ../../drivers/virtio/virtio_ring.c:2599:11: error: ‘struct virtio_device’ has no member named ‘config’ 2599 | if (!vdev->config->enable_vq_after_reset) | ^~ ../../drivers/virtio/virtio_ring.c:2602:12: error: ‘struct virtio_device’ has no member named ‘config’ 2602 | err = vdev->config->disable_vq_and_reset(_vq); | ^~ ../../drivers/virtio/virtio_ring.c:2614:10: error: ‘struct virtio_device’ has no member named ‘config’ 2614 | if (vdev->config->enable_vq_after_reset(_vq)) | ^~ make: *** [<builtin>: virtio_ring.o] Error 1 Signed-off-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com> Message-Id: <20220830110549.103168-1-xuanzhuo@linux.alibaba.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
98 lines
2.7 KiB
C
98 lines
2.7 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#include <linux/virtio_byteorder.h>
|
|
#include <linux/virtio.h>
|
|
#include <uapi/linux/virtio_config.h>
|
|
|
|
struct virtio_config_ops {
|
|
int (*disable_vq_and_reset)(struct virtqueue *vq);
|
|
int (*enable_vq_after_reset)(struct virtqueue *vq);
|
|
};
|
|
|
|
/*
|
|
* __virtio_test_bit - helper to test feature bits. For use by transports.
|
|
* Devices should normally use virtio_has_feature,
|
|
* which includes more checks.
|
|
* @vdev: the device
|
|
* @fbit: the feature bit
|
|
*/
|
|
static inline bool __virtio_test_bit(const struct virtio_device *vdev,
|
|
unsigned int fbit)
|
|
{
|
|
return vdev->features & (1ULL << fbit);
|
|
}
|
|
|
|
/**
|
|
* __virtio_set_bit - helper to set feature bits. For use by transports.
|
|
* @vdev: the device
|
|
* @fbit: the feature bit
|
|
*/
|
|
static inline void __virtio_set_bit(struct virtio_device *vdev,
|
|
unsigned int fbit)
|
|
{
|
|
vdev->features |= (1ULL << fbit);
|
|
}
|
|
|
|
/**
|
|
* __virtio_clear_bit - helper to clear feature bits. For use by transports.
|
|
* @vdev: the device
|
|
* @fbit: the feature bit
|
|
*/
|
|
static inline void __virtio_clear_bit(struct virtio_device *vdev,
|
|
unsigned int fbit)
|
|
{
|
|
vdev->features &= ~(1ULL << fbit);
|
|
}
|
|
|
|
#define virtio_has_feature(dev, feature) \
|
|
(__virtio_test_bit((dev), feature))
|
|
|
|
/**
|
|
* virtio_has_dma_quirk - determine whether this device has the DMA quirk
|
|
* @vdev: the device
|
|
*/
|
|
static inline bool virtio_has_dma_quirk(const struct virtio_device *vdev)
|
|
{
|
|
/*
|
|
* Note the reverse polarity of the quirk feature (compared to most
|
|
* other features), this is for compatibility with legacy systems.
|
|
*/
|
|
return !virtio_has_feature(vdev, VIRTIO_F_ACCESS_PLATFORM);
|
|
}
|
|
|
|
static inline bool virtio_is_little_endian(struct virtio_device *vdev)
|
|
{
|
|
return virtio_has_feature(vdev, VIRTIO_F_VERSION_1) ||
|
|
virtio_legacy_is_little_endian();
|
|
}
|
|
|
|
/* Memory accessors */
|
|
static inline u16 virtio16_to_cpu(struct virtio_device *vdev, __virtio16 val)
|
|
{
|
|
return __virtio16_to_cpu(virtio_is_little_endian(vdev), val);
|
|
}
|
|
|
|
static inline __virtio16 cpu_to_virtio16(struct virtio_device *vdev, u16 val)
|
|
{
|
|
return __cpu_to_virtio16(virtio_is_little_endian(vdev), val);
|
|
}
|
|
|
|
static inline u32 virtio32_to_cpu(struct virtio_device *vdev, __virtio32 val)
|
|
{
|
|
return __virtio32_to_cpu(virtio_is_little_endian(vdev), val);
|
|
}
|
|
|
|
static inline __virtio32 cpu_to_virtio32(struct virtio_device *vdev, u32 val)
|
|
{
|
|
return __cpu_to_virtio32(virtio_is_little_endian(vdev), val);
|
|
}
|
|
|
|
static inline u64 virtio64_to_cpu(struct virtio_device *vdev, __virtio64 val)
|
|
{
|
|
return __virtio64_to_cpu(virtio_is_little_endian(vdev), val);
|
|
}
|
|
|
|
static inline __virtio64 cpu_to_virtio64(struct virtio_device *vdev, u64 val)
|
|
{
|
|
return __cpu_to_virtio64(virtio_is_little_endian(vdev), val);
|
|
}
|