hif.h 67 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392
  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. /**
  584. * enum HIF_DEVICE_POWER_CHANGE_TYPE: Device Power change type
  585. *
  586. * @HIF_DEVICE_POWER_UP: HIF layer should power up interface and/or module
  587. * @HIF_DEVICE_POWER_DOWN: HIF layer should initiate bus-specific measures to
  588. * minimize power
  589. * @HIF_DEVICE_POWER_CUT: HIF layer should initiate bus-specific AND/OR
  590. * platform-specific measures to completely power-off
  591. * the module and associated hardware (i.e. cut power
  592. * supplies)
  593. */
  594. enum HIF_DEVICE_POWER_CHANGE_TYPE {
  595. HIF_DEVICE_POWER_UP,
  596. HIF_DEVICE_POWER_DOWN,
  597. HIF_DEVICE_POWER_CUT
  598. };
  599. /**
  600. * enum hif_enable_type: what triggered the enabling of hif
  601. *
  602. * @HIF_ENABLE_TYPE_PROBE: probe triggered enable
  603. * @HIF_ENABLE_TYPE_REINIT: reinit triggered enable
  604. */
  605. enum hif_enable_type {
  606. HIF_ENABLE_TYPE_PROBE,
  607. HIF_ENABLE_TYPE_REINIT,
  608. HIF_ENABLE_TYPE_MAX
  609. };
  610. /**
  611. * enum hif_disable_type: what triggered the disabling of hif
  612. *
  613. * @HIF_DISABLE_TYPE_PROBE_ERROR: probe error triggered disable
  614. * @HIF_DISABLE_TYPE_REINIT_ERROR: reinit error triggered disable
  615. * @HIF_DISABLE_TYPE_REMOVE: remove triggered disable
  616. * @HIF_DISABLE_TYPE_SHUTDOWN: shutdown triggered disable
  617. */
  618. enum hif_disable_type {
  619. HIF_DISABLE_TYPE_PROBE_ERROR,
  620. HIF_DISABLE_TYPE_REINIT_ERROR,
  621. HIF_DISABLE_TYPE_REMOVE,
  622. HIF_DISABLE_TYPE_SHUTDOWN,
  623. HIF_DISABLE_TYPE_MAX
  624. };
  625. /**
  626. * enum hif_device_config_opcode: configure mode
  627. *
  628. * @HIF_DEVICE_POWER_STATE: device power state
  629. * @HIF_DEVICE_GET_BLOCK_SIZE: get block size
  630. * @HIF_DEVICE_GET_ADDR: get block address
  631. * @HIF_DEVICE_GET_PENDING_EVENTS_FUNC: get pending events functions
  632. * @HIF_DEVICE_GET_IRQ_PROC_MODE: get irq proc mode
  633. * @HIF_DEVICE_GET_RECV_EVENT_MASK_UNMASK_FUNC: receive event function
  634. * @HIF_DEVICE_POWER_STATE_CHANGE: change power state
  635. * @HIF_DEVICE_GET_IRQ_YIELD_PARAMS: get yield params
  636. * @HIF_CONFIGURE_QUERY_SCATTER_REQUEST_SUPPORT: configure scatter request
  637. * @HIF_DEVICE_GET_OS_DEVICE: get OS device
  638. * @HIF_DEVICE_DEBUG_BUS_STATE: debug bus state
  639. * @HIF_BMI_DONE: bmi done
  640. * @HIF_DEVICE_SET_TARGET_TYPE: set target type
  641. * @HIF_DEVICE_SET_HTC_CONTEXT: set htc context
  642. * @HIF_DEVICE_GET_HTC_CONTEXT: get htc context
  643. */
  644. enum hif_device_config_opcode {
  645. HIF_DEVICE_POWER_STATE = 0,
  646. HIF_DEVICE_GET_BLOCK_SIZE,
  647. HIF_DEVICE_GET_FIFO_ADDR,
  648. HIF_DEVICE_GET_PENDING_EVENTS_FUNC,
  649. HIF_DEVICE_GET_IRQ_PROC_MODE,
  650. HIF_DEVICE_GET_RECV_EVENT_MASK_UNMASK_FUNC,
  651. HIF_DEVICE_POWER_STATE_CHANGE,
  652. HIF_DEVICE_GET_IRQ_YIELD_PARAMS,
  653. HIF_CONFIGURE_QUERY_SCATTER_REQUEST_SUPPORT,
  654. HIF_DEVICE_GET_OS_DEVICE,
  655. HIF_DEVICE_DEBUG_BUS_STATE,
  656. HIF_BMI_DONE,
  657. HIF_DEVICE_SET_TARGET_TYPE,
  658. HIF_DEVICE_SET_HTC_CONTEXT,
  659. HIF_DEVICE_GET_HTC_CONTEXT,
  660. };
  661. #ifdef CONFIG_ATH_PCIE_ACCESS_DEBUG
  662. struct HID_ACCESS_LOG {
  663. uint32_t seqnum;
  664. bool is_write;
  665. void *addr;
  666. uint32_t value;
  667. };
  668. #endif
  669. void hif_reg_write(struct hif_opaque_softc *hif_ctx, uint32_t offset,
  670. uint32_t value);
  671. uint32_t hif_reg_read(struct hif_opaque_softc *hif_ctx, uint32_t offset);
  672. #define HIF_MAX_DEVICES 1
  673. /**
  674. * struct htc_callbacks - Structure for HTC Callbacks methods
  675. * @context: context to pass to the dsrhandler
  676. * note : rwCompletionHandler is provided the context
  677. * passed to hif_read_write
  678. * @rwCompletionHandler: Read / write completion handler
  679. * @dsrHandler: DSR Handler
  680. */
  681. struct htc_callbacks {
  682. void *context;
  683. QDF_STATUS(*rw_compl_handler)(void *rw_ctx, QDF_STATUS status);
  684. QDF_STATUS(*dsr_handler)(void *context);
  685. };
  686. /**
  687. * struct hif_driver_state_callbacks - Callbacks for HIF to query Driver state
  688. * @context: Private data context
  689. * @set_recovery_in_progress: To Set Driver state for recovery in progress
  690. * @is_recovery_in_progress: Query if driver state is recovery in progress
  691. * @is_load_unload_in_progress: Query if driver state Load/Unload in Progress
  692. * @is_driver_unloading: Query if driver is unloading.
  693. * @get_bandwidth_level: Query current bandwidth level for the driver
  694. * @prealloc_get_consistent_mem_unligned: get prealloc unaligned consistent mem
  695. * @prealloc_put_consistent_mem_unligned: put unaligned consistent mem to pool
  696. * This Structure provides callback pointer for HIF to query hdd for driver
  697. * states.
  698. */
  699. struct hif_driver_state_callbacks {
  700. void *context;
  701. void (*set_recovery_in_progress)(void *context, uint8_t val);
  702. bool (*is_recovery_in_progress)(void *context);
  703. bool (*is_load_unload_in_progress)(void *context);
  704. bool (*is_driver_unloading)(void *context);
  705. bool (*is_target_ready)(void *context);
  706. int (*get_bandwidth_level)(void *context);
  707. void *(*prealloc_get_consistent_mem_unaligned)(qdf_size_t size,
  708. qdf_dma_addr_t *paddr,
  709. uint32_t ring_type);
  710. void (*prealloc_put_consistent_mem_unaligned)(void *vaddr);
  711. };
  712. /* This API detaches the HTC layer from the HIF device */
  713. void hif_detach_htc(struct hif_opaque_softc *hif_ctx);
  714. /****************************************************************/
  715. /* BMI and Diag window abstraction */
  716. /****************************************************************/
  717. #define HIF_BMI_EXCHANGE_NO_TIMEOUT ((uint32_t)(0))
  718. #define DIAG_TRANSFER_LIMIT 2048U /* maximum number of bytes that can be
  719. * handled atomically by
  720. * DiagRead/DiagWrite
  721. */
  722. #ifdef WLAN_FEATURE_BMI
  723. /*
  724. * API to handle HIF-specific BMI message exchanges, this API is synchronous
  725. * and only allowed to be called from a context that can block (sleep)
  726. */
  727. QDF_STATUS hif_exchange_bmi_msg(struct hif_opaque_softc *hif_ctx,
  728. qdf_dma_addr_t cmd, qdf_dma_addr_t rsp,
  729. uint8_t *pSendMessage, uint32_t Length,
  730. uint8_t *pResponseMessage,
  731. uint32_t *pResponseLength, uint32_t TimeoutMS);
  732. void hif_register_bmi_callbacks(struct hif_opaque_softc *hif_ctx);
  733. bool hif_needs_bmi(struct hif_opaque_softc *hif_ctx);
  734. #else /* WLAN_FEATURE_BMI */
  735. static inline void
  736. hif_register_bmi_callbacks(struct hif_opaque_softc *hif_ctx)
  737. {
  738. }
  739. static inline bool
  740. hif_needs_bmi(struct hif_opaque_softc *hif_ctx)
  741. {
  742. return false;
  743. }
  744. #endif /* WLAN_FEATURE_BMI */
  745. #ifdef HIF_CPU_CLEAR_AFFINITY
  746. /**
  747. * hif_config_irq_clear_cpu_affinity() - Remove cpu affinity of IRQ
  748. * @scn: HIF handle
  749. * @intr_ctxt_id: interrupt group index
  750. * @cpu: CPU core to clear
  751. *
  752. * Return: None
  753. */
  754. void hif_config_irq_clear_cpu_affinity(struct hif_opaque_softc *scn,
  755. int intr_ctxt_id, int cpu);
  756. #else
  757. static inline
  758. void hif_config_irq_clear_cpu_affinity(struct hif_opaque_softc *scn,
  759. int intr_ctxt_id, int cpu)
  760. {
  761. }
  762. #endif
  763. /*
  764. * APIs to handle HIF specific diagnostic read accesses. These APIs are
  765. * synchronous and only allowed to be called from a context that
  766. * can block (sleep). They are not high performance APIs.
  767. *
  768. * hif_diag_read_access reads a 4 Byte aligned/length value from a
  769. * Target register or memory word.
  770. *
  771. * hif_diag_read_mem reads an arbitrary length of arbitrarily aligned memory.
  772. */
  773. QDF_STATUS hif_diag_read_access(struct hif_opaque_softc *hif_ctx,
  774. uint32_t address, uint32_t *data);
  775. QDF_STATUS hif_diag_read_mem(struct hif_opaque_softc *hif_ctx, uint32_t address,
  776. uint8_t *data, int nbytes);
  777. void hif_dump_target_memory(struct hif_opaque_softc *hif_ctx,
  778. void *ramdump_base, uint32_t address, uint32_t size);
  779. /*
  780. * APIs to handle HIF specific diagnostic write accesses. These APIs are
  781. * synchronous and only allowed to be called from a context that
  782. * can block (sleep).
  783. * They are not high performance APIs.
  784. *
  785. * hif_diag_write_access writes a 4 Byte aligned/length value to a
  786. * Target register or memory word.
  787. *
  788. * hif_diag_write_mem writes an arbitrary length of arbitrarily aligned memory.
  789. */
  790. QDF_STATUS hif_diag_write_access(struct hif_opaque_softc *hif_ctx,
  791. uint32_t address, uint32_t data);
  792. QDF_STATUS hif_diag_write_mem(struct hif_opaque_softc *hif_ctx,
  793. uint32_t address, uint8_t *data, int nbytes);
  794. typedef void (*fastpath_msg_handler)(void *, qdf_nbuf_t *, uint32_t);
  795. void hif_enable_polled_mode(struct hif_opaque_softc *hif_ctx);
  796. bool hif_is_polled_mode_enabled(struct hif_opaque_softc *hif_ctx);
  797. /*
  798. * Set the FASTPATH_mode_on flag in sc, for use by data path
  799. */
  800. #ifdef WLAN_FEATURE_FASTPATH
  801. void hif_enable_fastpath(struct hif_opaque_softc *hif_ctx);
  802. bool hif_is_fastpath_mode_enabled(struct hif_opaque_softc *hif_ctx);
  803. void *hif_get_ce_handle(struct hif_opaque_softc *hif_ctx, int ret);
  804. /**
  805. * hif_ce_fastpath_cb_register() - Register callback for fastpath msg handler
  806. * @handler: Callback funtcion
  807. * @context: handle for callback function
  808. *
  809. * Return: QDF_STATUS_SUCCESS on success or QDF_STATUS_E_FAILURE
  810. */
  811. QDF_STATUS hif_ce_fastpath_cb_register(
  812. struct hif_opaque_softc *hif_ctx,
  813. fastpath_msg_handler handler, void *context);
  814. #else
  815. static inline QDF_STATUS hif_ce_fastpath_cb_register(
  816. struct hif_opaque_softc *hif_ctx,
  817. fastpath_msg_handler handler, void *context)
  818. {
  819. return QDF_STATUS_E_FAILURE;
  820. }
  821. static inline void *hif_get_ce_handle(struct hif_opaque_softc *hif_ctx, int ret)
  822. {
  823. return NULL;
  824. }
  825. #endif
  826. /*
  827. * Enable/disable CDC max performance workaround
  828. * For max-performace set this to 0
  829. * To allow SoC to enter sleep set this to 1
  830. */
  831. #define CONFIG_DISABLE_CDC_MAX_PERF_WAR 0
  832. void hif_ipa_get_ce_resource(struct hif_opaque_softc *hif_ctx,
  833. qdf_shared_mem_t **ce_sr,
  834. uint32_t *ce_sr_ring_size,
  835. qdf_dma_addr_t *ce_reg_paddr);
  836. /**
  837. * @brief List of callbacks - filled in by HTC.
  838. */
  839. struct hif_msg_callbacks {
  840. void *Context;
  841. /**< context meaningful to HTC */
  842. QDF_STATUS (*txCompletionHandler)(void *Context, qdf_nbuf_t wbuf,
  843. uint32_t transferID,
  844. uint32_t toeplitz_hash_result);
  845. QDF_STATUS (*rxCompletionHandler)(void *Context, qdf_nbuf_t wbuf,
  846. uint8_t pipeID);
  847. void (*txResourceAvailHandler)(void *context, uint8_t pipe);
  848. void (*fwEventHandler)(void *context, QDF_STATUS status);
  849. void (*update_bundle_stats)(void *context, uint8_t no_of_pkt_in_bundle);
  850. };
  851. enum hif_target_status {
  852. TARGET_STATUS_CONNECTED = 0, /* target connected */
  853. TARGET_STATUS_RESET, /* target got reset */
  854. TARGET_STATUS_EJECT, /* target got ejected */
  855. TARGET_STATUS_SUSPEND /*target got suspend */
  856. };
  857. /**
  858. * enum hif_attribute_flags: configure hif
  859. *
  860. * @HIF_LOWDESC_CE_CFG: Configure HIF with Low descriptor CE
  861. * @HIF_LOWDESC_CE_NO_PKTLOG_CFG: Configure HIF with Low descriptor
  862. * + No pktlog CE
  863. */
  864. enum hif_attribute_flags {
  865. HIF_LOWDESC_CE_CFG = 1,
  866. HIF_LOWDESC_CE_NO_PKTLOG_CFG
  867. };
  868. #define HIF_DATA_ATTR_SET_TX_CLASSIFY(attr, v) \
  869. (attr |= (v & 0x01) << 5)
  870. #define HIF_DATA_ATTR_SET_ENCAPSULATION_TYPE(attr, v) \
  871. (attr |= (v & 0x03) << 6)
  872. #define HIF_DATA_ATTR_SET_ADDR_X_SEARCH_DISABLE(attr, v) \
  873. (attr |= (v & 0x01) << 13)
  874. #define HIF_DATA_ATTR_SET_ADDR_Y_SEARCH_DISABLE(attr, v) \
  875. (attr |= (v & 0x01) << 14)
  876. #define HIF_DATA_ATTR_SET_TOEPLITZ_HASH_ENABLE(attr, v) \
  877. (attr |= (v & 0x01) << 15)
  878. #define HIF_DATA_ATTR_SET_PACKET_OR_RESULT_OFFSET(attr, v) \
  879. (attr |= (v & 0x0FFF) << 16)
  880. #define HIF_DATA_ATTR_SET_ENABLE_11H(attr, v) \
  881. (attr |= (v & 0x01) << 30)
  882. struct hif_ul_pipe_info {
  883. unsigned int nentries;
  884. unsigned int nentries_mask;
  885. unsigned int sw_index;
  886. unsigned int write_index; /* cached copy */
  887. unsigned int hw_index; /* cached copy */
  888. void *base_addr_owner_space; /* Host address space */
  889. qdf_dma_addr_t base_addr_CE_space; /* CE address space */
  890. };
  891. struct hif_dl_pipe_info {
  892. unsigned int nentries;
  893. unsigned int nentries_mask;
  894. unsigned int sw_index;
  895. unsigned int write_index; /* cached copy */
  896. unsigned int hw_index; /* cached copy */
  897. void *base_addr_owner_space; /* Host address space */
  898. qdf_dma_addr_t base_addr_CE_space; /* CE address space */
  899. };
  900. struct hif_pipe_addl_info {
  901. uint32_t pci_mem;
  902. uint32_t ctrl_addr;
  903. struct hif_ul_pipe_info ul_pipe;
  904. struct hif_dl_pipe_info dl_pipe;
  905. };
  906. #ifdef CONFIG_SLUB_DEBUG_ON
  907. #define MSG_FLUSH_NUM 16
  908. #else /* PERF build */
  909. #define MSG_FLUSH_NUM 32
  910. #endif /* SLUB_DEBUG_ON */
  911. struct hif_bus_id;
  912. void hif_claim_device(struct hif_opaque_softc *hif_ctx);
  913. QDF_STATUS hif_get_config_item(struct hif_opaque_softc *hif_ctx,
  914. int opcode, void *config, uint32_t config_len);
  915. void hif_set_mailbox_swap(struct hif_opaque_softc *hif_ctx);
  916. void hif_mask_interrupt_call(struct hif_opaque_softc *hif_ctx);
  917. void hif_post_init(struct hif_opaque_softc *hif_ctx, void *hHTC,
  918. struct hif_msg_callbacks *callbacks);
  919. QDF_STATUS hif_start(struct hif_opaque_softc *hif_ctx);
  920. void hif_stop(struct hif_opaque_softc *hif_ctx);
  921. void hif_flush_surprise_remove(struct hif_opaque_softc *hif_ctx);
  922. void hif_dump(struct hif_opaque_softc *hif_ctx, uint8_t CmdId, bool start);
  923. void hif_trigger_dump(struct hif_opaque_softc *hif_ctx,
  924. uint8_t cmd_id, bool start);
  925. QDF_STATUS hif_send_head(struct hif_opaque_softc *hif_ctx, uint8_t PipeID,
  926. uint32_t transferID, uint32_t nbytes,
  927. qdf_nbuf_t wbuf, uint32_t data_attr);
  928. void hif_send_complete_check(struct hif_opaque_softc *hif_ctx, uint8_t PipeID,
  929. int force);
  930. void hif_schedule_ce_tasklet(struct hif_opaque_softc *hif_ctx, uint8_t PipeID);
  931. void hif_shut_down_device(struct hif_opaque_softc *hif_ctx);
  932. void hif_get_default_pipe(struct hif_opaque_softc *hif_ctx, uint8_t *ULPipe,
  933. uint8_t *DLPipe);
  934. int hif_map_service_to_pipe(struct hif_opaque_softc *hif_ctx, uint16_t svc_id,
  935. uint8_t *ul_pipe, uint8_t *dl_pipe, int *ul_is_polled,
  936. int *dl_is_polled);
  937. uint16_t
  938. hif_get_free_queue_number(struct hif_opaque_softc *hif_ctx, uint8_t PipeID);
  939. void *hif_get_targetdef(struct hif_opaque_softc *hif_ctx);
  940. uint32_t hif_hia_item_address(uint32_t target_type, uint32_t item_offset);
  941. void hif_set_target_sleep(struct hif_opaque_softc *hif_ctx, bool sleep_ok,
  942. bool wait_for_it);
  943. int hif_check_fw_reg(struct hif_opaque_softc *hif_ctx);
  944. #ifndef HIF_PCI
  945. static inline int hif_check_soc_status(struct hif_opaque_softc *hif_ctx)
  946. {
  947. return 0;
  948. }
  949. #else
  950. int hif_check_soc_status(struct hif_opaque_softc *hif_ctx);
  951. #endif
  952. void hif_get_hw_info(struct hif_opaque_softc *hif_ctx, u32 *version,
  953. u32 *revision, const char **target_name);
  954. #ifdef RECEIVE_OFFLOAD
  955. /**
  956. * hif_offld_flush_cb_register() - Register the offld flush callback
  957. * @scn: HIF opaque context
  958. * @offld_flush_handler: Flush callback is either ol_flush, incase of rx_thread
  959. * Or GRO/LRO flush when RxThread is not enabled. Called
  960. * with corresponding context for flush.
  961. * Return: None
  962. */
  963. void hif_offld_flush_cb_register(struct hif_opaque_softc *scn,
  964. void (offld_flush_handler)(void *ol_ctx));
  965. /**
  966. * hif_offld_flush_cb_deregister() - deRegister the offld flush callback
  967. * @scn: HIF opaque context
  968. *
  969. * Return: None
  970. */
  971. void hif_offld_flush_cb_deregister(struct hif_opaque_softc *scn);
  972. #endif
  973. #ifdef WLAN_FEATURE_RX_SOFTIRQ_TIME_LIMIT
  974. /**
  975. * hif_exec_should_yield() - Check if hif napi context should yield
  976. * @hif_ctx - HIF opaque context
  977. * @grp_id - grp_id of the napi for which check needs to be done
  978. *
  979. * The function uses grp_id to look for NAPI and checks if NAPI needs to
  980. * yield. HIF_EXT_GROUP_MAX_YIELD_DURATION_NS is the duration used for
  981. * yield decision.
  982. *
  983. * Return: true if NAPI needs to yield, else false
  984. */
  985. bool hif_exec_should_yield(struct hif_opaque_softc *hif_ctx, uint grp_id);
  986. #else
  987. static inline bool hif_exec_should_yield(struct hif_opaque_softc *hif_ctx,
  988. uint grp_id)
  989. {
  990. return false;
  991. }
  992. #endif
  993. void hif_disable_isr(struct hif_opaque_softc *hif_ctx);
  994. void hif_reset_soc(struct hif_opaque_softc *hif_ctx);
  995. void hif_save_htc_htt_config_endpoint(struct hif_opaque_softc *hif_ctx,
  996. int htc_htt_tx_endpoint);
  997. /**
  998. * hif_open() - Create hif handle
  999. * @qdf_ctx: qdf context
  1000. * @mode: Driver Mode
  1001. * @bus_type: Bus Type
  1002. * @cbk: CDS Callbacks
  1003. * @psoc: psoc object manager
  1004. *
  1005. * API to open HIF Context
  1006. *
  1007. * Return: HIF Opaque Pointer
  1008. */
  1009. struct hif_opaque_softc *hif_open(qdf_device_t qdf_ctx,
  1010. uint32_t mode,
  1011. enum qdf_bus_type bus_type,
  1012. struct hif_driver_state_callbacks *cbk,
  1013. struct wlan_objmgr_psoc *psoc);
  1014. /**
  1015. * hif_init_dma_mask() - Set dma mask for the dev
  1016. * @dev: dev for which DMA mask is to be set
  1017. * @bus_type: bus type for the target
  1018. *
  1019. * This API sets the DMA mask for the device. before the datapath
  1020. * memory pre-allocation is done. If the DMA mask is not set before
  1021. * requesting the DMA memory, kernel defaults to a 32-bit DMA mask,
  1022. * and does not utilize the full device capability.
  1023. *
  1024. * Return: 0 - success, non-zero on failure.
  1025. */
  1026. int hif_init_dma_mask(struct device *dev, enum qdf_bus_type bus_type);
  1027. void hif_close(struct hif_opaque_softc *hif_ctx);
  1028. QDF_STATUS hif_enable(struct hif_opaque_softc *hif_ctx, struct device *dev,
  1029. void *bdev, const struct hif_bus_id *bid,
  1030. enum qdf_bus_type bus_type,
  1031. enum hif_enable_type type);
  1032. void hif_disable(struct hif_opaque_softc *hif_ctx, enum hif_disable_type type);
  1033. #ifdef CE_TASKLET_DEBUG_ENABLE
  1034. void hif_enable_ce_latency_stats(struct hif_opaque_softc *hif_ctx,
  1035. uint8_t value);
  1036. #endif
  1037. void hif_display_stats(struct hif_opaque_softc *hif_ctx);
  1038. void hif_clear_stats(struct hif_opaque_softc *hif_ctx);
  1039. /**
  1040. * enum hif_pm_wake_irq_type - Wake interrupt type for Power Management
  1041. * HIF_PM_INVALID_WAKE: Wake irq is invalid or not configured
  1042. * HIF_PM_MSI_WAKE: Wake irq is MSI interrupt
  1043. * HIF_PM_CE_WAKE: Wake irq is CE interrupt
  1044. */
  1045. typedef enum {
  1046. HIF_PM_INVALID_WAKE,
  1047. HIF_PM_MSI_WAKE,
  1048. HIF_PM_CE_WAKE,
  1049. } hif_pm_wake_irq_type;
  1050. /**
  1051. * hif_pm_get_wake_irq_type - Get wake irq type for Power Management
  1052. * @hif_ctx: HIF context
  1053. *
  1054. * Return: enum hif_pm_wake_irq_type
  1055. */
  1056. hif_pm_wake_irq_type hif_pm_get_wake_irq_type(struct hif_opaque_softc *hif_ctx);
  1057. /**
  1058. * enum hif_ep_vote_type - hif ep vote type
  1059. * HIF_EP_VOTE_DP_ACCESS: vote type is specific DP
  1060. * HIF_EP_VOTE_NONDP_ACCESS: ep vote for over all access
  1061. */
  1062. enum hif_ep_vote_type {
  1063. HIF_EP_VOTE_DP_ACCESS,
  1064. HIF_EP_VOTE_NONDP_ACCESS
  1065. };
  1066. /**
  1067. * enum hif_ep_vote_access - hif ep vote access
  1068. * HIF_EP_VOTE_ACCESS_ENABLE: Enable ep voting
  1069. * HIF_EP_VOTE_INTERMEDIATE_ACCESS: allow during transistion
  1070. * HIF_EP_VOTE_ACCESS_DISABLE: disable ep voting
  1071. */
  1072. enum hif_ep_vote_access {
  1073. HIF_EP_VOTE_ACCESS_ENABLE,
  1074. HIF_EP_VOTE_INTERMEDIATE_ACCESS,
  1075. HIF_EP_VOTE_ACCESS_DISABLE
  1076. };
  1077. /**
  1078. * enum hif_rpm_id - modules registered with runtime pm module
  1079. * @HIF_RTPM_ID_RESERVED: Reserved ID
  1080. * @HIF_RTPM_ID_HAL_REO_CMD: HAL REO commands
  1081. * @HIF_RTPM_ID_WMI: WMI commands Tx
  1082. * @HIF_RTPM_ID_HTT: HTT commands Tx
  1083. * @HIF_RTPM_ID_DP_TX: Datapath Tx path
  1084. * @HIF_RTPM_ID_DP_RING_STATS: Datapath ring stats
  1085. * @HIF_RTPM_ID_CE_SEND_FAST: CE Tx buffer posting
  1086. * @HIF_RTPM_ID_FORCE_WAKE: Force wake request
  1087. * @HIF_RTPM_ID_PREVENT_LINKDOWN: Prevent linkdown by not allowing runtime PM
  1088. * @HIF_RTPM_ID_PREVENT_ALLOW_LOCK: Generic ID for runtime PM lock contexts
  1089. * @HIF_RTPM_ID_MAX: Max id
  1090. */
  1091. enum hif_rtpm_client_id {
  1092. HIF_RTPM_ID_RESERVED,
  1093. HIF_RTPM_ID_HAL_REO_CMD,
  1094. HIF_RTPM_ID_WMI,
  1095. HIF_RTPM_ID_HTT,
  1096. HIF_RTPM_ID_DP,
  1097. HIF_RTPM_ID_DP_RING_STATS,
  1098. HIF_RTPM_ID_CE,
  1099. HIF_RTPM_ID_FORCE_WAKE,
  1100. HIF_RTPM_ID_PM_QOS_NOTIFY,
  1101. HIF_RTPM_ID_WIPHY_SUSPEND,
  1102. HIF_RTPM_ID_MAX
  1103. };
  1104. /**
  1105. * enum hif_rpm_type - Get and Put calls types
  1106. * HIF_RTPM_GET_ASYNC: Increment usage count and when system is suspended
  1107. * schedule resume process, return depends on pm state.
  1108. * HIF_RTPM_GET_FORCE: Increment usage count and when system is suspended
  1109. * shedule resume process, returns success irrespective of
  1110. * pm_state.
  1111. * HIF_RTPM_GET_SYNC: Increment usage count and when system is suspended,
  1112. * wait till process is resumed.
  1113. * HIF_RTPM_GET_NORESUME: Only increments usage count.
  1114. * HIF_RTPM_PUT_ASYNC: Decrements usage count and puts system in idle state.
  1115. * HIF_RTPM_PUT_SYNC_SUSPEND: Decrements usage count and puts system in
  1116. * suspended state.
  1117. * HIF_RTPM_PUT_NOIDLE: Decrements usage count.
  1118. */
  1119. enum rpm_type {
  1120. HIF_RTPM_GET_ASYNC,
  1121. HIF_RTPM_GET_FORCE,
  1122. HIF_RTPM_GET_SYNC,
  1123. HIF_RTPM_GET_NORESUME,
  1124. HIF_RTPM_PUT_ASYNC,
  1125. HIF_RTPM_PUT_SYNC_SUSPEND,
  1126. HIF_RTPM_PUT_NOIDLE,
  1127. };
  1128. /**
  1129. * struct hif_pm_runtime_lock - data structure for preventing runtime suspend
  1130. * @list - global list of runtime locks
  1131. * @active - true if this lock is preventing suspend
  1132. * @name - character string for tracking this lock
  1133. */
  1134. struct hif_pm_runtime_lock {
  1135. struct list_head list;
  1136. bool active;
  1137. const char *name;
  1138. };
  1139. #ifdef FEATURE_RUNTIME_PM
  1140. /**
  1141. * hif_rtpm_register() - Register a module with runtime PM.
  1142. * @id: ID of the module which needs to be registered
  1143. * @hif_rpm_cbk: callback to be called when get was called in suspended state.
  1144. * @prevent_multiple_get: not allow simultaneous get calls or put calls
  1145. *
  1146. * Return: success status if successfully registered
  1147. */
  1148. QDF_STATUS hif_rtpm_register(uint32_t id, void (*hif_rpm_cbk)(void));
  1149. /**
  1150. * hif_rtpm_deregister() - Deregister the module
  1151. * @id: ID of the module which needs to be de-registered
  1152. */
  1153. QDF_STATUS hif_rtpm_deregister(uint32_t id);
  1154. /**
  1155. * hif_runtime_lock_init() - API to initialize Runtime PM context
  1156. * @lock: QDF lock context
  1157. * @name: Context name
  1158. *
  1159. * This API initializes the Runtime PM context of the caller and
  1160. * return the pointer.
  1161. *
  1162. * Return: None
  1163. */
  1164. int hif_runtime_lock_init(qdf_runtime_lock_t *lock, const char *name);
  1165. /**
  1166. * hif_runtime_lock_deinit() - This API frees the runtime pm context
  1167. * @data: Runtime PM context
  1168. *
  1169. * Return: void
  1170. */
  1171. void hif_runtime_lock_deinit(struct hif_pm_runtime_lock *data);
  1172. /**
  1173. * hif_rtpm_get() - Increment usage_count on the device to avoid suspend.
  1174. * @type: get call types from hif_rpm_type
  1175. * @id: ID of the module calling get()
  1176. *
  1177. * A get operation will prevent a runtime suspend until a
  1178. * corresponding put is done. This api should be used when accessing bus.
  1179. *
  1180. * CONTRARY TO THE REGULAR RUNTIME PM, WHEN THE BUS IS SUSPENDED,
  1181. * THIS API WILL ONLY REQUEST THE RESUME AND NOT DO A GET!!!
  1182. *
  1183. * return: success if a get has been issued, else error code.
  1184. */
  1185. QDF_STATUS hif_rtpm_get(uint8_t type, uint32_t id);
  1186. /**
  1187. * hif_pm_runtime_put() - do a put operation on the device
  1188. * @type: put call types from hif_rpm_type
  1189. * @id: ID of the module calling put()
  1190. *
  1191. * A put operation will allow a runtime suspend after a corresponding
  1192. * get was done. This api should be used when finished accessing bus.
  1193. *
  1194. * This api will return a failure if runtime pm is stopped
  1195. * This api will return failure if it would decrement the usage count below 0.
  1196. *
  1197. * return: QDF_STATUS_SUCCESS if the put is performed
  1198. */
  1199. QDF_STATUS hif_rtpm_put(uint8_t type, uint32_t id);
  1200. /**
  1201. * hif_pm_runtime_prevent_suspend() - Prevent Runtime suspend
  1202. * @data: runtime PM lock
  1203. *
  1204. * This function will prevent runtime suspend, by incrementing
  1205. * device's usage count.
  1206. *
  1207. * Return: status
  1208. */
  1209. int hif_pm_runtime_prevent_suspend(struct hif_pm_runtime_lock *data);
  1210. /**
  1211. * hif_pm_runtime_allow_suspend() - Allow Runtime suspend
  1212. * @data: runtime PM lock
  1213. *
  1214. * This function will allow runtime suspend, by decrementing
  1215. * device's usage count.
  1216. *
  1217. * Return: status
  1218. */
  1219. int hif_pm_runtime_allow_suspend(struct hif_pm_runtime_lock *data);
  1220. /**
  1221. * hif_rtpm_request_resume() - Request resume if bus is suspended
  1222. *
  1223. * Return: None
  1224. */
  1225. void hif_rtpm_request_resume(void);
  1226. /**
  1227. * hif_rtpm_sync_resume() - Invoke synchronous runtime resume.
  1228. *
  1229. * This function will invoke synchronous runtime resume.
  1230. *
  1231. * Return: status
  1232. */
  1233. QDF_STATUS hif_rtpm_sync_resume(void);
  1234. /**
  1235. * hif_rtpm_check_and_request_resume() - check if bus is suspended and
  1236. * request resume.
  1237. *
  1238. * Return: void
  1239. */
  1240. void hif_rtpm_check_and_request_resume(void);
  1241. /**
  1242. * hif_rtpm_set_client_job() - Set job for the client.
  1243. * @client_id: Client id for which job needs to be set
  1244. *
  1245. * If get failed due to system being in suspended state, set the client job so
  1246. * when system resumes the client's job is called.
  1247. *
  1248. * Return: None
  1249. */
  1250. void hif_rtpm_set_client_job(uint32_t client_id);
  1251. /**
  1252. * hif_rtpm_mark_last_busy() - Mark last busy to delay retry to suspend
  1253. * @id: ID marking last busy
  1254. *
  1255. * Return: None
  1256. */
  1257. void hif_rtpm_mark_last_busy(uint32_t id);
  1258. /**
  1259. * hif_rtpm_get_monitor_wake_intr() - API to get monitor_wake_intr
  1260. *
  1261. * monitor_wake_intr variable can be used to indicate if driver expects wake
  1262. * MSI for runtime PM
  1263. *
  1264. * Return: monitor_wake_intr variable
  1265. */
  1266. int hif_rtpm_get_monitor_wake_intr(void);
  1267. /**
  1268. * hif_rtpm_set_monitor_wake_intr() - API to set monitor_wake_intr
  1269. * @val: value to set
  1270. *
  1271. * monitor_wake_intr variable can be used to indicate if driver expects wake
  1272. * MSI for runtime PM
  1273. *
  1274. * Return: void
  1275. */
  1276. void hif_rtpm_set_monitor_wake_intr(int val);
  1277. /**
  1278. * hif_pre_runtime_suspend() - book keeping before beginning runtime suspend.
  1279. * @hif_ctx: HIF context
  1280. *
  1281. * Makes sure that the pci link will be taken down by the suspend opperation.
  1282. * If the hif layer is configured to leave the bus on, runtime suspend will
  1283. * not save any power.
  1284. *
  1285. * Set the runtime suspend state to SUSPENDING.
  1286. *
  1287. * return -EINVAL if the bus won't go down. otherwise return 0
  1288. */
  1289. int hif_pre_runtime_suspend(struct hif_opaque_softc *hif_ctx);
  1290. /**
  1291. * hif_pre_runtime_resume() - bookkeeping before beginning runtime resume
  1292. *
  1293. * update the runtime pm state to RESUMING.
  1294. * Return: void
  1295. */
  1296. void hif_pre_runtime_resume(void);
  1297. /**
  1298. * hif_process_runtime_suspend_success() - bookkeeping of suspend success
  1299. *
  1300. * Record the success.
  1301. * update the runtime_pm state to SUSPENDED
  1302. * Return: void
  1303. */
  1304. void hif_process_runtime_suspend_success(void);
  1305. /**
  1306. * hif_process_runtime_suspend_failure() - bookkeeping of suspend failure
  1307. *
  1308. * Record the failure.
  1309. * mark last busy to delay a retry.
  1310. * update the runtime_pm state back to ON
  1311. *
  1312. * Return: void
  1313. */
  1314. void hif_process_runtime_suspend_failure(void);
  1315. /**
  1316. * hif_process_runtime_suspend_failure() - bookkeeping of resuming link up
  1317. *
  1318. * update the runtime_pm state to RESUMING_LINKUP
  1319. * Return: void
  1320. */
  1321. void hif_process_runtime_resume_linkup(void);
  1322. /**
  1323. * hif_process_runtime_resume_success() - bookkeeping after a runtime resume
  1324. *
  1325. * record the success.
  1326. * update the runtime_pm state to SUSPENDED
  1327. * Return: void
  1328. */
  1329. void hif_process_runtime_resume_success(void);
  1330. /**
  1331. * hif_rtpm_print_prevent_list() - list the clients preventing suspend.
  1332. *
  1333. * Return: None
  1334. */
  1335. void hif_rtpm_print_prevent_list(void);
  1336. /**
  1337. * hif_rtpm_suspend_lock() - spin_lock on marking runtime suspend
  1338. *
  1339. * Return: void
  1340. */
  1341. void hif_rtpm_suspend_lock(void);
  1342. /**
  1343. * hif_rtpm_suspend_unlock() - spin_unlock on marking runtime suspend
  1344. *
  1345. * Return: void
  1346. */
  1347. void hif_rtpm_suspend_unlock(void);
  1348. /**
  1349. * hif_runtime_suspend() - do the bus suspend part of a runtime suspend
  1350. * @hif_ctx: HIF context
  1351. *
  1352. * Return: 0 for success and non-zero error code for failure
  1353. */
  1354. int hif_runtime_suspend(struct hif_opaque_softc *hif_ctx);
  1355. /**
  1356. * hif_runtime_resume() - do the bus resume part of a runtime resume
  1357. * @hif_ctx: HIF context
  1358. *
  1359. * Return: 0 for success and non-zero error code for failure
  1360. */
  1361. int hif_runtime_resume(struct hif_opaque_softc *hif_ctx);
  1362. /**
  1363. * hif_fastpath_resume() - resume fastpath for runtimepm
  1364. * @hif_ctx: HIF context
  1365. *
  1366. * ensure that the fastpath write index register is up to date
  1367. * since runtime pm may cause ce_send_fast to skip the register
  1368. * write.
  1369. *
  1370. * fastpath only applicable to legacy copy engine
  1371. */
  1372. void hif_fastpath_resume(struct hif_opaque_softc *hif_ctx);
  1373. #else
  1374. static inline
  1375. QDF_STATUS hif_rtpm_register(uint32_t id, void (*hif_rpm_cbk)(void))
  1376. { return QDF_STATUS_SUCCESS; }
  1377. static inline
  1378. QDF_STATUS hif_rtpm_deregister(uint32_t id)
  1379. { return QDF_STATUS_SUCCESS; }
  1380. static inline
  1381. int hif_runtime_lock_init(qdf_runtime_lock_t *lock, const char *name)
  1382. { return 0; }
  1383. static inline
  1384. void hif_runtime_lock_deinit(struct hif_pm_runtime_lock *data)
  1385. {}
  1386. static inline
  1387. int hif_rtpm_get(uint8_t type, uint32_t id)
  1388. { return QDF_STATUS_SUCCESS; }
  1389. static inline
  1390. QDF_STATUS hif_rtpm_put(uint8_t type, uint32_t id)
  1391. { return QDF_STATUS_SUCCESS; }
  1392. static inline
  1393. int hif_pm_runtime_allow_suspend(struct hif_pm_runtime_lock *data)
  1394. { return 0; }
  1395. static inline
  1396. int hif_pm_runtime_prevent_suspend(struct hif_pm_runtime_lock *data)
  1397. { return 0; }
  1398. static inline
  1399. QDF_STATUS hif_rtpm_sync_resume(void)
  1400. { return QDF_STATUS_SUCCESS; }
  1401. static inline
  1402. void hif_rtpm_request_resume(void)
  1403. {}
  1404. static inline
  1405. void hif_rtpm_check_and_request_resume(void)
  1406. {}
  1407. static inline
  1408. void hif_rtpm_set_client_job(uint32_t client_id)
  1409. {}
  1410. static inline
  1411. void hif_rtpm_print_prevent_list(void)
  1412. {}
  1413. static inline
  1414. void hif_rtpm_suspend_unlock(void)
  1415. {}
  1416. static inline
  1417. void hif_rtpm_suspend_lock(void)
  1418. {}
  1419. static inline
  1420. int hif_rtpm_get_monitor_wake_intr(void)
  1421. { return 0; }
  1422. static inline
  1423. void hif_rtpm_set_monitor_wake_intr(int val)
  1424. {}
  1425. static inline
  1426. void hif_rtpm_mark_last_busy(uint32_t id)
  1427. {}
  1428. #endif
  1429. void hif_enable_power_management(struct hif_opaque_softc *hif_ctx,
  1430. bool is_packet_log_enabled);
  1431. void hif_disable_power_management(struct hif_opaque_softc *hif_ctx);
  1432. void hif_vote_link_up(struct hif_opaque_softc *hif_ctx);
  1433. void hif_vote_link_down(struct hif_opaque_softc *hif_ctx);
  1434. bool hif_can_suspend_link(struct hif_opaque_softc *hif_ctx);
  1435. #ifdef IPA_OFFLOAD
  1436. /**
  1437. * hif_get_ipa_hw_type() - get IPA hw type
  1438. *
  1439. * This API return the IPA hw type.
  1440. *
  1441. * Return: IPA hw type
  1442. */
  1443. static inline
  1444. enum ipa_hw_type hif_get_ipa_hw_type(void)
  1445. {
  1446. return ipa_get_hw_type();
  1447. }
  1448. /**
  1449. * hif_get_ipa_present() - get IPA hw status
  1450. *
  1451. * This API return the IPA hw status.
  1452. *
  1453. * Return: true if IPA is present or false otherwise
  1454. */
  1455. static inline
  1456. bool hif_get_ipa_present(void)
  1457. {
  1458. if (ipa_uc_reg_rdyCB(NULL) != -EPERM)
  1459. return true;
  1460. else
  1461. return false;
  1462. }
  1463. #endif
  1464. int hif_bus_resume(struct hif_opaque_softc *hif_ctx);
  1465. /**
  1466. * hif_bus_ealry_suspend() - stop non wmi tx traffic
  1467. * @context: hif context
  1468. */
  1469. int hif_bus_early_suspend(struct hif_opaque_softc *hif_ctx);
  1470. /**
  1471. * hif_bus_late_resume() - resume non wmi traffic
  1472. * @context: hif context
  1473. */
  1474. int hif_bus_late_resume(struct hif_opaque_softc *hif_ctx);
  1475. int hif_bus_suspend(struct hif_opaque_softc *hif_ctx);
  1476. int hif_bus_resume_noirq(struct hif_opaque_softc *hif_ctx);
  1477. int hif_bus_suspend_noirq(struct hif_opaque_softc *hif_ctx);
  1478. /**
  1479. * hif_apps_irqs_enable() - Enables all irqs from the APPS side
  1480. * @hif_ctx: an opaque HIF handle to use
  1481. *
  1482. * As opposed to the standard hif_irq_enable, this function always applies to
  1483. * the APPS side kernel interrupt handling.
  1484. *
  1485. * Return: errno
  1486. */
  1487. int hif_apps_irqs_enable(struct hif_opaque_softc *hif_ctx);
  1488. /**
  1489. * hif_apps_irqs_disable() - Disables all irqs from the APPS side
  1490. * @hif_ctx: an opaque HIF handle to use
  1491. *
  1492. * As opposed to the standard hif_irq_disable, this function always applies to
  1493. * the APPS side kernel interrupt handling.
  1494. *
  1495. * Return: errno
  1496. */
  1497. int hif_apps_irqs_disable(struct hif_opaque_softc *hif_ctx);
  1498. /**
  1499. * hif_apps_wake_irq_enable() - Enables the wake irq from the APPS side
  1500. * @hif_ctx: an opaque HIF handle to use
  1501. *
  1502. * As opposed to the standard hif_irq_enable, this function always applies to
  1503. * the APPS side kernel interrupt handling.
  1504. *
  1505. * Return: errno
  1506. */
  1507. int hif_apps_wake_irq_enable(struct hif_opaque_softc *hif_ctx);
  1508. /**
  1509. * hif_apps_wake_irq_disable() - Disables the wake irq from the APPS side
  1510. * @hif_ctx: an opaque HIF handle to use
  1511. *
  1512. * As opposed to the standard hif_irq_disable, this function always applies to
  1513. * the APPS side kernel interrupt handling.
  1514. *
  1515. * Return: errno
  1516. */
  1517. int hif_apps_wake_irq_disable(struct hif_opaque_softc *hif_ctx);
  1518. /**
  1519. * hif_apps_enable_irq_wake() - Enables the irq wake from the APPS side
  1520. * @hif_ctx: an opaque HIF handle to use
  1521. *
  1522. * This function always applies to the APPS side kernel interrupt handling
  1523. * to wake the system from suspend.
  1524. *
  1525. * Return: errno
  1526. */
  1527. int hif_apps_enable_irq_wake(struct hif_opaque_softc *hif_ctx);
  1528. /**
  1529. * hif_apps_disable_irq_wake() - Disables the wake irq from the APPS side
  1530. * @hif_ctx: an opaque HIF handle to use
  1531. *
  1532. * This function always applies to the APPS side kernel interrupt handling
  1533. * to disable the wake irq.
  1534. *
  1535. * Return: errno
  1536. */
  1537. int hif_apps_disable_irq_wake(struct hif_opaque_softc *hif_ctx);
  1538. /**
  1539. * hif_apps_enable_irqs_except_wake_irq() - Enables all irqs except wake_irq
  1540. * @hif_ctx: an opaque HIF handle to use
  1541. *
  1542. * As opposed to the standard hif_irq_enable, this function always applies to
  1543. * the APPS side kernel interrupt handling.
  1544. *
  1545. * Return: errno
  1546. */
  1547. int hif_apps_enable_irqs_except_wake_irq(struct hif_opaque_softc *hif_ctx);
  1548. /**
  1549. * hif_apps_disable_irqs_except_wake_irq() - Disables all irqs except wake_irq
  1550. * @hif_ctx: an opaque HIF handle to use
  1551. *
  1552. * As opposed to the standard hif_irq_disable, this function always applies to
  1553. * the APPS side kernel interrupt handling.
  1554. *
  1555. * Return: errno
  1556. */
  1557. int hif_apps_disable_irqs_except_wake_irq(struct hif_opaque_softc *hif_ctx);
  1558. int hif_get_irq_num(struct hif_opaque_softc *scn, int *irq, uint32_t size);
  1559. int hif_dump_registers(struct hif_opaque_softc *scn);
  1560. int ol_copy_ramdump(struct hif_opaque_softc *scn);
  1561. void hif_crash_shutdown(struct hif_opaque_softc *hif_ctx);
  1562. void hif_get_hw_info(struct hif_opaque_softc *hif_ctx, u32 *version,
  1563. u32 *revision, const char **target_name);
  1564. enum qdf_bus_type hif_get_bus_type(struct hif_opaque_softc *hif_hdl);
  1565. struct hif_target_info *hif_get_target_info_handle(struct hif_opaque_softc *
  1566. scn);
  1567. struct hif_config_info *hif_get_ini_handle(struct hif_opaque_softc *hif_ctx);
  1568. struct ramdump_info *hif_get_ramdump_ctx(struct hif_opaque_softc *hif_ctx);
  1569. enum hif_target_status hif_get_target_status(struct hif_opaque_softc *hif_ctx);
  1570. void hif_set_target_status(struct hif_opaque_softc *hif_ctx, enum
  1571. hif_target_status);
  1572. void hif_init_ini_config(struct hif_opaque_softc *hif_ctx,
  1573. struct hif_config_info *cfg);
  1574. void hif_update_tx_ring(struct hif_opaque_softc *osc, u_int32_t num_htt_cmpls);
  1575. qdf_nbuf_t hif_batch_send(struct hif_opaque_softc *osc, qdf_nbuf_t msdu,
  1576. uint32_t transfer_id, u_int32_t len, uint32_t sendhead);
  1577. QDF_STATUS hif_send_single(struct hif_opaque_softc *osc, qdf_nbuf_t msdu,
  1578. uint32_t transfer_id, u_int32_t len);
  1579. int hif_send_fast(struct hif_opaque_softc *osc, qdf_nbuf_t nbuf,
  1580. uint32_t transfer_id, uint32_t download_len);
  1581. void hif_pkt_dl_len_set(void *hif_sc, unsigned int pkt_download_len);
  1582. void hif_ce_war_disable(void);
  1583. void hif_ce_war_enable(void);
  1584. void hif_disable_interrupt(struct hif_opaque_softc *osc, uint32_t pipe_num);
  1585. #ifdef QCA_NSS_WIFI_OFFLOAD_SUPPORT
  1586. struct hif_pipe_addl_info *hif_get_addl_pipe_info(struct hif_opaque_softc *osc,
  1587. struct hif_pipe_addl_info *hif_info, uint32_t pipe_number);
  1588. uint32_t hif_set_nss_wifiol_mode(struct hif_opaque_softc *osc,
  1589. uint32_t pipe_num);
  1590. int32_t hif_get_nss_wifiol_bypass_nw_process(struct hif_opaque_softc *osc);
  1591. #endif /* QCA_NSS_WIFI_OFFLOAD_SUPPORT */
  1592. void hif_set_bundle_mode(struct hif_opaque_softc *hif_ctx, bool enabled,
  1593. int rx_bundle_cnt);
  1594. int hif_bus_reset_resume(struct hif_opaque_softc *hif_ctx);
  1595. void hif_set_attribute(struct hif_opaque_softc *osc, uint8_t hif_attrib);
  1596. void *hif_get_lro_info(int ctx_id, struct hif_opaque_softc *hif_hdl);
  1597. enum hif_exec_type {
  1598. HIF_EXEC_NAPI_TYPE,
  1599. HIF_EXEC_TASKLET_TYPE,
  1600. };
  1601. typedef uint32_t (*ext_intr_handler)(void *, uint32_t);
  1602. /**
  1603. * hif_get_int_ctx_irq_num() - retrieve an irq num for an interrupt context id
  1604. * @softc: hif opaque context owning the exec context
  1605. * @id: the id of the interrupt context
  1606. *
  1607. * Return: IRQ number of the first (zero'th) IRQ within the interrupt context ID
  1608. * 'id' registered with the OS
  1609. */
  1610. int32_t hif_get_int_ctx_irq_num(struct hif_opaque_softc *softc,
  1611. uint8_t id);
  1612. /**
  1613. * hif_configure_ext_group_interrupts() - Congigure ext group intrrupts
  1614. * @hif_ctx: hif opaque context
  1615. *
  1616. * Return: QDF_STATUS
  1617. */
  1618. QDF_STATUS hif_configure_ext_group_interrupts(struct hif_opaque_softc *hif_ctx);
  1619. /**
  1620. * hif_deconfigure_ext_group_interrupts() - Deconfigure ext group intrrupts
  1621. * @hif_ctx: hif opaque context
  1622. *
  1623. * Return: None
  1624. */
  1625. void hif_deconfigure_ext_group_interrupts(struct hif_opaque_softc *hif_ctx);
  1626. /**
  1627. * hif_register_ext_group() - API to register external group
  1628. * interrupt handler.
  1629. * @hif_ctx : HIF Context
  1630. * @numirq: number of irq's in the group
  1631. * @irq: array of irq values
  1632. * @handler: callback interrupt handler function
  1633. * @cb_ctx: context to passed in callback
  1634. * @type: napi vs tasklet
  1635. *
  1636. * Return: QDF_STATUS
  1637. */
  1638. QDF_STATUS hif_register_ext_group(struct hif_opaque_softc *hif_ctx,
  1639. uint32_t numirq, uint32_t irq[],
  1640. ext_intr_handler handler,
  1641. void *cb_ctx, const char *context_name,
  1642. enum hif_exec_type type, uint32_t scale);
  1643. void hif_deregister_exec_group(struct hif_opaque_softc *hif_ctx,
  1644. const char *context_name);
  1645. void hif_update_pipe_callback(struct hif_opaque_softc *osc,
  1646. u_int8_t pipeid,
  1647. struct hif_msg_callbacks *callbacks);
  1648. /**
  1649. * hif_print_napi_stats() - Display HIF NAPI stats
  1650. * @hif_ctx - HIF opaque context
  1651. *
  1652. * Return: None
  1653. */
  1654. void hif_print_napi_stats(struct hif_opaque_softc *hif_ctx);
  1655. /* hif_clear_napi_stats() - function clears the stats of the
  1656. * latency when called.
  1657. * @hif_ctx - the HIF context to assign the callback to
  1658. *
  1659. * Return: None
  1660. */
  1661. void hif_clear_napi_stats(struct hif_opaque_softc *hif_ctx);
  1662. #ifdef __cplusplus
  1663. }
  1664. #endif
  1665. #ifdef FORCE_WAKE
  1666. /**
  1667. * hif_force_wake_request() - Function to wake from power collapse
  1668. * @handle: HIF opaque handle
  1669. *
  1670. * Description: API to check if the device is awake or not before
  1671. * read/write to BAR + 4K registers. If device is awake return
  1672. * success otherwise write '1' to
  1673. * PCIE_PCIE_LOCAL_REG_PCIE_SOC_WAKE_PCIE_LOCAL_REG which will interrupt
  1674. * the device and does wakeup the PCI and MHI within 50ms
  1675. * and then the device writes a value to
  1676. * PCIE_SOC_PCIE_REG_PCIE_SCRATCH_0_SOC_PCIE_REG to complete the
  1677. * handshake process to let the host know the device is awake.
  1678. *
  1679. * Return: zero - success/non-zero - failure
  1680. */
  1681. int hif_force_wake_request(struct hif_opaque_softc *handle);
  1682. /**
  1683. * hif_force_wake_release() - API to release/reset the SOC wake register
  1684. * from interrupting the device.
  1685. * @handle: HIF opaque handle
  1686. *
  1687. * Description: API to set the
  1688. * PCIE_PCIE_LOCAL_REG_PCIE_SOC_WAKE_PCIE_LOCAL_REG to '0'
  1689. * to release the interrupt line.
  1690. *
  1691. * Return: zero - success/non-zero - failure
  1692. */
  1693. int hif_force_wake_release(struct hif_opaque_softc *handle);
  1694. #else
  1695. static inline
  1696. int hif_force_wake_request(struct hif_opaque_softc *handle)
  1697. {
  1698. return 0;
  1699. }
  1700. static inline
  1701. int hif_force_wake_release(struct hif_opaque_softc *handle)
  1702. {
  1703. return 0;
  1704. }
  1705. #endif /* FORCE_WAKE */
  1706. #ifdef FEATURE_HAL_DELAYED_REG_WRITE
  1707. /**
  1708. * hif_prevent_link_low_power_states() - Prevent from going to low power states
  1709. * @hif - HIF opaque context
  1710. *
  1711. * Return: 0 on success. Error code on failure.
  1712. */
  1713. int hif_prevent_link_low_power_states(struct hif_opaque_softc *hif);
  1714. /**
  1715. * hif_allow_link_low_power_states() - Allow link to go to low power states
  1716. * @hif - HIF opaque context
  1717. *
  1718. * Return: None
  1719. */
  1720. void hif_allow_link_low_power_states(struct hif_opaque_softc *hif);
  1721. #else
  1722. static inline
  1723. int hif_prevent_link_low_power_states(struct hif_opaque_softc *hif)
  1724. {
  1725. return 0;
  1726. }
  1727. static inline
  1728. void hif_allow_link_low_power_states(struct hif_opaque_softc *hif)
  1729. {
  1730. }
  1731. #endif
  1732. void *hif_get_dev_ba(struct hif_opaque_softc *hif_handle);
  1733. void *hif_get_dev_ba_ce(struct hif_opaque_softc *hif_handle);
  1734. /**
  1735. * hif_set_initial_wakeup_cb() - set the initial wakeup event handler function
  1736. * @hif_ctx - the HIF context to assign the callback to
  1737. * @callback - the callback to assign
  1738. * @priv - the private data to pass to the callback when invoked
  1739. *
  1740. * Return: None
  1741. */
  1742. void hif_set_initial_wakeup_cb(struct hif_opaque_softc *hif_ctx,
  1743. void (*callback)(void *),
  1744. void *priv);
  1745. /*
  1746. * Note: For MCL, #if defined (HIF_CONFIG_SLUB_DEBUG_ON) needs to be checked
  1747. * for defined here
  1748. */
  1749. #if defined(HIF_CONFIG_SLUB_DEBUG_ON) || defined(HIF_CE_DEBUG_DATA_BUF)
  1750. ssize_t hif_dump_desc_trace_buf(struct device *dev,
  1751. struct device_attribute *attr, char *buf);
  1752. ssize_t hif_input_desc_trace_buf_index(struct hif_softc *scn,
  1753. const char *buf, size_t size);
  1754. ssize_t hif_ce_en_desc_hist(struct hif_softc *scn,
  1755. const char *buf, size_t size);
  1756. ssize_t hif_disp_ce_enable_desc_data_hist(struct hif_softc *scn, char *buf);
  1757. ssize_t hif_dump_desc_event(struct hif_softc *scn, char *buf);
  1758. #endif/*#if defined(HIF_CONFIG_SLUB_DEBUG_ON)||defined(HIF_CE_DEBUG_DATA_BUF)*/
  1759. /**
  1760. * hif_set_ce_service_max_yield_time() - sets CE service max yield time
  1761. * @hif: hif context
  1762. * @ce_service_max_yield_time: CE service max yield time to set
  1763. *
  1764. * This API storess CE service max yield time in hif context based
  1765. * on ini value.
  1766. *
  1767. * Return: void
  1768. */
  1769. void hif_set_ce_service_max_yield_time(struct hif_opaque_softc *hif,
  1770. uint32_t ce_service_max_yield_time);
  1771. /**
  1772. * hif_get_ce_service_max_yield_time() - get CE service max yield time
  1773. * @hif: hif context
  1774. *
  1775. * This API returns CE service max yield time.
  1776. *
  1777. * Return: CE service max yield time
  1778. */
  1779. unsigned long long
  1780. hif_get_ce_service_max_yield_time(struct hif_opaque_softc *hif);
  1781. /**
  1782. * hif_set_ce_service_max_rx_ind_flush() - sets CE service max rx ind flush
  1783. * @hif: hif context
  1784. * @ce_service_max_rx_ind_flush: CE service max rx ind flush to set
  1785. *
  1786. * This API stores CE service max rx ind flush in hif context based
  1787. * on ini value.
  1788. *
  1789. * Return: void
  1790. */
  1791. void hif_set_ce_service_max_rx_ind_flush(struct hif_opaque_softc *hif,
  1792. uint8_t ce_service_max_rx_ind_flush);
  1793. #ifdef OL_ATH_SMART_LOGGING
  1794. /*
  1795. * hif_log_ce_dump() - Copy all the CE DEST ring to buf
  1796. * @scn : HIF handler
  1797. * @buf_cur: Current pointer in ring buffer
  1798. * @buf_init:Start of the ring buffer
  1799. * @buf_sz: Size of the ring buffer
  1800. * @ce: Copy Engine id
  1801. * @skb_sz: Max size of the SKB buffer to be copied
  1802. *
  1803. * Calls the respective function to dump all the CE SRC/DEST ring descriptors
  1804. * and buffers pointed by them in to the given buf
  1805. *
  1806. * Return: Current pointer in ring buffer
  1807. */
  1808. uint8_t *hif_log_dump_ce(struct hif_softc *scn, uint8_t *buf_cur,
  1809. uint8_t *buf_init, uint32_t buf_sz,
  1810. uint32_t ce, uint32_t skb_sz);
  1811. #endif /* OL_ATH_SMART_LOGGING */
  1812. /*
  1813. * hif_softc_to_hif_opaque_softc - API to convert hif_softc handle
  1814. * to hif_opaque_softc handle
  1815. * @hif_handle - hif_softc type
  1816. *
  1817. * Return: hif_opaque_softc type
  1818. */
  1819. static inline struct hif_opaque_softc *
  1820. hif_softc_to_hif_opaque_softc(struct hif_softc *hif_handle)
  1821. {
  1822. return (struct hif_opaque_softc *)hif_handle;
  1823. }
  1824. #if defined(HIF_IPCI) && defined(FEATURE_HAL_DELAYED_REG_WRITE)
  1825. QDF_STATUS hif_try_prevent_ep_vote_access(struct hif_opaque_softc *hif_ctx);
  1826. void hif_set_ep_intermediate_vote_access(struct hif_opaque_softc *hif_ctx);
  1827. void hif_allow_ep_vote_access(struct hif_opaque_softc *hif_ctx);
  1828. void hif_set_ep_vote_access(struct hif_opaque_softc *hif_ctx,
  1829. uint8_t type, uint8_t access);
  1830. uint8_t hif_get_ep_vote_access(struct hif_opaque_softc *hif_ctx,
  1831. uint8_t type);
  1832. #else
  1833. static inline QDF_STATUS
  1834. hif_try_prevent_ep_vote_access(struct hif_opaque_softc *hif_ctx)
  1835. {
  1836. return QDF_STATUS_SUCCESS;
  1837. }
  1838. static inline void
  1839. hif_set_ep_intermediate_vote_access(struct hif_opaque_softc *hif_ctx)
  1840. {
  1841. }
  1842. static inline void
  1843. hif_allow_ep_vote_access(struct hif_opaque_softc *hif_ctx)
  1844. {
  1845. }
  1846. static inline void
  1847. hif_set_ep_vote_access(struct hif_opaque_softc *hif_ctx,
  1848. uint8_t type, uint8_t access)
  1849. {
  1850. }
  1851. static inline uint8_t
  1852. hif_get_ep_vote_access(struct hif_opaque_softc *hif_ctx,
  1853. uint8_t type)
  1854. {
  1855. return HIF_EP_VOTE_ACCESS_ENABLE;
  1856. }
  1857. #endif
  1858. #ifdef FORCE_WAKE
  1859. /**
  1860. * hif_srng_init_phase(): Indicate srng initialization phase
  1861. * to avoid force wake as UMAC power collapse is not yet
  1862. * enabled
  1863. * @hif_ctx: hif opaque handle
  1864. * @init_phase: initialization phase
  1865. *
  1866. * Return: None
  1867. */
  1868. void hif_srng_init_phase(struct hif_opaque_softc *hif_ctx,
  1869. bool init_phase);
  1870. #else
  1871. static inline
  1872. void hif_srng_init_phase(struct hif_opaque_softc *hif_ctx,
  1873. bool init_phase)
  1874. {
  1875. }
  1876. #endif /* FORCE_WAKE */
  1877. #ifdef HIF_IPCI
  1878. /**
  1879. * hif_shutdown_notifier_cb - Call back for shutdown notifier
  1880. * @ctx: hif handle
  1881. *
  1882. * Return: None
  1883. */
  1884. void hif_shutdown_notifier_cb(void *ctx);
  1885. #else
  1886. static inline
  1887. void hif_shutdown_notifier_cb(void *ctx)
  1888. {
  1889. }
  1890. #endif /* HIF_IPCI */
  1891. #ifdef HIF_CE_LOG_INFO
  1892. /**
  1893. * hif_log_ce_info() - API to log ce info
  1894. * @scn: hif handle
  1895. * @data: hang event data buffer
  1896. * @offset: offset at which data needs to be written
  1897. *
  1898. * Return: None
  1899. */
  1900. void hif_log_ce_info(struct hif_softc *scn, uint8_t *data,
  1901. unsigned int *offset);
  1902. #else
  1903. static inline
  1904. void hif_log_ce_info(struct hif_softc *scn, uint8_t *data,
  1905. unsigned int *offset)
  1906. {
  1907. }
  1908. #endif
  1909. #ifdef HIF_CPU_PERF_AFFINE_MASK
  1910. /**
  1911. * hif_config_irq_set_perf_affinity_hint() - API to set affinity
  1912. * @hif_ctx: hif opaque handle
  1913. *
  1914. * This function is used to move the WLAN IRQs to perf cores in
  1915. * case of defconfig builds.
  1916. *
  1917. * Return: None
  1918. */
  1919. void hif_config_irq_set_perf_affinity_hint(
  1920. struct hif_opaque_softc *hif_ctx);
  1921. #else
  1922. static inline void hif_config_irq_set_perf_affinity_hint(
  1923. struct hif_opaque_softc *hif_ctx)
  1924. {
  1925. }
  1926. #endif
  1927. /**
  1928. * hif_apps_grp_irqs_enable() - enable ext grp irqs
  1929. * @hif - HIF opaque context
  1930. *
  1931. * Return: 0 on success. Error code on failure.
  1932. */
  1933. int hif_apps_grp_irqs_enable(struct hif_opaque_softc *hif_ctx);
  1934. /**
  1935. * hif_apps_grp_irqs_disable() - disable ext grp irqs
  1936. * @hif - HIF opaque context
  1937. *
  1938. * Return: 0 on success. Error code on failure.
  1939. */
  1940. int hif_apps_grp_irqs_disable(struct hif_opaque_softc *hif_ctx);
  1941. /**
  1942. * hif_disable_grp_irqs() - disable ext grp irqs
  1943. * @hif - HIF opaque context
  1944. *
  1945. * Return: 0 on success. Error code on failure.
  1946. */
  1947. int hif_disable_grp_irqs(struct hif_opaque_softc *scn);
  1948. /**
  1949. * hif_enable_grp_irqs() - enable ext grp irqs
  1950. * @hif - HIF opaque context
  1951. *
  1952. * Return: 0 on success. Error code on failure.
  1953. */
  1954. int hif_enable_grp_irqs(struct hif_opaque_softc *scn);
  1955. enum hif_credit_exchange_type {
  1956. HIF_REQUEST_CREDIT,
  1957. HIF_PROCESS_CREDIT_REPORT,
  1958. };
  1959. enum hif_detect_latency_type {
  1960. HIF_DETECT_TASKLET,
  1961. HIF_DETECT_CREDIT,
  1962. HIF_DETECT_UNKNOWN
  1963. };
  1964. #ifdef HIF_DETECTION_LATENCY_ENABLE
  1965. void hif_latency_detect_credit_record_time(
  1966. enum hif_credit_exchange_type type,
  1967. struct hif_opaque_softc *hif_ctx);
  1968. void hif_latency_detect_timer_start(struct hif_opaque_softc *hif_ctx);
  1969. void hif_latency_detect_timer_stop(struct hif_opaque_softc *hif_ctx);
  1970. void hif_tasklet_latency(struct hif_softc *scn, bool from_timer);
  1971. void hif_credit_latency(struct hif_softc *scn, bool from_timer);
  1972. void hif_check_detection_latency(struct hif_softc *scn,
  1973. bool from_timer,
  1974. uint32_t bitmap_type);
  1975. void hif_set_enable_detection(struct hif_opaque_softc *hif_ctx, bool value);
  1976. #else
  1977. static inline
  1978. void hif_latency_detect_timer_start(struct hif_opaque_softc *hif_ctx)
  1979. {}
  1980. static inline
  1981. void hif_latency_detect_timer_stop(struct hif_opaque_softc *hif_ctx)
  1982. {}
  1983. static inline
  1984. void hif_latency_detect_credit_record_time(
  1985. enum hif_credit_exchange_type type,
  1986. struct hif_opaque_softc *hif_ctx)
  1987. {}
  1988. static inline
  1989. void hif_check_detection_latency(struct hif_softc *scn,
  1990. bool from_timer,
  1991. uint32_t bitmap_type)
  1992. {}
  1993. static inline
  1994. void hif_set_enable_detection(struct hif_opaque_softc *hif_ctx, bool value)
  1995. {}
  1996. #endif
  1997. #ifdef SYSTEM_PM_CHECK
  1998. /**
  1999. * __hif_system_pm_set_state() - Set system pm state
  2000. * @hif: hif opaque handle
  2001. * @state: system state
  2002. *
  2003. * Return: None
  2004. */
  2005. void __hif_system_pm_set_state(struct hif_opaque_softc *hif,
  2006. enum hif_system_pm_state state);
  2007. /**
  2008. * hif_system_pm_set_state_on() - Set system pm state to ON
  2009. * @hif: hif opaque handle
  2010. *
  2011. * Return: None
  2012. */
  2013. static inline
  2014. void hif_system_pm_set_state_on(struct hif_opaque_softc *hif)
  2015. {
  2016. __hif_system_pm_set_state(hif, HIF_SYSTEM_PM_STATE_ON);
  2017. }
  2018. /**
  2019. * hif_system_pm_set_state_resuming() - Set system pm state to resuming
  2020. * @hif: hif opaque handle
  2021. *
  2022. * Return: None
  2023. */
  2024. static inline
  2025. void hif_system_pm_set_state_resuming(struct hif_opaque_softc *hif)
  2026. {
  2027. __hif_system_pm_set_state(hif, HIF_SYSTEM_PM_STATE_BUS_RESUMING);
  2028. }
  2029. /**
  2030. * hif_system_pm_set_state_suspending() - Set system pm state to suspending
  2031. * @hif: hif opaque handle
  2032. *
  2033. * Return: None
  2034. */
  2035. static inline
  2036. void hif_system_pm_set_state_suspending(struct hif_opaque_softc *hif)
  2037. {
  2038. __hif_system_pm_set_state(hif, HIF_SYSTEM_PM_STATE_BUS_SUSPENDING);
  2039. }
  2040. /**
  2041. * hif_system_pm_set_state_suspended() - Set system pm state to suspended
  2042. * @hif: hif opaque handle
  2043. *
  2044. * Return: None
  2045. */
  2046. static inline
  2047. void hif_system_pm_set_state_suspended(struct hif_opaque_softc *hif)
  2048. {
  2049. __hif_system_pm_set_state(hif, HIF_SYSTEM_PM_STATE_BUS_SUSPENDED);
  2050. }
  2051. /**
  2052. * hif_system_pm_get_state() - Get system pm state
  2053. * @hif: hif opaque handle
  2054. *
  2055. * Return: system state
  2056. */
  2057. int32_t hif_system_pm_get_state(struct hif_opaque_softc *hif);
  2058. /**
  2059. * hif_system_pm_state_check() - Check system state and trigger resume
  2060. * if required
  2061. * @hif: hif opaque handle
  2062. *
  2063. * Return: 0 if system is in on state else error code
  2064. */
  2065. int hif_system_pm_state_check(struct hif_opaque_softc *hif);
  2066. #else
  2067. static inline
  2068. void __hif_system_pm_set_state(struct hif_opaque_softc *hif,
  2069. enum hif_system_pm_state state)
  2070. {
  2071. }
  2072. static inline
  2073. void hif_system_pm_set_state_on(struct hif_opaque_softc *hif)
  2074. {
  2075. }
  2076. static inline
  2077. void hif_system_pm_set_state_resuming(struct hif_opaque_softc *hif)
  2078. {
  2079. }
  2080. static inline
  2081. void hif_system_pm_set_state_suspending(struct hif_opaque_softc *hif)
  2082. {
  2083. }
  2084. static inline
  2085. void hif_system_pm_set_state_suspended(struct hif_opaque_softc *hif)
  2086. {
  2087. }
  2088. static inline
  2089. int32_t hif_system_pm_get_state(struct hif_opaque_softc *hif)
  2090. {
  2091. return 0;
  2092. }
  2093. static inline int hif_system_pm_state_check(struct hif_opaque_softc *hif)
  2094. {
  2095. return 0;
  2096. }
  2097. #endif
  2098. #ifdef FEATURE_IRQ_AFFINITY
  2099. /**
  2100. * hif_set_grp_intr_affinity() - API to set affinity for grp
  2101. * intrs set in the bitmap
  2102. * @scn: hif handle
  2103. * @grp_intr_bitmask: grp intrs for which perf affinity should be
  2104. * applied
  2105. * @perf: affine to perf or non-perf cluster
  2106. *
  2107. * Return: None
  2108. */
  2109. void hif_set_grp_intr_affinity(struct hif_opaque_softc *scn,
  2110. uint32_t grp_intr_bitmask, bool perf);
  2111. #else
  2112. static inline
  2113. void hif_set_grp_intr_affinity(struct hif_opaque_softc *scn,
  2114. uint32_t grp_intr_bitmask, bool perf)
  2115. {
  2116. }
  2117. #endif
  2118. /**
  2119. * hif_get_max_wmi_ep() - Get max WMI EPs configured in target svc map
  2120. * @hif_ctx: hif opaque handle
  2121. *
  2122. * Description:
  2123. * Gets number of WMI EPs configured in target svc map. Since EP map
  2124. * include IN and OUT direction pipes, count only OUT pipes to get EPs
  2125. * configured for WMI service.
  2126. *
  2127. * Return:
  2128. * uint8_t: count for WMI eps in target svc map
  2129. */
  2130. uint8_t hif_get_max_wmi_ep(struct hif_opaque_softc *scn);
  2131. #ifdef DP_UMAC_HW_RESET_SUPPORT
  2132. /**
  2133. * hif_register_umac_reset_handler() - Register UMAC HW reset handler
  2134. * @hif_scn: hif opaque handle
  2135. * @handler: callback handler function
  2136. * @cb_ctx: context to passed to @handler
  2137. * @irq: irq number to be used for UMAC HW reset interrupt
  2138. *
  2139. * Return: QDF_STATUS of operation
  2140. */
  2141. QDF_STATUS hif_register_umac_reset_handler(struct hif_opaque_softc *hif_scn,
  2142. int (*handler)(void *cb_ctx),
  2143. void *cb_ctx, int irq);
  2144. /**
  2145. * hif_unregister_umac_reset_handler() - Unregister UMAC HW reset handler
  2146. * @hif_scn: hif opaque handle
  2147. *
  2148. * Return: QDF_STATUS of operation
  2149. */
  2150. QDF_STATUS hif_unregister_umac_reset_handler(struct hif_opaque_softc *hif_scn);
  2151. #else
  2152. static inline
  2153. QDF_STATUS hif_register_umac_reset_handler(struct hif_opaque_softc *hif_scn,
  2154. int (*handler)(void *cb_ctx),
  2155. void *cb_ctx, int irq)
  2156. {
  2157. return QDF_STATUS_SUCCESS;
  2158. }
  2159. static inline
  2160. QDF_STATUS hif_unregister_umac_reset_handler(struct hif_opaque_softc *hif_scn)
  2161. {
  2162. return QDF_STATUS_SUCCESS;
  2163. }
  2164. #endif /* DP_UMAC_HW_RESET_SUPPORT */
  2165. #endif /* _HIF_H_ */