hif.h 55 KB

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