[SLOF] [PATCH v1 08/27] virtio: make virtio_get_qsize 1.0 aware
Nikunj A Dadhania
nikunj at linux.vnet.ibm.com
Wed Jan 13 22:16:55 AEDT 2016
Also return unsigned int
Signed-off-by: Nikunj A Dadhania <nikunj at linux.vnet.ibm.com>
---
lib/libvirtio/virtio.c | 15 +++++++++++----
lib/libvirtio/virtio.h | 2 +-
2 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/lib/libvirtio/virtio.c b/lib/libvirtio/virtio.c
index bcf050b..77676c7 100644
--- a/lib/libvirtio/virtio.c
+++ b/lib/libvirtio/virtio.c
@@ -185,17 +185,24 @@ unsigned long virtio_vring_size(unsigned int qsize)
* @param queue virtio queue number
* @return number of elements
*/
-int virtio_get_qsize(struct virtio_device *dev, int queue)
+unsigned int virtio_get_qsize(struct virtio_device *dev, int queue)
{
- int size = 0;
+ unsigned int size = 0;
- if (dev->type == VIRTIO_TYPE_PCI) {
+ if (dev->type != VIRTIO_TYPE_PCI)
+ return 0;
+ if (dev->is_modern) {
+ void *addr = dev->common.addr + offset_of(struct virtio_dev_common, q_select);
+ ci_write_16(addr, cpu_to_le16(queue));
+ eieio();
+ size = le16_to_cpu(ci_read_16(addr + 2));
+ }
+ else {
ci_write_16(dev->base+VIRTIOHDR_QUEUE_SELECT,
cpu_to_le16(queue));
eieio();
size = le16_to_cpu(ci_read_16(dev->base+VIRTIOHDR_QUEUE_SIZE));
}
-
return size;
}
diff --git a/lib/libvirtio/virtio.h b/lib/libvirtio/virtio.h
index eee3144..537862b 100644
--- a/lib/libvirtio/virtio.h
+++ b/lib/libvirtio/virtio.h
@@ -107,7 +107,7 @@ struct vqs {
#define VQ_ALIGN(addr) (((addr) + 0xfff) & ~0xfff)
extern unsigned long virtio_vring_size(unsigned int qsize);
-extern int virtio_get_qsize(struct virtio_device *dev, int queue);
+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);
--
2.5.0
More information about the SLOF
mailing list