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 6E500A0C43; Tue, 19 Oct 2021 13:40:20 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1B766410FA; Tue, 19 Oct 2021 13:40:20 +0200 (CEST) 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 B9779410F4 for ; Tue, 19 Oct 2021 13:40:18 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YYy/TL/EJaduvAhtBhsVdrH4ByNFuOvKKRlj/ghkBy6G6iC5MOlhoutTtNtA1NiX4xlxTlVj1oRr0iQcwQUg5Oy59mAdl5JtKoa+QzIsb2X75xUI7g3ynKUndQnyijtq5FUFCSoSypjG1N9lmLltOeU92I+BZic+9kU/O3mRn8Mi9pKd3M/euUUctKl0BLgbq4p2ByGjzLDS18hvW1GjvPv+BiARTIuKin6C6Foul98LJ9+/yaW70+oKdVw/P4XSoKIERSNnoCrZziwHDaQOpckzf9mDz01x0uGEgVVwG6X5gXJ3dEq/td04NO3dgj4DKuNN0XJzvltS8PZ+xE+8Gg== 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=ugfBWjlrh8RFuCuCRcfS+jZMV4rcCYv/aQYZp9iolUM=; b=aYKRnOVUK3ubvMc1yO1i5qtPW3ti44xHTm1usNvFpHmH+Oc1dKRLtYsUwtTXUC8vo5Qte7DPx0FgBKslPb3BOdt2HWVBW0HKL7qVnxAbnh96u165rsmr47owcc+TQVA8G7ypzXKfRF0PvSUbsomwq3Nmsp9cZCOxm9ixwuanfSKSKqadwCo7X5lAF/huiWQA0dellmzp2njazJny+ai/6QFE/kFadsOBavoyMezhhdrwQ9y2S4RgfxtYaLO8gVXpYfZOvwJ0dml3Z2hJWhamNCbKFvwfdLQgX5igucoUWXpnlhzOE0rQlooCMPFMRvOIowuSgvz0KGFTDgirZ02fxg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=intel.com smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=quarantine 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=ugfBWjlrh8RFuCuCRcfS+jZMV4rcCYv/aQYZp9iolUM=; b=f9grGKLCb//wRQ3U3m+/45P0aD8zMMFzwkYiP3MTScG9TIyYuvSk2tHrL9P+Tb5mEHTf9N3hVhtfOmIhLwz13TCC1T52kfCEHfjfqLnmz9GbQ7hXLPerXp8bpkYQcbkAcSqqmeDFq8L9tneEQPTecPARF9wYiYFJ1P5pzTKMERqzgP2Cl/17sQoYzv/Mev7mBeclMKO2dbq2L5zYv1XnkkBQpQGCpxJUMMd6qOIB0DhfKKeDzLGC8Wd1gE4DMxMLtZossrxXAHNFLqRxscD5nqGsdW7yJGr1OEBESeBHpP/GlRBhF6J1SlEyExpLfNoLhuNWYTb7HzP3X8+I2ePnmA== Received: from MW4P223CA0028.NAMP223.PROD.OUTLOOK.COM (2603:10b6:303:80::33) by DM6PR12MB4137.namprd12.prod.outlook.com (2603:10b6:5:218::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.16; Tue, 19 Oct 2021 11:40:17 +0000 Received: from CO1NAM11FT068.eop-nam11.prod.protection.outlook.com (2603:10b6:303:80:cafe::60) by MW4P223CA0028.outlook.office365.com (2603:10b6:303:80::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.16 via Frontend Transport; Tue, 19 Oct 2021 11:40:17 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by CO1NAM11FT068.mail.protection.outlook.com (10.13.175.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4608.15 via Frontend Transport; Tue, 19 Oct 2021 11:40:16 +0000 Received: from nvidia.com (172.20.187.6) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Tue, 19 Oct 2021 11:40:14 +0000 From: Xueming Li To: CC: , Maxime Coquelin , Chenbo Xia Date: Tue, 19 Oct 2021 19:39:56 +0800 Message-ID: <20211019113956.2254537-1-xuemingl@nvidia.com> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.20.187.6] X-ClientProxiedBy: HQMAIL111.nvidia.com (172.20.187.18) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a9c04294-fe30-466f-97f9-08d992f538cf X-MS-TrafficTypeDiagnostic: DM6PR12MB4137: 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: bQ9D6aFaOBy1GXPBTgkaJ1I0opji2Jekw4Ke+riW9+PGbj+9tKrB30G3t+3NabJJhriw0ebk7LrSoCCsHnMZSsCj5W+db2fFWbJ9z6duRwzW4oikpxynECZSPQIOUP+O6HqHihopjNY/kcVl4WWa+CnbC7ga0xhYzYZaziA6AXcK79SgV4JOGeKudda3/TgNZ9fuRzbi/DHPT/7HIwtURMymfzKhVV5ZPq3XyPlf2XFKPeY9cz7sN7qjvE3v9vzKGsdWMPmr1xVlQu3mHMPNQChl4p4MLsHsGjAqLaHtz9i89b8zfLO3wzju3tI86eRYewFaF4lPOXu/rov1de6zRygat++vBvIS8mquAHOH7Q/meFgtpEd5GatX60/rNnMmAMSSb4JZbP/XE7t1hJ6gPnHapehd8EpD8ViL++xNgKqRKlVsthBAof7pfsEFLIUU2cbG+mwMJaQ4OpnYya2izX7ZrAZiQbmH3lVKvCpZDB6oTqtbEscugekJAHp4Uuyq981CISp5qSkxOTIUZIReksXGCTpBShNgnaj2pHPv/PMFjawBJdO9rUAyygdwhXjeKf1UQN4qTY7HBTVLjbNVMnOSxRLA1L/o+BTol33nkd9/BUYO/jhb91lCxgMDfzK7+N8CvpZbneNz3bKGp2mvl1AR8bWLlCDy3QRzDOIIKgpvZIg8zv7szxsMqmIw2Q1LjcIxY9GqfHGx0kUDHrFE0g== X-Forefront-Antispam-Report: CIP:216.228.112.34; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid03.nvidia.com; CAT:NONE; SFS:(4636009)(36840700001)(46966006)(6286002)(5660300002)(83380400001)(6916009)(86362001)(508600001)(36860700001)(70206006)(36756003)(54906003)(356005)(336012)(2906002)(1076003)(4326008)(47076005)(70586007)(7636003)(16526019)(8676002)(8936002)(55016002)(426003)(7696005)(316002)(6666004)(2616005)(186003)(82310400003)(26005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2021 11:40:16.5798 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a9c04294-fe30-466f-97f9-08d992f538cf X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.112.34]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT068.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4137 Subject: [dpdk-dev] [PATCH] vhost: add vDPA resource cleanup callback 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 Sender: "dev" This patch adds vDPA device cleanup callback to release resources on vhost user connection close. Signed-off-by: Xueming Li --- 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