[dpdk-dev] [PATCH] mempool: Introduce _populate_mz_range api
From: Santosh Shukla HW pool manager e.g. Cavium SoC need s/w to program start and end address of pool. Currently there is no such api in ext-mempool. So introducing _populate_mz_range API which will let HW(pool manager) know about hugepage mapped virtual start and end address. Signed-off-by: Santosh Shukla --- lib/librte_mempool/rte_mempool.c |4 lib/librte_mempool/rte_mempool.h | 22 ++ lib/librte_mempool/rte_mempool_ops.c | 17 + lib/librte_mempool/rte_mempool_ring.c |4 lib/librte_mempool/rte_mempool_stack.c |3 ++- 5 files changed, 49 insertions(+), 1 deletion(-) diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c index 1c2aed8..9a39f5c 100644 --- a/lib/librte_mempool/rte_mempool.c +++ b/lib/librte_mempool/rte_mempool.c @@ -568,6 +568,10 @@ static unsigned optimize_object_size(unsigned obj_size) else paddr = mz->phys_addr; + /* Populate mz range */ + if ((mp->flags & MEMPOOL_F_POOL_CREATED) == 0) + rte_mempool_ops_populate_mz_range(mp, mz); + if (rte_eal_has_hugepages() && !rte_xen_dom0_supported()) ret = rte_mempool_populate_phys(mp, mz->addr, paddr, mz->len, diff --git a/lib/librte_mempool/rte_mempool.h b/lib/librte_mempool/rte_mempool.h index d0f5b27..3ae8aa8 100644 --- a/lib/librte_mempool/rte_mempool.h +++ b/lib/librte_mempool/rte_mempool.h @@ -387,6 +387,12 @@ typedef int (*rte_mempool_dequeue_t)(struct rte_mempool *mp, */ typedef unsigned (*rte_mempool_get_count)(const struct rte_mempool *mp); +/** + * Set the memzone va/pa addr range and len in the external pool. + */ +typedef void (*rte_mempool_populate_mz_range_t)(struct rte_mempool *mp, + const struct rte_memzone *mz); + /** Structure defining mempool operations structure */ struct rte_mempool_ops { char name[RTE_MEMPOOL_OPS_NAMESIZE]; /**< Name of mempool ops struct. */ @@ -395,6 +401,8 @@ struct rte_mempool_ops { rte_mempool_enqueue_t enqueue; /**< Enqueue an object. */ rte_mempool_dequeue_t dequeue; /**< Dequeue an object. */ rte_mempool_get_count get_count; /**< Get qty of available objs. */ + rte_mempool_populate_mz_range_t populate_mz_range; /**< set per pool + memzone info */ } __rte_cache_aligned; #define RTE_MEMPOOL_MAX_OPS_IDX 16 /**< Max registered ops structs */ @@ -438,6 +446,20 @@ struct rte_mempool_ops_table { } /** + * @internal Wrapper for mempool_ops populate memzone's va/pa addr callback. + * + * @param mp + * Pointer to the memory pool. + * + * @param mz + * Pointer to the memory zone. + */ +void +rte_mempool_ops_populate_mz_range(struct rte_mempool *mp, + const struct rte_memzone *mz); + + +/** * @internal Wrapper for mempool_ops alloc callback. * * @param mp diff --git a/lib/librte_mempool/rte_mempool_ops.c b/lib/librte_mempool/rte_mempool_ops.c index 5f24de2..ea79fc1 100644 --- a/lib/librte_mempool/rte_mempool_ops.c +++ b/lib/librte_mempool/rte_mempool_ops.c @@ -85,12 +85,29 @@ struct rte_mempool_ops_table rte_mempool_ops_table = { ops->enqueue = h->enqueue; ops->dequeue = h->dequeue; ops->get_count = h->get_count; + ops->populate_mz_range = h->populate_mz_range; rte_spinlock_unlock(&rte_mempool_ops_table.sl); return ops_index; } +/* + * wrapper to populate mz's pa/va addr range and len info to external + * mempool. HW mempool implementation to cache-in this inforamation + * in their local data structure. + * Note: api always get called before ops_alloc(). + * */ +void +rte_mempool_ops_populate_mz_range(struct rte_mempool *mp, + const struct rte_memzone *mz) +{ + struct rte_mempool_ops *ops; + + ops = rte_mempool_get_ops(mp->ops_index); + return ops->populate_mz_range(mp, mz); +} + /* wrapper to allocate an external mempool's private (pool) data. */ int rte_mempool_ops_alloc(struct rte_mempool *mp) diff --git a/lib/librte_mempool/rte_mempool_ring.c b/lib/librte_mempool/rte_mempool_ring.c index b9aa64d..7d32384 100644 --- a/lib/librte_mempool/rte_mempool_ring.c +++ b/lib/librte_mempool/rte_mempool_ring.c @@ -126,6 +126,7 @@ .enqueue = common_ring_mp_enqueue, .dequeue = common_ring_mc_dequeue, .get_count = common_ring_get_count, + .populate_mz_range = NULL, }; static const struct rte_mempool_ops ops_sp_sc = { @@ -135,6 +136,7 @@ .enqueue = common_ring_sp_enqueue, .dequeue = common_ring_sc_dequeue, .get_count = common_ring_get_count, + .populate_mz_range = NULL, }; static const struct rte_mempool_ops ops_mp_sc = { @@ -144,6 +146,7 @@ .enqueue = common_ring_mp_enqueue, .dequeue = common_ri
[dpdk-dev] [PATCH v2] mempool: Introduce _populate_mz_range api
From: Santosh Shukla HW pool manager e.g. Cavium SoC need s/w to program start and end address of pool. Currently there is no such api in ext-mempool. So introducing _populate_mz_range API which will let HW(pool manager) know about hugepage mapped virtual start and end address. Signed-off-by: Santosh Shukla --- v1-->v2: - added ops->populate_mz_range NULL check - Removed return ops->populate_mz_range; As function is void. lib/librte_mempool/rte_mempool.c |4 lib/librte_mempool/rte_mempool.h | 22 ++ lib/librte_mempool/rte_mempool_ops.c | 18 ++ lib/librte_mempool/rte_mempool_ring.c |4 lib/librte_mempool/rte_mempool_stack.c |3 ++- 5 files changed, 50 insertions(+), 1 deletion(-) diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c index 1c2aed8..9a39f5c 100644 --- a/lib/librte_mempool/rte_mempool.c +++ b/lib/librte_mempool/rte_mempool.c @@ -568,6 +568,10 @@ static unsigned optimize_object_size(unsigned obj_size) else paddr = mz->phys_addr; + /* Populate mz range */ + if ((mp->flags & MEMPOOL_F_POOL_CREATED) == 0) + rte_mempool_ops_populate_mz_range(mp, mz); + if (rte_eal_has_hugepages() && !rte_xen_dom0_supported()) ret = rte_mempool_populate_phys(mp, mz->addr, paddr, mz->len, diff --git a/lib/librte_mempool/rte_mempool.h b/lib/librte_mempool/rte_mempool.h index d0f5b27..3ae8aa8 100644 --- a/lib/librte_mempool/rte_mempool.h +++ b/lib/librte_mempool/rte_mempool.h @@ -387,6 +387,12 @@ typedef int (*rte_mempool_dequeue_t)(struct rte_mempool *mp, */ typedef unsigned (*rte_mempool_get_count)(const struct rte_mempool *mp); +/** + * Set the memzone va/pa addr range and len in the external pool. + */ +typedef void (*rte_mempool_populate_mz_range_t)(struct rte_mempool *mp, + const struct rte_memzone *mz); + /** Structure defining mempool operations structure */ struct rte_mempool_ops { char name[RTE_MEMPOOL_OPS_NAMESIZE]; /**< Name of mempool ops struct. */ @@ -395,6 +401,8 @@ struct rte_mempool_ops { rte_mempool_enqueue_t enqueue; /**< Enqueue an object. */ rte_mempool_dequeue_t dequeue; /**< Dequeue an object. */ rte_mempool_get_count get_count; /**< Get qty of available objs. */ + rte_mempool_populate_mz_range_t populate_mz_range; /**< set per pool + memzone info */ } __rte_cache_aligned; #define RTE_MEMPOOL_MAX_OPS_IDX 16 /**< Max registered ops structs */ @@ -438,6 +446,20 @@ struct rte_mempool_ops_table { } /** + * @internal Wrapper for mempool_ops populate memzone's va/pa addr callback. + * + * @param mp + * Pointer to the memory pool. + * + * @param mz + * Pointer to the memory zone. + */ +void +rte_mempool_ops_populate_mz_range(struct rte_mempool *mp, + const struct rte_memzone *mz); + + +/** * @internal Wrapper for mempool_ops alloc callback. * * @param mp diff --git a/lib/librte_mempool/rte_mempool_ops.c b/lib/librte_mempool/rte_mempool_ops.c index 5f24de2..6c2bc7b 100644 --- a/lib/librte_mempool/rte_mempool_ops.c +++ b/lib/librte_mempool/rte_mempool_ops.c @@ -85,12 +85,30 @@ struct rte_mempool_ops_table rte_mempool_ops_table = { ops->enqueue = h->enqueue; ops->dequeue = h->dequeue; ops->get_count = h->get_count; + ops->populate_mz_range = h->populate_mz_range; rte_spinlock_unlock(&rte_mempool_ops_table.sl); return ops_index; } +/* + * wrapper to populate mz's pa/va addr range and len info to external + * mempool. HW mempool implementation to cache-in this inforamation + * in their local data structure. + * Note: api always get called before ops_alloc(). + * */ +void +rte_mempool_ops_populate_mz_range(struct rte_mempool *mp, + const struct rte_memzone *mz) +{ + struct rte_mempool_ops *ops; + + ops = rte_mempool_get_ops(mp->ops_index); + if (ops->populate_mz_range) + ops->populate_mz_range(mp, mz); +} + /* wrapper to allocate an external mempool's private (pool) data. */ int rte_mempool_ops_alloc(struct rte_mempool *mp) diff --git a/lib/librte_mempool/rte_mempool_ring.c b/lib/librte_mempool/rte_mempool_ring.c index b9aa64d..7d32384 100644 --- a/lib/librte_mempool/rte_mempool_ring.c +++ b/lib/librte_mempool/rte_mempool_ring.c @@ -126,6 +126,7 @@ .enqueue = common_ring_mp_enqueue, .dequeue = common_ring_mc_dequeue, .get_count = common_ring_get_count, + .populate_mz_range = NULL, }; static const struct rte_mempool_ops ops_sp_sc = { @@ -135,6 +136,7 @@ .enqueue = common_ring_sp_enqueue, .dequeue = common_ring_sc_dequeue, .get_count = common_ring_get_count, + .populate_mz_range = NU