hif.h 65 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145
  1. /*
  2. * Copyright (c) 2013-2022 The Linux Foundation. All rights reserved.
  3. * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved.
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for
  6. * any purpose with or without fee is hereby granted, provided that the
  7. * above copyright notice and this permission notice appear in all
  8. * copies.
  9. *
  10. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  11. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  12. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  13. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  14. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  15. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  16. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  17. * PERFORMANCE OF THIS SOFTWARE.
  18. */
  19. #ifndef _HIF_H_
  20. #define _HIF_H_
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif /* __cplusplus */
  24. /* Header files */
  25. #include <qdf_status.h>
  26. #include "qdf_nbuf.h"
  27. #include "qdf_lro.h"
  28. #include "ol_if_athvar.h"
  29. #include <linux/platform_device.h>
  30. #ifdef HIF_PCI
  31. #include <linux/pci.h>
  32. #endif /* HIF_PCI */
  33. #ifdef HIF_USB
  34. #include <linux/usb.h>
  35. #endif /* HIF_USB */
  36. #ifdef IPA_OFFLOAD
  37. #include <linux/ipa.h>
  38. #endif
  39. #include "cfg_ucfg_api.h"
  40. #include "qdf_dev.h"
  41. #include <wlan_init_cfg.h>
  42. #define ENABLE_MBOX_DUMMY_SPACE_FEATURE 1
  43. typedef void __iomem *A_target_id_t;
  44. typedef void *hif_handle_t;
  45. #if defined(HIF_IPCI) && defined(FEATURE_HAL_DELAYED_REG_WRITE)
  46. #define HIF_WORK_DRAIN_WAIT_CNT 50
  47. #define HIF_EP_WAKE_RESET_WAIT_CNT 10
  48. #endif
  49. #define HIF_TYPE_AR6002 2
  50. #define HIF_TYPE_AR6003 3
  51. #define HIF_TYPE_AR6004 5
  52. #define HIF_TYPE_AR9888 6
  53. #define HIF_TYPE_AR6320 7
  54. #define HIF_TYPE_AR6320V2 8
  55. /* For attaching Peregrine 2.0 board host_reg_tbl only */
  56. #define HIF_TYPE_AR9888V2 9
  57. #define HIF_TYPE_ADRASTEA 10
  58. #define HIF_TYPE_AR900B 11
  59. #define HIF_TYPE_QCA9984 12
  60. #define HIF_TYPE_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_KIWI 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. /**
  1569. * hif_ce_debug_history_prealloc_init() - alloc ce debug history memory
  1570. *
  1571. * alloc ce debug history memory with driver init, so such memory can
  1572. * be existed even after stop module.
  1573. * on ini value.
  1574. *
  1575. * Return: QDF_STATUS_SUCCESS for success, other for fail.
  1576. */
  1577. QDF_STATUS hif_ce_debug_history_prealloc_init(void);
  1578. /**
  1579. * hif_ce_debug_history_prealloc_deinit() - free ce debug history memory
  1580. *
  1581. * free ce debug history memory when driver deinit.
  1582. *
  1583. * Return: QDF_STATUS_SUCCESS for success, other for fail.
  1584. */
  1585. QDF_STATUS hif_ce_debug_history_prealloc_deinit(void);
  1586. #else
  1587. static inline
  1588. QDF_STATUS hif_ce_debug_history_prealloc_init(void)
  1589. {
  1590. return QDF_STATUS_SUCCESS;
  1591. }
  1592. static inline
  1593. QDF_STATUS hif_ce_debug_history_prealloc_deinit(void)
  1594. {
  1595. return QDF_STATUS_SUCCESS;
  1596. }
  1597. #endif/*#if defined(HIF_CONFIG_SLUB_DEBUG_ON)||defined(HIF_CE_DEBUG_DATA_BUF)*/
  1598. /**
  1599. * hif_set_ce_service_max_yield_time() - sets CE service max yield time
  1600. * @hif: hif context
  1601. * @ce_service_max_yield_time: CE service max yield time to set
  1602. *
  1603. * This API storess CE service max yield time in hif context based
  1604. * on ini value.
  1605. *
  1606. * Return: void
  1607. */
  1608. void hif_set_ce_service_max_yield_time(struct hif_opaque_softc *hif,
  1609. uint32_t ce_service_max_yield_time);
  1610. /**
  1611. * hif_get_ce_service_max_yield_time() - get CE service max yield time
  1612. * @hif: hif context
  1613. *
  1614. * This API returns CE service max yield time.
  1615. *
  1616. * Return: CE service max yield time
  1617. */
  1618. unsigned long long
  1619. hif_get_ce_service_max_yield_time(struct hif_opaque_softc *hif);
  1620. /**
  1621. * hif_set_ce_service_max_rx_ind_flush() - sets CE service max rx ind flush
  1622. * @hif: hif context
  1623. * @ce_service_max_rx_ind_flush: CE service max rx ind flush to set
  1624. *
  1625. * This API stores CE service max rx ind flush in hif context based
  1626. * on ini value.
  1627. *
  1628. * Return: void
  1629. */
  1630. void hif_set_ce_service_max_rx_ind_flush(struct hif_opaque_softc *hif,
  1631. uint8_t ce_service_max_rx_ind_flush);
  1632. #ifdef OL_ATH_SMART_LOGGING
  1633. /*
  1634. * hif_log_ce_dump() - Copy all the CE DEST ring to buf
  1635. * @scn : HIF handler
  1636. * @buf_cur: Current pointer in ring buffer
  1637. * @buf_init:Start of the ring buffer
  1638. * @buf_sz: Size of the ring buffer
  1639. * @ce: Copy Engine id
  1640. * @skb_sz: Max size of the SKB buffer to be copied
  1641. *
  1642. * Calls the respective function to dump all the CE SRC/DEST ring descriptors
  1643. * and buffers pointed by them in to the given buf
  1644. *
  1645. * Return: Current pointer in ring buffer
  1646. */
  1647. uint8_t *hif_log_dump_ce(struct hif_softc *scn, uint8_t *buf_cur,
  1648. uint8_t *buf_init, uint32_t buf_sz,
  1649. uint32_t ce, uint32_t skb_sz);
  1650. #endif /* OL_ATH_SMART_LOGGING */
  1651. /*
  1652. * hif_softc_to_hif_opaque_softc - API to convert hif_softc handle
  1653. * to hif_opaque_softc handle
  1654. * @hif_handle - hif_softc type
  1655. *
  1656. * Return: hif_opaque_softc type
  1657. */
  1658. static inline struct hif_opaque_softc *
  1659. hif_softc_to_hif_opaque_softc(struct hif_softc *hif_handle)
  1660. {
  1661. return (struct hif_opaque_softc *)hif_handle;
  1662. }
  1663. #if defined(HIF_IPCI) && defined(FEATURE_HAL_DELAYED_REG_WRITE)
  1664. QDF_STATUS hif_try_prevent_ep_vote_access(struct hif_opaque_softc *hif_ctx);
  1665. void hif_set_ep_intermediate_vote_access(struct hif_opaque_softc *hif_ctx);
  1666. void hif_allow_ep_vote_access(struct hif_opaque_softc *hif_ctx);
  1667. void hif_set_ep_vote_access(struct hif_opaque_softc *hif_ctx,
  1668. uint8_t type, uint8_t access);
  1669. uint8_t hif_get_ep_vote_access(struct hif_opaque_softc *hif_ctx,
  1670. uint8_t type);
  1671. #else
  1672. static inline QDF_STATUS
  1673. hif_try_prevent_ep_vote_access(struct hif_opaque_softc *hif_ctx)
  1674. {
  1675. return QDF_STATUS_SUCCESS;
  1676. }
  1677. static inline void
  1678. hif_set_ep_intermediate_vote_access(struct hif_opaque_softc *hif_ctx)
  1679. {
  1680. }
  1681. static inline void
  1682. hif_allow_ep_vote_access(struct hif_opaque_softc *hif_ctx)
  1683. {
  1684. }
  1685. static inline void
  1686. hif_set_ep_vote_access(struct hif_opaque_softc *hif_ctx,
  1687. uint8_t type, uint8_t access)
  1688. {
  1689. }
  1690. static inline uint8_t
  1691. hif_get_ep_vote_access(struct hif_opaque_softc *hif_ctx,
  1692. uint8_t type)
  1693. {
  1694. return HIF_EP_VOTE_ACCESS_ENABLE;
  1695. }
  1696. #endif
  1697. #ifdef FORCE_WAKE
  1698. /**
  1699. * hif_srng_init_phase(): Indicate srng initialization phase
  1700. * to avoid force wake as UMAC power collapse is not yet
  1701. * enabled
  1702. * @hif_ctx: hif opaque handle
  1703. * @init_phase: initialization phase
  1704. *
  1705. * Return: None
  1706. */
  1707. void hif_srng_init_phase(struct hif_opaque_softc *hif_ctx,
  1708. bool init_phase);
  1709. #else
  1710. static inline
  1711. void hif_srng_init_phase(struct hif_opaque_softc *hif_ctx,
  1712. bool init_phase)
  1713. {
  1714. }
  1715. #endif /* FORCE_WAKE */
  1716. #ifdef HIF_IPCI
  1717. /**
  1718. * hif_shutdown_notifier_cb - Call back for shutdown notifier
  1719. * @ctx: hif handle
  1720. *
  1721. * Return: None
  1722. */
  1723. void hif_shutdown_notifier_cb(void *ctx);
  1724. #else
  1725. static inline
  1726. void hif_shutdown_notifier_cb(void *ctx)
  1727. {
  1728. }
  1729. #endif /* HIF_IPCI */
  1730. #ifdef HIF_CE_LOG_INFO
  1731. /**
  1732. * hif_log_ce_info() - API to log ce info
  1733. * @scn: hif handle
  1734. * @data: hang event data buffer
  1735. * @offset: offset at which data needs to be written
  1736. *
  1737. * Return: None
  1738. */
  1739. void hif_log_ce_info(struct hif_softc *scn, uint8_t *data,
  1740. unsigned int *offset);
  1741. #else
  1742. static inline
  1743. void hif_log_ce_info(struct hif_softc *scn, uint8_t *data,
  1744. unsigned int *offset)
  1745. {
  1746. }
  1747. #endif
  1748. #ifdef HIF_CPU_PERF_AFFINE_MASK
  1749. /**
  1750. * hif_config_irq_set_perf_affinity_hint() - API to set affinity
  1751. * @hif_ctx: hif opaque handle
  1752. *
  1753. * This function is used to move the WLAN IRQs to perf cores in
  1754. * case of defconfig builds.
  1755. *
  1756. * Return: None
  1757. */
  1758. void hif_config_irq_set_perf_affinity_hint(
  1759. struct hif_opaque_softc *hif_ctx);
  1760. #else
  1761. static inline void hif_config_irq_set_perf_affinity_hint(
  1762. struct hif_opaque_softc *hif_ctx)
  1763. {
  1764. }
  1765. #endif
  1766. /**
  1767. * hif_apps_grp_irqs_enable() - enable ext grp irqs
  1768. * @hif - HIF opaque context
  1769. *
  1770. * Return: 0 on success. Error code on failure.
  1771. */
  1772. int hif_apps_grp_irqs_enable(struct hif_opaque_softc *hif_ctx);
  1773. /**
  1774. * hif_apps_grp_irqs_disable() - disable ext grp irqs
  1775. * @hif - HIF opaque context
  1776. *
  1777. * Return: 0 on success. Error code on failure.
  1778. */
  1779. int hif_apps_grp_irqs_disable(struct hif_opaque_softc *hif_ctx);
  1780. /**
  1781. * hif_disable_grp_irqs() - disable ext grp irqs
  1782. * @hif - HIF opaque context
  1783. *
  1784. * Return: 0 on success. Error code on failure.
  1785. */
  1786. int hif_disable_grp_irqs(struct hif_opaque_softc *scn);
  1787. /**
  1788. * hif_enable_grp_irqs() - enable ext grp irqs
  1789. * @hif - HIF opaque context
  1790. *
  1791. * Return: 0 on success. Error code on failure.
  1792. */
  1793. int hif_enable_grp_irqs(struct hif_opaque_softc *scn);
  1794. enum hif_credit_exchange_type {
  1795. HIF_REQUEST_CREDIT,
  1796. HIF_PROCESS_CREDIT_REPORT,
  1797. };
  1798. enum hif_detect_latency_type {
  1799. HIF_DETECT_TASKLET,
  1800. HIF_DETECT_CREDIT,
  1801. HIF_DETECT_UNKNOWN
  1802. };
  1803. #ifdef HIF_DETECTION_LATENCY_ENABLE
  1804. void hif_latency_detect_credit_record_time(
  1805. enum hif_credit_exchange_type type,
  1806. struct hif_opaque_softc *hif_ctx);
  1807. void hif_latency_detect_timer_start(struct hif_opaque_softc *hif_ctx);
  1808. void hif_latency_detect_timer_stop(struct hif_opaque_softc *hif_ctx);
  1809. void hif_tasklet_latency(struct hif_softc *scn, bool from_timer);
  1810. void hif_credit_latency(struct hif_softc *scn, bool from_timer);
  1811. void hif_check_detection_latency(struct hif_softc *scn,
  1812. bool from_timer,
  1813. uint32_t bitmap_type);
  1814. void hif_set_enable_detection(struct hif_opaque_softc *hif_ctx, bool value);
  1815. #else
  1816. static inline
  1817. void hif_latency_detect_timer_start(struct hif_opaque_softc *hif_ctx)
  1818. {}
  1819. static inline
  1820. void hif_latency_detect_timer_stop(struct hif_opaque_softc *hif_ctx)
  1821. {}
  1822. static inline
  1823. void hif_latency_detect_credit_record_time(
  1824. enum hif_credit_exchange_type type,
  1825. struct hif_opaque_softc *hif_ctx)
  1826. {}
  1827. static inline
  1828. void hif_check_detection_latency(struct hif_softc *scn,
  1829. bool from_timer,
  1830. uint32_t bitmap_type)
  1831. {}
  1832. static inline
  1833. void hif_set_enable_detection(struct hif_opaque_softc *hif_ctx, bool value)
  1834. {}
  1835. #endif
  1836. #ifdef SYSTEM_PM_CHECK
  1837. /**
  1838. * __hif_system_pm_set_state() - Set system pm state
  1839. * @hif: hif opaque handle
  1840. * @state: system state
  1841. *
  1842. * Return: None
  1843. */
  1844. void __hif_system_pm_set_state(struct hif_opaque_softc *hif,
  1845. enum hif_system_pm_state state);
  1846. /**
  1847. * hif_system_pm_set_state_on() - Set system pm state to ON
  1848. * @hif: hif opaque handle
  1849. *
  1850. * Return: None
  1851. */
  1852. static inline
  1853. void hif_system_pm_set_state_on(struct hif_opaque_softc *hif)
  1854. {
  1855. __hif_system_pm_set_state(hif, HIF_SYSTEM_PM_STATE_ON);
  1856. }
  1857. /**
  1858. * hif_system_pm_set_state_resuming() - Set system pm state to resuming
  1859. * @hif: hif opaque handle
  1860. *
  1861. * Return: None
  1862. */
  1863. static inline
  1864. void hif_system_pm_set_state_resuming(struct hif_opaque_softc *hif)
  1865. {
  1866. __hif_system_pm_set_state(hif, HIF_SYSTEM_PM_STATE_BUS_RESUMING);
  1867. }
  1868. /**
  1869. * hif_system_pm_set_state_suspending() - Set system pm state to suspending
  1870. * @hif: hif opaque handle
  1871. *
  1872. * Return: None
  1873. */
  1874. static inline
  1875. void hif_system_pm_set_state_suspending(struct hif_opaque_softc *hif)
  1876. {
  1877. __hif_system_pm_set_state(hif, HIF_SYSTEM_PM_STATE_BUS_SUSPENDING);
  1878. }
  1879. /**
  1880. * hif_system_pm_set_state_suspended() - Set system pm state to suspended
  1881. * @hif: hif opaque handle
  1882. *
  1883. * Return: None
  1884. */
  1885. static inline
  1886. void hif_system_pm_set_state_suspended(struct hif_opaque_softc *hif)
  1887. {
  1888. __hif_system_pm_set_state(hif, HIF_SYSTEM_PM_STATE_BUS_SUSPENDED);
  1889. }
  1890. /**
  1891. * hif_system_pm_get_state() - Get system pm state
  1892. * @hif: hif opaque handle
  1893. *
  1894. * Return: system state
  1895. */
  1896. int32_t hif_system_pm_get_state(struct hif_opaque_softc *hif);
  1897. /**
  1898. * hif_system_pm_state_check() - Check system state and trigger resume
  1899. * if required
  1900. * @hif: hif opaque handle
  1901. *
  1902. * Return: 0 if system is in on state else error code
  1903. */
  1904. int hif_system_pm_state_check(struct hif_opaque_softc *hif);
  1905. #else
  1906. static inline
  1907. void __hif_system_pm_set_state(struct hif_opaque_softc *hif,
  1908. enum hif_system_pm_state state)
  1909. {
  1910. }
  1911. static inline
  1912. void hif_system_pm_set_state_on(struct hif_opaque_softc *hif)
  1913. {
  1914. }
  1915. static inline
  1916. void hif_system_pm_set_state_resuming(struct hif_opaque_softc *hif)
  1917. {
  1918. }
  1919. static inline
  1920. void hif_system_pm_set_state_suspending(struct hif_opaque_softc *hif)
  1921. {
  1922. }
  1923. static inline
  1924. void hif_system_pm_set_state_suspended(struct hif_opaque_softc *hif)
  1925. {
  1926. }
  1927. static inline
  1928. int32_t hif_system_pm_get_state(struct hif_opaque_softc *hif)
  1929. {
  1930. return 0;
  1931. }
  1932. static inline int hif_system_pm_state_check(struct hif_opaque_softc *hif)
  1933. {
  1934. return 0;
  1935. }
  1936. #endif
  1937. #ifdef FEATURE_IRQ_AFFINITY
  1938. /**
  1939. * hif_set_grp_intr_affinity() - API to set affinity for grp
  1940. * intrs set in the bitmap
  1941. * @scn: hif handle
  1942. * @grp_intr_bitmask: grp intrs for which perf affinity should be
  1943. * applied
  1944. * @perf: affine to perf or non-perf cluster
  1945. *
  1946. * Return: None
  1947. */
  1948. void hif_set_grp_intr_affinity(struct hif_opaque_softc *scn,
  1949. uint32_t grp_intr_bitmask, bool perf);
  1950. #else
  1951. static inline
  1952. void hif_set_grp_intr_affinity(struct hif_opaque_softc *scn,
  1953. uint32_t grp_intr_bitmask, bool perf)
  1954. {
  1955. }
  1956. #endif
  1957. #endif /* _HIF_H_ */