aboutsummaryrefslogtreecommitdiff
path: root/lib/libvirtio/virtio.c
diff options
context:
space:
mode:
authorNikunj A Dadhania <nikunj@linux.vnet.ibm.com>2016-02-01 11:17:58 +0530
committerAlexey Kardashevskiy <aik@ozlabs.ru>2016-02-08 16:40:38 +1100
commitfdb62149dc88c8003f1c2273f6becca08629910a (patch)
tree6c1ae5e12ac0d35dd13ac2b532512707b59ed36c /lib/libvirtio/virtio.c
parentb5a692d3f7c2cf3ca2eea5e9f8f99f0972cf56d1 (diff)
downloadSLOF-fdb62149dc88c8003f1c2273f6becca08629910a.zip
SLOF-fdb62149dc88c8003f1c2273f6becca08629910a.tar.gz
SLOF-fdb62149dc88c8003f1c2273f6becca08629910a.tar.bz2
virtio-blk: add helpers for filling descriptors
Enable virtio_fill_desc/fill_blk_hdr with legacy and modern mode for further use Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Diffstat (limited to 'lib/libvirtio/virtio.c')
-rw-r--r--lib/libvirtio/virtio.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/libvirtio/virtio.c b/lib/libvirtio/virtio.c
index 063a621..4ea8278 100644
--- a/lib/libvirtio/virtio.c
+++ b/lib/libvirtio/virtio.c
@@ -113,6 +113,25 @@ struct vring_used *virtio_get_vring_used(struct virtio_device *dev, int queue)
* sizeof(struct vring_avail));
}
+/**
+ * Fill the virtio ring descriptor depending on the legacy mode or virtio 1.0
+ */
+void virtio_fill_desc(struct vring_desc *desc, bool is_modern,
+ uint64_t addr, uint32_t len,
+ uint16_t flags, uint16_t next)
+{
+ if (is_modern) {
+ desc->addr = cpu_to_le64(addr);
+ desc->len = cpu_to_le32(len);
+ desc->flags = cpu_to_le16(flags);
+ desc->next = cpu_to_le16(next);
+ } else {
+ desc->addr = addr;
+ desc->len = len;
+ desc->flags = flags;
+ desc->next = next;
+ }
+}
/**
* Reset virtio device