diff mbox

[02/11] api: init: added thread type to local init

Message ID 1436449585-23252-3-git-send-email-maxim.uvarov@linaro.org
State Accepted
Commit 3501aeea1b0316aa5e951e6e601b891a05e0d1c4
Headers show

Commit Message

Maxim Uvarov July 9, 2015, 1:46 p.m. UTC
From: Petri Savolainen <petri.savolainen@nokia.com>

User needs to select the thread type (worker or control) of
the initialized thread. Implementation may reserve HW direct access
only to worker threads, while control threads share HW access, etc.

Signed-off-by: Petri Savolainen <petri.savolainen@nokia.com>
Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>

Conflicts:
	helper/linux.c
---
 example/classifier/odp_classifier.c           | 2 +-
 example/generator/odp_generator.c             | 2 +-
 example/ipsec/odp_ipsec.c                     | 2 +-
 example/packet/odp_pktio.c                    | 2 +-
 example/timer/odp_timer_test.c                | 2 +-
 helper/linux.c                                | 4 ++--
 helper/test/odp_chksum.c                      | 2 +-
 helper/test/odp_process.c                     | 2 +-
 helper/test/odp_thread.c                      | 2 +-
 include/odp/api/init.h                        | 5 ++++-
 platform/linux-generic/odp_init.c             | 2 +-
 test/performance/odp_l2fwd.c                  | 2 +-
 test/performance/odp_pktio_perf.c             | 2 +-
 test/performance/odp_scheduling.c             | 2 +-
 test/validation/common/odp_cunit_common.c     | 2 +-
 test/validation/crypto/crypto.c               | 2 +-
 test/validation/synchronizers/synchronizers.c | 2 +-
 17 files changed, 21 insertions(+), 18 deletions(-)
diff mbox

Patch

diff --git a/example/classifier/odp_classifier.c b/example/classifier/odp_classifier.c
index 643e16c..a716966 100644
--- a/example/classifier/odp_classifier.c
+++ b/example/classifier/odp_classifier.c
@@ -384,7 +384,7 @@  int main(int argc, char *argv[])
 	}
 
 	/* Init this thread */
-	if (odp_init_local()) {
+	if (odp_init_local(ODP_THREAD_CONTROL)) {
 		EXAMPLE_ERR("Error: ODP local init failed.\n");
 		exit(EXIT_FAILURE);
 	}
diff --git a/example/generator/odp_generator.c b/example/generator/odp_generator.c
index 0ff264c..76b6f42 100644
--- a/example/generator/odp_generator.c
+++ b/example/generator/odp_generator.c
@@ -599,7 +599,7 @@  int main(int argc, char *argv[])
 		exit(EXIT_FAILURE);
 	}
 
-	if (odp_init_local()) {
+	if (odp_init_local(ODP_THREAD_CONTROL)) {
 		EXAMPLE_ERR("Error: ODP local init failed.\n");
 		exit(EXIT_FAILURE);
 	}
diff --git a/example/ipsec/odp_ipsec.c b/example/ipsec/odp_ipsec.c
index 4928985..471a390 100644
--- a/example/ipsec/odp_ipsec.c
+++ b/example/ipsec/odp_ipsec.c
@@ -1239,7 +1239,7 @@  main(int argc, char *argv[])
 	}
 
 	/* Init this thread */
-	if (odp_init_local()) {
+	if (odp_init_local(ODP_THREAD_CONTROL)) {
 		EXAMPLE_ERR("Error: ODP local init failed.\n");
 		exit(EXIT_FAILURE);
 	}
diff --git a/example/packet/odp_pktio.c b/example/packet/odp_pktio.c
index 0b4a8f1..a71b5d4 100644
--- a/example/packet/odp_pktio.c
+++ b/example/packet/odp_pktio.c
@@ -345,7 +345,7 @@  int main(int argc, char *argv[])
 	}
 
 	/* Init this thread */
-	if (odp_init_local()) {
+	if (odp_init_local(ODP_THREAD_CONTROL)) {
 		EXAMPLE_ERR("Error: ODP local init failed.\n");
 		exit(EXIT_FAILURE);
 	}
diff --git a/example/timer/odp_timer_test.c b/example/timer/odp_timer_test.c
index f4af0e2..f184eda 100644
--- a/example/timer/odp_timer_test.c
+++ b/example/timer/odp_timer_test.c
@@ -355,7 +355,7 @@  int main(int argc, char *argv[])
 	}
 
 	/* Init this thread. */
-	if (odp_init_local()) {
+	if (odp_init_local(ODP_THREAD_CONTROL)) {
 		printf("ODP local init failed.\n");
 		return -1;
 	}
diff --git a/helper/linux.c b/helper/linux.c
index 46313f4..a2eacc1 100644
--- a/helper/linux.c
+++ b/helper/linux.c
@@ -58,7 +58,7 @@  static void *odp_run_start_routine(void *arg)
 	odp_start_args_t *start_args = arg;
 
 	/* ODP thread local init */
-	if (odp_init_local()) {
+	if (odp_init_local(ODP_THREAD_WORKER)) {
 		ODPH_ERR("Local init failed\n");
 		return NULL;
 	}
@@ -203,7 +203,7 @@  int odph_linux_process_fork_n(odph_linux_process_t *proc_tbl,
 			return -2;
 		}
 
-		if (odp_init_local()) {
+		if (odp_init_local(ODP_THREAD_WORKER)) {
 			ODPH_ERR("Local init failed\n");
 			return -2;
 		}
diff --git a/helper/test/odp_chksum.c b/helper/test/odp_chksum.c
index dae2a5b..830ffe8 100644
--- a/helper/test/odp_chksum.c
+++ b/helper/test/odp_chksum.c
@@ -126,7 +126,7 @@  int main(int argc TEST_UNUSED, char *argv[] TEST_UNUSED)
 		exit(EXIT_FAILURE);
 	}
 
-	if (odp_init_local()) {
+	if (odp_init_local(ODP_THREAD_WORKER)) {
 		LOG_ERR("Error: ODP local init failed.\n");
 		exit(EXIT_FAILURE);
 	}
diff --git a/helper/test/odp_process.c b/helper/test/odp_process.c
index 3483549..97f4669 100644
--- a/helper/test/odp_process.c
+++ b/helper/test/odp_process.c
@@ -33,7 +33,7 @@  int main(int argc TEST_UNUSED, char *argv[] TEST_UNUSED)
 		exit(EXIT_FAILURE);
 	}
 
-	if (odp_init_local()) {
+	if (odp_init_local(ODP_THREAD_CONTROL)) {
 		LOG_ERR("Error: ODP local init failed.\n");
 		exit(EXIT_FAILURE);
 	}
diff --git a/helper/test/odp_thread.c b/helper/test/odp_thread.c
index 04c6b1e..634be96 100644
--- a/helper/test/odp_thread.c
+++ b/helper/test/odp_thread.c
@@ -34,7 +34,7 @@  int main(int argc TEST_UNUSED, char *argv[] TEST_UNUSED)
 		exit(EXIT_FAILURE);
 	}
 
-	if (odp_init_local()) {
+	if (odp_init_local(ODP_THREAD_CONTROL)) {
 		LOG_ERR("Error: ODP local init failed.\n");
 		exit(EXIT_FAILURE);
 	}
diff --git a/include/odp/api/init.h b/include/odp/api/init.h
index 01faedc..0e940fc 100644
--- a/include/odp/api/init.h
+++ b/include/odp/api/init.h
@@ -30,6 +30,7 @@  extern "C" {
 
 #include <odp/std_types.h>
 #include <odp/hints.h>
+#include <odp/thread.h>
 
 /** @defgroup odp_initialization ODP INITIALIZATION
  *  Initialisation operations.
@@ -174,10 +175,12 @@  int odp_term_global(void);
  * @sa odp_term_local()
  * @sa odp_init_global() which must have been called prior to this.
  *
+ * @param thr_type  Thread type
+ *
  * @retval 0 on success
  * @retval <0 on failure
  */
-int odp_init_local(void);
+int odp_init_local(odp_thread_type_t thr_type);
 
 
 /**
diff --git a/platform/linux-generic/odp_init.c b/platform/linux-generic/odp_init.c
index bf36e68..0b13a6d 100644
--- a/platform/linux-generic/odp_init.c
+++ b/platform/linux-generic/odp_init.c
@@ -121,7 +121,7 @@  int odp_term_global(void)
 	return rc;
 }
 
-int odp_init_local(void)
+int odp_init_local(odp_thread_type_t thr_type ODP_UNUSED)
 {
 	if (odp_shm_init_local()) {
 		ODP_ERR("ODP shm local init failed.\n");
diff --git a/test/performance/odp_l2fwd.c b/test/performance/odp_l2fwd.c
index dd0b4b1..3184147 100644
--- a/test/performance/odp_l2fwd.c
+++ b/test/performance/odp_l2fwd.c
@@ -367,7 +367,7 @@  int main(int argc, char *argv[])
 	}
 
 	/* Init this thread */
-	if (odp_init_local()) {
+	if (odp_init_local(ODP_THREAD_CONTROL)) {
 		LOG_ERR("Error: ODP local init failed.\n");
 		exit(EXIT_FAILURE);
 	}
diff --git a/test/performance/odp_pktio_perf.c b/test/performance/odp_pktio_perf.c
index 3a22f9d..c3cc54d 100644
--- a/test/performance/odp_pktio_perf.c
+++ b/test/performance/odp_pktio_perf.c
@@ -952,7 +952,7 @@  int main(int argc, char **argv)
 	if (odp_init_global(NULL, NULL) != 0)
 		LOG_ABORT("Failed global init.\n");
 
-	if (odp_init_local() != 0)
+	if (odp_init_local(ODP_THREAD_CONTROL) != 0)
 		LOG_ABORT("Failed local init.\n");
 
 	shm = odp_shm_reserve("test_globals",
diff --git a/test/performance/odp_scheduling.c b/test/performance/odp_scheduling.c
index 99f0f9b..ee1c5da 100644
--- a/test/performance/odp_scheduling.c
+++ b/test/performance/odp_scheduling.c
@@ -860,7 +860,7 @@  int main(int argc, char *argv[])
 	 * Init this thread. It makes also ODP calls when
 	 * setting up resources for worker threads.
 	 */
-	if (odp_init_local()) {
+	if (odp_init_local(ODP_THREAD_CONTROL)) {
 		LOG_ERR("ODP global init failed.\n");
 		return -1;
 	}
diff --git a/test/validation/common/odp_cunit_common.c b/test/validation/common/odp_cunit_common.c
index 67938f2..f7b7ea1 100644
--- a/test/validation/common/odp_cunit_common.c
+++ b/test/validation/common/odp_cunit_common.c
@@ -48,7 +48,7 @@  ODP_WEAK_SYMBOL int tests_global_init(void)
 		fprintf(stderr, "error: odp_init_global() failed.\n");
 		return -1;
 	}
-	if (0 != odp_init_local()) {
+	if (0 != odp_init_local(ODP_THREAD_CONTROL)) {
 		fprintf(stderr, "error: odp_init_local() failed.\n");
 		return -1;
 	}
diff --git a/test/validation/crypto/crypto.c b/test/validation/crypto/crypto.c
index 899fb51..9d8a02b 100644
--- a/test/validation/crypto/crypto.c
+++ b/test/validation/crypto/crypto.c
@@ -33,7 +33,7 @@  int tests_global_init(void)
 		fprintf(stderr, "error: odp_init_global() failed.\n");
 		return -1;
 	}
-	if (0 != odp_init_local()) {
+	if (0 != odp_init_local(ODP_THREAD_CONTROL)) {
 		fprintf(stderr, "error: odp_init_local() failed.\n");
 		return -1;
 	}
diff --git a/test/validation/synchronizers/synchronizers.c b/test/validation/synchronizers/synchronizers.c
index 61c6026..4f89366 100644
--- a/test/validation/synchronizers/synchronizers.c
+++ b/test/validation/synchronizers/synchronizers.c
@@ -1061,7 +1061,7 @@  int tests_global_init(void)
 		fprintf(stderr, "error: odp_init_global() failed.\n");
 		return -1;
 	}
-	if (0 != odp_init_local()) {
+	if (0 != odp_init_local(ODP_THREAD_CONTROL)) {
 		fprintf(stderr, "error: odp_init_local() failed.\n");
 		return -1;
 	}