|
Justin M. Forbes |
272dfe |
vhost needs physical addresses for ring and other queue fields,
|
|
Justin M. Forbes |
272dfe |
so add APIs for these.
|
|
Justin M. Forbes |
272dfe |
|
|
Justin M. Forbes |
272dfe |
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
|
Justin M. Forbes |
272dfe |
---
|
|
Justin M. Forbes |
272dfe |
hw/virtio.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++----
|
|
Justin M. Forbes |
272dfe |
hw/virtio.h | 10 +++++++++-
|
|
Justin M. Forbes |
272dfe |
2 files changed, 56 insertions(+), 5 deletions(-)
|
|
Justin M. Forbes |
272dfe |
|
|
Justin M. Forbes |
272dfe |
diff --git a/hw/virtio.c b/hw/virtio.c
|
|
Justin M. Forbes |
272dfe |
index c2b80aa..b16ee1a 100644
|
|
Justin M. Forbes |
272dfe |
--- a/hw/virtio.c
|
|
Justin M. Forbes |
272dfe |
+++ b/hw/virtio.c
|
|
Justin M. Forbes |
272dfe |
@@ -73,6 +73,9 @@ struct VirtQueue
|
|
Justin M. Forbes |
272dfe |
int inuse;
|
|
Justin M. Forbes |
272dfe |
uint16_t vector;
|
|
Justin M. Forbes |
272dfe |
void (*handle_output)(VirtIODevice *vdev, VirtQueue *vq);
|
|
Justin M. Forbes |
272dfe |
+ VirtIODevice *vdev;
|
|
Justin M. Forbes |
272dfe |
+ EventNotifier guest_notifier;
|
|
Justin M. Forbes |
272dfe |
+ EventNotifier host_notifier;
|
|
Justin M. Forbes |
272dfe |
};
|
|
Justin M. Forbes |
272dfe |
|
|
Justin M. Forbes |
272dfe |
/* virt queue functions */
|
|
Justin M. Forbes |
272dfe |
@@ -594,10 +597,10 @@ VirtQueue *virtio_add_queue(VirtIODevice *vdev, int queue_size,
|
|
Justin M. Forbes |
272dfe |
return &vdev->vq[i];
|
|
Justin M. Forbes |
272dfe |
}
|
|
Justin M. Forbes |
272dfe |
|
|
Justin M. Forbes |
272dfe |
-void virtio_irq(VirtIODevice *vdev, VirtQueue *vq)
|
|
Justin M. Forbes |
272dfe |
+void virtio_irq(VirtQueue *vq)
|
|
Justin M. Forbes |
272dfe |
{
|
|
Justin M. Forbes |
272dfe |
- vdev->isr |= 0x01;
|
|
Justin M. Forbes |
272dfe |
- virtio_notify_vector(vdev, vq->vector);
|
|
Justin M. Forbes |
272dfe |
+ vq->vdev->isr |= 0x01;
|
|
Justin M. Forbes |
272dfe |
+ virtio_notify_vector(vq->vdev, vq->vector);
|
|
Justin M. Forbes |
272dfe |
}
|
|
Justin M. Forbes |
272dfe |
|
|
Justin M. Forbes |
272dfe |
void virtio_notify(VirtIODevice *vdev, VirtQueue *vq)
|
|
Justin M. Forbes |
272dfe |
@@ -608,7 +611,8 @@ void virtio_notify(VirtIODevice *vdev, VirtQueue *vq)
|
|
Justin M. Forbes |
272dfe |
(vq->inuse || vring_avail_idx(vq) != vq->last_avail_idx)))
|
|
Justin M. Forbes |
272dfe |
return;
|
|
Justin M. Forbes |
272dfe |
|
|
Justin M. Forbes |
272dfe |
- virtio_irq(vdev, vq);
|
|
Justin M. Forbes |
272dfe |
+ vdev->isr |= 0x01;
|
|
Justin M. Forbes |
272dfe |
+ virtio_notify_vector(vdev, vq->vector);
|
|
Justin M. Forbes |
272dfe |
}
|
|
Justin M. Forbes |
272dfe |
|
|
Justin M. Forbes |
272dfe |
void virtio_notify_config(VirtIODevice *vdev)
|
|
Justin M. Forbes |
272dfe |
@@ -742,3 +746,42 @@ void virtio_bind_device(VirtIODevice *vdev, const VirtIOBindings *binding,
|
|
Justin M. Forbes |
272dfe |
vdev->binding = binding;
|
|
Justin M. Forbes |
272dfe |
vdev->binding_opaque = opaque;
|
|
Justin M. Forbes |
272dfe |
}
|
|
Justin M. Forbes |
272dfe |
+
|
|
Justin M. Forbes |
272dfe |
+target_phys_addr_t virtio_queue_get_desc(VirtIODevice *vdev, int n)
|
|
Justin M. Forbes |
272dfe |
+{
|
|
Justin M. Forbes |
272dfe |
+ return vdev->vq[n].vring.desc;
|
|
Justin M. Forbes |
272dfe |
+}
|
|
Justin M. Forbes |
272dfe |
+
|
|
Justin M. Forbes |
272dfe |
+target_phys_addr_t virtio_queue_get_avail(VirtIODevice *vdev, int n)
|
|
Justin M. Forbes |
272dfe |
+{
|
|
Justin M. Forbes |
272dfe |
+ return vdev->vq[n].vring.avail;
|
|
Justin M. Forbes |
272dfe |
+}
|
|
Justin M. Forbes |
272dfe |
+
|
|
Justin M. Forbes |
272dfe |
+target_phys_addr_t virtio_queue_get_used(VirtIODevice *vdev, int n)
|
|
Justin M. Forbes |
272dfe |
+{
|
|
Justin M. Forbes |
272dfe |
+ return vdev->vq[n].vring.used;
|
|
Justin M. Forbes |
272dfe |
+}
|
|
Justin M. Forbes |
272dfe |
+
|
|
Justin M. Forbes |
272dfe |
+uint16_t virtio_queue_last_avail_idx(VirtIODevice *vdev, int n)
|
|
Justin M. Forbes |
272dfe |
+{
|
|
Justin M. Forbes |
272dfe |
+ return vdev->vq[n].last_avail_idx;
|
|
Justin M. Forbes |
272dfe |
+}
|
|
Justin M. Forbes |
272dfe |
+
|
|
Justin M. Forbes |
272dfe |
+void virtio_queue_set_last_avail_idx(VirtIODevice *vdev, int n, uint16_t idx)
|
|
Justin M. Forbes |
272dfe |
+{
|
|
Justin M. Forbes |
272dfe |
+ vdev->vq[n].last_avail_idx = idx;
|
|
Justin M. Forbes |
272dfe |
+}
|
|
Justin M. Forbes |
272dfe |
+
|
|
Justin M. Forbes |
272dfe |
+VirtQueue *virtio_queue(VirtIODevice *vdev, int n)
|
|
Justin M. Forbes |
272dfe |
+{
|
|
Justin M. Forbes |
272dfe |
+ return vdev->vq + n;
|
|
Justin M. Forbes |
272dfe |
+}
|
|
Justin M. Forbes |
272dfe |
+
|
|
Justin M. Forbes |
272dfe |
+EventNotifier *virtio_queue_guest_notifier(VirtQueue *vq)
|
|
Justin M. Forbes |
272dfe |
+{
|
|
Justin M. Forbes |
272dfe |
+ return &vq->guest_notifier;
|
|
Justin M. Forbes |
272dfe |
+}
|
|
Justin M. Forbes |
272dfe |
+EventNotifier *virtio_queue_host_notifier(VirtQueue *vq)
|
|
Justin M. Forbes |
272dfe |
+{
|
|
Justin M. Forbes |
272dfe |
+ return &vq->host_notifier;
|
|
Justin M. Forbes |
272dfe |
+}
|
|
Justin M. Forbes |
272dfe |
diff --git a/hw/virtio.h b/hw/virtio.h
|
|
Justin M. Forbes |
272dfe |
index 10a0959..f140ca3 100644
|
|
Justin M. Forbes |
272dfe |
--- a/hw/virtio.h
|
|
Justin M. Forbes |
272dfe |
+++ b/hw/virtio.h
|
|
Justin M. Forbes |
272dfe |
@@ -183,5 +183,13 @@ void virtio_net_exit(VirtIODevice *vdev);
|
|
Justin M. Forbes |
272dfe |
DEFINE_PROP_BIT("indirect_desc", _state, _field, \
|
|
Justin M. Forbes |
272dfe |
VIRTIO_RING_F_INDIRECT_DESC, true)
|
|
Justin M. Forbes |
272dfe |
|
|
Justin M. Forbes |
272dfe |
-void virtio_irq(VirtIODevice *vdev, VirtQueue *vq);
|
|
Justin M. Forbes |
272dfe |
+target_phys_addr_t virtio_queue_get_desc(VirtIODevice *vdev, int n);
|
|
Justin M. Forbes |
272dfe |
+target_phys_addr_t virtio_queue_get_avail(VirtIODevice *vdev, int n);
|
|
Justin M. Forbes |
272dfe |
+target_phys_addr_t virtio_queue_get_used(VirtIODevice *vdev, int n);
|
|
Justin M. Forbes |
272dfe |
+uint16_t virtio_queue_last_avail_idx(VirtIODevice *vdev, int n);
|
|
Justin M. Forbes |
272dfe |
+void virtio_queue_set_last_avail_idx(VirtIODevice *vdev, int n, uint16_t idx);
|
|
Justin M. Forbes |
272dfe |
+VirtQueue *virtio_queue(VirtIODevice *vdev, int n);
|
|
Justin M. Forbes |
272dfe |
+EventNotifier *virtio_queue_guest_notifier(VirtQueue *vq);
|
|
Justin M. Forbes |
272dfe |
+EventNotifier *virtio_queue_host_notifier(VirtQueue *vq);
|
|
Justin M. Forbes |
272dfe |
+void virtio_irq(VirtQueue *vq);
|
|
Justin M. Forbes |
272dfe |
#endif
|
|
Justin M. Forbes |
272dfe |
--
|
|
Justin M. Forbes |
272dfe |
1.6.6.144.g5c3af
|