[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v15 06/10] virtio: add support for configure interrupt
From: |
Cindy Lu |
Subject: |
[PATCH v15 06/10] virtio: add support for configure interrupt |
Date: |
Sun, 24 Jul 2022 14:44:50 +0800 |
Add the functions to support the configure interrupt in virtio
The function virtio_config_guest_notifier_read will notify the
guest if there is an configure interrupt.
The function virtio_config_set_guest_notifier_fd_handler is
to set the fd hander for the notifier
Signed-off-by: Cindy Lu <lulu@redhat.com>
---
hw/virtio/virtio.c | 29 +++++++++++++++++++++++++++++
include/hw/virtio/virtio.h | 4 ++++
2 files changed, 33 insertions(+)
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index 5d607aeaa0..ab1b46ae28 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -3521,7 +3521,14 @@ static void
virtio_queue_guest_notifier_read(EventNotifier *n)
virtio_irq(vq);
}
}
+static void virtio_config_guest_notifier_read(EventNotifier *n)
+{
+ VirtIODevice *vdev = container_of(n, VirtIODevice, config_notifier);
+ if (event_notifier_test_and_clear(n)) {
+ virtio_notify_config(vdev);
+ }
+}
void virtio_queue_set_guest_notifier_fd_handler(VirtQueue *vq, bool assign,
bool with_irqfd)
{
@@ -3538,6 +3545,23 @@ void
virtio_queue_set_guest_notifier_fd_handler(VirtQueue *vq, bool assign,
}
}
+void virtio_config_set_guest_notifier_fd_handler(VirtIODevice *vdev,
+ bool assign, bool with_irqfd)
+{
+ EventNotifier *n;
+ n = &vdev->config_notifier;
+ if (assign && !with_irqfd) {
+ event_notifier_set_handler(n, virtio_config_guest_notifier_read);
+ } else {
+ event_notifier_set_handler(n, NULL);
+ }
+ if (!assign) {
+ /* Test and clear notifier before closing it,*/
+ /* in case poll callback didn't have time to run. */
+ virtio_config_guest_notifier_read(n);
+ }
+}
+
EventNotifier *virtio_queue_get_guest_notifier(VirtQueue *vq)
{
return &vq->guest_notifier;
@@ -3618,6 +3642,11 @@ EventNotifier *virtio_queue_get_host_notifier(VirtQueue
*vq)
return &vq->host_notifier;
}
+EventNotifier *virtio_config_get_guest_notifier(VirtIODevice *vdev)
+{
+ return &vdev->config_notifier;
+}
+
void virtio_queue_set_host_notifier_enabled(VirtQueue *vq, bool enabled)
{
vq->host_notifier_enabled = enabled;
diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
index e985ef133f..a7b8cebb60 100644
--- a/include/hw/virtio/virtio.h
+++ b/include/hw/virtio/virtio.h
@@ -113,6 +113,7 @@ struct VirtIODevice
bool use_guest_notifier_mask;
AddressSpace *dma_as;
QLIST_HEAD(, VirtQueue) *vector_queues;
+ EventNotifier config_notifier;
};
struct VirtioDeviceClass {
@@ -327,6 +328,9 @@ void
virtio_queue_aio_attach_host_notifier_no_poll(VirtQueue *vq, AioContext *ct
void virtio_queue_aio_detach_host_notifier(VirtQueue *vq, AioContext *ctx);
VirtQueue *virtio_vector_first_queue(VirtIODevice *vdev, uint16_t vector);
VirtQueue *virtio_vector_next_queue(VirtQueue *vq);
+EventNotifier *virtio_config_get_guest_notifier(VirtIODevice *vdev);
+void virtio_config_set_guest_notifier_fd_handler(VirtIODevice *vdev,
+ bool assign, bool with_irqfd);
static inline void virtio_add_feature(uint64_t *features, unsigned int fbit)
{
--
2.34.3
- [PATCH v15 00/10] vhost-vdpa: add support for configure interrupt, Cindy Lu, 2022/07/24
- [PATCH v15 01/10] virtio: introduce macro VIRTIO_CONFIG_IRQ_IDX, Cindy Lu, 2022/07/24
- [PATCH v15 03/10] virtio-pci: decouple the single vector from the interrupt process, Cindy Lu, 2022/07/24
- [PATCH v15 02/10] virtio-pci: decouple notifier from interrupt process, Cindy Lu, 2022/07/24
- [PATCH v15 04/10] vhost: introduce new VhostOps vhost_set_config_call, Cindy Lu, 2022/07/24
- [PATCH v15 05/10] vhost-vdpa: add support for config interrupt, Cindy Lu, 2022/07/24
- [PATCH v15 06/10] virtio: add support for configure interrupt,
Cindy Lu <=
- [PATCH v15 07/10] vhost: add support for configure interrupt, Cindy Lu, 2022/07/24
- [PATCH v15 08/10] virtio-net: add support for configure interrupt, Cindy Lu, 2022/07/24
- [PATCH v15 09/10] virtio-mmio: add support for configure interrupt, Cindy Lu, 2022/07/24
- [PATCH v15 10/10] virtio-pci: add support for configure interrupt, Cindy Lu, 2022/07/24
- Re: [PATCH v15 00/10] vhost-vdpa: add support for configure interrupt, Michael S. Tsirkin, 2022/07/26