diff mbox series

[v2] vhost: add vDPA resource cleanup callback

Message ID 20220127084535.673527-1-xuemingl@nvidia.com (mailing list archive)
State Accepted, archived
Delegated to: Maxime Coquelin
Headers show
Series [v2] vhost: add vDPA resource cleanup callback | expand

Checks

Context Check Description
ci/intel-Testing success Testing PASS
ci/Intel-compilation success Compilation OK
ci/iol-abi-testing warning Testing issues
ci/iol-x86_64-compile-testing fail Testing issues
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/github-robot: build success github build: passed
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/checkpatch success coding style OK

Commit Message

Xueming(Steven) Li Jan. 27, 2022, 8:45 a.m. UTC
This patch adds vDPA device cleanup callback to release resources on
vhost user connection close.

Signed-off-by: Xueming Li <xuemingl@nvidia.com>
---
 lib/vhost/vdpa_driver.h | 3 +++
 lib/vhost/vhost_user.c  | 6 ++++++
 2 files changed, 9 insertions(+)

Comments

Maxime Coquelin Feb. 3, 2022, 1:47 p.m. UTC | #1
On 1/27/22 09:45, Xueming Li wrote:
> This patch adds vDPA device cleanup callback to release resources on
> vhost user connection close.
> 
> Signed-off-by: Xueming Li <xuemingl@nvidia.com>
> ---
>   lib/vhost/vdpa_driver.h | 3 +++
>   lib/vhost/vhost_user.c  | 6 ++++++
>   2 files changed, 9 insertions(+)
> 
> diff --git a/lib/vhost/vdpa_driver.h b/lib/vhost/vdpa_driver.h
> index fc2d6acedd1..fddbd506523 100644
> --- a/lib/vhost/vdpa_driver.h
> +++ b/lib/vhost/vdpa_driver.h
> @@ -34,6 +34,9 @@ struct rte_vdpa_dev_ops {
>   	/** Driver close the device (Mandatory) */
>   	int (*dev_close)(int vid);
>   
> +	/** Connection closed, clean up resources */
> +	int (*dev_cleanup)(int vid);
> +
>   	/** Enable/disable this vring (Mandatory) */
>   	int (*set_vring_state)(int vid, int vring, int state);
>   
> diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c
> index 5eb1dd68123..798b0ca4c0d 100644
> --- a/lib/vhost/vhost_user.c
> +++ b/lib/vhost/vhost_user.c
> @@ -220,6 +220,12 @@ free_mem_region(struct virtio_net *dev)
>   void
>   vhost_backend_cleanup(struct virtio_net *dev)
>   {
> +	struct rte_vdpa_device *vdpa_dev;
> +
> +	vdpa_dev = dev->vdpa_dev;
> +	if (vdpa_dev && vdpa_dev->ops->dev_cleanup != NULL)
> +		vdpa_dev->ops->dev_cleanup(dev->vid);
> +
>   	if (dev->mem) {
>   		free_mem_region(dev);
>   		rte_free(dev->mem);

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

Thanks,
Maxime
Maxime Coquelin Feb. 10, 2022, 3:13 p.m. UTC | #2
On 1/27/22 09:45, Xueming Li wrote:
> This patch adds vDPA device cleanup callback to release resources on
> vhost user connection close.
> 
> Signed-off-by: Xueming Li <xuemingl@nvidia.com>
> ---
>   lib/vhost/vdpa_driver.h | 3 +++
>   lib/vhost/vhost_user.c  | 6 ++++++
>   2 files changed, 9 insertions(+)
> 
> diff --git a/lib/vhost/vdpa_driver.h b/lib/vhost/vdpa_driver.h
> index fc2d6acedd1..fddbd506523 100644
> --- a/lib/vhost/vdpa_driver.h
> +++ b/lib/vhost/vdpa_driver.h
> @@ -34,6 +34,9 @@ struct rte_vdpa_dev_ops {
>   	/** Driver close the device (Mandatory) */
>   	int (*dev_close)(int vid);
>   
> +	/** Connection closed, clean up resources */
> +	int (*dev_cleanup)(int vid);
> +
>   	/** Enable/disable this vring (Mandatory) */
>   	int (*set_vring_state)(int vid, int vring, int state);
>   
> diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c
> index 5eb1dd68123..798b0ca4c0d 100644
> --- a/lib/vhost/vhost_user.c
> +++ b/lib/vhost/vhost_user.c
> @@ -220,6 +220,12 @@ free_mem_region(struct virtio_net *dev)
>   void
>   vhost_backend_cleanup(struct virtio_net *dev)
>   {
> +	struct rte_vdpa_device *vdpa_dev;
> +
> +	vdpa_dev = dev->vdpa_dev;
> +	if (vdpa_dev && vdpa_dev->ops->dev_cleanup != NULL)
> +		vdpa_dev->ops->dev_cleanup(dev->vid);
> +
>   	if (dev->mem) {
>   		free_mem_region(dev);
>   		rte_free(dev->mem);


Applied to dpdk-next-virtio/main.

Thanks,
Maxime
diff mbox series

Patch

diff --git a/lib/vhost/vdpa_driver.h b/lib/vhost/vdpa_driver.h
index fc2d6acedd1..fddbd506523 100644
--- a/lib/vhost/vdpa_driver.h
+++ b/lib/vhost/vdpa_driver.h
@@ -34,6 +34,9 @@  struct rte_vdpa_dev_ops {
 	/** Driver close the device (Mandatory) */
 	int (*dev_close)(int vid);
 
+	/** Connection closed, clean up resources */
+	int (*dev_cleanup)(int vid);
+
 	/** Enable/disable this vring (Mandatory) */
 	int (*set_vring_state)(int vid, int vring, int state);
 
diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c
index 5eb1dd68123..798b0ca4c0d 100644
--- a/lib/vhost/vhost_user.c
+++ b/lib/vhost/vhost_user.c
@@ -220,6 +220,12 @@  free_mem_region(struct virtio_net *dev)
 void
 vhost_backend_cleanup(struct virtio_net *dev)
 {
+	struct rte_vdpa_device *vdpa_dev;
+
+	vdpa_dev = dev->vdpa_dev;
+	if (vdpa_dev && vdpa_dev->ops->dev_cleanup != NULL)
+		vdpa_dev->ops->dev_cleanup(dev->vid);
+
 	if (dev->mem) {
 		free_mem_region(dev);
 		rte_free(dev->mem);