From 76d68ff0d6f965fadee4d954ab1e67d68eb16e77 Mon Sep 17 00:00:00 2001 From: Sasha Levin Date: Thu, 17 Nov 2011 15:53:24 +0200 Subject: [PATCH] kvm tools: Prepare support for VIRTIO_RING_F_EVENT_IDX This patch is the base for enabling support for event index feature in the virtio spec. We do so by updating and evaluating the used/avail event idx in the virtio ring functions. Actual usage of this flag is in the following patches. The results are less notifications between the guest and host, and in result faster operation of the virt queues. Signed-off-by: Sasha Levin Signed-off-by: Pekka Enberg --- tools/kvm/include/kvm/virtio.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tools/kvm/include/kvm/virtio.h b/tools/kvm/include/kvm/virtio.h index c6c380d3e500..cd24285390bc 100644 --- a/tools/kvm/include/kvm/virtio.h +++ b/tools/kvm/include/kvm/virtio.h @@ -38,6 +38,8 @@ static inline bool virt_queue__available(struct virt_queue *vq) { if (!vq->vring.avail) return 0; + + vring_avail_event(&vq->vring) = vq->last_avail_idx; return vq->vring.avail->idx != vq->last_avail_idx; } @@ -51,6 +53,11 @@ static inline void *guest_pfn_to_host(struct kvm *kvm, u32 pfn) return guest_flat_to_host(kvm, (unsigned long)pfn << VIRTIO_PCI_QUEUE_ADDR_SHIFT); } +static inline int virtio_queue__should_signal(struct virt_queue *vq) +{ + return vring_used_event(&vq->vring) <= vq->vring.used->idx; +} + struct vring_used_elem *virt_queue__set_used_elem(struct virt_queue *queue, u32 head, u32 len); u16 virt_queue__get_iov(struct virt_queue *queue, struct iovec iov[], u16 *out, u16 *in, struct kvm *kvm); -- 2.39.5