hif.h 67 KB

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