|
|
a6040a |
From 297fcc013877e57c387e444bf7323fbfd77e4b3f Mon Sep 17 00:00:00 2001
|
|
|
a6040a |
From: Maxime Coquelin <maxime.coquelin@redhat.com>
|
|
|
a6040a |
Date: Wed, 13 Dec 2017 09:51:08 +0100
|
|
|
a6040a |
Subject: [PATCH 3/6] vhost: extract virtqueue cleaning and freeing functions
|
|
|
a6040a |
|
|
|
a6040a |
This patch extracts needed code for vhost_user.c to be able
|
|
|
a6040a |
to clean and free virtqueues unitary.
|
|
|
a6040a |
|
|
|
a6040a |
Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
|
|
|
a6040a |
Acked-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
a6040a |
Acked-by: Yuanhan Liu <yliu@fridaylinux.org>
|
|
|
a6040a |
(cherry picked from commit 467fe22df94b85d2df67b9be3ccbfb3dd72cdd6d)
|
|
|
a6040a |
Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
|
|
|
a6040a |
---
|
|
|
a6040a |
dpdk-17.11/lib/librte_vhost/vhost.c | 22 ++++++++++++----------
|
|
|
a6040a |
dpdk-17.11/lib/librte_vhost/vhost.h | 3 +++
|
|
|
a6040a |
2 files changed, 15 insertions(+), 10 deletions(-)
|
|
|
a6040a |
|
|
|
a6040a |
diff --git a/lib/librte_vhost/vhost.c b/lib/librte_vhost/vhost.c
|
|
|
a6040a |
index 4f8b73a09..df528a4ea 100644
|
|
|
a6040a |
--- a/lib/librte_vhost/vhost.c
|
|
|
a6040a |
+++ b/lib/librte_vhost/vhost.c
|
|
|
a6040a |
@@ -103,7 +103,7 @@ get_device(int vid)
|
|
|
a6040a |
return dev;
|
|
|
a6040a |
}
|
|
|
a6040a |
|
|
|
a6040a |
-static void
|
|
|
a6040a |
+void
|
|
|
a6040a |
cleanup_vq(struct vhost_virtqueue *vq, int destroy)
|
|
|
a6040a |
{
|
|
|
a6040a |
if ((vq->callfd >= 0) && (destroy != 0))
|
|
|
a6040a |
@@ -127,6 +127,15 @@ cleanup_device(struct virtio_net *dev, int destroy)
|
|
|
a6040a |
cleanup_vq(dev->virtqueue[i], destroy);
|
|
|
a6040a |
}
|
|
|
a6040a |
|
|
|
a6040a |
+void
|
|
|
a6040a |
+free_vq(struct vhost_virtqueue *vq)
|
|
|
a6040a |
+{
|
|
|
a6040a |
+ rte_free(vq->shadow_used_ring);
|
|
|
a6040a |
+ rte_free(vq->batch_copy_elems);
|
|
|
a6040a |
+ rte_mempool_free(vq->iotlb_pool);
|
|
|
a6040a |
+ rte_free(vq);
|
|
|
a6040a |
+}
|
|
|
a6040a |
+
|
|
|
a6040a |
/*
|
|
|
a6040a |
* Release virtqueues and device memory.
|
|
|
a6040a |
*/
|
|
|
a6040a |
@@ -134,16 +143,9 @@ static void
|
|
|
a6040a |
free_device(struct virtio_net *dev)
|
|
|
a6040a |
{
|
|
|
a6040a |
uint32_t i;
|
|
|
a6040a |
- struct vhost_virtqueue *vq;
|
|
|
a6040a |
-
|
|
|
a6040a |
- for (i = 0; i < dev->nr_vring; i++) {
|
|
|
a6040a |
- vq = dev->virtqueue[i];
|
|
|
a6040a |
|
|
|
a6040a |
- rte_free(vq->shadow_used_ring);
|
|
|
a6040a |
- rte_free(vq->batch_copy_elems);
|
|
|
a6040a |
- rte_mempool_free(vq->iotlb_pool);
|
|
|
a6040a |
- rte_free(vq);
|
|
|
a6040a |
- }
|
|
|
a6040a |
+ for (i = 0; i < dev->nr_vring; i++)
|
|
|
a6040a |
+ free_vq(dev->virtqueue[i]);
|
|
|
a6040a |
|
|
|
a6040a |
rte_free(dev);
|
|
|
a6040a |
}
|
|
|
a6040a |
diff --git a/lib/librte_vhost/vhost.h b/lib/librte_vhost/vhost.h
|
|
|
a6040a |
index 1cc81c17c..9cad1bb3c 100644
|
|
|
a6040a |
--- a/lib/librte_vhost/vhost.h
|
|
|
a6040a |
+++ b/lib/librte_vhost/vhost.h
|
|
|
a6040a |
@@ -364,6 +364,9 @@ void cleanup_device(struct virtio_net *dev, int destroy);
|
|
|
a6040a |
void reset_device(struct virtio_net *dev);
|
|
|
a6040a |
void vhost_destroy_device(int);
|
|
|
a6040a |
|
|
|
a6040a |
+void cleanup_vq(struct vhost_virtqueue *vq, int destroy);
|
|
|
a6040a |
+void free_vq(struct vhost_virtqueue *vq);
|
|
|
a6040a |
+
|
|
|
a6040a |
int alloc_vring_queue(struct virtio_net *dev, uint32_t vring_idx);
|
|
|
a6040a |
|
|
|
a6040a |
void vhost_set_ifname(int, const char *if_name, unsigned int if_len);
|
|
|
a6040a |
--
|
|
|
a6040a |
2.14.3
|
|
|
a6040a |
|