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 52C91A0A02; Fri, 15 Jan 2021 13:08:25 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BFCC414101C; Fri, 15 Jan 2021 13:08:24 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mails.dpdk.org (Postfix) with ESMTP id ED96214100D for ; Fri, 15 Jan 2021 13:08:22 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1610712502; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ISJqEhCCNahN7lA7MV4QPRAb7/vLHZtJp088SrwG+r8=; b=c5Os4Na9HaU9b7r6uN7SDKEnuatA1kTcHv7EeZPV7lqZ+lZSDSOaKbBohP4sYgbVXygBpW fq0nysKIKYPH48TkYB5xzCMg23v+ZUK3R7/Yxs/B/vFYqrsYDpp0uiM+JdeUERc5HumhxK doEEHBgWKvUCeEc+3EG0XNH4M//McCY= 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-63-L2SJDYqwPPaPcH9ca8VwhA-1; Fri, 15 Jan 2021 07:08:20 -0500 X-MC-Unique: L2SJDYqwPPaPcH9ca8VwhA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 72EDE107ACF9; Fri, 15 Jan 2021 12:08:18 +0000 (UTC) Received: from [10.36.110.24] (unknown [10.36.110.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1D0435D74D; Fri, 15 Jan 2021 12:08:16 +0000 (UTC) To: "Xia, Chenbo" , "dev@dpdk.org" , "olivier.matz@6wind.com" , "amorenoz@redhat.com" , "david.marchand@redhat.com" References: <20201220211405.313012-1-maxime.coquelin@redhat.com> <20201220211405.313012-41-maxime.coquelin@redhat.com> From: Maxime Coquelin Message-ID: Date: Fri, 15 Jan 2021 13:08:15 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH 40/40] net/virtio: move Vhost-vDPA data to its backend 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" On 1/7/21 7:50 AM, Xia, Chenbo wrote: > Hi Maxime, > >> -----Original Message----- >> From: Maxime Coquelin >> Sent: Monday, December 21, 2020 5:14 AM >> To: dev@dpdk.org; Xia, Chenbo ; olivier.matz@6wind.com; >> amorenoz@redhat.com; david.marchand@redhat.com >> Cc: Maxime Coquelin >> Subject: [PATCH 40/40] net/virtio: move Vhost-vDPA data to its backend >> >> As done earlier for Vhost-user and Vhost-kernel, this >> patch moves the Vhost-vDPA specific data to its backend >> file. >> >> Signed-off-by: Maxime Coquelin >> --- >> drivers/net/virtio/virtio_user/vhost_vdpa.c | 77 ++++++++++++++----- >> .../net/virtio/virtio_user/virtio_user_dev.h | 3 - >> 2 files changed, 58 insertions(+), 22 deletions(-) >> > > > >> @@ -269,16 +298,23 @@ vhost_vdpa_set_status(struct virtio_user_dev *dev, >> uint8_t status) >> static int >> vhost_vdpa_setup(struct virtio_user_dev *dev) >> { >> + struct vhost_vdpa_data *data; >> uint32_t did = (uint32_t)-1; >> >> - dev->vhostfd = open(dev->path, O_RDWR); >> - if (dev->vhostfd < 0) { >> + data = malloc(sizeof(*data)); >> + if (!data) { >> + PMD_DRV_LOG(ERR, "(%s) Faidle to allocate backend data", dev- >>> path); >> + return -1; >> + } >> + >> + data->vhostfd = open(dev->path, O_RDWR); >> + if (data->vhostfd < 0) { >> PMD_DRV_LOG(ERR, "Failed to open %s: %s\n", >> dev->path, strerror(errno)); >> return -1; >> } >> >> - if (ioctl(dev->vhostfd, VHOST_VDPA_GET_DEVICE_ID, &did) < 0 || >> + if (ioctl(data->vhostfd, VHOST_VDPA_GET_DEVICE_ID, &did) < 0 || >> did != VIRTIO_ID_NETWORK) { >> PMD_DRV_LOG(ERR, "Invalid vdpa device ID: %u\n", did); >> return -1; > > Need to clean up resources when error happens? Yes, and also assign ddev->backend_data in case of success. > >> @@ -288,9 +324,12 @@ vhost_vdpa_setup(struct virtio_user_dev *dev) >> } >> >> static int >> -vhost_vdpa_destroy(struct virtio_user_dev *dev __rte_unused) >> +vhost_vdpa_destroy(struct virtio_user_dev *dev ) > > Should delete the space before ')'? Done >> { >> - return; >> + struct vhost_vdpa_data *data = dev->backend_data; >> + >> + close(data->vhostfd); >> + >> return 0; >> } >> >> diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.h >> b/drivers/net/virtio/virtio_user/virtio_user_dev.h >> index 5a2c9d38dd..2e0d6504f6 100644 >> --- a/drivers/net/virtio/virtio_user/virtio_user_dev.h >> +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.h >> @@ -28,9 +28,6 @@ struct virtio_user_dev { >> enum virtio_user_backend_type backend_type; >> bool is_server; /* server or client mode */ >> >> - /* for vhost_vdpa backend */ >> - int vhostfd; >> - >> /* for both vhost_user and vhost_kernel */ > > Is this comment no longer needed too? Removed. Thanks! Maxime > Thanks! > Chenbo > >> int callfds[VIRTIO_MAX_VIRTQUEUES]; >> int kickfds[VIRTIO_MAX_VIRTQUEUES]; >> -- >> 2.29.2 >