From patchwork Wed Jun 21 02:57:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tiwei Bie X-Patchwork-Id: 25527 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 5FBC758F6; Wed, 21 Jun 2017 05:00:24 +0200 (CEST) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id 97AF25323 for ; Wed, 21 Jun 2017 04:59:41 +0200 (CEST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga105.jf.intel.com with ESMTP; 20 Jun 2017 19:59:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.39,367,1493708400"; d="scan'208";a="101830330" Received: from dpdk25.sh.intel.com ([10.67.111.75]) by orsmga002.jf.intel.com with ESMTP; 20 Jun 2017 19:59:40 -0700 From: Tiwei Bie To: dev@dpdk.org Date: Wed, 21 Jun 2017 10:57:56 +0800 Message-Id: <1498013885-102779-21-git-send-email-tiwei.bie@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1498013885-102779-1-git-send-email-tiwei.bie@intel.com> References: <1498013885-102779-1-git-send-email-tiwei.bie@intel.com> Subject: [dpdk-dev] [RFC 20/29] vhost: fix vring addr setup 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" Signed-off-by: Tiwei Bie --- lib/librte_vhost/vhost.c | 4 ++++ lib/librte_vhost/vhost_user.c | 17 +++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/lib/librte_vhost/vhost.c b/lib/librte_vhost/vhost.c index 19c5a43..b7bc1ee 100644 --- a/lib/librte_vhost/vhost.c +++ b/lib/librte_vhost/vhost.c @@ -441,6 +441,10 @@ rte_vhost_enable_guest_notification(int vid, uint16_t queue_id, int enable) return -1; } + if (dev->features & (1ULL << VIRTIO_F_VERSION_1_1)) { + return 0; + } + dev->virtqueue[queue_id]->used->flags = VRING_USED_F_NO_NOTIFY; return 0; } diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c index 3a2de79..9265dcb 100644 --- a/lib/librte_vhost/vhost_user.c +++ b/lib/librte_vhost/vhost_user.c @@ -342,6 +342,19 @@ vhost_user_set_vring_addr(struct virtio_net *dev, VhostUserMsg *msg) /* addr->index refers to the queue index. The txq 1, rxq is 0. */ vq = dev->virtqueue[msg->payload.addr.index]; + if (dev->features & (1ULL << VIRTIO_F_VERSION_1_1)) { + vq->desc_1_1 = (struct vring_desc_1_1 *)(uintptr_t)qva_to_vva + (dev, msg->payload.addr.desc_user_addr); + vq->desc = NULL; + vq->avail = NULL; + vq->used = NULL; + vq->log_guest_addr = 0; + + assert(vq->last_used_idx == 0); + + return 0; + } + /* The addresses are converted from QEMU virtual to Vhost virtual. */ vq->desc = (struct vring_desc *)(uintptr_t)qva_to_vva(dev, msg->payload.addr.desc_user_addr); @@ -351,7 +364,7 @@ vhost_user_set_vring_addr(struct virtio_net *dev, VhostUserMsg *msg) dev->vid); return -1; } - vq->desc_1_1 = (struct vring_desc_1_1 *)vq->desc; + vq->desc_1_1 = NULL; dev = numa_realloc(dev, msg->payload.addr.index); vq = dev->virtqueue[msg->payload.addr.index]; @@ -617,7 +630,7 @@ vhost_user_set_mem_table(struct virtio_net *dev, struct VhostUserMsg *pmsg) static int vq_is_ready(struct vhost_virtqueue *vq) { - return vq && vq->desc && + return vq && (vq->desc || vq->desc_1_1) && vq->kickfd != VIRTIO_UNINITIALIZED_EVENTFD && vq->callfd != VIRTIO_UNINITIALIZED_EVENTFD; }