hif.h 61 KB

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