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 <[email protected]>
---
 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 ++--
 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 +-
 12 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/example/classifier/odp_classifier.c 
b/example/classifier/odp_classifier.c
index 35d9684..b2f451c 100644
--- a/example/classifier/odp_classifier.c
+++ b/example/classifier/odp_classifier.c
@@ -382,7 +382,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 8ae5b29..66b9472 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 cb8f535..b51f633 100644
--- a/example/ipsec/odp_ipsec.c
+++ b/example/ipsec/odp_ipsec.c
@@ -1160,7 +1160,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 f08d9f4..17b54b2 100644
--- a/example/packet/odp_pktio.c
+++ b/example/packet/odp_pktio.c
@@ -337,7 +337,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 526342b..3bca125 100644
--- a/example/timer/odp_timer_test.c
+++ b/example/timer/odp_timer_test.c
@@ -364,7 +364,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 be1ea13..7352c76 100644
--- a/helper/linux.c
+++ b/helper/linux.c
@@ -60,7 +60,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)) {
                ODP_ERR("Local init failed\n");
                return NULL;
        }
@@ -200,7 +200,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)) {
                        ODP_ERR("Local init failed\n");
                        return -2;
                }
diff --git a/include/odp/api/init.h b/include/odp/api/init.h
index c3101d9..ab12a80 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.
@@ -175,13 +176,15 @@ int odp_term_global(void);
  * All threads must call this function before calling any other ODP API
  * functions.
  *
+ * @param thr_type  Thread type
+ *
  * @retval 0 on success
  * @retval <0 on failure
  *
  * @see odp_term_local()
  * @see odp_init_global() which must have been called prior to this.
  */
-int odp_init_local(void);
+int odp_init_local(odp_thread_type_t thr_type);
 
 /**
  * Thread local ODP termination
diff --git a/platform/linux-generic/odp_init.c 
b/platform/linux-generic/odp_init.c
index ab63c3c..48c9bba 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 5d4b833..fd6b544 100644
--- a/test/performance/odp_l2fwd.c
+++ b/test/performance/odp_l2fwd.c
@@ -359,7 +359,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 38ce328..a5f2731 100644
--- a/test/performance/odp_pktio_perf.c
+++ b/test/performance/odp_pktio_perf.c
@@ -908,7 +908,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 2af4410..6b80413 100644
--- a/test/validation/common/odp_cunit_common.c
+++ b/test/validation/common/odp_cunit_common.c
@@ -60,7 +60,7 @@ int main(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;
        }
-- 
2.4.0

_______________________________________________
lng-odp mailing list
[email protected]
https://lists.linaro.org/mailman/listinfo/lng-odp

Reply via email to