Changed odp_schedule_multi() and odp_queue_enq_multi() to
use events instead of buffers.

Signed-off-by: Petri Savolainen <petri.savolai...@linaro.org>
---
 platform/linux-generic/include/api/odp_queue.h    |  8 ++++----
 platform/linux-generic/include/api/odp_schedule.h | 16 ++++++++--------
 platform/linux-generic/odp_queue.c                |  4 ++--
 platform/linux-generic/odp_schedule.c             |  4 ++--
 test/performance/odp_scheduling.c                 | 22 +++++++++++++---------
 test/validation/odp_pktio.c                       |  8 ++++----
 test/validation/odp_queue.c                       | 16 ++++++++++------
 test/validation/odp_schedule.c                    | 12 +++++++-----
 8 files changed, 50 insertions(+), 40 deletions(-)

diff --git a/platform/linux-generic/include/api/odp_queue.h 
b/platform/linux-generic/include/api/odp_queue.h
index 3caa7c1..61afd36 100644
--- a/platform/linux-generic/include/api/odp_queue.h
+++ b/platform/linux-generic/include/api/odp_queue.h
@@ -181,15 +181,15 @@ void *odp_queue_get_context(odp_queue_t queue);
 int odp_queue_enq(odp_queue_t queue, odp_event_t ev);
 
 /**
- * Enqueue multiple buffers to a queue
+ * Enqueue multiple events to a queue
  *
  * @param queue   Queue handle
- * @param buf     Buffer handles
- * @param num     Number of buffer handles
+ * @param ev      Event handles
+ * @param num     Number of event handles
  *
  * @return 0 if succesful
  */
-int odp_queue_enq_multi(odp_queue_t queue, odp_buffer_t buf[], int num);
+int odp_queue_enq_multi(odp_queue_t queue, odp_event_t ev[], int num);
 
 /**
  * Queue dequeue
diff --git a/platform/linux-generic/include/api/odp_schedule.h 
b/platform/linux-generic/include/api/odp_schedule.h
index 45fa48c..688a6db 100644
--- a/platform/linux-generic/include/api/odp_schedule.h
+++ b/platform/linux-generic/include/api/odp_schedule.h
@@ -64,22 +64,22 @@ uint64_t odp_schedule_wait_time(uint64_t ns);
 odp_event_t odp_schedule(odp_queue_t *from, uint64_t wait);
 
 /**
- * Schedule multiple buffers
+ * Schedule multiple events
  *
- * Like odp_schedule(), but returns multiple buffers from a queue.
+ * Like odp_schedule(), but returns multiple events from a queue.
  *
- * @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.
- * @param out_buf Buffer array for output
- * @param num     Maximum number of buffers to output
+ * @param events  Event array for output
+ * @param num     Maximum number of events to output
  *
- * @return Number of buffers outputed (0 ... num)
+ * @return Number of events outputed (0 ... num)
  */
-int odp_schedule_multi(odp_queue_t *from, uint64_t wait, odp_buffer_t 
out_buf[],
+int odp_schedule_multi(odp_queue_t *from, uint64_t wait, odp_event_t events[],
                       unsigned int num);
 
 /**
diff --git a/platform/linux-generic/odp_queue.c 
b/platform/linux-generic/odp_queue.c
index c027f23..f3046e2 100644
--- a/platform/linux-generic/odp_queue.c
+++ b/platform/linux-generic/odp_queue.c
@@ -385,7 +385,7 @@ int queue_enq_multi_dummy(queue_entry_t *queue ODP_UNUSED,
        return -1;
 }
 
-int odp_queue_enq_multi(odp_queue_t handle, odp_buffer_t buf[], int num)
+int odp_queue_enq_multi(odp_queue_t handle, odp_event_t ev[], int num)
 {
        odp_buffer_hdr_t *buf_hdr[QUEUE_MULTI_MAX];
        queue_entry_t *queue;
@@ -397,7 +397,7 @@ int odp_queue_enq_multi(odp_queue_t handle, odp_buffer_t 
buf[], int num)
        queue = queue_to_qentry(handle);
 
        for (i = 0; i < num; i++)
-               buf_hdr[i] = odp_buf_to_hdr(buf[i]);
+               buf_hdr[i] = odp_buf_to_hdr(odp_buffer_from_event(ev[i]));
 
        return queue->s.enqueue_multi(queue, buf_hdr, num);
 }
diff --git a/platform/linux-generic/odp_schedule.c 
b/platform/linux-generic/odp_schedule.c
index 7b25e8a..1e54fd2 100644
--- a/platform/linux-generic/odp_schedule.c
+++ b/platform/linux-generic/odp_schedule.c
@@ -380,9 +380,9 @@ odp_event_t odp_schedule(odp_queue_t *out_queue, uint64_t 
wait)
 
 
 int odp_schedule_multi(odp_queue_t *out_queue, uint64_t wait,
-                      odp_buffer_t out_buf[], unsigned int num)
+                      odp_event_t events[], unsigned int num)
 {
-       return schedule_loop(out_queue, wait, out_buf, num, MAX_DEQ);
+       return schedule_loop(out_queue, wait, (odp_buffer_t *)events, num, 
MAX_DEQ);
 }
 
 
diff --git a/test/performance/odp_scheduling.c 
b/test/performance/odp_scheduling.c
index 09f5db1..7a48eed 100644
--- a/test/performance/odp_scheduling.c
+++ b/test/performance/odp_scheduling.c
@@ -481,7 +481,7 @@ static int test_schedule_multi(const char *str, int thr,
                               odp_buffer_pool_t msg_pool,
                               int prio, odp_barrier_t *barrier)
 {
-       odp_buffer_t buf[MULTI_BUFS_MAX];
+       odp_event_t ev[MULTI_BUFS_MAX];
        odp_queue_t queue;
        uint64_t t1 = 0;
        uint64_t t2 = 0;
@@ -508,16 +508,20 @@ static int test_schedule_multi(const char *str, int thr,
                }
 
                for (j = 0; j < MULTI_BUFS_MAX; j++) {
-                       buf[j] = odp_buffer_alloc(msg_pool);
+                       odp_buffer_t buf;
 
-                       if (!odp_buffer_is_valid(buf[j])) {
+                       buf = odp_buffer_alloc(msg_pool);
+
+                       if (!odp_buffer_is_valid(buf)) {
                                LOG_ERR("  [%i] msg_pool alloc failed\n",
                                        thr);
                                return -1;
                        }
+
+                       ev[j] = odp_buffer_to_event(buf);
                }
 
-               if (odp_queue_enq_multi(queue, buf, MULTI_BUFS_MAX)) {
+               if (odp_queue_enq_multi(queue, ev, MULTI_BUFS_MAX)) {
                        LOG_ERR("  [%i] Queue enqueue failed.\n", thr);
                        return -1;
                }
@@ -527,22 +531,22 @@ static int test_schedule_multi(const char *str, int thr,
        t1 = odp_time_cycles();
 
        for (i = 0; i < QUEUE_ROUNDS; i++) {
-               num = odp_schedule_multi(&queue, ODP_SCHED_WAIT, buf,
+               num = odp_schedule_multi(&queue, ODP_SCHED_WAIT, ev,
                                         MULTI_BUFS_MAX);
 
                tot += num;
 
-               if (odp_queue_enq_multi(queue, buf, num)) {
+               if (odp_queue_enq_multi(queue, ev, num)) {
                        LOG_ERR("  [%i] Queue enqueue failed.\n", thr);
                        return -1;
                }
        }
 
-       /* Clear possible locally stored buffers */
+       /* Clear possible locally stored events */
        odp_schedule_pause();
 
        while (1) {
-               num = odp_schedule_multi(&queue, ODP_SCHED_NO_WAIT, buf,
+               num = odp_schedule_multi(&queue, ODP_SCHED_NO_WAIT, ev,
                                         MULTI_BUFS_MAX);
 
                if (num == 0)
@@ -550,7 +554,7 @@ static int test_schedule_multi(const char *str, int thr,
 
                tot += num;
 
-               if (odp_queue_enq_multi(queue, buf, num)) {
+               if (odp_queue_enq_multi(queue, ev, num)) {
                        LOG_ERR("  [%i] Queue enqueue failed.\n", thr);
                        return -1;
                }
diff --git a/test/validation/odp_pktio.c b/test/validation/odp_pktio.c
index b404a14..16e85fa 100644
--- a/test/validation/odp_pktio.c
+++ b/test/validation/odp_pktio.c
@@ -300,7 +300,7 @@ static void pktio_txrx_multi(pktio_info_t *pktio_a, 
pktio_info_t *pktio_b,
                             int num_pkts)
 {
        odp_packet_t tx_pkt[num_pkts];
-       odp_buffer_t tx_buf[num_pkts];
+       odp_event_t tx_ev[num_pkts];
        odp_packet_t rx_pkt;
        uint32_t tx_seq[num_pkts];
        int i, ret;
@@ -319,7 +319,7 @@ static void pktio_txrx_multi(pktio_info_t *pktio_a, 
pktio_info_t *pktio_b,
                if (pktio_fixup_checksums(tx_pkt[i]) != 0)
                        break;
 
-               tx_buf[i] = odp_packet_to_buffer(tx_pkt[i]);
+               tx_ev[i] = odp_packet_to_event(tx_pkt[i]);
        }
 
        if (i != num_pkts) {
@@ -329,9 +329,9 @@ 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, 
odp_buffer_to_event(tx_buf[0]));
+               ret = odp_queue_enq(pktio_a->outq, tx_ev[0]);
        else
-               ret = odp_queue_enq_multi(pktio_a->outq, tx_buf, num_pkts);
+               ret = odp_queue_enq_multi(pktio_a->outq, tx_ev, num_pkts);
 
        if (ret != 0) {
                CU_FAIL("failed to enqueue test packets");
diff --git a/test/validation/odp_queue.c b/test/validation/odp_queue.c
index a083c26..7c5e8dd 100644
--- a/test/validation/odp_queue.c
+++ b/test/validation/odp_queue.c
@@ -35,7 +35,8 @@ static int init_queue_suite(void)
 static void test_odp_queue_sunnyday(void)
 {
        odp_queue_t queue_creat_id, queue_id;
-       odp_buffer_t enbuf[MAX_BUFFER_QUEUE], debuf[MAX_BUFFER_QUEUE];
+       odp_event_t enev[MAX_BUFFER_QUEUE];
+       odp_buffer_t debuf[MAX_BUFFER_QUEUE];
        odp_buffer_t buf;
        odp_buffer_pool_t msg_pool;
        odp_queue_param_t param;
@@ -72,14 +73,16 @@ static void test_odp_queue_sunnyday(void)
        CU_ASSERT_EQUAL(buf, odp_queue_deq(queue_id));
        odp_buffer_free(buf);
 
-       for (i = 0; i < MAX_BUFFER_QUEUE; i++)
-               enbuf[i] = odp_buffer_alloc(msg_pool);
+       for (i = 0; i < MAX_BUFFER_QUEUE; i++) {
+               odp_buffer_t buf = odp_buffer_alloc(msg_pool);
+               enev[i] = odp_buffer_to_event(buf);
+       }
 
        /*
         * odp_queue_enq_multi may return 0..n buffers due to the resource
         * constraints in the implementation at that given point of time.
         */
-       ret = odp_queue_enq_multi(queue_id, enbuf, MAX_BUFFER_QUEUE);
+       ret = odp_queue_enq_multi(queue_id, enev, MAX_BUFFER_QUEUE);
        CU_ASSERT(0 == ret);
        pbuf_tmp = debuf;
        do {
@@ -92,8 +95,9 @@ static void test_odp_queue_sunnyday(void)
        } while (nr_deq_entries < MAX_BUFFER_QUEUE);
 
        for (i = 0; i < MAX_BUFFER_QUEUE; i++) {
-               CU_ASSERT_EQUAL(enbuf[i], debuf[i]);
-               odp_buffer_free(enbuf[i]);
+               odp_buffer_t enbuf = odp_buffer_from_event(enev[i]);
+               CU_ASSERT_EQUAL(enbuf, debuf[i]);
+               odp_buffer_free(enbuf);
        }
 
        return;
diff --git a/test/validation/odp_schedule.c b/test/validation/odp_schedule.c
index 8f33f69..74f9b6f 100644
--- a/test/validation/odp_schedule.c
+++ b/test/validation/odp_schedule.c
@@ -117,16 +117,18 @@ static void *schedule_common_(void *arg)
                odp_ticketlock_unlock(&globals->count_lock);
 
                if (args->enable_schd_multi) {
-                       odp_buffer_t bufs[BURST_BUF_SIZE];
+                       odp_event_t events[BURST_BUF_SIZE];
                        int j;
-                       num = odp_schedule_multi(&from, ODP_SCHED_NO_WAIT, bufs,
-                                                BURST_BUF_SIZE);
+                       num = odp_schedule_multi(&from, ODP_SCHED_NO_WAIT,
+                                                events, BURST_BUF_SIZE);
                        CU_ASSERT(num >= 0);
                        CU_ASSERT(num <= BURST_BUF_SIZE);
                        if (num == 0)
                                continue;
-                       for (j = 0; j < num; j++)
-                               odp_buffer_free(bufs[j]);
+                       for (j = 0; j < num; j++) {
+                               buf = odp_buffer_from_event(events[j]);
+                               odp_buffer_free(buf);
+                       }
                } else {
                        ev  = odp_schedule(&from, ODP_SCHED_NO_WAIT);
                        buf = odp_buffer_from_event(ev);
-- 
2.2.2


_______________________________________________
lng-odp mailing list
lng-odp@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/lng-odp

Reply via email to