From: Brian Brooks <brian.bro...@arm.com> Signed-off-by: Brian Brooks <brian.bro...@arm.com> Reviewed-by: Honnappa Nagarahalli <honnappa.nagaraha...@arm.com> Reviewed-by: Kevin Wang <kevin.w...@arm.com> --- /** Email created from pull request 166 (brbrooks:cloud-dev) ** https://github.com/Linaro/odp/pull/166 ** Patch: https://github.com/Linaro/odp/pull/166.patch ** Base sha: 344fe21a06ef4273f34c4441edd0caef876517d9 ** Merge commit sha: 45584e110dae85e9ed20736b254a7fdd044e6a76 **/ platform/linux-dpdk/Makefile.am | 20 +- platform/linux-dpdk/odp_init.c | 8 +- platform/linux-generic/Makefile.am | 21 +- platform/linux-generic/include/odp_internal.h | 5 + platform/linux-generic/include/odp_schedule_if.h | 39 +--- platform/linux-generic/odp_init.c | 8 +- platform/linux-generic/odp_schedule_if.c | 121 +--------- .../{odp_schedule.c => schedule/generic.c} | 28 ++- .../{odp_schedule_iquery.c => schedule/iquery.c} | 22 +- .../scalable.c} | 22 +- .../scalable_ordered.c} | 0 .../{odp_schedule_sp.c => schedule/sp.c} | 22 +- platform/linux-generic/schedule/subsystem.c | 253 +++++++++++++++++++++ 13 files changed, 376 insertions(+), 193 deletions(-) rename platform/linux-generic/{odp_schedule.c => schedule/generic.c} (98%) rename platform/linux-generic/{odp_schedule_iquery.c => schedule/iquery.c} (98%) rename platform/linux-generic/{odp_schedule_scalable.c => schedule/scalable.c} (99%) rename platform/linux-generic/{odp_schedule_scalable_ordered.c => schedule/scalable_ordered.c} (100%) rename platform/linux-generic/{odp_schedule_sp.c => schedule/sp.c} (97%)
diff --git a/platform/linux-dpdk/Makefile.am b/platform/linux-dpdk/Makefile.am index 8b94b7d2..587d4836 100644 --- a/platform/linux-dpdk/Makefile.am +++ b/platform/linux-dpdk/Makefile.am @@ -252,9 +252,12 @@ __LIB__libodp_dpdk_la_SOURCES = \ ../linux-generic/odp_rwlock.c \ ../linux-generic/odp_rwlock_recursive.c \ ../linux-generic/pool/subsystem.c \ - ../linux-generic/odp_schedule.c \ ../linux-generic/odp_schedule_if.c \ - ../linux-generic/odp_schedule_iquery.c \ + ../linux-generic/schedule/generic.c \ + ../linux-generic/schedule/iquery.c \ + ../linux-generic/schedule/scalable.c \ + ../linux-generic/schedule/scalable_ordered.c \ + ../linux-generic/schedule/sp.c \ ../linux-generic/schedule/subsystem.c \ ../linux-generic/odp_shared_memory.c \ ../linux-generic/odp_sorted_list.c \ @@ -297,6 +300,19 @@ __LIB__libodp_dpdk_la_SOURCES += arch/x86/cpu_flags.c \ endif pool/dpdk.lo: AM_CFLAGS += -DIM_ACTIVE_MODULE +if ODP_SCHEDULE_SCALABLE +../linux-generic/schedule/scalable.lo: AM_CFLAGS += -DIM_ACTIVE_MODULE +else +if ODP_SCHEDULE_SP +../linux-generic/schedule/sp.lo: AM_CFLAGS += -DIM_ACTIVE_MODULE +else +if ODP_SCHEDULE_IQUERY +../linux-generic/schedule/iquery.lo: AM_CFLAGS += -DIM_ACTIVE_MODULE +else +../linux-generic/schedule/generic.lo: AM_CFLAGS += -DIM_ACTIVE_MODULE +endif +endif +endif # Build modular framework into odp-linux library modularframeworkdir = $(top_srcdir)/frameworks/modular diff --git a/platform/linux-dpdk/odp_init.c b/platform/linux-dpdk/odp_init.c index 96c535ba..cd7abce6 100644 --- a/platform/linux-dpdk/odp_init.c +++ b/platform/linux-dpdk/odp_init.c @@ -358,7 +358,7 @@ int odp_init_global(odp_instance_t *instance, } stage = QUEUE_INIT; - if (sched_fn->init_global()) { + if (odp_schedule_init_global()) { ODP_ERR("ODP schedule init failed.\n"); goto init_failed; } @@ -488,7 +488,7 @@ int _odp_term_global(enum init_stage stage) /* Fall through */ case SCHED_INIT: - if (sched_fn->term_global()) { + if (odp_schedule_term_global()) { ODP_ERR("ODP schedule term failed.\n"); rc = -1; } @@ -590,7 +590,7 @@ int odp_init_local(odp_instance_t instance, odp_thread_type_t thr_type) } stage = POOL_INIT; - if (sched_fn->init_local()) { + if (odp_schedule_init_local()) { ODP_ERR("ODP schedule local init failed.\n"); goto init_fail; } @@ -617,7 +617,7 @@ int _odp_term_local(enum init_stage stage) case ALL_INIT: case SCHED_INIT: - if (sched_fn->term_local()) { + if (odp_schedule_term_local()) { ODP_ERR("ODP schedule local term failed.\n"); rc = -1; } diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am index 78e95760..cbbefa4e 100644 --- a/platform/linux-generic/Makefile.am +++ b/platform/linux-generic/Makefile.am @@ -281,12 +281,12 @@ __LIB__libodp_linux_la_SOURCES = \ odp_queue_scalable.c \ odp_rwlock.c \ odp_rwlock_recursive.c \ - odp_schedule.c \ odp_schedule_if.c \ - odp_schedule_sp.c \ - odp_schedule_iquery.c \ - odp_schedule_scalable.c \ - odp_schedule_scalable_ordered.c \ + schedule/generic.c \ + schedule/iquery.c \ + schedule/scalable.c \ + schedule/scalable_ordered.c \ + schedule/sp.c \ schedule/subsystem.c \ odp_shared_memory.c \ odp_sorted_list.c \ @@ -334,6 +334,17 @@ endif pool/generic.lo: AM_CFLAGS += -DIM_ACTIVE_MODULE buffer/generic.lo: AM_CFLAGS += -DIM_ACTIVE_MODULE +if ODP_SCHEDULE_SCALABLE +schedule/scalable.lo: AM_CFLAGS += -DIM_ACTIVE_MODULE +else +schedule/generic.lo: AM_CFLAGS += -DIM_ACTIVE_MODULE +endif +if ODP_SCHEDULE_SP +schedule/sp.lo: AM_CFLAGS += -DIM_ACTIVE_MODULE +endif +if ODP_SCHEDULE_IQUERY +schedule/iquery.lo: AM_CFLAGS += -DIM_ACTIVE_MODULE +endif # Build modular framework into odp-linux library modularframeworkdir = $(top_srcdir)/frameworks/modular diff --git a/platform/linux-generic/include/odp_internal.h b/platform/linux-generic/include/odp_internal.h index bb70bd72..2c935a9f 100644 --- a/platform/linux-generic/include/odp_internal.h +++ b/platform/linux-generic/include/odp_internal.h @@ -113,6 +113,11 @@ int odp_queue_term_global(void); int odp_crypto_init_global(void); int odp_crypto_term_global(void); +int odp_schedule_init_global(void); +int odp_schedule_term_global(void); +int odp_schedule_init_local(void); +int odp_schedule_term_local(void); + int odp_timer_init_global(const odp_init_t *params); int odp_timer_term_global(void); int odp_timer_disarm_all(void); diff --git a/platform/linux-generic/include/odp_schedule_if.h b/platform/linux-generic/include/odp_schedule_if.h index 657993b1..2bcf23f2 100644 --- a/platform/linux-generic/include/odp_schedule_if.h +++ b/platform/linux-generic/include/odp_schedule_if.h @@ -20,18 +20,13 @@ typedef void (*schedule_pktio_start_fn_t)(int pktio_index, int num_in_queue, typedef int (*schedule_thr_add_fn_t)(odp_schedule_group_t group, int thr); typedef int (*schedule_thr_rem_fn_t)(odp_schedule_group_t group, int thr); typedef int (*schedule_num_grps_fn_t)(void); -typedef int (*schedule_init_queue_fn_t)(uint32_t queue_index, - const odp_schedule_param_t *sched_param - ); +typedef int (*schedule_init_queue_fn_t)( + uint32_t queue_index, const odp_schedule_param_t *sched_param); typedef void (*schedule_destroy_queue_fn_t)(uint32_t queue_index); typedef int (*schedule_sched_queue_fn_t)(uint32_t queue_index); typedef int (*schedule_unsched_queue_fn_t)(uint32_t queue_index); typedef int (*schedule_ord_enq_multi_fn_t)(queue_t q_int, void *buf_hdr[], int num, int *ret); -typedef int (*schedule_init_global_fn_t)(void); -typedef int (*schedule_term_global_fn_t)(void); -typedef int (*schedule_init_local_fn_t)(void); -typedef int (*schedule_term_local_fn_t)(void); typedef void (*schedule_order_lock_fn_t)(void); typedef void (*schedule_order_unlock_fn_t)(void); typedef unsigned (*schedule_max_ordered_locks_fn_t)(void); @@ -47,10 +42,6 @@ typedef struct schedule_fn_t { schedule_destroy_queue_fn_t destroy_queue; schedule_sched_queue_fn_t sched_queue; schedule_ord_enq_multi_fn_t ord_enq_multi; - schedule_init_global_fn_t init_global; - schedule_term_global_fn_t term_global; - schedule_init_local_fn_t init_local; - schedule_term_local_fn_t term_local; schedule_order_lock_fn_t order_lock; schedule_order_unlock_fn_t order_unlock; schedule_max_ordered_locks_fn_t max_ordered_locks; @@ -72,32 +63,6 @@ void sched_cb_queue_destroy_finalize(uint32_t queue_index); int sched_cb_queue_deq_multi(uint32_t queue_index, odp_event_t ev[], int num); int sched_cb_queue_empty(uint32_t queue_index); -/* API functions */ -typedef struct { - uint64_t (*schedule_wait_time)(uint64_t); - odp_event_t (*schedule)(odp_queue_t *, uint64_t); - int (*schedule_multi)(odp_queue_t *, uint64_t, odp_event_t [], int); - void (*schedule_pause)(void); - void (*schedule_resume)(void); - void (*schedule_release_atomic)(void); - void (*schedule_release_ordered)(void); - void (*schedule_prefetch)(int); - int (*schedule_num_prio)(void); - odp_schedule_group_t (*schedule_group_create)(const char *, - const odp_thrmask_t *); - int (*schedule_group_destroy)(odp_schedule_group_t); - odp_schedule_group_t (*schedule_group_lookup)(const char *); - int (*schedule_group_join)(odp_schedule_group_t, const odp_thrmask_t *); - int (*schedule_group_leave)(odp_schedule_group_t, - const odp_thrmask_t *); - int (*schedule_group_thrmask)(odp_schedule_group_t, odp_thrmask_t *); - int (*schedule_group_info)(odp_schedule_group_t, - odp_schedule_group_info_t *); - void (*schedule_order_lock)(unsigned); - void (*schedule_order_unlock)(unsigned); - -} schedule_api_t; - #ifdef __cplusplus } #endif diff --git a/platform/linux-generic/odp_init.c b/platform/linux-generic/odp_init.c index 0d5ee710..340171a5 100644 --- a/platform/linux-generic/odp_init.c +++ b/platform/linux-generic/odp_init.c @@ -178,7 +178,7 @@ int odp_init_global(odp_instance_t *instance, } stage = QUEUE_INIT; - if (sched_fn->init_global()) { + if (odp_schedule_init_global()) { ODP_ERR("ODP schedule init failed.\n"); goto init_failed; } @@ -306,7 +306,7 @@ int _odp_term_global(enum init_stage stage) /* Fall through */ case SCHED_INIT: - if (sched_fn->term_global()) { + if (odp_schedule_term_global()) { ODP_ERR("ODP schedule term failed.\n"); rc = -1; } @@ -414,7 +414,7 @@ int odp_init_local(odp_instance_t instance, odp_thread_type_t thr_type) } stage = QUEUE_INIT; - if (sched_fn->init_local()) { + if (odp_schedule_init_local()) { ODP_ERR("ODP schedule local init failed.\n"); goto init_fail; } @@ -447,7 +447,7 @@ int _odp_term_local(enum init_stage stage) case ALL_INIT: case SCHED_INIT: - if (sched_fn->term_local()) { + if (odp_schedule_term_local()) { ODP_ERR("ODP schedule local term failed.\n"); rc = -1; } diff --git a/platform/linux-generic/odp_schedule_if.c b/platform/linux-generic/odp_schedule_if.c index 2f07aafe..b06ab130 100644 --- a/platform/linux-generic/odp_schedule_if.c +++ b/platform/linux-generic/odp_schedule_if.c @@ -7,123 +7,16 @@ #include <odp_schedule_if.h> extern const schedule_fn_t schedule_sp_fn; -extern const schedule_api_t schedule_sp_api; - -extern const schedule_fn_t schedule_default_fn; -extern const schedule_api_t schedule_default_api; - extern const schedule_fn_t schedule_iquery_fn; -extern const schedule_api_t schedule_iquery_api; - -extern const schedule_fn_t schedule_scalable_fn; -extern const schedule_api_t schedule_scalable_api; +extern const schedule_fn_t schedule_scalable_fn; +extern const schedule_fn_t schedule_default_fn; -#ifdef ODP_SCHEDULE_SP -const schedule_fn_t *sched_fn = &schedule_sp_fn; -const schedule_api_t *sched_api = &schedule_sp_api; +#if defined(ODP_SCHEDULE_SP) +const schedule_fn_t *sched_fn = &schedule_sp_fn; #elif defined(ODP_SCHEDULE_IQUERY) -const schedule_fn_t *sched_fn = &schedule_iquery_fn; -const schedule_api_t *sched_api = &schedule_iquery_api; +const schedule_fn_t *sched_fn = &schedule_iquery_fn; #elif defined(ODP_SCHEDULE_SCALABLE) -const schedule_fn_t *sched_fn = &schedule_scalable_fn; -const schedule_api_t *sched_api = &schedule_scalable_api; +const schedule_fn_t *sched_fn = &schedule_scalable_fn; #else -const schedule_fn_t *sched_fn = &schedule_default_fn; -const schedule_api_t *sched_api = &schedule_default_api; +const schedule_fn_t *sched_fn = &schedule_default_fn; #endif - -uint64_t odp_schedule_wait_time(uint64_t ns) -{ - return sched_api->schedule_wait_time(ns); -} - -odp_event_t odp_schedule(odp_queue_t *from, uint64_t wait) -{ - return sched_api->schedule(from, wait); -} - -int odp_schedule_multi(odp_queue_t *from, uint64_t wait, odp_event_t events[], - int num) -{ - return sched_api->schedule_multi(from, wait, events, num); -} - -void odp_schedule_pause(void) -{ - return sched_api->schedule_pause(); -} - -void odp_schedule_resume(void) -{ - return sched_api->schedule_resume(); -} - -void odp_schedule_release_atomic(void) -{ - return sched_api->schedule_release_atomic(); -} - -void odp_schedule_release_ordered(void) -{ - return sched_api->schedule_release_ordered(); -} - -void odp_schedule_prefetch(int num) -{ - return sched_api->schedule_prefetch(num); -} - -int odp_schedule_num_prio(void) -{ - return sched_api->schedule_num_prio(); -} - -odp_schedule_group_t odp_schedule_group_create(const char *name, - const odp_thrmask_t *mask) -{ - return sched_api->schedule_group_create(name, mask); -} - -int odp_schedule_group_destroy(odp_schedule_group_t group) -{ - return sched_api->schedule_group_destroy(group); -} - -odp_schedule_group_t odp_schedule_group_lookup(const char *name) -{ - return sched_api->schedule_group_lookup(name); -} - -int odp_schedule_group_join(odp_schedule_group_t group, - const odp_thrmask_t *mask) -{ - return sched_api->schedule_group_join(group, mask); -} - -int odp_schedule_group_leave(odp_schedule_group_t group, - const odp_thrmask_t *mask) -{ - return sched_api->schedule_group_leave(group, mask); -} - -int odp_schedule_group_thrmask(odp_schedule_group_t group, - odp_thrmask_t *thrmask) -{ - return sched_api->schedule_group_thrmask(group, thrmask); -} - -int odp_schedule_group_info(odp_schedule_group_t group, - odp_schedule_group_info_t *info) -{ - return sched_api->schedule_group_info(group, info); -} - -void odp_schedule_order_lock(unsigned lock_index) -{ - return sched_api->schedule_order_lock(lock_index); -} - -void odp_schedule_order_unlock(unsigned lock_index) -{ - return sched_api->schedule_order_unlock(lock_index); -} diff --git a/platform/linux-generic/odp_schedule.c b/platform/linux-generic/schedule/generic.c similarity index 98% rename from platform/linux-generic/odp_schedule.c rename to platform/linux-generic/schedule/generic.c index a696d251..24ab8e06 100644 --- a/platform/linux-generic/odp_schedule.c +++ b/platform/linux-generic/schedule/generic.c @@ -23,6 +23,7 @@ #include <odp/api/packet_io.h> #include <odp_ring_internal.h> #include <odp_timer_internal.h> +#include <odp_schedule_subsystem.h> /* Should remove this dependency */ #include <odp_queue_internal.h> @@ -389,9 +390,9 @@ static int schedule_term_global(void) odp_event_t events[1]; int num; - num = sched_cb_queue_deq_multi(qi, - events, - 1); + num = queue_idx_deq_multi(qi, + events, + 1); if (num < 0) queue_destroy_finalize(qi); @@ -1397,10 +1398,6 @@ const schedule_fn_t schedule_default_fn = { .destroy_queue = schedule_destroy_queue, .sched_queue = schedule_sched_queue, .ord_enq_multi = schedule_ord_enq_multi, - .init_global = schedule_init_global, - .term_global = schedule_term_global, - .init_local = schedule_init_local, - .term_local = schedule_term_local, .order_lock = order_lock, .order_unlock = order_unlock, .max_ordered_locks = schedule_max_ordered_locks, @@ -1409,8 +1406,15 @@ const schedule_fn_t schedule_default_fn = { }; /* Fill in scheduler API calls */ -const schedule_api_t schedule_default_api = { - .schedule_wait_time = schedule_wait_time, +odp_schedule_module_t schedule_generic = { + .base = { + .name = "schedule_generic", + .init_global = schedule_init_global, + .term_global = schedule_term_global, + .init_local = schedule_init_local, + .term_local = schedule_term_local, + }, + .wait_time = schedule_wait_time, .schedule = schedule, .schedule_multi = schedule_multi, .schedule_pause = schedule_pause, @@ -1429,3 +1433,9 @@ const schedule_api_t schedule_default_api = { .schedule_order_lock = schedule_order_lock, .schedule_order_unlock = schedule_order_unlock }; + +ODP_MODULE_CONSTRUCTOR(schedule_generic) +{ + odp_module_constructor(&schedule_generic); + odp_subsystem_register_module(schedule, &schedule_generic); +} diff --git a/platform/linux-generic/odp_schedule_iquery.c b/platform/linux-generic/schedule/iquery.c similarity index 98% rename from platform/linux-generic/odp_schedule_iquery.c rename to platform/linux-generic/schedule/iquery.c index 86f5d53e..f03014b8 100644 --- a/platform/linux-generic/odp_schedule_iquery.c +++ b/platform/linux-generic/schedule/iquery.c @@ -23,6 +23,7 @@ #include <odp/api/packet_io.h> #include <odp_config_internal.h> #include <odp_timer_internal.h> +#include <odp_schedule_subsystem.h> /* Should remove this dependency */ #include <odp_queue_internal.h> @@ -1336,10 +1337,6 @@ const schedule_fn_t schedule_iquery_fn = { .destroy_queue = destroy_sched_queue, .sched_queue = schedule_sched_queue, .ord_enq_multi = schedule_ord_enq_multi, - .init_global = schedule_init_global, - .term_global = schedule_term_global, - .init_local = schedule_init_local, - .term_local = schedule_term_local, .order_lock = order_lock, .order_unlock = order_unlock, .max_ordered_locks = schedule_max_ordered_locks, @@ -1348,8 +1345,15 @@ const schedule_fn_t schedule_iquery_fn = { }; /* Fill in scheduler API calls */ -const schedule_api_t schedule_iquery_api = { - .schedule_wait_time = schedule_wait_time, +odp_schedule_module_t schedule_iquery = { + .base = { + .name = "schedule_iquery", + .init_global = schedule_init_global, + .term_global = schedule_term_global, + .init_local = schedule_init_local, + .term_local = schedule_term_local, + }, + .wait_time = schedule_wait_time, .schedule = schedule, .schedule_multi = schedule_multi, .schedule_pause = schedule_pause, @@ -1369,6 +1373,12 @@ const schedule_api_t schedule_iquery_api = { .schedule_order_unlock = schedule_order_unlock }; +ODP_MODULE_CONSTRUCTOR(schedule_iquery) +{ + odp_module_constructor(&schedule_iquery); + odp_subsystem_register_module(schedule, &schedule_iquery); +} + static void thread_set_interest(sched_thread_local_t *thread, unsigned int queue_index, int prio) { diff --git a/platform/linux-generic/odp_schedule_scalable.c b/platform/linux-generic/schedule/scalable.c similarity index 99% rename from platform/linux-generic/odp_schedule_scalable.c rename to platform/linux-generic/schedule/scalable.c index 78159b53..787553ca 100644 --- a/platform/linux-generic/odp_schedule_scalable.c +++ b/platform/linux-generic/schedule/scalable.c @@ -28,6 +28,7 @@ #include <odp_llqueue.h> #include <odp_queue_scalable_internal.h> #include <odp_schedule_if.h> +#include <odp_schedule_subsystem.h> #include <odp_bitset.h> #include <odp_packet_io_internal.h> @@ -1949,17 +1950,20 @@ const schedule_fn_t schedule_scalable_fn = { .destroy_queue = destroy_queue, .sched_queue = sched_queue, .ord_enq_multi = ord_enq_multi, - .init_global = schedule_init_global, - .term_global = schedule_term_global, - .init_local = schedule_init_local, - .term_local = schedule_term_local, .order_lock = order_lock, .order_unlock = order_unlock, .max_ordered_locks = schedule_max_ordered_locks, }; -const schedule_api_t schedule_scalable_api = { - .schedule_wait_time = schedule_wait_time, +odp_schedule_module_t schedule_scalable = { + .base = { + .name = "schedule_scalable", + .init_global = schedule_init_global, + .term_global = schedule_term_global, + .init_local = schedule_init_local, + .term_local = schedule_term_local, + }, + .wait_time = schedule_wait_time, .schedule = schedule, .schedule_multi = schedule_multi, .schedule_pause = schedule_pause, @@ -1978,3 +1982,9 @@ const schedule_api_t schedule_scalable_api = { .schedule_order_lock = schedule_order_lock, .schedule_order_unlock = schedule_order_unlock, }; + +ODP_MODULE_CONSTRUCTOR(schedule_scalable) +{ + odp_module_constructor(&schedule_scalable); + odp_subsystem_register_module(schedule, &schedule_scalable); +} diff --git a/platform/linux-generic/odp_schedule_scalable_ordered.c b/platform/linux-generic/schedule/scalable_ordered.c similarity index 100% rename from platform/linux-generic/odp_schedule_scalable_ordered.c rename to platform/linux-generic/schedule/scalable_ordered.c diff --git a/platform/linux-generic/odp_schedule_sp.c b/platform/linux-generic/schedule/sp.c similarity index 97% rename from platform/linux-generic/odp_schedule_sp.c rename to platform/linux-generic/schedule/sp.c index 9829acc5..19700f90 100644 --- a/platform/linux-generic/odp_schedule_sp.c +++ b/platform/linux-generic/schedule/sp.c @@ -16,6 +16,7 @@ #include <odp_config_internal.h> #include <odp_ring_internal.h> #include <odp_timer_internal.h> +#include <odp_schedule_subsystem.h> #define NUM_THREAD ODP_THREAD_COUNT_MAX #define NUM_QUEUE ODP_CONFIG_QUEUES @@ -836,10 +837,6 @@ const schedule_fn_t schedule_sp_fn = { .destroy_queue = destroy_queue, .sched_queue = sched_queue, .ord_enq_multi = ord_enq_multi, - .init_global = init_global, - .term_global = term_global, - .init_local = init_local, - .term_local = term_local, .order_lock = order_lock, .order_unlock = order_unlock, .max_ordered_locks = max_ordered_locks, @@ -848,8 +845,15 @@ const schedule_fn_t schedule_sp_fn = { }; /* Fill in scheduler API calls */ -const schedule_api_t schedule_sp_api = { - .schedule_wait_time = schedule_wait_time, +odp_schedule_module_t schedule_sp = { + .base = { + .name = "schedule_sp", + .init_global = init_global, + .term_global = term_global, + .init_local = init_local, + .term_local = term_local, + }, + .wait_time = schedule_wait_time, .schedule = schedule, .schedule_multi = schedule_multi, .schedule_pause = schedule_pause, @@ -868,3 +872,9 @@ const schedule_api_t schedule_sp_api = { .schedule_order_lock = schedule_order_lock, .schedule_order_unlock = schedule_order_unlock }; + +ODP_MODULE_CONSTRUCTOR(schedule_sp) +{ + odp_module_constructor(&schedule_sp); + odp_subsystem_register_module(schedule, &schedule_sp); +} diff --git a/platform/linux-generic/schedule/subsystem.c b/platform/linux-generic/schedule/subsystem.c index ae2bf3fd..6ca6459e 100644 --- a/platform/linux-generic/schedule/subsystem.c +++ b/platform/linux-generic/schedule/subsystem.c @@ -6,7 +6,12 @@ * SPDX-License-Identifier: BSD-3-Clause */ +/* API header files */ +#include <odp.h> + /* Internal header files */ +#include <odp_debug_internal.h> +#include <odp_internal.h> #include <odp_module.h> #include <odp_schedule_subsystem.h> @@ -17,3 +22,251 @@ ODP_SUBSYSTEM_CONSTRUCTOR(schedule) { odp_subsystem_constructor(schedule); } + +int odp_schedule_init_global(void) +{ + odp_schedule_module_t *module = + odp_subsystem_active_module(schedule, module); + + ODP_ASSERT(module); + ODP_ASSERT(module->base.init_global); + + return module->base.init_global(); +} + +int odp_schedule_term_global(void) +{ + odp_schedule_module_t *module = + odp_subsystem_active_module(schedule, module); + + ODP_ASSERT(module); + ODP_ASSERT(module->base.term_global); + + return module->base.term_global(); +} + +int odp_schedule_init_local(void) +{ + odp_schedule_module_t *module = + odp_subsystem_active_module(schedule, module); + + ODP_ASSERT(module); + ODP_ASSERT(module->base.init_local); + + return module->base.init_local(); +} + +int odp_schedule_term_local(void) +{ + odp_schedule_module_t *module = + odp_subsystem_active_module(schedule, module); + + ODP_ASSERT(module); + ODP_ASSERT(module->base.term_local); + + return module->base.term_local(); +} + +uint64_t odp_schedule_wait_time(uint64_t ns) +{ + odp_schedule_module_t *module = + odp_subsystem_active_module(schedule, module); + + ODP_ASSERT(module); + ODP_ASSERT(module->wait_time); + + return module->wait_time(ns); +} + +odp_event_t odp_schedule(odp_queue_t *from, uint64_t wait) +{ + odp_schedule_module_t *module = + odp_subsystem_active_module(schedule, module); + + ODP_ASSERT(module); + ODP_ASSERT(module->schedule); + + return module->schedule(from, wait); +} + +int odp_schedule_multi(odp_queue_t *from, uint64_t wait, odp_event_t events[], + int num) +{ + odp_schedule_module_t *module = + odp_subsystem_active_module(schedule, module); + + ODP_ASSERT(module); + ODP_ASSERT(module->schedule_multi); + + return module->schedule_multi(from, wait, events, num); +} + +void odp_schedule_pause(void) +{ + odp_schedule_module_t *module = + odp_subsystem_active_module(schedule, module); + + ODP_ASSERT(module); + ODP_ASSERT(module->schedule_pause); + + return module->schedule_pause(); +} + +void odp_schedule_resume(void) +{ + odp_schedule_module_t *module = + odp_subsystem_active_module(schedule, module); + + ODP_ASSERT(module); + ODP_ASSERT(module->schedule_resume); + + return module->schedule_resume(); +} + +void odp_schedule_release_atomic(void) +{ + odp_schedule_module_t *module = + odp_subsystem_active_module(schedule, module); + + ODP_ASSERT(module); + ODP_ASSERT(module->schedule_release_atomic); + + return module->schedule_release_atomic(); +} + +void odp_schedule_release_ordered(void) +{ + odp_schedule_module_t *module = + odp_subsystem_active_module(schedule, module); + + ODP_ASSERT(module); + ODP_ASSERT(module->schedule_release_ordered); + + return module->schedule_release_ordered(); +} + +void odp_schedule_prefetch(int num) +{ + odp_schedule_module_t *module = + odp_subsystem_active_module(schedule, module); + + ODP_ASSERT(module); + ODP_ASSERT(module->schedule_prefetch); + + return module->schedule_prefetch(num); +} + +int odp_schedule_num_prio(void) +{ + odp_schedule_module_t *module = + odp_subsystem_active_module(schedule, module); + + ODP_ASSERT(module); + ODP_ASSERT(module->schedule_num_prio); + + return module->schedule_num_prio(); +} + +odp_schedule_group_t odp_schedule_group_create(const char *name, + const odp_thrmask_t *mask) +{ + odp_schedule_module_t *module = + odp_subsystem_active_module(schedule, module); + + ODP_ASSERT(module); + ODP_ASSERT(module->schedule_group_create); + + return module->schedule_group_create(name, mask); +} + +int odp_schedule_group_destroy(odp_schedule_group_t group) +{ + odp_schedule_module_t *module = + odp_subsystem_active_module(schedule, module); + + ODP_ASSERT(module); + ODP_ASSERT(module->schedule_group_destroy); + + return module->schedule_group_destroy(group); +} + +odp_schedule_group_t odp_schedule_group_lookup(const char *name) +{ + odp_schedule_module_t *module = + odp_subsystem_active_module(schedule, module); + + ODP_ASSERT(module); + ODP_ASSERT(module->schedule_group_lookup); + + return module->schedule_group_lookup(name); +} + +int odp_schedule_group_join(odp_schedule_group_t group, + const odp_thrmask_t *mask) +{ + odp_schedule_module_t *module = + odp_subsystem_active_module(schedule, module); + + ODP_ASSERT(module); + ODP_ASSERT(module->schedule_group_join); + + return module->schedule_group_join(group, mask); +} + +int odp_schedule_group_leave(odp_schedule_group_t group, + const odp_thrmask_t *mask) +{ + odp_schedule_module_t *module = + odp_subsystem_active_module(schedule, module); + + ODP_ASSERT(module); + ODP_ASSERT(module->schedule_group_leave); + + return module->schedule_group_leave(group, mask); +} + +int odp_schedule_group_thrmask(odp_schedule_group_t group, + odp_thrmask_t *thrmask) +{ + odp_schedule_module_t *module = + odp_subsystem_active_module(schedule, module); + + ODP_ASSERT(module); + ODP_ASSERT(module->schedule_group_thrmask); + + return module->schedule_group_thrmask(group, thrmask); +} + +int odp_schedule_group_info(odp_schedule_group_t group, + odp_schedule_group_info_t *info) +{ + odp_schedule_module_t *module = + odp_subsystem_active_module(schedule, module); + + ODP_ASSERT(module); + ODP_ASSERT(module->schedule_group_info); + + return module->schedule_group_info(group, info); +} + +void odp_schedule_order_lock(unsigned lock_index) +{ + odp_schedule_module_t *module = + odp_subsystem_active_module(schedule, module); + + ODP_ASSERT(module); + ODP_ASSERT(module->schedule_order_lock); + + return module->schedule_order_lock(lock_index); +} + +void odp_schedule_order_unlock(unsigned lock_index) +{ + odp_schedule_module_t *module = + odp_subsystem_active_module(schedule, module); + + ODP_ASSERT(module); + ODP_ASSERT(module->schedule_order_unlock); + + return module->schedule_order_unlock(lock_index); +}