hif.h 39 KB

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