vhost: get available vring entries
authorHuawei Xie <huawei.xie@intel.com>
Wed, 8 Oct 2014 18:54:51 +0000 (02:54 +0800)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Mon, 13 Oct 2014 17:16:54 +0000 (19:16 +0200)
Signed-off-by: Huawei Xie <huawei.xie@intel.com>
Acked-by: Changchun Ouyang <changchun.ouyang@intel.com>
[Thomas: split patch]

lib/librte_vhost/rte_virtio_net.h

index 0e9c473..73423dd 100644 (file)
@@ -119,6 +119,12 @@ struct virtio_net_device_ops {
        void (* destroy_device) (volatile struct virtio_net *); /* Remove device. */
 };
 
+static inline uint16_t __attribute__((always_inline))
+rte_vring_available_entries(struct virtio_net *dev, uint16_t queue_id)
+{
+       struct vhost_virtqueue *vq = dev->virtqueue[queue_id];
+       return *(volatile uint16_t *)&vq->avail->idx - vq->last_used_idx_res;
+}
 
 /**
  * Function to convert guest physical addresses to vhost virtual addresses.