From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 832038D95 for ; Wed, 12 Aug 2015 10:03:10 +0200 (CEST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga101.jf.intel.com with ESMTP; 12 Aug 2015 01:03:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,659,1432623600"; d="scan'208";a="767051138" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by fmsmga001.fm.intel.com with ESMTP; 12 Aug 2015 01:03:08 -0700 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id t7C836bN027071; Wed, 12 Aug 2015 16:03:06 +0800 Received: from shecgisg004.sh.intel.com (localhost [127.0.0.1]) by shecgisg004.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id t7C833E1003654; Wed, 12 Aug 2015 16:03:05 +0800 Received: (from couyang@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id t7C833SI003650; Wed, 12 Aug 2015 16:03:03 +0800 From: Ouyang Changchun To: dev@dpdk.org Date: Wed, 12 Aug 2015 16:02:39 +0800 Message-Id: <1439366567-3402-5-git-send-email-changchun.ouyang@intel.com> X-Mailer: git-send-email 1.7.12.2 In-Reply-To: <1439366567-3402-1-git-send-email-changchun.ouyang@intel.com> References: <1434355006-30583-1-git-send-email-changchun.ouyang@intel.com> <1439366567-3402-1-git-send-email-changchun.ouyang@intel.com> Subject: [dpdk-dev] [PATCH v4 04/12] vhost: set memory layout for multiple queues mode X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Aug 2015 08:03:12 -0000 QEMU sends separate commands orderly to set the memory layout for each queue in one virtio device, accordingly vhost need keep memory layout information for each queue of the virtio device. This also need adjust the interface a bit for function gpa_to_vva by introducing the queue index to specify queue of device to look up its virtual vhost address for the incoming guest physical address. Signed-off-by: Changchun Ouyang --- Chagnes in v4 - rebase and fix conflicts - call calloc for dev.mem_arr Chagnes in v3 - fix coding style Chagnes in v2 - q_idx is changed into qp_idx - dynamically alloc mem for dev mem_arr - fix checkpatch errors examples/vhost/main.c | 21 +++++----- lib/librte_vhost/rte_virtio_net.h | 10 +++-- lib/librte_vhost/vhost_cuse/virtio-net-cdev.c | 57 ++++++++++++++------------ lib/librte_vhost/vhost_rxtx.c | 22 +++++----- lib/librte_vhost/vhost_user/virtio-net-user.c | 59 ++++++++++++++------------- lib/librte_vhost/virtio-net.c | 38 ++++++++++++----- 6 files changed, 119 insertions(+), 88 deletions(-) diff --git a/examples/vhost/main.c b/examples/vhost/main.c index 1b137b9..d3c45dd 100644 --- a/examples/vhost/main.c +++ b/examples/vhost/main.c @@ -1466,11 +1466,11 @@ attach_rxmbuf_zcp(struct virtio_net *dev) desc = &vq->desc[desc_idx]; if (desc->flags & VRING_DESC_F_NEXT) { desc = &vq->desc[desc->next]; - buff_addr = gpa_to_vva(dev, desc->addr); + buff_addr = gpa_to_vva(dev, 0, desc->addr); phys_addr = gpa_to_hpa(vdev, desc->addr, desc->len, &addr_type); } else { - buff_addr = gpa_to_vva(dev, + buff_addr = gpa_to_vva(dev, 0, desc->addr + vq->vhost_hlen); phys_addr = gpa_to_hpa(vdev, desc->addr + vq->vhost_hlen, @@ -1722,7 +1722,7 @@ virtio_dev_rx_zcp(struct virtio_net *dev, struct rte_mbuf **pkts, rte_pktmbuf_data_len(buff), 0); /* Buffer address translation for virtio header. */ - buff_hdr_addr = gpa_to_vva(dev, desc->addr); + buff_hdr_addr = gpa_to_vva(dev, 0, desc->addr); packet_len = rte_pktmbuf_data_len(buff) + vq->vhost_hlen; /* @@ -1946,7 +1946,7 @@ virtio_dev_tx_zcp(struct virtio_net *dev) desc = &vq->desc[desc->next]; /* Buffer address translation. */ - buff_addr = gpa_to_vva(dev, desc->addr); + buff_addr = gpa_to_vva(dev, 0, desc->addr); /* Need check extra VLAN_HLEN size for inserting VLAN tag */ phys_addr = gpa_to_hpa(vdev, desc->addr, desc->len + VLAN_HLEN, &addr_type); @@ -2604,13 +2604,14 @@ new_device (struct virtio_net *dev) dev->priv = vdev; if (zero_copy) { - vdev->nregions_hpa = dev->mem->nregions; - for (regionidx = 0; regionidx < dev->mem->nregions; regionidx++) { + struct virtio_memory *dev_mem = dev->mem_arr[0]; + vdev->nregions_hpa = dev_mem->nregions; + for (regionidx = 0; regionidx < dev_mem->nregions; regionidx++) { vdev->nregions_hpa += check_hpa_regions( - dev->mem->regions[regionidx].guest_phys_address - + dev->mem->regions[regionidx].address_offset, - dev->mem->regions[regionidx].memory_size); + dev_mem->regions[regionidx].guest_phys_address + + dev_mem->regions[regionidx].address_offset, + dev_mem->regions[regionidx].memory_size); } @@ -2626,7 +2627,7 @@ new_device (struct virtio_net *dev) if (fill_hpa_memory_regions( - vdev->regions_hpa, dev->mem + vdev->regions_hpa, dev_mem ) != vdev->nregions_hpa) { RTE_LOG(ERR, VHOST_CONFIG, diff --git a/lib/librte_vhost/rte_virtio_net.h b/lib/librte_vhost/rte_virtio_net.h index d9e887f..8520d96 100644 --- a/lib/librte_vhost/rte_virtio_net.h +++ b/lib/librte_vhost/rte_virtio_net.h @@ -95,14 +95,15 @@ struct vhost_virtqueue { * Device structure contains all configuration information relating to the device. */ struct virtio_net { - struct virtio_memory *mem; /**< QEMU memory and memory region information. */ struct vhost_virtqueue **virtqueue; /**< Contains all virtqueue information. */ + struct virtio_memory **mem_arr; /**< Array for QEMU memory and memory region information. */ uint64_t features; /**< Negotiated feature set. */ uint64_t device_fh; /**< device identifier. */ uint32_t flags; /**< Device flags. Only used to check if device is running on data core. */ #define IF_NAME_SZ (PATH_MAX > IFNAMSIZ ? PATH_MAX : IFNAMSIZ) char ifname[IF_NAME_SZ]; /**< Name of the tap device or socket path. */ uint32_t virt_qp_nb; + uint32_t mem_idx; /** Used in set memory layout, unique for each queue within virtio device. */ void *priv; /**< private context */ } __rte_cache_aligned; @@ -153,14 +154,15 @@ rte_vring_available_entries(struct virtio_net *dev, uint16_t queue_id) * This is used to convert guest virtio buffer addresses. */ static inline uint64_t __attribute__((always_inline)) -gpa_to_vva(struct virtio_net *dev, uint64_t guest_pa) +gpa_to_vva(struct virtio_net *dev, uint32_t q_idx, uint64_t guest_pa) { struct virtio_memory_regions *region; + struct virtio_memory *dev_mem = dev->mem_arr[q_idx]; uint32_t regionidx; uint64_t vhost_va = 0; - for (regionidx = 0; regionidx < dev->mem->nregions; regionidx++) { - region = &dev->mem->regions[regionidx]; + for (regionidx = 0; regionidx < dev_mem->nregions; regionidx++) { + region = &dev_mem->regions[regionidx]; if ((guest_pa >= region->guest_phys_address) && (guest_pa <= region->guest_phys_address_end)) { vhost_va = region->address_offset + guest_pa; diff --git a/lib/librte_vhost/vhost_cuse/virtio-net-cdev.c b/lib/librte_vhost/vhost_cuse/virtio-net-cdev.c index ae2c3fa..34648f6 100644 --- a/lib/librte_vhost/vhost_cuse/virtio-net-cdev.c +++ b/lib/librte_vhost/vhost_cuse/virtio-net-cdev.c @@ -273,28 +273,32 @@ cuse_set_mem_table(struct vhost_device_ctx ctx, ((uint64_t)(uintptr_t)mem_regions_addr + size); uint64_t base_address = 0, mapped_address, mapped_size; struct virtio_net *dev; + struct virtio_memory *dev_mem = NULL; dev = get_device(ctx); if (dev == NULL) - return -1; - - if (dev->mem && dev->mem->mapped_address) { - munmap((void *)(uintptr_t)dev->mem->mapped_address, - (size_t)dev->mem->mapped_size); - free(dev->mem); - dev->mem = NULL; + goto error; + + dev_mem = dev->mem_arr[dev->mem_idx]; + if (dev_mem && dev_mem->mapped_address) { + munmap((void *)(uintptr_t)dev_mem->mapped_address, + (size_t)dev_mem->mapped_size); + free(dev_mem); + dev->mem_arr[dev->mem_idx] = NULL; } - dev->mem = calloc(1, sizeof(struct virtio_memory) + + dev->mem_arr[dev->mem_idx] = calloc(1, sizeof(struct virtio_memory) + sizeof(struct virtio_memory_regions) * nregions); - if (dev->mem == NULL) { + dev_mem = dev->mem_arr[dev->mem_idx]; + + if (dev_mem == NULL) { RTE_LOG(ERR, VHOST_CONFIG, - "(%"PRIu64") Failed to allocate memory for dev->mem\n", - dev->device_fh); - return -1; + "(%"PRIu64") Failed to allocate memory for dev->mem_arr[%d]\n", + dev->device_fh, dev->mem_idx); + goto error; } - pregion = &dev->mem->regions[0]; + pregion = &dev_mem->regions[0]; for (idx = 0; idx < nregions; idx++) { pregion[idx].guest_phys_address = @@ -320,14 +324,12 @@ cuse_set_mem_table(struct vhost_device_ctx ctx, pregion[idx].userspace_address; /* Map VM memory file */ if (host_memory_map(ctx.pid, base_address, - &mapped_address, &mapped_size) != 0) { - free(dev->mem); - dev->mem = NULL; - return -1; - } - dev->mem->mapped_address = mapped_address; - dev->mem->base_address = base_address; - dev->mem->mapped_size = mapped_size; + &mapped_address, &mapped_size) != 0) + goto free; + + dev_mem->mapped_address = mapped_address; + dev_mem->base_address = base_address; + dev_mem->mapped_size = mapped_size; } } @@ -335,9 +337,7 @@ cuse_set_mem_table(struct vhost_device_ctx ctx, if (base_address == 0) { RTE_LOG(ERR, VHOST_CONFIG, "Failed to find base address of qemu memory file.\n"); - free(dev->mem); - dev->mem = NULL; - return -1; + goto free; } valid_regions = nregions; @@ -369,9 +369,16 @@ cuse_set_mem_table(struct vhost_device_ctx ctx, pregion[idx].userspace_address - pregion[idx].guest_phys_address; } - dev->mem->nregions = valid_regions; + dev_mem->nregions = valid_regions; + dev->mem_idx = (dev->mem_idx + 1) % (dev->virt_qp_nb * VIRTIO_QNUM); return 0; + +free: + free(dev_mem); + dev->mem_arr[dev->mem_idx] = NULL; +error: + return -1; } /* diff --git a/lib/librte_vhost/vhost_rxtx.c b/lib/librte_vhost/vhost_rxtx.c index db4ad88..a60b542 100644 --- a/lib/librte_vhost/vhost_rxtx.c +++ b/lib/librte_vhost/vhost_rxtx.c @@ -139,7 +139,7 @@ virtio_dev_rx(struct virtio_net *dev, uint16_t queue_id, buff = pkts[packet_success]; /* Convert from gpa to vva (guest physical addr -> vhost virtual addr) */ - buff_addr = gpa_to_vva(dev, desc->addr); + buff_addr = gpa_to_vva(dev, queue_id / VIRTIO_QNUM, desc->addr); /* Prefetch buffer address. */ rte_prefetch0((void *)(uintptr_t)buff_addr); @@ -154,7 +154,7 @@ virtio_dev_rx(struct virtio_net *dev, uint16_t queue_id, (desc->len == vq->vhost_hlen)) { desc = &vq->desc[desc->next]; /* Buffer address translation. */ - buff_addr = gpa_to_vva(dev, desc->addr); + buff_addr = gpa_to_vva(dev, queue_id / VIRTIO_QNUM, desc->addr); } else { vb_offset += vq->vhost_hlen; hdr = 1; @@ -191,7 +191,7 @@ virtio_dev_rx(struct virtio_net *dev, uint16_t queue_id, if (vb_offset == desc->len) { if (desc->flags & VRING_DESC_F_NEXT) { desc = &vq->desc[desc->next]; - buff_addr = gpa_to_vva(dev, desc->addr); + buff_addr = gpa_to_vva(dev, queue_id, desc->addr); vb_offset = 0; } else { /* Room in vring buffer is not enough */ @@ -281,8 +281,8 @@ copy_from_mbuf_to_vring(struct virtio_net *dev, uint16_t queue_id, * (guest physical addr -> vhost virtual addr) */ vq = dev->virtqueue[queue_id]; - vb_addr = - gpa_to_vva(dev, vq->buf_vec[vec_idx].buf_addr); + vb_addr = gpa_to_vva(dev, queue_id / VIRTIO_QNUM, + vq->buf_vec[vec_idx].buf_addr); vb_hdr_addr = vb_addr; /* Prefetch buffer address. */ @@ -322,7 +322,8 @@ copy_from_mbuf_to_vring(struct virtio_net *dev, uint16_t queue_id, } vec_idx++; - vb_addr = gpa_to_vva(dev, vq->buf_vec[vec_idx].buf_addr); + vb_addr = gpa_to_vva(dev, queue_id / VIRTIO_QNUM, + vq->buf_vec[vec_idx].buf_addr); /* Prefetch buffer address. */ rte_prefetch0((void *)(uintptr_t)vb_addr); @@ -367,7 +368,7 @@ copy_from_mbuf_to_vring(struct virtio_net *dev, uint16_t queue_id, } vec_idx++; - vb_addr = gpa_to_vva(dev, + vb_addr = gpa_to_vva(dev, queue_id / VIRTIO_QNUM, vq->buf_vec[vec_idx].buf_addr); vb_offset = 0; vb_avail = vq->buf_vec[vec_idx].buf_len; @@ -410,7 +411,7 @@ copy_from_mbuf_to_vring(struct virtio_net *dev, uint16_t queue_id, /* Get next buffer from buf_vec. */ vec_idx++; - vb_addr = gpa_to_vva(dev, + vb_addr = gpa_to_vva(dev, queue_id / VIRTIO_QNUM, vq->buf_vec[vec_idx].buf_addr); vb_avail = vq->buf_vec[vec_idx].buf_len; @@ -639,7 +640,7 @@ rte_vhost_dequeue_burst(struct virtio_net *dev, uint16_t queue_id, } /* Buffer address translation. */ - vb_addr = gpa_to_vva(dev, desc->addr); + vb_addr = gpa_to_vva(dev, queue_id / VIRTIO_QNUM, desc->addr); /* Prefetch buffer address. */ rte_prefetch0((void *)(uintptr_t)vb_addr); @@ -743,7 +744,8 @@ rte_vhost_dequeue_burst(struct virtio_net *dev, uint16_t queue_id, desc = &vq->desc[desc->next]; /* Buffer address translation. */ - vb_addr = gpa_to_vva(dev, desc->addr); + vb_addr = gpa_to_vva(dev, + queue_id / VIRTIO_QNUM, desc->addr); /* Prefetch buffer address. */ rte_prefetch0((void *)(uintptr_t)vb_addr); vb_offset = 0; diff --git a/lib/librte_vhost/vhost_user/virtio-net-user.c b/lib/librte_vhost/vhost_user/virtio-net-user.c index 4c1d4df..d749f27 100644 --- a/lib/librte_vhost/vhost_user/virtio-net-user.c +++ b/lib/librte_vhost/vhost_user/virtio-net-user.c @@ -70,17 +70,17 @@ get_blk_size(int fd) } static void -free_mem_region(struct virtio_net *dev) +free_mem_region(struct virtio_memory *dev_mem) { struct orig_region_map *region; unsigned int idx; uint64_t alignment; - if (!dev || !dev->mem) + if (!dev_mem) return; - region = orig_region(dev->mem, dev->mem->nregions); - for (idx = 0; idx < dev->mem->nregions; idx++) { + region = orig_region(dev_mem, dev_mem->nregions); + for (idx = 0; idx < dev_mem->nregions; idx++) { if (region[idx].mapped_address) { alignment = region[idx].blksz; munmap((void *)(uintptr_t) @@ -103,37 +103,37 @@ user_set_mem_table(struct vhost_device_ctx ctx, struct VhostUserMsg *pmsg) unsigned int idx = 0; struct orig_region_map *pregion_orig; uint64_t alignment; + struct virtio_memory *dev_mem = NULL; /* unmap old memory regions one by one*/ dev = get_device(ctx); if (dev == NULL) return -1; - /* Remove from the data plane. */ - if (dev->flags & VIRTIO_DEV_RUNNING) - notify_ops->destroy_device(dev); - - if (dev->mem) { - free_mem_region(dev); - free(dev->mem); - dev->mem = NULL; + dev_mem = dev->mem_arr[dev->mem_idx]; + if (dev_mem) { + free_mem_region(dev_mem); + free(dev_mem); + dev->mem_arr[dev->mem_idx] = NULL; } - dev->mem = calloc(1, + dev->mem_arr[dev->mem_idx] = calloc(1, sizeof(struct virtio_memory) + sizeof(struct virtio_memory_regions) * memory.nregions + sizeof(struct orig_region_map) * memory.nregions); - if (dev->mem == NULL) { + + dev_mem = dev->mem_arr[dev->mem_idx]; + if (dev_mem == NULL) { RTE_LOG(ERR, VHOST_CONFIG, - "(%"PRIu64") Failed to allocate memory for dev->mem\n", - dev->device_fh); + "(%"PRIu64") Failed to allocate memory for dev->mem_arr[%d]\n", + dev->device_fh, dev->mem_idx); return -1; } - dev->mem->nregions = memory.nregions; + dev_mem->nregions = memory.nregions; - pregion_orig = orig_region(dev->mem, memory.nregions); + pregion_orig = orig_region(dev_mem, memory.nregions); for (idx = 0; idx < memory.nregions; idx++) { - pregion = &dev->mem->regions[idx]; + pregion = &dev_mem->regions[idx]; pregion->guest_phys_address = memory.regions[idx].guest_phys_addr; pregion->guest_phys_address_end = @@ -175,9 +175,9 @@ user_set_mem_table(struct vhost_device_ctx ctx, struct VhostUserMsg *pmsg) pregion->guest_phys_address; if (memory.regions[idx].guest_phys_addr == 0) { - dev->mem->base_address = + dev_mem->base_address = memory.regions[idx].userspace_addr; - dev->mem->mapped_address = + dev_mem->mapped_address = pregion->address_offset; } @@ -189,6 +189,7 @@ user_set_mem_table(struct vhost_device_ctx ctx, struct VhostUserMsg *pmsg) pregion->memory_size); } + dev->mem_idx = (dev->mem_idx + 1) % (dev->virt_qp_nb * VIRTIO_QNUM); return 0; err_mmap: @@ -200,8 +201,8 @@ err_mmap: alignment)); close(pregion_orig[idx].fd); } - free(dev->mem); - dev->mem = NULL; + free(dev_mem); + dev->mem_arr[dev->mem_idx] = NULL; return -1; } @@ -346,13 +347,15 @@ void user_destroy_device(struct vhost_device_ctx ctx) { struct virtio_net *dev = get_device(ctx); + uint32_t i; if (dev && (dev->flags & VIRTIO_DEV_RUNNING)) notify_ops->destroy_device(dev); - if (dev && dev->mem) { - free_mem_region(dev); - free(dev->mem); - dev->mem = NULL; - } + for (i = 0; i < dev->virt_qp_nb; i++) + if (dev && dev->mem_arr[i]) { + free_mem_region(dev->mem_arr[i]); + free(dev->mem_arr[i]); + dev->mem_arr[i] = NULL; + } } diff --git a/lib/librte_vhost/virtio-net.c b/lib/librte_vhost/virtio-net.c index 2a4b791..fd66a06 100644 --- a/lib/librte_vhost/virtio-net.c +++ b/lib/librte_vhost/virtio-net.c @@ -81,15 +81,16 @@ static uint64_t VHOST_FEATURES = VHOST_SUPPORTED_FEATURES; * used to convert the ring addresses to our address space. */ static uint64_t -qva_to_vva(struct virtio_net *dev, uint64_t qemu_va) +qva_to_vva(struct virtio_net *dev, uint32_t q_idx, uint64_t qemu_va) { struct virtio_memory_regions *region; uint64_t vhost_va = 0; uint32_t regionidx = 0; + struct virtio_memory *dev_mem = dev->mem_arr[q_idx]; /* Find the region where the address lives. */ - for (regionidx = 0; regionidx < dev->mem->nregions; regionidx++) { - region = &dev->mem->regions[regionidx]; + for (regionidx = 0; regionidx < dev_mem->nregions; regionidx++) { + region = &dev_mem->regions[regionidx]; if ((qemu_va >= region->userspace_address) && (qemu_va <= region->userspace_address + region->memory_size)) { @@ -186,10 +187,13 @@ cleanup_device(struct virtio_net *dev) uint32_t qp_idx; /* Unmap QEMU memory file if mapped. */ - if (dev->mem) { - munmap((void *)(uintptr_t)dev->mem->mapped_address, - (size_t)dev->mem->mapped_size); - free(dev->mem); + for (qp_idx = 0; qp_idx < dev->virt_qp_nb; qp_idx++) { + struct virtio_memory *dev_mem = dev->mem_arr[qp_idx]; + if (dev_mem) { + munmap((void *)(uintptr_t)dev_mem->mapped_address, + (size_t)dev_mem->mapped_size); + free(dev_mem); + } } /* Close any event notifiers opened by device. */ @@ -218,6 +222,8 @@ free_device(struct virtio_net_config_ll *ll_dev) /* * Free any malloc'd memory. */ + free(ll_dev->dev.mem_arr); + /* Free every queue pair. */ for (qp_idx = 0; qp_idx < ll_dev->dev.virt_qp_nb; qp_idx++) { uint32_t virt_rx_q_idx = qp_idx * VIRTIO_QNUM + VIRTIO_RXQ; @@ -289,7 +295,7 @@ init_device(struct virtio_net *dev) * Virtqueues have already been malloced so * we don't want to set them to NULL. */ - vq_offset = offsetof(struct virtio_net, mem); + vq_offset = offsetof(struct virtio_net, features); /* Set everything to 0. */ memset((void *)(uintptr_t)((uint64_t)(uintptr_t)dev + vq_offset), 0, @@ -359,6 +365,16 @@ new_device(struct vhost_device_ctx ctx) return -1; } + new_ll_dev->dev.mem_arr = + calloc(VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MAX, sizeof(struct virtio_memory *)); + if (new_ll_dev->dev.mem_arr == NULL) { + RTE_LOG(ERR, VHOST_CONFIG, + "(%"PRIu64") Failed to allocate memory for dev.mem_arr.\n", + ctx.fh); + free_device(new_ll_dev); + return -1; + } + /* Initialise device and virtqueues. */ init_device(&new_ll_dev->dev); @@ -637,7 +653,7 @@ set_vring_addr(struct vhost_device_ctx ctx, struct vhost_vring_addr *addr) /* The addresses are converted from QEMU virtual to Vhost virtual. */ vq->desc = (struct vring_desc *)(uintptr_t)qva_to_vva(dev, - addr->desc_user_addr); + addr->index / VIRTIO_QNUM, addr->desc_user_addr); if (vq->desc == 0) { RTE_LOG(ERR, VHOST_CONFIG, "(%"PRIu64") Failed to find desc ring address.\n", @@ -649,7 +665,7 @@ set_vring_addr(struct vhost_device_ctx ctx, struct vhost_vring_addr *addr) vq = dev->virtqueue[addr->index]; vq->avail = (struct vring_avail *)(uintptr_t)qva_to_vva(dev, - addr->avail_user_addr); + addr->index / VIRTIO_QNUM, addr->avail_user_addr); if (vq->avail == 0) { RTE_LOG(ERR, VHOST_CONFIG, "(%"PRIu64") Failed to find avail ring address.\n", @@ -658,7 +674,7 @@ set_vring_addr(struct vhost_device_ctx ctx, struct vhost_vring_addr *addr) } vq->used = (struct vring_used *)(uintptr_t)qva_to_vva(dev, - addr->used_user_addr); + addr->index / VIRTIO_QNUM, addr->used_user_addr); if (vq->used == 0) { RTE_LOG(ERR, VHOST_CONFIG, "(%"PRIu64") Failed to find used ring address.\n", -- 1.8.4.2