rte_virtio: remove rte_memzone from vq

Use standard spdk_dma_malloc instead.
This removes another direct DPDK
dependency. Yet, for multi-process
support we will more likely use a
memzone for the entire virtio device,
not it's virtqueues.

Change-Id: I57119ad830b573b718605b46cc3099b105651ee9
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/385629
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
This commit is contained in:
Dariusz Stojaczyk 2017-11-03 17:37:51 +01:00 committed by Jim Harris
parent 17a1f07e57
commit 73bfcede86
4 changed files with 14 additions and 32 deletions

View File

@ -154,8 +154,9 @@ static int
virtio_init_queue(struct virtio_dev *dev, uint16_t vtpci_queue_idx)
{
char vq_name[VIRTQUEUE_MAX_NAME_SZ];
const struct rte_memzone *mz = NULL;
void *queue_mem;
unsigned int vq_size, size;
uint64_t queue_mem_phys_addr;
struct virtqueue *vq;
int ret;
@ -205,31 +206,21 @@ virtio_init_queue(struct virtio_dev *dev, uint16_t vtpci_queue_idx)
SPDK_DEBUGLOG(SPDK_TRACE_VIRTIO_DEV, "vring_size: %u, rounded_vring_size: %u\n",
size, vq->vq_ring_size);
mz = rte_memzone_reserve_aligned(vq_name, vq->vq_ring_size,
SOCKET_ID_ANY,
0, VIRTIO_PCI_VRING_ALIGN);
if (mz == NULL) {
if (rte_errno == EEXIST)
mz = rte_memzone_lookup(vq_name);
if (mz == NULL) {
ret = -ENOMEM;
goto fail_q_alloc;
}
queue_mem = spdk_dma_zmalloc(vq->vq_ring_size, VIRTIO_PCI_VRING_ALIGN, &queue_mem_phys_addr);
if (queue_mem == NULL) {
ret = -ENOMEM;
goto fail_q_alloc;
}
memset(mz->addr, 0, sizeof(mz->len));
vq->vq_ring_mem = mz->phys_addr;
vq->vq_ring_virt_mem = mz->addr;
vq->vq_ring_mem = queue_mem_phys_addr;
vq->vq_ring_virt_mem = queue_mem;
SPDK_DEBUGLOG(SPDK_TRACE_VIRTIO_DEV, "vq->vq_ring_mem: 0x%" PRIx64 "\n",
(uint64_t)mz->phys_addr);
vq->vq_ring_mem);
SPDK_DEBUGLOG(SPDK_TRACE_VIRTIO_DEV, "vq->vq_ring_virt_mem: 0x%" PRIx64 "\n",
(uint64_t)(uintptr_t)mz->addr);
(uint64_t)(uintptr_t)vq->vq_ring_virt_mem);
virtio_init_vring(vq);
vq->mz = mz;
vq->owner_thread = NULL;
vq->poller = NULL;
@ -241,7 +232,6 @@ virtio_init_queue(struct virtio_dev *dev, uint16_t vtpci_queue_idx)
return 0;
fail_q_alloc:
rte_memzone_free(mz);
rte_free(vq);
return ret;
@ -262,7 +252,7 @@ virtio_free_queues(struct virtio_dev *dev)
if (!vq)
continue;
rte_memzone_free(vq->mz);
spdk_dma_free(vq->vq_ring_virt_mem);
rte_free(vq);
dev->vqs[i] = NULL;

View File

@ -40,9 +40,6 @@
#include <linux/virtio_pci.h>
#include <linux/virtio_config.h>
#include <rte_config.h>
#include <rte_mempool.h>
#include "spdk_internal/log.h"
#include "spdk/likely.h"
#include "spdk/queue.h"
@ -152,9 +149,7 @@ struct virtqueue {
void *vq_ring_virt_mem; /**< virtual address of vring */
unsigned int vq_ring_size;
const struct rte_memzone *mz; /**< mem zone to populate TX ring. */
phys_addr_t vq_ring_mem; /**< physical address of vring */
uint64_t vq_ring_mem; /**< physical address of vring */
/**
* Head of the free chain in the descriptor table. If

View File

@ -241,9 +241,8 @@ modern_setup_queue(struct virtio_dev *dev, struct virtqueue *vq)
desc_addr = vq->vq_ring_mem;
avail_addr = desc_addr + vq->vq_nentries * sizeof(struct vring_desc);
used_addr = RTE_ALIGN_CEIL(avail_addr + offsetof(struct vring_avail,
ring[vq->vq_nentries]),
VIRTIO_PCI_VRING_ALIGN);
used_addr = (avail_addr + offsetof(struct vring_avail, ring[vq->vq_nentries])
+ VIRTIO_PCI_VRING_ALIGN - 1) & ~(VIRTIO_PCI_VRING_ALIGN - 1);
spdk_mmio_write_2(&hw->common_cfg->queue_select, vq->vq_queue_index);

View File

@ -293,8 +293,6 @@ vhost_user_sock(struct virtio_user_dev *dev,
int i, len;
int vhostfd = dev->vhostfd;
RTE_SET_USED(m);
SPDK_DEBUGLOG(SPDK_TRACE_VIRTIO_USER, "sent message %d = %s\n", req, vhost_msg_strings[req]);
msg.request = req;