@@ -372,7 +372,7 @@ static void *gen_send_thread(void *arg)
return NULL;
}
- err = odp_queue_enq(outq_def, odp_packet_to_buffer(pkt));
+ err = odp_queue_enq(outq_def, odp_packet_to_event(pkt));
if (err != 0) {
EXAMPLE_ERR(" [%02i] send pkt err!\n", thr);
return NULL;
@@ -502,7 +502,7 @@ static void *gen_recv_thread(void *arg)
odp_pktio_t pktio;
thread_args_t *thr_args;
odp_packet_t pkt;
- odp_buffer_t buf;
+ odp_event_t ev;
thr = odp_thread_id();
thr_args = arg;
@@ -518,9 +518,9 @@ static void *gen_recv_thread(void *arg)
for (;;) {
/* Use schedule to get buf from any input queue */
- buf = odp_schedule(NULL, ODP_SCHED_WAIT);
+ ev = odp_schedule(NULL, ODP_SCHED_WAIT);
- pkt = odp_packet_from_buffer(buf);
+ pkt = odp_packet_from_event(ev);
/* Drop packets with errors */
if (odp_unlikely(odp_packet_error(pkt))) {
odp_packet_free(pkt);
@@ -1037,7 +1037,7 @@ void *pktio_thread(void *arg EXAMPLE_UNUSED)
{
int thr;
odp_packet_t pkt;
- odp_buffer_t buf;
+ odp_event_t ev;
unsigned long pkt_cnt = 0;
thr = odp_thread_id();
@@ -1053,8 +1053,8 @@ void *pktio_thread(void *arg EXAMPLE_UNUSED)
odp_queue_t dispatchq;
/* Use schedule to get buf from any input queue */
- buf = SCHEDULE(&dispatchq, ODP_SCHED_WAIT);
- pkt = odp_packet_from_buffer(buf);
+ ev = SCHEDULE(&dispatchq, ODP_SCHED_WAIT);
+ pkt = odp_packet_from_event(ev);
/* Determine new work versus completion or sequence number */
if ((completionq != dispatchq) && (seqnumq != dispatchq)) {
@@ -1113,7 +1113,7 @@ void *pktio_thread(void *arg EXAMPLE_UNUSED)
ctx->state = PKT_STATE_TRANSMIT;
} else {
ctx->state = PKT_STATE_IPSEC_OUT_SEQ;
- odp_queue_enq(seqnumq, buf);
+ odp_queue_enq(seqnumq, ev);
}
break;
@@ -1131,7 +1131,7 @@ void *pktio_thread(void *arg EXAMPLE_UNUSED)
case PKT_STATE_TRANSMIT:
- odp_queue_enq(ctx->outq, buf);
+ odp_queue_enq(ctx->outq, ev);
rc = PKT_DONE;
break;
@@ -497,7 +497,7 @@ int create_stream_db_inputs(void)
break;
}
stream->created++;
- odp_queue_enq(queue, pkt);
+ odp_queue_enq(queue, odp_packet_to_event(pkt));
/* Count this stream when we create first packet */
if (1 == stream->created)
@@ -111,7 +111,7 @@ static void *pktio_queue_thread(void *arg)
int thr;
odp_queue_t outq_def;
odp_packet_t pkt;
- odp_buffer_t buf;
+ odp_event_t ev;
unsigned long pkt_cnt = 0;
unsigned long err_cnt = 0;
@@ -124,8 +124,8 @@ static void *pktio_queue_thread(void *arg)
/* Loop packets */
for (;;) {
/* Use schedule to get buf from any input queue */
- buf = odp_schedule(NULL, ODP_SCHED_WAIT);
- pkt = odp_packet_from_buffer(buf);
+ ev = odp_schedule(NULL, ODP_SCHED_WAIT);
+ pkt = odp_packet_from_event(ev);
/* Drop packets with errors */
if (odp_unlikely(drop_err_pkts(&pkt, 1) == 0)) {
@@ -136,7 +136,7 @@ static void *pktio_queue_thread(void *arg)
outq_def = lookup_dest_q(pkt);
/* Enqueue the packet for output */
- odp_queue_enq(outq_def, buf);
+ odp_queue_enq(outq_def, ev);
/* Print packet counts every once in a while */
if (odp_unlikely(pkt_cnt++ % 100000 == 0)) {
@@ -151,7 +151,7 @@ static void *pktio_queue_thread(void *arg)
thread_args_t *thr_args;
odp_queue_t outq_def;
odp_packet_t pkt;
- odp_buffer_t buf;
+ odp_event_t ev;
unsigned long pkt_cnt = 0;
unsigned long err_cnt = 0;
@@ -175,7 +175,7 @@ static void *pktio_queue_thread(void *arg)
#if 1
/* Use schedule to get buf from any input queue */
- buf = odp_schedule(NULL, ODP_SCHED_WAIT);
+ ev = odp_schedule(NULL, ODP_SCHED_WAIT);
#else
/* Always dequeue from the same input queue */
buf = odp_queue_deq(inq_def);
@@ -183,7 +183,7 @@ static void *pktio_queue_thread(void *arg)
continue;
#endif
- pkt = odp_packet_from_buffer(buf);
+ pkt = odp_packet_from_event(ev);
/* Drop packets with errors */
if (odp_unlikely(drop_err_pkts(&pkt, 1) == 0)) {
@@ -204,7 +204,7 @@ static void *pktio_queue_thread(void *arg)
swap_pkt_addrs(&pkt, 1);
/* Enqueue the packet for output */
- odp_queue_enq(outq_def, buf);
+ odp_queue_enq(outq_def, ev);
/* Print packet counts every once in a while */
if (odp_unlikely(pkt_cnt++ % 100000 == 0)) {
@@ -114,7 +114,7 @@ static void test_abs_timeouts(int thr, test_args_t *args)
tick = odp_timer_current_tick(tp);
while ((int)odp_atomic_load_u32(&remain) > 0) {
- odp_buffer_t buf;
+ odp_event_t ev;
odp_timer_set_t rc;
tick += period;
@@ -134,23 +134,23 @@ static void test_abs_timeouts(int thr, test_args_t *args)
uint64_t sched_tmo =
odp_schedule_wait_time(1500000000ULL);
do {
- buf = odp_schedule(&queue, sched_tmo);
+ ev = odp_schedule(&queue, sched_tmo);
/* Check if odp_schedule() timed out, possibly there
* are no remaining timeouts to receive */
- } while (buf == ODP_BUFFER_INVALID &&
+ } while (ev == ODP_EVENT_INVALID &&
(int)odp_atomic_load_u32(&remain) > 0);
- if (buf == ODP_BUFFER_INVALID)
+ if (ev == ODP_EVENT_INVALID)
break; /* No more timeouts */
- if (odp_buffer_type(buf) != ODP_BUFFER_TYPE_TIMEOUT) {
+ if (odp_event_type(ev) != ODP_EVENT_TIMEOUT) {
/* Not a default timeout buffer */
- EXAMPLE_ABORT("Unexpected buffer type (%u) received\n",
- odp_buffer_type(buf));
+ EXAMPLE_ABORT("Unexpected event type (%u) received\n",
+ odp_event_type(ev));
}
- odp_timeout_t tmo = odp_timeout_from_buf(buf);
+ odp_timeout_t tmo = odp_timeout_from_event(ev);
tick = odp_timeout_tick(tmo);
ttp = odp_timeout_user_ptr(tmo);
- ttp->buf = buf;
+ ttp->buf = odp_buffer_from_event(ev);
if (!odp_timeout_fresh(tmo)) {
/* Not the expected expiration tick, timer has
* been reset or cancelled or freed */
@@ -174,11 +174,11 @@ void *odp_queue_get_context(odp_queue_t queue);
* Queue enqueue
*
* @param queue Queue handle
- * @param buf Buffer handle
+ * @param ev Event handle
*
* @return 0 if succesful
*/
-int odp_queue_enq(odp_queue_t queue, odp_buffer_t buf);
+int odp_queue_enq(odp_queue_t queue, odp_event_t ev);
/**
* Enqueue multiple buffers to a queue
@@ -47,21 +47,21 @@ uint64_t odp_schedule_wait_time(uint64_t ns);
* Schedule
*
* Schedules all queues created with ODP_QUEUE_TYPE_SCHED type. Returns
- * next highest priority buffer which is available for the calling thread.
- * Outputs the source queue of the buffer. If there's no buffer available, waits
- * for a buffer according to the wait parameter setting. Returns
- * ODP_BUFFER_INVALID if reaches end of the wait period.
+ * next highest priority event which is available for the calling thread.
+ * Outputs the source queue of the event. If there's no event available, waits
+ * for an event according to the wait parameter setting. Returns
+ * ODP_EVENT_INVALID if reaches end of the wait period.
*
- * @param from Output parameter for the source queue (where the buffer was
+ * @param from Output parameter for the source queue (where the event was
* dequeued from). Ignored if NULL.
- * @param wait Minimum time to wait for a buffer. Waits infinitely, if set to
+ * @param wait Minimum time to wait for an event. Waits infinitely, if set to
* ODP_SCHED_WAIT. Does not wait, if set to ODP_SCHED_NO_WAIT.
* Use odp_schedule_wait_time() to convert time to other wait
* values.
*
- * @return Next highest priority buffer, or ODP_BUFFER_INVALID
+ * @return Next highest priority event, or ODP_EVENT_INVALID
*/
-odp_buffer_t odp_schedule(odp_queue_t *from, uint64_t wait);
+odp_event_t odp_schedule(odp_queue_t *from, uint64_t wait);
/**
* Schedule multiple buffers
@@ -391,7 +391,8 @@ odp_crypto_operation(odp_crypto_op_params_t *params,
/* If specified during creation post event to completion queue */
if (ODP_QUEUE_INVALID != session->compl_queue) {
- odp_queue_enq(session->compl_queue, completion_event);
+ odp_queue_enq(session->compl_queue,
+ odp_buffer_to_event(completion_event));
*posted = 1;
}
return 0;
@@ -403,13 +403,13 @@ int odp_queue_enq_multi(odp_queue_t handle, odp_buffer_t buf[], int num)
}
-int odp_queue_enq(odp_queue_t handle, odp_buffer_t buf)
+int odp_queue_enq(odp_queue_t handle, odp_event_t ev)
{
odp_buffer_hdr_t *buf_hdr;
queue_entry_t *queue;
queue = queue_to_qentry(handle);
- buf_hdr = odp_buf_to_hdr(buf);
+ buf_hdr = odp_buf_to_hdr(odp_buffer_from_event(ev));
return queue->s.enqueue(queue, buf_hdr);
}
@@ -198,7 +198,7 @@ void odp_schedule_queue(odp_queue_t queue, int prio)
pri_queue = select_pri_queue(queue, prio);
desc_buf = queue_sched_buf(queue);
- odp_queue_enq(pri_queue, desc_buf);
+ odp_queue_enq(pri_queue, odp_buffer_to_event(desc_buf));
}
@@ -207,7 +207,8 @@ void odp_schedule_release_atomic(void)
if (sched_local.pri_queue != ODP_QUEUE_INVALID &&
sched_local.num == 0) {
/* Release current atomic queue */
- odp_queue_enq(sched_local.pri_queue, sched_local.desc_buf);
+ odp_queue_enq(sched_local.pri_queue,
+ odp_buffer_to_event(sched_local.desc_buf));
sched_local.pri_queue = ODP_QUEUE_INVALID;
}
}
@@ -297,7 +298,7 @@ static int schedule(odp_queue_t *out_queue, odp_buffer_t out_buf[],
if (odp_queue_type(queue) ==
ODP_QUEUE_TYPE_PKTIN &&
!queue_is_destroyed(queue))
- odp_queue_enq(pri_q, desc_buf);
+ odp_queue_enq(pri_q, odp_buffer_to_event(desc_buf));
continue;
}
@@ -314,7 +315,7 @@ static int schedule(odp_queue_t *out_queue, odp_buffer_t out_buf[],
sched_local.desc_buf = desc_buf;
} else {
/* Continue scheduling the queue */
- odp_queue_enq(pri_q, desc_buf);
+ odp_queue_enq(pri_q, odp_buffer_to_event(desc_buf));
}
/* Output the source queue handle */
@@ -367,7 +368,7 @@ static int schedule_loop(odp_queue_t *out_queue, uint64_t wait,
}
-odp_buffer_t odp_schedule(odp_queue_t *out_queue, uint64_t wait)
+odp_event_t odp_schedule(odp_queue_t *out_queue, uint64_t wait)
{
odp_buffer_t buf;
@@ -375,7 +376,7 @@ odp_buffer_t odp_schedule(odp_queue_t *out_queue, uint64_t wait)
schedule_loop(out_queue, wait, &buf, 1, MAX_DEQ);
- return buf;
+ return odp_buffer_to_event(buf);
}
@@ -567,7 +567,8 @@ static unsigned timer_expire(odp_timer_pool *tp, uint32_t idx, uint64_t tick)
}
/* Else ignore buffers of other types */
/* Post the timeout to the destination queue */
- int rc = odp_queue_enq(tim->queue, tmo_buf);
+ int rc = odp_queue_enq(tim->queue,
+ odp_buffer_to_event(tmo_buf));
if (odp_unlikely(rc != 0))
ODP_ABORT("Failed to enqueue timeout buffer (%d)\n",
rc);
@@ -65,14 +65,16 @@ typedef struct {
*/
static void clear_sched_queues(void)
{
+ odp_event_t ev;
odp_buffer_t buf;
while (1) {
- buf = odp_schedule(NULL, ODP_SCHED_NO_WAIT);
+ ev = odp_schedule(NULL, ODP_SCHED_NO_WAIT);
- if (buf == ODP_BUFFER_INVALID)
+ if (ev == ODP_EVENT_INVALID)
break;
+ buf = odp_buffer_from_event(ev);
odp_buffer_free(buf);
}
}
@@ -109,7 +111,7 @@ static int create_queue(int thr, odp_buffer_pool_t msg_pool, int prio)
return -1;
}
- if (odp_queue_enq(queue, buf)) {
+ if (odp_queue_enq(queue, odp_buffer_to_event(buf))) {
LOG_ERR(" [%i] Queue enqueue failed.\n", thr);
return -1;
}
@@ -156,7 +158,7 @@ static int create_queues(int thr, odp_buffer_pool_t msg_pool, int prio)
return -1;
}
- if (odp_queue_enq(queue, buf)) {
+ if (odp_queue_enq(queue, odp_buffer_to_event(buf))) {
LOG_ERR(" [%i] Queue enqueue failed.\n", thr);
return -1;
}
@@ -286,7 +288,7 @@ static int test_poll_queue(int thr, odp_buffer_pool_t msg_pool)
t1 = odp_time_cycles();
for (i = 0; i < QUEUE_ROUNDS; i++) {
- if (odp_queue_enq(queue, buf)) {
+ if (odp_queue_enq(queue, odp_buffer_to_event(buf))) {
LOG_ERR(" [%i] Queue enqueue failed.\n", thr);
return -1;
}
@@ -328,7 +330,7 @@ static int test_schedule_single(const char *str, int thr,
odp_buffer_pool_t msg_pool,
int prio, odp_barrier_t *barrier)
{
- odp_buffer_t buf;
+ odp_event_t ev;
odp_queue_t queue;
uint64_t t1, t2, cycles, ns;
uint32_t i;
@@ -340,9 +342,9 @@ static int test_schedule_single(const char *str, int thr,
t1 = odp_time_cycles();
for (i = 0; i < QUEUE_ROUNDS; i++) {
- buf = odp_schedule(&queue, ODP_SCHED_WAIT);
+ ev = odp_schedule(&queue, ODP_SCHED_WAIT);
- if (odp_queue_enq(queue, buf)) {
+ if (odp_queue_enq(queue, ev)) {
LOG_ERR(" [%i] Queue enqueue failed.\n", thr);
return -1;
}
@@ -354,14 +356,14 @@ static int test_schedule_single(const char *str, int thr,
tot = i;
while (1) {
- buf = odp_schedule(&queue, ODP_SCHED_NO_WAIT);
+ ev = odp_schedule(&queue, ODP_SCHED_NO_WAIT);
- if (buf == ODP_BUFFER_INVALID)
+ if (ev == ODP_EVENT_INVALID)
break;
tot++;
- if (odp_queue_enq(queue, buf)) {
+ if (odp_queue_enq(queue, ev)) {
LOG_ERR(" [%i] Queue enqueue failed.\n", thr);
return -1;
}
@@ -404,7 +406,7 @@ static int test_schedule_many(const char *str, int thr,
odp_buffer_pool_t msg_pool,
int prio, odp_barrier_t *barrier)
{
- odp_buffer_t buf;
+ odp_event_t ev;
odp_queue_t queue;
uint64_t t1 = 0;
uint64_t t2 = 0;
@@ -419,9 +421,9 @@ static int test_schedule_many(const char *str, int thr,
t1 = odp_time_cycles();
for (i = 0; i < QUEUE_ROUNDS; i++) {
- buf = odp_schedule(&queue, ODP_SCHED_WAIT);
+ ev = odp_schedule(&queue, ODP_SCHED_WAIT);
- if (odp_queue_enq(queue, buf)) {
+ if (odp_queue_enq(queue, ev)) {
LOG_ERR(" [%i] Queue enqueue failed.\n", thr);
return -1;
}
@@ -433,14 +435,14 @@ static int test_schedule_many(const char *str, int thr,
tot = i;
while (1) {
- buf = odp_schedule(&queue, ODP_SCHED_NO_WAIT);
+ ev = odp_schedule(&queue, ODP_SCHED_NO_WAIT);
- if (buf == ODP_BUFFER_INVALID)
+ if (ev == ODP_EVENT_INVALID)
break;
tot++;
- if (odp_queue_enq(queue, buf)) {
+ if (odp_queue_enq(queue, ev)) {
LOG_ERR(" [%i] Queue enqueue failed.\n", thr);
return -1;
}
@@ -266,16 +266,19 @@ static odp_packet_t wait_for_packet(odp_queue_t queue,
uint32_t seq, uint64_t ns)
{
uint64_t start, now, diff;
+ odp_event_t ev;
odp_buffer_t buf;
odp_packet_t pkt = ODP_PACKET_INVALID;
start = odp_time_cycles();
do {
- if (queue != ODP_QUEUE_INVALID)
+ if (queue != ODP_QUEUE_INVALID) {
buf = queue_deq_wait_time(queue, ns);
- else
- buf = odp_schedule(NULL, ns);
+ } else {
+ ev = odp_schedule(NULL, ns);
+ buf = odp_buffer_from_event(ev);
+ }
if (buf != ODP_BUFFER_INVALID &&
odp_buffer_type(buf) == ODP_BUFFER_TYPE_PACKET) {
@@ -326,7 +329,8 @@ static void pktio_txrx_multi(pktio_info_t *pktio_a, pktio_info_t *pktio_b,
/* send packet(s) out */
if (num_pkts == 1)
- ret = odp_queue_enq(pktio_a->outq, tx_buf[0]);
+ ret = odp_queue_enq(pktio_a->outq,
+ odp_buffer_to_event(tx_buf[0]));
else
ret = odp_queue_enq_multi(pktio_a->outq, tx_buf, num_pkts);
@@ -68,7 +68,7 @@ static void test_odp_queue_sunnyday(void)
msg_pool = odp_buffer_pool_lookup("msg_pool");
buf = odp_buffer_alloc(msg_pool);
- odp_queue_enq(queue_id, buf);
+ odp_queue_enq(queue_id, odp_buffer_to_event(buf));
CU_ASSERT_EQUAL(buf, odp_queue_deq(queue_id));
odp_buffer_free(buf);
@@ -102,6 +102,7 @@ static void *schedule_common_(void *arg)
odp_barrier_wait(&globals->barrier);
while (1) {
+ odp_event_t ev;
odp_buffer_t buf;
odp_queue_t from;
int num = 0;
@@ -127,7 +128,8 @@ static void *schedule_common_(void *arg)
for (j = 0; j < num; j++)
odp_buffer_free(bufs[j]);
} else {
- buf = odp_schedule(&from, ODP_SCHED_NO_WAIT);
+ ev = odp_schedule(&from, ODP_SCHED_NO_WAIT);
+ buf = odp_buffer_from_event(ev);
if (buf == ODP_BUFFER_INVALID)
continue;
num = 1;
@@ -203,9 +205,11 @@ static void fill_queues(thread_args_t *args)
for (k = 0; k < args->num_bufs; k++) {
odp_buffer_t buf;
+ odp_event_t ev;
buf = odp_buffer_alloc(pool);
CU_ASSERT(buf != ODP_BUFFER_INVALID);
- CU_ASSERT(odp_queue_enq(queue, buf) == 0);
+ ev = odp_buffer_to_event(buf);
+ CU_ASSERT(odp_queue_enq(queue, ev) == 0);
}
}
}
Changed odp_schedule() and odp_queue_enq() to use events instead of buffers. Signed-off-by: Petri Savolainen <petri.savolainen@linaro.org> --- example/generator/odp_generator.c | 8 ++--- example/ipsec/odp_ipsec.c | 10 +++---- example/ipsec/odp_ipsec_stream.c | 2 +- example/l2fwd/odp_l2fwd.c | 8 ++--- example/packet/odp_pktio.c | 8 ++--- example/timer/odp_timer_test.c | 18 ++++++------ platform/linux-generic/include/api/odp_queue.h | 4 +-- platform/linux-generic/include/api/odp_schedule.h | 16 +++++----- platform/linux-generic/odp_crypto.c | 3 +- platform/linux-generic/odp_queue.c | 4 +-- platform/linux-generic/odp_schedule.c | 13 ++++---- platform/linux-generic/odp_timer.c | 3 +- test/performance/odp_scheduling.c | 36 ++++++++++++----------- test/validation/odp_pktio.c | 12 +++++--- test/validation/odp_queue.c | 2 +- test/validation/odp_schedule.c | 8 +++-- 16 files changed, 84 insertions(+), 71 deletions(-)