blob: bfc76650a0caf68a6c60ff67fe4a64c322f3eb1e [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 *
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/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
28#ifndef __CE_H__
29#define __CE_H__
30
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +053031#include "qdf_atomic.h"
32#include "qdf_lock.h"
Komal Seelam644263d2016-02-22 20:45:49 +053033#include "hif_main.h"
Nirav Shahb70bd732016-05-25 14:31:51 +053034#include "qdf_util.h"
Houston Hoffmandef86a32017-04-21 20:23:45 -070035#include "hif_exec.h"
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080036
37#define CE_HTT_T2H_MSG 1
38#define CE_HTT_H2T_MSG 4
39
Govind Singh2443fb32016-01-13 17:44:48 +053040#define CE_OFFSET 0x00000400
41#define CE_USEFUL_SIZE 0x00000058
Venkateswara Swamy Bandaru13164aa2016-09-20 20:24:54 +053042#define CE_ALL_BITMAP 0xFFFF
Govind Singh2443fb32016-01-13 17:44:48 +053043
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080044/**
45 * enum ce_id_type
46 *
47 * @ce_id_type: Copy engine ID
48 */
49enum ce_id_type {
50 CE_ID_0,
51 CE_ID_1,
52 CE_ID_2,
53 CE_ID_3,
54 CE_ID_4,
55 CE_ID_5,
56 CE_ID_6,
57 CE_ID_7,
58 CE_ID_8,
59 CE_ID_9,
60 CE_ID_10,
61 CE_ID_11,
62 CE_ID_MAX
63};
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080064
Houston Hoffmanabd00772016-05-06 17:02:48 -070065#ifdef CONFIG_WIN
Houston Hoffmanabd00772016-05-06 17:02:48 -070066#define QWLAN_VERSIONSTR "WIN"
67#endif
68
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080069enum ol_ath_hif_pkt_ecodes {
70 HIF_PIPE_NO_RESOURCE = 0
71};
72
73struct HIF_CE_state;
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080074
75/* Per-pipe state. */
76struct HIF_CE_pipe_info {
77 /* Handle of underlying Copy Engine */
78 struct CE_handle *ce_hdl;
79
80 /* Our pipe number; facilitiates use of pipe_info ptrs. */
81 uint8_t pipe_num;
82
83 /* Convenience back pointer to HIF_CE_state. */
84 struct HIF_CE_state *HIF_CE_state;
85
86 /* Instantaneous number of receive buffers that should be posted */
87 atomic_t recv_bufs_needed;
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +053088 qdf_size_t buf_sz;
89 qdf_spinlock_t recv_bufs_needed_lock;
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080090
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +053091 qdf_spinlock_t completion_freeq_lock;
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080092 /* Limit the number of outstanding send requests. */
93 int num_sends_allowed;
Houston Hoffman9c12f7f2015-09-28 16:52:14 -070094
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -080095 /* adding three counts for debugging ring buffer errors */
96 uint32_t nbuf_alloc_err_count;
97 uint32_t nbuf_dma_err_count;
98 uint32_t nbuf_ce_enqueue_err_count;
Venkateswara Swamy Bandaru26f6f1e2016-10-03 19:35:57 +053099 struct hif_msg_callbacks pipe_callbacks;
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800100};
101
102/**
103 * struct ce_tasklet_entry
104 *
105 * @intr_tq: intr_tq
106 * @ce_id: ce_id
107 * @inited: inited
108 * @hif_ce_state: hif_ce_state
109 * @from_irq: from_irq
110 */
111struct ce_tasklet_entry {
112 struct tasklet_struct intr_tq;
113 enum ce_id_type ce_id;
114 bool inited;
115 void *hif_ce_state;
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800116};
117
Houston Hoffmandef86a32017-04-21 20:23:45 -0700118static inline bool hif_dummy_grp_done(struct hif_exec_context *grp_entry, int
119 work_done)
120{
121 return true;
122}
123
124extern struct hif_execution_ops tasklet_sched_ops;
125extern struct hif_execution_ops napi_sched_ops;
Venkateswara Swamy Bandaru31108f32016-08-08 18:04:29 +0530126
Mohit Khanna518eb502016-10-06 19:58:02 -0700127struct ce_stats {
Nirav Shahb70bd732016-05-25 14:31:51 +0530128 uint32_t ce_per_cpu[CE_COUNT_MAX][QDF_MAX_AVAILABLE_CPU];
129};
130
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800131struct HIF_CE_state {
Komal Seelam644263d2016-02-22 20:45:49 +0530132 struct hif_softc ol_sc;
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800133 bool started;
134 struct ce_tasklet_entry tasklets[CE_COUNT_MAX];
Houston Hoffmandef86a32017-04-21 20:23:45 -0700135 struct hif_exec_context *hif_ext_group[HIF_MAX_GROUP];
Venkateswara Swamy Bandaru31108f32016-08-08 18:04:29 +0530136 uint32_t hif_num_extgroup;
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530137 qdf_spinlock_t keep_awake_lock;
Venkateswara Swamy Bandaru9fd9af02016-09-20 20:27:31 +0530138 qdf_spinlock_t irq_reg_lock;
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800139 unsigned int keep_awake_count;
140 bool verified_awake;
141 bool fake_sleep;
Chouhan, Anuragfc06aa92016-03-03 19:05:05 +0530142 qdf_timer_t sleep_timer;
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800143 bool sleep_timer_init;
Houston Hoffman2bfb82f2016-04-29 16:09:04 -0700144 qdf_time_t sleep_ticks;
Kiran Venkatappaa17e5e52016-12-20 11:32:06 +0530145 uint32_t ce_register_irq_done;
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800146
Venkateswara Swamy Bandaru13164aa2016-09-20 20:24:54 +0530147 struct CE_pipe_config *target_ce_config;
148 struct CE_attr *host_ce_config;
149 uint32_t target_ce_config_sz;
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800150 /* Per-pipe state. */
151 struct HIF_CE_pipe_info pipe_info[CE_COUNT_MAX];
152 /* to be activated after BMI_DONE */
153 struct hif_msg_callbacks msg_callbacks_pending;
154 /* current msg callbacks in use */
155 struct hif_msg_callbacks msg_callbacks_current;
156
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800157 /* Target address used to signal a pending firmware event */
158 uint32_t fw_indicator_address;
159
160 /* Copy Engine used for Diagnostic Accesses */
161 struct CE_handle *ce_diag;
Mohit Khanna518eb502016-10-06 19:58:02 -0700162 struct ce_stats stats;
Kiran Venkatappaf41ef2e2016-09-05 10:59:58 +0530163 struct ce_ops *ce_services;
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800164};
Govind Singh8f7a1ff2016-05-06 16:35:12 +0530165
166/*
167 * HIA Map Definition
168 */
169struct host_interest_area_t {
170 uint32_t hi_interconnect_state;
171 uint32_t hi_early_alloc;
172 uint32_t hi_option_flag2;
173 uint32_t hi_board_data;
174 uint32_t hi_board_data_initialized;
175 uint32_t hi_failure_state;
176 uint32_t hi_rddi_msi_num;
177 uint32_t hi_pcie_perst_couple_en;
178 uint32_t hi_sw_protocol_version;
179};
180
181struct shadow_reg_cfg {
182 uint16_t ce_id;
183 uint16_t reg_offset;
184};
185
Houston Hoffman5141f9d2017-01-05 10:49:17 -0800186struct shadow_reg_v2_cfg {
187 uint32_t reg_value;
188};
189
Poddar, Siddarthe41943f2016-04-27 15:33:48 +0530190void hif_ce_stop(struct hif_softc *scn);
Komal Seelam644263d2016-02-22 20:45:49 +0530191int hif_dump_ce_registers(struct hif_softc *scn);
Poddar, Siddarthe41943f2016-04-27 15:33:48 +0530192void
193hif_ce_dump_target_memory(struct hif_softc *scn, void *ramdump_base,
194 uint32_t address, uint32_t size);
Houston Hoffman854e67f2016-03-14 21:11:39 -0700195
Poddar, Siddarthe41943f2016-04-27 15:33:48 +0530196#ifdef IPA_OFFLOAD
197void hif_ce_ipa_get_ce_resource(struct hif_softc *scn,
198 qdf_dma_addr_t *ce_sr_base_paddr,
199 uint32_t *ce_sr_ring_size,
200 qdf_dma_addr_t *ce_reg_paddr);
201#else
202static inline
203void hif_ce_ipa_get_ce_resource(struct hif_softc *scn,
204 qdf_dma_addr_t *ce_sr_base_paddr,
205 uint32_t *ce_sr_ring_size,
206 qdf_dma_addr_t *ce_reg_paddr)
207{
Poddar, Siddarthe41943f2016-04-27 15:33:48 +0530208}
209
210#endif
Houston Hoffman854e67f2016-03-14 21:11:39 -0700211int hif_wlan_enable(struct hif_softc *scn);
212void hif_wlan_disable(struct hif_softc *scn);
Venkateswara Swamy Bandaru13164aa2016-09-20 20:24:54 +0530213void hif_get_target_ce_config(struct hif_softc *scn,
214 struct CE_pipe_config **target_ce_config_ret,
Houston Hoffman748e1a62017-03-30 17:20:42 -0700215 uint32_t *target_ce_config_sz_ret,
Houston Hoffman854e67f2016-03-14 21:11:39 -0700216 struct service_to_pipe **target_service_to_ce_map_ret,
Houston Hoffman748e1a62017-03-30 17:20:42 -0700217 uint32_t *target_service_to_ce_map_sz_ret,
Houston Hoffman5141f9d2017-01-05 10:49:17 -0800218 struct shadow_reg_cfg **target_shadow_reg_cfg_v1_ret,
Houston Hoffman748e1a62017-03-30 17:20:42 -0700219 uint32_t *shadow_cfg_v1_sz_ret);
Houston Hoffman5141f9d2017-01-05 10:49:17 -0800220
Nirav Shah0d0cce82018-01-17 17:00:31 +0530221#ifdef WLAN_FEATURE_EPPING
222void hif_ce_prepare_epping_config(struct HIF_CE_state *hif_state);
223void hif_select_epping_service_to_pipe_map(struct service_to_pipe
224 **tgt_svc_map_to_use,
225 uint32_t *sz_tgt_svc_map_to_use);
226
227#else
228static inline
229void hif_ce_prepare_epping_config(struct HIF_CE_state *hif_state)
230{ }
231static inline
232void hif_select_epping_service_to_pipe_map(struct service_to_pipe
233 **tgt_svc_map_to_use,
234 uint32_t *sz_tgt_svc_map_to_use)
235{ }
236#endif
237
Prakash Dhavalid5c9f1c2015-11-08 19:04:44 -0800238#endif /* __CE_H__ */