On Tue, Jan 23, 2018 at 01:15:59PM +0000, Andrew Rybchenko wrote:
> The callback allows to customize how objects are stored in the
> memory chunk. Default implementation of the callback which simply
> puts objects one by one is available.
> 
> Suggested-by: Olivier Matz <olivier.m...@6wind.com>
> Signed-off-by: Andrew Rybchenko <arybche...@solarflare.com>

...

>  
> +int
> +rte_mempool_populate_one_by_one(struct rte_mempool *mp, unsigned int 
> max_objs,
> +             void *vaddr, rte_iova_t iova, size_t len,
> +             rte_mempool_populate_obj_cb_t *obj_cb)

We shall find a better name for this function.
Unfortunatly rte_mempool_populate_default() already exists...

I'm also wondering if having a file rte_mempool_ops_default.c
with all the default behaviors would make sense?

...

> @@ -466,16 +487,13 @@ rte_mempool_populate_iova(struct rte_mempool *mp, char 
> *vaddr,
>       else
>               off = RTE_PTR_ALIGN_CEIL(vaddr, RTE_CACHE_LINE_SIZE) - vaddr;
>  
> -     while (off + total_elt_sz <= len && mp->populated_size < mp->size) {
> -             off += mp->header_size;
> -             if (iova == RTE_BAD_IOVA)
> -                     mempool_add_elem(mp, (char *)vaddr + off,
> -                             RTE_BAD_IOVA);
> -             else
> -                     mempool_add_elem(mp, (char *)vaddr + off, iova + off);
> -             off += mp->elt_size + mp->trailer_size;
> -             i++;
> -     }
> +     if (off > len)
> +             return -EINVAL;
> +
> +     i = rte_mempool_ops_populate(mp, mp->size - mp->populated_size,
> +             (char *)vaddr + off,
> +             (iova == RTE_BAD_IOVA) ? RTE_BAD_IOVA : (iova + off),
> +             len - off, mempool_add_elem);

My initial idea was to provide populate_iova(), populate_virt(), ...
as mempool ops. I don't see any strong requirement for doing it now, but
on the other hand it would break the API to do it later. What's
your opinion?

Also, I see that mempool_add_elem() is passed as a callback to
rte_mempool_ops_populate(). Instead, would it make sense to
export mempool_add_elem() and let the implementation of populate()
ops to call it?

Reply via email to