hif.h 67 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401
  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_allow_suspend() - Allow Runtime suspend
  1219. * @data: runtime PM lock
  1220. *
  1221. * This function will allow runtime suspend, by decrementing
  1222. * device's usage count.
  1223. *
  1224. * Return: status
  1225. */
  1226. int hif_pm_runtime_allow_suspend(struct hif_pm_runtime_lock *data);
  1227. /**
  1228. * hif_rtpm_request_resume() - Request resume if bus is suspended
  1229. *
  1230. * Return: None
  1231. */
  1232. void hif_rtpm_request_resume(void);
  1233. /**
  1234. * hif_rtpm_sync_resume() - Invoke synchronous runtime resume.
  1235. *
  1236. * This function will invoke synchronous runtime resume.
  1237. *
  1238. * Return: status
  1239. */
  1240. QDF_STATUS hif_rtpm_sync_resume(void);
  1241. /**
  1242. * hif_rtpm_check_and_request_resume() - check if bus is suspended and
  1243. * request resume.
  1244. *
  1245. * Return: void
  1246. */
  1247. void hif_rtpm_check_and_request_resume(void);
  1248. /**
  1249. * hif_rtpm_set_client_job() - Set job for the client.
  1250. * @client_id: Client id for which job needs to be set
  1251. *
  1252. * If get failed due to system being in suspended state, set the client job so
  1253. * when system resumes the client's job is called.
  1254. *
  1255. * Return: None
  1256. */
  1257. void hif_rtpm_set_client_job(uint32_t client_id);
  1258. /**
  1259. * hif_rtpm_mark_last_busy() - Mark last busy to delay retry to suspend
  1260. * @id: ID marking last busy
  1261. *
  1262. * Return: None
  1263. */
  1264. void hif_rtpm_mark_last_busy(uint32_t id);
  1265. /**
  1266. * hif_rtpm_get_monitor_wake_intr() - API to get monitor_wake_intr
  1267. *
  1268. * monitor_wake_intr variable can be used to indicate if driver expects wake
  1269. * MSI for runtime PM
  1270. *
  1271. * Return: monitor_wake_intr variable
  1272. */
  1273. int hif_rtpm_get_monitor_wake_intr(void);
  1274. /**
  1275. * hif_rtpm_set_monitor_wake_intr() - API to set monitor_wake_intr
  1276. * @val: value to set
  1277. *
  1278. * monitor_wake_intr variable can be used to indicate if driver expects wake
  1279. * MSI for runtime PM
  1280. *
  1281. * Return: void
  1282. */
  1283. void hif_rtpm_set_monitor_wake_intr(int val);
  1284. /**
  1285. * hif_pre_runtime_suspend() - book keeping before beginning runtime suspend.
  1286. * @hif_ctx: HIF context
  1287. *
  1288. * Makes sure that the pci link will be taken down by the suspend opperation.
  1289. * If the hif layer is configured to leave the bus on, runtime suspend will
  1290. * not save any power.
  1291. *
  1292. * Set the runtime suspend state to SUSPENDING.
  1293. *
  1294. * return -EINVAL if the bus won't go down. otherwise return 0
  1295. */
  1296. int hif_pre_runtime_suspend(struct hif_opaque_softc *hif_ctx);
  1297. /**
  1298. * hif_pre_runtime_resume() - bookkeeping before beginning runtime resume
  1299. *
  1300. * update the runtime pm state to RESUMING.
  1301. * Return: void
  1302. */
  1303. void hif_pre_runtime_resume(void);
  1304. /**
  1305. * hif_process_runtime_suspend_success() - bookkeeping of suspend success
  1306. *
  1307. * Record the success.
  1308. * update the runtime_pm state to SUSPENDED
  1309. * Return: void
  1310. */
  1311. void hif_process_runtime_suspend_success(void);
  1312. /**
  1313. * hif_process_runtime_suspend_failure() - bookkeeping of suspend failure
  1314. *
  1315. * Record the failure.
  1316. * mark last busy to delay a retry.
  1317. * update the runtime_pm state back to ON
  1318. *
  1319. * Return: void
  1320. */
  1321. void hif_process_runtime_suspend_failure(void);
  1322. /**
  1323. * hif_process_runtime_suspend_failure() - bookkeeping of resuming link up
  1324. *
  1325. * update the runtime_pm state to RESUMING_LINKUP
  1326. * Return: void
  1327. */
  1328. void hif_process_runtime_resume_linkup(void);
  1329. /**
  1330. * hif_process_runtime_resume_success() - bookkeeping after a runtime resume
  1331. *
  1332. * record the success.
  1333. * update the runtime_pm state to SUSPENDED
  1334. * Return: void
  1335. */
  1336. void hif_process_runtime_resume_success(void);
  1337. /**
  1338. * hif_rtpm_print_prevent_list() - list the clients preventing suspend.
  1339. *
  1340. * Return: None
  1341. */
  1342. void hif_rtpm_print_prevent_list(void);
  1343. /**
  1344. * hif_rtpm_suspend_lock() - spin_lock on marking runtime suspend
  1345. *
  1346. * Return: void
  1347. */
  1348. void hif_rtpm_suspend_lock(void);
  1349. /**
  1350. * hif_rtpm_suspend_unlock() - spin_unlock on marking runtime suspend
  1351. *
  1352. * Return: void
  1353. */
  1354. void hif_rtpm_suspend_unlock(void);
  1355. /**
  1356. * hif_runtime_suspend() - do the bus suspend part of a runtime suspend
  1357. * @hif_ctx: HIF context
  1358. *
  1359. * Return: 0 for success and non-zero error code for failure
  1360. */
  1361. int hif_runtime_suspend(struct hif_opaque_softc *hif_ctx);
  1362. /**
  1363. * hif_runtime_resume() - do the bus resume part of a runtime resume
  1364. * @hif_ctx: HIF context
  1365. *
  1366. * Return: 0 for success and non-zero error code for failure
  1367. */
  1368. int hif_runtime_resume(struct hif_opaque_softc *hif_ctx);
  1369. /**
  1370. * hif_fastpath_resume() - resume fastpath for runtimepm
  1371. * @hif_ctx: HIF context
  1372. *
  1373. * ensure that the fastpath write index register is up to date
  1374. * since runtime pm may cause ce_send_fast to skip the register
  1375. * write.
  1376. *
  1377. * fastpath only applicable to legacy copy engine
  1378. */
  1379. void hif_fastpath_resume(struct hif_opaque_softc *hif_ctx);
  1380. #else
  1381. static inline
  1382. QDF_STATUS hif_rtpm_register(uint32_t id, void (*hif_rpm_cbk)(void))
  1383. { return QDF_STATUS_SUCCESS; }
  1384. static inline
  1385. QDF_STATUS hif_rtpm_deregister(uint32_t id)
  1386. { return QDF_STATUS_SUCCESS; }
  1387. static inline
  1388. int hif_runtime_lock_init(qdf_runtime_lock_t *lock, const char *name)
  1389. { return 0; }
  1390. static inline
  1391. void hif_runtime_lock_deinit(struct hif_pm_runtime_lock *data)
  1392. {}
  1393. static inline
  1394. int hif_rtpm_get(uint8_t type, uint32_t id)
  1395. { return QDF_STATUS_SUCCESS; }
  1396. static inline
  1397. QDF_STATUS hif_rtpm_put(uint8_t type, uint32_t id)
  1398. { return QDF_STATUS_SUCCESS; }
  1399. static inline
  1400. int hif_pm_runtime_allow_suspend(struct hif_pm_runtime_lock *data)
  1401. { return 0; }
  1402. static inline
  1403. int hif_pm_runtime_prevent_suspend(struct hif_pm_runtime_lock *data)
  1404. { return 0; }
  1405. static inline
  1406. QDF_STATUS hif_rtpm_sync_resume(void)
  1407. { return QDF_STATUS_SUCCESS; }
  1408. static inline
  1409. void hif_rtpm_request_resume(void)
  1410. {}
  1411. static inline
  1412. void hif_rtpm_check_and_request_resume(void)
  1413. {}
  1414. static inline
  1415. void hif_rtpm_set_client_job(uint32_t client_id)
  1416. {}
  1417. static inline
  1418. void hif_rtpm_print_prevent_list(void)
  1419. {}
  1420. static inline
  1421. void hif_rtpm_suspend_unlock(void)
  1422. {}
  1423. static inline
  1424. void hif_rtpm_suspend_lock(void)
  1425. {}
  1426. static inline
  1427. int hif_rtpm_get_monitor_wake_intr(void)
  1428. { return 0; }
  1429. static inline
  1430. void hif_rtpm_set_monitor_wake_intr(int val)
  1431. {}
  1432. static inline
  1433. void hif_rtpm_mark_last_busy(uint32_t id)
  1434. {}
  1435. #endif
  1436. void hif_enable_power_management(struct hif_opaque_softc *hif_ctx,
  1437. bool is_packet_log_enabled);
  1438. void hif_disable_power_management(struct hif_opaque_softc *hif_ctx);
  1439. void hif_vote_link_up(struct hif_opaque_softc *hif_ctx);
  1440. void hif_vote_link_down(struct hif_opaque_softc *hif_ctx);
  1441. bool hif_can_suspend_link(struct hif_opaque_softc *hif_ctx);
  1442. #ifdef IPA_OFFLOAD
  1443. /**
  1444. * hif_get_ipa_hw_type() - get IPA hw type
  1445. *
  1446. * This API return the IPA hw type.
  1447. *
  1448. * Return: IPA hw type
  1449. */
  1450. static inline
  1451. enum ipa_hw_type hif_get_ipa_hw_type(void)
  1452. {
  1453. return ipa_get_hw_type();
  1454. }
  1455. /**
  1456. * hif_get_ipa_present() - get IPA hw status
  1457. *
  1458. * This API return the IPA hw status.
  1459. *
  1460. * Return: true if IPA is present or false otherwise
  1461. */
  1462. static inline
  1463. bool hif_get_ipa_present(void)
  1464. {
  1465. if (ipa_uc_reg_rdyCB(NULL) != -EPERM)
  1466. return true;
  1467. else
  1468. return false;
  1469. }
  1470. #endif
  1471. int hif_bus_resume(struct hif_opaque_softc *hif_ctx);
  1472. /**
  1473. * hif_bus_ealry_suspend() - stop non wmi tx traffic
  1474. * @context: hif context
  1475. */
  1476. int hif_bus_early_suspend(struct hif_opaque_softc *hif_ctx);
  1477. /**
  1478. * hif_bus_late_resume() - resume non wmi traffic
  1479. * @context: hif context
  1480. */
  1481. int hif_bus_late_resume(struct hif_opaque_softc *hif_ctx);
  1482. int hif_bus_suspend(struct hif_opaque_softc *hif_ctx);
  1483. int hif_bus_resume_noirq(struct hif_opaque_softc *hif_ctx);
  1484. int hif_bus_suspend_noirq(struct hif_opaque_softc *hif_ctx);
  1485. /**
  1486. * hif_apps_irqs_enable() - Enables all irqs from the APPS side
  1487. * @hif_ctx: an opaque HIF handle to use
  1488. *
  1489. * As opposed to the standard hif_irq_enable, this function always applies to
  1490. * the APPS side kernel interrupt handling.
  1491. *
  1492. * Return: errno
  1493. */
  1494. int hif_apps_irqs_enable(struct hif_opaque_softc *hif_ctx);
  1495. /**
  1496. * hif_apps_irqs_disable() - Disables all irqs from the APPS side
  1497. * @hif_ctx: an opaque HIF handle to use
  1498. *
  1499. * As opposed to the standard hif_irq_disable, this function always applies to
  1500. * the APPS side kernel interrupt handling.
  1501. *
  1502. * Return: errno
  1503. */
  1504. int hif_apps_irqs_disable(struct hif_opaque_softc *hif_ctx);
  1505. /**
  1506. * hif_apps_wake_irq_enable() - Enables the wake irq from the APPS side
  1507. * @hif_ctx: an opaque HIF handle to use
  1508. *
  1509. * As opposed to the standard hif_irq_enable, this function always applies to
  1510. * the APPS side kernel interrupt handling.
  1511. *
  1512. * Return: errno
  1513. */
  1514. int hif_apps_wake_irq_enable(struct hif_opaque_softc *hif_ctx);
  1515. /**
  1516. * hif_apps_wake_irq_disable() - Disables the wake irq from the APPS side
  1517. * @hif_ctx: an opaque HIF handle to use
  1518. *
  1519. * As opposed to the standard hif_irq_disable, this function always applies to
  1520. * the APPS side kernel interrupt handling.
  1521. *
  1522. * Return: errno
  1523. */
  1524. int hif_apps_wake_irq_disable(struct hif_opaque_softc *hif_ctx);
  1525. /**
  1526. * hif_apps_enable_irq_wake() - Enables the irq wake from the APPS side
  1527. * @hif_ctx: an opaque HIF handle to use
  1528. *
  1529. * This function always applies to the APPS side kernel interrupt handling
  1530. * to wake the system from suspend.
  1531. *
  1532. * Return: errno
  1533. */
  1534. int hif_apps_enable_irq_wake(struct hif_opaque_softc *hif_ctx);
  1535. /**
  1536. * hif_apps_disable_irq_wake() - Disables the wake irq from the APPS side
  1537. * @hif_ctx: an opaque HIF handle to use
  1538. *
  1539. * This function always applies to the APPS side kernel interrupt handling
  1540. * to disable the wake irq.
  1541. *
  1542. * Return: errno
  1543. */
  1544. int hif_apps_disable_irq_wake(struct hif_opaque_softc *hif_ctx);
  1545. /**
  1546. * hif_apps_enable_irqs_except_wake_irq() - Enables all irqs except wake_irq
  1547. * @hif_ctx: an opaque HIF handle to use
  1548. *
  1549. * As opposed to the standard hif_irq_enable, this function always applies to
  1550. * the APPS side kernel interrupt handling.
  1551. *
  1552. * Return: errno
  1553. */
  1554. int hif_apps_enable_irqs_except_wake_irq(struct hif_opaque_softc *hif_ctx);
  1555. /**
  1556. * hif_apps_disable_irqs_except_wake_irq() - Disables all irqs except wake_irq
  1557. * @hif_ctx: an opaque HIF handle to use
  1558. *
  1559. * As opposed to the standard hif_irq_disable, this function always applies to
  1560. * the APPS side kernel interrupt handling.
  1561. *
  1562. * Return: errno
  1563. */
  1564. int hif_apps_disable_irqs_except_wake_irq(struct hif_opaque_softc *hif_ctx);
  1565. int hif_get_irq_num(struct hif_opaque_softc *scn, int *irq, uint32_t size);
  1566. int hif_dump_registers(struct hif_opaque_softc *scn);
  1567. int ol_copy_ramdump(struct hif_opaque_softc *scn);
  1568. void hif_crash_shutdown(struct hif_opaque_softc *hif_ctx);
  1569. void hif_get_hw_info(struct hif_opaque_softc *hif_ctx, u32 *version,
  1570. u32 *revision, const char **target_name);
  1571. enum qdf_bus_type hif_get_bus_type(struct hif_opaque_softc *hif_hdl);
  1572. struct hif_target_info *hif_get_target_info_handle(struct hif_opaque_softc *
  1573. scn);
  1574. struct hif_config_info *hif_get_ini_handle(struct hif_opaque_softc *hif_ctx);
  1575. struct ramdump_info *hif_get_ramdump_ctx(struct hif_opaque_softc *hif_ctx);
  1576. enum hif_target_status hif_get_target_status(struct hif_opaque_softc *hif_ctx);
  1577. void hif_set_target_status(struct hif_opaque_softc *hif_ctx, enum
  1578. hif_target_status);
  1579. void hif_init_ini_config(struct hif_opaque_softc *hif_ctx,
  1580. struct hif_config_info *cfg);
  1581. void hif_update_tx_ring(struct hif_opaque_softc *osc, u_int32_t num_htt_cmpls);
  1582. qdf_nbuf_t hif_batch_send(struct hif_opaque_softc *osc, qdf_nbuf_t msdu,
  1583. uint32_t transfer_id, u_int32_t len, uint32_t sendhead);
  1584. QDF_STATUS hif_send_single(struct hif_opaque_softc *osc, qdf_nbuf_t msdu,
  1585. uint32_t transfer_id, u_int32_t len);
  1586. int hif_send_fast(struct hif_opaque_softc *osc, qdf_nbuf_t nbuf,
  1587. uint32_t transfer_id, uint32_t download_len);
  1588. void hif_pkt_dl_len_set(void *hif_sc, unsigned int pkt_download_len);
  1589. void hif_ce_war_disable(void);
  1590. void hif_ce_war_enable(void);
  1591. void hif_disable_interrupt(struct hif_opaque_softc *osc, uint32_t pipe_num);
  1592. #ifdef QCA_NSS_WIFI_OFFLOAD_SUPPORT
  1593. struct hif_pipe_addl_info *hif_get_addl_pipe_info(struct hif_opaque_softc *osc,
  1594. struct hif_pipe_addl_info *hif_info, uint32_t pipe_number);
  1595. uint32_t hif_set_nss_wifiol_mode(struct hif_opaque_softc *osc,
  1596. uint32_t pipe_num);
  1597. int32_t hif_get_nss_wifiol_bypass_nw_process(struct hif_opaque_softc *osc);
  1598. #endif /* QCA_NSS_WIFI_OFFLOAD_SUPPORT */
  1599. void hif_set_bundle_mode(struct hif_opaque_softc *hif_ctx, bool enabled,
  1600. int rx_bundle_cnt);
  1601. int hif_bus_reset_resume(struct hif_opaque_softc *hif_ctx);
  1602. void hif_set_attribute(struct hif_opaque_softc *osc, uint8_t hif_attrib);
  1603. void *hif_get_lro_info(int ctx_id, struct hif_opaque_softc *hif_hdl);
  1604. enum hif_exec_type {
  1605. HIF_EXEC_NAPI_TYPE,
  1606. HIF_EXEC_TASKLET_TYPE,
  1607. };
  1608. typedef uint32_t (*ext_intr_handler)(void *, uint32_t);
  1609. /**
  1610. * hif_get_int_ctx_irq_num() - retrieve an irq num for an interrupt context id
  1611. * @softc: hif opaque context owning the exec context
  1612. * @id: the id of the interrupt context
  1613. *
  1614. * Return: IRQ number of the first (zero'th) IRQ within the interrupt context ID
  1615. * 'id' registered with the OS
  1616. */
  1617. int32_t hif_get_int_ctx_irq_num(struct hif_opaque_softc *softc,
  1618. uint8_t id);
  1619. /**
  1620. * hif_configure_ext_group_interrupts() - Congigure ext group intrrupts
  1621. * @hif_ctx: hif opaque context
  1622. *
  1623. * Return: QDF_STATUS
  1624. */
  1625. QDF_STATUS hif_configure_ext_group_interrupts(struct hif_opaque_softc *hif_ctx);
  1626. /**
  1627. * hif_deconfigure_ext_group_interrupts() - Deconfigure ext group intrrupts
  1628. * @hif_ctx: hif opaque context
  1629. *
  1630. * Return: None
  1631. */
  1632. void hif_deconfigure_ext_group_interrupts(struct hif_opaque_softc *hif_ctx);
  1633. /**
  1634. * hif_register_ext_group() - API to register external group
  1635. * interrupt handler.
  1636. * @hif_ctx : HIF Context
  1637. * @numirq: number of irq's in the group
  1638. * @irq: array of irq values
  1639. * @handler: callback interrupt handler function
  1640. * @cb_ctx: context to passed in callback
  1641. * @type: napi vs tasklet
  1642. *
  1643. * Return: QDF_STATUS
  1644. */
  1645. QDF_STATUS hif_register_ext_group(struct hif_opaque_softc *hif_ctx,
  1646. uint32_t numirq, uint32_t irq[],
  1647. ext_intr_handler handler,
  1648. void *cb_ctx, const char *context_name,
  1649. enum hif_exec_type type, uint32_t scale);
  1650. void hif_deregister_exec_group(struct hif_opaque_softc *hif_ctx,
  1651. const char *context_name);
  1652. void hif_update_pipe_callback(struct hif_opaque_softc *osc,
  1653. u_int8_t pipeid,
  1654. struct hif_msg_callbacks *callbacks);
  1655. /**
  1656. * hif_print_napi_stats() - Display HIF NAPI stats
  1657. * @hif_ctx - HIF opaque context
  1658. *
  1659. * Return: None
  1660. */
  1661. void hif_print_napi_stats(struct hif_opaque_softc *hif_ctx);
  1662. /* hif_clear_napi_stats() - function clears the stats of the
  1663. * latency when called.
  1664. * @hif_ctx - the HIF context to assign the callback to
  1665. *
  1666. * Return: None
  1667. */
  1668. void hif_clear_napi_stats(struct hif_opaque_softc *hif_ctx);
  1669. #ifdef __cplusplus
  1670. }
  1671. #endif
  1672. #ifdef FORCE_WAKE
  1673. /**
  1674. * hif_force_wake_request() - Function to wake from power collapse
  1675. * @handle: HIF opaque handle
  1676. *
  1677. * Description: API to check if the device is awake or not before
  1678. * read/write to BAR + 4K registers. If device is awake return
  1679. * success otherwise write '1' to
  1680. * PCIE_PCIE_LOCAL_REG_PCIE_SOC_WAKE_PCIE_LOCAL_REG which will interrupt
  1681. * the device and does wakeup the PCI and MHI within 50ms
  1682. * and then the device writes a value to
  1683. * PCIE_SOC_PCIE_REG_PCIE_SCRATCH_0_SOC_PCIE_REG to complete the
  1684. * handshake process to let the host know the device is awake.
  1685. *
  1686. * Return: zero - success/non-zero - failure
  1687. */
  1688. int hif_force_wake_request(struct hif_opaque_softc *handle);
  1689. /**
  1690. * hif_force_wake_release() - API to release/reset the SOC wake register
  1691. * from interrupting the device.
  1692. * @handle: HIF opaque handle
  1693. *
  1694. * Description: API to set the
  1695. * PCIE_PCIE_LOCAL_REG_PCIE_SOC_WAKE_PCIE_LOCAL_REG to '0'
  1696. * to release the interrupt line.
  1697. *
  1698. * Return: zero - success/non-zero - failure
  1699. */
  1700. int hif_force_wake_release(struct hif_opaque_softc *handle);
  1701. #else
  1702. static inline
  1703. int hif_force_wake_request(struct hif_opaque_softc *handle)
  1704. {
  1705. return 0;
  1706. }
  1707. static inline
  1708. int hif_force_wake_release(struct hif_opaque_softc *handle)
  1709. {
  1710. return 0;
  1711. }
  1712. #endif /* FORCE_WAKE */
  1713. #ifdef FEATURE_HAL_DELAYED_REG_WRITE
  1714. /**
  1715. * hif_prevent_link_low_power_states() - Prevent from going to low power states
  1716. * @hif - HIF opaque context
  1717. *
  1718. * Return: 0 on success. Error code on failure.
  1719. */
  1720. int hif_prevent_link_low_power_states(struct hif_opaque_softc *hif);
  1721. /**
  1722. * hif_allow_link_low_power_states() - Allow link to go to low power states
  1723. * @hif - HIF opaque context
  1724. *
  1725. * Return: None
  1726. */
  1727. void hif_allow_link_low_power_states(struct hif_opaque_softc *hif);
  1728. #else
  1729. static inline
  1730. int hif_prevent_link_low_power_states(struct hif_opaque_softc *hif)
  1731. {
  1732. return 0;
  1733. }
  1734. static inline
  1735. void hif_allow_link_low_power_states(struct hif_opaque_softc *hif)
  1736. {
  1737. }
  1738. #endif
  1739. void *hif_get_dev_ba(struct hif_opaque_softc *hif_handle);
  1740. void *hif_get_dev_ba_ce(struct hif_opaque_softc *hif_handle);
  1741. /**
  1742. * hif_set_initial_wakeup_cb() - set the initial wakeup event handler function
  1743. * @hif_ctx - the HIF context to assign the callback to
  1744. * @callback - the callback to assign
  1745. * @priv - the private data to pass to the callback when invoked
  1746. *
  1747. * Return: None
  1748. */
  1749. void hif_set_initial_wakeup_cb(struct hif_opaque_softc *hif_ctx,
  1750. void (*callback)(void *),
  1751. void *priv);
  1752. /*
  1753. * Note: For MCL, #if defined (HIF_CONFIG_SLUB_DEBUG_ON) needs to be checked
  1754. * for defined here
  1755. */
  1756. #if defined(HIF_CONFIG_SLUB_DEBUG_ON) || defined(HIF_CE_DEBUG_DATA_BUF)
  1757. ssize_t hif_dump_desc_trace_buf(struct device *dev,
  1758. struct device_attribute *attr, char *buf);
  1759. ssize_t hif_input_desc_trace_buf_index(struct hif_softc *scn,
  1760. const char *buf, size_t size);
  1761. ssize_t hif_ce_en_desc_hist(struct hif_softc *scn,
  1762. const char *buf, size_t size);
  1763. ssize_t hif_disp_ce_enable_desc_data_hist(struct hif_softc *scn, char *buf);
  1764. ssize_t hif_dump_desc_event(struct hif_softc *scn, char *buf);
  1765. #endif/*#if defined(HIF_CONFIG_SLUB_DEBUG_ON)||defined(HIF_CE_DEBUG_DATA_BUF)*/
  1766. /**
  1767. * hif_set_ce_service_max_yield_time() - sets CE service max yield time
  1768. * @hif: hif context
  1769. * @ce_service_max_yield_time: CE service max yield time to set
  1770. *
  1771. * This API storess CE service max yield time in hif context based
  1772. * on ini value.
  1773. *
  1774. * Return: void
  1775. */
  1776. void hif_set_ce_service_max_yield_time(struct hif_opaque_softc *hif,
  1777. uint32_t ce_service_max_yield_time);
  1778. /**
  1779. * hif_get_ce_service_max_yield_time() - get CE service max yield time
  1780. * @hif: hif context
  1781. *
  1782. * This API returns CE service max yield time.
  1783. *
  1784. * Return: CE service max yield time
  1785. */
  1786. unsigned long long
  1787. hif_get_ce_service_max_yield_time(struct hif_opaque_softc *hif);
  1788. /**
  1789. * hif_set_ce_service_max_rx_ind_flush() - sets CE service max rx ind flush
  1790. * @hif: hif context
  1791. * @ce_service_max_rx_ind_flush: CE service max rx ind flush to set
  1792. *
  1793. * This API stores CE service max rx ind flush in hif context based
  1794. * on ini value.
  1795. *
  1796. * Return: void
  1797. */
  1798. void hif_set_ce_service_max_rx_ind_flush(struct hif_opaque_softc *hif,
  1799. uint8_t ce_service_max_rx_ind_flush);
  1800. #ifdef OL_ATH_SMART_LOGGING
  1801. /*
  1802. * hif_log_ce_dump() - Copy all the CE DEST ring to buf
  1803. * @scn : HIF handler
  1804. * @buf_cur: Current pointer in ring buffer
  1805. * @buf_init:Start of the ring buffer
  1806. * @buf_sz: Size of the ring buffer
  1807. * @ce: Copy Engine id
  1808. * @skb_sz: Max size of the SKB buffer to be copied
  1809. *
  1810. * Calls the respective function to dump all the CE SRC/DEST ring descriptors
  1811. * and buffers pointed by them in to the given buf
  1812. *
  1813. * Return: Current pointer in ring buffer
  1814. */
  1815. uint8_t *hif_log_dump_ce(struct hif_softc *scn, uint8_t *buf_cur,
  1816. uint8_t *buf_init, uint32_t buf_sz,
  1817. uint32_t ce, uint32_t skb_sz);
  1818. #endif /* OL_ATH_SMART_LOGGING */
  1819. /*
  1820. * hif_softc_to_hif_opaque_softc - API to convert hif_softc handle
  1821. * to hif_opaque_softc handle
  1822. * @hif_handle - hif_softc type
  1823. *
  1824. * Return: hif_opaque_softc type
  1825. */
  1826. static inline struct hif_opaque_softc *
  1827. hif_softc_to_hif_opaque_softc(struct hif_softc *hif_handle)
  1828. {
  1829. return (struct hif_opaque_softc *)hif_handle;
  1830. }
  1831. #if defined(HIF_IPCI) && defined(FEATURE_HAL_DELAYED_REG_WRITE)
  1832. QDF_STATUS hif_try_prevent_ep_vote_access(struct hif_opaque_softc *hif_ctx);
  1833. void hif_set_ep_intermediate_vote_access(struct hif_opaque_softc *hif_ctx);
  1834. void hif_allow_ep_vote_access(struct hif_opaque_softc *hif_ctx);
  1835. void hif_set_ep_vote_access(struct hif_opaque_softc *hif_ctx,
  1836. uint8_t type, uint8_t access);
  1837. uint8_t hif_get_ep_vote_access(struct hif_opaque_softc *hif_ctx,
  1838. uint8_t type);
  1839. #else
  1840. static inline QDF_STATUS
  1841. hif_try_prevent_ep_vote_access(struct hif_opaque_softc *hif_ctx)
  1842. {
  1843. return QDF_STATUS_SUCCESS;
  1844. }
  1845. static inline void
  1846. hif_set_ep_intermediate_vote_access(struct hif_opaque_softc *hif_ctx)
  1847. {
  1848. }
  1849. static inline void
  1850. hif_allow_ep_vote_access(struct hif_opaque_softc *hif_ctx)
  1851. {
  1852. }
  1853. static inline void
  1854. hif_set_ep_vote_access(struct hif_opaque_softc *hif_ctx,
  1855. uint8_t type, uint8_t access)
  1856. {
  1857. }
  1858. static inline uint8_t
  1859. hif_get_ep_vote_access(struct hif_opaque_softc *hif_ctx,
  1860. uint8_t type)
  1861. {
  1862. return HIF_EP_VOTE_ACCESS_ENABLE;
  1863. }
  1864. #endif
  1865. #ifdef FORCE_WAKE
  1866. /**
  1867. * hif_srng_init_phase(): Indicate srng initialization phase
  1868. * to avoid force wake as UMAC power collapse is not yet
  1869. * enabled
  1870. * @hif_ctx: hif opaque handle
  1871. * @init_phase: initialization phase
  1872. *
  1873. * Return: None
  1874. */
  1875. void hif_srng_init_phase(struct hif_opaque_softc *hif_ctx,
  1876. bool init_phase);
  1877. #else
  1878. static inline
  1879. void hif_srng_init_phase(struct hif_opaque_softc *hif_ctx,
  1880. bool init_phase)
  1881. {
  1882. }
  1883. #endif /* FORCE_WAKE */
  1884. #ifdef HIF_IPCI
  1885. /**
  1886. * hif_shutdown_notifier_cb - Call back for shutdown notifier
  1887. * @ctx: hif handle
  1888. *
  1889. * Return: None
  1890. */
  1891. void hif_shutdown_notifier_cb(void *ctx);
  1892. #else
  1893. static inline
  1894. void hif_shutdown_notifier_cb(void *ctx)
  1895. {
  1896. }
  1897. #endif /* HIF_IPCI */
  1898. #ifdef HIF_CE_LOG_INFO
  1899. /**
  1900. * hif_log_ce_info() - API to log ce info
  1901. * @scn: hif handle
  1902. * @data: hang event data buffer
  1903. * @offset: offset at which data needs to be written
  1904. *
  1905. * Return: None
  1906. */
  1907. void hif_log_ce_info(struct hif_softc *scn, uint8_t *data,
  1908. unsigned int *offset);
  1909. #else
  1910. static inline
  1911. void hif_log_ce_info(struct hif_softc *scn, uint8_t *data,
  1912. unsigned int *offset)
  1913. {
  1914. }
  1915. #endif
  1916. #ifdef HIF_CPU_PERF_AFFINE_MASK
  1917. /**
  1918. * hif_config_irq_set_perf_affinity_hint() - API to set affinity
  1919. * @hif_ctx: hif opaque handle
  1920. *
  1921. * This function is used to move the WLAN IRQs to perf cores in
  1922. * case of defconfig builds.
  1923. *
  1924. * Return: None
  1925. */
  1926. void hif_config_irq_set_perf_affinity_hint(
  1927. struct hif_opaque_softc *hif_ctx);
  1928. #else
  1929. static inline void hif_config_irq_set_perf_affinity_hint(
  1930. struct hif_opaque_softc *hif_ctx)
  1931. {
  1932. }
  1933. #endif
  1934. /**
  1935. * hif_apps_grp_irqs_enable() - enable 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_enable(struct hif_opaque_softc *hif_ctx);
  1941. /**
  1942. * hif_apps_grp_irqs_disable() - disable ext grp irqs
  1943. * @hif - HIF opaque context
  1944. *
  1945. * Return: 0 on success. Error code on failure.
  1946. */
  1947. int hif_apps_grp_irqs_disable(struct hif_opaque_softc *hif_ctx);
  1948. /**
  1949. * hif_disable_grp_irqs() - disable ext grp irqs
  1950. * @hif - HIF opaque context
  1951. *
  1952. * Return: 0 on success. Error code on failure.
  1953. */
  1954. int hif_disable_grp_irqs(struct hif_opaque_softc *scn);
  1955. /**
  1956. * hif_enable_grp_irqs() - enable ext grp irqs
  1957. * @hif - HIF opaque context
  1958. *
  1959. * Return: 0 on success. Error code on failure.
  1960. */
  1961. int hif_enable_grp_irqs(struct hif_opaque_softc *scn);
  1962. enum hif_credit_exchange_type {
  1963. HIF_REQUEST_CREDIT,
  1964. HIF_PROCESS_CREDIT_REPORT,
  1965. };
  1966. enum hif_detect_latency_type {
  1967. HIF_DETECT_TASKLET,
  1968. HIF_DETECT_CREDIT,
  1969. HIF_DETECT_UNKNOWN
  1970. };
  1971. #ifdef HIF_DETECTION_LATENCY_ENABLE
  1972. void hif_latency_detect_credit_record_time(
  1973. enum hif_credit_exchange_type type,
  1974. struct hif_opaque_softc *hif_ctx);
  1975. void hif_latency_detect_timer_start(struct hif_opaque_softc *hif_ctx);
  1976. void hif_latency_detect_timer_stop(struct hif_opaque_softc *hif_ctx);
  1977. void hif_tasklet_latency(struct hif_softc *scn, bool from_timer);
  1978. void hif_credit_latency(struct hif_softc *scn, bool from_timer);
  1979. void hif_check_detection_latency(struct hif_softc *scn,
  1980. bool from_timer,
  1981. uint32_t bitmap_type);
  1982. void hif_set_enable_detection(struct hif_opaque_softc *hif_ctx, bool value);
  1983. #else
  1984. static inline
  1985. void hif_latency_detect_timer_start(struct hif_opaque_softc *hif_ctx)
  1986. {}
  1987. static inline
  1988. void hif_latency_detect_timer_stop(struct hif_opaque_softc *hif_ctx)
  1989. {}
  1990. static inline
  1991. void hif_latency_detect_credit_record_time(
  1992. enum hif_credit_exchange_type type,
  1993. struct hif_opaque_softc *hif_ctx)
  1994. {}
  1995. static inline
  1996. void hif_check_detection_latency(struct hif_softc *scn,
  1997. bool from_timer,
  1998. uint32_t bitmap_type)
  1999. {}
  2000. static inline
  2001. void hif_set_enable_detection(struct hif_opaque_softc *hif_ctx, bool value)
  2002. {}
  2003. #endif
  2004. #ifdef SYSTEM_PM_CHECK
  2005. /**
  2006. * __hif_system_pm_set_state() - Set system pm state
  2007. * @hif: hif opaque handle
  2008. * @state: system state
  2009. *
  2010. * Return: None
  2011. */
  2012. void __hif_system_pm_set_state(struct hif_opaque_softc *hif,
  2013. enum hif_system_pm_state state);
  2014. /**
  2015. * hif_system_pm_set_state_on() - Set system pm state to ON
  2016. * @hif: hif opaque handle
  2017. *
  2018. * Return: None
  2019. */
  2020. static inline
  2021. void hif_system_pm_set_state_on(struct hif_opaque_softc *hif)
  2022. {
  2023. __hif_system_pm_set_state(hif, HIF_SYSTEM_PM_STATE_ON);
  2024. }
  2025. /**
  2026. * hif_system_pm_set_state_resuming() - Set system pm state to resuming
  2027. * @hif: hif opaque handle
  2028. *
  2029. * Return: None
  2030. */
  2031. static inline
  2032. void hif_system_pm_set_state_resuming(struct hif_opaque_softc *hif)
  2033. {
  2034. __hif_system_pm_set_state(hif, HIF_SYSTEM_PM_STATE_BUS_RESUMING);
  2035. }
  2036. /**
  2037. * hif_system_pm_set_state_suspending() - Set system pm state to suspending
  2038. * @hif: hif opaque handle
  2039. *
  2040. * Return: None
  2041. */
  2042. static inline
  2043. void hif_system_pm_set_state_suspending(struct hif_opaque_softc *hif)
  2044. {
  2045. __hif_system_pm_set_state(hif, HIF_SYSTEM_PM_STATE_BUS_SUSPENDING);
  2046. }
  2047. /**
  2048. * hif_system_pm_set_state_suspended() - Set system pm state to suspended
  2049. * @hif: hif opaque handle
  2050. *
  2051. * Return: None
  2052. */
  2053. static inline
  2054. void hif_system_pm_set_state_suspended(struct hif_opaque_softc *hif)
  2055. {
  2056. __hif_system_pm_set_state(hif, HIF_SYSTEM_PM_STATE_BUS_SUSPENDED);
  2057. }
  2058. /**
  2059. * hif_system_pm_get_state() - Get system pm state
  2060. * @hif: hif opaque handle
  2061. *
  2062. * Return: system state
  2063. */
  2064. int32_t hif_system_pm_get_state(struct hif_opaque_softc *hif);
  2065. /**
  2066. * hif_system_pm_state_check() - Check system state and trigger resume
  2067. * if required
  2068. * @hif: hif opaque handle
  2069. *
  2070. * Return: 0 if system is in on state else error code
  2071. */
  2072. int hif_system_pm_state_check(struct hif_opaque_softc *hif);
  2073. #else
  2074. static inline
  2075. void __hif_system_pm_set_state(struct hif_opaque_softc *hif,
  2076. enum hif_system_pm_state state)
  2077. {
  2078. }
  2079. static inline
  2080. void hif_system_pm_set_state_on(struct hif_opaque_softc *hif)
  2081. {
  2082. }
  2083. static inline
  2084. void hif_system_pm_set_state_resuming(struct hif_opaque_softc *hif)
  2085. {
  2086. }
  2087. static inline
  2088. void hif_system_pm_set_state_suspending(struct hif_opaque_softc *hif)
  2089. {
  2090. }
  2091. static inline
  2092. void hif_system_pm_set_state_suspended(struct hif_opaque_softc *hif)
  2093. {
  2094. }
  2095. static inline
  2096. int32_t hif_system_pm_get_state(struct hif_opaque_softc *hif)
  2097. {
  2098. return 0;
  2099. }
  2100. static inline int hif_system_pm_state_check(struct hif_opaque_softc *hif)
  2101. {
  2102. return 0;
  2103. }
  2104. #endif
  2105. #ifdef FEATURE_IRQ_AFFINITY
  2106. /**
  2107. * hif_set_grp_intr_affinity() - API to set affinity for grp
  2108. * intrs set in the bitmap
  2109. * @scn: hif handle
  2110. * @grp_intr_bitmask: grp intrs for which perf affinity should be
  2111. * applied
  2112. * @perf: affine to perf or non-perf cluster
  2113. *
  2114. * Return: None
  2115. */
  2116. void hif_set_grp_intr_affinity(struct hif_opaque_softc *scn,
  2117. uint32_t grp_intr_bitmask, bool perf);
  2118. #else
  2119. static inline
  2120. void hif_set_grp_intr_affinity(struct hif_opaque_softc *scn,
  2121. uint32_t grp_intr_bitmask, bool perf)
  2122. {
  2123. }
  2124. #endif
  2125. /**
  2126. * hif_get_max_wmi_ep() - Get max WMI EPs configured in target svc map
  2127. * @hif_ctx: hif opaque handle
  2128. *
  2129. * Description:
  2130. * Gets number of WMI EPs configured in target svc map. Since EP map
  2131. * include IN and OUT direction pipes, count only OUT pipes to get EPs
  2132. * configured for WMI service.
  2133. *
  2134. * Return:
  2135. * uint8_t: count for WMI eps in target svc map
  2136. */
  2137. uint8_t hif_get_max_wmi_ep(struct hif_opaque_softc *scn);
  2138. #ifdef DP_UMAC_HW_RESET_SUPPORT
  2139. /**
  2140. * hif_register_umac_reset_handler() - Register UMAC HW reset handler
  2141. * @hif_scn: hif opaque handle
  2142. * @handler: callback handler function
  2143. * @cb_ctx: context to passed to @handler
  2144. * @irq: irq number to be used for UMAC HW reset interrupt
  2145. *
  2146. * Return: QDF_STATUS of operation
  2147. */
  2148. QDF_STATUS hif_register_umac_reset_handler(struct hif_opaque_softc *hif_scn,
  2149. int (*handler)(void *cb_ctx),
  2150. void *cb_ctx, int irq);
  2151. /**
  2152. * hif_unregister_umac_reset_handler() - Unregister UMAC HW reset handler
  2153. * @hif_scn: hif opaque handle
  2154. *
  2155. * Return: QDF_STATUS of operation
  2156. */
  2157. QDF_STATUS hif_unregister_umac_reset_handler(struct hif_opaque_softc *hif_scn);
  2158. #else
  2159. static inline
  2160. QDF_STATUS hif_register_umac_reset_handler(struct hif_opaque_softc *hif_scn,
  2161. int (*handler)(void *cb_ctx),
  2162. void *cb_ctx, int irq)
  2163. {
  2164. return QDF_STATUS_SUCCESS;
  2165. }
  2166. static inline
  2167. QDF_STATUS hif_unregister_umac_reset_handler(struct hif_opaque_softc *hif_scn)
  2168. {
  2169. return QDF_STATUS_SUCCESS;
  2170. }
  2171. #endif /* DP_UMAC_HW_RESET_SUPPORT */
  2172. #endif /* _HIF_H_ */