hif.h 62 KB

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