hif.h 72 KB

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