[dpdk-dev] [PATCH 1/2] vhost: unify Rx mergeable and non-mergeable paths

Maxime Coquelin maxime.coquelin at redhat.com
Mon May 28 20:33:19 CEST 2018



On 05/28/2018 06:23 PM, Maxime Coquelin wrote:
> @@ -602,7 +297,7 @@ reserve_avail_buf_mergeable(struct virtio_net *dev, struct vhost_virtqueue *vq,

Just notice I forgot to remove "mergeable" from the functions names here
and below. I'll fix this in next revision after having collected some
feedback.

>   {
>   	uint16_t cur_idx;
>   	uint32_t vec_idx = 0;
> -	uint16_t tries = 0;
> +	uint16_t max_tries, tries = 0;
>   
>   	uint16_t head_idx = 0;
>   	uint16_t len = 0;
> @@ -610,6 +305,11 @@ reserve_avail_buf_mergeable(struct virtio_net *dev, struct vhost_virtqueue *vq,
>   	*num_buffers = 0;
>   	cur_idx  = vq->last_avail_idx;
>   
> +	if (rxvq_is_mergeable(dev))
> +		max_tries = vq->size;
> +	else
> +		max_tries = 1;
> +
>   	while (size > 0) {
>   		if (unlikely(cur_idx == avail_head))
>   			return -1;
> @@ -630,7 +330,7 @@ reserve_avail_buf_mergeable(struct virtio_net *dev, struct vhost_virtqueue *vq,
>   		 * can't get enough buf, it means something abnormal
>   		 * happened.
>   		 */
> -		if (unlikely(tries >= vq->size))
> +		if (unlikely(tries > max_tries))
>   			return -1;
>   	}
>   
> @@ -748,7 +448,9 @@ copy_mbuf_to_desc_mergeable(struct virtio_net *dev, struct vhost_virtqueue *vq,
>   
>   		if (hdr_addr) {
>   			virtio_enqueue_offload(hdr_mbuf, &hdr->hdr);
> -			ASSIGN_UNLESS_EQUAL(hdr->num_buffers, num_buffers);
> +			if (rxvq_is_mergeable(dev))
> +				ASSIGN_UNLESS_EQUAL(hdr->num_buffers,
> +						num_buffers);
>   
>   			if (unlikely(hdr == &tmp_hdr)) {
>   				uint64_t len;
> @@ -923,10 +625,7 @@ rte_vhost_enqueue_burst(int vid, uint16_t queue_id,
>   		return 0;
>   	}
>   
> -	if (dev->features & (1 << VIRTIO_NET_F_MRG_RXBUF))
> -		return virtio_dev_merge_rx(dev, queue_id, pkts, count);
> -	else
> -		return virtio_dev_rx(dev, queue_id, pkts, count);
> +	return virtio_dev_merge_rx(dev, queue_id, pkts, count);
>   }
>   
>   static inline bool
> -- 2.14.3


More information about the dev mailing list