From 01d234075533e2b6597761f68a47e874be4ff054 Mon Sep 17 00:00:00 2001 From: Dmitry Eremin-Solenikov Date: Wed, 7 Nov 2018 17:39:48 +0300 Subject: [PATCH] linux-gen: implement odp_schedule_config() API call Add odp_schedule_config() stub, which does nothing at this point. Use it to actually check (in debug mode) that application call it in proper place. Signed-off-by: Dmitry Eremin-Solenikov Signed-off-by: Balasubramanian Manoharan Reviewed-by: Bill Fischofer Reviewed-by: Petri Savolainen Signed-off-by: Maxim Uvarov --- .../linux-generic/include/odp_schedule_if.h | 7 ++++ platform/linux-generic/odp_schedule_basic.c | 17 +++++++++ platform/linux-generic/odp_schedule_if.c | 36 +++++++++++++++++++ .../linux-generic/odp_schedule_scalable.c | 15 ++++++++ platform/linux-generic/odp_schedule_sp.c | 20 +++++++++++ 5 files changed, 95 insertions(+) diff --git a/platform/linux-generic/include/odp_schedule_if.h b/platform/linux-generic/include/odp_schedule_if.h index abc64d0d4d..15c9159043 100644 --- a/platform/linux-generic/include/odp_schedule_if.h +++ b/platform/linux-generic/include/odp_schedule_if.h @@ -87,10 +87,17 @@ int sched_cb_pktin_poll(int pktio_index, int pktin_index, int sched_cb_pktin_poll_one(int pktio_index, int rx_queue, odp_event_t evts[]); void sched_cb_pktio_stop_finalize(int pktio_index); +/* For debugging */ +#ifdef ODP_DEBUG +extern int _odp_schedule_configured; +#endif + /* API functions */ typedef struct { uint64_t (*schedule_wait_time)(uint64_t ns); int (*schedule_capability)(odp_schedule_capability_t *capa); + void (*schedule_config_init)(odp_schedule_config_t *config); + int (*schedule_config)(const odp_schedule_config_t *config); odp_event_t (*schedule)(odp_queue_t *from, uint64_t wait); int (*schedule_multi)(odp_queue_t *from, uint64_t wait, odp_event_t events[], int num); diff --git a/platform/linux-generic/odp_schedule_basic.c b/platform/linux-generic/odp_schedule_basic.c index f057f46897..48f232e6be 100644 --- a/platform/linux-generic/odp_schedule_basic.c +++ b/platform/linux-generic/odp_schedule_basic.c @@ -597,6 +597,8 @@ static int schedule_init_queue(uint32_t queue_index, int i; int prio = prio_level_from_api(sched_param->prio); + ODP_ASSERT(_odp_schedule_configured); + pri_set_queue(queue_index, prio); sched->queue[queue_index].grp = sched_param->group; sched->queue[queue_index].prio = prio; @@ -797,6 +799,19 @@ static int schedule_term_local(void) return 0; } +static void schedule_config_init(odp_schedule_config_t *config) +{ + config->num_queues = ODP_CONFIG_QUEUES - NUM_INTERNAL_QUEUES; + config->queue_size = queue_glb->config.max_queue_size; +} + +static int schedule_config(const odp_schedule_config_t *config) +{ + (void)config; + + return 0; +} + static inline int copy_from_stash(odp_event_t out_ev[], unsigned int max) { int i = 0; @@ -1589,6 +1604,8 @@ const schedule_fn_t schedule_basic_fn = { const schedule_api_t schedule_basic_api = { .schedule_wait_time = schedule_wait_time, .schedule_capability = schedule_capability, + .schedule_config_init = schedule_config_init, + .schedule_config = schedule_config, .schedule = schedule, .schedule_multi = schedule_multi, .schedule_multi_wait = schedule_multi_wait, diff --git a/platform/linux-generic/odp_schedule_if.c b/platform/linux-generic/odp_schedule_if.c index 92e0a62f8f..cb52f15546 100644 --- a/platform/linux-generic/odp_schedule_if.c +++ b/platform/linux-generic/odp_schedule_if.c @@ -25,6 +25,10 @@ extern const schedule_api_t schedule_scalable_api; const schedule_fn_t *sched_fn; const schedule_api_t *sched_api; +#ifdef ODP_DEBUG +int _odp_schedule_configured; +#endif + uint64_t odp_schedule_wait_time(uint64_t ns) { return sched_api->schedule_wait_time(ns); @@ -35,14 +39,46 @@ int odp_schedule_capability(odp_schedule_capability_t *capa) return sched_api->schedule_capability(capa); } +void odp_schedule_config_init(odp_schedule_config_t *config) +{ + memset(config, 0, sizeof(*config)); + + sched_api->schedule_config_init(config); +} + +int odp_schedule_config(const odp_schedule_config_t *config) +{ + int ret; + odp_schedule_config_t defconfig; + + ODP_ASSERT(!_odp_schedule_configured); + + if (!config) { + odp_schedule_config_init(&defconfig); + config = &defconfig; + } + + ret = sched_api->schedule_config(config); +#ifdef ODP_DEBUG + if (ret >= 0) + _odp_schedule_configured = 1; +#endif + + return ret; +} + odp_event_t odp_schedule(odp_queue_t *from, uint64_t wait) { + ODP_ASSERT(_odp_schedule_configured); + return sched_api->schedule(from, wait); } int odp_schedule_multi(odp_queue_t *from, uint64_t wait, odp_event_t events[], int num) { + ODP_ASSERT(_odp_schedule_configured); + return sched_api->schedule_multi(from, wait, events, num); } diff --git a/platform/linux-generic/odp_schedule_scalable.c b/platform/linux-generic/odp_schedule_scalable.c index 091e5ff9ed..4e9dd77177 100644 --- a/platform/linux-generic/odp_schedule_scalable.c +++ b/platform/linux-generic/odp_schedule_scalable.c @@ -1994,6 +1994,19 @@ static int schedule_term_local(void) return rc; } +static void schedule_config_init(odp_schedule_config_t *config) +{ + config->num_queues = ODP_CONFIG_QUEUES - NUM_INTERNAL_QUEUES; + config->queue_size = 0; /* FIXME ? */ +} + +static int schedule_config(const odp_schedule_config_t *config) +{ + (void)config; + + return 0; +} + static int num_grps(void) { return MAX_SCHED_GROUP; @@ -2141,6 +2154,8 @@ const schedule_fn_t schedule_scalable_fn = { const schedule_api_t schedule_scalable_api = { .schedule_wait_time = schedule_wait_time, .schedule_capability = schedule_capability, + .schedule_config_init = schedule_config_init, + .schedule_config = schedule_config, .schedule = schedule, .schedule_multi = schedule_multi, .schedule_multi_wait = schedule_multi_wait, diff --git a/platform/linux-generic/odp_schedule_sp.c b/platform/linux-generic/odp_schedule_sp.c index 6cc8f3766e..eec88a60a2 100644 --- a/platform/linux-generic/odp_schedule_sp.c +++ b/platform/linux-generic/odp_schedule_sp.c @@ -257,6 +257,19 @@ static int term_local(void) return 0; } +static void schedule_config_init(odp_schedule_config_t *config) +{ + config->num_queues = ODP_CONFIG_QUEUES - NUM_INTERNAL_QUEUES; + config->queue_size = queue_glb->config.max_queue_size; +} + +static int schedule_config(const odp_schedule_config_t *config) +{ + (void)config; + + return 0; +} + static uint32_t max_ordered_locks(void) { return NUM_ORDERED_LOCKS; @@ -362,6 +375,11 @@ static int init_queue(uint32_t qi, const odp_schedule_param_t *sched_param) odp_schedule_group_t group = sched_param->group; int prio = 0; +#ifdef ODP_DEBUG + if (!_odp_schedule_configured) + ODP_ABORT("Scheduler not configured!\n"); +#endif + if (group < 0 || group >= NUM_GROUP) return -1; @@ -961,6 +979,8 @@ const schedule_fn_t schedule_sp_fn = { const schedule_api_t schedule_sp_api = { .schedule_wait_time = schedule_wait_time, .schedule_capability = schedule_capability, + .schedule_config_init = schedule_config_init, + .schedule_config = schedule_config, .schedule = schedule, .schedule_multi = schedule_multi, .schedule_multi_wait = schedule_multi_wait,