This function allows to get the current available ring index. Signed-off-by: Antonios Motakis <a.mota...@virtualopensystems.com> Signed-off-by: Nikolay Nikolaev <n.nikol...@virtualopensystems.com> --- hw/virtio/virtio.c | 5 +++++ include/hw/virtio/virtio.h | 1 + 2 files changed, 6 insertions(+)
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index aeabf3a..3c46e86 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -1058,6 +1058,11 @@ hwaddr virtio_queue_get_ring_size(VirtIODevice *vdev, int n) virtio_queue_get_used_size(vdev, n); } +uint16_t virtio_queue_get_avail_idx(VirtIODevice *vdev, int n) +{ + return vring_avail_idx(&vdev->vq[n]); +} + uint16_t virtio_queue_get_last_avail_idx(VirtIODevice *vdev, int n) { return vdev->vq[n].last_avail_idx; diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index 3e54e90..3bb0db2 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -239,6 +239,7 @@ hwaddr virtio_queue_get_desc_size(VirtIODevice *vdev, int n); hwaddr virtio_queue_get_avail_size(VirtIODevice *vdev, int n); hwaddr virtio_queue_get_used_size(VirtIODevice *vdev, int n); hwaddr virtio_queue_get_ring_size(VirtIODevice *vdev, int n); +uint16_t virtio_queue_get_avail_idx(VirtIODevice *vdev, int n); uint16_t virtio_queue_get_last_avail_idx(VirtIODevice *vdev, int n); void virtio_queue_set_last_avail_idx(VirtIODevice *vdev, int n, uint16_t idx); void virtio_queue_invalidate_signalled_used(VirtIODevice *vdev, int n); -- 1.8.3.2