On Mon, Mar 26, 2018 at 05:12:56PM +0100, Andrew Rybchenko wrote: > From: "Artem V. Andreev" <artem.andr...@oktetlabs.ru> > > If mempool manager supports object blocks (physically and virtual > contiguous set of objects), it is sufficient to get the first > object only and the function allows to avoid filling in of > information about each block member. > > Signed-off-by: Artem V. Andreev <artem.andr...@oktetlabs.ru> > Signed-off-by: Andrew Rybchenko <arybche...@solarflare.com>
Minor things here, please see below. [...] > @@ -1531,6 +1615,71 @@ rte_mempool_get(struct rte_mempool *mp, void **obj_p) > } > > /** > + * @internal Get contiguous blocks of objects from the pool. Used internally. > + * @param mp > + * A pointer to the mempool structure. > + * @param first_obj_table > + * A pointer to a pointer to the first object in each block. > + * @param n > + * A number of blocks to get. > + * @return > + * - >0: Success > + * - <0: Error I guess it is 0 here, not >0. > + */ > +static __rte_always_inline int > +__mempool_generic_get_contig_blocks(struct rte_mempool *mp, > + void **first_obj_table, unsigned int n) > +{ > + int ret; > + > + ret = rte_mempool_ops_dequeue_contig_blocks(mp, first_obj_table, n); > + if (ret < 0) > + __MEMPOOL_CONTIG_BLOCKS_STAT_ADD(mp, get_fail, n); > + else > + __MEMPOOL_CONTIG_BLOCKS_STAT_ADD(mp, get_success, n); > + > + return ret; > +} > + Is it worth having this function? I think it would be simple to include the code in rte_mempool_get_contig_blocks() below... or am I missing something? > +/** > + * @warning > + * @b EXPERIMENTAL: this API may change without prior notice. > + * > + * Get a contiguous blocks of objects from the mempool. > + * > + * If cache is enabled, consider to flush it first, to reuse objects > + * as soon as possible. > + * > + * The application should check that the driver supports the operation > + * by calling rte_mempool_ops_get_info() and checking that > `contig_block_size` > + * is not zero. > + * > + * @param mp > + * A pointer to the mempool structure. > + * @param first_obj_table > + * A pointer to a pointer to the first object in each block. > + * @param n > + * The number of blocks to get from mempool. > + * @return > + * - 0: Success; blocks taken. > + * - -ENOBUFS: Not enough entries in the mempool; no object is retrieved. > + * - -EOPNOTSUPP: The mempool driver does not support block dequeue > + */ > +static __rte_always_inline int > +__rte_experimental > +rte_mempool_get_contig_blocks(struct rte_mempool *mp, > + void **first_obj_table, unsigned int n) > +{ > + int ret; > + > + ret = __mempool_generic_get_contig_blocks(mp, first_obj_table, n); > + if (ret == 0) > + __mempool_contig_blocks_check_cookies(mp, first_obj_table, n, > + 1); > + return ret; > +}