diff --git a/include/spdk/env.h b/include/spdk/env.h index 25f1542a9..cb9f42b05 100644 --- a/include/spdk/env.h +++ b/include/spdk/env.h @@ -430,6 +430,18 @@ void spdk_mempool_put_bulk(struct spdk_mempool *mp, void **ele_arr, size_t count */ size_t spdk_mempool_count(const struct spdk_mempool *pool); +/** + * Iterate through all elements of the pool and call a function on each one. + * + * \param mp Memory pool to iterate on. + * \param obj_cb Function to call on each element. + * \param obj_cb_arg Opaque pointer passed to the callback function. + * + * \return Number of elements iterated. + */ +uint32_t spdk_mempool_obj_iter(struct spdk_mempool *mp, spdk_mempool_obj_cb_t obj_cb, + void *obj_cb_arg); + /** * Get the number of dedicated CPU cores utilized by this env abstraction. * diff --git a/lib/env_dpdk/env.c b/lib/env_dpdk/env.c index 0421ade73..dbd746dc8 100644 --- a/lib/env_dpdk/env.c +++ b/lib/env_dpdk/env.c @@ -288,6 +288,14 @@ spdk_mempool_count(const struct spdk_mempool *pool) return rte_mempool_avail_count((struct rte_mempool *)pool); } +uint32_t +spdk_mempool_obj_iter(struct spdk_mempool *mp, spdk_mempool_obj_cb_t obj_cb, + void *obj_cb_arg) +{ + return rte_mempool_obj_iter((struct rte_mempool *)mp, (rte_mempool_obj_cb_t *)obj_cb, + obj_cb_arg); +} + bool spdk_process_is_primary(void) {