DPDK  25.11.3
rte_thread.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2021 Mellanox Technologies, Ltd
3  * Copyright (C) 2022 Microsoft Corporation
4  */
5 
6 #include <pthread.h>
7 #include <stdint.h>
8 
9 #include <rte_os.h>
10 #include <rte_compat.h>
11 
12 #ifndef _RTE_THREAD_H_
13 #define _RTE_THREAD_H_
14 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
28 #define RTE_THREAD_NAME_SIZE 16
29 /* Old definition, aliased for compatibility. */
30 #define RTE_MAX_THREAD_NAME_LEN RTE_THREAD_NAME_SIZE
31 
33 #define RTE_THREAD_INTERNAL_PREFIX "dpdk-"
34 
35 #define RTE_THREAD_INTERNAL_NAME_SIZE 11
36 
40 typedef struct {
41  uintptr_t opaque_id;
42 } rte_thread_t;
43 
54 typedef uint32_t (*rte_thread_func) (void *arg);
55 
64 };
65 
69 typedef struct {
70  enum rte_thread_priority priority;
71 #ifdef RTE_HAS_CPUSET
72  rte_cpuset_t cpuset;
73 #endif
75 
79 typedef struct eal_tls_key *rte_thread_key;
80 
100 int rte_thread_create(rte_thread_t *thread_id,
101  const rte_thread_attr_t *thread_attr,
102  rte_thread_func thread_func, void *arg);
103 
126 int
127 rte_thread_create_control(rte_thread_t *thread, const char *name,
128  rte_thread_func thread_func, void *arg);
129 
154 __rte_internal
155 int
157  rte_thread_func func, void *arg);
158 
172 int rte_thread_join(rte_thread_t thread_id, uint32_t *value_ptr);
173 
185 int rte_thread_detach(rte_thread_t thread_id);
186 
194 
209 void
210 rte_thread_set_name(rte_thread_t thread_id, const char *thread_name);
211 
228 __rte_internal
229 void
230 rte_thread_set_prefixed_name(rte_thread_t id, const char *name);
231 
246 
260 
276  enum rte_thread_priority priority);
277 
278 #ifdef RTE_HAS_CPUSET
279 
295  rte_cpuset_t *cpuset);
296 
312  rte_cpuset_t *cpuset);
313 
329  const rte_cpuset_t *cpuset);
330 
346  rte_cpuset_t *cpuset);
347 
357 int rte_thread_set_affinity(rte_cpuset_t *cpusetp);
358 
366 void rte_thread_get_affinity(rte_cpuset_t *cpusetp);
367 
368 #endif /* RTE_HAS_CPUSET */
369 
384  enum rte_thread_priority *priority);
385 
400  enum rte_thread_priority priority);
401 
421  void (*destructor)(void *));
422 
436 
451 int rte_thread_value_set(rte_thread_key key, const void *value);
452 
466 
478 __rte_internal
479 void rte_thread_mutex_init_shared(pthread_mutex_t *mutex);
480 
481 #ifdef __cplusplus
482 }
483 #endif
484 
485 #endif /* _RTE_THREAD_H_ */
void rte_thread_set_name(rte_thread_t thread_id, const char *thread_name)
void * rte_thread_value_get(rte_thread_key key)
int rte_thread_value_set(rte_thread_key key, const void *value)
int rte_thread_equal(rte_thread_t t1, rte_thread_t t2)
__rte_internal int rte_thread_create_internal_control(rte_thread_t *id, const char *name, rte_thread_func func, void *arg)
int rte_thread_attr_set_priority(rte_thread_attr_t *thread_attr, enum rte_thread_priority priority)
int rte_thread_join(rte_thread_t thread_id, uint32_t *value_ptr)
int rte_thread_attr_set_affinity(rte_thread_attr_t *thread_attr, rte_cpuset_t *cpuset)
int rte_thread_set_priority(rte_thread_t thread_id, enum rte_thread_priority priority)
__rte_internal void rte_thread_set_prefixed_name(rte_thread_t id, const char *name)
int rte_thread_create(rte_thread_t *thread_id, const rte_thread_attr_t *thread_attr, rte_thread_func thread_func, void *arg)
int rte_thread_attr_get_affinity(rte_thread_attr_t *thread_attr, rte_cpuset_t *cpuset)
struct eal_tls_key * rte_thread_key
Definition: rte_thread.h:79
rte_thread_priority
Definition: rte_thread.h:59
rte_cpuset_t cpuset
Definition: rte_thread.h:72
int rte_thread_attr_init(rte_thread_attr_t *attr)
uintptr_t opaque_id
Definition: rte_thread.h:41
int rte_thread_set_affinity(rte_cpuset_t *cpusetp)
int rte_thread_get_priority(rte_thread_t thread_id, enum rte_thread_priority *priority)
int rte_thread_detach(rte_thread_t thread_id)
void rte_thread_get_affinity(rte_cpuset_t *cpusetp)
rte_thread_t rte_thread_self(void)
int rte_thread_key_delete(rte_thread_key key)
int rte_thread_create_control(rte_thread_t *thread, const char *name, rte_thread_func thread_func, void *arg)
uint32_t(* rte_thread_func)(void *arg)
Definition: rte_thread.h:54
int rte_thread_key_create(rte_thread_key *key, void(*destructor)(void *))
int rte_thread_set_affinity_by_id(rte_thread_t thread_id, const rte_cpuset_t *cpuset)
int rte_thread_get_affinity_by_id(rte_thread_t thread_id, rte_cpuset_t *cpuset)
__rte_internal void rte_thread_mutex_init_shared(pthread_mutex_t *mutex)