34 static ENV_LOCAL unsigned int _eo_tbl_iter_idx;
36 static ENV_LOCAL unsigned int _eo_q_iter_idx;
51 if (unlikely(start == NULL || stop == NULL || receive == NULL)) {
53 "Mandatory EO function pointer(s) NULL!");
64 eo_elem = eo_elem_get(eo);
65 if (unlikely(eo_elem == NULL)) {
68 "Invalid EO:%" PRI_EO "", eo);
72 env_spinlock_lock(&eo_elem->
lock);
76 strncpy(eo_elem->name, name,
sizeof(eo_elem->name));
77 eo_elem->name[
sizeof(eo_elem->name) - 1] =
'\0';
79 eo_elem->name[0] =
'\0';
85 eo_elem->
stash = ODP_STASH_INVALID;
94 eo_elem->max_events = 1;
99 eo_elem->
eo_ctx = (
void *)(uintptr_t)eo_ctx;
103 env_spinlock_unlock(&eo_elem->
lock);
110 if (unlikely(!param)) {
112 EM_ESCOPE_EO_MULTIRCV_PARAM_INIT,
113 "Param pointer NULL!");
128 if (unlikely(!param ||
131 "Invalid param ptr:\n"
132 "Use em_eo_multircv_param_init() before create");
138 "Mandatory EO function pointer(s) NULL!");
144 "Max number of events too small:%d",
159 eo_elem = eo_elem_get(eo);
160 if (unlikely(eo_elem == NULL)) {
163 EM_ESCOPE_EO_CREATE_MULTIRCV,
164 "Invalid EO:%" PRI_EO "", eo);
168 env_spinlock_lock(&eo_elem->
lock);
172 strncpy(eo_elem->name, name,
sizeof(eo_elem->name));
173 eo_elem->name[
sizeof(eo_elem->name) - 1] =
'\0';
175 eo_elem->name[0] =
'\0';
181 eo_elem->
stash = ODP_STASH_INVALID;
189 eo_elem->use_multi_rcv =
EM_TRUE;
190 eo_elem->max_events = max_events;
199 env_spinlock_unlock(&eo_elem->
lock);
207 eo_elem_t *
const eo_elem = eo_elem_get(eo);
211 "Invalid EO:%" PRI_EO "!", eo);
215 "EO not allocated:%" PRI_EO "", eo);
220 "EO invalid state, cannot delete:%d", eo_elem->
state);
222 status = eo_delete_queue_all(eo_elem);
225 "EO delete: delete queues failed!");
228 status = eo_free(eo);
230 "EO delete failed!");
238 const eo_elem_t *eo_elem = eo_elem_get(eo);
240 if (name == NULL || maxlen == 0) {
242 "Invalid ptr or maxlen (name=0x%" PRIx64
", maxlen=%zu)",
249 if (unlikely(eo_elem == NULL)) {
251 "Invalid EO%" PRI_EO "", eo);
255 if (unlikely(!eo_allocated(eo_elem))) {
257 "EO not created:%" PRI_EO "", eo);
261 return eo_get_name(eo_elem, name, maxlen);
283 eo_add_queue_escope(em_eo_t eo, em_queue_t queue,
286 {
eo_elem_t *
const eo_elem = eo_elem_get(eo);
307 "Invalid queue type: %" PRI_QTYPE
"", q_type);
312 "Invalid notif cfg given!");
317 "eo_add_queue(Q:%" PRI_QUEUE ") fails", queue);
322 "queue_enable(Q:%" PRI_QUEUE ") fails", queue);
329 "EO:%" PRI_EO " send notif fails", eo);
339 return eo_add_queue_escope(eo, queue, num_notif, notif_tbl,
340 EM_ESCOPE_EO_ADD_QUEUE);
347 return eo_add_queue_escope(eo, queue, 0, NULL,
348 EM_ESCOPE_EO_ADD_QUEUE_SYNC);
355 eo_elem_t *
const eo_elem = eo_elem_get(eo);
376 "Invalid queue type: %" PRI_QTYPE
"", q_type);
380 "Invalid notif cfg given!");
383 "Can't remove Q:%" PRI_QUEUE ", not added to this EO",
405 return eo_remove_queue_local_req(eo_elem, q_elem, num_notif, notif_tbl);
412 eo_elem_t *
const eo_elem = eo_elem_get(eo);
433 EM_ESCOPE_EO_REMOVE_QUEUE_SYNC,
434 "Invalid queue type: %" PRI_QTYPE
"", q_type);
438 "Can't remove Q:%" PRI_QUEUE ", not added to this EO",
452 if (unlikely(ret !=
EM_OK))
453 goto eo_remove_queue_sync_error;
462 ret = eo_remove_queue_sync_local_req(eo_elem, q_elem);
463 if (unlikely(ret !=
EM_OK))
464 goto eo_remove_queue_sync_error;
477 eo_remove_queue_sync_error:
489 eo_elem_t *
const eo_elem = eo_elem_get(eo);
493 EM_ESCOPE_EO_REMOVE_QUEUE_ALL,
494 "Invalid EO:%" PRI_EO "", eo);
496 EM_ESCOPE_EO_REMOVE_QUEUE_ALL,
497 "EO:%" PRI_EO " not created", eo);
500 "Invalid notif cfg given!");
504 "queue_disable_all() failed!");
512 return eo_remove_queue_all_local_req(eo_elem, delete_queues,
513 num_notif, notif_tbl);
520 eo_elem_t *
const eo_elem = eo_elem_get(eo);
524 EM_ESCOPE_EO_REMOVE_QUEUE_ALL_SYNC,
525 "Invalid EO:%" PRI_EO "", eo);
527 EM_ESCOPE_EO_REMOVE_QUEUE_ALL_SYNC,
528 "EO:%" PRI_EO " not created", eo);
534 if (unlikely(ret !=
EM_OK))
535 goto eo_remove_queue_all_sync_error;
543 ret = eo_remove_queue_all_sync_local_req(eo_elem, delete_queues);
544 if (unlikely(ret !=
EM_OK))
545 goto eo_remove_queue_all_sync_error;
558 eo_remove_queue_all_sync_error:
562 "Failure: EO:%" PRI_EO "", eo);
568 eo_elem_t *
const eo_elem = eo_elem_get(eo);
572 "Invalid args: EO:%" PRI_EO " handler:%p", eo, handler);
575 "EO:%" PRI_EO " not created", eo);
577 env_spinlock_lock(&eo_elem->
lock);
579 env_spinlock_unlock(&eo_elem->
lock);
587 eo_elem_t *
const eo_elem = eo_elem_get(eo);
590 EM_ESCOPE_EO_UNREGISTER_ERROR_HANDLER,
591 "Invalid EO id %" PRI_EO "", eo);
593 EM_ESCOPE_EO_UNREGISTER_ERROR_HANDLER,
594 "EO not created:%" PRI_EO "", eo);
596 env_spinlock_lock(&eo_elem->
lock);
598 env_spinlock_unlock(&eo_elem->
lock);
608 eo_elem_t *
const eo_elem = eo_elem_get(eo);
614 "Invalid EO id %" PRI_EO "", eo);
617 "EO not created:%" PRI_EO "", eo);
620 "EO invalid state, cannot start:%d", eo_elem->
state);
623 "Invalid notif cfg given!");
629 if (unlikely(eo_elem->
stash == ODP_STASH_INVALID)) {
631 "EO:%" PRI_EO " start stash creation fails", eo);
642 memset(&tmp_q_elem, 0,
sizeof(tmp_q_elem));
643 tmp_q_elem.
eo = (uint16_t)(uintptr_t)eo;
656 if (unlikely(ret !=
EM_OK)) {
658 "EO:%" PRI_EO " start func fails:0x%08x",
670 ret = eo_start_local_req(eo_elem, num_notif, notif_tbl);
672 if (unlikely(ret !=
EM_OK)) {
674 "EO:%" PRI_EO " local start func fails",
694 if (unlikely(ret !=
EM_OK))
706 if (unlikely(ret !=
EM_OK)) {
708 "EO:%" PRI_EO " send notif fails",
728 eo_elem_t *
const eo_elem = eo_elem_get(eo);
734 "Invalid EO id %" PRI_EO "", eo);
737 "EO not created:%" PRI_EO "", eo);
740 "EO invalid state, cannot start:%d", eo_elem->
state);
746 if (unlikely(eo_elem->
stash == ODP_STASH_INVALID)) {
748 "EO:%" PRI_EO " start stash creation fails", eo);
761 memset(&tmp_q_elem, 0,
sizeof(tmp_q_elem));
762 tmp_q_elem.
eo = (uint16_t)(uintptr_t)eo;
774 if (unlikely(ret !=
EM_OK)) {
776 "EO:%" PRI_EO " start func fails:0x%08x",
798 if (unlikely(ret !=
EM_OK)) {
800 "EO:%" PRI_EO " local start func fails", eo);
802 goto eo_start_sync_error;
805 ret = eo_start_sync_local_req(eo_elem);
806 if (unlikely(ret !=
EM_OK)) {
808 "EO:%" PRI_EO " eo_start_sync_local_req", eo);
810 goto eo_start_sync_error;
837 if (unlikely(ret !=
EM_OK))
838 goto eo_start_sync_error;
856 eo_elem_t *
const eo_elem = eo_elem_get(eo);
861 "Invalid EO:%" PRI_EO "", eo);
864 "EO invalid state, cannot stop:%d", eo_elem->
state);
867 "Invalid notif cfg given!");
883 ret = eo_stop_local_req(eo_elem, num_notif, notif_tbl);
885 if (unlikely(ret !=
EM_OK)) {
888 "EO:%" PRI_EO " local stop func fails", eo);
900 eo_elem_t *
const eo_elem = eo_elem_get(eo);
907 "Invalid EO:%" PRI_EO "", eo);
910 "EO invalid state, cannot stop:%d", eo_elem->
state);
922 if (unlikely(ret !=
EM_OK))
923 goto eo_stop_sync_error;
931 memset(&tmp_q_elem, 0,
sizeof(tmp_q_elem));
932 tmp_q_elem.
eo = (uint16_t)(uintptr_t)eo;
940 if (unlikely(ret !=
EM_OK))
941 goto eo_stop_sync_error;
950 ret = eo_stop_sync_local_req(eo_elem);
952 if (unlikely(ret !=
EM_OK)) {
955 "EO:%" PRI_EO " local stop func fails", eo);
957 goto eo_stop_sync_error;
982 "EO:%" PRI_EO " stop-func failed", eo);
992 "Failure: EO:%" PRI_EO "", eo);
1004 const eo_elem_t *eo_elem = eo_elem_get(eo);
1009 "Invalid EO:%" PRI_EO "", eo);
1015 "EO:%" PRI_EO " not created!", eo);
1019 eo_state = eo_elem->
state;
1022 "Invalid EO state: EO:%" PRI_EO " state:%d",
1033 const eo_elem_t *eo_elem = eo_elem_get(eo);
1037 "Invalid EO:%" PRI_EO "", eo);
1043 "EO:%" PRI_EO " not created", eo);
1047 return eo_elem->
state;
1053 _eo_tbl_iter_idx = 0;
1054 const unsigned int eo_cnt = eo_count();
1065 while (!eo_allocated(&
em_shm->eo_tbl.eo_elem[_eo_tbl_iter_idx])) {
1071 return eo_idx2hdl(_eo_tbl_iter_idx);
1083 while (!eo_allocated(&
em_shm->eo_tbl.eo_elem[_eo_tbl_iter_idx])) {
1089 return eo_idx2hdl(_eo_tbl_iter_idx);
1095 const eo_elem_t *eo_elem = eo_elem_get(eo);
1096 const unsigned int max_queues =
em_shm->opt.queue.max_num;
1098 if (unlikely(eo_elem == NULL || !eo_allocated(eo_elem))) {
1100 "Invalid EO:%" PRI_EO "", eo);
1106 const unsigned int num_queues = env_atomic32_get(&eo_elem->
num_queues);
1111 if (num_queues == 0) {
1112 _eo_q_iter_idx = max_queues;
1129 while (!queue_allocated(&queue_tbl->queue_elem[_eo_q_iter_idx]) ||
1130 queue_tbl->queue_elem[_eo_q_iter_idx].eo != (uint16_t)(uintptr_t)_eo_q_iter_eo) {
1132 if (_eo_q_iter_idx >= max_queues)
1136 return queue_idx2hdl(_eo_q_iter_idx);
1142 const unsigned int max_queues =
em_shm->opt.queue.max_num;
1144 if (_eo_q_iter_idx >= max_queues - 1)
1152 while (!queue_allocated(&queue_tbl->queue_elem[_eo_q_iter_idx]) ||
1153 queue_tbl->queue_elem[_eo_q_iter_idx].eo != (uint16_t)(uintptr_t)_eo_q_iter_eo) {
1155 if (_eo_q_iter_idx >= max_queues)
1159 return queue_idx2hdl(_eo_q_iter_idx);
1164 return (uint64_t)eo;