41 static ENV_LOCAL unsigned int _pool_tbl_iter_idx;
45 odp_pool_param_t odp_pool_defaults;
46 uint32_t buf_cache_sz;
47 uint32_t pkt_cache_sz;
48 uint32_t vec_cache_sz;
51 if (unlikely(!pool_cfg)) {
54 "pool_cfg pointer NULL!");
58 odp_pool_param_init(&odp_pool_defaults);
59 memset(pool_cfg, 0,
sizeof(*pool_cfg));
63 buf_cache_sz = odp_pool_defaults.buf.cache_size;
64 pkt_cache_sz = odp_pool_defaults.pkt.cache_size;
65 vec_cache_sz = odp_pool_defaults.vector.cache_size;
66 cache_sz = MIN(buf_cache_sz, pkt_cache_sz);
67 cache_sz = MIN(cache_sz, vec_cache_sz);
78 em_pool_t pool_created;
79 const char *err_str =
"";
82 int err = invalid_pool_cfg(pool_cfg, &err_str);
86 "Pool create: invalid pool-config(%d): %s",
91 err = check_pool_uarea_persistence(pool_cfg, &err_str);
95 "Pool create: user area persistence unsupported(%d): %s",
100 pool_created = pool_create(name, pool, pool_cfg);
105 "Pool create failed,\n"
119 stat = pool_delete(pool);
121 "Pool delete failed");
130 return pool_find(name);
141 if (unlikely(name == NULL || maxlen == 0)) {
143 "Invalid args: name=0x%" PRIx64
", maxlen=%zu",
148 if (unlikely(mpool_elem == NULL || !pool_allocated(mpool_elem))) {
150 "Invalid Pool:%" PRI_POOL "", pool);
155 len = strnlen(mpool_elem->name,
sizeof(mpool_elem->name) - 1);
156 if (maxlen - 1 < len)
159 memcpy(name, mpool_elem->name, len);
170 const unsigned int pool_cnt = pool_count();
172 _pool_tbl_iter_idx = 0;
183 while (!pool_allocated(mpool_elem)) {
184 _pool_tbl_iter_idx++;
187 mpool_elem = &mpool_elem_tbl[_pool_tbl_iter_idx];
190 return pool_idx2hdl(_pool_tbl_iter_idx);
199 _pool_tbl_iter_idx++;
202 const mpool_elem_t *mpool_elem = &mpool_elem_tbl[_pool_tbl_iter_idx];
205 while (!pool_allocated(mpool_elem)) {
206 _pool_tbl_iter_idx++;
209 mpool_elem = &mpool_elem_tbl[_pool_tbl_iter_idx];
212 return pool_idx2hdl(_pool_tbl_iter_idx);
223 "Inv. args: pool:%" PRI_POOL " pool_info:%p",
229 "EM-pool:%" PRI_POOL " not created", pool);
231 memset(pool_info, 0,
sizeof(*pool_info));
233 strncpy(pool_info->name, pool_elem->name,
sizeof(pool_info->name));
234 pool_info->name[
sizeof(pool_info->name) - 1] =
'\0';
242 pool_info->subpool[i].
size = pool_elem->
size[i];
253 if (!pool_elem->
stats_opt.bit.available &&
254 !pool_elem->
stats_opt.bit.cache_available)
262 odp_pool_stats_t odp_stats;
265 odp_stats.thread.first = 0;
266 odp_stats.thread.last = 0;
268 int ret = odp_pool_stats(pool_elem->
odp_pool[i], &odp_stats);
271 "EM-pool:%" PRI_POOL " subpool:%d stats failed:%d",
274 free = odp_stats.available + odp_stats.cache_available;
279 pool_info->subpool[i].
used = used;
280 pool_info->subpool[i].
free = free;
289 pool_info_print_hdr(1);
290 pool_info_print(pool);
299 "Inv. args: pool:%" PRI_POOL, pool);
303 if (
EM_CHECK_LEVEL >= 2 && unlikely(!pool_allocated(pool_elem))) {
305 "EM-pool:%" PRI_POOL " not created", pool);
320 pool_info_print_hdr(num);
322 pool_info_print(pool);
331 odp_pool_stats_t *odp_stats;
337 "Inv. args: pool:%" PRI_POOL " pool_stats:%p",
343 "EM-pool: %" PRI_POOL "not created", pool);
347 odp_stats = (odp_pool_stats_t *)&pool_stats->subpool_stats[i];
350 odp_stats->thread.first = 0;
351 odp_stats->thread.last = 0;
353 ret = odp_pool_stats(pool_elem->
odp_pool[i], odp_stats);
356 "EM-pool:%" PRI_POOL " subpool:%d stats failed:%d",
360 pool_stats->num_subpools = i;
373 "EM-pool:%" PRI_POOL " invalid", pool);
378 "EM-pool:%" PRI_POOL " not created", pool);
381 ret = odp_pool_stats_reset(pool_elem->
odp_pool[i]);
383 "EM-pool:%" PRI_POOL " subpool:%d stats reset failed:%d",
392 pool_stats_print(pool);
395 #define SUBPOOL_STATS_INV_ARG_FMT \
396 "Inv. args: pool:%" PRI_POOL " subpools:%p num_subpools:%d subpool_stats:%p"
404 odp_pool_stats_t *odp_stats;
408 unlikely(!pool_elem || !subpools || !subpool_stats ||
409 num_subpools <= 0 || num_subpools > pool_elem->
num_subpools)) {
411 SUBPOOL_STATS_INV_ARG_FMT, pool, subpools,
412 num_subpools, subpool_stats);
416 if (
EM_CHECK_LEVEL >= 2 && unlikely(!pool_allocated(pool_elem))) {
418 "EM-pool: %" PRI_POOL "not allocated", pool);
422 for (
int i = 0; i < num_subpools; i++) {
426 "arg 'subpools[%d]: %d' out of range", i, subpools[i]);
430 odp_stats = (odp_pool_stats_t *)&subpool_stats[i];
433 odp_stats->thread.first = 0;
434 odp_stats->thread.last = 0;
436 ret = odp_pool_stats(pool_elem->
odp_pool[subpools[i]], odp_stats);
437 if (unlikely(ret < 0)) {
439 "EM-pool:%" PRI_POOL " subpool:%d stats failed:%d",
440 pool, subpools[i], ret);
459 "Inv. args: pool:%" PRI_POOL " subpools:%p num:%d",
460 pool, subpools, num_subpools);
465 "EM-pool:%" PRI_POOL " not created", pool);
467 for (
int i = 0; i < num_subpools; i++) {
470 "arg 'subpools[%d]: %d' out of range", i, subpools[i]);
472 ret = odp_pool_stats_reset(pool_elem->
odp_pool[subpools[i]]);
474 "EM-pool:%" PRI_POOL " subpool:%d stats reset failed:%d",
475 pool, subpools[i], ret);
483 subpools_stats_print(pool, subpools, num_subpools);
486 static inline void assign_odp_stats_opt(odp_pool_stats_opt_t *opt_odp,
490 opt_odp->bit.available = opt_em->
available;
491 opt_odp->bit.alloc_ops = opt_em->
alloc_ops;
493 opt_odp->bit.free_ops = opt_em->
free_ops;
494 opt_odp->bit.total_ops = opt_em->
total_ops;
506 odp_pool_stats_opt_t opt_odp;
507 odp_pool_stats_selected_t *odp_stats;
513 "Inv. args: pool:%" PRI_POOL " pool_stats:%p opt: %p",
514 pool, pool_stats, opt);
519 "EM-pool: %" PRI_POOL "not created", pool);
521 assign_odp_stats_opt(&opt_odp, opt);
524 odp_pool_t odp_pool = pool_elem->
odp_pool[i];
529 "EM-pool:%" PRI_POOL " invalid subpool:%d",
532 odp_stats = (odp_pool_stats_selected_t *)&pool_stats->subpool_stats[i];
534 ret = odp_pool_stats_selected(odp_pool, odp_stats, &opt_odp);
537 "EM-pool:%" PRI_POOL " subpool:%d stats selected failed:%d",
541 pool_stats->num_subpools = i;
548 pool_stats_selected_print(pool, opt);
551 #define SUBPOOL_STATS_SELECTED_INV_ARG_FMT \
552 "Inv. args: pool:%" PRI_POOL " subpools:%p num_subpools:%d subpool_stats:%p opt: %p"
560 odp_pool_stats_opt_t opt_odp;
561 odp_pool_stats_selected_t *odp_stats;
565 unlikely(!pool_elem || !subpools || !subpool_stats || !opt ||
566 num_subpools <= 0 || num_subpools > pool_elem->
num_subpools)) {
568 SUBPOOL_STATS_SELECTED_INV_ARG_FMT, pool, subpools,
569 num_subpools, subpool_stats, opt);
573 if (
EM_CHECK_LEVEL >= 2 && unlikely(!pool_allocated(pool_elem))) {
575 "EM-pool: %" PRI_POOL "not allocated", pool);
579 assign_odp_stats_opt(&opt_odp, opt);
581 for (
int i = 0; i < num_subpools; i++) {
582 odp_pool_t odp_pool = pool_elem->
odp_pool[subpools[i]];
587 "arg 'subpools[%d]: %d' out of range", i, subpools[i]);
591 if (
EM_CHECK_LEVEL >= 3 && unlikely(odp_pool == ODP_POOL_INVALID)) {
593 "EM-pool:%" PRI_POOL " invalid subpool:%d", pool, i);
597 odp_stats = (odp_pool_stats_selected_t *)&subpool_stats[i];
599 ret = odp_pool_stats_selected(odp_pool, odp_stats, &opt_odp);
600 if (unlikely(ret < 0)) {
602 "EM-pool:%" PRI_POOL " subpool:%d stats failed:%d",
603 pool, subpools[i], ret);
616 subpools_stats_selected_print(pool, subpools, num_subpools, opt);
621 return (uint64_t)pool;