DPDK  20.08.0
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);
30 enum rte_lcore_role_t {
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_master_lcore(void);
87 
94 unsigned int rte_lcore_count(void);
95 
110 int rte_lcore_index(int lcore_id);
111 
118 unsigned int rte_socket_id(void);
119 
130 unsigned int
131 rte_socket_count(void);
132 
147 int
148 rte_socket_id_by_idx(unsigned int idx);
149 
158 unsigned int
159 rte_lcore_to_socket_id(unsigned int lcore_id);
160 
172 __rte_experimental
173 int
174 rte_lcore_to_cpu_id(int lcore_id);
175 
186 __rte_experimental
187 rte_cpuset_t
188 rte_lcore_cpuset(unsigned int lcore_id);
189 
199 int rte_lcore_is_enabled(unsigned int lcore_id);
200 
214 unsigned int rte_get_next_lcore(unsigned int i, int skip_master, int wrap);
215 
219 #define RTE_LCORE_FOREACH(i) \
220  for (i = rte_get_next_lcore(-1, 0, 0); \
221  i<RTE_MAX_LCORE; \
222  i = rte_get_next_lcore(i, 0, 0))
223 
227 #define RTE_LCORE_FOREACH_SLAVE(i) \
228  for (i = rte_get_next_lcore(-1, 1, 0); \
229  i<RTE_MAX_LCORE; \
230  i = rte_get_next_lcore(i, 1, 0))
231 
243 typedef int (*rte_lcore_init_cb)(unsigned int lcore_id, void *arg);
244 
253 typedef void (*rte_lcore_uninit_cb)(unsigned int lcore_id, void *arg);
254 
283 __rte_experimental
284 void *
285 rte_lcore_callback_register(const char *name, rte_lcore_init_cb init,
286  rte_lcore_uninit_cb uninit, void *arg);
287 
298 __rte_experimental
299 void
300 rte_lcore_callback_unregister(void *handle);
301 
313 typedef int (*rte_lcore_iterate_cb)(unsigned int lcore_id, void *arg);
314 
331 __rte_experimental
332 int
334 
341 __rte_experimental
342 void
343 rte_lcore_dump(FILE *f);
344 
354 int rte_thread_set_affinity(rte_cpuset_t *cpusetp);
355 
364 void rte_thread_get_affinity(rte_cpuset_t *cpusetp);
365 
378 int rte_thread_setname(pthread_t id, const char *name);
379 
394 __rte_experimental
395 int rte_thread_getname(pthread_t id, char *name, size_t len);
396 
410 __rte_experimental
411 int
412 rte_thread_register(void);
413 
417 __rte_experimental
418 void
420 
443 int
444 rte_ctrl_thread_create(pthread_t *thread, const char *name,
445  const pthread_attr_t *attr,
446  void *(*start_routine)(void *), void *arg);
447 
448 #ifdef __cplusplus
449 }
450 #endif
451 
452 
453 #endif /* _RTE_LCORE_H_ */
rte_lcore_role_t
Definition: rte_lcore.h:30
void(* rte_lcore_uninit_cb)(unsigned int lcore_id, void *arg)
Definition: rte_lcore.h:253
void rte_thread_get_affinity(rte_cpuset_t *cpusetp)
__rte_experimental int rte_lcore_iterate(rte_lcore_iterate_cb cb, void *arg)
__rte_experimental void rte_thread_unregister(void)
int rte_thread_setname(pthread_t id, const char *name)
unsigned int rte_lcore_count(void)
int rte_lcore_has_role(unsigned int lcore_id, enum rte_lcore_role_t role)
__rte_experimental void rte_lcore_callback_unregister(void *handle)
unsigned int rte_socket_count(void)
int(* rte_lcore_init_cb)(unsigned int lcore_id, void *arg)
Definition: rte_lcore.h:243
unsigned int rte_lcore_to_socket_id(unsigned int lcore_id)
int(* rte_lcore_iterate_cb)(unsigned int lcore_id, void *arg)
Definition: rte_lcore.h:313
__rte_experimental void * rte_lcore_callback_register(const char *name, rte_lcore_init_cb init, rte_lcore_uninit_cb uninit, void *arg)
unsigned int rte_socket_id(void)
__rte_experimental rte_cpuset_t rte_lcore_cpuset(unsigned int lcore_id)
static unsigned rte_lcore_id(void)
Definition: rte_lcore.h:75
__rte_experimental int rte_thread_register(void)
__rte_experimental void rte_lcore_dump(FILE *f)
int rte_socket_id_by_idx(unsigned int idx)
__rte_experimental int rte_lcore_to_cpu_id(int lcore_id)
int rte_lcore_index(int lcore_id)
int rte_ctrl_thread_create(pthread_t *thread, const char *name, const pthread_attr_t *attr, void *(*start_routine)(void *), void *arg)
int rte_lcore_is_enabled(unsigned int lcore_id)
#define RTE_PER_LCORE(name)
Definition: rte_per_lcore.h:44
unsigned int rte_get_master_lcore(void)
enum rte_lcore_role_t rte_eal_lcore_role(unsigned int lcore_id)
int rte_thread_set_affinity(rte_cpuset_t *cpusetp)
__rte_experimental int rte_thread_getname(pthread_t id, char *name, size_t len)
unsigned int rte_get_next_lcore(unsigned int i, int skip_master, int wrap)