@@ -28,11 +28,6 @@ static inline odp_buffer_t buf_from_buf_hdr(odp_buffer_hdr_t *hdr)
return (odp_buffer_t)hdr;
}
-static inline odp_event_t event_from_buf_hdr(odp_buffer_hdr_t *hdr)
-{
- return (odp_event_t)hdr;
-}
-
#ifdef __cplusplus
}
#endif
@@ -422,43 +422,34 @@ static int queue_int_enq(queue_t q_int, odp_buffer_hdr_t *buf_hdr)
static int queue_enq_multi(odp_queue_t handle, const odp_event_t ev[], int num)
{
- odp_buffer_hdr_t *buf_hdr[QUEUE_MULTI_MAX];
- queue_entry_t *queue;
- int i;
+ queue_entry_t *queue = handle_to_qentry(handle);
+
+ if (odp_unlikely(num == 0))
+ return 0;
if (num > QUEUE_MULTI_MAX)
num = QUEUE_MULTI_MAX;
- queue = handle_to_qentry(handle);
-
- for (i = 0; i < num; i++)
- buf_hdr[i] = buf_hdl_to_hdr(odp_buffer_from_event(ev[i]));
-
- return num == 0 ? 0 : queue->s.enqueue_multi(qentry_to_int(queue),
- buf_hdr, num);
+ return queue->s.enqueue_multi(qentry_to_int(queue),
+ (odp_buffer_hdr_t **)(uintptr_t)ev, num);
}
static int queue_enq(odp_queue_t handle, odp_event_t ev)
{
- odp_buffer_hdr_t *buf_hdr;
- queue_entry_t *queue;
-
- queue = handle_to_qentry(handle);
- buf_hdr = buf_hdl_to_hdr(odp_buffer_from_event(ev));
+ queue_entry_t *queue = handle_to_qentry(handle);
- return queue->s.enqueue(qentry_to_int(queue), buf_hdr);
+ return queue->s.enqueue(qentry_to_int(queue),
+ (odp_buffer_hdr_t *)(uintptr_t)ev);
}
-static inline int deq_multi(queue_t q_int, odp_buffer_hdr_t *buf_hdr[],
+static inline int deq_multi(queue_entry_t *queue, odp_buffer_hdr_t *buf_hdr[],
int num)
{
odp_buffer_hdr_t *hdr, *next;
int i, j;
- queue_entry_t *queue;
int updated = 0;
int status_sync = sched_fn->status_sync;
- queue = qentry_from_int(q_int);
LOCK(&queue->s.lock);
if (odp_unlikely(queue->s.status < QUEUE_STATUS_READY)) {
/* Bad queue, or queue has been destroyed.
@@ -529,15 +520,18 @@ static inline int deq_multi(queue_t q_int, odp_buffer_hdr_t *buf_hdr[],
static int queue_int_deq_multi(queue_t q_int, odp_buffer_hdr_t *buf_hdr[],
int num)
{
- return deq_multi(q_int, buf_hdr, num);
+ queue_entry_t *queue = qentry_from_int(q_int);
+
+ return deq_multi(queue, buf_hdr, num);
}
static odp_buffer_hdr_t *queue_int_deq(queue_t q_int)
{
+ queue_entry_t *queue = qentry_from_int(q_int);
odp_buffer_hdr_t *buf_hdr = NULL;
int ret;
- ret = deq_multi(q_int, &buf_hdr, 1);
+ ret = deq_multi(queue, &buf_hdr, 1);
if (ret == 1)
return buf_hdr;
@@ -545,38 +539,22 @@ static odp_buffer_hdr_t *queue_int_deq(queue_t q_int)
return NULL;
}
-static int queue_deq_multi(odp_queue_t handle, odp_event_t events[], int num)
+static int queue_deq_multi(odp_queue_t handle, odp_event_t ev[], int num)
{
- queue_entry_t *queue;
- odp_buffer_hdr_t *buf_hdr[QUEUE_MULTI_MAX];
- int i, ret;
+ queue_entry_t *queue = handle_to_qentry(handle);
if (num > QUEUE_MULTI_MAX)
num = QUEUE_MULTI_MAX;
- queue = handle_to_qentry(handle);
-
- ret = queue->s.dequeue_multi(qentry_to_int(queue), buf_hdr, num);
-
- for (i = 0; i < ret; i++)
- events[i] = event_from_buf_hdr(buf_hdr[i]);
-
- return ret;
+ return queue->s.dequeue_multi(qentry_to_int(queue),
+ (odp_buffer_hdr_t **)ev, num);
}
-
static odp_event_t queue_deq(odp_queue_t handle)
{
- queue_entry_t *queue;
- odp_buffer_hdr_t *buf_hdr;
-
- queue = handle_to_qentry(handle);
- buf_hdr = queue->s.dequeue(qentry_to_int(queue));
-
- if (buf_hdr)
- return event_from_buf_hdr(buf_hdr);
+ queue_entry_t *queue = handle_to_qentry(handle);
- return ODP_EVENT_INVALID;
+ return (odp_event_t)queue->s.dequeue(qentry_to_int(queue));
}
static int queue_init(queue_entry_t *queue, const char *name,
@@ -678,17 +656,9 @@ odp_queue_t sched_cb_queue_handle(uint32_t queue_index)
int sched_cb_queue_deq_multi(uint32_t queue_index, odp_event_t ev[], int num)
{
- int i, ret;
queue_entry_t *qe = get_qentry(queue_index);
- odp_buffer_hdr_t *buf_hdr[num];
- ret = deq_multi(qentry_to_int(qe), buf_hdr, num);
-
- if (ret > 0)
- for (i = 0; i < ret; i++)
- ev[i] = event_from_buf_hdr(buf_hdr[i]);
-
- return ret;
+ return deq_multi(qe, (odp_buffer_hdr_t **)ev, num);
}
int sched_cb_queue_empty(uint32_t queue_index)
Conversions are not needed as event handles are buffer header pointers. Signed-off-by: Petri Savolainen <petri.savolainen@linaro.org> --- .../linux-generic/include/odp_buffer_inlines.h | 5 -- platform/linux-generic/odp_queue.c | 74 +++++++--------------- 2 files changed, 22 insertions(+), 57 deletions(-) -- 2.13.0