wmi_unified.c 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392
  1. /*
  2. * Copyright (c) 2015-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. /*
  27. * Host WMI unified implementation
  28. */
  29. #include "athdefs.h"
  30. #include "osapi_linux.h"
  31. #include "a_types.h"
  32. #include "a_debug.h"
  33. #include "ol_if_athvar.h"
  34. #include "ol_defines.h"
  35. #include "ol_fw.h"
  36. #include "htc_api.h"
  37. #include "htc_api.h"
  38. #include "dbglog_host.h"
  39. #include "wmi.h"
  40. #include "wmi_unified_priv.h"
  41. #include "wma_api.h"
  42. #include "wma.h"
  43. #include "mac_trace.h"
  44. #define WMI_MIN_HEAD_ROOM 64
  45. #ifdef WMI_INTERFACE_EVENT_LOGGING
  46. /* WMI commands */
  47. uint32_t g_wmi_command_buf_idx = 0;
  48. struct wmi_command_debug wmi_command_log_buffer[WMI_EVENT_DEBUG_MAX_ENTRY];
  49. /* WMI commands TX completed */
  50. uint32_t g_wmi_command_tx_cmp_buf_idx = 0;
  51. struct wmi_command_debug
  52. wmi_command_tx_cmp_log_buffer[WMI_EVENT_DEBUG_MAX_ENTRY];
  53. /* WMI events when processed */
  54. uint32_t g_wmi_event_buf_idx = 0;
  55. struct wmi_event_debug wmi_event_log_buffer[WMI_EVENT_DEBUG_MAX_ENTRY];
  56. /* WMI events when queued */
  57. uint32_t g_wmi_rx_event_buf_idx = 0;
  58. struct wmi_event_debug wmi_rx_event_log_buffer[WMI_EVENT_DEBUG_MAX_ENTRY];
  59. #define WMI_COMMAND_RECORD(a, b) { \
  60. if (WMI_EVENT_DEBUG_MAX_ENTRY <= g_wmi_command_buf_idx) \
  61. g_wmi_command_buf_idx = 0; \
  62. wmi_command_log_buffer[g_wmi_command_buf_idx].command = a; \
  63. cdf_mem_copy(wmi_command_log_buffer[g_wmi_command_buf_idx].data, b, 16); \
  64. wmi_command_log_buffer[g_wmi_command_buf_idx].time = \
  65. cdf_get_log_timestamp(); \
  66. g_wmi_command_buf_idx++; \
  67. }
  68. #define WMI_COMMAND_TX_CMP_RECORD(a, b) { \
  69. if (WMI_EVENT_DEBUG_MAX_ENTRY <= g_wmi_command_tx_cmp_buf_idx) \
  70. g_wmi_command_tx_cmp_buf_idx = 0; \
  71. wmi_command_tx_cmp_log_buffer[g_wmi_command_tx_cmp_buf_idx].command = a; \
  72. cdf_mem_copy(wmi_command_tx_cmp_log_buffer \
  73. [g_wmi_command_tx_cmp_buf_idx].data, b, 16); \
  74. wmi_command_tx_cmp_log_buffer[g_wmi_command_tx_cmp_buf_idx].time = \
  75. cdf_get_log_timestamp(); \
  76. g_wmi_command_tx_cmp_buf_idx++; \
  77. }
  78. #define WMI_EVENT_RECORD(a, b) { \
  79. if (WMI_EVENT_DEBUG_MAX_ENTRY <= g_wmi_event_buf_idx) \
  80. g_wmi_event_buf_idx = 0; \
  81. wmi_event_log_buffer[g_wmi_event_buf_idx].event = a; \
  82. cdf_mem_copy(wmi_event_log_buffer[g_wmi_event_buf_idx].data, b, 16); \
  83. wmi_event_log_buffer[g_wmi_event_buf_idx].time = \
  84. cdf_get_log_timestamp(); \
  85. g_wmi_event_buf_idx++; \
  86. }
  87. #define WMI_RX_EVENT_RECORD(a,b) { \
  88. if (WMI_EVENT_DEBUG_MAX_ENTRY <= g_wmi_rx_event_buf_idx) \
  89. g_wmi_rx_event_buf_idx = 0; \
  90. wmi_rx_event_log_buffer[g_wmi_rx_event_buf_idx].event = a; \
  91. cdf_mem_copy(wmi_rx_event_log_buffer[g_wmi_rx_event_buf_idx].data, b, 16); \
  92. wmi_rx_event_log_buffer[g_wmi_rx_event_buf_idx].time = \
  93. cdf_get_log_timestamp(); \
  94. g_wmi_rx_event_buf_idx++; \
  95. }
  96. /* wmi_mgmt commands */
  97. #define WMI_MGMT_EVENT_DEBUG_MAX_ENTRY (256)
  98. uint32_t g_wmi_mgmt_command_buf_idx = 0;
  99. struct
  100. wmi_command_debug wmi_mgmt_command_log_buffer[WMI_MGMT_EVENT_DEBUG_MAX_ENTRY];
  101. /* wmi_mgmt commands TX completed */
  102. uint32_t g_wmi_mgmt_command_tx_cmp_buf_idx = 0;
  103. struct wmi_command_debug
  104. wmi_mgmt_command_tx_cmp_log_buffer[WMI_MGMT_EVENT_DEBUG_MAX_ENTRY];
  105. /* wmi_mgmt events when processed */
  106. uint32_t g_wmi_mgmt_event_buf_idx = 0;
  107. struct wmi_event_debug
  108. wmi_mgmt_event_log_buffer[WMI_MGMT_EVENT_DEBUG_MAX_ENTRY];
  109. #define WMI_MGMT_COMMAND_RECORD(a, b) { \
  110. if (WMI_MGMT_EVENT_DEBUG_MAX_ENTRY <= \
  111. g_wmi_mgmt_command_buf_idx) \
  112. g_wmi_mgmt_command_buf_idx = 0; \
  113. wmi_mgmt_command_log_buffer[g_wmi_mgmt_command_buf_idx].command = a; \
  114. cdf_mem_copy( \
  115. wmi_mgmt_command_log_buffer[g_wmi_mgmt_command_buf_idx].data,\
  116. b, 16); \
  117. wmi_mgmt_command_log_buffer[g_wmi_mgmt_command_buf_idx].time = \
  118. cdf_get_log_timestamp(); \
  119. g_wmi_mgmt_command_buf_idx++; \
  120. }
  121. #define WMI_MGMT_COMMAND_TX_CMP_RECORD(a, b) { \
  122. if (WMI_MGMT_EVENT_DEBUG_MAX_ENTRY <= \
  123. g_wmi_mgmt_command_tx_cmp_buf_idx) \
  124. g_wmi_mgmt_command_tx_cmp_buf_idx = 0; \
  125. wmi_mgmt_command_tx_cmp_log_buffer[g_wmi_mgmt_command_tx_cmp_buf_idx].\
  126. command = a; \
  127. cdf_mem_copy(wmi_mgmt_command_tx_cmp_log_buffer \
  128. [g_wmi_mgmt_command_tx_cmp_buf_idx].data, b, 16); \
  129. wmi_mgmt_command_tx_cmp_log_buffer[g_wmi_mgmt_command_tx_cmp_buf_idx].\
  130. time =\
  131. cdf_get_log_timestamp(); \
  132. g_wmi_mgmt_command_tx_cmp_buf_idx++; \
  133. }
  134. #define WMI_MGMT_EVENT_RECORD(a, b) { \
  135. if (WMI_MGMT_EVENT_DEBUG_MAX_ENTRY <= g_wmi_mgmt_event_buf_idx) \
  136. g_wmi_mgmt_event_buf_idx = 0; \
  137. wmi_mgmt_event_log_buffer[g_wmi_mgmt_event_buf_idx].event = a; \
  138. cdf_mem_copy(wmi_mgmt_event_log_buffer[g_wmi_mgmt_event_buf_idx].data,\
  139. b, 16); \
  140. wmi_mgmt_event_log_buffer[g_wmi_mgmt_event_buf_idx].time = \
  141. cdf_get_log_timestamp(); \
  142. g_wmi_mgmt_event_buf_idx++; \
  143. }
  144. #endif /*WMI_INTERFACE_EVENT_LOGGING */
  145. static void __wmi_control_rx(struct wmi_unified *wmi_handle, wmi_buf_t evt_buf);
  146. int wmi_get_host_credits(wmi_unified_t wmi_handle);
  147. /* WMI buffer APIs */
  148. #ifdef MEMORY_DEBUG
  149. wmi_buf_t
  150. wmi_buf_alloc_debug(wmi_unified_t wmi_handle, uint16_t len, uint8_t *file_name,
  151. uint32_t line_num)
  152. {
  153. wmi_buf_t wmi_buf;
  154. if (roundup(len + WMI_MIN_HEAD_ROOM, 4) > wmi_handle->max_msg_len) {
  155. CDF_ASSERT(0);
  156. return NULL;
  157. }
  158. wmi_buf = cdf_nbuf_alloc_debug(NULL,
  159. roundup(len + WMI_MIN_HEAD_ROOM, 4),
  160. WMI_MIN_HEAD_ROOM, 4, false, file_name,
  161. line_num);
  162. if (!wmi_buf)
  163. return NULL;
  164. /* Clear the wmi buffer */
  165. OS_MEMZERO(cdf_nbuf_data(wmi_buf), len);
  166. /*
  167. * Set the length of the buffer to match the allocation size.
  168. */
  169. cdf_nbuf_set_pktlen(wmi_buf, len);
  170. return wmi_buf;
  171. }
  172. void wmi_buf_free(wmi_buf_t net_buf)
  173. {
  174. cdf_nbuf_free(net_buf);
  175. }
  176. #else
  177. wmi_buf_t wmi_buf_alloc(wmi_unified_t wmi_handle, uint16_t len)
  178. {
  179. wmi_buf_t wmi_buf;
  180. if (roundup(len + WMI_MIN_HEAD_ROOM, 4) > wmi_handle->max_msg_len) {
  181. CDF_ASSERT(0);
  182. return NULL;
  183. }
  184. wmi_buf = cdf_nbuf_alloc(NULL, roundup(len + WMI_MIN_HEAD_ROOM, 4),
  185. WMI_MIN_HEAD_ROOM, 4, false);
  186. if (!wmi_buf)
  187. return NULL;
  188. /* Clear the wmi buffer */
  189. OS_MEMZERO(cdf_nbuf_data(wmi_buf), len);
  190. /*
  191. * Set the length of the buffer to match the allocation size.
  192. */
  193. cdf_nbuf_set_pktlen(wmi_buf, len);
  194. return wmi_buf;
  195. }
  196. void wmi_buf_free(wmi_buf_t net_buf)
  197. {
  198. cdf_nbuf_free(net_buf);
  199. }
  200. #endif
  201. /**
  202. * wmi_get_max_msg_len() - get maximum WMI message length
  203. * @wmi_handle: WMI handle.
  204. *
  205. * This function returns the maximum WMI message length
  206. *
  207. * Return: maximum WMI message length
  208. */
  209. uint16_t wmi_get_max_msg_len(wmi_unified_t wmi_handle)
  210. {
  211. return wmi_handle->max_msg_len - WMI_MIN_HEAD_ROOM;
  212. }
  213. static uint8_t *get_wmi_cmd_string(WMI_CMD_ID wmi_command)
  214. {
  215. switch (wmi_command) {
  216. /** initialize the wlan sub system */
  217. CASE_RETURN_STRING(WMI_INIT_CMDID);
  218. /* Scan specific commands */
  219. /** start scan request to FW */
  220. CASE_RETURN_STRING(WMI_START_SCAN_CMDID);
  221. /** stop scan request to FW */
  222. CASE_RETURN_STRING(WMI_STOP_SCAN_CMDID);
  223. /** full list of channels as defined by the regulatory that will be used by scanner */
  224. CASE_RETURN_STRING(WMI_SCAN_CHAN_LIST_CMDID);
  225. /** overwrite default priority table in scan scheduler */
  226. CASE_RETURN_STRING(WMI_SCAN_SCH_PRIO_TBL_CMDID);
  227. /** This command to adjust the priority and min.max_rest_time
  228. * of an on ongoing scan request.
  229. */
  230. CASE_RETURN_STRING(WMI_SCAN_UPDATE_REQUEST_CMDID);
  231. /* PDEV(physical device) specific commands */
  232. /** set regulatorty ctl id used by FW to determine the exact ctl power limits */
  233. CASE_RETURN_STRING(WMI_PDEV_SET_REGDOMAIN_CMDID);
  234. /** set channel. mainly used for supporting monitor mode */
  235. CASE_RETURN_STRING(WMI_PDEV_SET_CHANNEL_CMDID);
  236. /** set pdev specific parameters */
  237. CASE_RETURN_STRING(WMI_PDEV_SET_PARAM_CMDID);
  238. /** enable packet log */
  239. CASE_RETURN_STRING(WMI_PDEV_PKTLOG_ENABLE_CMDID);
  240. /** disable packet log*/
  241. CASE_RETURN_STRING(WMI_PDEV_PKTLOG_DISABLE_CMDID);
  242. /** set wmm parameters */
  243. CASE_RETURN_STRING(WMI_PDEV_SET_WMM_PARAMS_CMDID);
  244. /** set HT cap ie that needs to be carried probe requests HT/VHT channels */
  245. CASE_RETURN_STRING(WMI_PDEV_SET_HT_CAP_IE_CMDID);
  246. /** set VHT cap ie that needs to be carried on probe requests on VHT channels */
  247. CASE_RETURN_STRING(WMI_PDEV_SET_VHT_CAP_IE_CMDID);
  248. /** Command to send the DSCP-to-TID map to the target */
  249. CASE_RETURN_STRING(WMI_PDEV_SET_DSCP_TID_MAP_CMDID);
  250. /** set quiet ie parameters. primarily used in AP mode */
  251. CASE_RETURN_STRING(WMI_PDEV_SET_QUIET_MODE_CMDID);
  252. /** Enable/Disable Green AP Power Save */
  253. CASE_RETURN_STRING(WMI_PDEV_GREEN_AP_PS_ENABLE_CMDID);
  254. /** get TPC config for the current operating channel */
  255. CASE_RETURN_STRING(WMI_PDEV_GET_TPC_CONFIG_CMDID);
  256. /** set the base MAC address for the physical device before a VDEV is created.
  257. * For firmware that doesn’t support this feature and this command, the pdev
  258. * MAC address will not be changed. */
  259. CASE_RETURN_STRING(WMI_PDEV_SET_BASE_MACADDR_CMDID);
  260. /* eeprom content dump , the same to bdboard data */
  261. CASE_RETURN_STRING(WMI_PDEV_DUMP_CMDID);
  262. /* VDEV(virtual device) specific commands */
  263. /** vdev create */
  264. CASE_RETURN_STRING(WMI_VDEV_CREATE_CMDID);
  265. /** vdev delete */
  266. CASE_RETURN_STRING(WMI_VDEV_DELETE_CMDID);
  267. /** vdev start request */
  268. CASE_RETURN_STRING(WMI_VDEV_START_REQUEST_CMDID);
  269. /** vdev restart request (RX only, NO TX, used for CAC period)*/
  270. CASE_RETURN_STRING(WMI_VDEV_RESTART_REQUEST_CMDID);
  271. /** vdev up request */
  272. CASE_RETURN_STRING(WMI_VDEV_UP_CMDID);
  273. /** vdev stop request */
  274. CASE_RETURN_STRING(WMI_VDEV_STOP_CMDID);
  275. /** vdev down request */
  276. CASE_RETURN_STRING(WMI_VDEV_DOWN_CMDID);
  277. /* set a vdev param */
  278. CASE_RETURN_STRING(WMI_VDEV_SET_PARAM_CMDID);
  279. /* set a key (used for setting per peer unicast and per vdev multicast) */
  280. CASE_RETURN_STRING(WMI_VDEV_INSTALL_KEY_CMDID);
  281. /* wnm sleep mode command */
  282. CASE_RETURN_STRING(WMI_VDEV_WNM_SLEEPMODE_CMDID);
  283. CASE_RETURN_STRING(WMI_VDEV_WMM_ADDTS_CMDID);
  284. CASE_RETURN_STRING(WMI_VDEV_WMM_DELTS_CMDID);
  285. CASE_RETURN_STRING(WMI_VDEV_SET_WMM_PARAMS_CMDID);
  286. CASE_RETURN_STRING(WMI_VDEV_SET_GTX_PARAMS_CMDID);
  287. CASE_RETURN_STRING(WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMDID);
  288. CASE_RETURN_STRING(WMI_VDEV_PLMREQ_START_CMDID);
  289. CASE_RETURN_STRING(WMI_VDEV_PLMREQ_STOP_CMDID);
  290. CASE_RETURN_STRING(WMI_VDEV_TSF_TSTAMP_ACTION_CMDID);
  291. CASE_RETURN_STRING(WMI_VDEV_SET_IE_CMDID);
  292. /* peer specific commands */
  293. /** create a peer */
  294. CASE_RETURN_STRING(WMI_PEER_CREATE_CMDID);
  295. /** delete a peer */
  296. CASE_RETURN_STRING(WMI_PEER_DELETE_CMDID);
  297. /** flush specific tid queues of a peer */
  298. CASE_RETURN_STRING(WMI_PEER_FLUSH_TIDS_CMDID);
  299. /** set a parameter of a peer */
  300. CASE_RETURN_STRING(WMI_PEER_SET_PARAM_CMDID);
  301. /** set peer to associated state. will cary all parameters determined during assocication time */
  302. CASE_RETURN_STRING(WMI_PEER_ASSOC_CMDID);
  303. /**add a wds (4 address ) entry. used only for testing WDS feature on AP products */
  304. CASE_RETURN_STRING(WMI_PEER_ADD_WDS_ENTRY_CMDID);
  305. /**remove wds (4 address ) entry. used only for testing WDS feature on AP products */
  306. CASE_RETURN_STRING(WMI_PEER_REMOVE_WDS_ENTRY_CMDID);
  307. /** set up mcast group infor for multicast to unicast conversion */
  308. CASE_RETURN_STRING(WMI_PEER_MCAST_GROUP_CMDID);
  309. /** request peer info from FW. FW shall respond with PEER_INFO_EVENTID */
  310. CASE_RETURN_STRING(WMI_PEER_INFO_REQ_CMDID);
  311. /* beacon/management specific commands */
  312. /** transmit beacon by reference . used for transmitting beacon on low latency interface like pcie */
  313. CASE_RETURN_STRING(WMI_BCN_TX_CMDID);
  314. /** transmit beacon by value */
  315. CASE_RETURN_STRING(WMI_PDEV_SEND_BCN_CMDID);
  316. /** set the beacon template. used in beacon offload mode to setup the
  317. * the common beacon template with the FW to be used by FW to generate beacons */
  318. CASE_RETURN_STRING(WMI_BCN_TMPL_CMDID);
  319. /** set beacon filter with FW */
  320. CASE_RETURN_STRING(WMI_BCN_FILTER_RX_CMDID);
  321. /* enable/disable filtering of probe requests in the firmware */
  322. CASE_RETURN_STRING(WMI_PRB_REQ_FILTER_RX_CMDID);
  323. /** transmit management frame by value. will be deprecated */
  324. CASE_RETURN_STRING(WMI_MGMT_TX_CMDID);
  325. /** set the probe response template. used in beacon offload mode to setup the
  326. * the common probe response template with the FW to be used by FW to generate
  327. * probe responses */
  328. CASE_RETURN_STRING(WMI_PRB_TMPL_CMDID);
  329. /** commands to directly control ba negotiation directly from host. only used in test mode */
  330. /** turn off FW Auto addba mode and let host control addba */
  331. CASE_RETURN_STRING(WMI_ADDBA_CLEAR_RESP_CMDID);
  332. /** send add ba request */
  333. CASE_RETURN_STRING(WMI_ADDBA_SEND_CMDID);
  334. CASE_RETURN_STRING(WMI_ADDBA_STATUS_CMDID);
  335. /** send del ba */
  336. CASE_RETURN_STRING(WMI_DELBA_SEND_CMDID);
  337. /** set add ba response will be used by FW to generate addba response*/
  338. CASE_RETURN_STRING(WMI_ADDBA_SET_RESP_CMDID);
  339. /** send single VHT MPDU with AMSDU */
  340. CASE_RETURN_STRING(WMI_SEND_SINGLEAMSDU_CMDID);
  341. /** Station power save specific config */
  342. /** enable/disable station powersave */
  343. CASE_RETURN_STRING(WMI_STA_POWERSAVE_MODE_CMDID);
  344. /** set station power save specific parameter */
  345. CASE_RETURN_STRING(WMI_STA_POWERSAVE_PARAM_CMDID);
  346. /** set station mimo powersave mode */
  347. CASE_RETURN_STRING(WMI_STA_MIMO_PS_MODE_CMDID);
  348. /** DFS-specific commands */
  349. /** enable DFS (radar detection)*/
  350. CASE_RETURN_STRING(WMI_PDEV_DFS_ENABLE_CMDID);
  351. /** disable DFS (radar detection)*/
  352. CASE_RETURN_STRING(WMI_PDEV_DFS_DISABLE_CMDID);
  353. /** enable DFS phyerr/parse filter offload */
  354. CASE_RETURN_STRING(WMI_DFS_PHYERR_FILTER_ENA_CMDID);
  355. /** enable DFS phyerr/parse filter offload */
  356. CASE_RETURN_STRING(WMI_DFS_PHYERR_FILTER_DIS_CMDID);
  357. /* Roaming specific commands */
  358. /** set roam scan mode */
  359. CASE_RETURN_STRING(WMI_ROAM_SCAN_MODE);
  360. /** set roam scan rssi threshold below which roam scan is enabled */
  361. CASE_RETURN_STRING(WMI_ROAM_SCAN_RSSI_THRESHOLD);
  362. /** set roam scan period for periodic roam scan mode */
  363. CASE_RETURN_STRING(WMI_ROAM_SCAN_PERIOD);
  364. /** set roam scan trigger rssi change threshold */
  365. CASE_RETURN_STRING(WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD);
  366. /** set roam AP profile */
  367. CASE_RETURN_STRING(WMI_ROAM_AP_PROFILE);
  368. /** set channel list for roam scans */
  369. CASE_RETURN_STRING(WMI_ROAM_CHAN_LIST);
  370. /** offload scan specific commands */
  371. /** set offload scan AP profile */
  372. CASE_RETURN_STRING(WMI_OFL_SCAN_ADD_AP_PROFILE);
  373. /** remove offload scan AP profile */
  374. CASE_RETURN_STRING(WMI_OFL_SCAN_REMOVE_AP_PROFILE);
  375. /** set offload scan period */
  376. CASE_RETURN_STRING(WMI_OFL_SCAN_PERIOD);
  377. /* P2P specific commands */
  378. /**set P2P device info. FW will used by FW to create P2P IE to be carried in probe response
  379. * generated during p2p listen and for p2p discoverability */
  380. CASE_RETURN_STRING(WMI_P2P_DEV_SET_DEVICE_INFO);
  381. /** enable/disable p2p discoverability on STA/AP VDEVs */
  382. CASE_RETURN_STRING(WMI_P2P_DEV_SET_DISCOVERABILITY);
  383. /** set p2p ie to be carried in beacons generated by FW for GO */
  384. CASE_RETURN_STRING(WMI_P2P_GO_SET_BEACON_IE);
  385. /** set p2p ie to be carried in probe response frames generated by FW for GO */
  386. CASE_RETURN_STRING(WMI_P2P_GO_SET_PROBE_RESP_IE);
  387. /** set the vendor specific p2p ie data. FW will use this to parse the P2P NoA
  388. * attribute in the beacons/probe responses received.
  389. */
  390. CASE_RETURN_STRING(WMI_P2P_SET_VENDOR_IE_DATA_CMDID);
  391. /** set the configure of p2p find offload */
  392. CASE_RETURN_STRING(WMI_P2P_DISC_OFFLOAD_CONFIG_CMDID);
  393. /** set the vendor specific p2p ie data for p2p find offload using */
  394. CASE_RETURN_STRING(WMI_P2P_DISC_OFFLOAD_APPIE_CMDID);
  395. /** set the BSSID/device name pattern of p2p find offload */
  396. CASE_RETURN_STRING(WMI_P2P_DISC_OFFLOAD_PATTERN_CMDID);
  397. /** set OppPS related parameters **/
  398. CASE_RETURN_STRING(WMI_P2P_SET_OPPPS_PARAM_CMDID);
  399. /** AP power save specific config */
  400. /** set AP power save specific param */
  401. CASE_RETURN_STRING(WMI_AP_PS_PEER_PARAM_CMDID);
  402. /** set AP UAPSD coex pecific param */
  403. CASE_RETURN_STRING(WMI_AP_PS_PEER_UAPSD_COEX_CMDID);
  404. /** Rate-control specific commands */
  405. CASE_RETURN_STRING(WMI_PEER_RATE_RETRY_SCHED_CMDID);
  406. /** WLAN Profiling commands. */
  407. CASE_RETURN_STRING(WMI_WLAN_PROFILE_TRIGGER_CMDID);
  408. CASE_RETURN_STRING(WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID);
  409. CASE_RETURN_STRING(WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID);
  410. CASE_RETURN_STRING(WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID);
  411. CASE_RETURN_STRING(WMI_WLAN_PROFILE_LIST_PROFILE_ID_CMDID);
  412. /** Suspend resume command Ids */
  413. CASE_RETURN_STRING(WMI_PDEV_SUSPEND_CMDID);
  414. CASE_RETURN_STRING(WMI_PDEV_RESUME_CMDID);
  415. /* Beacon filter commands */
  416. /** add a beacon filter */
  417. CASE_RETURN_STRING(WMI_ADD_BCN_FILTER_CMDID);
  418. /** remove a beacon filter */
  419. CASE_RETURN_STRING(WMI_RMV_BCN_FILTER_CMDID);
  420. /* WOW Specific WMI commands */
  421. /** add pattern for awake */
  422. CASE_RETURN_STRING(WMI_WOW_ADD_WAKE_PATTERN_CMDID);
  423. /** deleta a wake pattern */
  424. CASE_RETURN_STRING(WMI_WOW_DEL_WAKE_PATTERN_CMDID);
  425. /** enable/deisable wake event */
  426. CASE_RETURN_STRING(WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID);
  427. /** enable WOW */
  428. CASE_RETURN_STRING(WMI_WOW_ENABLE_CMDID);
  429. /** host woke up from sleep event to FW. Generated in response to WOW Hardware event */
  430. CASE_RETURN_STRING(WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID);
  431. /* RTT measurement related cmd */
  432. /** reques to make an RTT measurement */
  433. CASE_RETURN_STRING(WMI_RTT_MEASREQ_CMDID);
  434. /** reques to report a tsf measurement */
  435. CASE_RETURN_STRING(WMI_RTT_TSF_CMDID);
  436. /** spectral scan command */
  437. /** configure spectral scan */
  438. CASE_RETURN_STRING(WMI_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID);
  439. /** enable/disable spectral scan and trigger */
  440. CASE_RETURN_STRING(WMI_VDEV_SPECTRAL_SCAN_ENABLE_CMDID);
  441. /* F/W stats */
  442. /** one time request for stats */
  443. CASE_RETURN_STRING(WMI_REQUEST_STATS_CMDID);
  444. /** Push MCC Adaptive Scheduler Stats to Firmware */
  445. CASE_RETURN_STRING(WMI_MCC_SCHED_TRAFFIC_STATS_CMDID);
  446. /** ARP OFFLOAD REQUEST*/
  447. CASE_RETURN_STRING(WMI_SET_ARP_NS_OFFLOAD_CMDID);
  448. /** Proactive ARP Response Add Pattern Command*/
  449. CASE_RETURN_STRING(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMDID);
  450. /** Proactive ARP Response Del Pattern Command*/
  451. CASE_RETURN_STRING(WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMDID);
  452. /** NS offload confid*/
  453. CASE_RETURN_STRING(WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
  454. /* GTK offload Specific WMI commands */
  455. CASE_RETURN_STRING(WMI_GTK_OFFLOAD_CMDID);
  456. /* CSA offload Specific WMI commands */
  457. /** csa offload enable */
  458. CASE_RETURN_STRING(WMI_CSA_OFFLOAD_ENABLE_CMDID);
  459. /** chan switch command */
  460. CASE_RETURN_STRING(WMI_CSA_OFFLOAD_CHANSWITCH_CMDID);
  461. /* Chatter commands */
  462. /* Change chatter mode of operation */
  463. CASE_RETURN_STRING(WMI_CHATTER_SET_MODE_CMDID);
  464. /** chatter add coalescing filter command */
  465. CASE_RETURN_STRING(WMI_CHATTER_ADD_COALESCING_FILTER_CMDID);
  466. /** chatter delete coalescing filter command */
  467. CASE_RETURN_STRING(WMI_CHATTER_DELETE_COALESCING_FILTER_CMDID);
  468. /** chatter coalecing query command */
  469. CASE_RETURN_STRING(WMI_CHATTER_COALESCING_QUERY_CMDID);
  470. /**addba specific commands */
  471. /** start the aggregation on this TID */
  472. CASE_RETURN_STRING(WMI_PEER_TID_ADDBA_CMDID);
  473. /** stop the aggregation on this TID */
  474. CASE_RETURN_STRING(WMI_PEER_TID_DELBA_CMDID);
  475. /** set station mimo powersave method */
  476. CASE_RETURN_STRING(WMI_STA_DTIM_PS_METHOD_CMDID);
  477. /** Configure the Station UAPSD AC Auto Trigger Parameters */
  478. CASE_RETURN_STRING(WMI_STA_UAPSD_AUTO_TRIG_CMDID);
  479. /** Configure the Keep Alive Parameters */
  480. CASE_RETURN_STRING(WMI_STA_KEEPALIVE_CMDID);
  481. /* Request ssn from target for a sta/tid pair */
  482. CASE_RETURN_STRING(WMI_BA_REQ_SSN_CMDID);
  483. /* misc command group */
  484. /** echo command mainly used for testing */
  485. CASE_RETURN_STRING(WMI_ECHO_CMDID);
  486. /* !!IMPORTANT!!
  487. * If you need to add a new WMI command to the CASE_RETURN_STRING(WMI_GRP_MISC sub-group,
  488. * please make sure you add it BEHIND CASE_RETURN_STRING(WMI_PDEV_UTF_CMDID);
  489. * as we MUST have a fixed value here to maintain compatibility between
  490. * UTF and the ART2 driver
  491. */
  492. /** UTF WMI commands */
  493. CASE_RETURN_STRING(WMI_PDEV_UTF_CMDID);
  494. /** set debug log config */
  495. CASE_RETURN_STRING(WMI_DBGLOG_CFG_CMDID);
  496. /* QVIT specific command id */
  497. CASE_RETURN_STRING(WMI_PDEV_QVIT_CMDID);
  498. /* Factory Testing Mode request command
  499. * used for integrated chipsets */
  500. CASE_RETURN_STRING(WMI_PDEV_FTM_INTG_CMDID);
  501. /* set and get keepalive parameters command */
  502. CASE_RETURN_STRING(WMI_VDEV_SET_KEEPALIVE_CMDID);
  503. CASE_RETURN_STRING(WMI_VDEV_GET_KEEPALIVE_CMDID);
  504. /* For fw recovery test command */
  505. CASE_RETURN_STRING(WMI_FORCE_FW_HANG_CMDID);
  506. /* Set Mcast/Bdcast filter */
  507. CASE_RETURN_STRING(WMI_SET_MCASTBCAST_FILTER_CMDID);
  508. /** set thermal management params **/
  509. CASE_RETURN_STRING(WMI_THERMAL_MGMT_CMDID);
  510. CASE_RETURN_STRING(WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID);
  511. CASE_RETURN_STRING(WMI_LRO_CONFIG_CMDID);
  512. CASE_RETURN_STRING(WMI_TRANSFER_DATA_TO_FLASH_CMDID);
  513. CASE_RETURN_STRING(WMI_MAWC_SENSOR_REPORT_IND_CMDID);
  514. CASE_RETURN_STRING(WMI_ROAM_CONFIGURE_MAWC_CMDID);
  515. CASE_RETURN_STRING(WMI_NLO_CONFIGURE_MAWC_CMDID);
  516. CASE_RETURN_STRING(WMI_EXTSCAN_CONFIGURE_MAWC_CMDID);
  517. /* GPIO Configuration */
  518. CASE_RETURN_STRING(WMI_GPIO_CONFIG_CMDID);
  519. CASE_RETURN_STRING(WMI_GPIO_OUTPUT_CMDID);
  520. /* Txbf configuration command */
  521. CASE_RETURN_STRING(WMI_TXBF_CMDID);
  522. /* FWTEST Commands */
  523. CASE_RETURN_STRING(WMI_FWTEST_VDEV_MCC_SET_TBTT_MODE_CMDID);
  524. /** set NoA descs **/
  525. CASE_RETURN_STRING(WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID);
  526. /** TDLS Configuration */
  527. /** enable/disable TDLS */
  528. CASE_RETURN_STRING(WMI_TDLS_SET_STATE_CMDID);
  529. /** set tdls peer state */
  530. CASE_RETURN_STRING(WMI_TDLS_PEER_UPDATE_CMDID);
  531. /** Resmgr Configuration */
  532. /** Adaptive OCS is enabled by default in the FW. This command is used to
  533. * disable FW based adaptive OCS.
  534. */
  535. CASE_RETURN_STRING
  536. (WMI_RESMGR_ADAPTIVE_OCS_ENABLE_DISABLE_CMDID);
  537. /** set the requested channel time quota for the home channels */
  538. CASE_RETURN_STRING(WMI_RESMGR_SET_CHAN_TIME_QUOTA_CMDID);
  539. /** set the requested latency for the home channels */
  540. CASE_RETURN_STRING(WMI_RESMGR_SET_CHAN_LATENCY_CMDID);
  541. /** STA SMPS Configuration */
  542. /** force SMPS mode */
  543. CASE_RETURN_STRING(WMI_STA_SMPS_FORCE_MODE_CMDID);
  544. /** set SMPS parameters */
  545. CASE_RETURN_STRING(WMI_STA_SMPS_PARAM_CMDID);
  546. /* Wlan HB commands */
  547. /* enalbe/disable wlan HB */
  548. CASE_RETURN_STRING(WMI_HB_SET_ENABLE_CMDID);
  549. /* set tcp parameters for wlan HB */
  550. CASE_RETURN_STRING(WMI_HB_SET_TCP_PARAMS_CMDID);
  551. /* set tcp pkt filter for wlan HB */
  552. CASE_RETURN_STRING(WMI_HB_SET_TCP_PKT_FILTER_CMDID);
  553. /* set udp parameters for wlan HB */
  554. CASE_RETURN_STRING(WMI_HB_SET_UDP_PARAMS_CMDID);
  555. /* set udp pkt filter for wlan HB */
  556. CASE_RETURN_STRING(WMI_HB_SET_UDP_PKT_FILTER_CMDID);
  557. /** Wlan RMC commands*/
  558. /** enable/disable RMC */
  559. CASE_RETURN_STRING(WMI_RMC_SET_MODE_CMDID);
  560. /** configure action frame period */
  561. CASE_RETURN_STRING(WMI_RMC_SET_ACTION_PERIOD_CMDID);
  562. /** For debug/future enhancement purposes only,
  563. * configures/finetunes RMC algorithms */
  564. CASE_RETURN_STRING(WMI_RMC_CONFIG_CMDID);
  565. /** WLAN MHF offload commands */
  566. /** enable/disable MHF offload */
  567. CASE_RETURN_STRING(WMI_MHF_OFFLOAD_SET_MODE_CMDID);
  568. /** Plumb routing table for MHF offload */
  569. CASE_RETURN_STRING(WMI_MHF_OFFLOAD_PLUMB_ROUTING_TBL_CMDID);
  570. /*location scan commands */
  571. /*start batch scan */
  572. CASE_RETURN_STRING(WMI_BATCH_SCAN_ENABLE_CMDID);
  573. /*stop batch scan */
  574. CASE_RETURN_STRING(WMI_BATCH_SCAN_DISABLE_CMDID);
  575. /*get batch scan result */
  576. CASE_RETURN_STRING(WMI_BATCH_SCAN_TRIGGER_RESULT_CMDID);
  577. /* OEM related cmd */
  578. CASE_RETURN_STRING(WMI_OEM_REQ_CMDID);
  579. CASE_RETURN_STRING(WMI_OEM_REQUEST_CMDID);
  580. /* NAN request cmd */
  581. CASE_RETURN_STRING(WMI_NAN_CMDID);
  582. /* Modem power state cmd */
  583. CASE_RETURN_STRING(WMI_MODEM_POWER_STATE_CMDID);
  584. CASE_RETURN_STRING(WMI_REQUEST_STATS_EXT_CMDID);
  585. CASE_RETURN_STRING(WMI_OBSS_SCAN_ENABLE_CMDID);
  586. CASE_RETURN_STRING(WMI_OBSS_SCAN_DISABLE_CMDID);
  587. CASE_RETURN_STRING(WMI_PEER_GET_ESTIMATED_LINKSPEED_CMDID);
  588. CASE_RETURN_STRING(WMI_ROAM_SCAN_CMD);
  589. CASE_RETURN_STRING(WMI_PDEV_SET_LED_CONFIG_CMDID);
  590. CASE_RETURN_STRING(WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID);
  591. CASE_RETURN_STRING(WMI_CHAN_AVOID_UPDATE_CMDID);
  592. CASE_RETURN_STRING(WMI_WOW_IOAC_ADD_KEEPALIVE_CMDID);
  593. CASE_RETURN_STRING(WMI_WOW_IOAC_DEL_KEEPALIVE_CMDID);
  594. CASE_RETURN_STRING(WMI_WOW_IOAC_ADD_WAKE_PATTERN_CMDID);
  595. CASE_RETURN_STRING(WMI_WOW_IOAC_DEL_WAKE_PATTERN_CMDID);
  596. CASE_RETURN_STRING(WMI_REQUEST_LINK_STATS_CMDID);
  597. CASE_RETURN_STRING(WMI_START_LINK_STATS_CMDID);
  598. CASE_RETURN_STRING(WMI_CLEAR_LINK_STATS_CMDID);
  599. CASE_RETURN_STRING(WMI_GET_FW_MEM_DUMP_CMDID);
  600. CASE_RETURN_STRING(WMI_LPI_MGMT_SNOOPING_CONFIG_CMDID);
  601. CASE_RETURN_STRING(WMI_LPI_START_SCAN_CMDID);
  602. CASE_RETURN_STRING(WMI_LPI_STOP_SCAN_CMDID);
  603. CASE_RETURN_STRING(WMI_EXTSCAN_START_CMDID);
  604. CASE_RETURN_STRING(WMI_EXTSCAN_STOP_CMDID);
  605. CASE_RETURN_STRING
  606. (WMI_EXTSCAN_CONFIGURE_WLAN_CHANGE_MONITOR_CMDID);
  607. CASE_RETURN_STRING(WMI_EXTSCAN_CONFIGURE_HOTLIST_MONITOR_CMDID);
  608. CASE_RETURN_STRING(WMI_EXTSCAN_GET_CACHED_RESULTS_CMDID);
  609. CASE_RETURN_STRING(WMI_EXTSCAN_GET_WLAN_CHANGE_RESULTS_CMDID);
  610. CASE_RETURN_STRING(WMI_EXTSCAN_SET_CAPABILITIES_CMDID);
  611. CASE_RETURN_STRING(WMI_EXTSCAN_GET_CAPABILITIES_CMDID);
  612. CASE_RETURN_STRING(WMI_EXTSCAN_CONFIGURE_HOTLIST_SSID_MONITOR_CMDID);
  613. CASE_RETURN_STRING(WMI_ROAM_SYNCH_COMPLETE);
  614. CASE_RETURN_STRING(WMI_D0_WOW_ENABLE_DISABLE_CMDID);
  615. CASE_RETURN_STRING(WMI_EXTWOW_ENABLE_CMDID);
  616. CASE_RETURN_STRING(WMI_EXTWOW_SET_APP_TYPE1_PARAMS_CMDID);
  617. CASE_RETURN_STRING(WMI_EXTWOW_SET_APP_TYPE2_PARAMS_CMDID);
  618. CASE_RETURN_STRING(WMI_UNIT_TEST_CMDID);
  619. CASE_RETURN_STRING(WMI_ROAM_SET_RIC_REQUEST_CMDID);
  620. CASE_RETURN_STRING(WMI_PDEV_GET_TEMPERATURE_CMDID);
  621. CASE_RETURN_STRING(WMI_SET_DHCP_SERVER_OFFLOAD_CMDID);
  622. CASE_RETURN_STRING(WMI_TPC_CHAINMASK_CONFIG_CMDID);
  623. CASE_RETURN_STRING(WMI_IPA_OFFLOAD_ENABLE_DISABLE_CMDID);
  624. CASE_RETURN_STRING(WMI_SCAN_PROB_REQ_OUI_CMDID);
  625. CASE_RETURN_STRING(WMI_TDLS_SET_OFFCHAN_MODE_CMDID);
  626. CASE_RETURN_STRING(WMI_PDEV_SET_LED_FLASHING_CMDID);
  627. CASE_RETURN_STRING(WMI_MDNS_OFFLOAD_ENABLE_CMDID);
  628. CASE_RETURN_STRING(WMI_MDNS_SET_FQDN_CMDID);
  629. CASE_RETURN_STRING(WMI_MDNS_SET_RESPONSE_CMDID);
  630. CASE_RETURN_STRING(WMI_MDNS_GET_STATS_CMDID);
  631. CASE_RETURN_STRING(WMI_ROAM_INVOKE_CMDID);
  632. CASE_RETURN_STRING(WMI_SET_ANTENNA_DIVERSITY_CMDID);
  633. CASE_RETURN_STRING(WMI_SAP_OFL_ENABLE_CMDID);
  634. CASE_RETURN_STRING(WMI_APFIND_CMDID);
  635. CASE_RETURN_STRING(WMI_PASSPOINT_LIST_CONFIG_CMDID);
  636. CASE_RETURN_STRING(WMI_OCB_SET_SCHED_CMDID);
  637. CASE_RETURN_STRING(WMI_OCB_SET_CONFIG_CMDID);
  638. CASE_RETURN_STRING(WMI_OCB_SET_UTC_TIME_CMDID);
  639. CASE_RETURN_STRING(WMI_OCB_START_TIMING_ADVERT_CMDID);
  640. CASE_RETURN_STRING(WMI_OCB_STOP_TIMING_ADVERT_CMDID);
  641. CASE_RETURN_STRING(WMI_OCB_GET_TSF_TIMER_CMDID);
  642. CASE_RETURN_STRING(WMI_DCC_GET_STATS_CMDID);
  643. CASE_RETURN_STRING(WMI_DCC_CLEAR_STATS_CMDID);
  644. CASE_RETURN_STRING(WMI_DCC_UPDATE_NDL_CMDID);
  645. CASE_RETURN_STRING(WMI_ROAM_FILTER_CMDID);
  646. CASE_RETURN_STRING(WMI_ROAM_SUBNET_CHANGE_CONFIG_CMDID);
  647. CASE_RETURN_STRING(WMI_DEBUG_MESG_FLUSH_CMDID);
  648. CASE_RETURN_STRING(WMI_PEER_SET_RATE_REPORT_CONDITION_CMDID);
  649. CASE_RETURN_STRING(WMI_SOC_SET_PCL_CMDID);
  650. CASE_RETURN_STRING(WMI_SOC_SET_HW_MODE_CMDID);
  651. CASE_RETURN_STRING(WMI_SOC_SET_DUAL_MAC_CONFIG_CMDID);
  652. CASE_RETURN_STRING(WMI_WOW_ENABLE_ICMPV6_NA_FLT_CMDID);
  653. CASE_RETURN_STRING(WMI_DIAG_EVENT_LOG_CONFIG_CMDID);
  654. CASE_RETURN_STRING(WMI_PACKET_FILTER_CONFIG_CMDID);
  655. CASE_RETURN_STRING(WMI_PACKET_FILTER_ENABLE_CMDID);
  656. CASE_RETURN_STRING(WMI_SAP_SET_BLACKLIST_PARAM_CMDID);
  657. CASE_RETURN_STRING(WMI_WOW_UDP_SVC_OFLD_CMDID);
  658. CASE_RETURN_STRING(WMI_MGMT_TX_SEND_CMDID);
  659. CASE_RETURN_STRING(WMI_SOC_SET_ANTENNA_MODE_CMDID);
  660. CASE_RETURN_STRING(WMI_WOW_HOSTWAKEUP_GPIO_PIN_PATTERN_CONFIG_CMDID);
  661. CASE_RETURN_STRING(WMI_AP_PS_EGAP_PARAM_CMDID);
  662. CASE_RETURN_STRING(WMI_PMF_OFFLOAD_SET_SA_QUERY_CMDID);
  663. CASE_RETURN_STRING(WMI_BPF_GET_CAPABILITY_CMDID);
  664. CASE_RETURN_STRING(WMI_BPF_GET_VDEV_STATS_CMDID);
  665. CASE_RETURN_STRING(WMI_BPF_SET_VDEV_INSTRUCTIONS_CMDID);
  666. CASE_RETURN_STRING(WMI_BPF_DEL_VDEV_INSTRUCTIONS_CMDID);
  667. }
  668. return "Invalid WMI cmd";
  669. }
  670. #ifdef QCA_WIFI_3_0_EMU
  671. static inline void wma_log_cmd_id(WMI_CMD_ID cmd_id)
  672. {
  673. WMA_LOGE("Send WMI command:%s command_id:%d",
  674. get_wmi_cmd_string(cmd_id), cmd_id);
  675. }
  676. #else
  677. static inline void wma_log_cmd_id(WMI_CMD_ID cmd_id)
  678. {
  679. WMA_LOGD("Send WMI command:%s command_id:%d",
  680. get_wmi_cmd_string(cmd_id), cmd_id);
  681. }
  682. #endif
  683. /**
  684. * wmi_is_runtime_pm_cmd() - check if a cmd is part of the suspend resume sequence
  685. * @cmd: command to check
  686. *
  687. * Return: true if the command is part of the suspend resume sequence.
  688. */
  689. bool wmi_is_runtime_pm_cmd(WMI_CMD_ID cmd_id)
  690. {
  691. switch (cmd_id) {
  692. case WMI_WOW_ENABLE_CMDID:
  693. case WMI_PDEV_SUSPEND_CMDID:
  694. case WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID:
  695. case WMI_WOW_ADD_WAKE_PATTERN_CMDID:
  696. case WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID:
  697. case WMI_PDEV_RESUME_CMDID:
  698. case WMI_WOW_DEL_WAKE_PATTERN_CMDID:
  699. case WMI_D0_WOW_ENABLE_DISABLE_CMDID:
  700. return true;
  701. default:
  702. return false;
  703. }
  704. }
  705. /* WMI command API */
  706. int wmi_unified_cmd_send(wmi_unified_t wmi_handle, wmi_buf_t buf, int len,
  707. WMI_CMD_ID cmd_id)
  708. {
  709. HTC_PACKET *pkt;
  710. A_STATUS status;
  711. struct ol_softc *scn;
  712. uint16_t htc_tag = 0;
  713. if (wmi_get_runtime_pm_inprogress(wmi_handle)) {
  714. if (wmi_is_runtime_pm_cmd(cmd_id))
  715. htc_tag = HTC_TX_PACKET_TAG_AUTO_PM;
  716. } else if (cdf_atomic_read(&wmi_handle->is_target_suspended) &&
  717. ((WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID != cmd_id) &&
  718. (WMI_PDEV_RESUME_CMDID != cmd_id))) {
  719. pr_err("%s: Target is suspended could not send WMI command\n",
  720. __func__);
  721. CDF_ASSERT(0);
  722. return -EBUSY;
  723. }
  724. /* Do sanity check on the TLV parameter structure */
  725. {
  726. void *buf_ptr = (void *)cdf_nbuf_data(buf);
  727. if (wmitlv_check_command_tlv_params(NULL, buf_ptr, len, cmd_id)
  728. != 0) {
  729. cdf_print
  730. ("\nERROR: %s: Invalid WMI Parameter Buffer for Cmd:%d\n",
  731. __func__, cmd_id);
  732. return -1;
  733. }
  734. }
  735. if (cdf_nbuf_push_head(buf, sizeof(WMI_CMD_HDR)) == NULL) {
  736. pr_err("%s, Failed to send cmd %x, no memory\n",
  737. __func__, cmd_id);
  738. return -ENOMEM;
  739. }
  740. WMI_SET_FIELD(cdf_nbuf_data(buf), WMI_CMD_HDR, COMMANDID, cmd_id);
  741. cdf_atomic_inc(&wmi_handle->pending_cmds);
  742. if (cdf_atomic_read(&wmi_handle->pending_cmds) >= WMI_MAX_CMDS) {
  743. scn = cds_get_context(CDF_MODULE_ID_HIF);
  744. pr_err("\n%s: hostcredits = %d\n", __func__,
  745. wmi_get_host_credits(wmi_handle));
  746. htc_dump_counter_info(wmi_handle->htc_handle);
  747. /* dump_ce_register(scn); */
  748. /* dump_ce_debug_register(scn->hif_sc); */
  749. cdf_atomic_dec(&wmi_handle->pending_cmds);
  750. pr_err("%s: MAX 1024 WMI Pending cmds reached.\n", __func__);
  751. CDF_BUG(0);
  752. return -EBUSY;
  753. }
  754. pkt = cdf_mem_malloc(sizeof(*pkt));
  755. if (!pkt) {
  756. cdf_atomic_dec(&wmi_handle->pending_cmds);
  757. pr_err("%s, Failed to alloc htc packet %x, no memory\n",
  758. __func__, cmd_id);
  759. return -ENOMEM;
  760. }
  761. SET_HTC_PACKET_INFO_TX(pkt,
  762. NULL,
  763. cdf_nbuf_data(buf), len + sizeof(WMI_CMD_HDR),
  764. /* htt_host_data_dl_len(buf)+20 */
  765. wmi_handle->wmi_endpoint_id, htc_tag);
  766. SET_HTC_PACKET_NET_BUF_CONTEXT(pkt, buf);
  767. wma_log_cmd_id(cmd_id);
  768. #ifdef WMI_INTERFACE_EVENT_LOGGING
  769. cdf_spin_lock_bh(&wmi_handle->wmi_record_lock);
  770. /*Record 16 bytes of WMI cmd data - exclude TLV and WMI headers */
  771. if (cmd_id == WMI_MGMT_TX_SEND_CMDID) {
  772. WMI_MGMT_COMMAND_RECORD(cmd_id,
  773. ((uint32_t *)cdf_nbuf_data(buf) + 2));
  774. } else {
  775. WMI_COMMAND_RECORD(cmd_id, ((uint32_t *) cdf_nbuf_data(buf) +
  776. 2));
  777. }
  778. cdf_spin_unlock_bh(&wmi_handle->wmi_record_lock);
  779. #endif
  780. status = htc_send_pkt(wmi_handle->htc_handle, pkt);
  781. if (A_OK != status) {
  782. cdf_atomic_dec(&wmi_handle->pending_cmds);
  783. pr_err("%s %d, htc_send_pkt failed\n", __func__, __LINE__);
  784. }
  785. return ((status == A_OK) ? EOK : -1);
  786. }
  787. /* WMI Event handler register API */
  788. int wmi_unified_get_event_handler_ix(wmi_unified_t wmi_handle,
  789. WMI_EVT_ID event_id)
  790. {
  791. uint32_t idx = 0;
  792. for (idx = 0; (idx < wmi_handle->max_event_idx &&
  793. idx < WMI_UNIFIED_MAX_EVENT); ++idx) {
  794. if (wmi_handle->event_id[idx] == event_id &&
  795. wmi_handle->event_handler[idx] != NULL) {
  796. return idx;
  797. }
  798. }
  799. return -1;
  800. }
  801. int wmi_unified_register_event_handler(wmi_unified_t wmi_handle,
  802. WMI_EVT_ID event_id,
  803. wmi_unified_event_handler handler_func)
  804. {
  805. uint32_t idx = 0;
  806. if (wmi_unified_get_event_handler_ix(wmi_handle, event_id) != -1) {
  807. printk("%s : event handler already registered 0x%x \n",
  808. __func__, event_id);
  809. return -1;
  810. }
  811. if (wmi_handle->max_event_idx == WMI_UNIFIED_MAX_EVENT) {
  812. printk("%s : no more event handlers 0x%x \n",
  813. __func__, event_id);
  814. return -1;
  815. }
  816. idx = wmi_handle->max_event_idx;
  817. wmi_handle->event_handler[idx] = handler_func;
  818. wmi_handle->event_id[idx] = event_id;
  819. wmi_handle->max_event_idx++;
  820. return 0;
  821. }
  822. int wmi_unified_unregister_event_handler(wmi_unified_t wmi_handle,
  823. WMI_EVT_ID event_id)
  824. {
  825. uint32_t idx = 0;
  826. if ((idx =
  827. wmi_unified_get_event_handler_ix(wmi_handle, event_id)) == -1) {
  828. printk("%s : event handler is not registered: event id 0x%x \n",
  829. __func__, event_id);
  830. return -1;
  831. }
  832. wmi_handle->event_handler[idx] = NULL;
  833. wmi_handle->event_id[idx] = 0;
  834. --wmi_handle->max_event_idx;
  835. wmi_handle->event_handler[idx] =
  836. wmi_handle->event_handler[wmi_handle->max_event_idx];
  837. wmi_handle->event_id[idx] =
  838. wmi_handle->event_id[wmi_handle->max_event_idx];
  839. return 0;
  840. }
  841. #if 0 /* currently not used */
  842. static int wmi_unified_event_rx(struct wmi_unified *wmi_handle,
  843. wmi_buf_t evt_buf)
  844. {
  845. uint32_t id;
  846. uint8_t *event;
  847. uint16_t len;
  848. int status = -1;
  849. uint32_t idx = 0;
  850. ASSERT(evt_buf != NULL);
  851. id = WMI_GET_FIELD(cdf_nbuf_data(evt_buf), WMI_CMD_HDR, COMMANDID);
  852. if (cdf_nbuf_pull_head(evt_buf, sizeof(WMI_CMD_HDR)) == NULL)
  853. goto end;
  854. idx = wmi_unified_get_event_handler_ix(wmi_handle, id);
  855. if (idx == -1) {
  856. pr_err("%s : event handler is not registered: event id: 0x%x\n",
  857. __func__, id);
  858. goto end;
  859. }
  860. event = cdf_nbuf_data(evt_buf);
  861. len = cdf_nbuf_len(evt_buf);
  862. /* Call the WMI registered event handler */
  863. status = wmi_handle->event_handler[idx] (wmi_handle->scn_handle,
  864. event, len);
  865. end:
  866. cdf_nbuf_free(evt_buf);
  867. return status;
  868. }
  869. #endif /* 0 */
  870. /*
  871. * Event process by below function will be in tasket context.
  872. * Please use this method only for time sensitive functions.
  873. */
  874. static void wmi_process_fw_event_tasklet_ctx(struct wmi_unified *wmi_handle,
  875. HTC_PACKET *htc_packet)
  876. {
  877. wmi_buf_t evt_buf;
  878. evt_buf = (wmi_buf_t) htc_packet->pPktContext;
  879. __wmi_control_rx(wmi_handle, evt_buf);
  880. return;
  881. }
  882. /*
  883. * Event process by below function will be in mc_thread context.
  884. * By default all event will be executed in mc_thread context.
  885. * Use this method for all events which are processed by protocol stack.
  886. * This method will reduce context switching and race conditions.
  887. */
  888. static void wmi_process_fw_event_mc_thread_ctx(struct wmi_unified *wmi_handle,
  889. HTC_PACKET *htc_packet)
  890. {
  891. wmi_buf_t evt_buf;
  892. evt_buf = (wmi_buf_t) htc_packet->pPktContext;
  893. wmi_handle->wma_process_fw_event_handler_cbk(wmi_handle, evt_buf);
  894. return;
  895. }
  896. /*
  897. * Event process by below function will be in worker thread context.
  898. * Use this method for events which are not critical and not
  899. * handled in protocol stack.
  900. */
  901. static void wmi_process_fw_event_worker_thread_ctx
  902. (struct wmi_unified *wmi_handle, HTC_PACKET *htc_packet)
  903. {
  904. wmi_buf_t evt_buf;
  905. uint32_t id;
  906. uint8_t *data;
  907. evt_buf = (wmi_buf_t) htc_packet->pPktContext;
  908. id = WMI_GET_FIELD(cdf_nbuf_data(evt_buf), WMI_CMD_HDR, COMMANDID);
  909. data = cdf_nbuf_data(evt_buf);
  910. cdf_spin_lock_bh(&wmi_handle->wmi_record_lock);
  911. /* Exclude 4 bytes of TLV header */
  912. WMI_RX_EVENT_RECORD(id, ((uint8_t *) data + 4));
  913. cdf_spin_unlock_bh(&wmi_handle->wmi_record_lock);
  914. cdf_spin_lock_bh(&wmi_handle->eventq_lock);
  915. cdf_nbuf_queue_add(&wmi_handle->event_queue, evt_buf);
  916. cdf_spin_unlock_bh(&wmi_handle->eventq_lock);
  917. schedule_work(&wmi_handle->rx_event_work);
  918. return;
  919. }
  920. /*
  921. * Temporarily added to support older WMI events. We should move all events to unified
  922. * when the target is ready to support it.
  923. */
  924. void wmi_control_rx(void *ctx, HTC_PACKET *htc_packet)
  925. {
  926. struct wmi_unified *wmi_handle = (struct wmi_unified *)ctx;
  927. wmi_buf_t evt_buf;
  928. uint32_t id;
  929. evt_buf = (wmi_buf_t) htc_packet->pPktContext;
  930. id = WMI_GET_FIELD(cdf_nbuf_data(evt_buf), WMI_CMD_HDR, COMMANDID);
  931. switch (id) {
  932. /*Event will be handled in tasklet ctx*/
  933. case WMI_TX_PAUSE_EVENTID:
  934. case WMI_WOW_WAKEUP_HOST_EVENTID:
  935. case WMI_PDEV_RESUME_EVENTID:
  936. case WMI_D0_WOW_DISABLE_ACK_EVENTID:
  937. wmi_process_fw_event_tasklet_ctx
  938. (wmi_handle, htc_packet);
  939. break;
  940. /*Event will be handled in worker thread ctx*/
  941. case WMI_DEBUG_MESG_EVENTID:
  942. case WMI_DFS_RADAR_EVENTID:
  943. case WMI_PHYERR_EVENTID:
  944. case WMI_PEER_STATE_EVENTID:
  945. case WMI_MGMT_RX_EVENTID:
  946. case WMI_ROAM_EVENTID:
  947. wmi_process_fw_event_worker_thread_ctx
  948. (wmi_handle, htc_packet);
  949. break;
  950. /*Event will be handled in mc_thread ctx*/
  951. default:
  952. wmi_process_fw_event_mc_thread_ctx
  953. (wmi_handle, htc_packet);
  954. break;
  955. }
  956. }
  957. void wmi_process_fw_event(struct wmi_unified *wmi_handle, wmi_buf_t evt_buf)
  958. {
  959. __wmi_control_rx(wmi_handle, evt_buf);
  960. }
  961. void __wmi_control_rx(struct wmi_unified *wmi_handle, wmi_buf_t evt_buf)
  962. {
  963. uint32_t id;
  964. uint8_t *data;
  965. uint32_t len;
  966. void *wmi_cmd_struct_ptr = NULL;
  967. int tlv_ok_status = 0;
  968. id = WMI_GET_FIELD(cdf_nbuf_data(evt_buf), WMI_CMD_HDR, COMMANDID);
  969. if (cdf_nbuf_pull_head(evt_buf, sizeof(WMI_CMD_HDR)) == NULL)
  970. goto end;
  971. data = cdf_nbuf_data(evt_buf);
  972. len = cdf_nbuf_len(evt_buf);
  973. /* Validate and pad(if necessary) the TLVs */
  974. tlv_ok_status = wmitlv_check_and_pad_event_tlvs(wmi_handle->scn_handle,
  975. data, len, id,
  976. &wmi_cmd_struct_ptr);
  977. if (tlv_ok_status != 0) {
  978. pr_err("%s: Error: id=0x%d, wmitlv_check_and_pad_tlvs ret=%d\n",
  979. __func__, id, tlv_ok_status);
  980. goto end;
  981. }
  982. if ((id >= WMI_EVT_GRP_START_ID(WMI_GRP_START)) &&
  983. /* WMI_SERVICE_READY_EXT_EVENTID is supposed to be part of the
  984. * WMI_GRP_START group. Since the group is out of space, FW
  985. * has accomodated this in WMI_GRP_VDEV.
  986. * WMI_SERVICE_READY_EXT_EVENTID does not have any specific
  987. * event handler registered. So, we do not want to go through
  988. * the WMI registered event handler path for this event.
  989. */
  990. (id != WMI_SERVICE_READY_EXT_EVENTID)) {
  991. uint32_t idx = 0;
  992. idx = wmi_unified_get_event_handler_ix(wmi_handle, id);
  993. if (idx == -1) {
  994. pr_err
  995. ("%s : event handler is not registered: event id 0x%x\n",
  996. __func__, id);
  997. goto end;
  998. }
  999. #ifdef WMI_INTERFACE_EVENT_LOGGING
  1000. cdf_spin_lock_bh(&wmi_handle->wmi_record_lock);
  1001. /* Exclude 4 bytes of TLV header */
  1002. if (id == WMI_MGMT_TX_COMPLETION_EVENTID) {
  1003. WMI_MGMT_EVENT_RECORD(id, ((uint8_t *) data + 4));
  1004. } else {
  1005. WMI_EVENT_RECORD(id, ((uint8_t *) data + 4));
  1006. }
  1007. cdf_spin_unlock_bh(&wmi_handle->wmi_record_lock);
  1008. #endif
  1009. /* Call the WMI registered event handler */
  1010. wmi_handle->event_handler[idx] (wmi_handle->scn_handle,
  1011. wmi_cmd_struct_ptr, len);
  1012. goto end;
  1013. }
  1014. switch (id) {
  1015. default:
  1016. pr_info("%s: Unhandled WMI event %d\n", __func__, id);
  1017. break;
  1018. case WMI_SERVICE_READY_EVENTID:
  1019. pr_info("%s: WMI UNIFIED SERVICE READY event\n", __func__);
  1020. wma_rx_service_ready_event(wmi_handle->scn_handle,
  1021. wmi_cmd_struct_ptr);
  1022. break;
  1023. case WMI_SERVICE_READY_EXT_EVENTID:
  1024. WMA_LOGA("%s: WMI UNIFIED SERVICE READY Extended event",
  1025. __func__);
  1026. wma_rx_service_ready_ext_event(wmi_handle->scn_handle,
  1027. wmi_cmd_struct_ptr);
  1028. break;
  1029. case WMI_READY_EVENTID:
  1030. pr_info("%s: WMI UNIFIED READY event\n", __func__);
  1031. wma_rx_ready_event(wmi_handle->scn_handle, wmi_cmd_struct_ptr);
  1032. break;
  1033. }
  1034. end:
  1035. wmitlv_free_allocated_event_tlvs(id, &wmi_cmd_struct_ptr);
  1036. cdf_nbuf_free(evt_buf);
  1037. }
  1038. void wmi_rx_event_work(struct work_struct *work)
  1039. {
  1040. struct wmi_unified *wmi = container_of(work, struct wmi_unified,
  1041. rx_event_work);
  1042. wmi_buf_t buf;
  1043. cdf_spin_lock_bh(&wmi->eventq_lock);
  1044. buf = cdf_nbuf_queue_remove(&wmi->event_queue);
  1045. cdf_spin_unlock_bh(&wmi->eventq_lock);
  1046. while (buf) {
  1047. __wmi_control_rx(wmi, buf);
  1048. cdf_spin_lock_bh(&wmi->eventq_lock);
  1049. buf = cdf_nbuf_queue_remove(&wmi->event_queue);
  1050. cdf_spin_unlock_bh(&wmi->eventq_lock);
  1051. }
  1052. }
  1053. /* WMI Initialization functions */
  1054. #ifdef FEATURE_RUNTIME_PM
  1055. /**
  1056. * wmi_runtime_pm_init() - initialize runtime pm wmi variables
  1057. * @wmi_handle: wmi context
  1058. */
  1059. void wmi_runtime_pm_init(struct wmi_unified *wmi_handle)
  1060. {
  1061. cdf_atomic_init(&wmi_handle->runtime_pm_inprogress);
  1062. }
  1063. #else
  1064. void wmi_runtime_pm_init(struct wmi_unified *wmi_handle)
  1065. {
  1066. }
  1067. #endif
  1068. void *wmi_unified_attach(ol_scn_t scn_handle,
  1069. wma_process_fw_event_handler_cbk func)
  1070. {
  1071. struct wmi_unified *wmi_handle;
  1072. wmi_handle =
  1073. (struct wmi_unified *)os_malloc(NULL, sizeof(struct wmi_unified),
  1074. GFP_ATOMIC);
  1075. if (wmi_handle == NULL) {
  1076. printk("allocation of wmi handle failed %zu \n",
  1077. sizeof(struct wmi_unified));
  1078. return NULL;
  1079. }
  1080. OS_MEMZERO(wmi_handle, sizeof(struct wmi_unified));
  1081. wmi_handle->scn_handle = scn_handle;
  1082. cdf_atomic_init(&wmi_handle->pending_cmds);
  1083. cdf_atomic_init(&wmi_handle->is_target_suspended);
  1084. wmi_runtime_pm_init(wmi_handle);
  1085. cdf_spinlock_init(&wmi_handle->eventq_lock);
  1086. cdf_nbuf_queue_init(&wmi_handle->event_queue);
  1087. #ifdef CONFIG_CNSS
  1088. cnss_init_work(&wmi_handle->rx_event_work, wmi_rx_event_work);
  1089. #else
  1090. INIT_WORK(&wmi_handle->rx_event_work, wmi_rx_event_work);
  1091. #endif
  1092. #ifdef WMI_INTERFACE_EVENT_LOGGING
  1093. cdf_spinlock_init(&wmi_handle->wmi_record_lock);
  1094. #endif
  1095. wmi_handle->wma_process_fw_event_handler_cbk = func;
  1096. return wmi_handle;
  1097. }
  1098. void wmi_unified_detach(struct wmi_unified *wmi_handle)
  1099. {
  1100. wmi_buf_t buf;
  1101. cds_flush_work(&wmi_handle->rx_event_work);
  1102. cdf_spin_lock_bh(&wmi_handle->eventq_lock);
  1103. buf = cdf_nbuf_queue_remove(&wmi_handle->event_queue);
  1104. while (buf) {
  1105. cdf_nbuf_free(buf);
  1106. buf = cdf_nbuf_queue_remove(&wmi_handle->event_queue);
  1107. }
  1108. cdf_spin_unlock_bh(&wmi_handle->eventq_lock);
  1109. if (wmi_handle != NULL) {
  1110. OS_FREE(wmi_handle);
  1111. wmi_handle = NULL;
  1112. }
  1113. }
  1114. /**
  1115. * wmi_unified_remove_work() - detach for WMI work
  1116. * @wmi_handle: handle to WMI
  1117. *
  1118. * A function that does not fully detach WMI, but just remove work
  1119. * queue items associated with it. This is used to make sure that
  1120. * before any other processing code that may destroy related contexts
  1121. * (HTC, etc), work queue processing on WMI has already been stopped.
  1122. *
  1123. * Return: None
  1124. */
  1125. void
  1126. wmi_unified_remove_work(struct wmi_unified *wmi_handle)
  1127. {
  1128. wmi_buf_t buf;
  1129. CDF_TRACE(CDF_MODULE_ID_WMI, CDF_TRACE_LEVEL_INFO,
  1130. "Enter: %s", __func__);
  1131. cds_flush_work(&wmi_handle->rx_event_work);
  1132. cdf_spin_lock_bh(&wmi_handle->eventq_lock);
  1133. buf = cdf_nbuf_queue_remove(&wmi_handle->event_queue);
  1134. while (buf) {
  1135. cdf_nbuf_free(buf);
  1136. buf = cdf_nbuf_queue_remove(&wmi_handle->event_queue);
  1137. }
  1138. cdf_spin_unlock_bh(&wmi_handle->eventq_lock);
  1139. CDF_TRACE(CDF_MODULE_ID_WMA, CDF_TRACE_LEVEL_INFO,
  1140. "Done: %s", __func__);
  1141. }
  1142. void wmi_htc_tx_complete(void *ctx, HTC_PACKET *htc_pkt)
  1143. {
  1144. struct wmi_unified *wmi_handle = (struct wmi_unified *)ctx;
  1145. wmi_buf_t wmi_cmd_buf = GET_HTC_PACKET_NET_BUF_CONTEXT(htc_pkt);
  1146. #ifdef WMI_INTERFACE_EVENT_LOGGING
  1147. uint32_t cmd_id;
  1148. #endif
  1149. ASSERT(wmi_cmd_buf);
  1150. #ifdef WMI_INTERFACE_EVENT_LOGGING
  1151. cmd_id = WMI_GET_FIELD(cdf_nbuf_data(wmi_cmd_buf),
  1152. WMI_CMD_HDR, COMMANDID);
  1153. #ifdef QCA_WIFI_3_0_EMU
  1154. printk("\nSent WMI command:%s command_id:0x%x over dma and recieved tx complete interupt\n",
  1155. get_wmi_cmd_string(cmd_id), cmd_id);
  1156. #endif
  1157. cdf_spin_lock_bh(&wmi_handle->wmi_record_lock);
  1158. /* Record 16 bytes of WMI cmd tx complete data
  1159. - exclude TLV and WMI headers */
  1160. if (cmd_id == WMI_MGMT_TX_SEND_CMDID) {
  1161. WMI_MGMT_COMMAND_TX_CMP_RECORD(cmd_id,
  1162. ((uint32_t *) cdf_nbuf_data(wmi_cmd_buf) + 2));
  1163. } else {
  1164. WMI_COMMAND_TX_CMP_RECORD(cmd_id,
  1165. ((uint32_t *) cdf_nbuf_data(wmi_cmd_buf) + 2));
  1166. }
  1167. cdf_spin_unlock_bh(&wmi_handle->wmi_record_lock);
  1168. #endif
  1169. cdf_nbuf_free(wmi_cmd_buf);
  1170. cdf_mem_free(htc_pkt);
  1171. cdf_atomic_dec(&wmi_handle->pending_cmds);
  1172. }
  1173. int
  1174. wmi_unified_connect_htc_service(struct wmi_unified *wmi_handle,
  1175. void *htc_handle)
  1176. {
  1177. int status;
  1178. HTC_SERVICE_CONNECT_RESP response;
  1179. HTC_SERVICE_CONNECT_REQ connect;
  1180. OS_MEMZERO(&connect, sizeof(connect));
  1181. OS_MEMZERO(&response, sizeof(response));
  1182. /* meta data is unused for now */
  1183. connect.pMetaData = NULL;
  1184. connect.MetaDataLength = 0;
  1185. /* these fields are the same for all service endpoints */
  1186. connect.EpCallbacks.pContext = wmi_handle;
  1187. connect.EpCallbacks.EpTxCompleteMultiple =
  1188. NULL /* Control path completion ar6000_tx_complete */;
  1189. connect.EpCallbacks.EpRecv = wmi_control_rx /* Control path rx */;
  1190. connect.EpCallbacks.EpRecvRefill = NULL /* ar6000_rx_refill */;
  1191. connect.EpCallbacks.EpSendFull = NULL /* ar6000_tx_queue_full */;
  1192. connect.EpCallbacks.EpTxComplete =
  1193. wmi_htc_tx_complete /* ar6000_tx_queue_full */;
  1194. /* connect to control service */
  1195. connect.service_id = WMI_CONTROL_SVC;
  1196. if ((status =
  1197. htc_connect_service(htc_handle, &connect, &response)) != EOK) {
  1198. printk
  1199. (" Failed to connect to WMI CONTROL service status:%d \n",
  1200. status);
  1201. return -1;;
  1202. }
  1203. wmi_handle->wmi_endpoint_id = response.Endpoint;
  1204. wmi_handle->htc_handle = htc_handle;
  1205. wmi_handle->max_msg_len = response.MaxMsgLength;
  1206. return EOK;
  1207. }
  1208. int wmi_get_host_credits(wmi_unified_t wmi_handle)
  1209. {
  1210. int host_credits;
  1211. htc_get_control_endpoint_tx_host_credits(wmi_handle->htc_handle,
  1212. &host_credits);
  1213. return host_credits;
  1214. }
  1215. int wmi_get_pending_cmds(wmi_unified_t wmi_handle)
  1216. {
  1217. return cdf_atomic_read(&wmi_handle->pending_cmds);
  1218. }
  1219. void wmi_set_target_suspend(wmi_unified_t wmi_handle, A_BOOL val)
  1220. {
  1221. cdf_atomic_set(&wmi_handle->is_target_suspended, val);
  1222. }
  1223. #ifdef FEATURE_RUNTIME_PM
  1224. void wmi_set_runtime_pm_inprogress(wmi_unified_t wmi_handle, A_BOOL val)
  1225. {
  1226. cdf_atomic_set(&wmi_handle->runtime_pm_inprogress, val);
  1227. }
  1228. inline bool wmi_get_runtime_pm_inprogress(wmi_unified_t wmi_handle)
  1229. {
  1230. return cdf_atomic_read(&wmi_handle->runtime_pm_inprogress);
  1231. }
  1232. #endif