hif.h 68 KB

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