[SLOF] [PATCH v1 20/27] virtio: make virtio_fill_desc 1.0 aware
Alexey Kardashevskiy
aik at ozlabs.ru
Thu Jan 14 18:29:22 AEDT 2016
On 01/13/2016 10:17 PM, Nikunj A Dadhania wrote:
> Signed-off-by: Nikunj A Dadhania <nikunj at linux.vnet.ibm.com>
> ---
> lib/libvirtio/virtio-blk.c | 6 +++---
> lib/libvirtio/virtio.c | 21 +++++++++++++++------
> lib/libvirtio/virtio.h | 2 +-
> 3 files changed, 19 insertions(+), 10 deletions(-)
>
> diff --git a/lib/libvirtio/virtio-blk.c b/lib/libvirtio/virtio-blk.c
> index 2d8982d..19819cf 100644
> --- a/lib/libvirtio/virtio-blk.c
> +++ b/lib/libvirtio/virtio-blk.c
> @@ -152,17 +152,17 @@ virtioblk_read(struct virtio_device *dev, char *buf, long blocknum, long cnt)
>
> /* Set up virtqueue descriptor for header */
> desc = &vq_desc[id];
> - virtio_fill_desc(desc, (uint64_t)&blkhdr, sizeof(struct virtio_blk_req),
> + virtio_fill_desc(desc, 0, (uint64_t)&blkhdr, sizeof(struct virtio_blk_req),
> VRING_DESC_F_NEXT, (id + 1) % vq_size);
>
> /* Set up virtqueue descriptor for data */
> desc = &vq_desc[(id + 1) % vq_size];
> - virtio_fill_desc(desc, (uint64_t)buf, cnt * blk_size,
> + virtio_fill_desc(desc, 0, (uint64_t)buf, cnt * blk_size,
> VRING_DESC_F_NEXT | VRING_DESC_F_WRITE, (id + 2) % vq_size);
>
> /* Set up virtqueue descriptor for status */
> desc = &vq_desc[(id + 2) % vq_size];
> - virtio_fill_desc(desc, (uint64_t)&status, 1, VRING_DESC_F_WRITE, 0);
> + virtio_fill_desc(desc, 0, (uint64_t)&status, 1, VRING_DESC_F_WRITE, 0);
>
> vq_avail->ring[vq_avail->idx % vq_size] = id;
> mb();
> diff --git a/lib/libvirtio/virtio.c b/lib/libvirtio/virtio.c
> index e81d78e..e1ab97f 100644
> --- a/lib/libvirtio/virtio.c
> +++ b/lib/libvirtio/virtio.c
> @@ -304,15 +304,24 @@ struct vring_used *virtio_get_vring_used(struct virtio_device *dev, int queue)
> }
> }
>
> -
> -void virtio_fill_desc(struct vring_desc *desc,
> +/**
> + * Fill the virtio ring descriptor depending on the legacy mode or virtio 1.0
> + */
> +void virtio_fill_desc(struct vring_desc *desc, uint32_t is_modern,
s/uint32_t is_modern/bool is_modern/
And it belongs to 03/27. Or 03/27 is better be merged into this. Up to you.
Please avoid changing same bits of code several times in the same patchset,
it is confusing.
> uint64_t addr, uint32_t len,
> uint16_t flags, uint16_t next)
> {
> - desc->addr = addr;
> - desc->len = len;
> - desc->flags = flags;
> - desc->next = 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;
> + }
> }
>
> /**
> diff --git a/lib/libvirtio/virtio.h b/lib/libvirtio/virtio.h
> index 07bd28c..afa3c9c 100644
> --- a/lib/libvirtio/virtio.h
> +++ b/lib/libvirtio/virtio.h
> @@ -113,7 +113,7 @@ extern unsigned int virtio_get_qsize(struct virtio_device *dev, int queue);
> extern struct vring_desc *virtio_get_vring_desc(struct virtio_device *dev, int queue);
> extern struct vring_avail *virtio_get_vring_avail(struct virtio_device *dev, int queue);
> extern struct vring_used *virtio_get_vring_used(struct virtio_device *dev, int queue);
> -extern void virtio_fill_desc(struct vring_desc *desc,
> +extern void virtio_fill_desc(struct vring_desc *desc, uint32_t is_modern,
> uint64_t addr, uint32_t len,
> uint16_t flags, uint16_t next);
> extern int virtio_queue_init_vq(struct virtio_device *dev, struct vqs *vq, unsigned int id);
>
--
Alexey
More information about the SLOF
mailing list