hif.h 68 KB

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