wmi_unified.c 81 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533
  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 "htc_api.h"
  36. #include "htc_api.h"
  37. #include "dbglog_host.h"
  38. #include "wmi_unified_priv.h"
  39. #include "wmi_unified_param.h"
  40. #ifndef WMI_NON_TLV_SUPPORT
  41. #include "wmi_tlv_helper.h"
  42. #endif
  43. #include <linux/debugfs.h>
  44. /* This check for CONFIG_WIN temporary added due to redeclaration compilation
  45. error in MCL. Error is caused due to inclusion of wmi.h in wmi_unified_api.h
  46. which gets included here through ol_if_athvar.h. Eventually it is expected that
  47. wmi.h will be removed from wmi_unified_api.h after cleanup, which will need
  48. WMI_CMD_HDR to be defined here. */
  49. #ifdef CONFIG_WIN
  50. /* Copied from wmi.h */
  51. #undef MS
  52. #define MS(_v, _f) (((_v) & _f##_MASK) >> _f##_LSB)
  53. #undef SM
  54. #define SM(_v, _f) (((_v) << _f##_LSB) & _f##_MASK)
  55. #undef WO
  56. #define WO(_f) ((_f##_OFFSET) >> 2)
  57. #undef GET_FIELD
  58. #define GET_FIELD(_addr, _f) MS(*((A_UINT32 *)(_addr) + WO(_f)), _f)
  59. #undef SET_FIELD
  60. #define SET_FIELD(_addr, _f, _val) \
  61. (*((A_UINT32 *)(_addr) + WO(_f)) = \
  62. (*((A_UINT32 *)(_addr) + WO(_f)) & ~_f##_MASK) | SM(_val, _f))
  63. #define WMI_GET_FIELD(_msg_buf, _msg_type, _f) \
  64. GET_FIELD(_msg_buf, _msg_type ## _ ## _f)
  65. #define WMI_SET_FIELD(_msg_buf, _msg_type, _f, _val) \
  66. SET_FIELD(_msg_buf, _msg_type ## _ ## _f, _val)
  67. #define WMI_EP_APASS 0x0
  68. #define WMI_EP_LPASS 0x1
  69. #define WMI_EP_SENSOR 0x2
  70. /*
  71. * * Control Path
  72. * */
  73. typedef PREPACK struct {
  74. A_UINT32 commandId:24,
  75. reserved:2, /* used for WMI endpoint ID */
  76. plt_priv:6; /* platform private */
  77. } POSTPACK WMI_CMD_HDR; /* used for commands and events */
  78. #define WMI_CMD_HDR_COMMANDID_LSB 0
  79. #define WMI_CMD_HDR_COMMANDID_MASK 0x00ffffff
  80. #define WMI_CMD_HDR_COMMANDID_OFFSET 0x00000000
  81. #define WMI_CMD_HDR_WMI_ENDPOINTID_MASK 0x03000000
  82. #define WMI_CMD_HDR_WMI_ENDPOINTID_OFFSET 24
  83. #define WMI_CMD_HDR_PLT_PRIV_LSB 24
  84. #define WMI_CMD_HDR_PLT_PRIV_MASK 0xff000000
  85. #define WMI_CMD_HDR_PLT_PRIV_OFFSET 0x00000000
  86. /* end of copy wmi.h */
  87. #endif /* CONFIG_WIN */
  88. #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0))
  89. /* TODO Cleanup this backported function */
  90. static int qcacld_bp_seq_printf(struct seq_file *m, const char *f, ...)
  91. {
  92. va_list args;
  93. va_start(args, f);
  94. seq_printf(m, f, args);
  95. va_end(args);
  96. return m->count;
  97. }
  98. #define seq_printf(m, fmt, ...) qcacld_bp_seq_printf((m), fmt, ##__VA_ARGS__)
  99. #endif
  100. #define WMI_MIN_HEAD_ROOM 64
  101. #ifdef WMI_INTERFACE_EVENT_LOGGING
  102. #ifndef MAX_WMI_INSTANCES
  103. #ifdef CONFIG_MCL
  104. #define MAX_WMI_INSTANCES 1
  105. #else
  106. #define MAX_WMI_INSTANCES 3
  107. #endif
  108. #define CUSTOM_MGMT_CMD_DATA_SIZE 4
  109. #endif
  110. #ifdef CONFIG_MCL
  111. /* WMI commands */
  112. uint32_t g_wmi_command_buf_idx = 0;
  113. struct wmi_command_debug wmi_command_log_buffer[WMI_EVENT_DEBUG_MAX_ENTRY];
  114. /* WMI commands TX completed */
  115. uint32_t g_wmi_command_tx_cmp_buf_idx = 0;
  116. struct wmi_command_debug
  117. wmi_command_tx_cmp_log_buffer[WMI_EVENT_DEBUG_MAX_ENTRY];
  118. /* WMI events when processed */
  119. uint32_t g_wmi_event_buf_idx = 0;
  120. struct wmi_event_debug wmi_event_log_buffer[WMI_EVENT_DEBUG_MAX_ENTRY];
  121. /* WMI events when queued */
  122. uint32_t g_wmi_rx_event_buf_idx = 0;
  123. struct wmi_event_debug wmi_rx_event_log_buffer[WMI_EVENT_DEBUG_MAX_ENTRY];
  124. #endif
  125. #define WMI_COMMAND_RECORD(h, a, b) { \
  126. if (wmi_log_max_entry <= \
  127. *(h->log_info.wmi_command_log_buf_info.p_buf_tail_idx)) \
  128. *(h->log_info.wmi_command_log_buf_info.p_buf_tail_idx) = 0;\
  129. ((struct wmi_command_debug *)h->log_info.wmi_command_log_buf_info.buf)\
  130. [*(h->log_info.wmi_command_log_buf_info.p_buf_tail_idx)]\
  131. .command = a; \
  132. qdf_mem_copy(((struct wmi_command_debug *)h->log_info. \
  133. wmi_command_log_buf_info.buf) \
  134. [*(h->log_info.wmi_command_log_buf_info.p_buf_tail_idx)].data,\
  135. b, wmi_record_max_length); \
  136. ((struct wmi_command_debug *)h->log_info.wmi_command_log_buf_info.buf)\
  137. [*(h->log_info.wmi_command_log_buf_info.p_buf_tail_idx)].\
  138. time = qdf_get_log_timestamp(); \
  139. (*(h->log_info.wmi_command_log_buf_info.p_buf_tail_idx))++; \
  140. h->log_info.wmi_command_log_buf_info.length++; \
  141. }
  142. #define WMI_COMMAND_TX_CMP_RECORD(h, a, b) { \
  143. if (wmi_log_max_entry <= \
  144. *(h->log_info.wmi_command_tx_cmp_log_buf_info.p_buf_tail_idx))\
  145. *(h->log_info.wmi_command_tx_cmp_log_buf_info. \
  146. p_buf_tail_idx) = 0; \
  147. ((struct wmi_command_debug *)h->log_info. \
  148. wmi_command_tx_cmp_log_buf_info.buf) \
  149. [*(h->log_info.wmi_command_tx_cmp_log_buf_info. \
  150. p_buf_tail_idx)]. \
  151. command = a; \
  152. qdf_mem_copy(((struct wmi_command_debug *)h->log_info. \
  153. wmi_command_tx_cmp_log_buf_info.buf) \
  154. [*(h->log_info.wmi_command_tx_cmp_log_buf_info. \
  155. p_buf_tail_idx)]. \
  156. data, b, wmi_record_max_length); \
  157. ((struct wmi_command_debug *)h->log_info. \
  158. wmi_command_tx_cmp_log_buf_info.buf) \
  159. [*(h->log_info.wmi_command_tx_cmp_log_buf_info. \
  160. p_buf_tail_idx)]. \
  161. time = qdf_get_log_timestamp(); \
  162. (*(h->log_info.wmi_command_tx_cmp_log_buf_info.p_buf_tail_idx))++;\
  163. h->log_info.wmi_command_tx_cmp_log_buf_info.length++; \
  164. }
  165. #define WMI_EVENT_RECORD(h, a, b) { \
  166. if (wmi_log_max_entry <= \
  167. *(h->log_info.wmi_event_log_buf_info.p_buf_tail_idx)) \
  168. *(h->log_info.wmi_event_log_buf_info.p_buf_tail_idx) = 0;\
  169. ((struct wmi_event_debug *)h->log_info.wmi_event_log_buf_info.buf)\
  170. [*(h->log_info.wmi_event_log_buf_info.p_buf_tail_idx)]. \
  171. event = a; \
  172. qdf_mem_copy(((struct wmi_event_debug *)h->log_info. \
  173. wmi_event_log_buf_info.buf) \
  174. [*(h->log_info.wmi_event_log_buf_info.p_buf_tail_idx)].data, b,\
  175. wmi_record_max_length); \
  176. ((struct wmi_event_debug *)h->log_info.wmi_event_log_buf_info.buf)\
  177. [*(h->log_info.wmi_event_log_buf_info.p_buf_tail_idx)].time =\
  178. qdf_get_log_timestamp(); \
  179. (*(h->log_info.wmi_event_log_buf_info.p_buf_tail_idx))++; \
  180. h->log_info.wmi_event_log_buf_info.length++; \
  181. }
  182. #define WMI_RX_EVENT_RECORD(h, a, b) { \
  183. if (wmi_log_max_entry <= \
  184. *(h->log_info.wmi_rx_event_log_buf_info.p_buf_tail_idx))\
  185. *(h->log_info.wmi_rx_event_log_buf_info.p_buf_tail_idx) = 0;\
  186. ((struct wmi_event_debug *)h->log_info.wmi_rx_event_log_buf_info.buf)\
  187. [*(h->log_info.wmi_rx_event_log_buf_info.p_buf_tail_idx)].\
  188. event = a; \
  189. qdf_mem_copy(((struct wmi_event_debug *)h->log_info. \
  190. wmi_rx_event_log_buf_info.buf) \
  191. [*(h->log_info.wmi_rx_event_log_buf_info.p_buf_tail_idx)].\
  192. data, b, wmi_record_max_length); \
  193. ((struct wmi_event_debug *)h->log_info.wmi_rx_event_log_buf_info.buf)\
  194. [*(h->log_info.wmi_rx_event_log_buf_info.p_buf_tail_idx)].\
  195. time = qdf_get_log_timestamp(); \
  196. (*(h->log_info.wmi_rx_event_log_buf_info.p_buf_tail_idx))++; \
  197. h->log_info.wmi_rx_event_log_buf_info.length++; \
  198. }
  199. #ifdef CONFIG_MCL
  200. uint32_t g_wmi_mgmt_command_buf_idx = 0;
  201. struct
  202. wmi_command_debug wmi_mgmt_command_log_buffer[WMI_MGMT_EVENT_DEBUG_MAX_ENTRY];
  203. /* wmi_mgmt commands TX completed */
  204. uint32_t g_wmi_mgmt_command_tx_cmp_buf_idx = 0;
  205. struct wmi_command_debug
  206. wmi_mgmt_command_tx_cmp_log_buffer[WMI_MGMT_EVENT_DEBUG_MAX_ENTRY];
  207. /* wmi_mgmt events when processed */
  208. uint32_t g_wmi_mgmt_event_buf_idx = 0;
  209. struct wmi_event_debug
  210. wmi_mgmt_event_log_buffer[WMI_MGMT_EVENT_DEBUG_MAX_ENTRY];
  211. #endif
  212. #define WMI_MGMT_COMMAND_RECORD(h, a, b) { \
  213. if (wmi_mgmt_log_max_entry <= \
  214. *(h->log_info.wmi_mgmt_command_log_buf_info.p_buf_tail_idx)) \
  215. *(h->log_info.wmi_mgmt_command_log_buf_info. \
  216. p_buf_tail_idx) = 0; \
  217. ((struct wmi_command_debug *)h->log_info. \
  218. wmi_mgmt_command_log_buf_info.buf) \
  219. [*(h->log_info.wmi_mgmt_command_log_buf_info.p_buf_tail_idx)].\
  220. command = a; \
  221. qdf_mem_copy(((struct wmi_command_debug *)h->log_info. \
  222. wmi_mgmt_command_log_buf_info.buf) \
  223. [*(h->log_info.wmi_mgmt_command_log_buf_info.p_buf_tail_idx)].\
  224. data, b, \
  225. wmi_record_max_length); \
  226. ((struct wmi_command_debug *)h->log_info. \
  227. wmi_mgmt_command_log_buf_info.buf) \
  228. [*(h->log_info.wmi_mgmt_command_log_buf_info.p_buf_tail_idx)].\
  229. time = qdf_get_log_timestamp(); \
  230. (*(h->log_info.wmi_mgmt_command_log_buf_info.p_buf_tail_idx))++;\
  231. h->log_info.wmi_mgmt_command_log_buf_info.length++; \
  232. }
  233. #define WMI_MGMT_COMMAND_TX_CMP_RECORD(h, a, b) { \
  234. if (wmi_mgmt_log_max_entry <= \
  235. *(h->log_info.wmi_mgmt_command_tx_cmp_log_buf_info. \
  236. p_buf_tail_idx)) \
  237. *(h->log_info.wmi_mgmt_command_tx_cmp_log_buf_info. \
  238. p_buf_tail_idx) = 0; \
  239. ((struct wmi_command_debug *)h->log_info. \
  240. wmi_mgmt_command_tx_cmp_log_buf_info.buf) \
  241. [*(h->log_info.wmi_mgmt_command_tx_cmp_log_buf_info. \
  242. p_buf_tail_idx)].command = a; \
  243. qdf_mem_copy(((struct wmi_command_debug *)h->log_info. \
  244. wmi_mgmt_command_tx_cmp_log_buf_info.buf)\
  245. [*(h->log_info.wmi_mgmt_command_tx_cmp_log_buf_info. \
  246. p_buf_tail_idx)].data, b, \
  247. wmi_record_max_length); \
  248. ((struct wmi_command_debug *)h->log_info. \
  249. wmi_mgmt_command_tx_cmp_log_buf_info.buf) \
  250. [*(h->log_info.wmi_mgmt_command_tx_cmp_log_buf_info. \
  251. p_buf_tail_idx)].time = \
  252. qdf_get_log_timestamp(); \
  253. (*(h->log_info.wmi_mgmt_command_tx_cmp_log_buf_info. \
  254. p_buf_tail_idx))++; \
  255. h->log_info.wmi_mgmt_command_tx_cmp_log_buf_info.length++; \
  256. }
  257. #define WMI_MGMT_EVENT_RECORD(h, a, b) { \
  258. if (wmi_mgmt_log_max_entry <= \
  259. *(h->log_info.wmi_mgmt_event_log_buf_info.p_buf_tail_idx))\
  260. *(h->log_info.wmi_mgmt_event_log_buf_info.p_buf_tail_idx) = 0;\
  261. ((struct wmi_event_debug *)h->log_info.wmi_mgmt_event_log_buf_info.buf)\
  262. [*(h->log_info.wmi_mgmt_event_log_buf_info.p_buf_tail_idx)]\
  263. .event = a; \
  264. qdf_mem_copy(((struct wmi_event_debug *)h->log_info. \
  265. wmi_mgmt_event_log_buf_info.buf) \
  266. [*(h->log_info.wmi_mgmt_event_log_buf_info.p_buf_tail_idx)].\
  267. data, b, wmi_record_max_length); \
  268. ((struct wmi_event_debug *)h->log_info.wmi_mgmt_event_log_buf_info.buf)\
  269. [*(h->log_info.wmi_mgmt_event_log_buf_info.p_buf_tail_idx)].\
  270. time = qdf_get_log_timestamp(); \
  271. (*(h->log_info.wmi_mgmt_event_log_buf_info.p_buf_tail_idx))++; \
  272. h->log_info.wmi_mgmt_event_log_buf_info.length++; \
  273. }
  274. /* These are defined to made it as module param, which can be configured */
  275. uint32_t wmi_log_max_entry = WMI_EVENT_DEBUG_MAX_ENTRY;
  276. uint32_t wmi_mgmt_log_max_entry = WMI_MGMT_EVENT_DEBUG_MAX_ENTRY;
  277. uint32_t wmi_record_max_length = WMI_EVENT_DEBUG_ENTRY_MAX_LENGTH;
  278. uint32_t wmi_display_size = 100;
  279. static uint8_t *wmi_id_to_name(uint32_t wmi_command);
  280. /**
  281. * wmi_log_init() - Initialize WMI event logging
  282. * @wmi_handle: WMI handle.
  283. *
  284. * Return: Initialization status
  285. */
  286. #ifdef CONFIG_MCL
  287. static QDF_STATUS wmi_log_init(struct wmi_unified *wmi_handle)
  288. {
  289. struct wmi_log_buf_t *cmd_log_buf =
  290. &wmi_handle->log_info.wmi_command_log_buf_info;
  291. struct wmi_log_buf_t *cmd_tx_cmpl_log_buf =
  292. &wmi_handle->log_info.wmi_command_tx_cmp_log_buf_info;
  293. struct wmi_log_buf_t *event_log_buf =
  294. &wmi_handle->log_info.wmi_event_log_buf_info;
  295. struct wmi_log_buf_t *rx_event_log_buf =
  296. &wmi_handle->log_info.wmi_rx_event_log_buf_info;
  297. struct wmi_log_buf_t *mgmt_cmd_log_buf =
  298. &wmi_handle->log_info.wmi_mgmt_command_log_buf_info;
  299. struct wmi_log_buf_t *mgmt_cmd_tx_cmp_log_buf =
  300. &wmi_handle->log_info.wmi_mgmt_command_tx_cmp_log_buf_info;
  301. struct wmi_log_buf_t *mgmt_event_log_buf =
  302. &wmi_handle->log_info.wmi_mgmt_event_log_buf_info;
  303. /* WMI commands */
  304. cmd_log_buf->length = 0;
  305. cmd_log_buf->buf_tail_idx = 0;
  306. cmd_log_buf->buf = wmi_command_log_buffer;
  307. cmd_log_buf->p_buf_tail_idx = &g_wmi_command_buf_idx;
  308. /* WMI commands TX completed */
  309. cmd_tx_cmpl_log_buf->length = 0;
  310. cmd_tx_cmpl_log_buf->buf_tail_idx = 0;
  311. cmd_tx_cmpl_log_buf->buf = wmi_command_tx_cmp_log_buffer;
  312. cmd_tx_cmpl_log_buf->p_buf_tail_idx = &g_wmi_command_tx_cmp_buf_idx;
  313. /* WMI events when processed */
  314. event_log_buf->length = 0;
  315. event_log_buf->buf_tail_idx = 0;
  316. event_log_buf->buf = wmi_event_log_buffer;
  317. event_log_buf->p_buf_tail_idx = &g_wmi_event_buf_idx;
  318. /* WMI events when queued */
  319. rx_event_log_buf->length = 0;
  320. rx_event_log_buf->buf_tail_idx = 0;
  321. rx_event_log_buf->buf = wmi_rx_event_log_buffer;
  322. rx_event_log_buf->p_buf_tail_idx = &g_wmi_rx_event_buf_idx;
  323. /* WMI Management commands */
  324. mgmt_cmd_log_buf->length = 0;
  325. mgmt_cmd_log_buf->buf_tail_idx = 0;
  326. mgmt_cmd_log_buf->buf = wmi_mgmt_command_log_buffer;
  327. mgmt_cmd_log_buf->p_buf_tail_idx = &g_wmi_mgmt_command_buf_idx;
  328. /* WMI Management commands Tx completed*/
  329. mgmt_cmd_tx_cmp_log_buf->length = 0;
  330. mgmt_cmd_tx_cmp_log_buf->buf_tail_idx = 0;
  331. mgmt_cmd_tx_cmp_log_buf->buf = wmi_mgmt_command_tx_cmp_log_buffer;
  332. mgmt_cmd_tx_cmp_log_buf->p_buf_tail_idx =
  333. &g_wmi_mgmt_command_tx_cmp_buf_idx;
  334. /* WMI Management events when processed*/
  335. mgmt_event_log_buf->length = 0;
  336. mgmt_event_log_buf->buf_tail_idx = 0;
  337. mgmt_event_log_buf->buf = wmi_mgmt_event_log_buffer;
  338. mgmt_event_log_buf->p_buf_tail_idx = &g_wmi_mgmt_event_buf_idx;
  339. qdf_spinlock_create(&wmi_handle->log_info.wmi_record_lock);
  340. wmi_handle->log_info.wmi_logging_enable = 1;
  341. return QDF_STATUS_SUCCESS;
  342. }
  343. #else
  344. static QDF_STATUS wmi_log_init(struct wmi_unified *wmi_handle)
  345. {
  346. struct wmi_log_buf_t *cmd_log_buf =
  347. &wmi_handle->log_info.wmi_command_log_buf_info;
  348. struct wmi_log_buf_t *cmd_tx_cmpl_log_buf =
  349. &wmi_handle->log_info.wmi_command_tx_cmp_log_buf_info;
  350. struct wmi_log_buf_t *event_log_buf =
  351. &wmi_handle->log_info.wmi_event_log_buf_info;
  352. struct wmi_log_buf_t *rx_event_log_buf =
  353. &wmi_handle->log_info.wmi_rx_event_log_buf_info;
  354. struct wmi_log_buf_t *mgmt_cmd_log_buf =
  355. &wmi_handle->log_info.wmi_mgmt_command_log_buf_info;
  356. struct wmi_log_buf_t *mgmt_cmd_tx_cmp_log_buf =
  357. &wmi_handle->log_info.wmi_mgmt_command_tx_cmp_log_buf_info;
  358. struct wmi_log_buf_t *mgmt_event_log_buf =
  359. &wmi_handle->log_info.wmi_mgmt_event_log_buf_info;
  360. wmi_handle->log_info.wmi_logging_enable = 0;
  361. /* WMI commands */
  362. cmd_log_buf->length = 0;
  363. cmd_log_buf->buf_tail_idx = 0;
  364. cmd_log_buf->buf = (struct wmi_command_debug *) qdf_mem_malloc(
  365. wmi_log_max_entry * sizeof(struct wmi_command_debug));
  366. if (!cmd_log_buf->buf) {
  367. qdf_print("no memory for WMI command log buffer..\n");
  368. return QDF_STATUS_E_NOMEM;
  369. }
  370. cmd_log_buf->p_buf_tail_idx = &cmd_log_buf->buf_tail_idx;
  371. /* WMI commands TX completed */
  372. cmd_tx_cmpl_log_buf->length = 0;
  373. cmd_tx_cmpl_log_buf->buf_tail_idx = 0;
  374. cmd_tx_cmpl_log_buf->buf = (struct wmi_command_debug *) qdf_mem_malloc(
  375. wmi_log_max_entry * sizeof(struct wmi_command_debug));
  376. if (!cmd_tx_cmpl_log_buf->buf) {
  377. qdf_print("no memory for WMI Command Tx Complete log buffer..\n");
  378. return QDF_STATUS_E_NOMEM;
  379. }
  380. cmd_tx_cmpl_log_buf->p_buf_tail_idx =
  381. &cmd_tx_cmpl_log_buf->buf_tail_idx;
  382. /* WMI events when processed */
  383. event_log_buf->length = 0;
  384. event_log_buf->buf_tail_idx = 0;
  385. event_log_buf->buf = (struct wmi_event_debug *) qdf_mem_malloc(
  386. wmi_log_max_entry * sizeof(struct wmi_event_debug));
  387. if (!event_log_buf->buf) {
  388. qdf_print("no memory for WMI Event log buffer..\n");
  389. return QDF_STATUS_E_NOMEM;
  390. }
  391. event_log_buf->p_buf_tail_idx = &event_log_buf->buf_tail_idx;
  392. /* WMI events when queued */
  393. rx_event_log_buf->length = 0;
  394. rx_event_log_buf->buf_tail_idx = 0;
  395. rx_event_log_buf->buf = (struct wmi_event_debug *) qdf_mem_malloc(
  396. wmi_log_max_entry * sizeof(struct wmi_event_debug));
  397. if (!rx_event_log_buf->buf) {
  398. qdf_print("no memory for WMI Event Rx log buffer..\n");
  399. return QDF_STATUS_E_NOMEM;
  400. }
  401. rx_event_log_buf->p_buf_tail_idx = &rx_event_log_buf->buf_tail_idx;
  402. /* WMI Management commands */
  403. mgmt_cmd_log_buf->length = 0;
  404. mgmt_cmd_log_buf->buf_tail_idx = 0;
  405. mgmt_cmd_log_buf->buf = (struct wmi_command_debug *) qdf_mem_malloc(
  406. wmi_mgmt_log_max_entry *
  407. sizeof(struct wmi_command_debug));
  408. if (!mgmt_cmd_log_buf->buf) {
  409. qdf_print("no memory for WMI Management Command log buffer..\n");
  410. return QDF_STATUS_E_NOMEM;
  411. }
  412. mgmt_cmd_log_buf->p_buf_tail_idx = &mgmt_cmd_log_buf->buf_tail_idx;
  413. /* WMI Management commands Tx completed*/
  414. mgmt_cmd_tx_cmp_log_buf->length = 0;
  415. mgmt_cmd_tx_cmp_log_buf->buf_tail_idx = 0;
  416. mgmt_cmd_tx_cmp_log_buf->buf = (struct wmi_command_debug *)
  417. qdf_mem_malloc(
  418. wmi_mgmt_log_max_entry *
  419. sizeof(struct wmi_command_debug));
  420. if (!mgmt_cmd_tx_cmp_log_buf->buf) {
  421. qdf_print("no memory for WMI Management Command Tx complete log buffer..\n");
  422. return QDF_STATUS_E_NOMEM;
  423. }
  424. mgmt_cmd_tx_cmp_log_buf->p_buf_tail_idx =
  425. &mgmt_cmd_tx_cmp_log_buf->buf_tail_idx;
  426. /* WMI Management events when processed*/
  427. mgmt_event_log_buf->length = 0;
  428. mgmt_event_log_buf->buf_tail_idx = 0;
  429. mgmt_event_log_buf->buf = (struct wmi_event_debug *) qdf_mem_malloc(
  430. wmi_mgmt_log_max_entry *
  431. sizeof(struct wmi_event_debug));
  432. if (!mgmt_event_log_buf->buf) {
  433. qdf_print("no memory for WMI Management Event log buffer..\n");
  434. return QDF_STATUS_E_NOMEM;
  435. }
  436. mgmt_event_log_buf->p_buf_tail_idx = &mgmt_event_log_buf->buf_tail_idx;
  437. qdf_spinlock_create(&wmi_handle->log_info.wmi_record_lock);
  438. wmi_handle->log_info.wmi_logging_enable = 1;
  439. return QDF_STATUS_SUCCESS;
  440. }
  441. #endif
  442. /**
  443. * wmi_log_buffer_free() - Free all dynamic allocated buffer memory for
  444. * event logging
  445. * @wmi_handle: WMI handle.
  446. *
  447. * Return: None
  448. */
  449. #ifndef CONFIG_MCL
  450. static inline void wmi_log_buffer_free(struct wmi_unified *wmi_handle)
  451. {
  452. if (wmi_handle->log_info.wmi_command_log_buf_info.buf)
  453. qdf_mem_free(wmi_handle->log_info.wmi_command_log_buf_info.buf);
  454. if (wmi_handle->log_info.wmi_command_tx_cmp_log_buf_info.buf)
  455. qdf_mem_free(
  456. wmi_handle->log_info.wmi_command_tx_cmp_log_buf_info.buf);
  457. if (wmi_handle->log_info.wmi_event_log_buf_info.buf)
  458. qdf_mem_free(wmi_handle->log_info.wmi_event_log_buf_info.buf);
  459. if (wmi_handle->log_info.wmi_rx_event_log_buf_info.buf)
  460. qdf_mem_free(
  461. wmi_handle->log_info.wmi_rx_event_log_buf_info.buf);
  462. if (wmi_handle->log_info.wmi_mgmt_command_log_buf_info.buf)
  463. qdf_mem_free(
  464. wmi_handle->log_info.wmi_mgmt_command_log_buf_info.buf);
  465. if (wmi_handle->log_info.wmi_mgmt_command_tx_cmp_log_buf_info.buf)
  466. qdf_mem_free(
  467. wmi_handle->log_info.wmi_mgmt_command_tx_cmp_log_buf_info.buf);
  468. if (wmi_handle->log_info.wmi_mgmt_event_log_buf_info.buf)
  469. qdf_mem_free(
  470. wmi_handle->log_info.wmi_mgmt_event_log_buf_info.buf);
  471. wmi_handle->log_info.wmi_logging_enable = 0;
  472. qdf_spinlock_destroy(&wmi_handle->log_info.wmi_record_lock);
  473. }
  474. #else
  475. static inline void wmi_log_buffer_free(struct wmi_unified *wmi_handle)
  476. {
  477. /* Do Nothing */
  478. }
  479. #endif
  480. #ifdef CONFIG_MCL
  481. const int8_t * const debugfs_dir[MAX_WMI_INSTANCES] = {"WMI0"};
  482. #else
  483. const int8_t * const debugfs_dir[MAX_WMI_INSTANCES] = {"WMI0", "WMI1", "WMI2"};
  484. #endif
  485. /* debugfs routines*/
  486. /**
  487. * debug_wmi_##func_base##_show() - debugfs functions to display content of
  488. * command and event buffers. Macro uses max buffer length to display
  489. * buffer when it is wraparound.
  490. *
  491. * @m: debugfs handler to access wmi_handle
  492. * @v: Variable arguments (not used)
  493. *
  494. * Return: Length of characters printed
  495. */
  496. #define GENERATE_COMMAND_DEBUG_SHOW_FUNCS(func_base, wmi_ring_size) \
  497. static int debug_wmi_##func_base##_show(struct seq_file *m, \
  498. void *v) \
  499. { \
  500. wmi_unified_t wmi_handle = (wmi_unified_t) m->private; \
  501. struct wmi_log_buf_t *wmi_log = \
  502. &wmi_handle->log_info.wmi_##func_base##_buf_info;\
  503. int pos, nread, outlen; \
  504. int i; \
  505. \
  506. qdf_spin_lock(&wmi_handle->log_info.wmi_record_lock); \
  507. if (!wmi_log->length) { \
  508. qdf_spin_unlock(&wmi_handle->log_info.wmi_record_lock);\
  509. return seq_printf(m, \
  510. "no elements to read from ring buffer!\n"); \
  511. } \
  512. \
  513. if (wmi_log->length <= wmi_ring_size) \
  514. nread = wmi_log->length; \
  515. else \
  516. nread = wmi_ring_size; \
  517. \
  518. if (*(wmi_log->p_buf_tail_idx) == 0) \
  519. /* tail can be 0 after wrap-around */ \
  520. pos = wmi_ring_size - 1; \
  521. else \
  522. pos = *(wmi_log->p_buf_tail_idx) - 1; \
  523. \
  524. outlen = seq_printf(m, "Length = %d\n", wmi_log->length);\
  525. qdf_spin_unlock(&wmi_handle->log_info.wmi_record_lock); \
  526. while (nread--) { \
  527. struct wmi_command_debug *wmi_record; \
  528. \
  529. wmi_record = (struct wmi_command_debug *) \
  530. &(((struct wmi_command_debug *)wmi_log->buf)[pos]);\
  531. outlen += seq_printf(m, "CMD ID = %x\n", \
  532. (wmi_record->command)); \
  533. outlen += seq_printf(m, "CMD = "); \
  534. for (i = 0; i < (wmi_record_max_length/ \
  535. sizeof(uint32_t)); i++) \
  536. outlen += seq_printf(m, "%x ", \
  537. wmi_record->data[i]); \
  538. outlen += seq_printf(m, "\n"); \
  539. \
  540. if (pos == 0) \
  541. pos = wmi_ring_size - 1; \
  542. else \
  543. pos--; \
  544. } \
  545. \
  546. return outlen; \
  547. } \
  548. #define GENERATE_EVENT_DEBUG_SHOW_FUNCS(func_base, wmi_ring_size) \
  549. static int debug_wmi_##func_base##_show(struct seq_file *m, \
  550. void *v) \
  551. { \
  552. wmi_unified_t wmi_handle = (wmi_unified_t) m->private; \
  553. struct wmi_log_buf_t *wmi_log = \
  554. &wmi_handle->log_info.wmi_##func_base##_buf_info;\
  555. int pos, nread, outlen; \
  556. int i; \
  557. \
  558. qdf_spin_lock(&wmi_handle->log_info.wmi_record_lock); \
  559. if (!wmi_log->length) { \
  560. qdf_spin_unlock(&wmi_handle->log_info.wmi_record_lock);\
  561. return seq_printf(m, \
  562. "no elements to read from ring buffer!\n"); \
  563. } \
  564. \
  565. if (wmi_log->length <= wmi_ring_size) \
  566. nread = wmi_log->length; \
  567. else \
  568. nread = wmi_ring_size; \
  569. \
  570. if (*(wmi_log->p_buf_tail_idx) == 0) \
  571. /* tail can be 0 after wrap-around */ \
  572. pos = wmi_ring_size - 1; \
  573. else \
  574. pos = *(wmi_log->p_buf_tail_idx) - 1; \
  575. \
  576. outlen = seq_printf(m, "Length = %d\n", wmi_log->length);\
  577. qdf_spin_unlock(&wmi_handle->log_info.wmi_record_lock); \
  578. while (nread--) { \
  579. struct wmi_event_debug *wmi_record; \
  580. \
  581. wmi_record = (struct wmi_event_debug *) \
  582. &(((struct wmi_event_debug *)wmi_log->buf)[pos]);\
  583. outlen += seq_printf(m, "Event ID = %x\n", \
  584. (wmi_record->event)); \
  585. outlen += seq_printf(m, "CMD = "); \
  586. for (i = 0; i < (wmi_record_max_length/ \
  587. sizeof(uint32_t)); i++) \
  588. outlen += seq_printf(m, "%x ", \
  589. wmi_record->data[i]); \
  590. outlen += seq_printf(m, "\n"); \
  591. \
  592. if (pos == 0) \
  593. pos = wmi_ring_size - 1; \
  594. else \
  595. pos--; \
  596. } \
  597. \
  598. return outlen; \
  599. }
  600. GENERATE_COMMAND_DEBUG_SHOW_FUNCS(command_log, wmi_display_size);
  601. GENERATE_COMMAND_DEBUG_SHOW_FUNCS(command_tx_cmp_log, wmi_display_size);
  602. GENERATE_EVENT_DEBUG_SHOW_FUNCS(event_log, wmi_display_size);
  603. GENERATE_EVENT_DEBUG_SHOW_FUNCS(rx_event_log, wmi_display_size);
  604. GENERATE_COMMAND_DEBUG_SHOW_FUNCS(mgmt_command_log, wmi_display_size);
  605. GENERATE_COMMAND_DEBUG_SHOW_FUNCS(mgmt_command_tx_cmp_log,
  606. wmi_display_size);
  607. GENERATE_EVENT_DEBUG_SHOW_FUNCS(mgmt_event_log, wmi_display_size);
  608. /**
  609. * debug_wmi_enable_show() - debugfs functions to display enable state of
  610. * wmi logging feature.
  611. *
  612. * @m: debugfs handler to access wmi_handle
  613. * @v: Variable arguments (not used)
  614. *
  615. * Return: always 1
  616. */
  617. static int debug_wmi_enable_show(struct seq_file *m, void *v)
  618. {
  619. wmi_unified_t wmi_handle = (wmi_unified_t) m->private;
  620. return seq_printf(m, "%d\n", wmi_handle->log_info.wmi_logging_enable);
  621. }
  622. /**
  623. * debug_wmi_log_size_show() - debugfs functions to display configured size of
  624. * wmi logging command/event buffer and management command/event buffer.
  625. *
  626. * @m: debugfs handler to access wmi_handle
  627. * @v: Variable arguments (not used)
  628. *
  629. * Return: Length of characters printed
  630. */
  631. static int debug_wmi_log_size_show(struct seq_file *m, void *v)
  632. {
  633. seq_printf(m, "WMI command/event log max size:%d\n", wmi_log_max_entry);
  634. return seq_printf(m, "WMI management command/events log max size:%d\n",
  635. wmi_mgmt_log_max_entry);
  636. }
  637. /**
  638. * debug_wmi_##func_base##_write() - debugfs functions to clear
  639. * wmi logging command/event buffer and management command/event buffer.
  640. *
  641. * @file: file handler to access wmi_handle
  642. * @buf: received data buffer
  643. * @count: length of received buffer
  644. * @ppos: Not used
  645. *
  646. * Return: count
  647. */
  648. #define GENERATE_DEBUG_WRITE_FUNCS(func_base, wmi_ring_size, wmi_record_type)\
  649. static ssize_t debug_wmi_##func_base##_write(struct file *file, \
  650. const char __user *buf, \
  651. size_t count, loff_t *ppos) \
  652. { \
  653. int k, ret; \
  654. wmi_unified_t wmi_handle = file->private_data; \
  655. struct wmi_log_buf_t *wmi_log = &wmi_handle->log_info. \
  656. wmi_##func_base##_buf_info; \
  657. \
  658. ret = sscanf(buf, "%d", &k); \
  659. if ((ret != 1) || (k != 0)) { \
  660. qdf_print("Wrong input, echo 0 to clear the wmi buffer\n");\
  661. return -EINVAL; \
  662. } \
  663. \
  664. qdf_spin_lock(&wmi_handle->log_info.wmi_record_lock); \
  665. qdf_mem_zero(wmi_log->buf, wmi_ring_size * \
  666. sizeof(struct wmi_record_type)); \
  667. wmi_log->length = 0; \
  668. *(wmi_log->p_buf_tail_idx) = 0; \
  669. qdf_spin_unlock(&wmi_handle->log_info.wmi_record_lock); \
  670. \
  671. return count; \
  672. }
  673. GENERATE_DEBUG_WRITE_FUNCS(command_log, wmi_log_max_entry,
  674. wmi_command_debug);
  675. GENERATE_DEBUG_WRITE_FUNCS(command_tx_cmp_log, wmi_log_max_entry,
  676. wmi_command_debug);
  677. GENERATE_DEBUG_WRITE_FUNCS(event_log, wmi_log_max_entry,
  678. wmi_event_debug);
  679. GENERATE_DEBUG_WRITE_FUNCS(rx_event_log, wmi_log_max_entry,
  680. wmi_event_debug);
  681. GENERATE_DEBUG_WRITE_FUNCS(mgmt_command_log, wmi_mgmt_log_max_entry,
  682. wmi_command_debug);
  683. GENERATE_DEBUG_WRITE_FUNCS(mgmt_command_tx_cmp_log,
  684. wmi_mgmt_log_max_entry, wmi_command_debug);
  685. GENERATE_DEBUG_WRITE_FUNCS(mgmt_event_log, wmi_mgmt_log_max_entry,
  686. wmi_event_debug);
  687. /**
  688. * debug_wmi_enable_write() - debugfs functions to enable/disable
  689. * wmi logging feature.
  690. *
  691. * @file: file handler to access wmi_handle
  692. * @buf: received data buffer
  693. * @count: length of received buffer
  694. * @ppos: Not used
  695. *
  696. * Return: count
  697. */
  698. static ssize_t debug_wmi_enable_write(struct file *file, const char __user *buf,
  699. size_t count, loff_t *ppos)
  700. {
  701. wmi_unified_t wmi_handle = file->private_data;
  702. int k, ret;
  703. ret = sscanf(buf, "%d", &k);
  704. if ((ret != 1) || ((k != 0) && (k != 1)))
  705. return -EINVAL;
  706. wmi_handle->log_info.wmi_logging_enable = k;
  707. return count;
  708. }
  709. /**
  710. * debug_wmi_log_size_write() - reserved.
  711. *
  712. * @file: file handler to access wmi_handle
  713. * @buf: received data buffer
  714. * @count: length of received buffer
  715. * @ppos: Not used
  716. *
  717. * Return: count
  718. */
  719. static ssize_t debug_wmi_log_size_write(struct file *file,
  720. const char __user *buf, size_t count, loff_t *ppos)
  721. {
  722. return -EINVAL;
  723. }
  724. /* Structure to maintain debug information */
  725. struct wmi_debugfs_info {
  726. const char *name;
  727. struct dentry *de[MAX_WMI_INSTANCES];
  728. const struct file_operations *ops;
  729. };
  730. #define DEBUG_FOO(func_base) { .name = #func_base, \
  731. .ops = &debug_##func_base##_ops }
  732. /**
  733. * debug_##func_base##_open() - Open debugfs entry for respective command
  734. * and event buffer.
  735. *
  736. * @inode: node for debug dir entry
  737. * @file: file handler
  738. *
  739. * Return: open status
  740. */
  741. #define GENERATE_DEBUG_STRUCTS(func_base) \
  742. static int debug_##func_base##_open(struct inode *inode, \
  743. struct file *file) \
  744. { \
  745. return single_open(file, debug_##func_base##_show, \
  746. inode->i_private); \
  747. } \
  748. \
  749. \
  750. static struct file_operations debug_##func_base##_ops = { \
  751. .open = debug_##func_base##_open, \
  752. .read = seq_read, \
  753. .llseek = seq_lseek, \
  754. .write = debug_##func_base##_write, \
  755. .release = single_release, \
  756. };
  757. GENERATE_DEBUG_STRUCTS(wmi_command_log);
  758. GENERATE_DEBUG_STRUCTS(wmi_command_tx_cmp_log);
  759. GENERATE_DEBUG_STRUCTS(wmi_event_log);
  760. GENERATE_DEBUG_STRUCTS(wmi_rx_event_log);
  761. GENERATE_DEBUG_STRUCTS(wmi_mgmt_command_log);
  762. GENERATE_DEBUG_STRUCTS(wmi_mgmt_command_tx_cmp_log);
  763. GENERATE_DEBUG_STRUCTS(wmi_mgmt_event_log);
  764. GENERATE_DEBUG_STRUCTS(wmi_enable);
  765. GENERATE_DEBUG_STRUCTS(wmi_log_size);
  766. struct wmi_debugfs_info wmi_debugfs_infos[] = {
  767. DEBUG_FOO(wmi_command_log),
  768. DEBUG_FOO(wmi_command_tx_cmp_log),
  769. DEBUG_FOO(wmi_event_log),
  770. DEBUG_FOO(wmi_rx_event_log),
  771. DEBUG_FOO(wmi_mgmt_command_log),
  772. DEBUG_FOO(wmi_mgmt_command_tx_cmp_log),
  773. DEBUG_FOO(wmi_mgmt_event_log),
  774. DEBUG_FOO(wmi_enable),
  775. DEBUG_FOO(wmi_log_size),
  776. };
  777. #define NUM_DEBUG_INFOS (sizeof(wmi_debugfs_infos) / \
  778. sizeof(wmi_debugfs_infos[0]))
  779. /**
  780. * wmi_debugfs_create() - Create debug_fs entry for wmi logging.
  781. *
  782. * @wmi_handle: wmi handle
  783. * @par_entry: debug directory entry
  784. * @id: Index to debug info data array
  785. *
  786. * Return: none
  787. */
  788. static void wmi_debugfs_create(wmi_unified_t wmi_handle,
  789. struct dentry *par_entry, int id)
  790. {
  791. int i;
  792. if (par_entry == NULL || (id < 0) || (id >= MAX_WMI_INSTANCES))
  793. goto out;
  794. for (i = 0; i < NUM_DEBUG_INFOS; ++i) {
  795. wmi_debugfs_infos[i].de[id] = debugfs_create_file(
  796. wmi_debugfs_infos[i].name, 0644, par_entry,
  797. wmi_handle, wmi_debugfs_infos[i].ops);
  798. if (wmi_debugfs_infos[i].de[id] == NULL) {
  799. qdf_print("%s: debug Entry creation failed!\n",
  800. __func__);
  801. goto out;
  802. }
  803. }
  804. return;
  805. out:
  806. qdf_print("%s: debug Entry creation failed!\n", __func__);
  807. wmi_log_buffer_free(wmi_handle);
  808. return;
  809. }
  810. /**
  811. * wmi_debugfs_remove() - Remove debugfs entry for wmi logging.
  812. * @wmi_handle: wmi handle
  813. * @dentry: debugfs directory entry
  814. * @id: Index to debug info data array
  815. *
  816. * Return: none
  817. */
  818. static void wmi_debugfs_remove(wmi_unified_t wmi_handle)
  819. {
  820. int i;
  821. struct dentry *dentry = wmi_handle->log_info.wmi_log_debugfs_dir;
  822. int id = wmi_handle->log_info.wmi_instance_id;
  823. if (dentry && (!(id < 0) || (id >= MAX_WMI_INSTANCES))) {
  824. for (i = 0; i < NUM_DEBUG_INFOS; ++i) {
  825. if (wmi_debugfs_infos[i].de[id])
  826. wmi_debugfs_infos[i].de[id] = NULL;
  827. }
  828. }
  829. if (dentry)
  830. debugfs_remove_recursive(dentry);
  831. }
  832. /**
  833. * wmi_debugfs_init() - debugfs functions to create debugfs directory and to
  834. * create debugfs enteries.
  835. *
  836. * @h: wmi handler
  837. *
  838. * Return: init status
  839. */
  840. static QDF_STATUS wmi_debugfs_init(wmi_unified_t wmi_handle)
  841. {
  842. static int wmi_index;
  843. if (wmi_index < MAX_WMI_INSTANCES)
  844. wmi_handle->log_info.wmi_log_debugfs_dir =
  845. debugfs_create_dir(debugfs_dir[wmi_index], NULL);
  846. if (wmi_handle->log_info.wmi_log_debugfs_dir == NULL) {
  847. qdf_print("error while creating debugfs dir for %s\n",
  848. debugfs_dir[wmi_index]);
  849. return QDF_STATUS_E_FAILURE;
  850. }
  851. wmi_debugfs_create(wmi_handle, wmi_handle->log_info.wmi_log_debugfs_dir,
  852. wmi_index);
  853. wmi_handle->log_info.wmi_instance_id = wmi_index++;
  854. return QDF_STATUS_SUCCESS;
  855. }
  856. /**
  857. * wmi_mgmt_cmd_record() - Wrapper function for mgmt command logging macro
  858. *
  859. * @wmi_handle: wmi handle
  860. * @cmd: mgmt command
  861. * @header: pointer to 802.11 header
  862. * @vdev_id: vdev id
  863. * @chanfreq: channel frequency
  864. *
  865. * Return: none
  866. */
  867. void wmi_mgmt_cmd_record(wmi_unified_t wmi_handle, uint32_t cmd,
  868. void *header, uint32_t vdev_id, uint32_t chanfreq)
  869. {
  870. uint32_t data[CUSTOM_MGMT_CMD_DATA_SIZE];
  871. data[0] = ((struct wmi_command_header *)header)->type;
  872. data[1] = ((struct wmi_command_header *)header)->sub_type;
  873. data[2] = vdev_id;
  874. data[3] = chanfreq;
  875. qdf_spin_lock_bh(&wmi_handle->log_info.wmi_record_lock);
  876. WMI_MGMT_COMMAND_RECORD(wmi_handle, cmd, data);
  877. qdf_spin_unlock_bh(&wmi_handle->log_info.wmi_record_lock);
  878. }
  879. #else
  880. /**
  881. * wmi_debugfs_remove() - Remove debugfs entry for wmi logging.
  882. * @wmi_handle: wmi handle
  883. * @dentry: debugfs directory entry
  884. * @id: Index to debug info data array
  885. *
  886. * Return: none
  887. */
  888. static void wmi_debugfs_remove(wmi_unified_t wmi_handle) { }
  889. void wmi_mgmt_cmd_record(wmi_unified_t wmi_handle, uint32_t cmd,
  890. void *header, uint32_t vdev_id, uint32_t chanfreq) { }
  891. #endif /*WMI_INTERFACE_EVENT_LOGGING */
  892. int wmi_get_host_credits(wmi_unified_t wmi_handle);
  893. /* WMI buffer APIs */
  894. #ifdef MEMORY_DEBUG
  895. wmi_buf_t
  896. wmi_buf_alloc_debug(wmi_unified_t wmi_handle, uint16_t len, uint8_t *file_name,
  897. uint32_t line_num)
  898. {
  899. wmi_buf_t wmi_buf;
  900. if (roundup(len + WMI_MIN_HEAD_ROOM, 4) > wmi_handle->max_msg_len) {
  901. QDF_ASSERT(0);
  902. return NULL;
  903. }
  904. wmi_buf = qdf_nbuf_alloc_debug(NULL,
  905. roundup(len + WMI_MIN_HEAD_ROOM, 4),
  906. WMI_MIN_HEAD_ROOM, 4, false, file_name,
  907. line_num);
  908. if (!wmi_buf)
  909. return NULL;
  910. /* Clear the wmi buffer */
  911. OS_MEMZERO(qdf_nbuf_data(wmi_buf), len);
  912. /*
  913. * Set the length of the buffer to match the allocation size.
  914. */
  915. qdf_nbuf_set_pktlen(wmi_buf, len);
  916. return wmi_buf;
  917. }
  918. void wmi_buf_free(wmi_buf_t net_buf)
  919. {
  920. qdf_nbuf_free(net_buf);
  921. }
  922. #else
  923. wmi_buf_t wmi_buf_alloc(wmi_unified_t wmi_handle, uint16_t len)
  924. {
  925. wmi_buf_t wmi_buf;
  926. if (roundup(len + WMI_MIN_HEAD_ROOM, 4) > wmi_handle->max_msg_len) {
  927. QDF_ASSERT(0);
  928. return NULL;
  929. }
  930. wmi_buf = qdf_nbuf_alloc(NULL, roundup(len + WMI_MIN_HEAD_ROOM, 4),
  931. WMI_MIN_HEAD_ROOM, 4, false);
  932. if (!wmi_buf)
  933. return NULL;
  934. /* Clear the wmi buffer */
  935. OS_MEMZERO(qdf_nbuf_data(wmi_buf), len);
  936. /*
  937. * Set the length of the buffer to match the allocation size.
  938. */
  939. qdf_nbuf_set_pktlen(wmi_buf, len);
  940. return wmi_buf;
  941. }
  942. void wmi_buf_free(wmi_buf_t net_buf)
  943. {
  944. qdf_nbuf_free(net_buf);
  945. }
  946. #endif
  947. /**
  948. * wmi_get_max_msg_len() - get maximum WMI message length
  949. * @wmi_handle: WMI handle.
  950. *
  951. * This function returns the maximum WMI message length
  952. *
  953. * Return: maximum WMI message length
  954. */
  955. uint16_t wmi_get_max_msg_len(wmi_unified_t wmi_handle)
  956. {
  957. return wmi_handle->max_msg_len - WMI_MIN_HEAD_ROOM;
  958. }
  959. #ifdef CONFIG_MCL
  960. static uint8_t *wmi_id_to_name(uint32_t wmi_command)
  961. {
  962. switch (wmi_command) {
  963. /* initialize the wlan sub system */
  964. CASE_RETURN_STRING(WMI_INIT_CMDID);
  965. /* Scan specific commands */
  966. /* start scan request to FW */
  967. CASE_RETURN_STRING(WMI_START_SCAN_CMDID);
  968. /* stop scan request to FW */
  969. CASE_RETURN_STRING(WMI_STOP_SCAN_CMDID);
  970. /* full list of channels as defined by the regulatory
  971. * that will be used by scanner */
  972. CASE_RETURN_STRING(WMI_SCAN_CHAN_LIST_CMDID);
  973. /* overwrite default priority table in scan scheduler */
  974. CASE_RETURN_STRING(WMI_SCAN_SCH_PRIO_TBL_CMDID);
  975. /* This command to adjust the priority and min.max_rest_time
  976. * of an on ongoing scan request.
  977. */
  978. CASE_RETURN_STRING(WMI_SCAN_UPDATE_REQUEST_CMDID);
  979. /* PDEV(physical device) specific commands */
  980. /* set regulatorty ctl id used by FW to determine the exact
  981. * ctl power limits */
  982. CASE_RETURN_STRING(WMI_PDEV_SET_REGDOMAIN_CMDID);
  983. /* set channel. mainly used for supporting monitor mode */
  984. CASE_RETURN_STRING(WMI_PDEV_SET_CHANNEL_CMDID);
  985. /* set pdev specific parameters */
  986. CASE_RETURN_STRING(WMI_PDEV_SET_PARAM_CMDID);
  987. /* enable packet log */
  988. CASE_RETURN_STRING(WMI_PDEV_PKTLOG_ENABLE_CMDID);
  989. /* disable packet log*/
  990. CASE_RETURN_STRING(WMI_PDEV_PKTLOG_DISABLE_CMDID);
  991. /* set wmm parameters */
  992. CASE_RETURN_STRING(WMI_PDEV_SET_WMM_PARAMS_CMDID);
  993. /* set HT cap ie that needs to be carried probe requests
  994. * HT/VHT channels */
  995. CASE_RETURN_STRING(WMI_PDEV_SET_HT_CAP_IE_CMDID);
  996. /* set VHT cap ie that needs to be carried on probe
  997. * requests on VHT channels */
  998. CASE_RETURN_STRING(WMI_PDEV_SET_VHT_CAP_IE_CMDID);
  999. /* Command to send the DSCP-to-TID map to the target */
  1000. CASE_RETURN_STRING(WMI_PDEV_SET_DSCP_TID_MAP_CMDID);
  1001. /* set quiet ie parameters. primarily used in AP mode */
  1002. CASE_RETURN_STRING(WMI_PDEV_SET_QUIET_MODE_CMDID);
  1003. /* Enable/Disable Green AP Power Save */
  1004. CASE_RETURN_STRING(WMI_PDEV_GREEN_AP_PS_ENABLE_CMDID);
  1005. /* get TPC config for the current operating channel */
  1006. CASE_RETURN_STRING(WMI_PDEV_GET_TPC_CONFIG_CMDID);
  1007. /* set the base MAC address for the physical device before
  1008. * a VDEV is created. For firmware that does not support
  1009. * this feature and this command, the pdev MAC address will
  1010. * not be changed. */
  1011. CASE_RETURN_STRING(WMI_PDEV_SET_BASE_MACADDR_CMDID);
  1012. /* eeprom content dump , the same to bdboard data */
  1013. CASE_RETURN_STRING(WMI_PDEV_DUMP_CMDID);
  1014. /* VDEV(virtual device) specific commands */
  1015. /* vdev create */
  1016. CASE_RETURN_STRING(WMI_VDEV_CREATE_CMDID);
  1017. /* vdev delete */
  1018. CASE_RETURN_STRING(WMI_VDEV_DELETE_CMDID);
  1019. /* vdev start request */
  1020. CASE_RETURN_STRING(WMI_VDEV_START_REQUEST_CMDID);
  1021. /* vdev restart request (RX only, NO TX, used for CAC period)*/
  1022. CASE_RETURN_STRING(WMI_VDEV_RESTART_REQUEST_CMDID);
  1023. /* vdev up request */
  1024. CASE_RETURN_STRING(WMI_VDEV_UP_CMDID);
  1025. /* vdev stop request */
  1026. CASE_RETURN_STRING(WMI_VDEV_STOP_CMDID);
  1027. /* vdev down request */
  1028. CASE_RETURN_STRING(WMI_VDEV_DOWN_CMDID);
  1029. /* set a vdev param */
  1030. CASE_RETURN_STRING(WMI_VDEV_SET_PARAM_CMDID);
  1031. /* set a key (used for setting per peer unicast
  1032. * and per vdev multicast) */
  1033. CASE_RETURN_STRING(WMI_VDEV_INSTALL_KEY_CMDID);
  1034. /* wnm sleep mode command */
  1035. CASE_RETURN_STRING(WMI_VDEV_WNM_SLEEPMODE_CMDID);
  1036. CASE_RETURN_STRING(WMI_VDEV_WMM_ADDTS_CMDID);
  1037. CASE_RETURN_STRING(WMI_VDEV_WMM_DELTS_CMDID);
  1038. CASE_RETURN_STRING(WMI_VDEV_SET_WMM_PARAMS_CMDID);
  1039. CASE_RETURN_STRING(WMI_VDEV_SET_GTX_PARAMS_CMDID);
  1040. CASE_RETURN_STRING(WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMDID);
  1041. CASE_RETURN_STRING(WMI_VDEV_PLMREQ_START_CMDID);
  1042. CASE_RETURN_STRING(WMI_VDEV_PLMREQ_STOP_CMDID);
  1043. CASE_RETURN_STRING(WMI_VDEV_TSF_TSTAMP_ACTION_CMDID);
  1044. CASE_RETURN_STRING(WMI_VDEV_SET_IE_CMDID);
  1045. /* peer specific commands */
  1046. /** create a peer */
  1047. CASE_RETURN_STRING(WMI_PEER_CREATE_CMDID);
  1048. /** delete a peer */
  1049. CASE_RETURN_STRING(WMI_PEER_DELETE_CMDID);
  1050. /** flush specific tid queues of a peer */
  1051. CASE_RETURN_STRING(WMI_PEER_FLUSH_TIDS_CMDID);
  1052. /** set a parameter of a peer */
  1053. CASE_RETURN_STRING(WMI_PEER_SET_PARAM_CMDID);
  1054. /* set peer to associated state. will cary all parameters
  1055. * determined during assocication time */
  1056. CASE_RETURN_STRING(WMI_PEER_ASSOC_CMDID);
  1057. /* add a wds (4 address ) entry. used only for testing
  1058. * WDS feature on AP products */
  1059. CASE_RETURN_STRING(WMI_PEER_ADD_WDS_ENTRY_CMDID);
  1060. /* remove wds (4 address ) entry. used only for testing WDS
  1061. * feature on AP products */
  1062. CASE_RETURN_STRING(WMI_PEER_REMOVE_WDS_ENTRY_CMDID);
  1063. /* set up mcast info for multicast to unicast conversion */
  1064. CASE_RETURN_STRING(WMI_PEER_MCAST_GROUP_CMDID);
  1065. /* request peer info from FW to get PEER_INFO_EVENTID */
  1066. CASE_RETURN_STRING(WMI_PEER_INFO_REQ_CMDID);
  1067. /* beacon/management specific commands */
  1068. /* transmit beacon by reference. used for transmitting beacon
  1069. * on low latency interface like pcie */
  1070. CASE_RETURN_STRING(WMI_BCN_TX_CMDID);
  1071. /* transmit beacon by value */
  1072. CASE_RETURN_STRING(WMI_PDEV_SEND_BCN_CMDID);
  1073. /* set the beacon template. used in beacon offload mode to setup
  1074. * the common beacon template with the FW to be used by FW to
  1075. * generate beacons */
  1076. CASE_RETURN_STRING(WMI_BCN_TMPL_CMDID);
  1077. /* set beacon filter with FW */
  1078. CASE_RETURN_STRING(WMI_BCN_FILTER_RX_CMDID);
  1079. /* enable/disable filtering of probe requests in the firmware */
  1080. CASE_RETURN_STRING(WMI_PRB_REQ_FILTER_RX_CMDID);
  1081. /* transmit management frame by value. will be deprecated */
  1082. CASE_RETURN_STRING(WMI_MGMT_TX_CMDID);
  1083. /* set the probe response template. used in beacon offload mode
  1084. * to setup the common probe response template with the FW to
  1085. * be used by FW to generate probe responses */
  1086. CASE_RETURN_STRING(WMI_PRB_TMPL_CMDID);
  1087. /* commands to directly control ba negotiation directly from
  1088. * host. only used in test mode */
  1089. /* turn off FW Auto addba mode and let host control addba */
  1090. CASE_RETURN_STRING(WMI_ADDBA_CLEAR_RESP_CMDID);
  1091. /* send add ba request */
  1092. CASE_RETURN_STRING(WMI_ADDBA_SEND_CMDID);
  1093. CASE_RETURN_STRING(WMI_ADDBA_STATUS_CMDID);
  1094. /* send del ba */
  1095. CASE_RETURN_STRING(WMI_DELBA_SEND_CMDID);
  1096. /* set add ba response will be used by FW to generate
  1097. * addba response*/
  1098. CASE_RETURN_STRING(WMI_ADDBA_SET_RESP_CMDID);
  1099. /* send single VHT MPDU with AMSDU */
  1100. CASE_RETURN_STRING(WMI_SEND_SINGLEAMSDU_CMDID);
  1101. /* Station power save specific config */
  1102. /* enable/disable station powersave */
  1103. CASE_RETURN_STRING(WMI_STA_POWERSAVE_MODE_CMDID);
  1104. /* set station power save specific parameter */
  1105. CASE_RETURN_STRING(WMI_STA_POWERSAVE_PARAM_CMDID);
  1106. /* set station mimo powersave mode */
  1107. CASE_RETURN_STRING(WMI_STA_MIMO_PS_MODE_CMDID);
  1108. /* DFS-specific commands */
  1109. /* enable DFS (radar detection)*/
  1110. CASE_RETURN_STRING(WMI_PDEV_DFS_ENABLE_CMDID);
  1111. /* disable DFS (radar detection)*/
  1112. CASE_RETURN_STRING(WMI_PDEV_DFS_DISABLE_CMDID);
  1113. /* enable DFS phyerr/parse filter offload */
  1114. CASE_RETURN_STRING(WMI_DFS_PHYERR_FILTER_ENA_CMDID);
  1115. /* enable DFS phyerr/parse filter offload */
  1116. CASE_RETURN_STRING(WMI_DFS_PHYERR_FILTER_DIS_CMDID);
  1117. /* Roaming specific commands */
  1118. /* set roam scan mode */
  1119. CASE_RETURN_STRING(WMI_ROAM_SCAN_MODE);
  1120. /* set roam scan rssi threshold below which roam
  1121. * scan is enabled */
  1122. CASE_RETURN_STRING(WMI_ROAM_SCAN_RSSI_THRESHOLD);
  1123. /* set roam scan period for periodic roam scan mode */
  1124. CASE_RETURN_STRING(WMI_ROAM_SCAN_PERIOD);
  1125. /* set roam scan trigger rssi change threshold */
  1126. CASE_RETURN_STRING(WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD);
  1127. /* set roam AP profile */
  1128. CASE_RETURN_STRING(WMI_ROAM_AP_PROFILE);
  1129. /* set channel list for roam scans */
  1130. CASE_RETURN_STRING(WMI_ROAM_CHAN_LIST);
  1131. /* offload scan specific commands */
  1132. /* set offload scan AP profile */
  1133. CASE_RETURN_STRING(WMI_OFL_SCAN_ADD_AP_PROFILE);
  1134. /* remove offload scan AP profile */
  1135. CASE_RETURN_STRING(WMI_OFL_SCAN_REMOVE_AP_PROFILE);
  1136. /* set offload scan period */
  1137. CASE_RETURN_STRING(WMI_OFL_SCAN_PERIOD);
  1138. /* P2P specific commands */
  1139. /* set P2P device info. FW will used by FW to create P2P IE
  1140. * to be carried in probe response generated during p2p listen
  1141. * and for p2p discoverability */
  1142. CASE_RETURN_STRING(WMI_P2P_DEV_SET_DEVICE_INFO);
  1143. /* enable/disable p2p discoverability on STA/AP VDEVs */
  1144. CASE_RETURN_STRING(WMI_P2P_DEV_SET_DISCOVERABILITY);
  1145. /* set p2p ie to be carried in beacons generated by FW for GO */
  1146. CASE_RETURN_STRING(WMI_P2P_GO_SET_BEACON_IE);
  1147. /* set p2p ie to be carried in probe response frames generated
  1148. * by FW for GO */
  1149. CASE_RETURN_STRING(WMI_P2P_GO_SET_PROBE_RESP_IE);
  1150. /* set the vendor specific p2p ie data.
  1151. * FW will use this to parse the P2P NoA
  1152. * attribute in the beacons/probe responses received.
  1153. */
  1154. CASE_RETURN_STRING(WMI_P2P_SET_VENDOR_IE_DATA_CMDID);
  1155. /* set the configure of p2p find offload */
  1156. CASE_RETURN_STRING(WMI_P2P_DISC_OFFLOAD_CONFIG_CMDID);
  1157. /* set the vendor specific p2p ie data for p2p find offload */
  1158. CASE_RETURN_STRING(WMI_P2P_DISC_OFFLOAD_APPIE_CMDID);
  1159. /* set the BSSID/device name pattern of p2p find offload */
  1160. CASE_RETURN_STRING(WMI_P2P_DISC_OFFLOAD_PATTERN_CMDID);
  1161. /* set OppPS related parameters **/
  1162. CASE_RETURN_STRING(WMI_P2P_SET_OPPPS_PARAM_CMDID);
  1163. /* AP power save specific config
  1164. * set AP power save specific param */
  1165. CASE_RETURN_STRING(WMI_AP_PS_PEER_PARAM_CMDID);
  1166. /* set AP UAPSD coex pecific param */
  1167. CASE_RETURN_STRING(WMI_AP_PS_PEER_UAPSD_COEX_CMDID);
  1168. /* Rate-control specific commands */
  1169. CASE_RETURN_STRING(WMI_PEER_RATE_RETRY_SCHED_CMDID);
  1170. /* WLAN Profiling commands. */
  1171. CASE_RETURN_STRING(WMI_WLAN_PROFILE_TRIGGER_CMDID);
  1172. CASE_RETURN_STRING(WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID);
  1173. CASE_RETURN_STRING(WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID);
  1174. CASE_RETURN_STRING(WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID);
  1175. CASE_RETURN_STRING(WMI_WLAN_PROFILE_LIST_PROFILE_ID_CMDID);
  1176. /* Suspend resume command Ids */
  1177. CASE_RETURN_STRING(WMI_PDEV_SUSPEND_CMDID);
  1178. CASE_RETURN_STRING(WMI_PDEV_RESUME_CMDID);
  1179. /* Beacon filter commands */
  1180. /* add a beacon filter */
  1181. CASE_RETURN_STRING(WMI_ADD_BCN_FILTER_CMDID);
  1182. /* remove a beacon filter */
  1183. CASE_RETURN_STRING(WMI_RMV_BCN_FILTER_CMDID);
  1184. /* WOW Specific WMI commands */
  1185. /* add pattern for awake */
  1186. CASE_RETURN_STRING(WMI_WOW_ADD_WAKE_PATTERN_CMDID);
  1187. /* deleta a wake pattern */
  1188. CASE_RETURN_STRING(WMI_WOW_DEL_WAKE_PATTERN_CMDID);
  1189. /* enable/deisable wake event */
  1190. CASE_RETURN_STRING(WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID);
  1191. /* enable WOW */
  1192. CASE_RETURN_STRING(WMI_WOW_ENABLE_CMDID);
  1193. /* host woke up from sleep event to FW. Generated in response
  1194. * to WOW Hardware event */
  1195. CASE_RETURN_STRING(WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID);
  1196. /* RTT measurement related cmd */
  1197. /* reques to make an RTT measurement */
  1198. CASE_RETURN_STRING(WMI_RTT_MEASREQ_CMDID);
  1199. /* reques to report a tsf measurement */
  1200. CASE_RETURN_STRING(WMI_RTT_TSF_CMDID);
  1201. /* spectral scan command */
  1202. /* configure spectral scan */
  1203. CASE_RETURN_STRING(WMI_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID);
  1204. /* enable/disable spectral scan and trigger */
  1205. CASE_RETURN_STRING(WMI_VDEV_SPECTRAL_SCAN_ENABLE_CMDID);
  1206. /* F/W stats */
  1207. /* one time request for stats */
  1208. CASE_RETURN_STRING(WMI_REQUEST_STATS_CMDID);
  1209. /* Push MCC Adaptive Scheduler Stats to Firmware */
  1210. CASE_RETURN_STRING(WMI_MCC_SCHED_TRAFFIC_STATS_CMDID);
  1211. /* ARP OFFLOAD REQUEST*/
  1212. CASE_RETURN_STRING(WMI_SET_ARP_NS_OFFLOAD_CMDID);
  1213. /* Proactive ARP Response Add Pattern Command*/
  1214. CASE_RETURN_STRING(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMDID);
  1215. /* Proactive ARP Response Del Pattern Command*/
  1216. CASE_RETURN_STRING(WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMDID);
  1217. /* NS offload confid*/
  1218. CASE_RETURN_STRING(WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
  1219. /* GTK offload Specific WMI commands */
  1220. CASE_RETURN_STRING(WMI_GTK_OFFLOAD_CMDID);
  1221. /* CSA offload Specific WMI commands */
  1222. /* csa offload enable */
  1223. CASE_RETURN_STRING(WMI_CSA_OFFLOAD_ENABLE_CMDID);
  1224. /* chan switch command */
  1225. CASE_RETURN_STRING(WMI_CSA_OFFLOAD_CHANSWITCH_CMDID);
  1226. /* Chatter commands */
  1227. /* Change chatter mode of operation */
  1228. CASE_RETURN_STRING(WMI_CHATTER_SET_MODE_CMDID);
  1229. /* chatter add coalescing filter command */
  1230. CASE_RETURN_STRING(WMI_CHATTER_ADD_COALESCING_FILTER_CMDID);
  1231. /* chatter delete coalescing filter command */
  1232. CASE_RETURN_STRING(WMI_CHATTER_DELETE_COALESCING_FILTER_CMDID);
  1233. /* chatter coalecing query command */
  1234. CASE_RETURN_STRING(WMI_CHATTER_COALESCING_QUERY_CMDID);
  1235. /* addba specific commands */
  1236. /* start the aggregation on this TID */
  1237. CASE_RETURN_STRING(WMI_PEER_TID_ADDBA_CMDID);
  1238. /* stop the aggregation on this TID */
  1239. CASE_RETURN_STRING(WMI_PEER_TID_DELBA_CMDID);
  1240. /* set station mimo powersave method */
  1241. CASE_RETURN_STRING(WMI_STA_DTIM_PS_METHOD_CMDID);
  1242. /* Configure the Station UAPSD AC Auto Trigger Parameters */
  1243. CASE_RETURN_STRING(WMI_STA_UAPSD_AUTO_TRIG_CMDID);
  1244. /* Configure the Keep Alive Parameters */
  1245. CASE_RETURN_STRING(WMI_STA_KEEPALIVE_CMDID);
  1246. /* Request ssn from target for a sta/tid pair */
  1247. CASE_RETURN_STRING(WMI_BA_REQ_SSN_CMDID);
  1248. /* misc command group */
  1249. /* echo command mainly used for testing */
  1250. CASE_RETURN_STRING(WMI_ECHO_CMDID);
  1251. /* !!IMPORTANT!!
  1252. * If you need to add a new WMI command to the CASE_RETURN_STRING(WMI_GRP_MISC sub-group,
  1253. * please make sure you add it BEHIND CASE_RETURN_STRING(WMI_PDEV_UTF_CMDID);
  1254. * as we MUST have a fixed value here to maintain compatibility between
  1255. * UTF and the ART2 driver
  1256. */
  1257. /* UTF WMI commands */
  1258. CASE_RETURN_STRING(WMI_PDEV_UTF_CMDID);
  1259. /* set debug log config */
  1260. CASE_RETURN_STRING(WMI_DBGLOG_CFG_CMDID);
  1261. /* QVIT specific command id */
  1262. CASE_RETURN_STRING(WMI_PDEV_QVIT_CMDID);
  1263. /* Factory Testing Mode request command
  1264. * used for integrated chipsets */
  1265. CASE_RETURN_STRING(WMI_PDEV_FTM_INTG_CMDID);
  1266. /* set and get keepalive parameters command */
  1267. CASE_RETURN_STRING(WMI_VDEV_SET_KEEPALIVE_CMDID);
  1268. CASE_RETURN_STRING(WMI_VDEV_GET_KEEPALIVE_CMDID);
  1269. /* For fw recovery test command */
  1270. CASE_RETURN_STRING(WMI_FORCE_FW_HANG_CMDID);
  1271. /* Set Mcast/Bdcast filter */
  1272. CASE_RETURN_STRING(WMI_SET_MCASTBCAST_FILTER_CMDID);
  1273. /* set thermal management params */
  1274. CASE_RETURN_STRING(WMI_THERMAL_MGMT_CMDID);
  1275. CASE_RETURN_STRING(WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID);
  1276. CASE_RETURN_STRING(WMI_LRO_CONFIG_CMDID);
  1277. CASE_RETURN_STRING(WMI_TRANSFER_DATA_TO_FLASH_CMDID);
  1278. CASE_RETURN_STRING(WMI_CONFIG_ENHANCED_MCAST_FILTER_CMDID);
  1279. CASE_RETURN_STRING(WMI_VDEV_WISA_CMDID);
  1280. CASE_RETURN_STRING(WMI_SCAN_ADAPTIVE_DWELL_CONFIG_CMDID);
  1281. CASE_RETURN_STRING(WMI_WOW_SET_ACTION_WAKE_UP_CMDID);
  1282. CASE_RETURN_STRING(WMI_MAWC_SENSOR_REPORT_IND_CMDID);
  1283. CASE_RETURN_STRING(WMI_ROAM_CONFIGURE_MAWC_CMDID);
  1284. CASE_RETURN_STRING(WMI_NLO_CONFIGURE_MAWC_CMDID);
  1285. CASE_RETURN_STRING(WMI_EXTSCAN_CONFIGURE_MAWC_CMDID);
  1286. /* GPIO Configuration */
  1287. CASE_RETURN_STRING(WMI_GPIO_CONFIG_CMDID);
  1288. CASE_RETURN_STRING(WMI_GPIO_OUTPUT_CMDID);
  1289. /* Txbf configuration command */
  1290. CASE_RETURN_STRING(WMI_TXBF_CMDID);
  1291. /* FWTEST Commands */
  1292. CASE_RETURN_STRING(WMI_FWTEST_VDEV_MCC_SET_TBTT_MODE_CMDID);
  1293. /* set NoA descs */
  1294. CASE_RETURN_STRING(WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID);
  1295. /* TDLS Configuration */
  1296. /* enable/disable TDLS */
  1297. CASE_RETURN_STRING(WMI_TDLS_SET_STATE_CMDID);
  1298. /* set tdls peer state */
  1299. CASE_RETURN_STRING(WMI_TDLS_PEER_UPDATE_CMDID);
  1300. /* Resmgr Configuration */
  1301. /* Adaptive OCS is enabled by default in the FW.
  1302. * This command is used to disable FW based adaptive OCS.
  1303. */
  1304. CASE_RETURN_STRING
  1305. (WMI_RESMGR_ADAPTIVE_OCS_ENABLE_DISABLE_CMDID);
  1306. /* set the requested channel time quota for the home channels */
  1307. CASE_RETURN_STRING(WMI_RESMGR_SET_CHAN_TIME_QUOTA_CMDID);
  1308. /* set the requested latency for the home channels */
  1309. CASE_RETURN_STRING(WMI_RESMGR_SET_CHAN_LATENCY_CMDID);
  1310. /* STA SMPS Configuration */
  1311. /* force SMPS mode */
  1312. CASE_RETURN_STRING(WMI_STA_SMPS_FORCE_MODE_CMDID);
  1313. /* set SMPS parameters */
  1314. CASE_RETURN_STRING(WMI_STA_SMPS_PARAM_CMDID);
  1315. /* Wlan HB commands */
  1316. /* enalbe/disable wlan HB */
  1317. CASE_RETURN_STRING(WMI_HB_SET_ENABLE_CMDID);
  1318. /* set tcp parameters for wlan HB */
  1319. CASE_RETURN_STRING(WMI_HB_SET_TCP_PARAMS_CMDID);
  1320. /* set tcp pkt filter for wlan HB */
  1321. CASE_RETURN_STRING(WMI_HB_SET_TCP_PKT_FILTER_CMDID);
  1322. /* set udp parameters for wlan HB */
  1323. CASE_RETURN_STRING(WMI_HB_SET_UDP_PARAMS_CMDID);
  1324. /* set udp pkt filter for wlan HB */
  1325. CASE_RETURN_STRING(WMI_HB_SET_UDP_PKT_FILTER_CMDID);
  1326. /* Wlan RMC commands*/
  1327. /* enable/disable RMC */
  1328. CASE_RETURN_STRING(WMI_RMC_SET_MODE_CMDID);
  1329. /* configure action frame period */
  1330. CASE_RETURN_STRING(WMI_RMC_SET_ACTION_PERIOD_CMDID);
  1331. /* For debug/future enhancement purposes only,
  1332. * configures/finetunes RMC algorithms */
  1333. CASE_RETURN_STRING(WMI_RMC_CONFIG_CMDID);
  1334. /* WLAN MHF offload commands */
  1335. /* enable/disable MHF offload */
  1336. CASE_RETURN_STRING(WMI_MHF_OFFLOAD_SET_MODE_CMDID);
  1337. /* Plumb routing table for MHF offload */
  1338. CASE_RETURN_STRING(WMI_MHF_OFFLOAD_PLUMB_ROUTING_TBL_CMDID);
  1339. /* location scan commands */
  1340. /* start batch scan */
  1341. CASE_RETURN_STRING(WMI_BATCH_SCAN_ENABLE_CMDID);
  1342. /* stop batch scan */
  1343. CASE_RETURN_STRING(WMI_BATCH_SCAN_DISABLE_CMDID);
  1344. /* get batch scan result */
  1345. CASE_RETURN_STRING(WMI_BATCH_SCAN_TRIGGER_RESULT_CMDID);
  1346. /* OEM related cmd */
  1347. CASE_RETURN_STRING(WMI_OEM_REQ_CMDID);
  1348. CASE_RETURN_STRING(WMI_OEM_REQUEST_CMDID);
  1349. /* NAN request cmd */
  1350. CASE_RETURN_STRING(WMI_NAN_CMDID);
  1351. /* Modem power state cmd */
  1352. CASE_RETURN_STRING(WMI_MODEM_POWER_STATE_CMDID);
  1353. CASE_RETURN_STRING(WMI_REQUEST_STATS_EXT_CMDID);
  1354. CASE_RETURN_STRING(WMI_OBSS_SCAN_ENABLE_CMDID);
  1355. CASE_RETURN_STRING(WMI_OBSS_SCAN_DISABLE_CMDID);
  1356. CASE_RETURN_STRING(WMI_PEER_GET_ESTIMATED_LINKSPEED_CMDID);
  1357. CASE_RETURN_STRING(WMI_ROAM_SCAN_CMD);
  1358. CASE_RETURN_STRING(WMI_PDEV_SET_LED_CONFIG_CMDID);
  1359. CASE_RETURN_STRING(WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID);
  1360. CASE_RETURN_STRING(WMI_CHAN_AVOID_UPDATE_CMDID);
  1361. CASE_RETURN_STRING(WMI_COEX_CONFIG_CMDID);
  1362. CASE_RETURN_STRING(WMI_WOW_IOAC_ADD_KEEPALIVE_CMDID);
  1363. CASE_RETURN_STRING(WMI_WOW_IOAC_DEL_KEEPALIVE_CMDID);
  1364. CASE_RETURN_STRING(WMI_WOW_IOAC_ADD_WAKE_PATTERN_CMDID);
  1365. CASE_RETURN_STRING(WMI_WOW_IOAC_DEL_WAKE_PATTERN_CMDID);
  1366. CASE_RETURN_STRING(WMI_REQUEST_LINK_STATS_CMDID);
  1367. CASE_RETURN_STRING(WMI_START_LINK_STATS_CMDID);
  1368. CASE_RETURN_STRING(WMI_CLEAR_LINK_STATS_CMDID);
  1369. CASE_RETURN_STRING(WMI_GET_FW_MEM_DUMP_CMDID);
  1370. CASE_RETURN_STRING(WMI_LPI_MGMT_SNOOPING_CONFIG_CMDID);
  1371. CASE_RETURN_STRING(WMI_LPI_START_SCAN_CMDID);
  1372. CASE_RETURN_STRING(WMI_LPI_STOP_SCAN_CMDID);
  1373. CASE_RETURN_STRING(WMI_EXTSCAN_START_CMDID);
  1374. CASE_RETURN_STRING(WMI_EXTSCAN_STOP_CMDID);
  1375. CASE_RETURN_STRING
  1376. (WMI_EXTSCAN_CONFIGURE_WLAN_CHANGE_MONITOR_CMDID);
  1377. CASE_RETURN_STRING(WMI_EXTSCAN_CONFIGURE_HOTLIST_MONITOR_CMDID);
  1378. CASE_RETURN_STRING(WMI_EXTSCAN_GET_CACHED_RESULTS_CMDID);
  1379. CASE_RETURN_STRING(WMI_EXTSCAN_GET_WLAN_CHANGE_RESULTS_CMDID);
  1380. CASE_RETURN_STRING(WMI_EXTSCAN_SET_CAPABILITIES_CMDID);
  1381. CASE_RETURN_STRING(WMI_EXTSCAN_GET_CAPABILITIES_CMDID);
  1382. CASE_RETURN_STRING(WMI_EXTSCAN_CONFIGURE_HOTLIST_SSID_MONITOR_CMDID);
  1383. CASE_RETURN_STRING(WMI_ROAM_SYNCH_COMPLETE);
  1384. CASE_RETURN_STRING(WMI_D0_WOW_ENABLE_DISABLE_CMDID);
  1385. CASE_RETURN_STRING(WMI_EXTWOW_ENABLE_CMDID);
  1386. CASE_RETURN_STRING(WMI_EXTWOW_SET_APP_TYPE1_PARAMS_CMDID);
  1387. CASE_RETURN_STRING(WMI_EXTWOW_SET_APP_TYPE2_PARAMS_CMDID);
  1388. CASE_RETURN_STRING(WMI_UNIT_TEST_CMDID);
  1389. CASE_RETURN_STRING(WMI_ROAM_SET_RIC_REQUEST_CMDID);
  1390. CASE_RETURN_STRING(WMI_PDEV_GET_TEMPERATURE_CMDID);
  1391. CASE_RETURN_STRING(WMI_SET_DHCP_SERVER_OFFLOAD_CMDID);
  1392. CASE_RETURN_STRING(WMI_TPC_CHAINMASK_CONFIG_CMDID);
  1393. CASE_RETURN_STRING(WMI_IPA_OFFLOAD_ENABLE_DISABLE_CMDID);
  1394. CASE_RETURN_STRING(WMI_SCAN_PROB_REQ_OUI_CMDID);
  1395. CASE_RETURN_STRING(WMI_TDLS_SET_OFFCHAN_MODE_CMDID);
  1396. CASE_RETURN_STRING(WMI_PDEV_SET_LED_FLASHING_CMDID);
  1397. CASE_RETURN_STRING(WMI_MDNS_OFFLOAD_ENABLE_CMDID);
  1398. CASE_RETURN_STRING(WMI_MDNS_SET_FQDN_CMDID);
  1399. CASE_RETURN_STRING(WMI_MDNS_SET_RESPONSE_CMDID);
  1400. CASE_RETURN_STRING(WMI_MDNS_GET_STATS_CMDID);
  1401. CASE_RETURN_STRING(WMI_ROAM_INVOKE_CMDID);
  1402. CASE_RETURN_STRING(WMI_SET_ANTENNA_DIVERSITY_CMDID);
  1403. CASE_RETURN_STRING(WMI_SAP_OFL_ENABLE_CMDID);
  1404. CASE_RETURN_STRING(WMI_APFIND_CMDID);
  1405. CASE_RETURN_STRING(WMI_PASSPOINT_LIST_CONFIG_CMDID);
  1406. CASE_RETURN_STRING(WMI_OCB_SET_SCHED_CMDID);
  1407. CASE_RETURN_STRING(WMI_OCB_SET_CONFIG_CMDID);
  1408. CASE_RETURN_STRING(WMI_OCB_SET_UTC_TIME_CMDID);
  1409. CASE_RETURN_STRING(WMI_OCB_START_TIMING_ADVERT_CMDID);
  1410. CASE_RETURN_STRING(WMI_OCB_STOP_TIMING_ADVERT_CMDID);
  1411. CASE_RETURN_STRING(WMI_OCB_GET_TSF_TIMER_CMDID);
  1412. CASE_RETURN_STRING(WMI_DCC_GET_STATS_CMDID);
  1413. CASE_RETURN_STRING(WMI_DCC_CLEAR_STATS_CMDID);
  1414. CASE_RETURN_STRING(WMI_DCC_UPDATE_NDL_CMDID);
  1415. CASE_RETURN_STRING(WMI_ROAM_FILTER_CMDID);
  1416. CASE_RETURN_STRING(WMI_ROAM_SUBNET_CHANGE_CONFIG_CMDID);
  1417. CASE_RETURN_STRING(WMI_DEBUG_MESG_FLUSH_CMDID);
  1418. CASE_RETURN_STRING(WMI_PEER_SET_RATE_REPORT_CONDITION_CMDID);
  1419. CASE_RETURN_STRING(WMI_SOC_SET_PCL_CMDID);
  1420. CASE_RETURN_STRING(WMI_SOC_SET_HW_MODE_CMDID);
  1421. CASE_RETURN_STRING(WMI_SOC_SET_DUAL_MAC_CONFIG_CMDID);
  1422. CASE_RETURN_STRING(WMI_WOW_ENABLE_ICMPV6_NA_FLT_CMDID);
  1423. CASE_RETURN_STRING(WMI_DIAG_EVENT_LOG_CONFIG_CMDID);
  1424. CASE_RETURN_STRING(WMI_PACKET_FILTER_CONFIG_CMDID);
  1425. CASE_RETURN_STRING(WMI_PACKET_FILTER_ENABLE_CMDID);
  1426. CASE_RETURN_STRING(WMI_SAP_SET_BLACKLIST_PARAM_CMDID);
  1427. CASE_RETURN_STRING(WMI_WOW_UDP_SVC_OFLD_CMDID);
  1428. CASE_RETURN_STRING(WMI_MGMT_TX_SEND_CMDID);
  1429. CASE_RETURN_STRING(WMI_SOC_SET_ANTENNA_MODE_CMDID);
  1430. CASE_RETURN_STRING(WMI_WOW_HOSTWAKEUP_GPIO_PIN_PATTERN_CONFIG_CMDID);
  1431. CASE_RETURN_STRING(WMI_AP_PS_EGAP_PARAM_CMDID);
  1432. CASE_RETURN_STRING(WMI_PMF_OFFLOAD_SET_SA_QUERY_CMDID);
  1433. CASE_RETURN_STRING(WMI_BPF_GET_CAPABILITY_CMDID);
  1434. CASE_RETURN_STRING(WMI_BPF_GET_VDEV_STATS_CMDID);
  1435. CASE_RETURN_STRING(WMI_BPF_SET_VDEV_INSTRUCTIONS_CMDID);
  1436. CASE_RETURN_STRING(WMI_BPF_DEL_VDEV_INSTRUCTIONS_CMDID);
  1437. CASE_RETURN_STRING(WMI_NDI_GET_CAP_REQ_CMDID);
  1438. CASE_RETURN_STRING(WMI_NDP_INITIATOR_REQ_CMDID);
  1439. CASE_RETURN_STRING(WMI_NDP_RESPONDER_REQ_CMDID);
  1440. CASE_RETURN_STRING(WMI_NDP_END_REQ_CMDID);
  1441. CASE_RETURN_STRING(WMI_PEER_UPDATE_WDS_ENTRY_CMDID);
  1442. CASE_RETURN_STRING(WMI_PEER_ADD_PROXY_STA_ENTRY_CMDID);
  1443. CASE_RETURN_STRING(WMI_PDEV_FIPS_CMDID);
  1444. CASE_RETURN_STRING(WMI_PDEV_SMART_ANT_ENABLE_CMDID);
  1445. CASE_RETURN_STRING(WMI_PDEV_SMART_ANT_SET_RX_ANTENNA_CMDID);
  1446. CASE_RETURN_STRING(WMI_PDEV_SET_ANTENNA_SWITCH_TABLE_CMDID);
  1447. CASE_RETURN_STRING(WMI_PDEV_SET_CTL_TABLE_CMDID);
  1448. CASE_RETURN_STRING(WMI_PDEV_SET_MIMOGAIN_TABLE_CMDID);
  1449. CASE_RETURN_STRING(WMI_PDEV_GET_TPC_CMDID);
  1450. CASE_RETURN_STRING(WMI_MIB_STATS_ENABLE_CMDID);
  1451. CASE_RETURN_STRING(WMI_PDEV_GET_ANI_CCK_CONFIG_CMDID);
  1452. CASE_RETURN_STRING(WMI_PDEV_GET_ANI_OFDM_CONFIG_CMDID);
  1453. CASE_RETURN_STRING(WMI_VDEV_RATEMASK_CMDID);
  1454. CASE_RETURN_STRING(WMI_VDEV_ATF_REQUEST_CMDID);
  1455. CASE_RETURN_STRING(WMI_VDEV_SET_DSCP_TID_MAP_CMDID);
  1456. CASE_RETURN_STRING(WMI_VDEV_FILTER_NEIGHBOR_RX_PACKETS_CMDID);
  1457. CASE_RETURN_STRING(WMI_VDEV_SET_QUIET_MODE_CMDID);
  1458. CASE_RETURN_STRING(WMI_PEER_SMART_ANT_SET_TX_ANTENNA_CMDID);
  1459. CASE_RETURN_STRING(WMI_PEER_SMART_ANT_SET_TRAIN_INFO_CMDID);
  1460. CASE_RETURN_STRING(WMI_PEER_SMART_ANT_SET_NODE_CONFIG_OPS_CMDID);
  1461. CASE_RETURN_STRING(WMI_PEER_ATF_REQUEST_CMDID);
  1462. CASE_RETURN_STRING(WMI_FWTEST_CMDID);
  1463. CASE_RETURN_STRING(WMI_QBOOST_CFG_CMDID);
  1464. CASE_RETURN_STRING(WMI_PDEV_GET_NFCAL_POWER_CMDID);
  1465. CASE_RETURN_STRING(WMI_PDEV_SET_PCL_CMDID);
  1466. CASE_RETURN_STRING(WMI_PDEV_SET_HW_MODE_CMDID);
  1467. CASE_RETURN_STRING(WMI_PDEV_SET_MAC_CONFIG_CMDID);
  1468. CASE_RETURN_STRING(WMI_PDEV_SET_ANTENNA_MODE_CMDID);
  1469. CASE_RETURN_STRING(WMI_ROAM_SET_MBO_PARAM_CMDID);
  1470. CASE_RETURN_STRING(WMI_CHAN_AVOID_RPT_ALLOW_CMDID);
  1471. CASE_RETURN_STRING(WMI_SET_PERIODIC_CHANNEL_STATS_CONFIG_CMDID);
  1472. CASE_RETURN_STRING(WMI_VDEV_SET_CUSTOM_AGGR_SIZE_CMDID);
  1473. CASE_RETURN_STRING(WMI_PDEV_WAL_POWER_DEBUG_CMDID);
  1474. CASE_RETURN_STRING(WMI_PEER_BWF_REQUEST_CMDID);
  1475. CASE_RETURN_STRING(WMI_DBGLOG_TIME_STAMP_SYNC_CMDID);
  1476. CASE_RETURN_STRING(WMI_P2P_LISTEN_OFFLOAD_START_CMDID);
  1477. CASE_RETURN_STRING(WMI_P2P_LISTEN_OFFLOAD_STOP_CMDID);
  1478. CASE_RETURN_STRING(WMI_PEER_REORDER_QUEUE_SETUP_CMDID);
  1479. CASE_RETURN_STRING(WMI_PEER_REORDER_QUEUE_REMOVE_CMDID);
  1480. CASE_RETURN_STRING(WMI_SET_MULTIPLE_MCAST_FILTER_CMDID);
  1481. CASE_RETURN_STRING(WMI_READ_DATA_FROM_FLASH_CMDID);
  1482. CASE_RETURN_STRING(WMI_PDEV_SET_REORDER_TIMEOUT_VAL_CMDID);
  1483. CASE_RETURN_STRING(WMI_PEER_SET_RX_BLOCKSIZE_CMDID);
  1484. CASE_RETURN_STRING(WMI_PDEV_SET_WAKEUP_CONFIG_CMDID);
  1485. CASE_RETURN_STRING(WMI_PDEV_GET_ANTDIV_STATUS_CMDID);
  1486. CASE_RETURN_STRING(WMI_PEER_ANTDIV_INFO_REQ_CMDID);
  1487. CASE_RETURN_STRING(WMI_MNT_FILTER_CMDID);
  1488. CASE_RETURN_STRING(WMI_PDEV_GET_CHIP_POWER_STATS_CMDID);
  1489. CASE_RETURN_STRING(WMI_COEX_GET_ANTENNA_ISOLATION_CMDID);
  1490. CASE_RETURN_STRING(WMI_PDEV_SET_STATS_THRESHOLD_CMDID);
  1491. CASE_RETURN_STRING(WMI_REQUEST_WLAN_STATS_CMDID);
  1492. CASE_RETURN_STRING(WMI_VDEV_ENCRYPT_DECRYPT_DATA_REQ_CMDID);
  1493. CASE_RETURN_STRING(WMI_PDEV_DFS_PHYERR_OFFLOAD_ENABLE_CMDID);
  1494. CASE_RETURN_STRING(WMI_PDEV_DFS_PHYERR_OFFLOAD_DISABLE_CMDID);
  1495. CASE_RETURN_STRING(WMI_VDEV_ADFS_CH_CFG_CMDID);
  1496. CASE_RETURN_STRING(WMI_VDEV_ADFS_OCAC_ABORT_CMDID);
  1497. }
  1498. return "Invalid WMI cmd";
  1499. }
  1500. static inline void wma_log_cmd_id(uint32_t cmd_id, uint32_t tag)
  1501. {
  1502. WMI_LOGD("Send WMI command:%s command_id:%d htc_tag:%d\n",
  1503. wmi_id_to_name(cmd_id), cmd_id, tag);
  1504. }
  1505. #else
  1506. static uint8_t *wmi_id_to_name(uint32_t wmi_command)
  1507. {
  1508. return "Invalid WMI cmd";
  1509. }
  1510. #endif
  1511. /**
  1512. * wmi_is_runtime_pm_cmd() - check if a cmd is from suspend resume sequence
  1513. * @cmd: command to check
  1514. *
  1515. * Return: true if the command is part of the suspend resume sequence.
  1516. */
  1517. #ifdef CONFIG_MCL
  1518. static bool wmi_is_runtime_pm_cmd(uint32_t cmd_id)
  1519. {
  1520. switch (cmd_id) {
  1521. case WMI_WOW_ENABLE_CMDID:
  1522. case WMI_PDEV_SUSPEND_CMDID:
  1523. case WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID:
  1524. case WMI_WOW_ADD_WAKE_PATTERN_CMDID:
  1525. case WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID:
  1526. case WMI_PDEV_RESUME_CMDID:
  1527. case WMI_WOW_DEL_WAKE_PATTERN_CMDID:
  1528. case WMI_D0_WOW_ENABLE_DISABLE_CMDID:
  1529. return true;
  1530. default:
  1531. return false;
  1532. }
  1533. }
  1534. /**
  1535. * wmi_is_pm_resume_cmd() - check if a cmd is part of the resume sequence
  1536. * @cmd_id: command to check
  1537. *
  1538. * Return: true if the command is part of the resume sequence.
  1539. */
  1540. static bool wmi_is_pm_resume_cmd(uint32_t cmd_id)
  1541. {
  1542. switch (cmd_id) {
  1543. case WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID:
  1544. case WMI_PDEV_RESUME_CMDID:
  1545. return true;
  1546. default:
  1547. return false;
  1548. }
  1549. }
  1550. #else
  1551. static bool wmi_is_runtime_pm_cmd(uint32_t cmd_id)
  1552. {
  1553. return false;
  1554. }
  1555. static bool wmi_is_pm_resume_cmd(uint32_t cmd_id)
  1556. {
  1557. return false;
  1558. }
  1559. #endif
  1560. /**
  1561. * wmi_unified_cmd_send() - WMI command API
  1562. * @wmi_handle: handle to wmi
  1563. * @buf: wmi buf
  1564. * @len: wmi buffer length
  1565. * @cmd_id: wmi command id
  1566. *
  1567. * Note, it is NOT safe to access buf after calling this function!
  1568. *
  1569. * Return: 0 on success
  1570. */
  1571. QDF_STATUS wmi_unified_cmd_send(wmi_unified_t wmi_handle, wmi_buf_t buf,
  1572. uint32_t len, uint32_t cmd_id)
  1573. {
  1574. HTC_PACKET *pkt;
  1575. A_STATUS status;
  1576. uint16_t htc_tag = 0;
  1577. if (wmi_get_runtime_pm_inprogress(wmi_handle)) {
  1578. if (wmi_is_runtime_pm_cmd(cmd_id))
  1579. htc_tag = HTC_TX_PACKET_TAG_AUTO_PM;
  1580. } else if (qdf_atomic_read(&wmi_handle->is_target_suspended) &&
  1581. (!wmi_is_pm_resume_cmd(cmd_id))) {
  1582. QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_ERROR,
  1583. "%s: Target is suspended", __func__);
  1584. QDF_ASSERT(0);
  1585. return QDF_STATUS_E_BUSY;
  1586. }
  1587. if (wmi_handle->wmi_stopinprogress) {
  1588. QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_ERROR,
  1589. "WMI stop in progress\n");
  1590. return QDF_STATUS_E_INVAL;
  1591. }
  1592. #ifndef WMI_NON_TLV_SUPPORT
  1593. /* Do sanity check on the TLV parameter structure */
  1594. if (wmi_handle->target_type == WMI_TLV_TARGET) {
  1595. void *buf_ptr = (void *)qdf_nbuf_data(buf);
  1596. if (wmitlv_check_command_tlv_params(NULL, buf_ptr, len, cmd_id)
  1597. != 0) {
  1598. QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_ERROR,
  1599. "\nERROR: %s: Invalid WMI Param Buffer for Cmd:%d",
  1600. __func__, cmd_id);
  1601. return QDF_STATUS_E_INVAL;
  1602. }
  1603. }
  1604. #endif
  1605. if (qdf_nbuf_push_head(buf, sizeof(WMI_CMD_HDR)) == NULL) {
  1606. QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_ERROR,
  1607. "%s, Failed to send cmd %x, no memory",
  1608. __func__, cmd_id);
  1609. return QDF_STATUS_E_NOMEM;
  1610. }
  1611. WMI_SET_FIELD(qdf_nbuf_data(buf), WMI_CMD_HDR, COMMANDID, cmd_id);
  1612. qdf_atomic_inc(&wmi_handle->pending_cmds);
  1613. if (qdf_atomic_read(&wmi_handle->pending_cmds) >= WMI_MAX_CMDS) {
  1614. QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_ERROR,
  1615. "\n%s: hostcredits = %d", __func__,
  1616. wmi_get_host_credits(wmi_handle));
  1617. htc_dump_counter_info(wmi_handle->htc_handle);
  1618. qdf_atomic_dec(&wmi_handle->pending_cmds);
  1619. QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_ERROR,
  1620. "%s: MAX %d WMI Pending cmds reached.", __func__,
  1621. WMI_MAX_CMDS);
  1622. QDF_BUG(0);
  1623. return QDF_STATUS_E_BUSY;
  1624. }
  1625. pkt = qdf_mem_malloc(sizeof(*pkt));
  1626. if (!pkt) {
  1627. qdf_atomic_dec(&wmi_handle->pending_cmds);
  1628. QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_ERROR,
  1629. "%s, Failed to alloc htc packet %x, no memory",
  1630. __func__, cmd_id);
  1631. return QDF_STATUS_E_NOMEM;
  1632. }
  1633. SET_HTC_PACKET_INFO_TX(pkt,
  1634. NULL,
  1635. qdf_nbuf_data(buf), len + sizeof(WMI_CMD_HDR),
  1636. wmi_handle->wmi_endpoint_id, htc_tag);
  1637. SET_HTC_PACKET_NET_BUF_CONTEXT(pkt, buf);
  1638. #ifdef CONFIG_MCL
  1639. wma_log_cmd_id(cmd_id, htc_tag);
  1640. #endif
  1641. #ifdef WMI_INTERFACE_EVENT_LOGGING
  1642. if (wmi_handle->log_info.wmi_logging_enable) {
  1643. qdf_spin_lock_bh(&wmi_handle->log_info.wmi_record_lock);
  1644. /*Record 16 bytes of WMI cmd data -
  1645. * * exclude TLV and WMI headers */
  1646. if (wmi_handle->log_info.is_management_record(cmd_id)) {
  1647. WMI_MGMT_COMMAND_RECORD(wmi_handle, cmd_id,
  1648. ((uint32_t *) qdf_nbuf_data(buf) +
  1649. wmi_handle->log_info.buf_offset_command));
  1650. } else {
  1651. WMI_COMMAND_RECORD(wmi_handle, cmd_id,
  1652. ((uint32_t *) qdf_nbuf_data(buf) +
  1653. wmi_handle->log_info.buf_offset_command));
  1654. }
  1655. qdf_spin_unlock_bh(&wmi_handle->log_info.wmi_record_lock);
  1656. }
  1657. #endif
  1658. status = htc_send_pkt(wmi_handle->htc_handle, pkt);
  1659. if (A_OK != status) {
  1660. qdf_atomic_dec(&wmi_handle->pending_cmds);
  1661. QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_ERROR,
  1662. "%s %d, htc_send_pkt failed", __func__, __LINE__);
  1663. qdf_mem_free(pkt);
  1664. }
  1665. if (status)
  1666. return QDF_STATUS_E_FAILURE;
  1667. return QDF_STATUS_SUCCESS;
  1668. }
  1669. /**
  1670. * wmi_unified_get_event_handler_ix() - gives event handler's index
  1671. * @wmi_handle: handle to wmi
  1672. * @event_id: wmi event id
  1673. *
  1674. * Return: event handler's index
  1675. */
  1676. static int wmi_unified_get_event_handler_ix(wmi_unified_t wmi_handle,
  1677. uint32_t event_id)
  1678. {
  1679. uint32_t idx = 0;
  1680. int32_t invalid_idx = -1;
  1681. for (idx = 0; (idx < wmi_handle->max_event_idx &&
  1682. idx < WMI_UNIFIED_MAX_EVENT); ++idx) {
  1683. if (wmi_handle->event_id[idx] == event_id &&
  1684. wmi_handle->event_handler[idx] != NULL) {
  1685. return idx;
  1686. }
  1687. }
  1688. return invalid_idx;
  1689. }
  1690. /**
  1691. * wmi_unified_register_event_handler() - register wmi event handler
  1692. * @wmi_handle: handle to wmi
  1693. * @event_id: wmi event id
  1694. * @handler_func: wmi event handler function
  1695. * @rx_ctx: rx execution context for wmi rx events
  1696. *
  1697. * Return: 0 on success
  1698. */
  1699. int wmi_unified_register_event_handler(wmi_unified_t wmi_handle,
  1700. uint32_t event_id,
  1701. wmi_unified_event_handler handler_func,
  1702. uint8_t rx_ctx)
  1703. {
  1704. uint32_t idx = 0;
  1705. uint32_t evt_id;
  1706. #ifndef CONFIG_MCL
  1707. if (event_id >= wmi_events_max ||
  1708. wmi_handle->wmi_events[event_id] == WMI_EVENT_ID_INVALID) {
  1709. qdf_print("%s: Event id %d is unavailable\n",
  1710. __func__, event_id);
  1711. return QDF_STATUS_E_FAILURE;
  1712. }
  1713. evt_id = wmi_handle->wmi_events[event_id];
  1714. #else
  1715. evt_id = event_id;
  1716. #endif
  1717. if (wmi_unified_get_event_handler_ix(wmi_handle, evt_id) != -1) {
  1718. qdf_print("%s : event handler already registered 0x%x\n",
  1719. __func__, evt_id);
  1720. return QDF_STATUS_E_FAILURE;
  1721. }
  1722. if (wmi_handle->max_event_idx == WMI_UNIFIED_MAX_EVENT) {
  1723. qdf_print("%s : no more event handlers 0x%x\n",
  1724. __func__, evt_id);
  1725. return QDF_STATUS_E_FAILURE;
  1726. }
  1727. idx = wmi_handle->max_event_idx;
  1728. wmi_handle->event_handler[idx] = handler_func;
  1729. wmi_handle->event_id[idx] = evt_id;
  1730. qdf_spin_lock_bh(&wmi_handle->ctx_lock);
  1731. wmi_handle->ctx[idx] = rx_ctx;
  1732. qdf_spin_unlock_bh(&wmi_handle->ctx_lock);
  1733. wmi_handle->max_event_idx++;
  1734. return 0;
  1735. }
  1736. /**
  1737. * wmi_unified_unregister_event_handler() - unregister wmi event handler
  1738. * @wmi_handle: handle to wmi
  1739. * @event_id: wmi event id
  1740. *
  1741. * Return: 0 on success
  1742. */
  1743. int wmi_unified_unregister_event_handler(wmi_unified_t wmi_handle,
  1744. uint32_t event_id)
  1745. {
  1746. uint32_t idx = 0;
  1747. uint32_t evt_id;
  1748. #ifndef CONFIG_MCL
  1749. if (event_id >= wmi_events_max ||
  1750. wmi_handle->wmi_events[event_id] == WMI_EVENT_ID_INVALID) {
  1751. qdf_print("%s: Event id %d is unavailable\n",
  1752. __func__, event_id);
  1753. return QDF_STATUS_E_FAILURE;
  1754. }
  1755. evt_id = wmi_handle->wmi_events[event_id];
  1756. #else
  1757. evt_id = event_id;
  1758. #endif
  1759. idx = wmi_unified_get_event_handler_ix(wmi_handle, evt_id);
  1760. if (idx == -1) {
  1761. qdf_print("%s : event handler is not registered: evt id 0x%x\n",
  1762. __func__, evt_id);
  1763. return QDF_STATUS_E_FAILURE;
  1764. }
  1765. wmi_handle->event_handler[idx] = NULL;
  1766. wmi_handle->event_id[idx] = 0;
  1767. --wmi_handle->max_event_idx;
  1768. wmi_handle->event_handler[idx] =
  1769. wmi_handle->event_handler[wmi_handle->max_event_idx];
  1770. wmi_handle->event_id[idx] =
  1771. wmi_handle->event_id[wmi_handle->max_event_idx];
  1772. return 0;
  1773. }
  1774. /**
  1775. * wmi_process_fw_event_default_ctx() - process in default caller context
  1776. * @wmi_handle: handle to wmi
  1777. * @htc_packet: pointer to htc packet
  1778. * @exec_ctx: execution context for wmi fw event
  1779. *
  1780. * Event process by below function will be in default caller context.
  1781. * wmi internally provides rx work thread processing context.
  1782. *
  1783. * Return: none
  1784. */
  1785. static void wmi_process_fw_event_default_ctx(struct wmi_unified *wmi_handle,
  1786. HTC_PACKET *htc_packet, uint8_t exec_ctx)
  1787. {
  1788. wmi_buf_t evt_buf;
  1789. evt_buf = (wmi_buf_t) htc_packet->pPktContext;
  1790. #ifndef CONFIG_MCL
  1791. wmi_handle->rx_ops.wma_process_fw_event_handler_cbk
  1792. (wmi_handle->scn_handle, evt_buf, exec_ctx);
  1793. #else
  1794. wmi_handle->rx_ops.wma_process_fw_event_handler_cbk(wmi_handle,
  1795. evt_buf, exec_ctx);
  1796. #endif
  1797. return;
  1798. }
  1799. /**
  1800. * wmi_process_fw_event_worker_thread_ctx() - process in worker thread context
  1801. * @wmi_handle: handle to wmi
  1802. * @htc_packet: pointer to htc packet
  1803. *
  1804. * Event process by below function will be in worker thread context.
  1805. * Use this method for events which are not critical and not
  1806. * handled in protocol stack.
  1807. *
  1808. * Return: none
  1809. */
  1810. static void wmi_process_fw_event_worker_thread_ctx
  1811. (struct wmi_unified *wmi_handle, HTC_PACKET *htc_packet)
  1812. {
  1813. wmi_buf_t evt_buf;
  1814. uint32_t id;
  1815. uint8_t *data;
  1816. evt_buf = (wmi_buf_t) htc_packet->pPktContext;
  1817. id = WMI_GET_FIELD(qdf_nbuf_data(evt_buf), WMI_CMD_HDR, COMMANDID);
  1818. data = qdf_nbuf_data(evt_buf);
  1819. #ifdef WMI_INTERFACE_EVENT_LOGGING
  1820. if (wmi_handle->log_info.wmi_logging_enable) {
  1821. qdf_spin_lock_bh(&wmi_handle->log_info.wmi_record_lock);
  1822. /* Exclude 4 bytes of TLV header */
  1823. WMI_RX_EVENT_RECORD(wmi_handle, id, ((uint8_t *) data +
  1824. wmi_handle->log_info.buf_offset_event));
  1825. qdf_spin_unlock_bh(&wmi_handle->log_info.wmi_record_lock);
  1826. }
  1827. #endif
  1828. qdf_spin_lock_bh(&wmi_handle->eventq_lock);
  1829. qdf_nbuf_queue_add(&wmi_handle->event_queue, evt_buf);
  1830. qdf_spin_unlock_bh(&wmi_handle->eventq_lock);
  1831. schedule_work(&wmi_handle->rx_event_work);
  1832. return;
  1833. }
  1834. /**
  1835. * wmi_control_rx() - process fw events callbacks
  1836. * @ctx: handle to wmi
  1837. * @htc_packet: pointer to htc packet
  1838. *
  1839. * Return: none
  1840. */
  1841. static void wmi_control_rx(void *ctx, HTC_PACKET *htc_packet)
  1842. {
  1843. struct wmi_unified *wmi_handle = (struct wmi_unified *)ctx;
  1844. wmi_buf_t evt_buf;
  1845. uint32_t id;
  1846. uint32_t idx = 0;
  1847. enum wmi_rx_exec_ctx exec_ctx;
  1848. evt_buf = (wmi_buf_t) htc_packet->pPktContext;
  1849. id = WMI_GET_FIELD(qdf_nbuf_data(evt_buf), WMI_CMD_HDR, COMMANDID);
  1850. idx = wmi_unified_get_event_handler_ix(wmi_handle, id);
  1851. if (qdf_unlikely(idx == A_ERROR)) {
  1852. qdf_print
  1853. ("%s :event handler is not registered: event id 0x%x\n",
  1854. __func__, id);
  1855. qdf_nbuf_free(evt_buf);
  1856. return;
  1857. }
  1858. qdf_spin_lock_bh(&wmi_handle->ctx_lock);
  1859. exec_ctx = wmi_handle->ctx[idx];
  1860. qdf_spin_unlock_bh(&wmi_handle->ctx_lock);
  1861. if (exec_ctx == WMI_RX_WORK_CTX) {
  1862. wmi_process_fw_event_worker_thread_ctx
  1863. (wmi_handle, htc_packet);
  1864. } else if (exec_ctx > WMI_RX_WORK_CTX) {
  1865. wmi_process_fw_event_default_ctx
  1866. (wmi_handle, htc_packet, exec_ctx);
  1867. } else {
  1868. qdf_print("%s :Invalid event context %d\n", __func__, exec_ctx);
  1869. qdf_nbuf_free(evt_buf);
  1870. }
  1871. }
  1872. /**
  1873. * wmi_process_fw_event() - process any fw event
  1874. * @wmi_handle: wmi handle
  1875. * @evt_buf: fw event buffer
  1876. *
  1877. * This function process fw event in caller context
  1878. *
  1879. * Return: none
  1880. */
  1881. void wmi_process_fw_event(struct wmi_unified *wmi_handle, wmi_buf_t evt_buf)
  1882. {
  1883. __wmi_control_rx(wmi_handle, evt_buf);
  1884. }
  1885. /**
  1886. * __wmi_control_rx() - process serialize wmi event callback
  1887. * @wmi_handle: wmi handle
  1888. * @evt_buf: fw event buffer
  1889. *
  1890. * Return: none
  1891. */
  1892. void __wmi_control_rx(struct wmi_unified *wmi_handle, wmi_buf_t evt_buf)
  1893. {
  1894. uint32_t id;
  1895. uint8_t *data;
  1896. uint32_t len;
  1897. void *wmi_cmd_struct_ptr = NULL;
  1898. #ifndef WMI_NON_TLV_SUPPORT
  1899. int tlv_ok_status = 0;
  1900. #endif
  1901. uint32_t idx = 0;
  1902. id = WMI_GET_FIELD(qdf_nbuf_data(evt_buf), WMI_CMD_HDR, COMMANDID);
  1903. if (qdf_nbuf_pull_head(evt_buf, sizeof(WMI_CMD_HDR)) == NULL)
  1904. goto end;
  1905. data = qdf_nbuf_data(evt_buf);
  1906. len = qdf_nbuf_len(evt_buf);
  1907. #ifndef WMI_NON_TLV_SUPPORT
  1908. if (wmi_handle->target_type == WMI_TLV_TARGET) {
  1909. /* Validate and pad(if necessary) the TLVs */
  1910. tlv_ok_status =
  1911. wmitlv_check_and_pad_event_tlvs(wmi_handle->scn_handle,
  1912. data, len, id,
  1913. &wmi_cmd_struct_ptr);
  1914. if (tlv_ok_status != 0) {
  1915. QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_ERROR,
  1916. "%s: Error: id=0x%d, wmitlv check status=%d\n",
  1917. __func__, id, tlv_ok_status);
  1918. goto end;
  1919. }
  1920. }
  1921. #endif
  1922. idx = wmi_unified_get_event_handler_ix(wmi_handle, id);
  1923. if (idx == A_ERROR) {
  1924. QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_ERROR,
  1925. "%s : event handler is not registered: event id 0x%x\n",
  1926. __func__, id);
  1927. goto end;
  1928. }
  1929. #ifdef WMI_INTERFACE_EVENT_LOGGING
  1930. if (wmi_handle->log_info.wmi_logging_enable) {
  1931. qdf_spin_lock_bh(&wmi_handle->log_info.wmi_record_lock);
  1932. /* Exclude 4 bytes of TLV header */
  1933. if (wmi_handle->log_info.is_management_record(id)) {
  1934. WMI_MGMT_EVENT_RECORD(wmi_handle, id, ((uint8_t *) data
  1935. + wmi_handle->log_info.buf_offset_event));
  1936. } else {
  1937. WMI_EVENT_RECORD(wmi_handle, id, ((uint8_t *) data +
  1938. wmi_handle->log_info.buf_offset_event));
  1939. }
  1940. qdf_spin_unlock_bh(&wmi_handle->log_info.wmi_record_lock);
  1941. }
  1942. #endif
  1943. /* Call the WMI registered event handler */
  1944. if (wmi_handle->target_type == WMI_TLV_TARGET)
  1945. wmi_handle->event_handler[idx] (wmi_handle->scn_handle,
  1946. wmi_cmd_struct_ptr, len);
  1947. else
  1948. wmi_handle->event_handler[idx] (wmi_handle->scn_handle,
  1949. data, len);
  1950. end:
  1951. /* Free event buffer and allocated event tlv */
  1952. #ifndef WMI_NON_TLV_SUPPORT
  1953. if (wmi_handle->target_type == WMI_TLV_TARGET)
  1954. wmitlv_free_allocated_event_tlvs(id, &wmi_cmd_struct_ptr);
  1955. #endif
  1956. qdf_nbuf_free(evt_buf);
  1957. }
  1958. /**
  1959. * wmi_rx_event_work() - process rx event in rx work queue context
  1960. * @work: rx work queue struct
  1961. *
  1962. * This function process any fw event to serialize it through rx worker thread.
  1963. *
  1964. * Return: none
  1965. */
  1966. static void wmi_rx_event_work(struct work_struct *work)
  1967. {
  1968. struct wmi_unified *wmi = container_of(work, struct wmi_unified,
  1969. rx_event_work);
  1970. wmi_buf_t buf;
  1971. qdf_spin_lock_bh(&wmi->eventq_lock);
  1972. buf = qdf_nbuf_queue_remove(&wmi->event_queue);
  1973. qdf_spin_unlock_bh(&wmi->eventq_lock);
  1974. while (buf) {
  1975. __wmi_control_rx(wmi, buf);
  1976. qdf_spin_lock_bh(&wmi->eventq_lock);
  1977. buf = qdf_nbuf_queue_remove(&wmi->event_queue);
  1978. qdf_spin_unlock_bh(&wmi->eventq_lock);
  1979. }
  1980. }
  1981. #ifdef FEATURE_RUNTIME_PM
  1982. /**
  1983. * wmi_runtime_pm_init() - initialize runtime pm wmi variables
  1984. * @wmi_handle: wmi context
  1985. */
  1986. static void wmi_runtime_pm_init(struct wmi_unified *wmi_handle)
  1987. {
  1988. qdf_atomic_init(&wmi_handle->runtime_pm_inprogress);
  1989. }
  1990. /**
  1991. * wmi_set_runtime_pm_inprogress() - set runtime pm progress flag
  1992. * @wmi_handle: wmi context
  1993. * @val: runtime pm progress flag
  1994. */
  1995. void wmi_set_runtime_pm_inprogress(wmi_unified_t wmi_handle, A_BOOL val)
  1996. {
  1997. qdf_atomic_set(&wmi_handle->runtime_pm_inprogress, val);
  1998. }
  1999. /**
  2000. * wmi_get_runtime_pm_inprogress() - get runtime pm progress flag
  2001. * @wmi_handle: wmi context
  2002. */
  2003. inline bool wmi_get_runtime_pm_inprogress(wmi_unified_t wmi_handle)
  2004. {
  2005. return qdf_atomic_read(&wmi_handle->runtime_pm_inprogress);
  2006. }
  2007. #else
  2008. static void wmi_runtime_pm_init(struct wmi_unified *wmi_handle)
  2009. {
  2010. }
  2011. #endif
  2012. /**
  2013. * wmi_unified_attach() - attach for unified WMI
  2014. * @scn_handle: handle to SCN
  2015. * @osdev: OS device context
  2016. * @target_type: TLV or not-TLV based target
  2017. * @use_cookie: cookie based allocation enabled/disabled
  2018. * @ops: umac rx callbacks
  2019. *
  2020. * @Return: wmi handle.
  2021. */
  2022. void *wmi_unified_attach(void *scn_handle,
  2023. osdev_t osdev, enum wmi_target_type target_type,
  2024. bool use_cookie, struct wmi_rx_ops *rx_ops)
  2025. {
  2026. struct wmi_unified *wmi_handle;
  2027. #ifdef CONFIG_MCL
  2028. wmi_handle =
  2029. (struct wmi_unified *)os_malloc(NULL,
  2030. sizeof(struct wmi_unified),
  2031. GFP_ATOMIC);
  2032. #else
  2033. wmi_handle =
  2034. (struct wmi_unified *) qdf_mem_malloc(
  2035. sizeof(struct wmi_unified));
  2036. #endif
  2037. if (wmi_handle == NULL) {
  2038. qdf_print("allocation of wmi handle failed %zu\n",
  2039. sizeof(struct wmi_unified));
  2040. return NULL;
  2041. }
  2042. OS_MEMZERO(wmi_handle, sizeof(struct wmi_unified));
  2043. wmi_handle->scn_handle = scn_handle;
  2044. qdf_atomic_init(&wmi_handle->pending_cmds);
  2045. qdf_atomic_init(&wmi_handle->is_target_suspended);
  2046. wmi_runtime_pm_init(wmi_handle);
  2047. qdf_spinlock_create(&wmi_handle->eventq_lock);
  2048. qdf_nbuf_queue_init(&wmi_handle->event_queue);
  2049. INIT_WORK(&wmi_handle->rx_event_work, wmi_rx_event_work);
  2050. #ifdef WMI_INTERFACE_EVENT_LOGGING
  2051. if (QDF_STATUS_SUCCESS == wmi_log_init(wmi_handle)) {
  2052. qdf_spinlock_create(&wmi_handle->log_info.wmi_record_lock);
  2053. wmi_debugfs_init(wmi_handle);
  2054. }
  2055. #endif
  2056. /* Attach mc_thread context processing function */
  2057. wmi_handle->rx_ops.wma_process_fw_event_handler_cbk =
  2058. rx_ops->wma_process_fw_event_handler_cbk;
  2059. wmi_handle->target_type = target_type;
  2060. if (target_type == WMI_TLV_TARGET)
  2061. wmi_tlv_attach(wmi_handle);
  2062. else
  2063. wmi_non_tlv_attach(wmi_handle);
  2064. /* Assign target cookie capablity */
  2065. wmi_handle->use_cookie = use_cookie;
  2066. wmi_handle->osdev = osdev;
  2067. wmi_handle->wmi_stopinprogress = 0;
  2068. qdf_spinlock_create(&wmi_handle->ctx_lock);
  2069. return wmi_handle;
  2070. }
  2071. /**
  2072. * wmi_unified_detach() - detach for unified WMI
  2073. *
  2074. * @wmi_handle : handle to wmi.
  2075. *
  2076. * @Return: none.
  2077. */
  2078. void wmi_unified_detach(struct wmi_unified *wmi_handle)
  2079. {
  2080. wmi_buf_t buf;
  2081. cancel_work_sync(&wmi_handle->rx_event_work);
  2082. wmi_debugfs_remove(wmi_handle);
  2083. buf = qdf_nbuf_queue_remove(&wmi_handle->event_queue);
  2084. while (buf) {
  2085. qdf_nbuf_free(buf);
  2086. buf = qdf_nbuf_queue_remove(&wmi_handle->event_queue);
  2087. }
  2088. #ifdef WMI_INTERFACE_EVENT_LOGGING
  2089. wmi_log_buffer_free(wmi_handle);
  2090. #endif
  2091. qdf_spinlock_destroy(&wmi_handle->eventq_lock);
  2092. qdf_spinlock_destroy(&wmi_handle->ctx_lock);
  2093. OS_FREE(wmi_handle);
  2094. wmi_handle = NULL;
  2095. }
  2096. /**
  2097. * wmi_unified_remove_work() - detach for WMI work
  2098. * @wmi_handle: handle to WMI
  2099. *
  2100. * A function that does not fully detach WMI, but just remove work
  2101. * queue items associated with it. This is used to make sure that
  2102. * before any other processing code that may destroy related contexts
  2103. * (HTC, etc), work queue processing on WMI has already been stopped.
  2104. *
  2105. * Return: None
  2106. */
  2107. void
  2108. wmi_unified_remove_work(struct wmi_unified *wmi_handle)
  2109. {
  2110. wmi_buf_t buf;
  2111. QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
  2112. "Enter: %s", __func__);
  2113. cancel_work_sync(&wmi_handle->rx_event_work);
  2114. qdf_spin_lock_bh(&wmi_handle->eventq_lock);
  2115. buf = qdf_nbuf_queue_remove(&wmi_handle->event_queue);
  2116. while (buf) {
  2117. qdf_nbuf_free(buf);
  2118. buf = qdf_nbuf_queue_remove(&wmi_handle->event_queue);
  2119. }
  2120. qdf_spin_unlock_bh(&wmi_handle->eventq_lock);
  2121. QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
  2122. "Done: %s", __func__);
  2123. }
  2124. /**
  2125. * wmi_htc_tx_complete() - Process htc tx completion
  2126. *
  2127. * @ctx: handle to wmi
  2128. * @htc_packet: pointer to htc packet
  2129. *
  2130. * @Return: none.
  2131. */
  2132. static void wmi_htc_tx_complete(void *ctx, HTC_PACKET *htc_pkt)
  2133. {
  2134. struct wmi_unified *wmi_handle = (struct wmi_unified *)ctx;
  2135. wmi_buf_t wmi_cmd_buf = GET_HTC_PACKET_NET_BUF_CONTEXT(htc_pkt);
  2136. u_int8_t *buf_ptr;
  2137. u_int32_t len;
  2138. #ifdef WMI_INTERFACE_EVENT_LOGGING
  2139. uint32_t cmd_id;
  2140. #endif
  2141. ASSERT(wmi_cmd_buf);
  2142. #ifdef WMI_INTERFACE_EVENT_LOGGING
  2143. if (wmi_handle->log_info.wmi_logging_enable) {
  2144. cmd_id = WMI_GET_FIELD(qdf_nbuf_data(wmi_cmd_buf),
  2145. WMI_CMD_HDR, COMMANDID);
  2146. qdf_spin_lock_bh(&wmi_handle->log_info.wmi_record_lock);
  2147. /* Record 16 bytes of WMI cmd tx complete data
  2148. - exclude TLV and WMI headers */
  2149. if (wmi_handle->log_info.is_management_record(cmd_id)) {
  2150. WMI_MGMT_COMMAND_TX_CMP_RECORD(wmi_handle, cmd_id,
  2151. ((uint32_t *) qdf_nbuf_data(wmi_cmd_buf) +
  2152. wmi_handle->log_info.buf_offset_command));
  2153. } else {
  2154. WMI_COMMAND_TX_CMP_RECORD(wmi_handle, cmd_id,
  2155. ((uint32_t *) qdf_nbuf_data(wmi_cmd_buf) +
  2156. wmi_handle->log_info.buf_offset_command));
  2157. }
  2158. qdf_spin_unlock_bh(&wmi_handle->log_info.wmi_record_lock);
  2159. }
  2160. #endif
  2161. buf_ptr = (u_int8_t *) wmi_buf_data(wmi_cmd_buf);
  2162. len = qdf_nbuf_len(wmi_cmd_buf);
  2163. qdf_mem_zero(buf_ptr, len);
  2164. qdf_nbuf_free(wmi_cmd_buf);
  2165. qdf_mem_free(htc_pkt);
  2166. qdf_atomic_dec(&wmi_handle->pending_cmds);
  2167. }
  2168. /**
  2169. * wmi_get_host_credits() - WMI API to get updated host_credits
  2170. *
  2171. * @wmi_handle: handle to WMI.
  2172. *
  2173. * @Return: updated host_credits.
  2174. */
  2175. int
  2176. wmi_unified_connect_htc_service(struct wmi_unified *wmi_handle,
  2177. void *htc_handle)
  2178. {
  2179. int status;
  2180. HTC_SERVICE_CONNECT_RESP response;
  2181. HTC_SERVICE_CONNECT_REQ connect;
  2182. OS_MEMZERO(&connect, sizeof(connect));
  2183. OS_MEMZERO(&response, sizeof(response));
  2184. /* meta data is unused for now */
  2185. connect.pMetaData = NULL;
  2186. connect.MetaDataLength = 0;
  2187. /* these fields are the same for all service endpoints */
  2188. connect.EpCallbacks.pContext = wmi_handle;
  2189. connect.EpCallbacks.EpTxCompleteMultiple =
  2190. NULL /* Control path completion ar6000_tx_complete */;
  2191. connect.EpCallbacks.EpRecv = wmi_control_rx /* Control path rx */;
  2192. connect.EpCallbacks.EpRecvRefill = NULL /* ar6000_rx_refill */;
  2193. connect.EpCallbacks.EpSendFull = NULL /* ar6000_tx_queue_full */;
  2194. connect.EpCallbacks.EpTxComplete =
  2195. wmi_htc_tx_complete /* ar6000_tx_queue_full */;
  2196. /* connect to control service */
  2197. connect.service_id = WMI_CONTROL_SVC;
  2198. status = htc_connect_service(htc_handle, &connect,
  2199. &response);
  2200. if (status != EOK) {
  2201. qdf_print
  2202. ("Failed to connect to WMI CONTROL service status:%d \n",
  2203. status);
  2204. return status;
  2205. }
  2206. wmi_handle->wmi_endpoint_id = response.Endpoint;
  2207. wmi_handle->htc_handle = htc_handle;
  2208. wmi_handle->max_msg_len = response.MaxMsgLength;
  2209. return EOK;
  2210. }
  2211. /**
  2212. * wmi_get_host_credits() - WMI API to get updated host_credits
  2213. *
  2214. * @wmi_handle: handle to WMI.
  2215. *
  2216. * @Return: updated host_credits.
  2217. */
  2218. int wmi_get_host_credits(wmi_unified_t wmi_handle)
  2219. {
  2220. int host_credits = 0;
  2221. htc_get_control_endpoint_tx_host_credits(wmi_handle->htc_handle,
  2222. &host_credits);
  2223. return host_credits;
  2224. }
  2225. /**
  2226. * wmi_get_pending_cmds() - WMI API to get WMI Pending Commands in the HTC
  2227. * queue
  2228. *
  2229. * @wmi_handle: handle to WMI.
  2230. *
  2231. * @Return: Pending Commands in the HTC queue.
  2232. */
  2233. int wmi_get_pending_cmds(wmi_unified_t wmi_handle)
  2234. {
  2235. return qdf_atomic_read(&wmi_handle->pending_cmds);
  2236. }
  2237. /**
  2238. * wmi_set_target_suspend() - WMI API to set target suspend state
  2239. *
  2240. * @wmi_handle: handle to WMI.
  2241. * @val: suspend state boolean.
  2242. *
  2243. * @Return: none.
  2244. */
  2245. void wmi_set_target_suspend(wmi_unified_t wmi_handle, A_BOOL val)
  2246. {
  2247. qdf_atomic_set(&wmi_handle->is_target_suspended, val);
  2248. }
  2249. #ifndef CONFIG_MCL
  2250. /**
  2251. * API to flush all the previous packets associated with the wmi endpoint
  2252. *
  2253. * @param wmi_handle : handle to WMI.
  2254. */
  2255. void
  2256. wmi_flush_endpoint(wmi_unified_t wmi_handle)
  2257. {
  2258. htc_flush_endpoint(wmi_handle->htc_handle,
  2259. wmi_handle->wmi_endpoint_id, 0);
  2260. }
  2261. /**
  2262. * generic function to block unified WMI command
  2263. * @param wmi_handle : handle to WMI.
  2264. * @return 0 on success and -ve on failure.
  2265. */
  2266. int
  2267. wmi_stop(wmi_unified_t wmi_handle)
  2268. {
  2269. QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
  2270. "WMI Stop\n");
  2271. wmi_handle->wmi_stopinprogress = 1;
  2272. return 0;
  2273. }
  2274. #endif