hif.h 63 KB

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