blob: 75342a247c78d9e0ac1eeb3d49607a9773e766aa [file] [log] [blame]
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -08001/*
Nirav Shah0d0cce82018-01-17 17:00:31 +05302 * Copyright (c) 2015-2018 The Linux Foundation. All rights reserved.
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -08003 *
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -08004 * 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
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080019#ifndef __CE_H__
20#define __CE_H__
21
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +053022#include "qdf_atomic.h"
23#include "qdf_lock.h"
Komal Seelam644263d2016-02-22 20:45:49 +053024#include "hif_main.h"
Nirav Shahb70bd732016-05-25 14:31:51 +053025#include "qdf_util.h"
Houston Hoffmandef86a32017-04-21 20:23:45 -070026#include "hif_exec.h"
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080027
28#define CE_HTT_T2H_MSG 1
29#define CE_HTT_H2T_MSG 4
30
Govind Singh2443fb32016-01-13 17:44:48 +053031#define CE_OFFSET 0x00000400
32#define CE_USEFUL_SIZE 0x00000058
Venkateswara Swamy Bandaru13164aa2016-09-20 20:24:54 +053033#define CE_ALL_BITMAP 0xFFFF
Govind Singh2443fb32016-01-13 17:44:48 +053034
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080035/**
36 * enum ce_id_type
37 *
38 * @ce_id_type: Copy engine ID
39 */
40enum 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};
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080055
Houston Hoffmanabd00772016-05-06 17:02:48 -070056#ifdef CONFIG_WIN
Houston Hoffmanabd00772016-05-06 17:02:48 -070057#define QWLAN_VERSIONSTR "WIN"
58#endif
59
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080060enum ol_ath_hif_pkt_ecodes {
61 HIF_PIPE_NO_RESOURCE = 0
62};
63
64struct HIF_CE_state;
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080065
66/* Per-pipe state. */
67struct HIF_CE_pipe_info {
68 /* Handle of underlying Copy Engine */
69 struct CE_handle *ce_hdl;
70
71 /* Our pipe number; facilitiates use of pipe_info ptrs. */
72 uint8_t pipe_num;
73
74 /* Convenience back pointer to HIF_CE_state. */
75 struct HIF_CE_state *HIF_CE_state;
76
77 /* Instantaneous number of receive buffers that should be posted */
78 atomic_t recv_bufs_needed;
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +053079 qdf_size_t buf_sz;
80 qdf_spinlock_t recv_bufs_needed_lock;
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080081
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +053082 qdf_spinlock_t completion_freeq_lock;
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080083 /* Limit the number of outstanding send requests. */
84 int num_sends_allowed;
Houston Hoffman9c12f7f2015-09-28 16:52:14 -070085
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080086 /* adding three counts for debugging ring buffer errors */
87 uint32_t nbuf_alloc_err_count;
88 uint32_t nbuf_dma_err_count;
89 uint32_t nbuf_ce_enqueue_err_count;
Venkateswara Swamy Bandaru26f6f1e2016-10-03 19:35:57 +053090 struct hif_msg_callbacks pipe_callbacks;
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080091};
92
93/**
94 * struct ce_tasklet_entry
95 *
96 * @intr_tq: intr_tq
97 * @ce_id: ce_id
98 * @inited: inited
99 * @hif_ce_state: hif_ce_state
100 * @from_irq: from_irq
101 */
102struct ce_tasklet_entry {
103 struct tasklet_struct intr_tq;
104 enum ce_id_type ce_id;
105 bool inited;
106 void *hif_ce_state;
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800107};
108
Houston Hoffmandef86a32017-04-21 20:23:45 -0700109static inline bool hif_dummy_grp_done(struct hif_exec_context *grp_entry, int
110 work_done)
111{
112 return true;
113}
114
115extern struct hif_execution_ops tasklet_sched_ops;
116extern struct hif_execution_ops napi_sched_ops;
Venkateswara Swamy Bandaru31108f32016-08-08 18:04:29 +0530117
Mohit Khanna518eb502016-10-06 19:58:02 -0700118struct ce_stats {
Nirav Shahb70bd732016-05-25 14:31:51 +0530119 uint32_t ce_per_cpu[CE_COUNT_MAX][QDF_MAX_AVAILABLE_CPU];
120};
121
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800122struct HIF_CE_state {
Komal Seelam644263d2016-02-22 20:45:49 +0530123 struct hif_softc ol_sc;
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800124 bool started;
125 struct ce_tasklet_entry tasklets[CE_COUNT_MAX];
Houston Hoffmandef86a32017-04-21 20:23:45 -0700126 struct hif_exec_context *hif_ext_group[HIF_MAX_GROUP];
Venkateswara Swamy Bandaru31108f32016-08-08 18:04:29 +0530127 uint32_t hif_num_extgroup;
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530128 qdf_spinlock_t keep_awake_lock;
Venkateswara Swamy Bandaru9fd9af02016-09-20 20:27:31 +0530129 qdf_spinlock_t irq_reg_lock;
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800130 unsigned int keep_awake_count;
131 bool verified_awake;
132 bool fake_sleep;
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530133 qdf_timer_t sleep_timer;
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800134 bool sleep_timer_init;
Houston Hoffman2bfb82f2016-04-29 16:09:04 -0700135 qdf_time_t sleep_ticks;
Kiran Venkatappaa17e5e52016-12-20 11:32:06 +0530136 uint32_t ce_register_irq_done;
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800137
Venkateswara Swamy Bandaru13164aa2016-09-20 20:24:54 +0530138 struct CE_pipe_config *target_ce_config;
139 struct CE_attr *host_ce_config;
140 uint32_t target_ce_config_sz;
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800141 /* Per-pipe state. */
142 struct HIF_CE_pipe_info pipe_info[CE_COUNT_MAX];
143 /* to be activated after BMI_DONE */
144 struct hif_msg_callbacks msg_callbacks_pending;
145 /* current msg callbacks in use */
146 struct hif_msg_callbacks msg_callbacks_current;
147
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800148 /* Target address used to signal a pending firmware event */
149 uint32_t fw_indicator_address;
150
151 /* Copy Engine used for Diagnostic Accesses */
152 struct CE_handle *ce_diag;
Mohit Khanna518eb502016-10-06 19:58:02 -0700153 struct ce_stats stats;
Kiran Venkatappaf41ef2e2016-09-05 10:59:58 +0530154 struct ce_ops *ce_services;
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800155};
Govind Singh8f7a1ff2016-05-06 16:35:12 +0530156
157/*
158 * HIA Map Definition
159 */
160struct host_interest_area_t {
161 uint32_t hi_interconnect_state;
162 uint32_t hi_early_alloc;
163 uint32_t hi_option_flag2;
164 uint32_t hi_board_data;
165 uint32_t hi_board_data_initialized;
166 uint32_t hi_failure_state;
167 uint32_t hi_rddi_msi_num;
168 uint32_t hi_pcie_perst_couple_en;
169 uint32_t hi_sw_protocol_version;
170};
171
172struct shadow_reg_cfg {
173 uint16_t ce_id;
174 uint16_t reg_offset;
175};
176
Houston Hoffman5141f9d2017-01-05 10:49:17 -0800177struct shadow_reg_v2_cfg {
178 uint32_t reg_value;
179};
180
Poddar, Siddarthe41943f2016-04-27 15:33:48 +0530181void hif_ce_stop(struct hif_softc *scn);
Komal Seelam644263d2016-02-22 20:45:49 +0530182int hif_dump_ce_registers(struct hif_softc *scn);
Poddar, Siddarthe41943f2016-04-27 15:33:48 +0530183void
184hif_ce_dump_target_memory(struct hif_softc *scn, void *ramdump_base,
185 uint32_t address, uint32_t size);
Houston Hoffman854e67f2016-03-14 21:11:39 -0700186
Poddar, Siddarthe41943f2016-04-27 15:33:48 +0530187#ifdef IPA_OFFLOAD
188void hif_ce_ipa_get_ce_resource(struct hif_softc *scn,
Sravan Kumar Kairam58e0adf2018-02-27 18:37:40 +0530189 qdf_shared_mem_t **ce_sr,
Poddar, Siddarthe41943f2016-04-27 15:33:48 +0530190 uint32_t *ce_sr_ring_size,
191 qdf_dma_addr_t *ce_reg_paddr);
192#else
193static inline
194void hif_ce_ipa_get_ce_resource(struct hif_softc *scn,
Sravan Kumar Kairam58e0adf2018-02-27 18:37:40 +0530195 qdf_shared_mem_t **ce_sr,
Poddar, Siddarthe41943f2016-04-27 15:33:48 +0530196 uint32_t *ce_sr_ring_size,
197 qdf_dma_addr_t *ce_reg_paddr)
198{
Poddar, Siddarthe41943f2016-04-27 15:33:48 +0530199}
200
201#endif
Houston Hoffman854e67f2016-03-14 21:11:39 -0700202int hif_wlan_enable(struct hif_softc *scn);
Nandha Kishore Easwaran7cdaae22018-07-30 15:02:51 +0530203void ce_enable_polling(void *cestate);
204void ce_disable_polling(void *cestate);
Houston Hoffman854e67f2016-03-14 21:11:39 -0700205void hif_wlan_disable(struct hif_softc *scn);
Venkateswara Swamy Bandaru13164aa2016-09-20 20:24:54 +0530206void hif_get_target_ce_config(struct hif_softc *scn,
207 struct CE_pipe_config **target_ce_config_ret,
Houston Hoffman748e1a62017-03-30 17:20:42 -0700208 uint32_t *target_ce_config_sz_ret,
Houston Hoffman854e67f2016-03-14 21:11:39 -0700209 struct service_to_pipe **target_service_to_ce_map_ret,
Houston Hoffman748e1a62017-03-30 17:20:42 -0700210 uint32_t *target_service_to_ce_map_sz_ret,
Houston Hoffman5141f9d2017-01-05 10:49:17 -0800211 struct shadow_reg_cfg **target_shadow_reg_cfg_v1_ret,
Houston Hoffman748e1a62017-03-30 17:20:42 -0700212 uint32_t *shadow_cfg_v1_sz_ret);
Houston Hoffman5141f9d2017-01-05 10:49:17 -0800213
Nirav Shah0d0cce82018-01-17 17:00:31 +0530214#ifdef WLAN_FEATURE_EPPING
215void hif_ce_prepare_epping_config(struct HIF_CE_state *hif_state);
216void hif_select_epping_service_to_pipe_map(struct service_to_pipe
217 **tgt_svc_map_to_use,
218 uint32_t *sz_tgt_svc_map_to_use);
219
220#else
221static inline
222void hif_ce_prepare_epping_config(struct HIF_CE_state *hif_state)
223{ }
224static inline
225void hif_select_epping_service_to_pipe_map(struct service_to_pipe
226 **tgt_svc_map_to_use,
227 uint32_t *sz_tgt_svc_map_to_use)
228{ }
229#endif
230
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800231#endif /* __CE_H__ */