hif.h 82 KB

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