From: Mark McLoughlin <markmc@redhat.com>
To: Avi Kivity <avi@redhat.com>
Cc: kvm@vger.kernel.org, Rusty Russell <rusty@rustcorp.com.au>,
Mark McLoughlin <markmc@redhat.com>
Subject: [PATCH 2/5] kvm: qemu: Introduce virtqueue_fill() and virtqueue_flush()
Date: Wed, 8 Oct 2008 20:35:10 +0100 [thread overview]
Message-ID: <1223494513-18826-2-git-send-email-markmc@redhat.com> (raw)
In-Reply-To: <1223494513-18826-1-git-send-email-markmc@redhat.com>
Split virtqueue_push() into two logical steps - adding an element
to the used ring and notifying the other side of added elements.
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
---
qemu/hw/virtio.c | 23 ++++++++++++++++++-----
qemu/hw/virtio.h | 3 +++
2 files changed, 21 insertions(+), 5 deletions(-)
diff --git a/qemu/hw/virtio.c b/qemu/hw/virtio.c
index b3ee649..74b898f 100644
--- a/qemu/hw/virtio.c
+++ b/qemu/hw/virtio.c
@@ -107,19 +107,32 @@ static void virtqueue_init(VirtQueue *vq, void *p)
vq->vring.used = (void *)TARGET_PAGE_ALIGN((unsigned long)&vq->vring.avail->ring[vq->vring.num]);
}
-void virtqueue_push(VirtQueue *vq, const VirtQueueElement *elem,
- unsigned int len)
+void virtqueue_fill(VirtQueue *vq, const VirtQueueElement *elem,
+ unsigned int len, unsigned int idx)
{
VRingUsedElem *used;
+ idx += vq->vring.used->idx;
+
/* Get a pointer to the next entry in the used ring. */
- used = &vq->vring.used->ring[vq->vring.used->idx % vq->vring.num];
+ used = &vq->vring.used->ring[idx % vq->vring.num];
used->id = elem->index;
used->len = len;
+}
+
+void virtqueue_flush(VirtQueue *vq, unsigned int count)
+{
/* Make sure buffer is written before we update index. */
wmb();
- vq->vring.used->idx++;
- vq->inuse--;
+ vq->vring.used->idx += count;
+ vq->inuse -= count;
+}
+
+void virtqueue_push(VirtQueue *vq, const VirtQueueElement *elem,
+ unsigned int len)
+{
+ virtqueue_fill(vq, elem, len, 0);
+ virtqueue_flush(vq, 1);
}
static unsigned virtqueue_next_desc(VirtQueue *vq, unsigned int i)
diff --git a/qemu/hw/virtio.h b/qemu/hw/virtio.h
index 0dcedbf..87a15cc 100644
--- a/qemu/hw/virtio.h
+++ b/qemu/hw/virtio.h
@@ -139,6 +139,9 @@ VirtQueue *virtio_add_queue(VirtIODevice *vdev, int queue_size,
void virtqueue_push(VirtQueue *vq, const VirtQueueElement *elem,
unsigned int len);
+void virtqueue_flush(VirtQueue *vq, unsigned int count);
+void virtqueue_fill(VirtQueue *vq, const VirtQueueElement *elem,
+ unsigned int len, unsigned int idx);
int virtqueue_pop(VirtQueue *vq, VirtQueueElement *elem);
--
1.5.4.3
next prev parent reply other threads:[~2008-10-08 19:35 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-08 19:35 [PATCH 1/5] kvm: qemu: Move virtqueue_next_desc() around Mark McLoughlin
2008-10-08 19:35 ` Mark McLoughlin [this message]
2008-10-08 19:35 ` [PATCH 3/5] kvm: qemu: Simplify virtio_net_can_receive() a little Mark McLoughlin
2008-10-08 19:35 ` [PATCH 4/5] kvm: qemu: Split iov_fill() out from virtio_net_receive() Mark McLoughlin
2008-10-08 19:35 ` [PATCH 5/5] kvm: qemu: Improve virtio_net recv buffer allocation scheme Mark McLoughlin
2008-10-12 10:00 ` Avi Kivity
2008-10-14 13:44 ` Mark McLoughlin
2008-10-14 15:47 ` Avi Kivity
2008-11-26 14:50 ` [PATCH 0/5] kvm: qemu: virtio_net: add support for mergeable rx buffers Mark McLoughlin
2008-11-26 14:50 ` [PATCH 1/5] kvm: qemu: virtio: move virtqueue_next_desc() around Mark McLoughlin
2008-11-26 14:50 ` [PATCH 2/5] kvm: qemu: virtio: introduce virtqueue_fill() and virtqueue_flush() Mark McLoughlin
2008-11-26 14:50 ` [PATCH 3/5] kvm: qemu: virtio: split some helpers out of virtqueue_pop() Mark McLoughlin
2008-11-26 14:50 ` [PATCH 4/5] kvm: qemu: virtio-net: split iov_fill() out from virtio_net_receive() Mark McLoughlin
2008-11-26 14:50 ` [PATCH 5/5] kvm: qemu: virtio-net: add a new virtio-net receive buffer scheme Mark McLoughlin
2008-11-27 12:45 ` [PATCH 0/5] kvm: qemu: virtio_net: add support for mergeable rx buffers Avi Kivity
2008-11-27 13:32 ` Mark McLoughlin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1223494513-18826-2-git-send-email-markmc@redhat.com \
--to=markmc@redhat.com \
--cc=avi@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=rusty@rustcorp.com.au \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.