hif_main.h 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. /*
  2. * Copyright (c) 2013-2016 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. /*
  27. * NB: Inappropriate references to "HTC" are used in this (and other)
  28. * HIF implementations. HTC is typically the calling layer, but it
  29. * theoretically could be some alternative.
  30. */
  31. /*
  32. * This holds all state needed to process a pending send/recv interrupt.
  33. * The information is saved here as soon as the interrupt occurs (thus
  34. * allowing the underlying CE to re-use the ring descriptor). The
  35. * information here is eventually processed by a completion processing
  36. * thread.
  37. */
  38. #ifndef __HIF_MAIN_H__
  39. #define __HIF_MAIN_H__
  40. #include <qdf_atomic.h> /* qdf_atomic_read */
  41. #include "qdf_lock.h"
  42. #include "cepci.h"
  43. #include "hif.h"
  44. #include "multibus.h"
  45. #define HIF_MIN_SLEEP_INACTIVITY_TIME_MS 50
  46. #define HIF_SLEEP_INACTIVITY_TIMER_PERIOD_MS 60
  47. #define HIF_MAX_BUDGET 0xFFFF
  48. /*
  49. * This macro implementation is exposed for efficiency only.
  50. * The implementation may change and callers should
  51. * consider the targid to be a completely opaque handle.
  52. */
  53. #define TARGID_TO_PCI_ADDR(targid) (*((A_target_id_t *)(targid)))
  54. #ifdef QCA_WIFI_3_0
  55. #define DISABLE_L1SS_STATES 1
  56. #endif
  57. #define MAX_NUM_OF_RECEIVES HIF_NAPI_MAX_RECEIVES
  58. #ifdef QCA_WIFI_3_0_ADRASTEA
  59. #define ADRASTEA_BU 1
  60. #else
  61. #define ADRASTEA_BU 0
  62. #endif
  63. #ifdef QCA_WIFI_3_0
  64. #define HAS_FW_INDICATOR 0
  65. #else
  66. #define HAS_FW_INDICATOR 1
  67. #endif
  68. #define AR9888_DEVICE_ID (0x003c)
  69. #define AR6320_DEVICE_ID (0x003e)
  70. #define AR6320_FW_1_1 (0x11)
  71. #define AR6320_FW_1_3 (0x13)
  72. #define AR6320_FW_2_0 (0x20)
  73. #define AR6320_FW_3_0 (0x30)
  74. #define AR6320_FW_3_2 (0x32)
  75. #define ADRASTEA_DEVICE_ID (0xabcd)
  76. #define ADRASTEA_DEVICE_ID_P2_E12 (0x7021)
  77. #define AR9887_DEVICE_ID (0x0050)
  78. #define AR900B_DEVICE_ID (0x0040)
  79. #define QCA9984_DEVICE_ID (0x0046)
  80. #define QCA9888_DEVICE_ID (0x0056)
  81. #define IPQ4019_DEVICE_ID (0x12ef)
  82. #define QCA8074_DEVICE_ID (0xffff) /* Todo: replace this with
  83. actual number once available.
  84. currently defining this to 0xffff for
  85. emulation purpose */
  86. #define HIF_GET_PCI_SOFTC(scn) ((struct hif_pci_softc *)scn)
  87. #define HIF_GET_CE_STATE(scn) ((struct HIF_CE_state *)scn)
  88. #define HIF_GET_SDIO_SOFTC(scn) ((struct hif_sdio_softc *)scn)
  89. #define HIF_GET_USB_SOFTC(scn) ((struct hif_usb_softc *)scn)
  90. #define HIF_GET_USB_DEVICE(scn) ((HIF_DEVICE_USB *)scn)
  91. #define HIF_GET_SOFTC(scn) ((struct hif_softc *)scn)
  92. #define GET_HIF_OPAQUE_HDL(scn) ((struct hif_opaque_softc *)scn)
  93. struct hif_ce_stats {
  94. int hif_pipe_no_resrc_count;
  95. int ce_ring_delta_fail_count;
  96. };
  97. #ifdef WLAN_SUSPEND_RESUME_TEST
  98. struct fake_apps_context {
  99. unsigned long state;
  100. hif_fake_resume_callback resume_callback;
  101. struct work_struct resume_work;
  102. };
  103. enum hif_fake_apps_state_bits {
  104. HIF_FA_SUSPENDED_BIT = 0
  105. };
  106. void hif_fake_apps_resume_work(struct work_struct *work);
  107. #endif /* WLAN_SUSPEND_RESUME_TEST */
  108. struct hif_softc {
  109. struct hif_opaque_softc osc;
  110. struct hif_config_info hif_config;
  111. struct hif_target_info target_info;
  112. void __iomem *mem;
  113. enum qdf_bus_type bus_type;
  114. struct hif_bus_ops bus_ops;
  115. void *ce_id_to_state[CE_COUNT_MAX];
  116. qdf_device_t qdf_dev;
  117. bool hif_init_done;
  118. bool request_irq_done;
  119. /* Packet statistics */
  120. struct hif_ce_stats pkt_stats;
  121. enum hif_target_status target_status;
  122. struct targetdef_s *targetdef;
  123. struct ce_reg_def *target_ce_def;
  124. struct hostdef_s *hostdef;
  125. struct host_shadow_regs_s *host_shadow_regs;
  126. bool recovery;
  127. bool notice_send;
  128. bool per_ce_irq;
  129. uint32_t ce_irq_summary;
  130. /* No of copy engines supported */
  131. unsigned int ce_count;
  132. atomic_t active_tasklet_cnt;
  133. atomic_t active_grp_tasklet_cnt;
  134. atomic_t link_suspended;
  135. uint32_t *vaddr_rri_on_ddr;
  136. int linkstate_vote;
  137. bool fastpath_mode_on;
  138. atomic_t tasklet_from_intr;
  139. int htc_htt_tx_endpoint;
  140. qdf_dma_addr_t mem_pa;
  141. bool athdiag_procfs_inited;
  142. #ifdef FEATURE_NAPI
  143. struct qca_napi_data napi_data;
  144. #endif /* FEATURE_NAPI */
  145. struct hif_driver_state_callbacks callbacks;
  146. uint32_t hif_con_param;
  147. #ifdef QCA_NSS_WIFI_OFFLOAD_SUPPORT
  148. uint32_t nss_wifi_ol_mode;
  149. #endif
  150. void *hal_soc;
  151. #ifdef WLAN_SUSPEND_RESUME_TEST
  152. struct fake_apps_context fake_apps_ctx;
  153. #endif /* WLAN_SUSPEND_RESUME_TEST */
  154. };
  155. #ifdef QCA_NSS_WIFI_OFFLOAD_SUPPORT
  156. static inline bool hif_is_nss_wifi_enabled(struct hif_softc *sc)
  157. {
  158. return !!(sc->nss_wifi_ol_mode);
  159. }
  160. #else
  161. static inline bool hif_is_nss_wifi_enabled(struct hif_softc *sc)
  162. {
  163. return false;
  164. }
  165. #endif
  166. A_target_id_t hif_get_target_id(struct hif_softc *scn);
  167. void hif_dump_pipe_debug_count(struct hif_softc *scn);
  168. void hif_display_bus_stats(struct hif_opaque_softc *scn);
  169. void hif_clear_bus_stats(struct hif_opaque_softc *scn);
  170. bool hif_max_num_receives_reached(struct hif_softc *scn, unsigned int count);
  171. void hif_shutdown_device(struct hif_opaque_softc *hif_ctx);
  172. int hif_bus_configure(struct hif_softc *scn);
  173. void hif_cancel_deferred_target_sleep(struct hif_softc *scn);
  174. int hif_config_ce(struct hif_softc *scn);
  175. void hif_unconfig_ce(struct hif_softc *scn);
  176. void hif_ce_prepare_config(struct hif_softc *scn);
  177. QDF_STATUS hif_ce_open(struct hif_softc *scn);
  178. void hif_ce_close(struct hif_softc *scn);
  179. int athdiag_procfs_init(void *scn);
  180. void athdiag_procfs_remove(void);
  181. /* routine to modify the initial buffer count to be allocated on an os
  182. * platform basis. Platform owner will need to modify this as needed
  183. */
  184. qdf_size_t init_buffer_count(qdf_size_t maxSize);
  185. irqreturn_t hif_fw_interrupt_handler(int irq, void *arg);
  186. int hif_get_device_type(uint32_t device_id,
  187. uint32_t revision_id,
  188. uint32_t *hif_type, uint32_t *target_type);
  189. /*These functions are exposed to HDD*/
  190. void hif_nointrs(struct hif_softc *scn);
  191. void hif_bus_close(struct hif_softc *ol_sc);
  192. QDF_STATUS hif_bus_open(struct hif_softc *ol_sc,
  193. enum qdf_bus_type bus_type);
  194. QDF_STATUS hif_enable_bus(struct hif_softc *ol_sc, struct device *dev,
  195. void *bdev, const hif_bus_id *bid, enum hif_enable_type type);
  196. void hif_disable_bus(struct hif_softc *scn);
  197. void hif_bus_prevent_linkdown(struct hif_softc *scn, bool flag);
  198. int hif_bus_get_context_size(enum qdf_bus_type bus_type);
  199. void hif_read_phy_mem_base(struct hif_softc *scn, qdf_dma_addr_t *bar_value);
  200. uint32_t hif_get_conparam(struct hif_softc *scn);
  201. struct hif_driver_state_callbacks *hif_get_callbacks_handle(struct hif_softc *scn);
  202. bool hif_is_driver_unloading(struct hif_softc *scn);
  203. bool hif_is_load_or_unload_in_progress(struct hif_softc *scn);
  204. bool hif_is_recovery_in_progress(struct hif_softc *scn);
  205. void hif_wlan_disable(struct hif_softc *scn);
  206. int hif_target_sleep_state_adjust(struct hif_softc *scn,
  207. bool sleep_ok,
  208. bool wait_for_it);
  209. #ifdef HIF_USB
  210. void hif_usb_get_hw_info(struct hif_softc *scn);
  211. void hif_ramdump_handler(struct hif_opaque_softc *scn);
  212. #else
  213. static inline void hif_usb_get_hw_info(struct hif_softc *scn) {}
  214. static inline void hif_ramdump_handler(struct hif_opaque_softc *scn) {}
  215. #endif
  216. void hif_ext_grp_tasklet(unsigned long data);
  217. void hif_grp_tasklet_kill(struct hif_softc *scn);
  218. #endif /* __HIF_MAIN_H__ */