DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] bus/vmbus: add cleanup support
@ 2023-03-21 19:31 longli
  2023-06-06 14:27 ` Thomas Monjalon
  0 siblings, 1 reply; 2+ messages in thread
From: longli @ 2023-03-21 19:31 UTC (permalink / raw)
  To: Ferruh Yigit; +Cc: dev, Ajay Sharma, Long Li

From: Long Li <longli@microsoft.com>

Implement VMBUS cleanup callback from eal_cleanup().

Signed-off-by: Long Li <longli@microsoft.com>
---
 drivers/bus/vmbus/vmbus_common.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/drivers/bus/vmbus/vmbus_common.c b/drivers/bus/vmbus/vmbus_common.c
index 8d32d66504..a6277bfc06 100644
--- a/drivers/bus/vmbus/vmbus_common.c
+++ b/drivers/bus/vmbus/vmbus_common.c
@@ -188,6 +188,34 @@ rte_vmbus_probe(void)
 	return (probed && probed == failed) ? -1 : 0;
 }
 
+static int
+rte_vmbus_cleanup(void)
+{
+	struct rte_vmbus_device *dev, *tmp_dev;
+	int error = 0;
+
+	RTE_TAILQ_FOREACH_SAFE(dev, &rte_vmbus_bus.device_list, next, tmp_dev) {
+
+		const struct rte_vmbus_driver *drv = dev->driver;
+		int ret;
+
+		if (!drv || !drv->remove)
+			continue;
+
+		ret = drv->remove(dev);
+		if (ret < 0)
+			error = -1;
+
+		rte_vmbus_unmap_device(dev);
+
+		dev->driver = NULL;
+		dev->device.driver = NULL;
+		free(dev);
+	}
+
+	return error;
+}
+
 static int
 vmbus_parse(const char *name, void *addr)
 {
@@ -285,6 +313,7 @@ struct rte_vmbus_bus rte_vmbus_bus = {
 	.bus = {
 		.scan = rte_vmbus_scan,
 		.probe = rte_vmbus_probe,
+		.cleanup = rte_vmbus_cleanup,
 		.find_device = vmbus_find_device,
 		.parse = vmbus_parse,
 	},
-- 
2.32.0


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

end of thread, other threads:[~2023-06-06 14:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-21 19:31 [PATCH] bus/vmbus: add cleanup support longli
2023-06-06 14:27 ` Thomas Monjalon

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