diff mbox

[v2,05/10] linux-generic: queue: add term_global

Message ID 1424116520-20381-6-git-send-email-mike.holmes@linaro.org
State New
Headers show

Commit Message

Mike Holmes Feb. 16, 2015, 7:55 p.m. UTC
From: Yan Sonming <yan.songming@linaro.org>

Signed-off-by: Yan Songming <yan.songming@linaro.org>
Signed-off-by: Mike Holmes <mike.holmes@linaro.org>
---
 platform/linux-generic/include/odp_internal.h |  1 +
 platform/linux-generic/odp_init.c             |  5 +++++
 platform/linux-generic/odp_queue.c            | 25 +++++++++++++++++++++++++
 3 files changed, 31 insertions(+)
diff mbox

Patch

diff --git a/platform/linux-generic/include/odp_internal.h b/platform/linux-generic/include/odp_internal.h
index d244c75..202c914 100644
--- a/platform/linux-generic/include/odp_internal.h
+++ b/platform/linux-generic/include/odp_internal.h
@@ -48,6 +48,7 @@  int odp_classification_init_global(void);
 int odp_classification_term_global(void);
 
 int odp_queue_init_global(void);
+int odp_queue_term_global(void);
 
 int odp_crypto_init_global(void);
 int odp_crypto_term_global(void);
diff --git a/platform/linux-generic/odp_init.c b/platform/linux-generic/odp_init.c
index 2788e46..93fdc2c 100644
--- a/platform/linux-generic/odp_init.c
+++ b/platform/linux-generic/odp_init.c
@@ -96,6 +96,11 @@  int odp_term_global(void)
 		return -1;
 	}
 
+	if (odp_queue_term_global()) {
+		ODP_ERR("ODP queue term failed.\n");
+		return -1;
+	}
+
 	return 0;
 }
 
diff --git a/platform/linux-generic/odp_queue.c b/platform/linux-generic/odp_queue.c
index 76bf4d7..0aa0e9c 100644
--- a/platform/linux-generic/odp_queue.c
+++ b/platform/linux-generic/odp_queue.c
@@ -128,6 +128,31 @@  int odp_queue_init_global(void)
 	return 0;
 }
 
+int odp_queue_term_global(void)
+{
+	odp_shm_t shm;
+	int ret = 0;
+	queue_entry_t *queue;
+	int i;
+
+	for (i = 0; i < ODP_CONFIG_QUEUES; i++) {
+		queue = &queue_tbl->queue[i];
+		LOCK(&queue->s.lock);
+		if (queue->s.status != QUEUE_STATUS_FREE) {
+			ODP_ERR("Not destroyed queue: %s\n", queue->s.name);
+			ret = -1;
+		}
+		UNLOCK(&queue->s.lock);
+	}
+
+	shm = odp_shm_lookup("odp_queues");
+	if (shm == ODP_SHM_INVALID)
+		return -1;
+	ret = odp_shm_free(shm);
+
+	return ret;
+}
+
 odp_queue_type_t odp_queue_type(odp_queue_t handle)
 {
 	queue_entry_t *queue;