[dpdk-dev,5/5] mempool: allow rte_pktmbuf_pool_create switch between memool handlers

Message ID 1453829155-1366-6-git-send-email-david.hunt@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers

Commit Message

Hunt, David Jan. 26, 2016, 5:25 p.m. UTC
  if the user wants to have rte_pktmbuf_pool_create() use an external mempool
handler, they simply define MEMPOOL_HANDLER_NAME to be the name of the
mempool handler they wish to use. May move this to config

Signed-off-by: David Hunt <david.hunt@intel.com>
---
 lib/librte_mbuf/rte_mbuf.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
  

Comments

Olivier Matz Feb. 5, 2016, 10:11 a.m. UTC | #1
Hi David,

On 01/26/2016 06:25 PM, David Hunt wrote:
> if the user wants to have rte_pktmbuf_pool_create() use an external mempool
> handler, they simply define MEMPOOL_HANDLER_NAME to be the name of the
> mempool handler they wish to use. May move this to config

I agree it could move to configuration.


> 
> Signed-off-by: David Hunt <david.hunt@intel.com>
> ---
>  lib/librte_mbuf/rte_mbuf.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c
> index c18b438..362396e 100644
> --- a/lib/librte_mbuf/rte_mbuf.c
> +++ b/lib/librte_mbuf/rte_mbuf.c
> @@ -167,10 +167,21 @@ 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;
>  
> +/* #define MEMPOOL_HANDLER_NAME "custom_handler" */
> +#undef MEMPOOL_HANDLER_NAME
> +
> +#ifndef MEMPOOL_HANDLER_NAME
>  	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);
> +#else
> +	return rte_mempool_create_ext(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,
> +		MEMPOOL_HANDLER_NAME);
> +#endif
>  }

Is it possible to always use rte_mempool_create_ext(), and set
the default handler name to 'ring_mp_mc'?

After checking in rte_mempool_create(), I found the behavior
is different when using xen. Do you know if xen still works with
your patches?

Regards,
Olivier
  

Patch

diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c
index c18b438..362396e 100644
--- a/lib/librte_mbuf/rte_mbuf.c
+++ b/lib/librte_mbuf/rte_mbuf.c
@@ -167,10 +167,21 @@  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;
 
+/* #define MEMPOOL_HANDLER_NAME "custom_handler" */
+#undef MEMPOOL_HANDLER_NAME
+
+#ifndef MEMPOOL_HANDLER_NAME
 	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);
+#else
+	return rte_mempool_create_ext(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,
+		MEMPOOL_HANDLER_NAME);
+#endif
 }
 
 /* do some sanity checks on a mbuf: panic if it fails */