[dpdk-dev] [PATCH 2/2] mbuf: add support for preferred mempool list

Hemant Agrawal hemant.agrawal at nxp.com
Tue Jul 4 14:22:48 CEST 2017


This patch extend the existing default mempool ops support.
There may be more than one type of mempool supported by the
given platform. This decision may be based on the resource
availability or required capabilities. The mempool list can be
a combination of external mempools and sw mempools.

This patch support configuring multiple backups for the default
mempool.

This patch also support to find out the most preferred support
for a given mempool ops from the configured mempool list (if available).

Current patch support only 3 mempool ops i.e. default + 2 backup.
However this can be extended in future if required.

Signed-off-by: Hemant Agrawal <hemant.agrawal at nxp.com>
---
 config/common_base         |  2 ++
 lib/librte_mbuf/rte_mbuf.c | 28 +++++++++++++++++++++++-----
 2 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/config/common_base b/config/common_base
index 660588a..3020b35 100644
--- a/config/common_base
+++ b/config/common_base
@@ -557,6 +557,8 @@ CONFIG_RTE_DRIVER_MEMPOOL_STACK=y
 CONFIG_RTE_LIBRTE_MBUF=y
 CONFIG_RTE_LIBRTE_MBUF_DEBUG=n
 CONFIG_RTE_MBUF_DEFAULT_MEMPOOL_OPS="ring_mp_mc"
+CONFIG_RTE_MBUF_BACKUP_MEMPOOL_OPS_1=""
+CONFIG_RTE_MBUF_BACKUP_MEMPOOL_OPS_2=""
 CONFIG_RTE_MBUF_REFCNT_ATOMIC=y
 CONFIG_RTE_PKTMBUF_HEADROOM=128
 
diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c
index ab436b9..64519ef 100644
--- a/lib/librte_mbuf/rte_mbuf.c
+++ b/lib/librte_mbuf/rte_mbuf.c
@@ -159,6 +159,13 @@ rte_pktmbuf_pool_create(const char *name, unsigned n,
 	struct rte_pktmbuf_pool_private mbp_priv;
 	unsigned elt_size;
 	int ret;
+	const char *ops[] = {
+			RTE_MBUF_DEFAULT_MEMPOOL_OPS,
+			RTE_MBUF_BACKUP_MEMPOOL_OPS_1,
+			RTE_MBUF_BACKUP_MEMPOOL_OPS_2,
+			NULL,
+		};
+	const char **op;
 
 	if (RTE_ALIGN(priv_size, RTE_MBUF_PRIV_ALIGN) != priv_size) {
 		RTE_LOG(ERR, MBUF, "mbuf priv_size=%u is not aligned\n",
@@ -176,12 +183,23 @@ rte_pktmbuf_pool_create(const char *name, unsigned n,
 	if (mp == NULL)
 		return NULL;
 
-	ret = rte_mempool_set_ops_byname(mp,
-		RTE_MBUF_DEFAULT_MEMPOOL_OPS, NULL);
-	if (ret != 0) {
-		RTE_LOG(ERR, MBUF, "error setting mempool handler\n");
+	/*Check the perfered mempool ops based on config*/
+	for (op = &ops[0]; *op != NULL; op++) {
+		ret = rte_mempool_ops_check_support(mp, *op);
+		if (ret == 0)
+			break;
+	}
+	if (*op != NULL) {
+		ret = rte_mempool_set_ops_byname(mp, *op, NULL);
+		if (ret != 0) {
+			RTE_LOG(ERR, MBUF, "error setting mempool handler\n");
+			rte_mempool_free(mp);
+			rte_errno = -ret;
+			return NULL;
+		}
+	} else {
 		rte_mempool_free(mp);
-		rte_errno = -ret;
+		rte_errno = ENOTSUP;
 		return NULL;
 	}
 	rte_pktmbuf_pool_init(mp, &mbp_priv);
-- 
2.7.4



More information about the dev mailing list