hif.h 81 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952
  1. /*
  2. * Copyright (c) 2013-2021 The Linux Foundation. All rights reserved.
  3. * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved.
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for
  6. * any purpose with or without fee is hereby granted, provided that the
  7. * above copyright notice and this permission notice appear in all
  8. * copies.
  9. *
  10. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  11. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  12. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  13. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  14. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  15. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  16. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  17. * PERFORMANCE OF THIS SOFTWARE.
  18. */
  19. #ifndef _HIF_H_
  20. #define _HIF_H_
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif /* __cplusplus */
  24. /* Header files */
  25. #include <qdf_status.h>
  26. #include "qdf_ipa.h"
  27. #include "qdf_nbuf.h"
  28. #include "qdf_lro.h"
  29. #include "ol_if_athvar.h"
  30. #include <linux/platform_device.h>
  31. #ifdef HIF_PCI
  32. #include <linux/pci.h>
  33. #endif /* HIF_PCI */
  34. #ifdef HIF_USB
  35. #include <linux/usb.h>
  36. #endif /* HIF_USB */
  37. #ifdef IPA_OFFLOAD
  38. #include <linux/ipa.h>
  39. #endif
  40. #include "cfg_ucfg_api.h"
  41. #include "qdf_dev.h"
  42. #include <wlan_init_cfg.h>
  43. #define ENABLE_MBOX_DUMMY_SPACE_FEATURE 1
  44. typedef void __iomem *A_target_id_t;
  45. typedef void *hif_handle_t;
  46. #if defined(HIF_IPCI) && defined(FEATURE_HAL_DELAYED_REG_WRITE)
  47. #define HIF_WORK_DRAIN_WAIT_CNT 50
  48. #define HIF_EP_WAKE_RESET_WAIT_CNT 10
  49. #endif
  50. #define HIF_TYPE_AR6002 2
  51. #define HIF_TYPE_AR6003 3
  52. #define HIF_TYPE_AR6004 5
  53. #define HIF_TYPE_AR9888 6
  54. #define HIF_TYPE_AR6320 7
  55. #define HIF_TYPE_AR6320V2 8
  56. /* For attaching Peregrine 2.0 board host_reg_tbl only */
  57. #define HIF_TYPE_AR9888V2 9
  58. #define HIF_TYPE_ADRASTEA 10
  59. #define HIF_TYPE_AR900B 11
  60. #define HIF_TYPE_QCA9984 12
  61. #define HIF_TYPE_QCA9888 14
  62. #define HIF_TYPE_QCA8074 15
  63. #define HIF_TYPE_QCA6290 16
  64. #define HIF_TYPE_QCN7605 17
  65. #define HIF_TYPE_QCA6390 18
  66. #define HIF_TYPE_QCA8074V2 19
  67. #define HIF_TYPE_QCA6018 20
  68. #define HIF_TYPE_QCN9000 21
  69. #define HIF_TYPE_QCA6490 22
  70. #define HIF_TYPE_QCA6750 23
  71. #define HIF_TYPE_QCA5018 24
  72. #define HIF_TYPE_QCN6122 25
  73. #define HIF_TYPE_KIWI 26
  74. #define HIF_TYPE_QCN9224 27
  75. #define HIF_TYPE_QCA9574 28
  76. #define HIF_TYPE_MANGO 29
  77. #define HIF_TYPE_QCA5332 30
  78. #define HIF_TYPE_QCN9160 31
  79. #define HIF_TYPE_PEACH 32
  80. #define HIF_TYPE_WCN6450 33
  81. #define HIF_TYPE_QCN6432 34
  82. #define DMA_COHERENT_MASK_DEFAULT 37
  83. #ifdef IPA_OFFLOAD
  84. #define DMA_COHERENT_MASK_BELOW_IPA_VER_3 32
  85. #endif
  86. /* enum hif_ic_irq - enum defining integrated chip irq numbers
  87. * defining irq nubers that can be used by external modules like datapath
  88. */
  89. enum hif_ic_irq {
  90. host2wbm_desc_feed = 16,
  91. host2reo_re_injection,
  92. host2reo_command,
  93. host2rxdma_monitor_ring3,
  94. host2rxdma_monitor_ring2,
  95. host2rxdma_monitor_ring1,
  96. reo2host_exception,
  97. wbm2host_rx_release,
  98. reo2host_status,
  99. reo2host_destination_ring4,
  100. reo2host_destination_ring3,
  101. reo2host_destination_ring2,
  102. reo2host_destination_ring1,
  103. rxdma2host_monitor_destination_mac3,
  104. rxdma2host_monitor_destination_mac2,
  105. rxdma2host_monitor_destination_mac1,
  106. ppdu_end_interrupts_mac3,
  107. ppdu_end_interrupts_mac2,
  108. ppdu_end_interrupts_mac1,
  109. rxdma2host_monitor_status_ring_mac3,
  110. rxdma2host_monitor_status_ring_mac2,
  111. rxdma2host_monitor_status_ring_mac1,
  112. host2rxdma_host_buf_ring_mac3,
  113. host2rxdma_host_buf_ring_mac2,
  114. host2rxdma_host_buf_ring_mac1,
  115. rxdma2host_destination_ring_mac3,
  116. rxdma2host_destination_ring_mac2,
  117. rxdma2host_destination_ring_mac1,
  118. host2tcl_input_ring4,
  119. host2tcl_input_ring3,
  120. host2tcl_input_ring2,
  121. host2tcl_input_ring1,
  122. wbm2host_tx_completions_ring4,
  123. wbm2host_tx_completions_ring3,
  124. wbm2host_tx_completions_ring2,
  125. wbm2host_tx_completions_ring1,
  126. tcl2host_status_ring,
  127. txmon2host_monitor_destination_mac3,
  128. txmon2host_monitor_destination_mac2,
  129. txmon2host_monitor_destination_mac1,
  130. host2tx_monitor_ring1,
  131. };
  132. #ifdef QCA_SUPPORT_LEGACY_INTERRUPTS
  133. enum hif_legacy_pci_irq {
  134. ce0,
  135. ce1,
  136. ce2,
  137. ce3,
  138. ce4,
  139. ce5,
  140. ce6,
  141. ce7,
  142. ce8,
  143. ce9,
  144. ce10,
  145. ce11,
  146. ce12,
  147. ce13,
  148. ce14,
  149. ce15,
  150. reo2sw8_intr2,
  151. reo2sw7_intr2,
  152. reo2sw6_intr2,
  153. reo2sw5_intr2,
  154. reo2sw4_intr2,
  155. reo2sw3_intr2,
  156. reo2sw2_intr2,
  157. reo2sw1_intr2,
  158. reo2sw0_intr2,
  159. reo2sw8_intr,
  160. reo2sw7_intr,
  161. reo2sw6_inrr,
  162. reo2sw5_intr,
  163. reo2sw4_intr,
  164. reo2sw3_intr,
  165. reo2sw2_intr,
  166. reo2sw1_intr,
  167. reo2sw0_intr,
  168. reo2status_intr2,
  169. reo_status,
  170. reo2rxdma_out_2,
  171. reo2rxdma_out_1,
  172. reo_cmd,
  173. sw2reo6,
  174. sw2reo5,
  175. sw2reo1,
  176. sw2reo,
  177. rxdma2reo_mlo_0_dst_ring1,
  178. rxdma2reo_mlo_0_dst_ring0,
  179. rxdma2reo_mlo_1_dst_ring1,
  180. rxdma2reo_mlo_1_dst_ring0,
  181. rxdma2reo_dst_ring1,
  182. rxdma2reo_dst_ring0,
  183. rxdma2sw_dst_ring1,
  184. rxdma2sw_dst_ring0,
  185. rxdma2release_dst_ring1,
  186. rxdma2release_dst_ring0,
  187. sw2rxdma_2_src_ring,
  188. sw2rxdma_1_src_ring,
  189. sw2rxdma_0,
  190. wbm2sw6_release2,
  191. wbm2sw5_release2,
  192. wbm2sw4_release2,
  193. wbm2sw3_release2,
  194. wbm2sw2_release2,
  195. wbm2sw1_release2,
  196. wbm2sw0_release2,
  197. wbm2sw6_release,
  198. wbm2sw5_release,
  199. wbm2sw4_release,
  200. wbm2sw3_release,
  201. wbm2sw2_release,
  202. wbm2sw1_release,
  203. wbm2sw0_release,
  204. wbm2sw_link,
  205. wbm_error_release,
  206. sw2txmon_src_ring,
  207. sw2rxmon_src_ring,
  208. txmon2sw_p1_intr1,
  209. txmon2sw_p1_intr0,
  210. txmon2sw_p0_dest1,
  211. txmon2sw_p0_dest0,
  212. rxmon2sw_p1_intr1,
  213. rxmon2sw_p1_intr0,
  214. rxmon2sw_p0_dest1,
  215. rxmon2sw_p0_dest0,
  216. sw_release,
  217. sw2tcl_credit2,
  218. sw2tcl_credit,
  219. sw2tcl4,
  220. sw2tcl5,
  221. sw2tcl3,
  222. sw2tcl2,
  223. sw2tcl1,
  224. sw2wbm1,
  225. misc_8,
  226. misc_7,
  227. misc_6,
  228. misc_5,
  229. misc_4,
  230. misc_3,
  231. misc_2,
  232. misc_1,
  233. misc_0,
  234. };
  235. #endif
  236. struct CE_state;
  237. #ifdef QCA_WIFI_QCN9224
  238. #define CE_COUNT_MAX 16
  239. #else
  240. #define CE_COUNT_MAX 12
  241. #endif
  242. #ifndef HIF_MAX_GROUP
  243. #define HIF_MAX_GROUP WLAN_CFG_INT_NUM_CONTEXTS
  244. #endif
  245. #ifdef CONFIG_BERYLLIUM
  246. #define HIF_MAX_GRP_IRQ 25
  247. #else
  248. #define HIF_MAX_GRP_IRQ 16
  249. #endif
  250. #ifndef NAPI_YIELD_BUDGET_BASED
  251. #ifndef QCA_NAPI_DEF_SCALE_BIN_SHIFT
  252. #define QCA_NAPI_DEF_SCALE_BIN_SHIFT 4
  253. #endif
  254. #else /* NAPI_YIELD_BUDGET_BASED */
  255. #define QCA_NAPI_DEF_SCALE_BIN_SHIFT 2
  256. #endif /* NAPI_YIELD_BUDGET_BASED */
  257. #define QCA_NAPI_BUDGET 64
  258. #define QCA_NAPI_DEF_SCALE \
  259. (1 << QCA_NAPI_DEF_SCALE_BIN_SHIFT)
  260. #define HIF_NAPI_MAX_RECEIVES (QCA_NAPI_BUDGET * QCA_NAPI_DEF_SCALE)
  261. /* NOTE: "napi->scale" can be changed,
  262. * but this does not change the number of buckets
  263. */
  264. #define QCA_NAPI_NUM_BUCKETS 4
  265. /**
  266. * struct qca_napi_stat - stats structure for execution contexts
  267. * @napi_schedules: number of times the schedule function is called
  268. * @napi_polls: number of times the execution context runs
  269. * @napi_completes: number of times that the generating interrupt is re-enabled
  270. * @napi_workdone: cumulative of all work done reported by handler
  271. * @cpu_corrected: incremented when execution context runs on a different core
  272. * than the one that its irq is affined to.
  273. * @napi_budget_uses: histogram of work done per execution run
  274. * @time_limit_reached: count of yields due to time limit thresholds
  275. * @rxpkt_thresh_reached: count of yields due to a work limit
  276. * @napi_max_poll_time:
  277. * @poll_time_buckets: histogram of poll times for the napi
  278. *
  279. */
  280. struct qca_napi_stat {
  281. uint32_t napi_schedules;
  282. uint32_t napi_polls;
  283. uint32_t napi_completes;
  284. uint32_t napi_workdone;
  285. uint32_t cpu_corrected;
  286. uint32_t napi_budget_uses[QCA_NAPI_NUM_BUCKETS];
  287. uint32_t time_limit_reached;
  288. uint32_t rxpkt_thresh_reached;
  289. unsigned long long napi_max_poll_time;
  290. #ifdef WLAN_FEATURE_RX_SOFTIRQ_TIME_LIMIT
  291. uint32_t poll_time_buckets[QCA_NAPI_NUM_BUCKETS];
  292. #endif
  293. };
  294. /*Number of buckets for latency*/
  295. #define HIF_SCHED_LATENCY_BUCKETS 8
  296. /*Buckets for latency between 0 to 2 ms*/
  297. #define HIF_SCHED_LATENCY_BUCKET_0_2 2
  298. /*Buckets for latency between 3 to 10 ms*/
  299. #define HIF_SCHED_LATENCY_BUCKET_3_10 10
  300. /*Buckets for latency between 11 to 20 ms*/
  301. #define HIF_SCHED_LATENCY_BUCKET_11_20 20
  302. /*Buckets for latency between 21 to 50 ms*/
  303. #define HIF_SCHED_LATENCY_BUCKET_21_50 50
  304. /*Buckets for latency between 50 to 100 ms*/
  305. #define HIF_SCHED_LATENCY_BUCKET_51_100 100
  306. /*Buckets for latency between 100 to 250 ms*/
  307. #define HIF_SCHED_LATENCY_BUCKET_101_250 250
  308. /*Buckets for latency between 250 to 500 ms*/
  309. #define HIF_SCHED_LATENCY_BUCKET_251_500 500
  310. /**
  311. * struct qca_napi_info - per NAPI instance data structure
  312. * @netdev: dummy net_dev
  313. * @hif_ctx:
  314. * @napi:
  315. * @scale:
  316. * @id:
  317. * @cpu:
  318. * @irq:
  319. * @cpumask:
  320. * @stats:
  321. * @offld_flush_cb:
  322. * @rx_thread_napi:
  323. * @rx_thread_netdev:
  324. * @lro_ctx:
  325. * @poll_start_time: napi poll service start time
  326. * @sched_latency_stats: napi schedule latency stats
  327. * @tstamp: napi schedule start timestamp
  328. *
  329. * This data structure holds stuff per NAPI instance.
  330. * Note that, in the current implementation, though scale is
  331. * an instance variable, it is set to the same value for all
  332. * instances.
  333. */
  334. struct qca_napi_info {
  335. struct net_device netdev; /* dummy net_dev */
  336. void *hif_ctx;
  337. struct napi_struct napi;
  338. uint8_t scale; /* currently same on all instances */
  339. uint8_t id;
  340. uint8_t cpu;
  341. int irq;
  342. cpumask_t cpumask;
  343. struct qca_napi_stat stats[NR_CPUS];
  344. #ifdef RECEIVE_OFFLOAD
  345. /* will only be present for data rx CE's */
  346. void (*offld_flush_cb)(void *);
  347. struct napi_struct rx_thread_napi;
  348. struct net_device rx_thread_netdev;
  349. #endif /* RECEIVE_OFFLOAD */
  350. qdf_lro_ctx_t lro_ctx;
  351. #ifdef WLAN_FEATURE_RX_SOFTIRQ_TIME_LIMIT
  352. unsigned long long poll_start_time;
  353. #endif
  354. #ifdef HIF_LATENCY_PROFILE_ENABLE
  355. uint64_t sched_latency_stats[HIF_SCHED_LATENCY_BUCKETS];
  356. uint64_t tstamp;
  357. #endif
  358. };
  359. enum qca_napi_tput_state {
  360. QCA_NAPI_TPUT_UNINITIALIZED,
  361. QCA_NAPI_TPUT_LO,
  362. QCA_NAPI_TPUT_HI
  363. };
  364. enum qca_napi_cpu_state {
  365. QCA_NAPI_CPU_UNINITIALIZED,
  366. QCA_NAPI_CPU_DOWN,
  367. QCA_NAPI_CPU_UP };
  368. /**
  369. * struct qca_napi_cpu - an entry of the napi cpu table
  370. * @state:
  371. * @core_id: physical core id of the core
  372. * @cluster_id: cluster this core belongs to
  373. * @core_mask: mask to match all core of this cluster
  374. * @thread_mask: mask for this core within the cluster
  375. * @max_freq: maximum clock this core can be clocked at
  376. * same for all cpus of the same core.
  377. * @napis: bitmap of napi instances on this core
  378. * @execs: bitmap of execution contexts on this core
  379. * @cluster_nxt: chain to link cores within the same cluster
  380. *
  381. * This structure represents a single entry in the napi cpu
  382. * table. The table is part of struct qca_napi_data.
  383. * This table is initialized by the init function, called while
  384. * the first napi instance is being created, updated by hotplug
  385. * notifier and when cpu affinity decisions are made (by throughput
  386. * detection), and deleted when the last napi instance is removed.
  387. */
  388. struct qca_napi_cpu {
  389. enum qca_napi_cpu_state state;
  390. int core_id;
  391. int cluster_id;
  392. cpumask_t core_mask;
  393. cpumask_t thread_mask;
  394. unsigned int max_freq;
  395. uint32_t napis;
  396. uint32_t execs;
  397. int cluster_nxt; /* index, not pointer */
  398. };
  399. /**
  400. * struct qca_napi_data - collection of napi data for a single hif context
  401. * @hif_softc: pointer to the hif context
  402. * @lock: spinlock used in the event state machine
  403. * @state: state variable used in the napi stat machine
  404. * @ce_map: bit map indicating which ce's have napis running
  405. * @exec_map: bit map of instantiated exec contexts
  406. * @user_cpu_affin_mask: CPU affinity mask from INI config.
  407. * @napis:
  408. * @napi_cpu: cpu info for irq affinity
  409. * @lilcl_head:
  410. * @bigcl_head:
  411. * @napi_mode: irq affinity & clock voting mode
  412. * @cpuhp_handler: CPU hotplug event registration handle
  413. * @flags:
  414. */
  415. struct qca_napi_data {
  416. struct hif_softc *hif_softc;
  417. qdf_spinlock_t lock;
  418. uint32_t state;
  419. /* bitmap of created/registered NAPI instances, indexed by pipe_id,
  420. * not used by clients (clients use an id returned by create)
  421. */
  422. uint32_t ce_map;
  423. uint32_t exec_map;
  424. uint32_t user_cpu_affin_mask;
  425. struct qca_napi_info *napis[CE_COUNT_MAX];
  426. struct qca_napi_cpu napi_cpu[NR_CPUS];
  427. int lilcl_head, bigcl_head;
  428. enum qca_napi_tput_state napi_mode;
  429. struct qdf_cpuhp_handler *cpuhp_handler;
  430. uint8_t flags;
  431. };
  432. /**
  433. * struct hif_config_info - Place Holder for HIF configuration
  434. * @enable_self_recovery: Self Recovery
  435. * @enable_runtime_pm: Enable Runtime PM
  436. * @runtime_pm_delay: Runtime PM Delay
  437. * @rx_softirq_max_yield_duration_ns: Max Yield time duration for RX Softirq
  438. *
  439. * Structure for holding HIF ini parameters.
  440. */
  441. struct hif_config_info {
  442. bool enable_self_recovery;
  443. #ifdef FEATURE_RUNTIME_PM
  444. uint8_t enable_runtime_pm;
  445. u_int32_t runtime_pm_delay;
  446. #endif
  447. uint64_t rx_softirq_max_yield_duration_ns;
  448. };
  449. /**
  450. * struct hif_target_info - Target Information
  451. * @target_version: Target Version
  452. * @target_type: Target Type
  453. * @target_revision: Target Revision
  454. * @soc_version: SOC Version
  455. * @hw_name: pointer to hardware name
  456. *
  457. * Structure to hold target information.
  458. */
  459. struct hif_target_info {
  460. uint32_t target_version;
  461. uint32_t target_type;
  462. uint32_t target_revision;
  463. uint32_t soc_version;
  464. char *hw_name;
  465. };
  466. struct hif_opaque_softc {
  467. };
  468. /**
  469. * struct hif_ce_ring_info - CE ring information
  470. * @ring_id: ring id
  471. * @ring_dir: ring direction
  472. * @num_entries: number of entries in ring
  473. * @entry_size: ring entry size
  474. * @ring_base_paddr: srng base physical address
  475. * @hp_paddr: head pointer physical address
  476. * @tp_paddr: tail pointer physical address
  477. */
  478. struct hif_ce_ring_info {
  479. uint8_t ring_id;
  480. uint8_t ring_dir;
  481. uint32_t num_entries;
  482. uint32_t entry_size;
  483. uint64_t ring_base_paddr;
  484. uint64_t hp_paddr;
  485. uint64_t tp_paddr;
  486. };
  487. /**
  488. * struct hif_direct_link_ce_info - Direct Link CE information
  489. * @ce_id: CE ide
  490. * @pipe_dir: Pipe direction
  491. * @ring_info: ring information
  492. */
  493. struct hif_direct_link_ce_info {
  494. uint8_t ce_id;
  495. uint8_t pipe_dir;
  496. struct hif_ce_ring_info ring_info;
  497. };
  498. /**
  499. * enum hif_event_type - Type of DP events to be recorded
  500. * @HIF_EVENT_IRQ_TRIGGER: IRQ trigger event
  501. * @HIF_EVENT_TIMER_ENTRY: Monitor Timer entry event
  502. * @HIF_EVENT_TIMER_EXIT: Monitor Timer exit event
  503. * @HIF_EVENT_BH_SCHED: NAPI POLL scheduled event
  504. * @HIF_EVENT_SRNG_ACCESS_START: hal ring access start event
  505. * @HIF_EVENT_SRNG_ACCESS_END: hal ring access end event
  506. * @HIF_EVENT_BH_COMPLETE: NAPI POLL completion event
  507. * @HIF_EVENT_BH_FORCE_BREAK: NAPI POLL force break event
  508. * @HIF_EVENT_IRQ_DISABLE_EXPIRED: IRQ disable expired event
  509. */
  510. enum hif_event_type {
  511. HIF_EVENT_IRQ_TRIGGER,
  512. HIF_EVENT_TIMER_ENTRY,
  513. HIF_EVENT_TIMER_EXIT,
  514. HIF_EVENT_BH_SCHED,
  515. HIF_EVENT_SRNG_ACCESS_START,
  516. HIF_EVENT_SRNG_ACCESS_END,
  517. HIF_EVENT_BH_COMPLETE,
  518. HIF_EVENT_BH_FORCE_BREAK,
  519. HIF_EVENT_IRQ_DISABLE_EXPIRED,
  520. /* Do check hif_hist_skip_event_record when adding new events */
  521. };
  522. /**
  523. * enum hif_system_pm_state - System PM state
  524. * @HIF_SYSTEM_PM_STATE_ON: System in active state
  525. * @HIF_SYSTEM_PM_STATE_BUS_RESUMING: bus resume in progress as part of
  526. * system resume
  527. * @HIF_SYSTEM_PM_STATE_BUS_SUSPENDING: bus suspend in progress as part of
  528. * system suspend
  529. * @HIF_SYSTEM_PM_STATE_BUS_SUSPENDED: bus suspended as part of system suspend
  530. */
  531. enum hif_system_pm_state {
  532. HIF_SYSTEM_PM_STATE_ON,
  533. HIF_SYSTEM_PM_STATE_BUS_RESUMING,
  534. HIF_SYSTEM_PM_STATE_BUS_SUSPENDING,
  535. HIF_SYSTEM_PM_STATE_BUS_SUSPENDED,
  536. };
  537. #ifdef WLAN_FEATURE_DP_EVENT_HISTORY
  538. #define HIF_NUM_INT_CONTEXTS HIF_MAX_GROUP
  539. #if defined(HIF_CONFIG_SLUB_DEBUG_ON) || defined(HIF_CE_DEBUG_DATA_BUF)
  540. /* HIF_EVENT_HIST_MAX should always be power of 2 */
  541. #define HIF_EVENT_HIST_MAX 512
  542. #define HIF_EVENT_HIST_ENABLE_MASK 0xFF
  543. static inline uint64_t hif_get_log_timestamp(void)
  544. {
  545. return qdf_get_log_timestamp();
  546. }
  547. #else
  548. #define HIF_EVENT_HIST_MAX 32
  549. /* Enable IRQ TRIGGER, NAPI SCHEDULE, SRNG ACCESS START */
  550. #define HIF_EVENT_HIST_ENABLE_MASK 0x19
  551. static inline uint64_t hif_get_log_timestamp(void)
  552. {
  553. return qdf_sched_clock();
  554. }
  555. #endif
  556. /**
  557. * struct hif_event_record - an entry of the DP event history
  558. * @hal_ring_id: ring id for which event is recorded
  559. * @hp: head pointer of the ring (may not be applicable for all events)
  560. * @tp: tail pointer of the ring (may not be applicable for all events)
  561. * @cpu_id: cpu id on which the event occurred
  562. * @timestamp: timestamp when event occurred
  563. * @type: type of the event
  564. *
  565. * This structure represents the information stored for every datapath
  566. * event which is logged in the history.
  567. */
  568. struct hif_event_record {
  569. uint8_t hal_ring_id;
  570. uint32_t hp;
  571. uint32_t tp;
  572. int cpu_id;
  573. uint64_t timestamp;
  574. enum hif_event_type type;
  575. };
  576. /**
  577. * struct hif_event_misc - history related misc info
  578. * @last_irq_index: last irq event index in history
  579. * @last_irq_ts: last irq timestamp
  580. */
  581. struct hif_event_misc {
  582. int32_t last_irq_index;
  583. uint64_t last_irq_ts;
  584. };
  585. #ifdef WLAN_FEATURE_AFFINITY_MGR
  586. /**
  587. * struct hif_cpu_affinity - CPU affinity mask info for IRQ
  588. *
  589. * @current_irq_mask: Current CPU mask set for IRQ
  590. * @wlan_requested_mask: CPU mask requested by WLAN
  591. * @walt_taken_mask: Current CPU taken by Audio
  592. * @last_updated: Last time IRQ CPU affinity was updated
  593. * @last_affined_away: Last time when IRQ was affined away
  594. * @update_requested: IRQ affinity hint set requested by WLAN
  595. * @irq: IRQ number
  596. */
  597. struct hif_cpu_affinity {
  598. qdf_cpu_mask current_irq_mask;
  599. qdf_cpu_mask wlan_requested_mask;
  600. qdf_cpu_mask walt_taken_mask;
  601. uint64_t last_updated;
  602. uint64_t last_affined_away;
  603. bool update_requested;
  604. int irq;
  605. };
  606. #endif
  607. /**
  608. * struct hif_event_history - history for one interrupt group
  609. * @index: index to store new event
  610. * @misc: event misc information
  611. * @event: event entry
  612. *
  613. * This structure represents the datapath history for one
  614. * interrupt group.
  615. */
  616. struct hif_event_history {
  617. qdf_atomic_t index;
  618. struct hif_event_misc misc;
  619. struct hif_event_record event[HIF_EVENT_HIST_MAX];
  620. };
  621. /**
  622. * hif_hist_record_event() - Record one datapath event in history
  623. * @hif_ctx: HIF opaque context
  624. * @event: DP event entry
  625. * @intr_grp_id: interrupt group ID registered with hif
  626. *
  627. * Return: None
  628. */
  629. void hif_hist_record_event(struct hif_opaque_softc *hif_ctx,
  630. struct hif_event_record *event,
  631. uint8_t intr_grp_id);
  632. /**
  633. * hif_event_history_init() - Initialize SRNG event history buffers
  634. * @hif_ctx: HIF opaque context
  635. * @id: context group ID for which history is recorded
  636. *
  637. * Returns: None
  638. */
  639. void hif_event_history_init(struct hif_opaque_softc *hif_ctx, uint8_t id);
  640. /**
  641. * hif_event_history_deinit() - De-initialize SRNG event history buffers
  642. * @hif_ctx: HIF opaque context
  643. * @id: context group ID for which history is recorded
  644. *
  645. * Returns: None
  646. */
  647. void hif_event_history_deinit(struct hif_opaque_softc *hif_ctx, uint8_t id);
  648. /**
  649. * hif_record_event() - Wrapper function to form and record DP event
  650. * @hif_ctx: HIF opaque context
  651. * @intr_grp_id: interrupt group ID registered with hif
  652. * @hal_ring_id: ring id for which event is recorded
  653. * @hp: head pointer index of the srng
  654. * @tp: tail pointer index of the srng
  655. * @type: type of the event to be logged in history
  656. *
  657. * Return: None
  658. */
  659. static inline void hif_record_event(struct hif_opaque_softc *hif_ctx,
  660. uint8_t intr_grp_id,
  661. uint8_t hal_ring_id,
  662. uint32_t hp,
  663. uint32_t tp,
  664. enum hif_event_type type)
  665. {
  666. struct hif_event_record event;
  667. event.hal_ring_id = hal_ring_id;
  668. event.hp = hp;
  669. event.tp = tp;
  670. event.type = type;
  671. hif_hist_record_event(hif_ctx, &event, intr_grp_id);
  672. return;
  673. }
  674. #else
  675. static inline void hif_record_event(struct hif_opaque_softc *hif_ctx,
  676. uint8_t intr_grp_id,
  677. uint8_t hal_ring_id,
  678. uint32_t hp,
  679. uint32_t tp,
  680. enum hif_event_type type)
  681. {
  682. }
  683. static inline void hif_event_history_init(struct hif_opaque_softc *hif_ctx,
  684. uint8_t id)
  685. {
  686. }
  687. static inline void hif_event_history_deinit(struct hif_opaque_softc *hif_ctx,
  688. uint8_t id)
  689. {
  690. }
  691. #endif /* WLAN_FEATURE_DP_EVENT_HISTORY */
  692. void hif_display_ctrl_traffic_pipes_state(struct hif_opaque_softc *hif_ctx);
  693. #if defined(HIF_CONFIG_SLUB_DEBUG_ON) || defined(HIF_CE_DEBUG_DATA_BUF)
  694. void hif_display_latest_desc_hist(struct hif_opaque_softc *hif_ctx);
  695. #else
  696. static
  697. inline void hif_display_latest_desc_hist(struct hif_opaque_softc *hif_ctx) {}
  698. #endif
  699. /**
  700. * enum HIF_DEVICE_POWER_CHANGE_TYPE: Device Power change type
  701. *
  702. * @HIF_DEVICE_POWER_UP: HIF layer should power up interface and/or module
  703. * @HIF_DEVICE_POWER_DOWN: HIF layer should initiate bus-specific measures to
  704. * minimize power
  705. * @HIF_DEVICE_POWER_CUT: HIF layer should initiate bus-specific AND/OR
  706. * platform-specific measures to completely power-off
  707. * the module and associated hardware (i.e. cut power
  708. * supplies)
  709. */
  710. enum HIF_DEVICE_POWER_CHANGE_TYPE {
  711. HIF_DEVICE_POWER_UP,
  712. HIF_DEVICE_POWER_DOWN,
  713. HIF_DEVICE_POWER_CUT
  714. };
  715. /**
  716. * enum hif_enable_type: what triggered the enabling of hif
  717. *
  718. * @HIF_ENABLE_TYPE_PROBE: probe triggered enable
  719. * @HIF_ENABLE_TYPE_REINIT: reinit triggered enable
  720. * @HIF_ENABLE_TYPE_MAX: Max value
  721. */
  722. enum hif_enable_type {
  723. HIF_ENABLE_TYPE_PROBE,
  724. HIF_ENABLE_TYPE_REINIT,
  725. HIF_ENABLE_TYPE_MAX
  726. };
  727. /**
  728. * enum hif_disable_type: what triggered the disabling of hif
  729. *
  730. * @HIF_DISABLE_TYPE_PROBE_ERROR: probe error triggered disable
  731. * @HIF_DISABLE_TYPE_REINIT_ERROR: reinit error triggered disable
  732. * @HIF_DISABLE_TYPE_REMOVE: remove triggered disable
  733. * @HIF_DISABLE_TYPE_SHUTDOWN: shutdown triggered disable
  734. * @HIF_DISABLE_TYPE_MAX: Max value
  735. */
  736. enum hif_disable_type {
  737. HIF_DISABLE_TYPE_PROBE_ERROR,
  738. HIF_DISABLE_TYPE_REINIT_ERROR,
  739. HIF_DISABLE_TYPE_REMOVE,
  740. HIF_DISABLE_TYPE_SHUTDOWN,
  741. HIF_DISABLE_TYPE_MAX
  742. };
  743. /**
  744. * enum hif_device_config_opcode: configure mode
  745. *
  746. * @HIF_DEVICE_POWER_STATE: device power state
  747. * @HIF_DEVICE_GET_BLOCK_SIZE: get block size
  748. * @HIF_DEVICE_GET_FIFO_ADDR: get block address
  749. * @HIF_DEVICE_GET_PENDING_EVENTS_FUNC: get pending events functions
  750. * @HIF_DEVICE_GET_IRQ_PROC_MODE: get irq proc mode
  751. * @HIF_DEVICE_GET_RECV_EVENT_MASK_UNMASK_FUNC: receive event function
  752. * @HIF_DEVICE_POWER_STATE_CHANGE: change power state
  753. * @HIF_DEVICE_GET_IRQ_YIELD_PARAMS: get yield params
  754. * @HIF_CONFIGURE_QUERY_SCATTER_REQUEST_SUPPORT: configure scatter request
  755. * @HIF_DEVICE_GET_OS_DEVICE: get OS device
  756. * @HIF_DEVICE_DEBUG_BUS_STATE: debug bus state
  757. * @HIF_BMI_DONE: bmi done
  758. * @HIF_DEVICE_SET_TARGET_TYPE: set target type
  759. * @HIF_DEVICE_SET_HTC_CONTEXT: set htc context
  760. * @HIF_DEVICE_GET_HTC_CONTEXT: get htc context
  761. */
  762. enum hif_device_config_opcode {
  763. HIF_DEVICE_POWER_STATE = 0,
  764. HIF_DEVICE_GET_BLOCK_SIZE,
  765. HIF_DEVICE_GET_FIFO_ADDR,
  766. HIF_DEVICE_GET_PENDING_EVENTS_FUNC,
  767. HIF_DEVICE_GET_IRQ_PROC_MODE,
  768. HIF_DEVICE_GET_RECV_EVENT_MASK_UNMASK_FUNC,
  769. HIF_DEVICE_POWER_STATE_CHANGE,
  770. HIF_DEVICE_GET_IRQ_YIELD_PARAMS,
  771. HIF_CONFIGURE_QUERY_SCATTER_REQUEST_SUPPORT,
  772. HIF_DEVICE_GET_OS_DEVICE,
  773. HIF_DEVICE_DEBUG_BUS_STATE,
  774. HIF_BMI_DONE,
  775. HIF_DEVICE_SET_TARGET_TYPE,
  776. HIF_DEVICE_SET_HTC_CONTEXT,
  777. HIF_DEVICE_GET_HTC_CONTEXT,
  778. };
  779. #ifdef CONFIG_ATH_PCIE_ACCESS_DEBUG
  780. struct HID_ACCESS_LOG {
  781. uint32_t seqnum;
  782. bool is_write;
  783. void *addr;
  784. uint32_t value;
  785. };
  786. #endif
  787. void hif_reg_write(struct hif_opaque_softc *hif_ctx, uint32_t offset,
  788. uint32_t value);
  789. uint32_t hif_reg_read(struct hif_opaque_softc *hif_ctx, uint32_t offset);
  790. #define HIF_MAX_DEVICES 1
  791. /**
  792. * struct htc_callbacks - Structure for HTC Callbacks methods
  793. * @context: context to pass to the @dsr_handler
  794. * note : @rw_compl_handler is provided the context
  795. * passed to hif_read_write
  796. * @rw_compl_handler: Read / write completion handler
  797. * @dsr_handler: DSR Handler
  798. */
  799. struct htc_callbacks {
  800. void *context;
  801. QDF_STATUS(*rw_compl_handler)(void *rw_ctx, QDF_STATUS status);
  802. QDF_STATUS(*dsr_handler)(void *context);
  803. };
  804. /**
  805. * struct hif_driver_state_callbacks - Callbacks for HIF to query Driver state
  806. * @context: Private data context
  807. * @set_recovery_in_progress: To Set Driver state for recovery in progress
  808. * @is_recovery_in_progress: Query if driver state is recovery in progress
  809. * @is_load_unload_in_progress: Query if driver state Load/Unload in Progress
  810. * @is_driver_unloading: Query if driver is unloading.
  811. * @is_target_ready:
  812. * @get_bandwidth_level: Query current bandwidth level for the driver
  813. * @prealloc_get_consistent_mem_unaligned: get prealloc unaligned consistent mem
  814. * @prealloc_put_consistent_mem_unaligned: put unaligned consistent mem to pool
  815. * @prealloc_get_multi_pages: get prealloc multi pages memory
  816. * @prealloc_put_multi_pages: put prealloc multi pages memory back to pool
  817. * This Structure provides callback pointer for HIF to query hdd for driver
  818. * states.
  819. */
  820. struct hif_driver_state_callbacks {
  821. void *context;
  822. void (*set_recovery_in_progress)(void *context, uint8_t val);
  823. bool (*is_recovery_in_progress)(void *context);
  824. bool (*is_load_unload_in_progress)(void *context);
  825. bool (*is_driver_unloading)(void *context);
  826. bool (*is_target_ready)(void *context);
  827. int (*get_bandwidth_level)(void *context);
  828. void *(*prealloc_get_consistent_mem_unaligned)(qdf_size_t size,
  829. qdf_dma_addr_t *paddr,
  830. uint32_t ring_type);
  831. void (*prealloc_put_consistent_mem_unaligned)(void *vaddr);
  832. void (*prealloc_get_multi_pages)(uint32_t desc_type,
  833. qdf_size_t elem_size,
  834. uint16_t elem_num,
  835. struct qdf_mem_multi_page_t *pages,
  836. bool cacheable);
  837. void (*prealloc_put_multi_pages)(uint32_t desc_type,
  838. struct qdf_mem_multi_page_t *pages);
  839. };
  840. /* This API detaches the HTC layer from the HIF device */
  841. void hif_detach_htc(struct hif_opaque_softc *hif_ctx);
  842. /****************************************************************/
  843. /* BMI and Diag window abstraction */
  844. /****************************************************************/
  845. #define HIF_BMI_EXCHANGE_NO_TIMEOUT ((uint32_t)(0))
  846. #define DIAG_TRANSFER_LIMIT 2048U /* maximum number of bytes that can be
  847. * handled atomically by
  848. * DiagRead/DiagWrite
  849. */
  850. #ifdef WLAN_FEATURE_BMI
  851. /*
  852. * API to handle HIF-specific BMI message exchanges, this API is synchronous
  853. * and only allowed to be called from a context that can block (sleep)
  854. */
  855. QDF_STATUS hif_exchange_bmi_msg(struct hif_opaque_softc *hif_ctx,
  856. qdf_dma_addr_t cmd, qdf_dma_addr_t rsp,
  857. uint8_t *pSendMessage, uint32_t Length,
  858. uint8_t *pResponseMessage,
  859. uint32_t *pResponseLength, uint32_t TimeoutMS);
  860. void hif_register_bmi_callbacks(struct hif_opaque_softc *hif_ctx);
  861. bool hif_needs_bmi(struct hif_opaque_softc *hif_ctx);
  862. #else /* WLAN_FEATURE_BMI */
  863. static inline void
  864. hif_register_bmi_callbacks(struct hif_opaque_softc *hif_ctx)
  865. {
  866. }
  867. static inline bool
  868. hif_needs_bmi(struct hif_opaque_softc *hif_ctx)
  869. {
  870. return false;
  871. }
  872. #endif /* WLAN_FEATURE_BMI */
  873. #ifdef HIF_CPU_CLEAR_AFFINITY
  874. /**
  875. * hif_config_irq_clear_cpu_affinity() - Remove cpu affinity of IRQ
  876. * @scn: HIF handle
  877. * @intr_ctxt_id: interrupt group index
  878. * @cpu: CPU core to clear
  879. *
  880. * Return: None
  881. */
  882. void hif_config_irq_clear_cpu_affinity(struct hif_opaque_softc *scn,
  883. int intr_ctxt_id, int cpu);
  884. #else
  885. static inline
  886. void hif_config_irq_clear_cpu_affinity(struct hif_opaque_softc *scn,
  887. int intr_ctxt_id, int cpu)
  888. {
  889. }
  890. #endif
  891. /*
  892. * APIs to handle HIF specific diagnostic read accesses. These APIs are
  893. * synchronous and only allowed to be called from a context that
  894. * can block (sleep). They are not high performance APIs.
  895. *
  896. * hif_diag_read_access reads a 4 Byte aligned/length value from a
  897. * Target register or memory word.
  898. *
  899. * hif_diag_read_mem reads an arbitrary length of arbitrarily aligned memory.
  900. */
  901. QDF_STATUS hif_diag_read_access(struct hif_opaque_softc *hif_ctx,
  902. uint32_t address, uint32_t *data);
  903. QDF_STATUS hif_diag_read_mem(struct hif_opaque_softc *hif_ctx, uint32_t address,
  904. uint8_t *data, int nbytes);
  905. void hif_dump_target_memory(struct hif_opaque_softc *hif_ctx,
  906. void *ramdump_base, uint32_t address, uint32_t size);
  907. /*
  908. * APIs to handle HIF specific diagnostic write accesses. These APIs are
  909. * synchronous and only allowed to be called from a context that
  910. * can block (sleep).
  911. * They are not high performance APIs.
  912. *
  913. * hif_diag_write_access writes a 4 Byte aligned/length value to a
  914. * Target register or memory word.
  915. *
  916. * hif_diag_write_mem writes an arbitrary length of arbitrarily aligned memory.
  917. */
  918. QDF_STATUS hif_diag_write_access(struct hif_opaque_softc *hif_ctx,
  919. uint32_t address, uint32_t data);
  920. QDF_STATUS hif_diag_write_mem(struct hif_opaque_softc *hif_ctx,
  921. uint32_t address, uint8_t *data, int nbytes);
  922. typedef void (*fastpath_msg_handler)(void *, qdf_nbuf_t *, uint32_t);
  923. void hif_enable_polled_mode(struct hif_opaque_softc *hif_ctx);
  924. bool hif_is_polled_mode_enabled(struct hif_opaque_softc *hif_ctx);
  925. /*
  926. * Set the FASTPATH_mode_on flag in sc, for use by data path
  927. */
  928. #ifdef WLAN_FEATURE_FASTPATH
  929. void hif_enable_fastpath(struct hif_opaque_softc *hif_ctx);
  930. bool hif_is_fastpath_mode_enabled(struct hif_opaque_softc *hif_ctx);
  931. void *hif_get_ce_handle(struct hif_opaque_softc *hif_ctx, int ret);
  932. /**
  933. * hif_ce_fastpath_cb_register() - Register callback for fastpath msg handler
  934. * @hif_ctx: HIF opaque context
  935. * @handler: Callback function
  936. * @context: handle for callback function
  937. *
  938. * Return: QDF_STATUS_SUCCESS on success or QDF_STATUS_E_FAILURE
  939. */
  940. QDF_STATUS hif_ce_fastpath_cb_register(
  941. struct hif_opaque_softc *hif_ctx,
  942. fastpath_msg_handler handler, void *context);
  943. #else
  944. static inline QDF_STATUS hif_ce_fastpath_cb_register(
  945. struct hif_opaque_softc *hif_ctx,
  946. fastpath_msg_handler handler, void *context)
  947. {
  948. return QDF_STATUS_E_FAILURE;
  949. }
  950. static inline void *hif_get_ce_handle(struct hif_opaque_softc *hif_ctx, int ret)
  951. {
  952. return NULL;
  953. }
  954. #endif
  955. /*
  956. * Enable/disable CDC max performance workaround
  957. * For max-performance set this to 0
  958. * To allow SoC to enter sleep set this to 1
  959. */
  960. #define CONFIG_DISABLE_CDC_MAX_PERF_WAR 0
  961. void hif_ipa_get_ce_resource(struct hif_opaque_softc *hif_ctx,
  962. qdf_shared_mem_t **ce_sr,
  963. uint32_t *ce_sr_ring_size,
  964. qdf_dma_addr_t *ce_reg_paddr);
  965. /**
  966. * struct hif_msg_callbacks - List of callbacks - filled in by HTC.
  967. * @Context: context meaningful to HTC
  968. * @txCompletionHandler:
  969. * @rxCompletionHandler:
  970. * @txResourceAvailHandler:
  971. * @fwEventHandler:
  972. * @update_bundle_stats:
  973. */
  974. struct hif_msg_callbacks {
  975. void *Context;
  976. /**< context meaningful to HTC */
  977. QDF_STATUS (*txCompletionHandler)(void *Context, qdf_nbuf_t wbuf,
  978. uint32_t transferID,
  979. uint32_t toeplitz_hash_result);
  980. QDF_STATUS (*rxCompletionHandler)(void *Context, qdf_nbuf_t wbuf,
  981. uint8_t pipeID);
  982. void (*txResourceAvailHandler)(void *context, uint8_t pipe);
  983. void (*fwEventHandler)(void *context, QDF_STATUS status);
  984. void (*update_bundle_stats)(void *context, uint8_t no_of_pkt_in_bundle);
  985. };
  986. enum hif_target_status {
  987. TARGET_STATUS_CONNECTED = 0, /* target connected */
  988. TARGET_STATUS_RESET, /* target got reset */
  989. TARGET_STATUS_EJECT, /* target got ejected */
  990. TARGET_STATUS_SUSPEND /*target got suspend */
  991. };
  992. /**
  993. * enum hif_attribute_flags: configure hif
  994. *
  995. * @HIF_LOWDESC_CE_CFG: Configure HIF with Low descriptor CE
  996. * @HIF_LOWDESC_CE_NO_PKTLOG_CFG: Configure HIF with Low descriptor
  997. * + No pktlog CE
  998. */
  999. enum hif_attribute_flags {
  1000. HIF_LOWDESC_CE_CFG = 1,
  1001. HIF_LOWDESC_CE_NO_PKTLOG_CFG
  1002. };
  1003. #define HIF_DATA_ATTR_SET_TX_CLASSIFY(attr, v) \
  1004. (attr |= (v & 0x01) << 5)
  1005. #define HIF_DATA_ATTR_SET_ENCAPSULATION_TYPE(attr, v) \
  1006. (attr |= (v & 0x03) << 6)
  1007. #define HIF_DATA_ATTR_SET_ADDR_X_SEARCH_DISABLE(attr, v) \
  1008. (attr |= (v & 0x01) << 13)
  1009. #define HIF_DATA_ATTR_SET_ADDR_Y_SEARCH_DISABLE(attr, v) \
  1010. (attr |= (v & 0x01) << 14)
  1011. #define HIF_DATA_ATTR_SET_TOEPLITZ_HASH_ENABLE(attr, v) \
  1012. (attr |= (v & 0x01) << 15)
  1013. #define HIF_DATA_ATTR_SET_PACKET_OR_RESULT_OFFSET(attr, v) \
  1014. (attr |= (v & 0x0FFF) << 16)
  1015. #define HIF_DATA_ATTR_SET_ENABLE_11H(attr, v) \
  1016. (attr |= (v & 0x01) << 30)
  1017. struct hif_ul_pipe_info {
  1018. unsigned int nentries;
  1019. unsigned int nentries_mask;
  1020. unsigned int sw_index;
  1021. unsigned int write_index; /* cached copy */
  1022. unsigned int hw_index; /* cached copy */
  1023. void *base_addr_owner_space; /* Host address space */
  1024. qdf_dma_addr_t base_addr_CE_space; /* CE address space */
  1025. };
  1026. struct hif_dl_pipe_info {
  1027. unsigned int nentries;
  1028. unsigned int nentries_mask;
  1029. unsigned int sw_index;
  1030. unsigned int write_index; /* cached copy */
  1031. unsigned int hw_index; /* cached copy */
  1032. void *base_addr_owner_space; /* Host address space */
  1033. qdf_dma_addr_t base_addr_CE_space; /* CE address space */
  1034. };
  1035. struct hif_pipe_addl_info {
  1036. uint32_t pci_mem;
  1037. uint32_t ctrl_addr;
  1038. struct hif_ul_pipe_info ul_pipe;
  1039. struct hif_dl_pipe_info dl_pipe;
  1040. };
  1041. #ifdef CONFIG_SLUB_DEBUG_ON
  1042. #define MSG_FLUSH_NUM 16
  1043. #else /* PERF build */
  1044. #define MSG_FLUSH_NUM 32
  1045. #endif /* SLUB_DEBUG_ON */
  1046. struct hif_bus_id;
  1047. #ifdef CUSTOM_CB_SCHEDULER_SUPPORT
  1048. /**
  1049. * hif_register_ce_custom_cb() - Helper API to register the custom callback
  1050. * @hif_ctx: HIF opaque context
  1051. * @pipe: Pipe number
  1052. * @custom_cb: Custom call back function pointer
  1053. * @custom_cb_context: Custom callback context
  1054. *
  1055. * return: QDF_STATUS
  1056. */
  1057. QDF_STATUS
  1058. hif_register_ce_custom_cb(struct hif_opaque_softc *hif_ctx, uint8_t pipe,
  1059. void (*custom_cb)(void *), void *custom_cb_context);
  1060. /**
  1061. * hif_unregister_ce_custom_cb() - Helper API to unregister the custom callback
  1062. * @hif_ctx: HIF opaque context
  1063. * @pipe: Pipe number
  1064. *
  1065. * return: QDF_STATUS
  1066. */
  1067. QDF_STATUS
  1068. hif_unregister_ce_custom_cb(struct hif_opaque_softc *hif_ctx, uint8_t pipe);
  1069. /**
  1070. * hif_enable_ce_custom_cb() - Helper API to enable the custom callback
  1071. * @hif_ctx: HIF opaque context
  1072. * @pipe: Pipe number
  1073. *
  1074. * return: QDF_STATUS
  1075. */
  1076. QDF_STATUS
  1077. hif_enable_ce_custom_cb(struct hif_opaque_softc *hif_ctx, uint8_t pipe);
  1078. /**
  1079. * hif_disable_ce_custom_cb() - Helper API to disable the custom callback
  1080. * @hif_ctx: HIF opaque context
  1081. * @pipe: Pipe number
  1082. *
  1083. * return: QDF_STATUS
  1084. */
  1085. QDF_STATUS
  1086. hif_disable_ce_custom_cb(struct hif_opaque_softc *hif_ctx, uint8_t pipe);
  1087. #endif /* CUSTOM_CB_SCHEDULER_SUPPORT */
  1088. void hif_claim_device(struct hif_opaque_softc *hif_ctx);
  1089. QDF_STATUS hif_get_config_item(struct hif_opaque_softc *hif_ctx,
  1090. int opcode, void *config, uint32_t config_len);
  1091. void hif_set_mailbox_swap(struct hif_opaque_softc *hif_ctx);
  1092. void hif_mask_interrupt_call(struct hif_opaque_softc *hif_ctx);
  1093. void hif_post_init(struct hif_opaque_softc *hif_ctx, void *hHTC,
  1094. struct hif_msg_callbacks *callbacks);
  1095. QDF_STATUS hif_start(struct hif_opaque_softc *hif_ctx);
  1096. void hif_stop(struct hif_opaque_softc *hif_ctx);
  1097. void hif_flush_surprise_remove(struct hif_opaque_softc *hif_ctx);
  1098. void hif_dump(struct hif_opaque_softc *hif_ctx, uint8_t CmdId, bool start);
  1099. void hif_trigger_dump(struct hif_opaque_softc *hif_ctx,
  1100. uint8_t cmd_id, bool start);
  1101. QDF_STATUS hif_send_head(struct hif_opaque_softc *hif_ctx, uint8_t PipeID,
  1102. uint32_t transferID, uint32_t nbytes,
  1103. qdf_nbuf_t wbuf, uint32_t data_attr);
  1104. void hif_send_complete_check(struct hif_opaque_softc *hif_ctx, uint8_t PipeID,
  1105. int force);
  1106. void hif_schedule_ce_tasklet(struct hif_opaque_softc *hif_ctx, uint8_t PipeID);
  1107. void hif_shut_down_device(struct hif_opaque_softc *hif_ctx);
  1108. void hif_get_default_pipe(struct hif_opaque_softc *hif_ctx, uint8_t *ULPipe,
  1109. uint8_t *DLPipe);
  1110. int hif_map_service_to_pipe(struct hif_opaque_softc *hif_ctx, uint16_t svc_id,
  1111. uint8_t *ul_pipe, uint8_t *dl_pipe, int *ul_is_polled,
  1112. int *dl_is_polled);
  1113. uint16_t
  1114. hif_get_free_queue_number(struct hif_opaque_softc *hif_ctx, uint8_t PipeID);
  1115. void *hif_get_targetdef(struct hif_opaque_softc *hif_ctx);
  1116. uint32_t hif_hia_item_address(uint32_t target_type, uint32_t item_offset);
  1117. void hif_set_target_sleep(struct hif_opaque_softc *hif_ctx, bool sleep_ok,
  1118. bool wait_for_it);
  1119. int hif_check_fw_reg(struct hif_opaque_softc *hif_ctx);
  1120. #ifndef HIF_PCI
  1121. static inline int hif_check_soc_status(struct hif_opaque_softc *hif_ctx)
  1122. {
  1123. return 0;
  1124. }
  1125. #else
  1126. int hif_check_soc_status(struct hif_opaque_softc *hif_ctx);
  1127. #endif
  1128. void hif_get_hw_info(struct hif_opaque_softc *hif_ctx, u32 *version,
  1129. u32 *revision, const char **target_name);
  1130. #ifdef RECEIVE_OFFLOAD
  1131. /**
  1132. * hif_offld_flush_cb_register() - Register the offld flush callback
  1133. * @scn: HIF opaque context
  1134. * @offld_flush_handler: Flush callback is either ol_flush, incase of rx_thread
  1135. * Or GRO/LRO flush when RxThread is not enabled. Called
  1136. * with corresponding context for flush.
  1137. * Return: None
  1138. */
  1139. void hif_offld_flush_cb_register(struct hif_opaque_softc *scn,
  1140. void (offld_flush_handler)(void *ol_ctx));
  1141. /**
  1142. * hif_offld_flush_cb_deregister() - deRegister the offld flush callback
  1143. * @scn: HIF opaque context
  1144. *
  1145. * Return: None
  1146. */
  1147. void hif_offld_flush_cb_deregister(struct hif_opaque_softc *scn);
  1148. #endif
  1149. #ifdef WLAN_FEATURE_RX_SOFTIRQ_TIME_LIMIT
  1150. /**
  1151. * hif_exec_should_yield() - Check if hif napi context should yield
  1152. * @hif_ctx: HIF opaque context
  1153. * @grp_id: grp_id of the napi for which check needs to be done
  1154. *
  1155. * The function uses grp_id to look for NAPI and checks if NAPI needs to
  1156. * yield. HIF_EXT_GROUP_MAX_YIELD_DURATION_NS is the duration used for
  1157. * yield decision.
  1158. *
  1159. * Return: true if NAPI needs to yield, else false
  1160. */
  1161. bool hif_exec_should_yield(struct hif_opaque_softc *hif_ctx, uint grp_id);
  1162. #else
  1163. static inline bool hif_exec_should_yield(struct hif_opaque_softc *hif_ctx,
  1164. uint grp_id)
  1165. {
  1166. return false;
  1167. }
  1168. #endif
  1169. void hif_disable_isr(struct hif_opaque_softc *hif_ctx);
  1170. void hif_reset_soc(struct hif_opaque_softc *hif_ctx);
  1171. void hif_save_htc_htt_config_endpoint(struct hif_opaque_softc *hif_ctx,
  1172. int htc_htt_tx_endpoint);
  1173. /**
  1174. * hif_open() - Create hif handle
  1175. * @qdf_ctx: qdf context
  1176. * @mode: Driver Mode
  1177. * @bus_type: Bus Type
  1178. * @cbk: CDS Callbacks
  1179. * @psoc: psoc object manager
  1180. *
  1181. * API to open HIF Context
  1182. *
  1183. * Return: HIF Opaque Pointer
  1184. */
  1185. struct hif_opaque_softc *hif_open(qdf_device_t qdf_ctx,
  1186. uint32_t mode,
  1187. enum qdf_bus_type bus_type,
  1188. struct hif_driver_state_callbacks *cbk,
  1189. struct wlan_objmgr_psoc *psoc);
  1190. /**
  1191. * hif_init_dma_mask() - Set dma mask for the dev
  1192. * @dev: dev for which DMA mask is to be set
  1193. * @bus_type: bus type for the target
  1194. *
  1195. * This API sets the DMA mask for the device. before the datapath
  1196. * memory pre-allocation is done. If the DMA mask is not set before
  1197. * requesting the DMA memory, kernel defaults to a 32-bit DMA mask,
  1198. * and does not utilize the full device capability.
  1199. *
  1200. * Return: 0 - success, non-zero on failure.
  1201. */
  1202. int hif_init_dma_mask(struct device *dev, enum qdf_bus_type bus_type);
  1203. void hif_close(struct hif_opaque_softc *hif_ctx);
  1204. QDF_STATUS hif_enable(struct hif_opaque_softc *hif_ctx, struct device *dev,
  1205. void *bdev, const struct hif_bus_id *bid,
  1206. enum qdf_bus_type bus_type,
  1207. enum hif_enable_type type);
  1208. void hif_disable(struct hif_opaque_softc *hif_ctx, enum hif_disable_type type);
  1209. #ifdef CE_TASKLET_DEBUG_ENABLE
  1210. void hif_enable_ce_latency_stats(struct hif_opaque_softc *hif_ctx,
  1211. uint8_t value);
  1212. #endif
  1213. void hif_display_stats(struct hif_opaque_softc *hif_ctx);
  1214. void hif_clear_stats(struct hif_opaque_softc *hif_ctx);
  1215. /**
  1216. * enum hif_pm_wake_irq_type - Wake interrupt type for Power Management
  1217. * @HIF_PM_INVALID_WAKE: Wake irq is invalid or not configured
  1218. * @HIF_PM_MSI_WAKE: Wake irq is MSI interrupt
  1219. * @HIF_PM_CE_WAKE: Wake irq is CE interrupt
  1220. */
  1221. typedef enum {
  1222. HIF_PM_INVALID_WAKE,
  1223. HIF_PM_MSI_WAKE,
  1224. HIF_PM_CE_WAKE,
  1225. } hif_pm_wake_irq_type;
  1226. /**
  1227. * hif_pm_get_wake_irq_type - Get wake irq type for Power Management
  1228. * @hif_ctx: HIF context
  1229. *
  1230. * Return: enum hif_pm_wake_irq_type
  1231. */
  1232. hif_pm_wake_irq_type hif_pm_get_wake_irq_type(struct hif_opaque_softc *hif_ctx);
  1233. /**
  1234. * enum hif_ep_vote_type - hif ep vote type
  1235. * @HIF_EP_VOTE_DP_ACCESS: vote type is specific DP
  1236. * @HIF_EP_VOTE_NONDP_ACCESS: ep vote for over all access
  1237. */
  1238. enum hif_ep_vote_type {
  1239. HIF_EP_VOTE_DP_ACCESS,
  1240. HIF_EP_VOTE_NONDP_ACCESS
  1241. };
  1242. /**
  1243. * enum hif_ep_vote_access - hif ep vote access
  1244. * @HIF_EP_VOTE_ACCESS_ENABLE: Enable ep voting
  1245. * @HIF_EP_VOTE_INTERMEDIATE_ACCESS: allow during transition
  1246. * @HIF_EP_VOTE_ACCESS_DISABLE: disable ep voting
  1247. */
  1248. enum hif_ep_vote_access {
  1249. HIF_EP_VOTE_ACCESS_ENABLE,
  1250. HIF_EP_VOTE_INTERMEDIATE_ACCESS,
  1251. HIF_EP_VOTE_ACCESS_DISABLE
  1252. };
  1253. /**
  1254. * enum hif_rtpm_client_id - modules registered with runtime pm module
  1255. * @HIF_RTPM_ID_RESERVED: Reserved ID
  1256. * @HIF_RTPM_ID_HAL_REO_CMD: HAL REO commands
  1257. * @HIF_RTPM_ID_WMI: WMI commands Tx
  1258. * @HIF_RTPM_ID_HTT: HTT commands Tx
  1259. * @HIF_RTPM_ID_DP: Datapath Tx path
  1260. * @HIF_RTPM_ID_DP_RING_STATS: Datapath ring stats
  1261. * @HIF_RTPM_ID_CE: CE Tx buffer posting
  1262. * @HIF_RTPM_ID_FORCE_WAKE: Force wake request
  1263. * @HIF_RTPM_ID_PM_QOS_NOTIFY:
  1264. * @HIF_RTPM_ID_WIPHY_SUSPEND:
  1265. * @HIF_RTPM_ID_MAX: Max id
  1266. */
  1267. enum hif_rtpm_client_id {
  1268. HIF_RTPM_ID_RESERVED,
  1269. HIF_RTPM_ID_HAL_REO_CMD,
  1270. HIF_RTPM_ID_WMI,
  1271. HIF_RTPM_ID_HTT,
  1272. HIF_RTPM_ID_DP,
  1273. HIF_RTPM_ID_DP_RING_STATS,
  1274. HIF_RTPM_ID_CE,
  1275. HIF_RTPM_ID_FORCE_WAKE,
  1276. HIF_RTPM_ID_PM_QOS_NOTIFY,
  1277. HIF_RTPM_ID_WIPHY_SUSPEND,
  1278. HIF_RTPM_ID_MAX
  1279. };
  1280. /**
  1281. * enum rpm_type - Get and Put calls types
  1282. * @HIF_RTPM_GET_ASYNC: Increment usage count and when system is suspended
  1283. * schedule resume process, return depends on pm state.
  1284. * @HIF_RTPM_GET_FORCE: Increment usage count and when system is suspended
  1285. * schedule resume process, returns success irrespective of
  1286. * pm_state.
  1287. * @HIF_RTPM_GET_SYNC: Increment usage count and when system is suspended,
  1288. * wait till process is resumed.
  1289. * @HIF_RTPM_GET_NORESUME: Only increments usage count.
  1290. * @HIF_RTPM_PUT_ASYNC: Decrements usage count and puts system in idle state.
  1291. * @HIF_RTPM_PUT_SYNC_SUSPEND: Decrements usage count and puts system in
  1292. * suspended state.
  1293. * @HIF_RTPM_PUT_NOIDLE: Decrements usage count.
  1294. */
  1295. enum rpm_type {
  1296. HIF_RTPM_GET_ASYNC,
  1297. HIF_RTPM_GET_FORCE,
  1298. HIF_RTPM_GET_SYNC,
  1299. HIF_RTPM_GET_NORESUME,
  1300. HIF_RTPM_PUT_ASYNC,
  1301. HIF_RTPM_PUT_SYNC_SUSPEND,
  1302. HIF_RTPM_PUT_NOIDLE,
  1303. };
  1304. /**
  1305. * struct hif_pm_runtime_lock - data structure for preventing runtime suspend
  1306. * @list: global list of runtime locks
  1307. * @active: true if this lock is preventing suspend
  1308. * @name: character string for tracking this lock
  1309. */
  1310. struct hif_pm_runtime_lock {
  1311. struct list_head list;
  1312. bool active;
  1313. const char *name;
  1314. };
  1315. #ifdef FEATURE_RUNTIME_PM
  1316. /**
  1317. * hif_rtpm_register() - Register a module with runtime PM.
  1318. * @id: ID of the module which needs to be registered
  1319. * @hif_rpm_cbk: callback to be called when get was called in suspended state.
  1320. *
  1321. * Return: success status if successfully registered
  1322. */
  1323. QDF_STATUS hif_rtpm_register(uint32_t id, void (*hif_rpm_cbk)(void));
  1324. /**
  1325. * hif_rtpm_deregister() - Deregister the module
  1326. * @id: ID of the module which needs to be de-registered
  1327. */
  1328. QDF_STATUS hif_rtpm_deregister(uint32_t id);
  1329. /**
  1330. * hif_rtpm_set_autosuspend_delay() - Set delay to trigger RTPM suspend
  1331. * @delay: delay in ms to be set
  1332. *
  1333. * Return: Success if delay is set successfully
  1334. */
  1335. QDF_STATUS hif_rtpm_set_autosuspend_delay(int delay);
  1336. /**
  1337. * hif_rtpm_restore_autosuspend_delay() - Restore delay value to default value
  1338. *
  1339. * Return: Success if reset done. E_ALREADY if delay same as config value
  1340. */
  1341. QDF_STATUS hif_rtpm_restore_autosuspend_delay(void);
  1342. /**
  1343. * hif_rtpm_get_autosuspend_delay() -Get delay to trigger RTPM suspend
  1344. *
  1345. * Return: Delay in ms
  1346. */
  1347. int hif_rtpm_get_autosuspend_delay(void);
  1348. /**
  1349. * hif_runtime_lock_init() - API to initialize Runtime PM context
  1350. * @lock: QDF lock context
  1351. * @name: Context name
  1352. *
  1353. * This API initializes the Runtime PM context of the caller and
  1354. * return the pointer.
  1355. *
  1356. * Return: None
  1357. */
  1358. int hif_runtime_lock_init(qdf_runtime_lock_t *lock, const char *name);
  1359. /**
  1360. * hif_runtime_lock_deinit() - This API frees the runtime pm context
  1361. * @data: Runtime PM context
  1362. *
  1363. * Return: void
  1364. */
  1365. void hif_runtime_lock_deinit(struct hif_pm_runtime_lock *data);
  1366. /**
  1367. * hif_rtpm_get() - Increment usage_count on the device to avoid suspend.
  1368. * @type: get call types from hif_rpm_type
  1369. * @id: ID of the module calling get()
  1370. *
  1371. * A get operation will prevent a runtime suspend until a
  1372. * corresponding put is done. This api should be used when accessing bus.
  1373. *
  1374. * CONTRARY TO THE REGULAR RUNTIME PM, WHEN THE BUS IS SUSPENDED,
  1375. * THIS API WILL ONLY REQUEST THE RESUME AND NOT DO A GET!!!
  1376. *
  1377. * return: success if a get has been issued, else error code.
  1378. */
  1379. QDF_STATUS hif_rtpm_get(uint8_t type, uint32_t id);
  1380. /**
  1381. * hif_rtpm_put() - do a put operation on the device
  1382. * @type: put call types from hif_rpm_type
  1383. * @id: ID of the module calling put()
  1384. *
  1385. * A put operation will allow a runtime suspend after a corresponding
  1386. * get was done. This api should be used when finished accessing bus.
  1387. *
  1388. * This api will return a failure if runtime pm is stopped
  1389. * This api will return failure if it would decrement the usage count below 0.
  1390. *
  1391. * return: QDF_STATUS_SUCCESS if the put is performed
  1392. */
  1393. QDF_STATUS hif_rtpm_put(uint8_t type, uint32_t id);
  1394. /**
  1395. * hif_pm_runtime_prevent_suspend() - Prevent Runtime suspend
  1396. * @data: runtime PM lock
  1397. *
  1398. * This function will prevent runtime suspend, by incrementing
  1399. * device's usage count.
  1400. *
  1401. * Return: status
  1402. */
  1403. int hif_pm_runtime_prevent_suspend(struct hif_pm_runtime_lock *data);
  1404. /**
  1405. * hif_pm_runtime_prevent_suspend_sync() - Synchronized prevent Runtime suspend
  1406. * @data: runtime PM lock
  1407. *
  1408. * This function will prevent runtime suspend, by incrementing
  1409. * device's usage count.
  1410. *
  1411. * Return: status
  1412. */
  1413. int hif_pm_runtime_prevent_suspend_sync(struct hif_pm_runtime_lock *data);
  1414. /**
  1415. * hif_pm_runtime_allow_suspend() - Allow Runtime suspend
  1416. * @data: runtime PM lock
  1417. *
  1418. * This function will allow runtime suspend, by decrementing
  1419. * device's usage count.
  1420. *
  1421. * Return: status
  1422. */
  1423. int hif_pm_runtime_allow_suspend(struct hif_pm_runtime_lock *data);
  1424. /**
  1425. * hif_rtpm_request_resume() - Request resume if bus is suspended
  1426. *
  1427. * Return: None
  1428. */
  1429. void hif_rtpm_request_resume(void);
  1430. /**
  1431. * hif_rtpm_sync_resume() - Invoke synchronous runtime resume.
  1432. *
  1433. * This function will invoke synchronous runtime resume.
  1434. *
  1435. * Return: status
  1436. */
  1437. QDF_STATUS hif_rtpm_sync_resume(void);
  1438. /**
  1439. * hif_rtpm_check_and_request_resume() - check if bus is suspended and
  1440. * request resume.
  1441. *
  1442. * Return: void
  1443. */
  1444. void hif_rtpm_check_and_request_resume(void);
  1445. /**
  1446. * hif_rtpm_set_client_job() - Set job for the client.
  1447. * @client_id: Client id for which job needs to be set
  1448. *
  1449. * If get failed due to system being in suspended state, set the client job so
  1450. * when system resumes the client's job is called.
  1451. *
  1452. * Return: None
  1453. */
  1454. void hif_rtpm_set_client_job(uint32_t client_id);
  1455. /**
  1456. * hif_rtpm_mark_last_busy() - Mark last busy to delay retry to suspend
  1457. * @id: ID marking last busy
  1458. *
  1459. * Return: None
  1460. */
  1461. void hif_rtpm_mark_last_busy(uint32_t id);
  1462. /**
  1463. * hif_rtpm_get_monitor_wake_intr() - API to get monitor_wake_intr
  1464. *
  1465. * monitor_wake_intr variable can be used to indicate if driver expects wake
  1466. * MSI for runtime PM
  1467. *
  1468. * Return: monitor_wake_intr variable
  1469. */
  1470. int hif_rtpm_get_monitor_wake_intr(void);
  1471. /**
  1472. * hif_rtpm_set_monitor_wake_intr() - API to set monitor_wake_intr
  1473. * @val: value to set
  1474. *
  1475. * monitor_wake_intr variable can be used to indicate if driver expects wake
  1476. * MSI for runtime PM
  1477. *
  1478. * Return: void
  1479. */
  1480. void hif_rtpm_set_monitor_wake_intr(int val);
  1481. /**
  1482. * hif_pre_runtime_suspend() - book keeping before beginning runtime suspend.
  1483. * @hif_ctx: HIF context
  1484. *
  1485. * Makes sure that the pci link will be taken down by the suspend operation.
  1486. * If the hif layer is configured to leave the bus on, runtime suspend will
  1487. * not save any power.
  1488. *
  1489. * Set the runtime suspend state to SUSPENDING.
  1490. *
  1491. * return -EINVAL if the bus won't go down. otherwise return 0
  1492. */
  1493. int hif_pre_runtime_suspend(struct hif_opaque_softc *hif_ctx);
  1494. /**
  1495. * hif_pre_runtime_resume() - bookkeeping before beginning runtime resume
  1496. *
  1497. * update the runtime pm state to RESUMING.
  1498. * Return: void
  1499. */
  1500. void hif_pre_runtime_resume(void);
  1501. /**
  1502. * hif_process_runtime_suspend_success() - bookkeeping of suspend success
  1503. *
  1504. * Record the success.
  1505. * update the runtime_pm state to SUSPENDED
  1506. * Return: void
  1507. */
  1508. void hif_process_runtime_suspend_success(void);
  1509. /**
  1510. * hif_process_runtime_suspend_failure() - bookkeeping of suspend failure
  1511. *
  1512. * Record the failure.
  1513. * mark last busy to delay a retry.
  1514. * update the runtime_pm state back to ON
  1515. *
  1516. * Return: void
  1517. */
  1518. void hif_process_runtime_suspend_failure(void);
  1519. /**
  1520. * hif_process_runtime_resume_linkup() - bookkeeping of resuming link up
  1521. *
  1522. * update the runtime_pm state to RESUMING_LINKUP
  1523. * Return: void
  1524. */
  1525. void hif_process_runtime_resume_linkup(void);
  1526. /**
  1527. * hif_process_runtime_resume_success() - bookkeeping after a runtime resume
  1528. *
  1529. * record the success.
  1530. * update the runtime_pm state to SUSPENDED
  1531. * Return: void
  1532. */
  1533. void hif_process_runtime_resume_success(void);
  1534. /**
  1535. * hif_rtpm_print_prevent_list() - list the clients preventing suspend.
  1536. *
  1537. * Return: None
  1538. */
  1539. void hif_rtpm_print_prevent_list(void);
  1540. /**
  1541. * hif_rtpm_suspend_lock() - spin_lock on marking runtime suspend
  1542. *
  1543. * Return: void
  1544. */
  1545. void hif_rtpm_suspend_lock(void);
  1546. /**
  1547. * hif_rtpm_suspend_unlock() - spin_unlock on marking runtime suspend
  1548. *
  1549. * Return: void
  1550. */
  1551. void hif_rtpm_suspend_unlock(void);
  1552. /**
  1553. * hif_runtime_suspend() - do the bus suspend part of a runtime suspend
  1554. * @hif_ctx: HIF context
  1555. *
  1556. * Return: 0 for success and non-zero error code for failure
  1557. */
  1558. int hif_runtime_suspend(struct hif_opaque_softc *hif_ctx);
  1559. /**
  1560. * hif_runtime_resume() - do the bus resume part of a runtime resume
  1561. * @hif_ctx: HIF context
  1562. *
  1563. * Return: 0 for success and non-zero error code for failure
  1564. */
  1565. int hif_runtime_resume(struct hif_opaque_softc *hif_ctx);
  1566. /**
  1567. * hif_fastpath_resume() - resume fastpath for runtimepm
  1568. * @hif_ctx: HIF context
  1569. *
  1570. * ensure that the fastpath write index register is up to date
  1571. * since runtime pm may cause ce_send_fast to skip the register
  1572. * write.
  1573. *
  1574. * fastpath only applicable to legacy copy engine
  1575. */
  1576. void hif_fastpath_resume(struct hif_opaque_softc *hif_ctx);
  1577. /**
  1578. * hif_rtpm_get_state(): get rtpm link state
  1579. *
  1580. * Return: state
  1581. */
  1582. int hif_rtpm_get_state(void);
  1583. /**
  1584. * hif_rtpm_display_last_busy_hist() - Display runtimepm last busy history
  1585. * @hif_ctx: HIF context
  1586. *
  1587. * Return: None
  1588. */
  1589. void hif_rtpm_display_last_busy_hist(struct hif_opaque_softc *hif_ctx);
  1590. /**
  1591. * hif_rtpm_record_ce_last_busy_evt() - Record CE runtimepm last busy event
  1592. * @scn: HIF context
  1593. * @ce_id: CE id
  1594. *
  1595. * Return: None
  1596. */
  1597. void hif_rtpm_record_ce_last_busy_evt(struct hif_softc *scn,
  1598. unsigned long ce_id);
  1599. #else
  1600. /**
  1601. * hif_rtpm_display_last_busy_hist() - Display runtimepm last busy history
  1602. * @hif_ctx: HIF context
  1603. *
  1604. * Return: None
  1605. */
  1606. static inline
  1607. void hif_rtpm_display_last_busy_hist(struct hif_opaque_softc *hif_ctx) { }
  1608. /**
  1609. * hif_rtpm_record_ce_last_busy_evt() - Record CE runtimepm last busy event
  1610. * @scn: HIF context
  1611. * @ce_id: CE id
  1612. *
  1613. * Return: None
  1614. */
  1615. static inline
  1616. void hif_rtpm_record_ce_last_busy_evt(struct hif_softc *scn,
  1617. unsigned long ce_id)
  1618. { }
  1619. static inline
  1620. QDF_STATUS hif_rtpm_register(uint32_t id, void (*hif_rpm_cbk)(void))
  1621. { return QDF_STATUS_SUCCESS; }
  1622. static inline
  1623. QDF_STATUS hif_rtpm_deregister(uint32_t id)
  1624. { return QDF_STATUS_SUCCESS; }
  1625. static inline
  1626. QDF_STATUS hif_rtpm_set_autosuspend_delay(int delay)
  1627. { return QDF_STATUS_SUCCESS; }
  1628. static inline QDF_STATUS hif_rtpm_restore_autosuspend_delay(void)
  1629. { return QDF_STATUS_SUCCESS; }
  1630. static inline int hif_rtpm_get_autosuspend_delay(void)
  1631. { return 0; }
  1632. static inline
  1633. int hif_runtime_lock_init(qdf_runtime_lock_t *lock, const char *name)
  1634. { return 0; }
  1635. static inline
  1636. void hif_runtime_lock_deinit(struct hif_pm_runtime_lock *data)
  1637. {}
  1638. static inline
  1639. int hif_rtpm_get(uint8_t type, uint32_t id)
  1640. { return QDF_STATUS_SUCCESS; }
  1641. static inline
  1642. QDF_STATUS hif_rtpm_put(uint8_t type, uint32_t id)
  1643. { return QDF_STATUS_SUCCESS; }
  1644. static inline
  1645. int hif_pm_runtime_allow_suspend(struct hif_pm_runtime_lock *data)
  1646. { return 0; }
  1647. static inline
  1648. int hif_pm_runtime_prevent_suspend(struct hif_pm_runtime_lock *data)
  1649. { return 0; }
  1650. static inline
  1651. int hif_pm_runtime_prevent_suspend_sync(struct hif_pm_runtime_lock *data)
  1652. { return 0; }
  1653. static inline
  1654. QDF_STATUS hif_rtpm_sync_resume(void)
  1655. { return QDF_STATUS_SUCCESS; }
  1656. static inline
  1657. void hif_rtpm_request_resume(void)
  1658. {}
  1659. static inline
  1660. void hif_rtpm_check_and_request_resume(void)
  1661. {}
  1662. static inline
  1663. void hif_rtpm_set_client_job(uint32_t client_id)
  1664. {}
  1665. static inline
  1666. void hif_rtpm_print_prevent_list(void)
  1667. {}
  1668. static inline
  1669. void hif_rtpm_suspend_unlock(void)
  1670. {}
  1671. static inline
  1672. void hif_rtpm_suspend_lock(void)
  1673. {}
  1674. static inline
  1675. int hif_rtpm_get_monitor_wake_intr(void)
  1676. { return 0; }
  1677. static inline
  1678. void hif_rtpm_set_monitor_wake_intr(int val)
  1679. {}
  1680. static inline
  1681. void hif_rtpm_mark_last_busy(uint32_t id)
  1682. {}
  1683. #endif
  1684. void hif_enable_power_management(struct hif_opaque_softc *hif_ctx,
  1685. bool is_packet_log_enabled);
  1686. void hif_disable_power_management(struct hif_opaque_softc *hif_ctx);
  1687. void hif_vote_link_up(struct hif_opaque_softc *hif_ctx);
  1688. void hif_vote_link_down(struct hif_opaque_softc *hif_ctx);
  1689. bool hif_can_suspend_link(struct hif_opaque_softc *hif_ctx);
  1690. #ifdef IPA_OFFLOAD
  1691. /**
  1692. * hif_get_ipa_hw_type() - get IPA hw type
  1693. *
  1694. * This API return the IPA hw type.
  1695. *
  1696. * Return: IPA hw type
  1697. */
  1698. static inline
  1699. enum ipa_hw_type hif_get_ipa_hw_type(void)
  1700. {
  1701. return ipa_get_hw_type();
  1702. }
  1703. /**
  1704. * hif_get_ipa_present() - get IPA hw status
  1705. *
  1706. * This API return the IPA hw status.
  1707. *
  1708. * Return: true if IPA is present or false otherwise
  1709. */
  1710. static inline
  1711. bool hif_get_ipa_present(void)
  1712. {
  1713. if (qdf_ipa_uc_reg_rdyCB(NULL) != -EPERM)
  1714. return true;
  1715. else
  1716. return false;
  1717. }
  1718. #endif
  1719. int hif_bus_resume(struct hif_opaque_softc *hif_ctx);
  1720. /**
  1721. * hif_bus_early_suspend() - stop non wmi tx traffic
  1722. * @hif_ctx: hif context
  1723. */
  1724. int hif_bus_early_suspend(struct hif_opaque_softc *hif_ctx);
  1725. /**
  1726. * hif_bus_late_resume() - resume non wmi traffic
  1727. * @hif_ctx: hif context
  1728. */
  1729. int hif_bus_late_resume(struct hif_opaque_softc *hif_ctx);
  1730. int hif_bus_suspend(struct hif_opaque_softc *hif_ctx);
  1731. int hif_bus_resume_noirq(struct hif_opaque_softc *hif_ctx);
  1732. int hif_bus_suspend_noirq(struct hif_opaque_softc *hif_ctx);
  1733. /**
  1734. * hif_apps_irqs_enable() - Enables all irqs from the APPS side
  1735. * @hif_ctx: an opaque HIF handle to use
  1736. *
  1737. * As opposed to the standard hif_irq_enable, this function always applies to
  1738. * the APPS side kernel interrupt handling.
  1739. *
  1740. * Return: errno
  1741. */
  1742. int hif_apps_irqs_enable(struct hif_opaque_softc *hif_ctx);
  1743. /**
  1744. * hif_apps_irqs_disable() - Disables all irqs from the APPS side
  1745. * @hif_ctx: an opaque HIF handle to use
  1746. *
  1747. * As opposed to the standard hif_irq_disable, this function always applies to
  1748. * the APPS side kernel interrupt handling.
  1749. *
  1750. * Return: errno
  1751. */
  1752. int hif_apps_irqs_disable(struct hif_opaque_softc *hif_ctx);
  1753. /**
  1754. * hif_apps_wake_irq_enable() - Enables the wake irq from the APPS side
  1755. * @hif_ctx: an opaque HIF handle to use
  1756. *
  1757. * As opposed to the standard hif_irq_enable, this function always applies to
  1758. * the APPS side kernel interrupt handling.
  1759. *
  1760. * Return: errno
  1761. */
  1762. int hif_apps_wake_irq_enable(struct hif_opaque_softc *hif_ctx);
  1763. /**
  1764. * hif_apps_wake_irq_disable() - Disables the wake irq from the APPS side
  1765. * @hif_ctx: an opaque HIF handle to use
  1766. *
  1767. * As opposed to the standard hif_irq_disable, this function always applies to
  1768. * the APPS side kernel interrupt handling.
  1769. *
  1770. * Return: errno
  1771. */
  1772. int hif_apps_wake_irq_disable(struct hif_opaque_softc *hif_ctx);
  1773. /**
  1774. * hif_apps_enable_irq_wake() - Enables the irq wake from the APPS side
  1775. * @hif_ctx: an opaque HIF handle to use
  1776. *
  1777. * This function always applies to the APPS side kernel interrupt handling
  1778. * to wake the system from suspend.
  1779. *
  1780. * Return: errno
  1781. */
  1782. int hif_apps_enable_irq_wake(struct hif_opaque_softc *hif_ctx);
  1783. /**
  1784. * hif_apps_disable_irq_wake() - Disables the wake irq from the APPS side
  1785. * @hif_ctx: an opaque HIF handle to use
  1786. *
  1787. * This function always applies to the APPS side kernel interrupt handling
  1788. * to disable the wake irq.
  1789. *
  1790. * Return: errno
  1791. */
  1792. int hif_apps_disable_irq_wake(struct hif_opaque_softc *hif_ctx);
  1793. /**
  1794. * hif_apps_enable_irqs_except_wake_irq() - Enables all irqs except wake_irq
  1795. * @hif_ctx: an opaque HIF handle to use
  1796. *
  1797. * As opposed to the standard hif_irq_enable, this function always applies to
  1798. * the APPS side kernel interrupt handling.
  1799. *
  1800. * Return: errno
  1801. */
  1802. int hif_apps_enable_irqs_except_wake_irq(struct hif_opaque_softc *hif_ctx);
  1803. /**
  1804. * hif_apps_disable_irqs_except_wake_irq() - Disables all irqs except wake_irq
  1805. * @hif_ctx: an opaque HIF handle to use
  1806. *
  1807. * As opposed to the standard hif_irq_disable, this function always applies to
  1808. * the APPS side kernel interrupt handling.
  1809. *
  1810. * Return: errno
  1811. */
  1812. int hif_apps_disable_irqs_except_wake_irq(struct hif_opaque_softc *hif_ctx);
  1813. int hif_get_irq_num(struct hif_opaque_softc *scn, int *irq, uint32_t size);
  1814. int hif_dump_registers(struct hif_opaque_softc *scn);
  1815. int ol_copy_ramdump(struct hif_opaque_softc *scn);
  1816. void hif_crash_shutdown(struct hif_opaque_softc *hif_ctx);
  1817. void hif_get_hw_info(struct hif_opaque_softc *hif_ctx, u32 *version,
  1818. u32 *revision, const char **target_name);
  1819. enum qdf_bus_type hif_get_bus_type(struct hif_opaque_softc *hif_hdl);
  1820. struct hif_target_info *hif_get_target_info_handle(struct hif_opaque_softc *
  1821. scn);
  1822. struct hif_config_info *hif_get_ini_handle(struct hif_opaque_softc *hif_ctx);
  1823. struct ramdump_info *hif_get_ramdump_ctx(struct hif_opaque_softc *hif_ctx);
  1824. enum hif_target_status hif_get_target_status(struct hif_opaque_softc *hif_ctx);
  1825. void hif_set_target_status(struct hif_opaque_softc *hif_ctx, enum
  1826. hif_target_status);
  1827. void hif_init_ini_config(struct hif_opaque_softc *hif_ctx,
  1828. struct hif_config_info *cfg);
  1829. void hif_update_tx_ring(struct hif_opaque_softc *osc, u_int32_t num_htt_cmpls);
  1830. qdf_nbuf_t hif_batch_send(struct hif_opaque_softc *osc, qdf_nbuf_t msdu,
  1831. uint32_t transfer_id, u_int32_t len, uint32_t sendhead);
  1832. QDF_STATUS hif_send_single(struct hif_opaque_softc *osc, qdf_nbuf_t msdu,
  1833. uint32_t transfer_id, u_int32_t len);
  1834. int hif_send_fast(struct hif_opaque_softc *osc, qdf_nbuf_t nbuf,
  1835. uint32_t transfer_id, uint32_t download_len);
  1836. void hif_pkt_dl_len_set(void *hif_sc, unsigned int pkt_download_len);
  1837. void hif_ce_war_disable(void);
  1838. void hif_ce_war_enable(void);
  1839. void hif_disable_interrupt(struct hif_opaque_softc *osc, uint32_t pipe_num);
  1840. #ifdef QCA_NSS_WIFI_OFFLOAD_SUPPORT
  1841. struct hif_pipe_addl_info *hif_get_addl_pipe_info(struct hif_opaque_softc *osc,
  1842. struct hif_pipe_addl_info *hif_info, uint32_t pipe_number);
  1843. uint32_t hif_set_nss_wifiol_mode(struct hif_opaque_softc *osc,
  1844. uint32_t pipe_num);
  1845. int32_t hif_get_nss_wifiol_bypass_nw_process(struct hif_opaque_softc *osc);
  1846. #endif /* QCA_NSS_WIFI_OFFLOAD_SUPPORT */
  1847. void hif_set_bundle_mode(struct hif_opaque_softc *hif_ctx, bool enabled,
  1848. int rx_bundle_cnt);
  1849. int hif_bus_reset_resume(struct hif_opaque_softc *hif_ctx);
  1850. void hif_set_attribute(struct hif_opaque_softc *osc, uint8_t hif_attrib);
  1851. void *hif_get_lro_info(int ctx_id, struct hif_opaque_softc *hif_hdl);
  1852. enum hif_exec_type {
  1853. HIF_EXEC_NAPI_TYPE,
  1854. HIF_EXEC_TASKLET_TYPE,
  1855. };
  1856. typedef uint32_t (*ext_intr_handler)(void *, uint32_t, int);
  1857. /**
  1858. * hif_get_int_ctx_irq_num() - retrieve an irq num for an interrupt context id
  1859. * @softc: hif opaque context owning the exec context
  1860. * @id: the id of the interrupt context
  1861. *
  1862. * Return: IRQ number of the first (zero'th) IRQ within the interrupt context ID
  1863. * 'id' registered with the OS
  1864. */
  1865. int32_t hif_get_int_ctx_irq_num(struct hif_opaque_softc *softc,
  1866. uint8_t id);
  1867. /**
  1868. * hif_configure_ext_group_interrupts() - Configure ext group interrupts
  1869. * @hif_ctx: hif opaque context
  1870. *
  1871. * Return: QDF_STATUS
  1872. */
  1873. QDF_STATUS hif_configure_ext_group_interrupts(struct hif_opaque_softc *hif_ctx);
  1874. /**
  1875. * hif_deconfigure_ext_group_interrupts() - Deconfigure ext group interrupts
  1876. * @hif_ctx: hif opaque context
  1877. *
  1878. * Return: None
  1879. */
  1880. void hif_deconfigure_ext_group_interrupts(struct hif_opaque_softc *hif_ctx);
  1881. /**
  1882. * hif_register_ext_group() - API to register external group
  1883. * interrupt handler.
  1884. * @hif_ctx : HIF Context
  1885. * @numirq: number of irq's in the group
  1886. * @irq: array of irq values
  1887. * @handler: callback interrupt handler function
  1888. * @cb_ctx: context to passed in callback
  1889. * @context_name: text name of the context
  1890. * @type: napi vs tasklet
  1891. * @scale:
  1892. *
  1893. * Return: QDF_STATUS
  1894. */
  1895. QDF_STATUS hif_register_ext_group(struct hif_opaque_softc *hif_ctx,
  1896. uint32_t numirq, uint32_t irq[],
  1897. ext_intr_handler handler,
  1898. void *cb_ctx, const char *context_name,
  1899. enum hif_exec_type type, uint32_t scale);
  1900. void hif_deregister_exec_group(struct hif_opaque_softc *hif_ctx,
  1901. const char *context_name);
  1902. void hif_update_pipe_callback(struct hif_opaque_softc *osc,
  1903. u_int8_t pipeid,
  1904. struct hif_msg_callbacks *callbacks);
  1905. /**
  1906. * hif_print_napi_stats() - Display HIF NAPI stats
  1907. * @hif_ctx: HIF opaque context
  1908. *
  1909. * Return: None
  1910. */
  1911. void hif_print_napi_stats(struct hif_opaque_softc *hif_ctx);
  1912. /**
  1913. * hif_clear_napi_stats() - function clears the stats of the
  1914. * latency when called.
  1915. * @hif_ctx: the HIF context to assign the callback to
  1916. *
  1917. * Return: None
  1918. */
  1919. void hif_clear_napi_stats(struct hif_opaque_softc *hif_ctx);
  1920. #ifdef __cplusplus
  1921. }
  1922. #endif
  1923. #ifdef FORCE_WAKE
  1924. /**
  1925. * hif_force_wake_request() - Function to wake from power collapse
  1926. * @handle: HIF opaque handle
  1927. *
  1928. * Description: API to check if the device is awake or not before
  1929. * read/write to BAR + 4K registers. If device is awake return
  1930. * success otherwise write '1' to
  1931. * PCIE_PCIE_LOCAL_REG_PCIE_SOC_WAKE_PCIE_LOCAL_REG which will interrupt
  1932. * the device and does wakeup the PCI and MHI within 50ms
  1933. * and then the device writes a value to
  1934. * PCIE_SOC_PCIE_REG_PCIE_SCRATCH_0_SOC_PCIE_REG to complete the
  1935. * handshake process to let the host know the device is awake.
  1936. *
  1937. * Return: zero - success/non-zero - failure
  1938. */
  1939. int hif_force_wake_request(struct hif_opaque_softc *handle);
  1940. /**
  1941. * hif_force_wake_release() - API to release/reset the SOC wake register
  1942. * from interrupting the device.
  1943. * @handle: HIF opaque handle
  1944. *
  1945. * Description: API to set the
  1946. * PCIE_PCIE_LOCAL_REG_PCIE_SOC_WAKE_PCIE_LOCAL_REG to '0'
  1947. * to release the interrupt line.
  1948. *
  1949. * Return: zero - success/non-zero - failure
  1950. */
  1951. int hif_force_wake_release(struct hif_opaque_softc *handle);
  1952. #else
  1953. static inline
  1954. int hif_force_wake_request(struct hif_opaque_softc *handle)
  1955. {
  1956. return 0;
  1957. }
  1958. static inline
  1959. int hif_force_wake_release(struct hif_opaque_softc *handle)
  1960. {
  1961. return 0;
  1962. }
  1963. #endif /* FORCE_WAKE */
  1964. #if defined(FEATURE_HAL_DELAYED_REG_WRITE) || \
  1965. defined(FEATURE_HIF_DELAYED_REG_WRITE)
  1966. /**
  1967. * hif_prevent_link_low_power_states() - Prevent from going to low power states
  1968. * @hif: HIF opaque context
  1969. *
  1970. * Return: 0 on success. Error code on failure.
  1971. */
  1972. int hif_prevent_link_low_power_states(struct hif_opaque_softc *hif);
  1973. /**
  1974. * hif_allow_link_low_power_states() - Allow link to go to low power states
  1975. * @hif: HIF opaque context
  1976. *
  1977. * Return: None
  1978. */
  1979. void hif_allow_link_low_power_states(struct hif_opaque_softc *hif);
  1980. #else
  1981. static inline
  1982. int hif_prevent_link_low_power_states(struct hif_opaque_softc *hif)
  1983. {
  1984. return 0;
  1985. }
  1986. static inline
  1987. void hif_allow_link_low_power_states(struct hif_opaque_softc *hif)
  1988. {
  1989. }
  1990. #endif
  1991. #ifdef IPA_OPT_WIFI_DP
  1992. /**
  1993. * hif_prevent_l1() - Prevent from going to low power states
  1994. * @hif: HIF opaque context
  1995. *
  1996. * Return: 0 on success. Error code on failure.
  1997. */
  1998. int hif_prevent_l1(struct hif_opaque_softc *hif);
  1999. /**
  2000. * hif_allow_l1() - Allow link to go to low power states
  2001. * @hif: HIF opaque context
  2002. *
  2003. * Return: None
  2004. */
  2005. void hif_allow_l1(struct hif_opaque_softc *hif);
  2006. #else
  2007. static inline
  2008. int hif_prevent_l1(struct hif_opaque_softc *hif)
  2009. {
  2010. return 0;
  2011. }
  2012. static inline
  2013. void hif_allow_l1(struct hif_opaque_softc *hif)
  2014. {
  2015. }
  2016. #endif
  2017. void *hif_get_dev_ba(struct hif_opaque_softc *hif_handle);
  2018. void *hif_get_dev_ba_ce(struct hif_opaque_softc *hif_handle);
  2019. void *hif_get_dev_ba_pmm(struct hif_opaque_softc *hif_handle);
  2020. /**
  2021. * hif_get_dev_ba_cmem() - get base address of CMEM
  2022. * @hif_handle: the HIF context
  2023. *
  2024. */
  2025. void *hif_get_dev_ba_cmem(struct hif_opaque_softc *hif_handle);
  2026. /**
  2027. * hif_get_soc_version() - get soc major version from target info
  2028. * @hif_handle: the HIF context
  2029. *
  2030. * Return: version number
  2031. */
  2032. uint32_t hif_get_soc_version(struct hif_opaque_softc *hif_handle);
  2033. /**
  2034. * hif_set_initial_wakeup_cb() - set the initial wakeup event handler function
  2035. * @hif_ctx: the HIF context to assign the callback to
  2036. * @callback: the callback to assign
  2037. * @priv: the private data to pass to the callback when invoked
  2038. *
  2039. * Return: None
  2040. */
  2041. void hif_set_initial_wakeup_cb(struct hif_opaque_softc *hif_ctx,
  2042. void (*callback)(void *),
  2043. void *priv);
  2044. /*
  2045. * Note: For MCL, #if defined (HIF_CONFIG_SLUB_DEBUG_ON) needs to be checked
  2046. * for defined here
  2047. */
  2048. #if defined(HIF_CONFIG_SLUB_DEBUG_ON) || defined(HIF_CE_DEBUG_DATA_BUF)
  2049. ssize_t hif_dump_desc_trace_buf(struct device *dev,
  2050. struct device_attribute *attr, char *buf);
  2051. ssize_t hif_input_desc_trace_buf_index(struct hif_softc *scn,
  2052. const char *buf, size_t size);
  2053. ssize_t hif_ce_en_desc_hist(struct hif_softc *scn,
  2054. const char *buf, size_t size);
  2055. ssize_t hif_disp_ce_enable_desc_data_hist(struct hif_softc *scn, char *buf);
  2056. ssize_t hif_dump_desc_event(struct hif_softc *scn, char *buf);
  2057. #endif/*#if defined(HIF_CONFIG_SLUB_DEBUG_ON)||defined(HIF_CE_DEBUG_DATA_BUF)*/
  2058. /**
  2059. * hif_set_ce_service_max_yield_time() - sets CE service max yield time
  2060. * @hif: hif context
  2061. * @ce_service_max_yield_time: CE service max yield time to set
  2062. *
  2063. * This API storess CE service max yield time in hif context based
  2064. * on ini value.
  2065. *
  2066. * Return: void
  2067. */
  2068. void hif_set_ce_service_max_yield_time(struct hif_opaque_softc *hif,
  2069. uint32_t ce_service_max_yield_time);
  2070. /**
  2071. * hif_get_ce_service_max_yield_time() - get CE service max yield time
  2072. * @hif: hif context
  2073. *
  2074. * This API returns CE service max yield time.
  2075. *
  2076. * Return: CE service max yield time
  2077. */
  2078. unsigned long long
  2079. hif_get_ce_service_max_yield_time(struct hif_opaque_softc *hif);
  2080. /**
  2081. * hif_set_ce_service_max_rx_ind_flush() - sets CE service max rx ind flush
  2082. * @hif: hif context
  2083. * @ce_service_max_rx_ind_flush: CE service max rx ind flush to set
  2084. *
  2085. * This API stores CE service max rx ind flush in hif context based
  2086. * on ini value.
  2087. *
  2088. * Return: void
  2089. */
  2090. void hif_set_ce_service_max_rx_ind_flush(struct hif_opaque_softc *hif,
  2091. uint8_t ce_service_max_rx_ind_flush);
  2092. #ifdef OL_ATH_SMART_LOGGING
  2093. /**
  2094. * hif_log_dump_ce() - Copy all the CE DEST ring to buf
  2095. * @scn: HIF handler
  2096. * @buf_cur: Current pointer in ring buffer
  2097. * @buf_init:Start of the ring buffer
  2098. * @buf_sz: Size of the ring buffer
  2099. * @ce: Copy Engine id
  2100. * @skb_sz: Max size of the SKB buffer to be copied
  2101. *
  2102. * Calls the respective function to dump all the CE SRC/DEST ring descriptors
  2103. * and buffers pointed by them in to the given buf
  2104. *
  2105. * Return: Current pointer in ring buffer
  2106. */
  2107. uint8_t *hif_log_dump_ce(struct hif_softc *scn, uint8_t *buf_cur,
  2108. uint8_t *buf_init, uint32_t buf_sz,
  2109. uint32_t ce, uint32_t skb_sz);
  2110. #endif /* OL_ATH_SMART_LOGGING */
  2111. /**
  2112. * hif_softc_to_hif_opaque_softc() - API to convert hif_softc handle
  2113. * to hif_opaque_softc handle
  2114. * @hif_handle: hif_softc type
  2115. *
  2116. * Return: hif_opaque_softc type
  2117. */
  2118. static inline struct hif_opaque_softc *
  2119. hif_softc_to_hif_opaque_softc(struct hif_softc *hif_handle)
  2120. {
  2121. return (struct hif_opaque_softc *)hif_handle;
  2122. }
  2123. #if defined(HIF_IPCI) && defined(FEATURE_HAL_DELAYED_REG_WRITE)
  2124. QDF_STATUS hif_try_prevent_ep_vote_access(struct hif_opaque_softc *hif_ctx);
  2125. void hif_set_ep_intermediate_vote_access(struct hif_opaque_softc *hif_ctx);
  2126. void hif_allow_ep_vote_access(struct hif_opaque_softc *hif_ctx);
  2127. void hif_set_ep_vote_access(struct hif_opaque_softc *hif_ctx,
  2128. uint8_t type, uint8_t access);
  2129. uint8_t hif_get_ep_vote_access(struct hif_opaque_softc *hif_ctx,
  2130. uint8_t type);
  2131. #else
  2132. static inline QDF_STATUS
  2133. hif_try_prevent_ep_vote_access(struct hif_opaque_softc *hif_ctx)
  2134. {
  2135. return QDF_STATUS_SUCCESS;
  2136. }
  2137. static inline void
  2138. hif_set_ep_intermediate_vote_access(struct hif_opaque_softc *hif_ctx)
  2139. {
  2140. }
  2141. static inline void
  2142. hif_allow_ep_vote_access(struct hif_opaque_softc *hif_ctx)
  2143. {
  2144. }
  2145. static inline void
  2146. hif_set_ep_vote_access(struct hif_opaque_softc *hif_ctx,
  2147. uint8_t type, uint8_t access)
  2148. {
  2149. }
  2150. static inline uint8_t
  2151. hif_get_ep_vote_access(struct hif_opaque_softc *hif_ctx,
  2152. uint8_t type)
  2153. {
  2154. return HIF_EP_VOTE_ACCESS_ENABLE;
  2155. }
  2156. #endif
  2157. #ifdef FORCE_WAKE
  2158. /**
  2159. * hif_srng_init_phase(): Indicate srng initialization phase
  2160. * to avoid force wake as UMAC power collapse is not yet
  2161. * enabled
  2162. * @hif_ctx: hif opaque handle
  2163. * @init_phase: initialization phase
  2164. *
  2165. * Return: None
  2166. */
  2167. void hif_srng_init_phase(struct hif_opaque_softc *hif_ctx,
  2168. bool init_phase);
  2169. #else
  2170. static inline
  2171. void hif_srng_init_phase(struct hif_opaque_softc *hif_ctx,
  2172. bool init_phase)
  2173. {
  2174. }
  2175. #endif /* FORCE_WAKE */
  2176. #ifdef HIF_IPCI
  2177. /**
  2178. * hif_shutdown_notifier_cb - Call back for shutdown notifier
  2179. * @ctx: hif handle
  2180. *
  2181. * Return: None
  2182. */
  2183. void hif_shutdown_notifier_cb(void *ctx);
  2184. #else
  2185. static inline
  2186. void hif_shutdown_notifier_cb(void *ctx)
  2187. {
  2188. }
  2189. #endif /* HIF_IPCI */
  2190. #ifdef HIF_CE_LOG_INFO
  2191. /**
  2192. * hif_log_ce_info() - API to log ce info
  2193. * @scn: hif handle
  2194. * @data: hang event data buffer
  2195. * @offset: offset at which data needs to be written
  2196. *
  2197. * Return: None
  2198. */
  2199. void hif_log_ce_info(struct hif_softc *scn, uint8_t *data,
  2200. unsigned int *offset);
  2201. #else
  2202. static inline
  2203. void hif_log_ce_info(struct hif_softc *scn, uint8_t *data,
  2204. unsigned int *offset)
  2205. {
  2206. }
  2207. #endif
  2208. #ifdef HIF_CPU_PERF_AFFINE_MASK
  2209. /**
  2210. * hif_config_irq_set_perf_affinity_hint() - API to set affinity
  2211. * @hif_ctx: hif opaque handle
  2212. *
  2213. * This function is used to move the WLAN IRQs to perf cores in
  2214. * case of defconfig builds.
  2215. *
  2216. * Return: None
  2217. */
  2218. void hif_config_irq_set_perf_affinity_hint(
  2219. struct hif_opaque_softc *hif_ctx);
  2220. #else
  2221. static inline void hif_config_irq_set_perf_affinity_hint(
  2222. struct hif_opaque_softc *hif_ctx)
  2223. {
  2224. }
  2225. #endif
  2226. /**
  2227. * hif_apps_grp_irqs_enable() - enable ext grp irqs
  2228. * @hif_ctx: HIF opaque context
  2229. *
  2230. * Return: 0 on success. Error code on failure.
  2231. */
  2232. int hif_apps_grp_irqs_enable(struct hif_opaque_softc *hif_ctx);
  2233. /**
  2234. * hif_apps_grp_irqs_disable() - disable ext grp irqs
  2235. * @hif_ctx: HIF opaque context
  2236. *
  2237. * Return: 0 on success. Error code on failure.
  2238. */
  2239. int hif_apps_grp_irqs_disable(struct hif_opaque_softc *hif_ctx);
  2240. /**
  2241. * hif_disable_grp_irqs() - disable ext grp irqs
  2242. * @scn: HIF opaque context
  2243. *
  2244. * Return: 0 on success. Error code on failure.
  2245. */
  2246. int hif_disable_grp_irqs(struct hif_opaque_softc *scn);
  2247. /**
  2248. * hif_enable_grp_irqs() - enable ext grp irqs
  2249. * @scn: HIF opaque context
  2250. *
  2251. * Return: 0 on success. Error code on failure.
  2252. */
  2253. int hif_enable_grp_irqs(struct hif_opaque_softc *scn);
  2254. enum hif_credit_exchange_type {
  2255. HIF_REQUEST_CREDIT,
  2256. HIF_PROCESS_CREDIT_REPORT,
  2257. };
  2258. enum hif_detect_latency_type {
  2259. HIF_DETECT_TASKLET,
  2260. HIF_DETECT_CREDIT,
  2261. HIF_DETECT_UNKNOWN
  2262. };
  2263. #ifdef HIF_DETECTION_LATENCY_ENABLE
  2264. void hif_latency_detect_credit_record_time(
  2265. enum hif_credit_exchange_type type,
  2266. struct hif_opaque_softc *hif_ctx);
  2267. void hif_latency_detect_timer_start(struct hif_opaque_softc *hif_ctx);
  2268. void hif_latency_detect_timer_stop(struct hif_opaque_softc *hif_ctx);
  2269. void hif_check_detection_latency(struct hif_softc *scn,
  2270. bool from_timer,
  2271. uint32_t bitmap_type);
  2272. void hif_set_enable_detection(struct hif_opaque_softc *hif_ctx, bool value);
  2273. /**
  2274. * hif_tasklet_latency_record_exec() - record execute time and
  2275. * check the latency
  2276. * @scn: HIF opaque context
  2277. * @idx: CE id
  2278. *
  2279. * Return: None
  2280. */
  2281. void hif_tasklet_latency_record_exec(struct hif_softc *scn, int idx);
  2282. /**
  2283. * hif_tasklet_latency_record_sched() - record schedule time of a tasklet
  2284. * @scn: HIF opaque context
  2285. * @idx: CE id
  2286. *
  2287. * Return: None
  2288. */
  2289. void hif_tasklet_latency_record_sched(struct hif_softc *scn, int idx);
  2290. #else
  2291. static inline
  2292. void hif_latency_detect_timer_start(struct hif_opaque_softc *hif_ctx)
  2293. {}
  2294. static inline
  2295. void hif_latency_detect_timer_stop(struct hif_opaque_softc *hif_ctx)
  2296. {}
  2297. static inline
  2298. void hif_latency_detect_credit_record_time(
  2299. enum hif_credit_exchange_type type,
  2300. struct hif_opaque_softc *hif_ctx)
  2301. {}
  2302. static inline
  2303. void hif_check_detection_latency(struct hif_softc *scn,
  2304. bool from_timer,
  2305. uint32_t bitmap_type)
  2306. {}
  2307. static inline
  2308. void hif_set_enable_detection(struct hif_opaque_softc *hif_ctx, bool value)
  2309. {}
  2310. static inline
  2311. void hif_tasklet_latency_record_exec(struct hif_softc *scn, int idx)
  2312. {}
  2313. static inline
  2314. void hif_tasklet_latency_record_sched(struct hif_softc *scn, int idx)
  2315. {}
  2316. #endif
  2317. #ifdef SYSTEM_PM_CHECK
  2318. /**
  2319. * __hif_system_pm_set_state() - Set system pm state
  2320. * @hif: hif opaque handle
  2321. * @state: system state
  2322. *
  2323. * Return: None
  2324. */
  2325. void __hif_system_pm_set_state(struct hif_opaque_softc *hif,
  2326. enum hif_system_pm_state state);
  2327. /**
  2328. * hif_system_pm_set_state_on() - Set system pm state to ON
  2329. * @hif: hif opaque handle
  2330. *
  2331. * Return: None
  2332. */
  2333. static inline
  2334. void hif_system_pm_set_state_on(struct hif_opaque_softc *hif)
  2335. {
  2336. __hif_system_pm_set_state(hif, HIF_SYSTEM_PM_STATE_ON);
  2337. }
  2338. /**
  2339. * hif_system_pm_set_state_resuming() - Set system pm state to resuming
  2340. * @hif: hif opaque handle
  2341. *
  2342. * Return: None
  2343. */
  2344. static inline
  2345. void hif_system_pm_set_state_resuming(struct hif_opaque_softc *hif)
  2346. {
  2347. __hif_system_pm_set_state(hif, HIF_SYSTEM_PM_STATE_BUS_RESUMING);
  2348. }
  2349. /**
  2350. * hif_system_pm_set_state_suspending() - Set system pm state to suspending
  2351. * @hif: hif opaque handle
  2352. *
  2353. * Return: None
  2354. */
  2355. static inline
  2356. void hif_system_pm_set_state_suspending(struct hif_opaque_softc *hif)
  2357. {
  2358. __hif_system_pm_set_state(hif, HIF_SYSTEM_PM_STATE_BUS_SUSPENDING);
  2359. }
  2360. /**
  2361. * hif_system_pm_set_state_suspended() - Set system pm state to suspended
  2362. * @hif: hif opaque handle
  2363. *
  2364. * Return: None
  2365. */
  2366. static inline
  2367. void hif_system_pm_set_state_suspended(struct hif_opaque_softc *hif)
  2368. {
  2369. __hif_system_pm_set_state(hif, HIF_SYSTEM_PM_STATE_BUS_SUSPENDED);
  2370. }
  2371. /**
  2372. * hif_system_pm_get_state() - Get system pm state
  2373. * @hif: hif opaque handle
  2374. *
  2375. * Return: system state
  2376. */
  2377. int32_t hif_system_pm_get_state(struct hif_opaque_softc *hif);
  2378. /**
  2379. * hif_system_pm_state_check() - Check system state and trigger resume
  2380. * if required
  2381. * @hif: hif opaque handle
  2382. *
  2383. * Return: 0 if system is in on state else error code
  2384. */
  2385. int hif_system_pm_state_check(struct hif_opaque_softc *hif);
  2386. #else
  2387. static inline
  2388. void __hif_system_pm_set_state(struct hif_opaque_softc *hif,
  2389. enum hif_system_pm_state state)
  2390. {
  2391. }
  2392. static inline
  2393. void hif_system_pm_set_state_on(struct hif_opaque_softc *hif)
  2394. {
  2395. }
  2396. static inline
  2397. void hif_system_pm_set_state_resuming(struct hif_opaque_softc *hif)
  2398. {
  2399. }
  2400. static inline
  2401. void hif_system_pm_set_state_suspending(struct hif_opaque_softc *hif)
  2402. {
  2403. }
  2404. static inline
  2405. void hif_system_pm_set_state_suspended(struct hif_opaque_softc *hif)
  2406. {
  2407. }
  2408. static inline
  2409. int32_t hif_system_pm_get_state(struct hif_opaque_softc *hif)
  2410. {
  2411. return 0;
  2412. }
  2413. static inline int hif_system_pm_state_check(struct hif_opaque_softc *hif)
  2414. {
  2415. return 0;
  2416. }
  2417. #endif
  2418. #ifdef FEATURE_IRQ_AFFINITY
  2419. /**
  2420. * hif_set_grp_intr_affinity() - API to set affinity for grp
  2421. * intrs set in the bitmap
  2422. * @scn: hif handle
  2423. * @grp_intr_bitmask: grp intrs for which perf affinity should be
  2424. * applied
  2425. * @perf: affine to perf or non-perf cluster
  2426. *
  2427. * Return: None
  2428. */
  2429. void hif_set_grp_intr_affinity(struct hif_opaque_softc *scn,
  2430. uint32_t grp_intr_bitmask, bool perf);
  2431. #else
  2432. static inline
  2433. void hif_set_grp_intr_affinity(struct hif_opaque_softc *scn,
  2434. uint32_t grp_intr_bitmask, bool perf)
  2435. {
  2436. }
  2437. #endif
  2438. /**
  2439. * hif_get_max_wmi_ep() - Get max WMI EPs configured in target svc map
  2440. * @scn: hif opaque handle
  2441. *
  2442. * Description:
  2443. * Gets number of WMI EPs configured in target svc map. Since EP map
  2444. * include IN and OUT direction pipes, count only OUT pipes to get EPs
  2445. * configured for WMI service.
  2446. *
  2447. * Return:
  2448. * uint8_t: count for WMI eps in target svc map
  2449. */
  2450. uint8_t hif_get_max_wmi_ep(struct hif_opaque_softc *scn);
  2451. #ifdef DP_UMAC_HW_RESET_SUPPORT
  2452. /**
  2453. * hif_register_umac_reset_handler() - Register UMAC HW reset handler
  2454. * @hif_scn: hif opaque handle
  2455. * @irq_handler: irq callback handler function
  2456. * @tl_handler: tasklet callback handler function
  2457. * @cb_ctx: context to passed to @handler
  2458. * @irq: irq number to be used for UMAC HW reset interrupt
  2459. *
  2460. * Return: QDF_STATUS of operation
  2461. */
  2462. QDF_STATUS hif_register_umac_reset_handler(struct hif_opaque_softc *hif_scn,
  2463. bool (*irq_handler)(void *cb_ctx),
  2464. int (*tl_handler)(void *cb_ctx),
  2465. void *cb_ctx, int irq);
  2466. /**
  2467. * hif_unregister_umac_reset_handler() - Unregister UMAC HW reset handler
  2468. * @hif_scn: hif opaque handle
  2469. *
  2470. * Return: QDF_STATUS of operation
  2471. */
  2472. QDF_STATUS hif_unregister_umac_reset_handler(struct hif_opaque_softc *hif_scn);
  2473. QDF_STATUS hif_get_umac_reset_irq(struct hif_opaque_softc *hif_scn,
  2474. int *umac_reset_irq);
  2475. #else
  2476. static inline
  2477. QDF_STATUS hif_register_umac_reset_handler(struct hif_opaque_softc *hif_scn,
  2478. bool (*irq_handler)(void *cb_ctx),
  2479. int (*tl_handler)(void *cb_ctx),
  2480. void *cb_ctx, int irq)
  2481. {
  2482. return QDF_STATUS_SUCCESS;
  2483. }
  2484. static inline
  2485. QDF_STATUS hif_unregister_umac_reset_handler(struct hif_opaque_softc *hif_scn)
  2486. {
  2487. return QDF_STATUS_SUCCESS;
  2488. }
  2489. static inline
  2490. QDF_STATUS hif_get_umac_reset_irq(struct hif_opaque_softc *hif_scn,
  2491. int *umac_reset_irq)
  2492. {
  2493. return QDF_STATUS_SUCCESS;
  2494. }
  2495. #endif /* DP_UMAC_HW_RESET_SUPPORT */
  2496. #ifdef FEATURE_DIRECT_LINK
  2497. /**
  2498. * hif_set_irq_config_by_ceid() - Set irq configuration for CE given by id
  2499. * @scn: hif opaque handle
  2500. * @ce_id: CE id
  2501. * @addr: irq trigger address
  2502. * @data: irq trigger data
  2503. *
  2504. * Return: QDF status
  2505. */
  2506. QDF_STATUS
  2507. hif_set_irq_config_by_ceid(struct hif_opaque_softc *scn, uint8_t ce_id,
  2508. uint64_t addr, uint32_t data);
  2509. /**
  2510. * hif_get_direct_link_ce_dest_srng_buffers() - Get Direct Link ce dest srng
  2511. * buffer information
  2512. * @scn: hif opaque handle
  2513. * @dma_addr: pointer to array of dma addresses
  2514. * @buf_size: ce dest ring buffer size
  2515. *
  2516. * Return: Number of buffers attached to the dest srng.
  2517. */
  2518. uint16_t hif_get_direct_link_ce_dest_srng_buffers(struct hif_opaque_softc *scn,
  2519. uint64_t **dma_addr,
  2520. uint32_t *buf_size);
  2521. /**
  2522. * hif_get_direct_link_ce_srng_info() - Get Direct Link CE srng information
  2523. * @scn: hif opaque handle
  2524. * @info: Direct Link CEs information
  2525. * @max_ce_info_len: max array size of ce info
  2526. *
  2527. * Return: QDF status
  2528. */
  2529. QDF_STATUS
  2530. hif_get_direct_link_ce_srng_info(struct hif_opaque_softc *scn,
  2531. struct hif_direct_link_ce_info *info,
  2532. uint8_t max_ce_info_len);
  2533. #else
  2534. static inline QDF_STATUS
  2535. hif_set_irq_config_by_ceid(struct hif_opaque_softc *scn, uint8_t ce_id,
  2536. uint64_t addr, uint32_t data)
  2537. {
  2538. return QDF_STATUS_SUCCESS;
  2539. }
  2540. static inline
  2541. uint16_t hif_get_direct_link_ce_dest_srng_buffers(struct hif_opaque_softc *scn,
  2542. uint64_t **dma_addr,
  2543. uint32_t *buf_size)
  2544. {
  2545. return 0;
  2546. }
  2547. static inline QDF_STATUS
  2548. hif_get_direct_link_ce_srng_info(struct hif_opaque_softc *scn,
  2549. struct hif_direct_link_ce_info *info,
  2550. uint8_t max_ce_info_len)
  2551. {
  2552. return QDF_STATUS_SUCCESS;
  2553. }
  2554. #endif
  2555. static inline QDF_STATUS
  2556. hif_irq_set_affinity_hint(int irq_num, qdf_cpu_mask *cpu_mask)
  2557. {
  2558. QDF_STATUS status;
  2559. qdf_dev_modify_irq_status(irq_num, IRQ_NO_BALANCING, 0);
  2560. status = qdf_dev_set_irq_affinity(irq_num,
  2561. (struct qdf_cpu_mask *)cpu_mask);
  2562. qdf_dev_modify_irq_status(irq_num, 0, IRQ_NO_BALANCING);
  2563. return status;
  2564. }
  2565. #ifdef WLAN_FEATURE_AFFINITY_MGR
  2566. /**
  2567. * hif_affinity_mgr_init_ce_irq() - Init for CE IRQ
  2568. * @scn: hif opaque handle
  2569. * @id: CE ID
  2570. * @irq: IRQ assigned
  2571. *
  2572. * Return: None
  2573. */
  2574. void
  2575. hif_affinity_mgr_init_ce_irq(struct hif_softc *scn, int id, int irq);
  2576. /**
  2577. * hif_affinity_mgr_init_grp_irq() - Init for group IRQ
  2578. * @scn: hif opaque handle
  2579. * @grp_id: GRP ID
  2580. * @irq_num: IRQ number of hif ext group
  2581. * @irq: IRQ number assigned
  2582. *
  2583. * Return: None
  2584. */
  2585. void
  2586. hif_affinity_mgr_init_grp_irq(struct hif_softc *scn, int grp_id,
  2587. int irq_num, int irq);
  2588. /**
  2589. * hif_affinity_mgr_set_qrg_irq_affinity() - Set affinity for group IRQ
  2590. * @scn: hif opaque handle
  2591. * @irq: IRQ assigned
  2592. * @grp_id: GRP ID
  2593. * @irq_index: IRQ number of hif ext group
  2594. * @cpu_mask: reuquested cpu_mask for IRQ
  2595. *
  2596. * Return: status
  2597. */
  2598. QDF_STATUS
  2599. hif_affinity_mgr_set_qrg_irq_affinity(struct hif_softc *scn, uint32_t irq,
  2600. uint32_t grp_id, uint32_t irq_index,
  2601. qdf_cpu_mask *cpu_mask);
  2602. /**
  2603. * hif_affinity_mgr_set_ce_irq_affinity() - Set affinity for CE IRQ
  2604. * @scn: hif opaque handle
  2605. * @irq: IRQ assigned
  2606. * @ce_id: CE ID
  2607. * @cpu_mask: reuquested cpu_mask for IRQ
  2608. *
  2609. * Return: status
  2610. */
  2611. QDF_STATUS
  2612. hif_affinity_mgr_set_ce_irq_affinity(struct hif_softc *scn, uint32_t irq,
  2613. uint32_t ce_id, qdf_cpu_mask *cpu_mask);
  2614. /**
  2615. * hif_affinity_mgr_affine_irq() - Affine CE and GRP IRQs
  2616. * @scn: hif opaque handle
  2617. *
  2618. * Return: None
  2619. */
  2620. void hif_affinity_mgr_affine_irq(struct hif_softc *scn);
  2621. #else
  2622. static inline void
  2623. hif_affinity_mgr_init_ce_irq(struct hif_softc *scn, int id, int irq)
  2624. {
  2625. }
  2626. static inline void
  2627. hif_affinity_mgr_init_grp_irq(struct hif_softc *scn, int grp_id, int irq_num,
  2628. int irq)
  2629. {
  2630. }
  2631. static inline QDF_STATUS
  2632. hif_affinity_mgr_set_qrg_irq_affinity(struct hif_softc *scn, uint32_t irq,
  2633. uint32_t grp_id, uint32_t irq_index,
  2634. qdf_cpu_mask *cpu_mask)
  2635. {
  2636. return hif_irq_set_affinity_hint(irq, cpu_mask);
  2637. }
  2638. static inline QDF_STATUS
  2639. hif_affinity_mgr_set_ce_irq_affinity(struct hif_softc *scn, uint32_t irq,
  2640. uint32_t ce_id, qdf_cpu_mask *cpu_mask)
  2641. {
  2642. return hif_irq_set_affinity_hint(irq, cpu_mask);
  2643. }
  2644. static inline
  2645. void hif_affinity_mgr_affine_irq(struct hif_softc *scn)
  2646. {
  2647. }
  2648. #endif
  2649. /**
  2650. * hif_affinity_mgr_set_affinity() - Affine CE and GRP IRQs
  2651. * @scn: hif opaque handle
  2652. *
  2653. * Return: None
  2654. */
  2655. void hif_affinity_mgr_set_affinity(struct hif_opaque_softc *scn);
  2656. #ifdef FEATURE_HIF_DELAYED_REG_WRITE
  2657. /**
  2658. * hif_print_reg_write_stats() - Print hif delayed reg write stats
  2659. * @hif_ctx: hif opaque handle
  2660. *
  2661. * Return: None
  2662. */
  2663. void hif_print_reg_write_stats(struct hif_opaque_softc *hif_ctx);
  2664. #else
  2665. static inline void hif_print_reg_write_stats(struct hif_opaque_softc *hif_ctx)
  2666. {
  2667. }
  2668. #endif
  2669. #endif /* _HIF_H_ */