From: Cornelia Huck <cornelia.huck@de.ibm.com>
To: Pierre Morel <pmorel@linux.vnet.ibm.com>
Cc: mst@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com,
gkurz@linux.vnet.ibm.com
Subject: Re: [Qemu-devel] [PATCH v2] virtio dataplane: adapt dataplane for virtio Version 1
Date: Wed, 26 Aug 2015 16:57:42 +0200 [thread overview]
Message-ID: <20150826165742.4bb3c4eb.cornelia.huck@de.ibm.com> (raw)
In-Reply-To: <1440595482-15503-1-git-send-email-pmorel@linux.vnet.ibm.com>
On Wed, 26 Aug 2015 15:24:42 +0200
Pierre Morel <pmorel@linux.vnet.ibm.com> wrote:
> Let dataplane allocate different region for the desc/avail/used
s/region/regions/
> ring regions.
>
> Signed-off-by: Pierre Morel <pmorel@linux.vnet.ibm.com>
> Acked-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
> Tested-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
> ---
> hw/virtio/dataplane/vring.c | 48 ++++++++++++++++++++++++++-----------
> include/hw/virtio/dataplane/vring.h | 4 +++-
> 2 files changed, 37 insertions(+), 15 deletions(-)
>
> diff --git a/hw/virtio/dataplane/vring.c b/hw/virtio/dataplane/vring.c
> index 07fd69c..ad86be5 100644
> --- a/hw/virtio/dataplane/vring.c
> +++ b/hw/virtio/dataplane/vring.c
> @@ -65,24 +65,34 @@ static void vring_unmap(void *buffer, bool is_write)
> }
>
> /* Map the guest's vring to host memory */
> +
> +#define MAP_VRING_DESCRIPTOR(d) { \
> + hwaddr addr; \
> + hwaddr size; \
> + void *ptr; \
> + \
> + addr = virtio_queue_get_##d##_addr(vdev, n); \
> + size = virtio_queue_get_##d## _size(vdev, n); \
Inconsistent spacing (but probably can be fixed when applying).
> + ptr = vring_map(&vring->mr_##d, addr, size, true); \
> + if (!ptr) { \
> + error_report("Failed to map vring "#d" " \
> + "addr %#" HWADDR_PRIx " size %" HWADDR_PRIu, \
> + addr, size); \
> + goto out_err_##d; \
> + } \
> + vr->d = ptr; \
> + }
> +
> bool vring_setup(Vring *vring, VirtIODevice *vdev, int n)
> {
> - hwaddr vring_addr = virtio_queue_get_ring_addr(vdev, n);
> - hwaddr vring_size = virtio_queue_get_ring_size(vdev, n);
> - void *vring_ptr;
> + struct vring *vr = &vring->vr;
>
> vring->broken = false;
> + vr->num = virtio_queue_get_num(vdev, n);
>
> - vring_ptr = vring_map(&vring->mr, vring_addr, vring_size, true);
> - if (!vring_ptr) {
> - error_report("Failed to map vring "
> - "addr %#" HWADDR_PRIx " size %" HWADDR_PRIu,
> - vring_addr, vring_size);
> - vring->broken = true;
> - return false;
> - }
> -
> - vring_init(&vring->vr, virtio_queue_get_num(vdev, n), vring_ptr, 4096);
> + MAP_VRING_DESCRIPTOR(desc);
> + MAP_VRING_DESCRIPTOR(avail);
> + MAP_VRING_DESCRIPTOR(used);
>
> vring->last_avail_idx = virtio_queue_get_last_avail_idx(vdev, n);
> vring->last_used_idx = vring_get_used_idx(vdev, vring);
> @@ -92,6 +102,14 @@ bool vring_setup(Vring *vring, VirtIODevice *vdev, int n)
> trace_vring_setup(virtio_queue_get_ring_addr(vdev, n),
> vring->vr.desc, vring->vr.avail, vring->vr.used);
> return true;
> +
> +out_err_used:
> + memory_region_unref(vring->mr_avail);
> +out_err_avail:
> + memory_region_unref(vring->mr_desc);
> +out_err_desc:
> + vring->broken = true;
> + return false;
My only worry is that this might be a bit hard to parse as the gotos
are hidden in the macro. But in the end, both this and the original
version are basically fine.
> }
>
> void vring_teardown(Vring *vring, VirtIODevice *vdev, int n)
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
next prev parent reply other threads:[~2015-08-26 15:44 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-26 13:24 [Qemu-devel] [PATCH v2] virtio dataplane: adapt dataplane for virtio Version 1 Pierre Morel
2015-08-26 14:09 ` Greg Kurz
2015-08-26 14:57 ` Cornelia Huck [this message]
2015-08-27 11:14 ` Michael S. Tsirkin
2015-09-01 14:08 ` Stefan Hajnoczi
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=20150826165742.4bb3c4eb.cornelia.huck@de.ibm.com \
--to=cornelia.huck@de.ibm.com \
--cc=gkurz@linux.vnet.ibm.com \
--cc=mst@redhat.com \
--cc=pmorel@linux.vnet.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).