DPDK
24.11.0-rc3
|
#include <stddef.h>
#include <stdalign.h>
#include <rte_common.h>
#include <rte_config.h>
#include <rte_lcore.h>
Go to the source code of this file.
Macros | |
#define | RTE_LCORE_VAR_HANDLE_TYPE(type) type * |
#define | RTE_LCORE_VAR_HANDLE(type, name) RTE_LCORE_VAR_HANDLE_TYPE(type) name |
#define | RTE_LCORE_VAR_ALLOC_SIZE_ALIGN(handle, size, align) handle = rte_lcore_var_alloc(size, align) |
#define | RTE_LCORE_VAR_ALLOC_SIZE(handle, size) RTE_LCORE_VAR_ALLOC_SIZE_ALIGN(handle, size, 0) |
#define | RTE_LCORE_VAR_ALLOC(handle) |
#define | RTE_LCORE_VAR_INIT_SIZE_ALIGN(name, size, align) |
#define | RTE_LCORE_VAR_INIT_SIZE(name, size) RTE_LCORE_VAR_INIT_SIZE_ALIGN(name, size, 0) |
#define | RTE_LCORE_VAR_INIT(name) |
#define | RTE_LCORE_VAR_LCORE(lcore_id, handle) ((typeof(handle))rte_lcore_var_lcore(lcore_id, handle)) |
#define | RTE_LCORE_VAR(handle) RTE_LCORE_VAR_LCORE(rte_lcore_id(), 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_size(1) __rte_alloc_align(2) |
Lcore variables
This API provides a mechanism to create and access per-lcore id variables in a space- and cycle-efficient manner.
Please refer to the lcore variables' programmer's guide for an overview of this API and its implementation.
EXPERIMENTAL: this API may change, or be removed, without prior notice.
Definition in file rte_lcore_var.h.
#define RTE_LCORE_VAR_HANDLE_TYPE | ( | type | ) | type * |
Given the lcore variable type, produces the type of the lcore variable handle.
Definition at line 36 of file rte_lcore_var.h.
#define RTE_LCORE_VAR_HANDLE | ( | type, | |
name | |||
) | RTE_LCORE_VAR_HANDLE_TYPE(type) name |
Define an lcore variable handle.
This macro defines a variable which is used as a handle to access the various instances of a per-lcore id variable.
This macro clarifies that the declaration is an lcore handle, not a regular pointer.
Add static as a prefix in case the lcore variable is only to be accessed from a particular translation unit.
Definition at line 51 of file rte_lcore_var.h.
#define RTE_LCORE_VAR_ALLOC_SIZE_ALIGN | ( | handle, | |
size, | |||
align | |||
) | 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.
Definition at line 59 of file rte_lcore_var.h.
#define RTE_LCORE_VAR_ALLOC_SIZE | ( | handle, | |
size | |||
) | 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 68 of file rte_lcore_var.h.
#define RTE_LCORE_VAR_ALLOC | ( | handle | ) |
Allocate space for an lcore variable of the size and alignment requirements suggested by the handle pointer type, and initialize its handle.
The values of the lcore variable are initialized to zero.
Definition at line 77 of file rte_lcore_var.h.
#define RTE_LCORE_VAR_INIT_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 87 of file rte_lcore_var.h.
#define RTE_LCORE_VAR_INIT_SIZE | ( | name, | |
size | |||
) | 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 99 of file rte_lcore_var.h.
#define RTE_LCORE_VAR_INIT | ( | 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 107 of file rte_lcore_var.h.
#define RTE_LCORE_VAR_LCORE | ( | lcore_id, | |
handle | |||
) | ((typeof(handle))rte_lcore_var_lcore(lcore_id, handle)) |
Get pointer to lcore variable instance with the specified lcore id.
lcore_id | The lcore id specifying which of the RTE_MAX_LCORE value instances should be accessed. The lcore id need not be valid (e.g., may be LCORE_ID_ANY), but in such a case, the pointer is also not valid (and thus should not be dereferenced). |
handle | The lcore variable handle. |
Definition at line 143 of file rte_lcore_var.h.
#define RTE_LCORE_VAR | ( | handle | ) | RTE_LCORE_VAR_LCORE(rte_lcore_id(), handle) |
Get pointer to lcore variable instance of the current thread.
May only be used by EAL threads and registered non-EAL threads.
Definition at line 151 of file rte_lcore_var.h.
#define RTE_LCORE_VAR_FOREACH | ( | lcore_id, | |
value, | |||
handle | |||
) |
Iterate over each lcore id's value for an lcore variable.
lcore_id | An unsigned int variable successively set to the lcore id of every valid lcore id (up to RTE_MAX_LCORE ). |
value | A pointer variable successively set to point to lcore variable value instance of the current lcore id being processed. |
handle | The lcore variable handle. |
Definition at line 166 of file rte_lcore_var.h.
|
inlinestatic |
Get void pointer to lcore variable instance with the specified lcore id.
lcore_id | The lcore id specifying which of the RTE_MAX_LCORE value instances should be accessed. The lcore id need not be valid (e.g., may be LCORE_ID_ANY), but in such a case, the pointer is also not valid (and thus should not be dereferenced). |
handle | The lcore variable handle. |
Definition at line 126 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.
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.
rte_lcore_var_alloc() is not multi-thread safe.
The allocated memory cannot be freed.
size | The size (in bytes) of the variable's per-lcore id value. Must be > 0. |
align | If 0, 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 of align, which must be a power of 2 and equal or less than RTE_CACHE_LINE_SIZE . |