hif.h 64 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107
  1. /*
  2. * Copyright (c) 2013-2021 The Linux Foundation. All rights reserved.
  3. * Copyright (c) 2021 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_IPQ4019 13
  61. #define HIF_TYPE_QCA9888 14
  62. #define HIF_TYPE_QCA8074 15
  63. #define HIF_TYPE_QCA6290 16
  64. #define HIF_TYPE_QCN7605 17
  65. #define HIF_TYPE_QCA6390 18
  66. #define HIF_TYPE_QCA8074V2 19
  67. #define HIF_TYPE_QCA6018 20
  68. #define HIF_TYPE_QCN9000 21
  69. #define HIF_TYPE_QCA6490 22
  70. #define HIF_TYPE_QCA6750 23
  71. #define HIF_TYPE_QCA5018 24
  72. #define HIF_TYPE_QCN6122 25
  73. #define HIF_TYPE_WCN7850 26
  74. #define HIF_TYPE_QCN9224 27
  75. #define HIF_TYPE_QCA9574 28
  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_ring3,
  117. wbm2host_tx_completions_ring2,
  118. wbm2host_tx_completions_ring1,
  119. tcl2host_status_ring,
  120. };
  121. struct CE_state;
  122. #ifdef QCA_WIFI_QCN9224
  123. #define CE_COUNT_MAX 16
  124. #else
  125. #define CE_COUNT_MAX 12
  126. #endif
  127. #ifndef HIF_MAX_GROUP
  128. #define HIF_MAX_GROUP WLAN_CFG_INT_NUM_CONTEXTS
  129. #endif
  130. #ifdef CONFIG_BERYLLIUM
  131. #define HIF_MAX_GRP_IRQ 25
  132. #else
  133. #define HIF_MAX_GRP_IRQ 16
  134. #endif
  135. #ifndef NAPI_YIELD_BUDGET_BASED
  136. #ifndef QCA_NAPI_DEF_SCALE_BIN_SHIFT
  137. #define QCA_NAPI_DEF_SCALE_BIN_SHIFT 4
  138. #endif
  139. #else /* NAPI_YIELD_BUDGET_BASED */
  140. #define QCA_NAPI_DEF_SCALE_BIN_SHIFT 2
  141. #endif /* NAPI_YIELD_BUDGET_BASED */
  142. #define QCA_NAPI_BUDGET 64
  143. #define QCA_NAPI_DEF_SCALE \
  144. (1 << QCA_NAPI_DEF_SCALE_BIN_SHIFT)
  145. #define HIF_NAPI_MAX_RECEIVES (QCA_NAPI_BUDGET * QCA_NAPI_DEF_SCALE)
  146. /* NOTE: "napi->scale" can be changed,
  147. * but this does not change the number of buckets
  148. */
  149. #define QCA_NAPI_NUM_BUCKETS 4
  150. /**
  151. * qca_napi_stat - stats structure for execution contexts
  152. * @napi_schedules - number of times the schedule function is called
  153. * @napi_polls - number of times the execution context runs
  154. * @napi_completes - number of times that the generating interrupt is reenabled
  155. * @napi_workdone - cumulative of all work done reported by handler
  156. * @cpu_corrected - incremented when execution context runs on a different core
  157. * than the one that its irq is affined to.
  158. * @napi_budget_uses - histogram of work done per execution run
  159. * @time_limit_reache - count of yields due to time limit threshholds
  160. * @rxpkt_thresh_reached - count of yields due to a work limit
  161. * @poll_time_buckets - histogram of poll times for the napi
  162. *
  163. */
  164. struct qca_napi_stat {
  165. uint32_t napi_schedules;
  166. uint32_t napi_polls;
  167. uint32_t napi_completes;
  168. uint32_t napi_workdone;
  169. uint32_t cpu_corrected;
  170. uint32_t napi_budget_uses[QCA_NAPI_NUM_BUCKETS];
  171. uint32_t time_limit_reached;
  172. uint32_t rxpkt_thresh_reached;
  173. unsigned long long napi_max_poll_time;
  174. #ifdef WLAN_FEATURE_RX_SOFTIRQ_TIME_LIMIT
  175. uint32_t poll_time_buckets[QCA_NAPI_NUM_BUCKETS];
  176. #endif
  177. };
  178. /**
  179. * per NAPI instance data structure
  180. * This data structure holds stuff per NAPI instance.
  181. * Note that, in the current implementation, though scale is
  182. * an instance variable, it is set to the same value for all
  183. * instances.
  184. */
  185. struct qca_napi_info {
  186. struct net_device netdev; /* dummy net_dev */
  187. void *hif_ctx;
  188. struct napi_struct napi;
  189. uint8_t scale; /* currently same on all instances */
  190. uint8_t id;
  191. uint8_t cpu;
  192. int irq;
  193. cpumask_t cpumask;
  194. struct qca_napi_stat stats[NR_CPUS];
  195. #ifdef RECEIVE_OFFLOAD
  196. /* will only be present for data rx CE's */
  197. void (*offld_flush_cb)(void *);
  198. struct napi_struct rx_thread_napi;
  199. struct net_device rx_thread_netdev;
  200. #endif /* RECEIVE_OFFLOAD */
  201. qdf_lro_ctx_t lro_ctx;
  202. };
  203. enum qca_napi_tput_state {
  204. QCA_NAPI_TPUT_UNINITIALIZED,
  205. QCA_NAPI_TPUT_LO,
  206. QCA_NAPI_TPUT_HI
  207. };
  208. enum qca_napi_cpu_state {
  209. QCA_NAPI_CPU_UNINITIALIZED,
  210. QCA_NAPI_CPU_DOWN,
  211. QCA_NAPI_CPU_UP };
  212. /**
  213. * struct qca_napi_cpu - an entry of the napi cpu table
  214. * @core_id: physical core id of the core
  215. * @cluster_id: cluster this core belongs to
  216. * @core_mask: mask to match all core of this cluster
  217. * @thread_mask: mask for this core within the cluster
  218. * @max_freq: maximum clock this core can be clocked at
  219. * same for all cpus of the same core.
  220. * @napis: bitmap of napi instances on this core
  221. * @execs: bitmap of execution contexts on this core
  222. * cluster_nxt: chain to link cores within the same cluster
  223. *
  224. * This structure represents a single entry in the napi cpu
  225. * table. The table is part of struct qca_napi_data.
  226. * This table is initialized by the init function, called while
  227. * the first napi instance is being created, updated by hotplug
  228. * notifier and when cpu affinity decisions are made (by throughput
  229. * detection), and deleted when the last napi instance is removed.
  230. */
  231. struct qca_napi_cpu {
  232. enum qca_napi_cpu_state state;
  233. int core_id;
  234. int cluster_id;
  235. cpumask_t core_mask;
  236. cpumask_t thread_mask;
  237. unsigned int max_freq;
  238. uint32_t napis;
  239. uint32_t execs;
  240. int cluster_nxt; /* index, not pointer */
  241. };
  242. /**
  243. * struct qca_napi_data - collection of napi data for a single hif context
  244. * @hif_softc: pointer to the hif context
  245. * @lock: spinlock used in the event state machine
  246. * @state: state variable used in the napi stat machine
  247. * @ce_map: bit map indicating which ce's have napis running
  248. * @exec_map: bit map of instanciated exec contexts
  249. * @user_cpu_affin_map: CPU affinity map from INI config.
  250. * @napi_cpu: cpu info for irq affinty
  251. * @lilcl_head:
  252. * @bigcl_head:
  253. * @napi_mode: irq affinity & clock voting mode
  254. * @cpuhp_handler: CPU hotplug event registration handle
  255. */
  256. struct qca_napi_data {
  257. struct hif_softc *hif_softc;
  258. qdf_spinlock_t lock;
  259. uint32_t state;
  260. /* bitmap of created/registered NAPI instances, indexed by pipe_id,
  261. * not used by clients (clients use an id returned by create)
  262. */
  263. uint32_t ce_map;
  264. uint32_t exec_map;
  265. uint32_t user_cpu_affin_mask;
  266. struct qca_napi_info *napis[CE_COUNT_MAX];
  267. struct qca_napi_cpu napi_cpu[NR_CPUS];
  268. int lilcl_head, bigcl_head;
  269. enum qca_napi_tput_state napi_mode;
  270. struct qdf_cpuhp_handler *cpuhp_handler;
  271. uint8_t flags;
  272. };
  273. /**
  274. * struct hif_config_info - Place Holder for HIF configuration
  275. * @enable_self_recovery: Self Recovery
  276. * @enable_runtime_pm: Enable Runtime PM
  277. * @runtime_pm_delay: Runtime PM Delay
  278. * @rx_softirq_max_yield_duration_ns: Max Yield time duration for RX Softirq
  279. *
  280. * Structure for holding HIF ini parameters.
  281. */
  282. struct hif_config_info {
  283. bool enable_self_recovery;
  284. #ifdef FEATURE_RUNTIME_PM
  285. uint8_t enable_runtime_pm;
  286. u_int32_t runtime_pm_delay;
  287. #endif
  288. uint64_t rx_softirq_max_yield_duration_ns;
  289. };
  290. /**
  291. * struct hif_target_info - Target Information
  292. * @target_version: Target Version
  293. * @target_type: Target Type
  294. * @target_revision: Target Revision
  295. * @soc_version: SOC Version
  296. * @hw_name: pointer to hardware name
  297. *
  298. * Structure to hold target information.
  299. */
  300. struct hif_target_info {
  301. uint32_t target_version;
  302. uint32_t target_type;
  303. uint32_t target_revision;
  304. uint32_t soc_version;
  305. char *hw_name;
  306. };
  307. struct hif_opaque_softc {
  308. };
  309. /**
  310. * enum hif_event_type - Type of DP events to be recorded
  311. * @HIF_EVENT_IRQ_TRIGGER: IRQ trigger event
  312. * @HIF_EVENT_TIMER_ENTRY: Monitor Timer entry event
  313. * @HIF_EVENT_TIMER_EXIT: Monitor Timer exit event
  314. * @HIF_EVENT_BH_SCHED: NAPI POLL scheduled event
  315. * @HIF_EVENT_SRNG_ACCESS_START: hal ring access start event
  316. * @HIF_EVENT_SRNG_ACCESS_END: hal ring access end event
  317. * @HIF_EVENT_BH_COMPLETE: NAPI POLL completion event
  318. * @HIF_EVENT_BH_FORCE_BREAK: NAPI POLL force break event
  319. */
  320. enum hif_event_type {
  321. HIF_EVENT_IRQ_TRIGGER,
  322. HIF_EVENT_TIMER_ENTRY,
  323. HIF_EVENT_TIMER_EXIT,
  324. HIF_EVENT_BH_SCHED,
  325. HIF_EVENT_SRNG_ACCESS_START,
  326. HIF_EVENT_SRNG_ACCESS_END,
  327. HIF_EVENT_BH_COMPLETE,
  328. HIF_EVENT_BH_FORCE_BREAK,
  329. /* Do check hif_hist_skip_event_record when adding new events */
  330. };
  331. /**
  332. * enum hif_system_pm_state - System PM state
  333. * HIF_SYSTEM_PM_STATE_ON: System in active state
  334. * HIF_SYSTEM_PM_STATE_BUS_RESUMING: bus resume in progress as part of
  335. * system resume
  336. * HIF_SYSTEM_PM_STATE_BUS_SUSPENDING: bus suspend in progress as part of
  337. * system suspend
  338. * HIF_SYSTEM_PM_STATE_BUS_SUSPENDED: bus suspended as part of system suspend
  339. */
  340. enum hif_system_pm_state {
  341. HIF_SYSTEM_PM_STATE_ON,
  342. HIF_SYSTEM_PM_STATE_BUS_RESUMING,
  343. HIF_SYSTEM_PM_STATE_BUS_SUSPENDING,
  344. HIF_SYSTEM_PM_STATE_BUS_SUSPENDED,
  345. };
  346. #ifdef WLAN_FEATURE_DP_EVENT_HISTORY
  347. #define HIF_NUM_INT_CONTEXTS HIF_MAX_GROUP
  348. #if defined(HIF_CONFIG_SLUB_DEBUG_ON) || defined(HIF_CE_DEBUG_DATA_BUF)
  349. /* HIF_EVENT_HIST_MAX should always be power of 2 */
  350. #define HIF_EVENT_HIST_MAX 512
  351. #define HIF_EVENT_HIST_ENABLE_MASK 0xFF
  352. static inline uint64_t hif_get_log_timestamp(void)
  353. {
  354. return qdf_get_log_timestamp();
  355. }
  356. #else
  357. #define HIF_EVENT_HIST_MAX 32
  358. /* Enable IRQ TRIGGER, NAPI SCHEDULE, SRNG ACCESS START */
  359. #define HIF_EVENT_HIST_ENABLE_MASK 0x19
  360. static inline uint64_t hif_get_log_timestamp(void)
  361. {
  362. return qdf_sched_clock();
  363. }
  364. #endif
  365. /**
  366. * struct hif_event_record - an entry of the DP event history
  367. * @hal_ring_id: ring id for which event is recorded
  368. * @hp: head pointer of the ring (may not be applicable for all events)
  369. * @tp: tail pointer of the ring (may not be applicable for all events)
  370. * @cpu_id: cpu id on which the event occurred
  371. * @timestamp: timestamp when event occurred
  372. * @type: type of the event
  373. *
  374. * This structure represents the information stored for every datapath
  375. * event which is logged in the history.
  376. */
  377. struct hif_event_record {
  378. uint8_t hal_ring_id;
  379. uint32_t hp;
  380. uint32_t tp;
  381. int cpu_id;
  382. uint64_t timestamp;
  383. enum hif_event_type type;
  384. };
  385. /**
  386. * struct hif_event_misc - history related misc info
  387. * @last_irq_index: last irq event index in history
  388. * @last_irq_ts: last irq timestamp
  389. */
  390. struct hif_event_misc {
  391. int32_t last_irq_index;
  392. uint64_t last_irq_ts;
  393. };
  394. /**
  395. * struct hif_event_history - history for one interrupt group
  396. * @index: index to store new event
  397. * @event: event entry
  398. *
  399. * This structure represents the datapath history for one
  400. * interrupt group.
  401. */
  402. struct hif_event_history {
  403. qdf_atomic_t index;
  404. struct hif_event_misc misc;
  405. struct hif_event_record event[HIF_EVENT_HIST_MAX];
  406. };
  407. /**
  408. * hif_hist_record_event() - Record one datapath event in history
  409. * @hif_ctx: HIF opaque context
  410. * @event: DP event entry
  411. * @intr_grp_id: interrupt group ID registered with hif
  412. *
  413. * Return: None
  414. */
  415. void hif_hist_record_event(struct hif_opaque_softc *hif_ctx,
  416. struct hif_event_record *event,
  417. uint8_t intr_grp_id);
  418. /**
  419. * hif_event_history_init() - Initialize SRNG event history buffers
  420. * @hif_ctx: HIF opaque context
  421. * @id: context group ID for which history is recorded
  422. *
  423. * Returns: None
  424. */
  425. void hif_event_history_init(struct hif_opaque_softc *hif_ctx, uint8_t id);
  426. /**
  427. * hif_event_history_deinit() - De-initialize SRNG event history buffers
  428. * @hif_ctx: HIF opaque context
  429. * @id: context group ID for which history is recorded
  430. *
  431. * Returns: None
  432. */
  433. void hif_event_history_deinit(struct hif_opaque_softc *hif_ctx, uint8_t id);
  434. /**
  435. * hif_record_event() - Wrapper function to form and record DP event
  436. * @hif_ctx: HIF opaque context
  437. * @intr_grp_id: interrupt group ID registered with hif
  438. * @hal_ring_id: ring id for which event is recorded
  439. * @hp: head pointer index of the srng
  440. * @tp: tail pointer index of the srng
  441. * @type: type of the event to be logged in history
  442. *
  443. * Return: None
  444. */
  445. static inline void hif_record_event(struct hif_opaque_softc *hif_ctx,
  446. uint8_t intr_grp_id,
  447. uint8_t hal_ring_id,
  448. uint32_t hp,
  449. uint32_t tp,
  450. enum hif_event_type type)
  451. {
  452. struct hif_event_record event;
  453. event.hal_ring_id = hal_ring_id;
  454. event.hp = hp;
  455. event.tp = tp;
  456. event.type = type;
  457. hif_hist_record_event(hif_ctx, &event, intr_grp_id);
  458. return;
  459. }
  460. #else
  461. static inline void hif_record_event(struct hif_opaque_softc *hif_ctx,
  462. uint8_t intr_grp_id,
  463. uint8_t hal_ring_id,
  464. uint32_t hp,
  465. uint32_t tp,
  466. enum hif_event_type type)
  467. {
  468. }
  469. static inline void hif_event_history_init(struct hif_opaque_softc *hif_ctx,
  470. uint8_t id)
  471. {
  472. }
  473. static inline void hif_event_history_deinit(struct hif_opaque_softc *hif_ctx,
  474. uint8_t id)
  475. {
  476. }
  477. #endif /* WLAN_FEATURE_DP_EVENT_HISTORY */
  478. /**
  479. * enum HIF_DEVICE_POWER_CHANGE_TYPE: Device Power change type
  480. *
  481. * @HIF_DEVICE_POWER_UP: HIF layer should power up interface and/or module
  482. * @HIF_DEVICE_POWER_DOWN: HIF layer should initiate bus-specific measures to
  483. * minimize power
  484. * @HIF_DEVICE_POWER_CUT: HIF layer should initiate bus-specific AND/OR
  485. * platform-specific measures to completely power-off
  486. * the module and associated hardware (i.e. cut power
  487. * supplies)
  488. */
  489. enum HIF_DEVICE_POWER_CHANGE_TYPE {
  490. HIF_DEVICE_POWER_UP,
  491. HIF_DEVICE_POWER_DOWN,
  492. HIF_DEVICE_POWER_CUT
  493. };
  494. /**
  495. * enum hif_enable_type: what triggered the enabling of hif
  496. *
  497. * @HIF_ENABLE_TYPE_PROBE: probe triggered enable
  498. * @HIF_ENABLE_TYPE_REINIT: reinit triggered enable
  499. */
  500. enum hif_enable_type {
  501. HIF_ENABLE_TYPE_PROBE,
  502. HIF_ENABLE_TYPE_REINIT,
  503. HIF_ENABLE_TYPE_MAX
  504. };
  505. /**
  506. * enum hif_disable_type: what triggered the disabling of hif
  507. *
  508. * @HIF_DISABLE_TYPE_PROBE_ERROR: probe error triggered disable
  509. * @HIF_DISABLE_TYPE_REINIT_ERROR: reinit error triggered disable
  510. * @HIF_DISABLE_TYPE_REMOVE: remove triggered disable
  511. * @HIF_DISABLE_TYPE_SHUTDOWN: shutdown triggered disable
  512. */
  513. enum hif_disable_type {
  514. HIF_DISABLE_TYPE_PROBE_ERROR,
  515. HIF_DISABLE_TYPE_REINIT_ERROR,
  516. HIF_DISABLE_TYPE_REMOVE,
  517. HIF_DISABLE_TYPE_SHUTDOWN,
  518. HIF_DISABLE_TYPE_MAX
  519. };
  520. /**
  521. * enum hif_device_config_opcode: configure mode
  522. *
  523. * @HIF_DEVICE_POWER_STATE: device power state
  524. * @HIF_DEVICE_GET_BLOCK_SIZE: get block size
  525. * @HIF_DEVICE_GET_ADDR: get block address
  526. * @HIF_DEVICE_GET_PENDING_EVENTS_FUNC: get pending events functions
  527. * @HIF_DEVICE_GET_IRQ_PROC_MODE: get irq proc mode
  528. * @HIF_DEVICE_GET_RECV_EVENT_MASK_UNMASK_FUNC: receive event function
  529. * @HIF_DEVICE_POWER_STATE_CHANGE: change power state
  530. * @HIF_DEVICE_GET_IRQ_YIELD_PARAMS: get yield params
  531. * @HIF_CONFIGURE_QUERY_SCATTER_REQUEST_SUPPORT: configure scatter request
  532. * @HIF_DEVICE_GET_OS_DEVICE: get OS device
  533. * @HIF_DEVICE_DEBUG_BUS_STATE: debug bus state
  534. * @HIF_BMI_DONE: bmi done
  535. * @HIF_DEVICE_SET_TARGET_TYPE: set target type
  536. * @HIF_DEVICE_SET_HTC_CONTEXT: set htc context
  537. * @HIF_DEVICE_GET_HTC_CONTEXT: get htc context
  538. */
  539. enum hif_device_config_opcode {
  540. HIF_DEVICE_POWER_STATE = 0,
  541. HIF_DEVICE_GET_BLOCK_SIZE,
  542. HIF_DEVICE_GET_FIFO_ADDR,
  543. HIF_DEVICE_GET_PENDING_EVENTS_FUNC,
  544. HIF_DEVICE_GET_IRQ_PROC_MODE,
  545. HIF_DEVICE_GET_RECV_EVENT_MASK_UNMASK_FUNC,
  546. HIF_DEVICE_POWER_STATE_CHANGE,
  547. HIF_DEVICE_GET_IRQ_YIELD_PARAMS,
  548. HIF_CONFIGURE_QUERY_SCATTER_REQUEST_SUPPORT,
  549. HIF_DEVICE_GET_OS_DEVICE,
  550. HIF_DEVICE_DEBUG_BUS_STATE,
  551. HIF_BMI_DONE,
  552. HIF_DEVICE_SET_TARGET_TYPE,
  553. HIF_DEVICE_SET_HTC_CONTEXT,
  554. HIF_DEVICE_GET_HTC_CONTEXT,
  555. };
  556. #ifdef CONFIG_ATH_PCIE_ACCESS_DEBUG
  557. struct HID_ACCESS_LOG {
  558. uint32_t seqnum;
  559. bool is_write;
  560. void *addr;
  561. uint32_t value;
  562. };
  563. #endif
  564. void hif_reg_write(struct hif_opaque_softc *hif_ctx, uint32_t offset,
  565. uint32_t value);
  566. uint32_t hif_reg_read(struct hif_opaque_softc *hif_ctx, uint32_t offset);
  567. #define HIF_MAX_DEVICES 1
  568. /**
  569. * struct htc_callbacks - Structure for HTC Callbacks methods
  570. * @context: context to pass to the dsrhandler
  571. * note : rwCompletionHandler is provided the context
  572. * passed to hif_read_write
  573. * @rwCompletionHandler: Read / write completion handler
  574. * @dsrHandler: DSR Handler
  575. */
  576. struct htc_callbacks {
  577. void *context;
  578. QDF_STATUS(*rw_compl_handler)(void *rw_ctx, QDF_STATUS status);
  579. QDF_STATUS(*dsr_handler)(void *context);
  580. };
  581. /**
  582. * struct hif_driver_state_callbacks - Callbacks for HIF to query Driver state
  583. * @context: Private data context
  584. * @set_recovery_in_progress: To Set Driver state for recovery in progress
  585. * @is_recovery_in_progress: Query if driver state is recovery in progress
  586. * @is_load_unload_in_progress: Query if driver state Load/Unload in Progress
  587. * @is_driver_unloading: Query if driver is unloading.
  588. * @get_bandwidth_level: Query current bandwidth level for the driver
  589. * @prealloc_get_consistent_mem_unligned: get prealloc unaligned consistent mem
  590. * @prealloc_put_consistent_mem_unligned: put unaligned consistent mem to pool
  591. * This Structure provides callback pointer for HIF to query hdd for driver
  592. * states.
  593. */
  594. struct hif_driver_state_callbacks {
  595. void *context;
  596. void (*set_recovery_in_progress)(void *context, uint8_t val);
  597. bool (*is_recovery_in_progress)(void *context);
  598. bool (*is_load_unload_in_progress)(void *context);
  599. bool (*is_driver_unloading)(void *context);
  600. bool (*is_target_ready)(void *context);
  601. int (*get_bandwidth_level)(void *context);
  602. void *(*prealloc_get_consistent_mem_unaligned)(qdf_size_t size,
  603. qdf_dma_addr_t *paddr,
  604. uint32_t ring_type);
  605. void (*prealloc_put_consistent_mem_unaligned)(void *vaddr);
  606. };
  607. /* This API detaches the HTC layer from the HIF device */
  608. void hif_detach_htc(struct hif_opaque_softc *hif_ctx);
  609. /****************************************************************/
  610. /* BMI and Diag window abstraction */
  611. /****************************************************************/
  612. #define HIF_BMI_EXCHANGE_NO_TIMEOUT ((uint32_t)(0))
  613. #define DIAG_TRANSFER_LIMIT 2048U /* maximum number of bytes that can be
  614. * handled atomically by
  615. * DiagRead/DiagWrite
  616. */
  617. #ifdef WLAN_FEATURE_BMI
  618. /*
  619. * API to handle HIF-specific BMI message exchanges, this API is synchronous
  620. * and only allowed to be called from a context that can block (sleep)
  621. */
  622. QDF_STATUS hif_exchange_bmi_msg(struct hif_opaque_softc *hif_ctx,
  623. qdf_dma_addr_t cmd, qdf_dma_addr_t rsp,
  624. uint8_t *pSendMessage, uint32_t Length,
  625. uint8_t *pResponseMessage,
  626. uint32_t *pResponseLength, uint32_t TimeoutMS);
  627. void hif_register_bmi_callbacks(struct hif_opaque_softc *hif_ctx);
  628. bool hif_needs_bmi(struct hif_opaque_softc *hif_ctx);
  629. #else /* WLAN_FEATURE_BMI */
  630. static inline void
  631. hif_register_bmi_callbacks(struct hif_opaque_softc *hif_ctx)
  632. {
  633. }
  634. static inline bool
  635. hif_needs_bmi(struct hif_opaque_softc *hif_ctx)
  636. {
  637. return false;
  638. }
  639. #endif /* WLAN_FEATURE_BMI */
  640. #ifdef HIF_CPU_CLEAR_AFFINITY
  641. /**
  642. * hif_config_irq_clear_cpu_affinity() - Remove cpu affinity of IRQ
  643. * @scn: HIF handle
  644. * @intr_ctxt_id: interrupt group index
  645. * @cpu: CPU core to clear
  646. *
  647. * Return: None
  648. */
  649. void hif_config_irq_clear_cpu_affinity(struct hif_opaque_softc *scn,
  650. int intr_ctxt_id, int cpu);
  651. #else
  652. static inline
  653. void hif_config_irq_clear_cpu_affinity(struct hif_opaque_softc *scn,
  654. int intr_ctxt_id, int cpu)
  655. {
  656. }
  657. #endif
  658. /*
  659. * APIs to handle HIF specific diagnostic read accesses. These APIs are
  660. * synchronous and only allowed to be called from a context that
  661. * can block (sleep). They are not high performance APIs.
  662. *
  663. * hif_diag_read_access reads a 4 Byte aligned/length value from a
  664. * Target register or memory word.
  665. *
  666. * hif_diag_read_mem reads an arbitrary length of arbitrarily aligned memory.
  667. */
  668. QDF_STATUS hif_diag_read_access(struct hif_opaque_softc *hif_ctx,
  669. uint32_t address, uint32_t *data);
  670. QDF_STATUS hif_diag_read_mem(struct hif_opaque_softc *hif_ctx, uint32_t address,
  671. uint8_t *data, int nbytes);
  672. void hif_dump_target_memory(struct hif_opaque_softc *hif_ctx,
  673. void *ramdump_base, uint32_t address, uint32_t size);
  674. /*
  675. * APIs to handle HIF specific diagnostic write accesses. These APIs are
  676. * synchronous and only allowed to be called from a context that
  677. * can block (sleep).
  678. * They are not high performance APIs.
  679. *
  680. * hif_diag_write_access writes a 4 Byte aligned/length value to a
  681. * Target register or memory word.
  682. *
  683. * hif_diag_write_mem writes an arbitrary length of arbitrarily aligned memory.
  684. */
  685. QDF_STATUS hif_diag_write_access(struct hif_opaque_softc *hif_ctx,
  686. uint32_t address, uint32_t data);
  687. QDF_STATUS hif_diag_write_mem(struct hif_opaque_softc *hif_ctx,
  688. uint32_t address, uint8_t *data, int nbytes);
  689. typedef void (*fastpath_msg_handler)(void *, qdf_nbuf_t *, uint32_t);
  690. void hif_enable_polled_mode(struct hif_opaque_softc *hif_ctx);
  691. bool hif_is_polled_mode_enabled(struct hif_opaque_softc *hif_ctx);
  692. /*
  693. * Set the FASTPATH_mode_on flag in sc, for use by data path
  694. */
  695. #ifdef WLAN_FEATURE_FASTPATH
  696. void hif_enable_fastpath(struct hif_opaque_softc *hif_ctx);
  697. bool hif_is_fastpath_mode_enabled(struct hif_opaque_softc *hif_ctx);
  698. void *hif_get_ce_handle(struct hif_opaque_softc *hif_ctx, int ret);
  699. /**
  700. * hif_ce_fastpath_cb_register() - Register callback for fastpath msg handler
  701. * @handler: Callback funtcion
  702. * @context: handle for callback function
  703. *
  704. * Return: QDF_STATUS_SUCCESS on success or QDF_STATUS_E_FAILURE
  705. */
  706. QDF_STATUS hif_ce_fastpath_cb_register(
  707. struct hif_opaque_softc *hif_ctx,
  708. fastpath_msg_handler handler, void *context);
  709. #else
  710. static inline QDF_STATUS hif_ce_fastpath_cb_register(
  711. struct hif_opaque_softc *hif_ctx,
  712. fastpath_msg_handler handler, void *context)
  713. {
  714. return QDF_STATUS_E_FAILURE;
  715. }
  716. static inline void *hif_get_ce_handle(struct hif_opaque_softc *hif_ctx, int ret)
  717. {
  718. return NULL;
  719. }
  720. #endif
  721. /*
  722. * Enable/disable CDC max performance workaround
  723. * For max-performace set this to 0
  724. * To allow SoC to enter sleep set this to 1
  725. */
  726. #define CONFIG_DISABLE_CDC_MAX_PERF_WAR 0
  727. void hif_ipa_get_ce_resource(struct hif_opaque_softc *hif_ctx,
  728. qdf_shared_mem_t **ce_sr,
  729. uint32_t *ce_sr_ring_size,
  730. qdf_dma_addr_t *ce_reg_paddr);
  731. /**
  732. * @brief List of callbacks - filled in by HTC.
  733. */
  734. struct hif_msg_callbacks {
  735. void *Context;
  736. /**< context meaningful to HTC */
  737. QDF_STATUS (*txCompletionHandler)(void *Context, qdf_nbuf_t wbuf,
  738. uint32_t transferID,
  739. uint32_t toeplitz_hash_result);
  740. QDF_STATUS (*rxCompletionHandler)(void *Context, qdf_nbuf_t wbuf,
  741. uint8_t pipeID);
  742. void (*txResourceAvailHandler)(void *context, uint8_t pipe);
  743. void (*fwEventHandler)(void *context, QDF_STATUS status);
  744. void (*update_bundle_stats)(void *context, uint8_t no_of_pkt_in_bundle);
  745. };
  746. enum hif_target_status {
  747. TARGET_STATUS_CONNECTED = 0, /* target connected */
  748. TARGET_STATUS_RESET, /* target got reset */
  749. TARGET_STATUS_EJECT, /* target got ejected */
  750. TARGET_STATUS_SUSPEND /*target got suspend */
  751. };
  752. /**
  753. * enum hif_attribute_flags: configure hif
  754. *
  755. * @HIF_LOWDESC_CE_CFG: Configure HIF with Low descriptor CE
  756. * @HIF_LOWDESC_CE_NO_PKTLOG_CFG: Configure HIF with Low descriptor
  757. * + No pktlog CE
  758. */
  759. enum hif_attribute_flags {
  760. HIF_LOWDESC_CE_CFG = 1,
  761. HIF_LOWDESC_CE_NO_PKTLOG_CFG
  762. };
  763. #define HIF_DATA_ATTR_SET_TX_CLASSIFY(attr, v) \
  764. (attr |= (v & 0x01) << 5)
  765. #define HIF_DATA_ATTR_SET_ENCAPSULATION_TYPE(attr, v) \
  766. (attr |= (v & 0x03) << 6)
  767. #define HIF_DATA_ATTR_SET_ADDR_X_SEARCH_DISABLE(attr, v) \
  768. (attr |= (v & 0x01) << 13)
  769. #define HIF_DATA_ATTR_SET_ADDR_Y_SEARCH_DISABLE(attr, v) \
  770. (attr |= (v & 0x01) << 14)
  771. #define HIF_DATA_ATTR_SET_TOEPLITZ_HASH_ENABLE(attr, v) \
  772. (attr |= (v & 0x01) << 15)
  773. #define HIF_DATA_ATTR_SET_PACKET_OR_RESULT_OFFSET(attr, v) \
  774. (attr |= (v & 0x0FFF) << 16)
  775. #define HIF_DATA_ATTR_SET_ENABLE_11H(attr, v) \
  776. (attr |= (v & 0x01) << 30)
  777. struct hif_ul_pipe_info {
  778. unsigned int nentries;
  779. unsigned int nentries_mask;
  780. unsigned int sw_index;
  781. unsigned int write_index; /* cached copy */
  782. unsigned int hw_index; /* cached copy */
  783. void *base_addr_owner_space; /* Host address space */
  784. qdf_dma_addr_t base_addr_CE_space; /* CE address space */
  785. };
  786. struct hif_dl_pipe_info {
  787. unsigned int nentries;
  788. unsigned int nentries_mask;
  789. unsigned int sw_index;
  790. unsigned int write_index; /* cached copy */
  791. unsigned int hw_index; /* cached copy */
  792. void *base_addr_owner_space; /* Host address space */
  793. qdf_dma_addr_t base_addr_CE_space; /* CE address space */
  794. };
  795. struct hif_pipe_addl_info {
  796. uint32_t pci_mem;
  797. uint32_t ctrl_addr;
  798. struct hif_ul_pipe_info ul_pipe;
  799. struct hif_dl_pipe_info dl_pipe;
  800. };
  801. #ifdef CONFIG_SLUB_DEBUG_ON
  802. #define MSG_FLUSH_NUM 16
  803. #else /* PERF build */
  804. #define MSG_FLUSH_NUM 32
  805. #endif /* SLUB_DEBUG_ON */
  806. struct hif_bus_id;
  807. void hif_claim_device(struct hif_opaque_softc *hif_ctx);
  808. QDF_STATUS hif_get_config_item(struct hif_opaque_softc *hif_ctx,
  809. int opcode, void *config, uint32_t config_len);
  810. void hif_set_mailbox_swap(struct hif_opaque_softc *hif_ctx);
  811. void hif_mask_interrupt_call(struct hif_opaque_softc *hif_ctx);
  812. void hif_post_init(struct hif_opaque_softc *hif_ctx, void *hHTC,
  813. struct hif_msg_callbacks *callbacks);
  814. QDF_STATUS hif_start(struct hif_opaque_softc *hif_ctx);
  815. void hif_stop(struct hif_opaque_softc *hif_ctx);
  816. void hif_flush_surprise_remove(struct hif_opaque_softc *hif_ctx);
  817. void hif_dump(struct hif_opaque_softc *hif_ctx, uint8_t CmdId, bool start);
  818. void hif_trigger_dump(struct hif_opaque_softc *hif_ctx,
  819. uint8_t cmd_id, bool start);
  820. QDF_STATUS hif_send_head(struct hif_opaque_softc *hif_ctx, uint8_t PipeID,
  821. uint32_t transferID, uint32_t nbytes,
  822. qdf_nbuf_t wbuf, uint32_t data_attr);
  823. void hif_send_complete_check(struct hif_opaque_softc *hif_ctx, uint8_t PipeID,
  824. int force);
  825. void hif_shut_down_device(struct hif_opaque_softc *hif_ctx);
  826. void hif_get_default_pipe(struct hif_opaque_softc *hif_ctx, uint8_t *ULPipe,
  827. uint8_t *DLPipe);
  828. int hif_map_service_to_pipe(struct hif_opaque_softc *hif_ctx, uint16_t svc_id,
  829. uint8_t *ul_pipe, uint8_t *dl_pipe, int *ul_is_polled,
  830. int *dl_is_polled);
  831. uint16_t
  832. hif_get_free_queue_number(struct hif_opaque_softc *hif_ctx, uint8_t PipeID);
  833. void *hif_get_targetdef(struct hif_opaque_softc *hif_ctx);
  834. uint32_t hif_hia_item_address(uint32_t target_type, uint32_t item_offset);
  835. void hif_set_target_sleep(struct hif_opaque_softc *hif_ctx, bool sleep_ok,
  836. bool wait_for_it);
  837. int hif_check_fw_reg(struct hif_opaque_softc *hif_ctx);
  838. #ifndef HIF_PCI
  839. static inline int hif_check_soc_status(struct hif_opaque_softc *hif_ctx)
  840. {
  841. return 0;
  842. }
  843. #else
  844. int hif_check_soc_status(struct hif_opaque_softc *hif_ctx);
  845. #endif
  846. void hif_get_hw_info(struct hif_opaque_softc *hif_ctx, u32 *version,
  847. u32 *revision, const char **target_name);
  848. #ifdef RECEIVE_OFFLOAD
  849. /**
  850. * hif_offld_flush_cb_register() - Register the offld flush callback
  851. * @scn: HIF opaque context
  852. * @offld_flush_handler: Flush callback is either ol_flush, incase of rx_thread
  853. * Or GRO/LRO flush when RxThread is not enabled. Called
  854. * with corresponding context for flush.
  855. * Return: None
  856. */
  857. void hif_offld_flush_cb_register(struct hif_opaque_softc *scn,
  858. void (offld_flush_handler)(void *ol_ctx));
  859. /**
  860. * hif_offld_flush_cb_deregister() - deRegister the offld flush callback
  861. * @scn: HIF opaque context
  862. *
  863. * Return: None
  864. */
  865. void hif_offld_flush_cb_deregister(struct hif_opaque_softc *scn);
  866. #endif
  867. #ifdef WLAN_FEATURE_RX_SOFTIRQ_TIME_LIMIT
  868. /**
  869. * hif_exec_should_yield() - Check if hif napi context should yield
  870. * @hif_ctx - HIF opaque context
  871. * @grp_id - grp_id of the napi for which check needs to be done
  872. *
  873. * The function uses grp_id to look for NAPI and checks if NAPI needs to
  874. * yield. HIF_EXT_GROUP_MAX_YIELD_DURATION_NS is the duration used for
  875. * yield decision.
  876. *
  877. * Return: true if NAPI needs to yield, else false
  878. */
  879. bool hif_exec_should_yield(struct hif_opaque_softc *hif_ctx, uint grp_id);
  880. #else
  881. static inline bool hif_exec_should_yield(struct hif_opaque_softc *hif_ctx,
  882. uint grp_id)
  883. {
  884. return false;
  885. }
  886. #endif
  887. void hif_disable_isr(struct hif_opaque_softc *hif_ctx);
  888. void hif_reset_soc(struct hif_opaque_softc *hif_ctx);
  889. void hif_save_htc_htt_config_endpoint(struct hif_opaque_softc *hif_ctx,
  890. int htc_htt_tx_endpoint);
  891. /**
  892. * hif_open() - Create hif handle
  893. * @qdf_ctx: qdf context
  894. * @mode: Driver Mode
  895. * @bus_type: Bus Type
  896. * @cbk: CDS Callbacks
  897. * @psoc: psoc object manager
  898. *
  899. * API to open HIF Context
  900. *
  901. * Return: HIF Opaque Pointer
  902. */
  903. struct hif_opaque_softc *hif_open(qdf_device_t qdf_ctx,
  904. uint32_t mode,
  905. enum qdf_bus_type bus_type,
  906. struct hif_driver_state_callbacks *cbk,
  907. struct wlan_objmgr_psoc *psoc);
  908. /**
  909. * hif_init_dma_mask() - Set dma mask for the dev
  910. * @dev: dev for which DMA mask is to be set
  911. * @bus_type: bus type for the target
  912. *
  913. * This API sets the DMA mask for the device. before the datapath
  914. * memory pre-allocation is done. If the DMA mask is not set before
  915. * requesting the DMA memory, kernel defaults to a 32-bit DMA mask,
  916. * and does not utilize the full device capability.
  917. *
  918. * Return: 0 - success, non-zero on failure.
  919. */
  920. int hif_init_dma_mask(struct device *dev, enum qdf_bus_type bus_type);
  921. void hif_close(struct hif_opaque_softc *hif_ctx);
  922. QDF_STATUS hif_enable(struct hif_opaque_softc *hif_ctx, struct device *dev,
  923. void *bdev, const struct hif_bus_id *bid,
  924. enum qdf_bus_type bus_type,
  925. enum hif_enable_type type);
  926. void hif_disable(struct hif_opaque_softc *hif_ctx, enum hif_disable_type type);
  927. #ifdef CE_TASKLET_DEBUG_ENABLE
  928. void hif_enable_ce_latency_stats(struct hif_opaque_softc *hif_ctx,
  929. uint8_t value);
  930. #endif
  931. void hif_display_stats(struct hif_opaque_softc *hif_ctx);
  932. void hif_clear_stats(struct hif_opaque_softc *hif_ctx);
  933. /**
  934. * enum hif_pm_wake_irq_type - Wake interrupt type for Power Management
  935. * HIF_PM_INVALID_WAKE: Wake irq is invalid or not configured
  936. * HIF_PM_MSI_WAKE: Wake irq is MSI interrupt
  937. * HIF_PM_CE_WAKE: Wake irq is CE interrupt
  938. */
  939. typedef enum {
  940. HIF_PM_INVALID_WAKE,
  941. HIF_PM_MSI_WAKE,
  942. HIF_PM_CE_WAKE,
  943. } hif_pm_wake_irq_type;
  944. /**
  945. * hif_pm_get_wake_irq_type - Get wake irq type for Power Management
  946. * @hif_ctx: HIF context
  947. *
  948. * Return: enum hif_pm_wake_irq_type
  949. */
  950. hif_pm_wake_irq_type hif_pm_get_wake_irq_type(struct hif_opaque_softc *hif_ctx);
  951. /**
  952. * enum wlan_rtpm_dbgid - runtime pm put/get debug id
  953. * @RTPM_ID_RESVERD: Reserved
  954. * @RTPM_ID_WMI: WMI sending msg, expect put happen at
  955. * tx completion from CE level directly.
  956. * @RTPM_ID_HTC: pkt sending by HTT_DATA_MSG_SVC, expect
  957. * put from fw response or just in
  958. * htc_issue_packets
  959. * @RTPM_ID_QOS_NOTIFY: pm qos notifer
  960. * @RTPM_ID_DP_TX_DESC_ALLOC_FREE: tx desc alloc/free
  961. * @RTPM_ID_CE_SEND_FAST: operation in ce_send_fast, not include
  962. * the pkt put happens outside this function
  963. * @RTPM_ID_SUSPEND_RESUME: suspend/resume in hdd
  964. * @RTPM_ID_DW_TX_HW_ENQUEUE: operation in functin dp_tx_hw_enqueue
  965. * @RTPM_ID_HAL_REO_CMD: HAL_REO_CMD operation
  966. * @RTPM_ID_DP_PRINT_RING_STATS: operation in dp_print_ring_stats
  967. * @RTPM_ID_PM_STOP: operation in hif_pm_runtime_stop
  968. * @RTPM_ID_CONN_DISCONNECT:operation when issue disconnect
  969. * @RTPM_ID_SOC_REMOVE: operation in soc remove
  970. * @RTPM_ID_DRIVER_UNLOAD: operation in driver unload
  971. * @RTPM_ID_CE_INTR_HANDLER: operation from ce interrupt handler
  972. * @RTPM_ID_WAKE_INTR_HANDLER: operation from wake interrupt handler
  973. */
  974. /* New value added to the enum must also be reflected in function
  975. * rtpm_string_from_dbgid()
  976. */
  977. typedef enum {
  978. RTPM_ID_RESVERD = 0,
  979. RTPM_ID_WMI,
  980. RTPM_ID_HTC,
  981. RTPM_ID_QOS_NOTIFY,
  982. RTPM_ID_DP_TX_DESC_ALLOC_FREE,
  983. RTPM_ID_CE_SEND_FAST,
  984. RTPM_ID_SUSPEND_RESUME,
  985. RTPM_ID_DW_TX_HW_ENQUEUE,
  986. RTPM_ID_HAL_REO_CMD,
  987. RTPM_ID_DP_PRINT_RING_STATS,
  988. RTPM_ID_PM_STOP,
  989. RTPM_ID_CONN_DISCONNECT,
  990. RTPM_ID_SOC_REMOVE,
  991. RTPM_ID_DRIVER_UNLOAD,
  992. RTPM_ID_CE_INTR_HANDLER,
  993. RTPM_ID_WAKE_INTR_HANDLER,
  994. RTPM_ID_MAX,
  995. } wlan_rtpm_dbgid;
  996. /**
  997. * rtpm_string_from_dbgid() - Convert dbgid to respective string
  998. * @id - debug id
  999. *
  1000. * Debug support function to convert dbgid to string.
  1001. * Please note to add new string in the array at index equal to
  1002. * its enum value in wlan_rtpm_dbgid.
  1003. */
  1004. static inline char *rtpm_string_from_dbgid(wlan_rtpm_dbgid id)
  1005. {
  1006. static const char *strings[] = { "RTPM_ID_RESVERD",
  1007. "RTPM_ID_WMI",
  1008. "RTPM_ID_HTC",
  1009. "RTPM_ID_QOS_NOTIFY",
  1010. "RTPM_ID_DP_TX_DESC_ALLOC_FREE",
  1011. "RTPM_ID_CE_SEND_FAST",
  1012. "RTPM_ID_SUSPEND_RESUME",
  1013. "RTPM_ID_DW_TX_HW_ENQUEUE",
  1014. "RTPM_ID_HAL_REO_CMD",
  1015. "RTPM_ID_DP_PRINT_RING_STATS",
  1016. "RTPM_ID_PM_STOP",
  1017. "RTPM_ID_CONN_DISCONNECT",
  1018. "RTPM_ID_SOC_REMOVE",
  1019. "RTPM_ID_DRIVER_UNLOAD",
  1020. "RTPM_ID_CE_INTR_HANDLER",
  1021. "RTPM_ID_WAKE_INTR_HANDLER",
  1022. "RTPM_ID_MAX"};
  1023. return (char *)strings[id];
  1024. }
  1025. /**
  1026. * enum hif_ep_vote_type - hif ep vote type
  1027. * HIF_EP_VOTE_DP_ACCESS: vote type is specific DP
  1028. * HIF_EP_VOTE_NONDP_ACCESS: ep vote for over all access
  1029. */
  1030. enum hif_ep_vote_type {
  1031. HIF_EP_VOTE_DP_ACCESS,
  1032. HIF_EP_VOTE_NONDP_ACCESS
  1033. };
  1034. /**
  1035. * enum hif_ep_vote_access - hif ep vote access
  1036. * HIF_EP_VOTE_ACCESS_ENABLE: Enable ep voting
  1037. * HIF_EP_VOTE_INTERMEDIATE_ACCESS: allow during transistion
  1038. * HIF_EP_VOTE_ACCESS_DISABLE: disable ep voting
  1039. */
  1040. enum hif_ep_vote_access {
  1041. HIF_EP_VOTE_ACCESS_ENABLE,
  1042. HIF_EP_VOTE_INTERMEDIATE_ACCESS,
  1043. HIF_EP_VOTE_ACCESS_DISABLE
  1044. };
  1045. /**
  1046. * enum hif_pm_link_state - hif link state
  1047. * HIF_PM_LINK_STATE_DOWN: hif link state is down
  1048. * HIF_PM_LINK_STATE_UP: hif link state is up
  1049. */
  1050. enum hif_pm_link_state {
  1051. HIF_PM_LINK_STATE_DOWN,
  1052. HIF_PM_LINK_STATE_UP
  1053. };
  1054. /**
  1055. * enum hif_pm_htc_stats - hif runtime PM stats for HTC layer
  1056. * HIF_PM_HTC_STATS_GET_HTT_RESPONSE: PM stats for RTPM GET for HTT packets
  1057. with response
  1058. * HIF_PM_HTC_STATS_GET_HTT_NO_RESPONSE: PM stats for RTPM GET for HTT packets
  1059. with no response
  1060. * HIF_PM_HTC_STATS_PUT_HTT_RESPONSE: PM stats for RTPM PUT for HTT packets
  1061. with response
  1062. * HIF_PM_HTC_STATS_PUT_HTT_NO_RESPONSE: PM stats for RTPM PUT for HTT packets
  1063. with no response
  1064. * HIF_PM_HTC_STATS_PUT_HTT_ERROR: PM stats for RTPM PUT for failed HTT packets
  1065. * HIF_PM_HTC_STATS_PUT_HTC_CLEANUP: PM stats for RTPM PUT during HTC cleanup
  1066. * HIF_PM_HTC_STATS_GET_HTC_KICK_QUEUES: PM stats for RTPM GET done during
  1067. * htc_kick_queues()
  1068. * HIF_PM_HTC_STATS_PUT_HTC_KICK_QUEUES: PM stats for RTPM PUT done during
  1069. * htc_kick_queues()
  1070. * HIF_PM_HTC_STATS_GET_HTT_FETCH_PKTS: PM stats for RTPM GET while fetching
  1071. * HTT packets from endpoint TX queue
  1072. * HIF_PM_HTC_STATS_PUT_HTT_FETCH_PKTS: PM stats for RTPM PUT while fetching
  1073. * HTT packets from endpoint TX queue
  1074. */
  1075. enum hif_pm_htc_stats {
  1076. HIF_PM_HTC_STATS_GET_HTT_RESPONSE,
  1077. HIF_PM_HTC_STATS_GET_HTT_NO_RESPONSE,
  1078. HIF_PM_HTC_STATS_PUT_HTT_RESPONSE,
  1079. HIF_PM_HTC_STATS_PUT_HTT_NO_RESPONSE,
  1080. HIF_PM_HTC_STATS_PUT_HTT_ERROR,
  1081. HIF_PM_HTC_STATS_PUT_HTC_CLEANUP,
  1082. HIF_PM_HTC_STATS_GET_HTC_KICK_QUEUES,
  1083. HIF_PM_HTC_STATS_PUT_HTC_KICK_QUEUES,
  1084. HIF_PM_HTC_STATS_GET_HTT_FETCH_PKTS,
  1085. HIF_PM_HTC_STATS_PUT_HTT_FETCH_PKTS,
  1086. };
  1087. #ifdef FEATURE_RUNTIME_PM
  1088. struct hif_pm_runtime_lock;
  1089. void hif_fastpath_resume(struct hif_opaque_softc *hif_ctx);
  1090. int hif_pm_runtime_get_sync(struct hif_opaque_softc *hif_ctx,
  1091. wlan_rtpm_dbgid rtpm_dbgid);
  1092. int hif_pm_runtime_put_sync_suspend(struct hif_opaque_softc *hif_ctx,
  1093. wlan_rtpm_dbgid rtpm_dbgid);
  1094. int hif_pm_runtime_request_resume(struct hif_opaque_softc *hif_ctx,
  1095. wlan_rtpm_dbgid rtpm_dbgid);
  1096. int hif_pm_runtime_get(struct hif_opaque_softc *hif_ctx,
  1097. wlan_rtpm_dbgid rtpm_dbgid,
  1098. bool is_critical_ctx);
  1099. void hif_pm_runtime_get_noresume(struct hif_opaque_softc *hif_ctx,
  1100. wlan_rtpm_dbgid rtpm_dbgid);
  1101. int hif_pm_runtime_put(struct hif_opaque_softc *hif_ctx,
  1102. wlan_rtpm_dbgid rtpm_dbgid);
  1103. int hif_pm_runtime_put_noidle(struct hif_opaque_softc *hif_ctx,
  1104. wlan_rtpm_dbgid rtpm_dbgid);
  1105. void hif_pm_runtime_mark_last_busy(struct hif_opaque_softc *hif_ctx);
  1106. int hif_runtime_lock_init(qdf_runtime_lock_t *lock, const char *name);
  1107. void hif_runtime_lock_deinit(struct hif_opaque_softc *hif_ctx,
  1108. struct hif_pm_runtime_lock *lock);
  1109. int hif_pm_runtime_prevent_suspend(struct hif_opaque_softc *ol_sc,
  1110. struct hif_pm_runtime_lock *lock);
  1111. int hif_pm_runtime_allow_suspend(struct hif_opaque_softc *ol_sc,
  1112. struct hif_pm_runtime_lock *lock);
  1113. bool hif_pm_runtime_is_suspended(struct hif_opaque_softc *hif_ctx);
  1114. void hif_pm_runtime_suspend_lock(struct hif_opaque_softc *hif_ctx);
  1115. void hif_pm_runtime_suspend_unlock(struct hif_opaque_softc *hif_ctx);
  1116. int hif_pm_runtime_get_monitor_wake_intr(struct hif_opaque_softc *hif_ctx);
  1117. void hif_pm_runtime_set_monitor_wake_intr(struct hif_opaque_softc *hif_ctx,
  1118. int val);
  1119. void hif_pm_runtime_check_and_request_resume(struct hif_opaque_softc *hif_ctx);
  1120. void hif_pm_runtime_mark_dp_rx_busy(struct hif_opaque_softc *hif_ctx);
  1121. int hif_pm_runtime_is_dp_rx_busy(struct hif_opaque_softc *hif_ctx);
  1122. qdf_time_t hif_pm_runtime_get_dp_rx_busy_mark(struct hif_opaque_softc *hif_ctx);
  1123. int hif_pm_runtime_sync_resume(struct hif_opaque_softc *hif_ctx,
  1124. wlan_rtpm_dbgid rtpm_dbgid);
  1125. void hif_pm_runtime_update_stats(struct hif_opaque_softc *hif_ctx,
  1126. wlan_rtpm_dbgid rtpm_dbgid,
  1127. enum hif_pm_htc_stats stats);
  1128. /**
  1129. * hif_pm_set_link_state() - set link state during RTPM
  1130. * @hif_sc: HIF Context
  1131. *
  1132. * Return: None
  1133. */
  1134. void hif_pm_set_link_state(struct hif_opaque_softc *hif_handle, uint8_t val);
  1135. /**
  1136. * hif_is_link_state_up() - Is link state up
  1137. * @hif_sc: HIF Context
  1138. *
  1139. * Return: 1 link is up, 0 link is down
  1140. */
  1141. uint8_t hif_pm_get_link_state(struct hif_opaque_softc *hif_handle);
  1142. #else
  1143. struct hif_pm_runtime_lock {
  1144. const char *name;
  1145. };
  1146. static inline void hif_fastpath_resume(struct hif_opaque_softc *hif_ctx) {}
  1147. static inline int
  1148. hif_pm_runtime_get_sync(struct hif_opaque_softc *hif_ctx,
  1149. wlan_rtpm_dbgid rtpm_dbgid)
  1150. { return 0; }
  1151. static inline int
  1152. hif_pm_runtime_put_sync_suspend(struct hif_opaque_softc *hif_ctx,
  1153. wlan_rtpm_dbgid rtpm_dbgid)
  1154. { return 0; }
  1155. static inline int
  1156. hif_pm_runtime_request_resume(struct hif_opaque_softc *hif_ctx,
  1157. wlan_rtpm_dbgid rtpm_dbgid)
  1158. { return 0; }
  1159. static inline void
  1160. hif_pm_runtime_get_noresume(struct hif_opaque_softc *hif_ctx,
  1161. wlan_rtpm_dbgid rtpm_dbgid)
  1162. {}
  1163. static inline int
  1164. hif_pm_runtime_get(struct hif_opaque_softc *hif_ctx, wlan_rtpm_dbgid rtpm_dbgid,
  1165. bool is_critical_ctx)
  1166. { return 0; }
  1167. static inline int
  1168. hif_pm_runtime_put(struct hif_opaque_softc *hif_ctx, wlan_rtpm_dbgid rtpm_dbgid)
  1169. { return 0; }
  1170. static inline int
  1171. hif_pm_runtime_put_noidle(struct hif_opaque_softc *hif_ctx,
  1172. wlan_rtpm_dbgid rtpm_dbgid)
  1173. { return 0; }
  1174. static inline void
  1175. hif_pm_runtime_mark_last_busy(struct hif_opaque_softc *hif_ctx) {};
  1176. static inline int hif_runtime_lock_init(qdf_runtime_lock_t *lock,
  1177. const char *name)
  1178. { return 0; }
  1179. static inline void
  1180. hif_runtime_lock_deinit(struct hif_opaque_softc *hif_ctx,
  1181. struct hif_pm_runtime_lock *lock) {}
  1182. static inline int hif_pm_runtime_prevent_suspend(struct hif_opaque_softc *ol_sc,
  1183. struct hif_pm_runtime_lock *lock)
  1184. { return 0; }
  1185. static inline int hif_pm_runtime_allow_suspend(struct hif_opaque_softc *ol_sc,
  1186. struct hif_pm_runtime_lock *lock)
  1187. { return 0; }
  1188. static inline bool hif_pm_runtime_is_suspended(struct hif_opaque_softc *hif_ctx)
  1189. { return false; }
  1190. static inline void
  1191. hif_pm_runtime_suspend_lock(struct hif_opaque_softc *hif_ctx)
  1192. { return; }
  1193. static inline void
  1194. hif_pm_runtime_suspend_unlock(struct hif_opaque_softc *hif_ctx)
  1195. { return; }
  1196. static inline int
  1197. hif_pm_runtime_get_monitor_wake_intr(struct hif_opaque_softc *hif_ctx)
  1198. { return 0; }
  1199. static inline void
  1200. hif_pm_runtime_set_monitor_wake_intr(struct hif_opaque_softc *hif_ctx, int val)
  1201. { return; }
  1202. static inline void
  1203. hif_pm_runtime_check_and_request_resume(struct hif_opaque_softc *hif_ctx)
  1204. { return; }
  1205. static inline void
  1206. hif_pm_runtime_mark_dp_rx_busy(struct hif_opaque_softc *hif_ctx) {};
  1207. static inline int
  1208. hif_pm_runtime_is_dp_rx_busy(struct hif_opaque_softc *hif_ctx)
  1209. { return 0; }
  1210. static inline qdf_time_t
  1211. hif_pm_runtime_get_dp_rx_busy_mark(struct hif_opaque_softc *hif_ctx)
  1212. { return 0; }
  1213. static inline int hif_pm_runtime_sync_resume(struct hif_opaque_softc *hif_ctx,
  1214. wlan_rtpm_dbgid rtpm_dbgid)
  1215. { return 0; }
  1216. static inline
  1217. void hif_pm_set_link_state(struct hif_opaque_softc *hif_handle, uint8_t val)
  1218. {}
  1219. static inline
  1220. void hif_pm_runtime_update_stats(struct hif_opaque_softc *hif_ctx,
  1221. wlan_rtpm_dbgid rtpm_dbgid,
  1222. enum hif_pm_htc_stats stats)
  1223. {}
  1224. #endif
  1225. void hif_enable_power_management(struct hif_opaque_softc *hif_ctx,
  1226. bool is_packet_log_enabled);
  1227. void hif_disable_power_management(struct hif_opaque_softc *hif_ctx);
  1228. void hif_vote_link_down(struct hif_opaque_softc *hif_ctx);
  1229. void hif_vote_link_up(struct hif_opaque_softc *hif_ctx);
  1230. bool hif_can_suspend_link(struct hif_opaque_softc *hif_ctx);
  1231. #ifdef IPA_OFFLOAD
  1232. /**
  1233. * hif_get_ipa_hw_type() - get IPA hw type
  1234. *
  1235. * This API return the IPA hw type.
  1236. *
  1237. * Return: IPA hw type
  1238. */
  1239. static inline
  1240. enum ipa_hw_type hif_get_ipa_hw_type(void)
  1241. {
  1242. return ipa_get_hw_type();
  1243. }
  1244. /**
  1245. * hif_get_ipa_present() - get IPA hw status
  1246. *
  1247. * This API return the IPA hw status.
  1248. *
  1249. * Return: true if IPA is present or false otherwise
  1250. */
  1251. static inline
  1252. bool hif_get_ipa_present(void)
  1253. {
  1254. if (ipa_uc_reg_rdyCB(NULL) != -EPERM)
  1255. return true;
  1256. else
  1257. return false;
  1258. }
  1259. #endif
  1260. int hif_bus_resume(struct hif_opaque_softc *hif_ctx);
  1261. /**
  1262. * hif_bus_ealry_suspend() - stop non wmi tx traffic
  1263. * @context: hif context
  1264. */
  1265. int hif_bus_early_suspend(struct hif_opaque_softc *hif_ctx);
  1266. /**
  1267. * hif_bus_late_resume() - resume non wmi traffic
  1268. * @context: hif context
  1269. */
  1270. int hif_bus_late_resume(struct hif_opaque_softc *hif_ctx);
  1271. int hif_bus_suspend(struct hif_opaque_softc *hif_ctx);
  1272. int hif_bus_resume_noirq(struct hif_opaque_softc *hif_ctx);
  1273. int hif_bus_suspend_noirq(struct hif_opaque_softc *hif_ctx);
  1274. /**
  1275. * hif_apps_irqs_enable() - Enables all irqs from the APPS side
  1276. * @hif_ctx: an opaque HIF handle to use
  1277. *
  1278. * As opposed to the standard hif_irq_enable, this function always applies to
  1279. * the APPS side kernel interrupt handling.
  1280. *
  1281. * Return: errno
  1282. */
  1283. int hif_apps_irqs_enable(struct hif_opaque_softc *hif_ctx);
  1284. /**
  1285. * hif_apps_irqs_disable() - Disables all irqs from the APPS side
  1286. * @hif_ctx: an opaque HIF handle to use
  1287. *
  1288. * As opposed to the standard hif_irq_disable, this function always applies to
  1289. * the APPS side kernel interrupt handling.
  1290. *
  1291. * Return: errno
  1292. */
  1293. int hif_apps_irqs_disable(struct hif_opaque_softc *hif_ctx);
  1294. /**
  1295. * hif_apps_wake_irq_enable() - Enables the wake irq from the APPS side
  1296. * @hif_ctx: an opaque HIF handle to use
  1297. *
  1298. * As opposed to the standard hif_irq_enable, this function always applies to
  1299. * the APPS side kernel interrupt handling.
  1300. *
  1301. * Return: errno
  1302. */
  1303. int hif_apps_wake_irq_enable(struct hif_opaque_softc *hif_ctx);
  1304. /**
  1305. * hif_apps_wake_irq_disable() - Disables the wake irq from the APPS side
  1306. * @hif_ctx: an opaque HIF handle to use
  1307. *
  1308. * As opposed to the standard hif_irq_disable, this function always applies to
  1309. * the APPS side kernel interrupt handling.
  1310. *
  1311. * Return: errno
  1312. */
  1313. int hif_apps_wake_irq_disable(struct hif_opaque_softc *hif_ctx);
  1314. /**
  1315. * hif_apps_enable_irq_wake() - Enables the irq wake from the APPS side
  1316. * @hif_ctx: an opaque HIF handle to use
  1317. *
  1318. * This function always applies to the APPS side kernel interrupt handling
  1319. * to wake the system from suspend.
  1320. *
  1321. * Return: errno
  1322. */
  1323. int hif_apps_enable_irq_wake(struct hif_opaque_softc *hif_ctx);
  1324. /**
  1325. * hif_apps_disable_irq_wake() - Disables the wake irq from the APPS side
  1326. * @hif_ctx: an opaque HIF handle to use
  1327. *
  1328. * This function always applies to the APPS side kernel interrupt handling
  1329. * to disable the wake irq.
  1330. *
  1331. * Return: errno
  1332. */
  1333. int hif_apps_disable_irq_wake(struct hif_opaque_softc *hif_ctx);
  1334. /**
  1335. * hif_apps_enable_irqs_except_wake_irq() - Enables all irqs except wake_irq
  1336. * @hif_ctx: an opaque HIF handle to use
  1337. *
  1338. * As opposed to the standard hif_irq_enable, this function always applies to
  1339. * the APPS side kernel interrupt handling.
  1340. *
  1341. * Return: errno
  1342. */
  1343. int hif_apps_enable_irqs_except_wake_irq(struct hif_opaque_softc *hif_ctx);
  1344. /**
  1345. * hif_apps_disable_irqs_except_wake_irq() - Disables all irqs except wake_irq
  1346. * @hif_ctx: an opaque HIF handle to use
  1347. *
  1348. * As opposed to the standard hif_irq_disable, this function always applies to
  1349. * the APPS side kernel interrupt handling.
  1350. *
  1351. * Return: errno
  1352. */
  1353. int hif_apps_disable_irqs_except_wake_irq(struct hif_opaque_softc *hif_ctx);
  1354. #ifdef FEATURE_RUNTIME_PM
  1355. void hif_print_runtime_pm_prevent_list(struct hif_opaque_softc *hif_ctx);
  1356. int hif_pre_runtime_suspend(struct hif_opaque_softc *hif_ctx);
  1357. void hif_pre_runtime_resume(struct hif_opaque_softc *hif_ctx);
  1358. int hif_runtime_suspend(struct hif_opaque_softc *hif_ctx);
  1359. int hif_runtime_resume(struct hif_opaque_softc *hif_ctx);
  1360. void hif_process_runtime_suspend_success(struct hif_opaque_softc *hif_ctx);
  1361. void hif_process_runtime_suspend_failure(struct hif_opaque_softc *hif_ctx);
  1362. void hif_process_runtime_resume_success(struct hif_opaque_softc *hif_ctx);
  1363. #else
  1364. static inline void
  1365. hif_print_runtime_pm_prevent_list(struct hif_opaque_softc *hif_ctx)
  1366. {}
  1367. #endif
  1368. int hif_get_irq_num(struct hif_opaque_softc *scn, int *irq, uint32_t size);
  1369. int hif_dump_registers(struct hif_opaque_softc *scn);
  1370. int ol_copy_ramdump(struct hif_opaque_softc *scn);
  1371. void hif_crash_shutdown(struct hif_opaque_softc *hif_ctx);
  1372. void hif_get_hw_info(struct hif_opaque_softc *hif_ctx, u32 *version,
  1373. u32 *revision, const char **target_name);
  1374. enum qdf_bus_type hif_get_bus_type(struct hif_opaque_softc *hif_hdl);
  1375. struct hif_target_info *hif_get_target_info_handle(struct hif_opaque_softc *
  1376. scn);
  1377. struct hif_config_info *hif_get_ini_handle(struct hif_opaque_softc *hif_ctx);
  1378. struct ramdump_info *hif_get_ramdump_ctx(struct hif_opaque_softc *hif_ctx);
  1379. enum hif_target_status hif_get_target_status(struct hif_opaque_softc *hif_ctx);
  1380. void hif_set_target_status(struct hif_opaque_softc *hif_ctx, enum
  1381. hif_target_status);
  1382. void hif_init_ini_config(struct hif_opaque_softc *hif_ctx,
  1383. struct hif_config_info *cfg);
  1384. void hif_update_tx_ring(struct hif_opaque_softc *osc, u_int32_t num_htt_cmpls);
  1385. qdf_nbuf_t hif_batch_send(struct hif_opaque_softc *osc, qdf_nbuf_t msdu,
  1386. uint32_t transfer_id, u_int32_t len, uint32_t sendhead);
  1387. QDF_STATUS hif_send_single(struct hif_opaque_softc *osc, qdf_nbuf_t msdu,
  1388. uint32_t transfer_id, u_int32_t len);
  1389. int hif_send_fast(struct hif_opaque_softc *osc, qdf_nbuf_t nbuf,
  1390. uint32_t transfer_id, uint32_t download_len);
  1391. void hif_pkt_dl_len_set(void *hif_sc, unsigned int pkt_download_len);
  1392. void hif_ce_war_disable(void);
  1393. void hif_ce_war_enable(void);
  1394. void hif_disable_interrupt(struct hif_opaque_softc *osc, uint32_t pipe_num);
  1395. #ifdef QCA_NSS_WIFI_OFFLOAD_SUPPORT
  1396. struct hif_pipe_addl_info *hif_get_addl_pipe_info(struct hif_opaque_softc *osc,
  1397. struct hif_pipe_addl_info *hif_info, uint32_t pipe_number);
  1398. uint32_t hif_set_nss_wifiol_mode(struct hif_opaque_softc *osc,
  1399. uint32_t pipe_num);
  1400. int32_t hif_get_nss_wifiol_bypass_nw_process(struct hif_opaque_softc *osc);
  1401. #endif /* QCA_NSS_WIFI_OFFLOAD_SUPPORT */
  1402. void hif_set_bundle_mode(struct hif_opaque_softc *hif_ctx, bool enabled,
  1403. int rx_bundle_cnt);
  1404. int hif_bus_reset_resume(struct hif_opaque_softc *hif_ctx);
  1405. void hif_set_attribute(struct hif_opaque_softc *osc, uint8_t hif_attrib);
  1406. void *hif_get_lro_info(int ctx_id, struct hif_opaque_softc *hif_hdl);
  1407. enum hif_exec_type {
  1408. HIF_EXEC_NAPI_TYPE,
  1409. HIF_EXEC_TASKLET_TYPE,
  1410. };
  1411. typedef uint32_t (*ext_intr_handler)(void *, uint32_t);
  1412. /**
  1413. * hif_get_int_ctx_irq_num() - retrieve an irq num for an interrupt context id
  1414. * @softc: hif opaque context owning the exec context
  1415. * @id: the id of the interrupt context
  1416. *
  1417. * Return: IRQ number of the first (zero'th) IRQ within the interrupt context ID
  1418. * 'id' registered with the OS
  1419. */
  1420. int32_t hif_get_int_ctx_irq_num(struct hif_opaque_softc *softc,
  1421. uint8_t id);
  1422. /**
  1423. * hif_configure_ext_group_interrupts() - Congigure ext group intrrupts
  1424. * @hif_ctx: hif opaque context
  1425. *
  1426. * Return: QDF_STATUS
  1427. */
  1428. QDF_STATUS hif_configure_ext_group_interrupts(struct hif_opaque_softc *hif_ctx);
  1429. /**
  1430. * hif_deconfigure_ext_group_interrupts() - Deconfigure ext group intrrupts
  1431. * @hif_ctx: hif opaque context
  1432. *
  1433. * Return: None
  1434. */
  1435. void hif_deconfigure_ext_group_interrupts(struct hif_opaque_softc *hif_ctx);
  1436. /**
  1437. * hif_register_ext_group() - API to register external group
  1438. * interrupt handler.
  1439. * @hif_ctx : HIF Context
  1440. * @numirq: number of irq's in the group
  1441. * @irq: array of irq values
  1442. * @handler: callback interrupt handler function
  1443. * @cb_ctx: context to passed in callback
  1444. * @type: napi vs tasklet
  1445. *
  1446. * Return: QDF_STATUS
  1447. */
  1448. QDF_STATUS hif_register_ext_group(struct hif_opaque_softc *hif_ctx,
  1449. uint32_t numirq, uint32_t irq[],
  1450. ext_intr_handler handler,
  1451. void *cb_ctx, const char *context_name,
  1452. enum hif_exec_type type, uint32_t scale);
  1453. void hif_deregister_exec_group(struct hif_opaque_softc *hif_ctx,
  1454. const char *context_name);
  1455. void hif_update_pipe_callback(struct hif_opaque_softc *osc,
  1456. u_int8_t pipeid,
  1457. struct hif_msg_callbacks *callbacks);
  1458. /**
  1459. * hif_print_napi_stats() - Display HIF NAPI stats
  1460. * @hif_ctx - HIF opaque context
  1461. *
  1462. * Return: None
  1463. */
  1464. void hif_print_napi_stats(struct hif_opaque_softc *hif_ctx);
  1465. /* hif_clear_napi_stats() - function clears the stats of the
  1466. * latency when called.
  1467. * @hif_ctx - the HIF context to assign the callback to
  1468. *
  1469. * Return: None
  1470. */
  1471. void hif_clear_napi_stats(struct hif_opaque_softc *hif_ctx);
  1472. #ifdef __cplusplus
  1473. }
  1474. #endif
  1475. #ifdef FORCE_WAKE
  1476. /**
  1477. * hif_force_wake_request() - Function to wake from power collapse
  1478. * @handle: HIF opaque handle
  1479. *
  1480. * Description: API to check if the device is awake or not before
  1481. * read/write to BAR + 4K registers. If device is awake return
  1482. * success otherwise write '1' to
  1483. * PCIE_PCIE_LOCAL_REG_PCIE_SOC_WAKE_PCIE_LOCAL_REG which will interrupt
  1484. * the device and does wakeup the PCI and MHI within 50ms
  1485. * and then the device writes a value to
  1486. * PCIE_SOC_PCIE_REG_PCIE_SCRATCH_0_SOC_PCIE_REG to complete the
  1487. * handshake process to let the host know the device is awake.
  1488. *
  1489. * Return: zero - success/non-zero - failure
  1490. */
  1491. int hif_force_wake_request(struct hif_opaque_softc *handle);
  1492. /**
  1493. * hif_force_wake_release() - API to release/reset the SOC wake register
  1494. * from interrupting the device.
  1495. * @handle: HIF opaque handle
  1496. *
  1497. * Description: API to set the
  1498. * PCIE_PCIE_LOCAL_REG_PCIE_SOC_WAKE_PCIE_LOCAL_REG to '0'
  1499. * to release the interrupt line.
  1500. *
  1501. * Return: zero - success/non-zero - failure
  1502. */
  1503. int hif_force_wake_release(struct hif_opaque_softc *handle);
  1504. #else
  1505. static inline
  1506. int hif_force_wake_request(struct hif_opaque_softc *handle)
  1507. {
  1508. return 0;
  1509. }
  1510. static inline
  1511. int hif_force_wake_release(struct hif_opaque_softc *handle)
  1512. {
  1513. return 0;
  1514. }
  1515. #endif /* FORCE_WAKE */
  1516. #ifdef FEATURE_HAL_DELAYED_REG_WRITE
  1517. /**
  1518. * hif_prevent_link_low_power_states() - Prevent from going to low power states
  1519. * @hif - HIF opaque context
  1520. *
  1521. * Return: 0 on success. Error code on failure.
  1522. */
  1523. int hif_prevent_link_low_power_states(struct hif_opaque_softc *hif);
  1524. /**
  1525. * hif_allow_link_low_power_states() - Allow link to go to low power states
  1526. * @hif - HIF opaque context
  1527. *
  1528. * Return: None
  1529. */
  1530. void hif_allow_link_low_power_states(struct hif_opaque_softc *hif);
  1531. #else
  1532. static inline
  1533. int hif_prevent_link_low_power_states(struct hif_opaque_softc *hif)
  1534. {
  1535. return 0;
  1536. }
  1537. static inline
  1538. void hif_allow_link_low_power_states(struct hif_opaque_softc *hif)
  1539. {
  1540. }
  1541. #endif
  1542. void *hif_get_dev_ba(struct hif_opaque_softc *hif_handle);
  1543. void *hif_get_dev_ba_ce(struct hif_opaque_softc *hif_handle);
  1544. /**
  1545. * hif_set_initial_wakeup_cb() - set the initial wakeup event handler function
  1546. * @hif_ctx - the HIF context to assign the callback to
  1547. * @callback - the callback to assign
  1548. * @priv - the private data to pass to the callback when invoked
  1549. *
  1550. * Return: None
  1551. */
  1552. void hif_set_initial_wakeup_cb(struct hif_opaque_softc *hif_ctx,
  1553. void (*callback)(void *),
  1554. void *priv);
  1555. /*
  1556. * Note: For MCL, #if defined (HIF_CONFIG_SLUB_DEBUG_ON) needs to be checked
  1557. * for defined here
  1558. */
  1559. #if defined(HIF_CONFIG_SLUB_DEBUG_ON) || defined(HIF_CE_DEBUG_DATA_BUF)
  1560. ssize_t hif_dump_desc_trace_buf(struct device *dev,
  1561. struct device_attribute *attr, char *buf);
  1562. ssize_t hif_input_desc_trace_buf_index(struct hif_softc *scn,
  1563. const char *buf, size_t size);
  1564. ssize_t hif_ce_en_desc_hist(struct hif_softc *scn,
  1565. const char *buf, size_t size);
  1566. ssize_t hif_disp_ce_enable_desc_data_hist(struct hif_softc *scn, char *buf);
  1567. ssize_t hif_dump_desc_event(struct hif_softc *scn, char *buf);
  1568. #endif/*#if defined(HIF_CONFIG_SLUB_DEBUG_ON)||defined(HIF_CE_DEBUG_DATA_BUF)*/
  1569. /**
  1570. * hif_set_ce_service_max_yield_time() - sets CE service max yield time
  1571. * @hif: hif context
  1572. * @ce_service_max_yield_time: CE service max yield time to set
  1573. *
  1574. * This API storess CE service max yield time in hif context based
  1575. * on ini value.
  1576. *
  1577. * Return: void
  1578. */
  1579. void hif_set_ce_service_max_yield_time(struct hif_opaque_softc *hif,
  1580. uint32_t ce_service_max_yield_time);
  1581. /**
  1582. * hif_get_ce_service_max_yield_time() - get CE service max yield time
  1583. * @hif: hif context
  1584. *
  1585. * This API returns CE service max yield time.
  1586. *
  1587. * Return: CE service max yield time
  1588. */
  1589. unsigned long long
  1590. hif_get_ce_service_max_yield_time(struct hif_opaque_softc *hif);
  1591. /**
  1592. * hif_set_ce_service_max_rx_ind_flush() - sets CE service max rx ind flush
  1593. * @hif: hif context
  1594. * @ce_service_max_rx_ind_flush: CE service max rx ind flush to set
  1595. *
  1596. * This API stores CE service max rx ind flush in hif context based
  1597. * on ini value.
  1598. *
  1599. * Return: void
  1600. */
  1601. void hif_set_ce_service_max_rx_ind_flush(struct hif_opaque_softc *hif,
  1602. uint8_t ce_service_max_rx_ind_flush);
  1603. #ifdef OL_ATH_SMART_LOGGING
  1604. /*
  1605. * hif_log_ce_dump() - Copy all the CE DEST ring to buf
  1606. * @scn : HIF handler
  1607. * @buf_cur: Current pointer in ring buffer
  1608. * @buf_init:Start of the ring buffer
  1609. * @buf_sz: Size of the ring buffer
  1610. * @ce: Copy Engine id
  1611. * @skb_sz: Max size of the SKB buffer to be copied
  1612. *
  1613. * Calls the respective function to dump all the CE SRC/DEST ring descriptors
  1614. * and buffers pointed by them in to the given buf
  1615. *
  1616. * Return: Current pointer in ring buffer
  1617. */
  1618. uint8_t *hif_log_dump_ce(struct hif_softc *scn, uint8_t *buf_cur,
  1619. uint8_t *buf_init, uint32_t buf_sz,
  1620. uint32_t ce, uint32_t skb_sz);
  1621. #endif /* OL_ATH_SMART_LOGGING */
  1622. /*
  1623. * hif_softc_to_hif_opaque_softc - API to convert hif_softc handle
  1624. * to hif_opaque_softc handle
  1625. * @hif_handle - hif_softc type
  1626. *
  1627. * Return: hif_opaque_softc type
  1628. */
  1629. static inline struct hif_opaque_softc *
  1630. hif_softc_to_hif_opaque_softc(struct hif_softc *hif_handle)
  1631. {
  1632. return (struct hif_opaque_softc *)hif_handle;
  1633. }
  1634. #if defined(HIF_IPCI) && defined(FEATURE_HAL_DELAYED_REG_WRITE)
  1635. QDF_STATUS hif_try_prevent_ep_vote_access(struct hif_opaque_softc *hif_ctx);
  1636. void hif_set_ep_intermediate_vote_access(struct hif_opaque_softc *hif_ctx);
  1637. void hif_allow_ep_vote_access(struct hif_opaque_softc *hif_ctx);
  1638. void hif_set_ep_vote_access(struct hif_opaque_softc *hif_ctx,
  1639. uint8_t type, uint8_t access);
  1640. uint8_t hif_get_ep_vote_access(struct hif_opaque_softc *hif_ctx,
  1641. uint8_t type);
  1642. #else
  1643. static inline QDF_STATUS
  1644. hif_try_prevent_ep_vote_access(struct hif_opaque_softc *hif_ctx)
  1645. {
  1646. return QDF_STATUS_SUCCESS;
  1647. }
  1648. static inline void
  1649. hif_set_ep_intermediate_vote_access(struct hif_opaque_softc *hif_ctx)
  1650. {
  1651. }
  1652. static inline void
  1653. hif_allow_ep_vote_access(struct hif_opaque_softc *hif_ctx)
  1654. {
  1655. }
  1656. static inline void
  1657. hif_set_ep_vote_access(struct hif_opaque_softc *hif_ctx,
  1658. uint8_t type, uint8_t access)
  1659. {
  1660. }
  1661. static inline uint8_t
  1662. hif_get_ep_vote_access(struct hif_opaque_softc *hif_ctx,
  1663. uint8_t type)
  1664. {
  1665. return HIF_EP_VOTE_ACCESS_ENABLE;
  1666. }
  1667. #endif
  1668. #ifdef FORCE_WAKE
  1669. /**
  1670. * hif_srng_init_phase(): Indicate srng initialization phase
  1671. * to avoid force wake as UMAC power collapse is not yet
  1672. * enabled
  1673. * @hif_ctx: hif opaque handle
  1674. * @init_phase: initialization phase
  1675. *
  1676. * Return: None
  1677. */
  1678. void hif_srng_init_phase(struct hif_opaque_softc *hif_ctx,
  1679. bool init_phase);
  1680. #else
  1681. static inline
  1682. void hif_srng_init_phase(struct hif_opaque_softc *hif_ctx,
  1683. bool init_phase)
  1684. {
  1685. }
  1686. #endif /* FORCE_WAKE */
  1687. #ifdef HIF_IPCI
  1688. /**
  1689. * hif_shutdown_notifier_cb - Call back for shutdown notifier
  1690. * @ctx: hif handle
  1691. *
  1692. * Return: None
  1693. */
  1694. void hif_shutdown_notifier_cb(void *ctx);
  1695. #else
  1696. static inline
  1697. void hif_shutdown_notifier_cb(void *ctx)
  1698. {
  1699. }
  1700. #endif /* HIF_IPCI */
  1701. #ifdef HIF_CE_LOG_INFO
  1702. /**
  1703. * hif_log_ce_info() - API to log ce info
  1704. * @scn: hif handle
  1705. * @data: hang event data buffer
  1706. * @offset: offset at which data needs to be written
  1707. *
  1708. * Return: None
  1709. */
  1710. void hif_log_ce_info(struct hif_softc *scn, uint8_t *data,
  1711. unsigned int *offset);
  1712. #else
  1713. static inline
  1714. void hif_log_ce_info(struct hif_softc *scn, uint8_t *data,
  1715. unsigned int *offset)
  1716. {
  1717. }
  1718. #endif
  1719. #ifdef HIF_CPU_PERF_AFFINE_MASK
  1720. /**
  1721. * hif_config_irq_set_perf_affinity_hint() - API to set affinity
  1722. * @hif_ctx: hif opaque handle
  1723. *
  1724. * This function is used to move the WLAN IRQs to perf cores in
  1725. * case of defconfig builds.
  1726. *
  1727. * Return: None
  1728. */
  1729. void hif_config_irq_set_perf_affinity_hint(
  1730. struct hif_opaque_softc *hif_ctx);
  1731. #else
  1732. static inline void hif_config_irq_set_perf_affinity_hint(
  1733. struct hif_opaque_softc *hif_ctx)
  1734. {
  1735. }
  1736. #endif
  1737. /**
  1738. * hif_apps_grp_irqs_enable() - enable ext grp irqs
  1739. * @hif - HIF opaque context
  1740. *
  1741. * Return: 0 on success. Error code on failure.
  1742. */
  1743. int hif_apps_grp_irqs_enable(struct hif_opaque_softc *hif_ctx);
  1744. /**
  1745. * hif_apps_grp_irqs_disable() - disable ext grp irqs
  1746. * @hif - HIF opaque context
  1747. *
  1748. * Return: 0 on success. Error code on failure.
  1749. */
  1750. int hif_apps_grp_irqs_disable(struct hif_opaque_softc *hif_ctx);
  1751. /**
  1752. * hif_disable_grp_irqs() - disable ext grp irqs
  1753. * @hif - HIF opaque context
  1754. *
  1755. * Return: 0 on success. Error code on failure.
  1756. */
  1757. int hif_disable_grp_irqs(struct hif_opaque_softc *scn);
  1758. /**
  1759. * hif_enable_grp_irqs() - enable ext grp irqs
  1760. * @hif - HIF opaque context
  1761. *
  1762. * Return: 0 on success. Error code on failure.
  1763. */
  1764. int hif_enable_grp_irqs(struct hif_opaque_softc *scn);
  1765. enum hif_credit_exchange_type {
  1766. HIF_REQUEST_CREDIT,
  1767. HIF_PROCESS_CREDIT_REPORT,
  1768. };
  1769. enum hif_detect_latency_type {
  1770. HIF_DETECT_TASKLET,
  1771. HIF_DETECT_CREDIT,
  1772. HIF_DETECT_UNKNOWN
  1773. };
  1774. #ifdef HIF_DETECTION_LATENCY_ENABLE
  1775. void hif_latency_detect_credit_record_time(
  1776. enum hif_credit_exchange_type type,
  1777. struct hif_opaque_softc *hif_ctx);
  1778. void hif_latency_detect_timer_start(struct hif_opaque_softc *hif_ctx);
  1779. void hif_latency_detect_timer_stop(struct hif_opaque_softc *hif_ctx);
  1780. void hif_tasklet_latency(struct hif_softc *scn, bool from_timer);
  1781. void hif_credit_latency(struct hif_softc *scn, bool from_timer);
  1782. void hif_check_detection_latency(struct hif_softc *scn,
  1783. bool from_timer,
  1784. uint32_t bitmap_type);
  1785. void hif_set_enable_detection(struct hif_opaque_softc *hif_ctx, bool value);
  1786. #else
  1787. static inline
  1788. void hif_latency_detect_timer_start(struct hif_opaque_softc *hif_ctx)
  1789. {}
  1790. static inline
  1791. void hif_latency_detect_timer_stop(struct hif_opaque_softc *hif_ctx)
  1792. {}
  1793. static inline
  1794. void hif_latency_detect_credit_record_time(
  1795. enum hif_credit_exchange_type type,
  1796. struct hif_opaque_softc *hif_ctx)
  1797. {}
  1798. static inline
  1799. void hif_check_detection_latency(struct hif_softc *scn,
  1800. bool from_timer,
  1801. uint32_t bitmap_type)
  1802. {}
  1803. static inline
  1804. void hif_set_enable_detection(struct hif_opaque_softc *hif_ctx, bool value)
  1805. {}
  1806. #endif
  1807. #ifdef SYSTEM_PM_CHECK
  1808. /**
  1809. * __hif_system_pm_set_state() - Set system pm state
  1810. * @hif: hif opaque handle
  1811. * @state: system state
  1812. *
  1813. * Return: None
  1814. */
  1815. void __hif_system_pm_set_state(struct hif_opaque_softc *hif,
  1816. enum hif_system_pm_state state);
  1817. /**
  1818. * hif_system_pm_set_state_on() - Set system pm state to ON
  1819. * @hif: hif opaque handle
  1820. *
  1821. * Return: None
  1822. */
  1823. static inline
  1824. void hif_system_pm_set_state_on(struct hif_opaque_softc *hif)
  1825. {
  1826. __hif_system_pm_set_state(hif, HIF_SYSTEM_PM_STATE_ON);
  1827. }
  1828. /**
  1829. * hif_system_pm_set_state_resuming() - Set system pm state to resuming
  1830. * @hif: hif opaque handle
  1831. *
  1832. * Return: None
  1833. */
  1834. static inline
  1835. void hif_system_pm_set_state_resuming(struct hif_opaque_softc *hif)
  1836. {
  1837. __hif_system_pm_set_state(hif, HIF_SYSTEM_PM_STATE_BUS_RESUMING);
  1838. }
  1839. /**
  1840. * hif_system_pm_set_state_suspending() - Set system pm state to suspending
  1841. * @hif: hif opaque handle
  1842. *
  1843. * Return: None
  1844. */
  1845. static inline
  1846. void hif_system_pm_set_state_suspending(struct hif_opaque_softc *hif)
  1847. {
  1848. __hif_system_pm_set_state(hif, HIF_SYSTEM_PM_STATE_BUS_SUSPENDING);
  1849. }
  1850. /**
  1851. * hif_system_pm_set_state_suspended() - Set system pm state to suspended
  1852. * @hif: hif opaque handle
  1853. *
  1854. * Return: None
  1855. */
  1856. static inline
  1857. void hif_system_pm_set_state_suspended(struct hif_opaque_softc *hif)
  1858. {
  1859. __hif_system_pm_set_state(hif, HIF_SYSTEM_PM_STATE_BUS_SUSPENDED);
  1860. }
  1861. /**
  1862. * hif_system_pm_get_state() - Get system pm state
  1863. * @hif: hif opaque handle
  1864. *
  1865. * Return: system state
  1866. */
  1867. int32_t hif_system_pm_get_state(struct hif_opaque_softc *hif);
  1868. /**
  1869. * hif_system_pm_state_check() - Check system state and trigger resume
  1870. * if required
  1871. * @hif: hif opaque handle
  1872. *
  1873. * Return: 0 if system is in on state else error code
  1874. */
  1875. int hif_system_pm_state_check(struct hif_opaque_softc *hif);
  1876. #else
  1877. static inline
  1878. void __hif_system_pm_set_state(struct hif_opaque_softc *hif,
  1879. enum hif_system_pm_state state)
  1880. {
  1881. }
  1882. static inline
  1883. void hif_system_pm_set_state_on(struct hif_opaque_softc *hif)
  1884. {
  1885. }
  1886. static inline
  1887. void hif_system_pm_set_state_resuming(struct hif_opaque_softc *hif)
  1888. {
  1889. }
  1890. static inline
  1891. void hif_system_pm_set_state_suspending(struct hif_opaque_softc *hif)
  1892. {
  1893. }
  1894. static inline
  1895. void hif_system_pm_set_state_suspended(struct hif_opaque_softc *hif)
  1896. {
  1897. }
  1898. static inline
  1899. int32_t hif_system_pm_get_state(struct hif_opaque_softc *hif)
  1900. {
  1901. return 0;
  1902. }
  1903. static inline int hif_system_pm_state_check(struct hif_opaque_softc *hif)
  1904. {
  1905. return 0;
  1906. }
  1907. #endif
  1908. /**
  1909. * hif_set_grp_intr_affinity() - API to set affinity for grp
  1910. * intrs set in the bitmap
  1911. * @scn: hif handle
  1912. * @grp_intr_bitmask: grp intrs for which perf affinity should be
  1913. * applied
  1914. * @perf: affine to perf or non-perf cluster
  1915. *
  1916. * Return: None
  1917. */
  1918. void hif_set_grp_intr_affinity(struct hif_opaque_softc *scn,
  1919. uint32_t grp_intr_bitmask, bool perf);
  1920. #endif /* _HIF_H_ */