From: Santosh Shukla Date: Sun, 1 Oct 2017 09:29:02 +0000 (+0530) Subject: mempool: notify memory area to pool X-Git-Tag: spdx-start~1724 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=12b8cc1a7e86;p=dpdk.git mempool: notify memory area to pool HW pool manager e.g. Octeontx SoC demands s/w to program start and end address of pool. Currently, there is no such api in external mempool. Introducing rte_mempool_ops_register_memory_area api which will let HW(pool manager) to know when common layer selects hugepage: For each hugepage - Notify its start/end address to HW pool manager. Signed-off-by: Santosh Shukla Signed-off-by: Jerin Jacob Acked-by: Olivier Matz --- diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c index df9d67ae67..de3c18601f 100644 --- a/lib/librte_mempool/rte_mempool.c +++ b/lib/librte_mempool/rte_mempool.c @@ -367,6 +367,11 @@ rte_mempool_populate_phys(struct rte_mempool *mp, char *vaddr, struct rte_mempool_memhdr *memhdr; int ret; + /* Notify memory area to mempool */ + ret = rte_mempool_ops_register_memory_area(mp, vaddr, paddr, len); + if (ret != -ENOTSUP && ret < 0) + return ret; + /* create the internal ring if not already done */ if ((mp->flags & MEMPOOL_F_POOL_CREATED) == 0) { ret = rte_mempool_ops_alloc(mp); diff --git a/lib/librte_mempool/rte_mempool.h b/lib/librte_mempool/rte_mempool.h index 24195dda00..c69841ec46 100644 --- a/lib/librte_mempool/rte_mempool.h +++ b/lib/librte_mempool/rte_mempool.h @@ -413,6 +413,12 @@ typedef unsigned (*rte_mempool_get_count)(const struct rte_mempool *mp); typedef int (*rte_mempool_get_capabilities_t)(const struct rte_mempool *mp, unsigned int *flags); +/** + * Notify new memory area to mempool. + */ +typedef int (*rte_mempool_ops_register_memory_area_t) +(const struct rte_mempool *mp, char *vaddr, phys_addr_t paddr, size_t len); + /** Structure defining mempool operations structure */ struct rte_mempool_ops { char name[RTE_MEMPOOL_OPS_NAMESIZE]; /**< Name of mempool ops struct. */ @@ -425,6 +431,10 @@ struct rte_mempool_ops { * Get the mempool capabilities */ rte_mempool_get_capabilities_t get_capabilities; + /** + * Notify new memory area to mempool + */ + rte_mempool_ops_register_memory_area_t register_memory_area; } __rte_cache_aligned; #define RTE_MEMPOOL_MAX_OPS_IDX 16 /**< Max registered ops structs */ @@ -552,6 +562,26 @@ rte_mempool_ops_get_count(const struct rte_mempool *mp); int rte_mempool_ops_get_capabilities(const struct rte_mempool *mp, unsigned int *flags); +/** + * @internal wrapper for mempool_ops register_memory_area callback. + * API to notify the mempool handler when a new memory area is added to pool. + * + * @param mp + * Pointer to the memory pool. + * @param vaddr + * Pointer to the buffer virtual address. + * @param paddr + * Pointer to the buffer physical address. + * @param len + * Pool size. + * @return + * - 0: Success; + * - -ENOTSUP - doesn't support register_memory_area ops (valid error case). + * - Otherwise, rte_mempool_populate_phys fails thus pool create fails. + */ +int +rte_mempool_ops_register_memory_area(const struct rte_mempool *mp, + char *vaddr, phys_addr_t paddr, size_t len); /** * @internal wrapper for mempool_ops free callback. diff --git a/lib/librte_mempool/rte_mempool_ops.c b/lib/librte_mempool/rte_mempool_ops.c index f2af5e5bbe..a6b5f20029 100644 --- a/lib/librte_mempool/rte_mempool_ops.c +++ b/lib/librte_mempool/rte_mempool_ops.c @@ -87,6 +87,7 @@ rte_mempool_register_ops(const struct rte_mempool_ops *h) ops->dequeue = h->dequeue; ops->get_count = h->get_count; ops->get_capabilities = h->get_capabilities; + ops->register_memory_area = h->register_memory_area; rte_spinlock_unlock(&rte_mempool_ops_table.sl); @@ -138,6 +139,19 @@ rte_mempool_ops_get_capabilities(const struct rte_mempool *mp, return ops->get_capabilities(mp, flags); } +/* wrapper to notify new memory area to external mempool */ +int +rte_mempool_ops_register_memory_area(const struct rte_mempool *mp, char *vaddr, + phys_addr_t paddr, size_t len) +{ + struct rte_mempool_ops *ops; + + ops = rte_mempool_get_ops(mp->ops_index); + + RTE_FUNC_PTR_OR_ERR_RET(ops->register_memory_area, -ENOTSUP); + return ops->register_memory_area(mp, vaddr, paddr, len); +} + /* sets mempool ops previously registered by rte_mempool_register_ops. */ int rte_mempool_set_ops_byname(struct rte_mempool *mp, const char *name, diff --git a/lib/librte_mempool/rte_mempool_version.map b/lib/librte_mempool/rte_mempool_version.map index 3c34715077..ff86dc9a7d 100644 --- a/lib/librte_mempool/rte_mempool_version.map +++ b/lib/librte_mempool/rte_mempool_version.map @@ -46,5 +46,6 @@ DPDK_17.11 { global: rte_mempool_ops_get_capabilities; + rte_mempool_ops_register_memory_area; } DPDK_16.07;