1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18#ifndef _CE_H_
19#define _CE_H_
20
21#include "hif.h"
22
23#define CE_HTT_H2T_MSG_SRC_NENTRIES 8192
24
25
26#define CE_DESC_RING_ALIGN 8
27#define CE_SEND_FLAG_GATHER 0x00010000
28
29
30
31
32
33
34
35struct ath10k_ce_pipe;
36
37#define CE_DESC_FLAGS_GATHER (1 << 0)
38#define CE_DESC_FLAGS_BYTE_SWAP (1 << 1)
39
40
41#define CE_DESC_FLAGS_HOST_INT_DIS (1 << 2)
42#define CE_DESC_FLAGS_TGT_INT_DIS (1 << 3)
43
44#define CE_DESC_FLAGS_META_DATA_MASK ar->hw_values->ce_desc_meta_data_mask
45#define CE_DESC_FLAGS_META_DATA_LSB ar->hw_values->ce_desc_meta_data_lsb
46
47struct ce_desc {
48 __le32 addr;
49 __le16 nbytes;
50 __le16 flags;
51};
52
53struct ath10k_ce_ring {
54
55 unsigned int nentries;
56 unsigned int nentries_mask;
57
58
59
60
61
62
63
64
65
66
67
68
69 unsigned int sw_index;
70
71 unsigned int write_index;
72
73
74
75
76
77
78
79
80
81
82
83 unsigned int hw_index;
84
85
86
87 void *base_addr_owner_space_unaligned;
88
89 u32 base_addr_ce_space_unaligned;
90
91
92
93
94
95
96
97 void *base_addr_owner_space;
98
99
100 u32 base_addr_ce_space;
101
102
103 void *per_transfer_context[0];
104};
105
106struct ath10k_ce_pipe {
107 struct ath10k *ar;
108 unsigned int id;
109
110 unsigned int attr_flags;
111
112 u32 ctrl_addr;
113
114 void (*send_cb)(struct ath10k_ce_pipe *);
115 void (*recv_cb)(struct ath10k_ce_pipe *);
116
117 unsigned int src_sz_max;
118 struct ath10k_ce_ring *src_ring;
119 struct ath10k_ce_ring *dest_ring;
120};
121
122
123struct ce_attr;
124
125struct ath10k_bus_ops {
126 u32 (*read32)(struct ath10k *ar, u32 offset);
127 void (*write32)(struct ath10k *ar, u32 offset, u32 value);
128 int (*get_num_banks)(struct ath10k *ar);
129};
130
131static inline struct ath10k_ce *ath10k_ce_priv(struct ath10k *ar)
132{
133 return (struct ath10k_ce *)ar->ce_priv;
134}
135
136struct ath10k_ce {
137
138 spinlock_t ce_lock;
139 const struct ath10k_bus_ops *bus_ops;
140 struct ath10k_ce_pipe ce_states[CE_COUNT_MAX];
141};
142
143
144
145
146#define CE_SEND_FLAG_BYTE_SWAP 1
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161int ath10k_ce_send(struct ath10k_ce_pipe *ce_state,
162 void *per_transfer_send_context,
163 u32 buffer,
164 unsigned int nbytes,
165
166 unsigned int transfer_id,
167 unsigned int flags);
168
169int ath10k_ce_send_nolock(struct ath10k_ce_pipe *ce_state,
170 void *per_transfer_context,
171 u32 buffer,
172 unsigned int nbytes,
173 unsigned int transfer_id,
174 unsigned int flags);
175
176void __ath10k_ce_send_revert(struct ath10k_ce_pipe *pipe);
177
178int ath10k_ce_num_free_src_entries(struct ath10k_ce_pipe *pipe);
179
180
181
182int __ath10k_ce_rx_num_free_bufs(struct ath10k_ce_pipe *pipe);
183int __ath10k_ce_rx_post_buf(struct ath10k_ce_pipe *pipe, void *ctx, u32 paddr);
184int ath10k_ce_rx_post_buf(struct ath10k_ce_pipe *pipe, void *ctx, u32 paddr);
185void ath10k_ce_rx_update_write_idx(struct ath10k_ce_pipe *pipe, u32 nentries);
186
187
188
189#define CE_RECV_FLAG_SWAPPED 1
190
191
192
193
194
195int ath10k_ce_completed_recv_next(struct ath10k_ce_pipe *ce_state,
196 void **per_transfer_contextp,
197 unsigned int *nbytesp);
198
199
200
201
202int ath10k_ce_completed_send_next(struct ath10k_ce_pipe *ce_state,
203 void **per_transfer_contextp);
204
205int ath10k_ce_completed_send_next_nolock(struct ath10k_ce_pipe *ce_state,
206 void **per_transfer_contextp);
207
208
209
210int ath10k_ce_init_pipe(struct ath10k *ar, unsigned int ce_id,
211 const struct ce_attr *attr);
212void ath10k_ce_deinit_pipe(struct ath10k *ar, unsigned int ce_id);
213int ath10k_ce_alloc_pipe(struct ath10k *ar, int ce_id,
214 const struct ce_attr *attr);
215void ath10k_ce_free_pipe(struct ath10k *ar, int ce_id);
216
217
218
219
220
221
222
223int ath10k_ce_revoke_recv_next(struct ath10k_ce_pipe *ce_state,
224 void **per_transfer_contextp,
225 u32 *bufferp);
226
227int ath10k_ce_completed_recv_next_nolock(struct ath10k_ce_pipe *ce_state,
228 void **per_transfer_contextp,
229 unsigned int *nbytesp);
230
231
232
233
234
235
236int ath10k_ce_cancel_send_next(struct ath10k_ce_pipe *ce_state,
237 void **per_transfer_contextp,
238 u32 *bufferp,
239 unsigned int *nbytesp,
240 unsigned int *transfer_idp);
241
242
243void ath10k_ce_per_engine_service_any(struct ath10k *ar);
244void ath10k_ce_per_engine_service(struct ath10k *ar, unsigned int ce_id);
245int ath10k_ce_disable_interrupts(struct ath10k *ar);
246void ath10k_ce_enable_interrupts(struct ath10k *ar);
247void ath10k_ce_dump_registers(struct ath10k *ar,
248 struct ath10k_fw_crash_data *crash_data);
249
250
251
252#define CE_ATTR_NO_SNOOP 1
253
254
255#define CE_ATTR_BYTE_SWAP_DATA 2
256
257
258#define CE_ATTR_SWIZZLE_DESCRIPTORS 4
259
260
261#define CE_ATTR_DIS_INTR 8
262
263
264struct ce_attr {
265
266 unsigned int flags;
267
268
269 unsigned int src_nentries;
270
271
272
273
274
275 unsigned int src_sz_max;
276
277
278 unsigned int dest_nentries;
279
280 void (*send_cb)(struct ath10k_ce_pipe *);
281 void (*recv_cb)(struct ath10k_ce_pipe *);
282};
283
284static inline u32 ath10k_ce_base_address(struct ath10k *ar, unsigned int ce_id)
285{
286 return CE0_BASE_ADDRESS + (CE1_BASE_ADDRESS - CE0_BASE_ADDRESS) * ce_id;
287}
288
289#define CE_SRC_RING_TO_DESC(baddr, idx) \
290 (&(((struct ce_desc *)baddr)[idx]))
291
292#define CE_DEST_RING_TO_DESC(baddr, idx) \
293 (&(((struct ce_desc *)baddr)[idx]))
294
295
296#define CE_RING_DELTA(nentries_mask, fromidx, toidx) \
297 (((int)(toidx) - (int)(fromidx)) & (nentries_mask))
298
299#define CE_RING_IDX_INCR(nentries_mask, idx) (((idx) + 1) & (nentries_mask))
300#define CE_RING_IDX_ADD(nentries_mask, idx, num) \
301 (((idx) + (num)) & (nentries_mask))
302
303#define CE_WRAPPER_INTERRUPT_SUMMARY_HOST_MSI_LSB \
304 ar->regs->ce_wrap_intr_sum_host_msi_lsb
305#define CE_WRAPPER_INTERRUPT_SUMMARY_HOST_MSI_MASK \
306 ar->regs->ce_wrap_intr_sum_host_msi_mask
307#define CE_WRAPPER_INTERRUPT_SUMMARY_HOST_MSI_GET(x) \
308 (((x) & CE_WRAPPER_INTERRUPT_SUMMARY_HOST_MSI_MASK) >> \
309 CE_WRAPPER_INTERRUPT_SUMMARY_HOST_MSI_LSB)
310#define CE_WRAPPER_INTERRUPT_SUMMARY_ADDRESS 0x0000
311
312static inline u32 ath10k_ce_interrupt_summary(struct ath10k *ar)
313{
314 struct ath10k_ce *ce = ath10k_ce_priv(ar);
315
316 return CE_WRAPPER_INTERRUPT_SUMMARY_HOST_MSI_GET(
317 ce->bus_ops->read32((ar), CE_WRAPPER_BASE_ADDRESS +
318 CE_WRAPPER_INTERRUPT_SUMMARY_ADDRESS));
319}
320
321#endif
322