| rte_mempool.h(3) | Library Functions Manual | rte_mempool.h(3) |
rte_mempool.h
#include <stdalign.h>
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
#include <rte_compat.h>
#include <rte_config.h>
#include <rte_spinlock.h>
#include <rte_debug.h>
#include <rte_lcore.h>
#include <rte_log.h>
#include <rte_branch_prediction.h>
#include <rte_ring.h>
#include <rte_memcpy.h>
#include <rte_common.h>
#include 'rte_mempool_trace_fp.h'
struct rte_mempool_cache
struct rte_mempool_objsz
struct rte_mempool_objhdr
struct rte_mempool_memhdr
struct rte_mempool_info
struct rte_mempool
struct rte_mempool_ops
struct rte_mempool_ops_table
struct rte_mempool_mem_range_info
#define RTE_MEMPOOL_HEADER_COOKIE1 0xbadbadbadadd2e55ULL
#define RTE_MEMPOOL_HEADER_COOKIE2 0xf2eef2eedadd2e55ULL
#define RTE_MEMPOOL_TRAILER_COOKIE 0xadd2e55badbadbadULL
#define RTE_MEMPOOL_ALIGN RTE_CACHE_LINE_SIZE
#define RTE_MEMPOOL_F_NO_SPREAD 0x0001
#define MEMPOOL_F_NO_SPREAD RTE_MEMPOOL_F_NO_SPREAD
#define RTE_MEMPOOL_F_NO_CACHE_ALIGN 0x0002
#define MEMPOOL_F_NO_CACHE_ALIGN RTE_MEMPOOL_F_NO_CACHE_ALIGN
#define RTE_MEMPOOL_F_SP_PUT 0x0004
#define MEMPOOL_F_SP_PUT RTE_MEMPOOL_F_SP_PUT
#define RTE_MEMPOOL_F_SC_GET 0x0008
#define MEMPOOL_F_SC_GET RTE_MEMPOOL_F_SC_GET
#define RTE_MEMPOOL_F_POOL_CREATED 0x0010
#define RTE_MEMPOOL_F_NO_IOVA_CONTIG 0x0020
#define MEMPOOL_F_NO_IOVA_CONTIG RTE_MEMPOOL_F_NO_IOVA_CONTIG
#define RTE_MEMPOOL_F_NON_IO 0x0040
#define RTE_MEMPOOL_VALID_USER_FLAGS
#define RTE_MEMPOOL_OPS_NAMESIZE 32
#define RTE_MEMPOOL_POPULATE_F_ALIGN_OBJ 0x0001
#define RTE_MEMPOOL_MAX_OPS_IDX 16
#define RTE_MEMPOOL_REGISTER_OPS(ops)
typedef void() rte_mempool_memchunk_free_cb_t(struct
rte_mempool_memhdr *memhdr, void *opaque)
typedef int(* rte_mempool_alloc_t) (struct rte_mempool
*mp)
typedef void(* rte_mempool_free_t) (struct rte_mempool
*mp)
typedef int(* rte_mempool_enqueue_t) (struct rte_mempool
*mp, void *const *obj_table, unsigned int n)
typedef int(* rte_mempool_dequeue_t) (struct rte_mempool
*mp, void **obj_table, unsigned int n)
typedef int(* rte_mempool_dequeue_contig_blocks_t) (struct
rte_mempool *mp, void **first_obj_table, unsigned int n)
typedef unsigned(* rte_mempool_get_count) (const struct
rte_mempool *mp)
typedef ssize_t(* rte_mempool_calc_mem_size_t) (const struct
rte_mempool *mp, uint32_t obj_num, uint32_t pg_shift, size_t
*min_chunk_size, size_t *align)
typedef void() rte_mempool_populate_obj_cb_t(struct
rte_mempool *mp, void *opaque, void *vaddr, rte_iova_t iova)
typedef int(* rte_mempool_populate_t) (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, void *obj_cb_arg)
typedef int(* rte_mempool_get_info_t) (const struct
rte_mempool *mp, struct rte_mempool_info *info)
typedef void() rte_mempool_obj_cb_t(struct rte_mempool
*mp, void *opaque, void *obj, unsigned obj_idx)
typedef void() rte_mempool_mem_cb_t(struct rte_mempool
*mp, void *opaque, struct rte_mempool_memhdr *memhdr, unsigned
mem_idx)
typedef void() rte_mempool_ctor_t(struct rte_mempool *,
void *)
enum rte_mempool_event { RTE_MEMPOOL_EVENT_READY =
0, RTE_MEMPOOL_EVENT_DESTROY = 1 }
RTE_STAILQ_HEAD (rte_mempool_objhdr_list,
rte_mempool_objhdr)
RTE_STAILQ_HEAD (rte_mempool_memhdr_list, rte_mempool_memhdr)
static struct rte_mempool * rte_mempool_from_obj (void *obj)
ssize_t rte_mempool_op_calc_mem_size_default (const struct
rte_mempool *mp, uint32_t obj_num, uint32_t pg_shift, size_t
*min_chunk_size, size_t *align)
int rte_mempool_op_populate_default (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, void *obj_cb_arg)
int rte_mempool_ops_get_info (const struct rte_mempool *mp,
struct rte_mempool_info *info)
int rte_mempool_set_ops_byname (struct rte_mempool *mp, const
char *name, void *pool_config)
int rte_mempool_register_ops (const struct rte_mempool_ops *ops)
struct rte_mempool * rte_mempool_create (const char *name,
unsigned n, unsigned elt_size, unsigned cache_size, unsigned
private_data_size, rte_mempool_ctor_t *mp_init, void *mp_init_arg,
rte_mempool_obj_cb_t *obj_init, void *obj_init_arg, int socket_id,
unsigned flags)
struct rte_mempool * rte_mempool_create_empty (const char *name,
unsigned n, unsigned elt_size, unsigned cache_size, unsigned
private_data_size, int socket_id, unsigned flags)
void rte_mempool_free (struct rte_mempool *mp)
int rte_mempool_populate_iova (struct rte_mempool *mp, char
*vaddr, rte_iova_t iova, size_t len,
rte_mempool_memchunk_free_cb_t *free_cb, void *opaque)
int rte_mempool_populate_virt (struct rte_mempool *mp, char
*addr, size_t len, size_t pg_sz, rte_mempool_memchunk_free_cb_t
*free_cb, void *opaque)
int rte_mempool_populate_default (struct rte_mempool *mp)
int rte_mempool_populate_anon (struct rte_mempool *mp)
uint32_t rte_mempool_obj_iter (struct rte_mempool *mp,
rte_mempool_obj_cb_t *obj_cb, void *obj_cb_arg)
uint32_t rte_mempool_mem_iter (struct rte_mempool *mp,
rte_mempool_mem_cb_t *mem_cb, void *mem_cb_arg)
void rte_mempool_dump (FILE *f, struct rte_mempool *mp)
struct rte_mempool_cache * rte_mempool_cache_create (uint32_t
size, int socket_id)
void rte_mempool_cache_free (struct rte_mempool_cache *cache)
static __rte_always_inline struct rte_mempool_cache *
rte_mempool_default_cache (struct rte_mempool *mp, unsigned
lcore_id)
static __rte_always_inline void rte_mempool_cache_flush (struct
rte_mempool_cache *cache, struct rte_mempool *mp)
static __rte_always_inline void rte_mempool_generic_put (struct
rte_mempool *mp, void *const *obj_table, unsigned int n, struct
rte_mempool_cache *cache)
static __rte_always_inline void rte_mempool_put_bulk (struct
rte_mempool *mp, void *const *obj_table, unsigned int n)
static __rte_always_inline void rte_mempool_put (struct
rte_mempool *mp, void *obj)
static __rte_always_inline int rte_mempool_generic_get (struct
rte_mempool *mp, void **obj_table, unsigned int n, struct
rte_mempool_cache *cache)
static __rte_always_inline int rte_mempool_get_bulk (struct
rte_mempool *mp, void **obj_table, unsigned int n)
static __rte_always_inline int rte_mempool_get (struct
rte_mempool *mp, void **obj_p)
static __rte_always_inline int rte_mempool_get_contig_blocks
(struct rte_mempool *mp, void **first_obj_table, unsigned int n)
unsigned int rte_mempool_avail_count (const struct rte_mempool
*mp)
unsigned int rte_mempool_in_use_count (const struct rte_mempool
*mp)
static int rte_mempool_full (const struct rte_mempool *mp)
static int rte_mempool_empty (const struct rte_mempool *mp)
static rte_iova_t rte_mempool_virt2iova (const void *elt)
void rte_mempool_audit (struct rte_mempool *mp)
static void * rte_mempool_get_priv (struct rte_mempool *mp)
void rte_mempool_list_dump (FILE *f)
struct rte_mempool * rte_mempool_lookup (const char *name)
uint32_t rte_mempool_calc_obj_size (uint32_t elt_size, uint32_t flags,
struct rte_mempool_objsz *sz)
void rte_mempool_walk (void(*func)(struct rte_mempool *, void
*arg), void *arg)
__rte_experimental int rte_mempool_get_mem_range (const struct
rte_mempool *mp, struct rte_mempool_mem_range_info *mem_range)
__rte_experimental size_t rte_mempool_get_obj_alignment (const struct
rte_mempool *mp)
struct rte_mempool_ops_table rte_mempool_ops_table
RTE Mempool.
A memory pool is an allocator of fixed-size object. It is identified by its name, and uses a ring to store free objects. It provides some other optional services, like a per-core object cache, and an alignment helper to ensure that objects are padded to spread them equally on all RAM channels, ranks, and so on.
Objects owned by a mempool should never be added in another mempool. When an object is freed using rte_mempool_put() or equivalent, the object data is not modified; the user can save some meta-data in the object data and retrieve them when allocating a new object.
Note: the mempool implementation is not preemptible. An lcore must not be interrupted by another task that uses the same mempool (because it uses a ring which is not preemptible). Also, usual mempool functions like rte_mempool_get() or rte_mempool_put() are designed to be called from an EAL thread due to the internal per-lcore cache. Due to the lack of caching, rte_mempool_get() or rte_mempool_put() performance will suffer when called by unregistered non-EAL threads. Instead, unregistered non-EAL threads should call rte_mempool_generic_get() or rte_mempool_generic_put() with a user cache created with rte_mempool_cache_create().
Definition in file rte_mempool.h.
Header cookie.
Definition at line 59 of file rte_mempool.h.
Header cookie.
Definition at line 60 of file rte_mempool.h.
Trailer cookie.
Definition at line 61 of file rte_mempool.h.
Alignment of elements inside mempool.
Definition at line 139 of file rte_mempool.h.
Spreading among memory channels not required.
Definition at line 275 of file rte_mempool.h.
Backward compatibility synonym for RTE_MEMPOOL_F_NO_SPREAD. To be deprecated.
Definition at line 280 of file rte_mempool.h.
Do not align objects on cache lines.
Definition at line 282 of file rte_mempool.h.
Backward compatibility synonym for RTE_MEMPOOL_F_NO_CACHE_ALIGN. To be deprecated.
Definition at line 287 of file rte_mempool.h.
Default put is 'single-producer'.
Definition at line 289 of file rte_mempool.h.
Backward compatibility synonym for RTE_MEMPOOL_F_SP_PUT. To be deprecated.
Definition at line 294 of file rte_mempool.h.
Default get is 'single-consumer'.
Definition at line 296 of file rte_mempool.h.
Backward compatibility synonym for RTE_MEMPOOL_F_SC_GET. To be deprecated.
Definition at line 301 of file rte_mempool.h.
Internal: pool is created.
Definition at line 303 of file rte_mempool.h.
Don't need IOVA contiguous objects.
Definition at line 305 of file rte_mempool.h.
Backward compatibility synonym for RTE_MEMPOOL_F_NO_IOVA_CONTIG. To be deprecated.
Definition at line 310 of file rte_mempool.h.
Internal: no object from the pool can be used for device IO (DMA).
Definition at line 312 of file rte_mempool.h.
Value:.PP
(RTE_MEMPOOL_F_NO_SPREAD \
| RTE_MEMPOOL_F_NO_CACHE_ALIGN \
| RTE_MEMPOOL_F_SP_PUT \
| RTE_MEMPOOL_F_SC_GET \
| RTE_MEMPOOL_F_NO_IOVA_CONTIG \
)
This macro lists all the mempool flags an application may request.
Definition at line 317 of file rte_mempool.h.
Max length of ops struct name.
Definition at line 458 of file rte_mempool.h.
Align objects on addresses multiple of total_elt_sz.
Definition at line 634 of file rte_mempool.h.
Max registered ops structs
Definition at line 719 of file rte_mempool.h.
Value:.PP
RTE_INIT(mp_hdlr_init_##ops) \
{ \
rte_mempool_register_ops(&ops); \
}
Macro to statically register the ops of a mempool handler. Note that the rte_mempool_register_ops fails silently here when more than RTE_MEMPOOL_MAX_OPS_IDX is registered.
Definition at line 983 of file rte_mempool.h.
Callback used to free a memory chunk
Definition at line 197 of file rte_mempool.h.
Prototype for implementation specific data provisioning function.
The function should provide the implementation specific memory for use by the other mempool ops functions in a given mempool ops struct. E.g. the default ops provides an instance of the rte_ring for this purpose. it will most likely point to a different type of data structure, and will be transparent to the application programmer. This function should set mp->pool_data.
Definition at line 470 of file rte_mempool.h.
Free the opaque private data pointed to by mp->pool_data pointer.
Definition at line 475 of file rte_mempool.h.
Enqueue 'n' objects into the external pool.
Returns
Definition at line 483 of file rte_mempool.h.
Dequeue 'n' objects from the external pool.
Returns
Definition at line 492 of file rte_mempool.h.
Dequeue a number of contiguous object blocks from the external pool.
Definition at line 498 of file rte_mempool.h.
Return the number of available objects in the external pool.
Definition at line 504 of file rte_mempool.h.
Calculate memory size required to store given number of objects.
If mempool objects are not required to be IOVA-contiguous (the flag RTE_MEMPOOL_F_NO_IOVA_CONTIG is set), min_chunk_size defines virtually contiguous chunk size. Otherwise, if mempool objects must be IOVA-contiguous (the flag RTE_MEMPOOL_F_NO_IOVA_CONTIG is clear), min_chunk_size defines IOVA-contiguous chunk size.
Parameters
Returns
Definition at line 529 of file rte_mempool.h.
Function to be called for each populated object.
Parameters
Definition at line 595 of file rte_mempool.h.
Populate memory pool objects using provided memory chunk.
Populated objects should be enqueued to the pool, e.g. using rte_mempool_ops_enqueue_bulk().
If the given IO address is unknown (iova = RTE_BAD_IOVA), the chunk doesn't need to be physically contiguous (only virtually), and allocated objects may span two pages.
Parameters
Returns
Definition at line 626 of file rte_mempool.h.
Get some additional information about a mempool.
Definition at line 687 of file rte_mempool.h.
An object callback function for mempool.
Used by rte_mempool_create() and rte_mempool_obj_iter().
Definition at line 994 of file rte_mempool.h.
A memory callback function for mempool.
Used by rte_mempool_mem_iter().
Definition at line 1003 of file rte_mempool.h.
A mempool constructor callback function.
Arguments are the mempool and the opaque pointer given by the user in rte_mempool_create().
Definition at line 1013 of file rte_mempool.h.
Mempool event type.
Enumerator
Definition at line 1979 of file rte_mempool.h.
A list of object headers type
A list of memory where objects are stored
Return a pointer to the mempool owning this object.
Parameters
Returns
Definition at line 392 of file rte_mempool.h.
Default way to calculate memory size required to store given number of objects.
Equivalent to rte_mempool_op_calc_mem_size_helper(mp, obj_num, pg_shift, 0, min_chunk_size, align).
Default way to populate memory pool object using provided memory chunk.
Equivalent to rte_mempool_op_populate_helper(mp, 0, max_objs, vaddr, iova, len, obj_cb, obj_cb_arg).
Wrapper for mempool_ops get_info callback.
Parameters
Returns
Set the ops of a mempool.
This can only be done on a mempool that is not populated, i.e. just after a call to rte_mempool_create_empty().
Parameters
Returns
Register mempool operations.
Parameters
Returns
Create a new mempool named name in memory.
This function uses rte_memzone_reserve() to allocate memory. The pool contains n elements of elt_size. Its size is set to n.
Parameters
Returns
Create an empty mempool
The mempool is allocated and initialized, but it is not populated: no memory is allocated for the mempool elements. The user has to call rte_mempool_populate_*() to add memory chunks to the pool. Once populated, the user may also want to initialize each object with rte_mempool_obj_iter().
Parameters
Returns
Free a mempool
Unlink the mempool from global list, free the memory chunks, and all memory referenced by the mempool. The objects must not be used by other cores as they will be freed.
Parameters
Add physically contiguous memory for objects in the pool at init
Add a virtually and physically contiguous memory chunk in the pool where objects can be instantiated.
If the given IO address is unknown (iova = RTE_BAD_IOVA), the chunk doesn't need to be physically contiguous (only virtually), and allocated objects may span two pages.
Parameters
Returns
Add virtually contiguous memory for objects in the pool at init
Add a virtually contiguous memory chunk in the pool where objects can be instantiated.
Parameters
Returns
Add memory for objects in the pool at init
This is the default function used by rte_mempool_create() to populate the mempool. It adds memory allocated using rte_memzone_reserve().
Parameters
Returns
Add memory from anonymous mapping for objects in the pool at init
This function mmap an anonymous memory zone that is locked in memory to store the objects of the mempool.
Parameters
Returns
Call a function for each mempool element
Iterate across all objects attached to a rte_mempool and call the callback function on it.
Parameters
Returns
Call a function for each mempool memory chunk
Iterate across all memory chunks attached to a rte_mempool and call the callback function on it.
Parameters
Returns
Dump the status of the mempool to a file.
Parameters
Create a user-owned mempool cache.
This can be used by unregistered non-EAL threads to enable caching when they interact with a mempool.
Parameters
Free a user-owned mempool cache.
Parameters
Get a pointer to the per-lcore default mempool cache.
Parameters
Returns
Definition at line 1331 of file rte_mempool.h.
Flush a user-owned mempool cache to the specified mempool.
Parameters
Definition at line 1353 of file rte_mempool.h.
Put several objects back in the mempool.
Parameters
Definition at line 1442 of file rte_mempool.h.
Put several objects back in the mempool.
This function calls the multi-producer or the single-producer version depending on the default behavior that was specified at mempool creation time (see flags).
Parameters
Definition at line 1465 of file rte_mempool.h.
Put one object back in the mempool.
This function calls the multi-producer or the single-producer version depending on the default behavior that was specified at mempool creation time (see flags).
Parameters
Definition at line 1487 of file rte_mempool.h.
Get several objects from the mempool.
If cache is enabled, objects will be retrieved first from cache, subsequently from the common pool. Note that it can return -ENOENT when the local cache and common pool are empty, even if cache from other lcores are full.
Parameters
Returns
Definition at line 1645 of file rte_mempool.h.
Get several objects from the mempool.
This function calls the multi-consumers or the single-consumer version, depending on the default behaviour that was specified at mempool creation time (see flags).
If cache is enabled, objects will be retrieved first from cache, subsequently from the common pool. Note that it can return -ENOENT when the local cache and common pool are empty, even if cache from other lcores are full.
Parameters
Returns
Definition at line 1679 of file rte_mempool.h.
Get one object from the mempool.
This function calls the multi-consumers or the single-consumer version, depending on the default behavior that was specified at mempool creation (see flags).
If cache is enabled, objects will be retrieved first from cache, subsequently from the common pool. Note that it can return -ENOENT when the local cache and common pool are empty, even if cache from other lcores are full.
Parameters
Returns
Definition at line 1708 of file rte_mempool.h.
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.
Parameters
Returns
Definition at line 1735 of file rte_mempool.h.
Return the number of entries in the mempool.
When cache is enabled, this function has to browse the length of all lcores, so it should not be used in a data path, but only for debug purposes. User-owned mempool caches are not accounted for.
Parameters
Returns
Return the number of elements which have been allocated from the mempool
When cache is enabled, this function has to browse the length of all lcores, so it should not be used in a data path, but only for debug purposes.
Parameters
Returns
Test if the mempool is full.
When cache is enabled, this function has to browse the length of all lcores, so it should not be used in a data path, but only for debug purposes. User-owned mempool caches are not accounted for.
Parameters
Returns
Definition at line 1798 of file rte_mempool.h.
Test if the mempool is empty.
When cache is enabled, this function has to browse the length of all lcores, so it should not be used in a data path, but only for debug purposes. User-owned mempool caches are not accounted for.
Parameters
Returns
Definition at line 1817 of file rte_mempool.h.
Return the IO address of elt, which is an element of the pool mp.
Parameters
Returns
Definition at line 1833 of file rte_mempool.h.
Check the consistency of mempool objects.
Verify the coherency of fields in the mempool structure. Also check that the cookies of mempool objects (even the ones that are not present in pool) have a correct value. If not, a panic will occur.
Parameters
Return a pointer to the private data in an mempool structure.
Parameters
Returns
Definition at line 1861 of file rte_mempool.h.
Dump the status of all mempools on the console
Parameters
Search a mempool from its name
Parameters
Returns
Get the header, trailer and total size of a mempool element.
Given a desired size of the mempool element and mempool flags, calculates header, trailer, body and total sizes of the mempool object.
Parameters
Returns
Walk list of all memory pools
Parameters
Warning
Get information about the memory range used to store objects in the mempool.
Parameters
Returns
Warning
Return alignment of objects stored in the mempool.
Parameters
Returns
Array of registered ops structs.
Generated automatically by Doxygen for DPDK from the source code.
| Version 24.11.3 | DPDK |