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 C6DB0A0560; Tue, 18 Oct 2022 08:24:32 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E68C54282F; Tue, 18 Oct 2022 08:24:00 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mails.dpdk.org (Postfix) with ESMTP id BEC074282F for ; Tue, 18 Oct 2022 08:23:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1666074239; x=1697610239; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=bLUdGyeJtzSX70RKlILn/klniEcd69/6Rxzgv+tpG7A=; b=kF5fyI+9F8y40WgQz3KAJtFv5AkHUV2k7ya6rLp/l667WRDU0y2EeQoU cuugUisSyTvQ5O2DOpcb2USFKeH3NyEvNC+UVgiDm4UQGfa2aX4kk6u/Q 1V4rbErKXIIM/gdAjB6soASlAlqX00p1YpSesQJkav6eFxktxalSW7C/N sc8kUTK//6H9un2dBFmXVblRyh/ozEY8M7VTGKRc8SlJUFVX0EaJkEeUi sTSvxe0m6ULldioHet/UO0wAov1rXENaVcN2NJ8hJvodWtqbBIeKrAFDe FGtejf1DzeBhYaAF1J17g3L+ygbBPvQA6sbAGCQ+ieqsfsj8RhOJP/4Em g==; X-IronPort-AV: E=McAfee;i="6500,9779,10503"; a="285732807" X-IronPort-AV: E=Sophos;i="5.95,193,1661842800"; d="scan'208";a="285732807" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Oct 2022 23:23:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10503"; a="659655915" X-IronPort-AV: E=Sophos;i="5.95,193,1661842800"; d="scan'208";a="659655915" Received: from dpdk-dipei.sh.intel.com ([10.67.110.251]) by orsmga008.jf.intel.com with ESMTP; 17 Oct 2022 23:23:56 -0700 From: Andy Pei To: dev@dpdk.org Cc: chenbo.xia@intel.com, rosen.xu@intel.com, wei.huang@intel.com, gang.cao@intel.com, maxime.coquelin@redhat.com Subject: [PATCH v7 11/12] vhost: vDPA blk device gets ready when the first queue is ready Date: Tue, 18 Oct 2022 14:19:36 +0800 Message-Id: <1666073977-175484-12-git-send-email-andy.pei@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1666073977-175484-1-git-send-email-andy.pei@intel.com> References: <1661229305-240952-2-git-send-email-andy.pei@intel.com> <1666073977-175484-1-git-send-email-andy.pei@intel.com> 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 When boot from virtio blk device, seabios in QEMU only enables one queue. To work in this scenario, vDPA BLK device back-end configure device when the first queue is ready. Signed-off-by: Andy Pei Signed-off-by: Huang Wei --- lib/vhost/vhost_user.c | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c index cd65257..d5dbd9b 100644 --- a/lib/vhost/vhost_user.c +++ b/lib/vhost/vhost_user.c @@ -1441,11 +1441,14 @@ } #define VIRTIO_BUILTIN_NUM_VQS_TO_BE_READY 2u +#define VIRTIO_BLK_NUM_VQS_TO_BE_READY 1u static int virtio_is_ready(struct virtio_net *dev) { + struct rte_vdpa_device *vdpa_dev; struct vhost_virtqueue *vq; + uint32_t vdpa_type; uint32_t i, nr_vring = dev->nr_vring; if (dev->flags & VIRTIO_DEV_READY) @@ -1454,13 +1457,22 @@ if (!dev->nr_vring) return 0; - if (dev->flags & VIRTIO_DEV_BUILTIN_VIRTIO_NET) { - nr_vring = VIRTIO_BUILTIN_NUM_VQS_TO_BE_READY; + vdpa_dev = dev->vdpa_dev; + if (vdpa_dev) + vdpa_type = vdpa_dev->vdpa_device_type; + else + vdpa_type = -1; - if (dev->nr_vring < nr_vring) - return 0; + if (vdpa_type == RTE_VHOST_VDPA_DEVICE_TYPE_BLK) { + nr_vring = VIRTIO_BLK_NUM_VQS_TO_BE_READY; + } else { + if (dev->flags & VIRTIO_DEV_BUILTIN_VIRTIO_NET) + nr_vring = VIRTIO_BUILTIN_NUM_VQS_TO_BE_READY; } + if (dev->nr_vring < nr_vring) + return 0; + for (i = 0; i < nr_vring; i++) { vq = dev->virtqueue[i]; @@ -2958,7 +2970,7 @@ static int is_vring_iotlb(struct virtio_net *dev, int ret; int unlock_required = 0; bool handled; - uint32_t vdpa_type = 0; + uint32_t vdpa_type; uint32_t request; uint32_t i; @@ -3170,16 +3182,7 @@ static int is_vring_iotlb(struct virtio_net *dev, if (!vdpa_dev) goto out; - if (vdpa_dev->ops->get_dev_type) { - ret = vdpa_dev->ops->get_dev_type(vdpa_dev, &vdpa_type); - if (ret) { - VHOST_LOG_CONFIG(dev->ifname, ERR, "failed to get vdpa dev type.\n"); - ret = -1; - goto out; - } - } else { - vdpa_type = RTE_VHOST_VDPA_DEVICE_TYPE_NET; - } + vdpa_type = vdpa_dev->vdpa_device_type; if (vdpa_type == RTE_VHOST_VDPA_DEVICE_TYPE_BLK && request != VHOST_USER_SET_VRING_CALL) goto out; -- 1.8.3.1