DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] vhost: add vDPA resource cleanup callback
@ 2021-10-19 11:39 Xueming Li
  2021-10-21 12:00 ` Maxime Coquelin
  2022-01-27  8:45 ` [PATCH v2] " Xueming Li
  0 siblings, 2 replies; 13+ messages in thread
From: Xueming Li @ 2021-10-19 11:39 UTC (permalink / raw)
  To: dev; +Cc: xuemingl, Maxime Coquelin, Chenbo Xia

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/rte_vdpa_dev.h | 3 +++
 lib/vhost/vhost_user.c   | 6 ++++++
 2 files changed, 9 insertions(+)

diff --git a/lib/vhost/rte_vdpa_dev.h b/lib/vhost/rte_vdpa_dev.h
index b0f494815fa..2711004fe05 100644
--- a/lib/vhost/rte_vdpa_dev.h
+++ b/lib/vhost/rte_vdpa_dev.h
@@ -32,6 +32,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 5a894ca0cc7..032b621c86c 100644
--- a/lib/vhost/vhost_user.c
+++ b/lib/vhost/vhost_user.c
@@ -162,6 +162,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);
-- 
2.33.0


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

end of thread, other threads:[~2022-02-10 15:13 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-19 11:39 [dpdk-dev] [PATCH] vhost: add vDPA resource cleanup callback Xueming Li
2021-10-21 12:00 ` Maxime Coquelin
2021-10-21 12:35   ` Xueming(Steven) Li
2021-11-03  8:41     ` Xia, Chenbo
2021-11-03  8:46       ` Maxime Coquelin
2021-11-03 13:45         ` Xueming(Steven) Li
2021-11-03 13:49           ` Maxime Coquelin
2022-01-26 10:03             ` Maxime Coquelin
2022-01-27  8:48               ` Xueming(Steven) Li
2021-11-03 13:42       ` [dpdk-dev] " Xueming(Steven) Li
2022-01-27  8:45 ` [PATCH v2] " Xueming Li
2022-02-03 13:47   ` Maxime Coquelin
2022-02-10 15:13   ` Maxime Coquelin

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).