[dpdk-dev] [PATCH v4 1/2] examples/vhost: add ioat ring space count and check

Hu, Jiayu jiayu.hu at intel.com
Mon Dec 28 03:50:30 CET 2020


Hi Cheng,

> -----Original Message-----
> From: Jiang, Cheng1 <cheng1.jiang at intel.com>
> Sent: Friday, December 25, 2020 4:07 PM
> To: maxime.coquelin at redhat.com; Xia, Chenbo <chenbo.xia at intel.com>
> Cc: dev at dpdk.org; Hu, Jiayu <jiayu.hu at intel.com>; Yang, YvonneX
> <yvonnex.yang at intel.com>; Jiang, Cheng1 <cheng1.jiang at intel.com>
> Subject: [PATCH v4 1/2] examples/vhost: add ioat ring space count and check
> 
> Add ioat ring space count and check, if ioat ring space is not enough
> for the next async vhost packet enqueue, then just return to prevent
> enqueue failure.
> 
> Signed-off-by: Cheng Jiang <Cheng1.jiang at intel.com>
> ---
>  examples/vhost/ioat.c | 15 +++++++--------
>  1 file changed, 7 insertions(+), 8 deletions(-)
> 
> diff --git a/examples/vhost/ioat.c b/examples/vhost/ioat.c
> index 71d8a1f1f..b0b04aa45 100644
> --- a/examples/vhost/ioat.c
> +++ b/examples/vhost/ioat.c
> @@ -17,6 +17,7 @@ struct packet_tracker {
>  	unsigned short next_read;
>  	unsigned short next_write;
>  	unsigned short last_remain;
> +	unsigned short ioat_space;
>  };
> 
>  struct packet_tracker cb_tracker[MAX_VHOST_DEVICE];
> @@ -113,7 +114,7 @@ open_ioat(const char *value)
>  			goto out;
>  		}
>  		rte_rawdev_start(dev_id);
> -
> +		cb_tracker[dev_id].ioat_space = IOAT_RING_SIZE;
>  		dma_info->nr++;
>  		i++;
>  	}
> @@ -140,13 +141,9 @@ ioat_transfer_data_cb(int vid, uint16_t queue_id,
>  			src = descs[i_desc].src;
>  			dst = descs[i_desc].dst;
>  			i_seg = 0;
> +			if (cb_tracker[dev_id].ioat_space < src->nr_segs)
> +				break;
>  			while (i_seg < src->nr_segs) {
> -				/*
> -				 * TODO: Assuming that the ring space of the
> -				 * IOAT device is large enough, so there is no
> -				 * error here, and the actual error handling
> -				 * will be added later.
> -				 */
>  				rte_ioat_enqueue_copy(dev_id,
>  					(uintptr_t)(src->iov[i_seg].iov_base)
>  						+ src->offset,
> @@ -158,7 +155,8 @@ ioat_transfer_data_cb(int vid, uint16_t queue_id,
>  				i_seg++;
>  			}
>  			write &= mask;
> -			cb_tracker[dev_id].size_track[write] = i_seg;
> +			cb_tracker[dev_id].size_track[write] = src->nr_segs;
> +			cb_tracker[dev_id].ioat_space -= src->nr_segs;
>  			write++;
>  		}
>  	} else {
> @@ -186,6 +184,7 @@ ioat_check_completed_copies_cb(int vid, uint16_t
> queue_id,
>  		int dev_id = dma_bind[vid].dmas[queue_id * 2
>  				+ VIRTIO_RXQ].dev_id;
>  		n_seg = rte_ioat_completed_ops(dev_id, 255, dump, dump);
> +		cb_tracker[dev_id].ioat_space += n_seg;

rte_ioat_completed_ops() may fail. In this case, its return value is -1, which
will cause n_seg to 65534.

Thanks,
Jiayu

>  		n_seg += cb_tracker[dev_id].last_remain;
>  		if (!n_seg)
>  			return 0;
> --
> 2.29.2



More information about the dev mailing list