[dpdk-dev] [PATCH v7 8/8] mempool: notify memory area to pool

Santosh Shukla santosh.shukla at caviumnetworks.com
Sun Oct 1 11:29:02 CEST 2017


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 <santosh.shukla at caviumnetworks.com>
Signed-off-by: Jerin Jacob <jerin.jacob at caviumnetworks.com>
---
v6 --> v7:
- Incorporated comment nits suggested by Olivier.

Refer [1].
[1] http://dpdk.org/dev/patchwork/patch/28468/

v5 --> v6:
- Renamed from rte_mempool_ops_update_range to 
rte_mempool_ops_register_memory_area (Suggested by Olivier)
- Now renamed api retuns int (Suggestd by Olivier)
- Update API description and Error details very explicitly
  (Suggested by Olivier)
  Refer [2]
  [2] http://dpdk.org/dev/patchwork/patch/28419/

 lib/librte_mempool/rte_mempool.c           |  5 +++++
 lib/librte_mempool/rte_mempool.h           | 30 ++++++++++++++++++++++++++++++
 lib/librte_mempool/rte_mempool_ops.c       | 14 ++++++++++++++
 lib/librte_mempool/rte_mempool_version.map |  1 +
 4 files changed, 50 insertions(+)

diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c
index df9d67ae6..fb49a010d 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;
 
+	/* Notfiy 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 24195dda0..c69841ec4 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 f2af5e5bb..a6b5f2002 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 3c3471507..ff86dc9a7 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;
-- 
2.14.1



More information about the dev mailing list