diff options
author | Santosh Shukla <santosh.shukla@linaro.org> | 2014-08-18 11:30:00 +0530 |
---|---|---|
committer | Santosh Shukla <sshukla@mvista.com> | 2014-08-18 11:31:03 +0530 |
commit | 1624c196812f9ce243f91d7e4b42546f84230197 (patch) | |
tree | 50aef56ce02c6baf88a60c2d41adbc71bac8d164 | |
parent | a9f281c3328181eee7094c25c381620bafd00bd4 (diff) |
implement odp_init_global init mask
Add ability to specify which odp layers should be
initialized.
Signed-off-by: Santosh Shukla <santosh.shukla@linaro.org>
-rw-r--r-- | example/generator/odp_generator.c | 2 | ||||
-rw-r--r-- | example/l2fwd/odp_l2fwd.c | 2 | ||||
-rw-r--r-- | example/odp_example/odp_example.c | 2 | ||||
-rw-r--r-- | example/packet/odp_pktio.c | 2 | ||||
-rw-r--r-- | example/packet_netmap/odp_pktio_netmap.c | 2 | ||||
-rw-r--r-- | example/timer/odp_timer_test.c | 2 | ||||
-rw-r--r-- | include/odp_init.h | 10 | ||||
-rw-r--r-- | platform/linux-dpdk/odp_init.c | 50 | ||||
-rw-r--r-- | platform/linux-generic/odp_init.c | 50 | ||||
-rw-r--r-- | platform/linux-keystone2/odp_init.c | 50 | ||||
-rw-r--r-- | test/api_test/odp_common.c | 2 |
11 files changed, 109 insertions, 65 deletions
diff --git a/example/generator/odp_generator.c b/example/generator/odp_generator.c index b10372e..4493f4f 100644 --- a/example/generator/odp_generator.c +++ b/example/generator/odp_generator.c @@ -530,7 +530,7 @@ int main(int argc, char *argv[]) int core_count; /* Init ODP before calling anything else */ - if (odp_init_global()) { + if (odp_init_global(ODP_INIT_F_ALL)) { ODP_ERR("Error: ODP global init failed.\n"); exit(EXIT_FAILURE); } diff --git a/example/l2fwd/odp_l2fwd.c b/example/l2fwd/odp_l2fwd.c index d74449a..dc228a8 100644 --- a/example/l2fwd/odp_l2fwd.c +++ b/example/l2fwd/odp_l2fwd.c @@ -323,7 +323,7 @@ int main(int argc, char *argv[]) odp_pktio_t pktio; /* Init ODP before calling anything else */ - if (odp_init_global()) { + if (odp_init_global(ODP_INIT_F_ALL)) { ODP_ERR("Error: ODP global init failed.\n"); exit(EXIT_FAILURE); } diff --git a/example/odp_example/odp_example.c b/example/odp_example/odp_example.c index f0bdf29..4582327 100644 --- a/example/odp_example/odp_example.c +++ b/example/odp_example/odp_example.c @@ -951,7 +951,7 @@ int main(int argc, char *argv[]) memset(thread_tbl, 0, sizeof(thread_tbl)); - if (odp_init_global()) { + if (odp_init_global(ODP_INIT_F_ALL)) { printf("ODP global init failed.\n"); return -1; } diff --git a/example/packet/odp_pktio.c b/example/packet/odp_pktio.c index f247bd0..9020afc 100644 --- a/example/packet/odp_pktio.c +++ b/example/packet/odp_pktio.c @@ -311,7 +311,7 @@ int main(int argc, char *argv[]) int core_count; /* Init ODP before calling anything else */ - if (odp_init_global()) { + if (odp_init_global(ODP_INIT_F_ALL & ~ODP_INIT_F_TIMER)) { ODP_ERR("Error: ODP global init failed.\n"); exit(EXIT_FAILURE); } diff --git a/example/packet_netmap/odp_pktio_netmap.c b/example/packet_netmap/odp_pktio_netmap.c index c0eb202..e3a93ea 100644 --- a/example/packet_netmap/odp_pktio_netmap.c +++ b/example/packet_netmap/odp_pktio_netmap.c @@ -227,7 +227,7 @@ int main(int argc, char *argv[]) int i; /* Init ODP before calling anything else */ - if (odp_init_global()) { + if (odp_init_global(ODP_INIT_F_ALL & ~ODP_INIT_F_TIMER)) { ODP_ERR("Error: ODP global init failed.\n"); exit(EXIT_FAILURE); } diff --git a/example/timer/odp_timer_test.c b/example/timer/odp_timer_test.c index dbe0e5b..4e566bc 100644 --- a/example/timer/odp_timer_test.c +++ b/example/timer/odp_timer_test.c @@ -210,7 +210,7 @@ int main(int argc, char *argv[]) memset(thread_tbl, 0, sizeof(thread_tbl)); - if (odp_init_global()) { + if (odp_init_global(ODP_INIT_F_ALL)) { printf("ODP global init failed.\n"); return -1; } diff --git a/include/odp_init.h b/include/odp_init.h index 490324a..f119e99 100644 --- a/include/odp_init.h +++ b/include/odp_init.h @@ -22,6 +22,13 @@ extern "C" { #include <odp_std_types.h> +#define ODP_INIT_F_ALL 0xff +#define ODP_INIT_F_SHMINIT (1 << 0) +#define ODP_INIT_F_GPOOL (1 << 1) +#define ODP_INIT_F_GQUEUE (1 << 2) +#define ODP_INIT_F_SCHEDULE (1 << 3) +#define ODP_INIT_F_PKTIO (1 << 4) +#define ODP_INIT_F_TIMER (1 << 5) @@ -31,9 +38,10 @@ extern "C" { * This function must be called once before calling * any other ODP API functions. * + * @param mask Mask odp layers to be initialized * @return 0 if successful */ -int odp_init_global(void); +int odp_init_global(uint8_t mask); /** diff --git a/platform/linux-dpdk/odp_init.c b/platform/linux-dpdk/odp_init.c index ecc2066..76ac94d 100644 --- a/platform/linux-dpdk/odp_init.c +++ b/platform/linux-dpdk/odp_init.c @@ -50,7 +50,7 @@ int odp_init_dpdk(void) return 0; } -int odp_init_global(void) +int odp_init_global(uint8_t mask) { odp_thread_init_global(); @@ -61,34 +61,46 @@ int odp_init_global(void) return -1; } - if (odp_shm_init_global()) { - ODP_ERR("ODP shm init failed.\n"); - return -1; + if (mask & ODP_INIT_F_SHMINIT) { + if (odp_shm_init_global()) { + ODP_ERR("ODP shm init failed.\n"); + return -1; + } } - if (odp_buffer_pool_init_global()) { - ODP_ERR("ODP buffer pool init failed.\n"); - return -1; + if (mask & ODP_INIT_F_GPOOL) { + if (odp_buffer_pool_init_global()) { + ODP_ERR("ODP buffer pool init failed.\n"); + return -1; + } } - if (odp_queue_init_global()) { - ODP_ERR("ODP queue init failed.\n"); - return -1; + if (mask & ODP_INIT_F_GQUEUE) { + if (odp_queue_init_global()) { + ODP_ERR("ODP queue init failed.\n"); + return -1; + } } - if (odp_schedule_init_global()) { - ODP_ERR("ODP schedule init failed.\n"); - return -1; + if (mask & ODP_INIT_F_SCHEDULE) { + if (odp_schedule_init_global()) { + ODP_ERR("ODP schedule init failed.\n"); + return -1; + } } - if (odp_pktio_init_global()) { - ODP_ERR("ODP packet io init failed.\n"); - return -1; + if (mask & ODP_INIT_F_PKTIO) { + if (odp_pktio_init_global()) { + ODP_ERR("ODP packet io init failed.\n"); + return -1; + } } - if (odp_timer_init_global()) { - ODP_ERR("ODP timer init failed.\n"); - return -1; + if (mask & ODP_INIT_F_TIMER) { + if (odp_timer_init_global()) { + ODP_ERR("ODP timer init failed.\n"); + return -1; + } } return 0; diff --git a/platform/linux-generic/odp_init.c b/platform/linux-generic/odp_init.c index 5b7e192..fca04c6 100644 --- a/platform/linux-generic/odp_init.c +++ b/platform/linux-generic/odp_init.c @@ -9,40 +9,52 @@ #include <odp_debug.h> -int odp_init_global(void) +int odp_init_global(uint8_t mask) { odp_thread_init_global(); odp_system_info_init(); - if (odp_shm_init_global()) { - ODP_ERR("ODP shm init failed.\n"); - return -1; + if (mask & ODP_INIT_F_SHMINIT) { + if (odp_shm_init_global()) { + ODP_ERR("ODP shm init failed.\n"); + return -1; + } } - if (odp_buffer_pool_init_global()) { - ODP_ERR("ODP buffer pool init failed.\n"); - return -1; + if (mask & ODP_INIT_F_GPOOL) { + if (odp_buffer_pool_init_global()) { + ODP_ERR("ODP buffer pool init failed.\n"); + return -1; + } } - if (odp_queue_init_global()) { - ODP_ERR("ODP queue init failed.\n"); - return -1; + if (mask & ODP_INIT_F_GQUEUE) { + if (odp_queue_init_global()) { + ODP_ERR("ODP queue init failed.\n"); + return -1; + } } - if (odp_schedule_init_global()) { - ODP_ERR("ODP schedule init failed.\n"); - return -1; + if (mask & ODP_INIT_F_SCHEDULE) { + if (odp_schedule_init_global()) { + ODP_ERR("ODP schedule init failed.\n"); + return -1; + } } - if (odp_pktio_init_global()) { - ODP_ERR("ODP packet io init failed.\n"); - return -1; + if (mask & ODP_INIT_F_PKTIO) { + if (odp_pktio_init_global()) { + ODP_ERR("ODP packet io init failed.\n"); + return -1; + } } - if (odp_timer_init_global()) { - ODP_ERR("ODP timer init failed.\n"); - return -1; + if (mask & ODP_INIT_F_TIMER) { + if (odp_timer_init_global()) { + ODP_ERR("ODP timer init failed.\n"); + return -1; + } } if (odp_crypto_init_global()) { diff --git a/platform/linux-keystone2/odp_init.c b/platform/linux-keystone2/odp_init.c index f832551..de28fda 100644 --- a/platform/linux-keystone2/odp_init.c +++ b/platform/linux-keystone2/odp_init.c @@ -90,7 +90,7 @@ static int ti_init_hw_config(void) } -int odp_init_global(void) +int odp_init_global(uint8_t mask) { odp_thread_init_global(); @@ -99,34 +99,46 @@ int odp_init_global(void) ti_em_osal_core_init_global(); ti_init_hw_config(); - if (odp_shm_init_global()) { - ODP_ERR("ODP shm init failed.\n"); - return -1; + if (mask & ODP_INIT_F_SHMINIT) { + if (odp_shm_init_global()) { + ODP_ERR("ODP shm init failed.\n"); + return -1; + } } - if (odp_buffer_pool_init_global()) { - ODP_ERR("ODP buffer pool init failed.\n"); - return -1; + if (mask & ODP_INIT_F_GPOOL) { + if (odp_buffer_pool_init_global()) { + ODP_ERR("ODP buffer pool init failed.\n"); + return -1; + } } - if (odp_queue_init_global()) { - ODP_ERR("ODP queue init failed.\n"); - return -1; + if (mask & ODP_INIT_F_GQUEUE) { + if (odp_queue_init_global()) { + ODP_ERR("ODP queue init failed.\n"); + return -1; + } } - if (odp_schedule_init_global()) { - ODP_ERR("ODP schedule init failed.\n"); - return -1; + if (mask & ODP_INIT_F_SCHEDULE) { + if (odp_schedule_init_global()) { + ODP_ERR("ODP schedule init failed.\n"); + return -1; + } } - if (odp_pktio_init_global()) { - ODP_ERR("ODP packet io init failed.\n"); - return -1; + if (mask & ODP_INIT_F_PKTIO) { + if (odp_pktio_init_global()) { + ODP_ERR("ODP packet io init failed.\n"); + return -1; + } } - if (odp_timer_init_global()) { - ODP_ERR("ODP timer init failed.\n"); - return -1; + if (mask & ODP_INIT_F_TIMER) { + if (odp_timer_init_global()) { + ODP_ERR("ODP timer init failed.\n"); + return -1; + } } return 0; diff --git a/test/api_test/odp_common.c b/test/api_test/odp_common.c index 89ebd2d..dcb13ed 100644 --- a/test/api_test/odp_common.c +++ b/test/api_test/odp_common.c @@ -56,7 +56,7 @@ int odp_test_global_init(void) { memset(thread_tbl, 0, sizeof(thread_tbl)); - if (odp_init_global()) { + if (odp_init_global(ODP_INIT_F_ALL)) { ODP_ERR("ODP global init failed.\n"); return -1; } |