Skip to content

Commit

Permalink
linux-gen: implement odp_schedule_config() API call
Browse files Browse the repository at this point in the history
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 <dmitry.ereminsolenikov@linaro.org>
Signed-off-by: Balasubramanian Manoharan <bala.manoharan@linaro.org>
Reviewed-by: Bill Fischofer <bill.fischofer@linaro.org>
Reviewed-by: Petri Savolainen <petri.savolainen@linaro.org>
Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
  • Loading branch information
Dmitry Eremin-Solenikov authored and muvarov committed Nov 30, 2018
1 parent 265dbea commit 01d2340
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 0 deletions.
7 changes: 7 additions & 0 deletions platform/linux-generic/include/odp_schedule_if.h
Expand Up @@ -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);
Expand Down
17 changes: 17 additions & 0 deletions platform/linux-generic/odp_schedule_basic.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down
36 changes: 36 additions & 0 deletions platform/linux-generic/odp_schedule_if.c
Expand Up @@ -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);
Expand All @@ -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);
}

Expand Down
15 changes: 15 additions & 0 deletions platform/linux-generic/odp_schedule_scalable.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down
20 changes: 20 additions & 0 deletions platform/linux-generic/odp_schedule_sp.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 01d2340

Please sign in to comment.