[dpdk-dev,v2,2/2] mempool:pktmbuf pool default fallback for mempool ops error

Message ID 1473959607-1951-2-git-send-email-hemant.agrawal@nxp.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers

Commit Message

Hemant Agrawal Sept. 15, 2016, 5:13 p.m. UTC
  In the rte_pktmbuf_pool_create, if the default external mempool is
not available, the implementation can default to "ring_mp_mc", which
is an software implementation.

Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>
---
 lib/librte_mbuf/rte_mbuf.c | 5 +++++
 1 file changed, 5 insertions(+)
  

Comments

Hunt, David Sept. 16, 2016, 8:29 a.m. UTC | #1
Hi Hemant,

On 15/9/2016 6:13 PM, Hemant Agrawal wrote:
> In the rte_pktmbuf_pool_create, if the default external mempool is
> not available, the implementation can default to "ring_mp_mc", which
> is an software implementation.
>
> Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>
> ---
>   lib/librte_mbuf/rte_mbuf.c | 5 +++++
>   1 file changed, 5 insertions(+)
>
> diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c
> index 4846b89..4adb4f5 100644
> --- a/lib/librte_mbuf/rte_mbuf.c
> +++ b/lib/librte_mbuf/rte_mbuf.c
> @@ -176,6 +176,11 @@ rte_pktmbuf_pool_create(const char *name, unsigned n,
>   
>   	rte_errno = rte_mempool_set_ops_byname(mp,
>   			RTE_MBUF_DEFAULT_MEMPOOL_OPS, NULL);
> +
> +	/* on error, try falling back to the software based default pool */
> +	if (rte_errno == -EOPNOTSUPP)
> +		rte_errno = rte_mempool_set_ops_byname(mp, "ring_mp_mc", NULL);

Should we log a warning message here saying that we're falling back to 
the mp/mc handler?

> +
>   	if (rte_errno != 0) {
>   		RTE_LOG(ERR, MBUF, "error setting mempool handler\n");
>   		return NULL;
  
Hemant Agrawal Sept. 16, 2016, 9:34 a.m. UTC | #2
Hi David,

> -----Original Message-----
> From: Hunt, David [mailto:david.hunt@intel.com]
> Sent: Friday, September 16, 2016 2:00 PM
> To: Hemant Agrawal <hemant.agrawal@nxp.com>; olivier.matz@6wind.com
> Cc: dev@dpdk.org; jerin.jacob@caviumnetworks.com
> Subject: Re: [PATCH v2 2/2] mempool:pktmbuf pool default fallback for
> mempool ops error
> 
> Hi Hemant,
> 
> On 15/9/2016 6:13 PM, Hemant Agrawal wrote:
> > In the rte_pktmbuf_pool_create, if the default external mempool is not
> > available, the implementation can default to "ring_mp_mc", which is an
> > software implementation.
> >
> > Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>
> > ---
> >   lib/librte_mbuf/rte_mbuf.c | 5 +++++
> >   1 file changed, 5 insertions(+)
> >
> > diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c
> > index 4846b89..4adb4f5 100644
> > --- a/lib/librte_mbuf/rte_mbuf.c
> > +++ b/lib/librte_mbuf/rte_mbuf.c
> > @@ -176,6 +176,11 @@ rte_pktmbuf_pool_create(const char *name,
> > unsigned n,
> >
> >   	rte_errno = rte_mempool_set_ops_byname(mp,
> >   			RTE_MBUF_DEFAULT_MEMPOOL_OPS, NULL);
> > +
> > +	/* on error, try falling back to the software based default pool */
> > +	if (rte_errno == -EOPNOTSUPP)
> > +		rte_errno = rte_mempool_set_ops_byname(mp, "ring_mp_mc",
> NULL);
> 
> Should we log a warning message here saying that we're falling back to the
> mp/mc handler?
> 
[Hemant]Agree. Will add it. 

> > +
> >   	if (rte_errno != 0) {
> >   		RTE_LOG(ERR, MBUF, "error setting mempool handler\n");
> >   		return NULL;
  

Patch

diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c
index 4846b89..4adb4f5 100644
--- a/lib/librte_mbuf/rte_mbuf.c
+++ b/lib/librte_mbuf/rte_mbuf.c
@@ -176,6 +176,11 @@  rte_pktmbuf_pool_create(const char *name, unsigned n,
 
 	rte_errno = rte_mempool_set_ops_byname(mp,
 			RTE_MBUF_DEFAULT_MEMPOOL_OPS, NULL);
+
+	/* on error, try falling back to the software based default pool */
+	if (rte_errno == -EOPNOTSUPP)
+		rte_errno = rte_mempool_set_ops_byname(mp, "ring_mp_mc", NULL);
+
 	if (rte_errno != 0) {
 		RTE_LOG(ERR, MBUF, "error setting mempool handler\n");
 		return NULL;