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 3D636A0C43; Thu, 21 Oct 2021 14:01:09 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F3B1D4118E; Thu, 21 Oct 2021 14:01:08 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id E78094117A for ; Thu, 21 Oct 2021 14:01:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1634817666; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ALRjR50EKFCyruyPrXnYj07cFQr4jp+JpMZEC1yiRXc=; b=gzYcscmONLsRZQdJGsw2z6SEOjzSiQTnOikIaRuYD+btqGaYaAsyq0iNG0CWms3quKUZnb WaSAtQaacYBmBdvnCT77S26D3+HB5M5e2cJdrZxxmEeSgDUj30dpG3/lpsoqK1LI0h6+z9 P2DiUDr4c/T6SG+OcYrPMtVMbiTXIkI= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-542-X9qn7X6eO26zbGPwaTo1HQ-1; Thu, 21 Oct 2021 08:01:03 -0400 X-MC-Unique: X9qn7X6eO26zbGPwaTo1HQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 27C8E879500; Thu, 21 Oct 2021 12:01:02 +0000 (UTC) Received: from [10.39.208.27] (unknown [10.39.208.27]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 52BA369203; Thu, 21 Oct 2021 12:01:01 +0000 (UTC) Message-ID: <2bfda127-f6de-d3fa-0903-566b8ec69be4@redhat.com> Date: Thu, 21 Oct 2021 14:00:59 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.1.0 To: Xueming Li , dev@dpdk.org Cc: Chenbo Xia References: <20211019113956.2254537-1-xuemingl@nvidia.com> From: Maxime Coquelin In-Reply-To: <20211019113956.2254537-1-xuemingl@nvidia.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=maxime.coquelin@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [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" Hi Xueming, On 10/19/21 13:39, Xueming Li wrote: > 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); > What will be done there that cannot be done in .dev_close()? Having the mlx5 implementation of this callback alongside this patch may help to understand. Thanks, Maxime