From patchwork Thu Jul 2 08:32:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Moreno X-Patchwork-Id: 72799 X-Patchwork-Delegate: maxime.coquelin@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 5A3E2A0524; Thu, 2 Jul 2020 10:33:20 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 7B26E1D673; Thu, 2 Jul 2020 10:33:06 +0200 (CEST) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by dpdk.org (Postfix) with ESMTP id B4ECF1D647 for ; Thu, 2 Jul 2020 10:33:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593678784; 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=9q3s3+gs+ho0Z0wJOcJLehcL4lBXzAHAhKCwqD0rZzk=; b=S45fqbZVtjMex6mrE+S5Y/VwRjh/tqrs9ojo+dml+ambSVfO7C3wAQtQHXhbDOnLPVqK0y d26o2tVin4hi04hnsAQefrIITsJ5RgX0SdrRRRwAAsalvtnmm1kr2k7E+N1e3qh7snN8r+ ZGB/a1hFEObOdsTa1gNgWE0ZcCSeozc= 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-491-EISXB5EtO0GmdbRGCtJtFg-1; Thu, 02 Jul 2020 04:33:00 -0400 X-MC-Unique: EISXB5EtO0GmdbRGCtJtFg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 947AA107ACCA; Thu, 2 Jul 2020 08:32:58 +0000 (UTC) Received: from amorenoz.users.ipa.redhat.com (ovpn-112-91.ams2.redhat.com [10.36.112.91]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8B44910098A8; Thu, 2 Jul 2020 08:32:56 +0000 (UTC) From: Adrian Moreno To: dev@dpdk.org, xiaolong.ye@intel.com, shahafs@mellanox.com, matan@mellanox.com, maxime.coquelin@redhat.com, xiao.w.wang@intel.com, viacheslavo@mellanox.com Cc: jasowang@redhat.com, lulu@redhat.com, Adrian Moreno Date: Thu, 2 Jul 2020 10:32:31 +0200 Message-Id: <20200702083237.1215652-3-amorenoz@redhat.com> In-Reply-To: <20200702083237.1215652-1-amorenoz@redhat.com> References: <20200702083237.1215652-1-amorenoz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=amorenoz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [dpdk-dev] [PATCH v2 2/8] vhost: refactor Virtio ready check 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" From: Maxime Coquelin This patch is a small refactoring, as preliminary work for adding support to Virtio status support. No functionnal change here. Signed-off-by: Maxime Coquelin Signed-off-by: Adrian Moreno --- lib/librte_vhost/vhost.c | 1 + lib/librte_vhost/vhost_user.c | 33 +++++++++++++++++++++------------ 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/lib/librte_vhost/vhost.c b/lib/librte_vhost/vhost.c index 0d822d6a3..aa1424261 100644 --- a/lib/librte_vhost/vhost.c +++ b/lib/librte_vhost/vhost.c @@ -710,6 +710,7 @@ vhost_enable_dequeue_zero_copy(int vid) return; dev->dequeue_zero_copy = 1; + VHOST_LOG_CONFIG(INFO, "dequeue zero copy is enabled\n"); } void diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c index 5750dde6d..ff8b1752b 100644 --- a/lib/librte_vhost/vhost_user.c +++ b/lib/librte_vhost/vhost_user.c @@ -1337,6 +1337,9 @@ virtio_is_ready(struct virtio_net *dev) struct vhost_virtqueue *vq; uint32_t i; + if (dev->flags & VIRTIO_DEV_READY) + return 1; + if (dev->nr_vring < VIRTIO_DEV_NUM_VQS_TO_BE_READY) return 0; @@ -1347,6 +1350,8 @@ virtio_is_ready(struct virtio_net *dev) return 0; } + dev->flags |= VIRTIO_DEV_READY; + if (!(dev->flags & VIRTIO_DEV_RUNNING)) VHOST_LOG_CONFIG(INFO, "virtio is now ready for processing.\n"); @@ -2825,28 +2830,32 @@ vhost_user_msg_handler(int vid, int fd) } - if (!(dev->flags & VIRTIO_DEV_READY) && virtio_is_ready(dev)) { - dev->flags |= VIRTIO_DEV_READY; + if (!virtio_is_ready(dev)) + goto out; - if (!(dev->flags & VIRTIO_DEV_RUNNING)) { - if (dev->dequeue_zero_copy) { - VHOST_LOG_CONFIG(INFO, - "dequeue zero copy is enabled\n"); - } + /* + * Virtio is now ready. If not done already, it is time + * to notify the application it can process the rings and + * configure the vDPA device if present. + */ - if (dev->notify_ops->new_device(dev->vid) == 0) - dev->flags |= VIRTIO_DEV_RUNNING; - } + if (!(dev->flags & VIRTIO_DEV_RUNNING)) { + if (dev->notify_ops->new_device(dev->vid) == 0) + dev->flags |= VIRTIO_DEV_RUNNING; } vdpa_dev = dev->vdpa_dev; - if (vdpa_dev && virtio_is_ready(dev) && - !(dev->flags & VIRTIO_DEV_VDPA_CONFIGURED)) { + if (!vdpa_dev) + goto out; + + if (!(dev->flags & VIRTIO_DEV_VDPA_CONFIGURED)) { if (vdpa_dev->ops->dev_conf) vdpa_dev->ops->dev_conf(dev->vid); + dev->flags |= VIRTIO_DEV_VDPA_CONFIGURED; } +out: return 0; }