[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC v2 02/12] virtio: Support transports which can specify
From: |
Evgeny Voevodin |
Subject: |
[Qemu-devel] [RFC v2 02/12] virtio: Support transports which can specify the vring alignment |
Date: |
Mon, 17 Sep 2012 14:00:32 +0400 |
From: Peter Maydell <address@hidden>
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 <address@hidden>
Signed-off-by: Evgeny Voevodin <address@hidden>
---
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 5334326..4f47d4e 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)
@@ -646,6 +649,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) {
@@ -686,6 +695,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 eb9953f..3f16367 100644
--- a/hw/virtio.h
+++ b/hw/virtio.h
@@ -179,6 +179,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);
--
1.7.9.5
- [Qemu-devel] [RFC v2 00/12] Virtio-mmio refactoring., Evgeny Voevodin, 2012/09/17
- [Qemu-devel] [RFC v2 08/12] hw/virtio-balloon.c: Add virtio-balloon device., Evgeny Voevodin, 2012/09/17
- [Qemu-devel] [RFC v2 05/12] hw/pci.c: Make pci_add_option_rom global visible, Evgeny Voevodin, 2012/09/17
- [Qemu-devel] [RFC v2 02/12] virtio: Support transports which can specify the vring alignment,
Evgeny Voevodin <=
- [Qemu-devel] [RFC v2 03/12] Virtio: Add transport bindings., Evgeny Voevodin, 2012/09/17
- [Qemu-devel] [RFC v2 01/12] virtio: Add support for guest setting of queue size, Evgeny Voevodin, 2012/09/17
- [Qemu-devel] [RFC v2 07/12] hw/virtio-serial-bus.c: Add virtio-serial device., Evgeny Voevodin, 2012/09/17
- [Qemu-devel] [RFC v2 06/12] Add MMIO based virtio transport, Evgeny Voevodin, 2012/09/17
- [Qemu-devel] [RFC v2 04/12] hw/qdev-properties.c: Add "transport" property., Evgeny Voevodin, 2012/09/17
- [Qemu-devel] [RFC v2 12/12] hw/exynos4210.c: Create two virtio-mmio transport instances., Evgeny Voevodin, 2012/09/17
- [Qemu-devel] [RFC v2 09/12] hw/virtio-net.c: Add virtio-net device., Evgeny Voevodin, 2012/09/17
- [Qemu-devel] [RFC v2 10/12] hw/virtio-blk.c: Add virtio-blk device., Evgeny Voevodin, 2012/09/17