hif_main.h 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  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 QCA6290_EMULATION_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 RUMIM2M_DEVICE_ID_NODE0 0xabc0
  87. #define RUMIM2M_DEVICE_ID_NODE1 0xabc1
  88. #define HIF_GET_PCI_SOFTC(scn) ((struct hif_pci_softc *)scn)
  89. #define HIF_GET_CE_STATE(scn) ((struct HIF_CE_state *)scn)
  90. #define HIF_GET_SDIO_SOFTC(scn) ((struct hif_sdio_softc *)scn)
  91. #define HIF_GET_USB_SOFTC(scn) ((struct hif_usb_softc *)scn)
  92. #define HIF_GET_USB_DEVICE(scn) ((HIF_DEVICE_USB *)scn)
  93. #define HIF_GET_SOFTC(scn) ((struct hif_softc *)scn)
  94. #define GET_HIF_OPAQUE_HDL(scn) ((struct hif_opaque_softc *)scn)
  95. struct hif_ce_stats {
  96. int hif_pipe_no_resrc_count;
  97. int ce_ring_delta_fail_count;
  98. };
  99. #ifdef WLAN_SUSPEND_RESUME_TEST
  100. struct fake_apps_context {
  101. unsigned long state;
  102. hif_fake_resume_callback resume_callback;
  103. struct work_struct resume_work;
  104. };
  105. enum hif_fake_apps_state_bits {
  106. HIF_FA_SUSPENDED_BIT = 0
  107. };
  108. void hif_fake_apps_resume_work(struct work_struct *work);
  109. #endif /* WLAN_SUSPEND_RESUME_TEST */
  110. struct hif_softc {
  111. struct hif_opaque_softc osc;
  112. struct hif_config_info hif_config;
  113. struct hif_target_info target_info;
  114. void __iomem *mem;
  115. enum qdf_bus_type bus_type;
  116. struct hif_bus_ops bus_ops;
  117. void *ce_id_to_state[CE_COUNT_MAX];
  118. qdf_device_t qdf_dev;
  119. bool hif_init_done;
  120. bool request_irq_done;
  121. /* Packet statistics */
  122. struct hif_ce_stats pkt_stats;
  123. enum hif_target_status target_status;
  124. struct targetdef_s *targetdef;
  125. struct ce_reg_def *target_ce_def;
  126. struct hostdef_s *hostdef;
  127. struct host_shadow_regs_s *host_shadow_regs;
  128. bool recovery;
  129. bool notice_send;
  130. bool per_ce_irq;
  131. uint32_t ce_irq_summary;
  132. /* No of copy engines supported */
  133. unsigned int ce_count;
  134. atomic_t active_tasklet_cnt;
  135. atomic_t active_grp_tasklet_cnt;
  136. atomic_t link_suspended;
  137. uint32_t *vaddr_rri_on_ddr;
  138. int linkstate_vote;
  139. bool fastpath_mode_on;
  140. atomic_t tasklet_from_intr;
  141. int htc_htt_tx_endpoint;
  142. qdf_dma_addr_t mem_pa;
  143. bool athdiag_procfs_inited;
  144. #ifdef FEATURE_NAPI
  145. struct qca_napi_data napi_data;
  146. #endif /* FEATURE_NAPI */
  147. struct hif_driver_state_callbacks callbacks;
  148. uint32_t hif_con_param;
  149. #ifdef QCA_NSS_WIFI_OFFLOAD_SUPPORT
  150. uint32_t nss_wifi_ol_mode;
  151. #endif
  152. void *hal_soc;
  153. #ifdef WLAN_SUSPEND_RESUME_TEST
  154. struct fake_apps_context fake_apps_ctx;
  155. #endif /* WLAN_SUSPEND_RESUME_TEST */
  156. uint32_t hif_attribute;
  157. };
  158. static inline void *hif_get_hal_handle(void *hif_hdl)
  159. {
  160. struct hif_softc *sc = (struct hif_softc *)hif_hdl;
  161. return sc->hal_soc;
  162. }
  163. #ifdef QCA_NSS_WIFI_OFFLOAD_SUPPORT
  164. static inline bool hif_is_nss_wifi_enabled(struct hif_softc *sc)
  165. {
  166. return !!(sc->nss_wifi_ol_mode);
  167. }
  168. #else
  169. static inline bool hif_is_nss_wifi_enabled(struct hif_softc *sc)
  170. {
  171. return false;
  172. }
  173. #endif
  174. static inline uint8_t hif_is_attribute_set(struct hif_softc *sc,
  175. uint32_t hif_attrib)
  176. {
  177. return sc->hif_attribute == hif_attrib;
  178. }
  179. A_target_id_t hif_get_target_id(struct hif_softc *scn);
  180. void hif_dump_pipe_debug_count(struct hif_softc *scn);
  181. void hif_display_bus_stats(struct hif_opaque_softc *scn);
  182. void hif_clear_bus_stats(struct hif_opaque_softc *scn);
  183. bool hif_max_num_receives_reached(struct hif_softc *scn, unsigned int count);
  184. void hif_shutdown_device(struct hif_opaque_softc *hif_ctx);
  185. int hif_bus_configure(struct hif_softc *scn);
  186. void hif_cancel_deferred_target_sleep(struct hif_softc *scn);
  187. int hif_config_ce(struct hif_softc *scn);
  188. void hif_unconfig_ce(struct hif_softc *scn);
  189. void hif_ce_prepare_config(struct hif_softc *scn);
  190. QDF_STATUS hif_ce_open(struct hif_softc *scn);
  191. void hif_ce_close(struct hif_softc *scn);
  192. int athdiag_procfs_init(void *scn);
  193. void athdiag_procfs_remove(void);
  194. /* routine to modify the initial buffer count to be allocated on an os
  195. * platform basis. Platform owner will need to modify this as needed
  196. */
  197. qdf_size_t init_buffer_count(qdf_size_t maxSize);
  198. irqreturn_t hif_fw_interrupt_handler(int irq, void *arg);
  199. int hif_get_device_type(uint32_t device_id,
  200. uint32_t revision_id,
  201. uint32_t *hif_type, uint32_t *target_type);
  202. /*These functions are exposed to HDD*/
  203. void hif_nointrs(struct hif_softc *scn);
  204. void hif_bus_close(struct hif_softc *ol_sc);
  205. QDF_STATUS hif_bus_open(struct hif_softc *ol_sc,
  206. enum qdf_bus_type bus_type);
  207. QDF_STATUS hif_enable_bus(struct hif_softc *ol_sc, struct device *dev,
  208. void *bdev, const hif_bus_id *bid, enum hif_enable_type type);
  209. void hif_disable_bus(struct hif_softc *scn);
  210. void hif_bus_prevent_linkdown(struct hif_softc *scn, bool flag);
  211. int hif_bus_get_context_size(enum qdf_bus_type bus_type);
  212. void hif_read_phy_mem_base(struct hif_softc *scn, qdf_dma_addr_t *bar_value);
  213. uint32_t hif_get_conparam(struct hif_softc *scn);
  214. struct hif_driver_state_callbacks *hif_get_callbacks_handle(struct hif_softc *scn);
  215. bool hif_is_driver_unloading(struct hif_softc *scn);
  216. bool hif_is_load_or_unload_in_progress(struct hif_softc *scn);
  217. bool hif_is_recovery_in_progress(struct hif_softc *scn);
  218. void hif_wlan_disable(struct hif_softc *scn);
  219. int hif_target_sleep_state_adjust(struct hif_softc *scn,
  220. bool sleep_ok,
  221. bool wait_for_it);
  222. int hif_get_rx_ctx_id(int ctx_id, struct hif_opaque_softc *hif_hdl);
  223. #ifdef HIF_USB
  224. void hif_usb_get_hw_info(struct hif_softc *scn);
  225. void hif_ramdump_handler(struct hif_opaque_softc *scn);
  226. #else
  227. static inline void hif_usb_get_hw_info(struct hif_softc *scn) {}
  228. static inline void hif_ramdump_handler(struct hif_opaque_softc *scn) {}
  229. #endif
  230. void hif_ext_grp_tasklet(unsigned long data);
  231. void hif_grp_tasklet_kill(struct hif_softc *scn);
  232. #endif /* __HIF_MAIN_H__ */