hif.h 60 KB

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