4 * Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
5 * Copyright(c) 2016 6WIND S.A.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in
16 * the documentation and/or other materials provided with the
18 * * Neither the name of Intel Corporation nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 #ifndef _RTE_MEMPOOL_H_
36 #define _RTE_MEMPOOL_H_
42 * A memory pool is an allocator of fixed-size object. It is
43 * identified by its name, and uses a ring to store free objects. It
44 * provides some other optional services, like a per-core object
45 * cache, and an alignment helper to ensure that objects are padded
46 * to spread them equally on all RAM channels, ranks, and so on.
48 * Objects owned by a mempool should never be added in another
49 * mempool. When an object is freed using rte_mempool_put() or
50 * equivalent, the object data is not modified; the user can save some
51 * meta-data in the object data and retrieve them when allocating a
54 * Note: the mempool implementation is not preemptable. A lcore must
55 * not be interrupted by another task that uses the same mempool
56 * (because it uses a ring which is not preemptable). Also, mempool
57 * functions must not be used outside the DPDK environment: for
58 * example, in linuxapp environment, a thread that is not created by
59 * the EAL must not use mempools. This is due to the per-lcore cache
60 * that won't work as rte_lcore_id() will not return a correct value.
68 #include <sys/queue.h>
70 #include <rte_spinlock.h>
72 #include <rte_debug.h>
73 #include <rte_lcore.h>
74 #include <rte_memory.h>
75 #include <rte_branch_prediction.h>
82 #define RTE_MEMPOOL_HEADER_COOKIE1 0xbadbadbadadd2e55ULL /**< Header cookie. */
83 #define RTE_MEMPOOL_HEADER_COOKIE2 0xf2eef2eedadd2e55ULL /**< Header cookie. */
84 #define RTE_MEMPOOL_TRAILER_COOKIE 0xadd2e55badbadbadULL /**< Trailer cookie.*/
86 #ifdef RTE_LIBRTE_MEMPOOL_DEBUG
88 * A structure that stores the mempool statistics (per-lcore).
90 struct rte_mempool_debug_stats {
91 uint64_t put_bulk; /**< Number of puts. */
92 uint64_t put_objs; /**< Number of objects successfully put. */
93 uint64_t get_success_bulk; /**< Successful allocation number. */
94 uint64_t get_success_objs; /**< Objects successfully allocated. */
95 uint64_t get_fail_bulk; /**< Failed allocation number. */
96 uint64_t get_fail_objs; /**< Objects that failed to be allocated. */
97 } __rte_cache_aligned;
101 * A structure that stores a per-core object cache.
103 struct rte_mempool_cache {
104 unsigned len; /**< Cache len */
106 * Cache is allocated to this size to allow it to overflow in certain
107 * cases to avoid needless emptying of cache.
109 void *objs[RTE_MEMPOOL_CACHE_MAX_SIZE * 3]; /**< Cache objects */
110 } __rte_cache_aligned;
113 * A structure that stores the size of mempool elements.
115 struct rte_mempool_objsz {
116 uint32_t elt_size; /**< Size of an element. */
117 uint32_t header_size; /**< Size of header (before elt). */
118 uint32_t trailer_size; /**< Size of trailer (after elt). */
120 /**< Total size of an object (header + elt + trailer). */
123 #define RTE_MEMPOOL_NAMESIZE 32 /**< Maximum length of a memory pool. */
124 #define RTE_MEMPOOL_MZ_PREFIX "MP_"
127 #define RTE_MEMPOOL_MZ_FORMAT RTE_MEMPOOL_MZ_PREFIX "%s"
129 #define MEMPOOL_PG_SHIFT_MAX (sizeof(uintptr_t) * CHAR_BIT - 1)
131 /** Mempool over one chunk of physically continuous memory */
132 #define MEMPOOL_PG_NUM_DEFAULT 1
134 #ifndef RTE_MEMPOOL_ALIGN
135 #define RTE_MEMPOOL_ALIGN RTE_CACHE_LINE_SIZE
138 #define RTE_MEMPOOL_ALIGN_MASK (RTE_MEMPOOL_ALIGN - 1)
141 * Mempool object header structure
143 * Each object stored in mempools are prefixed by this header structure,
144 * it allows to retrieve the mempool pointer from the object and to
145 * iterate on all objects attached to a mempool. When debug is enabled,
146 * a cookie is also added in this structure preventing corruptions and
149 struct rte_mempool_objhdr {
150 STAILQ_ENTRY(rte_mempool_objhdr) next; /**< Next in list. */
151 struct rte_mempool *mp; /**< The mempool owning the object. */
152 phys_addr_t physaddr; /**< Physical address of the object. */
153 #ifdef RTE_LIBRTE_MEMPOOL_DEBUG
154 uint64_t cookie; /**< Debug cookie. */
159 * A list of object headers type
161 STAILQ_HEAD(rte_mempool_objhdr_list, rte_mempool_objhdr);
164 * Mempool object trailer structure
166 * In debug mode, each object stored in mempools are suffixed by this
167 * trailer structure containing a cookie preventing memory corruptions.
169 struct rte_mempool_objtlr {
170 #ifdef RTE_LIBRTE_MEMPOOL_DEBUG
171 uint64_t cookie; /**< Debug cookie. */
176 * A list of memory where objects are stored
178 STAILQ_HEAD(rte_mempool_memhdr_list, rte_mempool_memhdr);
181 * Callback used to free a memory chunk
183 typedef void (rte_mempool_memchunk_free_cb_t)(struct rte_mempool_memhdr *memhdr,
187 * Mempool objects memory header structure
189 * The memory chunks where objects are stored. Each chunk is virtually
190 * and physically contiguous.
192 struct rte_mempool_memhdr {
193 STAILQ_ENTRY(rte_mempool_memhdr) next; /**< Next in list. */
194 struct rte_mempool *mp; /**< The mempool owning the chunk */
195 void *addr; /**< Virtual address of the chunk */
196 phys_addr_t phys_addr; /**< Physical address of the chunk */
197 size_t len; /**< length of the chunk */
198 rte_mempool_memchunk_free_cb_t *free_cb; /**< Free callback */
199 void *opaque; /**< Argument passed to the free callback */
203 * The RTE mempool structure.
206 char name[RTE_MEMPOOL_NAMESIZE]; /**< Name of mempool. */
208 void *pool_data; /**< Ring or pool to store objects. */
209 uint64_t pool_id; /**< External mempool identifier. */
211 void *pool_config; /**< optional args for ops alloc. */
212 const struct rte_memzone *mz; /**< Memzone where pool is alloc'd. */
213 int flags; /**< Flags of the mempool. */
214 int socket_id; /**< Socket id passed at create. */
215 uint32_t size; /**< Max size of the mempool. */
216 uint32_t cache_size; /**< Size of per-lcore local cache. */
217 uint32_t cache_flushthresh;
218 /**< Threshold before we flush excess elements. */
220 uint32_t elt_size; /**< Size of an element. */
221 uint32_t header_size; /**< Size of header (before elt). */
222 uint32_t trailer_size; /**< Size of trailer (after elt). */
224 unsigned private_data_size; /**< Size of private data. */
226 * Index into rte_mempool_ops_table array of mempool ops
227 * structs, which contain callback function pointers.
228 * We're using an index here rather than pointers to the callbacks
229 * to facilitate any secondary processes that may want to use
234 struct rte_mempool_cache *local_cache; /**< Per-lcore local cache */
236 uint32_t populated_size; /**< Number of populated objects. */
237 struct rte_mempool_objhdr_list elt_list; /**< List of objects in pool */
238 uint32_t nb_mem_chunks; /**< Number of memory chunks */
239 struct rte_mempool_memhdr_list mem_list; /**< List of memory chunks */
241 #ifdef RTE_LIBRTE_MEMPOOL_DEBUG
242 /** Per-lcore statistics. */
243 struct rte_mempool_debug_stats stats[RTE_MAX_LCORE];
245 } __rte_cache_aligned;
247 #define MEMPOOL_F_NO_SPREAD 0x0001 /**< Do not spread among memory channels. */
248 #define MEMPOOL_F_NO_CACHE_ALIGN 0x0002 /**< Do not align objs on cache lines.*/
249 #define MEMPOOL_F_SP_PUT 0x0004 /**< Default put is "single-producer".*/
250 #define MEMPOOL_F_SC_GET 0x0008 /**< Default get is "single-consumer".*/
251 #define MEMPOOL_F_POOL_CREATED 0x0010 /**< Internal: pool is created. */
252 #define MEMPOOL_F_NO_PHYS_CONTIG 0x0020 /**< Don't need physically contiguous objs. */
255 * @internal When debug is enabled, store some statistics.
258 * Pointer to the memory pool.
260 * Name of the statistics field to increment in the memory pool.
262 * Number to add to the object-oriented statistics.
264 #ifdef RTE_LIBRTE_MEMPOOL_DEBUG
265 #define __MEMPOOL_STAT_ADD(mp, name, n) do { \
266 unsigned __lcore_id = rte_lcore_id(); \
267 if (__lcore_id < RTE_MAX_LCORE) { \
268 mp->stats[__lcore_id].name##_objs += n; \
269 mp->stats[__lcore_id].name##_bulk += 1; \
273 #define __MEMPOOL_STAT_ADD(mp, name, n) do {} while(0)
277 * Calculate the size of the mempool header.
280 * Pointer to the memory pool.
282 * Size of the per-lcore cache.
284 #define MEMPOOL_HEADER_SIZE(mp, cs) \
285 (sizeof(*(mp)) + (((cs) == 0) ? 0 : \
286 (sizeof(struct rte_mempool_cache) * RTE_MAX_LCORE)))
288 /* return the header of a mempool object (internal) */
289 static inline struct rte_mempool_objhdr *__mempool_get_header(void *obj)
291 return (struct rte_mempool_objhdr *)RTE_PTR_SUB(obj,
292 sizeof(struct rte_mempool_objhdr));
296 * Return a pointer to the mempool owning this object.
299 * An object that is owned by a pool. If this is not the case,
300 * the behavior is undefined.
302 * A pointer to the mempool structure.
304 static inline struct rte_mempool *rte_mempool_from_obj(void *obj)
306 struct rte_mempool_objhdr *hdr = __mempool_get_header(obj);
310 /* return the trailer of a mempool object (internal) */
311 static inline struct rte_mempool_objtlr *__mempool_get_trailer(void *obj)
313 struct rte_mempool *mp = rte_mempool_from_obj(obj);
314 return (struct rte_mempool_objtlr *)RTE_PTR_ADD(obj, mp->elt_size);
318 * @internal Check and update cookies or panic.
321 * Pointer to the memory pool.
322 * @param obj_table_const
323 * Pointer to a table of void * pointers (objects).
325 * Index of object in object table.
327 * - 0: object is supposed to be allocated, mark it as free
328 * - 1: object is supposed to be free, mark it as allocated
329 * - 2: just check that cookie is valid (free or allocated)
331 void rte_mempool_check_cookies(const struct rte_mempool *mp,
332 void * const *obj_table_const, unsigned n, int free);
334 #ifdef RTE_LIBRTE_MEMPOOL_DEBUG
335 #define __mempool_check_cookies(mp, obj_table_const, n, free) \
336 rte_mempool_check_cookies(mp, obj_table_const, n, free)
338 #define __mempool_check_cookies(mp, obj_table_const, n, free) do {} while(0)
339 #endif /* RTE_LIBRTE_MEMPOOL_DEBUG */
341 #define RTE_MEMPOOL_OPS_NAMESIZE 32 /**< Max length of ops struct name. */
344 * Prototype for implementation specific data provisioning function.
346 * The function should provide the implementation specific memory for
347 * for use by the other mempool ops functions in a given mempool ops struct.
348 * E.g. the default ops provides an instance of the rte_ring for this purpose.
349 * it will most likely point to a different type of data structure, and
350 * will be transparent to the application programmer.
351 * This function should set mp->pool_data.
353 typedef int (*rte_mempool_alloc_t)(struct rte_mempool *mp);
356 * Free the opaque private data pointed to by mp->pool_data pointer.
358 typedef void (*rte_mempool_free_t)(struct rte_mempool *mp);
361 * Enqueue an object into the external pool.
363 typedef int (*rte_mempool_enqueue_t)(struct rte_mempool *mp,
364 void * const *obj_table, unsigned int n);
367 * Dequeue an object from the external pool.
369 typedef int (*rte_mempool_dequeue_t)(struct rte_mempool *mp,
370 void **obj_table, unsigned int n);
373 * Return the number of available objects in the external pool.
375 typedef unsigned (*rte_mempool_get_count)(const struct rte_mempool *mp);
377 /** Structure defining mempool operations structure */
378 struct rte_mempool_ops {
379 char name[RTE_MEMPOOL_OPS_NAMESIZE]; /**< Name of mempool ops struct. */
380 rte_mempool_alloc_t alloc; /**< Allocate private data. */
381 rte_mempool_free_t free; /**< Free the external pool. */
382 rte_mempool_enqueue_t enqueue; /**< Enqueue an object. */
383 rte_mempool_dequeue_t dequeue; /**< Dequeue an object. */
384 rte_mempool_get_count get_count; /**< Get qty of available objs. */
385 } __rte_cache_aligned;
387 #define RTE_MEMPOOL_MAX_OPS_IDX 16 /**< Max registered ops structs */
390 * Structure storing the table of registered ops structs, each of which contain
391 * the function pointers for the mempool ops functions.
392 * Each process has its own storage for this ops struct array so that
393 * the mempools can be shared across primary and secondary processes.
394 * The indices used to access the array are valid across processes, whereas
395 * any function pointers stored directly in the mempool struct would not be.
396 * This results in us simply having "ops_index" in the mempool struct.
398 struct rte_mempool_ops_table {
399 rte_spinlock_t sl; /**< Spinlock for add/delete. */
400 uint32_t num_ops; /**< Number of used ops structs in the table. */
402 * Storage for all possible ops structs.
404 struct rte_mempool_ops ops[RTE_MEMPOOL_MAX_OPS_IDX];
405 } __rte_cache_aligned;
407 /** Array of registered ops structs. */
408 extern struct rte_mempool_ops_table rte_mempool_ops_table;
411 * @internal Get the mempool ops struct from its index.
414 * The index of the ops struct in the ops struct table. It must be a valid
415 * index: (0 <= idx < num_ops).
417 * The pointer to the ops struct in the table.
419 static inline struct rte_mempool_ops *
420 rte_mempool_get_ops(int ops_index)
422 RTE_VERIFY((ops_index >= 0) && (ops_index < RTE_MEMPOOL_MAX_OPS_IDX));
424 return &rte_mempool_ops_table.ops[ops_index];
428 * @internal Wrapper for mempool_ops alloc callback.
431 * Pointer to the memory pool.
433 * - 0: Success; successfully allocated mempool pool_data.
434 * - <0: Error; code of alloc function.
437 rte_mempool_ops_alloc(struct rte_mempool *mp);
440 * @internal Wrapper for mempool_ops dequeue callback.
443 * Pointer to the memory pool.
445 * Pointer to a table of void * pointers (objects).
447 * Number of objects to get.
449 * - 0: Success; got n objects.
450 * - <0: Error; code of dequeue function.
453 rte_mempool_ops_dequeue_bulk(struct rte_mempool *mp,
454 void **obj_table, unsigned n)
456 struct rte_mempool_ops *ops;
458 ops = rte_mempool_get_ops(mp->ops_index);
459 return ops->dequeue(mp, obj_table, n);
463 * @internal wrapper for mempool_ops enqueue callback.
466 * Pointer to the memory pool.
468 * Pointer to a table of void * pointers (objects).
470 * Number of objects to put.
472 * - 0: Success; n objects supplied.
473 * - <0: Error; code of enqueue function.
476 rte_mempool_ops_enqueue_bulk(struct rte_mempool *mp, void * const *obj_table,
479 struct rte_mempool_ops *ops;
481 ops = rte_mempool_get_ops(mp->ops_index);
482 return ops->enqueue(mp, obj_table, n);
486 * @internal wrapper for mempool_ops get_count callback.
489 * Pointer to the memory pool.
491 * The number of available objects in the external pool.
494 rte_mempool_ops_get_count(const struct rte_mempool *mp);
497 * @internal wrapper for mempool_ops free callback.
500 * Pointer to the memory pool.
503 rte_mempool_ops_free(struct rte_mempool *mp);
506 * Set the ops of a mempool.
508 * This can only be done on a mempool that is not populated, i.e. just after
509 * a call to rte_mempool_create_empty().
512 * Pointer to the memory pool.
514 * Name of the ops structure to use for this mempool.
516 * Opaque data that can be passed by the application to the ops functions.
518 * - 0: Success; the mempool is now using the requested ops functions.
519 * - -EINVAL - Invalid ops struct name provided.
520 * - -EEXIST - mempool already has an ops struct assigned.
523 rte_mempool_set_ops_byname(struct rte_mempool *mp, const char *name,
527 * Register mempool operations.
530 * Pointer to an ops structure to register.
532 * - >=0: Success; return the index of the ops struct in the table.
533 * - -EINVAL - some missing callbacks while registering ops struct.
534 * - -ENOSPC - the maximum number of ops structs has been reached.
536 int rte_mempool_register_ops(const struct rte_mempool_ops *ops);
539 * Macro to statically register the ops of a mempool handler.
540 * Note that the rte_mempool_register_ops fails silently here when
541 * more then RTE_MEMPOOL_MAX_OPS_IDX is registered.
543 #define MEMPOOL_REGISTER_OPS(ops) \
544 void mp_hdlr_init_##ops(void); \
545 void __attribute__((constructor, used)) mp_hdlr_init_##ops(void)\
547 rte_mempool_register_ops(&ops); \
551 * An object callback function for mempool.
553 * Used by rte_mempool_create() and rte_mempool_obj_iter().
555 typedef void (rte_mempool_obj_cb_t)(struct rte_mempool *mp,
556 void *opaque, void *obj, unsigned obj_idx);
557 typedef rte_mempool_obj_cb_t rte_mempool_obj_ctor_t; /* compat */
560 * A memory callback function for mempool.
562 * Used by rte_mempool_mem_iter().
564 typedef void (rte_mempool_mem_cb_t)(struct rte_mempool *mp,
565 void *opaque, struct rte_mempool_memhdr *memhdr,
569 * A mempool constructor callback function.
571 * Arguments are the mempool and the opaque pointer given by the user in
572 * rte_mempool_create().
574 typedef void (rte_mempool_ctor_t)(struct rte_mempool *, void *);
577 * Create a new mempool named *name* in memory.
579 * This function uses ``memzone_reserve()`` to allocate memory. The
580 * pool contains n elements of elt_size. Its size is set to n.
581 * All elements of the mempool are allocated together with the mempool header,
582 * in one physically continuous chunk of memory.
585 * The name of the mempool.
587 * The number of elements in the mempool. The optimum size (in terms of
588 * memory usage) for a mempool is when n is a power of two minus one:
591 * The size of each element.
593 * If cache_size is non-zero, the rte_mempool library will try to
594 * limit the accesses to the common lockless pool, by maintaining a
595 * per-lcore object cache. This argument must be lower or equal to
596 * CONFIG_RTE_MEMPOOL_CACHE_MAX_SIZE and n / 1.5. It is advised to choose
597 * cache_size to have "n modulo cache_size == 0": if this is
598 * not the case, some elements will always stay in the pool and will
599 * never be used. The access to the per-lcore table is of course
600 * faster than the multi-producer/consumer pool. The cache can be
601 * disabled if the cache_size argument is set to 0; it can be useful to
602 * avoid losing objects in cache. Note that even if not used, the
603 * memory space for cache is always reserved in a mempool structure,
604 * except if CONFIG_RTE_MEMPOOL_CACHE_MAX_SIZE is set to 0.
605 * @param private_data_size
606 * The size of the private data appended after the mempool
607 * structure. This is useful for storing some private data after the
608 * mempool structure, as is done for rte_mbuf_pool for example.
610 * A function pointer that is called for initialization of the pool,
611 * before object initialization. The user can initialize the private
612 * data in this function if needed. This parameter can be NULL if
615 * An opaque pointer to data that can be used in the mempool
616 * constructor function.
618 * A function pointer that is called for each object at
619 * initialization of the pool. The user can set some meta data in
620 * objects if needed. This parameter can be NULL if not needed.
621 * The obj_init() function takes the mempool pointer, the init_arg,
622 * the object pointer and the object number as parameters.
623 * @param obj_init_arg
624 * An opaque pointer to data that can be used as an argument for
625 * each call to the object constructor function.
627 * The *socket_id* argument is the socket identifier in the case of
628 * NUMA. The value can be *SOCKET_ID_ANY* if there is no NUMA
629 * constraint for the reserved zone.
631 * The *flags* arguments is an OR of following flags:
632 * - MEMPOOL_F_NO_SPREAD: By default, objects addresses are spread
633 * between channels in RAM: the pool allocator will add padding
634 * between objects depending on the hardware configuration. See
635 * Memory alignment constraints for details. If this flag is set,
636 * the allocator will just align them to a cache line.
637 * - MEMPOOL_F_NO_CACHE_ALIGN: By default, the returned objects are
638 * cache-aligned. This flag removes this constraint, and no
639 * padding will be present between objects. This flag implies
640 * MEMPOOL_F_NO_SPREAD.
641 * - MEMPOOL_F_SP_PUT: If this flag is set, the default behavior
642 * when using rte_mempool_put() or rte_mempool_put_bulk() is
643 * "single-producer". Otherwise, it is "multi-producers".
644 * - MEMPOOL_F_SC_GET: If this flag is set, the default behavior
645 * when using rte_mempool_get() or rte_mempool_get_bulk() is
646 * "single-consumer". Otherwise, it is "multi-consumers".
647 * - MEMPOOL_F_NO_PHYS_CONTIG: If set, allocated objects won't
648 * necessarilly be contiguous in physical memory.
650 * The pointer to the new allocated mempool, on success. NULL on error
651 * with rte_errno set appropriately. Possible rte_errno values include:
652 * - E_RTE_NO_CONFIG - function could not get pointer to rte_config structure
653 * - E_RTE_SECONDARY - function was called from a secondary process instance
654 * - EINVAL - cache size provided is too large
655 * - ENOSPC - the maximum number of memzones has already been allocated
656 * - EEXIST - a memzone with the same name already exists
657 * - ENOMEM - no appropriate memory area found in which to create memzone
660 rte_mempool_create(const char *name, unsigned n, unsigned elt_size,
661 unsigned cache_size, unsigned private_data_size,
662 rte_mempool_ctor_t *mp_init, void *mp_init_arg,
663 rte_mempool_obj_cb_t *obj_init, void *obj_init_arg,
664 int socket_id, unsigned flags);
667 * Create a new mempool named *name* in memory.
669 * The pool contains n elements of elt_size. Its size is set to n.
670 * This function uses ``memzone_reserve()`` to allocate the mempool header
671 * (and the objects if vaddr is NULL).
672 * Depending on the input parameters, mempool elements can be either allocated
673 * together with the mempool header, or an externally provided memory buffer
674 * could be used to store mempool objects. In later case, that external
675 * memory buffer can consist of set of disjoint physical pages.
678 * The name of the mempool.
680 * The number of elements in the mempool. The optimum size (in terms of
681 * memory usage) for a mempool is when n is a power of two minus one:
684 * The size of each element.
686 * Size of the cache. See rte_mempool_create() for details.
687 * @param private_data_size
688 * The size of the private data appended after the mempool
689 * structure. This is useful for storing some private data after the
690 * mempool structure, as is done for rte_mbuf_pool for example.
692 * A function pointer that is called for initialization of the pool,
693 * before object initialization. The user can initialize the private
694 * data in this function if needed. This parameter can be NULL if
697 * An opaque pointer to data that can be used in the mempool
698 * constructor function.
700 * A function called for each object at initialization of the pool.
701 * See rte_mempool_create() for details.
702 * @param obj_init_arg
703 * An opaque pointer passed to the object constructor function.
705 * The *socket_id* argument is the socket identifier in the case of
706 * NUMA. The value can be *SOCKET_ID_ANY* if there is no NUMA
707 * constraint for the reserved zone.
709 * Flags controlling the behavior of the mempool. See
710 * rte_mempool_create() for details.
712 * Virtual address of the externally allocated memory buffer.
713 * Will be used to store mempool objects.
715 * Array of physical addresses of the pages that comprises given memory
718 * Number of elements in the paddr array.
720 * LOG2 of the physical pages size.
722 * The pointer to the new allocated mempool, on success. NULL on error
723 * with rte_errno set appropriately. See rte_mempool_create() for details.
726 rte_mempool_xmem_create(const char *name, unsigned n, unsigned elt_size,
727 unsigned cache_size, unsigned private_data_size,
728 rte_mempool_ctor_t *mp_init, void *mp_init_arg,
729 rte_mempool_obj_cb_t *obj_init, void *obj_init_arg,
730 int socket_id, unsigned flags, void *vaddr,
731 const phys_addr_t paddr[], uint32_t pg_num, uint32_t pg_shift);
734 * Create an empty mempool
736 * The mempool is allocated and initialized, but it is not populated: no
737 * memory is allocated for the mempool elements. The user has to call
738 * rte_mempool_populate_*() or to add memory chunks to the pool. Once
739 * populated, the user may also want to initialize each object with
740 * rte_mempool_obj_iter().
743 * The name of the mempool.
745 * The maximum number of elements that can be added in the mempool.
746 * The optimum size (in terms of memory usage) for a mempool is when n
747 * is a power of two minus one: n = (2^q - 1).
749 * The size of each element.
751 * Size of the cache. See rte_mempool_create() for details.
752 * @param private_data_size
753 * The size of the private data appended after the mempool
754 * structure. This is useful for storing some private data after the
755 * mempool structure, as is done for rte_mbuf_pool for example.
757 * The *socket_id* argument is the socket identifier in the case of
758 * NUMA. The value can be *SOCKET_ID_ANY* if there is no NUMA
759 * constraint for the reserved zone.
761 * Flags controlling the behavior of the mempool. See
762 * rte_mempool_create() for details.
764 * The pointer to the new allocated mempool, on success. NULL on error
765 * with rte_errno set appropriately. See rte_mempool_create() for details.
768 rte_mempool_create_empty(const char *name, unsigned n, unsigned elt_size,
769 unsigned cache_size, unsigned private_data_size,
770 int socket_id, unsigned flags);
774 * Unlink the mempool from global list, free the memory chunks, and all
775 * memory referenced by the mempool. The objects must not be used by
776 * other cores as they will be freed.
779 * A pointer to the mempool structure.
782 rte_mempool_free(struct rte_mempool *mp);
785 * Add physically contiguous memory for objects in the pool at init
787 * Add a virtually and physically contiguous memory chunk in the pool
788 * where objects can be instanciated.
791 * A pointer to the mempool structure.
793 * The virtual address of memory that should be used to store objects.
795 * The physical address
797 * The length of memory in bytes.
799 * The callback used to free this chunk when destroying the mempool.
801 * An opaque argument passed to free_cb.
803 * The number of objects added on success.
804 * On error, the chunk is not added in the memory list of the
805 * mempool and a negative errno is returned.
807 int rte_mempool_populate_phys(struct rte_mempool *mp, char *vaddr,
808 phys_addr_t paddr, size_t len, rte_mempool_memchunk_free_cb_t *free_cb,
812 * Add physical memory for objects in the pool at init
814 * Add a virtually contiguous memory chunk in the pool where objects can
815 * be instanciated. The physical addresses corresponding to the virtual
816 * area are described in paddr[], pg_num, pg_shift.
819 * A pointer to the mempool structure.
821 * The virtual address of memory that should be used to store objects.
823 * An array of physical addresses of each page composing the virtual
826 * Number of elements in the paddr array.
828 * LOG2 of the physical pages size.
830 * The callback used to free this chunk when destroying the mempool.
832 * An opaque argument passed to free_cb.
834 * The number of objects added on success.
835 * On error, the chunks are not added in the memory list of the
836 * mempool and a negative errno is returned.
838 int rte_mempool_populate_phys_tab(struct rte_mempool *mp, char *vaddr,
839 const phys_addr_t paddr[], uint32_t pg_num, uint32_t pg_shift,
840 rte_mempool_memchunk_free_cb_t *free_cb, void *opaque);
843 * Add virtually contiguous memory for objects in the pool at init
845 * Add a virtually contiguous memory chunk in the pool where objects can
849 * A pointer to the mempool structure.
851 * The virtual address of memory that should be used to store objects.
852 * Must be page-aligned.
854 * The length of memory in bytes. Must be page-aligned.
856 * The size of memory pages in this virtual area.
858 * The callback used to free this chunk when destroying the mempool.
860 * An opaque argument passed to free_cb.
862 * The number of objects added on success.
863 * On error, the chunk is not added in the memory list of the
864 * mempool and a negative errno is returned.
867 rte_mempool_populate_virt(struct rte_mempool *mp, char *addr,
868 size_t len, size_t pg_sz, rte_mempool_memchunk_free_cb_t *free_cb,
872 * Add memory for objects in the pool at init
874 * This is the default function used by rte_mempool_create() to populate
875 * the mempool. It adds memory allocated using rte_memzone_reserve().
878 * A pointer to the mempool structure.
880 * The number of objects added on success.
881 * On error, the chunk is not added in the memory list of the
882 * mempool and a negative errno is returned.
884 int rte_mempool_populate_default(struct rte_mempool *mp);
887 * Add memory from anonymous mapping for objects in the pool at init
889 * This function mmap an anonymous memory zone that is locked in
890 * memory to store the objects of the mempool.
893 * A pointer to the mempool structure.
895 * The number of objects added on success.
896 * On error, the chunk is not added in the memory list of the
897 * mempool and a negative errno is returned.
899 int rte_mempool_populate_anon(struct rte_mempool *mp);
902 * Call a function for each mempool element
904 * Iterate across all objects attached to a rte_mempool and call the
905 * callback function on it.
908 * A pointer to an initialized mempool.
910 * A function pointer that is called for each object.
912 * An opaque pointer passed to the callback function.
914 * Number of objects iterated.
916 uint32_t rte_mempool_obj_iter(struct rte_mempool *mp,
917 rte_mempool_obj_cb_t *obj_cb, void *obj_cb_arg);
920 * Call a function for each mempool memory chunk
922 * Iterate across all memory chunks attached to a rte_mempool and call
923 * the callback function on it.
926 * A pointer to an initialized mempool.
928 * A function pointer that is called for each memory chunk.
930 * An opaque pointer passed to the callback function.
932 * Number of memory chunks iterated.
934 uint32_t rte_mempool_mem_iter(struct rte_mempool *mp,
935 rte_mempool_mem_cb_t *mem_cb, void *mem_cb_arg);
938 * Dump the status of the mempool to the console.
941 * A pointer to a file for output
943 * A pointer to the mempool structure.
945 void rte_mempool_dump(FILE *f, struct rte_mempool *mp);
948 * @internal Put several objects back in the mempool; used internally.
950 * A pointer to the mempool structure.
952 * A pointer to a table of void * pointers (objects).
954 * The number of objects to store back in the mempool, must be strictly
957 * Mono-producer (0) or multi-producers (1).
959 static inline void __attribute__((always_inline))
960 __mempool_put_bulk(struct rte_mempool *mp, void * const *obj_table,
961 unsigned n, int is_mp)
963 struct rte_mempool_cache *cache;
966 unsigned lcore_id = rte_lcore_id();
967 uint32_t cache_size = mp->cache_size;
968 uint32_t flushthresh = mp->cache_flushthresh;
970 /* increment stat now, adding in mempool always success */
971 __MEMPOOL_STAT_ADD(mp, put, n);
973 /* cache is not enabled or single producer or non-EAL thread */
974 if (unlikely(cache_size == 0 || is_mp == 0 ||
975 lcore_id >= RTE_MAX_LCORE))
978 /* Go straight to ring if put would overflow mem allocated for cache */
979 if (unlikely(n > RTE_MEMPOOL_CACHE_MAX_SIZE))
982 cache = &mp->local_cache[lcore_id];
983 cache_objs = &cache->objs[cache->len];
986 * The cache follows the following algorithm
987 * 1. Add the objects to the cache
988 * 2. Anything greater than the cache min value (if it crosses the
989 * cache flush threshold) is flushed to the ring.
992 /* Add elements back into the cache */
993 for (index = 0; index < n; ++index, obj_table++)
994 cache_objs[index] = *obj_table;
998 if (cache->len >= flushthresh) {
999 rte_mempool_ops_enqueue_bulk(mp, &cache->objs[cache_size],
1000 cache->len - cache_size);
1001 cache->len = cache_size;
1008 /* push remaining objects in ring */
1009 #ifdef RTE_LIBRTE_MEMPOOL_DEBUG
1010 if (rte_mempool_ops_enqueue_bulk(mp, obj_table, n) < 0)
1011 rte_panic("cannot put objects in mempool\n");
1013 rte_mempool_ops_enqueue_bulk(mp, obj_table, n);
1019 * Put several objects back in the mempool (multi-producers safe).
1022 * A pointer to the mempool structure.
1024 * A pointer to a table of void * pointers (objects).
1026 * The number of objects to add in the mempool from the obj_table.
1028 static inline void __attribute__((always_inline))
1029 rte_mempool_mp_put_bulk(struct rte_mempool *mp, void * const *obj_table,
1032 __mempool_check_cookies(mp, obj_table, n, 0);
1033 __mempool_put_bulk(mp, obj_table, n, 1);
1037 * Put several objects back in the mempool (NOT multi-producers safe).
1040 * A pointer to the mempool structure.
1042 * A pointer to a table of void * pointers (objects).
1044 * The number of objects to add in the mempool from obj_table.
1047 rte_mempool_sp_put_bulk(struct rte_mempool *mp, void * const *obj_table,
1050 __mempool_check_cookies(mp, obj_table, n, 0);
1051 __mempool_put_bulk(mp, obj_table, n, 0);
1055 * Put several objects back in the mempool.
1057 * This function calls the multi-producer or the single-producer
1058 * version depending on the default behavior that was specified at
1059 * mempool creation time (see flags).
1062 * A pointer to the mempool structure.
1064 * A pointer to a table of void * pointers (objects).
1066 * The number of objects to add in the mempool from obj_table.
1068 static inline void __attribute__((always_inline))
1069 rte_mempool_put_bulk(struct rte_mempool *mp, void * const *obj_table,
1072 __mempool_check_cookies(mp, obj_table, n, 0);
1073 __mempool_put_bulk(mp, obj_table, n, !(mp->flags & MEMPOOL_F_SP_PUT));
1077 * Put one object in the mempool (multi-producers safe).
1080 * A pointer to the mempool structure.
1082 * A pointer to the object to be added.
1084 static inline void __attribute__((always_inline))
1085 rte_mempool_mp_put(struct rte_mempool *mp, void *obj)
1087 rte_mempool_mp_put_bulk(mp, &obj, 1);
1091 * Put one object back in the mempool (NOT multi-producers safe).
1094 * A pointer to the mempool structure.
1096 * A pointer to the object to be added.
1098 static inline void __attribute__((always_inline))
1099 rte_mempool_sp_put(struct rte_mempool *mp, void *obj)
1101 rte_mempool_sp_put_bulk(mp, &obj, 1);
1105 * Put one object back in the mempool.
1107 * This function calls the multi-producer or the single-producer
1108 * version depending on the default behavior that was specified at
1109 * mempool creation time (see flags).
1112 * A pointer to the mempool structure.
1114 * A pointer to the object to be added.
1116 static inline void __attribute__((always_inline))
1117 rte_mempool_put(struct rte_mempool *mp, void *obj)
1119 rte_mempool_put_bulk(mp, &obj, 1);
1123 * @internal Get several objects from the mempool; used internally.
1125 * A pointer to the mempool structure.
1127 * A pointer to a table of void * pointers (objects).
1129 * The number of objects to get, must be strictly positive.
1131 * Mono-consumer (0) or multi-consumers (1).
1133 * - >=0: Success; number of objects supplied.
1134 * - <0: Error; code of ring dequeue function.
1136 static inline int __attribute__((always_inline))
1137 __mempool_get_bulk(struct rte_mempool *mp, void **obj_table,
1138 unsigned n, int is_mc)
1141 struct rte_mempool_cache *cache;
1142 uint32_t index, len;
1144 unsigned lcore_id = rte_lcore_id();
1145 uint32_t cache_size = mp->cache_size;
1147 /* cache is not enabled or single consumer */
1148 if (unlikely(cache_size == 0 || is_mc == 0 ||
1149 n >= cache_size || lcore_id >= RTE_MAX_LCORE))
1152 cache = &mp->local_cache[lcore_id];
1153 cache_objs = cache->objs;
1155 /* Can this be satisfied from the cache? */
1156 if (cache->len < n) {
1157 /* No. Backfill the cache first, and then fill from it */
1158 uint32_t req = n + (cache_size - cache->len);
1160 /* How many do we require i.e. number to fill the cache + the request */
1161 ret = rte_mempool_ops_dequeue_bulk(mp,
1162 &cache->objs[cache->len], req);
1163 if (unlikely(ret < 0)) {
1165 * In the offchance that we are buffer constrained,
1166 * where we are not able to allocate cache + n, go to
1167 * the ring directly. If that fails, we are truly out of
1176 /* Now fill in the response ... */
1177 for (index = 0, len = cache->len - 1; index < n; ++index, len--, obj_table++)
1178 *obj_table = cache_objs[len];
1182 __MEMPOOL_STAT_ADD(mp, get_success, n);
1188 /* get remaining objects from ring */
1189 ret = rte_mempool_ops_dequeue_bulk(mp, obj_table, n);
1192 __MEMPOOL_STAT_ADD(mp, get_fail, n);
1194 __MEMPOOL_STAT_ADD(mp, get_success, n);
1200 * Get several objects from the mempool (multi-consumers safe).
1202 * If cache is enabled, objects will be retrieved first from cache,
1203 * subsequently from the common pool. Note that it can return -ENOENT when
1204 * the local cache and common pool are empty, even if cache from other
1208 * A pointer to the mempool structure.
1210 * A pointer to a table of void * pointers (objects) that will be filled.
1212 * The number of objects to get from mempool to obj_table.
1214 * - 0: Success; objects taken.
1215 * - -ENOENT: Not enough entries in the mempool; no object is retrieved.
1217 static inline int __attribute__((always_inline))
1218 rte_mempool_mc_get_bulk(struct rte_mempool *mp, void **obj_table, unsigned n)
1221 ret = __mempool_get_bulk(mp, obj_table, n, 1);
1223 __mempool_check_cookies(mp, obj_table, n, 1);
1228 * Get several objects from the mempool (NOT multi-consumers safe).
1230 * If cache is enabled, objects will be retrieved first from cache,
1231 * subsequently from the common pool. Note that it can return -ENOENT when
1232 * the local cache and common pool are empty, even if cache from other
1236 * A pointer to the mempool structure.
1238 * A pointer to a table of void * pointers (objects) that will be filled.
1240 * The number of objects to get from the mempool to obj_table.
1242 * - 0: Success; objects taken.
1243 * - -ENOENT: Not enough entries in the mempool; no object is
1246 static inline int __attribute__((always_inline))
1247 rte_mempool_sc_get_bulk(struct rte_mempool *mp, void **obj_table, unsigned n)
1250 ret = __mempool_get_bulk(mp, obj_table, n, 0);
1252 __mempool_check_cookies(mp, obj_table, n, 1);
1257 * Get several objects from the mempool.
1259 * This function calls the multi-consumers or the single-consumer
1260 * version, depending on the default behaviour that was specified at
1261 * mempool creation time (see flags).
1263 * If cache is enabled, objects will be retrieved first from cache,
1264 * subsequently from the common pool. Note that it can return -ENOENT when
1265 * the local cache and common pool are empty, even if cache from other
1269 * A pointer to the mempool structure.
1271 * A pointer to a table of void * pointers (objects) that will be filled.
1273 * The number of objects to get from the mempool to obj_table.
1275 * - 0: Success; objects taken
1276 * - -ENOENT: Not enough entries in the mempool; no object is retrieved.
1278 static inline int __attribute__((always_inline))
1279 rte_mempool_get_bulk(struct rte_mempool *mp, void **obj_table, unsigned n)
1282 ret = __mempool_get_bulk(mp, obj_table, n,
1283 !(mp->flags & MEMPOOL_F_SC_GET));
1285 __mempool_check_cookies(mp, obj_table, n, 1);
1290 * Get one object from the mempool (multi-consumers safe).
1292 * If cache is enabled, objects will be retrieved first from cache,
1293 * subsequently from the common pool. Note that it can return -ENOENT when
1294 * the local cache and common pool are empty, even if cache from other
1298 * A pointer to the mempool structure.
1300 * A pointer to a void * pointer (object) that will be filled.
1302 * - 0: Success; objects taken.
1303 * - -ENOENT: Not enough entries in the mempool; no object is retrieved.
1305 static inline int __attribute__((always_inline))
1306 rte_mempool_mc_get(struct rte_mempool *mp, void **obj_p)
1308 return rte_mempool_mc_get_bulk(mp, obj_p, 1);
1312 * Get one object from the mempool (NOT multi-consumers safe).
1314 * If cache is enabled, objects will be retrieved first from cache,
1315 * subsequently from the common pool. Note that it can return -ENOENT when
1316 * the local cache and common pool are empty, even if cache from other
1320 * A pointer to the mempool structure.
1322 * A pointer to a void * pointer (object) that will be filled.
1324 * - 0: Success; objects taken.
1325 * - -ENOENT: Not enough entries in the mempool; no object is retrieved.
1327 static inline int __attribute__((always_inline))
1328 rte_mempool_sc_get(struct rte_mempool *mp, void **obj_p)
1330 return rte_mempool_sc_get_bulk(mp, obj_p, 1);
1334 * Get one object from the mempool.
1336 * This function calls the multi-consumers or the single-consumer
1337 * version, depending on the default behavior that was specified at
1338 * mempool creation (see flags).
1340 * If cache is enabled, objects will be retrieved first from cache,
1341 * subsequently from the common pool. Note that it can return -ENOENT when
1342 * the local cache and common pool are empty, even if cache from other
1346 * A pointer to the mempool structure.
1348 * A pointer to a void * pointer (object) that will be filled.
1350 * - 0: Success; objects taken.
1351 * - -ENOENT: Not enough entries in the mempool; no object is retrieved.
1353 static inline int __attribute__((always_inline))
1354 rte_mempool_get(struct rte_mempool *mp, void **obj_p)
1356 return rte_mempool_get_bulk(mp, obj_p, 1);
1360 * Return the number of entries in the mempool.
1362 * When cache is enabled, this function has to browse the length of
1363 * all lcores, so it should not be used in a data path, but only for
1367 * A pointer to the mempool structure.
1369 * The number of entries in the mempool.
1371 unsigned rte_mempool_count(const struct rte_mempool *mp);
1374 * Return the number of free entries in the mempool ring.
1375 * i.e. how many entries can be freed back to the mempool.
1377 * NOTE: This corresponds to the number of elements *allocated* from the
1378 * memory pool, not the number of elements in the pool itself. To count
1379 * the number elements currently available in the pool, use "rte_mempool_count"
1381 * When cache is enabled, this function has to browse the length of
1382 * all lcores, so it should not be used in a data path, but only for
1386 * A pointer to the mempool structure.
1388 * The number of free entries in the mempool.
1390 static inline unsigned
1391 rte_mempool_free_count(const struct rte_mempool *mp)
1393 return mp->size - rte_mempool_count(mp);
1397 * Test if the mempool is full.
1399 * When cache is enabled, this function has to browse the length of all
1400 * lcores, so it should not be used in a data path, but only for debug
1404 * A pointer to the mempool structure.
1406 * - 1: The mempool is full.
1407 * - 0: The mempool is not full.
1410 rte_mempool_full(const struct rte_mempool *mp)
1412 return !!(rte_mempool_count(mp) == mp->size);
1416 * Test if the mempool is empty.
1418 * When cache is enabled, this function has to browse the length of all
1419 * lcores, so it should not be used in a data path, but only for debug
1423 * A pointer to the mempool structure.
1425 * - 1: The mempool is empty.
1426 * - 0: The mempool is not empty.
1429 rte_mempool_empty(const struct rte_mempool *mp)
1431 return !!(rte_mempool_count(mp) == 0);
1435 * Return the physical address of elt, which is an element of the pool mp.
1438 * A pointer to the mempool structure.
1440 * A pointer (virtual address) to the element of the pool.
1442 * The physical address of the elt element.
1443 * If the mempool was created with MEMPOOL_F_NO_PHYS_CONTIG, the
1444 * returned value is RTE_BAD_PHYS_ADDR.
1446 static inline phys_addr_t
1447 rte_mempool_virt2phy(__rte_unused const struct rte_mempool *mp, const void *elt)
1449 const struct rte_mempool_objhdr *hdr;
1450 hdr = (const struct rte_mempool_objhdr *)RTE_PTR_SUB(elt,
1452 return hdr->physaddr;
1456 * Check the consistency of mempool objects.
1458 * Verify the coherency of fields in the mempool structure. Also check
1459 * that the cookies of mempool objects (even the ones that are not
1460 * present in pool) have a correct value. If not, a panic will occur.
1463 * A pointer to the mempool structure.
1465 void rte_mempool_audit(struct rte_mempool *mp);
1468 * Return a pointer to the private data in an mempool structure.
1471 * A pointer to the mempool structure.
1473 * A pointer to the private data.
1475 static inline void *rte_mempool_get_priv(struct rte_mempool *mp)
1478 MEMPOOL_HEADER_SIZE(mp, mp->cache_size);
1482 * Dump the status of all mempools on the console
1485 * A pointer to a file for output
1487 void rte_mempool_list_dump(FILE *f);
1490 * Search a mempool from its name
1493 * The name of the mempool.
1495 * The pointer to the mempool matching the name, or NULL if not found.
1497 * with rte_errno set appropriately. Possible rte_errno values include:
1498 * - ENOENT - required entry not available to return.
1501 struct rte_mempool *rte_mempool_lookup(const char *name);
1504 * Get the header, trailer and total size of a mempool element.
1506 * Given a desired size of the mempool element and mempool flags,
1507 * calculates header, trailer, body and total sizes of the mempool object.
1510 * The size of each element, without header and trailer.
1512 * The flags used for the mempool creation.
1513 * Consult rte_mempool_create() for more information about possible values.
1514 * The size of each element.
1516 * The calculated detailed size the mempool object. May be NULL.
1518 * Total size of the mempool object.
1520 uint32_t rte_mempool_calc_obj_size(uint32_t elt_size, uint32_t flags,
1521 struct rte_mempool_objsz *sz);
1524 * Get the size of memory required to store mempool elements.
1526 * Calculate the maximum amount of memory required to store given number
1527 * of objects. Assume that the memory buffer will be aligned at page
1530 * Note that if object size is bigger then page size, then it assumes
1531 * that pages are grouped in subsets of physically continuous pages big
1532 * enough to store at least one object.
1535 * Number of elements.
1536 * @param total_elt_sz
1537 * The size of each element, including header and trailer, as returned
1538 * by rte_mempool_calc_obj_size().
1540 * LOG2 of the physical pages size. If set to 0, ignore page boundaries.
1542 * Required memory size aligned at page boundary.
1544 size_t rte_mempool_xmem_size(uint32_t elt_num, size_t total_elt_sz,
1548 * Get the size of memory required to store mempool elements.
1550 * Calculate how much memory would be actually required with the given
1551 * memory footprint to store required number of objects.
1554 * Virtual address of the externally allocated memory buffer.
1555 * Will be used to store mempool objects.
1557 * Number of elements.
1558 * @param total_elt_sz
1559 * The size of each element, including header and trailer, as returned
1560 * by rte_mempool_calc_obj_size().
1562 * Array of physical addresses of the pages that comprises given memory
1565 * Number of elements in the paddr array.
1567 * LOG2 of the physical pages size.
1569 * On success, the number of bytes needed to store given number of
1570 * objects, aligned to the given page size. If the provided memory
1571 * buffer is too small, return a negative value whose absolute value
1572 * is the actual number of elements that can be stored in that buffer.
1574 ssize_t rte_mempool_xmem_usage(void *vaddr, uint32_t elt_num,
1575 size_t total_elt_sz, const phys_addr_t paddr[], uint32_t pg_num,
1579 * Walk list of all memory pools
1584 * Argument passed to iterator
1586 void rte_mempool_walk(void (*func)(struct rte_mempool *, void *arg),
1593 #endif /* _RTE_MEMPOOL_H_ */