DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] vhost: allow to check in-flight packets for async vhost
@ 2021-06-02 15:05 Jiayu Hu
  2021-06-08 14:30 ` Maxime Coquelin
  2021-07-07 11:54 ` [dpdk-dev] [PATCH v2] " Jiayu Hu
  0 siblings, 2 replies; 6+ messages in thread
From: Jiayu Hu @ 2021-06-02 15:05 UTC (permalink / raw)
  To: dev; +Cc: maxime.coquelin, chenbo.xia, Jiayu Hu

This patch allows to check the amount of in-flight packets
for vhost queues which register async channel acceleration.

Signed-off-by: Jiayu Hu <jiayu.hu@intel.com>
---
 doc/guides/prog_guide/vhost_lib.rst |  5 +++++
 lib/vhost/rte_vhost_async.h         | 14 ++++++++++++++
 lib/vhost/version.map               |  3 +++
 lib/vhost/vhost.c                   | 35 +++++++++++++++++++++++++++++++++++
 4 files changed, 57 insertions(+)

diff --git a/doc/guides/prog_guide/vhost_lib.rst b/doc/guides/prog_guide/vhost_lib.rst
index d18fb98..9fdc6d5 100644
--- a/doc/guides/prog_guide/vhost_lib.rst
+++ b/doc/guides/prog_guide/vhost_lib.rst
@@ -281,6 +281,11 @@ The following is an overview of some key Vhost API functions:
   Poll enqueue completion status from async data path. Completed packets
   are returned to applications through ``pkts``.
 
+* ``rte_vhost_async_get_inflight(vid, queue_id)``
+
+  This function returns the amount of in-flight packets by now for the
+  vhost queue which registers async channel acceleration.
+
 Vhost-user Implementations
 --------------------------
 
diff --git a/lib/vhost/rte_vhost_async.h b/lib/vhost/rte_vhost_async.h
index 6faa31f..553da4d 100644
--- a/lib/vhost/rte_vhost_async.h
+++ b/lib/vhost/rte_vhost_async.h
@@ -193,4 +193,18 @@ __rte_experimental
 uint16_t rte_vhost_poll_enqueue_completed(int vid, uint16_t queue_id,
 		struct rte_mbuf **pkts, uint16_t count);
 
+/**
+ * This function returns the amount of in-flight packets by now
+ * for the vhost queue which registers async channel acceleration.
+ *
+ * @param vid
+ *  id of vhost device to enqueue data
+ * @param queue_id
+ *  queue id to enqueue data
+ * @return
+ *  the amount of in-flight packets on success; -1 on failure
+ */
+__rte_experimental
+int rte_vhost_async_get_inflight(int vid, uint16_t queue_id);
+
 #endif /* _RTE_VHOST_ASYNC_H_ */
diff --git a/lib/vhost/version.map b/lib/vhost/version.map
index 9103a23..28238cb 100644
--- a/lib/vhost/version.map
+++ b/lib/vhost/version.map
@@ -79,4 +79,7 @@ EXPERIMENTAL {
 
 	# added in 21.05
 	rte_vhost_get_negotiated_protocol_features;
+
+	# added in 21.08
+	rte_vhost_async_get_inflight;
 };
diff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c
index c96f633..4547705 100644
--- a/lib/vhost/vhost.c
+++ b/lib/vhost/vhost.c
@@ -1780,5 +1780,40 @@ int rte_vhost_async_channel_unregister(int vid, uint16_t queue_id)
 	return ret;
 }
 
+int rte_vhost_async_get_inflight(int vid, uint16_t queue_id)
+{
+	struct vhost_virtqueue *vq;
+	struct virtio_net *dev = get_device(vid);
+	int ret = -1;
+
+	if (dev == NULL)
+		return ret;
+
+	if (queue_id >= VHOST_MAX_VRING)
+		return ret;
+
+	vq = dev->virtqueue[queue_id];
+
+	if (vq == NULL)
+		return ret;
+
+	ret = 0;
+
+	if (!vq->async_registered)
+		return ret;
+
+	if (!rte_spinlock_trylock(&vq->access_lock)) {
+		VHOST_LOG_CONFIG(ERR, "Failed to check in-flight packets. "
+			"virt queue busy.\n");
+		return -1;
+	}
+
+	ret = vq->async_pkts_inflight_n;
+	rte_spinlock_unlock(&vq->access_lock);
+
+	return ret;
+
+}
+
 RTE_LOG_REGISTER_SUFFIX(vhost_config_log_level, config, INFO);
 RTE_LOG_REGISTER_SUFFIX(vhost_data_log_level, data, WARNING);
-- 
2.7.4


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dpdk-dev] [PATCH] vhost: allow to check in-flight packets for async vhost
  2021-06-02 15:05 [dpdk-dev] [PATCH] vhost: allow to check in-flight packets for async vhost Jiayu Hu
@ 2021-06-08 14:30 ` Maxime Coquelin
  2021-07-07 11:54 ` [dpdk-dev] [PATCH v2] " Jiayu Hu
  1 sibling, 0 replies; 6+ messages in thread
From: Maxime Coquelin @ 2021-06-08 14:30 UTC (permalink / raw)
  To: Jiayu Hu, dev; +Cc: maxime.coquelin, chenbo.xia

Hi Jiayu,

On 6/2/21 5:05 PM, Jiayu Hu wrote:
> This patch allows to check the amount of in-flight packets
> for vhost queues which register async channel acceleration.
> 
> Signed-off-by: Jiayu Hu <jiayu.hu@intel.com>
> ---
>  doc/guides/prog_guide/vhost_lib.rst |  5 +++++
>  lib/vhost/rte_vhost_async.h         | 14 ++++++++++++++
>  lib/vhost/version.map               |  3 +++
>  lib/vhost/vhost.c                   | 35 +++++++++++++++++++++++++++++++++++
>  4 files changed, 57 insertions(+)
> 
> diff --git a/doc/guides/prog_guide/vhost_lib.rst b/doc/guides/prog_guide/vhost_lib.rst
> index d18fb98..9fdc6d5 100644
> --- a/doc/guides/prog_guide/vhost_lib.rst
> +++ b/doc/guides/prog_guide/vhost_lib.rst
> @@ -281,6 +281,11 @@ The following is an overview of some key Vhost API functions:
>    Poll enqueue completion status from async data path. Completed packets
>    are returned to applications through ``pkts``.
>  
> +* ``rte_vhost_async_get_inflight(vid, queue_id)``
> +
> +  This function returns the amount of in-flight packets by now for the
> +  vhost queue which registers async channel acceleration.
> +
>  Vhost-user Implementations
>  --------------------------
>  
> diff --git a/lib/vhost/rte_vhost_async.h b/lib/vhost/rte_vhost_async.h
> index 6faa31f..553da4d 100644
> --- a/lib/vhost/rte_vhost_async.h
> +++ b/lib/vhost/rte_vhost_async.h
> @@ -193,4 +193,18 @@ __rte_experimental
>  uint16_t rte_vhost_poll_enqueue_completed(int vid, uint16_t queue_id,
>  		struct rte_mbuf **pkts, uint16_t count);
>  
> +/**
> + * This function returns the amount of in-flight packets by now
> + * for the vhost queue which registers async channel acceleration.
> + *
> + * @param vid
> + *  id of vhost device to enqueue data
> + * @param queue_id
> + *  queue id to enqueue data
> + * @return
> + *  the amount of in-flight packets on success; -1 on failure
> + */
> +__rte_experimental
> +int rte_vhost_async_get_inflight(int vid, uint16_t queue_id);
> +
>  #endif /* _RTE_VHOST_ASYNC_H_ */
> diff --git a/lib/vhost/version.map b/lib/vhost/version.map
> index 9103a23..28238cb 100644
> --- a/lib/vhost/version.map
> +++ b/lib/vhost/version.map
> @@ -79,4 +79,7 @@ EXPERIMENTAL {
>  
>  	# added in 21.05
>  	rte_vhost_get_negotiated_protocol_features;
> +
> +	# added in 21.08
> +	rte_vhost_async_get_inflight;
>  };
> diff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c
> index c96f633..4547705 100644
> --- a/lib/vhost/vhost.c
> +++ b/lib/vhost/vhost.c
> @@ -1780,5 +1780,40 @@ int rte_vhost_async_channel_unregister(int vid, uint16_t queue_id)
>  	return ret;
>  }
>  
> +int rte_vhost_async_get_inflight(int vid, uint16_t queue_id)
> +{
> +	struct vhost_virtqueue *vq;
> +	struct virtio_net *dev = get_device(vid);
> +	int ret = -1;
> +
> +	if (dev == NULL)
> +		return ret;
> +
> +	if (queue_id >= VHOST_MAX_VRING)
> +		return ret;
> +
> +	vq = dev->virtqueue[queue_id];
> +
> +	if (vq == NULL)
> +		return ret;
> +
> +	ret = 0;
> +
> +	if (!vq->async_registered)
> +		return ret;
> +
> +	if (!rte_spinlock_trylock(&vq->access_lock)) {
> +		VHOST_LOG_CONFIG(ERR, "Failed to check in-flight packets. "
> +			"virt queue busy.\n");

Maybe better to use DEBUG log level here, as it could flood the logs.

> +		return -1;
> +	}
> +
> +	ret = vq->async_pkts_inflight_n;
> +	rte_spinlock_unlock(&vq->access_lock);
> +
> +	return ret;
> +
> +}
> +
>  RTE_LOG_REGISTER_SUFFIX(vhost_config_log_level, config, INFO);
>  RTE_LOG_REGISTER_SUFFIX(vhost_data_log_level, data, WARNING);
> 


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dpdk-dev] [PATCH v2] vhost: allow to check in-flight packets for async vhost
  2021-07-07 11:54 ` [dpdk-dev] [PATCH v2] " Jiayu Hu
@ 2021-07-07  9:21   ` Maxime Coquelin
  2021-07-08 10:21   ` [dpdk-dev] [PATCH v3] " Jiayu Hu
  1 sibling, 0 replies; 6+ messages in thread
From: Maxime Coquelin @ 2021-07-07  9:21 UTC (permalink / raw)
  To: Jiayu Hu, dev; +Cc: chenbo.xia



On 7/7/21 1:54 PM, Jiayu Hu wrote:
> This patch allows to check the amount of in-flight packets
> for vhost queues which register async channel acceleration.
> 
> Signed-off-by: Jiayu Hu <jiayu.hu@intel.com>
> ---
> v2:
> * use DEBUG log level
> * return -1 when async is not registered
> 
>  doc/guides/prog_guide/vhost_lib.rst |  5 +++++
>  lib/vhost/rte_vhost_async.h         | 14 ++++++++++++++
>  lib/vhost/version.map               |  3 +++
>  lib/vhost/vhost.c                   | 33 +++++++++++++++++++++++++++++++++
>  4 files changed, 55 insertions(+)
> 
> diff --git a/doc/guides/prog_guide/vhost_lib.rst b/doc/guides/prog_guide/vhost_lib.rst
> index d18fb98..9fdc6d5 100644
> --- a/doc/guides/prog_guide/vhost_lib.rst
> +++ b/doc/guides/prog_guide/vhost_lib.rst
> @@ -281,6 +281,11 @@ The following is an overview of some key Vhost API functions:
>    Poll enqueue completion status from async data path. Completed packets
>    are returned to applications through ``pkts``.
>  
> +* ``rte_vhost_async_get_inflight(vid, queue_id)``
> +
> +  This function returns the amount of in-flight packets by now for the
> +  vhost queue which registers async channel acceleration.

What about:

"
This function returns the amount of in-flight packets for the Vhost
queue using async acceleration.
"

Other than that, it looks good to me:
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>

Thanks,
Maxime


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [dpdk-dev] [PATCH v2] vhost: allow to check in-flight packets for async vhost
  2021-06-02 15:05 [dpdk-dev] [PATCH] vhost: allow to check in-flight packets for async vhost Jiayu Hu
  2021-06-08 14:30 ` Maxime Coquelin
@ 2021-07-07 11:54 ` Jiayu Hu
  2021-07-07  9:21   ` Maxime Coquelin
  2021-07-08 10:21   ` [dpdk-dev] [PATCH v3] " Jiayu Hu
  1 sibling, 2 replies; 6+ messages in thread
From: Jiayu Hu @ 2021-07-07 11:54 UTC (permalink / raw)
  To: dev; +Cc: maxime.coquelin, chenbo.xia, Jiayu Hu

This patch allows to check the amount of in-flight packets
for vhost queues which register async channel acceleration.

Signed-off-by: Jiayu Hu <jiayu.hu@intel.com>
---
v2:
* use DEBUG log level
* return -1 when async is not registered

 doc/guides/prog_guide/vhost_lib.rst |  5 +++++
 lib/vhost/rte_vhost_async.h         | 14 ++++++++++++++
 lib/vhost/version.map               |  3 +++
 lib/vhost/vhost.c                   | 33 +++++++++++++++++++++++++++++++++
 4 files changed, 55 insertions(+)

diff --git a/doc/guides/prog_guide/vhost_lib.rst b/doc/guides/prog_guide/vhost_lib.rst
index d18fb98..9fdc6d5 100644
--- a/doc/guides/prog_guide/vhost_lib.rst
+++ b/doc/guides/prog_guide/vhost_lib.rst
@@ -281,6 +281,11 @@ The following is an overview of some key Vhost API functions:
   Poll enqueue completion status from async data path. Completed packets
   are returned to applications through ``pkts``.
 
+* ``rte_vhost_async_get_inflight(vid, queue_id)``
+
+  This function returns the amount of in-flight packets by now for the
+  vhost queue which registers async channel acceleration.
+
 Vhost-user Implementations
 --------------------------
 
diff --git a/lib/vhost/rte_vhost_async.h b/lib/vhost/rte_vhost_async.h
index 6faa31f..553da4d 100644
--- a/lib/vhost/rte_vhost_async.h
+++ b/lib/vhost/rte_vhost_async.h
@@ -193,4 +193,18 @@ __rte_experimental
 uint16_t rte_vhost_poll_enqueue_completed(int vid, uint16_t queue_id,
 		struct rte_mbuf **pkts, uint16_t count);
 
+/**
+ * This function returns the amount of in-flight packets by now
+ * for the vhost queue which registers async channel acceleration.
+ *
+ * @param vid
+ *  id of vhost device to enqueue data
+ * @param queue_id
+ *  queue id to enqueue data
+ * @return
+ *  the amount of in-flight packets on success; -1 on failure
+ */
+__rte_experimental
+int rte_vhost_async_get_inflight(int vid, uint16_t queue_id);
+
 #endif /* _RTE_VHOST_ASYNC_H_ */
diff --git a/lib/vhost/version.map b/lib/vhost/version.map
index 9103a23..28238cb 100644
--- a/lib/vhost/version.map
+++ b/lib/vhost/version.map
@@ -79,4 +79,7 @@ EXPERIMENTAL {
 
 	# added in 21.05
 	rte_vhost_get_negotiated_protocol_features;
+
+	# added in 21.08
+	rte_vhost_async_get_inflight;
 };
diff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c
index 53a470f..3f82d3f 100644
--- a/lib/vhost/vhost.c
+++ b/lib/vhost/vhost.c
@@ -1778,5 +1778,38 @@ int rte_vhost_async_channel_unregister(int vid, uint16_t queue_id)
 	return ret;
 }
 
+int rte_vhost_async_get_inflight(int vid, uint16_t queue_id)
+{
+	struct vhost_virtqueue *vq;
+	struct virtio_net *dev = get_device(vid);
+	int ret = -1;
+
+	if (dev == NULL)
+		return ret;
+
+	if (queue_id >= VHOST_MAX_VRING)
+		return ret;
+
+	vq = dev->virtqueue[queue_id];
+
+	if (vq == NULL)
+		return ret;
+
+	if (!vq->async_registered)
+		return ret;
+
+	if (!rte_spinlock_trylock(&vq->access_lock)) {
+		VHOST_LOG_CONFIG(DEBUG, "Failed to check in-flight packets. "
+			"virt queue busy.\n");
+		return ret;
+	}
+
+	ret = vq->async_pkts_inflight_n;
+	rte_spinlock_unlock(&vq->access_lock);
+
+	return ret;
+
+}
+
 RTE_LOG_REGISTER_SUFFIX(vhost_config_log_level, config, INFO);
 RTE_LOG_REGISTER_SUFFIX(vhost_data_log_level, data, WARNING);
-- 
2.7.4


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [dpdk-dev] [PATCH v3] vhost: allow to check in-flight packets for async vhost
  2021-07-07 11:54 ` [dpdk-dev] [PATCH v2] " Jiayu Hu
  2021-07-07  9:21   ` Maxime Coquelin
@ 2021-07-08 10:21   ` Jiayu Hu
  2021-07-20  2:47     ` Xia, Chenbo
  1 sibling, 1 reply; 6+ messages in thread
From: Jiayu Hu @ 2021-07-08 10:21 UTC (permalink / raw)
  To: dev; +Cc: maxime.coquelin, chenbo.xia, Jiayu Hu

This patch allows to check the amount of in-flight packets
for the vhost queue using async acceleration.

Signed-off-by: Jiayu Hu <jiayu.hu@intel.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
---
v3:
* update commit log and doc
v2:
* use DEBUG log level
* return -1 when async is not registered

 doc/guides/prog_guide/vhost_lib.rst |  5 +++++
 lib/vhost/rte_vhost_async.h         | 14 ++++++++++++++
 lib/vhost/version.map               |  3 +++
 lib/vhost/vhost.c                   | 33 +++++++++++++++++++++++++++++++++
 4 files changed, 55 insertions(+)

diff --git a/doc/guides/prog_guide/vhost_lib.rst b/doc/guides/prog_guide/vhost_lib.rst
index d18fb98..5094999 100644
--- a/doc/guides/prog_guide/vhost_lib.rst
+++ b/doc/guides/prog_guide/vhost_lib.rst
@@ -281,6 +281,11 @@ The following is an overview of some key Vhost API functions:
   Poll enqueue completion status from async data path. Completed packets
   are returned to applications through ``pkts``.
 
+* ``rte_vhost_async_get_inflight(vid, queue_id)``
+
+  This function returns the amount of in-flight packets for the vhost
+  queue using async acceleration.
+
 Vhost-user Implementations
 --------------------------
 
diff --git a/lib/vhost/rte_vhost_async.h b/lib/vhost/rte_vhost_async.h
index 6faa31f..7c55825 100644
--- a/lib/vhost/rte_vhost_async.h
+++ b/lib/vhost/rte_vhost_async.h
@@ -193,4 +193,18 @@ __rte_experimental
 uint16_t rte_vhost_poll_enqueue_completed(int vid, uint16_t queue_id,
 		struct rte_mbuf **pkts, uint16_t count);
 
+/**
+ * This function returns the amount of in-flight packets for the vhost
+ * queue which uses async channel acceleration.
+ *
+ * @param vid
+ *  id of vhost device to enqueue data
+ * @param queue_id
+ *  queue id to enqueue data
+ * @return
+ *  the amount of in-flight packets on success; -1 on failure
+ */
+__rte_experimental
+int rte_vhost_async_get_inflight(int vid, uint16_t queue_id);
+
 #endif /* _RTE_VHOST_ASYNC_H_ */
diff --git a/lib/vhost/version.map b/lib/vhost/version.map
index 9103a23..28238cb 100644
--- a/lib/vhost/version.map
+++ b/lib/vhost/version.map
@@ -79,4 +79,7 @@ EXPERIMENTAL {
 
 	# added in 21.05
 	rte_vhost_get_negotiated_protocol_features;
+
+	# added in 21.08
+	rte_vhost_async_get_inflight;
 };
diff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c
index 53a470f..3f82d3f 100644
--- a/lib/vhost/vhost.c
+++ b/lib/vhost/vhost.c
@@ -1778,5 +1778,38 @@ int rte_vhost_async_channel_unregister(int vid, uint16_t queue_id)
 	return ret;
 }
 
+int rte_vhost_async_get_inflight(int vid, uint16_t queue_id)
+{
+	struct vhost_virtqueue *vq;
+	struct virtio_net *dev = get_device(vid);
+	int ret = -1;
+
+	if (dev == NULL)
+		return ret;
+
+	if (queue_id >= VHOST_MAX_VRING)
+		return ret;
+
+	vq = dev->virtqueue[queue_id];
+
+	if (vq == NULL)
+		return ret;
+
+	if (!vq->async_registered)
+		return ret;
+
+	if (!rte_spinlock_trylock(&vq->access_lock)) {
+		VHOST_LOG_CONFIG(DEBUG, "Failed to check in-flight packets. "
+			"virt queue busy.\n");
+		return ret;
+	}
+
+	ret = vq->async_pkts_inflight_n;
+	rte_spinlock_unlock(&vq->access_lock);
+
+	return ret;
+
+}
+
 RTE_LOG_REGISTER_SUFFIX(vhost_config_log_level, config, INFO);
 RTE_LOG_REGISTER_SUFFIX(vhost_data_log_level, data, WARNING);
-- 
2.7.4


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dpdk-dev] [PATCH v3] vhost: allow to check in-flight packets for async vhost
  2021-07-08 10:21   ` [dpdk-dev] [PATCH v3] " Jiayu Hu
@ 2021-07-20  2:47     ` Xia, Chenbo
  0 siblings, 0 replies; 6+ messages in thread
From: Xia, Chenbo @ 2021-07-20  2:47 UTC (permalink / raw)
  To: Hu, Jiayu, dev; +Cc: maxime.coquelin

> -----Original Message-----
> From: Hu, Jiayu <jiayu.hu@intel.com>
> Sent: Thursday, July 8, 2021 6:21 PM
> To: dev@dpdk.org
> Cc: maxime.coquelin@redhat.com; Xia, Chenbo <chenbo.xia@intel.com>; Hu, Jiayu
> <jiayu.hu@intel.com>
> Subject: [PATCH v3] vhost: allow to check in-flight packets for async vhost
> 
> This patch allows to check the amount of in-flight packets
> for the vhost queue using async acceleration.
> 
> Signed-off-by: Jiayu Hu <jiayu.hu@intel.com>
> Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
> ---
> --
> 2.7.4

Applied to next-virtio/main, thanks.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-07-20  2:47 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-02 15:05 [dpdk-dev] [PATCH] vhost: allow to check in-flight packets for async vhost Jiayu Hu
2021-06-08 14:30 ` Maxime Coquelin
2021-07-07 11:54 ` [dpdk-dev] [PATCH v2] " Jiayu Hu
2021-07-07  9:21   ` Maxime Coquelin
2021-07-08 10:21   ` [dpdk-dev] [PATCH v3] " Jiayu Hu
2021-07-20  2:47     ` Xia, Chenbo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).