scheduler_api.h 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  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. #if !defined(__SCHEDULER_API_H)
  19. #define __SCHEDULER_API_H
  20. #include <qdf_event.h>
  21. #include <qdf_types.h>
  22. #include <qdf_lock.h>
  23. #include <qdf_mc_timer.h>
  24. #include <qdf_status.h>
  25. /* Controller thread various event masks
  26. * MC_POST_EVENT_MASK: wake up thread after posting message
  27. * MC_SUSPEND_EVENT_MASK: signal thread to suspend during kernel pm suspend
  28. * MC_SHUTDOWN_EVENT_MASK: signal thread to shutdown and exit during unload
  29. */
  30. #define MC_POST_EVENT_MASK 0x001
  31. #define MC_SUSPEND_EVENT_MASK 0x002
  32. #define MC_SHUTDOWN_EVENT_MASK 0x010
  33. /*
  34. * Cookie for timer messages. Note that anyone posting a timer message
  35. * has to write the COOKIE in the reserved field of the message. The
  36. * timer queue handler relies on this COOKIE
  37. */
  38. #define SYS_MSG_COOKIE 0xFACE
  39. typedef enum {
  40. SYS_MSG_ID_MC_THR_PROBE,
  41. SYS_MSG_ID_MC_TIMER,
  42. SYS_MSG_ID_FTM_RSP,
  43. SYS_MSG_ID_QVIT,
  44. SYS_MSG_ID_DATA_STALL_MSG,
  45. SYS_MSG_ID_UMAC_STOP,
  46. } SYS_MSG_ID;
  47. /**
  48. * struct scheduler_msg: scheduler message structure
  49. * @type: message type
  50. * @reserved: reserved field
  51. * @bodyval: message body val
  52. * @bodyptr: message body pointer based on the type either a bodyptr pointer
  53. * into memory or bodyval as a 32 bit data is used. bodyptr is always a
  54. * freeable pointer, one should always make sure that bodyptr is always
  55. * freeable.
  56. * Messages should use either bodyptr or bodyval; not both !!!
  57. * @callback: callback to be called by scheduler thread once message is posted
  58. * and scheduler thread has started processing the message.
  59. * @flush_callback: flush callback which will be invoked during driver unload
  60. * such that component can release the ref count of common global objects
  61. * like PSOC, PDEV, VDEV and PEER. A component needs to populate flush
  62. * callback in message body pointer for those messages which have taken ref
  63. * count for above mentioned common objects.
  64. * @node: list node for queue membership
  65. */
  66. struct scheduler_msg {
  67. uint16_t type;
  68. uint16_t reserved;
  69. uint32_t bodyval;
  70. void *bodyptr;
  71. void *callback;
  72. void *flush_callback;
  73. qdf_list_node_t node;
  74. };
  75. typedef QDF_STATUS (*scheduler_msg_process_fn_t) (struct scheduler_msg *msg);
  76. typedef void (*hdd_suspend_callback)(void);
  77. /**
  78. * scheduler_init() - initialize control path scheduler
  79. *
  80. * This API initializes control path scheduler.
  81. *
  82. * Return: QDF status
  83. */
  84. QDF_STATUS scheduler_init(void);
  85. /**
  86. * scheduler_deinit() - de-initialize control path scheduler
  87. *
  88. * This API de-initializes control path scheduler.
  89. *
  90. * Return: QDF status
  91. */
  92. QDF_STATUS scheduler_deinit(void);
  93. /**
  94. * scheduler_enable() - start the scheduler module
  95. *
  96. * Ready the scheduler module to service requests, and start the scheduler's
  97. * message processing thread. Must only be called after scheduler_init().
  98. *
  99. * Return: QDF_STATUS
  100. */
  101. QDF_STATUS scheduler_enable(void);
  102. /**
  103. * scheduler_disable() - stop the scheduler module
  104. *
  105. * Stop the scheduler module from servicing requests, and terminate the
  106. * scheduler's message processing thread. Must be called before
  107. * scheduler_deinit().
  108. *
  109. * Return: QDF_STATUS
  110. */
  111. QDF_STATUS scheduler_disable(void);
  112. /**
  113. * scheduler_register_module() - register input module/queue id
  114. * @qid: queue id to get registered
  115. * @callback: queue message to be called when a message is posted
  116. *
  117. * Return: QDF status
  118. */
  119. QDF_STATUS scheduler_register_module(QDF_MODULE_ID qid,
  120. scheduler_msg_process_fn_t callback);
  121. /**
  122. * scheduler_deregister_module() - deregister input module/queue id
  123. * @qid: queue id to get deregistered
  124. *
  125. * Return: QDF status
  126. */
  127. QDF_STATUS scheduler_deregister_module(QDF_MODULE_ID qid);
  128. /**
  129. * scheduler_post_msg_by_priority() - post messages by priority
  130. * @qid: queue id to to post message
  131. * @msg: message pointer
  132. * @is_high_priority: set to true for high priority message else false
  133. *
  134. * Return: QDF status
  135. */
  136. QDF_STATUS scheduler_post_msg_by_priority(QDF_MODULE_ID qid,
  137. struct scheduler_msg *msg, bool is_high_priority);
  138. /**
  139. * scheduler_post_msg() - post normal messages(no priority)
  140. * @qid: queue id to to post message
  141. * @msg: message pointer
  142. *
  143. * Return: QDF status
  144. */
  145. static inline QDF_STATUS scheduler_post_msg(QDF_MODULE_ID qid,
  146. struct scheduler_msg *msg)
  147. {
  148. return scheduler_post_msg_by_priority(qid, msg, false);
  149. }
  150. /**
  151. * scheduler_resume() - resume scheduler thread
  152. *
  153. * Complete scheduler thread resume wait event such that scheduler
  154. * thread can wake up and process message queues
  155. *
  156. * Return: none
  157. */
  158. void scheduler_resume(void);
  159. /**
  160. * scheduler_register_hdd_suspend_callback() - suspend callback to hdd
  161. * @callback: hdd callback to be called when controllred thread is suspended
  162. *
  163. * Return: none
  164. */
  165. void scheduler_register_hdd_suspend_callback(hdd_suspend_callback callback);
  166. /**
  167. * scheduler_wake_up_controller_thread() - wake up controller thread
  168. *
  169. * Wake up controller thread to process a critical message.
  170. *
  171. * Return: none
  172. */
  173. void scheduler_wake_up_controller_thread(void);
  174. /**
  175. * scheduler_set_event_mask() - set given event mask
  176. * @event_mask: event mask to set
  177. *
  178. * Set given event mask such that controller scheduler thread can do
  179. * specified work after wake up.
  180. *
  181. * Return: none
  182. */
  183. void scheduler_set_event_mask(uint32_t event_mask);
  184. /**
  185. * scheduler_clear_event_mask() - clear given event mask
  186. * @event_mask: event mask to set
  187. *
  188. * Return: none
  189. */
  190. void scheduler_clear_event_mask(uint32_t event_mask);
  191. /**
  192. * scheduler_target_if_mq_handler() - top level message queue handler for
  193. * target_if message queue
  194. * @msg: pointer to actual message being handled
  195. *
  196. * Return: none
  197. */
  198. QDF_STATUS scheduler_target_if_mq_handler(struct scheduler_msg *msg);
  199. /**
  200. * scheduler_os_if_mq_handler() - top level message queue handler for
  201. * os_if message queue
  202. * @msg: pointer to actual message being handled
  203. *
  204. * Return: none
  205. */
  206. QDF_STATUS scheduler_os_if_mq_handler(struct scheduler_msg *msg);
  207. /**
  208. * scheduler_timer_q_mq_handler() - top level message queue handler for
  209. * timer queue
  210. * @msg: pointer to actual message being handled
  211. *
  212. * Return: none
  213. */
  214. QDF_STATUS scheduler_timer_q_mq_handler(struct scheduler_msg *msg);
  215. /**
  216. * scheduler_scan_mq_handler() - top level message queue handler for
  217. * scan queue
  218. * @msg: pointer to actual message being handled
  219. *
  220. * Return: QDF status
  221. */
  222. QDF_STATUS scheduler_scan_mq_handler(struct scheduler_msg *msg);
  223. /**
  224. * scheduler_register_wma_legacy_handler() - register legacy wma handler
  225. * @callback: legacy wma handler to be called for WMA messages
  226. *
  227. * Return: QDF status
  228. */
  229. QDF_STATUS scheduler_register_wma_legacy_handler(scheduler_msg_process_fn_t
  230. callback);
  231. /**
  232. * scheduler_register_sys_legacy_handler() - register legacy sys handler
  233. * @callback: legacy sys handler to be called for sys messages
  234. *
  235. * Return: QDF status
  236. */
  237. QDF_STATUS scheduler_register_sys_legacy_handler(scheduler_msg_process_fn_t
  238. callback);
  239. /**
  240. * scheduler_deregister_sys_legacy_handler() - deregister legacy sys handler
  241. *
  242. * Return: QDF status
  243. */
  244. QDF_STATUS scheduler_deregister_sys_legacy_handler(void);
  245. /**
  246. * scheduler_deregister_wma_legacy_handler() - deregister legacy wma handler
  247. *
  248. * Return: QDF status
  249. */
  250. QDF_STATUS scheduler_deregister_wma_legacy_handler(void);
  251. /**
  252. * scheduler_mc_timer_callback() - timer callback, gets called at time out
  253. * @data: unsigned long, holds the timer object.
  254. *
  255. * Return: None
  256. */
  257. void scheduler_mc_timer_callback(unsigned long data);
  258. #endif