[v2] examples/vhost: add error propagation in ioat ops

Message ID 20210203142904.37625-1-Cheng1.jiang@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Maxime Coquelin
Headers
Series [v2] examples/vhost: add error propagation in ioat ops |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-testing warning Testing issues

Commit Message

Jiang, Cheng1 Feb. 3, 2021, 2:29 p.m. UTC
  It makes more sense to add error propagation for rte_ioat_completed_ops.
And change the type of dev_id from int to uint16_t.

Signed-off-by: Cheng Jiang <Cheng1.jiang@intel.com>
---
v2: mentioned dev_id type changes in git log

 examples/vhost/ioat.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

--
2.29.2
  

Comments

Maxime Coquelin Feb. 3, 2021, 4:43 p.m. UTC | #1
On 2/3/21 3:29 PM, Cheng Jiang wrote:
> It makes more sense to add error propagation for rte_ioat_completed_ops.
> And change the type of dev_id from int to uint16_t.

I would reword it to:

"
This patch adds add error propagation for rte_ioat_completed_ops call,
and also changes dev_id type from int to uint16_t.
"

Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>

> 
> Signed-off-by: Cheng Jiang <Cheng1.jiang@intel.com>
> ---
> v2: mentioned dev_id type changes in git log
> 
>  examples/vhost/ioat.c | 14 ++++++++++----
>  1 file changed, 10 insertions(+), 4 deletions(-)
> 
> diff --git a/examples/vhost/ioat.c b/examples/vhost/ioat.c
> index dbad28d43..60b73be93 100644
> --- a/examples/vhost/ioat.c
> +++ b/examples/vhost/ioat.c
> @@ -22,7 +22,6 @@ struct packet_tracker {
> 
>  struct packet_tracker cb_tracker[MAX_VHOST_DEVICE];
> 
> -
>  int
>  open_ioat(const char *value)
>  {
> @@ -129,7 +128,7 @@ ioat_transfer_data_cb(int vid, uint16_t queue_id,
>  		struct rte_vhost_async_status *opaque_data, uint16_t count)
>  {
>  	uint32_t i_desc;
> -	int dev_id = dma_bind[vid].dmas[queue_id * 2 + VIRTIO_RXQ].dev_id;
> +	uint16_t dev_id = dma_bind[vid].dmas[queue_id * 2 + VIRTIO_RXQ].dev_id;
>  	struct rte_vhost_iov_iter *src = NULL;
>  	struct rte_vhost_iov_iter *dst = NULL;
>  	unsigned long i_seg;
> @@ -182,10 +181,17 @@ ioat_check_completed_copies_cb(int vid, uint16_t queue_id,
>  		unsigned short mask = MAX_ENQUEUED_SIZE - 1;
>  		unsigned short i;
> 
> -		int dev_id = dma_bind[vid].dmas[queue_id * 2
> +		uint16_t dev_id = dma_bind[vid].dmas[queue_id * 2
>  				+ VIRTIO_RXQ].dev_id;
>  		n_seg = rte_ioat_completed_ops(dev_id, 255, dump, dump);
> -		if (n_seg <= 0)
> +		if (n_seg < 0) {
> +			RTE_LOG(ERR,
> +				VHOST_DATA,
> +				"fail to poll completed buf on IOAT device %u",
> +				dev_id);
> +			return 0;
> +		}
> +		if (n_seg == 0)
>  			return 0;
> 
>  		cb_tracker[dev_id].ioat_space += n_seg;
> --
> 2.29.2
>
  
Maxime Coquelin Feb. 3, 2021, 5:19 p.m. UTC | #2
On 2/3/21 3:29 PM, Cheng Jiang wrote:
> |It makes more sense to add error propagation for
> rte_ioat_completed_ops. And change the type of dev_id from int to
> uint16_t. Signed-off-by: Cheng Jiang <Cheng1.jiang@intel.com> --- v2:
> mentioned dev_id type changes in git log examples/vhost/ioat.c | 14
> ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)|


Applied to dpdk-next-virtio/main with commit message fixed.

Thanks,
Maxime
  

Patch

diff --git a/examples/vhost/ioat.c b/examples/vhost/ioat.c
index dbad28d43..60b73be93 100644
--- a/examples/vhost/ioat.c
+++ b/examples/vhost/ioat.c
@@ -22,7 +22,6 @@  struct packet_tracker {

 struct packet_tracker cb_tracker[MAX_VHOST_DEVICE];

-
 int
 open_ioat(const char *value)
 {
@@ -129,7 +128,7 @@  ioat_transfer_data_cb(int vid, uint16_t queue_id,
 		struct rte_vhost_async_status *opaque_data, uint16_t count)
 {
 	uint32_t i_desc;
-	int dev_id = dma_bind[vid].dmas[queue_id * 2 + VIRTIO_RXQ].dev_id;
+	uint16_t dev_id = dma_bind[vid].dmas[queue_id * 2 + VIRTIO_RXQ].dev_id;
 	struct rte_vhost_iov_iter *src = NULL;
 	struct rte_vhost_iov_iter *dst = NULL;
 	unsigned long i_seg;
@@ -182,10 +181,17 @@  ioat_check_completed_copies_cb(int vid, uint16_t queue_id,
 		unsigned short mask = MAX_ENQUEUED_SIZE - 1;
 		unsigned short i;

-		int dev_id = dma_bind[vid].dmas[queue_id * 2
+		uint16_t dev_id = dma_bind[vid].dmas[queue_id * 2
 				+ VIRTIO_RXQ].dev_id;
 		n_seg = rte_ioat_completed_ops(dev_id, 255, dump, dump);
-		if (n_seg <= 0)
+		if (n_seg < 0) {
+			RTE_LOG(ERR,
+				VHOST_DATA,
+				"fail to poll completed buf on IOAT device %u",
+				dev_id);
+			return 0;
+		}
+		if (n_seg == 0)
 			return 0;

 		cb_tracker[dev_id].ioat_space += n_seg;