diff mbox

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

Message ID 1424793647-28572-4-git-send-email-robking@cisco.com
State Accepted
Commit 16024f026eeaa7c933af1deb24b8b9304a71e206
Headers show

Commit Message

Robbie King Feb. 24, 2015, 4 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>
Signed-off-by: Robbie King <robking@cisco.com>
---
 platform/linux-generic/include/odp_internal.h |  1 +
 platform/linux-generic/odp_init.c             |  5 +++++
 platform/linux-generic/odp_packet_io.c        | 18 ++++++++++++++++++
 3 files changed, 24 insertions(+)
diff mbox

Patch

diff --git a/platform/linux-generic/include/odp_internal.h b/platform/linux-generic/include/odp_internal.h
index 9ae8530..e43608d 100644
--- a/platform/linux-generic/include/odp_internal.h
+++ b/platform/linux-generic/include/odp_internal.h
@@ -41,6 +41,7 @@  int odp_shm_init_local(void);
 int odp_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 602a3fd..d6382fb 100644
--- a/platform/linux-generic/odp_init.c
+++ b/platform/linux-generic/odp_init.c
@@ -88,6 +88,11 @@  int odp_term_global(void)
 		rc = -1;
 	}
 
+	if (odp_pktio_term_global()) {
+		ODP_ERR("ODP pktio term failed.\n");
+		rc = -1;
+	}
+
 	return rc;
 }
 
diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c
index c5d0569..a405bd7 100644
--- a/platform/linux-generic/odp_packet_io.c
+++ b/platform/linux-generic/odp_packet_io.c
@@ -79,6 +79,24 @@  int odp_pktio_init_global(void)
 	return 0;
 }
 
+int odp_pktio_term_global(void)
+{
+	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);
+	}
+
+	ret = odp_shm_free(odp_shm_lookup("odp_pktio_entries"));
+	if (ret < 0)
+		ODP_ERR("shm free failed for odp_pktio_entries");
+
+	return ret;
+}
+
 int odp_pktio_init_local(void)
 {
 	return 0;