hif.h 75 KB

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