aboutsummaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorMatias Elo <matias.elo@nokia.com>2023-05-04 17:30:40 +0300
committerMatias Elo <matias.elo@nokia.com>2023-06-09 09:50:02 +0300
commit7ac1fd5e6f056d5634d94df4eb1c8531aac4522f (patch)
tree4b6ee25b77c69ef4c39d18d44254fbdafcfb2d48 /platform
parent18349e109908cc63fd9e355169b7e09fc18c3fdf (diff)
linux-gen: pool: implement new odp_pool_stats_selected() function
Implement new function odp_pool_stats_selected() for reading selected pool statistic(s). Signed-off-by: Matias Elo <matias.elo@nokia.com> Reviewed-by: Petri Savolainen <petri.savolainen@nokia.com>
Diffstat (limited to 'platform')
-rw-r--r--platform/linux-generic/odp_pool.c62
1 files changed, 62 insertions, 0 deletions
diff --git a/platform/linux-generic/odp_pool.c b/platform/linux-generic/odp_pool.c
index d1bf26b64..d960c7353 100644
--- a/platform/linux-generic/odp_pool.c
+++ b/platform/linux-generic/odp_pool.c
@@ -176,6 +176,16 @@ static inline int cache_available(pool_t *pool, odp_pool_stats_t *stats)
return 0;
}
+static inline uint64_t cache_total_available(pool_t *pool)
+{
+ uint64_t cached = 0;
+
+ for (int i = 0; i < ODP_THREAD_COUNT_MAX; i++)
+ cached += odp_atomic_load_u32(&pool->local_cache[i].cache_num);
+
+ return cached;
+}
+
static int read_config_file(pool_global_t *pool_glb)
{
uint32_t local_cache_size, burst_size, align;
@@ -1700,6 +1710,58 @@ int odp_pool_stats(odp_pool_t pool_hdl, odp_pool_stats_t *stats)
return 0;
}
+int odp_pool_stats_selected(odp_pool_t pool_hdl, odp_pool_stats_selected_t *stats,
+ const odp_pool_stats_opt_t *opt)
+{
+ pool_t *pool;
+
+ if (odp_unlikely(pool_hdl == ODP_POOL_INVALID)) {
+ _ODP_ERR("Invalid pool handle\n");
+ return -1;
+ }
+ if (odp_unlikely(stats == NULL)) {
+ _ODP_ERR("Output buffer NULL\n");
+ return -1;
+ }
+ if (odp_unlikely(opt == NULL)) {
+ _ODP_ERR("Pool counters NULL\n");
+ return -1;
+ }
+
+ pool = _odp_pool_entry(pool_hdl);
+
+ if (odp_unlikely(opt->all & ~pool->params.stats.all)) {
+ _ODP_ERR("Trying to read disabled counter\n");
+ return -1;
+ }
+
+ if (opt->bit.available)
+ stats->available = ring_ptr_len(&pool->ring->hdr);
+
+ if (opt->bit.alloc_ops || opt->bit.total_ops)
+ stats->alloc_ops = odp_atomic_load_u64(&pool->stats.alloc_ops);
+
+ if (opt->bit.alloc_fails)
+ stats->alloc_fails = odp_atomic_load_u64(&pool->stats.alloc_fails);
+
+ if (opt->bit.free_ops || opt->bit.total_ops)
+ stats->free_ops = odp_atomic_load_u64(&pool->stats.free_ops);
+
+ if (opt->bit.total_ops)
+ stats->total_ops = stats->alloc_ops + stats->free_ops;
+
+ if (opt->bit.cache_available)
+ stats->cache_available = cache_total_available(pool);
+
+ if (opt->bit.cache_alloc_ops)
+ stats->cache_alloc_ops = odp_atomic_load_u64(&pool->stats.cache_alloc_ops);
+
+ if (opt->bit.cache_free_ops)
+ stats->cache_free_ops = odp_atomic_load_u64(&pool->stats.cache_free_ops);
+
+ return 0;
+}
+
int odp_pool_stats_reset(odp_pool_t pool_hdl)
{
pool_t *pool;