On 01/29/2018 03:11 PM, Jens Freimann wrote:
Add some helper functions to set/check descriptor flags
and toggle the used wrap counter.

Signed-off-by: Jens Freimann<jfreim...@redhat.com>
---
  lib/librte_vhost/virtio-1.1.h | 43 +++++++++++++++++++++++++++++++++++++++++++
  1 file changed, 43 insertions(+)

diff --git a/lib/librte_vhost/virtio-1.1.h b/lib/librte_vhost/virtio-1.1.h
index 5ca0bc33f..84039797e 100644
--- a/lib/librte_vhost/virtio-1.1.h
+++ b/lib/librte_vhost/virtio-1.1.h
@@ -17,4 +17,47 @@ struct vring_desc_1_1 {
        uint16_t flags;
  };
+static inline void
+toggle_wrap_counter(struct vhost_virtqueue *vq)
+{
+       vq->used_wrap_counter ^= 1;
+}
+
+static inline int
+desc_is_avail(struct vhost_virtqueue *vq, struct vring_desc_1_1 *desc)
+{
+       if (!vq)
+               return -1;

Maybe use unlikely() here?

Maxime

Reply via email to