hif.h 58 KB

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