hif.h 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867
  1. /*
  2. * Copyright (c) 2013-2017 The Linux Foundation. All rights reserved.
  3. *
  4. * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
  5. *
  6. *
  7. * Permission to use, copy, modify, and/or distribute this software for
  8. * any purpose with or without fee is hereby granted, provided that the
  9. * above copyright notice and this permission notice appear in all
  10. * copies.
  11. *
  12. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  13. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  14. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  15. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  16. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  17. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  18. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  19. * PERFORMANCE OF THIS SOFTWARE.
  20. */
  21. /*
  22. * This file was originally distributed by Qualcomm Atheros, Inc.
  23. * under proprietary terms before Copyright ownership was assigned
  24. * to the Linux Foundation.
  25. */
  26. #ifndef _HIF_H_
  27. #define _HIF_H_
  28. #ifdef __cplusplus
  29. extern "C" {
  30. #endif /* __cplusplus */
  31. /* Header files */
  32. #include <qdf_status.h>
  33. #include "qdf_nbuf.h"
  34. #include "ol_if_athvar.h"
  35. #include <linux/platform_device.h>
  36. #ifdef HIF_PCI
  37. #include <linux/pci.h>
  38. #endif /* HIF_PCI */
  39. #ifdef HIF_USB
  40. #include <linux/usb.h>
  41. #endif /* HIF_USB */
  42. #ifdef IPA_OFFLOAD
  43. #include <linux/ipa.h>
  44. #endif
  45. #define ENABLE_MBOX_DUMMY_SPACE_FEATURE 1
  46. typedef struct htc_callbacks HTC_CALLBACKS;
  47. typedef void __iomem *A_target_id_t;
  48. typedef void *hif_handle_t;
  49. #define HIF_TYPE_AR6002 2
  50. #define HIF_TYPE_AR6003 3
  51. #define HIF_TYPE_AR6004 5
  52. #define HIF_TYPE_AR9888 6
  53. #define HIF_TYPE_AR6320 7
  54. #define HIF_TYPE_AR6320V2 8
  55. /* For attaching Peregrine 2.0 board host_reg_tbl only */
  56. #define HIF_TYPE_AR9888V2 9
  57. #define HIF_TYPE_ADRASTEA 10
  58. #define HIF_TYPE_AR900B 11
  59. #define HIF_TYPE_QCA9984 12
  60. #define HIF_TYPE_IPQ4019 13
  61. #define HIF_TYPE_QCA9888 14
  62. #define HIF_TYPE_QCA8074 15
  63. #define HIF_TYPE_QCA6290 16
  64. /* TARGET definition needs to be abstracted in fw common
  65. * header files, below is the placeholder till WIN codebase
  66. * moved to latest copy of fw common header files.
  67. */
  68. #ifdef CONFIG_WIN
  69. #if ENABLE_10_4_FW_HDR
  70. #define TARGET_TYPE_UNKNOWN 0
  71. #define TARGET_TYPE_AR6001 1
  72. #define TARGET_TYPE_AR6002 2
  73. #define TARGET_TYPE_AR6003 3
  74. #define TARGET_TYPE_AR6004 5
  75. #define TARGET_TYPE_AR6006 6
  76. #define TARGET_TYPE_AR9888 7
  77. #define TARGET_TYPE_AR6320 8
  78. #define TARGET_TYPE_AR900B 9
  79. #define TARGET_TYPE_QCA9984 10
  80. #define TARGET_TYPE_IPQ4019 11
  81. #define TARGET_TYPE_QCA9888 12
  82. /* For attach Peregrine 2.0 board target_reg_tbl only */
  83. #define TARGET_TYPE_AR9888V2 13
  84. /* For attach Rome1.0 target_reg_tbl only*/
  85. #define TARGET_TYPE_AR6320V1 14
  86. /* For Rome2.0/2.1 target_reg_tbl ID*/
  87. #define TARGET_TYPE_AR6320V2 15
  88. /* For Rome3.0 target_reg_tbl ID*/
  89. #define TARGET_TYPE_AR6320V3 16
  90. /* For Tufello1.0 target_reg_tbl ID*/
  91. #define TARGET_TYPE_QCA9377V1 17
  92. #endif /* ENABLE_10_4_FW_HDR */
  93. /* For Adrastea target */
  94. #define TARGET_TYPE_ADRASTEA 19
  95. #endif /* CONFIG_WIN */
  96. #ifndef TARGET_TYPE_QCA8074
  97. #define TARGET_TYPE_QCA8074 20
  98. #endif
  99. #ifndef TARGET_TYPE_QCA6290
  100. #define TARGET_TYPE_QCA6290 21
  101. #endif
  102. #ifdef IPA_OFFLOAD
  103. #define DMA_COHERENT_MASK_IPA_VER_3_AND_ABOVE 37
  104. #define DMA_COHERENT_MASK_BELOW_IPA_VER_3 32
  105. #endif
  106. /* enum hif_ic_irq - enum defining integrated chip irq numbers
  107. * defining irq nubers that can be used by external modules like datapath
  108. */
  109. enum hif_ic_irq {
  110. host2wbm_desc_feed = 18,
  111. host2reo_re_injection,
  112. host2reo_command,
  113. host2rxdma_monitor_ring3,
  114. host2rxdma_monitor_ring2,
  115. host2rxdma_monitor_ring1,
  116. reo2ost_exception,
  117. wbm2host_rx_release,
  118. reo2host_status,
  119. reo2host_destination_ring4,
  120. reo2host_destination_ring3,
  121. reo2host_destination_ring2,
  122. reo2host_destination_ring1,
  123. rxdma2host_monitor_destination_mac3,
  124. rxdma2host_monitor_destination_mac2,
  125. rxdma2host_monitor_destination_mac1,
  126. ppdu_end_interrupts_mac3,
  127. ppdu_end_interrupts_mac2,
  128. ppdu_end_interrupts_mac1,
  129. rxdma2host_monitor_status_ring_mac3,
  130. rxdma2host_monitor_status_ring_mac2,
  131. rxdma2host_monitor_status_ring_mac1,
  132. host2rxdma_host_buf_ring_mac3,
  133. host2rxdma_host_buf_ring_mac2,
  134. host2rxdma_host_buf_ring_mac1,
  135. rxdma2host_destination_ring_mac3,
  136. rxdma2host_destination_ring_mac2,
  137. rxdma2host_destination_ring_mac1,
  138. host2tcl_input_ring4,
  139. host2tcl_input_ring3,
  140. host2tcl_input_ring2,
  141. host2tcl_input_ring1,
  142. wbm2host_tx_completions_ring3,
  143. wbm2host_tx_completions_ring2,
  144. wbm2host_tx_completions_ring1,
  145. tcl2host_status_ring,
  146. };
  147. struct CE_state;
  148. #define CE_COUNT_MAX 12
  149. #define HIF_MAX_GRP_IRQ 16
  150. #define HIF_MAX_GROUP 8
  151. #ifdef CONFIG_SLUB_DEBUG_ON
  152. #ifndef CONFIG_WIN
  153. #define HIF_CONFIG_SLUB_DEBUG_ON
  154. #endif
  155. #endif
  156. #ifndef NAPI_YIELD_BUDGET_BASED
  157. #ifdef HIF_CONFIG_SLUB_DEBUG_ON
  158. #define QCA_NAPI_BUDGET 64
  159. #define QCA_NAPI_DEF_SCALE 2
  160. #else /* PERF build */
  161. #define QCA_NAPI_BUDGET 64
  162. #define QCA_NAPI_DEF_SCALE 16
  163. #endif /* SLUB_DEBUG_ON */
  164. #else /* NAPI_YIELD_BUDGET_BASED */
  165. #define QCA_NAPI_BUDGET 64
  166. #define QCA_NAPI_DEF_SCALE 4
  167. #endif
  168. #define HIF_NAPI_MAX_RECEIVES (QCA_NAPI_BUDGET * QCA_NAPI_DEF_SCALE)
  169. /* NOTE: "napi->scale" can be changed,
  170. but this does not change the number of buckets */
  171. #define QCA_NAPI_NUM_BUCKETS 4
  172. struct qca_napi_stat {
  173. uint32_t napi_schedules;
  174. uint32_t napi_polls;
  175. uint32_t napi_completes;
  176. uint32_t napi_workdone;
  177. uint32_t cpu_corrected;
  178. uint32_t napi_budget_uses[QCA_NAPI_NUM_BUCKETS];
  179. uint32_t time_limit_reached;
  180. uint32_t rxpkt_thresh_reached;
  181. };
  182. /**
  183. * per NAPI instance data structure
  184. * This data structure holds stuff per NAPI instance.
  185. * Note that, in the current implementation, though scale is
  186. * an instance variable, it is set to the same value for all
  187. * instances.
  188. */
  189. struct qca_napi_info {
  190. struct net_device netdev; /* dummy net_dev */
  191. void *hif_ctx;
  192. struct napi_struct napi;
  193. uint8_t scale; /* currently same on all instances */
  194. uint8_t id;
  195. uint8_t cpu;
  196. int irq;
  197. struct qca_napi_stat stats[NR_CPUS];
  198. /* will only be present for data rx CE's */
  199. void (*lro_flush_cb)(void *);
  200. void *lro_ctx;
  201. qdf_spinlock_t lro_unloading_lock;
  202. };
  203. /**
  204. * struct qca_napi_cpu - an entry of the napi cpu table
  205. * @core_id: physical core id of the core
  206. * @cluster_id: cluster this core belongs to
  207. * @core_mask: mask to match all core of this cluster
  208. * @thread_mask: mask for this core within the cluster
  209. * @max_freq: maximum clock this core can be clocked at
  210. * same for all cpus of the same core.
  211. * @napis: bitmap of napi instances on this core
  212. * cluster_nxt: chain to link cores within the same cluster
  213. *
  214. * This structure represents a single entry in the napi cpu
  215. * table. The table is part of struct qca_napi_data.
  216. * This table is initialized by the init function, called while
  217. * the first napi instance is being created, updated by hotplug
  218. * notifier and when cpu affinity decisions are made (by throughput
  219. * detection), and deleted when the last napi instance is removed.
  220. */
  221. enum qca_napi_tput_state {
  222. QCA_NAPI_TPUT_UNINITIALIZED,
  223. QCA_NAPI_TPUT_LO,
  224. QCA_NAPI_TPUT_HI
  225. };
  226. enum qca_napi_cpu_state {
  227. QCA_NAPI_CPU_UNINITIALIZED,
  228. QCA_NAPI_CPU_DOWN,
  229. QCA_NAPI_CPU_UP };
  230. struct qca_napi_cpu {
  231. enum qca_napi_cpu_state state;
  232. int core_id;
  233. int cluster_id;
  234. cpumask_t core_mask;
  235. cpumask_t thread_mask;
  236. unsigned int max_freq;
  237. uint32_t napis;
  238. int cluster_nxt; /* index, not pointer */
  239. };
  240. /**
  241. * NAPI data-structure common to all NAPI instances.
  242. *
  243. * A variable of this type will be stored in hif module context.
  244. */
  245. struct qca_napi_data {
  246. qdf_spinlock_t lock;
  247. uint32_t state;
  248. uint32_t ce_map; /* bitmap of created/registered NAPI
  249. instances, indexed by pipe_id,
  250. not used by clients (clients use an
  251. id returned by create) */
  252. struct qca_napi_info napis[CE_COUNT_MAX];
  253. struct qca_napi_cpu napi_cpu[NR_CPUS];
  254. int lilcl_head, bigcl_head;
  255. enum qca_napi_tput_state napi_mode;
  256. struct notifier_block hnc_cpu_notifier;
  257. uint8_t flags;
  258. };
  259. /**
  260. * struct hif_config_info - Place Holder for hif confiruation
  261. * @enable_self_recovery: Self Recovery
  262. *
  263. * Structure for holding hif ini parameters.
  264. */
  265. struct hif_config_info {
  266. bool enable_self_recovery;
  267. #ifdef FEATURE_RUNTIME_PM
  268. bool enable_runtime_pm;
  269. u_int32_t runtime_pm_delay;
  270. #endif
  271. };
  272. /**
  273. * struct hif_target_info - Target Information
  274. * @target_version: Target Version
  275. * @target_type: Target Type
  276. * @target_revision: Target Revision
  277. * @soc_version: SOC Version
  278. *
  279. * Structure to hold target information.
  280. */
  281. struct hif_target_info {
  282. uint32_t target_version;
  283. uint32_t target_type;
  284. uint32_t target_revision;
  285. uint32_t soc_version;
  286. char *hw_name;
  287. };
  288. struct hif_opaque_softc {
  289. };
  290. typedef enum {
  291. HIF_DEVICE_POWER_UP, /* HIF layer should power up interface
  292. * and/or module */
  293. HIF_DEVICE_POWER_DOWN, /* HIF layer should initiate bus-specific
  294. * measures to minimize power */
  295. HIF_DEVICE_POWER_CUT /* HIF layer should initiate bus-specific
  296. * AND/OR platform-specific measures
  297. * to completely power-off the module and
  298. * associated hardware (i.e. cut power
  299. * supplies) */
  300. } HIF_DEVICE_POWER_CHANGE_TYPE;
  301. /**
  302. * enum hif_enable_type: what triggered the enabling of hif
  303. *
  304. * @HIF_ENABLE_TYPE_PROBE: probe triggered enable
  305. * @HIF_ENABLE_TYPE_REINIT: reinit triggered enable
  306. */
  307. enum hif_enable_type {
  308. HIF_ENABLE_TYPE_PROBE,
  309. HIF_ENABLE_TYPE_REINIT,
  310. HIF_ENABLE_TYPE_MAX
  311. };
  312. /**
  313. * enum hif_disable_type: what triggered the disabling of hif
  314. *
  315. * @HIF_DISABLE_TYPE_PROBE_ERROR: probe error triggered disable
  316. * @HIF_DISABLE_TYPE_REINIT_ERROR: reinit error triggered
  317. * disable
  318. * @HIF_DISABLE_TYPE_REMOVE: remove triggered disable
  319. * @HIF_DISABLE_TYPE_SHUTDOWN: shutdown triggered disable
  320. */
  321. enum hif_disable_type {
  322. HIF_DISABLE_TYPE_PROBE_ERROR,
  323. HIF_DISABLE_TYPE_REINIT_ERROR,
  324. HIF_DISABLE_TYPE_REMOVE,
  325. HIF_DISABLE_TYPE_SHUTDOWN,
  326. HIF_DISABLE_TYPE_MAX
  327. };
  328. /**
  329. * enum hif_device_config_opcode: configure mode
  330. *
  331. * @HIF_DEVICE_POWER_STATE: device power state
  332. * @HIF_DEVICE_GET_MBOX_BLOCK_SIZE: get mbox block size
  333. * @HIF_DEVICE_GET_MBOX_ADDR: get mbox block address
  334. * @HIF_DEVICE_GET_PENDING_EVENTS_FUNC: get pending events functions
  335. * @HIF_DEVICE_GET_IRQ_PROC_MODE: get irq proc mode
  336. * @HIF_DEVICE_GET_RECV_EVENT_MASK_UNMASK_FUNC: receive event function
  337. * @HIF_DEVICE_POWER_STATE_CHANGE: change power state
  338. * @HIF_DEVICE_GET_IRQ_YIELD_PARAMS: get yield params
  339. * @HIF_CONFIGURE_QUERY_SCATTER_REQUEST_SUPPORT: configure scatter request
  340. * @HIF_DEVICE_GET_OS_DEVICE: get OS device
  341. * @HIF_DEVICE_DEBUG_BUS_STATE: debug bus state
  342. * @HIF_BMI_DONE: bmi done
  343. * @HIF_DEVICE_SET_TARGET_TYPE: set target type
  344. * @HIF_DEVICE_SET_HTC_CONTEXT: set htc context
  345. * @HIF_DEVICE_GET_HTC_CONTEXT: get htc context
  346. */
  347. enum hif_device_config_opcode {
  348. HIF_DEVICE_POWER_STATE = 0,
  349. HIF_DEVICE_GET_MBOX_BLOCK_SIZE,
  350. HIF_DEVICE_GET_MBOX_ADDR,
  351. HIF_DEVICE_GET_PENDING_EVENTS_FUNC,
  352. HIF_DEVICE_GET_IRQ_PROC_MODE,
  353. HIF_DEVICE_GET_RECV_EVENT_MASK_UNMASK_FUNC,
  354. HIF_DEVICE_POWER_STATE_CHANGE,
  355. HIF_DEVICE_GET_IRQ_YIELD_PARAMS,
  356. HIF_CONFIGURE_QUERY_SCATTER_REQUEST_SUPPORT,
  357. HIF_DEVICE_GET_OS_DEVICE,
  358. HIF_DEVICE_DEBUG_BUS_STATE,
  359. HIF_BMI_DONE,
  360. HIF_DEVICE_SET_TARGET_TYPE,
  361. HIF_DEVICE_SET_HTC_CONTEXT,
  362. HIF_DEVICE_GET_HTC_CONTEXT,
  363. };
  364. #ifdef CONFIG_ATH_PCIE_ACCESS_DEBUG
  365. typedef struct _HID_ACCESS_LOG {
  366. uint32_t seqnum;
  367. bool is_write;
  368. void *addr;
  369. uint32_t value;
  370. } HIF_ACCESS_LOG;
  371. #endif
  372. void hif_reg_write(struct hif_opaque_softc *hif_ctx, uint32_t offset,
  373. uint32_t value);
  374. uint32_t hif_reg_read(struct hif_opaque_softc *hif_ctx, uint32_t offset);
  375. #define HIF_MAX_DEVICES 1
  376. struct htc_callbacks {
  377. void *context; /* context to pass to the dsrhandler
  378. * note : rwCompletionHandler is provided
  379. * the context passed to hif_read_write */
  380. QDF_STATUS(*rwCompletionHandler)(void *rwContext, QDF_STATUS status);
  381. QDF_STATUS(*dsrHandler)(void *context);
  382. };
  383. /**
  384. * struct hif_driver_state_callbacks - Callbacks for HIF to query Driver state
  385. * @context: Private data context
  386. * @set_recovery_in_progress: To Set Driver state for recovery in progress
  387. * @is_recovery_in_progress: Query if driver state is recovery in progress
  388. * @is_load_unload_in_progress: Query if driver state Load/Unload in Progress
  389. * @is_driver_unloading: Query if driver is unloading.
  390. *
  391. * This Structure provides callback pointer for HIF to query hdd for driver
  392. * states.
  393. */
  394. struct hif_driver_state_callbacks {
  395. void *context;
  396. void (*set_recovery_in_progress)(void *context, uint8_t val);
  397. bool (*is_recovery_in_progress)(void *context);
  398. bool (*is_load_unload_in_progress)(void *context);
  399. bool (*is_driver_unloading)(void *context);
  400. };
  401. /* This API detaches the HTC layer from the HIF device */
  402. void hif_detach_htc(struct hif_opaque_softc *scn);
  403. /****************************************************************/
  404. /* BMI and Diag window abstraction */
  405. /****************************************************************/
  406. #define HIF_BMI_EXCHANGE_NO_TIMEOUT ((uint32_t)(0))
  407. #define DIAG_TRANSFER_LIMIT 2048U /* maximum number of bytes that can be
  408. * handled atomically by
  409. * DiagRead/DiagWrite */
  410. /*
  411. * API to handle HIF-specific BMI message exchanges, this API is synchronous
  412. * and only allowed to be called from a context that can block (sleep) */
  413. QDF_STATUS hif_exchange_bmi_msg(struct hif_opaque_softc *scn,
  414. qdf_dma_addr_t cmd, qdf_dma_addr_t rsp,
  415. uint8_t *pSendMessage, uint32_t Length,
  416. uint8_t *pResponseMessage,
  417. uint32_t *pResponseLength, uint32_t TimeoutMS);
  418. /*
  419. * APIs to handle HIF specific diagnostic read accesses. These APIs are
  420. * synchronous and only allowed to be called from a context that
  421. * can block (sleep). They are not high performance APIs.
  422. *
  423. * hif_diag_read_access reads a 4 Byte aligned/length value from a
  424. * Target register or memory word.
  425. *
  426. * hif_diag_read_mem reads an arbitrary length of arbitrarily aligned memory.
  427. */
  428. QDF_STATUS hif_diag_read_access(struct hif_opaque_softc *scn, uint32_t address,
  429. uint32_t *data);
  430. QDF_STATUS hif_diag_read_mem(struct hif_opaque_softc *scn, uint32_t address,
  431. uint8_t *data, int nbytes);
  432. void hif_dump_target_memory(struct hif_opaque_softc *scn, void *ramdump_base,
  433. uint32_t address, uint32_t size);
  434. /*
  435. * APIs to handle HIF specific diagnostic write accesses. These APIs are
  436. * synchronous and only allowed to be called from a context that
  437. * can block (sleep).
  438. * They are not high performance APIs.
  439. *
  440. * hif_diag_write_access writes a 4 Byte aligned/length value to a
  441. * Target register or memory word.
  442. *
  443. * hif_diag_write_mem writes an arbitrary length of arbitrarily aligned memory.
  444. */
  445. QDF_STATUS hif_diag_write_access(struct hif_opaque_softc *scn, uint32_t address,
  446. uint32_t data);
  447. QDF_STATUS hif_diag_write_mem(struct hif_opaque_softc *scn, uint32_t address,
  448. uint8_t *data, int nbytes);
  449. typedef void (*fastpath_msg_handler)(void *, qdf_nbuf_t *, uint32_t);
  450. typedef uint32_t (*ext_intr_handler)(void *, uint32_t);
  451. /*
  452. * Set the FASTPATH_mode_on flag in sc, for use by data path
  453. */
  454. #ifdef WLAN_FEATURE_FASTPATH
  455. void hif_enable_fastpath(struct hif_opaque_softc *hif_ctx);
  456. bool hif_is_fastpath_mode_enabled(struct hif_opaque_softc *hif_ctx);
  457. void *hif_get_ce_handle(struct hif_opaque_softc *hif_ctx, int ret);
  458. int hif_ce_fastpath_cb_register(struct hif_opaque_softc *hif_ctx,
  459. fastpath_msg_handler handler, void *context);
  460. #else
  461. static inline int hif_ce_fastpath_cb_register(struct hif_opaque_softc *hif_ctx,
  462. fastpath_msg_handler handler,
  463. void *context)
  464. {
  465. return QDF_STATUS_E_FAILURE;
  466. }
  467. static inline void *hif_get_ce_handle(struct hif_opaque_softc *hif_ctx, int ret)
  468. {
  469. return NULL;
  470. }
  471. #endif
  472. /*
  473. * Enable/disable CDC max performance workaround
  474. * For max-performace set this to 0
  475. * To allow SoC to enter sleep set this to 1
  476. */
  477. #define CONFIG_DISABLE_CDC_MAX_PERF_WAR 0
  478. void hif_ipa_get_ce_resource(struct hif_opaque_softc *scn,
  479. qdf_dma_addr_t *ce_sr_base_paddr,
  480. uint32_t *ce_sr_ring_size,
  481. qdf_dma_addr_t *ce_reg_paddr);
  482. /**
  483. * @brief List of callbacks - filled in by HTC.
  484. */
  485. struct hif_msg_callbacks {
  486. void *Context;
  487. /**< context meaningful to HTC */
  488. QDF_STATUS (*txCompletionHandler)(void *Context, qdf_nbuf_t wbuf,
  489. uint32_t transferID,
  490. uint32_t toeplitz_hash_result);
  491. QDF_STATUS (*rxCompletionHandler)(void *Context, qdf_nbuf_t wbuf,
  492. uint8_t pipeID);
  493. void (*txResourceAvailHandler)(void *context, uint8_t pipe);
  494. void (*fwEventHandler)(void *context, QDF_STATUS status);
  495. };
  496. enum hif_target_status {
  497. TARGET_STATUS_CONNECTED = 0, /* target connected */
  498. TARGET_STATUS_RESET, /* target got reset */
  499. TARGET_STATUS_EJECT, /* target got ejected */
  500. TARGET_STATUS_SUSPEND /*target got suspend */
  501. };
  502. /**
  503. * enum hif_attribute_flags: configure hif
  504. *
  505. * @HIF_LOWDESC_CE_CFG: Configure HIF with Low descriptor CE
  506. * @HIF_LOWDESC_CE_NO_PKTLOG_CFG: Configure HIF with Low descriptor
  507. * + No pktlog CE
  508. */
  509. enum hif_attribute_flags {
  510. HIF_LOWDESC_CE_CFG = 1,
  511. HIF_LOWDESC_CE_NO_PKTLOG_CFG
  512. };
  513. #define HIF_DATA_ATTR_SET_TX_CLASSIFY(attr, v) \
  514. (attr |= (v & 0x01) << 5)
  515. #define HIF_DATA_ATTR_SET_ENCAPSULATION_TYPE(attr, v) \
  516. (attr |= (v & 0x03) << 6)
  517. #define HIF_DATA_ATTR_SET_ADDR_X_SEARCH_DISABLE(attr, v) \
  518. (attr |= (v & 0x01) << 13)
  519. #define HIF_DATA_ATTR_SET_ADDR_Y_SEARCH_DISABLE(attr, v) \
  520. (attr |= (v & 0x01) << 14)
  521. #define HIF_DATA_ATTR_SET_TOEPLITZ_HASH_ENABLE(attr, v) \
  522. (attr |= (v & 0x01) << 15)
  523. #define HIF_DATA_ATTR_SET_PACKET_OR_RESULT_OFFSET(attr, v) \
  524. (attr |= (v & 0x0FFF) << 16)
  525. #define HIF_DATA_ATTR_SET_ENABLE_11H(attr, v) \
  526. (attr |= (v & 0x01) << 30)
  527. struct hif_ul_pipe_info {
  528. unsigned int nentries;
  529. unsigned int nentries_mask;
  530. unsigned int sw_index;
  531. unsigned int write_index; /* cached copy */
  532. unsigned int hw_index; /* cached copy */
  533. void *base_addr_owner_space; /* Host address space */
  534. qdf_dma_addr_t base_addr_CE_space; /* CE address space */
  535. };
  536. struct hif_dl_pipe_info {
  537. unsigned int nentries;
  538. unsigned int nentries_mask;
  539. unsigned int sw_index;
  540. unsigned int write_index; /* cached copy */
  541. unsigned int hw_index; /* cached copy */
  542. void *base_addr_owner_space; /* Host address space */
  543. qdf_dma_addr_t base_addr_CE_space; /* CE address space */
  544. };
  545. struct hif_pipe_addl_info {
  546. uint32_t pci_mem;
  547. uint32_t ctrl_addr;
  548. struct hif_ul_pipe_info ul_pipe;
  549. struct hif_dl_pipe_info dl_pipe;
  550. };
  551. struct hif_bus_id;
  552. typedef struct hif_bus_id hif_bus_id;
  553. void hif_claim_device(struct hif_opaque_softc *hif_ctx);
  554. QDF_STATUS hif_get_config_item(struct hif_opaque_softc *hif_ctx,
  555. int opcode, void *config, uint32_t config_len);
  556. void hif_set_mailbox_swap(struct hif_opaque_softc *hif_ctx);
  557. void hif_mask_interrupt_call(struct hif_opaque_softc *scn);
  558. void hif_post_init(struct hif_opaque_softc *scn, void *hHTC,
  559. struct hif_msg_callbacks *callbacks);
  560. QDF_STATUS hif_start(struct hif_opaque_softc *scn);
  561. void hif_stop(struct hif_opaque_softc *scn);
  562. void hif_flush_surprise_remove(struct hif_opaque_softc *scn);
  563. void hif_dump(struct hif_opaque_softc *scn, uint8_t CmdId, bool start);
  564. void hif_trigger_dump(struct hif_opaque_softc *hif_ctx,
  565. uint8_t cmd_id, bool start);
  566. QDF_STATUS hif_send_head(struct hif_opaque_softc *scn, uint8_t PipeID,
  567. uint32_t transferID, uint32_t nbytes,
  568. qdf_nbuf_t wbuf, uint32_t data_attr);
  569. void hif_send_complete_check(struct hif_opaque_softc *scn, uint8_t PipeID,
  570. int force);
  571. void hif_shut_down_device(struct hif_opaque_softc *scn);
  572. void hif_get_default_pipe(struct hif_opaque_softc *scn, uint8_t *ULPipe,
  573. uint8_t *DLPipe);
  574. int hif_map_service_to_pipe(struct hif_opaque_softc *scn, uint16_t svc_id,
  575. uint8_t *ul_pipe, uint8_t *dl_pipe, int *ul_is_polled,
  576. int *dl_is_polled);
  577. uint16_t
  578. hif_get_free_queue_number(struct hif_opaque_softc *scn, uint8_t PipeID);
  579. void *hif_get_targetdef(struct hif_opaque_softc *scn);
  580. uint32_t hif_hia_item_address(uint32_t target_type, uint32_t item_offset);
  581. void hif_set_target_sleep(struct hif_opaque_softc *scn, bool sleep_ok,
  582. bool wait_for_it);
  583. int hif_check_fw_reg(struct hif_opaque_softc *scn);
  584. #ifndef HIF_PCI
  585. static inline int hif_check_soc_status(struct hif_opaque_softc *scn)
  586. {
  587. return 0;
  588. }
  589. #else
  590. int hif_check_soc_status(struct hif_opaque_softc *scn);
  591. #endif
  592. void hif_get_hw_info(struct hif_opaque_softc *scn, u32 *version, u32 *revision,
  593. const char **target_name);
  594. void hif_disable_isr(struct hif_opaque_softc *scn);
  595. void hif_reset_soc(struct hif_opaque_softc *scn);
  596. void hif_save_htc_htt_config_endpoint(struct hif_opaque_softc *hif_ctx,
  597. int htc_htt_tx_endpoint);
  598. struct hif_opaque_softc *hif_open(qdf_device_t qdf_ctx, uint32_t mode,
  599. enum qdf_bus_type bus_type,
  600. struct hif_driver_state_callbacks *cbk);
  601. void hif_close(struct hif_opaque_softc *hif_ctx);
  602. QDF_STATUS hif_enable(struct hif_opaque_softc *hif_ctx, struct device *dev,
  603. void *bdev, const hif_bus_id *bid,
  604. enum qdf_bus_type bus_type,
  605. enum hif_enable_type type);
  606. void hif_disable(struct hif_opaque_softc *hif_ctx, enum hif_disable_type type);
  607. void hif_display_stats(struct hif_opaque_softc *hif_ctx);
  608. void hif_clear_stats(struct hif_opaque_softc *hif_ctx);
  609. #ifdef FEATURE_RUNTIME_PM
  610. struct hif_pm_runtime_lock;
  611. void hif_fastpath_resume(struct hif_opaque_softc *hif_ctx);
  612. int hif_pm_runtime_get(struct hif_opaque_softc *hif_ctx);
  613. void hif_pm_runtime_get_noresume(struct hif_opaque_softc *hif_ctx);
  614. int hif_pm_runtime_put(struct hif_opaque_softc *hif_ctx);
  615. struct hif_pm_runtime_lock *hif_runtime_lock_init(const char *name);
  616. void hif_runtime_lock_deinit(struct hif_opaque_softc *hif_ctx,
  617. struct hif_pm_runtime_lock *lock);
  618. int hif_pm_runtime_prevent_suspend(struct hif_opaque_softc *ol_sc,
  619. struct hif_pm_runtime_lock *lock);
  620. int hif_pm_runtime_allow_suspend(struct hif_opaque_softc *ol_sc,
  621. struct hif_pm_runtime_lock *lock);
  622. int hif_pm_runtime_prevent_suspend_timeout(struct hif_opaque_softc *ol_sc,
  623. struct hif_pm_runtime_lock *lock, unsigned int delay);
  624. #else
  625. struct hif_pm_runtime_lock {
  626. const char *name;
  627. };
  628. static inline void hif_fastpath_resume(struct hif_opaque_softc *hif_ctx) {}
  629. static inline void hif_pm_runtime_get_noresume(struct hif_opaque_softc *hif_ctx)
  630. {}
  631. static inline int hif_pm_runtime_get(struct hif_opaque_softc *hif_ctx)
  632. { return 0; }
  633. static inline int hif_pm_runtime_put(struct hif_opaque_softc *hif_ctx)
  634. { return 0; }
  635. static inline struct hif_pm_runtime_lock *hif_runtime_lock_init(
  636. const char *name)
  637. { return NULL; }
  638. static inline void
  639. hif_runtime_lock_deinit(struct hif_opaque_softc *hif_ctx,
  640. struct hif_pm_runtime_lock *lock) {}
  641. static inline int hif_pm_runtime_prevent_suspend(struct hif_opaque_softc *ol_sc,
  642. struct hif_pm_runtime_lock *lock)
  643. { return 0; }
  644. static inline int hif_pm_runtime_allow_suspend(struct hif_opaque_softc *ol_sc,
  645. struct hif_pm_runtime_lock *lock)
  646. { return 0; }
  647. static inline int
  648. hif_pm_runtime_prevent_suspend_timeout(struct hif_opaque_softc *ol_sc,
  649. struct hif_pm_runtime_lock *lock, unsigned int delay)
  650. { return 0; }
  651. #endif
  652. void hif_enable_power_management(struct hif_opaque_softc *hif_ctx,
  653. bool is_packet_log_enabled);
  654. void hif_disable_power_management(struct hif_opaque_softc *hif_ctx);
  655. void hif_vote_link_down(struct hif_opaque_softc *);
  656. void hif_vote_link_up(struct hif_opaque_softc *);
  657. bool hif_can_suspend_link(struct hif_opaque_softc *);
  658. #ifdef IPA_OFFLOAD
  659. /**
  660. * hif_get_ipa_hw_type() - get IPA hw type
  661. *
  662. * This API return the IPA hw type.
  663. *
  664. * Return: IPA hw type
  665. */
  666. static inline
  667. enum ipa_hw_type hif_get_ipa_hw_type(void)
  668. {
  669. return ipa_get_hw_type();
  670. }
  671. #endif
  672. int hif_bus_resume(struct hif_opaque_softc *);
  673. /**
  674. * hif_bus_ealry_suspend() - stop non wmi tx traffic
  675. * @context: hif context
  676. */
  677. int hif_bus_early_suspend(struct hif_opaque_softc *hif_ctx);
  678. /**
  679. * hif_bus_late_resume() - resume non wmi traffic
  680. * @context: hif context
  681. */
  682. int hif_bus_late_resume(struct hif_opaque_softc *hif_ctx);
  683. int hif_bus_suspend(struct hif_opaque_softc *);
  684. int hif_bus_resume_noirq(struct hif_opaque_softc *);
  685. int hif_bus_suspend_noirq(struct hif_opaque_softc *);
  686. /**
  687. * hif_apps_irqs_enable() - Enables all irqs from the APPS side
  688. * @hif_ctx: an opaque HIF handle to use
  689. *
  690. * As opposed to the standard hif_irq_enable, this function always applies to
  691. * the APPS side kernel interrupt handling.
  692. *
  693. * Return: errno
  694. */
  695. int hif_apps_irqs_enable(struct hif_opaque_softc *hif_ctx);
  696. /**
  697. * hif_apps_irqs_disable() - Disables all irqs from the APPS side
  698. * @hif_ctx: an opaque HIF handle to use
  699. *
  700. * As opposed to the standard hif_irq_disable, this function always applies to
  701. * the APPS side kernel interrupt handling.
  702. *
  703. * Return: errno
  704. */
  705. int hif_apps_irqs_disable(struct hif_opaque_softc *hif_ctx);
  706. /**
  707. * hif_apps_wake_irq_enable() - Enables the wake irq from the APPS side
  708. * @hif_ctx: an opaque HIF handle to use
  709. *
  710. * As opposed to the standard hif_irq_enable, this function always applies to
  711. * the APPS side kernel interrupt handling.
  712. *
  713. * Return: errno
  714. */
  715. int hif_apps_wake_irq_enable(struct hif_opaque_softc *hif_ctx);
  716. /**
  717. * hif_apps_wake_irq_disable() - Disables the wake irq from the APPS side
  718. * @hif_ctx: an opaque HIF handle to use
  719. *
  720. * As opposed to the standard hif_irq_disable, this function always applies to
  721. * the APPS side kernel interrupt handling.
  722. *
  723. * Return: errno
  724. */
  725. int hif_apps_wake_irq_disable(struct hif_opaque_softc *hif_ctx);
  726. #ifdef FEATURE_RUNTIME_PM
  727. int hif_pre_runtime_suspend(struct hif_opaque_softc *hif_ctx);
  728. void hif_pre_runtime_resume(struct hif_opaque_softc *hif_ctx);
  729. int hif_runtime_suspend(struct hif_opaque_softc *hif_ctx);
  730. int hif_runtime_resume(struct hif_opaque_softc *hif_ctx);
  731. void hif_process_runtime_suspend_success(struct hif_opaque_softc *);
  732. void hif_process_runtime_suspend_failure(struct hif_opaque_softc *);
  733. void hif_process_runtime_resume_success(struct hif_opaque_softc *);
  734. #endif
  735. int hif_get_irq_num(struct hif_opaque_softc *scn, int *irq, uint32_t size);
  736. int hif_dump_registers(struct hif_opaque_softc *scn);
  737. int ol_copy_ramdump(struct hif_opaque_softc *scn);
  738. void hif_crash_shutdown(struct hif_opaque_softc *hif_ctx);
  739. void hif_get_hw_info(struct hif_opaque_softc *scn, u32 *version, u32 *revision,
  740. const char **target_name);
  741. void hif_lro_flush_cb_register(struct hif_opaque_softc *scn,
  742. void (lro_flush_handler)(void *),
  743. void *(lro_init_handler)(void));
  744. void hif_lro_flush_cb_deregister(struct hif_opaque_softc *scn,
  745. void (lro_deinit_cb)(void *));
  746. bool hif_needs_bmi(struct hif_opaque_softc *scn);
  747. enum qdf_bus_type hif_get_bus_type(struct hif_opaque_softc *hif_hdl);
  748. struct hif_target_info *hif_get_target_info_handle(struct hif_opaque_softc *
  749. scn);
  750. struct hif_config_info *hif_get_ini_handle(struct hif_opaque_softc *scn);
  751. struct ramdump_info *hif_get_ramdump_ctx(struct hif_opaque_softc *hif_ctx);
  752. enum hif_target_status hif_get_target_status(struct hif_opaque_softc *hif_ctx);
  753. void hif_set_target_status(struct hif_opaque_softc *hif_ctx, enum
  754. hif_target_status);
  755. void hif_init_ini_config(struct hif_opaque_softc *hif_ctx,
  756. struct hif_config_info *cfg);
  757. void hif_update_tx_ring(struct hif_opaque_softc *osc, u_int32_t num_htt_cmpls);
  758. qdf_nbuf_t hif_batch_send(struct hif_opaque_softc *osc, qdf_nbuf_t msdu,
  759. uint32_t transfer_id, u_int32_t len, uint32_t sendhead);
  760. int hif_send_single(struct hif_opaque_softc *osc, qdf_nbuf_t msdu, uint32_t
  761. transfer_id, u_int32_t len);
  762. int hif_send_fast(struct hif_opaque_softc *osc, qdf_nbuf_t nbuf,
  763. uint32_t transfer_id, uint32_t download_len);
  764. void hif_pkt_dl_len_set(void *hif_sc, unsigned int pkt_download_len);
  765. void hif_ce_war_disable(void);
  766. void hif_ce_war_enable(void);
  767. void hif_disable_interrupt(struct hif_opaque_softc *osc, uint32_t pipe_num);
  768. #ifdef QCA_NSS_WIFI_OFFLOAD_SUPPORT
  769. struct hif_pipe_addl_info *hif_get_addl_pipe_info(struct hif_opaque_softc *osc,
  770. struct hif_pipe_addl_info *hif_info, uint32_t pipe_number);
  771. uint32_t hif_set_nss_wifiol_mode(struct hif_opaque_softc *osc,
  772. uint32_t pipe_num);
  773. int32_t hif_get_nss_wifiol_bypass_nw_process(struct hif_opaque_softc *osc);
  774. #endif /* QCA_NSS_WIFI_OFFLOAD_SUPPORT */
  775. void hif_set_bundle_mode(struct hif_opaque_softc *scn, bool enabled,
  776. int rx_bundle_cnt);
  777. int hif_bus_reset_resume(struct hif_opaque_softc *scn);
  778. void hif_set_attribute(struct hif_opaque_softc *osc, uint8_t hif_attrib);
  779. void *hif_get_lro_info(int ctx_id, struct hif_opaque_softc *hif_hdl);
  780. #ifdef WLAN_SUSPEND_RESUME_TEST
  781. typedef void (*hif_fake_resume_callback)(uint32_t val);
  782. void hif_fake_apps_suspend(struct hif_opaque_softc *hif_ctx,
  783. hif_fake_resume_callback callback);
  784. void hif_fake_apps_resume(struct hif_opaque_softc *hif_ctx);
  785. #endif
  786. uint32_t hif_register_ext_group_int_handler(struct hif_opaque_softc *hif_ctx,
  787. uint32_t numirq, uint32_t irq[], ext_intr_handler handler,
  788. void *context);
  789. uint32_t hif_configure_ext_group_interrupts(struct hif_opaque_softc *hif_ctx);
  790. void hif_update_pipe_callback(struct hif_opaque_softc *osc,
  791. u_int8_t pipeid,
  792. struct hif_msg_callbacks *callbacks);
  793. #ifdef __cplusplus
  794. }
  795. #endif
  796. void *hif_get_dev_ba(struct hif_opaque_softc *hif_handle);
  797. #endif /* _HIF_H_ */