hif.h 74 KB

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