[SLOF] [PATCH v1 10/27] virtio: make virtio_vring_desc 1.0 aware
Nikunj A Dadhania
nikunj at linux.vnet.ibm.com
Wed Jan 13 22:16:57 AEDT 2016
Signed-off-by: Nikunj A Dadhania <nikunj at linux.vnet.ibm.com>
---
lib/libvirtio/virtio.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/lib/libvirtio/virtio.c b/lib/libvirtio/virtio.c
index aa4a45b..f95e86b 100644
--- a/lib/libvirtio/virtio.c
+++ b/lib/libvirtio/virtio.c
@@ -235,14 +235,22 @@ struct vring_desc *virtio_get_vring_desc(struct virtio_device *dev, int queue)
{
struct vring_desc *desc = 0;
- if (dev->type == VIRTIO_TYPE_PCI) {
+ if (dev->type != VIRTIO_TYPE_PCI)
+ return NULL;
+ if (dev->is_modern) {
+ void *q_sel = dev->common.addr + offset_of(struct virtio_dev_common, q_select);
+ void *q_desc = dev->common.addr + offset_of(struct virtio_dev_common, q_desc);
+
+ ci_write_16(q_sel, cpu_to_le16(queue));
+ eieio();
+ desc = (void *)(virtio_read64(q_desc));
+ } else {
ci_write_16(dev->base+VIRTIOHDR_QUEUE_SELECT,
cpu_to_le16(queue));
eieio();
desc = (void*)(4096L *
- le32_to_cpu(ci_read_32(dev->base+VIRTIOHDR_QUEUE_ADDRESS)));
+ le32_to_cpu(ci_read_32(dev->base+VIRTIOHDR_QUEUE_ADDRESS)));
}
-
return desc;
}
--
2.5.0
More information about the SLOF
mailing list