34 static ENV_LOCAL unsigned int _agrp_tbl_iter_idx;
36 static ENV_LOCAL unsigned int _agrp_q_iter_idx;
37 static ENV_LOCAL em_atomic_group_t _agrp_q_iter_agrp;
44 const char *err_str =
"";
48 if (unlikely(invalid_qgrp(queue_group))) {
50 err_str =
"Invalid queue group!";
59 err_str =
"Atomic group allocation failed!";
64 ag_elem = atomic_group_elem_get(atomic_group);
65 if (unlikely(!ag_elem)) {
68 err_str =
"Atomic group allocation failed: ag_elem NULL!";
78 strncpy(ag_elem->
name, name,
sizeof(ag_elem->
name));
79 ag_elem->
name[
sizeof(ag_elem->
name) - 1] =
'\0';
81 ag_elem->
name[0] =
'\0';
87 unsigned int num_obj = 0;
88 odp_stash_capability_t stash_capa;
89 odp_stash_param_t stash_param;
91 ret = odp_stash_capability(&stash_capa, ODP_STASH_TYPE_FIFO);
94 err_str =
"odp_stash_capability() failed!";
98 odp_stash_param_init(&stash_param);
100 stash_param.type = ODP_STASH_TYPE_FIFO;
101 stash_param.put_mode = ODP_STASH_OP_MT;
103 stash_param.get_mode = ODP_STASH_OP_ST;
106 num_obj =
em_shm->opt.queue.min_events_default;
108 stash_param.num_obj = num_obj;
111 stash_param.obj_size =
sizeof(uint64_t);
112 if (stash_param.num_obj > stash_capa.max_num.u64) {
114 "%s(): req stash.num_obj(%" PRIu64
") > capa.max_num.u64(%" PRIu64
").\n"
115 " ==> using max value:%" PRIu64
"\n", __func__,
116 stash_param.num_obj, stash_capa.max_num.u64, stash_capa.max_num.u64);
117 stash_param.num_obj = stash_capa.max_num.u64;
120 stash_param.cache_size = 0;
127 err_str =
"odp_stash_create() failed!";
146 ag_stash_destroy(odp_stash_t stash)
153 bool esv_ena = esv_enabled();
155 if (stash == ODP_STASH_INVALID)
159 cnt = odp_stash_get_u64(stash, &entry_tbl[0].u64 ,
163 for (int32_t i = 0; i < cnt; i++)
164 odp_evtbl[i] = (odp_event_t)(uintptr_t)entry_tbl[i].evptr;
166 events_odp2em(odp_evtbl, ev_tbl, cnt);
169 event_to_hdr_multi(ev_tbl, ev_hdr_tbl, cnt);
171 cnt, EVSTATE__AG_DELETE);
177 return odp_stash_destroy(stash);
184 atomic_group_elem_get(atomic_group);
190 "Invalid atomic group - cannot delete!");
192 env_spinlock_lock(&ag_elem->lock);
196 err |= !atomic_group_allocated(ag_elem);
199 env_spinlock_unlock(&ag_elem->lock);
201 EM_ESCOPE_ATOMIC_GROUP_DELETE,
202 "Atomic group in bad state - cannot delete!");
210 ag_elem->
name[0] =
'\0';
212 env_spinlock_unlock(&ag_elem->lock);
215 error = atomic_group_free(atomic_group);
217 error, EM_ESCOPE_ATOMIC_GROUP_DELETE,
218 "Atomic group free failed(%d)!", err);
229 em_queue_group_t queue_group;
231 atomic_group_elem_get(atomic_group);
232 const char *err_str =
"";
234 if (unlikely(!ag_elem || !atomic_group_allocated(ag_elem))) {
236 "Invalid Atomic Group:%" PRI_AGRP "",
248 "Atomic Group queue creation failed! (%s)",
253 q_elem = queue_elem_get(queue);
254 if (unlikely(!q_elem)) {
256 "Atomic Group Q:%" PRI_QUEUE " - q_elem = NULL",
263 atomic_group_add_queue_list(ag_elem, q_elem);
270 em_atomic_group_t atomic_group, em_queue_t queue,
273 em_queue_t queue_static;
274 em_queue_group_t queue_group;
276 atomic_group_elem_get(atomic_group);
277 const char *err_str =
"";
281 "Invalid Atomic Group:%" PRI_AGRP "", atomic_group);
286 queue_group, queue, atomic_group, conf,
291 "Atomic Group static queue:%" PRI_QUEUE " creation failed! (%s)",
298 EM_ESCOPE_QUEUE_CREATE_STATIC_AG,
300 queue, queue_static);
302 if (unlikely(queue_static != queue)) {
306 queue, queue_static);
310 atomic_group_add_queue_list(ag_elem, q_elem);
321 if (unlikely(q_elem == NULL || !queue_allocated(q_elem))) {
335 char *name,
size_t maxlen)
338 atomic_group_elem_get(atomic_group);
341 if (unlikely(name == NULL || maxlen == 0)) {
343 "Invalid args: name=0x%" PRIx64
", maxlen=%zu",
348 if (unlikely(ag_elem == NULL || !atomic_group_allocated(ag_elem))) {
350 "Invalid Atomic Group:%" PRI_AGRP "",
356 len = strnlen(ag_elem->
name,
sizeof(ag_elem->
name) - 1);
357 if (maxlen - 1 < len)
360 memcpy(name, ag_elem->
name, len);
372 &
em_shm->atomic_group_tbl.ag_elem[i];
374 if (atomic_group_allocated(ag_elem) &&
375 !strncmp(name, ag_elem->
name,
387 em_shm->atomic_group_tbl.ag_elem;
389 const unsigned int agrp_count = atomic_group_count();
391 _agrp_tbl_iter_idx = 0;
396 if (agrp_count == 0) {
402 while (!atomic_group_allocated(ag_elem)) {
403 _agrp_tbl_iter_idx++;
406 ag_elem = &agrp_elem_tbl[_agrp_tbl_iter_idx];
409 return agrp_idx2hdl(_agrp_tbl_iter_idx);
418 _agrp_tbl_iter_idx++;
421 em_shm->atomic_group_tbl.ag_elem;
425 while (!atomic_group_allocated(ag_elem)) {
426 _agrp_tbl_iter_idx++;
429 ag_elem = &agrp_elem_tbl[_agrp_tbl_iter_idx];
432 return agrp_idx2hdl(_agrp_tbl_iter_idx);
437 em_atomic_group_t atomic_group)
440 atomic_group_elem_get(atomic_group);
442 const unsigned int max_queues =
em_shm->opt.queue.max_num;
444 if (unlikely(agrp_elem == NULL || !atomic_group_allocated(agrp_elem))) {
446 EM_ESCOPE_ATOMIC_GROUP_QUEUE_GET_FIRST,
447 "Invalid atomic group:%" PRI_AGRP "",
454 const unsigned int num_queues =
460 if (num_queues == 0) {
461 _agrp_q_iter_idx = max_queues;
475 _agrp_q_iter_idx = 0;
476 _agrp_q_iter_agrp = atomic_group;
479 while (!queue_allocated(q_elem) ||
483 if (_agrp_q_iter_idx >= max_queues)
485 q_elem = &q_elem_tbl[_agrp_q_iter_idx];
488 return queue_idx2hdl(_agrp_q_iter_idx);
494 const unsigned int max_queues =
em_shm->opt.queue.max_num;
496 if (_agrp_q_iter_idx >= max_queues - 1)
502 const queue_elem_t *q_elem = &q_elem_tbl[_agrp_q_iter_idx];
505 while (!queue_allocated(q_elem) ||
509 if (_agrp_q_iter_idx >= max_queues)
511 q_elem = &q_elem_tbl[_agrp_q_iter_idx];
514 return queue_idx2hdl(_agrp_q_iter_idx);
519 return (uint64_t)atomic_group;