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 E2F16A0350; Thu, 27 Jan 2022 09:46:02 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 768724276D; Thu, 27 Jan 2022 09:46:02 +0100 (CET) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2049.outbound.protection.outlook.com [40.107.237.49]) by mails.dpdk.org (Postfix) with ESMTP id E239E4067C for ; Thu, 27 Jan 2022 09:46:00 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MITTiKmmDdwCB3xqMkLeeyMjzUutowrqtnmSpf9gH610qmShBXkb+gtG0GAeh/QpVBADQV0tfcrhr7gxFDnYsTNPmn012IVOIt5wWqbSitiPF2OUDgXSSYyPad59mKHI+7oFoJoKcoDwApFYMbJyXHF7rCuIiz5QWeYrlYpHiATTuV52zUk5iPXHNO2q0/JscVvGb3nSn5YYjSY6jqla0R1TMmmsHO/w2cE7nHhtImhDsY3JxVn3jHFcRVAfbfmlKYyd02irurSoUtpqY1lRWCkNF58gRUGcr3365vN6hMtgxDtgnzpOhL++R84GifqvdkyqPoteq3hhGNuSqEPTDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=2QNnfC1LTwasKkfr4FpUbFrHEUApMFoVFu1KRQUeC7w=; b=cDs1N0hjgzNSzNII9hqLl/LUn3uywrXroQkc0VNuyA9tKyrTIziUsPCdPV+1TEIa420K3B59T7R/8EhSPBEJ3mPLlp1sC8CUi5n9Wy96vxdeIV8+2L2MYHtmXNaJjJSUzbnJzNOYR4wm9si1lY36ugQHMC74YXqbctJPea2wG1wCzTPZ4kNIqvNmQ0+JW//5wOpscOUMUivL4bXwmtp5HKGtZJDJ8cPXt7AofkwIuClTY0qYUMNoW9eS8IQUaRLsAYucOQhUvJLJDEwHxVafrdXTEbGKmtGi5SEyHfVJWMdvbAOXi4HyGeL9JsnDZY7VM9Gi/4/tiZs/93tv42u73A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.234) smtp.rcpttodomain=redhat.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2QNnfC1LTwasKkfr4FpUbFrHEUApMFoVFu1KRQUeC7w=; b=RpGsEGG1aHaepytj26zMvvj+X6IZR23BCZRm4ulETGJGqcRRraBxaiQ6igXC1I/f81Z4HFUxUsOw9LsE78OUj1TRa5VLVRPjCdAB+s60SO8/yTffilKoWw9XbCvo4Lq+fecbtDm7jfPB6SZRTVBbqak3flegvUhQoczWKQJbLuc/hGZcuWEbFe+Sefp8iPevIBXpGYOs4nQAr/j23ktt1dqq0sUAOZGWrvu5vxCUHQJKNxn8pmlaF4NB1IfrvXtsPgEO7EY3qPTR7VDHio11EZyoLEM0/E0fw+uK0u6yC2KZkB/JXN7YXfJY2F8Cqf3fOEelBAG72jfWwDzfPyfrlw== Received: from BN8PR04CA0051.namprd04.prod.outlook.com (2603:10b6:408:d4::25) by BN6PR12MB1124.namprd12.prod.outlook.com (2603:10b6:404:19::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15; Thu, 27 Jan 2022 08:45:59 +0000 Received: from BN8NAM11FT013.eop-nam11.prod.protection.outlook.com (2603:10b6:408:d4:cafe::41) by BN8PR04CA0051.outlook.office365.com (2603:10b6:408:d4::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15 via Frontend Transport; Thu, 27 Jan 2022 08:45:59 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.234) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 12.22.5.234 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.234; helo=mail.nvidia.com; Received: from mail.nvidia.com (12.22.5.234) by BN8NAM11FT013.mail.protection.outlook.com (10.13.176.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4930.15 via Frontend Transport; Thu, 27 Jan 2022 08:45:59 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by DRHQMAIL101.nvidia.com (10.27.9.10) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Thu, 27 Jan 2022 08:45:58 +0000 Received: from nvidia.com (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.9; Thu, 27 Jan 2022 00:45:56 -0800 From: Xueming Li To: CC: , Matan Azrad , Xia Chenbo , Maxime Coquelin Subject: [PATCH v2] vhost: add vDPA resource cleanup callback Date: Thu, 27 Jan 2022 16:45:35 +0800 Message-ID: <20220127084535.673527-1-xuemingl@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20211019113956.2254537-1-xuemingl@nvidia.com> References: <20211019113956.2254537-1-xuemingl@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: drhqmail202.nvidia.com (10.126.190.181) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d65ed882-f474-4425-5f49-08d9e1717107 X-MS-TrafficTypeDiagnostic: BN6PR12MB1124:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1360; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OXeeVT/YA927DsXvV+jhOHCdx55fVuZluTbNqOx3R7OHvDDY1c6U0T0VN3PGkQcXUf1rZxHXUhhIC4FccfbmC3DWLfFYV7WVYLPyTenkJVLtf85WMBFsN/IUjdcDuRuY7rZg7dO8ZiQAOTeVIfXqTLt3mYDH/FqzMt8ufJx0eBnjCX4OxqSd2xZLuvdVOkcYEfzOw3penvA3jSqDM7cCaKTlVIsAuW+HYE9dIqCae+Xtmw37GySVMLanIBUMqvHnzv9bRDewpZ6Riw8m7E5ezJ9z2cUUrONj04XQCukq1uMHUIW1fdOpKr4YooRLlQxFCHNAcPiCRGDefuy7I0tmVpGgKiWoYAcnhTT5kFOFEa5czNknzZxmmWUtzAjIn8qJO5vgoqw60ANolHi9ZbHpQSNle4SexqGgved6da/sF3hsyq2sxnUxUNlu90ocyl+tnmDSNW4uK3s2mlw6lneEXGbXNRtMAuJj+9/cT813F/Kad2PMj+vTG5ze+PuPeQZqet8qoqNy46Z6aCOT+AmSSdehoHMvw2PPKtnv7I8rLJnNkA+nWnDN0bSakXR/FA3B57ENA2IHOvL5U9zD3ANcBmvlJtC0subrn5iVSk81ApQDpLsxcOx8PjK46r1XJ2XIefh3Hv6CnC0gcfXapYu9eWE51J5pVEzrwLFF4FCKpSR7FKVa71wZ5xpgpLVqEvIIGeASPwFU2jIXFwgYYyLyWQ== X-Forefront-Antispam-Report: CIP:12.22.5.234; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:mail.nvidia.com; PTR:InfoNoRecords; CAT:NONE; SFS:(13230001)(4636009)(36840700001)(46966006)(40470700004)(6916009)(54906003)(316002)(5660300002)(86362001)(82310400004)(8676002)(8936002)(4326008)(70586007)(70206006)(36860700001)(16526019)(47076005)(6286002)(1076003)(426003)(26005)(186003)(83380400001)(40460700003)(81166007)(2616005)(336012)(55016003)(356005)(7696005)(6666004)(36756003)(508600001)(2906002)(36900700001)(20210929001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jan 2022 08:45:59.1780 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d65ed882-f474-4425-5f49-08d9e1717107 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[12.22.5.234]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT013.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1124 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 This patch adds vDPA device cleanup callback to release resources on vhost user connection close. Signed-off-by: Xueming Li --- 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); -- 2.34.1