1 /* 2 * Copyright (c) 2014-2018 The Linux Foundation. All rights reserved. 3 * 4 * Permission to use, copy, modify, and/or distribute this software for 5 * any purpose with or without fee is hereby granted, provided that the 6 * above copyright notice and this permission notice appear in all 7 * copies. 8 * 9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 10 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 11 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 12 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 13 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 14 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 15 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 16 * PERFORMANCE OF THIS SOFTWARE. 17 */ 18 19 /** 20 * DOC: qdf_threads 21 * QCA driver framework (QDF) thread related APIs 22 */ 23 24 #if !defined(__QDF_THREADS_H) 25 #define __QDF_THREADS_H 26 27 #include <qdf_types.h> 28 #include "i_qdf_threads.h" 29 30 typedef __qdf_thread_t qdf_thread_t; 31 typedef QDF_STATUS (*qdf_thread_func)(void *context); 32 33 /* Function declarations and documenation */ 34 35 void qdf_sleep(uint32_t ms_interval); 36 37 void qdf_sleep_us(uint32_t us_interval); 38 39 void qdf_busy_wait(uint32_t us_interval); 40 41 /** 42 * qdf_set_user_nice() - set thread's nice value 43 * @thread: pointer to thread 44 * @nice: nice value 45 * 46 * Return: none 47 */ 48 void qdf_set_user_nice(qdf_thread_t *thread, long nice); 49 50 /** 51 * qdf_create_thread() - create a kernel thread 52 * @thread: pointer to thread 53 * @nice: nice value 54 * 55 * Return: pointer to created kernel thread 56 */ 57 qdf_thread_t *qdf_create_thread(int (*thread_handler)(void *data), void *data, 58 const char thread_name[]); 59 60 /** 61 * qdf_thread_run() - run the given function in a new thread 62 * 63 * You must call qdf_thread_join() to avoid a reasource leak! 64 * 65 * For more flexibility, use qdf_create_thread() instead. 66 * 67 * Return: a new qdf_thread pointer 68 */ 69 qdf_thread_t *qdf_thread_run(qdf_thread_func callback, void *context); 70 71 /** 72 * qdf_thread_join() - signal and wait for a thread to stop 73 * 74 * This sets a flag that the given thread can check to see if it should exit. 75 * The thread can check to see if this flag has been set by calling 76 * qdf_thread_should_stop(). 77 * 78 * Return: QDF_STATUS - the return value from the thread function 79 */ 80 QDF_STATUS qdf_thread_join(qdf_thread_t *thread); 81 82 /** 83 * qdf_thread_should_stop() - true if the current thread was signalled to stop 84 * 85 * If qdf_thread_join() has been called on the current thread, this API returns 86 * true. Otherwise, this returns false. 87 * 88 * Return: true if the current thread should stop 89 */ 90 bool qdf_thread_should_stop(void); 91 92 /** 93 * qdf_wake_up_process() - wake up given thread 94 * @thread: pointer to thread which needs to be woken up 95 * 96 * Return: none 97 */ 98 int qdf_wake_up_process(qdf_thread_t *thread); 99 100 /** 101 * qdf_print_stack_trace_thread() - prints the stack trace of the given thread 102 * @thread: the thread for which the stack trace will be printed 103 * 104 * Return: None 105 */ 106 void qdf_print_thread_trace(qdf_thread_t *thread); 107 108 /** 109 * qdf_get_current_task() - get current task struct 110 * 111 * Return: pointer to task struct 112 */ 113 qdf_thread_t *qdf_get_current_task(void); 114 #endif /* __QDF_THREADS_H */ 115