hif.h 62 KB

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