From patchwork Wed Apr 25 05:54:10 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evgeny Voevodin X-Patchwork-Id: 154800 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id F0C8DB6F13 for ; Wed, 25 Apr 2012 15:54:53 +1000 (EST) Received: from localhost ([::1]:41548 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SMvBj-0002rl-RF for incoming@patchwork.ozlabs.org; Wed, 25 Apr 2012 01:54:51 -0400 Received: from eggs.gnu.org ([208.118.235.92]:60976) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SMvBR-0002px-Vz for qemu-devel@nongnu.org; Wed, 25 Apr 2012 01:54:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SMvBP-0006cm-N4 for qemu-devel@nongnu.org; Wed, 25 Apr 2012 01:54:33 -0400 Received: from mailout4.w1.samsung.com ([210.118.77.14]:51853) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SMvBP-0006Yv-HV for qemu-devel@nongnu.org; Wed, 25 Apr 2012 01:54:31 -0400 MIME-version: 1.0 Content-transfer-encoding: 7BIT Content-type: TEXT/PLAIN Received: from euspt2 ([210.118.77.14]) by mailout4.w1.samsung.com (Sun Java(tm) System Messaging Server 6.3-8.04 (built Jul 29 2009; 32bit)) with ESMTP id <0M3000IVVTQZ8370@mailout4.w1.samsung.com> for qemu-devel@nongnu.org; Wed, 25 Apr 2012 06:54:35 +0100 (BST) Received: from evvoevodinPC.rnd.samsung.ru ([106.109.9.191]) by spt2.w1.samsung.com (iPlanet Messaging Server 5.2 Patch 2 (built Jul 14 2004)) with ESMTPA id <0M300064STQJKX@spt2.w1.samsung.com> for qemu-devel@nongnu.org; Wed, 25 Apr 2012 06:54:25 +0100 (BST) Date: Wed, 25 Apr 2012 09:54:10 +0400 From: Evgeny Voevodin In-reply-to: <1335333257-5128-1-git-send-email-e.voevodin@samsung.com> To: qemu-devel@nongnu.org Message-id: <1335333257-5128-3-git-send-email-e.voevodin@samsung.com> X-Mailer: git-send-email 1.7.5.4 References: <1335333257-5128-1-git-send-email-e.voevodin@samsung.com> X-detected-operating-system: by eggs.gnu.org: Solaris 9.1 X-Received-From: 210.118.77.14 Cc: peter.maydell@linaro.org, aliguori@us.ibm.com, i.mitsyanko@samsung.com, Evgeny Voevodin , kyungmin.park@samsung.com, d.solodkiy@samsung.com, m.kozlov@samsung.com Subject: [Qemu-devel] [RFC 2/9] virtio: Support transports which can specify the vring alignment X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Peter Maydell Support virtio transports which can specify the vring alignment (ie where the guest communicates this to the host) by providing a new virtio_queue_set_align() function. (The default alignment remains as before.) FIXME save/load support for this new field! Signed-off-by: Peter Maydell Signed-off-by: Evgeny Voevodin --- hw/virtio.c | 14 ++++++++++++-- hw/virtio.h | 1 + 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/hw/virtio.c b/hw/virtio.c index 71c4a10..3e2e264 100644 --- a/hw/virtio.c +++ b/hw/virtio.c @@ -19,7 +19,9 @@ #include "qemu-barrier.h" /* The alignment to use between consumer and producer parts of vring. - * x86 pagesize again. */ + * x86 pagesize again. This is the default, used by transports like PCI + * which don't provide a means for the guest to tell the host the alignment. + */ #define VIRTIO_PCI_VRING_ALIGN 4096 typedef struct VRingDesc @@ -53,6 +55,7 @@ typedef struct VRingUsed typedef struct VRing { unsigned int num; + unsigned int align; target_phys_addr_t desc; target_phys_addr_t avail; target_phys_addr_t used; @@ -90,7 +93,7 @@ static void virtqueue_init(VirtQueue *vq) vq->vring.avail = pa + vq->vring.num * sizeof(VRingDesc); vq->vring.used = vring_align(vq->vring.avail + offsetof(VRingAvail, ring[vq->vring.num]), - VIRTIO_PCI_VRING_ALIGN); + vq->vring.align); } static inline uint64_t vring_desc_addr(target_phys_addr_t desc_pa, int i) @@ -637,6 +640,12 @@ int virtio_queue_get_id(VirtQueue *vq) return vq - &vdev->vq[0]; } +void virtio_queue_set_align(VirtIODevice *vdev, int n, int align) +{ + vdev->vq[n].vring.align = align; + virtqueue_init(&vdev->vq[n]); +} + void virtio_queue_notify_vq(VirtQueue *vq) { if (vq->vring.desc) { @@ -677,6 +686,7 @@ VirtQueue *virtio_add_queue(VirtIODevice *vdev, int queue_size, abort(); vdev->vq[i].vring.num = queue_size; + vdev->vq[i].vring.align = VIRTIO_PCI_VRING_ALIGN; vdev->vq[i].handle_output = handle_output; return &vdev->vq[i]; diff --git a/hw/virtio.h b/hw/virtio.h index 72b56e3..c1f8666 100644 --- a/hw/virtio.h +++ b/hw/virtio.h @@ -180,6 +180,7 @@ void virtio_queue_set_addr(VirtIODevice *vdev, int n, target_phys_addr_t addr); target_phys_addr_t virtio_queue_get_addr(VirtIODevice *vdev, int n); void virtio_queue_set_num(VirtIODevice *vdev, int n, int num); int virtio_queue_get_num(VirtIODevice *vdev, int n); +void virtio_queue_set_align(VirtIODevice *vdev, int n, int align); void virtio_queue_notify(VirtIODevice *vdev, int n); uint16_t virtio_queue_vector(VirtIODevice *vdev, int n); void virtio_queue_set_vector(VirtIODevice *vdev, int n, uint16_t vector);