From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6BB26427FF; Tue, 21 Mar 2023 20:31:52 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E91F940A7F; Tue, 21 Mar 2023 20:31:51 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id A68C640A7A for ; Tue, 21 Mar 2023 20:31:49 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1004) id D7B5820FB6CE; Tue, 21 Mar 2023 12:31:48 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com D7B5820FB6CE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxonhyperv.com; s=default; t=1679427108; bh=ZF+J0rpXRv7cwj1GxowfeDCSSSo5MJnf8Zn0JNMWhak=; h=From:To:Cc:Subject:Date:From; b=cgRwk73qzcPq3VCAD8EU0GCoDE2EDVAYccCQrF3lM2bjoNAaY4raJm75Wi/D0HwBN w67lWLe+B2r4DjQ2WE77S0ZprxZXGeQYttv396GF/vewqCnqe7Lx8G7h5koiy+PoSN gofZh5tx69vVZn4YkImXGd+X0y1XwKHvREfT5dyQ= From: longli@linuxonhyperv.com To: Ferruh Yigit Cc: dev@dpdk.org, Ajay Sharma , Long Li Subject: [PATCH] bus/vmbus: add cleanup support Date: Tue, 21 Mar 2023 12:31:45 -0700 Message-Id: <1679427105-31644-1-git-send-email-longli@linuxonhyperv.com> X-Mailer: git-send-email 1.8.3.1 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Long Li Implement VMBUS cleanup callback from eal_cleanup(). Signed-off-by: Long Li --- 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