[RFC v2 09/13] fib: add tbl8 pool stats API
Maxime Leroy
maxime at leroys.fr
Tue Nov 24 19:02:45 CET 2026
Add rte_fib_tbl8_pool_get_stats() to retrieve the number of used and
total tbl8 groups from a pool handle directly, without going through
a FIB instance.
Signed-off-by: Maxime Leroy <maxime at leroys.fr>
---
doc/guides/prog_guide/fib_lib.rst | 3 +++
lib/fib/fib_tbl8_pool.c | 17 +++++++++++++++++
lib/fib/rte_fib_tbl8_pool.h | 20 ++++++++++++++++++++
3 files changed, 40 insertions(+)
diff --git a/doc/guides/prog_guide/fib_lib.rst b/doc/guides/prog_guide/fib_lib.rst
index 9623ffd44b..5d421c7fbd 100644
--- a/doc/guides/prog_guide/fib_lib.rst
+++ b/doc/guides/prog_guide/fib_lib.rst
@@ -160,6 +160,9 @@ variable, attached with ``rte_fib_tbl8_pool_rcu_qsbr_add()``, or by the first
The previous array is freed once the readers are done with it.
The pool never shrinks.
+``rte_fib_tbl8_pool_get_stats()`` returns the number of tbl8 groups taken
+from the pool, its current capacity and its maximum capacity.
+
The pool is not thread safe: the updates of all the FIBs sharing it,
their creation and their destruction must be serialized by the caller.
diff --git a/lib/fib/fib_tbl8_pool.c b/lib/fib/fib_tbl8_pool.c
index 2ea1484c29..3251647d11 100644
--- a/lib/fib/fib_tbl8_pool.c
+++ b/lib/fib/fib_tbl8_pool.c
@@ -346,3 +346,20 @@ rte_fib_tbl8_pool_rcu_qsbr_add(struct rte_fib_tbl8_pool *pool,
pool->v = cfg->v;
return 0;
}
+
+RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_fib_tbl8_pool_get_stats, 27.03)
+int
+rte_fib_tbl8_pool_get_stats(struct rte_fib_tbl8_pool *pool,
+ uint32_t *used, uint32_t *total, uint32_t *max)
+{
+ if (pool == NULL)
+ return -EINVAL;
+
+ if (used != NULL)
+ *used = pool->pool_pos;
+ if (total != NULL)
+ *total = pool->num_tbl8s;
+ if (max != NULL)
+ *max = pool->max_tbl8s;
+ return 0;
+}
diff --git a/lib/fib/rte_fib_tbl8_pool.h b/lib/fib/rte_fib_tbl8_pool.h
index c9354cdbad..28201d833f 100644
--- a/lib/fib/rte_fib_tbl8_pool.h
+++ b/lib/fib/rte_fib_tbl8_pool.h
@@ -132,6 +132,26 @@ int
rte_fib_tbl8_pool_resize(struct rte_fib_tbl8_pool *pool,
uint32_t new_num_tbl8);
+/**
+ * Retrieve tbl8 pool statistics.
+ *
+ * @param pool
+ * Pool handle
+ * @param used
+ * Number of tbl8 groups taken from the pool, including those waiting
+ * in an RCU defer queue (can be NULL)
+ * @param total
+ * Total number of tbl8 groups (current capacity, can be NULL)
+ * @param max
+ * Maximum number of tbl8 groups (0 = fixed, can be NULL)
+ * @return
+ * 0 on success, -EINVAL if pool is NULL
+ */
+__rte_experimental
+int
+rte_fib_tbl8_pool_get_stats(struct rte_fib_tbl8_pool *pool,
+ uint32_t *used, uint32_t *total, uint32_t *max);
+
#ifdef __cplusplus
}
#endif
--
2.43.0
More information about the dev
mailing list