Blame SOURCES/0003-vhost-extract-virtqueue-cleaning-and-freeing-functio.patch

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