wmi_unified.c 73 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550
  1. /*
  2. * Copyright (c) 2015-2018 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 "htc_api.h"
  30. #include "htc_api.h"
  31. #include "wmi_unified_priv.h"
  32. #include "qdf_module.h"
  33. #ifndef WMI_NON_TLV_SUPPORT
  34. #include "wmi_tlv_helper.h"
  35. #endif
  36. #include <linux/debugfs.h>
  37. /* This check for CONFIG_WIN temporary added due to redeclaration compilation
  38. error in MCL. Error is caused due to inclusion of wmi.h in wmi_unified_api.h
  39. which gets included here through ol_if_athvar.h. Eventually it is expected that
  40. wmi.h will be removed from wmi_unified_api.h after cleanup, which will need
  41. WMI_CMD_HDR to be defined here. */
  42. #ifdef CONFIG_WIN
  43. /* Copied from wmi.h */
  44. #undef MS
  45. #define MS(_v, _f) (((_v) & _f##_MASK) >> _f##_LSB)
  46. #undef SM
  47. #define SM(_v, _f) (((_v) << _f##_LSB) & _f##_MASK)
  48. #undef WO
  49. #define WO(_f) ((_f##_OFFSET) >> 2)
  50. #undef GET_FIELD
  51. #define GET_FIELD(_addr, _f) MS(*((uint32_t *)(_addr) + WO(_f)), _f)
  52. #undef SET_FIELD
  53. #define SET_FIELD(_addr, _f, _val) \
  54. (*((uint32_t *)(_addr) + WO(_f)) = \
  55. (*((uint32_t *)(_addr) + WO(_f)) & ~_f##_MASK) | SM(_val, _f))
  56. #define WMI_GET_FIELD(_msg_buf, _msg_type, _f) \
  57. GET_FIELD(_msg_buf, _msg_type ## _ ## _f)
  58. #define WMI_SET_FIELD(_msg_buf, _msg_type, _f, _val) \
  59. SET_FIELD(_msg_buf, _msg_type ## _ ## _f, _val)
  60. #define WMI_EP_APASS 0x0
  61. #define WMI_EP_LPASS 0x1
  62. #define WMI_EP_SENSOR 0x2
  63. /*
  64. * * Control Path
  65. * */
  66. typedef PREPACK struct {
  67. uint32_t commandId:24,
  68. reserved:2, /* used for WMI endpoint ID */
  69. plt_priv:6; /* platform private */
  70. } POSTPACK WMI_CMD_HDR; /* used for commands and events */
  71. #define WMI_CMD_HDR_COMMANDID_LSB 0
  72. #define WMI_CMD_HDR_COMMANDID_MASK 0x00ffffff
  73. #define WMI_CMD_HDR_COMMANDID_OFFSET 0x00000000
  74. #define WMI_CMD_HDR_WMI_ENDPOINTID_MASK 0x03000000
  75. #define WMI_CMD_HDR_WMI_ENDPOINTID_OFFSET 24
  76. #define WMI_CMD_HDR_PLT_PRIV_LSB 24
  77. #define WMI_CMD_HDR_PLT_PRIV_MASK 0xff000000
  78. #define WMI_CMD_HDR_PLT_PRIV_OFFSET 0x00000000
  79. /* end of copy wmi.h */
  80. #endif /* CONFIG_WIN */
  81. #define WMI_MIN_HEAD_ROOM 64
  82. #ifdef WMI_INTERFACE_EVENT_LOGGING
  83. #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0))
  84. /* TODO Cleanup this backported function */
  85. static int wmi_bp_seq_printf(struct seq_file *m, const char *f, ...)
  86. {
  87. va_list args;
  88. va_start(args, f);
  89. seq_vprintf(m, f, args);
  90. va_end(args);
  91. return 0;
  92. }
  93. #else
  94. #define wmi_bp_seq_printf(m, fmt, ...) seq_printf((m), fmt, ##__VA_ARGS__)
  95. #endif
  96. #ifndef MAX_WMI_INSTANCES
  97. #ifdef CONFIG_MCL
  98. #define MAX_WMI_INSTANCES 1
  99. #else
  100. #define MAX_WMI_INSTANCES 3
  101. #endif
  102. #define CUSTOM_MGMT_CMD_DATA_SIZE 4
  103. #endif
  104. #ifdef CONFIG_MCL
  105. /* WMI commands */
  106. uint32_t g_wmi_command_buf_idx = 0;
  107. struct wmi_command_debug wmi_command_log_buffer[WMI_EVENT_DEBUG_MAX_ENTRY];
  108. /* WMI commands TX completed */
  109. uint32_t g_wmi_command_tx_cmp_buf_idx = 0;
  110. struct wmi_command_debug
  111. wmi_command_tx_cmp_log_buffer[WMI_EVENT_DEBUG_MAX_ENTRY];
  112. /* WMI events when processed */
  113. uint32_t g_wmi_event_buf_idx = 0;
  114. struct wmi_event_debug wmi_event_log_buffer[WMI_EVENT_DEBUG_MAX_ENTRY];
  115. /* WMI events when queued */
  116. uint32_t g_wmi_rx_event_buf_idx = 0;
  117. struct wmi_event_debug wmi_rx_event_log_buffer[WMI_EVENT_DEBUG_MAX_ENTRY];
  118. #endif
  119. #define WMI_COMMAND_RECORD(h, a, b) { \
  120. if (wmi_log_max_entry <= \
  121. *(h->log_info.wmi_command_log_buf_info.p_buf_tail_idx)) \
  122. *(h->log_info.wmi_command_log_buf_info.p_buf_tail_idx) = 0;\
  123. ((struct wmi_command_debug *)h->log_info.wmi_command_log_buf_info.buf)\
  124. [*(h->log_info.wmi_command_log_buf_info.p_buf_tail_idx)]\
  125. .command = a; \
  126. qdf_mem_copy(((struct wmi_command_debug *)h->log_info. \
  127. wmi_command_log_buf_info.buf) \
  128. [*(h->log_info.wmi_command_log_buf_info.p_buf_tail_idx)].data,\
  129. b, wmi_record_max_length); \
  130. ((struct wmi_command_debug *)h->log_info.wmi_command_log_buf_info.buf)\
  131. [*(h->log_info.wmi_command_log_buf_info.p_buf_tail_idx)].\
  132. time = qdf_get_log_timestamp(); \
  133. (*(h->log_info.wmi_command_log_buf_info.p_buf_tail_idx))++; \
  134. h->log_info.wmi_command_log_buf_info.length++; \
  135. }
  136. #define WMI_COMMAND_TX_CMP_RECORD(h, a, b) { \
  137. if (wmi_log_max_entry <= \
  138. *(h->log_info.wmi_command_tx_cmp_log_buf_info.p_buf_tail_idx))\
  139. *(h->log_info.wmi_command_tx_cmp_log_buf_info. \
  140. p_buf_tail_idx) = 0; \
  141. ((struct wmi_command_debug *)h->log_info. \
  142. wmi_command_tx_cmp_log_buf_info.buf) \
  143. [*(h->log_info.wmi_command_tx_cmp_log_buf_info. \
  144. p_buf_tail_idx)]. \
  145. command = a; \
  146. qdf_mem_copy(((struct wmi_command_debug *)h->log_info. \
  147. wmi_command_tx_cmp_log_buf_info.buf) \
  148. [*(h->log_info.wmi_command_tx_cmp_log_buf_info. \
  149. p_buf_tail_idx)]. \
  150. data, b, wmi_record_max_length); \
  151. ((struct wmi_command_debug *)h->log_info. \
  152. wmi_command_tx_cmp_log_buf_info.buf) \
  153. [*(h->log_info.wmi_command_tx_cmp_log_buf_info. \
  154. p_buf_tail_idx)]. \
  155. time = qdf_get_log_timestamp(); \
  156. (*(h->log_info.wmi_command_tx_cmp_log_buf_info.p_buf_tail_idx))++;\
  157. h->log_info.wmi_command_tx_cmp_log_buf_info.length++; \
  158. }
  159. #define WMI_EVENT_RECORD(h, a, b) { \
  160. if (wmi_log_max_entry <= \
  161. *(h->log_info.wmi_event_log_buf_info.p_buf_tail_idx)) \
  162. *(h->log_info.wmi_event_log_buf_info.p_buf_tail_idx) = 0;\
  163. ((struct wmi_event_debug *)h->log_info.wmi_event_log_buf_info.buf)\
  164. [*(h->log_info.wmi_event_log_buf_info.p_buf_tail_idx)]. \
  165. event = a; \
  166. qdf_mem_copy(((struct wmi_event_debug *)h->log_info. \
  167. wmi_event_log_buf_info.buf) \
  168. [*(h->log_info.wmi_event_log_buf_info.p_buf_tail_idx)].data, b,\
  169. wmi_record_max_length); \
  170. ((struct wmi_event_debug *)h->log_info.wmi_event_log_buf_info.buf)\
  171. [*(h->log_info.wmi_event_log_buf_info.p_buf_tail_idx)].time =\
  172. qdf_get_log_timestamp(); \
  173. (*(h->log_info.wmi_event_log_buf_info.p_buf_tail_idx))++; \
  174. h->log_info.wmi_event_log_buf_info.length++; \
  175. }
  176. #define WMI_RX_EVENT_RECORD(h, a, b) { \
  177. if (wmi_log_max_entry <= \
  178. *(h->log_info.wmi_rx_event_log_buf_info.p_buf_tail_idx))\
  179. *(h->log_info.wmi_rx_event_log_buf_info.p_buf_tail_idx) = 0;\
  180. ((struct wmi_event_debug *)h->log_info.wmi_rx_event_log_buf_info.buf)\
  181. [*(h->log_info.wmi_rx_event_log_buf_info.p_buf_tail_idx)].\
  182. event = a; \
  183. qdf_mem_copy(((struct wmi_event_debug *)h->log_info. \
  184. wmi_rx_event_log_buf_info.buf) \
  185. [*(h->log_info.wmi_rx_event_log_buf_info.p_buf_tail_idx)].\
  186. data, b, wmi_record_max_length); \
  187. ((struct wmi_event_debug *)h->log_info.wmi_rx_event_log_buf_info.buf)\
  188. [*(h->log_info.wmi_rx_event_log_buf_info.p_buf_tail_idx)].\
  189. time = qdf_get_log_timestamp(); \
  190. (*(h->log_info.wmi_rx_event_log_buf_info.p_buf_tail_idx))++; \
  191. h->log_info.wmi_rx_event_log_buf_info.length++; \
  192. }
  193. #ifdef CONFIG_MCL
  194. uint32_t g_wmi_mgmt_command_buf_idx = 0;
  195. struct
  196. wmi_command_debug wmi_mgmt_command_log_buffer[WMI_MGMT_EVENT_DEBUG_MAX_ENTRY];
  197. /* wmi_mgmt commands TX completed */
  198. uint32_t g_wmi_mgmt_command_tx_cmp_buf_idx = 0;
  199. struct wmi_command_debug
  200. wmi_mgmt_command_tx_cmp_log_buffer[WMI_MGMT_EVENT_DEBUG_MAX_ENTRY];
  201. /* wmi_mgmt events when processed */
  202. uint32_t g_wmi_mgmt_event_buf_idx = 0;
  203. struct wmi_event_debug
  204. wmi_mgmt_event_log_buffer[WMI_MGMT_EVENT_DEBUG_MAX_ENTRY];
  205. #endif
  206. #define WMI_MGMT_COMMAND_RECORD(h, a, b) { \
  207. if (wmi_mgmt_log_max_entry <= \
  208. *(h->log_info.wmi_mgmt_command_log_buf_info.p_buf_tail_idx)) \
  209. *(h->log_info.wmi_mgmt_command_log_buf_info. \
  210. p_buf_tail_idx) = 0; \
  211. ((struct wmi_command_debug *)h->log_info. \
  212. wmi_mgmt_command_log_buf_info.buf) \
  213. [*(h->log_info.wmi_mgmt_command_log_buf_info.p_buf_tail_idx)].\
  214. command = a; \
  215. qdf_mem_copy(((struct wmi_command_debug *)h->log_info. \
  216. wmi_mgmt_command_log_buf_info.buf) \
  217. [*(h->log_info.wmi_mgmt_command_log_buf_info.p_buf_tail_idx)].\
  218. data, b, \
  219. wmi_record_max_length); \
  220. ((struct wmi_command_debug *)h->log_info. \
  221. wmi_mgmt_command_log_buf_info.buf) \
  222. [*(h->log_info.wmi_mgmt_command_log_buf_info.p_buf_tail_idx)].\
  223. time = qdf_get_log_timestamp(); \
  224. (*(h->log_info.wmi_mgmt_command_log_buf_info.p_buf_tail_idx))++;\
  225. h->log_info.wmi_mgmt_command_log_buf_info.length++; \
  226. }
  227. #define WMI_MGMT_COMMAND_TX_CMP_RECORD(h, a, b) { \
  228. if (wmi_mgmt_log_max_entry <= \
  229. *(h->log_info.wmi_mgmt_command_tx_cmp_log_buf_info. \
  230. p_buf_tail_idx)) \
  231. *(h->log_info.wmi_mgmt_command_tx_cmp_log_buf_info. \
  232. p_buf_tail_idx) = 0; \
  233. ((struct wmi_command_debug *)h->log_info. \
  234. wmi_mgmt_command_tx_cmp_log_buf_info.buf) \
  235. [*(h->log_info.wmi_mgmt_command_tx_cmp_log_buf_info. \
  236. p_buf_tail_idx)].command = a; \
  237. qdf_mem_copy(((struct wmi_command_debug *)h->log_info. \
  238. wmi_mgmt_command_tx_cmp_log_buf_info.buf)\
  239. [*(h->log_info.wmi_mgmt_command_tx_cmp_log_buf_info. \
  240. p_buf_tail_idx)].data, b, \
  241. wmi_record_max_length); \
  242. ((struct wmi_command_debug *)h->log_info. \
  243. wmi_mgmt_command_tx_cmp_log_buf_info.buf) \
  244. [*(h->log_info.wmi_mgmt_command_tx_cmp_log_buf_info. \
  245. p_buf_tail_idx)].time = \
  246. qdf_get_log_timestamp(); \
  247. (*(h->log_info.wmi_mgmt_command_tx_cmp_log_buf_info. \
  248. p_buf_tail_idx))++; \
  249. h->log_info.wmi_mgmt_command_tx_cmp_log_buf_info.length++; \
  250. }
  251. #define WMI_MGMT_EVENT_RECORD(h, a, b) { \
  252. if (wmi_mgmt_log_max_entry <= \
  253. *(h->log_info.wmi_mgmt_event_log_buf_info.p_buf_tail_idx))\
  254. *(h->log_info.wmi_mgmt_event_log_buf_info.p_buf_tail_idx) = 0;\
  255. ((struct wmi_event_debug *)h->log_info.wmi_mgmt_event_log_buf_info.buf)\
  256. [*(h->log_info.wmi_mgmt_event_log_buf_info.p_buf_tail_idx)]\
  257. .event = a; \
  258. qdf_mem_copy(((struct wmi_event_debug *)h->log_info. \
  259. wmi_mgmt_event_log_buf_info.buf) \
  260. [*(h->log_info.wmi_mgmt_event_log_buf_info.p_buf_tail_idx)].\
  261. data, b, wmi_record_max_length); \
  262. ((struct wmi_event_debug *)h->log_info.wmi_mgmt_event_log_buf_info.buf)\
  263. [*(h->log_info.wmi_mgmt_event_log_buf_info.p_buf_tail_idx)].\
  264. time = qdf_get_log_timestamp(); \
  265. (*(h->log_info.wmi_mgmt_event_log_buf_info.p_buf_tail_idx))++; \
  266. h->log_info.wmi_mgmt_event_log_buf_info.length++; \
  267. }
  268. /* These are defined to made it as module param, which can be configured */
  269. uint32_t wmi_log_max_entry = WMI_EVENT_DEBUG_MAX_ENTRY;
  270. uint32_t wmi_mgmt_log_max_entry = WMI_MGMT_EVENT_DEBUG_MAX_ENTRY;
  271. uint32_t wmi_record_max_length = WMI_EVENT_DEBUG_ENTRY_MAX_LENGTH;
  272. uint32_t wmi_display_size = 100;
  273. /**
  274. * wmi_log_init() - Initialize WMI event logging
  275. * @wmi_handle: WMI handle.
  276. *
  277. * Return: Initialization status
  278. */
  279. #ifdef CONFIG_MCL
  280. static QDF_STATUS wmi_log_init(struct wmi_unified *wmi_handle)
  281. {
  282. struct wmi_log_buf_t *cmd_log_buf =
  283. &wmi_handle->log_info.wmi_command_log_buf_info;
  284. struct wmi_log_buf_t *cmd_tx_cmpl_log_buf =
  285. &wmi_handle->log_info.wmi_command_tx_cmp_log_buf_info;
  286. struct wmi_log_buf_t *event_log_buf =
  287. &wmi_handle->log_info.wmi_event_log_buf_info;
  288. struct wmi_log_buf_t *rx_event_log_buf =
  289. &wmi_handle->log_info.wmi_rx_event_log_buf_info;
  290. struct wmi_log_buf_t *mgmt_cmd_log_buf =
  291. &wmi_handle->log_info.wmi_mgmt_command_log_buf_info;
  292. struct wmi_log_buf_t *mgmt_cmd_tx_cmp_log_buf =
  293. &wmi_handle->log_info.wmi_mgmt_command_tx_cmp_log_buf_info;
  294. struct wmi_log_buf_t *mgmt_event_log_buf =
  295. &wmi_handle->log_info.wmi_mgmt_event_log_buf_info;
  296. /* WMI commands */
  297. cmd_log_buf->length = 0;
  298. cmd_log_buf->buf_tail_idx = 0;
  299. cmd_log_buf->buf = wmi_command_log_buffer;
  300. cmd_log_buf->p_buf_tail_idx = &g_wmi_command_buf_idx;
  301. cmd_log_buf->size = WMI_EVENT_DEBUG_MAX_ENTRY;
  302. /* WMI commands TX completed */
  303. cmd_tx_cmpl_log_buf->length = 0;
  304. cmd_tx_cmpl_log_buf->buf_tail_idx = 0;
  305. cmd_tx_cmpl_log_buf->buf = wmi_command_tx_cmp_log_buffer;
  306. cmd_tx_cmpl_log_buf->p_buf_tail_idx = &g_wmi_command_tx_cmp_buf_idx;
  307. cmd_tx_cmpl_log_buf->size = WMI_EVENT_DEBUG_MAX_ENTRY;
  308. /* WMI events when processed */
  309. event_log_buf->length = 0;
  310. event_log_buf->buf_tail_idx = 0;
  311. event_log_buf->buf = wmi_event_log_buffer;
  312. event_log_buf->p_buf_tail_idx = &g_wmi_event_buf_idx;
  313. event_log_buf->size = WMI_EVENT_DEBUG_MAX_ENTRY;
  314. /* WMI events when queued */
  315. rx_event_log_buf->length = 0;
  316. rx_event_log_buf->buf_tail_idx = 0;
  317. rx_event_log_buf->buf = wmi_rx_event_log_buffer;
  318. rx_event_log_buf->p_buf_tail_idx = &g_wmi_rx_event_buf_idx;
  319. rx_event_log_buf->size = WMI_EVENT_DEBUG_MAX_ENTRY;
  320. /* WMI Management commands */
  321. mgmt_cmd_log_buf->length = 0;
  322. mgmt_cmd_log_buf->buf_tail_idx = 0;
  323. mgmt_cmd_log_buf->buf = wmi_mgmt_command_log_buffer;
  324. mgmt_cmd_log_buf->p_buf_tail_idx = &g_wmi_mgmt_command_buf_idx;
  325. mgmt_cmd_log_buf->size = WMI_MGMT_EVENT_DEBUG_MAX_ENTRY;
  326. /* WMI Management commands Tx completed*/
  327. mgmt_cmd_tx_cmp_log_buf->length = 0;
  328. mgmt_cmd_tx_cmp_log_buf->buf_tail_idx = 0;
  329. mgmt_cmd_tx_cmp_log_buf->buf = wmi_mgmt_command_tx_cmp_log_buffer;
  330. mgmt_cmd_tx_cmp_log_buf->p_buf_tail_idx =
  331. &g_wmi_mgmt_command_tx_cmp_buf_idx;
  332. mgmt_cmd_tx_cmp_log_buf->size = WMI_MGMT_EVENT_DEBUG_MAX_ENTRY;
  333. /* WMI Management events when processed*/
  334. mgmt_event_log_buf->length = 0;
  335. mgmt_event_log_buf->buf_tail_idx = 0;
  336. mgmt_event_log_buf->buf = wmi_mgmt_event_log_buffer;
  337. mgmt_event_log_buf->p_buf_tail_idx = &g_wmi_mgmt_event_buf_idx;
  338. mgmt_event_log_buf->size = WMI_MGMT_EVENT_DEBUG_MAX_ENTRY;
  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. cmd_log_buf->size = wmi_log_max_entry;
  367. if (!cmd_log_buf->buf) {
  368. qdf_print("no memory for WMI command log buffer..\n");
  369. return QDF_STATUS_E_NOMEM;
  370. }
  371. cmd_log_buf->p_buf_tail_idx = &cmd_log_buf->buf_tail_idx;
  372. /* WMI commands TX completed */
  373. cmd_tx_cmpl_log_buf->length = 0;
  374. cmd_tx_cmpl_log_buf->buf_tail_idx = 0;
  375. cmd_tx_cmpl_log_buf->buf = (struct wmi_command_debug *) qdf_mem_malloc(
  376. wmi_log_max_entry * sizeof(struct wmi_command_debug));
  377. cmd_tx_cmpl_log_buf->size = wmi_log_max_entry;
  378. if (!cmd_tx_cmpl_log_buf->buf) {
  379. qdf_print("no memory for WMI Command Tx Complete log buffer..\n");
  380. return QDF_STATUS_E_NOMEM;
  381. }
  382. cmd_tx_cmpl_log_buf->p_buf_tail_idx =
  383. &cmd_tx_cmpl_log_buf->buf_tail_idx;
  384. /* WMI events when processed */
  385. event_log_buf->length = 0;
  386. event_log_buf->buf_tail_idx = 0;
  387. event_log_buf->buf = (struct wmi_event_debug *) qdf_mem_malloc(
  388. wmi_log_max_entry * sizeof(struct wmi_event_debug));
  389. event_log_buf->size = wmi_log_max_entry;
  390. if (!event_log_buf->buf) {
  391. qdf_print("no memory for WMI Event log buffer..\n");
  392. return QDF_STATUS_E_NOMEM;
  393. }
  394. event_log_buf->p_buf_tail_idx = &event_log_buf->buf_tail_idx;
  395. /* WMI events when queued */
  396. rx_event_log_buf->length = 0;
  397. rx_event_log_buf->buf_tail_idx = 0;
  398. rx_event_log_buf->buf = (struct wmi_event_debug *) qdf_mem_malloc(
  399. wmi_log_max_entry * sizeof(struct wmi_event_debug));
  400. rx_event_log_buf->size = wmi_log_max_entry;
  401. if (!rx_event_log_buf->buf) {
  402. qdf_print("no memory for WMI Event Rx log buffer..\n");
  403. return QDF_STATUS_E_NOMEM;
  404. }
  405. rx_event_log_buf->p_buf_tail_idx = &rx_event_log_buf->buf_tail_idx;
  406. /* WMI Management commands */
  407. mgmt_cmd_log_buf->length = 0;
  408. mgmt_cmd_log_buf->buf_tail_idx = 0;
  409. mgmt_cmd_log_buf->buf = (struct wmi_command_debug *) qdf_mem_malloc(
  410. wmi_mgmt_log_max_entry * sizeof(struct wmi_command_debug));
  411. mgmt_cmd_log_buf->size = wmi_mgmt_log_max_entry;
  412. if (!mgmt_cmd_log_buf->buf) {
  413. qdf_print("no memory for WMI Management Command log buffer..\n");
  414. return QDF_STATUS_E_NOMEM;
  415. }
  416. mgmt_cmd_log_buf->p_buf_tail_idx = &mgmt_cmd_log_buf->buf_tail_idx;
  417. /* WMI Management commands Tx completed*/
  418. mgmt_cmd_tx_cmp_log_buf->length = 0;
  419. mgmt_cmd_tx_cmp_log_buf->buf_tail_idx = 0;
  420. mgmt_cmd_tx_cmp_log_buf->buf = (struct wmi_command_debug *)
  421. qdf_mem_malloc(
  422. wmi_mgmt_log_max_entry *
  423. sizeof(struct wmi_command_debug));
  424. mgmt_cmd_tx_cmp_log_buf->size = wmi_mgmt_log_max_entry;
  425. if (!mgmt_cmd_tx_cmp_log_buf->buf) {
  426. qdf_print("no memory for WMI Management Command Tx complete log buffer..\n");
  427. return QDF_STATUS_E_NOMEM;
  428. }
  429. mgmt_cmd_tx_cmp_log_buf->p_buf_tail_idx =
  430. &mgmt_cmd_tx_cmp_log_buf->buf_tail_idx;
  431. /* WMI Management events when processed*/
  432. mgmt_event_log_buf->length = 0;
  433. mgmt_event_log_buf->buf_tail_idx = 0;
  434. mgmt_event_log_buf->buf = (struct wmi_event_debug *) qdf_mem_malloc(
  435. wmi_mgmt_log_max_entry *
  436. sizeof(struct wmi_event_debug));
  437. mgmt_event_log_buf->size = wmi_mgmt_log_max_entry;
  438. if (!mgmt_event_log_buf->buf) {
  439. qdf_print("no memory for WMI Management Event log buffer..\n");
  440. return QDF_STATUS_E_NOMEM;
  441. }
  442. mgmt_event_log_buf->p_buf_tail_idx = &mgmt_event_log_buf->buf_tail_idx;
  443. qdf_spinlock_create(&wmi_handle->log_info.wmi_record_lock);
  444. wmi_handle->log_info.wmi_logging_enable = 1;
  445. return QDF_STATUS_SUCCESS;
  446. }
  447. #endif
  448. /**
  449. * wmi_log_buffer_free() - Free all dynamic allocated buffer memory for
  450. * event logging
  451. * @wmi_handle: WMI handle.
  452. *
  453. * Return: None
  454. */
  455. #ifndef CONFIG_MCL
  456. static inline void wmi_log_buffer_free(struct wmi_unified *wmi_handle)
  457. {
  458. if (wmi_handle->log_info.wmi_command_log_buf_info.buf)
  459. qdf_mem_free(wmi_handle->log_info.wmi_command_log_buf_info.buf);
  460. if (wmi_handle->log_info.wmi_command_tx_cmp_log_buf_info.buf)
  461. qdf_mem_free(
  462. wmi_handle->log_info.wmi_command_tx_cmp_log_buf_info.buf);
  463. if (wmi_handle->log_info.wmi_event_log_buf_info.buf)
  464. qdf_mem_free(wmi_handle->log_info.wmi_event_log_buf_info.buf);
  465. if (wmi_handle->log_info.wmi_rx_event_log_buf_info.buf)
  466. qdf_mem_free(
  467. wmi_handle->log_info.wmi_rx_event_log_buf_info.buf);
  468. if (wmi_handle->log_info.wmi_mgmt_command_log_buf_info.buf)
  469. qdf_mem_free(
  470. wmi_handle->log_info.wmi_mgmt_command_log_buf_info.buf);
  471. if (wmi_handle->log_info.wmi_mgmt_command_tx_cmp_log_buf_info.buf)
  472. qdf_mem_free(
  473. wmi_handle->log_info.wmi_mgmt_command_tx_cmp_log_buf_info.buf);
  474. if (wmi_handle->log_info.wmi_mgmt_event_log_buf_info.buf)
  475. qdf_mem_free(
  476. wmi_handle->log_info.wmi_mgmt_event_log_buf_info.buf);
  477. wmi_handle->log_info.wmi_logging_enable = 0;
  478. qdf_spinlock_destroy(&wmi_handle->log_info.wmi_record_lock);
  479. }
  480. #else
  481. static inline void wmi_log_buffer_free(struct wmi_unified *wmi_handle)
  482. {
  483. /* Do Nothing */
  484. }
  485. #endif
  486. /**
  487. * wmi_print_cmd_log_buffer() - an output agnostic wmi command log printer
  488. * @log_buffer: the command log buffer metadata of the buffer to print
  489. * @count: the maximum number of entries to print
  490. * @print: an abstract print method, e.g. a qdf_print() or seq_printf() wrapper
  491. * @print_priv: any data required by the print method, e.g. a file handle
  492. *
  493. * Return: None
  494. */
  495. static void
  496. wmi_print_cmd_log_buffer(struct wmi_log_buf_t *log_buffer, uint32_t count,
  497. qdf_abstract_print *print, void *print_priv)
  498. {
  499. static const int data_len =
  500. WMI_EVENT_DEBUG_ENTRY_MAX_LENGTH / sizeof(uint32_t);
  501. char str[128];
  502. uint32_t idx;
  503. if (count > log_buffer->size)
  504. count = log_buffer->size;
  505. if (count > log_buffer->length)
  506. count = log_buffer->length;
  507. /* subtract count from index, and wrap if necessary */
  508. idx = log_buffer->size + *log_buffer->p_buf_tail_idx - count;
  509. idx %= log_buffer->size;
  510. print(print_priv, "Time (seconds) Cmd Id Payload");
  511. while (count) {
  512. struct wmi_command_debug *cmd_log = (struct wmi_command_debug *)
  513. &((struct wmi_command_debug *)log_buffer->buf)[idx];
  514. uint64_t secs, usecs;
  515. int len = 0;
  516. int i;
  517. qdf_log_timestamp_to_secs(cmd_log->time, &secs, &usecs);
  518. len += scnprintf(str + len, sizeof(str) - len,
  519. "% 8lld.%06lld %6u (0x%06x) ",
  520. secs, usecs,
  521. cmd_log->command, cmd_log->command);
  522. for (i = 0; i < data_len; ++i) {
  523. len += scnprintf(str + len, sizeof(str) - len,
  524. "0x%08x ", cmd_log->data[i]);
  525. }
  526. print(print_priv, str);
  527. --count;
  528. ++idx;
  529. if (idx >= log_buffer->size)
  530. idx = 0;
  531. }
  532. }
  533. /**
  534. * wmi_print_event_log_buffer() - an output agnostic wmi event log printer
  535. * @log_buffer: the event log buffer metadata of the buffer to print
  536. * @count: the maximum number of entries to print
  537. * @print: an abstract print method, e.g. a qdf_print() or seq_printf() wrapper
  538. * @print_priv: any data required by the print method, e.g. a file handle
  539. *
  540. * Return: None
  541. */
  542. static void
  543. wmi_print_event_log_buffer(struct wmi_log_buf_t *log_buffer, uint32_t count,
  544. qdf_abstract_print *print, void *print_priv)
  545. {
  546. static const int data_len =
  547. WMI_EVENT_DEBUG_ENTRY_MAX_LENGTH / sizeof(uint32_t);
  548. char str[128];
  549. uint32_t idx;
  550. if (count > log_buffer->size)
  551. count = log_buffer->size;
  552. if (count > log_buffer->length)
  553. count = log_buffer->length;
  554. /* subtract count from index, and wrap if necessary */
  555. idx = log_buffer->size + *log_buffer->p_buf_tail_idx - count;
  556. idx %= log_buffer->size;
  557. print(print_priv, "Time (seconds) Event Id Payload");
  558. while (count) {
  559. struct wmi_event_debug *event_log = (struct wmi_event_debug *)
  560. &((struct wmi_event_debug *)log_buffer->buf)[idx];
  561. uint64_t secs, usecs;
  562. int len = 0;
  563. int i;
  564. qdf_log_timestamp_to_secs(event_log->time, &secs, &usecs);
  565. len += scnprintf(str + len, sizeof(str) - len,
  566. "% 8lld.%06lld %6u (0x%06x) ",
  567. secs, usecs,
  568. event_log->event, event_log->event);
  569. for (i = 0; i < data_len; ++i) {
  570. len += scnprintf(str + len, sizeof(str) - len,
  571. "0x%08x ", event_log->data[i]);
  572. }
  573. print(print_priv, str);
  574. --count;
  575. ++idx;
  576. if (idx >= log_buffer->size)
  577. idx = 0;
  578. }
  579. }
  580. inline void
  581. wmi_print_cmd_log(wmi_unified_t wmi, uint32_t count,
  582. qdf_abstract_print *print, void *print_priv)
  583. {
  584. wmi_print_cmd_log_buffer(
  585. &wmi->log_info.wmi_command_log_buf_info,
  586. count, print, print_priv);
  587. }
  588. inline void
  589. wmi_print_cmd_tx_cmp_log(wmi_unified_t wmi, uint32_t count,
  590. qdf_abstract_print *print, void *print_priv)
  591. {
  592. wmi_print_cmd_log_buffer(
  593. &wmi->log_info.wmi_command_tx_cmp_log_buf_info,
  594. count, print, print_priv);
  595. }
  596. inline void
  597. wmi_print_mgmt_cmd_log(wmi_unified_t wmi, uint32_t count,
  598. qdf_abstract_print *print, void *print_priv)
  599. {
  600. wmi_print_cmd_log_buffer(
  601. &wmi->log_info.wmi_mgmt_command_log_buf_info,
  602. count, print, print_priv);
  603. }
  604. inline void
  605. wmi_print_mgmt_cmd_tx_cmp_log(wmi_unified_t wmi, uint32_t count,
  606. qdf_abstract_print *print, void *print_priv)
  607. {
  608. wmi_print_cmd_log_buffer(
  609. &wmi->log_info.wmi_mgmt_command_tx_cmp_log_buf_info,
  610. count, print, print_priv);
  611. }
  612. inline void
  613. wmi_print_event_log(wmi_unified_t wmi, uint32_t count,
  614. qdf_abstract_print *print, void *print_priv)
  615. {
  616. wmi_print_event_log_buffer(
  617. &wmi->log_info.wmi_event_log_buf_info,
  618. count, print, print_priv);
  619. }
  620. inline void
  621. wmi_print_rx_event_log(wmi_unified_t wmi, uint32_t count,
  622. qdf_abstract_print *print, void *print_priv)
  623. {
  624. wmi_print_event_log_buffer(
  625. &wmi->log_info.wmi_rx_event_log_buf_info,
  626. count, print, print_priv);
  627. }
  628. inline void
  629. wmi_print_mgmt_event_log(wmi_unified_t wmi, uint32_t count,
  630. qdf_abstract_print *print, void *print_priv)
  631. {
  632. wmi_print_event_log_buffer(
  633. &wmi->log_info.wmi_mgmt_event_log_buf_info,
  634. count, print, print_priv);
  635. }
  636. #ifdef CONFIG_MCL
  637. const int8_t * const debugfs_dir[MAX_WMI_INSTANCES] = {"WMI0"};
  638. #else
  639. const int8_t * const debugfs_dir[MAX_WMI_INSTANCES] = {"WMI0", "WMI1", "WMI2"};
  640. #endif
  641. /* debugfs routines*/
  642. /**
  643. * debug_wmi_##func_base##_show() - debugfs functions to display content of
  644. * command and event buffers. Macro uses max buffer length to display
  645. * buffer when it is wraparound.
  646. *
  647. * @m: debugfs handler to access wmi_handle
  648. * @v: Variable arguments (not used)
  649. *
  650. * Return: Length of characters printed
  651. */
  652. #define GENERATE_COMMAND_DEBUG_SHOW_FUNCS(func_base, wmi_ring_size) \
  653. static int debug_wmi_##func_base##_show(struct seq_file *m, \
  654. void *v) \
  655. { \
  656. wmi_unified_t wmi_handle = (wmi_unified_t) m->private; \
  657. struct wmi_log_buf_t *wmi_log = \
  658. &wmi_handle->log_info.wmi_##func_base##_buf_info;\
  659. int pos, nread, outlen; \
  660. int i; \
  661. uint64_t secs, usecs; \
  662. \
  663. qdf_spin_lock(&wmi_handle->log_info.wmi_record_lock); \
  664. if (!wmi_log->length) { \
  665. qdf_spin_unlock(&wmi_handle->log_info.wmi_record_lock);\
  666. return wmi_bp_seq_printf(m, \
  667. "no elements to read from ring buffer!\n"); \
  668. } \
  669. \
  670. if (wmi_log->length <= wmi_ring_size) \
  671. nread = wmi_log->length; \
  672. else \
  673. nread = wmi_ring_size; \
  674. \
  675. if (*(wmi_log->p_buf_tail_idx) == 0) \
  676. /* tail can be 0 after wrap-around */ \
  677. pos = wmi_ring_size - 1; \
  678. else \
  679. pos = *(wmi_log->p_buf_tail_idx) - 1; \
  680. \
  681. outlen = wmi_bp_seq_printf(m, "Length = %d\n", wmi_log->length);\
  682. qdf_spin_unlock(&wmi_handle->log_info.wmi_record_lock); \
  683. while (nread--) { \
  684. struct wmi_command_debug *wmi_record; \
  685. \
  686. wmi_record = (struct wmi_command_debug *) \
  687. &(((struct wmi_command_debug *)wmi_log->buf)[pos]);\
  688. outlen += wmi_bp_seq_printf(m, "CMD ID = %x\n", \
  689. (wmi_record->command)); \
  690. qdf_log_timestamp_to_secs(wmi_record->time, &secs,\
  691. &usecs); \
  692. outlen += \
  693. wmi_bp_seq_printf(m, "CMD TIME = [%llu.%06llu]\n",\
  694. secs, usecs); \
  695. outlen += wmi_bp_seq_printf(m, "CMD = "); \
  696. for (i = 0; i < (wmi_record_max_length/ \
  697. sizeof(uint32_t)); i++) \
  698. outlen += wmi_bp_seq_printf(m, "%x ", \
  699. wmi_record->data[i]); \
  700. outlen += wmi_bp_seq_printf(m, "\n"); \
  701. \
  702. if (pos == 0) \
  703. pos = wmi_ring_size - 1; \
  704. else \
  705. pos--; \
  706. } \
  707. return outlen; \
  708. } \
  709. #define GENERATE_EVENT_DEBUG_SHOW_FUNCS(func_base, wmi_ring_size) \
  710. static int debug_wmi_##func_base##_show(struct seq_file *m, \
  711. void *v) \
  712. { \
  713. wmi_unified_t wmi_handle = (wmi_unified_t) m->private; \
  714. struct wmi_log_buf_t *wmi_log = \
  715. &wmi_handle->log_info.wmi_##func_base##_buf_info;\
  716. int pos, nread, outlen; \
  717. int i; \
  718. uint64_t secs, usecs; \
  719. \
  720. qdf_spin_lock(&wmi_handle->log_info.wmi_record_lock); \
  721. if (!wmi_log->length) { \
  722. qdf_spin_unlock(&wmi_handle->log_info.wmi_record_lock);\
  723. return wmi_bp_seq_printf(m, \
  724. "no elements to read from ring buffer!\n"); \
  725. } \
  726. \
  727. if (wmi_log->length <= wmi_ring_size) \
  728. nread = wmi_log->length; \
  729. else \
  730. nread = wmi_ring_size; \
  731. \
  732. if (*(wmi_log->p_buf_tail_idx) == 0) \
  733. /* tail can be 0 after wrap-around */ \
  734. pos = wmi_ring_size - 1; \
  735. else \
  736. pos = *(wmi_log->p_buf_tail_idx) - 1; \
  737. \
  738. outlen = wmi_bp_seq_printf(m, "Length = %d\n", wmi_log->length);\
  739. qdf_spin_unlock(&wmi_handle->log_info.wmi_record_lock); \
  740. while (nread--) { \
  741. struct wmi_event_debug *wmi_record; \
  742. \
  743. wmi_record = (struct wmi_event_debug *) \
  744. &(((struct wmi_event_debug *)wmi_log->buf)[pos]);\
  745. qdf_log_timestamp_to_secs(wmi_record->time, &secs,\
  746. &usecs); \
  747. outlen += wmi_bp_seq_printf(m, "Event ID = %x\n",\
  748. (wmi_record->event)); \
  749. outlen += \
  750. wmi_bp_seq_printf(m, "Event TIME = [%llu.%06llu]\n",\
  751. secs, usecs); \
  752. outlen += wmi_bp_seq_printf(m, "CMD = "); \
  753. for (i = 0; i < (wmi_record_max_length/ \
  754. sizeof(uint32_t)); i++) \
  755. outlen += wmi_bp_seq_printf(m, "%x ", \
  756. wmi_record->data[i]); \
  757. outlen += wmi_bp_seq_printf(m, "\n"); \
  758. \
  759. if (pos == 0) \
  760. pos = wmi_ring_size - 1; \
  761. else \
  762. pos--; \
  763. } \
  764. return outlen; \
  765. }
  766. GENERATE_COMMAND_DEBUG_SHOW_FUNCS(command_log, wmi_display_size);
  767. GENERATE_COMMAND_DEBUG_SHOW_FUNCS(command_tx_cmp_log, wmi_display_size);
  768. GENERATE_EVENT_DEBUG_SHOW_FUNCS(event_log, wmi_display_size);
  769. GENERATE_EVENT_DEBUG_SHOW_FUNCS(rx_event_log, wmi_display_size);
  770. GENERATE_COMMAND_DEBUG_SHOW_FUNCS(mgmt_command_log, wmi_display_size);
  771. GENERATE_COMMAND_DEBUG_SHOW_FUNCS(mgmt_command_tx_cmp_log,
  772. wmi_display_size);
  773. GENERATE_EVENT_DEBUG_SHOW_FUNCS(mgmt_event_log, wmi_display_size);
  774. /**
  775. * debug_wmi_enable_show() - debugfs functions to display enable state of
  776. * wmi logging feature.
  777. *
  778. * @m: debugfs handler to access wmi_handle
  779. * @v: Variable arguments (not used)
  780. *
  781. * Return: always 1
  782. */
  783. static int debug_wmi_enable_show(struct seq_file *m, void *v)
  784. {
  785. wmi_unified_t wmi_handle = (wmi_unified_t) m->private;
  786. return wmi_bp_seq_printf(m, "%d\n",
  787. wmi_handle->log_info.wmi_logging_enable);
  788. }
  789. /**
  790. * debug_wmi_log_size_show() - debugfs functions to display configured size of
  791. * wmi logging command/event buffer and management command/event buffer.
  792. *
  793. * @m: debugfs handler to access wmi_handle
  794. * @v: Variable arguments (not used)
  795. *
  796. * Return: Length of characters printed
  797. */
  798. static int debug_wmi_log_size_show(struct seq_file *m, void *v)
  799. {
  800. wmi_bp_seq_printf(m, "WMI command/event log max size:%d\n",
  801. wmi_log_max_entry);
  802. return wmi_bp_seq_printf(m,
  803. "WMI management command/events log max size:%d\n",
  804. wmi_mgmt_log_max_entry);
  805. }
  806. /**
  807. * debug_wmi_##func_base##_write() - debugfs functions to clear
  808. * wmi logging command/event buffer and management command/event buffer.
  809. *
  810. * @file: file handler to access wmi_handle
  811. * @buf: received data buffer
  812. * @count: length of received buffer
  813. * @ppos: Not used
  814. *
  815. * Return: count
  816. */
  817. #define GENERATE_DEBUG_WRITE_FUNCS(func_base, wmi_ring_size, wmi_record_type)\
  818. static ssize_t debug_wmi_##func_base##_write(struct file *file, \
  819. const char __user *buf, \
  820. size_t count, loff_t *ppos) \
  821. { \
  822. int k, ret; \
  823. wmi_unified_t wmi_handle = \
  824. ((struct seq_file *)file->private_data)->private;\
  825. struct wmi_log_buf_t *wmi_log = &wmi_handle->log_info. \
  826. wmi_##func_base##_buf_info; \
  827. char locbuf[50]; \
  828. \
  829. if ((!buf) || (count > 50)) \
  830. return -EFAULT; \
  831. \
  832. if (copy_from_user(locbuf, buf, count)) \
  833. return -EFAULT; \
  834. \
  835. ret = sscanf(locbuf, "%d", &k); \
  836. if ((ret != 1) || (k != 0)) { \
  837. qdf_print("Wrong input, echo 0 to clear the wmi buffer\n");\
  838. return -EINVAL; \
  839. } \
  840. \
  841. qdf_spin_lock(&wmi_handle->log_info.wmi_record_lock); \
  842. qdf_mem_zero(wmi_log->buf, wmi_ring_size * \
  843. sizeof(struct wmi_record_type)); \
  844. wmi_log->length = 0; \
  845. *(wmi_log->p_buf_tail_idx) = 0; \
  846. qdf_spin_unlock(&wmi_handle->log_info.wmi_record_lock); \
  847. \
  848. return count; \
  849. }
  850. GENERATE_DEBUG_WRITE_FUNCS(command_log, wmi_log_max_entry,
  851. wmi_command_debug);
  852. GENERATE_DEBUG_WRITE_FUNCS(command_tx_cmp_log, wmi_log_max_entry,
  853. wmi_command_debug);
  854. GENERATE_DEBUG_WRITE_FUNCS(event_log, wmi_log_max_entry,
  855. wmi_event_debug);
  856. GENERATE_DEBUG_WRITE_FUNCS(rx_event_log, wmi_log_max_entry,
  857. wmi_event_debug);
  858. GENERATE_DEBUG_WRITE_FUNCS(mgmt_command_log, wmi_mgmt_log_max_entry,
  859. wmi_command_debug);
  860. GENERATE_DEBUG_WRITE_FUNCS(mgmt_command_tx_cmp_log,
  861. wmi_mgmt_log_max_entry, wmi_command_debug);
  862. GENERATE_DEBUG_WRITE_FUNCS(mgmt_event_log, wmi_mgmt_log_max_entry,
  863. wmi_event_debug);
  864. /**
  865. * debug_wmi_enable_write() - debugfs functions to enable/disable
  866. * wmi logging feature.
  867. *
  868. * @file: file handler to access wmi_handle
  869. * @buf: received data buffer
  870. * @count: length of received buffer
  871. * @ppos: Not used
  872. *
  873. * Return: count
  874. */
  875. static ssize_t debug_wmi_enable_write(struct file *file, const char __user *buf,
  876. size_t count, loff_t *ppos)
  877. {
  878. wmi_unified_t wmi_handle =
  879. ((struct seq_file *)file->private_data)->private;
  880. int k, ret;
  881. char locbuf[50];
  882. if ((!buf) || (count > 50))
  883. return -EFAULT;
  884. if (copy_from_user(locbuf, buf, count))
  885. return -EFAULT;
  886. ret = sscanf(locbuf, "%d", &k);
  887. if ((ret != 1) || ((k != 0) && (k != 1)))
  888. return -EINVAL;
  889. wmi_handle->log_info.wmi_logging_enable = k;
  890. return count;
  891. }
  892. /**
  893. * debug_wmi_log_size_write() - reserved.
  894. *
  895. * @file: file handler to access wmi_handle
  896. * @buf: received data buffer
  897. * @count: length of received buffer
  898. * @ppos: Not used
  899. *
  900. * Return: count
  901. */
  902. static ssize_t debug_wmi_log_size_write(struct file *file,
  903. const char __user *buf, size_t count, loff_t *ppos)
  904. {
  905. return -EINVAL;
  906. }
  907. /* Structure to maintain debug information */
  908. struct wmi_debugfs_info {
  909. const char *name;
  910. struct dentry *de[MAX_WMI_INSTANCES];
  911. const struct file_operations *ops;
  912. };
  913. #define DEBUG_FOO(func_base) { .name = #func_base, \
  914. .ops = &debug_##func_base##_ops }
  915. /**
  916. * debug_##func_base##_open() - Open debugfs entry for respective command
  917. * and event buffer.
  918. *
  919. * @inode: node for debug dir entry
  920. * @file: file handler
  921. *
  922. * Return: open status
  923. */
  924. #define GENERATE_DEBUG_STRUCTS(func_base) \
  925. static int debug_##func_base##_open(struct inode *inode, \
  926. struct file *file) \
  927. { \
  928. return single_open(file, debug_##func_base##_show, \
  929. inode->i_private); \
  930. } \
  931. \
  932. \
  933. static struct file_operations debug_##func_base##_ops = { \
  934. .open = debug_##func_base##_open, \
  935. .read = seq_read, \
  936. .llseek = seq_lseek, \
  937. .write = debug_##func_base##_write, \
  938. .release = single_release, \
  939. };
  940. GENERATE_DEBUG_STRUCTS(wmi_command_log);
  941. GENERATE_DEBUG_STRUCTS(wmi_command_tx_cmp_log);
  942. GENERATE_DEBUG_STRUCTS(wmi_event_log);
  943. GENERATE_DEBUG_STRUCTS(wmi_rx_event_log);
  944. GENERATE_DEBUG_STRUCTS(wmi_mgmt_command_log);
  945. GENERATE_DEBUG_STRUCTS(wmi_mgmt_command_tx_cmp_log);
  946. GENERATE_DEBUG_STRUCTS(wmi_mgmt_event_log);
  947. GENERATE_DEBUG_STRUCTS(wmi_enable);
  948. GENERATE_DEBUG_STRUCTS(wmi_log_size);
  949. struct wmi_debugfs_info wmi_debugfs_infos[] = {
  950. DEBUG_FOO(wmi_command_log),
  951. DEBUG_FOO(wmi_command_tx_cmp_log),
  952. DEBUG_FOO(wmi_event_log),
  953. DEBUG_FOO(wmi_rx_event_log),
  954. DEBUG_FOO(wmi_mgmt_command_log),
  955. DEBUG_FOO(wmi_mgmt_command_tx_cmp_log),
  956. DEBUG_FOO(wmi_mgmt_event_log),
  957. DEBUG_FOO(wmi_enable),
  958. DEBUG_FOO(wmi_log_size),
  959. };
  960. #define NUM_DEBUG_INFOS (sizeof(wmi_debugfs_infos) / \
  961. sizeof(wmi_debugfs_infos[0]))
  962. /**
  963. * wmi_debugfs_create() - Create debug_fs entry for wmi logging.
  964. *
  965. * @wmi_handle: wmi handle
  966. * @par_entry: debug directory entry
  967. * @id: Index to debug info data array
  968. *
  969. * Return: none
  970. */
  971. static void wmi_debugfs_create(wmi_unified_t wmi_handle,
  972. struct dentry *par_entry, int id)
  973. {
  974. int i;
  975. if (par_entry == NULL || (id < 0) || (id >= MAX_WMI_INSTANCES))
  976. goto out;
  977. for (i = 0; i < NUM_DEBUG_INFOS; ++i) {
  978. wmi_debugfs_infos[i].de[id] = debugfs_create_file(
  979. wmi_debugfs_infos[i].name, 0644, par_entry,
  980. wmi_handle, wmi_debugfs_infos[i].ops);
  981. if (wmi_debugfs_infos[i].de[id] == NULL) {
  982. qdf_print("%s: debug Entry creation failed!\n",
  983. __func__);
  984. goto out;
  985. }
  986. }
  987. return;
  988. out:
  989. qdf_print("%s: debug Entry creation failed!\n", __func__);
  990. wmi_log_buffer_free(wmi_handle);
  991. return;
  992. }
  993. /**
  994. * wmi_debugfs_remove() - Remove debugfs entry for wmi logging.
  995. * @wmi_handle: wmi handle
  996. * @dentry: debugfs directory entry
  997. * @id: Index to debug info data array
  998. *
  999. * Return: none
  1000. */
  1001. static void wmi_debugfs_remove(wmi_unified_t wmi_handle)
  1002. {
  1003. int i;
  1004. struct dentry *dentry = wmi_handle->log_info.wmi_log_debugfs_dir;
  1005. int id;
  1006. if (!wmi_handle->log_info.wmi_instance_id)
  1007. return;
  1008. id = wmi_handle->log_info.wmi_instance_id - 1;
  1009. if (dentry && (!(id < 0) || (id >= MAX_WMI_INSTANCES))) {
  1010. for (i = 0; i < NUM_DEBUG_INFOS; ++i) {
  1011. if (wmi_debugfs_infos[i].de[id])
  1012. wmi_debugfs_infos[i].de[id] = NULL;
  1013. }
  1014. }
  1015. if (dentry)
  1016. debugfs_remove_recursive(dentry);
  1017. if (wmi_handle->log_info.wmi_instance_id)
  1018. wmi_handle->log_info.wmi_instance_id--;
  1019. }
  1020. /**
  1021. * wmi_debugfs_init() - debugfs functions to create debugfs directory and to
  1022. * create debugfs enteries.
  1023. *
  1024. * @h: wmi handler
  1025. *
  1026. * Return: init status
  1027. */
  1028. static QDF_STATUS wmi_debugfs_init(wmi_unified_t wmi_handle)
  1029. {
  1030. int wmi_index = wmi_handle->log_info.wmi_instance_id;
  1031. if (wmi_index < MAX_WMI_INSTANCES) {
  1032. wmi_handle->log_info.wmi_log_debugfs_dir =
  1033. debugfs_create_dir(debugfs_dir[wmi_index], NULL);
  1034. if (!wmi_handle->log_info.wmi_log_debugfs_dir) {
  1035. qdf_print("error while creating debugfs dir for %s\n",
  1036. debugfs_dir[wmi_index]);
  1037. return QDF_STATUS_E_FAILURE;
  1038. }
  1039. wmi_debugfs_create(wmi_handle,
  1040. wmi_handle->log_info.wmi_log_debugfs_dir,
  1041. wmi_index);
  1042. wmi_handle->log_info.wmi_instance_id++;
  1043. }
  1044. return QDF_STATUS_SUCCESS;
  1045. }
  1046. /**
  1047. * wmi_mgmt_cmd_record() - Wrapper function for mgmt command logging macro
  1048. *
  1049. * @wmi_handle: wmi handle
  1050. * @cmd: mgmt command
  1051. * @header: pointer to 802.11 header
  1052. * @vdev_id: vdev id
  1053. * @chanfreq: channel frequency
  1054. *
  1055. * Return: none
  1056. */
  1057. void wmi_mgmt_cmd_record(wmi_unified_t wmi_handle, uint32_t cmd,
  1058. void *header, uint32_t vdev_id, uint32_t chanfreq)
  1059. {
  1060. uint32_t data[CUSTOM_MGMT_CMD_DATA_SIZE];
  1061. data[0] = ((struct wmi_command_header *)header)->type;
  1062. data[1] = ((struct wmi_command_header *)header)->sub_type;
  1063. data[2] = vdev_id;
  1064. data[3] = chanfreq;
  1065. qdf_spin_lock_bh(&wmi_handle->log_info.wmi_record_lock);
  1066. WMI_MGMT_COMMAND_RECORD(wmi_handle, cmd, (uint8_t *)data);
  1067. qdf_spin_unlock_bh(&wmi_handle->log_info.wmi_record_lock);
  1068. }
  1069. #else
  1070. /**
  1071. * wmi_debugfs_remove() - Remove debugfs entry for wmi logging.
  1072. * @wmi_handle: wmi handle
  1073. * @dentry: debugfs directory entry
  1074. * @id: Index to debug info data array
  1075. *
  1076. * Return: none
  1077. */
  1078. static void wmi_debugfs_remove(wmi_unified_t wmi_handle) { }
  1079. void wmi_mgmt_cmd_record(wmi_unified_t wmi_handle, uint32_t cmd,
  1080. void *header, uint32_t vdev_id, uint32_t chanfreq) { }
  1081. static inline void wmi_log_buffer_free(struct wmi_unified *wmi_handle) { }
  1082. #endif /*WMI_INTERFACE_EVENT_LOGGING */
  1083. qdf_export_symbol(wmi_mgmt_cmd_record);
  1084. int wmi_get_host_credits(wmi_unified_t wmi_handle);
  1085. /* WMI buffer APIs */
  1086. #ifdef MEMORY_DEBUG
  1087. wmi_buf_t
  1088. wmi_buf_alloc_debug(wmi_unified_t wmi_handle, uint16_t len, uint8_t *file_name,
  1089. uint32_t line_num)
  1090. {
  1091. wmi_buf_t wmi_buf;
  1092. if (roundup(len + WMI_MIN_HEAD_ROOM, 4) > wmi_handle->max_msg_len) {
  1093. QDF_ASSERT(0);
  1094. return NULL;
  1095. }
  1096. wmi_buf = qdf_nbuf_alloc_debug(NULL,
  1097. roundup(len + WMI_MIN_HEAD_ROOM, 4),
  1098. WMI_MIN_HEAD_ROOM, 4, false, file_name,
  1099. line_num);
  1100. if (!wmi_buf)
  1101. return NULL;
  1102. /* Clear the wmi buffer */
  1103. OS_MEMZERO(qdf_nbuf_data(wmi_buf), len);
  1104. /*
  1105. * Set the length of the buffer to match the allocation size.
  1106. */
  1107. qdf_nbuf_set_pktlen(wmi_buf, len);
  1108. return wmi_buf;
  1109. }
  1110. qdf_export_symbol(wmi_buf_alloc_debug);
  1111. void wmi_buf_free(wmi_buf_t net_buf)
  1112. {
  1113. qdf_nbuf_free(net_buf);
  1114. }
  1115. qdf_export_symbol(wmi_buf_free);
  1116. #else
  1117. wmi_buf_t wmi_buf_alloc(wmi_unified_t wmi_handle, uint16_t len)
  1118. {
  1119. wmi_buf_t wmi_buf;
  1120. if (roundup(len + WMI_MIN_HEAD_ROOM, 4) > wmi_handle->max_msg_len) {
  1121. QDF_ASSERT(0);
  1122. return NULL;
  1123. }
  1124. wmi_buf = qdf_nbuf_alloc(NULL, roundup(len + WMI_MIN_HEAD_ROOM, 4),
  1125. WMI_MIN_HEAD_ROOM, 4, false);
  1126. if (!wmi_buf)
  1127. return NULL;
  1128. /* Clear the wmi buffer */
  1129. OS_MEMZERO(qdf_nbuf_data(wmi_buf), len);
  1130. /*
  1131. * Set the length of the buffer to match the allocation size.
  1132. */
  1133. qdf_nbuf_set_pktlen(wmi_buf, len);
  1134. return wmi_buf;
  1135. }
  1136. qdf_export_symbol(wmi_buf_alloc);
  1137. void wmi_buf_free(wmi_buf_t net_buf)
  1138. {
  1139. qdf_nbuf_free(net_buf);
  1140. }
  1141. qdf_export_symbol(wmi_buf_free);
  1142. #endif
  1143. /**
  1144. * wmi_get_max_msg_len() - get maximum WMI message length
  1145. * @wmi_handle: WMI handle.
  1146. *
  1147. * This function returns the maximum WMI message length
  1148. *
  1149. * Return: maximum WMI message length
  1150. */
  1151. uint16_t wmi_get_max_msg_len(wmi_unified_t wmi_handle)
  1152. {
  1153. return wmi_handle->max_msg_len - WMI_MIN_HEAD_ROOM;
  1154. }
  1155. qdf_export_symbol(wmi_get_max_msg_len);
  1156. #ifndef WMI_CMD_STRINGS
  1157. static uint8_t *wmi_id_to_name(uint32_t wmi_command)
  1158. {
  1159. return "Invalid WMI cmd";
  1160. }
  1161. #endif
  1162. #ifdef CONFIG_MCL
  1163. static inline void wmi_log_cmd_id(uint32_t cmd_id, uint32_t tag)
  1164. {
  1165. WMI_LOGD("Send WMI command:%s command_id:%d htc_tag:%d\n",
  1166. wmi_id_to_name(cmd_id), cmd_id, tag);
  1167. }
  1168. /**
  1169. * wmi_is_pm_resume_cmd() - check if a cmd is part of the resume sequence
  1170. * @cmd_id: command to check
  1171. *
  1172. * Return: true if the command is part of the resume sequence.
  1173. */
  1174. static bool wmi_is_pm_resume_cmd(uint32_t cmd_id)
  1175. {
  1176. switch (cmd_id) {
  1177. case WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID:
  1178. case WMI_PDEV_RESUME_CMDID:
  1179. return true;
  1180. default:
  1181. return false;
  1182. }
  1183. }
  1184. #else
  1185. static bool wmi_is_pm_resume_cmd(uint32_t cmd_id)
  1186. {
  1187. return false;
  1188. }
  1189. #endif
  1190. /**
  1191. * wmi_unified_cmd_send() - WMI command API
  1192. * @wmi_handle: handle to wmi
  1193. * @buf: wmi buf
  1194. * @len: wmi buffer length
  1195. * @cmd_id: wmi command id
  1196. *
  1197. * Note, it is NOT safe to access buf after calling this function!
  1198. *
  1199. * Return: 0 on success
  1200. */
  1201. QDF_STATUS wmi_unified_cmd_send(wmi_unified_t wmi_handle, wmi_buf_t buf,
  1202. uint32_t len, uint32_t cmd_id)
  1203. {
  1204. HTC_PACKET *pkt;
  1205. QDF_STATUS status;
  1206. uint16_t htc_tag = 0;
  1207. if (wmi_get_runtime_pm_inprogress(wmi_handle)) {
  1208. htc_tag =
  1209. (uint16_t)wmi_handle->ops->wmi_set_htc_tx_tag(
  1210. wmi_handle, buf, cmd_id);
  1211. } else if (qdf_atomic_read(&wmi_handle->is_target_suspended) &&
  1212. (!wmi_is_pm_resume_cmd(cmd_id))) {
  1213. QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_ERROR,
  1214. "%s: Target is suspended", __func__);
  1215. QDF_ASSERT(0);
  1216. return QDF_STATUS_E_BUSY;
  1217. }
  1218. if (wmi_handle->wmi_stopinprogress) {
  1219. QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_ERROR,
  1220. "WMI stop in progress\n");
  1221. return QDF_STATUS_E_INVAL;
  1222. }
  1223. #ifndef WMI_NON_TLV_SUPPORT
  1224. /* Do sanity check on the TLV parameter structure */
  1225. if (wmi_handle->target_type == WMI_TLV_TARGET) {
  1226. void *buf_ptr = (void *)qdf_nbuf_data(buf);
  1227. if (wmi_handle->ops->wmi_check_command_params(NULL, buf_ptr, len, cmd_id)
  1228. != 0) {
  1229. QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_ERROR,
  1230. "\nERROR: %s: Invalid WMI Param Buffer for Cmd:%d",
  1231. __func__, cmd_id);
  1232. return QDF_STATUS_E_INVAL;
  1233. }
  1234. }
  1235. #endif
  1236. if (qdf_nbuf_push_head(buf, sizeof(WMI_CMD_HDR)) == NULL) {
  1237. QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_ERROR,
  1238. "%s, Failed to send cmd %x, no memory",
  1239. __func__, cmd_id);
  1240. return QDF_STATUS_E_NOMEM;
  1241. }
  1242. WMI_SET_FIELD(qdf_nbuf_data(buf), WMI_CMD_HDR, COMMANDID, cmd_id);
  1243. qdf_atomic_inc(&wmi_handle->pending_cmds);
  1244. if (qdf_atomic_read(&wmi_handle->pending_cmds) >=
  1245. wmi_handle->wmi_max_cmds) {
  1246. QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_ERROR,
  1247. "\n%s: hostcredits = %d", __func__,
  1248. wmi_get_host_credits(wmi_handle));
  1249. htc_dump_counter_info(wmi_handle->htc_handle);
  1250. qdf_atomic_dec(&wmi_handle->pending_cmds);
  1251. QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_ERROR,
  1252. "%s: MAX %d WMI Pending cmds reached.", __func__,
  1253. wmi_handle->wmi_max_cmds);
  1254. QDF_BUG(0);
  1255. return QDF_STATUS_E_BUSY;
  1256. }
  1257. pkt = qdf_mem_malloc(sizeof(*pkt));
  1258. if (!pkt) {
  1259. qdf_atomic_dec(&wmi_handle->pending_cmds);
  1260. QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_ERROR,
  1261. "%s, Failed to alloc htc packet %x, no memory",
  1262. __func__, cmd_id);
  1263. return QDF_STATUS_E_NOMEM;
  1264. }
  1265. SET_HTC_PACKET_INFO_TX(pkt,
  1266. NULL,
  1267. qdf_nbuf_data(buf), len + sizeof(WMI_CMD_HDR),
  1268. wmi_handle->wmi_endpoint_id, htc_tag);
  1269. SET_HTC_PACKET_NET_BUF_CONTEXT(pkt, buf);
  1270. #ifdef CONFIG_MCL
  1271. wmi_log_cmd_id(cmd_id, htc_tag);
  1272. #endif
  1273. #ifdef WMI_INTERFACE_EVENT_LOGGING
  1274. if (wmi_handle->log_info.wmi_logging_enable) {
  1275. qdf_spin_lock_bh(&wmi_handle->log_info.wmi_record_lock);
  1276. /*
  1277. * Record 16 bytes of WMI cmd data -
  1278. * exclude TLV and WMI headers
  1279. *
  1280. * WMI mgmt command already recorded in wmi_mgmt_cmd_record
  1281. */
  1282. if (wmi_handle->ops->is_management_record(cmd_id) == false) {
  1283. WMI_COMMAND_RECORD(wmi_handle, cmd_id,
  1284. qdf_nbuf_data(buf) +
  1285. wmi_handle->log_info.buf_offset_command);
  1286. }
  1287. qdf_spin_unlock_bh(&wmi_handle->log_info.wmi_record_lock);
  1288. }
  1289. #endif
  1290. status = htc_send_pkt(wmi_handle->htc_handle, pkt);
  1291. if (QDF_STATUS_SUCCESS != status) {
  1292. qdf_atomic_dec(&wmi_handle->pending_cmds);
  1293. QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_ERROR,
  1294. "%s %d, htc_send_pkt failed", __func__, __LINE__);
  1295. qdf_mem_free(pkt);
  1296. return status;
  1297. }
  1298. return QDF_STATUS_SUCCESS;
  1299. }
  1300. qdf_export_symbol(wmi_unified_cmd_send);
  1301. /**
  1302. * wmi_unified_get_event_handler_ix() - gives event handler's index
  1303. * @wmi_handle: handle to wmi
  1304. * @event_id: wmi event id
  1305. *
  1306. * Return: event handler's index
  1307. */
  1308. static int wmi_unified_get_event_handler_ix(wmi_unified_t wmi_handle,
  1309. uint32_t event_id)
  1310. {
  1311. uint32_t idx = 0;
  1312. int32_t invalid_idx = -1;
  1313. struct wmi_soc *soc = wmi_handle->soc;
  1314. for (idx = 0; (idx < soc->max_event_idx &&
  1315. idx < WMI_UNIFIED_MAX_EVENT); ++idx) {
  1316. if (wmi_handle->event_id[idx] == event_id &&
  1317. wmi_handle->event_handler[idx] != NULL) {
  1318. return idx;
  1319. }
  1320. }
  1321. return invalid_idx;
  1322. }
  1323. /**
  1324. * wmi_unified_register_event() - register wmi event handler
  1325. * @wmi_handle: handle to wmi
  1326. * @event_id: wmi event id
  1327. * @handler_func: wmi event handler function
  1328. *
  1329. * Return: 0 on success
  1330. */
  1331. int wmi_unified_register_event(wmi_unified_t wmi_handle,
  1332. uint32_t event_id,
  1333. wmi_unified_event_handler handler_func)
  1334. {
  1335. uint32_t idx = 0;
  1336. uint32_t evt_id;
  1337. struct wmi_soc *soc = wmi_handle->soc;
  1338. if (event_id >= wmi_events_max ||
  1339. wmi_handle->wmi_events[event_id] == WMI_EVENT_ID_INVALID) {
  1340. qdf_print("%s: Event id %d is unavailable\n",
  1341. __func__, event_id);
  1342. return QDF_STATUS_E_FAILURE;
  1343. }
  1344. evt_id = wmi_handle->wmi_events[event_id];
  1345. if (wmi_unified_get_event_handler_ix(wmi_handle, evt_id) != -1) {
  1346. qdf_print("%s : event handler already registered 0x%x\n",
  1347. __func__, evt_id);
  1348. return QDF_STATUS_E_FAILURE;
  1349. }
  1350. if (soc->max_event_idx == WMI_UNIFIED_MAX_EVENT) {
  1351. qdf_print("%s : no more event handlers 0x%x\n",
  1352. __func__, evt_id);
  1353. return QDF_STATUS_E_FAILURE;
  1354. }
  1355. idx = soc->max_event_idx;
  1356. wmi_handle->event_handler[idx] = handler_func;
  1357. wmi_handle->event_id[idx] = evt_id;
  1358. qdf_spin_lock_bh(&soc->ctx_lock);
  1359. wmi_handle->ctx[idx] = WMI_RX_UMAC_CTX;
  1360. qdf_spin_unlock_bh(&soc->ctx_lock);
  1361. soc->max_event_idx++;
  1362. return 0;
  1363. }
  1364. /**
  1365. * wmi_unified_register_event_handler() - register wmi event handler
  1366. * @wmi_handle: handle to wmi
  1367. * @event_id: wmi event id
  1368. * @handler_func: wmi event handler function
  1369. * @rx_ctx: rx execution context for wmi rx events
  1370. *
  1371. * This API is to support legacy requirements. Will be deprecated in future.
  1372. * Return: 0 on success
  1373. */
  1374. int wmi_unified_register_event_handler(wmi_unified_t wmi_handle,
  1375. wmi_conv_event_id event_id,
  1376. wmi_unified_event_handler handler_func,
  1377. uint8_t rx_ctx)
  1378. {
  1379. uint32_t idx = 0;
  1380. uint32_t evt_id;
  1381. struct wmi_soc *soc = wmi_handle->soc;
  1382. if (event_id >= wmi_events_max ||
  1383. wmi_handle->wmi_events[event_id] == WMI_EVENT_ID_INVALID) {
  1384. qdf_print("%s: Event id %d is unavailable\n",
  1385. __func__, event_id);
  1386. return QDF_STATUS_E_FAILURE;
  1387. }
  1388. evt_id = wmi_handle->wmi_events[event_id];
  1389. if (wmi_unified_get_event_handler_ix(wmi_handle, evt_id) != -1) {
  1390. qdf_print("%s : event handler already registered 0x%x\n",
  1391. __func__, evt_id);
  1392. return QDF_STATUS_E_FAILURE;
  1393. }
  1394. if (soc->max_event_idx == WMI_UNIFIED_MAX_EVENT) {
  1395. qdf_print("%s : no more event handlers 0x%x\n",
  1396. __func__, evt_id);
  1397. return QDF_STATUS_E_FAILURE;
  1398. }
  1399. QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
  1400. "Registered event handler for event 0x%8x\n", evt_id);
  1401. idx = soc->max_event_idx;
  1402. wmi_handle->event_handler[idx] = handler_func;
  1403. wmi_handle->event_id[idx] = evt_id;
  1404. qdf_spin_lock_bh(&soc->ctx_lock);
  1405. wmi_handle->ctx[idx] = rx_ctx;
  1406. qdf_spin_unlock_bh(&soc->ctx_lock);
  1407. soc->max_event_idx++;
  1408. return 0;
  1409. }
  1410. qdf_export_symbol(wmi_unified_register_event_handler);
  1411. /**
  1412. * wmi_unified_unregister_event() - unregister wmi event handler
  1413. * @wmi_handle: handle to wmi
  1414. * @event_id: wmi event id
  1415. *
  1416. * Return: 0 on success
  1417. */
  1418. int wmi_unified_unregister_event(wmi_unified_t wmi_handle,
  1419. uint32_t event_id)
  1420. {
  1421. uint32_t idx = 0;
  1422. uint32_t evt_id;
  1423. struct wmi_soc *soc = wmi_handle->soc;
  1424. if (event_id >= wmi_events_max ||
  1425. wmi_handle->wmi_events[event_id] == WMI_EVENT_ID_INVALID) {
  1426. qdf_print("%s: Event id %d is unavailable\n",
  1427. __func__, event_id);
  1428. return QDF_STATUS_E_FAILURE;
  1429. }
  1430. evt_id = wmi_handle->wmi_events[event_id];
  1431. idx = wmi_unified_get_event_handler_ix(wmi_handle, evt_id);
  1432. if (idx == -1) {
  1433. qdf_print("%s : event handler is not registered: evt id 0x%x\n",
  1434. __func__, evt_id);
  1435. return QDF_STATUS_E_FAILURE;
  1436. }
  1437. wmi_handle->event_handler[idx] = NULL;
  1438. wmi_handle->event_id[idx] = 0;
  1439. --soc->max_event_idx;
  1440. wmi_handle->event_handler[idx] =
  1441. wmi_handle->event_handler[soc->max_event_idx];
  1442. wmi_handle->event_id[idx] =
  1443. wmi_handle->event_id[soc->max_event_idx];
  1444. return 0;
  1445. }
  1446. /**
  1447. * wmi_unified_unregister_event_handler() - unregister wmi event handler
  1448. * @wmi_handle: handle to wmi
  1449. * @event_id: wmi event id
  1450. *
  1451. * Return: 0 on success
  1452. */
  1453. int wmi_unified_unregister_event_handler(wmi_unified_t wmi_handle,
  1454. wmi_conv_event_id event_id)
  1455. {
  1456. uint32_t idx = 0;
  1457. uint32_t evt_id;
  1458. struct wmi_soc *soc = wmi_handle->soc;
  1459. if (event_id >= wmi_events_max ||
  1460. wmi_handle->wmi_events[event_id] == WMI_EVENT_ID_INVALID) {
  1461. qdf_print("%s: Event id %d is unavailable\n",
  1462. __func__, event_id);
  1463. return QDF_STATUS_E_FAILURE;
  1464. }
  1465. evt_id = wmi_handle->wmi_events[event_id];
  1466. idx = wmi_unified_get_event_handler_ix(wmi_handle, evt_id);
  1467. if (idx == -1) {
  1468. qdf_print("%s : event handler is not registered: evt id 0x%x\n",
  1469. __func__, evt_id);
  1470. return QDF_STATUS_E_FAILURE;
  1471. }
  1472. wmi_handle->event_handler[idx] = NULL;
  1473. wmi_handle->event_id[idx] = 0;
  1474. --soc->max_event_idx;
  1475. wmi_handle->event_handler[idx] =
  1476. wmi_handle->event_handler[soc->max_event_idx];
  1477. wmi_handle->event_id[idx] =
  1478. wmi_handle->event_id[soc->max_event_idx];
  1479. return 0;
  1480. }
  1481. qdf_export_symbol(wmi_unified_unregister_event_handler);
  1482. /**
  1483. * wmi_process_fw_event_default_ctx() - process in default caller context
  1484. * @wmi_handle: handle to wmi
  1485. * @htc_packet: pointer to htc packet
  1486. * @exec_ctx: execution context for wmi fw event
  1487. *
  1488. * Event process by below function will be in default caller context.
  1489. * wmi internally provides rx work thread processing context.
  1490. *
  1491. * Return: none
  1492. */
  1493. static void wmi_process_fw_event_default_ctx(struct wmi_unified *wmi_handle,
  1494. HTC_PACKET *htc_packet, uint8_t exec_ctx)
  1495. {
  1496. wmi_buf_t evt_buf;
  1497. evt_buf = (wmi_buf_t) htc_packet->pPktContext;
  1498. #ifndef CONFIG_MCL
  1499. wmi_handle->rx_ops.wma_process_fw_event_handler_cbk
  1500. (wmi_handle->scn_handle, evt_buf, exec_ctx);
  1501. #else
  1502. wmi_handle->rx_ops.wma_process_fw_event_handler_cbk(wmi_handle,
  1503. evt_buf, exec_ctx);
  1504. #endif
  1505. return;
  1506. }
  1507. /**
  1508. * wmi_process_fw_event_worker_thread_ctx() - process in worker thread context
  1509. * @wmi_handle: handle to wmi
  1510. * @htc_packet: pointer to htc packet
  1511. *
  1512. * Event process by below function will be in worker thread context.
  1513. * Use this method for events which are not critical and not
  1514. * handled in protocol stack.
  1515. *
  1516. * Return: none
  1517. */
  1518. static void wmi_process_fw_event_worker_thread_ctx
  1519. (struct wmi_unified *wmi_handle, HTC_PACKET *htc_packet)
  1520. {
  1521. wmi_buf_t evt_buf;
  1522. evt_buf = (wmi_buf_t) htc_packet->pPktContext;
  1523. qdf_spin_lock_bh(&wmi_handle->eventq_lock);
  1524. qdf_nbuf_queue_add(&wmi_handle->event_queue, evt_buf);
  1525. qdf_spin_unlock_bh(&wmi_handle->eventq_lock);
  1526. qdf_queue_work(0, wmi_handle->wmi_rx_work_queue,
  1527. &wmi_handle->rx_event_work);
  1528. return;
  1529. }
  1530. /**
  1531. * wmi_get_pdev_ep: Get wmi handle based on endpoint
  1532. * @soc: handle to wmi soc
  1533. * @ep: endpoint id
  1534. *
  1535. * Return: none
  1536. */
  1537. static struct wmi_unified *wmi_get_pdev_ep(struct wmi_soc *soc,
  1538. HTC_ENDPOINT_ID ep)
  1539. {
  1540. uint32_t i;
  1541. for (i = 0; i < WMI_MAX_RADIOS; i++)
  1542. if (soc->wmi_endpoint_id[i] == ep)
  1543. break;
  1544. if (i == WMI_MAX_RADIOS)
  1545. return NULL;
  1546. return soc->wmi_pdev[i];
  1547. }
  1548. /**
  1549. * wmi_control_rx() - process fw events callbacks
  1550. * @ctx: handle to wmi
  1551. * @htc_packet: pointer to htc packet
  1552. *
  1553. * Return: none
  1554. */
  1555. static void wmi_control_rx(void *ctx, HTC_PACKET *htc_packet)
  1556. {
  1557. struct wmi_soc *soc = (struct wmi_soc *) ctx;
  1558. struct wmi_unified *wmi_handle;
  1559. wmi_buf_t evt_buf;
  1560. uint32_t id;
  1561. uint32_t idx = 0;
  1562. enum wmi_rx_exec_ctx exec_ctx;
  1563. evt_buf = (wmi_buf_t) htc_packet->pPktContext;
  1564. wmi_handle = wmi_get_pdev_ep(soc, htc_packet->Endpoint);
  1565. if (wmi_handle == NULL) {
  1566. qdf_print
  1567. ("%s :unable to get wmi_handle to Endpoint %d\n",
  1568. __func__, htc_packet->Endpoint);
  1569. qdf_nbuf_free(evt_buf);
  1570. return;
  1571. }
  1572. id = WMI_GET_FIELD(qdf_nbuf_data(evt_buf), WMI_CMD_HDR, COMMANDID);
  1573. idx = wmi_unified_get_event_handler_ix(wmi_handle, id);
  1574. if (qdf_unlikely(idx == A_ERROR)) {
  1575. WMI_LOGD("%s :event handler is not registered: event id 0x%x\n",
  1576. __func__, id);
  1577. qdf_nbuf_free(evt_buf);
  1578. return;
  1579. }
  1580. qdf_spin_lock_bh(&soc->ctx_lock);
  1581. exec_ctx = wmi_handle->ctx[idx];
  1582. qdf_spin_unlock_bh(&soc->ctx_lock);
  1583. #ifdef WMI_INTERFACE_EVENT_LOGGING
  1584. if (wmi_handle->log_info.wmi_logging_enable) {
  1585. uint8_t *data;
  1586. data = qdf_nbuf_data(evt_buf);
  1587. qdf_spin_lock_bh(&wmi_handle->log_info.wmi_record_lock);
  1588. /* Exclude 4 bytes of TLV header */
  1589. WMI_RX_EVENT_RECORD(wmi_handle, id, data +
  1590. wmi_handle->log_info.buf_offset_event);
  1591. qdf_spin_unlock_bh(&wmi_handle->log_info.wmi_record_lock);
  1592. }
  1593. #endif
  1594. if (exec_ctx == WMI_RX_WORK_CTX) {
  1595. wmi_process_fw_event_worker_thread_ctx
  1596. (wmi_handle, htc_packet);
  1597. } else if (exec_ctx > WMI_RX_WORK_CTX) {
  1598. wmi_process_fw_event_default_ctx
  1599. (wmi_handle, htc_packet, exec_ctx);
  1600. } else {
  1601. qdf_print("%s :Invalid event context %d\n", __func__, exec_ctx);
  1602. qdf_nbuf_free(evt_buf);
  1603. }
  1604. }
  1605. /**
  1606. * wmi_process_fw_event() - process any fw event
  1607. * @wmi_handle: wmi handle
  1608. * @evt_buf: fw event buffer
  1609. *
  1610. * This function process fw event in caller context
  1611. *
  1612. * Return: none
  1613. */
  1614. void wmi_process_fw_event(struct wmi_unified *wmi_handle, wmi_buf_t evt_buf)
  1615. {
  1616. __wmi_control_rx(wmi_handle, evt_buf);
  1617. }
  1618. /**
  1619. * __wmi_control_rx() - process serialize wmi event callback
  1620. * @wmi_handle: wmi handle
  1621. * @evt_buf: fw event buffer
  1622. *
  1623. * Return: none
  1624. */
  1625. void __wmi_control_rx(struct wmi_unified *wmi_handle, wmi_buf_t evt_buf)
  1626. {
  1627. uint32_t id;
  1628. uint8_t *data;
  1629. uint32_t len;
  1630. void *wmi_cmd_struct_ptr = NULL;
  1631. #ifndef WMI_NON_TLV_SUPPORT
  1632. int tlv_ok_status = 0;
  1633. #endif
  1634. uint32_t idx = 0;
  1635. id = WMI_GET_FIELD(qdf_nbuf_data(evt_buf), WMI_CMD_HDR, COMMANDID);
  1636. if (qdf_nbuf_pull_head(evt_buf, sizeof(WMI_CMD_HDR)) == NULL)
  1637. goto end;
  1638. data = qdf_nbuf_data(evt_buf);
  1639. len = qdf_nbuf_len(evt_buf);
  1640. #ifndef WMI_NON_TLV_SUPPORT
  1641. if (wmi_handle->target_type == WMI_TLV_TARGET) {
  1642. /* Validate and pad(if necessary) the TLVs */
  1643. tlv_ok_status =
  1644. wmi_handle->ops->wmi_check_and_pad_event(wmi_handle->scn_handle,
  1645. data, len, id,
  1646. &wmi_cmd_struct_ptr);
  1647. if (tlv_ok_status != 0) {
  1648. QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_ERROR,
  1649. "%s: Error: id=0x%d, wmitlv check status=%d\n",
  1650. __func__, id, tlv_ok_status);
  1651. goto end;
  1652. }
  1653. }
  1654. #endif
  1655. idx = wmi_unified_get_event_handler_ix(wmi_handle, id);
  1656. if (idx == A_ERROR) {
  1657. QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_ERROR,
  1658. "%s : event handler is not registered: event id 0x%x\n",
  1659. __func__, id);
  1660. goto end;
  1661. }
  1662. #ifdef WMI_INTERFACE_EVENT_LOGGING
  1663. if (wmi_handle->log_info.wmi_logging_enable) {
  1664. qdf_spin_lock_bh(&wmi_handle->log_info.wmi_record_lock);
  1665. /* Exclude 4 bytes of TLV header */
  1666. if (wmi_handle->ops->is_management_record(id)) {
  1667. WMI_MGMT_EVENT_RECORD(wmi_handle, id, data
  1668. + wmi_handle->log_info.buf_offset_event);
  1669. } else {
  1670. WMI_EVENT_RECORD(wmi_handle, id, data +
  1671. wmi_handle->log_info.buf_offset_event);
  1672. }
  1673. qdf_spin_unlock_bh(&wmi_handle->log_info.wmi_record_lock);
  1674. }
  1675. #endif
  1676. /* Call the WMI registered event handler */
  1677. if (wmi_handle->target_type == WMI_TLV_TARGET)
  1678. wmi_handle->event_handler[idx] (wmi_handle->scn_handle,
  1679. wmi_cmd_struct_ptr, len);
  1680. else
  1681. wmi_handle->event_handler[idx] (wmi_handle->scn_handle,
  1682. data, len);
  1683. end:
  1684. /* Free event buffer and allocated event tlv */
  1685. #ifndef WMI_NON_TLV_SUPPORT
  1686. if (wmi_handle->target_type == WMI_TLV_TARGET)
  1687. wmi_handle->ops->wmi_free_allocated_event(id, &wmi_cmd_struct_ptr);
  1688. #endif
  1689. qdf_nbuf_free(evt_buf);
  1690. }
  1691. #define WMI_WQ_WD_TIMEOUT (30 * 1000) /* 30s */
  1692. static inline void wmi_workqueue_watchdog_warn(uint32_t msg_type_id)
  1693. {
  1694. QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
  1695. "%s: WLAN_BUG_RCA: Message type %x has exceeded its alloted time of %ds",
  1696. __func__, msg_type_id, WMI_WQ_WD_TIMEOUT / 1000);
  1697. }
  1698. #ifdef CONFIG_SLUB_DEBUG_ON
  1699. static void wmi_workqueue_watchdog_bite(void *arg)
  1700. {
  1701. struct wmi_wq_dbg_info *info = arg;
  1702. wmi_workqueue_watchdog_warn(info->wd_msg_type_id);
  1703. qdf_print_thread_trace(info->task);
  1704. QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
  1705. "%s: Going down for WMI WQ Watchdog Bite!", __func__);
  1706. QDF_BUG(0);
  1707. }
  1708. #else
  1709. static inline void wmi_workqueue_watchdog_bite(void *arg)
  1710. {
  1711. struct wmi_wq_dbg_info *info = arg;
  1712. wmi_workqueue_watchdog_warn(info->wd_msg_type_id);
  1713. }
  1714. #endif
  1715. /**
  1716. * wmi_rx_event_work() - process rx event in rx work queue context
  1717. * @arg: opaque pointer to wmi handle
  1718. *
  1719. * This function process any fw event to serialize it through rx worker thread.
  1720. *
  1721. * Return: none
  1722. */
  1723. static void wmi_rx_event_work(void *arg)
  1724. {
  1725. wmi_buf_t buf;
  1726. struct wmi_unified *wmi = arg;
  1727. qdf_timer_t wd_timer;
  1728. struct wmi_wq_dbg_info info;
  1729. /* initialize WMI workqueue watchdog timer */
  1730. qdf_timer_init(NULL, &wd_timer, &wmi_workqueue_watchdog_bite,
  1731. &info, QDF_TIMER_TYPE_SW);
  1732. qdf_spin_lock_bh(&wmi->eventq_lock);
  1733. buf = qdf_nbuf_queue_remove(&wmi->event_queue);
  1734. qdf_spin_unlock_bh(&wmi->eventq_lock);
  1735. while (buf) {
  1736. qdf_timer_start(&wd_timer, WMI_WQ_WD_TIMEOUT);
  1737. info.wd_msg_type_id =
  1738. WMI_GET_FIELD(qdf_nbuf_data(buf), WMI_CMD_HDR, COMMANDID);
  1739. info.wmi_wq = wmi->wmi_rx_work_queue;
  1740. info.task = qdf_get_current_task();
  1741. __wmi_control_rx(wmi, buf);
  1742. qdf_timer_stop(&wd_timer);
  1743. qdf_spin_lock_bh(&wmi->eventq_lock);
  1744. buf = qdf_nbuf_queue_remove(&wmi->event_queue);
  1745. qdf_spin_unlock_bh(&wmi->eventq_lock);
  1746. }
  1747. qdf_timer_free(&wd_timer);
  1748. }
  1749. #ifdef FEATURE_RUNTIME_PM
  1750. /**
  1751. * wmi_runtime_pm_init() - initialize runtime pm wmi variables
  1752. * @wmi_handle: wmi context
  1753. */
  1754. static void wmi_runtime_pm_init(struct wmi_unified *wmi_handle)
  1755. {
  1756. qdf_atomic_init(&wmi_handle->runtime_pm_inprogress);
  1757. }
  1758. /**
  1759. * wmi_set_runtime_pm_inprogress() - set runtime pm progress flag
  1760. * @wmi_handle: wmi context
  1761. * @val: runtime pm progress flag
  1762. */
  1763. void wmi_set_runtime_pm_inprogress(wmi_unified_t wmi_handle, A_BOOL val)
  1764. {
  1765. qdf_atomic_set(&wmi_handle->runtime_pm_inprogress, val);
  1766. }
  1767. /**
  1768. * wmi_get_runtime_pm_inprogress() - get runtime pm progress flag
  1769. * @wmi_handle: wmi context
  1770. */
  1771. inline bool wmi_get_runtime_pm_inprogress(wmi_unified_t wmi_handle)
  1772. {
  1773. return qdf_atomic_read(&wmi_handle->runtime_pm_inprogress);
  1774. }
  1775. #else
  1776. static void wmi_runtime_pm_init(struct wmi_unified *wmi_handle)
  1777. {
  1778. }
  1779. #endif
  1780. /**
  1781. * wmi_unified_get_soc_handle: Get WMI SoC handle
  1782. * @param wmi_handle: WMI context got from wmi_attach
  1783. *
  1784. * return: Pointer to Soc handle
  1785. */
  1786. void *wmi_unified_get_soc_handle(struct wmi_unified *wmi_handle)
  1787. {
  1788. return wmi_handle->soc;
  1789. }
  1790. /**
  1791. * wmi_interface_logging_init: Interface looging init
  1792. * @param wmi_handle: Pointer to wmi handle object
  1793. *
  1794. * return: None
  1795. */
  1796. #ifdef WMI_INTERFACE_EVENT_LOGGING
  1797. static inline void wmi_interface_logging_init(struct wmi_unified *wmi_handle)
  1798. {
  1799. if (QDF_STATUS_SUCCESS == wmi_log_init(wmi_handle)) {
  1800. qdf_spinlock_create(&wmi_handle->log_info.wmi_record_lock);
  1801. wmi_debugfs_init(wmi_handle);
  1802. }
  1803. }
  1804. #else
  1805. static inline void wmi_interface_logging_init(struct wmi_unified *wmi_handle)
  1806. {
  1807. }
  1808. #endif
  1809. /**
  1810. * wmi_target_params_init: Target specific params init
  1811. * @param wmi_soc: Pointer to wmi soc object
  1812. * @param wmi_handle: Pointer to wmi handle object
  1813. *
  1814. * return: None
  1815. */
  1816. #ifndef CONFIG_MCL
  1817. static inline void wmi_target_params_init(struct wmi_soc *soc,
  1818. struct wmi_unified *wmi_handle)
  1819. {
  1820. wmi_handle->pdev_param = soc->pdev_param;
  1821. wmi_handle->vdev_param = soc->vdev_param;
  1822. wmi_handle->services = soc->services;
  1823. }
  1824. #else
  1825. static inline void wmi_target_params_init(struct wmi_soc *soc,
  1826. struct wmi_unified *wmi_handle)
  1827. {
  1828. wmi_handle->services = soc->services;
  1829. }
  1830. #endif
  1831. /**
  1832. * wmi_unified_get_pdev_handle: Get WMI SoC handle
  1833. * @param wmi_soc: Pointer to wmi soc object
  1834. * @param pdev_idx: pdev index
  1835. *
  1836. * return: Pointer to wmi handle or NULL on failure
  1837. */
  1838. void *wmi_unified_get_pdev_handle(struct wmi_soc *soc, uint32_t pdev_idx)
  1839. {
  1840. struct wmi_unified *wmi_handle;
  1841. if (pdev_idx >= WMI_MAX_RADIOS)
  1842. return NULL;
  1843. if (soc->wmi_pdev[pdev_idx] == NULL) {
  1844. wmi_handle =
  1845. (struct wmi_unified *) qdf_mem_malloc(
  1846. sizeof(struct wmi_unified));
  1847. if (wmi_handle == NULL) {
  1848. qdf_print("allocation of wmi handle failed %zu\n",
  1849. sizeof(struct wmi_unified));
  1850. return NULL;
  1851. }
  1852. wmi_handle->scn_handle = soc->scn_handle;
  1853. wmi_handle->event_id = soc->event_id;
  1854. wmi_handle->event_handler = soc->event_handler;
  1855. wmi_handle->ctx = soc->ctx;
  1856. wmi_handle->ops = soc->ops;
  1857. qdf_spinlock_create(&wmi_handle->eventq_lock);
  1858. qdf_nbuf_queue_init(&wmi_handle->event_queue);
  1859. qdf_create_work(0, &wmi_handle->rx_event_work,
  1860. wmi_rx_event_work, wmi_handle);
  1861. wmi_handle->wmi_rx_work_queue =
  1862. qdf_create_workqueue("wmi_rx_event_work_queue");
  1863. if (NULL == wmi_handle->wmi_rx_work_queue) {
  1864. WMI_LOGE("failed to create wmi_rx_event_work_queue");
  1865. goto error;
  1866. }
  1867. wmi_handle->wmi_events = soc->wmi_events;
  1868. wmi_target_params_init(soc, wmi_handle);
  1869. wmi_interface_logging_init(wmi_handle);
  1870. qdf_atomic_init(&wmi_handle->pending_cmds);
  1871. qdf_atomic_init(&wmi_handle->is_target_suspended);
  1872. wmi_handle->target_type = soc->target_type;
  1873. wmi_handle->wmi_max_cmds = soc->wmi_max_cmds;
  1874. wmi_handle->soc = soc;
  1875. soc->wmi_pdev[pdev_idx] = wmi_handle;
  1876. } else
  1877. wmi_handle = soc->wmi_pdev[pdev_idx];
  1878. wmi_handle->wmi_stopinprogress = 0;
  1879. wmi_handle->wmi_endpoint_id = soc->wmi_endpoint_id[pdev_idx];
  1880. wmi_handle->htc_handle = soc->htc_handle;
  1881. wmi_handle->max_msg_len = soc->max_msg_len[pdev_idx];
  1882. return wmi_handle;
  1883. error:
  1884. qdf_mem_free(wmi_handle);
  1885. return NULL;
  1886. }
  1887. qdf_export_symbol(wmi_unified_get_pdev_handle);
  1888. static void (*wmi_attach_register[WMI_MAX_TARGET_TYPE])(wmi_unified_t);
  1889. void wmi_unified_register_module(enum wmi_target_type target_type,
  1890. void (*wmi_attach)(wmi_unified_t wmi_handle))
  1891. {
  1892. if (target_type < WMI_MAX_TARGET_TYPE)
  1893. wmi_attach_register[target_type] = wmi_attach;
  1894. return;
  1895. }
  1896. qdf_export_symbol(wmi_unified_register_module);
  1897. /**
  1898. * wmi_unified_attach() - attach for unified WMI
  1899. * @scn_handle: handle to SCN
  1900. * @osdev: OS device context
  1901. * @target_type: TLV or not-TLV based target
  1902. * @use_cookie: cookie based allocation enabled/disabled
  1903. * @ops: umac rx callbacks
  1904. * @psoc: objmgr psoc
  1905. *
  1906. * @Return: wmi handle.
  1907. */
  1908. void *wmi_unified_attach(void *scn_handle,
  1909. struct wmi_unified_attach_params *param)
  1910. {
  1911. struct wmi_unified *wmi_handle;
  1912. struct wmi_soc *soc;
  1913. soc = (struct wmi_soc *) qdf_mem_malloc(sizeof(struct wmi_soc));
  1914. if (soc == NULL) {
  1915. qdf_print("Allocation of wmi_soc failed %zu\n",
  1916. sizeof(struct wmi_soc));
  1917. return NULL;
  1918. }
  1919. wmi_handle =
  1920. (struct wmi_unified *) qdf_mem_malloc(
  1921. sizeof(struct wmi_unified));
  1922. if (wmi_handle == NULL) {
  1923. qdf_mem_free(soc);
  1924. qdf_print("allocation of wmi handle failed %zu\n",
  1925. sizeof(struct wmi_unified));
  1926. return NULL;
  1927. }
  1928. wmi_handle->soc = soc;
  1929. wmi_handle->event_id = soc->event_id;
  1930. wmi_handle->event_handler = soc->event_handler;
  1931. wmi_handle->ctx = soc->ctx;
  1932. wmi_handle->wmi_events = soc->wmi_events;
  1933. wmi_target_params_init(soc, wmi_handle);
  1934. wmi_handle->scn_handle = scn_handle;
  1935. soc->scn_handle = scn_handle;
  1936. qdf_atomic_init(&wmi_handle->pending_cmds);
  1937. qdf_atomic_init(&wmi_handle->is_target_suspended);
  1938. wmi_runtime_pm_init(wmi_handle);
  1939. qdf_spinlock_create(&wmi_handle->eventq_lock);
  1940. qdf_nbuf_queue_init(&wmi_handle->event_queue);
  1941. qdf_create_work(0, &wmi_handle->rx_event_work,
  1942. wmi_rx_event_work, wmi_handle);
  1943. wmi_handle->wmi_rx_work_queue =
  1944. qdf_create_workqueue("wmi_rx_event_work_queue");
  1945. if (NULL == wmi_handle->wmi_rx_work_queue) {
  1946. WMI_LOGE("failed to create wmi_rx_event_work_queue");
  1947. goto error;
  1948. }
  1949. wmi_interface_logging_init(wmi_handle);
  1950. /* Attach mc_thread context processing function */
  1951. wmi_handle->rx_ops.wma_process_fw_event_handler_cbk =
  1952. param->rx_ops->wma_process_fw_event_handler_cbk;
  1953. wmi_handle->target_type = param->target_type;
  1954. soc->target_type = param->target_type;
  1955. if (wmi_attach_register[param->target_type]) {
  1956. wmi_attach_register[param->target_type](wmi_handle);
  1957. } else {
  1958. WMI_LOGE("wmi attach is not registered");
  1959. goto error;
  1960. }
  1961. /* Assign target cookie capablity */
  1962. wmi_handle->use_cookie = param->use_cookie;
  1963. wmi_handle->osdev = param->osdev;
  1964. wmi_handle->wmi_stopinprogress = 0;
  1965. wmi_handle->wmi_max_cmds = param->max_commands;
  1966. soc->wmi_max_cmds = param->max_commands;
  1967. /* Increase the ref count once refcount infra is present */
  1968. soc->wmi_psoc = param->psoc;
  1969. qdf_spinlock_create(&soc->ctx_lock);
  1970. soc->ops = wmi_handle->ops;
  1971. soc->wmi_pdev[0] = wmi_handle;
  1972. return wmi_handle;
  1973. error:
  1974. qdf_mem_free(soc);
  1975. qdf_mem_free(wmi_handle);
  1976. return NULL;
  1977. }
  1978. /**
  1979. * wmi_unified_detach() - detach for unified WMI
  1980. *
  1981. * @wmi_handle : handle to wmi.
  1982. *
  1983. * @Return: none.
  1984. */
  1985. void wmi_unified_detach(struct wmi_unified *wmi_handle)
  1986. {
  1987. wmi_buf_t buf;
  1988. struct wmi_soc *soc;
  1989. uint8_t i;
  1990. soc = wmi_handle->soc;
  1991. for (i = 0; i < WMI_MAX_RADIOS; i++) {
  1992. if (soc->wmi_pdev[i]) {
  1993. qdf_flush_workqueue(0,
  1994. soc->wmi_pdev[i]->wmi_rx_work_queue);
  1995. qdf_destroy_workqueue(0,
  1996. soc->wmi_pdev[i]->wmi_rx_work_queue);
  1997. wmi_debugfs_remove(soc->wmi_pdev[i]);
  1998. buf = qdf_nbuf_queue_remove(
  1999. &soc->wmi_pdev[i]->event_queue);
  2000. while (buf) {
  2001. qdf_nbuf_free(buf);
  2002. buf = qdf_nbuf_queue_remove(
  2003. &soc->wmi_pdev[i]->event_queue);
  2004. }
  2005. wmi_log_buffer_free(soc->wmi_pdev[i]);
  2006. /* Free events logs list */
  2007. if (soc->wmi_pdev[i]->events_logs_list)
  2008. qdf_mem_free(
  2009. soc->wmi_pdev[i]->events_logs_list);
  2010. qdf_spinlock_destroy(&soc->wmi_pdev[i]->eventq_lock);
  2011. qdf_mem_free(soc->wmi_pdev[i]);
  2012. }
  2013. }
  2014. qdf_spinlock_destroy(&soc->ctx_lock);
  2015. if (soc->wmi_service_bitmap) {
  2016. qdf_mem_free(soc->wmi_service_bitmap);
  2017. soc->wmi_service_bitmap = NULL;
  2018. }
  2019. if (soc->wmi_ext_service_bitmap) {
  2020. qdf_mem_free(soc->wmi_ext_service_bitmap);
  2021. soc->wmi_ext_service_bitmap = NULL;
  2022. }
  2023. /* Decrease the ref count once refcount infra is present */
  2024. soc->wmi_psoc = NULL;
  2025. qdf_mem_free(soc);
  2026. }
  2027. /**
  2028. * wmi_unified_remove_work() - detach for WMI work
  2029. * @wmi_handle: handle to WMI
  2030. *
  2031. * A function that does not fully detach WMI, but just remove work
  2032. * queue items associated with it. This is used to make sure that
  2033. * before any other processing code that may destroy related contexts
  2034. * (HTC, etc), work queue processing on WMI has already been stopped.
  2035. *
  2036. * Return: None
  2037. */
  2038. void
  2039. wmi_unified_remove_work(struct wmi_unified *wmi_handle)
  2040. {
  2041. wmi_buf_t buf;
  2042. qdf_flush_workqueue(0, wmi_handle->wmi_rx_work_queue);
  2043. qdf_spin_lock_bh(&wmi_handle->eventq_lock);
  2044. buf = qdf_nbuf_queue_remove(&wmi_handle->event_queue);
  2045. while (buf) {
  2046. qdf_nbuf_free(buf);
  2047. buf = qdf_nbuf_queue_remove(&wmi_handle->event_queue);
  2048. }
  2049. qdf_spin_unlock_bh(&wmi_handle->eventq_lock);
  2050. }
  2051. /**
  2052. * wmi_htc_tx_complete() - Process htc tx completion
  2053. *
  2054. * @ctx: handle to wmi
  2055. * @htc_packet: pointer to htc packet
  2056. *
  2057. * @Return: none.
  2058. */
  2059. static void wmi_htc_tx_complete(void *ctx, HTC_PACKET *htc_pkt)
  2060. {
  2061. struct wmi_soc *soc = (struct wmi_soc *) ctx;
  2062. wmi_buf_t wmi_cmd_buf = GET_HTC_PACKET_NET_BUF_CONTEXT(htc_pkt);
  2063. u_int8_t *buf_ptr;
  2064. u_int32_t len;
  2065. struct wmi_unified *wmi_handle;
  2066. #ifdef WMI_INTERFACE_EVENT_LOGGING
  2067. uint32_t cmd_id;
  2068. #endif
  2069. ASSERT(wmi_cmd_buf);
  2070. wmi_handle = wmi_get_pdev_ep(soc, htc_pkt->Endpoint);
  2071. if (wmi_handle == NULL) {
  2072. WMI_LOGE("%s: Unable to get wmi handle\n", __func__);
  2073. QDF_ASSERT(0);
  2074. return;
  2075. }
  2076. #ifdef WMI_INTERFACE_EVENT_LOGGING
  2077. if (wmi_handle && wmi_handle->log_info.wmi_logging_enable) {
  2078. cmd_id = WMI_GET_FIELD(qdf_nbuf_data(wmi_cmd_buf),
  2079. WMI_CMD_HDR, COMMANDID);
  2080. qdf_spin_lock_bh(&wmi_handle->log_info.wmi_record_lock);
  2081. /* Record 16 bytes of WMI cmd tx complete data
  2082. - exclude TLV and WMI headers */
  2083. if (wmi_handle->ops->is_management_record(cmd_id)) {
  2084. WMI_MGMT_COMMAND_TX_CMP_RECORD(wmi_handle, cmd_id,
  2085. qdf_nbuf_data(wmi_cmd_buf) +
  2086. wmi_handle->log_info.buf_offset_command);
  2087. } else {
  2088. WMI_COMMAND_TX_CMP_RECORD(wmi_handle, cmd_id,
  2089. qdf_nbuf_data(wmi_cmd_buf) +
  2090. wmi_handle->log_info.buf_offset_command);
  2091. }
  2092. qdf_spin_unlock_bh(&wmi_handle->log_info.wmi_record_lock);
  2093. }
  2094. #endif
  2095. buf_ptr = (u_int8_t *) wmi_buf_data(wmi_cmd_buf);
  2096. len = qdf_nbuf_len(wmi_cmd_buf);
  2097. qdf_mem_zero(buf_ptr, len);
  2098. qdf_nbuf_free(wmi_cmd_buf);
  2099. qdf_mem_free(htc_pkt);
  2100. qdf_atomic_dec(&wmi_handle->pending_cmds);
  2101. }
  2102. /**
  2103. * wmi_connect_pdev_htc_service() - WMI API to get connect to HTC service
  2104. *
  2105. * @wmi_handle: handle to WMI.
  2106. * @pdev_idx: Pdev index
  2107. *
  2108. * @Return: status.
  2109. */
  2110. static int wmi_connect_pdev_htc_service(struct wmi_soc *soc,
  2111. uint32_t pdev_idx)
  2112. {
  2113. int status;
  2114. struct htc_service_connect_resp response;
  2115. struct htc_service_connect_req connect;
  2116. OS_MEMZERO(&connect, sizeof(connect));
  2117. OS_MEMZERO(&response, sizeof(response));
  2118. /* meta data is unused for now */
  2119. connect.pMetaData = NULL;
  2120. connect.MetaDataLength = 0;
  2121. /* these fields are the same for all service endpoints */
  2122. connect.EpCallbacks.pContext = soc;
  2123. connect.EpCallbacks.EpTxCompleteMultiple =
  2124. NULL /* Control path completion ar6000_tx_complete */;
  2125. connect.EpCallbacks.EpRecv = wmi_control_rx /* Control path rx */;
  2126. connect.EpCallbacks.EpRecvRefill = NULL /* ar6000_rx_refill */;
  2127. connect.EpCallbacks.EpSendFull = NULL /* ar6000_tx_queue_full */;
  2128. connect.EpCallbacks.EpTxComplete =
  2129. wmi_htc_tx_complete /* ar6000_tx_queue_full */;
  2130. /* connect to control service */
  2131. connect.service_id = soc->svc_ids[pdev_idx];
  2132. status = htc_connect_service(soc->htc_handle, &connect,
  2133. &response);
  2134. if (status != EOK) {
  2135. qdf_print
  2136. ("Failed to connect to WMI CONTROL service status:%d\n",
  2137. status);
  2138. return status;
  2139. }
  2140. soc->wmi_endpoint_id[pdev_idx] = response.Endpoint;
  2141. soc->max_msg_len[pdev_idx] = response.MaxMsgLength;
  2142. return 0;
  2143. }
  2144. /**
  2145. * wmi_unified_connect_htc_service() - WMI API to get connect to HTC service
  2146. *
  2147. * @wmi_handle: handle to WMI.
  2148. *
  2149. * @Return: status.
  2150. */
  2151. QDF_STATUS
  2152. wmi_unified_connect_htc_service(struct wmi_unified *wmi_handle,
  2153. void *htc_handle)
  2154. {
  2155. uint32_t i;
  2156. uint8_t wmi_ep_count;
  2157. wmi_handle->soc->htc_handle = htc_handle;
  2158. wmi_ep_count = htc_get_wmi_endpoint_count(htc_handle);
  2159. if (wmi_ep_count > WMI_MAX_RADIOS)
  2160. return QDF_STATUS_E_FAULT;
  2161. for (i = 0; i < wmi_ep_count; i++)
  2162. wmi_connect_pdev_htc_service(wmi_handle->soc, i);
  2163. wmi_handle->htc_handle = htc_handle;
  2164. wmi_handle->wmi_endpoint_id = wmi_handle->soc->wmi_endpoint_id[0];
  2165. wmi_handle->max_msg_len = wmi_handle->soc->max_msg_len[0];
  2166. return QDF_STATUS_SUCCESS;
  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 wmi_get_host_credits(wmi_unified_t wmi_handle)
  2176. {
  2177. int host_credits = 0;
  2178. htc_get_control_endpoint_tx_host_credits(wmi_handle->htc_handle,
  2179. &host_credits);
  2180. return host_credits;
  2181. }
  2182. /**
  2183. * wmi_get_pending_cmds() - WMI API to get WMI Pending Commands in the HTC
  2184. * queue
  2185. *
  2186. * @wmi_handle: handle to WMI.
  2187. *
  2188. * @Return: Pending Commands in the HTC queue.
  2189. */
  2190. int wmi_get_pending_cmds(wmi_unified_t wmi_handle)
  2191. {
  2192. return qdf_atomic_read(&wmi_handle->pending_cmds);
  2193. }
  2194. /**
  2195. * wmi_set_target_suspend() - WMI API to set target suspend state
  2196. *
  2197. * @wmi_handle: handle to WMI.
  2198. * @val: suspend state boolean.
  2199. *
  2200. * @Return: none.
  2201. */
  2202. void wmi_set_target_suspend(wmi_unified_t wmi_handle, A_BOOL val)
  2203. {
  2204. qdf_atomic_set(&wmi_handle->is_target_suspended, val);
  2205. }
  2206. /**
  2207. * WMI API to set crash injection state
  2208. * @param wmi_handle: handle to WMI.
  2209. * @param val: crash injection state boolean.
  2210. */
  2211. void wmi_tag_crash_inject(wmi_unified_t wmi_handle, A_BOOL flag)
  2212. {
  2213. wmi_handle->tag_crash_inject = flag;
  2214. }
  2215. /**
  2216. * WMI API to set bus suspend state
  2217. * @param wmi_handle: handle to WMI.
  2218. * @param val: suspend state boolean.
  2219. */
  2220. void wmi_set_is_wow_bus_suspended(wmi_unified_t wmi_handle, A_BOOL val)
  2221. {
  2222. qdf_atomic_set(&wmi_handle->is_wow_bus_suspended, val);
  2223. }
  2224. void wmi_set_tgt_assert(wmi_unified_t wmi_handle, bool val)
  2225. {
  2226. wmi_handle->tgt_force_assert_enable = val;
  2227. }
  2228. #ifndef CONFIG_MCL
  2229. /**
  2230. * API to flush all the previous packets associated with the wmi endpoint
  2231. *
  2232. * @param wmi_handle : handle to WMI.
  2233. */
  2234. void
  2235. wmi_flush_endpoint(wmi_unified_t wmi_handle)
  2236. {
  2237. htc_flush_endpoint(wmi_handle->htc_handle,
  2238. wmi_handle->wmi_endpoint_id, 0);
  2239. }
  2240. qdf_export_symbol(wmi_flush_endpoint);
  2241. /**
  2242. * generic function to block unified WMI command
  2243. * @param wmi_handle : handle to WMI.
  2244. * @return 0 on success and -ve on failure.
  2245. */
  2246. int
  2247. wmi_stop(wmi_unified_t wmi_handle)
  2248. {
  2249. QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
  2250. "WMI Stop\n");
  2251. wmi_handle->wmi_stopinprogress = 1;
  2252. return 0;
  2253. }
  2254. /**
  2255. * wmi_pdev_id_conversion_enable() - API to enable pdev_id conversion in WMI
  2256. * By default pdev_id conversion is not done in WMI.
  2257. * This API can be used enable conversion in WMI.
  2258. * @param wmi_handle : handle to WMI
  2259. * Return none
  2260. */
  2261. void wmi_pdev_id_conversion_enable(wmi_unified_t wmi_handle)
  2262. {
  2263. if (wmi_handle->target_type == WMI_TLV_TARGET)
  2264. wmi_handle->ops->wmi_pdev_id_conversion_enable(wmi_handle);
  2265. }
  2266. #endif