DPDK 24.11.0-rc2
Loading...
Searching...
No Matches
rte_lcore_var.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2024 Ericsson AB
3 */
4
5#ifndef RTE_LCORE_VAR_H
6#define RTE_LCORE_VAR_H
7
20#include <stddef.h>
21#include <stdalign.h>
22
23#include <rte_common.h>
24#include <rte_config.h>
25#include <rte_lcore.h>
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
34#define RTE_LCORE_VAR_HANDLE_TYPE(type) \
35 type *
36
49#define RTE_LCORE_VAR_HANDLE(type, name) \
50 RTE_LCORE_VAR_HANDLE_TYPE(type) name
51
57#define RTE_LCORE_VAR_ALLOC_SIZE_ALIGN(handle, size, align) \
58 handle = rte_lcore_var_alloc(size, align)
59
66#define RTE_LCORE_VAR_ALLOC_SIZE(handle, size) \
67 RTE_LCORE_VAR_ALLOC_SIZE_ALIGN(handle, size, 0)
68
75#define RTE_LCORE_VAR_ALLOC(handle) \
76 RTE_LCORE_VAR_ALLOC_SIZE_ALIGN(handle, sizeof(*(handle)), \
77 alignof(typeof(*(handle))))
78
85#define RTE_LCORE_VAR_INIT_SIZE_ALIGN(name, size, align) \
86 RTE_INIT(rte_lcore_var_init_ ## name) \
87 { \
88 RTE_LCORE_VAR_ALLOC_SIZE_ALIGN(name, size, align); \
89 }
90
97#define RTE_LCORE_VAR_INIT_SIZE(name, size) \
98 RTE_LCORE_VAR_INIT_SIZE_ALIGN(name, size, 0)
99
105#define RTE_LCORE_VAR_INIT(name) \
106 RTE_INIT(rte_lcore_var_init_ ## name) \
107 { \
108 RTE_LCORE_VAR_ALLOC(name); \
109 }
110
122/* access function 8< */
123static inline void *
124rte_lcore_var_lcore(unsigned int lcore_id, void *handle)
125{
126 return RTE_PTR_ADD(handle, lcore_id * RTE_MAX_LCORE_VAR);
127}
128/* >8 end of access function */
129
141#define RTE_LCORE_VAR_LCORE(lcore_id, handle) \
142 ((typeof(handle))rte_lcore_var_lcore(lcore_id, handle))
143
149#define RTE_LCORE_VAR(handle) \
150 RTE_LCORE_VAR_LCORE(rte_lcore_id(), handle)
151
164#define RTE_LCORE_VAR_FOREACH(lcore_id, value, handle) \
165 for ((lcore_id) = \
166 (((value) = RTE_LCORE_VAR_LCORE(0, handle)), 0); \
167 (lcore_id) < RTE_MAX_LCORE; \
168 (lcore_id)++, (value) = RTE_LCORE_VAR_LCORE(lcore_id, \
169 handle))
170
198__rte_experimental
199void *
200rte_lcore_var_alloc(size_t size, size_t align)
202
203#ifdef __cplusplus
204}
205#endif
206
207#endif /* RTE_LCORE_VAR_H */
#define __rte_alloc_align(argno)
Definition rte_common.h:241
#define __rte_alloc_size(...)
Definition rte_common.h:228
#define RTE_PTR_ADD(ptr, x)
Definition rte_common.h:469
__rte_experimental void * rte_lcore_var_alloc(size_t size, size_t align) __rte_alloc_size(1) __rte_alloc_align(2)
static void * rte_lcore_var_lcore(unsigned int lcore_id, void *handle)