199a2dd95SBruce Richardson /* SPDX-License-Identifier: BSD-3-Clause 299a2dd95SBruce Richardson * Copyright(c) 2021 Mellanox Technologies, Ltd 356539289STyler Retzlaff * Copyright (C) 2022 Microsoft Corporation 499a2dd95SBruce Richardson */ 599a2dd95SBruce Richardson 656539289STyler Retzlaff #include <stdint.h> 756539289STyler Retzlaff 899a2dd95SBruce Richardson #include <rte_os.h> 999a2dd95SBruce Richardson #include <rte_compat.h> 1099a2dd95SBruce Richardson 1199a2dd95SBruce Richardson #ifndef _RTE_THREAD_H_ 1299a2dd95SBruce Richardson #define _RTE_THREAD_H_ 1399a2dd95SBruce Richardson 1499a2dd95SBruce Richardson /** 1599a2dd95SBruce Richardson * @file 1699a2dd95SBruce Richardson * 1799a2dd95SBruce Richardson * Threading functions 1899a2dd95SBruce Richardson * 1999a2dd95SBruce Richardson * Simple threads functionality supplied by EAL. 2099a2dd95SBruce Richardson */ 2199a2dd95SBruce Richardson 2299a2dd95SBruce Richardson #ifdef __cplusplus 2399a2dd95SBruce Richardson extern "C" { 2499a2dd95SBruce Richardson #endif 2599a2dd95SBruce Richardson 2699a2dd95SBruce Richardson /** 2756539289STyler Retzlaff * Thread id descriptor. 2856539289STyler Retzlaff */ 2956539289STyler Retzlaff typedef struct { 3056539289STyler Retzlaff uintptr_t opaque_id; /**< thread identifier */ 3156539289STyler Retzlaff } rte_thread_t; 3256539289STyler Retzlaff 3356539289STyler Retzlaff /** 34ce6e911dSTyler Retzlaff * Thread function 35ce6e911dSTyler Retzlaff * 36ce6e911dSTyler Retzlaff * Function pointer to thread start routine. 37ce6e911dSTyler Retzlaff * 38ce6e911dSTyler Retzlaff * @param arg 39ce6e911dSTyler Retzlaff * Argument passed to rte_thread_create(). 40ce6e911dSTyler Retzlaff * @return 41ce6e911dSTyler Retzlaff * Thread function exit value. 42ce6e911dSTyler Retzlaff */ 43ce6e911dSTyler Retzlaff typedef uint32_t (*rte_thread_func) (void *arg); 44ce6e911dSTyler Retzlaff 45ce6e911dSTyler Retzlaff /** 46ca04c78bSTyler Retzlaff * Thread priority values. 47ca04c78bSTyler Retzlaff */ 48ca04c78bSTyler Retzlaff enum rte_thread_priority { 49ca04c78bSTyler Retzlaff RTE_THREAD_PRIORITY_NORMAL = 0, 50ca04c78bSTyler Retzlaff /**< normal thread priority, the default */ 51ca04c78bSTyler Retzlaff RTE_THREAD_PRIORITY_REALTIME_CRITICAL = 1, 52ca04c78bSTyler Retzlaff /**< highest thread priority allowed */ 53ca04c78bSTyler Retzlaff }; 54ca04c78bSTyler Retzlaff 55ca04c78bSTyler Retzlaff /** 5651e6608aSTyler Retzlaff * Representation for thread attributes. 5751e6608aSTyler Retzlaff */ 5851e6608aSTyler Retzlaff typedef struct { 5951e6608aSTyler Retzlaff enum rte_thread_priority priority; /**< thread priority */ 6051e6608aSTyler Retzlaff #ifdef RTE_HAS_CPUSET 6151e6608aSTyler Retzlaff rte_cpuset_t cpuset; /**< thread affinity */ 6251e6608aSTyler Retzlaff #endif 6351e6608aSTyler Retzlaff } rte_thread_attr_t; 6451e6608aSTyler Retzlaff 6551e6608aSTyler Retzlaff /** 6699a2dd95SBruce Richardson * TLS key type, an opaque pointer. 6799a2dd95SBruce Richardson */ 6899a2dd95SBruce Richardson typedef struct eal_tls_key *rte_thread_key; 6999a2dd95SBruce Richardson 7056539289STyler Retzlaff /** 7156539289STyler Retzlaff * @warning 7256539289STyler Retzlaff * @b EXPERIMENTAL: this API may change without prior notice. 7356539289STyler Retzlaff * 74ce6e911dSTyler Retzlaff * Create a new thread that will invoke the 'thread_func' routine. 75ce6e911dSTyler Retzlaff * 76ce6e911dSTyler Retzlaff * @param thread_id 77ce6e911dSTyler Retzlaff * A pointer that will store the id of the newly created thread. 78ce6e911dSTyler Retzlaff * 79ce6e911dSTyler Retzlaff * @param thread_attr 80ce6e911dSTyler Retzlaff * Attributes that are used at the creation of the new thread. 81ce6e911dSTyler Retzlaff * 82ce6e911dSTyler Retzlaff * @param thread_func 83ce6e911dSTyler Retzlaff * The routine that the new thread will invoke when starting execution. 84ce6e911dSTyler Retzlaff * 85ce6e911dSTyler Retzlaff * @param arg 86ce6e911dSTyler Retzlaff * Argument to be passed to the 'thread_func' routine. 87ce6e911dSTyler Retzlaff * 88ce6e911dSTyler Retzlaff * @return 89ce6e911dSTyler Retzlaff * On success, return 0. 90ce6e911dSTyler Retzlaff * On failure, return a positive errno-style error number. 91ce6e911dSTyler Retzlaff */ 92ce6e911dSTyler Retzlaff __rte_experimental 93ce6e911dSTyler Retzlaff int rte_thread_create(rte_thread_t *thread_id, 94ce6e911dSTyler Retzlaff const rte_thread_attr_t *thread_attr, 95ce6e911dSTyler Retzlaff rte_thread_func thread_func, void *arg); 96ce6e911dSTyler Retzlaff 97ce6e911dSTyler Retzlaff /** 98ce6e911dSTyler Retzlaff * @warning 99ce6e911dSTyler Retzlaff * @b EXPERIMENTAL: this API may change without prior notice. 100ce6e911dSTyler Retzlaff * 101ce6e911dSTyler Retzlaff * Waits for the thread identified by 'thread_id' to terminate 102ce6e911dSTyler Retzlaff * 103ce6e911dSTyler Retzlaff * @param thread_id 104ce6e911dSTyler Retzlaff * The identifier of the thread. 105ce6e911dSTyler Retzlaff * 106ce6e911dSTyler Retzlaff * @param value_ptr 107ce6e911dSTyler Retzlaff * Stores the exit status of the thread. 108ce6e911dSTyler Retzlaff * 109ce6e911dSTyler Retzlaff * @return 110ce6e911dSTyler Retzlaff * On success, return 0. 111ce6e911dSTyler Retzlaff * On failure, return a positive errno-style error number. 112ce6e911dSTyler Retzlaff */ 113ce6e911dSTyler Retzlaff __rte_experimental 114ce6e911dSTyler Retzlaff int rte_thread_join(rte_thread_t thread_id, uint32_t *value_ptr); 115ce6e911dSTyler Retzlaff 116ce6e911dSTyler Retzlaff /** 117ce6e911dSTyler Retzlaff * @warning 118ce6e911dSTyler Retzlaff * @b EXPERIMENTAL: this API may change without prior notice. 119ce6e911dSTyler Retzlaff * 120ce6e911dSTyler Retzlaff * Indicate that the return value of the thread is not needed and 121ce6e911dSTyler Retzlaff * all thread resources should be release when the thread terminates. 122ce6e911dSTyler Retzlaff * 123ce6e911dSTyler Retzlaff * @param thread_id 124ce6e911dSTyler Retzlaff * The id of the thread to be detached. 125ce6e911dSTyler Retzlaff * 126ce6e911dSTyler Retzlaff * @return 127ce6e911dSTyler Retzlaff * On success, return 0. 128ce6e911dSTyler Retzlaff * On failure, return a positive errno-style error number. 129ce6e911dSTyler Retzlaff */ 130ce6e911dSTyler Retzlaff __rte_experimental 131ce6e911dSTyler Retzlaff int rte_thread_detach(rte_thread_t thread_id); 132ce6e911dSTyler Retzlaff 133ce6e911dSTyler Retzlaff /** 134ce6e911dSTyler Retzlaff * @warning 135ce6e911dSTyler Retzlaff * @b EXPERIMENTAL: this API may change without prior notice. 136ce6e911dSTyler Retzlaff * 13756539289STyler Retzlaff * Get the id of the calling thread. 13856539289STyler Retzlaff * 13956539289STyler Retzlaff * @return 14056539289STyler Retzlaff * Return the thread id of the calling thread. 14156539289STyler Retzlaff */ 14256539289STyler Retzlaff __rte_experimental 14356539289STyler Retzlaff rte_thread_t rte_thread_self(void); 14456539289STyler Retzlaff 14551e6608aSTyler Retzlaff /** 14651e6608aSTyler Retzlaff * @warning 14751e6608aSTyler Retzlaff * @b EXPERIMENTAL: this API may change without prior notice. 14851e6608aSTyler Retzlaff * 149*a2e94ca8STyler Retzlaff * Check if 2 thread ids are equal. 150*a2e94ca8STyler Retzlaff * 151*a2e94ca8STyler Retzlaff * @param t1 152*a2e94ca8STyler Retzlaff * First thread id. 153*a2e94ca8STyler Retzlaff * 154*a2e94ca8STyler Retzlaff * @param t2 155*a2e94ca8STyler Retzlaff * Second thread id. 156*a2e94ca8STyler Retzlaff * 157*a2e94ca8STyler Retzlaff * @return 158*a2e94ca8STyler Retzlaff * If the ids are equal, return nonzero. 159*a2e94ca8STyler Retzlaff * Otherwise, return 0. 160*a2e94ca8STyler Retzlaff */ 161*a2e94ca8STyler Retzlaff __rte_experimental 162*a2e94ca8STyler Retzlaff int rte_thread_equal(rte_thread_t t1, rte_thread_t t2); 163*a2e94ca8STyler Retzlaff 164*a2e94ca8STyler Retzlaff /** 165*a2e94ca8STyler Retzlaff * @warning 166*a2e94ca8STyler Retzlaff * @b EXPERIMENTAL: this API may change without prior notice. 167*a2e94ca8STyler Retzlaff * 16851e6608aSTyler Retzlaff * Initialize the attributes of a thread. 16951e6608aSTyler Retzlaff * These attributes can be passed to the rte_thread_create() function 17051e6608aSTyler Retzlaff * that will create a new thread and set its attributes according to attr. 17151e6608aSTyler Retzlaff * 17251e6608aSTyler Retzlaff * @param attr 17351e6608aSTyler Retzlaff * Thread attributes to initialize. 17451e6608aSTyler Retzlaff * 17551e6608aSTyler Retzlaff * @return 17651e6608aSTyler Retzlaff * On success, return 0. 17751e6608aSTyler Retzlaff * On failure, return a positive errno-style error number. 17851e6608aSTyler Retzlaff */ 17951e6608aSTyler Retzlaff __rte_experimental 18051e6608aSTyler Retzlaff int rte_thread_attr_init(rte_thread_attr_t *attr); 18151e6608aSTyler Retzlaff 18251e6608aSTyler Retzlaff /** 18351e6608aSTyler Retzlaff * @warning 18451e6608aSTyler Retzlaff * @b EXPERIMENTAL: this API may change without prior notice. 18551e6608aSTyler Retzlaff * 18651e6608aSTyler Retzlaff * Set the thread priority value in the thread attributes pointed to 18751e6608aSTyler Retzlaff * by 'thread_attr'. 18851e6608aSTyler Retzlaff * 18951e6608aSTyler Retzlaff * @param thread_attr 19051e6608aSTyler Retzlaff * Points to the thread attributes in which priority will be updated. 19151e6608aSTyler Retzlaff * 19251e6608aSTyler Retzlaff * @param priority 19351e6608aSTyler Retzlaff * Points to the value of the priority to be set. 19451e6608aSTyler Retzlaff * 19551e6608aSTyler Retzlaff * @return 19651e6608aSTyler Retzlaff * On success, return 0. 19751e6608aSTyler Retzlaff * On failure, return a positive errno-style error number. 19851e6608aSTyler Retzlaff */ 19951e6608aSTyler Retzlaff __rte_experimental 20051e6608aSTyler Retzlaff int rte_thread_attr_set_priority(rte_thread_attr_t *thread_attr, 20151e6608aSTyler Retzlaff enum rte_thread_priority priority); 20251e6608aSTyler Retzlaff 20399a2dd95SBruce Richardson #ifdef RTE_HAS_CPUSET 20499a2dd95SBruce Richardson 20599a2dd95SBruce Richardson /** 206b70a9b78STyler Retzlaff * @warning 207b70a9b78STyler Retzlaff * @b EXPERIMENTAL: this API may change without prior notice. 208b70a9b78STyler Retzlaff * 20951e6608aSTyler Retzlaff * Set the CPU affinity value in the thread attributes pointed to 21051e6608aSTyler Retzlaff * by 'thread_attr'. 21151e6608aSTyler Retzlaff * 21251e6608aSTyler Retzlaff * @param thread_attr 21351e6608aSTyler Retzlaff * Points to the thread attributes in which affinity will be updated. 21451e6608aSTyler Retzlaff * 21551e6608aSTyler Retzlaff * @param cpuset 21651e6608aSTyler Retzlaff * Points to the value of the affinity to be set. 21751e6608aSTyler Retzlaff * 21851e6608aSTyler Retzlaff * @return 21951e6608aSTyler Retzlaff * On success, return 0. 22051e6608aSTyler Retzlaff * On failure, return a positive errno-style error number. 22151e6608aSTyler Retzlaff */ 22251e6608aSTyler Retzlaff __rte_experimental 22351e6608aSTyler Retzlaff int rte_thread_attr_set_affinity(rte_thread_attr_t *thread_attr, 22451e6608aSTyler Retzlaff rte_cpuset_t *cpuset); 22551e6608aSTyler Retzlaff 22651e6608aSTyler Retzlaff /** 22751e6608aSTyler Retzlaff * @warning 22851e6608aSTyler Retzlaff * @b EXPERIMENTAL: this API may change without prior notice. 22951e6608aSTyler Retzlaff * 23051e6608aSTyler Retzlaff * Get the value of CPU affinity that is set in the thread attributes pointed 23151e6608aSTyler Retzlaff * to by 'thread_attr'. 23251e6608aSTyler Retzlaff * 23351e6608aSTyler Retzlaff * @param thread_attr 23451e6608aSTyler Retzlaff * Points to the thread attributes from which affinity will be retrieved. 23551e6608aSTyler Retzlaff * 23651e6608aSTyler Retzlaff * @param cpuset 23751e6608aSTyler Retzlaff * Pointer to the memory that will store the affinity. 23851e6608aSTyler Retzlaff * 23951e6608aSTyler Retzlaff * @return 24051e6608aSTyler Retzlaff * On success, return 0. 24151e6608aSTyler Retzlaff * On failure, return a positive errno-style error number. 24251e6608aSTyler Retzlaff */ 24351e6608aSTyler Retzlaff __rte_experimental 24451e6608aSTyler Retzlaff int rte_thread_attr_get_affinity(rte_thread_attr_t *thread_attr, 24551e6608aSTyler Retzlaff rte_cpuset_t *cpuset); 24651e6608aSTyler Retzlaff 24751e6608aSTyler Retzlaff /** 24851e6608aSTyler Retzlaff * @warning 24951e6608aSTyler Retzlaff * @b EXPERIMENTAL: this API may change without prior notice. 25051e6608aSTyler Retzlaff * 251b70a9b78STyler Retzlaff * Set the affinity of thread 'thread_id' to the cpu set 252b70a9b78STyler Retzlaff * specified by 'cpuset'. 253b70a9b78STyler Retzlaff * 254b70a9b78STyler Retzlaff * @param thread_id 255b70a9b78STyler Retzlaff * Id of the thread for which to set the affinity. 256b70a9b78STyler Retzlaff * 257b70a9b78STyler Retzlaff * @param cpuset 258b70a9b78STyler Retzlaff * Pointer to CPU affinity to set. 259b70a9b78STyler Retzlaff * 260b70a9b78STyler Retzlaff * @return 261b70a9b78STyler Retzlaff * On success, return 0. 262b70a9b78STyler Retzlaff * On failure, return a positive errno-style error number. 263b70a9b78STyler Retzlaff */ 264b70a9b78STyler Retzlaff __rte_experimental 265b70a9b78STyler Retzlaff int rte_thread_set_affinity_by_id(rte_thread_t thread_id, 266b70a9b78STyler Retzlaff const rte_cpuset_t *cpuset); 267b70a9b78STyler Retzlaff 268b70a9b78STyler Retzlaff /** 269b70a9b78STyler Retzlaff * @warning 270b70a9b78STyler Retzlaff * @b EXPERIMENTAL: this API may change without prior notice. 271b70a9b78STyler Retzlaff * 272b70a9b78STyler Retzlaff * Get the affinity of thread 'thread_id' and store it 273b70a9b78STyler Retzlaff * in 'cpuset'. 274b70a9b78STyler Retzlaff * 275b70a9b78STyler Retzlaff * @param thread_id 276b70a9b78STyler Retzlaff * Id of the thread for which to get the affinity. 277b70a9b78STyler Retzlaff * 278b70a9b78STyler Retzlaff * @param cpuset 279b70a9b78STyler Retzlaff * Pointer for storing the affinity value. 280b70a9b78STyler Retzlaff * 281b70a9b78STyler Retzlaff * @return 282b70a9b78STyler Retzlaff * On success, return 0. 283b70a9b78STyler Retzlaff * On failure, return a positive errno-style error number. 284b70a9b78STyler Retzlaff */ 285b70a9b78STyler Retzlaff __rte_experimental 286b70a9b78STyler Retzlaff int rte_thread_get_affinity_by_id(rte_thread_t thread_id, 287b70a9b78STyler Retzlaff rte_cpuset_t *cpuset); 288b70a9b78STyler Retzlaff 289b70a9b78STyler Retzlaff /** 29099a2dd95SBruce Richardson * Set core affinity of the current thread. 29199a2dd95SBruce Richardson * Support both EAL and non-EAL thread and update TLS. 29299a2dd95SBruce Richardson * 29399a2dd95SBruce Richardson * @param cpusetp 29499a2dd95SBruce Richardson * Pointer to CPU affinity to set. 29599a2dd95SBruce Richardson * @return 29699a2dd95SBruce Richardson * On success, return 0; otherwise return -1; 29799a2dd95SBruce Richardson */ 29899a2dd95SBruce Richardson int rte_thread_set_affinity(rte_cpuset_t *cpusetp); 29999a2dd95SBruce Richardson 30099a2dd95SBruce Richardson /** 30199a2dd95SBruce Richardson * Get core affinity of the current thread. 30299a2dd95SBruce Richardson * 30399a2dd95SBruce Richardson * @param cpusetp 30499a2dd95SBruce Richardson * Pointer to CPU affinity of current thread. 30599a2dd95SBruce Richardson * It presumes input is not NULL, otherwise it causes panic. 30699a2dd95SBruce Richardson * 30799a2dd95SBruce Richardson */ 30899a2dd95SBruce Richardson void rte_thread_get_affinity(rte_cpuset_t *cpusetp); 30999a2dd95SBruce Richardson 31099a2dd95SBruce Richardson #endif /* RTE_HAS_CPUSET */ 31199a2dd95SBruce Richardson 31299a2dd95SBruce Richardson /** 313ca04c78bSTyler Retzlaff * @warning 314ca04c78bSTyler Retzlaff * @b EXPERIMENTAL: this API may change without prior notice. 315ca04c78bSTyler Retzlaff * 316ca04c78bSTyler Retzlaff * Get the priority of a thread. 317ca04c78bSTyler Retzlaff * 318ca04c78bSTyler Retzlaff * @param thread_id 319ca04c78bSTyler Retzlaff * Id of the thread for which to get priority. 320ca04c78bSTyler Retzlaff * 321ca04c78bSTyler Retzlaff * @param priority 322ca04c78bSTyler Retzlaff * Location to store the retrieved priority. 323ca04c78bSTyler Retzlaff * 324ca04c78bSTyler Retzlaff * @return 325ca04c78bSTyler Retzlaff * On success, return 0. 326ca04c78bSTyler Retzlaff * On failure, return a positive errno-style error number. 327ca04c78bSTyler Retzlaff */ 328ca04c78bSTyler Retzlaff __rte_experimental 329ca04c78bSTyler Retzlaff int rte_thread_get_priority(rte_thread_t thread_id, 330ca04c78bSTyler Retzlaff enum rte_thread_priority *priority); 331ca04c78bSTyler Retzlaff 332ca04c78bSTyler Retzlaff /** 333ca04c78bSTyler Retzlaff * @warning 334ca04c78bSTyler Retzlaff * @b EXPERIMENTAL: this API may change without prior notice. 335ca04c78bSTyler Retzlaff * 336ca04c78bSTyler Retzlaff * Set the priority of a thread. 337ca04c78bSTyler Retzlaff * 338ca04c78bSTyler Retzlaff * @param thread_id 339ca04c78bSTyler Retzlaff * Id of the thread for which to set priority. 340ca04c78bSTyler Retzlaff * 341ca04c78bSTyler Retzlaff * @param priority 342ca04c78bSTyler Retzlaff * Priority value to be set. 343ca04c78bSTyler Retzlaff * 344ca04c78bSTyler Retzlaff * @return 345ca04c78bSTyler Retzlaff * On success, return 0. 346ca04c78bSTyler Retzlaff * On failure, return a positive errno-style error number. 347ca04c78bSTyler Retzlaff */ 348ca04c78bSTyler Retzlaff __rte_experimental 349ca04c78bSTyler Retzlaff int rte_thread_set_priority(rte_thread_t thread_id, 350ca04c78bSTyler Retzlaff enum rte_thread_priority priority); 351ca04c78bSTyler Retzlaff 352ca04c78bSTyler Retzlaff /** 35399a2dd95SBruce Richardson * Create a TLS data key visible to all threads in the process. 35499a2dd95SBruce Richardson * the created key is later used to get/set a value. 35599a2dd95SBruce Richardson * and optional destructor can be set to be called when a thread exits. 35699a2dd95SBruce Richardson * 35799a2dd95SBruce Richardson * @param key 35899a2dd95SBruce Richardson * Pointer to store the allocated key. 35999a2dd95SBruce Richardson * @param destructor 36099a2dd95SBruce Richardson * The function to be called when the thread exits. 36199a2dd95SBruce Richardson * Ignored on Windows OS. 36299a2dd95SBruce Richardson * 36399a2dd95SBruce Richardson * @return 36499a2dd95SBruce Richardson * On success, zero. 36599a2dd95SBruce Richardson * On failure, a negative number and an error number is set in rte_errno. 36699a2dd95SBruce Richardson * rte_errno can be: ENOMEM - Memory allocation error. 36799a2dd95SBruce Richardson * ENOEXEC - Specific OS error. 36899a2dd95SBruce Richardson */ 36999a2dd95SBruce Richardson 37099a2dd95SBruce Richardson __rte_experimental 37199a2dd95SBruce Richardson int rte_thread_key_create(rte_thread_key *key, 37299a2dd95SBruce Richardson void (*destructor)(void *)); 37399a2dd95SBruce Richardson 37499a2dd95SBruce Richardson /** 37599a2dd95SBruce Richardson * Delete a TLS data key visible to all threads in the process. 37699a2dd95SBruce Richardson * 37799a2dd95SBruce Richardson * @param key 37899a2dd95SBruce Richardson * The key allocated by rte_thread_key_create(). 37999a2dd95SBruce Richardson * 38099a2dd95SBruce Richardson * @return 38199a2dd95SBruce Richardson * On success, zero. 38299a2dd95SBruce Richardson * On failure, a negative number and an error number is set in rte_errno. 38399a2dd95SBruce Richardson * rte_errno can be: EINVAL - Invalid parameter passed. 38499a2dd95SBruce Richardson * ENOEXEC - Specific OS error. 38599a2dd95SBruce Richardson */ 38699a2dd95SBruce Richardson __rte_experimental 38799a2dd95SBruce Richardson int rte_thread_key_delete(rte_thread_key key); 38899a2dd95SBruce Richardson 38999a2dd95SBruce Richardson /** 39099a2dd95SBruce Richardson * Set value bound to the TLS key on behalf of the calling thread. 39199a2dd95SBruce Richardson * 39299a2dd95SBruce Richardson * @param key 39399a2dd95SBruce Richardson * The key allocated by rte_thread_key_create(). 39499a2dd95SBruce Richardson * @param value 39599a2dd95SBruce Richardson * The value bound to the rte_thread_key key for the calling thread. 39699a2dd95SBruce Richardson * 39799a2dd95SBruce Richardson * @return 39899a2dd95SBruce Richardson * On success, zero. 39999a2dd95SBruce Richardson * On failure, a negative number and an error number is set in rte_errno. 40099a2dd95SBruce Richardson * rte_errno can be: EINVAL - Invalid parameter passed. 40199a2dd95SBruce Richardson * ENOEXEC - Specific OS error. 40299a2dd95SBruce Richardson */ 40399a2dd95SBruce Richardson __rte_experimental 40499a2dd95SBruce Richardson int rte_thread_value_set(rte_thread_key key, const void *value); 40599a2dd95SBruce Richardson 40699a2dd95SBruce Richardson /** 40799a2dd95SBruce Richardson * Get value bound to the TLS key on behalf of the calling thread. 40899a2dd95SBruce Richardson * 40999a2dd95SBruce Richardson * @param key 41099a2dd95SBruce Richardson * The key allocated by rte_thread_key_create(). 41199a2dd95SBruce Richardson * 41299a2dd95SBruce Richardson * @return 41399a2dd95SBruce Richardson * On success, value data pointer (can also be NULL). 41499a2dd95SBruce Richardson * On failure, NULL and an error number is set in rte_errno. 41599a2dd95SBruce Richardson * rte_errno can be: EINVAL - Invalid parameter passed. 41699a2dd95SBruce Richardson * ENOEXEC - Specific OS error. 41799a2dd95SBruce Richardson */ 41899a2dd95SBruce Richardson __rte_experimental 41999a2dd95SBruce Richardson void *rte_thread_value_get(rte_thread_key key); 42099a2dd95SBruce Richardson 42199a2dd95SBruce Richardson #ifdef __cplusplus 42299a2dd95SBruce Richardson } 42399a2dd95SBruce Richardson #endif 42499a2dd95SBruce Richardson 42599a2dd95SBruce Richardson #endif /* _RTE_THREAD_H_ */ 426