diff options
Diffstat (limited to 'drivers/net/wireless/ath/ath10k/ce.h')
-rw-r--r-- | drivers/net/wireless/ath/ath10k/ce.h | 126 |
1 files changed, 21 insertions, 105 deletions
diff --git a/drivers/net/wireless/ath/ath10k/ce.h b/drivers/net/wireless/ath/ath10k/ce.h index c17f07c026f4..15d45b5b7615 100644 --- a/drivers/net/wireless/ath/ath10k/ce.h +++ b/drivers/net/wireless/ath/ath10k/ce.h | |||
@@ -27,7 +27,6 @@ | |||
27 | 27 | ||
28 | /* Descriptor rings must be aligned to this boundary */ | 28 | /* Descriptor rings must be aligned to this boundary */ |
29 | #define CE_DESC_RING_ALIGN 8 | 29 | #define CE_DESC_RING_ALIGN 8 |
30 | #define CE_SENDLIST_ITEMS_MAX 12 | ||
31 | #define CE_SEND_FLAG_GATHER 0x00010000 | 30 | #define CE_SEND_FLAG_GATHER 0x00010000 |
32 | 31 | ||
33 | /* | 32 | /* |
@@ -36,16 +35,9 @@ | |||
36 | * how to use copy engines. | 35 | * how to use copy engines. |
37 | */ | 36 | */ |
38 | 37 | ||
39 | struct ce_state; | 38 | struct ath10k_ce_pipe; |
40 | 39 | ||
41 | 40 | ||
42 | /* Copy Engine operational state */ | ||
43 | enum ce_op_state { | ||
44 | CE_UNUSED, | ||
45 | CE_PAUSED, | ||
46 | CE_RUNNING, | ||
47 | }; | ||
48 | |||
49 | #define CE_DESC_FLAGS_GATHER (1 << 0) | 41 | #define CE_DESC_FLAGS_GATHER (1 << 0) |
50 | #define CE_DESC_FLAGS_BYTE_SWAP (1 << 1) | 42 | #define CE_DESC_FLAGS_BYTE_SWAP (1 << 1) |
51 | #define CE_DESC_FLAGS_META_DATA_MASK 0xFFFC | 43 | #define CE_DESC_FLAGS_META_DATA_MASK 0xFFFC |
@@ -57,8 +49,7 @@ struct ce_desc { | |||
57 | __le16 flags; /* %CE_DESC_FLAGS_ */ | 49 | __le16 flags; /* %CE_DESC_FLAGS_ */ |
58 | }; | 50 | }; |
59 | 51 | ||
60 | /* Copy Engine Ring internal state */ | 52 | struct ath10k_ce_ring { |
61 | struct ce_ring_state { | ||
62 | /* Number of entries in this ring; must be power of 2 */ | 53 | /* Number of entries in this ring; must be power of 2 */ |
63 | unsigned int nentries; | 54 | unsigned int nentries; |
64 | unsigned int nentries_mask; | 55 | unsigned int nentries_mask; |
@@ -116,49 +107,20 @@ struct ce_ring_state { | |||
116 | void **per_transfer_context; | 107 | void **per_transfer_context; |
117 | }; | 108 | }; |
118 | 109 | ||
119 | /* Copy Engine internal state */ | 110 | struct ath10k_ce_pipe { |
120 | struct ce_state { | ||
121 | struct ath10k *ar; | 111 | struct ath10k *ar; |
122 | unsigned int id; | 112 | unsigned int id; |
123 | 113 | ||
124 | unsigned int attr_flags; | 114 | unsigned int attr_flags; |
125 | 115 | ||
126 | u32 ctrl_addr; | 116 | u32 ctrl_addr; |
127 | enum ce_op_state state; | ||
128 | |||
129 | void (*send_cb) (struct ce_state *ce_state, | ||
130 | void *per_transfer_send_context, | ||
131 | u32 buffer, | ||
132 | unsigned int nbytes, | ||
133 | unsigned int transfer_id); | ||
134 | void (*recv_cb) (struct ce_state *ce_state, | ||
135 | void *per_transfer_recv_context, | ||
136 | u32 buffer, | ||
137 | unsigned int nbytes, | ||
138 | unsigned int transfer_id, | ||
139 | unsigned int flags); | ||
140 | |||
141 | unsigned int src_sz_max; | ||
142 | struct ce_ring_state *src_ring; | ||
143 | struct ce_ring_state *dest_ring; | ||
144 | }; | ||
145 | 117 | ||
146 | struct ce_sendlist_item { | 118 | void (*send_cb)(struct ath10k_ce_pipe *); |
147 | /* e.g. buffer or desc list */ | 119 | void (*recv_cb)(struct ath10k_ce_pipe *); |
148 | dma_addr_t data; | ||
149 | union { | ||
150 | /* simple buffer */ | ||
151 | unsigned int nbytes; | ||
152 | /* Rx descriptor list */ | ||
153 | unsigned int ndesc; | ||
154 | } u; | ||
155 | /* externally-specified flags; OR-ed with internal flags */ | ||
156 | u32 flags; | ||
157 | }; | ||
158 | 120 | ||
159 | struct ce_sendlist { | 121 | unsigned int src_sz_max; |
160 | unsigned int num_items; | 122 | struct ath10k_ce_ring *src_ring; |
161 | struct ce_sendlist_item item[CE_SENDLIST_ITEMS_MAX]; | 123 | struct ath10k_ce_ring *dest_ring; |
162 | }; | 124 | }; |
163 | 125 | ||
164 | /* Copy Engine settable attributes */ | 126 | /* Copy Engine settable attributes */ |
@@ -182,7 +144,7 @@ struct ce_attr; | |||
182 | * | 144 | * |
183 | * Implementation note: pushes 1 buffer to Source ring | 145 | * Implementation note: pushes 1 buffer to Source ring |
184 | */ | 146 | */ |
185 | int ath10k_ce_send(struct ce_state *ce_state, | 147 | int ath10k_ce_send(struct ath10k_ce_pipe *ce_state, |
186 | void *per_transfer_send_context, | 148 | void *per_transfer_send_context, |
187 | u32 buffer, | 149 | u32 buffer, |
188 | unsigned int nbytes, | 150 | unsigned int nbytes, |
@@ -190,36 +152,11 @@ int ath10k_ce_send(struct ce_state *ce_state, | |||
190 | unsigned int transfer_id, | 152 | unsigned int transfer_id, |
191 | unsigned int flags); | 153 | unsigned int flags); |
192 | 154 | ||
193 | void ath10k_ce_send_cb_register(struct ce_state *ce_state, | 155 | void ath10k_ce_send_cb_register(struct ath10k_ce_pipe *ce_state, |
194 | void (*send_cb) (struct ce_state *ce_state, | 156 | void (*send_cb)(struct ath10k_ce_pipe *), |
195 | void *transfer_context, | ||
196 | u32 buffer, | ||
197 | unsigned int nbytes, | ||
198 | unsigned int transfer_id), | ||
199 | int disable_interrupts); | 157 | int disable_interrupts); |
200 | 158 | ||
201 | /* Append a simple buffer (address/length) to a sendlist. */ | 159 | int ath10k_ce_num_free_src_entries(struct ath10k_ce_pipe *pipe); |
202 | void ath10k_ce_sendlist_buf_add(struct ce_sendlist *sendlist, | ||
203 | u32 buffer, | ||
204 | unsigned int nbytes, | ||
205 | /* OR-ed with internal flags */ | ||
206 | u32 flags); | ||
207 | |||
208 | /* | ||
209 | * Queue a "sendlist" of buffers to be sent using gather to a single | ||
210 | * anonymous destination buffer | ||
211 | * ce - which copy engine to use | ||
212 | * sendlist - list of simple buffers to send using gather | ||
213 | * transfer_id - arbitrary ID; reflected to destination | ||
214 | * Returns 0 on success; otherwise an error status. | ||
215 | * | ||
216 | * Implemenation note: Pushes multiple buffers with Gather to Source ring. | ||
217 | */ | ||
218 | int ath10k_ce_sendlist_send(struct ce_state *ce_state, | ||
219 | void *per_transfer_send_context, | ||
220 | struct ce_sendlist *sendlist, | ||
221 | /* 14 bits */ | ||
222 | unsigned int transfer_id); | ||
223 | 160 | ||
224 | /*==================Recv=======================*/ | 161 | /*==================Recv=======================*/ |
225 | 162 | ||
@@ -233,17 +170,12 @@ int ath10k_ce_sendlist_send(struct ce_state *ce_state, | |||
233 | * | 170 | * |
234 | * Implemenation note: Pushes a buffer to Dest ring. | 171 | * Implemenation note: Pushes a buffer to Dest ring. |
235 | */ | 172 | */ |
236 | int ath10k_ce_recv_buf_enqueue(struct ce_state *ce_state, | 173 | int ath10k_ce_recv_buf_enqueue(struct ath10k_ce_pipe *ce_state, |
237 | void *per_transfer_recv_context, | 174 | void *per_transfer_recv_context, |
238 | u32 buffer); | 175 | u32 buffer); |
239 | 176 | ||
240 | void ath10k_ce_recv_cb_register(struct ce_state *ce_state, | 177 | void ath10k_ce_recv_cb_register(struct ath10k_ce_pipe *ce_state, |
241 | void (*recv_cb) (struct ce_state *ce_state, | 178 | void (*recv_cb)(struct ath10k_ce_pipe *)); |
242 | void *transfer_context, | ||
243 | u32 buffer, | ||
244 | unsigned int nbytes, | ||
245 | unsigned int transfer_id, | ||
246 | unsigned int flags)); | ||
247 | 179 | ||
248 | /* recv flags */ | 180 | /* recv flags */ |
249 | /* Data is byte-swapped */ | 181 | /* Data is byte-swapped */ |
@@ -253,7 +185,7 @@ void ath10k_ce_recv_cb_register(struct ce_state *ce_state, | |||
253 | * Supply data for the next completed unprocessed receive descriptor. | 185 | * Supply data for the next completed unprocessed receive descriptor. |
254 | * Pops buffer from Dest ring. | 186 | * Pops buffer from Dest ring. |
255 | */ | 187 | */ |
256 | int ath10k_ce_completed_recv_next(struct ce_state *ce_state, | 188 | int ath10k_ce_completed_recv_next(struct ath10k_ce_pipe *ce_state, |
257 | void **per_transfer_contextp, | 189 | void **per_transfer_contextp, |
258 | u32 *bufferp, | 190 | u32 *bufferp, |
259 | unsigned int *nbytesp, | 191 | unsigned int *nbytesp, |
@@ -263,7 +195,7 @@ int ath10k_ce_completed_recv_next(struct ce_state *ce_state, | |||
263 | * Supply data for the next completed unprocessed send descriptor. | 195 | * Supply data for the next completed unprocessed send descriptor. |
264 | * Pops 1 completed send buffer from Source ring. | 196 | * Pops 1 completed send buffer from Source ring. |
265 | */ | 197 | */ |
266 | int ath10k_ce_completed_send_next(struct ce_state *ce_state, | 198 | int ath10k_ce_completed_send_next(struct ath10k_ce_pipe *ce_state, |
267 | void **per_transfer_contextp, | 199 | void **per_transfer_contextp, |
268 | u32 *bufferp, | 200 | u32 *bufferp, |
269 | unsigned int *nbytesp, | 201 | unsigned int *nbytesp, |
@@ -272,7 +204,7 @@ int ath10k_ce_completed_send_next(struct ce_state *ce_state, | |||
272 | /*==================CE Engine Initialization=======================*/ | 204 | /*==================CE Engine Initialization=======================*/ |
273 | 205 | ||
274 | /* Initialize an instance of a CE */ | 206 | /* Initialize an instance of a CE */ |
275 | struct ce_state *ath10k_ce_init(struct ath10k *ar, | 207 | struct ath10k_ce_pipe *ath10k_ce_init(struct ath10k *ar, |
276 | unsigned int ce_id, | 208 | unsigned int ce_id, |
277 | const struct ce_attr *attr); | 209 | const struct ce_attr *attr); |
278 | 210 | ||
@@ -282,7 +214,7 @@ struct ce_state *ath10k_ce_init(struct ath10k *ar, | |||
282 | * receive buffers. Target DMA must be stopped before using | 214 | * receive buffers. Target DMA must be stopped before using |
283 | * this API. | 215 | * this API. |
284 | */ | 216 | */ |
285 | int ath10k_ce_revoke_recv_next(struct ce_state *ce_state, | 217 | int ath10k_ce_revoke_recv_next(struct ath10k_ce_pipe *ce_state, |
286 | void **per_transfer_contextp, | 218 | void **per_transfer_contextp, |
287 | u32 *bufferp); | 219 | u32 *bufferp); |
288 | 220 | ||
@@ -291,13 +223,13 @@ int ath10k_ce_revoke_recv_next(struct ce_state *ce_state, | |||
291 | * pending sends. Target DMA must be stopped before using | 223 | * pending sends. Target DMA must be stopped before using |
292 | * this API. | 224 | * this API. |
293 | */ | 225 | */ |
294 | int ath10k_ce_cancel_send_next(struct ce_state *ce_state, | 226 | int ath10k_ce_cancel_send_next(struct ath10k_ce_pipe *ce_state, |
295 | void **per_transfer_contextp, | 227 | void **per_transfer_contextp, |
296 | u32 *bufferp, | 228 | u32 *bufferp, |
297 | unsigned int *nbytesp, | 229 | unsigned int *nbytesp, |
298 | unsigned int *transfer_idp); | 230 | unsigned int *transfer_idp); |
299 | 231 | ||
300 | void ath10k_ce_deinit(struct ce_state *ce_state); | 232 | void ath10k_ce_deinit(struct ath10k_ce_pipe *ce_state); |
301 | 233 | ||
302 | /*==================CE Interrupt Handlers====================*/ | 234 | /*==================CE Interrupt Handlers====================*/ |
303 | void ath10k_ce_per_engine_service_any(struct ath10k *ar); | 235 | void ath10k_ce_per_engine_service_any(struct ath10k *ar); |
@@ -322,9 +254,6 @@ struct ce_attr { | |||
322 | /* CE_ATTR_* values */ | 254 | /* CE_ATTR_* values */ |
323 | unsigned int flags; | 255 | unsigned int flags; |
324 | 256 | ||
325 | /* currently not in use */ | ||
326 | unsigned int priority; | ||
327 | |||
328 | /* #entries in source ring - Must be a power of 2 */ | 257 | /* #entries in source ring - Must be a power of 2 */ |
329 | unsigned int src_nentries; | 258 | unsigned int src_nentries; |
330 | 259 | ||
@@ -336,21 +265,8 @@ struct ce_attr { | |||
336 | 265 | ||
337 | /* #entries in destination ring - Must be a power of 2 */ | 266 | /* #entries in destination ring - Must be a power of 2 */ |
338 | unsigned int dest_nentries; | 267 | unsigned int dest_nentries; |
339 | |||
340 | /* Future use */ | ||
341 | void *reserved; | ||
342 | }; | 268 | }; |
343 | 269 | ||
344 | /* | ||
345 | * When using sendlist_send to transfer multiple buffer fragments, the | ||
346 | * transfer context of each fragment, except last one, will be filled | ||
347 | * with CE_SENDLIST_ITEM_CTXT. ce_completed_send will return success for | ||
348 | * each fragment done with send and the transfer context would be | ||
349 | * CE_SENDLIST_ITEM_CTXT. Upper layer could use this to identify the | ||
350 | * status of a send completion. | ||
351 | */ | ||
352 | #define CE_SENDLIST_ITEM_CTXT ((void *)0xcecebeef) | ||
353 | |||
354 | #define SR_BA_ADDRESS 0x0000 | 270 | #define SR_BA_ADDRESS 0x0000 |
355 | #define SR_SIZE_ADDRESS 0x0004 | 271 | #define SR_SIZE_ADDRESS 0x0004 |
356 | #define DR_BA_ADDRESS 0x0008 | 272 | #define DR_BA_ADDRESS 0x0008 |