1
2
3
4
5
6
7
8#ifndef _CE_H_
9#define _CE_H_
10
11#include "hif.h"
12
13#define CE_HTT_H2T_MSG_SRC_NENTRIES 8192
14
15
16#define CE_DESC_RING_ALIGN 8
17#define CE_SEND_FLAG_GATHER 0x00010000
18
19
20
21
22
23
24
25struct ath10k_ce_pipe;
26
27#define CE_DESC_FLAGS_GATHER (1 << 0)
28#define CE_DESC_FLAGS_BYTE_SWAP (1 << 1)
29#define CE_WCN3990_DESC_FLAGS_GATHER BIT(31)
30
31#define CE_DESC_ADDR_MASK GENMASK_ULL(34, 0)
32#define CE_DESC_ADDR_HI_MASK GENMASK(4, 0)
33
34
35#define CE_DESC_FLAGS_HOST_INT_DIS (1 << 2)
36#define CE_DESC_FLAGS_TGT_INT_DIS (1 << 3)
37
38#define CE_DESC_FLAGS_META_DATA_MASK ar->hw_values->ce_desc_meta_data_mask
39#define CE_DESC_FLAGS_META_DATA_LSB ar->hw_values->ce_desc_meta_data_lsb
40
41#define CE_DDR_RRI_MASK GENMASK(15, 0)
42#define CE_DDR_DRRI_SHIFT 16
43
44struct ce_desc {
45 __le32 addr;
46 __le16 nbytes;
47 __le16 flags;
48};
49
50struct ce_desc_64 {
51 __le64 addr;
52 __le16 nbytes;
53 __le16 flags;
54 __le32 toeplitz_hash_result;
55};
56
57#define CE_DESC_SIZE sizeof(struct ce_desc)
58#define CE_DESC_SIZE_64 sizeof(struct ce_desc_64)
59
60struct ath10k_ce_ring {
61
62 unsigned int nentries;
63 unsigned int nentries_mask;
64
65
66
67
68
69
70
71
72
73
74
75
76 unsigned int sw_index;
77
78 unsigned int write_index;
79
80
81
82
83
84
85
86
87
88
89
90 unsigned int hw_index;
91
92
93
94 void *base_addr_owner_space_unaligned;
95
96 dma_addr_t base_addr_ce_space_unaligned;
97
98
99
100
101
102
103
104 void *base_addr_owner_space;
105
106
107 dma_addr_t base_addr_ce_space;
108
109 char *shadow_base_unaligned;
110 struct ce_desc_64 *shadow_base;
111
112
113 void *per_transfer_context[0];
114};
115
116struct ath10k_ce_pipe {
117 struct ath10k *ar;
118 unsigned int id;
119
120 unsigned int attr_flags;
121
122 u32 ctrl_addr;
123
124 void (*send_cb)(struct ath10k_ce_pipe *);
125 void (*recv_cb)(struct ath10k_ce_pipe *);
126
127 unsigned int src_sz_max;
128 struct ath10k_ce_ring *src_ring;
129 struct ath10k_ce_ring *dest_ring;
130 const struct ath10k_ce_ops *ops;
131};
132
133
134struct ce_attr;
135
136struct ath10k_bus_ops {
137 u32 (*read32)(struct ath10k *ar, u32 offset);
138 void (*write32)(struct ath10k *ar, u32 offset, u32 value);
139 int (*get_num_banks)(struct ath10k *ar);
140};
141
142static inline struct ath10k_ce *ath10k_ce_priv(struct ath10k *ar)
143{
144 return (struct ath10k_ce *)ar->ce_priv;
145}
146
147struct ath10k_ce {
148
149 spinlock_t ce_lock;
150 const struct ath10k_bus_ops *bus_ops;
151 struct ath10k_ce_pipe ce_states[CE_COUNT_MAX];
152 u32 *vaddr_rri;
153 dma_addr_t paddr_rri;
154};
155
156
157
158
159#define CE_SEND_FLAG_BYTE_SWAP 1
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174int ath10k_ce_send(struct ath10k_ce_pipe *ce_state,
175 void *per_transfer_send_context,
176 dma_addr_t buffer,
177 unsigned int nbytes,
178
179 unsigned int transfer_id,
180 unsigned int flags);
181
182int ath10k_ce_send_nolock(struct ath10k_ce_pipe *ce_state,
183 void *per_transfer_context,
184 dma_addr_t buffer,
185 unsigned int nbytes,
186 unsigned int transfer_id,
187 unsigned int flags);
188
189void __ath10k_ce_send_revert(struct ath10k_ce_pipe *pipe);
190
191int ath10k_ce_num_free_src_entries(struct ath10k_ce_pipe *pipe);
192
193
194
195int __ath10k_ce_rx_num_free_bufs(struct ath10k_ce_pipe *pipe);
196int ath10k_ce_rx_post_buf(struct ath10k_ce_pipe *pipe, void *ctx,
197 dma_addr_t paddr);
198void ath10k_ce_rx_update_write_idx(struct ath10k_ce_pipe *pipe, u32 nentries);
199
200
201
202#define CE_RECV_FLAG_SWAPPED 1
203
204
205
206
207
208int ath10k_ce_completed_recv_next(struct ath10k_ce_pipe *ce_state,
209 void **per_transfer_contextp,
210 unsigned int *nbytesp);
211
212
213
214
215int ath10k_ce_completed_send_next(struct ath10k_ce_pipe *ce_state,
216 void **per_transfer_contextp);
217
218int ath10k_ce_completed_send_next_nolock(struct ath10k_ce_pipe *ce_state,
219 void **per_transfer_contextp);
220
221
222
223int ath10k_ce_init_pipe(struct ath10k *ar, unsigned int ce_id,
224 const struct ce_attr *attr);
225void ath10k_ce_deinit_pipe(struct ath10k *ar, unsigned int ce_id);
226int ath10k_ce_alloc_pipe(struct ath10k *ar, int ce_id,
227 const struct ce_attr *attr);
228void ath10k_ce_free_pipe(struct ath10k *ar, int ce_id);
229
230
231
232
233
234
235
236int ath10k_ce_revoke_recv_next(struct ath10k_ce_pipe *ce_state,
237 void **per_transfer_contextp,
238 dma_addr_t *bufferp);
239
240int ath10k_ce_completed_recv_next_nolock(struct ath10k_ce_pipe *ce_state,
241 void **per_transfer_contextp,
242 unsigned int *nbytesp);
243
244
245
246
247
248
249int ath10k_ce_cancel_send_next(struct ath10k_ce_pipe *ce_state,
250 void **per_transfer_contextp,
251 dma_addr_t *bufferp,
252 unsigned int *nbytesp,
253 unsigned int *transfer_idp);
254
255
256void ath10k_ce_per_engine_service_any(struct ath10k *ar);
257void ath10k_ce_per_engine_service(struct ath10k *ar, unsigned int ce_id);
258int ath10k_ce_disable_interrupts(struct ath10k *ar);
259void ath10k_ce_enable_interrupts(struct ath10k *ar);
260void ath10k_ce_dump_registers(struct ath10k *ar,
261 struct ath10k_fw_crash_data *crash_data);
262void ath10k_ce_alloc_rri(struct ath10k *ar);
263void ath10k_ce_free_rri(struct ath10k *ar);
264
265
266
267#define CE_ATTR_NO_SNOOP BIT(0)
268
269
270#define CE_ATTR_BYTE_SWAP_DATA BIT(1)
271
272
273#define CE_ATTR_SWIZZLE_DESCRIPTORS BIT(2)
274
275
276#define CE_ATTR_DIS_INTR BIT(3)
277
278
279#define CE_ATTR_POLL BIT(4)
280
281
282struct ce_attr {
283
284 unsigned int flags;
285
286
287 unsigned int src_nentries;
288
289
290
291
292
293 unsigned int src_sz_max;
294
295
296 unsigned int dest_nentries;
297
298 void (*send_cb)(struct ath10k_ce_pipe *);
299 void (*recv_cb)(struct ath10k_ce_pipe *);
300};
301
302struct ath10k_ce_ops {
303 struct ath10k_ce_ring *(*ce_alloc_src_ring)(struct ath10k *ar,
304 u32 ce_id,
305 const struct ce_attr *attr);
306 struct ath10k_ce_ring *(*ce_alloc_dst_ring)(struct ath10k *ar,
307 u32 ce_id,
308 const struct ce_attr *attr);
309 int (*ce_rx_post_buf)(struct ath10k_ce_pipe *pipe, void *ctx,
310 dma_addr_t paddr);
311 int (*ce_completed_recv_next_nolock)(struct ath10k_ce_pipe *ce_state,
312 void **per_transfer_contextp,
313 u32 *nbytesp);
314 int (*ce_revoke_recv_next)(struct ath10k_ce_pipe *ce_state,
315 void **per_transfer_contextp,
316 dma_addr_t *nbytesp);
317 void (*ce_extract_desc_data)(struct ath10k *ar,
318 struct ath10k_ce_ring *src_ring,
319 u32 sw_index, dma_addr_t *bufferp,
320 u32 *nbytesp, u32 *transfer_idp);
321 void (*ce_free_pipe)(struct ath10k *ar, int ce_id);
322 int (*ce_send_nolock)(struct ath10k_ce_pipe *pipe,
323 void *per_transfer_context,
324 dma_addr_t buffer, u32 nbytes,
325 u32 transfer_id, u32 flags);
326 void (*ce_set_src_ring_base_addr_hi)(struct ath10k *ar,
327 u32 ce_ctrl_addr,
328 u64 addr);
329 void (*ce_set_dest_ring_base_addr_hi)(struct ath10k *ar,
330 u32 ce_ctrl_addr,
331 u64 addr);
332 int (*ce_completed_send_next_nolock)(struct ath10k_ce_pipe *ce_state,
333 void **per_transfer_contextp);
334};
335
336static inline u32 ath10k_ce_base_address(struct ath10k *ar, unsigned int ce_id)
337{
338 return CE0_BASE_ADDRESS + (CE1_BASE_ADDRESS - CE0_BASE_ADDRESS) * ce_id;
339}
340
341#define COPY_ENGINE_ID(COPY_ENGINE_BASE_ADDRESS) (((COPY_ENGINE_BASE_ADDRESS) \
342 - CE0_BASE_ADDRESS) / (CE1_BASE_ADDRESS - CE0_BASE_ADDRESS))
343
344#define CE_SRC_RING_TO_DESC(baddr, idx) \
345 (&(((struct ce_desc *)baddr)[idx]))
346
347#define CE_DEST_RING_TO_DESC(baddr, idx) \
348 (&(((struct ce_desc *)baddr)[idx]))
349
350#define CE_SRC_RING_TO_DESC_64(baddr, idx) \
351 (&(((struct ce_desc_64 *)baddr)[idx]))
352
353#define CE_DEST_RING_TO_DESC_64(baddr, idx) \
354 (&(((struct ce_desc_64 *)baddr)[idx]))
355
356
357#define CE_RING_DELTA(nentries_mask, fromidx, toidx) \
358 (((int)(toidx) - (int)(fromidx)) & (nentries_mask))
359
360#define CE_RING_IDX_INCR(nentries_mask, idx) (((idx) + 1) & (nentries_mask))
361#define CE_RING_IDX_ADD(nentries_mask, idx, num) \
362 (((idx) + (num)) & (nentries_mask))
363
364#define CE_WRAPPER_INTERRUPT_SUMMARY_HOST_MSI_LSB \
365 ar->regs->ce_wrap_intr_sum_host_msi_lsb
366#define CE_WRAPPER_INTERRUPT_SUMMARY_HOST_MSI_MASK \
367 ar->regs->ce_wrap_intr_sum_host_msi_mask
368#define CE_WRAPPER_INTERRUPT_SUMMARY_HOST_MSI_GET(x) \
369 (((x) & CE_WRAPPER_INTERRUPT_SUMMARY_HOST_MSI_MASK) >> \
370 CE_WRAPPER_INTERRUPT_SUMMARY_HOST_MSI_LSB)
371#define CE_WRAPPER_INTERRUPT_SUMMARY_ADDRESS 0x0000
372#define CE_INTERRUPT_SUMMARY (GENMASK(CE_COUNT_MAX - 1, 0))
373
374static inline u32 ath10k_ce_interrupt_summary(struct ath10k *ar)
375{
376 struct ath10k_ce *ce = ath10k_ce_priv(ar);
377
378 if (!ar->hw_params.per_ce_irq)
379 return CE_WRAPPER_INTERRUPT_SUMMARY_HOST_MSI_GET(
380 ce->bus_ops->read32((ar), CE_WRAPPER_BASE_ADDRESS +
381 CE_WRAPPER_INTERRUPT_SUMMARY_ADDRESS));
382 else
383 return CE_INTERRUPT_SUMMARY;
384}
385
386
387#define CE_ATTR_FLAGS 0
388
389
390
391
392
393
394
395struct ce_pipe_config {
396 __le32 pipenum;
397 __le32 pipedir;
398 __le32 nentries;
399 __le32 nbytes_max;
400 __le32 flags;
401 __le32 reserved;
402};
403
404
405
406
407
408
409
410
411
412
413
414
415
416#define PIPEDIR_NONE 0
417#define PIPEDIR_IN 1
418#define PIPEDIR_OUT 2
419#define PIPEDIR_INOUT 3
420
421
422struct service_to_pipe {
423 __le32 service_id;
424 __le32 pipedir;
425 __le32 pipenum;
426};
427
428#endif
429