1 /* 2 * Copyright (c) 2015-2018 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 19 #ifndef __CE_H__ 20 #define __CE_H__ 21 22 #include "qdf_atomic.h" 23 #include "qdf_lock.h" 24 #include "hif_main.h" 25 #include "qdf_util.h" 26 #include "hif_exec.h" 27 28 #define CE_HTT_T2H_MSG 1 29 #define CE_HTT_H2T_MSG 4 30 31 #define CE_OFFSET 0x00000400 32 #define CE_USEFUL_SIZE 0x00000058 33 #define CE_ALL_BITMAP 0xFFFF 34 35 /** 36 * enum ce_id_type 37 * 38 * @ce_id_type: Copy engine ID 39 */ 40 enum ce_id_type { 41 CE_ID_0, 42 CE_ID_1, 43 CE_ID_2, 44 CE_ID_3, 45 CE_ID_4, 46 CE_ID_5, 47 CE_ID_6, 48 CE_ID_7, 49 CE_ID_8, 50 CE_ID_9, 51 CE_ID_10, 52 CE_ID_11, 53 CE_ID_MAX 54 }; 55 56 enum ce_target_type { 57 CE_SVC_LEGACY, 58 CE_SVC_SRNG, 59 CE_MAX_TARGET_TYPE 60 }; 61 62 #ifdef CONFIG_WIN 63 #define QWLAN_VERSIONSTR "WIN" 64 #endif 65 66 enum ol_ath_hif_pkt_ecodes { 67 HIF_PIPE_NO_RESOURCE = 0 68 }; 69 70 struct HIF_CE_state; 71 72 /* Per-pipe state. */ 73 struct HIF_CE_pipe_info { 74 /* Handle of underlying Copy Engine */ 75 struct CE_handle *ce_hdl; 76 77 /* Our pipe number; facilitiates use of pipe_info ptrs. */ 78 uint8_t pipe_num; 79 80 /* Convenience back pointer to HIF_CE_state. */ 81 struct HIF_CE_state *HIF_CE_state; 82 83 /* Instantaneous number of receive buffers that should be posted */ 84 atomic_t recv_bufs_needed; 85 qdf_size_t buf_sz; 86 qdf_spinlock_t recv_bufs_needed_lock; 87 88 qdf_spinlock_t completion_freeq_lock; 89 /* Limit the number of outstanding send requests. */ 90 int num_sends_allowed; 91 92 /* adding three counts for debugging ring buffer errors */ 93 uint32_t nbuf_alloc_err_count; 94 uint32_t nbuf_dma_err_count; 95 uint32_t nbuf_ce_enqueue_err_count; 96 struct hif_msg_callbacks pipe_callbacks; 97 }; 98 99 /** 100 * struct ce_tasklet_entry 101 * 102 * @intr_tq: intr_tq 103 * @ce_id: ce_id 104 * @inited: inited 105 * @hif_ce_state: hif_ce_state 106 * @from_irq: from_irq 107 */ 108 struct ce_tasklet_entry { 109 struct tasklet_struct intr_tq; 110 enum ce_id_type ce_id; 111 bool inited; 112 void *hif_ce_state; 113 }; 114 115 static inline bool hif_dummy_grp_done(struct hif_exec_context *grp_entry, int 116 work_done) 117 { 118 return true; 119 } 120 121 extern struct hif_execution_ops tasklet_sched_ops; 122 extern struct hif_execution_ops napi_sched_ops; 123 124 struct ce_stats { 125 uint32_t ce_per_cpu[CE_COUNT_MAX][QDF_MAX_AVAILABLE_CPU]; 126 }; 127 128 struct HIF_CE_state { 129 struct hif_softc ol_sc; 130 bool started; 131 struct ce_tasklet_entry tasklets[CE_COUNT_MAX]; 132 struct hif_exec_context *hif_ext_group[HIF_MAX_GROUP]; 133 uint32_t hif_num_extgroup; 134 qdf_spinlock_t keep_awake_lock; 135 qdf_spinlock_t irq_reg_lock; 136 unsigned int keep_awake_count; 137 bool verified_awake; 138 bool fake_sleep; 139 qdf_timer_t sleep_timer; 140 bool sleep_timer_init; 141 qdf_time_t sleep_ticks; 142 uint32_t ce_register_irq_done; 143 144 struct CE_pipe_config *target_ce_config; 145 struct CE_attr *host_ce_config; 146 uint32_t target_ce_config_sz; 147 /* Per-pipe state. */ 148 struct HIF_CE_pipe_info pipe_info[CE_COUNT_MAX]; 149 /* to be activated after BMI_DONE */ 150 struct hif_msg_callbacks msg_callbacks_pending; 151 /* current msg callbacks in use */ 152 struct hif_msg_callbacks msg_callbacks_current; 153 154 /* Target address used to signal a pending firmware event */ 155 uint32_t fw_indicator_address; 156 157 /* Copy Engine used for Diagnostic Accesses */ 158 struct CE_handle *ce_diag; 159 struct ce_stats stats; 160 struct ce_ops *ce_services; 161 }; 162 163 /* 164 * HIA Map Definition 165 */ 166 struct host_interest_area_t { 167 uint32_t hi_interconnect_state; 168 uint32_t hi_early_alloc; 169 uint32_t hi_option_flag2; 170 uint32_t hi_board_data; 171 uint32_t hi_board_data_initialized; 172 uint32_t hi_failure_state; 173 uint32_t hi_rddi_msi_num; 174 uint32_t hi_pcie_perst_couple_en; 175 uint32_t hi_sw_protocol_version; 176 }; 177 178 struct shadow_reg_cfg { 179 uint16_t ce_id; 180 uint16_t reg_offset; 181 }; 182 183 struct shadow_reg_v2_cfg { 184 uint32_t reg_value; 185 }; 186 187 void hif_ce_stop(struct hif_softc *scn); 188 int hif_dump_ce_registers(struct hif_softc *scn); 189 void 190 hif_ce_dump_target_memory(struct hif_softc *scn, void *ramdump_base, 191 uint32_t address, uint32_t size); 192 193 #ifdef IPA_OFFLOAD 194 void hif_ce_ipa_get_ce_resource(struct hif_softc *scn, 195 qdf_shared_mem_t **ce_sr, 196 uint32_t *ce_sr_ring_size, 197 qdf_dma_addr_t *ce_reg_paddr); 198 #else 199 static inline 200 void hif_ce_ipa_get_ce_resource(struct hif_softc *scn, 201 qdf_shared_mem_t **ce_sr, 202 uint32_t *ce_sr_ring_size, 203 qdf_dma_addr_t *ce_reg_paddr) 204 { 205 } 206 207 #endif 208 int hif_wlan_enable(struct hif_softc *scn); 209 void ce_enable_polling(void *cestate); 210 void ce_disable_polling(void *cestate); 211 void hif_wlan_disable(struct hif_softc *scn); 212 void hif_get_target_ce_config(struct hif_softc *scn, 213 struct CE_pipe_config **target_ce_config_ret, 214 uint32_t *target_ce_config_sz_ret, 215 struct service_to_pipe **target_service_to_ce_map_ret, 216 uint32_t *target_service_to_ce_map_sz_ret, 217 struct shadow_reg_cfg **target_shadow_reg_cfg_v1_ret, 218 uint32_t *shadow_cfg_v1_sz_ret); 219 220 #ifdef WLAN_FEATURE_EPPING 221 void hif_ce_prepare_epping_config(struct HIF_CE_state *hif_state); 222 void hif_select_epping_service_to_pipe_map(struct service_to_pipe 223 **tgt_svc_map_to_use, 224 uint32_t *sz_tgt_svc_map_to_use); 225 226 #else 227 static inline 228 void hif_ce_prepare_epping_config(struct HIF_CE_state *hif_state) 229 { } 230 static inline 231 void hif_select_epping_service_to_pipe_map(struct service_to_pipe 232 **tgt_svc_map_to_use, 233 uint32_t *sz_tgt_svc_map_to_use) 234 { } 235 #endif 236 237 void ce_service_register_module(enum ce_target_type target_type, 238 struct ce_ops* (*ce_attach)(void)); 239 240 #endif /* __CE_H__ */ 241