hif.h 75 KB

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