hif.h 52 KB

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