hif.h 49 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585
  1. /*
  2. * Copyright (c) 2013-2020 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. #define ENABLE_MBOX_DUMMY_SPACE_FEATURE 1
  41. typedef void __iomem *A_target_id_t;
  42. typedef void *hif_handle_t;
  43. #define HIF_TYPE_AR6002 2
  44. #define HIF_TYPE_AR6003 3
  45. #define HIF_TYPE_AR6004 5
  46. #define HIF_TYPE_AR9888 6
  47. #define HIF_TYPE_AR6320 7
  48. #define HIF_TYPE_AR6320V2 8
  49. /* For attaching Peregrine 2.0 board host_reg_tbl only */
  50. #define HIF_TYPE_AR9888V2 9
  51. #define HIF_TYPE_ADRASTEA 10
  52. #define HIF_TYPE_AR900B 11
  53. #define HIF_TYPE_QCA9984 12
  54. #define HIF_TYPE_IPQ4019 13
  55. #define HIF_TYPE_QCA9888 14
  56. #define HIF_TYPE_QCA8074 15
  57. #define HIF_TYPE_QCA6290 16
  58. #define HIF_TYPE_QCN7605 17
  59. #define HIF_TYPE_QCA6390 18
  60. #define HIF_TYPE_QCA8074V2 19
  61. #define HIF_TYPE_QCA6018 20
  62. #define HIF_TYPE_QCN9000 21
  63. #define HIF_TYPE_QCA6490 22
  64. #define HIF_TYPE_QCA6750 23
  65. #define HIF_TYPE_QCA5018 24
  66. #define HIF_TYPE_QCN9100 25
  67. #define DMA_COHERENT_MASK_DEFAULT 37
  68. #ifdef IPA_OFFLOAD
  69. #define DMA_COHERENT_MASK_BELOW_IPA_VER_3 32
  70. #endif
  71. /* enum hif_ic_irq - enum defining integrated chip irq numbers
  72. * defining irq nubers that can be used by external modules like datapath
  73. */
  74. enum hif_ic_irq {
  75. host2wbm_desc_feed = 16,
  76. host2reo_re_injection,
  77. host2reo_command,
  78. host2rxdma_monitor_ring3,
  79. host2rxdma_monitor_ring2,
  80. host2rxdma_monitor_ring1,
  81. reo2host_exception,
  82. wbm2host_rx_release,
  83. reo2host_status,
  84. reo2host_destination_ring4,
  85. reo2host_destination_ring3,
  86. reo2host_destination_ring2,
  87. reo2host_destination_ring1,
  88. rxdma2host_monitor_destination_mac3,
  89. rxdma2host_monitor_destination_mac2,
  90. rxdma2host_monitor_destination_mac1,
  91. ppdu_end_interrupts_mac3,
  92. ppdu_end_interrupts_mac2,
  93. ppdu_end_interrupts_mac1,
  94. rxdma2host_monitor_status_ring_mac3,
  95. rxdma2host_monitor_status_ring_mac2,
  96. rxdma2host_monitor_status_ring_mac1,
  97. host2rxdma_host_buf_ring_mac3,
  98. host2rxdma_host_buf_ring_mac2,
  99. host2rxdma_host_buf_ring_mac1,
  100. rxdma2host_destination_ring_mac3,
  101. rxdma2host_destination_ring_mac2,
  102. rxdma2host_destination_ring_mac1,
  103. host2tcl_input_ring4,
  104. host2tcl_input_ring3,
  105. host2tcl_input_ring2,
  106. host2tcl_input_ring1,
  107. wbm2host_tx_completions_ring3,
  108. wbm2host_tx_completions_ring2,
  109. wbm2host_tx_completions_ring1,
  110. tcl2host_status_ring,
  111. };
  112. struct CE_state;
  113. #define CE_COUNT_MAX 12
  114. #define HIF_MAX_GRP_IRQ 16
  115. #ifndef HIF_MAX_GROUP
  116. #define HIF_MAX_GROUP 7
  117. #endif
  118. #ifndef NAPI_YIELD_BUDGET_BASED
  119. #ifndef QCA_NAPI_DEF_SCALE_BIN_SHIFT
  120. #define QCA_NAPI_DEF_SCALE_BIN_SHIFT 4
  121. #endif
  122. #else /* NAPI_YIELD_BUDGET_BASED */
  123. #define QCA_NAPI_DEF_SCALE_BIN_SHIFT 2
  124. #endif /* NAPI_YIELD_BUDGET_BASED */
  125. #define QCA_NAPI_BUDGET 64
  126. #define QCA_NAPI_DEF_SCALE \
  127. (1 << QCA_NAPI_DEF_SCALE_BIN_SHIFT)
  128. #define HIF_NAPI_MAX_RECEIVES (QCA_NAPI_BUDGET * QCA_NAPI_DEF_SCALE)
  129. /* NOTE: "napi->scale" can be changed,
  130. * but this does not change the number of buckets
  131. */
  132. #define QCA_NAPI_NUM_BUCKETS 4
  133. /**
  134. * qca_napi_stat - stats structure for execution contexts
  135. * @napi_schedules - number of times the schedule function is called
  136. * @napi_polls - number of times the execution context runs
  137. * @napi_completes - number of times that the generating interrupt is reenabled
  138. * @napi_workdone - cumulative of all work done reported by handler
  139. * @cpu_corrected - incremented when execution context runs on a different core
  140. * than the one that its irq is affined to.
  141. * @napi_budget_uses - histogram of work done per execution run
  142. * @time_limit_reache - count of yields due to time limit threshholds
  143. * @rxpkt_thresh_reached - count of yields due to a work limit
  144. * @poll_time_buckets - histogram of poll times for the napi
  145. *
  146. */
  147. struct qca_napi_stat {
  148. uint32_t napi_schedules;
  149. uint32_t napi_polls;
  150. uint32_t napi_completes;
  151. uint32_t napi_workdone;
  152. uint32_t cpu_corrected;
  153. uint32_t napi_budget_uses[QCA_NAPI_NUM_BUCKETS];
  154. uint32_t time_limit_reached;
  155. uint32_t rxpkt_thresh_reached;
  156. unsigned long long napi_max_poll_time;
  157. #ifdef WLAN_FEATURE_RX_SOFTIRQ_TIME_LIMIT
  158. uint32_t poll_time_buckets[QCA_NAPI_NUM_BUCKETS];
  159. #endif
  160. };
  161. /**
  162. * per NAPI instance data structure
  163. * This data structure holds stuff per NAPI instance.
  164. * Note that, in the current implementation, though scale is
  165. * an instance variable, it is set to the same value for all
  166. * instances.
  167. */
  168. struct qca_napi_info {
  169. struct net_device netdev; /* dummy net_dev */
  170. void *hif_ctx;
  171. struct napi_struct napi;
  172. uint8_t scale; /* currently same on all instances */
  173. uint8_t id;
  174. uint8_t cpu;
  175. int irq;
  176. cpumask_t cpumask;
  177. struct qca_napi_stat stats[NR_CPUS];
  178. #ifdef RECEIVE_OFFLOAD
  179. /* will only be present for data rx CE's */
  180. void (*offld_flush_cb)(void *);
  181. struct napi_struct rx_thread_napi;
  182. struct net_device rx_thread_netdev;
  183. #endif /* RECEIVE_OFFLOAD */
  184. qdf_lro_ctx_t lro_ctx;
  185. };
  186. enum qca_napi_tput_state {
  187. QCA_NAPI_TPUT_UNINITIALIZED,
  188. QCA_NAPI_TPUT_LO,
  189. QCA_NAPI_TPUT_HI
  190. };
  191. enum qca_napi_cpu_state {
  192. QCA_NAPI_CPU_UNINITIALIZED,
  193. QCA_NAPI_CPU_DOWN,
  194. QCA_NAPI_CPU_UP };
  195. /**
  196. * struct qca_napi_cpu - an entry of the napi cpu table
  197. * @core_id: physical core id of the core
  198. * @cluster_id: cluster this core belongs to
  199. * @core_mask: mask to match all core of this cluster
  200. * @thread_mask: mask for this core within the cluster
  201. * @max_freq: maximum clock this core can be clocked at
  202. * same for all cpus of the same core.
  203. * @napis: bitmap of napi instances on this core
  204. * @execs: bitmap of execution contexts on this core
  205. * cluster_nxt: chain to link cores within the same cluster
  206. *
  207. * This structure represents a single entry in the napi cpu
  208. * table. The table is part of struct qca_napi_data.
  209. * This table is initialized by the init function, called while
  210. * the first napi instance is being created, updated by hotplug
  211. * notifier and when cpu affinity decisions are made (by throughput
  212. * detection), and deleted when the last napi instance is removed.
  213. */
  214. struct qca_napi_cpu {
  215. enum qca_napi_cpu_state state;
  216. int core_id;
  217. int cluster_id;
  218. cpumask_t core_mask;
  219. cpumask_t thread_mask;
  220. unsigned int max_freq;
  221. uint32_t napis;
  222. uint32_t execs;
  223. int cluster_nxt; /* index, not pointer */
  224. };
  225. /**
  226. * struct qca_napi_data - collection of napi data for a single hif context
  227. * @hif_softc: pointer to the hif context
  228. * @lock: spinlock used in the event state machine
  229. * @state: state variable used in the napi stat machine
  230. * @ce_map: bit map indicating which ce's have napis running
  231. * @exec_map: bit map of instanciated exec contexts
  232. * @user_cpu_affin_map: CPU affinity map from INI config.
  233. * @napi_cpu: cpu info for irq affinty
  234. * @lilcl_head:
  235. * @bigcl_head:
  236. * @napi_mode: irq affinity & clock voting mode
  237. * @cpuhp_handler: CPU hotplug event registration handle
  238. */
  239. struct qca_napi_data {
  240. struct hif_softc *hif_softc;
  241. qdf_spinlock_t lock;
  242. uint32_t state;
  243. /* bitmap of created/registered NAPI instances, indexed by pipe_id,
  244. * not used by clients (clients use an id returned by create)
  245. */
  246. uint32_t ce_map;
  247. uint32_t exec_map;
  248. uint32_t user_cpu_affin_mask;
  249. struct qca_napi_info *napis[CE_COUNT_MAX];
  250. struct qca_napi_cpu napi_cpu[NR_CPUS];
  251. int lilcl_head, bigcl_head;
  252. enum qca_napi_tput_state napi_mode;
  253. struct qdf_cpuhp_handler *cpuhp_handler;
  254. uint8_t flags;
  255. };
  256. /**
  257. * struct hif_config_info - Place Holder for HIF configuration
  258. * @enable_self_recovery: Self Recovery
  259. * @enable_runtime_pm: Enable Runtime PM
  260. * @runtime_pm_delay: Runtime PM Delay
  261. * @rx_softirq_max_yield_duration_ns: Max Yield time duration for RX Softirq
  262. *
  263. * Structure for holding HIF ini parameters.
  264. */
  265. struct hif_config_info {
  266. bool enable_self_recovery;
  267. #ifdef FEATURE_RUNTIME_PM
  268. uint8_t enable_runtime_pm;
  269. u_int32_t runtime_pm_delay;
  270. #endif
  271. uint64_t rx_softirq_max_yield_duration_ns;
  272. };
  273. /**
  274. * struct hif_target_info - Target Information
  275. * @target_version: Target Version
  276. * @target_type: Target Type
  277. * @target_revision: Target Revision
  278. * @soc_version: SOC Version
  279. * @hw_name: pointer to hardware name
  280. *
  281. * Structure to hold target information.
  282. */
  283. struct hif_target_info {
  284. uint32_t target_version;
  285. uint32_t target_type;
  286. uint32_t target_revision;
  287. uint32_t soc_version;
  288. char *hw_name;
  289. };
  290. struct hif_opaque_softc {
  291. };
  292. /**
  293. * enum hif_event_type - Type of DP events to be recorded
  294. * @HIF_EVENT_IRQ_TRIGGER: IRQ trigger event
  295. * @HIF_EVENT_TIMER_ENTRY: Monitor Timer entry event
  296. * @HIF_EVENT_TIMER_EXIT: Monitor Timer exit event
  297. * @HIF_EVENT_BH_SCHED: NAPI POLL scheduled event
  298. * @HIF_EVENT_SRNG_ACCESS_START: hal ring access start event
  299. * @HIF_EVENT_SRNG_ACCESS_END: hal ring access end event
  300. */
  301. enum hif_event_type {
  302. HIF_EVENT_IRQ_TRIGGER,
  303. HIF_EVENT_TIMER_ENTRY,
  304. HIF_EVENT_TIMER_EXIT,
  305. HIF_EVENT_BH_SCHED,
  306. HIF_EVENT_SRNG_ACCESS_START,
  307. HIF_EVENT_SRNG_ACCESS_END,
  308. /* Do check hif_hist_skip_event_record when adding new events */
  309. };
  310. #ifdef WLAN_FEATURE_DP_EVENT_HISTORY
  311. /* HIF_EVENT_HIST_MAX should always be power of 2 */
  312. #define HIF_EVENT_HIST_MAX 512
  313. #define HIF_NUM_INT_CONTEXTS HIF_MAX_GROUP
  314. #define HIF_EVENT_HIST_DISABLE_MASK 0
  315. /**
  316. * struct hif_event_record - an entry of the DP event history
  317. * @hal_ring_id: ring id for which event is recorded
  318. * @hp: head pointer of the ring (may not be applicable for all events)
  319. * @tp: tail pointer of the ring (may not be applicable for all events)
  320. * @cpu_id: cpu id on which the event occurred
  321. * @timestamp: timestamp when event occurred
  322. * @type: type of the event
  323. *
  324. * This structure represents the information stored for every datapath
  325. * event which is logged in the history.
  326. */
  327. struct hif_event_record {
  328. uint8_t hal_ring_id;
  329. uint32_t hp;
  330. uint32_t tp;
  331. int cpu_id;
  332. uint64_t timestamp;
  333. enum hif_event_type type;
  334. };
  335. /**
  336. * struct hif_event_misc - history related misc info
  337. * @last_irq_index: last irq event index in history
  338. * @last_irq_ts: last irq timestamp
  339. */
  340. struct hif_event_misc {
  341. int32_t last_irq_index;
  342. uint64_t last_irq_ts;
  343. };
  344. /**
  345. * struct hif_event_history - history for one interrupt group
  346. * @index: index to store new event
  347. * @event: event entry
  348. *
  349. * This structure represents the datapath history for one
  350. * interrupt group.
  351. */
  352. struct hif_event_history {
  353. qdf_atomic_t index;
  354. struct hif_event_misc misc;
  355. struct hif_event_record event[HIF_EVENT_HIST_MAX];
  356. };
  357. /**
  358. * hif_hist_record_event() - Record one datapath event in history
  359. * @hif_ctx: HIF opaque context
  360. * @event: DP event entry
  361. * @intr_grp_id: interrupt group ID registered with hif
  362. *
  363. * Return: None
  364. */
  365. void hif_hist_record_event(struct hif_opaque_softc *hif_ctx,
  366. struct hif_event_record *event,
  367. uint8_t intr_grp_id);
  368. /**
  369. * hif_event_history_init() - Initialize SRNG event history buffers
  370. * @hif_ctx: HIF opaque context
  371. * @id: context group ID for which history is recorded
  372. *
  373. * Returns: None
  374. */
  375. void hif_event_history_init(struct hif_opaque_softc *hif_ctx, uint8_t id);
  376. /**
  377. * hif_event_history_deinit() - De-initialize SRNG event history buffers
  378. * @hif_ctx: HIF opaque context
  379. * @id: context group ID for which history is recorded
  380. *
  381. * Returns: None
  382. */
  383. void hif_event_history_deinit(struct hif_opaque_softc *hif_ctx, uint8_t id);
  384. /**
  385. * hif_record_event() - Wrapper function to form and record DP event
  386. * @hif_ctx: HIF opaque context
  387. * @intr_grp_id: interrupt group ID registered with hif
  388. * @hal_ring_id: ring id for which event is recorded
  389. * @hp: head pointer index of the srng
  390. * @tp: tail pointer index of the srng
  391. * @type: type of the event to be logged in history
  392. *
  393. * Return: None
  394. */
  395. static inline void hif_record_event(struct hif_opaque_softc *hif_ctx,
  396. uint8_t intr_grp_id,
  397. uint8_t hal_ring_id,
  398. uint32_t hp,
  399. uint32_t tp,
  400. enum hif_event_type type)
  401. {
  402. struct hif_event_record event;
  403. event.hal_ring_id = hal_ring_id;
  404. event.hp = hp;
  405. event.tp = tp;
  406. event.type = type;
  407. hif_hist_record_event(hif_ctx, &event, intr_grp_id);
  408. return;
  409. }
  410. #else
  411. static inline void hif_record_event(struct hif_opaque_softc *hif_ctx,
  412. uint8_t intr_grp_id,
  413. uint8_t hal_ring_id,
  414. uint32_t hp,
  415. uint32_t tp,
  416. enum hif_event_type type)
  417. {
  418. }
  419. static inline void hif_event_history_init(struct hif_opaque_softc *hif_ctx,
  420. uint8_t id)
  421. {
  422. }
  423. static inline void hif_event_history_deinit(struct hif_opaque_softc *hif_ctx,
  424. uint8_t id)
  425. {
  426. }
  427. #endif /* WLAN_FEATURE_DP_EVENT_HISTORY */
  428. /**
  429. * enum HIF_DEVICE_POWER_CHANGE_TYPE: Device Power change type
  430. *
  431. * @HIF_DEVICE_POWER_UP: HIF layer should power up interface and/or module
  432. * @HIF_DEVICE_POWER_DOWN: HIF layer should initiate bus-specific measures to
  433. * minimize power
  434. * @HIF_DEVICE_POWER_CUT: HIF layer should initiate bus-specific AND/OR
  435. * platform-specific measures to completely power-off
  436. * the module and associated hardware (i.e. cut power
  437. * supplies)
  438. */
  439. enum HIF_DEVICE_POWER_CHANGE_TYPE {
  440. HIF_DEVICE_POWER_UP,
  441. HIF_DEVICE_POWER_DOWN,
  442. HIF_DEVICE_POWER_CUT
  443. };
  444. /**
  445. * enum hif_enable_type: what triggered the enabling of hif
  446. *
  447. * @HIF_ENABLE_TYPE_PROBE: probe triggered enable
  448. * @HIF_ENABLE_TYPE_REINIT: reinit triggered enable
  449. */
  450. enum hif_enable_type {
  451. HIF_ENABLE_TYPE_PROBE,
  452. HIF_ENABLE_TYPE_REINIT,
  453. HIF_ENABLE_TYPE_MAX
  454. };
  455. /**
  456. * enum hif_disable_type: what triggered the disabling of hif
  457. *
  458. * @HIF_DISABLE_TYPE_PROBE_ERROR: probe error triggered disable
  459. * @HIF_DISABLE_TYPE_REINIT_ERROR: reinit error triggered disable
  460. * @HIF_DISABLE_TYPE_REMOVE: remove triggered disable
  461. * @HIF_DISABLE_TYPE_SHUTDOWN: shutdown triggered disable
  462. */
  463. enum hif_disable_type {
  464. HIF_DISABLE_TYPE_PROBE_ERROR,
  465. HIF_DISABLE_TYPE_REINIT_ERROR,
  466. HIF_DISABLE_TYPE_REMOVE,
  467. HIF_DISABLE_TYPE_SHUTDOWN,
  468. HIF_DISABLE_TYPE_MAX
  469. };
  470. /**
  471. * enum hif_device_config_opcode: configure mode
  472. *
  473. * @HIF_DEVICE_POWER_STATE: device power state
  474. * @HIF_DEVICE_GET_BLOCK_SIZE: get block size
  475. * @HIF_DEVICE_GET_ADDR: get block address
  476. * @HIF_DEVICE_GET_PENDING_EVENTS_FUNC: get pending events functions
  477. * @HIF_DEVICE_GET_IRQ_PROC_MODE: get irq proc mode
  478. * @HIF_DEVICE_GET_RECV_EVENT_MASK_UNMASK_FUNC: receive event function
  479. * @HIF_DEVICE_POWER_STATE_CHANGE: change power state
  480. * @HIF_DEVICE_GET_IRQ_YIELD_PARAMS: get yield params
  481. * @HIF_CONFIGURE_QUERY_SCATTER_REQUEST_SUPPORT: configure scatter request
  482. * @HIF_DEVICE_GET_OS_DEVICE: get OS device
  483. * @HIF_DEVICE_DEBUG_BUS_STATE: debug bus state
  484. * @HIF_BMI_DONE: bmi done
  485. * @HIF_DEVICE_SET_TARGET_TYPE: set target type
  486. * @HIF_DEVICE_SET_HTC_CONTEXT: set htc context
  487. * @HIF_DEVICE_GET_HTC_CONTEXT: get htc context
  488. */
  489. enum hif_device_config_opcode {
  490. HIF_DEVICE_POWER_STATE = 0,
  491. HIF_DEVICE_GET_BLOCK_SIZE,
  492. HIF_DEVICE_GET_FIFO_ADDR,
  493. HIF_DEVICE_GET_PENDING_EVENTS_FUNC,
  494. HIF_DEVICE_GET_IRQ_PROC_MODE,
  495. HIF_DEVICE_GET_RECV_EVENT_MASK_UNMASK_FUNC,
  496. HIF_DEVICE_POWER_STATE_CHANGE,
  497. HIF_DEVICE_GET_IRQ_YIELD_PARAMS,
  498. HIF_CONFIGURE_QUERY_SCATTER_REQUEST_SUPPORT,
  499. HIF_DEVICE_GET_OS_DEVICE,
  500. HIF_DEVICE_DEBUG_BUS_STATE,
  501. HIF_BMI_DONE,
  502. HIF_DEVICE_SET_TARGET_TYPE,
  503. HIF_DEVICE_SET_HTC_CONTEXT,
  504. HIF_DEVICE_GET_HTC_CONTEXT,
  505. };
  506. #ifdef CONFIG_ATH_PCIE_ACCESS_DEBUG
  507. struct HID_ACCESS_LOG {
  508. uint32_t seqnum;
  509. bool is_write;
  510. void *addr;
  511. uint32_t value;
  512. };
  513. #endif
  514. void hif_reg_write(struct hif_opaque_softc *hif_ctx, uint32_t offset,
  515. uint32_t value);
  516. uint32_t hif_reg_read(struct hif_opaque_softc *hif_ctx, uint32_t offset);
  517. #define HIF_MAX_DEVICES 1
  518. /**
  519. * struct htc_callbacks - Structure for HTC Callbacks methods
  520. * @context: context to pass to the dsrhandler
  521. * note : rwCompletionHandler is provided the context
  522. * passed to hif_read_write
  523. * @rwCompletionHandler: Read / write completion handler
  524. * @dsrHandler: DSR Handler
  525. */
  526. struct htc_callbacks {
  527. void *context;
  528. QDF_STATUS(*rw_compl_handler)(void *rw_ctx, QDF_STATUS status);
  529. QDF_STATUS(*dsr_handler)(void *context);
  530. };
  531. /**
  532. * struct hif_driver_state_callbacks - Callbacks for HIF to query Driver state
  533. * @context: Private data context
  534. * @set_recovery_in_progress: To Set Driver state for recovery in progress
  535. * @is_recovery_in_progress: Query if driver state is recovery in progress
  536. * @is_load_unload_in_progress: Query if driver state Load/Unload in Progress
  537. * @is_driver_unloading: Query if driver is unloading.
  538. * @get_bandwidth_level: Query current bandwidth level for the driver
  539. * @prealloc_get_consistent_mem_unligned: get prealloc unaligned consistent mem
  540. * @prealloc_put_consistent_mem_unligned: put unaligned consistent mem to pool
  541. * This Structure provides callback pointer for HIF to query hdd for driver
  542. * states.
  543. */
  544. struct hif_driver_state_callbacks {
  545. void *context;
  546. void (*set_recovery_in_progress)(void *context, uint8_t val);
  547. bool (*is_recovery_in_progress)(void *context);
  548. bool (*is_load_unload_in_progress)(void *context);
  549. bool (*is_driver_unloading)(void *context);
  550. bool (*is_target_ready)(void *context);
  551. int (*get_bandwidth_level)(void *context);
  552. void *(*prealloc_get_consistent_mem_unaligned)(qdf_size_t size,
  553. qdf_dma_addr_t *paddr,
  554. uint32_t ring_type);
  555. void (*prealloc_put_consistent_mem_unaligned)(void *vaddr);
  556. };
  557. /* This API detaches the HTC layer from the HIF device */
  558. void hif_detach_htc(struct hif_opaque_softc *hif_ctx);
  559. /****************************************************************/
  560. /* BMI and Diag window abstraction */
  561. /****************************************************************/
  562. #define HIF_BMI_EXCHANGE_NO_TIMEOUT ((uint32_t)(0))
  563. #define DIAG_TRANSFER_LIMIT 2048U /* maximum number of bytes that can be
  564. * handled atomically by
  565. * DiagRead/DiagWrite
  566. */
  567. #ifdef WLAN_FEATURE_BMI
  568. /*
  569. * API to handle HIF-specific BMI message exchanges, this API is synchronous
  570. * and only allowed to be called from a context that can block (sleep)
  571. */
  572. QDF_STATUS hif_exchange_bmi_msg(struct hif_opaque_softc *hif_ctx,
  573. qdf_dma_addr_t cmd, qdf_dma_addr_t rsp,
  574. uint8_t *pSendMessage, uint32_t Length,
  575. uint8_t *pResponseMessage,
  576. uint32_t *pResponseLength, uint32_t TimeoutMS);
  577. void hif_register_bmi_callbacks(struct hif_opaque_softc *hif_ctx);
  578. bool hif_needs_bmi(struct hif_opaque_softc *hif_ctx);
  579. #else /* WLAN_FEATURE_BMI */
  580. static inline void
  581. hif_register_bmi_callbacks(struct hif_opaque_softc *hif_ctx)
  582. {
  583. }
  584. static inline bool
  585. hif_needs_bmi(struct hif_opaque_softc *hif_ctx)
  586. {
  587. return false;
  588. }
  589. #endif /* WLAN_FEATURE_BMI */
  590. /*
  591. * APIs to handle HIF specific diagnostic read accesses. These APIs are
  592. * synchronous and only allowed to be called from a context that
  593. * can block (sleep). They are not high performance APIs.
  594. *
  595. * hif_diag_read_access reads a 4 Byte aligned/length value from a
  596. * Target register or memory word.
  597. *
  598. * hif_diag_read_mem reads an arbitrary length of arbitrarily aligned memory.
  599. */
  600. QDF_STATUS hif_diag_read_access(struct hif_opaque_softc *hif_ctx,
  601. uint32_t address, uint32_t *data);
  602. QDF_STATUS hif_diag_read_mem(struct hif_opaque_softc *hif_ctx, uint32_t address,
  603. uint8_t *data, int nbytes);
  604. void hif_dump_target_memory(struct hif_opaque_softc *hif_ctx,
  605. void *ramdump_base, uint32_t address, uint32_t size);
  606. /*
  607. * APIs to handle HIF specific diagnostic write accesses. These APIs are
  608. * synchronous and only allowed to be called from a context that
  609. * can block (sleep).
  610. * They are not high performance APIs.
  611. *
  612. * hif_diag_write_access writes a 4 Byte aligned/length value to a
  613. * Target register or memory word.
  614. *
  615. * hif_diag_write_mem writes an arbitrary length of arbitrarily aligned memory.
  616. */
  617. QDF_STATUS hif_diag_write_access(struct hif_opaque_softc *hif_ctx,
  618. uint32_t address, uint32_t data);
  619. QDF_STATUS hif_diag_write_mem(struct hif_opaque_softc *hif_ctx,
  620. uint32_t address, uint8_t *data, int nbytes);
  621. typedef void (*fastpath_msg_handler)(void *, qdf_nbuf_t *, uint32_t);
  622. void hif_enable_polled_mode(struct hif_opaque_softc *hif_ctx);
  623. bool hif_is_polled_mode_enabled(struct hif_opaque_softc *hif_ctx);
  624. /*
  625. * Set the FASTPATH_mode_on flag in sc, for use by data path
  626. */
  627. #ifdef WLAN_FEATURE_FASTPATH
  628. void hif_enable_fastpath(struct hif_opaque_softc *hif_ctx);
  629. bool hif_is_fastpath_mode_enabled(struct hif_opaque_softc *hif_ctx);
  630. void *hif_get_ce_handle(struct hif_opaque_softc *hif_ctx, int ret);
  631. /**
  632. * hif_ce_fastpath_cb_register() - Register callback for fastpath msg handler
  633. * @handler: Callback funtcion
  634. * @context: handle for callback function
  635. *
  636. * Return: QDF_STATUS_SUCCESS on success or QDF_STATUS_E_FAILURE
  637. */
  638. QDF_STATUS hif_ce_fastpath_cb_register(
  639. struct hif_opaque_softc *hif_ctx,
  640. fastpath_msg_handler handler, void *context);
  641. #else
  642. static inline QDF_STATUS hif_ce_fastpath_cb_register(
  643. struct hif_opaque_softc *hif_ctx,
  644. fastpath_msg_handler handler, void *context)
  645. {
  646. return QDF_STATUS_E_FAILURE;
  647. }
  648. static inline void *hif_get_ce_handle(struct hif_opaque_softc *hif_ctx, int ret)
  649. {
  650. return NULL;
  651. }
  652. #endif
  653. /*
  654. * Enable/disable CDC max performance workaround
  655. * For max-performace set this to 0
  656. * To allow SoC to enter sleep set this to 1
  657. */
  658. #define CONFIG_DISABLE_CDC_MAX_PERF_WAR 0
  659. void hif_ipa_get_ce_resource(struct hif_opaque_softc *hif_ctx,
  660. qdf_shared_mem_t **ce_sr,
  661. uint32_t *ce_sr_ring_size,
  662. qdf_dma_addr_t *ce_reg_paddr);
  663. /**
  664. * @brief List of callbacks - filled in by HTC.
  665. */
  666. struct hif_msg_callbacks {
  667. void *Context;
  668. /**< context meaningful to HTC */
  669. QDF_STATUS (*txCompletionHandler)(void *Context, qdf_nbuf_t wbuf,
  670. uint32_t transferID,
  671. uint32_t toeplitz_hash_result);
  672. QDF_STATUS (*rxCompletionHandler)(void *Context, qdf_nbuf_t wbuf,
  673. uint8_t pipeID);
  674. void (*txResourceAvailHandler)(void *context, uint8_t pipe);
  675. void (*fwEventHandler)(void *context, QDF_STATUS status);
  676. void (*update_bundle_stats)(void *context, uint8_t no_of_pkt_in_bundle);
  677. };
  678. enum hif_target_status {
  679. TARGET_STATUS_CONNECTED = 0, /* target connected */
  680. TARGET_STATUS_RESET, /* target got reset */
  681. TARGET_STATUS_EJECT, /* target got ejected */
  682. TARGET_STATUS_SUSPEND /*target got suspend */
  683. };
  684. /**
  685. * enum hif_attribute_flags: configure hif
  686. *
  687. * @HIF_LOWDESC_CE_CFG: Configure HIF with Low descriptor CE
  688. * @HIF_LOWDESC_CE_NO_PKTLOG_CFG: Configure HIF with Low descriptor
  689. * + No pktlog CE
  690. */
  691. enum hif_attribute_flags {
  692. HIF_LOWDESC_CE_CFG = 1,
  693. HIF_LOWDESC_CE_NO_PKTLOG_CFG
  694. };
  695. #define HIF_DATA_ATTR_SET_TX_CLASSIFY(attr, v) \
  696. (attr |= (v & 0x01) << 5)
  697. #define HIF_DATA_ATTR_SET_ENCAPSULATION_TYPE(attr, v) \
  698. (attr |= (v & 0x03) << 6)
  699. #define HIF_DATA_ATTR_SET_ADDR_X_SEARCH_DISABLE(attr, v) \
  700. (attr |= (v & 0x01) << 13)
  701. #define HIF_DATA_ATTR_SET_ADDR_Y_SEARCH_DISABLE(attr, v) \
  702. (attr |= (v & 0x01) << 14)
  703. #define HIF_DATA_ATTR_SET_TOEPLITZ_HASH_ENABLE(attr, v) \
  704. (attr |= (v & 0x01) << 15)
  705. #define HIF_DATA_ATTR_SET_PACKET_OR_RESULT_OFFSET(attr, v) \
  706. (attr |= (v & 0x0FFF) << 16)
  707. #define HIF_DATA_ATTR_SET_ENABLE_11H(attr, v) \
  708. (attr |= (v & 0x01) << 30)
  709. struct hif_ul_pipe_info {
  710. unsigned int nentries;
  711. unsigned int nentries_mask;
  712. unsigned int sw_index;
  713. unsigned int write_index; /* cached copy */
  714. unsigned int hw_index; /* cached copy */
  715. void *base_addr_owner_space; /* Host address space */
  716. qdf_dma_addr_t base_addr_CE_space; /* CE address space */
  717. };
  718. struct hif_dl_pipe_info {
  719. unsigned int nentries;
  720. unsigned int nentries_mask;
  721. unsigned int sw_index;
  722. unsigned int write_index; /* cached copy */
  723. unsigned int hw_index; /* cached copy */
  724. void *base_addr_owner_space; /* Host address space */
  725. qdf_dma_addr_t base_addr_CE_space; /* CE address space */
  726. };
  727. struct hif_pipe_addl_info {
  728. uint32_t pci_mem;
  729. uint32_t ctrl_addr;
  730. struct hif_ul_pipe_info ul_pipe;
  731. struct hif_dl_pipe_info dl_pipe;
  732. };
  733. #ifdef CONFIG_SLUB_DEBUG_ON
  734. #define MSG_FLUSH_NUM 16
  735. #else /* PERF build */
  736. #define MSG_FLUSH_NUM 32
  737. #endif /* SLUB_DEBUG_ON */
  738. struct hif_bus_id;
  739. void hif_claim_device(struct hif_opaque_softc *hif_ctx);
  740. QDF_STATUS hif_get_config_item(struct hif_opaque_softc *hif_ctx,
  741. int opcode, void *config, uint32_t config_len);
  742. void hif_set_mailbox_swap(struct hif_opaque_softc *hif_ctx);
  743. void hif_mask_interrupt_call(struct hif_opaque_softc *hif_ctx);
  744. void hif_post_init(struct hif_opaque_softc *hif_ctx, void *hHTC,
  745. struct hif_msg_callbacks *callbacks);
  746. QDF_STATUS hif_start(struct hif_opaque_softc *hif_ctx);
  747. void hif_stop(struct hif_opaque_softc *hif_ctx);
  748. void hif_flush_surprise_remove(struct hif_opaque_softc *hif_ctx);
  749. void hif_dump(struct hif_opaque_softc *hif_ctx, uint8_t CmdId, bool start);
  750. void hif_trigger_dump(struct hif_opaque_softc *hif_ctx,
  751. uint8_t cmd_id, bool start);
  752. QDF_STATUS hif_send_head(struct hif_opaque_softc *hif_ctx, uint8_t PipeID,
  753. uint32_t transferID, uint32_t nbytes,
  754. qdf_nbuf_t wbuf, uint32_t data_attr);
  755. void hif_send_complete_check(struct hif_opaque_softc *hif_ctx, uint8_t PipeID,
  756. int force);
  757. void hif_shut_down_device(struct hif_opaque_softc *hif_ctx);
  758. void hif_get_default_pipe(struct hif_opaque_softc *hif_ctx, uint8_t *ULPipe,
  759. uint8_t *DLPipe);
  760. int hif_map_service_to_pipe(struct hif_opaque_softc *hif_ctx, uint16_t svc_id,
  761. uint8_t *ul_pipe, uint8_t *dl_pipe, int *ul_is_polled,
  762. int *dl_is_polled);
  763. uint16_t
  764. hif_get_free_queue_number(struct hif_opaque_softc *hif_ctx, uint8_t PipeID);
  765. void *hif_get_targetdef(struct hif_opaque_softc *hif_ctx);
  766. uint32_t hif_hia_item_address(uint32_t target_type, uint32_t item_offset);
  767. void hif_set_target_sleep(struct hif_opaque_softc *hif_ctx, bool sleep_ok,
  768. bool wait_for_it);
  769. int hif_check_fw_reg(struct hif_opaque_softc *hif_ctx);
  770. #ifndef HIF_PCI
  771. static inline int hif_check_soc_status(struct hif_opaque_softc *hif_ctx)
  772. {
  773. return 0;
  774. }
  775. #else
  776. int hif_check_soc_status(struct hif_opaque_softc *hif_ctx);
  777. #endif
  778. void hif_get_hw_info(struct hif_opaque_softc *hif_ctx, u32 *version,
  779. u32 *revision, const char **target_name);
  780. #ifdef RECEIVE_OFFLOAD
  781. /**
  782. * hif_offld_flush_cb_register() - Register the offld flush callback
  783. * @scn: HIF opaque context
  784. * @offld_flush_handler: Flush callback is either ol_flush, incase of rx_thread
  785. * Or GRO/LRO flush when RxThread is not enabled. Called
  786. * with corresponding context for flush.
  787. * Return: None
  788. */
  789. void hif_offld_flush_cb_register(struct hif_opaque_softc *scn,
  790. void (offld_flush_handler)(void *ol_ctx));
  791. /**
  792. * hif_offld_flush_cb_deregister() - deRegister the offld flush callback
  793. * @scn: HIF opaque context
  794. *
  795. * Return: None
  796. */
  797. void hif_offld_flush_cb_deregister(struct hif_opaque_softc *scn);
  798. #endif
  799. #ifdef WLAN_FEATURE_RX_SOFTIRQ_TIME_LIMIT
  800. /**
  801. * hif_exec_should_yield() - Check if hif napi context should yield
  802. * @hif_ctx - HIF opaque context
  803. * @grp_id - grp_id of the napi for which check needs to be done
  804. *
  805. * The function uses grp_id to look for NAPI and checks if NAPI needs to
  806. * yield. HIF_EXT_GROUP_MAX_YIELD_DURATION_NS is the duration used for
  807. * yield decision.
  808. *
  809. * Return: true if NAPI needs to yield, else false
  810. */
  811. bool hif_exec_should_yield(struct hif_opaque_softc *hif_ctx, uint grp_id);
  812. #else
  813. static inline bool hif_exec_should_yield(struct hif_opaque_softc *hif_ctx,
  814. uint grp_id)
  815. {
  816. return false;
  817. }
  818. #endif
  819. void hif_disable_isr(struct hif_opaque_softc *hif_ctx);
  820. void hif_reset_soc(struct hif_opaque_softc *hif_ctx);
  821. void hif_save_htc_htt_config_endpoint(struct hif_opaque_softc *hif_ctx,
  822. int htc_htt_tx_endpoint);
  823. /**
  824. * hif_open() - Create hif handle
  825. * @qdf_ctx: qdf context
  826. * @mode: Driver Mode
  827. * @bus_type: Bus Type
  828. * @cbk: CDS Callbacks
  829. * @psoc: psoc object manager
  830. *
  831. * API to open HIF Context
  832. *
  833. * Return: HIF Opaque Pointer
  834. */
  835. struct hif_opaque_softc *hif_open(qdf_device_t qdf_ctx,
  836. uint32_t mode,
  837. enum qdf_bus_type bus_type,
  838. struct hif_driver_state_callbacks *cbk,
  839. struct wlan_objmgr_psoc *psoc);
  840. void hif_close(struct hif_opaque_softc *hif_ctx);
  841. QDF_STATUS hif_enable(struct hif_opaque_softc *hif_ctx, struct device *dev,
  842. void *bdev, const struct hif_bus_id *bid,
  843. enum qdf_bus_type bus_type,
  844. enum hif_enable_type type);
  845. void hif_disable(struct hif_opaque_softc *hif_ctx, enum hif_disable_type type);
  846. #ifdef CE_TASKLET_DEBUG_ENABLE
  847. void hif_enable_ce_latency_stats(struct hif_opaque_softc *hif_ctx,
  848. uint8_t value);
  849. #endif
  850. void hif_display_stats(struct hif_opaque_softc *hif_ctx);
  851. void hif_clear_stats(struct hif_opaque_softc *hif_ctx);
  852. /**
  853. * enum wlan_rtpm_dbgid - runtime pm put/get debug id
  854. * @RTPM_ID_RESVERD: Reserved
  855. * @RTPM_ID_WMI: WMI sending msg, expect put happen at
  856. * tx completion from CE level directly.
  857. * @RTPM_ID_HTC: pkt sending by HTT_DATA_MSG_SVC, expect
  858. * put from fw response or just in
  859. * htc_issue_packets
  860. * @RTPM_ID_QOS_NOTIFY: pm qos notifer
  861. * @RTPM_ID_DP_TX_DESC_ALLOC_FREE: tx desc alloc/free
  862. * @RTPM_ID_CE_SEND_FAST: operation in ce_send_fast, not include
  863. * the pkt put happens outside this function
  864. * @RTPM_ID_SUSPEND_RESUME: suspend/resume in hdd
  865. * @RTPM_ID_DW_TX_HW_ENQUEUE: operation in functin dp_tx_hw_enqueue
  866. * @RTPM_ID_HAL_REO_CMD: HAL_REO_CMD operation
  867. * @RTPM_ID_DP_PRINT_RING_STATS: operation in dp_print_ring_stats
  868. */
  869. /* New value added to the enum must also be reflected in function
  870. * rtpm_string_from_dbgid()
  871. */
  872. typedef enum {
  873. RTPM_ID_RESVERD = 0,
  874. RTPM_ID_WMI = 1,
  875. RTPM_ID_HTC = 2,
  876. RTPM_ID_QOS_NOTIFY = 3,
  877. RTPM_ID_DP_TX_DESC_ALLOC_FREE = 4,
  878. RTPM_ID_CE_SEND_FAST = 5,
  879. RTPM_ID_SUSPEND_RESUME = 6,
  880. RTPM_ID_DW_TX_HW_ENQUEUE = 7,
  881. RTPM_ID_HAL_REO_CMD = 8,
  882. RTPM_ID_DP_PRINT_RING_STATS = 9,
  883. RTPM_ID_MAX,
  884. } wlan_rtpm_dbgid;
  885. /**
  886. * rtpm_string_from_dbgid() - Convert dbgid to respective string
  887. * @id - debug id
  888. *
  889. * Debug support function to convert dbgid to string.
  890. * Please note to add new string in the array at index equal to
  891. * its enum value in wlan_rtpm_dbgid.
  892. */
  893. static inline char *rtpm_string_from_dbgid(wlan_rtpm_dbgid id)
  894. {
  895. static const char *strings[] = { "RTPM_ID_RESVERD",
  896. "RTPM_ID_WMI",
  897. "RTPM_ID_HTC",
  898. "RTPM_ID_QOS_NOTIFY",
  899. "RTPM_ID_DP_TX_DESC_ALLOC_FREE",
  900. "RTPM_ID_CE_SEND_FAST",
  901. "RTPM_ID_SUSPEND_RESUME",
  902. "RTPM_ID_DW_TX_HW_ENQUEUE",
  903. "RTPM_ID_HAL_REO_CMD",
  904. "RTPM_ID_DP_PRINT_RING_STATS",
  905. "RTPM_ID_MAX"};
  906. return (char *)strings[id];
  907. }
  908. #ifdef FEATURE_RUNTIME_PM
  909. struct hif_pm_runtime_lock;
  910. void hif_fastpath_resume(struct hif_opaque_softc *hif_ctx);
  911. int hif_pm_runtime_get_sync(struct hif_opaque_softc *hif_ctx,
  912. wlan_rtpm_dbgid rtpm_dbgid);
  913. int hif_pm_runtime_put_sync_suspend(struct hif_opaque_softc *hif_ctx,
  914. wlan_rtpm_dbgid rtpm_dbgid);
  915. int hif_pm_runtime_request_resume(struct hif_opaque_softc *hif_ctx);
  916. int hif_pm_runtime_get(struct hif_opaque_softc *hif_ctx,
  917. wlan_rtpm_dbgid rtpm_dbgid);
  918. void hif_pm_runtime_get_noresume(struct hif_opaque_softc *hif_ctx,
  919. wlan_rtpm_dbgid rtpm_dbgid);
  920. int hif_pm_runtime_put(struct hif_opaque_softc *hif_ctx,
  921. wlan_rtpm_dbgid rtpm_dbgid);
  922. int hif_pm_runtime_put_noidle(struct hif_opaque_softc *hif_ctx,
  923. wlan_rtpm_dbgid rtpm_dbgid);
  924. void hif_pm_runtime_mark_last_busy(struct hif_opaque_softc *hif_ctx);
  925. int hif_runtime_lock_init(qdf_runtime_lock_t *lock, const char *name);
  926. void hif_runtime_lock_deinit(struct hif_opaque_softc *hif_ctx,
  927. struct hif_pm_runtime_lock *lock);
  928. int hif_pm_runtime_prevent_suspend(struct hif_opaque_softc *ol_sc,
  929. struct hif_pm_runtime_lock *lock);
  930. int hif_pm_runtime_allow_suspend(struct hif_opaque_softc *ol_sc,
  931. struct hif_pm_runtime_lock *lock);
  932. bool hif_pm_runtime_is_suspended(struct hif_opaque_softc *hif_ctx);
  933. int hif_pm_runtime_get_monitor_wake_intr(struct hif_opaque_softc *hif_ctx);
  934. void hif_pm_runtime_set_monitor_wake_intr(struct hif_opaque_softc *hif_ctx,
  935. int val);
  936. void hif_pm_runtime_check_and_request_resume(struct hif_opaque_softc *hif_ctx);
  937. void hif_pm_runtime_mark_dp_rx_busy(struct hif_opaque_softc *hif_ctx);
  938. int hif_pm_runtime_is_dp_rx_busy(struct hif_opaque_softc *hif_ctx);
  939. qdf_time_t hif_pm_runtime_get_dp_rx_busy_mark(struct hif_opaque_softc *hif_ctx);
  940. int hif_pm_runtime_sync_resume(struct hif_opaque_softc *hif_ctx);
  941. #else
  942. struct hif_pm_runtime_lock {
  943. const char *name;
  944. };
  945. static inline void hif_fastpath_resume(struct hif_opaque_softc *hif_ctx) {}
  946. static inline int
  947. hif_pm_runtime_get_sync(struct hif_opaque_softc *hif_ctx,
  948. wlan_rtpm_dbgid rtpm_dbgid)
  949. { return 0; }
  950. static inline int
  951. hif_pm_runtime_put_sync_suspend(struct hif_opaque_softc *hif_ctx,
  952. wlan_rtpm_dbgid rtpm_dbgid)
  953. { return 0; }
  954. static inline int
  955. hif_pm_runtime_request_resume(struct hif_opaque_softc *hif_ctx)
  956. { return 0; }
  957. static inline void
  958. hif_pm_runtime_get_noresume(struct hif_opaque_softc *hif_ctx,
  959. wlan_rtpm_dbgid rtpm_dbgid)
  960. {}
  961. static inline int
  962. hif_pm_runtime_get(struct hif_opaque_softc *hif_ctx, wlan_rtpm_dbgid rtpm_dbgid)
  963. { return 0; }
  964. static inline int
  965. hif_pm_runtime_put(struct hif_opaque_softc *hif_ctx, wlan_rtpm_dbgid rtpm_dbgid)
  966. { return 0; }
  967. static inline int
  968. hif_pm_runtime_put_noidle(struct hif_opaque_softc *hif_ctx,
  969. wlan_rtpm_dbgid rtpm_dbgid)
  970. { return 0; }
  971. static inline void
  972. hif_pm_runtime_mark_last_busy(struct hif_opaque_softc *hif_ctx) {};
  973. static inline int hif_runtime_lock_init(qdf_runtime_lock_t *lock,
  974. const char *name)
  975. { return 0; }
  976. static inline void
  977. hif_runtime_lock_deinit(struct hif_opaque_softc *hif_ctx,
  978. struct hif_pm_runtime_lock *lock) {}
  979. static inline int hif_pm_runtime_prevent_suspend(struct hif_opaque_softc *ol_sc,
  980. struct hif_pm_runtime_lock *lock)
  981. { return 0; }
  982. static inline int hif_pm_runtime_allow_suspend(struct hif_opaque_softc *ol_sc,
  983. struct hif_pm_runtime_lock *lock)
  984. { return 0; }
  985. static inline bool hif_pm_runtime_is_suspended(struct hif_opaque_softc *hif_ctx)
  986. { return false; }
  987. static inline int
  988. hif_pm_runtime_get_monitor_wake_intr(struct hif_opaque_softc *hif_ctx)
  989. { return 0; }
  990. static inline void
  991. hif_pm_runtime_set_monitor_wake_intr(struct hif_opaque_softc *hif_ctx, int val)
  992. { return; }
  993. static inline void
  994. hif_pm_runtime_check_and_request_resume(struct hif_opaque_softc *hif_ctx)
  995. { return; }
  996. static inline void
  997. hif_pm_runtime_mark_dp_rx_busy(struct hif_opaque_softc *hif_ctx) {};
  998. static inline int
  999. hif_pm_runtime_is_dp_rx_busy(struct hif_opaque_softc *hif_ctx)
  1000. { return 0; }
  1001. static inline qdf_time_t
  1002. hif_pm_runtime_get_dp_rx_busy_mark(struct hif_opaque_softc *hif_ctx)
  1003. { return 0; }
  1004. static inline int hif_pm_runtime_sync_resume(struct hif_opaque_softc *hif_ctx)
  1005. { return 0; }
  1006. #endif
  1007. void hif_enable_power_management(struct hif_opaque_softc *hif_ctx,
  1008. bool is_packet_log_enabled);
  1009. void hif_disable_power_management(struct hif_opaque_softc *hif_ctx);
  1010. void hif_vote_link_down(struct hif_opaque_softc *hif_ctx);
  1011. void hif_vote_link_up(struct hif_opaque_softc *hif_ctx);
  1012. bool hif_can_suspend_link(struct hif_opaque_softc *hif_ctx);
  1013. #ifdef IPA_OFFLOAD
  1014. /**
  1015. * hif_get_ipa_hw_type() - get IPA hw type
  1016. *
  1017. * This API return the IPA hw type.
  1018. *
  1019. * Return: IPA hw type
  1020. */
  1021. static inline
  1022. enum ipa_hw_type hif_get_ipa_hw_type(void)
  1023. {
  1024. return ipa_get_hw_type();
  1025. }
  1026. /**
  1027. * hif_get_ipa_present() - get IPA hw status
  1028. *
  1029. * This API return the IPA hw status.
  1030. *
  1031. * Return: true if IPA is present or false otherwise
  1032. */
  1033. static inline
  1034. bool hif_get_ipa_present(void)
  1035. {
  1036. if (ipa_uc_reg_rdyCB(NULL) != -EPERM)
  1037. return true;
  1038. else
  1039. return false;
  1040. }
  1041. #endif
  1042. int hif_bus_resume(struct hif_opaque_softc *hif_ctx);
  1043. /**
  1044. * hif_bus_ealry_suspend() - stop non wmi tx traffic
  1045. * @context: hif context
  1046. */
  1047. int hif_bus_early_suspend(struct hif_opaque_softc *hif_ctx);
  1048. /**
  1049. * hif_bus_late_resume() - resume non wmi traffic
  1050. * @context: hif context
  1051. */
  1052. int hif_bus_late_resume(struct hif_opaque_softc *hif_ctx);
  1053. int hif_bus_suspend(struct hif_opaque_softc *hif_ctx);
  1054. int hif_bus_resume_noirq(struct hif_opaque_softc *hif_ctx);
  1055. int hif_bus_suspend_noirq(struct hif_opaque_softc *hif_ctx);
  1056. /**
  1057. * hif_apps_irqs_enable() - Enables all irqs from the APPS side
  1058. * @hif_ctx: an opaque HIF handle to use
  1059. *
  1060. * As opposed to the standard hif_irq_enable, this function always applies to
  1061. * the APPS side kernel interrupt handling.
  1062. *
  1063. * Return: errno
  1064. */
  1065. int hif_apps_irqs_enable(struct hif_opaque_softc *hif_ctx);
  1066. /**
  1067. * hif_apps_irqs_disable() - Disables all irqs from the APPS side
  1068. * @hif_ctx: an opaque HIF handle to use
  1069. *
  1070. * As opposed to the standard hif_irq_disable, this function always applies to
  1071. * the APPS side kernel interrupt handling.
  1072. *
  1073. * Return: errno
  1074. */
  1075. int hif_apps_irqs_disable(struct hif_opaque_softc *hif_ctx);
  1076. /**
  1077. * hif_apps_wake_irq_enable() - Enables the wake irq from the APPS side
  1078. * @hif_ctx: an opaque HIF handle to use
  1079. *
  1080. * As opposed to the standard hif_irq_enable, this function always applies to
  1081. * the APPS side kernel interrupt handling.
  1082. *
  1083. * Return: errno
  1084. */
  1085. int hif_apps_wake_irq_enable(struct hif_opaque_softc *hif_ctx);
  1086. /**
  1087. * hif_apps_wake_irq_disable() - Disables the wake irq from the APPS side
  1088. * @hif_ctx: an opaque HIF handle to use
  1089. *
  1090. * As opposed to the standard hif_irq_disable, this function always applies to
  1091. * the APPS side kernel interrupt handling.
  1092. *
  1093. * Return: errno
  1094. */
  1095. int hif_apps_wake_irq_disable(struct hif_opaque_softc *hif_ctx);
  1096. /**
  1097. * hif_apps_enable_irq_wake() - Enables the irq wake from the APPS side
  1098. * @hif_ctx: an opaque HIF handle to use
  1099. *
  1100. * This function always applies to the APPS side kernel interrupt handling
  1101. * to wake the system from suspend.
  1102. *
  1103. * Return: errno
  1104. */
  1105. int hif_apps_enable_irq_wake(struct hif_opaque_softc *hif_ctx);
  1106. /**
  1107. * hif_apps_disable_irq_wake() - Disables the wake irq from the APPS side
  1108. * @hif_ctx: an opaque HIF handle to use
  1109. *
  1110. * This function always applies to the APPS side kernel interrupt handling
  1111. * to disable the wake irq.
  1112. *
  1113. * Return: errno
  1114. */
  1115. int hif_apps_disable_irq_wake(struct hif_opaque_softc *hif_ctx);
  1116. #ifdef FEATURE_RUNTIME_PM
  1117. int hif_pre_runtime_suspend(struct hif_opaque_softc *hif_ctx);
  1118. void hif_pre_runtime_resume(struct hif_opaque_softc *hif_ctx);
  1119. int hif_runtime_suspend(struct hif_opaque_softc *hif_ctx);
  1120. int hif_runtime_resume(struct hif_opaque_softc *hif_ctx);
  1121. void hif_process_runtime_suspend_success(struct hif_opaque_softc *hif_ctx);
  1122. void hif_process_runtime_suspend_failure(struct hif_opaque_softc *hif_ctx);
  1123. void hif_process_runtime_resume_success(struct hif_opaque_softc *hif_ctx);
  1124. #endif
  1125. int hif_get_irq_num(struct hif_opaque_softc *scn, int *irq, uint32_t size);
  1126. int hif_dump_registers(struct hif_opaque_softc *scn);
  1127. int ol_copy_ramdump(struct hif_opaque_softc *scn);
  1128. void hif_crash_shutdown(struct hif_opaque_softc *hif_ctx);
  1129. void hif_get_hw_info(struct hif_opaque_softc *hif_ctx, u32 *version,
  1130. u32 *revision, const char **target_name);
  1131. enum qdf_bus_type hif_get_bus_type(struct hif_opaque_softc *hif_hdl);
  1132. struct hif_target_info *hif_get_target_info_handle(struct hif_opaque_softc *
  1133. scn);
  1134. struct hif_config_info *hif_get_ini_handle(struct hif_opaque_softc *hif_ctx);
  1135. struct ramdump_info *hif_get_ramdump_ctx(struct hif_opaque_softc *hif_ctx);
  1136. enum hif_target_status hif_get_target_status(struct hif_opaque_softc *hif_ctx);
  1137. void hif_set_target_status(struct hif_opaque_softc *hif_ctx, enum
  1138. hif_target_status);
  1139. void hif_init_ini_config(struct hif_opaque_softc *hif_ctx,
  1140. struct hif_config_info *cfg);
  1141. void hif_update_tx_ring(struct hif_opaque_softc *osc, u_int32_t num_htt_cmpls);
  1142. qdf_nbuf_t hif_batch_send(struct hif_opaque_softc *osc, qdf_nbuf_t msdu,
  1143. uint32_t transfer_id, u_int32_t len, uint32_t sendhead);
  1144. QDF_STATUS hif_send_single(struct hif_opaque_softc *osc, qdf_nbuf_t msdu,
  1145. uint32_t transfer_id, u_int32_t len);
  1146. int hif_send_fast(struct hif_opaque_softc *osc, qdf_nbuf_t nbuf,
  1147. uint32_t transfer_id, uint32_t download_len);
  1148. void hif_pkt_dl_len_set(void *hif_sc, unsigned int pkt_download_len);
  1149. void hif_ce_war_disable(void);
  1150. void hif_ce_war_enable(void);
  1151. void hif_disable_interrupt(struct hif_opaque_softc *osc, uint32_t pipe_num);
  1152. #ifdef QCA_NSS_WIFI_OFFLOAD_SUPPORT
  1153. struct hif_pipe_addl_info *hif_get_addl_pipe_info(struct hif_opaque_softc *osc,
  1154. struct hif_pipe_addl_info *hif_info, uint32_t pipe_number);
  1155. uint32_t hif_set_nss_wifiol_mode(struct hif_opaque_softc *osc,
  1156. uint32_t pipe_num);
  1157. int32_t hif_get_nss_wifiol_bypass_nw_process(struct hif_opaque_softc *osc);
  1158. #endif /* QCA_NSS_WIFI_OFFLOAD_SUPPORT */
  1159. void hif_set_bundle_mode(struct hif_opaque_softc *hif_ctx, bool enabled,
  1160. int rx_bundle_cnt);
  1161. int hif_bus_reset_resume(struct hif_opaque_softc *hif_ctx);
  1162. void hif_set_attribute(struct hif_opaque_softc *osc, uint8_t hif_attrib);
  1163. void *hif_get_lro_info(int ctx_id, struct hif_opaque_softc *hif_hdl);
  1164. enum hif_exec_type {
  1165. HIF_EXEC_NAPI_TYPE,
  1166. HIF_EXEC_TASKLET_TYPE,
  1167. };
  1168. typedef uint32_t (*ext_intr_handler)(void *, uint32_t);
  1169. /**
  1170. * hif_get_int_ctx_irq_num() - retrieve an irq num for an interrupt context id
  1171. * @softc: hif opaque context owning the exec context
  1172. * @id: the id of the interrupt context
  1173. *
  1174. * Return: IRQ number of the first (zero'th) IRQ within the interrupt context ID
  1175. * 'id' registered with the OS
  1176. */
  1177. int32_t hif_get_int_ctx_irq_num(struct hif_opaque_softc *softc,
  1178. uint8_t id);
  1179. /**
  1180. * hif_configure_ext_group_interrupts() - Congigure ext group intrrupts
  1181. * @hif_ctx: hif opaque context
  1182. *
  1183. * Return: QDF_STATUS
  1184. */
  1185. QDF_STATUS hif_configure_ext_group_interrupts(struct hif_opaque_softc *hif_ctx);
  1186. /**
  1187. * hif_register_ext_group() - API to register external group
  1188. * interrupt handler.
  1189. * @hif_ctx : HIF Context
  1190. * @numirq: number of irq's in the group
  1191. * @irq: array of irq values
  1192. * @handler: callback interrupt handler function
  1193. * @cb_ctx: context to passed in callback
  1194. * @type: napi vs tasklet
  1195. *
  1196. * Return: QDF_STATUS
  1197. */
  1198. QDF_STATUS hif_register_ext_group(struct hif_opaque_softc *hif_ctx,
  1199. uint32_t numirq, uint32_t irq[],
  1200. ext_intr_handler handler,
  1201. void *cb_ctx, const char *context_name,
  1202. enum hif_exec_type type, uint32_t scale);
  1203. void hif_deregister_exec_group(struct hif_opaque_softc *hif_ctx,
  1204. const char *context_name);
  1205. void hif_update_pipe_callback(struct hif_opaque_softc *osc,
  1206. u_int8_t pipeid,
  1207. struct hif_msg_callbacks *callbacks);
  1208. /**
  1209. * hif_print_napi_stats() - Display HIF NAPI stats
  1210. * @hif_ctx - HIF opaque context
  1211. *
  1212. * Return: None
  1213. */
  1214. void hif_print_napi_stats(struct hif_opaque_softc *hif_ctx);
  1215. /* hif_clear_napi_stats() - function clears the stats of the
  1216. * latency when called.
  1217. * @hif_ctx - the HIF context to assign the callback to
  1218. *
  1219. * Return: None
  1220. */
  1221. void hif_clear_napi_stats(struct hif_opaque_softc *hif_ctx);
  1222. #ifdef __cplusplus
  1223. }
  1224. #endif
  1225. #ifdef FORCE_WAKE
  1226. /**
  1227. * hif_force_wake_request() - Function to wake from power collapse
  1228. * @handle: HIF opaque handle
  1229. *
  1230. * Description: API to check if the device is awake or not before
  1231. * read/write to BAR + 4K registers. If device is awake return
  1232. * success otherwise write '1' to
  1233. * PCIE_PCIE_LOCAL_REG_PCIE_SOC_WAKE_PCIE_LOCAL_REG which will interrupt
  1234. * the device and does wakeup the PCI and MHI within 50ms
  1235. * and then the device writes a value to
  1236. * PCIE_SOC_PCIE_REG_PCIE_SCRATCH_0_SOC_PCIE_REG to complete the
  1237. * handshake process to let the host know the device is awake.
  1238. *
  1239. * Return: zero - success/non-zero - failure
  1240. */
  1241. int hif_force_wake_request(struct hif_opaque_softc *handle);
  1242. /**
  1243. * hif_force_wake_release() - API to release/reset the SOC wake register
  1244. * from interrupting the device.
  1245. * @handle: HIF opaque handle
  1246. *
  1247. * Description: API to set the
  1248. * PCIE_PCIE_LOCAL_REG_PCIE_SOC_WAKE_PCIE_LOCAL_REG to '0'
  1249. * to release the interrupt line.
  1250. *
  1251. * Return: zero - success/non-zero - failure
  1252. */
  1253. int hif_force_wake_release(struct hif_opaque_softc *handle);
  1254. #else
  1255. static inline
  1256. int hif_force_wake_request(struct hif_opaque_softc *handle)
  1257. {
  1258. return 0;
  1259. }
  1260. static inline
  1261. int hif_force_wake_release(struct hif_opaque_softc *handle)
  1262. {
  1263. return 0;
  1264. }
  1265. #endif /* FORCE_WAKE */
  1266. #ifdef FEATURE_HAL_DELAYED_REG_WRITE
  1267. /**
  1268. * hif_prevent_link_low_power_states() - Prevent from going to low power states
  1269. * @hif - HIF opaque context
  1270. *
  1271. * Return: 0 on success. Error code on failure.
  1272. */
  1273. int hif_prevent_link_low_power_states(struct hif_opaque_softc *hif);
  1274. /**
  1275. * hif_allow_link_low_power_states() - Allow link to go to low power states
  1276. * @hif - HIF opaque context
  1277. *
  1278. * Return: None
  1279. */
  1280. void hif_allow_link_low_power_states(struct hif_opaque_softc *hif);
  1281. #else
  1282. static inline
  1283. int hif_prevent_link_low_power_states(struct hif_opaque_softc *hif)
  1284. {
  1285. return 0;
  1286. }
  1287. static inline
  1288. void hif_allow_link_low_power_states(struct hif_opaque_softc *hif)
  1289. {
  1290. }
  1291. #endif
  1292. void *hif_get_dev_ba(struct hif_opaque_softc *hif_handle);
  1293. void *hif_get_dev_ba_ce(struct hif_opaque_softc *hif_handle);
  1294. /**
  1295. * hif_set_initial_wakeup_cb() - set the initial wakeup event handler function
  1296. * @hif_ctx - the HIF context to assign the callback to
  1297. * @callback - the callback to assign
  1298. * @priv - the private data to pass to the callback when invoked
  1299. *
  1300. * Return: None
  1301. */
  1302. void hif_set_initial_wakeup_cb(struct hif_opaque_softc *hif_ctx,
  1303. void (*callback)(void *),
  1304. void *priv);
  1305. /*
  1306. * Note: For MCL, #if defined (HIF_CONFIG_SLUB_DEBUG_ON) needs to be checked
  1307. * for defined here
  1308. */
  1309. #if defined(HIF_CONFIG_SLUB_DEBUG_ON) || defined(HIF_CE_DEBUG_DATA_BUF)
  1310. ssize_t hif_dump_desc_trace_buf(struct device *dev,
  1311. struct device_attribute *attr, char *buf);
  1312. ssize_t hif_input_desc_trace_buf_index(struct hif_softc *scn,
  1313. const char *buf, size_t size);
  1314. ssize_t hif_ce_en_desc_hist(struct hif_softc *scn,
  1315. const char *buf, size_t size);
  1316. ssize_t hif_disp_ce_enable_desc_data_hist(struct hif_softc *scn, char *buf);
  1317. ssize_t hif_dump_desc_event(struct hif_softc *scn, char *buf);
  1318. #endif/*#if defined(HIF_CONFIG_SLUB_DEBUG_ON)||defined(HIF_CE_DEBUG_DATA_BUF)*/
  1319. /**
  1320. * hif_set_ce_service_max_yield_time() - sets CE service max yield time
  1321. * @hif: hif context
  1322. * @ce_service_max_yield_time: CE service max yield time to set
  1323. *
  1324. * This API storess CE service max yield time in hif context based
  1325. * on ini value.
  1326. *
  1327. * Return: void
  1328. */
  1329. void hif_set_ce_service_max_yield_time(struct hif_opaque_softc *hif,
  1330. uint32_t ce_service_max_yield_time);
  1331. /**
  1332. * hif_get_ce_service_max_yield_time() - get CE service max yield time
  1333. * @hif: hif context
  1334. *
  1335. * This API returns CE service max yield time.
  1336. *
  1337. * Return: CE service max yield time
  1338. */
  1339. unsigned long long
  1340. hif_get_ce_service_max_yield_time(struct hif_opaque_softc *hif);
  1341. /**
  1342. * hif_set_ce_service_max_rx_ind_flush() - sets CE service max rx ind flush
  1343. * @hif: hif context
  1344. * @ce_service_max_rx_ind_flush: CE service max rx ind flush to set
  1345. *
  1346. * This API stores CE service max rx ind flush in hif context based
  1347. * on ini value.
  1348. *
  1349. * Return: void
  1350. */
  1351. void hif_set_ce_service_max_rx_ind_flush(struct hif_opaque_softc *hif,
  1352. uint8_t ce_service_max_rx_ind_flush);
  1353. #ifdef OL_ATH_SMART_LOGGING
  1354. /*
  1355. * hif_log_ce_dump() - Copy all the CE DEST ring to buf
  1356. * @scn : HIF handler
  1357. * @buf_cur: Current pointer in ring buffer
  1358. * @buf_init:Start of the ring buffer
  1359. * @buf_sz: Size of the ring buffer
  1360. * @ce: Copy Engine id
  1361. * @skb_sz: Max size of the SKB buffer to be copied
  1362. *
  1363. * Calls the respective function to dump all the CE SRC/DEST ring descriptors
  1364. * and buffers pointed by them in to the given buf
  1365. *
  1366. * Return: Current pointer in ring buffer
  1367. */
  1368. uint8_t *hif_log_dump_ce(struct hif_softc *scn, uint8_t *buf_cur,
  1369. uint8_t *buf_init, uint32_t buf_sz,
  1370. uint32_t ce, uint32_t skb_sz);
  1371. #endif /* OL_ATH_SMART_LOGGING */
  1372. /*
  1373. * hif_softc_to_hif_opaque_softc - API to convert hif_softc handle
  1374. * to hif_opaque_softc handle
  1375. * @hif_handle - hif_softc type
  1376. *
  1377. * Return: hif_opaque_softc type
  1378. */
  1379. static inline struct hif_opaque_softc *
  1380. hif_softc_to_hif_opaque_softc(struct hif_softc *hif_handle)
  1381. {
  1382. return (struct hif_opaque_softc *)hif_handle;
  1383. }
  1384. #ifdef FORCE_WAKE
  1385. /**
  1386. * hif_srng_init_phase(): Indicate srng initialization phase
  1387. * to avoid force wake as UMAC power collapse is not yet
  1388. * enabled
  1389. * @hif_ctx: hif opaque handle
  1390. * @init_phase: initialization phase
  1391. *
  1392. * Return: None
  1393. */
  1394. void hif_srng_init_phase(struct hif_opaque_softc *hif_ctx,
  1395. bool init_phase);
  1396. #else
  1397. static inline
  1398. void hif_srng_init_phase(struct hif_opaque_softc *hif_ctx,
  1399. bool init_phase)
  1400. {
  1401. }
  1402. #endif /* FORCE_WAKE */
  1403. #ifdef HIF_IPCI
  1404. /**
  1405. * hif_shutdown_notifier_cb - Call back for shutdown notifier
  1406. * @ctx: hif handle
  1407. *
  1408. * Return: None
  1409. */
  1410. void hif_shutdown_notifier_cb(void *ctx);
  1411. #else
  1412. static inline
  1413. void hif_shutdown_notifier_cb(void *ctx)
  1414. {
  1415. }
  1416. #endif /* HIF_IPCI */
  1417. #ifdef HIF_CE_LOG_INFO
  1418. /**
  1419. * hif_log_ce_info() - API to log ce info
  1420. * @scn: hif handle
  1421. * @data: hang event data buffer
  1422. * @offset: offset at which data needs to be written
  1423. *
  1424. * Return: None
  1425. */
  1426. void hif_log_ce_info(struct hif_softc *scn, uint8_t *data,
  1427. unsigned int *offset);
  1428. #else
  1429. static inline
  1430. void hif_log_ce_info(struct hif_softc *scn, uint8_t *data,
  1431. unsigned int *offset)
  1432. {
  1433. }
  1434. #endif
  1435. #ifdef HIF_CPU_PERF_AFFINE_MASK
  1436. /**
  1437. * hif_config_irq_set_perf_affinity_hint() - API to set affinity
  1438. * @hif_ctx: hif opaque handle
  1439. *
  1440. * This function is used to move the WLAN IRQs to perf cores in
  1441. * case of defconfig builds.
  1442. *
  1443. * Return: None
  1444. */
  1445. void hif_config_irq_set_perf_affinity_hint(
  1446. struct hif_opaque_softc *hif_ctx);
  1447. #else
  1448. static inline void hif_config_irq_set_perf_affinity_hint(
  1449. struct hif_opaque_softc *hif_ctx)
  1450. {
  1451. }
  1452. #endif
  1453. #endif /* _HIF_H_ */