scheduler_api.h 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. /*
  2. * Copyright (c) 2014-2017 The Linux Foundation. All rights reserved.
  3. *
  4. * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
  5. *
  6. *
  7. * Permission to use, copy, modify, and/or distribute this software for
  8. * any purpose with or without fee is hereby granted, provided that the
  9. * above copyright notice and this permission notice appear in all
  10. * copies.
  11. *
  12. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  13. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  14. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  15. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  16. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  17. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  18. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  19. * PERFORMANCE OF THIS SOFTWARE.
  20. */
  21. /*
  22. * This file was originally distributed by Qualcomm Atheros, Inc.
  23. * under proprietary terms before Copyright ownership was assigned
  24. * to the Linux Foundation.
  25. */
  26. #if !defined(__SCHEDULER_API_H)
  27. #define __SCHEDULER_API_H
  28. #include <qdf_event.h>
  29. #include <qdf_types.h>
  30. #include <qdf_lock.h>
  31. #include <qdf_mc_timer.h>
  32. #include <qdf_status.h>
  33. /* Controller thread various event masks
  34. * MC_POST_EVENT_MASK: wake up thread after posting message
  35. * MC_SUSPEND_EVENT_MASK: signal thread to suspend during kernel pm suspend
  36. * MC_SHUTDOWN_EVENT_MASK: signal thread to shutdown and exit during unload
  37. */
  38. #define MC_POST_EVENT_MASK 0x001
  39. #define MC_SUSPEND_EVENT_MASK 0x002
  40. #define MC_SHUTDOWN_EVENT_MASK 0x010
  41. /*
  42. * Cookie for timer messages. Note that anyone posting a timer message
  43. * has to write the COOKIE in the reserved field of the message. The
  44. * timer queue handler relies on this COOKIE
  45. */
  46. #define SYS_MSG_COOKIE 0xFACE
  47. typedef enum {
  48. SYS_MSG_ID_MC_THR_PROBE,
  49. SYS_MSG_ID_MC_TIMER,
  50. SYS_MSG_ID_FTM_RSP,
  51. SYS_MSG_ID_QVIT,
  52. } SYS_MSG_ID;
  53. /**
  54. * struct scheduler_msg: scheduler message structure
  55. * @type: message type
  56. * @reserved: reserved field
  57. * @bodyptr: message body pointer based on the type either a bodyptr pointer
  58. * into memory or bodyval as a 32 bit data is used. bodyptr is always a
  59. * freeable pointer, one should always make sure that bodyptr is always
  60. * freeable.
  61. * Messages should use either bodyptr or bodyval; not both !!!
  62. * @bodyval: message body val
  63. * @callback: callback to be called by scheduler thread once message is posted
  64. * and scheduler thread has started processing the message.
  65. * @flush_callback: flush callback which will be invoked during driver unload
  66. * such that component can release the ref count of common global objects
  67. * like PSOC, PDEV, VDEV and PEER. A component needs to populate flush
  68. * callback in message body pointer for those messages which have taken ref
  69. * count for above mentioned common objects.
  70. */
  71. struct scheduler_msg {
  72. uint16_t type;
  73. uint16_t reserved;
  74. void *bodyptr;
  75. uint32_t bodyval;
  76. void *callback;
  77. void *flush_callback;
  78. };
  79. typedef QDF_STATUS (*scheduler_msg_process_fn_t) (struct scheduler_msg *msg);
  80. typedef void (*hdd_suspend_callback)(void);
  81. /**
  82. * scheduler_init() - initialize control path scheduler
  83. *
  84. * This API initializes control path scheduler.
  85. *
  86. * Return: QDF status
  87. */
  88. QDF_STATUS scheduler_init(void);
  89. /**
  90. * scheduler_deinit() - de-initialize control path scheduler
  91. *
  92. * This API de-initializes control path scheduler.
  93. *
  94. * Return: QDF status
  95. */
  96. QDF_STATUS scheduler_deinit(void);
  97. /**
  98. * scheduler_register_module() - register input module/queue id
  99. * @qid: queue id to get registered
  100. * @callback: queue message to be called when a message is posted
  101. *
  102. * Return: QDF status
  103. */
  104. QDF_STATUS scheduler_register_module(QDF_MODULE_ID qid,
  105. scheduler_msg_process_fn_t callback);
  106. /**
  107. * scheduler_deregister_module() - deregister input module/queue id
  108. * @qid: queue id to get deregistered
  109. *
  110. * Return: QDF status
  111. */
  112. QDF_STATUS scheduler_deregister_module(QDF_MODULE_ID qid);
  113. /**
  114. * scheduler_post_msg_by_priority() - post messages by priority
  115. * @qid: queue id to to post message
  116. * @msg: mesage pointer
  117. * @is_high_priority: set to true for high priority message else false
  118. *
  119. * Return: QDF status
  120. */
  121. QDF_STATUS scheduler_post_msg_by_priority(QDF_MODULE_ID qid,
  122. struct scheduler_msg *msg, bool is_high_priority);
  123. /**
  124. * scheduler_post_msg() - post normal messages(no priority)
  125. * @qid: queue id to to post message
  126. * @msg: mesage pointer
  127. *
  128. * Return: QDF status
  129. */
  130. static inline QDF_STATUS scheduler_post_msg(QDF_MODULE_ID qid,
  131. struct scheduler_msg *msg)
  132. {
  133. return scheduler_post_msg_by_priority(qid, msg, false);
  134. }
  135. /**
  136. * scheduler_resume() - resume scheduler thread
  137. *
  138. * Complete scheduler thread resume wait event such that scheduler
  139. * thread can wake up and process message queues
  140. *
  141. * Return: none
  142. */
  143. void scheduler_resume(void);
  144. /**
  145. * scheduler_register_hdd_suspend_callback() - suspend callback to hdd
  146. * @callback: hdd callback to be called when controllred thread is suspended
  147. *
  148. * Return: none
  149. */
  150. void scheduler_register_hdd_suspend_callback(hdd_suspend_callback callback);
  151. /**
  152. * scheduler_wake_up_controller_thread() - wake up controller thread
  153. *
  154. * Wake up controller thread to process a critical message.
  155. *
  156. * Return: none
  157. */
  158. void scheduler_wake_up_controller_thread(void);
  159. /**
  160. * scheduler_set_event_mask() - set given event mask
  161. * @event_mask: event mask to set
  162. *
  163. * Set given event mask such that controller scheduler thread can do
  164. * specified work after wake up.
  165. *
  166. * Return: none
  167. */
  168. void scheduler_set_event_mask(uint32_t event_mask);
  169. /**
  170. * scheduler_clear_event_mask() - clear given event mask
  171. * @event_mask: event mask to set
  172. *
  173. * Return: none
  174. */
  175. void scheduler_clear_event_mask(uint32_t event_mask);
  176. /**
  177. * scheduler_target_if_mq_handler() - top level message queue handler for
  178. * target_if message queue
  179. * @msg: pointer to actual message being handled
  180. *
  181. * Return: none
  182. */
  183. QDF_STATUS scheduler_target_if_mq_handler(struct scheduler_msg *msg);
  184. /**
  185. * scheduler_os_if_mq_handler() - top level message queue handler for
  186. * os_if message queue
  187. * @msg: pointer to actual message being handled
  188. *
  189. * Return: none
  190. */
  191. QDF_STATUS scheduler_os_if_mq_handler(struct scheduler_msg *msg);
  192. /**
  193. * scheduler_timer_q_mq_handler() - top level message queue handler for
  194. * timer queue
  195. * @msg: pointer to actual message being handled
  196. *
  197. * Return: none
  198. */
  199. QDF_STATUS scheduler_timer_q_mq_handler(struct scheduler_msg *msg);
  200. /**
  201. * scheduler_register_wma_legacy_handler() - register legacy wma handler
  202. * @callback: legacy wma handler to be called for WMA messages
  203. *
  204. * Return: QDF status
  205. */
  206. QDF_STATUS scheduler_register_wma_legacy_handler(scheduler_msg_process_fn_t
  207. callback);
  208. /**
  209. * scheduler_register_sys_legacy_handler() - register legacy sys handler
  210. * @callback: legacy sys handler to be called for sys messages
  211. *
  212. * Return: QDF status
  213. */
  214. QDF_STATUS scheduler_register_sys_legacy_handler(scheduler_msg_process_fn_t
  215. callback);
  216. /**
  217. * scheduler_deregister_sys_legacy_handler() - deregister legacy sys handler
  218. *
  219. * Return: QDF status
  220. */
  221. QDF_STATUS scheduler_deregister_sys_legacy_handler(void);
  222. /**
  223. * scheduler_deregister_wma_legacy_handler() - deregister legacy wma handler
  224. *
  225. * Return: QDF status
  226. */
  227. QDF_STATUS scheduler_deregister_wma_legacy_handler(void);
  228. /**
  229. * scheduler_mc_timer_callback() - timer callback, gets called at time out
  230. * @data: unsigned long, holds the timer object.
  231. *
  232. * Return: None
  233. */
  234. void scheduler_mc_timer_callback(unsigned long data);
  235. #endif