From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id C0E19A052A; Tue, 22 Dec 2020 16:20:38 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 60FA0CA36; Tue, 22 Dec 2020 16:20:37 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by dpdk.org (Postfix) with ESMTP id 44AD7CA2A for ; Tue, 22 Dec 2020 16:20:35 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608650433; 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=yaZn5prxwsp45faehVckoliMtvTFHQNqLY0WjkDTqmc=; b=DD5qhwI01h6Z7RwHS8j24QOQIymxh10eupVht3gNgyKqQMLYYxTdPm9EUSIfvH6kG+G8bu DuS4Lgfd7TOG9Go4wpOQyDuOyRoEREBGy1zGCHAQR9kkHXU+mQYr7ehEqDObRuZOeRiU+1 jL+aszSzK+rVBBYCTO0/ASRGKwQL/uQ= 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-23-HDzuzrmAMUCTjHqPThFfsg-1; Tue, 22 Dec 2020 10:20:30 -0500 X-MC-Unique: HDzuzrmAMUCTjHqPThFfsg-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 ACFDB835DE2; Tue, 22 Dec 2020 15:20:29 +0000 (UTC) Received: from [10.36.110.46] (unknown [10.36.110.46]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 087955D6A8; Tue, 22 Dec 2020 15:20:24 +0000 (UTC) To: dev@dpdk.org, chenbo.xia@intel.com, 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: Tue, 22 Dec 2020 16:20:22 +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: <20201220211405.313012-41-maxime.coquelin@redhat.com> 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.15 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 12/20/20 10:14 PM, Maxime Coquelin wrote: > 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; > @@ -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 ) > { > - return; > + struct vhost_vdpa_data *data = dev->backend_data; > + > + close(data->vhostfd); > + Note to self: free(data); here. > 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 */ > int callfds[VIRTIO_MAX_VIRTQUEUES]; > int kickfds[VIRTIO_MAX_VIRTQUEUES]; >