On Tue, Jan 23, 2018 at 01:16:06PM +0000, Andrew Rybchenko wrote:
> From: "Artem V. Andreev" <artem.andr...@oktetlabs.ru>
> 
> Callback to calculate required memory area size may require mempool
> driver data to be already allocated and initialized.
> 
> Signed-off-by: Artem V. Andreev <artem.andr...@oktetlabs.ru>
> Signed-off-by: Andrew Rybchenko <arybche...@solarflare.com>
> ---
>  lib/librte_mempool/rte_mempool.c | 29 ++++++++++++++++++++++-------
>  1 file changed, 22 insertions(+), 7 deletions(-)
> 
> diff --git a/lib/librte_mempool/rte_mempool.c 
> b/lib/librte_mempool/rte_mempool.c
> index fc9c95a..cbb4dd5 100644
> --- a/lib/librte_mempool/rte_mempool.c
> +++ b/lib/librte_mempool/rte_mempool.c
> @@ -370,6 +370,21 @@ rte_mempool_free_memchunks(struct rte_mempool *mp)
>       }
>  }
>  
> +static int
> +mempool_maybe_initialize(struct rte_mempool *mp)
> +{
> +     int ret;
> +
> +     /* create the internal ring if not already done */
> +     if ((mp->flags & MEMPOOL_F_POOL_CREATED) == 0) {
> +             ret = rte_mempool_ops_alloc(mp);
> +             if (ret != 0)
> +                     return ret;
> +             mp->flags |= MEMPOOL_F_POOL_CREATED;
> +     }
> +     return 0;
> +}

mempool_ops_alloc_once() ?

Reply via email to