scheduler_api.h 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. /*
  2. * Copyright (c) 2014-2016 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. #include <osdep.h>
  34. /* Controller thread various event masks
  35. * MC_POST_EVENT_MASK: wake up thread after posting message
  36. * MC_SUSPEND_EVENT_MASK: signal thread to suspend during kernel pm suspend
  37. * MC_SHUTDOWN_EVENT_MASK: signal thread to shutdown and exit during unload
  38. */
  39. #define MC_POST_EVENT_MASK 0x001
  40. #define MC_SUSPEND_EVENT_MASK 0x002
  41. #define MC_SHUTDOWN_EVENT_MASK 0x010
  42. /*
  43. * Cookie for timer messages. Note that anyone posting a timer message
  44. * has to write the COOKIE in the reserved field of the message. The
  45. * timer queue handler relies on this COOKIE
  46. */
  47. #define SYS_MSG_COOKIE 0xFACE
  48. /**
  49. * enum CDS_MQ_ID - message queues enum
  50. * @CDS_MQ_ID_SME: Legacy SME message queue ID
  51. * @CDS_MQ_ID_PE: Legacy PE message queue ID
  52. * @CDS_MQ_ID_WMA: Legacy WMA message queue ID
  53. * @CDS_MQ_ID_SYS: Legacy SYS message queue ID
  54. * @CDS_MQ_ID_OS_IF: OS IF(north interface) message queue ID
  55. * @CDS_MQ_ID_TARGET_IF: Target IF(south interface) message queue ID
  56. */
  57. typedef enum {
  58. CDS_MQ_ID_SME = QDF_MODULE_ID_SME,
  59. CDS_MQ_ID_PE = QDF_MODULE_ID_PE,
  60. CDS_MQ_ID_WMA = QDF_MODULE_ID_WMA,
  61. CDS_MQ_ID_SYS = QDF_MODULE_ID_SYS,
  62. CDS_MQ_ID_OS_IF = QDF_MODULE_ID_OS_IF,
  63. CDS_MQ_ID_TARGET_IF = QDF_MODULE_ID_TARGET_IF,
  64. } CDS_MQ_ID;
  65. typedef enum {
  66. SYS_MSG_ID_MC_START,
  67. SYS_MSG_ID_MC_THR_PROBE,
  68. SYS_MSG_ID_MC_TIMER,
  69. SYS_MSG_ID_MC_STOP,
  70. SYS_MSG_ID_FTM_RSP,
  71. SYS_MSG_ID_QVIT,
  72. } SYS_MSG_ID;
  73. /**
  74. * struct scheduler_msg: scheduler message structure
  75. * @type: message type
  76. * @reserved: reserved field
  77. * @bodyptr: message body pointer based on the type either a bodyptr pointer
  78. * into memory or bodyval as a 32 bit data is used. bodyptr is always a
  79. * freeable pointer, one should always make sure that bodyptr is always
  80. * freeable.
  81. * Messages should use either bodyptr or bodyval; not both !!!
  82. * @bodyval: message body val
  83. * @callback: callback to be called by scheduler thread once message is posted
  84. * and scheduler thread has started processing the message.
  85. */
  86. struct scheduler_msg {
  87. uint16_t type;
  88. uint16_t reserved;
  89. void *bodyptr;
  90. uint32_t bodyval;
  91. void *callback;
  92. };
  93. typedef QDF_STATUS (*scheduler_msg_process_fn_t) (struct scheduler_msg *msg);
  94. typedef void (*hdd_suspend_callback)(void);
  95. /**
  96. * scheduler_init() - initialize control path scheduler
  97. *
  98. * This API initializes control path scheduler.
  99. *
  100. * Return: QDF status
  101. */
  102. QDF_STATUS scheduler_init(void);
  103. /**
  104. * scheduler_deinit() - de-initialize control path scheduler
  105. *
  106. * This API de-initializes control path scheduler.
  107. *
  108. * Return: QDF status
  109. */
  110. QDF_STATUS scheduler_deinit(void);
  111. /**
  112. * scheduler_register_module() - register input module/queue id
  113. * @qid: queue id to get registered
  114. * @callback: queue message to be called when a message is posted
  115. *
  116. * Return: QDF status
  117. */
  118. QDF_STATUS scheduler_register_module(QDF_MODULE_ID qid,
  119. scheduler_msg_process_fn_t callback);
  120. /**
  121. * scheduler_deregister_module() - deregister input module/queue id
  122. * @qid: queue id to get deregistered
  123. *
  124. * Return: QDF status
  125. */
  126. QDF_STATUS scheduler_deregister_module(QDF_MODULE_ID qid);
  127. /**
  128. * scheduler_post_msg_by_priority() - post messages by priority
  129. * @qid: queue id to to post message
  130. * @msg: mesage pointer
  131. * @is_high_priority: set to true for high priority message else false
  132. *
  133. * IMPORTANT NOTE:
  134. * 1) Legacy MCL modules continue posting messages to following legacy
  135. * message queue IDs:
  136. * a) CDS_MQ_ID_SME : SME module message queue
  137. * b) CDS_MQ_ID_PE : PE module message queue
  138. * c) CDS_MQ_ID_WMA : WMA module message queue
  139. * d) CDS_MQ_ID_SYS : SYS module message queue
  140. * 2) All new components like SCM, P2P, TDLS, etc. needs to post messages
  141. * to following new message queue ids:
  142. * a) CDS_MQ_ID_OS_IF : North interface message queue for request comign
  143. * from operating systems
  144. * b) CDS_MQ_ID_TARGET_IF : South interface message queue for messages
  145. * and events coming from target(firmware)
  146. *
  147. * Return: QDF status
  148. */
  149. QDF_STATUS scheduler_post_msg_by_priority(CDS_MQ_ID qid,
  150. struct scheduler_msg *msg, bool is_high_priority);
  151. /**
  152. * scheduler_post_msg() - post normal messages(no priority)
  153. * @qid: queue id to to post message
  154. * @msg: mesage pointer
  155. *
  156. * IMPORTANT NOTE:
  157. * 1) Legacy MCL modules continue posting messages to following legacy
  158. * message queue IDs:
  159. * a) CDS_MQ_ID_SME : SME module message queue
  160. * b) CDS_MQ_ID_PE : PE module message queue
  161. * c) CDS_MQ_ID_WMA : WMA module message queue
  162. * d) CDS_MQ_ID_SYS : SYS module message queue
  163. * 2) All new components like SCM, P2P, TDLS, etc. needs to post messages
  164. * to following new message queue ids:
  165. * a) CDS_MQ_ID_OS_IF : North interface message queue for request comign
  166. * from operating systems
  167. * b) CDS_MQ_ID_TARGET_IF : South interface message queue for messages
  168. * and events coming from target(firmware)
  169. *
  170. * Return: QDF status
  171. */
  172. static inline QDF_STATUS scheduler_post_msg(CDS_MQ_ID qid,
  173. struct scheduler_msg *msg)
  174. {
  175. return scheduler_post_msg_by_priority(qid, msg, false);
  176. }
  177. /**
  178. * scheduler_resume_complete() - resume scheduler thread
  179. *
  180. * Complete scheduler thread resume wait event such that scheduler
  181. * thread can wake up and process message queues
  182. *
  183. * Return: none
  184. */
  185. void scheduler_resume_complete(void);
  186. /**
  187. * scheduler_register_hdd_suspend_callback() - suspend callback to hdd
  188. * @callback: hdd callback to be called when controllred thread is suspended
  189. *
  190. * Return: none
  191. */
  192. void scheduler_register_hdd_suspend_callback(hdd_suspend_callback callback);
  193. /**
  194. * scheduler_wake_up_controller_thread() - wake up controller thread
  195. *
  196. * Wake up controller thread to process a critical message.
  197. *
  198. * Return: none
  199. */
  200. void scheduler_wake_up_controller_thread(void);
  201. /**
  202. * scheduler_set_event_mask() - set given event mask
  203. * @event_mask: event mask to set
  204. *
  205. * Set given event mask such that controller scheduler thread can do
  206. * specified work after wake up.
  207. *
  208. * Return: none
  209. */
  210. void scheduler_set_event_mask(uint32_t event_mask);
  211. /**
  212. * scheduler_clear_event_mask() - clear given event mask
  213. * @event_mask: event mask to set
  214. *
  215. * Return: none
  216. */
  217. void scheduler_clear_event_mask(uint32_t event_mask);
  218. /**
  219. * scheduler_target_if_mq_handler() - top level message queue handler for
  220. * target_if message queue
  221. * @msg: pointer to actual message being handled
  222. *
  223. * Return: none
  224. */
  225. QDF_STATUS scheduler_target_if_mq_handler(struct scheduler_msg *msg);
  226. /**
  227. * scheduler_os_if_mq_handler() - top level message queue handler for
  228. * os_if message queue
  229. * @msg: pointer to actual message being handled
  230. *
  231. * Return: none
  232. */
  233. QDF_STATUS scheduler_os_if_mq_handler(struct scheduler_msg *msg);
  234. /**
  235. * scheduler_timer_q_mq_handler() - top level message queue handler for
  236. * timer queue
  237. * @msg: pointer to actual message being handled
  238. *
  239. * Return: none
  240. */
  241. QDF_STATUS scheduler_timer_q_mq_handler(struct scheduler_msg *msg);
  242. /**
  243. * scheduler_register_wma_legacy_handler() - register legacy wma handler
  244. * @callback: legacy wma handler to be called for WMA messages
  245. *
  246. * Return: QDF status
  247. */
  248. QDF_STATUS scheduler_register_wma_legacy_handler(scheduler_msg_process_fn_t
  249. callback);
  250. /**
  251. * scheduler_register_sys_legacy_handler() - register legacy sys handler
  252. * @callback: legacy sys handler to be called for sys messages
  253. *
  254. * Return: QDF status
  255. */
  256. QDF_STATUS scheduler_register_sys_legacy_handler(scheduler_msg_process_fn_t
  257. callback);
  258. /**
  259. * scheduler_mc_timer_callback() - timer callback, gets called at time out
  260. * @data: unsigned long, holds the timer object.
  261. *
  262. * Return: None
  263. */
  264. void scheduler_mc_timer_callback(unsigned long data);
  265. #endif