rte_mempool.h(3)

πŸ“¦ version 26.03, in nixos 26.05, nixpkgs unstable

πŸ’– rte_mempool.h(3) β€” Library Functions Manual πŸ’–

πŸŽ€ NAME

rte_mempool.h

✨ SYNOPSIS

okay bestie, here’s the include stack exactly as it shows up, no cap:

#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

these are the structs in the header, and yes we’re listing every single one πŸ’…

  • 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

here’s the macro roster, exactly as written β€” not skipping a single crumb πŸ“

#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

the typedefs are giving very β€œfunction-pointer family reunion” energy, and every one of them is here 🫢

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

one enum, two events, zero crumbs left behind ✨

enum rte_mempool_event { RTE_MEMPOOL_EVENT_READY = 0,
           RTE_MEMPOOL_EVENT_DESTROY = 1 }

πŸ”₯ Functions

this is the big one β€” every function signature is copied exactly, even the chaotic-looking wrapped bits, because we do not β€œfix” the header πŸ’€

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

one variable, sitting there with main-character energy πŸ‘‘

struct rte_mempool_ops_table rte_mempool_ops_table

πŸ’– Detailed Description

RTE Mempool. okay so a memory pool is literally an allocator of fixed-size object. It is identified by its name, and it 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. πŸ’…

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.

🌸 Macro Definition Documentation 🌸

Ok bestie, this section is literally just a parade of #defines and I promise it's more fun than it sounds. Every one of these is a flag or a magic number your mempool cares about. Let's go πŸ’…


RTE_MEMPOOL_HEADER_COOKIE1

#define RTE_MEMPOOL_HEADER_COOKIE1   0xbadbadbadadd2e55ULL

Header cookie πŸͺ (yes it's really called that, no I'm not kidding).

Definition at line 59 of file rte_mempool.h.


RTE_MEMPOOL_HEADER_COOKIE2

#define RTE_MEMPOOL_HEADER_COOKIE2   0xf2eef2eedadd2e55ULL

The other header cookie. Every good header needs two, apparently ✨

Definition at line 60 of file rte_mempool.h.


#define RTE_MEMPOOL_TRAILER_COOKIE   0xadd2e55badbadbadULL

Trailer cookie β€” the header cookies' slightly unhinged sibling at the other end of the buffer πŸ’€

Definition at line 61 of file rte_mempool.h.


RTE_MEMPOOL_ALIGN

#define RTE_MEMPOOL_ALIGN   RTE_CACHE_LINE_SIZE

How elements inside the mempool get aligned. It's literally just RTE_CACHE_LINE_SIZE, icon behaviour πŸ‘‘

Definition at line 139 of file rte_mempool.h.


RTE_MEMPOOL_F_NO_SPREAD

#define RTE_MEMPOOL_F_NO_SPREAD   0x0001

You're telling it you don't need objects spread across memory channels. Lowkey saying "nah, keep it simple" 🌈

Definition at line 275 of file rte_mempool.h.


MEMPOOL_F_NO_SPREAD

#define MEMPOOL_F_NO_SPREAD   RTE_MEMPOOL_F_NO_SPREAD

Backward compatibility synonym for RTE_MEMPOOL_F_NO_SPREAD. It's slated to be deprecated, so don't get too attached πŸ™ˆ

Definition at line 280 of file rte_mempool.h.


RTE_MEMPOOL_F_NO_CACHE_ALIGN

#define RTE_MEMPOOL_F_NO_CACHE_ALIGN   0x0002

Don't align objects on cache lines. Chaotic, but valid ✨

Definition at line 282 of file rte_mempool.h.


MEMPOOL_F_NO_CACHE_ALIGN

#define MEMPOOL_F_NO_CACHE_ALIGN   RTE_MEMPOOL_F_NO_CACHE_ALIGN

Backward compatibility synonym for RTE_MEMPOOL_F_NO_CACHE_ALIGN. To be deprecated 🫢

Definition at line 287 of file rte_mempool.h.


RTE_MEMPOOL_F_SP_PUT

#define RTE_MEMPOOL_F_SP_PUT   0x0004

The default put is "single-producer". One producer girlie at a time, please πŸ™

Definition at line 289 of file rte_mempool.h.


MEMPOOL_F_SP_PUT

#define MEMPOOL_F_SP_PUT   RTE_MEMPOOL_F_SP_PUT

Backward compatibility synonym for RTE_MEMPOOL_F_SP_PUT. To be deprecated πŸ’œ

Definition at line 294 of file rte_mempool.h.


RTE_MEMPOOL_F_SC_GET

#define RTE_MEMPOOL_F_SC_GET   0x0008

The default get is "single-consumer". Again β€” one consumer, main character energy only 🌟

Definition at line 296 of file rte_mempool.h.


MEMPOOL_F_SC_GET

#define MEMPOOL_F_SC_GET   RTE_MEMPOOL_F_SC_GET

Backward compatibility synonym for RTE_MEMPOOL_F_SC_GET. To be deprecated πŸŽ€

Definition at line 301 of file rte_mempool.h.


RTE_MEMPOOL_F_POOL_CREATED

#define RTE_MEMPOOL_F_POOL_CREATED   0x0010

Internal flag: the pool has been created. Not for you, bestie β€” hands off 🚫

Definition at line 303 of file rte_mempool.h.


RTE_MEMPOOL_F_NO_IOVA_CONTIG

#define RTE_MEMPOOL_F_NO_IOVA_CONTIG   0x0020

You don't need IOVA-contiguous objects. Freedom πŸ’«

Definition at line 305 of file rte_mempool.h.


MEMPOOL_F_NO_IOVA_CONTIG

#define MEMPOOL_F_NO_IOVA_CONTIG   RTE_MEMPOOL_F_NO_IOVA_CONTIG

Backward compatibility synonym for RTE_MEMPOOL_F_NO_IOVA_CONTIG. To be deprecated πŸ¦‹

Definition at line 310 of file rte_mempool.h.


RTE_MEMPOOL_F_NON_IO

#define RTE_MEMPOOL_F_NON_IO   0x0040

Internal flag: literally no object from this pool can be used for device IO (DMA). Not even one 😭

Definition at line 312 of file rte_mempool.h.


RTE_MEMPOOL_VALID_USER_FLAGS

#define RTE_MEMPOOL_VALID_USER_FLAGS

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

This macro is the guest list 🎟️ β€” it lists all the mempool flags an application is actually allowed to request. If your flag isn't on here, it's not getting past the bouncer.

Definition at line 317 of file rte_mempool.h.


RTE_MEMPOOL_OPS_NAMESIZE

#define RTE_MEMPOOL_OPS_NAMESIZE   32

Max length of the ops struct name. 32 characters, so make it count ✍️

Definition at line 458 of file rte_mempool.h.


RTE_MEMPOOL_POPULATE_F_ALIGN_OBJ

#define RTE_MEMPOOL_POPULATE_F_ALIGN_OBJ   0x0001

Align objects on addresses that are a multiple of total_elt_sz. Neat and tidy πŸ“

Definition at line 634 of file rte_mempool.h.


RTE_MEMPOOL_MAX_OPS_IDX

#define RTE_MEMPOOL_MAX_OPS_IDX   16

The max number of registered ops structs. Sixteen slots, no more πŸ‘‘

Definition at line 719 of file rte_mempool.h.


RTE_MEMPOOL_REGISTER_OPS

#define RTE_MEMPOOL_REGISTER_OPS( ops)

Value:

RTE_INIT(mp_hdlr_init_##ops)                \
{                           \
    rte_mempool_register_ops(&ops);         \
}

Macro to statically register the ops of a mempool handler.

Heads up, bestie 🚨 β€” rte_mempool_register_ops fails silently here when more than RTE_MEMPOOL_MAX_OPS_IDX are registered. Like, no error, no nothing. It just doesn't. πŸ’€

Definition at line 988 of file rte_mempool.h.


🧚 Typedef Documentation 🧚

These are all the function-pointer types the mempool machinery expects you to play nice with. Cute little contract types, honestly 🫢


rte_mempool_memchunk_free_cb_t

typedef void rte_mempool_memchunk_free_cb_t(struct rte_mempool_memhdr
     *memhdr, void *opaque)

Callback used to free a memory chunk 🧹

Definition at line 197 of file rte_mempool.h.


rte_mempool_alloc_t

typedef int(* rte_mempool_alloc_t) (struct rte_mempool *mp)

Prototype for the 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.


rte_mempool_free_t

typedef void(* rte_mempool_free_t) (struct rte_mempool *mp)

Free the opaque private data pointed to by the mp->pool_data pointer. Bye bestie πŸ‘‹

Definition at line 475 of file rte_mempool.h.


rte_mempool_enqueue_t

typedef int(* rte_mempool_enqueue_t) (struct rte_mempool *mp, void *const
     *obj_table, unsigned int n)

Enqueue n objects into the external pool.

Returns

  • 0: Success ✨
  • <0: Error 😭

Definition at line 483 of file rte_mempool.h.


rte_mempool_dequeue_t

typedef int(* rte_mempool_dequeue_t) (struct rte_mempool *mp, void
     **obj_table, unsigned int n)

Dequeue n objects from the external pool.

Returns

  • 0: Success ✨
  • <0: Error 😭

Definition at line 492 of file rte_mempool.h.


rte_mempool_dequeue_contig_blocks_t

typedef int(* rte_mempool_dequeue_contig_blocks_t) (struct rte_mempool *mp,
     void **first_obj_table, unsigned int n)

Dequeue a number of contiguous object blocks from the external pool 🧱

Definition at line 498 of file rte_mempool.h.


rte_mempool_get_count

typedef unsigned(* rte_mempool_get_count) (const struct rte_mempool *mp)

Return the number of available objects in the external pool. Counting is caring πŸ”’

Definition at line 504 of file rte_mempool.h.


rte_mempool_calc_mem_size_t

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)

Calculate the memory size required to store a 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. Slay, but read that twice πŸ’…

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.

Definition at line 529 of file rte_mempool.h.


rte_mempool_populate_obj_cb_t

typedef void rte_mempool_populate_obj_cb_t(struct rte_mempool *mp, void
     *opaque, void *vaddr, rte_iova_t iova)

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.

Definition at line 595 of file rte_mempool.h.


rte_mempool_populate_t

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)

Populate 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. Very chill of them ✨

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.

Definition at line 626 of file rte_mempool.h.


rte_mempool_get_info_t

typedef int(* rte_mempool_get_info_t) (const struct rte_mempool *mp, struct
     rte_mempool_info *info)

Get some additional information about a mempool. The tea β˜•

Definition at line 687 of file rte_mempool.h.


rte_mempool_obj_cb_t

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().

Definition at line 999 of file rte_mempool.h.


rte_mempool_mem_cb_t

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().

Definition at line 1008 of file rte_mempool.h.


rte_mempool_ctor_t

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() 🎬

Definition at line 1018 of file rte_mempool.h.


πŸ‘‘ Enumeration Type Documentation πŸ‘‘

enum rte_mempool_event

Mempool event type. The vibes, enumerated πŸ’«

Enumerator

  • RTE_MEMPOOL_EVENT_READY β€” Occurs after a mempool is fully populated. It's ready, it ate, no crumbs πŸ’…
  • RTE_MEMPOOL_EVENT_DESTROY β€” Occurs before the destruction of a mempool begins. The sad part 😭

Definition at line 1964 of file 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 πŸ—„οΈ


rte_mempool_from_obj

struct rte_mempool * rte_mempool_from_obj (void * obj) [inline],  [static]

Return a pointer to the mempool that owns this object. Like finding out which friend group someone belongs to 🫢

Parameters

  • obj β€” An object that is owned by a pool. If this is not the case, the behavior is undefined.
Bestie, fr fr β€” if that object isn't actually owned by a pool, all bets are off. Undefined behaviour, no cap πŸ’€

Returns

A pointer to the mempool structure.

Definition at line 392 of file rte_mempool.h.


rte_mempool_op_calc_mem_size_default

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)

Default way to calculate the memory size required to store a given number of objects.

Equivalent to rte_mempool_op_calc_mem_size_helper(mp, obj_num, pg_shift, 0, min_chunk_size, align). It's giving "we already did the math for you" ✨


rte_mempool_op_populate_default

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)

Default way to populate a memory pool object using a provided memory chunk.

Equivalent to rte_mempool_op_populate_helper(mp, 0, max_objs, vaddr, iova, len, obj_cb, obj_cb_arg). Same energy, one less argument πŸŽ€


rte_mempool_ops_get_info

int rte_mempool_ops_get_info (const struct rte_mempool * mp, struct
     rte_mempool_info * info)

Wrapper for the mempool_ops get_info callback. A little middle-man, but make it fashion πŸ’…

Parameters

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

Returns

  • 0: Success; the mempool driver supports retrieving supplementary mempool information
  • -ENOTSUP β€” doesn't support get_info ops (valid case, no drama πŸ’…).

int rte_mempool_set_ops_byname β€” set the ops of a mempool πŸŽ€

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

Okay so this one assigns which ops structure your mempool is gonna use. Big caveat bestie: you can only do this on a mempool that is not populated β€” like, literally just after you called rte_mempool_create_empty(). That's the window. Miss it and it's a no. πŸ™ˆ

Parameters

  • mp β€” pointer to the memory pool.
  • name β€” the name of the ops structure you wanna use for this mempool.
  • pool_config β€” opaque data that can be passed by the application to the ops functions.

Returns

  • 0 β€” success, slay; the mempool is now using the ops functions you asked for. ✨
  • -EINVAL β€” invalid ops struct name was provided.
  • -EEXIST β€” nope, this mempool already has an ops struct assigned.

int rte_mempool_register_ops β€” register mempool operations πŸ¦‹

int rte_mempool_register_ops(const struct rte_mempool_ops *ops)

This is the "hey the library, here's a new ops struct, add it to the table" function.

Parameters

  • ops β€” pointer to an ops structure to register.

Returns

  • >=0 β€” success; it returns the index of the ops struct in the table. ✨
  • -EINVAL β€” some callbacks were missing while registering the ops struct.
  • -ENOSPC β€” the maximum number of ops structs has been reached (the table is full, we're cooked πŸ’€).

void rte_mempool_free β€” free a mempool 🧹

void rte_mempool_free(struct rte_mempool *mp)

Unlinks the mempool from the global list, frees the memory chunks, and frees all memory referenced by the mempool. Cleanup era. 🌸

⚠️ The objects must not be used by other cores β€” they're gonna be freed. Like, actually freed. Don't touch them. 😭

Parameters

  • mp β€” a pointer to the mempool structure. If it's NULL then the function just does nothing (a true icon of not crashing).

struct rte_mempool * rte_mempool_create β€” create a new mempool named name in memory πŸ‘‘

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)

The main character constructor fr. 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.
  • 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. 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 argument is an OR of the 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

struct rte_mempool * rte_mempool_create_empty β€” create an empty 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)

The mempool is allocated and initialized, but it is not populated: no memory is allocated for the mempool elements. So you, yes you, have to call rte_mempool_populate_*() to add memory chunks to the pool. Once it's populated, you might also wanna 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.
  • 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.


int rte_mempool_populate_iova β€” add physically contiguous memory for objects in the pool at init 🧱

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)

Adds 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 and the following code is returned:

  • (0) β€” not enough room in chunk for one object.
  • (-ENOSPC) β€” mempool is already populated.
  • (-ENOMEM) β€” allocation failure.

int rte_mempool_populate_virt β€” add virtually contiguous memory for objects in the pool at init 🌈

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)

Adds a virtually contiguous memory chunk in the pool where objects can be instantiated. (Virtually only this time β€” no physical contiguity promises πŸ’….)

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 and the following code is returned:

  • (0) β€” not enough room in chunk for one object.
  • (-ENOSPC) β€” mempool is already populated.
  • (-ENOMEM) β€” allocation failure.

int rte_mempool_populate_default β€” add memory for objects in the pool at init ⭐

int rte_mempool_populate_default(struct rte_mempool *mp)

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

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. 😭


int rte_mempool_populate_anon β€” add memory from anonymous mapping for objects in the pool at init πŸ“

int rte_mempool_populate_anon(struct rte_mempool *mp)

This function mmaps 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.


uint32_t rte_mempool_obj_iter β€” call a function for each mempool element πŸ”

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

Iterates across all objects attached to a rte_mempool and calls the callback function on it. One by one, no skips. ✨

Parameters

  • mp β€” a pointer to an initialized mempool.
  • obj_cb β€” a function pointer that is called for each object.
  • obj_cb_arg β€” an opaque pointer passed to the callback function.

Returns

Number of objects iterated. πŸ‘‘


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

Iterates across all memory chunks attached to a rte_mempool and calls the callback function on it.

(still the chunk-walker, carry on bestie)

Parameters

  • mp β€” A pointer to an initialized mempool. πŸ’…
  • mem_cb β€” A function pointer that is called for each memory chunk. yeah, every single one, she's thorough.
  • mem_cb_arg β€” An opaque pointer passed to the callback function. it's the little bag of stuff you hand to your callback so it knows who it is πŸŽ€

Returns

Number of memory chunks iterated.


rte_mempool_dump

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

Dump the status of the mempool to a file. receipts, but for your pool 🧾✨

Parameters

  • f β€” A pointer to a file for output
  • mp β€” A pointer to the mempool structure.

rte_mempool_cache_create

struct rte_mempool_cache * rte_mempool_cache_create (uint32_t size, int socket_id)

Create a user-owned mempool cache. πŸ‘‘ your cache, your rules.

This can be used by unregistered non-EAL threads to enable caching when they interact with a mempool. so the threads that didn't get an invite to the EAL party can still have a cache, iconic

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. no cap, same rules.
  • 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.

rte_mempool_cache_free

void rte_mempool_cache_free (struct rte_mempool_cache * cache)

Free a user-owned mempool cache. bye bestie 🫢

Parameters

  • cache β€” A pointer to the mempool cache.

rte_mempool_default_cache

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

Get a pointer to the per-lcore default mempool cache. the default one, the main character of caches ✨

Parameters

  • mp β€” A pointer to the mempool structure.
  • lcore_id β€” The logical core id.

Returns

A pointer to the mempool cache or NULL if disabled or unregistered non-EAL thread. you might literally get nothing back, and that's on purpose πŸ’€

Definition at line 1333 of file rte_mempool.h.


rte_mempool_cache_flush

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

Flush a user-owned mempool cache to the specified mempool. emptying the bag back into the pool, self-care πŸ’…

Parameters

  • cache β€” A pointer to the mempool cache.
  • mp β€” A pointer to the mempool.

Definition at line 1355 of file rte_mempool.h.


rte_mempool_generic_put

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

Put several objects back in the mempool. returning them, giving them back to the pool, we love a returning queen 🌈

Parameters

  • mp β€” A pointer to the mempool structure.
  • obj_table β€” A pointer to a table of void * pointers (objects).
  • n β€” The number of objects to add in the mempool from the obj_table.
  • cache β€” A pointer to a mempool cache structure. May be NULL if not needed.

Definition at line 1445 of file rte_mempool.h.


rte_mempool_put_bulk

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

Put several objects back in the mempool. ✨ bulk edition ✨

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). she picks her fighter based on the flags you set, iykyk

Parameters

  • mp β€” A pointer to the mempool structure.
  • obj_table β€” A pointer to a table of void * pointers (objects).
  • n β€” The number of objects to add in the mempool from obj_table.

Definition at line 1468 of file rte_mempool.h.


rte_mempool_put

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

Put one object back in the mempool. just the one, she's lowkey

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

  • mp β€” A pointer to the mempool structure.
  • obj β€” A pointer to the object to be added.

Definition at line 1490 of file rte_mempool.h.


rte_mempool_generic_get

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

Get several objects from the mempool. shopping spree time πŸ›οΈ

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 dramatic β€” srsly check that, because someone else's cache being full does NOT mean you get anything 😭

Parameters

  • mp β€” A pointer to the mempool structure.
  • obj_table β€” A pointer to a table of void * pointers (objects) that will be filled.
  • n β€” The number of objects to get from mempool to obj_table.
  • cache β€” A pointer to a mempool cache structure. May be NULL if not needed.

Returns

  • 0: Success; objects taken.
  • -ENOENT: Not enough entries in the mempool; no object is retrieved.

Definition at line 1632 of file rte_mempool.h.


rte_mempool_get_bulk

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

Get several objects from the mempool. πŸ’– the group order πŸ’–

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. same caveat bestie, other lcores' caches full β‰  your cache full

Parameters

  • mp β€” A pointer to the mempool structure.
  • obj_table β€” A pointer to a table of void * pointers (objects) that will be filled.
  • n β€” The number of objects to get from the mempool to obj_table.

Returns

  • 0: Success; objects taken
  • -ENOENT: Not enough entries in the mempool; no object is retrieved.

Definition at line 1666 of file rte_mempool.h.


rte_mempool_get

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

Get one object from the mempool. single-item order, no notes πŸ’…

This function calls the multi-consumers or the single-consumer version, depending on the default behavior 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

  • mp β€” A pointer to the mempool structure.
  • obj_p β€” A pointer to a void * pointer (object) that will be filled.

Returns

  • 0: Success; objects taken.
  • -ENOENT: Not enough entries in the mempool; no object is retrieved.

Definition at line 1695 of file rte_mempool.h.


rte_mempool_get_contig_blocks

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

Get a contiguous blocks of objects from the mempool. blocks, plural, adjacent, the whole squad sitting together πŸ¦‹

If cache is enabled, consider to flush it first, to reuse objects as soon as possible. lowkey a glow-up tip: flush that cache, recycle faster

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. vibe check the driver FIRST or you're gonna have a bad time πŸ™ˆ

Parameters

  • mp β€” A pointer to the mempool structure.
  • first_obj_table β€” A pointer to a pointer to the first object in each block.
  • n β€” The number of blocks to get from mempool.

Returns

  • 0: Success; blocks taken.
  • -ENOBUFS: Not enough entries in the mempool; no object is retrieved.
  • -EOPNOTSUPP: The mempool driver does not support block dequeue

Definition at line 1722 of file rte_mempool.h.


rte_mempool_avail_count

unsigned int rte_mempool_avail_count (const struct rte_mempool * mp)

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. translating: it's slow, it's for debugging, and user-owned caches are literally not counted. do NOT put this in your data path fr fr

Parameters

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

Returns

The number of entries in the mempool.


rte_mempool_in_use_count

unsigned int rte_mempool_in_use_count (const struct rte_mempool * mp)

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. same warning, bestie β€” debug only, not data path ⭐

Parameters

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

Returns

The number of free entries in the mempool.


rte_mempool_full

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

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

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

Returns

  • 1: The mempool is full.
  • 0: The mempool is not full.

Definition at line 1785 of file rte_mempool.h.


rte_mempool_empty

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

Test if the mempool is empty. the sad little zero-entries moment 😭

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

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

Returns

  • 1: The mempool is empty.
  • 0: The mempool is not empty.

Definition at line 1804 of file rte_mempool.h.


rte_mempool_virt2iova

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

Return the IO address of elt, which is an element of the pool mp. virtual address in, IO address out, a whole transformation arc ✨

Parameters

  • elt β€” A pointer (virtual address) to the element of the pool.

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, don't come crying when you get RTE_BAD_IOVA β€” it's giving on purpose πŸ’€

Definition at line 1820 of file rte_mempool.h.


rte_mempool_audit

void rte_mempool_audit (struct rte_mempool * mp)

Check the consistency of mempool objects. the vibe check function

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. yes, an actual panic. like, the dramatic kind. no cap, it will go off 🚨

Parameters

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

rte_mempool_get_priv

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

Return a pointer to the private data in an mempool structure. the private stash, the secret pocket 🫢

Parameters

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

Returns

A pointer to the private data.

Definition at line 1848 of file rte_mempool.h.


rte_mempool_list_dump

void rte_mempool_list_dump (FILE * f)

Dump the status of all mempools on the console. ALL of them. every single pool. the full group chat screenshot 🧾

Parameters

  • f β€” A pointer to a file for output

rte_mempool_lookup

struct rte_mempool * rte_mempool_lookup (const char * name)

Search a mempool from its name. πŸ” find your girl by name

Parameters

  • name β€” The name of the mempool.

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)

Get the header, trailer and total size of a mempool element. the full fit check: header, trailer, and the whole lewk πŸ“

πŸ’… the size calculator (carried over from part 4)

okay so picture this: you hand it a size you want for a mempool element plus the flags you're building the pool with, and it goes off and calculates the header, trailer, body and total sizes of the mempool object for you. it's giving personal shopper for structs ✨

Parameters

  • elt_size β€” the size of each element, without the header and trailer. just the raw you-sized bit 🫢
  • flags β€” the flags used for mempool creation. the manpage literally says consult rte_mempool_create() for more info on the possible values, so go look there bestie, it's all documented πŸ‘€
  • sz β€” the calculated detailed size of the mempool object. and yes, this one may be NULL πŸ’€

Returns

Total size of the mempool object. that's the number you came for πŸ’–


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

Walk list of all memory pools. that's it, that's the whole vibe β€” you're strolling through every pool in the house like it's a house tour πŸšΆβ€β™€οΈπŸŽ€

Parameters

  • func β€” the iterator function. it gets called on each pool, struct rte_mempool * style, plus whatever arg you're dragging along.
  • arg β€” the argument passed to the iterator. your little plus-one 🫢

__rte_experimental int rte_mempool_get_mem_range (const struct rte_mempool * mp, struct rte_mempool_mem_range_info * mem_range)

⚠️ Warning: EXPERIMENTAL: this API may change without prior notice. no cap. it might glow up into something completely different tomorrow, so don't get too attached πŸ’€

Get information about the memory range used to store objects in the mempool. basically: where does this pool actually live in memory, and how much room does it take? πŸ“

Parameters

  • mp β€” pointer to an initialized mempool. initialized, bestie, don't come at it with a half-built one πŸ™ˆ
  • mem_range β€” pointer to a struct which is used to return the lowest address, the length of the memory range containing all the addresses, and whether these addresses are contiguous. three-for-one info package, iconic ✨

Returns

0 on success, -EINVAL if the mempool is not valid or mem_range is NULL. so if you get -EINVAL back, check your pointers before you check your life choices 😭


__rte_experimental size_t rte_mempool_get_obj_alignment (const struct rte_mempool * mp)

⚠️ Warning: EXPERIMENTAL: this API may change without prior notice. same drill, it's experimental, it's young, it's figuring itself out πŸ¦‹

Return the alignment of objects stored in the mempool. the size_t of it all πŸ’œ

Parameters

  • mp β€” pointer to a mempool.

Returns

Object alignment if mp is valid. 0 if mp is NULL. so a 0 back = you passed NULL, that's the whole story 🌸


🌈 VARIABLE DOCUMENTATION

struct rte_mempool_ops_table rte_mempool_ops_table [extern]

Array of registered ops structs. it's extern, it's a table, it's the ops registry and honestly it's lowkey the backbone of the whole operation πŸ‘‘


πŸŽ€ AUTHOR

Generated automatically by Doxygen for DPDK from the source code. so nobody hand-wrote this, the robots did it, and honestly? they ate πŸ€–βœ¨


and that's a wrap on rte_mempool.h(3) bestie!! πŸŽ‰ this came to you courtesy of DPDK Version 26.03.0 and it's the rte_mempool.h(3) page, straight from the source code by way of Doxygen. go build something iconic with your pools, mwah πŸ’…πŸ’–πŸŽ€
πŸ“¦ where this page comes from