aboutsummaryrefslogtreecommitdiff
path: root/platform/linux-generic/odp_schedule_basic.c
diff options
context:
space:
mode:
Diffstat (limited to 'platform/linux-generic/odp_schedule_basic.c')
-rw-r--r--platform/linux-generic/odp_schedule_basic.c38
1 files changed, 22 insertions, 16 deletions
diff --git a/platform/linux-generic/odp_schedule_basic.c b/platform/linux-generic/odp_schedule_basic.c
index 32a21442d..21f707be7 100644
--- a/platform/linux-generic/odp_schedule_basic.c
+++ b/platform/linux-generic/odp_schedule_basic.c
@@ -229,6 +229,7 @@ typedef struct {
/* Scheduler interface config options (not used in fast path) */
schedule_config_t config_if;
+ uint32_t max_queues;
} sched_global_t;
@@ -399,6 +400,7 @@ static int schedule_init_global(void)
odp_shm_t shm;
int i, j, grp;
int prefer_ratio;
+ uint32_t ring_size;
ODP_DBG("Schedule init ... ");
@@ -419,11 +421,23 @@ static int schedule_init_global(void)
return -1;
}
+ sched->shm = shm;
prefer_ratio = sched->config.prefer_ratio;
/* When num_spread == 1, only spread_tbl[0] is used. */
sched->max_spread = (sched->config.num_spread - 1) * prefer_ratio;
- sched->shm = shm;
+
+ ring_size = MAX_RING_SIZE / sched->config.num_spread;
+ ring_size = ROUNDUP_POWER2_U32(ring_size);
+ ODP_ASSERT(ring_size <= MAX_RING_SIZE);
+ sched->ring_mask = ring_size - 1;
+
+ /* Each ring can hold in maximum ring_size-1 queues. Due to ring size round up,
+ * total capacity of rings may be larger than CONFIG_MAX_SCHED_QUEUES. */
+ sched->max_queues = sched->ring_mask * sched->config.num_spread;
+ if (sched->max_queues > CONFIG_MAX_SCHED_QUEUES)
+ sched->max_queues = CONFIG_MAX_SCHED_QUEUES;
+
odp_spinlock_init(&sched->mask_lock);
for (grp = 0; grp < NUM_SCHED_GRPS; grp++) {
@@ -573,7 +587,6 @@ static inline int prio_level_from_api(int api_prio)
static int schedule_create_queue(uint32_t queue_index,
const odp_schedule_param_t *sched_param)
{
- uint32_t ring_size;
int i;
int prio = prio_level_from_api(sched_param->prio);
uint8_t spread = spread_index(queue_index);
@@ -620,11 +633,6 @@ static int schedule_create_queue(uint32_t queue_index,
sched->queue[queue_index].pktio_index = 0;
sched->queue[queue_index].pktin_index = 0;
- ring_size = MAX_RING_SIZE / sched->config.num_spread;
- ring_size = ROUNDUP_POWER2_U32(ring_size);
- ODP_ASSERT(ring_size <= MAX_RING_SIZE);
- sched->ring_mask = ring_size - 1;
-
odp_atomic_init_u64(&sched->order[queue_index].ctx, 0);
odp_atomic_init_u64(&sched->order[queue_index].next_ctx, 0);
@@ -762,7 +770,7 @@ static inline void ordered_stash_release(void)
num_enq = 0;
ODP_DBG("Dropped %i packets\n", num - num_enq);
- buffer_free_multi(&buf_hdr[num_enq], num - num_enq);
+ _odp_buffer_free_multi(&buf_hdr[num_enq], num - num_enq);
}
}
sched_local.ordered.stash_num = 0;
@@ -822,7 +830,7 @@ static int schedule_term_local(void)
static void schedule_config_init(odp_schedule_config_t *config)
{
- config->num_queues = CONFIG_MAX_SCHED_QUEUES;
+ config->num_queues = sched->max_queues;
config->queue_size = _odp_queue_glb->config.max_queue_size;
config->sched_group.all = sched->config_if.group_enable.all;
config->sched_group.control = sched->config_if.group_enable.control;
@@ -840,7 +848,6 @@ static void schedule_group_clear(odp_schedule_group_t group)
grp_update_mask(group, &zero);
sched->sched_grp[group].allocated = 0;
-
}
static int schedule_config(const odp_schedule_config_t *config)
@@ -999,7 +1006,7 @@ static inline int poll_pktin(uint32_t qi, int direct_recv,
num_enq = 0;
ODP_DBG("Dropped %i packets\n", num - num_enq);
- buffer_free_multi(&b_hdr[num_enq], num - num_enq);
+ _odp_buffer_free_multi(&b_hdr[num_enq], num - num_enq);
}
return ret;
@@ -1018,7 +1025,6 @@ static inline int do_schedule_grp(odp_queue_t *out_queue, odp_event_t out_ev[],
/* Schedule events */
for (prio = 0; prio < NUM_PRIO; prio++) {
-
if (sched->prio_q_mask[prio] == 0)
continue;
@@ -1253,7 +1259,6 @@ static inline int schedule_loop(odp_queue_t *out_queue, uint64_t wait,
int ret;
while (1) {
-
ret = do_schedule(out_queue, out_ev, max_num);
if (ret) {
timer_run(2);
@@ -1326,6 +1331,7 @@ static inline void order_lock(void)
static void order_unlock(void)
{
+ /* Nothing to do */
}
static void schedule_order_lock(uint32_t lock_index)
@@ -1621,9 +1627,9 @@ static int schedule_thr_rem(odp_schedule_group_t group, int thr)
return 0;
}
-/* This function is a no-op */
-static void schedule_prefetch(int num ODP_UNUSED)
+static void schedule_prefetch(int num)
{
+ (void)num;
}
static int schedule_num_grps(void)
@@ -1643,7 +1649,7 @@ static int schedule_capability(odp_schedule_capability_t *capa)
capa->max_ordered_locks = schedule_max_ordered_locks();
capa->max_groups = schedule_num_grps();
capa->max_prios = schedule_num_prio();
- capa->max_queues = CONFIG_MAX_SCHED_QUEUES;
+ capa->max_queues = sched->max_queues;
capa->max_queue_size = _odp_queue_glb->config.max_queue_size;
capa->max_flow_id = BUF_HDR_MAX_FLOW_ID;