hif.h 81 KB

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