hif.h 68 KB

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