summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Hunt <david.hunt@intel.com>2016-06-22 10:27:29 +0100
committerThomas Monjalon <thomas.monjalon@6wind.com>2016-06-24 11:01:05 +0200
commit152ca517900b39defec76796ca4e806c9e6d96a2 (patch)
treeb7c4540858a0844160159f965d7807d61acff3d3
parent99ca3b7a82b0fa0db8cda1f097901376dc86fdf5 (diff)
downloaddpdk-152ca517900b.zip
dpdk-152ca517900b.tar.gz
dpdk-152ca517900b.tar.xz
mbuf: use default mempool handler from config
By default, the mempool ops used for mbuf allocations is a multi producer and multi consumer ring. We could imagine a target (maybe some network processors?) that provides an hardware-assisted pool mechanism. In this case, the default configuration for this architecture would contain a different value for RTE_MBUF_DEFAULT_MEMPOOL_OPS. Signed-off-by: David Hunt <david.hunt@intel.com> Signed-off-by: Olivier Matz <olivier.matz@6wind.com> Reviewed-by: Jan Viktorin <viktorin@rehivetech.com> Acked-by: Shreyansh Jain <shreyansh.jain@nxp.com> Acked-by: Olivier Matz <olivier.matz@6wind.com>
-rw-r--r--config/common_base1
-rw-r--r--lib/librte_mbuf/rte_mbuf.c26
2 files changed, 23 insertions, 4 deletions
diff --git a/config/common_base b/config/common_base
index 3a04fba..5d9daf5 100644
--- a/config/common_base
+++ b/config/common_base
@@ -400,6 +400,7 @@ CONFIG_RTE_LIBRTE_MEMPOOL_DEBUG=n
#
CONFIG_RTE_LIBRTE_MBUF=y
CONFIG_RTE_LIBRTE_MBUF_DEBUG=n
+CONFIG_RTE_MBUF_DEFAULT_MEMPOOL_OPS="ring_mp_mc"
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 2ece742..8cf5436 100644
--- a/lib/librte_mbuf/rte_mbuf.c
+++ b/lib/librte_mbuf/rte_mbuf.c
@@ -153,6 +153,7 @@ rte_pktmbuf_pool_create(const char *name, unsigned n,
unsigned cache_size, uint16_t priv_size, uint16_t data_room_size,
int socket_id)
{
+ struct rte_mempool *mp;
struct rte_pktmbuf_pool_private mbp_priv;
unsigned elt_size;
@@ -167,10 +168,27 @@ rte_pktmbuf_pool_create(const char *name, unsigned n,
mbp_priv.mbuf_data_room_size = data_room_size;
mbp_priv.mbuf_priv_size = priv_size;
- return rte_mempool_create(name, n, elt_size,
- cache_size, sizeof(struct rte_pktmbuf_pool_private),
- rte_pktmbuf_pool_init, &mbp_priv, rte_pktmbuf_init, NULL,
- socket_id, 0);
+ mp = rte_mempool_create_empty(name, n, elt_size, cache_size,
+ sizeof(struct rte_pktmbuf_pool_private), socket_id, 0);
+ if (mp == NULL)
+ return NULL;
+
+ rte_errno = rte_mempool_set_ops_byname(mp,
+ RTE_MBUF_DEFAULT_MEMPOOL_OPS, NULL);
+ if (rte_errno != 0) {
+ RTE_LOG(ERR, MBUF, "error setting mempool handler\n");
+ return NULL;
+ }
+ rte_pktmbuf_pool_init(mp, &mbp_priv);
+
+ if (rte_mempool_populate_default(mp) < 0) {
+ rte_mempool_free(mp);
+ return NULL;
+ }
+
+ rte_mempool_obj_iter(mp, rte_pktmbuf_init, NULL);
+
+ return mp;
}
/* do some sanity checks on a mbuf: panic if it fails */