hif.h 75 KB

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