[dpdk-dev] [PATCH 11/14] vhost: add helpers for packed virtqueues

Maxime Coquelin maxime.coquelin at redhat.com
Thu Feb 1 10:20:12 CET 2018



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<jfreimann at 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


More information about the dev mailing list