wmi_unified.c 73 KB

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