qdf_threads.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. /*
  2. * Copyright (c) 2014-2019 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. * DOC: qdf_threads
  20. * QCA driver framework (QDF) thread related APIs
  21. */
  22. #if !defined(__QDF_THREADS_H)
  23. #define __QDF_THREADS_H
  24. #include <qdf_types.h>
  25. #include "i_qdf_threads.h"
  26. typedef __qdf_thread_t qdf_thread_t;
  27. typedef QDF_STATUS (*qdf_thread_func)(void *context);
  28. /* Function declarations and documenation */
  29. void qdf_sleep(uint32_t ms_interval);
  30. void qdf_sleep_us(uint32_t us_interval);
  31. void qdf_busy_wait(uint32_t us_interval);
  32. /**
  33. * qdf_set_wake_up_idle() - set wakeup idle value
  34. * @idle: true/false value for wake up idle
  35. *
  36. * Return: none
  37. */
  38. void qdf_set_wake_up_idle(bool idle);
  39. /**
  40. * qdf_set_user_nice() - set thread's nice value
  41. * @thread: pointer to thread
  42. * @nice: nice value
  43. *
  44. * Return: void
  45. */
  46. void qdf_set_user_nice(qdf_thread_t *thread, long nice);
  47. /**
  48. * qdf_create_thread() - create a kernel thread
  49. * @thread: pointer to thread
  50. * @nice: nice value
  51. *
  52. * Return: pointer to created kernel thread on success else NULL
  53. */
  54. qdf_thread_t *qdf_create_thread(int (*thread_handler)(void *data), void *data,
  55. const char thread_name[]);
  56. /**
  57. * qdf_thread_run() - run the given function in a new thread
  58. *
  59. * You must call qdf_thread_join() to avoid a reasource leak!
  60. *
  61. * For more flexibility, use qdf_create_thread() instead.
  62. *
  63. * Return: a new qdf_thread pointer
  64. */
  65. qdf_thread_t *qdf_thread_run(qdf_thread_func callback, void *context);
  66. /**
  67. * qdf_thread_join() - signal and wait for a thread to stop
  68. *
  69. * This sets a flag that the given thread can check to see if it should exit.
  70. * The thread can check to see if this flag has been set by calling
  71. * qdf_thread_should_stop().
  72. *
  73. * Return: QDF_STATUS - the return value from the thread function
  74. */
  75. QDF_STATUS qdf_thread_join(qdf_thread_t *thread);
  76. /**
  77. * qdf_thread_should_stop() - true if the current thread was signalled to stop
  78. *
  79. * If qdf_thread_join() has been called on the current thread, this API returns
  80. * true. Otherwise, this returns false.
  81. *
  82. * Return: true if the current thread should stop
  83. */
  84. bool qdf_thread_should_stop(void);
  85. /**
  86. * qdf_wake_up_process() - wake up given thread
  87. * @thread: pointer to thread which needs to be woken up
  88. *
  89. * Return: none
  90. */
  91. int qdf_wake_up_process(qdf_thread_t *thread);
  92. /**
  93. * qdf_print_stack_trace_thread() - prints the stack trace of the given thread
  94. * @thread: the thread for which the stack trace will be printed
  95. *
  96. * Return: None
  97. */
  98. void qdf_print_thread_trace(qdf_thread_t *thread);
  99. /**
  100. * qdf_get_current_task() - get current task struct
  101. *
  102. * Return: pointer to task struct
  103. */
  104. qdf_thread_t *qdf_get_current_task(void);
  105. /**
  106. * qdf_get_current_pid() - get current task's process id
  107. *
  108. * Return: current task's process id (int)
  109. */
  110. int qdf_get_current_pid(void);
  111. /**
  112. * qdf_get_current_comm() - get current task's command name
  113. *
  114. * Return: current task's command name(char *)
  115. */
  116. const char *qdf_get_current_comm(void);
  117. /**
  118. * qdf_thread_set_cpus_allowed_mask() - set cpu mask for a particular thread
  119. * @thread: thread for which new cpu mask is set
  120. * @new_mask: new cpu mask to be set for the thread
  121. *
  122. * Return: None
  123. */
  124. void
  125. qdf_thread_set_cpus_allowed_mask(qdf_thread_t *thread, qdf_cpu_mask *new_mask);
  126. /**
  127. * qdf_cpumask_clear() - clear all cpus in a cpumask
  128. * @dstp: cpumask pointer
  129. *
  130. * Return: None
  131. */
  132. void qdf_cpumask_clear(qdf_cpu_mask *dstp);
  133. /**
  134. * qdf_cpumask_set_cpu() - set a cpu in a cpumask
  135. * @cpu: cpu number
  136. * @dstp: cpumask pointer
  137. *
  138. * Return: None
  139. */
  140. void qdf_cpumask_set_cpu(unsigned int cpu, qdf_cpu_mask *dstp);
  141. /**
  142. * qdf_cpumask_setall - set all cpus
  143. * @dstp: cpumask pointer
  144. *
  145. * Return: None
  146. */
  147. void qdf_cpumask_setall(qdf_cpu_mask *dstp);
  148. #endif /* __QDF_THREADS_H */