diff mbox

[03/10] linux-generic: packet_io: add term_global

Message ID 1422586015-29874-4-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_packet_io.c        | 20 ++++++++++++++++++++
 3 files changed, 26 insertions(+)
diff mbox

Patch

diff --git a/platform/linux-generic/include/odp_internal.h b/platform/linux-generic/include/odp_internal.h
index 56dc377..b2b595c 100644
--- a/platform/linux-generic/include/odp_internal.h
+++ b/platform/linux-generic/include/odp_internal.h
@@ -36,6 +36,7 @@  int odp_shm_init_local(void);
 int odp_buffer_pool_init_global(void);
 
 int odp_pktio_init_global(void);
+int odp_pktio_term_global(void);
 int odp_pktio_init_local(void);
 
 int odp_classification_init_global(void);
diff --git a/platform/linux-generic/odp_init.c b/platform/linux-generic/odp_init.c
index d4a475f..97b4665 100644
--- a/platform/linux-generic/odp_init.c
+++ b/platform/linux-generic/odp_init.c
@@ -82,6 +82,11 @@  int odp_term_global(void)
 		return -1;
 	}
 
+	if (odp_pktio_term_global()) {
+		ODP_ERR("ODP pktio term failed.\n");
+		return -1;
+	}
+
 	return 0;
 }
 
diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c
index bdb690e..b3b51c8 100644
--- a/platform/linux-generic/odp_packet_io.c
+++ b/platform/linux-generic/odp_packet_io.c
@@ -79,6 +79,26 @@  int odp_pktio_init_global(void)
 	return 0;
 }
 
+int odp_pktio_term_global(void)
+{
+	odp_shm_t shm;
+	pktio_entry_t *pktio_entry;
+	int ret = 0;
+	int id;
+
+	for (id = 1; id <= ODP_CONFIG_PKTIO_ENTRIES; ++id) {
+		pktio_entry = &pktio_tbl->entries[id - 1];
+		odp_queue_destroy(pktio_entry->s.outq_default);
+	}
+
+	shm = odp_shm_lookup("odp_pktio_entries");
+	if (shm == ODP_SHM_INVALID)
+		return -1;
+	ret = odp_shm_free(shm);
+
+	return ret;
+}
+
 int odp_pktio_init_local(void)
 {
 	return 0;