aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetri Savolainen <petri.savolainen@linaro.org>2018-07-05 11:14:26 +0300
committerMaxim Uvarov <maxim.uvarov@linaro.org>2018-07-11 16:01:03 +0300
commit0070431f72dacef15d104bcf2baa9d70629d3d31 (patch)
tree8fe4703097398ed49f9d31ad1ec461b72cc91aea
parent5a43e72ba90dc5b4ea4ae3e8875075440e709655 (diff)
linux-gen: sched: move basic queue scheduler functions
Moved and renamed basic queue interface functions towards schedulers. Queue and scheduler implementations are tied together as queue enq/deq operations change queue scheduling state. Three schedulers are based on basic queue implementation and include basic queue internal header file already. Move this internal interface into proper internal header file. Signed-off-by: Petri Savolainen <petri.savolainen@linaro.org> Reviewed-by: Bill Fischofer <bill.fischofer@linaro.org> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
-rw-r--r--platform/linux-generic/include/odp_queue_basic_internal.h7
-rw-r--r--platform/linux-generic/include/odp_schedule_if.h6
-rw-r--r--platform/linux-generic/odp_queue_basic.c10
-rw-r--r--platform/linux-generic/odp_schedule_basic.c15
-rw-r--r--platform/linux-generic/odp_schedule_iquery.c9
-rw-r--r--platform/linux-generic/odp_schedule_sp.c8
6 files changed, 26 insertions, 29 deletions
diff --git a/platform/linux-generic/include/odp_queue_basic_internal.h b/platform/linux-generic/include/odp_queue_basic_internal.h
index 0a81f3c4b..654b9e312 100644
--- a/platform/linux-generic/include/odp_queue_basic_internal.h
+++ b/platform/linux-generic/include/odp_queue_basic_internal.h
@@ -98,6 +98,13 @@ static inline odp_queue_t queue_from_index(uint32_t queue_id)
void queue_spsc_init(queue_entry_t *queue, uint32_t queue_size);
+/* Functions for schedulers */
+void sched_queue_destroy_finalize(uint32_t queue_index);
+void sched_queue_set_status(uint32_t queue_index, int status);
+int sched_queue_deq(uint32_t queue_index, odp_event_t ev[], int num,
+ int update_status);
+int sched_queue_empty(uint32_t queue_index);
+
#ifdef __cplusplus
}
#endif
diff --git a/platform/linux-generic/include/odp_schedule_if.h b/platform/linux-generic/include/odp_schedule_if.h
index 0d0952621..8f082aaaf 100644
--- a/platform/linux-generic/include/odp_schedule_if.h
+++ b/platform/linux-generic/include/odp_schedule_if.h
@@ -82,12 +82,6 @@ int sched_cb_pktin_poll(int pktio_index, int pktin_index,
int sched_cb_pktin_poll_old(int pktio_index, int num_queue, int 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);
-odp_queue_t sched_cb_queue_handle(uint32_t queue_index);
-void sched_cb_queue_destroy_finalize(uint32_t queue_index);
-void sched_cb_queue_set_status(uint32_t queue_index, int status);
-int sched_cb_queue_deq_multi(uint32_t queue_index, odp_event_t ev[], int num,
- int update_status);
-int sched_cb_queue_empty(uint32_t queue_index);
/* API functions */
typedef struct {
diff --git a/platform/linux-generic/odp_queue_basic.c b/platform/linux-generic/odp_queue_basic.c
index 3962f9f1a..89eed3c0d 100644
--- a/platform/linux-generic/odp_queue_basic.c
+++ b/platform/linux-generic/odp_queue_basic.c
@@ -357,7 +357,7 @@ static odp_queue_t queue_create(const char *name,
return handle;
}
-void sched_cb_queue_destroy_finalize(uint32_t queue_index)
+void sched_queue_destroy_finalize(uint32_t queue_index)
{
queue_entry_t *queue = qentry_from_index(queue_index);
@@ -370,7 +370,7 @@ void sched_cb_queue_destroy_finalize(uint32_t queue_index)
UNLOCK(queue);
}
-void sched_cb_queue_set_status(uint32_t queue_index, int status)
+void sched_queue_set_status(uint32_t queue_index, int status)
{
queue_entry_t *queue = qentry_from_index(queue_index);
@@ -761,8 +761,8 @@ static int queue_info(odp_queue_t handle, odp_queue_info_t *info)
return 0;
}
-int sched_cb_queue_deq_multi(uint32_t queue_index, odp_event_t ev[],
- int max_num, int update_status)
+int sched_queue_deq(uint32_t queue_index, odp_event_t ev[], int max_num,
+ int update_status)
{
int num_deq;
ring_st_t *ring_st;
@@ -807,7 +807,7 @@ int sched_cb_queue_deq_multi(uint32_t queue_index, odp_event_t ev[],
return num_deq;
}
-int sched_cb_queue_empty(uint32_t queue_index)
+int sched_queue_empty(uint32_t queue_index)
{
queue_entry_t *queue = qentry_from_index(queue_index);
int ret = 0;
diff --git a/platform/linux-generic/odp_schedule_basic.c b/platform/linux-generic/odp_schedule_basic.c
index fbe5b26a3..754341497 100644
--- a/platform/linux-generic/odp_schedule_basic.c
+++ b/platform/linux-generic/odp_schedule_basic.c
@@ -363,7 +363,7 @@ static int schedule_init_global(void)
static inline void queue_destroy_finalize(uint32_t qi)
{
- sched_cb_queue_destroy_finalize(qi);
+ sched_queue_destroy_finalize(qi);
}
static int schedule_term_global(void)
@@ -384,9 +384,7 @@ static int schedule_term_global(void)
odp_event_t events[1];
int num;
- num = sched_cb_queue_deq_multi(qi,
- events,
- 1, 1);
+ num = sched_queue_deq(qi, events, 1, 1);
if (num < 0)
queue_destroy_finalize(qi);
@@ -581,7 +579,7 @@ static void schedule_pktio_start(int pktio_index, int num_pktin,
ODP_ASSERT(pktin_idx[i] <= MAX_PKTIN_INDEX);
/* Start polling */
- sched_cb_queue_set_status(qi, QUEUE_STATUS_SCHED);
+ sched_queue_set_status(qi, QUEUE_STATUS_SCHED);
schedule_sched_queue(qi);
}
}
@@ -797,7 +795,7 @@ static inline int poll_pktin(uint32_t qi, int direct_recv,
num_pktin = sched->pktio[pktio_index].num_pktin;
odp_spinlock_unlock(&sched->pktio_lock);
- sched_cb_queue_set_status(qi, QUEUE_STATUS_NOTSCHED);
+ sched_queue_set_status(qi, QUEUE_STATUS_NOTSCHED);
if (num_pktin == 0)
sched_cb_pktio_stop_finalize(pktio_index);
@@ -899,13 +897,12 @@ static inline int do_schedule_grp(odp_queue_t *out_queue, odp_event_t out_ev[],
pktin = queue_is_pktin(qi);
- num = sched_cb_queue_deq_multi(qi, ev_tbl, max_deq,
- !pktin);
+ num = sched_queue_deq(qi, ev_tbl, max_deq, !pktin);
if (num < 0) {
/* Destroyed queue. Continue scheduling the same
* priority queue. */
- sched_cb_queue_destroy_finalize(qi);
+ sched_queue_destroy_finalize(qi);
continue;
}
diff --git a/platform/linux-generic/odp_schedule_iquery.c b/platform/linux-generic/odp_schedule_iquery.c
index e7e23aa54..2501a3f68 100644
--- a/platform/linux-generic/odp_schedule_iquery.c
+++ b/platform/linux-generic/odp_schedule_iquery.c
@@ -289,10 +289,10 @@ static int schedule_term_global(void)
odp_event_t events[1];
if (sched->availables[i])
- count = sched_cb_queue_deq_multi(i, events, 1, 1);
+ count = sched_queue_deq(i, events, 1, 1);
if (count < 0)
- sched_cb_queue_destroy_finalize(i);
+ sched_queue_destroy_finalize(i);
else if (count > 0)
ODP_ERR("Queue (%d) not empty\n", i);
}
@@ -1532,12 +1532,11 @@ static inline int consume_queue(int prio, unsigned int queue_index)
if (is_ordered_queue(queue_index))
max = 1;
- count = sched_cb_queue_deq_multi(
- queue_index, cache->stash, max, 1);
+ count = sched_queue_deq(queue_index, cache->stash, max, 1);
if (count < 0) {
DO_SCHED_UNLOCK();
- sched_cb_queue_destroy_finalize(queue_index);
+ sched_queue_destroy_finalize(queue_index);
DO_SCHED_LOCK();
return 0;
}
diff --git a/platform/linux-generic/odp_schedule_sp.c b/platform/linux-generic/odp_schedule_sp.c
index b6bb3b2bb..ae292051b 100644
--- a/platform/linux-generic/odp_schedule_sp.c
+++ b/platform/linux-generic/odp_schedule_sp.c
@@ -228,7 +228,7 @@ static int term_global(void)
for (qi = 0; qi < NUM_QUEUE; qi++) {
if (sched_global->queue_cmd[qi].s.init) {
/* todo: dequeue until empty ? */
- sched_cb_queue_destroy_finalize(qi);
+ sched_queue_destroy_finalize(qi);
}
}
@@ -507,7 +507,7 @@ static int schedule_multi(odp_queue_t *from, uint64_t wait,
if (sched_local.cmd) {
/* Continue scheduling if queue is not empty */
- if (sched_cb_queue_empty(sched_local.cmd->s.index) == 0)
+ if (sched_queue_empty(sched_local.cmd->s.index) == 0)
add_tail(sched_local.cmd);
sched_local.cmd = NULL;
@@ -562,7 +562,7 @@ static int schedule_multi(odp_queue_t *from, uint64_t wait,
}
qi = cmd->s.index;
- num = sched_cb_queue_deq_multi(qi, events, 1, 1);
+ num = sched_queue_deq(qi, events, 1, 1);
if (num > 0) {
sched_local.cmd = cmd;
@@ -575,7 +575,7 @@ static int schedule_multi(odp_queue_t *from, uint64_t wait,
if (num < 0) {
/* Destroyed queue */
- sched_cb_queue_destroy_finalize(qi);
+ sched_queue_destroy_finalize(qi);
continue;
}