hif.h 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200
  1. /*
  2. * Copyright (c) 2013-2019 The Linux Foundation. All rights reserved.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for
  5. * any purpose with or without fee is hereby granted, provided that the
  6. * above copyright notice and this permission notice appear in all
  7. * copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  10. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  11. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  12. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  13. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  14. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  15. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  16. * PERFORMANCE OF THIS SOFTWARE.
  17. */
  18. #ifndef _HIF_H_
  19. #define _HIF_H_
  20. #ifdef __cplusplus
  21. extern "C" {
  22. #endif /* __cplusplus */
  23. /* Header files */
  24. #include <qdf_status.h>
  25. #include "qdf_nbuf.h"
  26. #include "qdf_lro.h"
  27. #include "ol_if_athvar.h"
  28. #include <linux/platform_device.h>
  29. #ifdef HIF_PCI
  30. #include <linux/pci.h>
  31. #endif /* HIF_PCI */
  32. #ifdef HIF_USB
  33. #include <linux/usb.h>
  34. #endif /* HIF_USB */
  35. #ifdef IPA_OFFLOAD
  36. #include <linux/ipa.h>
  37. #endif
  38. #define ENABLE_MBOX_DUMMY_SPACE_FEATURE 1
  39. typedef void __iomem *A_target_id_t;
  40. typedef void *hif_handle_t;
  41. #define HIF_TYPE_AR6002 2
  42. #define HIF_TYPE_AR6003 3
  43. #define HIF_TYPE_AR6004 5
  44. #define HIF_TYPE_AR9888 6
  45. #define HIF_TYPE_AR6320 7
  46. #define HIF_TYPE_AR6320V2 8
  47. /* For attaching Peregrine 2.0 board host_reg_tbl only */
  48. #define HIF_TYPE_AR9888V2 9
  49. #define HIF_TYPE_ADRASTEA 10
  50. #define HIF_TYPE_AR900B 11
  51. #define HIF_TYPE_QCA9984 12
  52. #define HIF_TYPE_IPQ4019 13
  53. #define HIF_TYPE_QCA9888 14
  54. #define HIF_TYPE_QCA8074 15
  55. #define HIF_TYPE_QCA6290 16
  56. #define HIF_TYPE_QCN7605 17
  57. #define HIF_TYPE_QCA6390 18
  58. #define HIF_TYPE_QCA8074V2 19
  59. #define HIF_TYPE_QCA6018 20
  60. #ifdef IPA_OFFLOAD
  61. #define DMA_COHERENT_MASK_IPA_VER_3_AND_ABOVE 37
  62. #define DMA_COHERENT_MASK_BELOW_IPA_VER_3 32
  63. #endif
  64. /* enum hif_ic_irq - enum defining integrated chip irq numbers
  65. * defining irq nubers that can be used by external modules like datapath
  66. */
  67. enum hif_ic_irq {
  68. host2wbm_desc_feed = 16,
  69. host2reo_re_injection,
  70. host2reo_command,
  71. host2rxdma_monitor_ring3,
  72. host2rxdma_monitor_ring2,
  73. host2rxdma_monitor_ring1,
  74. reo2host_exception,
  75. wbm2host_rx_release,
  76. reo2host_status,
  77. reo2host_destination_ring4,
  78. reo2host_destination_ring3,
  79. reo2host_destination_ring2,
  80. reo2host_destination_ring1,
  81. rxdma2host_monitor_destination_mac3,
  82. rxdma2host_monitor_destination_mac2,
  83. rxdma2host_monitor_destination_mac1,
  84. ppdu_end_interrupts_mac3,
  85. ppdu_end_interrupts_mac2,
  86. ppdu_end_interrupts_mac1,
  87. rxdma2host_monitor_status_ring_mac3,
  88. rxdma2host_monitor_status_ring_mac2,
  89. rxdma2host_monitor_status_ring_mac1,
  90. host2rxdma_host_buf_ring_mac3,
  91. host2rxdma_host_buf_ring_mac2,
  92. host2rxdma_host_buf_ring_mac1,
  93. rxdma2host_destination_ring_mac3,
  94. rxdma2host_destination_ring_mac2,
  95. rxdma2host_destination_ring_mac1,
  96. host2tcl_input_ring4,
  97. host2tcl_input_ring3,
  98. host2tcl_input_ring2,
  99. host2tcl_input_ring1,
  100. wbm2host_tx_completions_ring3,
  101. wbm2host_tx_completions_ring2,
  102. wbm2host_tx_completions_ring1,
  103. tcl2host_status_ring,
  104. };
  105. struct CE_state;
  106. #define CE_COUNT_MAX 12
  107. #define HIF_MAX_GRP_IRQ 16
  108. #ifndef HIF_MAX_GROUP
  109. #define HIF_MAX_GROUP 8
  110. #endif
  111. #ifdef CONFIG_SLUB_DEBUG_ON
  112. #ifndef CONFIG_WIN
  113. #define HIF_CONFIG_SLUB_DEBUG_ON
  114. #endif
  115. #endif
  116. #ifndef NAPI_YIELD_BUDGET_BASED
  117. #ifdef HIF_CONFIG_SLUB_DEBUG_ON
  118. #define QCA_NAPI_DEF_SCALE_BIN_SHIFT 1
  119. #else
  120. #ifndef QCA_NAPI_DEF_SCALE_BIN_SHIFT
  121. #define QCA_NAPI_DEF_SCALE_BIN_SHIFT 4
  122. #endif
  123. #endif /* SLUB_DEBUG_ON */
  124. #else /* NAPI_YIELD_BUDGET_BASED */
  125. #define QCA_NAPI_DEF_SCALE_BIN_SHIFT 2
  126. #endif /* NAPI_YIELD_BUDGET_BASED */
  127. #define QCA_NAPI_BUDGET 64
  128. #define QCA_NAPI_DEF_SCALE \
  129. (1 << QCA_NAPI_DEF_SCALE_BIN_SHIFT)
  130. #define HIF_NAPI_MAX_RECEIVES (QCA_NAPI_BUDGET * QCA_NAPI_DEF_SCALE)
  131. /* NOTE: "napi->scale" can be changed,
  132. * but this does not change the number of buckets
  133. */
  134. #define QCA_NAPI_NUM_BUCKETS 4
  135. /**
  136. * qca_napi_stat - stats structure for execution contexts
  137. * @napi_schedules - number of times the schedule function is called
  138. * @napi_polls - number of times the execution context runs
  139. * @napi_completes - number of times that the generating interrupt is reenabled
  140. * @napi_workdone - cumulative of all work done reported by handler
  141. * @cpu_corrected - incremented when execution context runs on a different core
  142. * than the one that its irq is affined to.
  143. * @napi_budget_uses - histogram of work done per execution run
  144. * @time_limit_reache - count of yields due to time limit threshholds
  145. * @rxpkt_thresh_reached - count of yields due to a work limit
  146. * @poll_time_buckets - histogram of poll times for the napi
  147. *
  148. */
  149. struct qca_napi_stat {
  150. uint32_t napi_schedules;
  151. uint32_t napi_polls;
  152. uint32_t napi_completes;
  153. uint32_t napi_workdone;
  154. uint32_t cpu_corrected;
  155. uint32_t napi_budget_uses[QCA_NAPI_NUM_BUCKETS];
  156. uint32_t time_limit_reached;
  157. uint32_t rxpkt_thresh_reached;
  158. unsigned long long napi_max_poll_time;
  159. #ifdef WLAN_FEATURE_RX_SOFTIRQ_TIME_LIMIT
  160. uint32_t poll_time_buckets[QCA_NAPI_NUM_BUCKETS];
  161. #endif
  162. };
  163. /**
  164. * per NAPI instance data structure
  165. * This data structure holds stuff per NAPI instance.
  166. * Note that, in the current implementation, though scale is
  167. * an instance variable, it is set to the same value for all
  168. * instances.
  169. */
  170. struct qca_napi_info {
  171. struct net_device netdev; /* dummy net_dev */
  172. void *hif_ctx;
  173. struct napi_struct napi;
  174. uint8_t scale; /* currently same on all instances */
  175. uint8_t id;
  176. uint8_t cpu;
  177. int irq;
  178. cpumask_t cpumask;
  179. struct qca_napi_stat stats[NR_CPUS];
  180. #ifdef RECEIVE_OFFLOAD
  181. /* will only be present for data rx CE's */
  182. void (*offld_flush_cb)(void *);
  183. struct napi_struct rx_thread_napi;
  184. struct net_device rx_thread_netdev;
  185. #endif /* RECEIVE_OFFLOAD */
  186. qdf_lro_ctx_t lro_ctx;
  187. };
  188. enum qca_napi_tput_state {
  189. QCA_NAPI_TPUT_UNINITIALIZED,
  190. QCA_NAPI_TPUT_LO,
  191. QCA_NAPI_TPUT_HI
  192. };
  193. enum qca_napi_cpu_state {
  194. QCA_NAPI_CPU_UNINITIALIZED,
  195. QCA_NAPI_CPU_DOWN,
  196. QCA_NAPI_CPU_UP };
  197. /**
  198. * struct qca_napi_cpu - an entry of the napi cpu table
  199. * @core_id: physical core id of the core
  200. * @cluster_id: cluster this core belongs to
  201. * @core_mask: mask to match all core of this cluster
  202. * @thread_mask: mask for this core within the cluster
  203. * @max_freq: maximum clock this core can be clocked at
  204. * same for all cpus of the same core.
  205. * @napis: bitmap of napi instances on this core
  206. * @execs: bitmap of execution contexts on this core
  207. * cluster_nxt: chain to link cores within the same cluster
  208. *
  209. * This structure represents a single entry in the napi cpu
  210. * table. The table is part of struct qca_napi_data.
  211. * This table is initialized by the init function, called while
  212. * the first napi instance is being created, updated by hotplug
  213. * notifier and when cpu affinity decisions are made (by throughput
  214. * detection), and deleted when the last napi instance is removed.
  215. */
  216. struct qca_napi_cpu {
  217. enum qca_napi_cpu_state state;
  218. int core_id;
  219. int cluster_id;
  220. cpumask_t core_mask;
  221. cpumask_t thread_mask;
  222. unsigned int max_freq;
  223. uint32_t napis;
  224. uint32_t execs;
  225. int cluster_nxt; /* index, not pointer */
  226. };
  227. /**
  228. * struct qca_napi_data - collection of napi data for a single hif context
  229. * @hif_softc: pointer to the hif context
  230. * @lock: spinlock used in the event state machine
  231. * @state: state variable used in the napi stat machine
  232. * @ce_map: bit map indicating which ce's have napis running
  233. * @exec_map: bit map of instanciated exec contexts
  234. * @user_cpu_affin_map: CPU affinity map from INI config.
  235. * @napi_cpu: cpu info for irq affinty
  236. * @lilcl_head:
  237. * @bigcl_head:
  238. * @napi_mode: irq affinity & clock voting mode
  239. * @cpuhp_handler: CPU hotplug event registration handle
  240. */
  241. struct qca_napi_data {
  242. struct hif_softc *hif_softc;
  243. qdf_spinlock_t lock;
  244. uint32_t state;
  245. /* bitmap of created/registered NAPI instances, indexed by pipe_id,
  246. * not used by clients (clients use an id returned by create)
  247. */
  248. uint32_t ce_map;
  249. uint32_t exec_map;
  250. uint32_t user_cpu_affin_mask;
  251. struct qca_napi_info *napis[CE_COUNT_MAX];
  252. struct qca_napi_cpu napi_cpu[NR_CPUS];
  253. int lilcl_head, bigcl_head;
  254. enum qca_napi_tput_state napi_mode;
  255. struct qdf_cpuhp_handler *cpuhp_handler;
  256. uint8_t flags;
  257. };
  258. /**
  259. * struct hif_config_info - Place Holder for HIF configuration
  260. * @enable_self_recovery: Self Recovery
  261. * @enable_runtime_pm: Enable Runtime PM
  262. * @runtime_pm_delay: Runtime PM Delay
  263. * @rx_softirq_max_yield_duration_ns: Max Yield time duration for RX Softirq
  264. *
  265. * Structure for holding HIF ini parameters.
  266. */
  267. struct hif_config_info {
  268. bool enable_self_recovery;
  269. #ifdef FEATURE_RUNTIME_PM
  270. bool enable_runtime_pm;
  271. u_int32_t runtime_pm_delay;
  272. #endif
  273. uint64_t rx_softirq_max_yield_duration_ns;
  274. };
  275. /**
  276. * struct hif_target_info - Target Information
  277. * @target_version: Target Version
  278. * @target_type: Target Type
  279. * @target_revision: Target Revision
  280. * @soc_version: SOC Version
  281. * @hw_name: pointer to hardware name
  282. *
  283. * Structure to hold target information.
  284. */
  285. struct hif_target_info {
  286. uint32_t target_version;
  287. uint32_t target_type;
  288. uint32_t target_revision;
  289. uint32_t soc_version;
  290. char *hw_name;
  291. };
  292. struct hif_opaque_softc {
  293. };
  294. /**
  295. * enum hif_event_type - Type of DP events to be recorded
  296. * @HIF_EVENT_IRQ_TRIGGER: IRQ trigger event
  297. * @HIF_EVENT_BH_SCHED: NAPI POLL scheduled event
  298. * @HIF_EVENT_SRNG_ACCESS_START: hal ring access start event
  299. * @HIF_EVENT_SRNG_ACCESS_END: hal ring access end event
  300. */
  301. enum hif_event_type {
  302. HIF_EVENT_IRQ_TRIGGER,
  303. HIF_EVENT_BH_SCHED,
  304. HIF_EVENT_SRNG_ACCESS_START,
  305. HIF_EVENT_SRNG_ACCESS_END,
  306. };
  307. #ifdef WLAN_FEATURE_DP_EVENT_HISTORY
  308. /* HIF_EVENT_HIST_MAX should always be power of 2 */
  309. #define HIF_EVENT_HIST_MAX 512
  310. #define HIF_NUM_INT_CONTEXTS 7
  311. #define HIF_EVENT_HIST_DISABLE_MASK 0
  312. /**
  313. * struct hif_event_record - an entry of the DP event history
  314. * @hal_ring_id: ring id for which event is recorded
  315. * @hp: head pointer of the ring (may not be applicable for all events)
  316. * @tp: tail pointer of the ring (may not be applicable for all events)
  317. * @cpu_id: cpu id on which the event occurred
  318. * @timestamp: timestamp when event occurred
  319. * @type: type of the event
  320. *
  321. * This structure represents the information stored for every datapath
  322. * event which is logged in the history.
  323. */
  324. struct hif_event_record {
  325. uint8_t hal_ring_id;
  326. uint32_t hp;
  327. uint32_t tp;
  328. int cpu_id;
  329. uint64_t timestamp;
  330. enum hif_event_type type;
  331. };
  332. /**
  333. * struct hif_event_history - history for one interrupt group
  334. * @index: index to store new event
  335. * @event: event entry
  336. *
  337. * This structure represents the datapath history for one
  338. * interrupt group.
  339. */
  340. struct hif_event_history {
  341. qdf_atomic_t index;
  342. struct hif_event_record event[HIF_EVENT_HIST_MAX];
  343. };
  344. /**
  345. * hif_hist_record_event() - Record one datapath event in history
  346. * @hif_ctx: HIF opaque context
  347. * @event: DP event entry
  348. * @intr_grp_id: interrupt group ID registered with hif
  349. *
  350. * Return: None
  351. */
  352. void hif_hist_record_event(struct hif_opaque_softc *hif_ctx,
  353. struct hif_event_record *event,
  354. uint8_t intr_grp_id);
  355. /**
  356. * hif_record_event() - Wrapper function to form and record DP event
  357. * @hif_ctx: HIF opaque context
  358. * @intr_grp_id: interrupt group ID registered with hif
  359. * @hal_ring_id: ring id for which event is recorded
  360. * @hp: head pointer index of the srng
  361. * @tp: tail pointer index of the srng
  362. * @type: type of the event to be logged in history
  363. *
  364. * Return: None
  365. */
  366. static inline void hif_record_event(struct hif_opaque_softc *hif_ctx,
  367. uint8_t intr_grp_id,
  368. uint8_t hal_ring_id,
  369. uint32_t hp,
  370. uint32_t tp,
  371. enum hif_event_type type)
  372. {
  373. struct hif_event_record event;
  374. event.hal_ring_id = hal_ring_id;
  375. event.hp = hp;
  376. event.tp = tp;
  377. event.type = type;
  378. return hif_hist_record_event(hif_ctx, &event,
  379. intr_grp_id);
  380. }
  381. #else
  382. static inline void hif_record_event(struct hif_opaque_softc *hif_ctx,
  383. uint8_t intr_grp_id,
  384. uint8_t hal_ring_id,
  385. uint32_t hp,
  386. uint32_t tp,
  387. enum hif_event_type type)
  388. {
  389. }
  390. #endif /* WLAN_FEATURE_DP_EVENT_HISTORY */
  391. /**
  392. * enum HIF_DEVICE_POWER_CHANGE_TYPE: Device Power change type
  393. *
  394. * @HIF_DEVICE_POWER_UP: HIF layer should power up interface and/or module
  395. * @HIF_DEVICE_POWER_DOWN: HIF layer should initiate bus-specific measures to
  396. * minimize power
  397. * @HIF_DEVICE_POWER_CUT: HIF layer should initiate bus-specific AND/OR
  398. * platform-specific measures to completely power-off
  399. * the module and associated hardware (i.e. cut power
  400. * supplies)
  401. */
  402. enum HIF_DEVICE_POWER_CHANGE_TYPE {
  403. HIF_DEVICE_POWER_UP,
  404. HIF_DEVICE_POWER_DOWN,
  405. HIF_DEVICE_POWER_CUT
  406. };
  407. /**
  408. * enum hif_enable_type: what triggered the enabling of hif
  409. *
  410. * @HIF_ENABLE_TYPE_PROBE: probe triggered enable
  411. * @HIF_ENABLE_TYPE_REINIT: reinit triggered enable
  412. */
  413. enum hif_enable_type {
  414. HIF_ENABLE_TYPE_PROBE,
  415. HIF_ENABLE_TYPE_REINIT,
  416. HIF_ENABLE_TYPE_MAX
  417. };
  418. /**
  419. * enum hif_disable_type: what triggered the disabling of hif
  420. *
  421. * @HIF_DISABLE_TYPE_PROBE_ERROR: probe error triggered disable
  422. * @HIF_DISABLE_TYPE_REINIT_ERROR: reinit error triggered disable
  423. * @HIF_DISABLE_TYPE_REMOVE: remove triggered disable
  424. * @HIF_DISABLE_TYPE_SHUTDOWN: shutdown triggered disable
  425. */
  426. enum hif_disable_type {
  427. HIF_DISABLE_TYPE_PROBE_ERROR,
  428. HIF_DISABLE_TYPE_REINIT_ERROR,
  429. HIF_DISABLE_TYPE_REMOVE,
  430. HIF_DISABLE_TYPE_SHUTDOWN,
  431. HIF_DISABLE_TYPE_MAX
  432. };
  433. /**
  434. * enum hif_device_config_opcode: configure mode
  435. *
  436. * @HIF_DEVICE_POWER_STATE: device power state
  437. * @HIF_DEVICE_GET_MBOX_BLOCK_SIZE: get mbox block size
  438. * @HIF_DEVICE_GET_MBOX_ADDR: get mbox block address
  439. * @HIF_DEVICE_GET_PENDING_EVENTS_FUNC: get pending events functions
  440. * @HIF_DEVICE_GET_IRQ_PROC_MODE: get irq proc mode
  441. * @HIF_DEVICE_GET_RECV_EVENT_MASK_UNMASK_FUNC: receive event function
  442. * @HIF_DEVICE_POWER_STATE_CHANGE: change power state
  443. * @HIF_DEVICE_GET_IRQ_YIELD_PARAMS: get yield params
  444. * @HIF_CONFIGURE_QUERY_SCATTER_REQUEST_SUPPORT: configure scatter request
  445. * @HIF_DEVICE_GET_OS_DEVICE: get OS device
  446. * @HIF_DEVICE_DEBUG_BUS_STATE: debug bus state
  447. * @HIF_BMI_DONE: bmi done
  448. * @HIF_DEVICE_SET_TARGET_TYPE: set target type
  449. * @HIF_DEVICE_SET_HTC_CONTEXT: set htc context
  450. * @HIF_DEVICE_GET_HTC_CONTEXT: get htc context
  451. */
  452. enum hif_device_config_opcode {
  453. HIF_DEVICE_POWER_STATE = 0,
  454. HIF_DEVICE_GET_BLOCK_SIZE,
  455. HIF_DEVICE_GET_FIFO_ADDR,
  456. HIF_DEVICE_GET_PENDING_EVENTS_FUNC,
  457. HIF_DEVICE_GET_IRQ_PROC_MODE,
  458. HIF_DEVICE_GET_RECV_EVENT_MASK_UNMASK_FUNC,
  459. HIF_DEVICE_POWER_STATE_CHANGE,
  460. HIF_DEVICE_GET_IRQ_YIELD_PARAMS,
  461. HIF_CONFIGURE_QUERY_SCATTER_REQUEST_SUPPORT,
  462. HIF_DEVICE_GET_OS_DEVICE,
  463. HIF_DEVICE_DEBUG_BUS_STATE,
  464. HIF_BMI_DONE,
  465. HIF_DEVICE_SET_TARGET_TYPE,
  466. HIF_DEVICE_SET_HTC_CONTEXT,
  467. HIF_DEVICE_GET_HTC_CONTEXT,
  468. };
  469. #ifdef CONFIG_ATH_PCIE_ACCESS_DEBUG
  470. struct HID_ACCESS_LOG {
  471. uint32_t seqnum;
  472. bool is_write;
  473. void *addr;
  474. uint32_t value;
  475. };
  476. #endif
  477. void hif_reg_write(struct hif_opaque_softc *hif_ctx, uint32_t offset,
  478. uint32_t value);
  479. uint32_t hif_reg_read(struct hif_opaque_softc *hif_ctx, uint32_t offset);
  480. #define HIF_MAX_DEVICES 1
  481. /**
  482. * struct htc_callbacks - Structure for HTC Callbacks methods
  483. * @context: context to pass to the dsrhandler
  484. * note : rwCompletionHandler is provided the context
  485. * passed to hif_read_write
  486. * @rwCompletionHandler: Read / write completion handler
  487. * @dsrHandler: DSR Handler
  488. */
  489. struct htc_callbacks {
  490. void *context;
  491. QDF_STATUS(*rw_compl_handler)(void *rw_ctx, QDF_STATUS status);
  492. QDF_STATUS(*dsr_handler)(void *context);
  493. };
  494. /**
  495. * struct hif_driver_state_callbacks - Callbacks for HIF to query Driver state
  496. * @context: Private data context
  497. * @set_recovery_in_progress: To Set Driver state for recovery in progress
  498. * @is_recovery_in_progress: Query if driver state is recovery in progress
  499. * @is_load_unload_in_progress: Query if driver state Load/Unload in Progress
  500. * @is_driver_unloading: Query if driver is unloading.
  501. *
  502. * This Structure provides callback pointer for HIF to query hdd for driver
  503. * states.
  504. */
  505. struct hif_driver_state_callbacks {
  506. void *context;
  507. void (*set_recovery_in_progress)(void *context, uint8_t val);
  508. bool (*is_recovery_in_progress)(void *context);
  509. bool (*is_load_unload_in_progress)(void *context);
  510. bool (*is_driver_unloading)(void *context);
  511. bool (*is_target_ready)(void *context);
  512. };
  513. /* This API detaches the HTC layer from the HIF device */
  514. void hif_detach_htc(struct hif_opaque_softc *hif_ctx);
  515. /****************************************************************/
  516. /* BMI and Diag window abstraction */
  517. /****************************************************************/
  518. #define HIF_BMI_EXCHANGE_NO_TIMEOUT ((uint32_t)(0))
  519. #define DIAG_TRANSFER_LIMIT 2048U /* maximum number of bytes that can be
  520. * handled atomically by
  521. * DiagRead/DiagWrite
  522. */
  523. #ifdef WLAN_FEATURE_BMI
  524. /*
  525. * API to handle HIF-specific BMI message exchanges, this API is synchronous
  526. * and only allowed to be called from a context that can block (sleep)
  527. */
  528. QDF_STATUS hif_exchange_bmi_msg(struct hif_opaque_softc *hif_ctx,
  529. qdf_dma_addr_t cmd, qdf_dma_addr_t rsp,
  530. uint8_t *pSendMessage, uint32_t Length,
  531. uint8_t *pResponseMessage,
  532. uint32_t *pResponseLength, uint32_t TimeoutMS);
  533. void hif_register_bmi_callbacks(struct hif_opaque_softc *hif_ctx);
  534. bool hif_needs_bmi(struct hif_opaque_softc *hif_ctx);
  535. #else /* WLAN_FEATURE_BMI */
  536. static inline void
  537. hif_register_bmi_callbacks(struct hif_opaque_softc *hif_ctx)
  538. {
  539. }
  540. static inline bool
  541. hif_needs_bmi(struct hif_opaque_softc *hif_ctx)
  542. {
  543. return false;
  544. }
  545. #endif /* WLAN_FEATURE_BMI */
  546. /*
  547. * APIs to handle HIF specific diagnostic read accesses. These APIs are
  548. * synchronous and only allowed to be called from a context that
  549. * can block (sleep). They are not high performance APIs.
  550. *
  551. * hif_diag_read_access reads a 4 Byte aligned/length value from a
  552. * Target register or memory word.
  553. *
  554. * hif_diag_read_mem reads an arbitrary length of arbitrarily aligned memory.
  555. */
  556. QDF_STATUS hif_diag_read_access(struct hif_opaque_softc *hif_ctx,
  557. uint32_t address, uint32_t *data);
  558. QDF_STATUS hif_diag_read_mem(struct hif_opaque_softc *hif_ctx, uint32_t address,
  559. uint8_t *data, int nbytes);
  560. void hif_dump_target_memory(struct hif_opaque_softc *hif_ctx,
  561. void *ramdump_base, uint32_t address, uint32_t size);
  562. /*
  563. * APIs to handle HIF specific diagnostic write accesses. These APIs are
  564. * synchronous and only allowed to be called from a context that
  565. * can block (sleep).
  566. * They are not high performance APIs.
  567. *
  568. * hif_diag_write_access writes a 4 Byte aligned/length value to a
  569. * Target register or memory word.
  570. *
  571. * hif_diag_write_mem writes an arbitrary length of arbitrarily aligned memory.
  572. */
  573. QDF_STATUS hif_diag_write_access(struct hif_opaque_softc *hif_ctx,
  574. uint32_t address, uint32_t data);
  575. QDF_STATUS hif_diag_write_mem(struct hif_opaque_softc *hif_ctx,
  576. uint32_t address, uint8_t *data, int nbytes);
  577. typedef void (*fastpath_msg_handler)(void *, qdf_nbuf_t *, uint32_t);
  578. void hif_enable_polled_mode(struct hif_opaque_softc *hif_ctx);
  579. bool hif_is_polled_mode_enabled(struct hif_opaque_softc *hif_ctx);
  580. /*
  581. * Set the FASTPATH_mode_on flag in sc, for use by data path
  582. */
  583. #ifdef WLAN_FEATURE_FASTPATH
  584. void hif_enable_fastpath(struct hif_opaque_softc *hif_ctx);
  585. bool hif_is_fastpath_mode_enabled(struct hif_opaque_softc *hif_ctx);
  586. void *hif_get_ce_handle(struct hif_opaque_softc *hif_ctx, int ret);
  587. int hif_ce_fastpath_cb_register(struct hif_opaque_softc *hif_ctx,
  588. fastpath_msg_handler handler, void *context);
  589. #else
  590. static inline int hif_ce_fastpath_cb_register(struct hif_opaque_softc *hif_ctx,
  591. fastpath_msg_handler handler,
  592. void *context)
  593. {
  594. return QDF_STATUS_E_FAILURE;
  595. }
  596. static inline void *hif_get_ce_handle(struct hif_opaque_softc *hif_ctx, int ret)
  597. {
  598. return NULL;
  599. }
  600. #endif
  601. /*
  602. * Enable/disable CDC max performance workaround
  603. * For max-performace set this to 0
  604. * To allow SoC to enter sleep set this to 1
  605. */
  606. #define CONFIG_DISABLE_CDC_MAX_PERF_WAR 0
  607. void hif_ipa_get_ce_resource(struct hif_opaque_softc *hif_ctx,
  608. qdf_shared_mem_t **ce_sr,
  609. uint32_t *ce_sr_ring_size,
  610. qdf_dma_addr_t *ce_reg_paddr);
  611. /**
  612. * @brief List of callbacks - filled in by HTC.
  613. */
  614. struct hif_msg_callbacks {
  615. void *Context;
  616. /**< context meaningful to HTC */
  617. QDF_STATUS (*txCompletionHandler)(void *Context, qdf_nbuf_t wbuf,
  618. uint32_t transferID,
  619. uint32_t toeplitz_hash_result);
  620. QDF_STATUS (*rxCompletionHandler)(void *Context, qdf_nbuf_t wbuf,
  621. uint8_t pipeID);
  622. void (*txResourceAvailHandler)(void *context, uint8_t pipe);
  623. void (*fwEventHandler)(void *context, QDF_STATUS status);
  624. };
  625. enum hif_target_status {
  626. TARGET_STATUS_CONNECTED = 0, /* target connected */
  627. TARGET_STATUS_RESET, /* target got reset */
  628. TARGET_STATUS_EJECT, /* target got ejected */
  629. TARGET_STATUS_SUSPEND /*target got suspend */
  630. };
  631. /**
  632. * enum hif_attribute_flags: configure hif
  633. *
  634. * @HIF_LOWDESC_CE_CFG: Configure HIF with Low descriptor CE
  635. * @HIF_LOWDESC_CE_NO_PKTLOG_CFG: Configure HIF with Low descriptor
  636. * + No pktlog CE
  637. */
  638. enum hif_attribute_flags {
  639. HIF_LOWDESC_CE_CFG = 1,
  640. HIF_LOWDESC_CE_NO_PKTLOG_CFG
  641. };
  642. #define HIF_DATA_ATTR_SET_TX_CLASSIFY(attr, v) \
  643. (attr |= (v & 0x01) << 5)
  644. #define HIF_DATA_ATTR_SET_ENCAPSULATION_TYPE(attr, v) \
  645. (attr |= (v & 0x03) << 6)
  646. #define HIF_DATA_ATTR_SET_ADDR_X_SEARCH_DISABLE(attr, v) \
  647. (attr |= (v & 0x01) << 13)
  648. #define HIF_DATA_ATTR_SET_ADDR_Y_SEARCH_DISABLE(attr, v) \
  649. (attr |= (v & 0x01) << 14)
  650. #define HIF_DATA_ATTR_SET_TOEPLITZ_HASH_ENABLE(attr, v) \
  651. (attr |= (v & 0x01) << 15)
  652. #define HIF_DATA_ATTR_SET_PACKET_OR_RESULT_OFFSET(attr, v) \
  653. (attr |= (v & 0x0FFF) << 16)
  654. #define HIF_DATA_ATTR_SET_ENABLE_11H(attr, v) \
  655. (attr |= (v & 0x01) << 30)
  656. struct hif_ul_pipe_info {
  657. unsigned int nentries;
  658. unsigned int nentries_mask;
  659. unsigned int sw_index;
  660. unsigned int write_index; /* cached copy */
  661. unsigned int hw_index; /* cached copy */
  662. void *base_addr_owner_space; /* Host address space */
  663. qdf_dma_addr_t base_addr_CE_space; /* CE address space */
  664. };
  665. struct hif_dl_pipe_info {
  666. unsigned int nentries;
  667. unsigned int nentries_mask;
  668. unsigned int sw_index;
  669. unsigned int write_index; /* cached copy */
  670. unsigned int hw_index; /* cached copy */
  671. void *base_addr_owner_space; /* Host address space */
  672. qdf_dma_addr_t base_addr_CE_space; /* CE address space */
  673. };
  674. struct hif_pipe_addl_info {
  675. uint32_t pci_mem;
  676. uint32_t ctrl_addr;
  677. struct hif_ul_pipe_info ul_pipe;
  678. struct hif_dl_pipe_info dl_pipe;
  679. };
  680. #ifdef CONFIG_SLUB_DEBUG_ON
  681. #define MSG_FLUSH_NUM 16
  682. #else /* PERF build */
  683. #define MSG_FLUSH_NUM 32
  684. #endif /* SLUB_DEBUG_ON */
  685. struct hif_bus_id;
  686. void hif_claim_device(struct hif_opaque_softc *hif_ctx);
  687. QDF_STATUS hif_get_config_item(struct hif_opaque_softc *hif_ctx,
  688. int opcode, void *config, uint32_t config_len);
  689. void hif_set_mailbox_swap(struct hif_opaque_softc *hif_ctx);
  690. void hif_mask_interrupt_call(struct hif_opaque_softc *hif_ctx);
  691. void hif_post_init(struct hif_opaque_softc *hif_ctx, void *hHTC,
  692. struct hif_msg_callbacks *callbacks);
  693. QDF_STATUS hif_start(struct hif_opaque_softc *hif_ctx);
  694. void hif_stop(struct hif_opaque_softc *hif_ctx);
  695. void hif_flush_surprise_remove(struct hif_opaque_softc *hif_ctx);
  696. void hif_dump(struct hif_opaque_softc *hif_ctx, uint8_t CmdId, bool start);
  697. void hif_trigger_dump(struct hif_opaque_softc *hif_ctx,
  698. uint8_t cmd_id, bool start);
  699. QDF_STATUS hif_send_head(struct hif_opaque_softc *hif_ctx, uint8_t PipeID,
  700. uint32_t transferID, uint32_t nbytes,
  701. qdf_nbuf_t wbuf, uint32_t data_attr);
  702. void hif_send_complete_check(struct hif_opaque_softc *hif_ctx, uint8_t PipeID,
  703. int force);
  704. void hif_shut_down_device(struct hif_opaque_softc *hif_ctx);
  705. void hif_get_default_pipe(struct hif_opaque_softc *hif_ctx, uint8_t *ULPipe,
  706. uint8_t *DLPipe);
  707. int hif_map_service_to_pipe(struct hif_opaque_softc *hif_ctx, uint16_t svc_id,
  708. uint8_t *ul_pipe, uint8_t *dl_pipe, int *ul_is_polled,
  709. int *dl_is_polled);
  710. uint16_t
  711. hif_get_free_queue_number(struct hif_opaque_softc *hif_ctx, uint8_t PipeID);
  712. void *hif_get_targetdef(struct hif_opaque_softc *hif_ctx);
  713. uint32_t hif_hia_item_address(uint32_t target_type, uint32_t item_offset);
  714. void hif_set_target_sleep(struct hif_opaque_softc *hif_ctx, bool sleep_ok,
  715. bool wait_for_it);
  716. int hif_check_fw_reg(struct hif_opaque_softc *hif_ctx);
  717. #ifndef HIF_PCI
  718. static inline int hif_check_soc_status(struct hif_opaque_softc *hif_ctx)
  719. {
  720. return 0;
  721. }
  722. #else
  723. int hif_check_soc_status(struct hif_opaque_softc *hif_ctx);
  724. #endif
  725. void hif_get_hw_info(struct hif_opaque_softc *hif_ctx, u32 *version,
  726. u32 *revision, const char **target_name);
  727. #ifdef RECEIVE_OFFLOAD
  728. /**
  729. * hif_offld_flush_cb_register() - Register the offld flush callback
  730. * @scn: HIF opaque context
  731. * @offld_flush_handler: Flush callback is either ol_flush, incase of rx_thread
  732. * Or GRO/LRO flush when RxThread is not enabled. Called
  733. * with corresponding context for flush.
  734. * Return: None
  735. */
  736. void hif_offld_flush_cb_register(struct hif_opaque_softc *scn,
  737. void (offld_flush_handler)(void *ol_ctx));
  738. /**
  739. * hif_offld_flush_cb_deregister() - deRegister the offld flush callback
  740. * @scn: HIF opaque context
  741. *
  742. * Return: None
  743. */
  744. void hif_offld_flush_cb_deregister(struct hif_opaque_softc *scn);
  745. #endif
  746. #ifdef WLAN_FEATURE_RX_SOFTIRQ_TIME_LIMIT
  747. /**
  748. * hif_exec_should_yield() - Check if hif napi context should yield
  749. * @hif_ctx - HIF opaque context
  750. * @grp_id - grp_id of the napi for which check needs to be done
  751. *
  752. * The function uses grp_id to look for NAPI and checks if NAPI needs to
  753. * yield. HIF_EXT_GROUP_MAX_YIELD_DURATION_NS is the duration used for
  754. * yield decision.
  755. *
  756. * Return: true if NAPI needs to yield, else false
  757. */
  758. bool hif_exec_should_yield(struct hif_opaque_softc *hif_ctx, uint grp_id);
  759. #else
  760. static inline bool hif_exec_should_yield(struct hif_opaque_softc *hif_ctx,
  761. uint grp_id)
  762. {
  763. return false;
  764. }
  765. #endif
  766. void hif_disable_isr(struct hif_opaque_softc *hif_ctx);
  767. void hif_reset_soc(struct hif_opaque_softc *hif_ctx);
  768. void hif_save_htc_htt_config_endpoint(struct hif_opaque_softc *hif_ctx,
  769. int htc_htt_tx_endpoint);
  770. struct hif_opaque_softc *hif_open(qdf_device_t qdf_ctx, uint32_t mode,
  771. enum qdf_bus_type bus_type,
  772. struct hif_driver_state_callbacks *cbk);
  773. void hif_close(struct hif_opaque_softc *hif_ctx);
  774. QDF_STATUS hif_enable(struct hif_opaque_softc *hif_ctx, struct device *dev,
  775. void *bdev, const struct hif_bus_id *bid,
  776. enum qdf_bus_type bus_type,
  777. enum hif_enable_type type);
  778. void hif_disable(struct hif_opaque_softc *hif_ctx, enum hif_disable_type type);
  779. void hif_display_stats(struct hif_opaque_softc *hif_ctx);
  780. void hif_clear_stats(struct hif_opaque_softc *hif_ctx);
  781. #ifdef FEATURE_RUNTIME_PM
  782. struct hif_pm_runtime_lock;
  783. void hif_fastpath_resume(struct hif_opaque_softc *hif_ctx);
  784. int hif_pm_runtime_request_resume(struct hif_opaque_softc *hif_ctx);
  785. int hif_pm_runtime_get(struct hif_opaque_softc *hif_ctx);
  786. void hif_pm_runtime_get_noresume(struct hif_opaque_softc *hif_ctx);
  787. int hif_pm_runtime_put(struct hif_opaque_softc *hif_ctx);
  788. void hif_pm_runtime_mark_last_busy(struct hif_opaque_softc *hif_ctx);
  789. int hif_runtime_lock_init(qdf_runtime_lock_t *lock, const char *name);
  790. void hif_runtime_lock_deinit(struct hif_opaque_softc *hif_ctx,
  791. struct hif_pm_runtime_lock *lock);
  792. int hif_pm_runtime_prevent_suspend(struct hif_opaque_softc *ol_sc,
  793. struct hif_pm_runtime_lock *lock);
  794. int hif_pm_runtime_allow_suspend(struct hif_opaque_softc *ol_sc,
  795. struct hif_pm_runtime_lock *lock);
  796. int hif_pm_runtime_prevent_suspend_timeout(struct hif_opaque_softc *ol_sc,
  797. struct hif_pm_runtime_lock *lock, unsigned int delay);
  798. bool hif_pm_runtime_is_suspended(struct hif_opaque_softc *hif_ctx);
  799. int hif_pm_runtime_get_monitor_wake_intr(struct hif_opaque_softc *hif_ctx);
  800. void hif_pm_runtime_set_monitor_wake_intr(struct hif_opaque_softc *hif_ctx,
  801. int val);
  802. #else
  803. struct hif_pm_runtime_lock {
  804. const char *name;
  805. };
  806. static inline void hif_fastpath_resume(struct hif_opaque_softc *hif_ctx) {}
  807. static inline int
  808. hif_pm_runtime_request_resume(struct hif_opaque_softc *hif_ctx)
  809. { return 0; }
  810. static inline void hif_pm_runtime_get_noresume(struct hif_opaque_softc *hif_ctx)
  811. {}
  812. static inline int hif_pm_runtime_get(struct hif_opaque_softc *hif_ctx)
  813. { return 0; }
  814. static inline int hif_pm_runtime_put(struct hif_opaque_softc *hif_ctx)
  815. { return 0; }
  816. static inline void
  817. hif_pm_runtime_mark_last_busy(struct hif_opaque_softc *hif_ctx) {};
  818. static inline int hif_runtime_lock_init(qdf_runtime_lock_t *lock,
  819. const char *name)
  820. { return 0; }
  821. static inline void
  822. hif_runtime_lock_deinit(struct hif_opaque_softc *hif_ctx,
  823. struct hif_pm_runtime_lock *lock) {}
  824. static inline int hif_pm_runtime_prevent_suspend(struct hif_opaque_softc *ol_sc,
  825. struct hif_pm_runtime_lock *lock)
  826. { return 0; }
  827. static inline int hif_pm_runtime_allow_suspend(struct hif_opaque_softc *ol_sc,
  828. struct hif_pm_runtime_lock *lock)
  829. { return 0; }
  830. static inline int
  831. hif_pm_runtime_prevent_suspend_timeout(struct hif_opaque_softc *ol_sc,
  832. struct hif_pm_runtime_lock *lock, unsigned int delay)
  833. { return 0; }
  834. static inline bool hif_pm_runtime_is_suspended(struct hif_opaque_softc *hif_ctx)
  835. { return false; }
  836. static inline int
  837. hif_pm_runtime_get_monitor_wake_intr(struct hif_opaque_softc *hif_ctx)
  838. { return 0; }
  839. static inline void
  840. hif_pm_runtime_set_monitor_wake_intr(struct hif_opaque_softc *hif_ctx, int val)
  841. { return; }
  842. #endif
  843. void hif_enable_power_management(struct hif_opaque_softc *hif_ctx,
  844. bool is_packet_log_enabled);
  845. void hif_disable_power_management(struct hif_opaque_softc *hif_ctx);
  846. void hif_vote_link_down(struct hif_opaque_softc *hif_ctx);
  847. void hif_vote_link_up(struct hif_opaque_softc *hif_ctx);
  848. bool hif_can_suspend_link(struct hif_opaque_softc *hif_ctx);
  849. #ifdef IPA_OFFLOAD
  850. /**
  851. * hif_get_ipa_hw_type() - get IPA hw type
  852. *
  853. * This API return the IPA hw type.
  854. *
  855. * Return: IPA hw type
  856. */
  857. static inline
  858. enum ipa_hw_type hif_get_ipa_hw_type(void)
  859. {
  860. return ipa_get_hw_type();
  861. }
  862. /**
  863. * hif_get_ipa_present() - get IPA hw status
  864. *
  865. * This API return the IPA hw status.
  866. *
  867. * Return: true if IPA is present or false otherwise
  868. */
  869. static inline
  870. bool hif_get_ipa_present(void)
  871. {
  872. if (ipa_uc_reg_rdyCB(NULL) != -EPERM)
  873. return true;
  874. else
  875. return false;
  876. }
  877. #endif
  878. int hif_bus_resume(struct hif_opaque_softc *hif_ctx);
  879. /**
  880. * hif_bus_ealry_suspend() - stop non wmi tx traffic
  881. * @context: hif context
  882. */
  883. int hif_bus_early_suspend(struct hif_opaque_softc *hif_ctx);
  884. /**
  885. * hif_bus_late_resume() - resume non wmi traffic
  886. * @context: hif context
  887. */
  888. int hif_bus_late_resume(struct hif_opaque_softc *hif_ctx);
  889. int hif_bus_suspend(struct hif_opaque_softc *hif_ctx);
  890. int hif_bus_resume_noirq(struct hif_opaque_softc *hif_ctx);
  891. int hif_bus_suspend_noirq(struct hif_opaque_softc *hif_ctx);
  892. /**
  893. * hif_apps_irqs_enable() - Enables all irqs from the APPS side
  894. * @hif_ctx: an opaque HIF handle to use
  895. *
  896. * As opposed to the standard hif_irq_enable, this function always applies to
  897. * the APPS side kernel interrupt handling.
  898. *
  899. * Return: errno
  900. */
  901. int hif_apps_irqs_enable(struct hif_opaque_softc *hif_ctx);
  902. /**
  903. * hif_apps_irqs_disable() - Disables all irqs from the APPS side
  904. * @hif_ctx: an opaque HIF handle to use
  905. *
  906. * As opposed to the standard hif_irq_disable, this function always applies to
  907. * the APPS side kernel interrupt handling.
  908. *
  909. * Return: errno
  910. */
  911. int hif_apps_irqs_disable(struct hif_opaque_softc *hif_ctx);
  912. /**
  913. * hif_apps_wake_irq_enable() - Enables the wake irq from the APPS side
  914. * @hif_ctx: an opaque HIF handle to use
  915. *
  916. * As opposed to the standard hif_irq_enable, this function always applies to
  917. * the APPS side kernel interrupt handling.
  918. *
  919. * Return: errno
  920. */
  921. int hif_apps_wake_irq_enable(struct hif_opaque_softc *hif_ctx);
  922. /**
  923. * hif_apps_wake_irq_disable() - Disables the wake irq from the APPS side
  924. * @hif_ctx: an opaque HIF handle to use
  925. *
  926. * As opposed to the standard hif_irq_disable, this function always applies to
  927. * the APPS side kernel interrupt handling.
  928. *
  929. * Return: errno
  930. */
  931. int hif_apps_wake_irq_disable(struct hif_opaque_softc *hif_ctx);
  932. #ifdef FEATURE_RUNTIME_PM
  933. int hif_pre_runtime_suspend(struct hif_opaque_softc *hif_ctx);
  934. void hif_pre_runtime_resume(struct hif_opaque_softc *hif_ctx);
  935. int hif_runtime_suspend(struct hif_opaque_softc *hif_ctx);
  936. int hif_runtime_resume(struct hif_opaque_softc *hif_ctx);
  937. void hif_process_runtime_suspend_success(struct hif_opaque_softc *hif_ctx);
  938. void hif_process_runtime_suspend_failure(struct hif_opaque_softc *hif_ctx);
  939. void hif_process_runtime_resume_success(struct hif_opaque_softc *hif_ctx);
  940. #endif
  941. int hif_get_irq_num(struct hif_opaque_softc *scn, int *irq, uint32_t size);
  942. int hif_dump_registers(struct hif_opaque_softc *scn);
  943. int ol_copy_ramdump(struct hif_opaque_softc *scn);
  944. void hif_crash_shutdown(struct hif_opaque_softc *hif_ctx);
  945. void hif_get_hw_info(struct hif_opaque_softc *hif_ctx, u32 *version,
  946. u32 *revision, const char **target_name);
  947. enum qdf_bus_type hif_get_bus_type(struct hif_opaque_softc *hif_hdl);
  948. struct hif_target_info *hif_get_target_info_handle(struct hif_opaque_softc *
  949. scn);
  950. struct hif_config_info *hif_get_ini_handle(struct hif_opaque_softc *hif_ctx);
  951. struct ramdump_info *hif_get_ramdump_ctx(struct hif_opaque_softc *hif_ctx);
  952. enum hif_target_status hif_get_target_status(struct hif_opaque_softc *hif_ctx);
  953. void hif_set_target_status(struct hif_opaque_softc *hif_ctx, enum
  954. hif_target_status);
  955. void hif_init_ini_config(struct hif_opaque_softc *hif_ctx,
  956. struct hif_config_info *cfg);
  957. void hif_update_tx_ring(struct hif_opaque_softc *osc, u_int32_t num_htt_cmpls);
  958. qdf_nbuf_t hif_batch_send(struct hif_opaque_softc *osc, qdf_nbuf_t msdu,
  959. uint32_t transfer_id, u_int32_t len, uint32_t sendhead);
  960. int hif_send_single(struct hif_opaque_softc *osc, qdf_nbuf_t msdu, uint32_t
  961. transfer_id, u_int32_t len);
  962. int hif_send_fast(struct hif_opaque_softc *osc, qdf_nbuf_t nbuf,
  963. uint32_t transfer_id, uint32_t download_len);
  964. void hif_pkt_dl_len_set(void *hif_sc, unsigned int pkt_download_len);
  965. void hif_ce_war_disable(void);
  966. void hif_ce_war_enable(void);
  967. void hif_disable_interrupt(struct hif_opaque_softc *osc, uint32_t pipe_num);
  968. #ifdef QCA_NSS_WIFI_OFFLOAD_SUPPORT
  969. struct hif_pipe_addl_info *hif_get_addl_pipe_info(struct hif_opaque_softc *osc,
  970. struct hif_pipe_addl_info *hif_info, uint32_t pipe_number);
  971. uint32_t hif_set_nss_wifiol_mode(struct hif_opaque_softc *osc,
  972. uint32_t pipe_num);
  973. int32_t hif_get_nss_wifiol_bypass_nw_process(struct hif_opaque_softc *osc);
  974. #endif /* QCA_NSS_WIFI_OFFLOAD_SUPPORT */
  975. void hif_set_bundle_mode(struct hif_opaque_softc *hif_ctx, bool enabled,
  976. int rx_bundle_cnt);
  977. int hif_bus_reset_resume(struct hif_opaque_softc *hif_ctx);
  978. void hif_set_attribute(struct hif_opaque_softc *osc, uint8_t hif_attrib);
  979. void *hif_get_lro_info(int ctx_id, struct hif_opaque_softc *hif_hdl);
  980. enum hif_exec_type {
  981. HIF_EXEC_NAPI_TYPE,
  982. HIF_EXEC_TASKLET_TYPE,
  983. };
  984. typedef uint32_t (*ext_intr_handler)(void *, uint32_t);
  985. /**
  986. * hif_get_int_ctx_irq_num() - retrieve an irq num for an interrupt context id
  987. * @softc: hif opaque context owning the exec context
  988. * @id: the id of the interrupt context
  989. *
  990. * Return: IRQ number of the first (zero'th) IRQ within the interrupt context ID
  991. * 'id' registered with the OS
  992. */
  993. int32_t hif_get_int_ctx_irq_num(struct hif_opaque_softc *softc,
  994. uint8_t id);
  995. uint32_t hif_configure_ext_group_interrupts(struct hif_opaque_softc *hif_ctx);
  996. uint32_t hif_register_ext_group(struct hif_opaque_softc *hif_ctx,
  997. uint32_t numirq, uint32_t irq[], ext_intr_handler handler,
  998. void *cb_ctx, const char *context_name,
  999. enum hif_exec_type type, uint32_t scale);
  1000. void hif_deregister_exec_group(struct hif_opaque_softc *hif_ctx,
  1001. const char *context_name);
  1002. void hif_update_pipe_callback(struct hif_opaque_softc *osc,
  1003. u_int8_t pipeid,
  1004. struct hif_msg_callbacks *callbacks);
  1005. /**
  1006. * hif_print_napi_stats() - Display HIF NAPI stats
  1007. * @hif_ctx - HIF opaque context
  1008. *
  1009. * Return: None
  1010. */
  1011. void hif_print_napi_stats(struct hif_opaque_softc *hif_ctx);
  1012. /* hif_clear_napi_stats() - function clears the stats of the
  1013. * latency when called.
  1014. * @hif_ctx - the HIF context to assign the callback to
  1015. *
  1016. * Return: None
  1017. */
  1018. void hif_clear_napi_stats(struct hif_opaque_softc *hif_ctx);
  1019. #ifdef __cplusplus
  1020. }
  1021. #endif
  1022. void *hif_get_dev_ba(struct hif_opaque_softc *hif_handle);
  1023. /**
  1024. * hif_set_initial_wakeup_cb() - set the initial wakeup event handler function
  1025. * @hif_ctx - the HIF context to assign the callback to
  1026. * @callback - the callback to assign
  1027. * @priv - the private data to pass to the callback when invoked
  1028. *
  1029. * Return: None
  1030. */
  1031. void hif_set_initial_wakeup_cb(struct hif_opaque_softc *hif_ctx,
  1032. void (*callback)(void *),
  1033. void *priv);
  1034. /*
  1035. * Note: For MCL, #if defined (HIF_CONFIG_SLUB_DEBUG_ON) needs to be checked
  1036. * for defined here
  1037. */
  1038. #if defined(HIF_CONFIG_SLUB_DEBUG_ON) || defined(HIF_CE_DEBUG_DATA_BUF)
  1039. ssize_t hif_dump_desc_trace_buf(struct device *dev,
  1040. struct device_attribute *attr, char *buf);
  1041. ssize_t hif_input_desc_trace_buf_index(struct hif_softc *scn,
  1042. const char *buf, size_t size);
  1043. ssize_t hif_ce_en_desc_hist(struct hif_softc *scn,
  1044. const char *buf, size_t size);
  1045. ssize_t hif_disp_ce_enable_desc_data_hist(struct hif_softc *scn, char *buf);
  1046. ssize_t hif_dump_desc_event(struct hif_softc *scn, char *buf);
  1047. #endif/*#if defined(HIF_CONFIG_SLUB_DEBUG_ON)||defined(HIF_CE_DEBUG_DATA_BUF)*/
  1048. /**
  1049. * hif_set_ce_service_max_yield_time() - sets CE service max yield time
  1050. * @hif: hif context
  1051. * @ce_service_max_yield_time: CE service max yield time to set
  1052. *
  1053. * This API storess CE service max yield time in hif context based
  1054. * on ini value.
  1055. *
  1056. * Return: void
  1057. */
  1058. void hif_set_ce_service_max_yield_time(struct hif_opaque_softc *hif,
  1059. uint32_t ce_service_max_yield_time);
  1060. /**
  1061. * hif_get_ce_service_max_yield_time() - get CE service max yield time
  1062. * @hif: hif context
  1063. *
  1064. * This API returns CE service max yield time.
  1065. *
  1066. * Return: CE service max yield time
  1067. */
  1068. unsigned long long
  1069. hif_get_ce_service_max_yield_time(struct hif_opaque_softc *hif);
  1070. /**
  1071. * hif_set_ce_service_max_rx_ind_flush() - sets CE service max rx ind flush
  1072. * @hif: hif context
  1073. * @ce_service_max_rx_ind_flush: CE service max rx ind flush to set
  1074. *
  1075. * This API stores CE service max rx ind flush in hif context based
  1076. * on ini value.
  1077. *
  1078. * Return: void
  1079. */
  1080. void hif_set_ce_service_max_rx_ind_flush(struct hif_opaque_softc *hif,
  1081. uint8_t ce_service_max_rx_ind_flush);
  1082. #ifdef OL_ATH_SMART_LOGGING
  1083. /*
  1084. * hif_log_ce_dump() - Copy all the CE DEST ring to buf
  1085. * @scn : HIF handler
  1086. * @buf_cur: Current pointer in ring buffer
  1087. * @buf_init:Start of the ring buffer
  1088. * @buf_sz: Size of the ring buffer
  1089. * @ce: Copy Engine id
  1090. * @skb_sz: Max size of the SKB buffer to be copied
  1091. *
  1092. * Calls the respective function to dump all the CE SRC/DEST ring descriptors
  1093. * and buffers pointed by them in to the given buf
  1094. *
  1095. * Return: Current pointer in ring buffer
  1096. */
  1097. uint8_t *hif_log_dump_ce(struct hif_softc *scn, uint8_t *buf_cur,
  1098. uint8_t *buf_init, uint32_t buf_sz,
  1099. uint32_t ce, uint32_t skb_sz);
  1100. #endif /* OL_ATH_SMART_LOGGING */
  1101. #endif /* _HIF_H_ */