rte_lcore_var.h(3)
π¦ rte_lcore_var.h β the DPDK per-lcore variable situation, explained π
okay bestie, sit down, hydrate, because this one is a library functions manual page from DPDK and it is genuinely useful. it's the header for lcore variables β per-lcore-id variables, done space- and cycle-efficiently. no cap. π«Ά
β¨ NAME β¨
rte_lcore_var.h β that's the header, that's the girl, that's the whole personality.
πΈ SYNOPSIS πΈ
start with the includes, always:
#include <stddef.h>
#include <stdalign.h>
#include <rte_common.h>
#include <rte_config.h>
#include <rte_debug.h>
#include <rte_lcore.h>
π Macros
#define RTE_LCORE_VAR_HANDLE_TYPE(type)
#define RTE_LCORE_VAR_HANDLE(type, name)
#define RTE_LCORE_VAR_ALLOC_SIZE_ALIGN(handle, size, align)
#define RTE_LCORE_VAR_ALLOC_SIZE(handle, size)
#define RTE_LCORE_VAR_ALLOC(handle)
#define RTE_LCORE_VAR_INIT_SIZE_ALIGN(name, size, align)
#define RTE_LCORE_VAR_INIT_SIZE(name, size)
#define RTE_LCORE_VAR_INIT(name)
#define RTE_LCORE_VAR_LCORE(lcore_id, handle)
#define RTE_LCORE_VAR(handle)
#define RTE_LCORE_VAR_FOREACH(lcore_id, value, handle)
π§ Functions
static void * rte_lcore_var_lcore (unsigned int lcore_id, void *handle)
__rte_experimental void * rte_lcore_var_alloc (size_t size, size_t
align) __rte_alloc_align(2)
π Detailed Description
Lcore variables
so this API gives you a whole mechanism to create and access per-lcore id variables β in a way that's space-efficient and cycle-efficient. literally the best of both worlds, we love to see it. π
please go read the lcore variables' programmer's guide for the full overview of this API and how it's implemented β that's where the lore lives, iykyk.
EXPERIMENTAL: this API may change, or be removed, without prior notice. β οΈ so like... don't build your whole personality on it.
Definition in file rte_lcore_var.h.
π Macro Definition Documentation
#define RTE_LCORE_VAR_HANDLE_TYPE( type)
Value:
type *
given the lcore variable type, this produces the type of the lcore variable handle. πͺ
Definition at line 37 of file rte_lcore_var.h.
#define RTE_LCORE_VAR_HANDLE( type, name)
Value:
RTE_LCORE_VAR_HANDLE_TYPE(type) name
define an lcore variable handle. β¨
this macro defines a variable that you use as a handle to access the various instances of a per-lcore id variable.
it also makes it clear that the declaration is an lcore handle, not just some regular pointer. main character clarity.
add static as a prefix if the lcore variable is only meant to be accessed from one particular translation unit. π
Definition at line 52 of file rte_lcore_var.h.
#define RTE_LCORE_VAR_ALLOC_SIZE_ALIGN( handle, size, align)
Value:
handle = rte_lcore_var_alloc(size, align)
allocate space for an lcore variable, and initialize its handle. π οΈ
the values of the lcore variable are initialized to zero. clean slate energy.
Definition at line 60 of file rte_lcore_var.h.
#define RTE_LCORE_VAR_ALLOC_SIZE( handle, size)
Value:
RTE_LCORE_VAR_ALLOC_SIZE_ALIGN(handle, size, 0)
allocate space for an lcore variable, and initialize its handle, with values aligned for any type of object. π
the values of the lcore variable are initialized to zero.
Definition at line 69 of file rte_lcore_var.h.
#define RTE_LCORE_VAR_ALLOC( handle)
Value:
RTE_LCORE_VAR_ALLOC_SIZE_ALIGN(handle, sizeof(*(handle)), \
alignof(typeof(*(handle))))
allocate space for an lcore variable using the size and alignment requirements suggested by the handle pointer type, and initialize its handle. it knows what it needs, she's self-aware. π
the values of the lcore variable are initialized to zero.
Definition at line 78 of file rte_lcore_var.h.
#define RTE_LCORE_VAR_INIT_SIZE_ALIGN( name, size, align)
Value:
RTE_INIT(rte_lcore_var_init_ ## name) \
{ \
RTE_LCORE_VAR_ALLOC_SIZE_ALIGN(name, size, align); \
}
allocate an explicitly-sized, explicitly-aligned lcore variable by means of a RTE_INIT constructor. π
the values of the lcore variable are initialized to zero.
Definition at line 88 of file rte_lcore_var.h.
#define RTE_LCORE_VAR_INIT_SIZE( name, size)
Value:
RTE_LCORE_VAR_INIT_SIZE_ALIGN(name, size, 0)
allocate an explicitly-sized lcore variable by means of a RTE_INIT constructor. β
the values of the lcore variable are initialized to zero.
Definition at line 100 of file rte_lcore_var.h.
#define RTE_LCORE_VAR_INIT( name)
Value:
RTE_INIT(rte_lcore_var_init_ ## name) \
{ \
RTE_LCORE_VAR_ALLOC(name); \
}
allocate an lcore variable by means of a RTE_INIT constructor. πΈ
the values of the lcore variable are initialized to zero.
Definition at line 108 of file rte_lcore_var.h.
#define RTE_LCORE_VAR_LCORE( lcore_id, handle)
Value:
((typeof(handle))rte_lcore_var_lcore(lcore_id, handle))
get a pointer to the lcore variable instance with the specified lcore id. π
Parameters
lcore_idβ the lcore id specifying which of theRTE_MAX_LCOREvalue instances should be accessed. the lcore id need not be valid (e.g., it may beLCORE_ID_ANY), but in that case, the pointer is also not valid β and thus should not be dereferenced. π«handleβ the lcore variable handle.
Definition at line 145 of file rte_lcore_var.h.
#define RTE_LCORE_VAR( handle)
Value:
RTE_LCORE_VAR_LCORE(rte_lcore_id(), handle)
get a pointer to the lcore variable instance of the current thread. π§΅
may only be used by EAL threads and registered non-EAL threads. okay read the room, bestie.
Definition at line 153 of file rte_lcore_var.h.
#define RTE_LCORE_VAR_FOREACH( lcore_id, value, handle)
Value:
for ((lcore_id) = \
(((value) = RTE_LCORE_VAR_LCORE(0, handle)), 0); \
(lcore_id) < RTE_MAX_LCORE; \
(lcore_id)++, (value) = RTE_LCORE_VAR_LCORE(lcore_id, \
handle))
iterate over each lcore id's value for an lcore variable. π the way this macro just loops for you... obsessed.
Parameters
lcore_idβ anunsigned intvariable, successively set to the lcore id of every valid lcore id (up toRTE_MAX_LCORE).valueβ a pointer variable, successively set to point to the lcore variable value instance of the current lcore id being processed.handleβ the lcore variable handle.
Definition at line 168 of file rte_lcore_var.h.
π Function Documentation
void * rte_lcore_var_lcore (unsigned int lcore_id, void * handle) [inline], [static]
get a void pointer to the lcore variable instance with the specified lcore id. π―
Parameters
lcore_idβ the lcore id specifying which of theRTE_MAX_LCOREvalue instances should be accessed. the lcore id need not be valid (e.g., it may beLCORE_ID_ANY), but in that case, the pointer is also not valid β and thus should not be dereferenced. πhandleβ the lcore variable handle.
Definition at line 127 of file rte_lcore_var.h.
__rte_experimental void * rte_lcore_var_alloc (size_t size, size_t align)
allocate space in the per-lcore id buffers for an lcore variable. ποΈ
the pointer returned is only an opaque identifier of the variable. to get an actual pointer to a particular instance of the variable, use RTE_LCORE_VAR or RTE_LCORE_VAR_LCORE. (yes this is giving "the map, not the territory".)
the lcore variable values' memory is set to zero.
the allocation is always successful, barring a fatal exhaustion of the per-lcore id buffer space. slay, but also π
rte_lcore_var_alloc() is not multi-thread safe. be careful out there.
the allocated memory cannot be freed. no take-backs, no eras, periodt.
Parameters
sizeβ the size (in bytes) of the variable's per-lcore id value. must be > 0.alignβ if0, the values will be suitably aligned for any kind of type (i.e.,alignof(max_align_t)). otherwise, the values will be aligned on a multiple ofalign, which must be a power of 2 and equal or less thanRTE_CACHE_LINE_SIZE. β‘
Returns
the variable's handle, stored in a void pointer value. the value is always non-NULL. π
π Author
generated automatically by Doxygen for DPDK from the source code. (not me writing it by hand, the robots did that part π€)
okay that's the whole page, bestie β every macro, every function, every parameter, every line number, all of it. you understood it, you ate it, no crumbs. π
π little sign-off: this one's DPDK, Version 25.11.3 β and remember, it's the manual page for rte_lcore_var.h(3), so if you need it again, it'll be right there. mwah π
π¦ where this page comes from
- ubuntu resolute: dpdk-doc 25.11.3-0ubuntu0.26.04.1 Β· BSD-3-Clause
- ubuntu stonking: dpdk-doc 25.11.3-1 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms