46 "queue_elem ptr NULL!");
47 return ODP_QUEUE_INVALID;
55 const queue_elem_t *queue_elem = odp_queue_context(queue);
59 unlikely(!queue_elem || queue_elem->
valid_check != QUEUE_ELEM_VALID))
62 return (em_queue_t)(uintptr_t)queue_elem->
queue;
73 static em_queue_t pktin_event_queue2em(odp_queue_t odp_queue)
76 const char *err_str =
"";
77 odp_queue_info_t odp_qinfo;
80 if (unlikely(odp_queue == ODP_QUEUE_INVALID)) {
82 "Bad arg: ODP queue invalid!");
92 ret = odp_queue_info(odp_queue, &odp_qinfo);
93 if (unlikely(ret || odp_qinfo.param.type != ODP_QUEUE_TYPE_SCHED)) {
94 err_str =
"odp_queue_info(): unsuitable odp queue";
101 odp_schedule_prio_t odp_prio = odp_schedule_default_prio();
105 for (
int i = 0; i < num_prio; i++) {
106 prio_em2odp(i, &odp_prio);
107 if (odp_prio == odp_qinfo.param.sched.prio) {
113 err_str =
"Can't convert ODP qprio to EM qprio";
122 ret = scheduled_queue_type_odp2em(odp_qinfo.param.sched.sync,
125 err_str =
"Can't convert ODP qtype to EM qtype";
132 em_queue_group_t queue_group;
137 qgrp_elem = queue_group_elem_get(queue_group);
144 err_str =
"No matching EM Queue Group found";
151 char q_name[ODP_QUEUE_NAME_LEN];
153 snprintf(q_name,
sizeof(q_name),
"EM:%s", odp_qinfo.name);
154 q_name[ODP_QUEUE_NAME_LEN - 1] =
'\0';
163 .queue_group = queue_group,
172 if (unlikely(!q_elem)) {
173 err_str =
"Queue elem NULL!";
196 ret = odp_queue_context_set(odp_queue, q_elem,
sizeof(*q_elem));
198 err_str =
"odp_queue_context_set() failed";
206 "%s (ret=%d)", err_str, ret);
208 odp_queue_print(odp_queue);
215 em_queue_t queues[],
int num)
219 for (i = 0; i < num; i++) {
220 queues[i] = pktin_event_queue2em(odp_pktin_event_queues[i]);
223 "Cannot create EM-Q using pktin-queue:%d (hdl:%" PRIu64
")",
224 i, odp_queue_to_u64(odp_pktin_event_queues[i]));
239 return event_em2odp(event);
243 odp_event_t odp_events[],
int num)
245 if (unlikely(num <= 0))
248 events_em2odp(events, odp_events, num);
253 em_event_t
event = event_init_odp(odp_event,
false, NULL);
259 em_event_t events[],
int num)
261 if (unlikely(num <= 0))
266 event_init_odp_multi(odp_events, events, ev_hdrs, num,
275 unlikely(!pool_elem || !odp_pools || num <= 0)) {
277 "Inv.args: pool:%" PRI_POOL " odp_pools:%p num:%d",
278 pool, odp_pools, num);
283 "Pool:%" PRI_POOL " not created", pool);
287 for (
int i = 0; i < num_subpools; i++)
288 odp_pools[i] = pool_elem->
odp_pool[i];
296 if (
EM_CHECK_LEVEL > 0 && unlikely(odp_pool == ODP_POOL_INVALID)) {
298 "Inv.arg: odp_pool invalid");
302 return pool_odp2em(odp_pool);
306 pkt_enqueue_scheduled(
const odp_packet_t pkt_tbl[],
int num,
309 odp_event_t odp_event_tbl[num];
311 odp_packet_to_event_multi(pkt_tbl, odp_event_tbl, num);
317 int sent = odp_queue_enq_multi(q_elem->
odp_queue,
319 if (unlikely(sent < num)) {
320 sent = unlikely(sent < 0) ? 0 : sent;
321 odp_packet_free_multi(&pkt_tbl[sent], num - sent);
332 pkt_enqueue_local(
const odp_packet_t pkt_tbl[],
int num,
335 odp_event_t odp_event_tbl[num];
336 em_event_t event_tbl[num];
338 odp_packet_to_event_multi(pkt_tbl, odp_event_tbl, num);
340 events_odp2em(odp_event_tbl, event_tbl, num);
346 int sent = send_local_multi(event_tbl, num, q_elem);
348 if (unlikely(sent < num)) {
349 sent = unlikely(sent < 0) ? 0 : sent;
350 odp_packet_free_multi(&pkt_tbl[sent], num - sent);
361 pkt_enqueue_chaining_out(
const odp_packet_t pkt_tbl[],
int num,
364 odp_event_t odp_event_tbl[num];
365 em_event_t event_tbl[num];
369 odp_packet_to_event_multi(pkt_tbl, odp_event_tbl, num);
371 events_odp2em(odp_event_tbl, event_tbl, num);
374 event_init_pkt_multi(pkt_tbl, event_tbl,
375 evhdr_tbl, num,
true );
378 if (likely(queue_external(queue)))
379 sent = send_chaining_multi(event_tbl, num, queue);
381 if (unlikely(sent < num)) {
382 sent = unlikely(sent < 0) ? 0 : sent;
390 pkt_enqueue_unscheduled(
const odp_packet_t pkt_tbl[],
int num,
393 odp_event_t odp_event_tbl[num];
394 em_event_t event_tbl[num];
397 odp_packet_to_event_multi(pkt_tbl, odp_event_tbl, num);
399 events_odp2em(odp_event_tbl, event_tbl, num);
402 event_init_pkt_multi(pkt_tbl, event_tbl,
403 evhdr_tbl, num,
true );
406 int sent = odp_queue_enq_multi(q_elem->
odp_queue, odp_event_tbl, num);
408 if (unlikely(sent < num)) {
409 sent = unlikely(sent < 0) ? 0 : sent;
417 pkt_enqueue_output(
const odp_packet_t pkt_tbl[],
int num,
420 odp_event_t odp_event_tbl[num];
421 em_event_t event_tbl[num];
424 odp_packet_to_event_multi(pkt_tbl, odp_event_tbl, num);
426 events_odp2em(odp_event_tbl, event_tbl, num);
429 event_init_pkt_multi(pkt_tbl, event_tbl,
430 evhdr_tbl, num,
true );
433 int sent = send_output_multi(event_tbl, num, q_elem);
435 if (unlikely(sent < num)) {
436 sent = unlikely(sent < 0) ? 0 : sent;
445 if (unlikely(!pkt_tbl || num <= 0))
452 return pkt_enqueue_chaining_out(pkt_tbl, num, queue);
455 return pkt_enqueue_scheduled(pkt_tbl, num, q_elem);
458 return pkt_enqueue_local(pkt_tbl, num, q_elem);
461 return pkt_enqueue_unscheduled(pkt_tbl, num, q_elem);
464 return pkt_enqueue_output(pkt_tbl, num, q_elem);
467 odp_packet_free_multi(pkt_tbl, num);
478 queue_group_elem_get(queue_group);
482 "Invalid queue group:%" PRI_QGRP "", queue_group);
483 return ODP_SCHED_GROUP_INVALID;
485 if (unlikely(
EM_CHECK_LEVEL >= 2 && !queue_group_allocated(qgrp_elem))) {
487 "Queue group:%" PRI_QGRP " not created", queue_group);
488 return ODP_SCHED_GROUP_INVALID;
496 unsigned int i = ((
unsigned int)((uintptr_t)(tmr) - 1));
499 return ODP_TIMER_POOL_INVALID;
503 return tmrs->timer[i].odp_tmr_pool;
509 return ODP_TIMER_INVALID;
511 return tmo->odp_timer;