[02/10] linux-generic: odp_crypto: add term_global

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

Commit Message

Mike Holmes Jan. 30, 2015, 2:46 a.m.
From: Yan Sonming <yan.songming@linaro.org>

Signed-off-by: Yan Sonming <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_crypto.c           | 13 +++++++++++++
 platform/linux-generic/odp_init.c             |  5 +++++
 3 files changed, 19 insertions(+)

Patch

diff --git a/platform/linux-generic/include/odp_internal.h b/platform/linux-generic/include/odp_internal.h
index 2bd4b83..56dc377 100644
--- a/platform/linux-generic/include/odp_internal.h
+++ b/platform/linux-generic/include/odp_internal.h
@@ -44,6 +44,7 @@  int odp_classification_term_global(void);
 int odp_queue_init_global(void);
 
 int odp_crypto_init_global(void);
+int odp_crypto_term_global(void);
 
 int odp_schedule_init_global(void);
 int odp_schedule_init_local(void);
diff --git a/platform/linux-generic/odp_crypto.c b/platform/linux-generic/odp_crypto.c
index 483925b..66cb49b 100644
--- a/platform/linux-generic/odp_crypto.c
+++ b/platform/linux-generic/odp_crypto.c
@@ -428,6 +428,19 @@  odp_crypto_init_global(void)
 	return 0;
 }
 
+int odp_crypto_term_global(void)
+{
+	odp_shm_t shm;
+	int ret = 0;
+
+	shm = odp_shm_lookup("crypto_pool");
+	if (shm == ODP_SHM_INVALID)
+		return -1;
+	ret = odp_shm_free(shm);
+
+	return ret;
+}
+
 int
 odp_hw_random_get(uint8_t *buf, size_t *len, bool use_entropy ODP_UNUSED)
 {
diff --git a/platform/linux-generic/odp_init.c b/platform/linux-generic/odp_init.c
index 88a2578..d4a475f 100644
--- a/platform/linux-generic/odp_init.c
+++ b/platform/linux-generic/odp_init.c
@@ -77,6 +77,11 @@  int odp_term_global(void)
 		return -1;
 	}
 
+	if (odp_crypto_term_global()) {
+		ODP_ERR("ODP crypto term failed.\n");
+		return -1;
+	}
+
 	return 0;
 }