rte_mempool.h(3)

๐Ÿ’– rte_mempool.h(3) โ€” Library Functions Manual ๐Ÿ’–

โœจ NAME โœจ

rte_mempool.h โ€” that's the header, bestie. That's the name.

๐Ÿฆ‹ SYNOPSIS ๐Ÿฆ‹

Okay so first, the includes. Copy these exactly, no freestyling:

#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'

๐Ÿงธ Data Structures

The struct squad, in order, periodt:

  • 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

๐Ÿ“ Macros

Macro definitions, exact characters only. These are the cookies, flags, and limits, okay? Don't paraphrase them:

#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)

๐ŸŒธ Typedefs

Typedef time, bestie. Exact signatures, no vibes-based edits:

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 *)

๐ŸŒˆ Enumerations

The enum, exactly as it is:

enum rte_mempool_event { RTE_MEMPOOL_EVENT_READY = 0,
    RTE_MEMPOOL_EVENT_DESTROY = 1 }

๐Ÿ”ฅ Functions

Function roster. This is the whole lineup, exact characters, no skipping:

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)
void rte_mempool_free (struct rte_mempool *mp)
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 int flags)
    __rte_malloc __rte_dealloc(rte_mempool_free
struct rte_mempool struct rte_mempool * rte_mempool_create_empty (const
    char *name, unsigned int n, unsigned int elt_size, unsigned int
    cache_size, unsigned int private_data_size, int socket_id, unsigned
    int flags) __rte_malloc __rte_dealloc(rte_mempool_free
struct rte_mempool struct rte_mempool 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)

๐Ÿ’… Variables

  • struct rte_mempool_ops_table rte_mempool_ops_table

๐Ÿ‘‘ Detailed Description ๐Ÿ‘‘

RTE Mempool.

So a memory pool is literally an allocator of fixed-size object. It's identified by its name, and uses a ring to store free objects. It also 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. The way it does all that? Iconic.

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. That's the whole vibe.

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.

๐Ÿ“ Macro Definition Documentation ๐Ÿ“

okay bestie, buckle up, we're doing the macros now and honestly? these are giving "under the hood but make it cute" ๐Ÿ’…

  • RTE_MEMPOOL_HEADER_COOKIE1 = 0xbadbadbadadd2e55ULL โ€” a header cookie ๐Ÿช (yes that's really the name, the devs were feeling silly). Defined at line 59 of rte_mempool.h.
  • RTE_MEMPOOL_HEADER_COOKIE2 = 0xf2eef2eedadd2e55ULL โ€” another header cookie. Two cookies, because one is never enough fr fr. Defined at line 60 of rte_mempool.h.
  • RTE_MEMPOOL_TRAILER_COOKIE = 0xadd2e55badbadbadULL โ€” the trailer cookie, guarding the other end of the vibe (and yes, the hex literally spells "bad bad bad" and "dadd2e55", the devs ate that one). Defined at line 61 of rte_mempool.h.
  • RTE_MEMPOOL_ALIGN = RTE_CACHE_LINE_SIZE โ€” how the elements inside the mempool get aligned. No cap. Defined at line 139 of rte_mempool.h.

โœจ the actual flags, the ones you'll actually touch โœจ

  • RTE_MEMPOOL_F_NO_SPREAD = 0x0001 โ€” spreading among memory channels? not required, we're chill like that. Defined at line 275 of rte_mempool.h.
  • MEMPOOL_F_NO_SPREAD = RTE_MEMPOOL_F_NO_SPREAD โ€” a backward compatibility synonym for RTE_MEMPOOL_F_NO_SPREAD. ๐Ÿšจ Heads up bestie, it's to be deprecated โ€” use the RTE_-prefixed one, ok? Defined at line 280 of rte_mempool.h.
  • RTE_MEMPOOL_F_NO_CACHE_ALIGN = 0x0002 โ€” do not align objects on cache lines. Chaotic, but valid. Defined at line 282 of rte_mempool.h.
  • MEMPOOL_F_NO_CACHE_ALIGN = RTE_MEMPOOL_F_NO_CACHE_ALIGN โ€” the backward compatible synonym, to be deprecated. Defined at line 287 of rte_mempool.h.
  • RTE_MEMPOOL_F_SP_PUT = 0x0004 โ€” the default put is "single-producer". one producer, main character energy ๐Ÿ‘‘. Defined at line 289 of rte_mempool.h.
  • MEMPOOL_F_SP_PUT = RTE_MEMPOOL_F_SP_PUT โ€” yet another backward compat synonym, to be deprecated. Defined at line 294 of rte_mempool.h.
  • RTE_MEMPOOL_F_SC_GET = 0x0008 โ€” the default get is "single-consumer". one consumer, iconic. Defined at line 296 of rte_mempool.h.
  • MEMPOOL_F_SC_GET = RTE_MEMPOOL_F_SC_GET โ€” backward compat synonym, to be deprecated. Defined at line 301 of rte_mempool.h.
  • RTE_MEMPOOL_F_POOL_CREATED = 0x0010 โ€” internal ๐Ÿ‘€: the pool is created. Defined at line 303 of rte_mempool.h.
  • RTE_MEMPOOL_F_NO_IOVA_CONTIG = 0x0020 โ€” don't need IOVA-contiguous objects. freeing, honestly. Defined at line 305 of rte_mempool.h.
  • MEMPOOL_F_NO_IOVA_CONTIG = RTE_MEMPOOL_F_NO_IOVA_CONTIG โ€” backward compat synonym, to be deprecated. Defined at line 310 of rte_mempool.h.
  • RTE_MEMPOOL_F_NON_IO = 0x0040 โ€” internal: no object from this pool can be used for device IO (DMA). Defined at line 312 of rte_mempool.h.
  • RTE_MEMPOOL_VALID_USER_FLAGS โ€” this macro is the master list of all the mempool flags an application may request, so if you're wondering what flag combos are legal, this is your vibe check โœ…. Its value:
(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 \
)

Defined at line 317 of rte_mempool.h.

  • RTE_MEMPOOL_OPS_NAMESIZE = 32 โ€” max length of an ops struct name. keep it short, keep it cute ๐ŸŽ€. Defined at line 458 of rte_mempool.h.
  • RTE_MEMPOOL_POPULATE_F_ALIGN_OBJ = 0x0001 โ€” align objects on addresses that are a multiple of total_elt_sz. obsessive in the best way. Defined at line 634 of rte_mempool.h.
  • RTE_MEMPOOL_MAX_OPS_IDX = 16 โ€” the max number of registered ops structs. like a guest list, capacity 16, no plus-ones beyond that. Defined at line 719 of rte_mempool.h.
  • RTE_MEMPOOL_REGISTER_OPS(ops) โ€” macro to statically register the ops of a mempool handler โœจ Its value:
RTE_INIT(mp_hdlr_init_##ops)                \
{                           \
    rte_mempool_register_ops(&ops);         \
}
โš ๏ธ lowercase warning bestie: rte_mempool_register_ops fails silently here when more than RTE_MEMPOOL_MAX_OPS_IDX is registered. so it'll justโ€ฆ not tell you ๐Ÿ˜ญ. watch your count.

Defined at line 988 of rte_mempool.h.


๐Ÿฆ‹ Typedef Documentation ๐Ÿฆ‹

  • rte_mempool_memchunk_free_cb_t โ€” signature typedef void rte_mempool_memchunk_free_cb_t(struct rte_mempool_memhdr *memhdr, void *opaque). It's the callback used to free a memory chunk. bye babe, releasing your resources ๐Ÿ’œ. Defined at line 197 of rte_mempool.h.
  • rte_mempool_alloc_t โ€” signature typedef int(* rte_mempool_alloc_t) (struct rte_mempool *mp). The prototype for an 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 โ€” for example, the default ops provides an instance of the rte_ring for this exact 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. Defined at line 470 of rte_mempool.h.
  • rte_mempool_free_t โ€” signature typedef void(* rte_mempool_free_t) (struct rte_mempool *mp). Frees the opaque private data pointed to by the mp->pool_data pointer. releasing time โœจ. Defined at line 475 of rte_mempool.h.
  • rte_mempool_enqueue_t โ€” signature typedef int(* rte_mempool_enqueue_t) (struct rte_mempool *mp, void *const *obj_table, unsigned int n). Enqueues 'n' objects into the external pool. Returns:
    • 0: Success โœ…
    • <0: Error ๐Ÿ’€

Defined at line 483 of rte_mempool.h.

  • rte_mempool_dequeue_t โ€” signature typedef int(* rte_mempool_dequeue_t) (struct rte_mempool *mp, void **obj_table, unsigned int n). Dequeues 'n' objects from the external pool. Returns:
    • 0: Success โœ…
    • <0: Error ๐Ÿ’€

Defined at line 492 of rte_mempool.h.

  • rte_mempool_dequeue_contig_blocks_t โ€” signature typedef int(* rte_mempool_dequeue_contig_blocks_t) (struct rte_mempool *mp, void **first_obj_table, unsigned int n). Dequeues a number of contiguous object blocks from the external pool. Defined at line 498 of rte_mempool.h.
  • rte_mempool_get_count โ€” signature typedef unsigned(* rte_mempool_get_count) (const struct rte_mempool *mp). Returns the number of available objects in the external pool. how many are left in the jar ๐Ÿ“. Defined at line 504 of rte_mempool.h.
  • rte_mempool_calc_mem_size_t โ€” signature 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). Calculates the memory size required to store a given number of objects ๐Ÿงฎ

Okay so here's the tea: if mempool objects are not required to be IOVA-contiguous (that's the flag RTE_MEMPOOL_F_NO_IOVA_CONTIG being set), then min_chunk_size defines the virtually contiguous chunk size. Otherwise, if mempool objects must be IOVA-contiguous (the flag RTE_MEMPOOL_F_NO_IOVA_CONTIG is clear), then min_chunk_size defines the IOVA-contiguous chunk size.

Parameters:

  • mp โ€” Pointer to the memory pool.
  • obj_num โ€” Number of objects.
  • pg_shift โ€” LOG2 of the physical pages size. If set to 0, ignore page boundaries.
  • min_chunk_size โ€” Location for minimum size of the memory chunk which may be used to store memory pool objects.
  • align โ€” Location for required memory chunk alignment.

Returns: Required memory size.

Defined at line 529 of rte_mempool.h.

  • rte_mempool_populate_obj_cb_t โ€” signature typedef void rte_mempool_populate_obj_cb_t(struct rte_mempool *mp, void *opaque, void *vaddr, rte_iova_t iova). The function to be called for each populated object ๐Ÿซถ Parameters:
    • mp โ€” A pointer to the mempool structure.
    • opaque โ€” An opaque pointer passed to iterator.
    • vaddr โ€” Object virtual address.
    • iova โ€” Input/output virtual address of the object or RTE_BAD_IOVA.

Defined at line 595 of rte_mempool.h.

  • rte_mempool_populate_t โ€” signature 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). Populates memory pool objects using a 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:

  • mp โ€” A pointer to the mempool structure.
  • max_objs โ€” Maximum number of objects to be populated.
  • vaddr โ€” The virtual address of memory that should be used to store objects.
  • iova โ€” The IO address.
  • len โ€” The length of memory in bytes.
  • obj_cb โ€” Callback function to be executed for each populated object.
  • obj_cb_arg โ€” An opaque pointer passed to the callback function.

Returns: The number of objects added on success. On error, no objects are populated and a negative errno is returned ๐Ÿ’€.

Defined at line 626 of rte_mempool.h.

  • rte_mempool_get_info_t โ€” signature typedef int(* rte_mempool_get_info_t) (const struct rte_mempool *mp, struct rte_mempool_info *info). Gets some additional information about a mempool ๐Ÿ” nosy but make it legal. Defined at line 687 of rte_mempool.h.
  • rte_mempool_obj_cb_t โ€” signature typedef void rte_mempool_obj_cb_t(struct rte_mempool *mp, void *opaque, void *obj, unsigned obj_idx). An object callback function for mempool. Used by rte_mempool_create() and rte_mempool_obj_iter(). Defined at line 999 of rte_mempool.h.
  • rte_mempool_mem_cb_t โ€” signature typedef void rte_mempool_mem_cb_t(struct rte_mempool *mp, void *opaque, struct rte_mempool_memhdr *memhdr, unsigned mem_idx). A memory callback function for mempool. Used by rte_mempool_mem_iter(). Defined at line 1008 of rte_mempool.h.
  • rte_mempool_ctor_t โ€” signature typedef void rte_mempool_ctor_t(struct rte_mempool *, void *). A mempool constructor callback function ๐ŸŽ€ The arguments are the mempool and the opaque pointer given by the user in rte_mempool_create(). Defined at line 1018 of rte_mempool.h.

๐ŸŒˆ Enumeration Type Documentation ๐ŸŒˆ

enum rte_mempool_event

Mempool event type โœจ the two moods of a mempool's life:

  • RTE_MEMPOOL_EVENT_READY โ€” occurs after a mempool is fully populated. the glow-up is complete ๐Ÿ’–
  • RTE_MEMPOOL_EVENT_DESTROY โ€” occurs before the destruction of a mempool begins. moment of silence ๐Ÿ•ฏ๏ธ

Defined at line 1991 of rte_mempool.h.


๐Ÿ‘‘ Function Documentation ๐Ÿ‘‘

  • RTE_STAILQ_HEAD (rte_mempool_objhdr_list , rte_mempool_objhdr ) โ€” a list of object headers type.
  • RTE_STAILQ_HEAD (rte_mempool_memhdr_list , rte_mempool_memhdr ) โ€” a list of memory where objects are stored.
  • struct rte_mempool * rte_mempool_from_obj (void * obj) [inline], [static] โ€” returns a pointer to the mempool owning this object ๐Ÿซถ

Parameters:

  • obj โ€” An object that is owned by a pool. If this is not the case, the behavior is undefined โš ๏ธ (so likeโ€ฆ don't, bestie).

Returns: A pointer to the mempool structure.

Defined at line 392 of rte_mempool.h.

  • 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) โ€” the default way to calculate the memory size required to store a given number of objects. It's equivalent to rte_mempool_op_calc_mem_size_helper(mp, obj_num, pg_shift, 0, min_chunk_size, 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) โ€” the default way to populate a memory pool object using a provided memory chunk. It's equivalent to rte_mempool_op_populate_helper(mp, 0, max_objs, vaddr, iova, len, obj_cb, obj_cb_arg).
  • int rte_mempool_ops_get_info (const struct rte_mempool * mp, struct rte_mempool_info * info) โ€” a wrapper for the mempool_ops get_info callback.

Parameters:

  • mp โ€” Pointer to the memory pool.
  • info โ€” Pointer to the rte_mempool_info structure.

Returns:

Returns, bestie:

  • 0 โ€” Success; The mempool driver supports retrieving supplementary mempool information
  • -ENOTSUP โ€” doesn't support get_info ops (valid case).

โœจ rte_mempool_set_ops_byname()

   int rte_mempool_set_ops_byname (struct rte_mempool * mp, const char * name,
       void * pool_config)

Okay so this one sets the ops of a mempool. Iconic. But it can ONLY be done on a mempool that is not populated, i.e. just after a call to rte_mempool_create_empty(). No cap.

Parameters:

  • mp โ€” Pointer to the memory pool.
  • name โ€” Name of the ops structure to use for this mempool.
  • pool_config โ€” Opaque data that can be passed by the application to the ops functions.

Returns:

  • 0: Success; the mempool is now using the requested ops functions.
  • -EINVAL โ€” Invalid ops struct name provided.
  • -EEXIST โ€” mempool already has an ops struct assigned.

โœจ rte_mempool_register_ops()

   int rte_mempool_register_ops (const struct rte_mempool_ops * ops)

Register mempool operations. Let's go.

Parameters:

  • ops โ€” Pointer to an ops structure to register.

Returns:

  • >=0: Success; return the index of the ops struct in the table.
  • -EINVAL โ€” some missing callbacks while registering ops struct.
  • -ENOSPC โ€” the maximum number of ops structs has been reached.

โœจ rte_mempool_free()

   void rte_mempool_free (struct rte_mempool * mp)

Free a mempool. Say goodbye, bestie.

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:

  • mp โ€” A pointer to the mempool structure. If NULL then, the function does nothing.

โœจ rte_mempool_create()

   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 int flags)

Create a new mempool named name in memory. Main character energy.

This function uses rte_memzone_reserve() to allocate memory. The pool contains n elements of elt_size. Its size is set to n.

Parameters:

  • name โ€” The name of the mempool.
  • n โ€” The number of elements in the mempool. The optimum size (in terms of memory usage) for a mempool is when n is a power of two minus one: n = (2^q - 1).
  • elt_size โ€” The size of each element.
  • cache_size โ€” If cache_size is non-zero, the rte_mempool library will try to limit the accesses to the common lockless pool, by maintaining a per-lcore object cache. This argument must be lower or equal to RTE_MEMPOOL_CACHE_MAX_SIZE and n / 1.5. It is advised to choose cache_size to have "n modulo cache_size == 0": if this is not the case, some elements will always stay in the pool and will never be used. The access to the per-lcore table is of course faster than the multi-producer/consumer pool. The cache can be disabled if the cache_size argument is set to 0; it can be useful to avoid losing objects in cache.
  • private_data_size โ€” The size of the private data appended after the mempool structure. This is useful for storing some private data after the mempool structure, as is done for rte_mbuf_pool for example.
  • mp_init โ€” A function pointer that is called for initialization of the pool, before object initialization. The user can initialize the private data in this function if needed. This parameter can be NULL if not needed.
  • mp_init_arg โ€” An opaque pointer to data that can be used in the mempool constructor function.
  • obj_init โ€” A function pointer that is called for each object at initialization of the pool. The user can set some meta data in objects if needed. This parameter can be NULL if not needed. The obj_init() function takes the mempool pointer, the init_arg, the object pointer and the object number as parameters.
  • obj_init_arg โ€” An opaque pointer to data that can be used as an argument for each call to the object constructor function.
  • socket_id โ€” The socket_id argument is the socket identifier in the case of NUMA. The value can be SOCKET_ID_ANY if there is no NUMA constraint for the reserved zone.
  • flags โ€” The flags arguments is an OR of following flags:
    • RTE_MEMPOOL_F_NO_SPREAD: By default, objects addresses are spread between channels in RAM: the pool allocator will add padding between objects depending on the hardware configuration. See Memory alignment constraints for details. If this flag is set, the allocator will just align them to a cache line.
    • RTE_MEMPOOL_F_NO_CACHE_ALIGN: By default, the returned objects are cache-aligned. This flag removes this constraint, and no padding will be present between objects. This flag implies RTE_MEMPOOL_F_NO_SPREAD.
    • RTE_MEMPOOL_F_SP_PUT: If this flag is set, the default behavior when using rte_mempool_put() or rte_mempool_put_bulk() is "single-producer". Otherwise, it is "multi-producers".
    • RTE_MEMPOOL_F_SC_GET: If this flag is set, the default behavior when using rte_mempool_get() or rte_mempool_get_bulk() is "single-consumer". Otherwise, it is "multi-consumers".
    • RTE_MEMPOOL_F_NO_IOVA_CONTIG: If set, allocated objects won't necessarily be contiguous in IO memory.

Returns: The pointer to the new allocated mempool, on success. NULL on error with rte_errno set appropriately. Possible rte_errno values include:

  • E_RTE_NO_CONFIG โ€” function could not get pointer to rte_config structure
  • EINVAL โ€” cache size provided is too large or an unknown flag was passed
  • ENOSPC โ€” the maximum number of memzones has already been allocated
  • EEXIST โ€” a memzone with the same name already exists
  • ENOMEM โ€” no appropriate memory area found in which to create memzone

โœจ rte_mempool_create_empty()

   struct rte_mempool struct rte_mempool * rte_mempool_create_empty (const char
       * name, unsigned int n, unsigned int elt_size, unsigned int cache_size,
       unsigned int private_data_size, int socket_id, unsigned int flags)

Create an empty mempool. It's giving "not yet populated".

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:

  • name โ€” The name of the mempool.
  • n โ€” The maximum number of elements that can be added in the mempool. The optimum size (in terms of memory usage) for a mempool is when n is a power of two minus one: n = (2^q - 1).
  • elt_size โ€” The size of each element.
  • cache_size โ€” Size of the cache. See rte_mempool_create() for details.
  • private_data_size โ€” The size of the private data appended after the mempool structure. This is useful for storing some private data after the mempool structure, as is done for rte_mbuf_pool for example.
  • socket_id โ€” The socket_id argument is the socket identifier in the case of NUMA. The value can be SOCKET_ID_ANY if there is no NUMA constraint for the reserved zone.
  • flags โ€” Flags controlling the behavior of the mempool. See rte_mempool_create() for details.

Returns: The pointer to the new allocated mempool, on success. NULL on error with rte_errno set appropriately. See rte_mempool_create() for details.


โœจ rte_mempool_populate_iova()

   struct rte_mempool struct rte_mempool 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)

Add physically contiguous memory for objects in the pool at init. Physical? We love a contiguous queen.

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:

  • mp โ€” A pointer to the mempool structure.
  • vaddr โ€” The virtual address of memory that should be used to store objects.
  • iova โ€” The IO address
  • len โ€” The length of memory in bytes.
  • free_cb โ€” The callback used to free this chunk when destroying the mempool.
  • opaque โ€” An opaque argument passed to free_cb.

Returns: The number of objects added on success (strictly positive). On error, the chunk is not added in the memory list of the mempool the following code is returned: (0): not enough room in chunk for one object. (-ENOSPC): mempool is already populated. (-ENOMEM): allocation failure.


โœจ rte_mempool_populate_virt()

   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)

Add virtually contiguous memory for objects in the pool at init. Virtual realness.

Add a virtually contiguous memory chunk in the pool where objects can be instantiated.

Parameters:

  • mp โ€” A pointer to the mempool structure.
  • addr โ€” The virtual address of memory that should be used to store objects.
  • len โ€” The length of memory in bytes.
  • pg_sz โ€” The size of memory pages in this virtual area.
  • free_cb โ€” The callback used to free this chunk when destroying the mempool.
  • opaque โ€” An opaque argument passed to free_cb.

Returns: The number of objects added on success (strictly positive). On error, the chunk is not added in the memory list of the mempool the following code is returned: (0): not enough room in chunk for one object. (-ENOSPC): mempool is already populated. (-ENOMEM): allocation failure.


โœจ rte_mempool_populate_default()

   int rte_mempool_populate_default (struct rte_mempool * mp)

Add memory for objects in the pool at init. Default slay.

This is the default function used by rte_mempool_create() to populate the mempool. It adds memory allocated using rte_memzone_reserve().

Parameters:

  • mp โ€” A pointer to the mempool structure.

Returns: The number of objects added on success. On error, the chunk is not added in the memory list of the mempool and a negative errno is returned.


โœจ rte_mempool_populate_anon()

   int rte_mempool_populate_anon (struct rte_mempool * mp)

Add memory from anonymous mapping for objects in the pool at init. Anonymous but locked in memory, iykyk.

This function mmap an anonymous memory zone that is locked in memory to store the objects of the mempool.

Parameters:

  • mp โ€” A pointer to the mempool structure.

Returns: The number of objects added on success. On error, 0 is returned, rte_errno is set, and the chunk is not added in the memory list of the mempool.


โœจ rte_mempool_obj_iter()

   uint32_t rte_mempool_obj_iter (struct rte_mempool * mp, rte_mempool_obj_cb_t
       * obj_cb, void * obj_cb_arg)

Call a function for each mempool element. Iterate, bestie, iterate.

Iterate across all objects attached to a rte_mempool and call the callback function on it.

Parameters for that last function, bestie ๐Ÿ’–:

  • mp โ€” a pointer to an initialized mempool. Like, it's already set up and ready to go โœจ
  • obj_cb โ€” a function pointer that's called for each object. It's giving callback energy ๐Ÿ’…
  • obj_cb_arg โ€” an opaque pointer passed to the callback function. Opaque means we don't peek, we just pass it through ๐Ÿซถ

Returns โ€” the number of objects iterated. That's how many times the callback got called, periodt. ๐Ÿ“Š


rte_mempool_mem_iter โ€” call a function for each mempool memory chunk ๐Ÿ’ซ

   uint32_t rte_mempool_mem_iter (struct rte_mempool * mp, rte_mempool_mem_cb_t
       * mem_cb, void * mem_cb_arg)

okay so this one iterates across all the memory chunks attached to a rte_mempool and calls the callback function on each one. It's like a little tour of every memory chunk, and your callback gets to say hi to each ๐Ÿงš

Parameters:

  • mp โ€” a pointer to an initialized mempool. It's the main character of this story ๐Ÿ‘‘
  • mem_cb โ€” a function pointer that gets called for each memory chunk. Your callback, your rules ๐Ÿ’…
  • mem_cb_arg โ€” an opaque pointer passed to the callback function. We don't touch it, we just deliver it ๐Ÿซถ

Returns โ€” the number of memory chunks iterated. That's how many chunks got the callback treatment โœจ


rte_mempool_dump โ€” dump the status of the mempool to a file ๐Ÿ“

   void rte_mempool_dump (FILE * f, struct rte_mempool * mp)

This one dumps the status of the mempool to a file. It's like a little mempool diary entry, but for debugging ๐Ÿ’…

Parameters:

  • f โ€” a pointer to a file for output. Where the tea gets written โ˜•
  • mp โ€” a pointer to the mempool structure. The mempool in question ๐Ÿ‘‘

rte_mempool_cache_create โ€” create a user-owned mempool cache ๐ŸŽ€

   struct rte_mempool_cache * rte_mempool_cache_create (uint32_t size, int
       socket_id)

This creates a user-owned mempool cache. It can be used by unregistered non-EAL threads to enable caching when they interact with a mempool. So if you're not a registered EAL thread, you can still have cache energy โœจ

Parameters:

  • size โ€” the size of the mempool cache. See rte_mempool_create()'s cache_size parameter description for more information. The same limits and considerations apply here too. So don't skip that part, bestie ๐Ÿ“
  • socket_id โ€” the socket identifier in the case of NUMA. The value can be SOCKET_ID_ANY if there is no NUMA constraint for the reserved zone. NUMA? More like NU-ME, am I right? ๐Ÿ’…

rte_mempool_cache_free โ€” free a user-owned mempool cache ๐Ÿ—‘๏ธ

   void rte_mempool_cache_free (struct rte_mempool_cache * cache)

Frees a user-owned mempool cache. It's giving cleanup era ๐Ÿงน

Parameters:

  • cache โ€” a pointer to the mempool cache. The one to free ๐Ÿ’–

rte_mempool_default_cache โ€” get a pointer to the per-lcore default mempool cache ๐ŸŒธ

   __rte_always_inline struct rte_mempool_cache * rte_mempool_default_cache
       (struct rte_mempool * mp, unsigned lcore_id) [static]

Gets a pointer to the per-lcore default mempool cache. It's like your lcore's personal cache bestie ๐Ÿ’…

Parameters:

  • mp โ€” a pointer to the mempool structure. The mempool in question ๐Ÿ‘‘
  • lcore_id โ€” the logical core id. Which core's cache we're talking about ๐Ÿง 

Returns โ€” a pointer to the mempool cache or NULL if disabled or unregistered non-EAL thread. So if you get NULL, don't come for me, it's just not enabled ๐Ÿ˜ญ

Definition at line 1339 of file rte_mempool.h.


rte_mempool_cache_flush โ€” flush a user-owned mempool cache to the specified mempool ๐Ÿšฟ

   __rte_always_inline void rte_mempool_cache_flush (struct rte_mempool_cache *
       cache, struct rte_mempool * mp) [static]

Flushes a user-owned mempool cache to the specified mempool. It's like emptying your pockets back into the pool, but make it fashion ๐Ÿ’…

Parameters:

  • cache โ€” a pointer to the mempool cache. The cache to flush ๐Ÿงบ
  • mp โ€” a pointer to the mempool. Where it gets flushed to ๐ŸŒŠ

Definition at line 1361 of file rte_mempool.h.


rte_mempool_generic_put โ€” put several objects back in the mempool ๐Ÿ“ฆ

   __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]

Puts several objects back in the mempool. It's a bulk return situation, no cap ๐Ÿงข

Parameters:

  • mp โ€” a pointer to the mempool structure. The destination ๐Ÿ‘‘
  • obj_table โ€” a pointer to a table of void * pointers (objects). The objects going back ๐ŸŽ’
  • n โ€” the number of objects to add in the mempool from the obj_table. How many are going back? Count them, bestie ๐Ÿ”ข
  • cache โ€” a pointer to a mempool cache structure. May be NULL if not needed. So optional, like a cute accessory ๐Ÿ’…

Definition at line 1451 of file rte_mempool.h.


rte_mempool_put_bulk โ€” put several objects back in the mempool ๐Ÿ“ฆ

   __rte_always_inline void rte_mempool_put_bulk (struct rte_mempool * mp, void
       *const * obj_table, unsigned int n) [static]

Puts 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). So it's got range, depending on how you set it up โœจ

Parameters:

  • mp โ€” a pointer to the mempool structure. The home base ๐Ÿ‘‘
  • obj_table โ€” a pointer to a table of void * pointers (objects). The squad of objects ๐Ÿงธ
  • n โ€” the number of objects to add in the mempool from obj_table. How many are we putting back? ๐Ÿ”ข

Definition at line 1474 of file rte_mempool.h.


rte_mempool_put โ€” put one object back in the mempool ๐Ÿงธ

   __rte_always_inline void rte_mempool_put (struct rte_mempool * mp, void *
       obj) [static]

Puts 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). Single object, single vibe ๐Ÿ’…

Parameters:

  • mp โ€” a pointer to the mempool structure. The pool ๐Ÿ‘‘
  • obj โ€” a pointer to the object to be added. The one object going back ๐ŸŽ€

Definition at line 1496 of file rte_mempool.h.


rte_mempool_generic_get โ€” get several objects from the mempool ๐Ÿ›๏ธ

   __rte_always_inline int rte_mempool_generic_get (struct rte_mempool * mp,
       void ** obj_table, unsigned int n, struct rte_mempool_cache * cache)
       [static]

Gets 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. So don't blame me if it's empty, it's just a lack of objects, periodt ๐Ÿ˜ญ

Parameters:

  • mp โ€” a pointer to the mempool structure. The source ๐Ÿ‘‘
  • obj_table โ€” a pointer to a table of void * pointers (objects) that will be filled. The shopping bag ๐Ÿ‘œ
  • n โ€” the number of objects to get from mempool to obj_table. How many do you want? ๐Ÿ”ข
  • cache โ€” a pointer to a mempool cache structure. May be NULL if not needed. Optional, like a little treat ๐Ÿ’…

Returns:

  • 0: Success; objects taken. Slay โœจ
  • -ENOENT: Not enough entries in the mempool; no object is retrieved. So empty, no cap ๐Ÿ˜ญ

Definition at line 1657 of file rte_mempool.h.


rte_mempool_get_bulk โ€” get several objects from the mempool ๐Ÿ›๏ธ

   __rte_always_inline int rte_mempool_get_bulk (struct rte_mempool * mp, void
       ** obj_table, unsigned int n) [static]

Gets 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. So yeah, it can be empty even if other lcores have stuff. It's a whole thing ๐Ÿคท

Parameters:

  • mp โ€” a pointer to the mempool structure. The source ๐Ÿ‘‘
  • obj_table โ€” a pointer to a table of void * pointers (objects) that will be filled. The bag ๐Ÿ‘œ
  • n โ€” the number of objects to get from the mempool to obj_table. How many? ๐Ÿ”ข

Returns:

  • 0: Success; objects taken. Ate ๐Ÿ’…
  • -ENOENT: Not enough entries in the mempool; no object is retrieved. Empty vibes ๐Ÿ˜ญ

Definition at line 1691 of file rte_mempool.h.


rte_mempool_get โ€” get one object from the mempool ๐ŸŽ

   __rte_always_inline int rte_mempool_get (struct rte_mempool * mp, void **
       obj_p) [static]

Gets 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. So just one object, but the same drama ๐Ÿ˜ญ

Parameters:

  • mp โ€” a pointer to the mempool structure. The pool ๐Ÿ‘‘
  • obj_p โ€” a pointer to a void * pointer (object) that will be filled. The spot where the object will go ๐Ÿ“

Returns:

  • 0: Success; objects taken. Got it ๐Ÿ’…
  • -ENOENT: Not enough entries in the mempool; no object is retrieved. Nada ๐Ÿ˜ญ

Definition at line 1720 of file rte_mempool.h.


rte_mempool_get_contig_blocks โ€” get a contiguous blocks of objects from the mempool ๐Ÿงฑ

   __rte_always_inline int rte_mempool_get_contig_blocks (struct rte_mempool *
       mp, void ** first_obj_table, unsigned int n) [static]

Gets 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. So don't just assume, check the driver, bestie ๐Ÿ•ต๏ธ

Parameters:

  • mp โ€” a pointer to the mempool structure. The pool ๐Ÿ‘‘
  • first_obj_table โ€” a pointer to a pointer to the first object in each block. The starting points of the blocks ๐Ÿ“
  • n โ€” the number of blocks to get from mempool. How many blocks? ๐Ÿ”ข

Returns:

  • 0: Success; blocks taken. Blocks secured ๐Ÿงฑ
  • -ENOBUFS: Not enough entries in the mempool; no object is retrieved. Not enough stuff ๐Ÿ˜ญ
  • -EOPNOTSUPP: The mempool driver does not support block dequeue. So the driver said no, and that's that ๐Ÿšซ

Definition at line 1747 of file rte_mempool.h.


rte_mempool_avail_count โ€” return the number of entries in the mempool ๐Ÿ”ข

   unsigned int rte_mempool_avail_count (const struct rte_mempool * mp)

Returns 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. So it's a debug tool, not a data path thing. Don't put it in your hot loop, bestie ๐Ÿข

Parameters:

  • mp โ€” a pointer to the mempool structure. The pool ๐Ÿ‘‘

Returns โ€” the number of entries in the mempool. That's the count, periodt ๐Ÿ“Š


rte_mempool_in_use_count โ€” return the number of elements which have been allocated from the mempool ๐Ÿ”ข

   unsigned int rte_mempool_in_use_count (const struct rte_mempool * mp)

Returns 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. Again, debug only, don't be putting this in your fast path ๐Ÿข

Parameters:

  • mp โ€” a pointer to the mempool structure. The pool ๐Ÿ‘‘

Returns โ€” the number of free entries in the mempool. Wait, it says free entries? That's what the original says. So it's the number of free entries. That's what it says, I don't make the rules ๐Ÿคท


rte_mempool_full โ€” test if the mempool is full ๐Ÿˆต

   int rte_mempool_full (const struct rte_mempool * mp) [inline],  [static]

Tests 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. So debug only, and it tells you if it's full ๐Ÿ’ฏ

Parameters:

  • mp โ€” a pointer to the mempool structure. The pool ๐Ÿ‘‘

Returns:

  • 1: The mempool is full. Full house ๐Ÿ 
  • 0: The mempool is not full. Still got room ๐Ÿ’…

Definition at line 1810 of file rte_mempool.h.


rte_mempool_empty โ€” test if the mempool is empty ๐Ÿˆณ

   int rte_mempool_empty (const struct rte_mempool * mp) [inline],  [static]

Tests 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. Debug only, and it tells you if it's empty ๐Ÿ˜ญ

Parameters:

  • mp โ€” a pointer to the mempool structure. The pool ๐Ÿ‘‘

Returns:

  • 1: The mempool is empty. Empty, no cap ๐Ÿ˜ญ
  • 0: The mempool is not empty. Still got stuff โœจ

Definition at line 1829 of file rte_mempool.h.


rte_mempool_virt2iova โ€” return the IO address of elt, which is an element of the pool mp ๐ŸŒ

   rte_iova_t rte_mempool_virt2iova (const void * elt) [inline],  [static]

Returns the IO address of elt, which is an element of the pool mp. It's giving address translation energy ๐Ÿ’…

Parameters:

  • elt โ€” a pointer (virtual address) to the element of the pool. The element in question ๐Ÿ“

Returns โ€” the IO address of the elt element. If the mempool was created with RTE_MEMPOOL_F_NO_IOVA_CONTIG, the returned value is RTE_BAD_IOVA. So if you set that flag, you get RTE_BAD_IOVA. Just a heads up ๐Ÿšจ

Definition at line 1845 of file rte_mempool.h.


rte_mempool_audit โ€” check the consistency of mempool objects ๐Ÿ”

   void rte_mempool_audit (struct rte_mempool * mp)

Checks the consistency of mempool objects. Verifies the coherency of fields in the mempool structure. Also checks 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. So if something's off, it's panic time. No cap ๐Ÿ˜ฑ

Parameters:

  • mp โ€” a pointer to the mempool structure. The pool to audit ๐Ÿ‘‘

rte_mempool_get_priv โ€” return a pointer to the private data in an mempool structure ๐Ÿ”

   void * rte_mempool_get_priv (struct rte_mempool * mp) [inline],  [static]

Returns a pointer to the private data in an mempool structure. It's giving private data access ๐Ÿ’…

Parameters:

  • mp โ€” a pointer to the mempool structure. The pool ๐Ÿ‘‘

Returns โ€” a pointer to the private data. The private data, just for you ๐Ÿซถ

Definition at line 1873 of file rte_mempool.h.


rte_mempool_list_dump โ€” dump the status of all mempools on the console ๐Ÿ–ฅ๏ธ

   void rte_mempool_list_dump (FILE * f)

Dumps the status of all mempools on the console. It's like a group chat for all your mempools, but for debugging ๐Ÿ’…

Parameters:

  • f โ€” a pointer to a file for output. Where the tea gets written โ˜•

rte_mempool_lookup โ€” search a mempool from its name ๐Ÿ”Ž

   struct rte_mempool * rte_mempool_lookup (const char * name)

Searches a mempool from its name. It's like finding your friend in a crowd, but by name ๐Ÿ’…

Parameters:

  • name โ€” the name of the mempool. The name you're looking for ๐Ÿท๏ธ

Returns โ€” the pointer to the mempool matching the name, or NULL if not found. NULL on error with rte_errno set appropriately. Possible rte_errno values include:

  • ENOENT โ€” required entry not available to return.

โœจ rte_mempool_calc_obj_size โœจ

uint32_t rte_mempool_calc_obj_size (uint32_t elt_size, uint32_t flags,
    struct rte_mempool_objsz * sz)

Okay so this function is your little size calculator, bestie. Get the header, trailer and total size of a mempool element. Given a desired size of the mempool element and mempool flags, it calculates header, trailer, body and total sizes of the mempool object. No cap.

Parameters

  • elt_size โ€” The size of each element, without header and trailer.
  • flags โ€” The flags used for the mempool creation. Consult rte_mempool_create() for more information about possible values. The size of each element.
  • sz โ€” The calculated detailed size the mempool object. May be NULL.

Returns โ€” Total size of the mempool object.


โœจ rte_mempool_walk โœจ

void rte_mempool_walk (void(* func )(struct rte_mempool *, void *arg), void
    * arg)

Walk list of all memory pools. Take a little stroll through every single memory pool, bestie.

Parameters

  • func โ€” Iterator function
  • arg โ€” Argument passed to iterator

โœจ rte_mempool_get_mem_range โœจ

Warning โ€” EXPERIMENTAL: this API may change without prior notice.
__rte_experimental int rte_mempool_get_mem_range (const struct rte_mempool *
    mp, struct rte_mempool_mem_range_info * mem_range)

Get information about the memory range used to store objects in the mempool. So this one tells you where your objects are chilling in memory, lowkey.

Parameters

  • mp โ€” Pointer to an initialized mempool.
  • mem_range โ€” Pointer to struct which is used to return lowest address, length of the memory range containing all the addresses, and whether these addresses are contiguous.

Returns โ€” 0 on success, -EINVAL if mempool is not valid or mem_range is NULL.


โœจ rte_mempool_get_obj_alignment โœจ

Warning โ€” EXPERIMENTAL: this API may change without prior notice.
__rte_experimental size_t rte_mempool_get_obj_alignment (const struct
    rte_mempool * mp)

Return alignment of objects stored in the mempool. Slay, alignment info coming right up.

Parameters

  • mp โ€” Pointer to a mempool.

Returns โ€” Object alignment if mp is valid. 0 if mp is NULL.


โœจ Variable Documentation โœจ

  • struct rte_mempool_ops_table rte_mempool_ops_table [extern] โ€” Array of registered ops structs.

โœจ Author โœจ

Generated automatically by Doxygen for DPDK from the source code.


And that's a wrap on this iconic manual page! ๐Ÿ’– Brought to you by DPDK Version 25.11.3 and the one and only rte_mempool.h(3). Now go forth and mempool like the main character you are. ๐Ÿ‘‘โœจ

๐Ÿ“ฆ where this page comes from