DPDK  20.11.1
rte_lcore.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2010-2014 Intel Corporation
3  */
4 
5 #ifndef _RTE_LCORE_H_
6 #define _RTE_LCORE_H_
7 
14 #include <rte_config.h>
15 #include <rte_per_lcore.h>
16 #include <rte_eal.h>
17 #include <rte_launch.h>
18 
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22 
23 #define LCORE_ID_ANY UINT32_MAX
25 RTE_DECLARE_PER_LCORE(unsigned, _lcore_id);
31  ROLE_RTE,
32  ROLE_OFF,
33  ROLE_SERVICE,
34  ROLE_NON_EAL,
35 };
36 
45 enum rte_lcore_role_t rte_eal_lcore_role(unsigned int lcore_id);
46 
58 int
59 rte_lcore_has_role(unsigned int lcore_id, enum rte_lcore_role_t role);
60 
74 static inline unsigned
76 {
77  return RTE_PER_LCORE(_lcore_id);
78 }
79 
86 unsigned int rte_get_main_lcore(void);
87 
94 __rte_deprecated
95 static inline unsigned int rte_get_master_lcore(void)
96 {
97  return rte_get_main_lcore();
98 }
99 
106 unsigned int rte_lcore_count(void);
107 
122 int rte_lcore_index(int lcore_id);
123 
130 unsigned int rte_socket_id(void);
131 
142 unsigned int
144 
159 int
160 rte_socket_id_by_idx(unsigned int idx);
161 
170 unsigned int
171 rte_lcore_to_socket_id(unsigned int lcore_id);
172 
184 __rte_experimental
185 int
186 rte_lcore_to_cpu_id(int lcore_id);
187 
198 __rte_experimental
199 rte_cpuset_t
200 rte_lcore_cpuset(unsigned int lcore_id);
201 
211 int rte_lcore_is_enabled(unsigned int lcore_id);
212 
226 unsigned int rte_get_next_lcore(unsigned int i, int skip_main, int wrap);
227 
231 #define RTE_LCORE_FOREACH(i) \
232  for (i = rte_get_next_lcore(-1, 0, 0); \
233  i < RTE_MAX_LCORE; \
234  i = rte_get_next_lcore(i, 0, 0))
235 
239 #define RTE_LCORE_FOREACH_WORKER(i) \
240  for (i = rte_get_next_lcore(-1, 1, 0); \
241  i < RTE_MAX_LCORE; \
242  i = rte_get_next_lcore(i, 1, 0))
243 
244 #define RTE_LCORE_FOREACH_SLAVE(l) \
245  RTE_DEPRECATED(RTE_LCORE_FOREACH_SLAVE) RTE_LCORE_FOREACH_WORKER(l)
246 
258 typedef int (*rte_lcore_init_cb)(unsigned int lcore_id, void *arg);
259 
268 typedef void (*rte_lcore_uninit_cb)(unsigned int lcore_id, void *arg);
269 
298 __rte_experimental
299 void *
301  rte_lcore_uninit_cb uninit, void *arg);
302 
313 __rte_experimental
314 void
316 
328 typedef int (*rte_lcore_iterate_cb)(unsigned int lcore_id, void *arg);
329 
346 __rte_experimental
347 int
349 
356 __rte_experimental
357 void
358 rte_lcore_dump(FILE *f);
359 
369 int rte_thread_set_affinity(rte_cpuset_t *cpusetp);
370 
379 void rte_thread_get_affinity(rte_cpuset_t *cpusetp);
380 
393 int rte_thread_setname(pthread_t id, const char *name);
394 
409 __rte_experimental
410 int rte_thread_getname(pthread_t id, char *name, size_t len);
411 
425 __rte_experimental
426 int
428 
432 __rte_experimental
433 void
435 
458 int
459 rte_ctrl_thread_create(pthread_t *thread, const char *name,
460  const pthread_attr_t *attr,
461  void *(*start_routine)(void *), void *arg);
462 
463 #ifdef __cplusplus
464 }
465 #endif
466 
467 
468 #endif /* _RTE_LCORE_H_ */
unsigned int rte_lcore_to_socket_id(unsigned int lcore_id)
RTE_DECLARE_PER_LCORE(unsigned, _lcore_id)
unsigned int rte_lcore_count(void)
void rte_thread_get_affinity(rte_cpuset_t *cpusetp)
void(* rte_lcore_uninit_cb)(unsigned int lcore_id, void *arg)
Definition: rte_lcore.h:268
int rte_lcore_index(int lcore_id)
rte_lcore_role_t
Definition: rte_lcore.h:30
__rte_experimental void rte_thread_unregister(void)
int rte_lcore_has_role(unsigned int lcore_id, enum rte_lcore_role_t role)
int rte_lcore_is_enabled(unsigned int lcore_id)
unsigned int rte_get_main_lcore(void)
__rte_experimental void * rte_lcore_callback_register(const char *name, rte_lcore_init_cb init, rte_lcore_uninit_cb uninit, void *arg)
__rte_experimental void rte_lcore_dump(FILE *f)
int rte_socket_id_by_idx(unsigned int idx)
__rte_experimental rte_cpuset_t rte_lcore_cpuset(unsigned int lcore_id)
unsigned int rte_socket_id(void)
enum rte_lcore_role_t rte_eal_lcore_role(unsigned int lcore_id)
static __rte_deprecated unsigned int rte_get_master_lcore(void)
Definition: rte_lcore.h:95
int rte_ctrl_thread_create(pthread_t *thread, const char *name, const pthread_attr_t *attr, void *(*start_routine)(void *), void *arg)
__rte_experimental int rte_thread_register(void)
__rte_experimental int rte_lcore_to_cpu_id(int lcore_id)
int(* rte_lcore_iterate_cb)(unsigned int lcore_id, void *arg)
Definition: rte_lcore.h:328
__rte_experimental void rte_lcore_callback_unregister(void *handle)
__rte_experimental int rte_thread_getname(pthread_t id, char *name, size_t len)
int(* rte_lcore_init_cb)(unsigned int lcore_id, void *arg)
Definition: rte_lcore.h:258
unsigned int rte_get_next_lcore(unsigned int i, int skip_main, int wrap)
int rte_thread_setname(pthread_t id, const char *name)
int rte_thread_set_affinity(rte_cpuset_t *cpusetp)
unsigned int rte_socket_count(void)
static unsigned rte_lcore_id(void)
Definition: rte_lcore.h:75
__rte_experimental int rte_lcore_iterate(rte_lcore_iterate_cb cb, void *arg)
#define RTE_PER_LCORE(name)
Definition: rte_per_lcore.h:44