diff mbox series

[v2,07/15] vhost: remove useless fields in async iterator struct

Message ID 20211026162904.482987-8-maxime.coquelin@redhat.com (mailing list archive)
State Accepted, archived
Delegated to: Maxime Coquelin
Headers show
Series vhost: clean-up and simplify async implementation | expand

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Maxime Coquelin Oct. 26, 2021, 4:28 p.m. UTC
Offset and count fields are unused and so can be removed.
The offset field was actually in the Vhost example, but
in a way that does not make sense.

Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
---
 examples/vhost/ioat.c       |  6 ++----
 lib/vhost/rte_vhost_async.h |  4 ----
 lib/vhost/virtio_net.c      | 19 ++++---------------
 3 files changed, 6 insertions(+), 23 deletions(-)

Comments

Xia, Chenbo Oct. 29, 2021, 6:19 a.m. UTC | #1
> -----Original Message-----
> From: Maxime Coquelin <maxime.coquelin@redhat.com>
> Sent: Wednesday, October 27, 2021 12:29 AM
> To: dev@dpdk.org; Xia, Chenbo <chenbo.xia@intel.com>; Hu, Jiayu
> <jiayu.hu@intel.com>; Wang, YuanX <yuanx.wang@intel.com>; Ma, WenwuX
> <wenwux.ma@intel.com>; Richardson, Bruce <bruce.richardson@intel.com>;
> Mcnamara, John <john.mcnamara@intel.com>
> Cc: Maxime Coquelin <maxime.coquelin@redhat.com>
> Subject: [PATCH v2 07/15] vhost: remove useless fields in async iterator
> struct
> 
> Offset and count fields are unused and so can be removed.
> The offset field was actually in the Vhost example, but
> in a way that does not make sense.
> 
> Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
> ---
>  examples/vhost/ioat.c       |  6 ++----
>  lib/vhost/rte_vhost_async.h |  4 ----
>  lib/vhost/virtio_net.c      | 19 ++++---------------
>  3 files changed, 6 insertions(+), 23 deletions(-)
> 
> diff --git a/examples/vhost/ioat.c b/examples/vhost/ioat.c
> index dcbcf65e4e..a8c588deff 100644
> --- a/examples/vhost/ioat.c
> +++ b/examples/vhost/ioat.c
> @@ -142,10 +142,8 @@ ioat_transfer_data_cb(int vid, uint16_t queue_id,
>  				break;
>  			while (i_seg < iter->nr_segs) {
>  				rte_ioat_enqueue_copy(dev_id,
> -					(uintptr_t)(iter->iov[i_seg].src_addr)
> -						+ iter->offset,
> -					(uintptr_t)(iter->iov[i_seg].dst_addr)
> -						+ iter->offset,
> +					(uintptr_t)(iter->iov[i_seg].src_addr),
> +					(uintptr_t)(iter->iov[i_seg].dst_addr),
>  					iter->iov[i_seg].len,
>  					0,
>  					0);
> diff --git a/lib/vhost/rte_vhost_async.h b/lib/vhost/rte_vhost_async.h
> index d7bb77bf90..4ea5cfab10 100644
> --- a/lib/vhost/rte_vhost_async.h
> +++ b/lib/vhost/rte_vhost_async.h
> @@ -20,10 +20,6 @@ struct rte_vhost_iovec {
>   * iovec iterator
>   */
>  struct rte_vhost_iov_iter {
> -	/** offset to the first byte of interesting data */
> -	size_t offset;
> -	/** total bytes of data in this iterator */
> -	size_t count;
>  	/** pointer to the iovec array */
>  	struct rte_vhost_iovec *iov;
>  	/** number of iovec in this iterator */
> diff --git a/lib/vhost/virtio_net.c b/lib/vhost/virtio_net.c
> index 3c8be48ca7..29254a1b11 100644
> --- a/lib/vhost/virtio_net.c
> +++ b/lib/vhost/virtio_net.c
> @@ -933,19 +933,10 @@ async_fill_vec(struct rte_vhost_iovec *v, void *src,
> void *dst, size_t len)
>  }
> 
>  static __rte_always_inline void
> -async_fill_iter(struct rte_vhost_iov_iter *it, size_t count,
> -	struct rte_vhost_iovec *vec, unsigned long nr_seg)
> +async_fill_iter(struct rte_vhost_iov_iter *it, struct rte_vhost_iovec *vec,
> unsigned long nr_seg)
>  {
> -	it->offset = 0;
> -	it->count = count;
> -
> -	if (count) {
> -		it->iov = vec;
> -		it->nr_segs = nr_seg;
> -	} else {
> -		it->iov = 0;
> -		it->nr_segs = 0;
> -	}
> +	it->iov = vec;
> +	it->nr_segs = nr_seg;
>  }
> 
>  static __rte_always_inline void
> @@ -971,7 +962,6 @@ async_mbuf_to_desc(struct virtio_net *dev, struct
> vhost_virtqueue *vq,
>  	uint32_t cpy_len, buf_len;
>  	int error = 0;
> 
> -	uint32_t tlen = 0;
>  	int tvec_idx = 0;
>  	void *hpa;
> 
> @@ -1076,7 +1066,6 @@ async_mbuf_to_desc(struct virtio_net *dev, struct
> vhost_virtqueue *vq,
>  				(void *)(uintptr_t)rte_pktmbuf_iova_offset(m,
>  				mbuf_offset), hpa, (size_t)mapped_len);
> 
> -			tlen += (uint32_t)mapped_len;
>  			cpy_len -= (uint32_t)mapped_len;
>  			mbuf_avail  -= (uint32_t)mapped_len;
>  			mbuf_offset += (uint32_t)mapped_len;
> @@ -1086,7 +1075,7 @@ async_mbuf_to_desc(struct virtio_net *dev, struct
> vhost_virtqueue *vq,
>  		}
>  	}
> 
> -	async_fill_iter(iter, tlen, iovec, tvec_idx);
> +	async_fill_iter(iter, iovec, tvec_idx);
>  out:
>  	return error;
>  }
> --
> 2.31.1

Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>
diff mbox series

Patch

diff --git a/examples/vhost/ioat.c b/examples/vhost/ioat.c
index dcbcf65e4e..a8c588deff 100644
--- a/examples/vhost/ioat.c
+++ b/examples/vhost/ioat.c
@@ -142,10 +142,8 @@  ioat_transfer_data_cb(int vid, uint16_t queue_id,
 				break;
 			while (i_seg < iter->nr_segs) {
 				rte_ioat_enqueue_copy(dev_id,
-					(uintptr_t)(iter->iov[i_seg].src_addr)
-						+ iter->offset,
-					(uintptr_t)(iter->iov[i_seg].dst_addr)
-						+ iter->offset,
+					(uintptr_t)(iter->iov[i_seg].src_addr),
+					(uintptr_t)(iter->iov[i_seg].dst_addr),
 					iter->iov[i_seg].len,
 					0,
 					0);
diff --git a/lib/vhost/rte_vhost_async.h b/lib/vhost/rte_vhost_async.h
index d7bb77bf90..4ea5cfab10 100644
--- a/lib/vhost/rte_vhost_async.h
+++ b/lib/vhost/rte_vhost_async.h
@@ -20,10 +20,6 @@  struct rte_vhost_iovec {
  * iovec iterator
  */
 struct rte_vhost_iov_iter {
-	/** offset to the first byte of interesting data */
-	size_t offset;
-	/** total bytes of data in this iterator */
-	size_t count;
 	/** pointer to the iovec array */
 	struct rte_vhost_iovec *iov;
 	/** number of iovec in this iterator */
diff --git a/lib/vhost/virtio_net.c b/lib/vhost/virtio_net.c
index 3c8be48ca7..29254a1b11 100644
--- a/lib/vhost/virtio_net.c
+++ b/lib/vhost/virtio_net.c
@@ -933,19 +933,10 @@  async_fill_vec(struct rte_vhost_iovec *v, void *src, void *dst, size_t len)
 }
 
 static __rte_always_inline void
-async_fill_iter(struct rte_vhost_iov_iter *it, size_t count,
-	struct rte_vhost_iovec *vec, unsigned long nr_seg)
+async_fill_iter(struct rte_vhost_iov_iter *it, struct rte_vhost_iovec *vec, unsigned long nr_seg)
 {
-	it->offset = 0;
-	it->count = count;
-
-	if (count) {
-		it->iov = vec;
-		it->nr_segs = nr_seg;
-	} else {
-		it->iov = 0;
-		it->nr_segs = 0;
-	}
+	it->iov = vec;
+	it->nr_segs = nr_seg;
 }
 
 static __rte_always_inline void
@@ -971,7 +962,6 @@  async_mbuf_to_desc(struct virtio_net *dev, struct vhost_virtqueue *vq,
 	uint32_t cpy_len, buf_len;
 	int error = 0;
 
-	uint32_t tlen = 0;
 	int tvec_idx = 0;
 	void *hpa;
 
@@ -1076,7 +1066,6 @@  async_mbuf_to_desc(struct virtio_net *dev, struct vhost_virtqueue *vq,
 				(void *)(uintptr_t)rte_pktmbuf_iova_offset(m,
 				mbuf_offset), hpa, (size_t)mapped_len);
 
-			tlen += (uint32_t)mapped_len;
 			cpy_len -= (uint32_t)mapped_len;
 			mbuf_avail  -= (uint32_t)mapped_len;
 			mbuf_offset += (uint32_t)mapped_len;
@@ -1086,7 +1075,7 @@  async_mbuf_to_desc(struct virtio_net *dev, struct vhost_virtqueue *vq,
 		}
 	}
 
-	async_fill_iter(iter, tlen, iovec, tvec_idx);
+	async_fill_iter(iter, iovec, tvec_idx);
 out:
 	return error;
 }