DPDK  21.11.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 #include <rte_thread.h>
19 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
24 #define LCORE_ID_ANY UINT32_MAX
26 RTE_DECLARE_PER_LCORE(unsigned, _lcore_id);
31 enum rte_lcore_role_t {
32  ROLE_RTE,
33  ROLE_OFF,
34  ROLE_SERVICE,
35  ROLE_NON_EAL,
36 };
37 
46 enum rte_lcore_role_t rte_eal_lcore_role(unsigned int lcore_id);
47 
59 int
60 rte_lcore_has_role(unsigned int lcore_id, enum rte_lcore_role_t role);
61 
75 static inline unsigned
77 {
78  return RTE_PER_LCORE(_lcore_id);
79 }
80 
87 unsigned int rte_get_main_lcore(void);
88 
95 unsigned int rte_lcore_count(void);
96 
111 int rte_lcore_index(int lcore_id);
112 
119 unsigned int rte_socket_id(void);
120 
131 unsigned int
132 rte_socket_count(void);
133 
148 int
149 rte_socket_id_by_idx(unsigned int idx);
150 
159 unsigned int
160 rte_lcore_to_socket_id(unsigned int lcore_id);
161 
173 __rte_experimental
174 int
175 rte_lcore_to_cpu_id(int lcore_id);
176 
177 #ifdef RTE_HAS_CPUSET
178 
189 __rte_experimental
190 rte_cpuset_t
191 rte_lcore_cpuset(unsigned int lcore_id);
192 
193 #endif /* RTE_HAS_CPUSET */
194 
204 int rte_lcore_is_enabled(unsigned int lcore_id);
205 
219 unsigned int rte_get_next_lcore(unsigned int i, int skip_main, int wrap);
220 
224 #define RTE_LCORE_FOREACH(i) \
225  for (i = rte_get_next_lcore(-1, 0, 0); \
226  i < RTE_MAX_LCORE; \
227  i = rte_get_next_lcore(i, 0, 0))
228 
232 #define RTE_LCORE_FOREACH_WORKER(i) \
233  for (i = rte_get_next_lcore(-1, 1, 0); \
234  i < RTE_MAX_LCORE; \
235  i = rte_get_next_lcore(i, 1, 0))
236 
248 typedef int (*rte_lcore_init_cb)(unsigned int lcore_id, void *arg);
249 
258 typedef void (*rte_lcore_uninit_cb)(unsigned int lcore_id, void *arg);
259 
288 void *
289 rte_lcore_callback_register(const char *name, rte_lcore_init_cb init,
290  rte_lcore_uninit_cb uninit, void *arg);
291 
302 void
303 rte_lcore_callback_unregister(void *handle);
304 
316 typedef int (*rte_lcore_iterate_cb)(unsigned int lcore_id, void *arg);
317 
334 int
336 
343 void
344 rte_lcore_dump(FILE *f);
345 
358 int rte_thread_setname(pthread_t id, const char *name);
359 
374 __rte_experimental
375 int rte_thread_getname(pthread_t id, char *name, size_t len);
376 
390 int
391 rte_thread_register(void);
392 
396 void
398 
422 int
423 rte_ctrl_thread_create(pthread_t *thread, const char *name,
424  const pthread_attr_t *attr,
425  void *(*start_routine)(void *), void *arg);
426 
427 #ifdef __cplusplus
428 }
429 #endif
430 
431 
432 #endif /* _RTE_LCORE_H_ */
rte_lcore_role_t
Definition: rte_lcore.h:31
void(* rte_lcore_uninit_cb)(unsigned int lcore_id, void *arg)
Definition: rte_lcore.h:258
unsigned int rte_get_main_lcore(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)
unsigned int rte_socket_count(void)
void rte_lcore_callback_unregister(void *handle)
void rte_thread_unregister(void)
int(* rte_lcore_init_cb)(unsigned int lcore_id, void *arg)
Definition: rte_lcore.h:248
unsigned int rte_get_next_lcore(unsigned int i, int skip_main, int wrap)
unsigned int rte_lcore_to_socket_id(unsigned int lcore_id)
int rte_lcore_iterate(rte_lcore_iterate_cb cb, void *arg)
int(* rte_lcore_iterate_cb)(unsigned int lcore_id, void *arg)
Definition: rte_lcore.h:316
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:76
int rte_socket_id_by_idx(unsigned int idx)
__rte_experimental int rte_lcore_to_cpu_id(int lcore_id)
void * rte_lcore_callback_register(const char *name, rte_lcore_init_cb init, rte_lcore_uninit_cb uninit, void *arg)
int rte_thread_register(void)
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)
void rte_lcore_dump(FILE *f)
int rte_lcore_is_enabled(unsigned int lcore_id)
#define RTE_PER_LCORE(name)
Definition: rte_per_lcore.h:44
enum rte_lcore_role_t rte_eal_lcore_role(unsigned int lcore_id)
__rte_experimental int rte_thread_getname(pthread_t id, char *name, size_t len)