[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 39/86] virtio: introduce virtio_queue_enable()
From: |
Michael S. Tsirkin |
Subject: |
[PULL 39/86] virtio: introduce virtio_queue_enable() |
Date: |
Mon, 31 Oct 2022 08:52:34 -0400 |
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>
Message-Id: <20221017092558.111082-4-xuanzhuo@linux.alibaba.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
include/hw/virtio/virtio.h | 2 ++
hw/virtio/virtio.c | 14 ++++++++++++++
2 files changed, 16 insertions(+)
diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
index b4c237201d..5cd7861aeb 100644
--- a/include/hw/virtio/virtio.h
+++ b/include/hw/virtio/virtio.h
@@ -149,6 +149,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.
@@ -288,6 +289,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);
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index cf5f9ca387..9683b2e158 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -2495,6 +2495,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;
--
MST
- [PULL 33/86] vhost: Change the sequence of device start, (continued)
- [PULL 33/86] vhost: Change the sequence of device start, Michael S. Tsirkin, 2022/10/31
- [PULL 19/86] bios-tables-test: teach test to use smbios 3.0 tables, Michael S. Tsirkin, 2022/10/31
- [PULL 26/86] tests/acpi: virt: update ACPI MADT and FADT binaries, Michael S. Tsirkin, 2022/10/31
- [PULL 31/86] hw/pci-bridge/cxl-upstream: Add a CDAT table access DOE, Michael S. Tsirkin, 2022/10/31
- [PULL 35/86] hw/virtio/virtio-iommu-pci: Enforce the device is plugged on the root bus, Michael S. Tsirkin, 2022/10/31
- [PULL 36/86] virtio: re-order vm_running and use_started checks, Michael S. Tsirkin, 2022/10/31
- [PULL 37/86] virtio: introduce __virtio_queue_reset(), Michael S. Tsirkin, 2022/10/31
- [PULL 38/86] virtio: introduce virtio_queue_reset(), Michael S. Tsirkin, 2022/10/31
- [PULL 28/86] hw/mem/cxl-type3: Add MSIX support, Michael S. Tsirkin, 2022/10/31
- [PULL 34/86] vhost-user: Support vhost_dev_start, Michael S. Tsirkin, 2022/10/31
- [PULL 39/86] virtio: introduce virtio_queue_enable(),
Michael S. Tsirkin <=
- [PULL 40/86] virtio: core: vq reset feature negotation support, Michael S. Tsirkin, 2022/10/31
- [PULL 41/86] virtio-pci: support queue reset, Michael S. Tsirkin, 2022/10/31
- [PULL 42/86] virtio-pci: support queue enable, Michael S. Tsirkin, 2022/10/31
- [PULL 43/86] vhost: expose vhost_virtqueue_start(), Michael S. Tsirkin, 2022/10/31
- [PULL 44/86] vhost: expose vhost_virtqueue_stop(), Michael S. Tsirkin, 2022/10/31
- [PULL 45/86] vhost-net: vhost-kernel: introduce vhost_net_virtqueue_reset(), Michael S. Tsirkin, 2022/10/31
- [PULL 46/86] vhost-net: vhost-kernel: introduce vhost_net_virtqueue_restart(), Michael S. Tsirkin, 2022/10/31
- [PULL 47/86] virtio-net: introduce flush_or_purge_queued_packets(), Michael S. Tsirkin, 2022/10/31
- [PULL 49/86] virtio-net: support queue_enable, Michael S. Tsirkin, 2022/10/31
- [PULL 48/86] virtio-net: support queue reset, Michael S. Tsirkin, 2022/10/31