[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v5 04/15] virtio: introduce virtio_queue_enable()
From: |
Xuan Zhuo |
Subject: |
[PATCH v5 04/15] virtio: introduce virtio_queue_enable() |
Date: |
Wed, 14 Sep 2022 12:20:44 +0800 |
From: Kangjie Xu <kangjie.xu@linux.alibaba.com>
Introduce the interface queue_enable() in VirtioDeviceClass and the
fucntion virtio_queue_enable() in virtio, it can be called when
VIRTIO_PCI_COMMON_Q_ENABLE is written and related virtqueue can be
started. It only supports the devices of virtio 1 or later. The
not-supported devices can only start the virtqueue when DRIVER_OK.
Signed-off-by: Kangjie Xu <kangjie.xu@linux.alibaba.com>
Signed-off-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
Acked-by: Jason Wang <jasowang@redhat.com>
---
hw/virtio/virtio.c | 14 ++++++++++++++
include/hw/virtio/virtio.h | 2 ++
2 files changed, 16 insertions(+)
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index 0e9d41366f..141f18c633 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -2050,6 +2050,20 @@ void virtio_queue_reset(VirtIODevice *vdev, uint32_t
queue_index)
__virtio_queue_reset(vdev, queue_index);
}
+void virtio_queue_enable(VirtIODevice *vdev, uint32_t queue_index)
+{
+ VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev);
+
+ if (!virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1)) {
+ error_report("queue_enable is only suppported in devices of virtio "
+ "1.0 or later.");
+ }
+
+ if (k->queue_enable) {
+ k->queue_enable(vdev, queue_index);
+ }
+}
+
void virtio_reset(void *opaque)
{
VirtIODevice *vdev = opaque;
diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
index 879394299b..085997d8f3 100644
--- a/include/hw/virtio/virtio.h
+++ b/include/hw/virtio/virtio.h
@@ -131,6 +131,7 @@ struct VirtioDeviceClass {
void (*reset)(VirtIODevice *vdev);
void (*set_status)(VirtIODevice *vdev, uint8_t val);
void (*queue_reset)(VirtIODevice *vdev, uint32_t queue_index);
+ void (*queue_enable)(VirtIODevice *vdev, uint32_t queue_index);
/* For transitional devices, this is a bitmap of features
* that are only exposed on the legacy interface but not
* the modern one.
@@ -270,6 +271,7 @@ int virtio_queue_set_host_notifier_mr(VirtIODevice *vdev,
int n,
int virtio_set_status(VirtIODevice *vdev, uint8_t val);
void virtio_reset(void *opaque);
void virtio_queue_reset(VirtIODevice *vdev, uint32_t queue_index);
+void virtio_queue_enable(VirtIODevice *vdev, uint32_t queue_index);
void virtio_update_irq(VirtIODevice *vdev);
int virtio_set_features(VirtIODevice *vdev, uint64_t val);
--
2.32.0.3.g01195cf9f
- Re: [PATCH v5 15/15] vhost: vhost-kernel: enable vq reset feature, (continued)
- [PATCH v5 07/15] virtio-pci: support queue enable, Xuan Zhuo, 2022/09/14
- [PATCH v5 01/15] virtio: sync relevant definitions with linux, Xuan Zhuo, 2022/09/14
- [PATCH v5 14/15] virtio-net: support queue_enable, Xuan Zhuo, 2022/09/14
- [PATCH v5 05/15] virtio: core: vq reset feature negotation support, Xuan Zhuo, 2022/09/14
- [PATCH v5 02/15] virtio: introduce __virtio_queue_reset(), Xuan Zhuo, 2022/09/14
- [PATCH v5 11/15] vhost-net: vhost-kernel: introduce vhost_net_virtqueue_restart(), Xuan Zhuo, 2022/09/14
- [PATCH v5 06/15] virtio-pci: support queue reset, Xuan Zhuo, 2022/09/14
- [PATCH v5 13/15] virtio-net: support queue reset, Xuan Zhuo, 2022/09/14
- [PATCH v5 04/15] virtio: introduce virtio_queue_enable(),
Xuan Zhuo <=