From: "Artem V. Andreev" <artem.andr...@oktetlabs.ru> Primarily, it is intended as a way for the mempool driver to provide additional information on how it lays up objects inside the mempool.
Signed-off-by: Artem V. Andreev <artem.andr...@oktetlabs.ru> Signed-off-by: Andrew Rybchenko <arybche...@solarflare.com> --- lib/librte_mempool/rte_mempool.h | 31 +++++++++++++++++++++++++++++++ lib/librte_mempool/rte_mempool_ops.c | 15 +++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/lib/librte_mempool/rte_mempool.h b/lib/librte_mempool/rte_mempool.h index 16d95ae..75630e6 100644 --- a/lib/librte_mempool/rte_mempool.h +++ b/lib/librte_mempool/rte_mempool.h @@ -218,6 +218,11 @@ struct rte_mempool_memhdr { void *opaque; /**< Argument passed to the free callback */ }; +/* + * Additional information about the mempool + */ +struct rte_mempool_info; + /** * The RTE mempool structure. */ @@ -484,6 +489,13 @@ int rte_mempool_populate_one_by_one(struct rte_mempool *mp, void *vaddr, rte_iova_t iova, size_t len, rte_mempool_populate_obj_cb_t *obj_cb); +/** + * Get some additional information about a mempool. + */ +typedef int (*rte_mempool_get_info_t)(const struct rte_mempool *mp, + struct rte_mempool_info *info); + + /** Structure defining mempool operations structure */ struct rte_mempool_ops { char name[RTE_MEMPOOL_OPS_NAMESIZE]; /**< Name of mempool ops struct. */ @@ -502,6 +514,10 @@ struct rte_mempool_ops { * provided memory chunk. */ rte_mempool_populate_t populate; + /** + * Get mempool info + */ + rte_mempool_get_info_t get_info; } __rte_cache_aligned; #define RTE_MEMPOOL_MAX_OPS_IDX 16 /**< Max registered ops structs */ @@ -662,6 +678,21 @@ int rte_mempool_ops_populate(struct rte_mempool *mp, unsigned int max_objs, rte_mempool_populate_obj_cb_t *obj_cb); /** + * @internal wrapper for mempool_ops get_info callback. + * + * @param mp [in] + * Pointer to the memory pool. + * @param info [out] + * Pointer to the rte_mempool_info structure + * @return + * - 0: Success; The mempool driver supports retrieving supplementary + * mempool information + * - -ENOTSUP - doesn't support get_info ops (valid case). + */ +int rte_mempool_ops_get_info(const struct rte_mempool *mp, + struct rte_mempool_info *info); + +/** * @internal wrapper for mempool_ops free callback. * * @param mp diff --git a/lib/librte_mempool/rte_mempool_ops.c b/lib/librte_mempool/rte_mempool_ops.c index 37b0802..949ab43 100644 --- a/lib/librte_mempool/rte_mempool_ops.c +++ b/lib/librte_mempool/rte_mempool_ops.c @@ -88,6 +88,7 @@ rte_mempool_register_ops(const struct rte_mempool_ops *h) ops->get_count = h->get_count; ops->calc_mem_size = h->calc_mem_size; ops->populate = h->populate; + ops->get_info = h->get_info; rte_spinlock_unlock(&rte_mempool_ops_table.sl); @@ -160,6 +161,20 @@ rte_mempool_ops_populate(struct rte_mempool *mp, unsigned int max_objs, return ops->populate(mp, max_objs, vaddr, iova, len, obj_cb); } +/* wrapper to get additional mempool info */ +int +rte_mempool_ops_get_info(const struct rte_mempool *mp, + struct rte_mempool_info *info) +{ + struct rte_mempool_ops *ops; + + ops = rte_mempool_get_ops(mp->ops_index); + + RTE_FUNC_PTR_OR_ERR_RET(ops->get_info, -ENOTSUP); + return ops->get_info(mp, info); +} + + /* sets mempool ops previously registered by rte_mempool_register_ops. */ int rte_mempool_set_ops_byname(struct rte_mempool *mp, const char *name, -- 2.7.4