qdf_threads.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. * 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_user_nice() - set thread's nice value
  34. * @thread: pointer to thread
  35. * @nice: nice value
  36. *
  37. * Return: none
  38. */
  39. void qdf_set_user_nice(qdf_thread_t *thread, long nice);
  40. /**
  41. * qdf_create_thread() - create a kernel thread
  42. * @thread: pointer to thread
  43. * @nice: nice value
  44. *
  45. * Return: pointer to created kernel thread
  46. */
  47. qdf_thread_t *qdf_create_thread(int (*thread_handler)(void *data), void *data,
  48. const char thread_name[]);
  49. /**
  50. * qdf_thread_run() - run the given function in a new thread
  51. *
  52. * You must call qdf_thread_join() to avoid a reasource leak!
  53. *
  54. * For more flexibility, use qdf_create_thread() instead.
  55. *
  56. * Return: a new qdf_thread pointer
  57. */
  58. qdf_thread_t *qdf_thread_run(qdf_thread_func callback, void *context);
  59. /**
  60. * qdf_thread_join() - signal and wait for a thread to stop
  61. *
  62. * This sets a flag that the given thread can check to see if it should exit.
  63. * The thread can check to see if this flag has been set by calling
  64. * qdf_thread_should_stop().
  65. *
  66. * Return: QDF_STATUS - the return value from the thread function
  67. */
  68. QDF_STATUS qdf_thread_join(qdf_thread_t *thread);
  69. /**
  70. * qdf_thread_should_stop() - true if the current thread was signalled to stop
  71. *
  72. * If qdf_thread_join() has been called on the current thread, this API returns
  73. * true. Otherwise, this returns false.
  74. *
  75. * Return: true if the current thread should stop
  76. */
  77. bool qdf_thread_should_stop(void);
  78. /**
  79. * qdf_wake_up_process() - wake up given thread
  80. * @thread: pointer to thread which needs to be woken up
  81. *
  82. * Return: none
  83. */
  84. int qdf_wake_up_process(qdf_thread_t *thread);
  85. /**
  86. * qdf_print_stack_trace_thread() - prints the stack trace of the given thread
  87. * @thread: the thread for which the stack trace will be printed
  88. *
  89. * Return: None
  90. */
  91. void qdf_print_thread_trace(qdf_thread_t *thread);
  92. /**
  93. * qdf_get_current_task() - get current task struct
  94. *
  95. * Return: pointer to task struct
  96. */
  97. qdf_thread_t *qdf_get_current_task(void);
  98. #endif /* __QDF_THREADS_H */