scheduler_api.h 8.1 KB

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