diff mbox

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

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

Commit Message

Mike Holmes Jan. 30, 2015, 2:46 a.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 79bf6e3..4790481 100644
--- a/platform/linux-generic/include/odp_internal.h
+++ b/platform/linux-generic/include/odp_internal.h
@@ -43,6 +43,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 b91fca4..d381fd4 100644
--- a/platform/linux-generic/odp_init.c
+++ b/platform/linux-generic/odp_init.c
@@ -92,6 +92,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 60be9c2..4549b25 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;