1 /*
2 * Copyright (c) 2005-2011 Atheros Communications Inc.
3 * Copyright (c) 2011-2017 Qualcomm Atheros, Inc.
4 *
5 * Permission to use, copy, modify, and/or distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 */
17
18 #include <linux/etherdevice.h>
19 #include "htt.h"
20 #include "mac.h"
21 #include "hif.h"
22 #include "txrx.h"
23 #include "debug.h"
24
ath10k_htt_tx_txq_calc_size(size_t count)25 static u8 ath10k_htt_tx_txq_calc_size(size_t count)
26 {
27 int exp;
28 int factor;
29
30 exp = 0;
31 factor = count >> 7;
32
33 while (factor >= 64 && exp < 4) {
34 factor >>= 3;
35 exp++;
36 }
37
38 if (exp == 4)
39 return 0xff;
40
41 if (count > 0)
42 factor = max(1, factor);
43
44 return SM(exp, HTT_TX_Q_STATE_ENTRY_EXP) |
45 SM(factor, HTT_TX_Q_STATE_ENTRY_FACTOR);
46 }
47
__ath10k_htt_tx_txq_recalc(struct ieee80211_hw * hw,struct ieee80211_txq * txq)48 static void __ath10k_htt_tx_txq_recalc(struct ieee80211_hw *hw,
49 struct ieee80211_txq *txq)
50 {
51 struct ath10k *ar = hw->priv;
52 struct ath10k_sta *arsta;
53 struct ath10k_vif *arvif = (void *)txq->vif->drv_priv;
54 unsigned long frame_cnt;
55 unsigned long byte_cnt;
56 int idx;
57 u32 bit;
58 u16 peer_id;
59 u8 tid;
60 u8 count;
61
62 lockdep_assert_held(&ar->htt.tx_lock);
63
64 if (!ar->htt.tx_q_state.enabled)
65 return;
66
67 if (ar->htt.tx_q_state.mode != HTT_TX_MODE_SWITCH_PUSH_PULL)
68 return;
69
70 if (txq->sta) {
71 arsta = (void *)txq->sta->drv_priv;
72 peer_id = arsta->peer_id;
73 } else {
74 peer_id = arvif->peer_id;
75 }
76
77 tid = txq->tid;
78 bit = BIT(peer_id % 32);
79 idx = peer_id / 32;
80
81 ieee80211_txq_get_depth(txq, &frame_cnt, &byte_cnt);
82 count = ath10k_htt_tx_txq_calc_size(byte_cnt);
83
84 if (unlikely(peer_id >= ar->htt.tx_q_state.num_peers) ||
85 unlikely(tid >= ar->htt.tx_q_state.num_tids)) {
86 ath10k_warn(ar, "refusing to update txq for peer_id %hu tid %hhu due to out of bounds\n",
87 peer_id, tid);
88 return;
89 }
90
91 ar->htt.tx_q_state.vaddr->count[tid][peer_id] = count;
92 ar->htt.tx_q_state.vaddr->map[tid][idx] &= ~bit;
93 ar->htt.tx_q_state.vaddr->map[tid][idx] |= count ? bit : 0;
94
95 ath10k_dbg(ar, ATH10K_DBG_HTT, "htt tx txq state update peer_id %hu tid %hhu count %hhu\n",
96 peer_id, tid, count);
97 }
98
__ath10k_htt_tx_txq_sync(struct ath10k * ar)99 static void __ath10k_htt_tx_txq_sync(struct ath10k *ar)
100 {
101 u32 seq;
102 size_t size;
103
104 lockdep_assert_held(&ar->htt.tx_lock);
105
106 if (!ar->htt.tx_q_state.enabled)
107 return;
108
109 if (ar->htt.tx_q_state.mode != HTT_TX_MODE_SWITCH_PUSH_PULL)
110 return;
111
112 seq = le32_to_cpu(ar->htt.tx_q_state.vaddr->seq);
113 seq++;
114 ar->htt.tx_q_state.vaddr->seq = cpu_to_le32(seq);
115
116 ath10k_dbg(ar, ATH10K_DBG_HTT, "htt tx txq state update commit seq %u\n",
117 seq);
118
119 size = sizeof(*ar->htt.tx_q_state.vaddr);
120 dma_sync_single_for_device(ar->dev,
121 ar->htt.tx_q_state.paddr,
122 size,
123 DMA_TO_DEVICE);
124 }
125
ath10k_htt_tx_txq_recalc(struct ieee80211_hw * hw,struct ieee80211_txq * txq)126 void ath10k_htt_tx_txq_recalc(struct ieee80211_hw *hw,
127 struct ieee80211_txq *txq)
128 {
129 struct ath10k *ar = hw->priv;
130
131 spin_lock_bh(&ar->htt.tx_lock);
132 __ath10k_htt_tx_txq_recalc(hw, txq);
133 spin_unlock_bh(&ar->htt.tx_lock);
134 }
135
ath10k_htt_tx_txq_sync(struct ath10k * ar)136 void ath10k_htt_tx_txq_sync(struct ath10k *ar)
137 {
138 spin_lock_bh(&ar->htt.tx_lock);
139 __ath10k_htt_tx_txq_sync(ar);
140 spin_unlock_bh(&ar->htt.tx_lock);
141 }
142
ath10k_htt_tx_txq_update(struct ieee80211_hw * hw,struct ieee80211_txq * txq)143 void ath10k_htt_tx_txq_update(struct ieee80211_hw *hw,
144 struct ieee80211_txq *txq)
145 {
146 struct ath10k *ar = hw->priv;
147
148 spin_lock_bh(&ar->htt.tx_lock);
149 __ath10k_htt_tx_txq_recalc(hw, txq);
150 __ath10k_htt_tx_txq_sync(ar);
151 spin_unlock_bh(&ar->htt.tx_lock);
152 }
153
ath10k_htt_tx_dec_pending(struct ath10k_htt * htt)154 void ath10k_htt_tx_dec_pending(struct ath10k_htt *htt)
155 {
156 lockdep_assert_held(&htt->tx_lock);
157
158 htt->num_pending_tx--;
159 if (htt->num_pending_tx == htt->max_num_pending_tx - 1)
160 ath10k_mac_tx_unlock(htt->ar, ATH10K_TX_PAUSE_Q_FULL);
161 }
162
ath10k_htt_tx_inc_pending(struct ath10k_htt * htt)163 int ath10k_htt_tx_inc_pending(struct ath10k_htt *htt)
164 {
165 lockdep_assert_held(&htt->tx_lock);
166
167 if (htt->num_pending_tx >= htt->max_num_pending_tx)
168 return -EBUSY;
169
170 htt->num_pending_tx++;
171 if (htt->num_pending_tx == htt->max_num_pending_tx)
172 ath10k_mac_tx_lock(htt->ar, ATH10K_TX_PAUSE_Q_FULL);
173
174 return 0;
175 }
176
ath10k_htt_tx_mgmt_inc_pending(struct ath10k_htt * htt,bool is_mgmt,bool is_presp)177 int ath10k_htt_tx_mgmt_inc_pending(struct ath10k_htt *htt, bool is_mgmt,
178 bool is_presp)
179 {
180 struct ath10k *ar = htt->ar;
181
182 lockdep_assert_held(&htt->tx_lock);
183
184 if (!is_mgmt || !ar->hw_params.max_probe_resp_desc_thres)
185 return 0;
186
187 if (is_presp &&
188 ar->hw_params.max_probe_resp_desc_thres < htt->num_pending_mgmt_tx)
189 return -EBUSY;
190
191 htt->num_pending_mgmt_tx++;
192
193 return 0;
194 }
195
ath10k_htt_tx_mgmt_dec_pending(struct ath10k_htt * htt)196 void ath10k_htt_tx_mgmt_dec_pending(struct ath10k_htt *htt)
197 {
198 lockdep_assert_held(&htt->tx_lock);
199
200 if (!htt->ar->hw_params.max_probe_resp_desc_thres)
201 return;
202
203 htt->num_pending_mgmt_tx--;
204 }
205
ath10k_htt_tx_alloc_msdu_id(struct ath10k_htt * htt,struct sk_buff * skb)206 int ath10k_htt_tx_alloc_msdu_id(struct ath10k_htt *htt, struct sk_buff *skb)
207 {
208 struct ath10k *ar = htt->ar;
209 int ret;
210
211 spin_lock_bh(&htt->tx_lock);
212 ret = idr_alloc(&htt->pending_tx, skb, 0,
213 htt->max_num_pending_tx, GFP_ATOMIC);
214 spin_unlock_bh(&htt->tx_lock);
215
216 ath10k_dbg(ar, ATH10K_DBG_HTT, "htt tx alloc msdu_id %d\n", ret);
217
218 return ret;
219 }
220
ath10k_htt_tx_free_msdu_id(struct ath10k_htt * htt,u16 msdu_id)221 void ath10k_htt_tx_free_msdu_id(struct ath10k_htt *htt, u16 msdu_id)
222 {
223 struct ath10k *ar = htt->ar;
224
225 lockdep_assert_held(&htt->tx_lock);
226
227 ath10k_dbg(ar, ATH10K_DBG_HTT, "htt tx free msdu_id %hu\n", msdu_id);
228
229 idr_remove(&htt->pending_tx, msdu_id);
230 }
231
ath10k_htt_tx_free_cont_txbuf_32(struct ath10k_htt * htt)232 static void ath10k_htt_tx_free_cont_txbuf_32(struct ath10k_htt *htt)
233 {
234 struct ath10k *ar = htt->ar;
235 size_t size;
236
237 if (!htt->txbuf.vaddr_txbuff_32)
238 return;
239
240 size = htt->txbuf.size;
241 dma_free_coherent(ar->dev, size, htt->txbuf.vaddr_txbuff_32,
242 htt->txbuf.paddr);
243 htt->txbuf.vaddr_txbuff_32 = NULL;
244 }
245
ath10k_htt_tx_alloc_cont_txbuf_32(struct ath10k_htt * htt)246 static int ath10k_htt_tx_alloc_cont_txbuf_32(struct ath10k_htt *htt)
247 {
248 struct ath10k *ar = htt->ar;
249 size_t size;
250
251 size = htt->max_num_pending_tx *
252 sizeof(struct ath10k_htt_txbuf_32);
253
254 htt->txbuf.vaddr_txbuff_32 = dma_alloc_coherent(ar->dev, size,
255 &htt->txbuf.paddr,
256 GFP_KERNEL);
257 if (!htt->txbuf.vaddr_txbuff_32)
258 return -ENOMEM;
259
260 htt->txbuf.size = size;
261
262 return 0;
263 }
264
ath10k_htt_tx_free_cont_txbuf_64(struct ath10k_htt * htt)265 static void ath10k_htt_tx_free_cont_txbuf_64(struct ath10k_htt *htt)
266 {
267 struct ath10k *ar = htt->ar;
268 size_t size;
269
270 if (!htt->txbuf.vaddr_txbuff_64)
271 return;
272
273 size = htt->txbuf.size;
274 dma_free_coherent(ar->dev, size, htt->txbuf.vaddr_txbuff_64,
275 htt->txbuf.paddr);
276 htt->txbuf.vaddr_txbuff_64 = NULL;
277 }
278
ath10k_htt_tx_alloc_cont_txbuf_64(struct ath10k_htt * htt)279 static int ath10k_htt_tx_alloc_cont_txbuf_64(struct ath10k_htt *htt)
280 {
281 struct ath10k *ar = htt->ar;
282 size_t size;
283
284 size = htt->max_num_pending_tx *
285 sizeof(struct ath10k_htt_txbuf_64);
286
287 htt->txbuf.vaddr_txbuff_64 = dma_alloc_coherent(ar->dev, size,
288 &htt->txbuf.paddr,
289 GFP_KERNEL);
290 if (!htt->txbuf.vaddr_txbuff_64)
291 return -ENOMEM;
292
293 htt->txbuf.size = size;
294
295 return 0;
296 }
297
ath10k_htt_tx_free_cont_frag_desc_32(struct ath10k_htt * htt)298 static void ath10k_htt_tx_free_cont_frag_desc_32(struct ath10k_htt *htt)
299 {
300 size_t size;
301
302 if (!htt->frag_desc.vaddr_desc_32)
303 return;
304
305 size = htt->max_num_pending_tx *
306 sizeof(struct htt_msdu_ext_desc);
307
308 dma_free_coherent(htt->ar->dev,
309 size,
310 htt->frag_desc.vaddr_desc_32,
311 htt->frag_desc.paddr);
312
313 htt->frag_desc.vaddr_desc_32 = NULL;
314 }
315
ath10k_htt_tx_alloc_cont_frag_desc_32(struct ath10k_htt * htt)316 static int ath10k_htt_tx_alloc_cont_frag_desc_32(struct ath10k_htt *htt)
317 {
318 struct ath10k *ar = htt->ar;
319 size_t size;
320
321 if (!ar->hw_params.continuous_frag_desc)
322 return 0;
323
324 size = htt->max_num_pending_tx *
325 sizeof(struct htt_msdu_ext_desc);
326 htt->frag_desc.vaddr_desc_32 = dma_alloc_coherent(ar->dev, size,
327 &htt->frag_desc.paddr,
328 GFP_KERNEL);
329 if (!htt->frag_desc.vaddr_desc_32) {
330 ath10k_err(ar, "failed to alloc fragment desc memory\n");
331 return -ENOMEM;
332 }
333 htt->frag_desc.size = size;
334
335 return 0;
336 }
337
ath10k_htt_tx_free_cont_frag_desc_64(struct ath10k_htt * htt)338 static void ath10k_htt_tx_free_cont_frag_desc_64(struct ath10k_htt *htt)
339 {
340 size_t size;
341
342 if (!htt->frag_desc.vaddr_desc_64)
343 return;
344
345 size = htt->max_num_pending_tx *
346 sizeof(struct htt_msdu_ext_desc_64);
347
348 dma_free_coherent(htt->ar->dev,
349 size,
350 htt->frag_desc.vaddr_desc_64,
351 htt->frag_desc.paddr);
352
353 htt->frag_desc.vaddr_desc_64 = NULL;
354 }
355
ath10k_htt_tx_alloc_cont_frag_desc_64(struct ath10k_htt * htt)356 static int ath10k_htt_tx_alloc_cont_frag_desc_64(struct ath10k_htt *htt)
357 {
358 struct ath10k *ar = htt->ar;
359 size_t size;
360
361 if (!ar->hw_params.continuous_frag_desc)
362 return 0;
363
364 size = htt->max_num_pending_tx *
365 sizeof(struct htt_msdu_ext_desc_64);
366
367 htt->frag_desc.vaddr_desc_64 = dma_alloc_coherent(ar->dev, size,
368 &htt->frag_desc.paddr,
369 GFP_KERNEL);
370 if (!htt->frag_desc.vaddr_desc_64) {
371 ath10k_err(ar, "failed to alloc fragment desc memory\n");
372 return -ENOMEM;
373 }
374 htt->frag_desc.size = size;
375
376 return 0;
377 }
378
ath10k_htt_tx_free_txq(struct ath10k_htt * htt)379 static void ath10k_htt_tx_free_txq(struct ath10k_htt *htt)
380 {
381 struct ath10k *ar = htt->ar;
382 size_t size;
383
384 if (!test_bit(ATH10K_FW_FEATURE_PEER_FLOW_CONTROL,
385 ar->running_fw->fw_file.fw_features))
386 return;
387
388 size = sizeof(*htt->tx_q_state.vaddr);
389
390 dma_unmap_single(ar->dev, htt->tx_q_state.paddr, size, DMA_TO_DEVICE);
391 kfree(htt->tx_q_state.vaddr);
392 }
393
ath10k_htt_tx_alloc_txq(struct ath10k_htt * htt)394 static int ath10k_htt_tx_alloc_txq(struct ath10k_htt *htt)
395 {
396 struct ath10k *ar = htt->ar;
397 size_t size;
398 int ret;
399
400 if (!test_bit(ATH10K_FW_FEATURE_PEER_FLOW_CONTROL,
401 ar->running_fw->fw_file.fw_features))
402 return 0;
403
404 htt->tx_q_state.num_peers = HTT_TX_Q_STATE_NUM_PEERS;
405 htt->tx_q_state.num_tids = HTT_TX_Q_STATE_NUM_TIDS;
406 htt->tx_q_state.type = HTT_Q_DEPTH_TYPE_BYTES;
407
408 size = sizeof(*htt->tx_q_state.vaddr);
409 htt->tx_q_state.vaddr = kzalloc(size, GFP_KERNEL);
410 if (!htt->tx_q_state.vaddr)
411 return -ENOMEM;
412
413 htt->tx_q_state.paddr = dma_map_single(ar->dev, htt->tx_q_state.vaddr,
414 size, DMA_TO_DEVICE);
415 ret = dma_mapping_error(ar->dev, htt->tx_q_state.paddr);
416 if (ret) {
417 ath10k_warn(ar, "failed to dma map tx_q_state: %d\n", ret);
418 kfree(htt->tx_q_state.vaddr);
419 return -EIO;
420 }
421
422 return 0;
423 }
424
ath10k_htt_tx_free_txdone_fifo(struct ath10k_htt * htt)425 static void ath10k_htt_tx_free_txdone_fifo(struct ath10k_htt *htt)
426 {
427 WARN_ON(!kfifo_is_empty(&htt->txdone_fifo));
428 kfifo_free(&htt->txdone_fifo);
429 }
430
ath10k_htt_tx_alloc_txdone_fifo(struct ath10k_htt * htt)431 static int ath10k_htt_tx_alloc_txdone_fifo(struct ath10k_htt *htt)
432 {
433 int ret;
434 size_t size;
435
436 size = roundup_pow_of_two(htt->max_num_pending_tx);
437 ret = kfifo_alloc(&htt->txdone_fifo, size, GFP_KERNEL);
438 return ret;
439 }
440
ath10k_htt_tx_alloc_buf(struct ath10k_htt * htt)441 static int ath10k_htt_tx_alloc_buf(struct ath10k_htt *htt)
442 {
443 struct ath10k *ar = htt->ar;
444 int ret;
445
446 ret = ath10k_htt_alloc_txbuff(htt);
447 if (ret) {
448 ath10k_err(ar, "failed to alloc cont tx buffer: %d\n", ret);
449 return ret;
450 }
451
452 ret = ath10k_htt_alloc_frag_desc(htt);
453 if (ret) {
454 ath10k_err(ar, "failed to alloc cont frag desc: %d\n", ret);
455 goto free_txbuf;
456 }
457
458 ret = ath10k_htt_tx_alloc_txq(htt);
459 if (ret) {
460 ath10k_err(ar, "failed to alloc txq: %d\n", ret);
461 goto free_frag_desc;
462 }
463
464 ret = ath10k_htt_tx_alloc_txdone_fifo(htt);
465 if (ret) {
466 ath10k_err(ar, "failed to alloc txdone fifo: %d\n", ret);
467 goto free_txq;
468 }
469
470 return 0;
471
472 free_txq:
473 ath10k_htt_tx_free_txq(htt);
474
475 free_frag_desc:
476 ath10k_htt_free_frag_desc(htt);
477
478 free_txbuf:
479 ath10k_htt_free_txbuff(htt);
480
481 return ret;
482 }
483
ath10k_htt_tx_start(struct ath10k_htt * htt)484 int ath10k_htt_tx_start(struct ath10k_htt *htt)
485 {
486 struct ath10k *ar = htt->ar;
487 int ret;
488
489 ath10k_dbg(ar, ATH10K_DBG_BOOT, "htt tx max num pending tx %d\n",
490 htt->max_num_pending_tx);
491
492 spin_lock_init(&htt->tx_lock);
493 idr_init(&htt->pending_tx);
494
495 if (htt->tx_mem_allocated)
496 return 0;
497
498 ret = ath10k_htt_tx_alloc_buf(htt);
499 if (ret)
500 goto free_idr_pending_tx;
501
502 htt->tx_mem_allocated = true;
503
504 return 0;
505
506 free_idr_pending_tx:
507 idr_destroy(&htt->pending_tx);
508
509 return ret;
510 }
511
ath10k_htt_tx_clean_up_pending(int msdu_id,void * skb,void * ctx)512 static int ath10k_htt_tx_clean_up_pending(int msdu_id, void *skb, void *ctx)
513 {
514 struct ath10k *ar = ctx;
515 struct ath10k_htt *htt = &ar->htt;
516 struct htt_tx_done tx_done = {0};
517
518 ath10k_dbg(ar, ATH10K_DBG_HTT, "force cleanup msdu_id %hu\n", msdu_id);
519
520 tx_done.msdu_id = msdu_id;
521 tx_done.status = HTT_TX_COMPL_STATE_DISCARD;
522
523 ath10k_txrx_tx_unref(htt, &tx_done);
524
525 return 0;
526 }
527
ath10k_htt_tx_destroy(struct ath10k_htt * htt)528 void ath10k_htt_tx_destroy(struct ath10k_htt *htt)
529 {
530 if (!htt->tx_mem_allocated)
531 return;
532
533 ath10k_htt_free_txbuff(htt);
534 ath10k_htt_tx_free_txq(htt);
535 ath10k_htt_free_frag_desc(htt);
536 ath10k_htt_tx_free_txdone_fifo(htt);
537 htt->tx_mem_allocated = false;
538 }
539
ath10k_htt_tx_stop(struct ath10k_htt * htt)540 void ath10k_htt_tx_stop(struct ath10k_htt *htt)
541 {
542 idr_for_each(&htt->pending_tx, ath10k_htt_tx_clean_up_pending, htt->ar);
543 idr_destroy(&htt->pending_tx);
544 }
545
ath10k_htt_tx_free(struct ath10k_htt * htt)546 void ath10k_htt_tx_free(struct ath10k_htt *htt)
547 {
548 ath10k_htt_tx_stop(htt);
549 ath10k_htt_tx_destroy(htt);
550 }
551
ath10k_htt_htc_tx_complete(struct ath10k * ar,struct sk_buff * skb)552 void ath10k_htt_htc_tx_complete(struct ath10k *ar, struct sk_buff *skb)
553 {
554 dev_kfree_skb_any(skb);
555 }
556
ath10k_htt_hif_tx_complete(struct ath10k * ar,struct sk_buff * skb)557 void ath10k_htt_hif_tx_complete(struct ath10k *ar, struct sk_buff *skb)
558 {
559 dev_kfree_skb_any(skb);
560 }
561 EXPORT_SYMBOL(ath10k_htt_hif_tx_complete);
562
ath10k_htt_h2t_ver_req_msg(struct ath10k_htt * htt)563 int ath10k_htt_h2t_ver_req_msg(struct ath10k_htt *htt)
564 {
565 struct ath10k *ar = htt->ar;
566 struct sk_buff *skb;
567 struct htt_cmd *cmd;
568 int len = 0;
569 int ret;
570
571 len += sizeof(cmd->hdr);
572 len += sizeof(cmd->ver_req);
573
574 skb = ath10k_htc_alloc_skb(ar, len);
575 if (!skb)
576 return -ENOMEM;
577
578 skb_put(skb, len);
579 cmd = (struct htt_cmd *)skb->data;
580 cmd->hdr.msg_type = HTT_H2T_MSG_TYPE_VERSION_REQ;
581
582 ret = ath10k_htc_send(&htt->ar->htc, htt->eid, skb);
583 if (ret) {
584 dev_kfree_skb_any(skb);
585 return ret;
586 }
587
588 return 0;
589 }
590
ath10k_htt_h2t_stats_req(struct ath10k_htt * htt,u8 mask,u64 cookie)591 int ath10k_htt_h2t_stats_req(struct ath10k_htt *htt, u8 mask, u64 cookie)
592 {
593 struct ath10k *ar = htt->ar;
594 struct htt_stats_req *req;
595 struct sk_buff *skb;
596 struct htt_cmd *cmd;
597 int len = 0, ret;
598
599 len += sizeof(cmd->hdr);
600 len += sizeof(cmd->stats_req);
601
602 skb = ath10k_htc_alloc_skb(ar, len);
603 if (!skb)
604 return -ENOMEM;
605
606 skb_put(skb, len);
607 cmd = (struct htt_cmd *)skb->data;
608 cmd->hdr.msg_type = HTT_H2T_MSG_TYPE_STATS_REQ;
609
610 req = &cmd->stats_req;
611
612 memset(req, 0, sizeof(*req));
613
614 /* currently we support only max 8 bit masks so no need to worry
615 * about endian support
616 */
617 req->upload_types[0] = mask;
618 req->reset_types[0] = mask;
619 req->stat_type = HTT_STATS_REQ_CFG_STAT_TYPE_INVALID;
620 req->cookie_lsb = cpu_to_le32(cookie & 0xffffffff);
621 req->cookie_msb = cpu_to_le32((cookie & 0xffffffff00000000ULL) >> 32);
622
623 ret = ath10k_htc_send(&htt->ar->htc, htt->eid, skb);
624 if (ret) {
625 ath10k_warn(ar, "failed to send htt type stats request: %d",
626 ret);
627 dev_kfree_skb_any(skb);
628 return ret;
629 }
630
631 return 0;
632 }
633
ath10k_htt_send_frag_desc_bank_cfg_32(struct ath10k_htt * htt)634 static int ath10k_htt_send_frag_desc_bank_cfg_32(struct ath10k_htt *htt)
635 {
636 struct ath10k *ar = htt->ar;
637 struct sk_buff *skb;
638 struct htt_cmd *cmd;
639 struct htt_frag_desc_bank_cfg32 *cfg;
640 int ret, size;
641 u8 info;
642
643 if (!ar->hw_params.continuous_frag_desc)
644 return 0;
645
646 if (!htt->frag_desc.paddr) {
647 ath10k_warn(ar, "invalid frag desc memory\n");
648 return -EINVAL;
649 }
650
651 size = sizeof(cmd->hdr) + sizeof(cmd->frag_desc_bank_cfg32);
652 skb = ath10k_htc_alloc_skb(ar, size);
653 if (!skb)
654 return -ENOMEM;
655
656 skb_put(skb, size);
657 cmd = (struct htt_cmd *)skb->data;
658 cmd->hdr.msg_type = HTT_H2T_MSG_TYPE_FRAG_DESC_BANK_CFG;
659
660 info = 0;
661 info |= SM(htt->tx_q_state.type,
662 HTT_FRAG_DESC_BANK_CFG_INFO_Q_STATE_DEPTH_TYPE);
663
664 if (test_bit(ATH10K_FW_FEATURE_PEER_FLOW_CONTROL,
665 ar->running_fw->fw_file.fw_features))
666 info |= HTT_FRAG_DESC_BANK_CFG_INFO_Q_STATE_VALID;
667
668 cfg = &cmd->frag_desc_bank_cfg32;
669 cfg->info = info;
670 cfg->num_banks = 1;
671 cfg->desc_size = sizeof(struct htt_msdu_ext_desc);
672 cfg->bank_base_addrs[0] = __cpu_to_le32(htt->frag_desc.paddr);
673 cfg->bank_id[0].bank_min_id = 0;
674 cfg->bank_id[0].bank_max_id = __cpu_to_le16(htt->max_num_pending_tx -
675 1);
676
677 cfg->q_state.paddr = cpu_to_le32(htt->tx_q_state.paddr);
678 cfg->q_state.num_peers = cpu_to_le16(htt->tx_q_state.num_peers);
679 cfg->q_state.num_tids = cpu_to_le16(htt->tx_q_state.num_tids);
680 cfg->q_state.record_size = HTT_TX_Q_STATE_ENTRY_SIZE;
681 cfg->q_state.record_multiplier = HTT_TX_Q_STATE_ENTRY_MULTIPLIER;
682
683 ath10k_dbg(ar, ATH10K_DBG_HTT, "htt frag desc bank cmd\n");
684
685 ret = ath10k_htc_send(&htt->ar->htc, htt->eid, skb);
686 if (ret) {
687 ath10k_warn(ar, "failed to send frag desc bank cfg request: %d\n",
688 ret);
689 dev_kfree_skb_any(skb);
690 return ret;
691 }
692
693 return 0;
694 }
695
ath10k_htt_send_frag_desc_bank_cfg_64(struct ath10k_htt * htt)696 static int ath10k_htt_send_frag_desc_bank_cfg_64(struct ath10k_htt *htt)
697 {
698 struct ath10k *ar = htt->ar;
699 struct sk_buff *skb;
700 struct htt_cmd *cmd;
701 struct htt_frag_desc_bank_cfg64 *cfg;
702 int ret, size;
703 u8 info;
704
705 if (!ar->hw_params.continuous_frag_desc)
706 return 0;
707
708 if (!htt->frag_desc.paddr) {
709 ath10k_warn(ar, "invalid frag desc memory\n");
710 return -EINVAL;
711 }
712
713 size = sizeof(cmd->hdr) + sizeof(cmd->frag_desc_bank_cfg64);
714 skb = ath10k_htc_alloc_skb(ar, size);
715 if (!skb)
716 return -ENOMEM;
717
718 skb_put(skb, size);
719 cmd = (struct htt_cmd *)skb->data;
720 cmd->hdr.msg_type = HTT_H2T_MSG_TYPE_FRAG_DESC_BANK_CFG;
721
722 info = 0;
723 info |= SM(htt->tx_q_state.type,
724 HTT_FRAG_DESC_BANK_CFG_INFO_Q_STATE_DEPTH_TYPE);
725
726 if (test_bit(ATH10K_FW_FEATURE_PEER_FLOW_CONTROL,
727 ar->running_fw->fw_file.fw_features))
728 info |= HTT_FRAG_DESC_BANK_CFG_INFO_Q_STATE_VALID;
729
730 cfg = &cmd->frag_desc_bank_cfg64;
731 cfg->info = info;
732 cfg->num_banks = 1;
733 cfg->desc_size = sizeof(struct htt_msdu_ext_desc_64);
734 cfg->bank_base_addrs[0] = __cpu_to_le64(htt->frag_desc.paddr);
735 cfg->bank_id[0].bank_min_id = 0;
736 cfg->bank_id[0].bank_max_id = __cpu_to_le16(htt->max_num_pending_tx -
737 1);
738
739 cfg->q_state.paddr = cpu_to_le32(htt->tx_q_state.paddr);
740 cfg->q_state.num_peers = cpu_to_le16(htt->tx_q_state.num_peers);
741 cfg->q_state.num_tids = cpu_to_le16(htt->tx_q_state.num_tids);
742 cfg->q_state.record_size = HTT_TX_Q_STATE_ENTRY_SIZE;
743 cfg->q_state.record_multiplier = HTT_TX_Q_STATE_ENTRY_MULTIPLIER;
744
745 ath10k_dbg(ar, ATH10K_DBG_HTT, "htt frag desc bank cmd\n");
746
747 ret = ath10k_htc_send(&htt->ar->htc, htt->eid, skb);
748 if (ret) {
749 ath10k_warn(ar, "failed to send frag desc bank cfg request: %d\n",
750 ret);
751 dev_kfree_skb_any(skb);
752 return ret;
753 }
754
755 return 0;
756 }
757
ath10k_htt_fill_rx_desc_offset_32(void * rx_ring)758 static void ath10k_htt_fill_rx_desc_offset_32(void *rx_ring)
759 {
760 struct htt_rx_ring_setup_ring32 *ring =
761 (struct htt_rx_ring_setup_ring32 *)rx_ring;
762
763 #define desc_offset(x) (offsetof(struct htt_rx_desc, x) / 4)
764 ring->mac80211_hdr_offset = __cpu_to_le16(desc_offset(rx_hdr_status));
765 ring->msdu_payload_offset = __cpu_to_le16(desc_offset(msdu_payload));
766 ring->ppdu_start_offset = __cpu_to_le16(desc_offset(ppdu_start));
767 ring->ppdu_end_offset = __cpu_to_le16(desc_offset(ppdu_end));
768 ring->mpdu_start_offset = __cpu_to_le16(desc_offset(mpdu_start));
769 ring->mpdu_end_offset = __cpu_to_le16(desc_offset(mpdu_end));
770 ring->msdu_start_offset = __cpu_to_le16(desc_offset(msdu_start));
771 ring->msdu_end_offset = __cpu_to_le16(desc_offset(msdu_end));
772 ring->rx_attention_offset = __cpu_to_le16(desc_offset(attention));
773 ring->frag_info_offset = __cpu_to_le16(desc_offset(frag_info));
774 #undef desc_offset
775 }
776
ath10k_htt_fill_rx_desc_offset_64(void * rx_ring)777 static void ath10k_htt_fill_rx_desc_offset_64(void *rx_ring)
778 {
779 struct htt_rx_ring_setup_ring64 *ring =
780 (struct htt_rx_ring_setup_ring64 *)rx_ring;
781
782 #define desc_offset(x) (offsetof(struct htt_rx_desc, x) / 4)
783 ring->mac80211_hdr_offset = __cpu_to_le16(desc_offset(rx_hdr_status));
784 ring->msdu_payload_offset = __cpu_to_le16(desc_offset(msdu_payload));
785 ring->ppdu_start_offset = __cpu_to_le16(desc_offset(ppdu_start));
786 ring->ppdu_end_offset = __cpu_to_le16(desc_offset(ppdu_end));
787 ring->mpdu_start_offset = __cpu_to_le16(desc_offset(mpdu_start));
788 ring->mpdu_end_offset = __cpu_to_le16(desc_offset(mpdu_end));
789 ring->msdu_start_offset = __cpu_to_le16(desc_offset(msdu_start));
790 ring->msdu_end_offset = __cpu_to_le16(desc_offset(msdu_end));
791 ring->rx_attention_offset = __cpu_to_le16(desc_offset(attention));
792 ring->frag_info_offset = __cpu_to_le16(desc_offset(frag_info));
793 #undef desc_offset
794 }
795
ath10k_htt_send_rx_ring_cfg_32(struct ath10k_htt * htt)796 static int ath10k_htt_send_rx_ring_cfg_32(struct ath10k_htt *htt)
797 {
798 struct ath10k *ar = htt->ar;
799 struct sk_buff *skb;
800 struct htt_cmd *cmd;
801 struct htt_rx_ring_setup_ring32 *ring;
802 const int num_rx_ring = 1;
803 u16 flags;
804 u32 fw_idx;
805 int len;
806 int ret;
807
808 /*
809 * the HW expects the buffer to be an integral number of 4-byte
810 * "words"
811 */
812 BUILD_BUG_ON(!IS_ALIGNED(HTT_RX_BUF_SIZE, 4));
813 BUILD_BUG_ON((HTT_RX_BUF_SIZE & HTT_MAX_CACHE_LINE_SIZE_MASK) != 0);
814
815 len = sizeof(cmd->hdr) + sizeof(cmd->rx_setup_32.hdr)
816 + (sizeof(*ring) * num_rx_ring);
817 skb = ath10k_htc_alloc_skb(ar, len);
818 if (!skb)
819 return -ENOMEM;
820
821 skb_put(skb, len);
822
823 cmd = (struct htt_cmd *)skb->data;
824 ring = &cmd->rx_setup_32.rings[0];
825
826 cmd->hdr.msg_type = HTT_H2T_MSG_TYPE_RX_RING_CFG;
827 cmd->rx_setup_32.hdr.num_rings = 1;
828
829 /* FIXME: do we need all of this? */
830 flags = 0;
831 flags |= HTT_RX_RING_FLAGS_MAC80211_HDR;
832 flags |= HTT_RX_RING_FLAGS_MSDU_PAYLOAD;
833 flags |= HTT_RX_RING_FLAGS_PPDU_START;
834 flags |= HTT_RX_RING_FLAGS_PPDU_END;
835 flags |= HTT_RX_RING_FLAGS_MPDU_START;
836 flags |= HTT_RX_RING_FLAGS_MPDU_END;
837 flags |= HTT_RX_RING_FLAGS_MSDU_START;
838 flags |= HTT_RX_RING_FLAGS_MSDU_END;
839 flags |= HTT_RX_RING_FLAGS_RX_ATTENTION;
840 flags |= HTT_RX_RING_FLAGS_FRAG_INFO;
841 flags |= HTT_RX_RING_FLAGS_UNICAST_RX;
842 flags |= HTT_RX_RING_FLAGS_MULTICAST_RX;
843 flags |= HTT_RX_RING_FLAGS_CTRL_RX;
844 flags |= HTT_RX_RING_FLAGS_MGMT_RX;
845 flags |= HTT_RX_RING_FLAGS_NULL_RX;
846 flags |= HTT_RX_RING_FLAGS_PHY_DATA_RX;
847
848 fw_idx = __le32_to_cpu(*htt->rx_ring.alloc_idx.vaddr);
849
850 ring->fw_idx_shadow_reg_paddr =
851 __cpu_to_le32(htt->rx_ring.alloc_idx.paddr);
852 ring->rx_ring_base_paddr = __cpu_to_le32(htt->rx_ring.base_paddr);
853 ring->rx_ring_len = __cpu_to_le16(htt->rx_ring.size);
854 ring->rx_ring_bufsize = __cpu_to_le16(HTT_RX_BUF_SIZE);
855 ring->flags = __cpu_to_le16(flags);
856 ring->fw_idx_init_val = __cpu_to_le16(fw_idx);
857
858 ath10k_htt_fill_rx_desc_offset_32(ring);
859 ret = ath10k_htc_send(&htt->ar->htc, htt->eid, skb);
860 if (ret) {
861 dev_kfree_skb_any(skb);
862 return ret;
863 }
864
865 return 0;
866 }
867
ath10k_htt_send_rx_ring_cfg_64(struct ath10k_htt * htt)868 static int ath10k_htt_send_rx_ring_cfg_64(struct ath10k_htt *htt)
869 {
870 struct ath10k *ar = htt->ar;
871 struct sk_buff *skb;
872 struct htt_cmd *cmd;
873 struct htt_rx_ring_setup_ring64 *ring;
874 const int num_rx_ring = 1;
875 u16 flags;
876 u32 fw_idx;
877 int len;
878 int ret;
879
880 /* HW expects the buffer to be an integral number of 4-byte
881 * "words"
882 */
883 BUILD_BUG_ON(!IS_ALIGNED(HTT_RX_BUF_SIZE, 4));
884 BUILD_BUG_ON((HTT_RX_BUF_SIZE & HTT_MAX_CACHE_LINE_SIZE_MASK) != 0);
885
886 len = sizeof(cmd->hdr) + sizeof(cmd->rx_setup_64.hdr)
887 + (sizeof(*ring) * num_rx_ring);
888 skb = ath10k_htc_alloc_skb(ar, len);
889 if (!skb)
890 return -ENOMEM;
891
892 skb_put(skb, len);
893
894 cmd = (struct htt_cmd *)skb->data;
895 ring = &cmd->rx_setup_64.rings[0];
896
897 cmd->hdr.msg_type = HTT_H2T_MSG_TYPE_RX_RING_CFG;
898 cmd->rx_setup_64.hdr.num_rings = 1;
899
900 flags = 0;
901 flags |= HTT_RX_RING_FLAGS_MAC80211_HDR;
902 flags |= HTT_RX_RING_FLAGS_MSDU_PAYLOAD;
903 flags |= HTT_RX_RING_FLAGS_PPDU_START;
904 flags |= HTT_RX_RING_FLAGS_PPDU_END;
905 flags |= HTT_RX_RING_FLAGS_MPDU_START;
906 flags |= HTT_RX_RING_FLAGS_MPDU_END;
907 flags |= HTT_RX_RING_FLAGS_MSDU_START;
908 flags |= HTT_RX_RING_FLAGS_MSDU_END;
909 flags |= HTT_RX_RING_FLAGS_RX_ATTENTION;
910 flags |= HTT_RX_RING_FLAGS_FRAG_INFO;
911 flags |= HTT_RX_RING_FLAGS_UNICAST_RX;
912 flags |= HTT_RX_RING_FLAGS_MULTICAST_RX;
913 flags |= HTT_RX_RING_FLAGS_CTRL_RX;
914 flags |= HTT_RX_RING_FLAGS_MGMT_RX;
915 flags |= HTT_RX_RING_FLAGS_NULL_RX;
916 flags |= HTT_RX_RING_FLAGS_PHY_DATA_RX;
917
918 fw_idx = __le32_to_cpu(*htt->rx_ring.alloc_idx.vaddr);
919
920 ring->fw_idx_shadow_reg_paddr = __cpu_to_le64(htt->rx_ring.alloc_idx.paddr);
921 ring->rx_ring_base_paddr = __cpu_to_le64(htt->rx_ring.base_paddr);
922 ring->rx_ring_len = __cpu_to_le16(htt->rx_ring.size);
923 ring->rx_ring_bufsize = __cpu_to_le16(HTT_RX_BUF_SIZE);
924 ring->flags = __cpu_to_le16(flags);
925 ring->fw_idx_init_val = __cpu_to_le16(fw_idx);
926
927 ath10k_htt_fill_rx_desc_offset_64(ring);
928 ret = ath10k_htc_send(&htt->ar->htc, htt->eid, skb);
929 if (ret) {
930 dev_kfree_skb_any(skb);
931 return ret;
932 }
933
934 return 0;
935 }
936
ath10k_htt_h2t_aggr_cfg_msg(struct ath10k_htt * htt,u8 max_subfrms_ampdu,u8 max_subfrms_amsdu)937 int ath10k_htt_h2t_aggr_cfg_msg(struct ath10k_htt *htt,
938 u8 max_subfrms_ampdu,
939 u8 max_subfrms_amsdu)
940 {
941 struct ath10k *ar = htt->ar;
942 struct htt_aggr_conf *aggr_conf;
943 struct sk_buff *skb;
944 struct htt_cmd *cmd;
945 int len;
946 int ret;
947
948 /* Firmware defaults are: amsdu = 3 and ampdu = 64 */
949
950 if (max_subfrms_ampdu == 0 || max_subfrms_ampdu > 64)
951 return -EINVAL;
952
953 if (max_subfrms_amsdu == 0 || max_subfrms_amsdu > 31)
954 return -EINVAL;
955
956 len = sizeof(cmd->hdr);
957 len += sizeof(cmd->aggr_conf);
958
959 skb = ath10k_htc_alloc_skb(ar, len);
960 if (!skb)
961 return -ENOMEM;
962
963 skb_put(skb, len);
964 cmd = (struct htt_cmd *)skb->data;
965 cmd->hdr.msg_type = HTT_H2T_MSG_TYPE_AGGR_CFG;
966
967 aggr_conf = &cmd->aggr_conf;
968 aggr_conf->max_num_ampdu_subframes = max_subfrms_ampdu;
969 aggr_conf->max_num_amsdu_subframes = max_subfrms_amsdu;
970
971 ath10k_dbg(ar, ATH10K_DBG_HTT, "htt h2t aggr cfg msg amsdu %d ampdu %d",
972 aggr_conf->max_num_amsdu_subframes,
973 aggr_conf->max_num_ampdu_subframes);
974
975 ret = ath10k_htc_send(&htt->ar->htc, htt->eid, skb);
976 if (ret) {
977 dev_kfree_skb_any(skb);
978 return ret;
979 }
980
981 return 0;
982 }
983
ath10k_htt_tx_fetch_resp(struct ath10k * ar,__le32 token,__le16 fetch_seq_num,struct htt_tx_fetch_record * records,size_t num_records)984 int ath10k_htt_tx_fetch_resp(struct ath10k *ar,
985 __le32 token,
986 __le16 fetch_seq_num,
987 struct htt_tx_fetch_record *records,
988 size_t num_records)
989 {
990 struct sk_buff *skb;
991 struct htt_cmd *cmd;
992 const u16 resp_id = 0;
993 int len = 0;
994 int ret;
995
996 /* Response IDs are echo-ed back only for host driver convienence
997 * purposes. They aren't used for anything in the driver yet so use 0.
998 */
999
1000 len += sizeof(cmd->hdr);
1001 len += sizeof(cmd->tx_fetch_resp);
1002 len += sizeof(cmd->tx_fetch_resp.records[0]) * num_records;
1003
1004 skb = ath10k_htc_alloc_skb(ar, len);
1005 if (!skb)
1006 return -ENOMEM;
1007
1008 skb_put(skb, len);
1009 cmd = (struct htt_cmd *)skb->data;
1010 cmd->hdr.msg_type = HTT_H2T_MSG_TYPE_TX_FETCH_RESP;
1011 cmd->tx_fetch_resp.resp_id = cpu_to_le16(resp_id);
1012 cmd->tx_fetch_resp.fetch_seq_num = fetch_seq_num;
1013 cmd->tx_fetch_resp.num_records = cpu_to_le16(num_records);
1014 cmd->tx_fetch_resp.token = token;
1015
1016 memcpy(cmd->tx_fetch_resp.records, records,
1017 sizeof(records[0]) * num_records);
1018
1019 ret = ath10k_htc_send(&ar->htc, ar->htt.eid, skb);
1020 if (ret) {
1021 ath10k_warn(ar, "failed to submit htc command: %d\n", ret);
1022 goto err_free_skb;
1023 }
1024
1025 return 0;
1026
1027 err_free_skb:
1028 dev_kfree_skb_any(skb);
1029
1030 return ret;
1031 }
1032
ath10k_htt_tx_get_vdev_id(struct ath10k * ar,struct sk_buff * skb)1033 static u8 ath10k_htt_tx_get_vdev_id(struct ath10k *ar, struct sk_buff *skb)
1034 {
1035 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
1036 struct ath10k_skb_cb *cb = ATH10K_SKB_CB(skb);
1037 struct ath10k_vif *arvif;
1038
1039 if (info->flags & IEEE80211_TX_CTL_TX_OFFCHAN) {
1040 return ar->scan.vdev_id;
1041 } else if (cb->vif) {
1042 arvif = (void *)cb->vif->drv_priv;
1043 return arvif->vdev_id;
1044 } else if (ar->monitor_started) {
1045 return ar->monitor_vdev_id;
1046 } else {
1047 return 0;
1048 }
1049 }
1050
ath10k_htt_tx_get_tid(struct sk_buff * skb,bool is_eth)1051 static u8 ath10k_htt_tx_get_tid(struct sk_buff *skb, bool is_eth)
1052 {
1053 struct ieee80211_hdr *hdr = (void *)skb->data;
1054 struct ath10k_skb_cb *cb = ATH10K_SKB_CB(skb);
1055
1056 if (!is_eth && ieee80211_is_mgmt(hdr->frame_control))
1057 return HTT_DATA_TX_EXT_TID_MGMT;
1058 else if (cb->flags & ATH10K_SKB_F_QOS)
1059 return skb->priority & IEEE80211_QOS_CTL_TID_MASK;
1060 else
1061 return HTT_DATA_TX_EXT_TID_NON_QOS_MCAST_BCAST;
1062 }
1063
ath10k_htt_mgmt_tx(struct ath10k_htt * htt,struct sk_buff * msdu)1064 int ath10k_htt_mgmt_tx(struct ath10k_htt *htt, struct sk_buff *msdu)
1065 {
1066 struct ath10k *ar = htt->ar;
1067 struct device *dev = ar->dev;
1068 struct sk_buff *txdesc = NULL;
1069 struct htt_cmd *cmd;
1070 struct ath10k_skb_cb *skb_cb = ATH10K_SKB_CB(msdu);
1071 u8 vdev_id = ath10k_htt_tx_get_vdev_id(ar, msdu);
1072 int len = 0;
1073 int msdu_id = -1;
1074 int res;
1075 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)msdu->data;
1076
1077 len += sizeof(cmd->hdr);
1078 len += sizeof(cmd->mgmt_tx);
1079
1080 res = ath10k_htt_tx_alloc_msdu_id(htt, msdu);
1081 if (res < 0)
1082 goto err;
1083
1084 msdu_id = res;
1085
1086 if ((ieee80211_is_action(hdr->frame_control) ||
1087 ieee80211_is_deauth(hdr->frame_control) ||
1088 ieee80211_is_disassoc(hdr->frame_control)) &&
1089 ieee80211_has_protected(hdr->frame_control)) {
1090 skb_put(msdu, IEEE80211_CCMP_MIC_LEN);
1091 }
1092
1093 txdesc = ath10k_htc_alloc_skb(ar, len);
1094 if (!txdesc) {
1095 res = -ENOMEM;
1096 goto err_free_msdu_id;
1097 }
1098
1099 skb_cb->paddr = dma_map_single(dev, msdu->data, msdu->len,
1100 DMA_TO_DEVICE);
1101 res = dma_mapping_error(dev, skb_cb->paddr);
1102 if (res) {
1103 res = -EIO;
1104 goto err_free_txdesc;
1105 }
1106
1107 skb_put(txdesc, len);
1108 cmd = (struct htt_cmd *)txdesc->data;
1109 memset(cmd, 0, len);
1110
1111 cmd->hdr.msg_type = HTT_H2T_MSG_TYPE_MGMT_TX;
1112 cmd->mgmt_tx.msdu_paddr = __cpu_to_le32(ATH10K_SKB_CB(msdu)->paddr);
1113 cmd->mgmt_tx.len = __cpu_to_le32(msdu->len);
1114 cmd->mgmt_tx.desc_id = __cpu_to_le32(msdu_id);
1115 cmd->mgmt_tx.vdev_id = __cpu_to_le32(vdev_id);
1116 memcpy(cmd->mgmt_tx.hdr, msdu->data,
1117 min_t(int, msdu->len, HTT_MGMT_FRM_HDR_DOWNLOAD_LEN));
1118
1119 res = ath10k_htc_send(&htt->ar->htc, htt->eid, txdesc);
1120 if (res)
1121 goto err_unmap_msdu;
1122
1123 return 0;
1124
1125 err_unmap_msdu:
1126 dma_unmap_single(dev, skb_cb->paddr, msdu->len, DMA_TO_DEVICE);
1127 err_free_txdesc:
1128 dev_kfree_skb_any(txdesc);
1129 err_free_msdu_id:
1130 spin_lock_bh(&htt->tx_lock);
1131 ath10k_htt_tx_free_msdu_id(htt, msdu_id);
1132 spin_unlock_bh(&htt->tx_lock);
1133 err:
1134 return res;
1135 }
1136
ath10k_htt_tx_32(struct ath10k_htt * htt,enum ath10k_hw_txrx_mode txmode,struct sk_buff * msdu)1137 static int ath10k_htt_tx_32(struct ath10k_htt *htt,
1138 enum ath10k_hw_txrx_mode txmode,
1139 struct sk_buff *msdu)
1140 {
1141 struct ath10k *ar = htt->ar;
1142 struct device *dev = ar->dev;
1143 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)msdu->data;
1144 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(msdu);
1145 struct ath10k_skb_cb *skb_cb = ATH10K_SKB_CB(msdu);
1146 struct ath10k_hif_sg_item sg_items[2];
1147 struct ath10k_htt_txbuf_32 *txbuf;
1148 struct htt_data_tx_desc_frag *frags;
1149 bool is_eth = (txmode == ATH10K_HW_TXRX_ETHERNET);
1150 u8 vdev_id = ath10k_htt_tx_get_vdev_id(ar, msdu);
1151 u8 tid = ath10k_htt_tx_get_tid(msdu, is_eth);
1152 int prefetch_len;
1153 int res;
1154 u8 flags0 = 0;
1155 u16 msdu_id, flags1 = 0;
1156 u16 freq = 0;
1157 u32 frags_paddr = 0;
1158 u32 txbuf_paddr;
1159 struct htt_msdu_ext_desc *ext_desc = NULL;
1160 struct htt_msdu_ext_desc *ext_desc_t = NULL;
1161
1162 res = ath10k_htt_tx_alloc_msdu_id(htt, msdu);
1163 if (res < 0)
1164 goto err;
1165
1166 msdu_id = res;
1167
1168 prefetch_len = min(htt->prefetch_len, msdu->len);
1169 prefetch_len = roundup(prefetch_len, 4);
1170
1171 txbuf = htt->txbuf.vaddr_txbuff_32 + msdu_id;
1172 txbuf_paddr = htt->txbuf.paddr +
1173 (sizeof(struct ath10k_htt_txbuf_32) * msdu_id);
1174
1175 if ((ieee80211_is_action(hdr->frame_control) ||
1176 ieee80211_is_deauth(hdr->frame_control) ||
1177 ieee80211_is_disassoc(hdr->frame_control)) &&
1178 ieee80211_has_protected(hdr->frame_control)) {
1179 skb_put(msdu, IEEE80211_CCMP_MIC_LEN);
1180 } else if (!(skb_cb->flags & ATH10K_SKB_F_NO_HWCRYPT) &&
1181 txmode == ATH10K_HW_TXRX_RAW &&
1182 ieee80211_has_protected(hdr->frame_control)) {
1183 skb_put(msdu, IEEE80211_CCMP_MIC_LEN);
1184 }
1185
1186 skb_cb->paddr = dma_map_single(dev, msdu->data, msdu->len,
1187 DMA_TO_DEVICE);
1188 res = dma_mapping_error(dev, skb_cb->paddr);
1189 if (res) {
1190 res = -EIO;
1191 goto err_free_msdu_id;
1192 }
1193
1194 if (unlikely(info->flags & IEEE80211_TX_CTL_TX_OFFCHAN))
1195 freq = ar->scan.roc_freq;
1196
1197 switch (txmode) {
1198 case ATH10K_HW_TXRX_RAW:
1199 case ATH10K_HW_TXRX_NATIVE_WIFI:
1200 flags0 |= HTT_DATA_TX_DESC_FLAGS0_MAC_HDR_PRESENT;
1201 /* fall through */
1202 case ATH10K_HW_TXRX_ETHERNET:
1203 if (ar->hw_params.continuous_frag_desc) {
1204 ext_desc_t = htt->frag_desc.vaddr_desc_32;
1205 memset(&ext_desc_t[msdu_id], 0,
1206 sizeof(struct htt_msdu_ext_desc));
1207 frags = (struct htt_data_tx_desc_frag *)
1208 &ext_desc_t[msdu_id].frags;
1209 ext_desc = &ext_desc_t[msdu_id];
1210 frags[0].tword_addr.paddr_lo =
1211 __cpu_to_le32(skb_cb->paddr);
1212 frags[0].tword_addr.paddr_hi = 0;
1213 frags[0].tword_addr.len_16 = __cpu_to_le16(msdu->len);
1214
1215 frags_paddr = htt->frag_desc.paddr +
1216 (sizeof(struct htt_msdu_ext_desc) * msdu_id);
1217 } else {
1218 frags = txbuf->frags;
1219 frags[0].dword_addr.paddr =
1220 __cpu_to_le32(skb_cb->paddr);
1221 frags[0].dword_addr.len = __cpu_to_le32(msdu->len);
1222 frags[1].dword_addr.paddr = 0;
1223 frags[1].dword_addr.len = 0;
1224
1225 frags_paddr = txbuf_paddr;
1226 }
1227 flags0 |= SM(txmode, HTT_DATA_TX_DESC_FLAGS0_PKT_TYPE);
1228 break;
1229 case ATH10K_HW_TXRX_MGMT:
1230 flags0 |= SM(ATH10K_HW_TXRX_MGMT,
1231 HTT_DATA_TX_DESC_FLAGS0_PKT_TYPE);
1232 flags0 |= HTT_DATA_TX_DESC_FLAGS0_MAC_HDR_PRESENT;
1233
1234 frags_paddr = skb_cb->paddr;
1235 break;
1236 }
1237
1238 /* Normally all commands go through HTC which manages tx credits for
1239 * each endpoint and notifies when tx is completed.
1240 *
1241 * HTT endpoint is creditless so there's no need to care about HTC
1242 * flags. In that case it is trivial to fill the HTC header here.
1243 *
1244 * MSDU transmission is considered completed upon HTT event. This
1245 * implies no relevant resources can be freed until after the event is
1246 * received. That's why HTC tx completion handler itself is ignored by
1247 * setting NULL to transfer_context for all sg items.
1248 *
1249 * There is simply no point in pushing HTT TX_FRM through HTC tx path
1250 * as it's a waste of resources. By bypassing HTC it is possible to
1251 * avoid extra memory allocations, compress data structures and thus
1252 * improve performance.
1253 */
1254
1255 txbuf->htc_hdr.eid = htt->eid;
1256 txbuf->htc_hdr.len = __cpu_to_le16(sizeof(txbuf->cmd_hdr) +
1257 sizeof(txbuf->cmd_tx) +
1258 prefetch_len);
1259 txbuf->htc_hdr.flags = 0;
1260
1261 if (skb_cb->flags & ATH10K_SKB_F_NO_HWCRYPT)
1262 flags0 |= HTT_DATA_TX_DESC_FLAGS0_NO_ENCRYPT;
1263
1264 flags1 |= SM((u16)vdev_id, HTT_DATA_TX_DESC_FLAGS1_VDEV_ID);
1265 flags1 |= SM((u16)tid, HTT_DATA_TX_DESC_FLAGS1_EXT_TID);
1266 if (msdu->ip_summed == CHECKSUM_PARTIAL &&
1267 !test_bit(ATH10K_FLAG_RAW_MODE, &ar->dev_flags)) {
1268 flags1 |= HTT_DATA_TX_DESC_FLAGS1_CKSUM_L3_OFFLOAD;
1269 flags1 |= HTT_DATA_TX_DESC_FLAGS1_CKSUM_L4_OFFLOAD;
1270 if (ar->hw_params.continuous_frag_desc)
1271 ext_desc->flags |= HTT_MSDU_CHECKSUM_ENABLE;
1272 }
1273
1274 /* Prevent firmware from sending up tx inspection requests. There's
1275 * nothing ath10k can do with frames requested for inspection so force
1276 * it to simply rely a regular tx completion with discard status.
1277 */
1278 flags1 |= HTT_DATA_TX_DESC_FLAGS1_POSTPONED;
1279
1280 txbuf->cmd_hdr.msg_type = HTT_H2T_MSG_TYPE_TX_FRM;
1281 txbuf->cmd_tx.flags0 = flags0;
1282 txbuf->cmd_tx.flags1 = __cpu_to_le16(flags1);
1283 txbuf->cmd_tx.len = __cpu_to_le16(msdu->len);
1284 txbuf->cmd_tx.id = __cpu_to_le16(msdu_id);
1285 txbuf->cmd_tx.frags_paddr = __cpu_to_le32(frags_paddr);
1286 if (ath10k_mac_tx_frm_has_freq(ar)) {
1287 txbuf->cmd_tx.offchan_tx.peerid =
1288 __cpu_to_le16(HTT_INVALID_PEERID);
1289 txbuf->cmd_tx.offchan_tx.freq =
1290 __cpu_to_le16(freq);
1291 } else {
1292 txbuf->cmd_tx.peerid =
1293 __cpu_to_le32(HTT_INVALID_PEERID);
1294 }
1295
1296 trace_ath10k_htt_tx(ar, msdu_id, msdu->len, vdev_id, tid);
1297 ath10k_dbg(ar, ATH10K_DBG_HTT,
1298 "htt tx flags0 %hhu flags1 %hu len %d id %hu frags_paddr %pad, msdu_paddr %pad vdev %hhu tid %hhu freq %hu\n",
1299 flags0, flags1, msdu->len, msdu_id, &frags_paddr,
1300 &skb_cb->paddr, vdev_id, tid, freq);
1301 ath10k_dbg_dump(ar, ATH10K_DBG_HTT_DUMP, NULL, "htt tx msdu: ",
1302 msdu->data, msdu->len);
1303 trace_ath10k_tx_hdr(ar, msdu->data, msdu->len);
1304 trace_ath10k_tx_payload(ar, msdu->data, msdu->len);
1305
1306 sg_items[0].transfer_id = 0;
1307 sg_items[0].transfer_context = NULL;
1308 sg_items[0].vaddr = &txbuf->htc_hdr;
1309 sg_items[0].paddr = txbuf_paddr +
1310 sizeof(txbuf->frags);
1311 sg_items[0].len = sizeof(txbuf->htc_hdr) +
1312 sizeof(txbuf->cmd_hdr) +
1313 sizeof(txbuf->cmd_tx);
1314
1315 sg_items[1].transfer_id = 0;
1316 sg_items[1].transfer_context = NULL;
1317 sg_items[1].vaddr = msdu->data;
1318 sg_items[1].paddr = skb_cb->paddr;
1319 sg_items[1].len = prefetch_len;
1320
1321 res = ath10k_hif_tx_sg(htt->ar,
1322 htt->ar->htc.endpoint[htt->eid].ul_pipe_id,
1323 sg_items, ARRAY_SIZE(sg_items));
1324 if (res)
1325 goto err_unmap_msdu;
1326
1327 return 0;
1328
1329 err_unmap_msdu:
1330 dma_unmap_single(dev, skb_cb->paddr, msdu->len, DMA_TO_DEVICE);
1331 err_free_msdu_id:
1332 ath10k_htt_tx_free_msdu_id(htt, msdu_id);
1333 err:
1334 return res;
1335 }
1336
ath10k_htt_tx_64(struct ath10k_htt * htt,enum ath10k_hw_txrx_mode txmode,struct sk_buff * msdu)1337 static int ath10k_htt_tx_64(struct ath10k_htt *htt,
1338 enum ath10k_hw_txrx_mode txmode,
1339 struct sk_buff *msdu)
1340 {
1341 struct ath10k *ar = htt->ar;
1342 struct device *dev = ar->dev;
1343 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)msdu->data;
1344 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(msdu);
1345 struct ath10k_skb_cb *skb_cb = ATH10K_SKB_CB(msdu);
1346 struct ath10k_hif_sg_item sg_items[2];
1347 struct ath10k_htt_txbuf_64 *txbuf;
1348 struct htt_data_tx_desc_frag *frags;
1349 bool is_eth = (txmode == ATH10K_HW_TXRX_ETHERNET);
1350 u8 vdev_id = ath10k_htt_tx_get_vdev_id(ar, msdu);
1351 u8 tid = ath10k_htt_tx_get_tid(msdu, is_eth);
1352 int prefetch_len;
1353 int res;
1354 u8 flags0 = 0;
1355 u16 msdu_id, flags1 = 0;
1356 u16 freq = 0;
1357 dma_addr_t frags_paddr = 0;
1358 u32 txbuf_paddr;
1359 struct htt_msdu_ext_desc_64 *ext_desc = NULL;
1360 struct htt_msdu_ext_desc_64 *ext_desc_t = NULL;
1361
1362 res = ath10k_htt_tx_alloc_msdu_id(htt, msdu);
1363 if (res < 0)
1364 goto err;
1365
1366 msdu_id = res;
1367
1368 prefetch_len = min(htt->prefetch_len, msdu->len);
1369 prefetch_len = roundup(prefetch_len, 4);
1370
1371 txbuf = htt->txbuf.vaddr_txbuff_64 + msdu_id;
1372 txbuf_paddr = htt->txbuf.paddr +
1373 (sizeof(struct ath10k_htt_txbuf_64) * msdu_id);
1374
1375 if ((ieee80211_is_action(hdr->frame_control) ||
1376 ieee80211_is_deauth(hdr->frame_control) ||
1377 ieee80211_is_disassoc(hdr->frame_control)) &&
1378 ieee80211_has_protected(hdr->frame_control)) {
1379 skb_put(msdu, IEEE80211_CCMP_MIC_LEN);
1380 } else if (!(skb_cb->flags & ATH10K_SKB_F_NO_HWCRYPT) &&
1381 txmode == ATH10K_HW_TXRX_RAW &&
1382 ieee80211_has_protected(hdr->frame_control)) {
1383 skb_put(msdu, IEEE80211_CCMP_MIC_LEN);
1384 }
1385
1386 skb_cb->paddr = dma_map_single(dev, msdu->data, msdu->len,
1387 DMA_TO_DEVICE);
1388 res = dma_mapping_error(dev, skb_cb->paddr);
1389 if (res) {
1390 res = -EIO;
1391 goto err_free_msdu_id;
1392 }
1393
1394 if (unlikely(info->flags & IEEE80211_TX_CTL_TX_OFFCHAN))
1395 freq = ar->scan.roc_freq;
1396
1397 switch (txmode) {
1398 case ATH10K_HW_TXRX_RAW:
1399 case ATH10K_HW_TXRX_NATIVE_WIFI:
1400 flags0 |= HTT_DATA_TX_DESC_FLAGS0_MAC_HDR_PRESENT;
1401 /* fall through */
1402 case ATH10K_HW_TXRX_ETHERNET:
1403 if (ar->hw_params.continuous_frag_desc) {
1404 ext_desc_t = htt->frag_desc.vaddr_desc_64;
1405 memset(&ext_desc_t[msdu_id], 0,
1406 sizeof(struct htt_msdu_ext_desc_64));
1407 frags = (struct htt_data_tx_desc_frag *)
1408 &ext_desc_t[msdu_id].frags;
1409 ext_desc = &ext_desc_t[msdu_id];
1410 frags[0].tword_addr.paddr_lo =
1411 __cpu_to_le32(skb_cb->paddr);
1412 frags[0].tword_addr.paddr_hi =
1413 __cpu_to_le16(upper_32_bits(skb_cb->paddr));
1414 frags[0].tword_addr.len_16 = __cpu_to_le16(msdu->len);
1415
1416 frags_paddr = htt->frag_desc.paddr +
1417 (sizeof(struct htt_msdu_ext_desc_64) * msdu_id);
1418 } else {
1419 frags = txbuf->frags;
1420 frags[0].tword_addr.paddr_lo =
1421 __cpu_to_le32(skb_cb->paddr);
1422 frags[0].tword_addr.paddr_hi =
1423 __cpu_to_le16(upper_32_bits(skb_cb->paddr));
1424 frags[0].tword_addr.len_16 = __cpu_to_le16(msdu->len);
1425 frags[1].tword_addr.paddr_lo = 0;
1426 frags[1].tword_addr.paddr_hi = 0;
1427 frags[1].tword_addr.len_16 = 0;
1428 }
1429 flags0 |= SM(txmode, HTT_DATA_TX_DESC_FLAGS0_PKT_TYPE);
1430 break;
1431 case ATH10K_HW_TXRX_MGMT:
1432 flags0 |= SM(ATH10K_HW_TXRX_MGMT,
1433 HTT_DATA_TX_DESC_FLAGS0_PKT_TYPE);
1434 flags0 |= HTT_DATA_TX_DESC_FLAGS0_MAC_HDR_PRESENT;
1435
1436 frags_paddr = skb_cb->paddr;
1437 break;
1438 }
1439
1440 /* Normally all commands go through HTC which manages tx credits for
1441 * each endpoint and notifies when tx is completed.
1442 *
1443 * HTT endpoint is creditless so there's no need to care about HTC
1444 * flags. In that case it is trivial to fill the HTC header here.
1445 *
1446 * MSDU transmission is considered completed upon HTT event. This
1447 * implies no relevant resources can be freed until after the event is
1448 * received. That's why HTC tx completion handler itself is ignored by
1449 * setting NULL to transfer_context for all sg items.
1450 *
1451 * There is simply no point in pushing HTT TX_FRM through HTC tx path
1452 * as it's a waste of resources. By bypassing HTC it is possible to
1453 * avoid extra memory allocations, compress data structures and thus
1454 * improve performance.
1455 */
1456
1457 txbuf->htc_hdr.eid = htt->eid;
1458 txbuf->htc_hdr.len = __cpu_to_le16(sizeof(txbuf->cmd_hdr) +
1459 sizeof(txbuf->cmd_tx) +
1460 prefetch_len);
1461 txbuf->htc_hdr.flags = 0;
1462
1463 if (skb_cb->flags & ATH10K_SKB_F_NO_HWCRYPT)
1464 flags0 |= HTT_DATA_TX_DESC_FLAGS0_NO_ENCRYPT;
1465
1466 flags1 |= SM((u16)vdev_id, HTT_DATA_TX_DESC_FLAGS1_VDEV_ID);
1467 flags1 |= SM((u16)tid, HTT_DATA_TX_DESC_FLAGS1_EXT_TID);
1468 if (msdu->ip_summed == CHECKSUM_PARTIAL &&
1469 !test_bit(ATH10K_FLAG_RAW_MODE, &ar->dev_flags)) {
1470 flags1 |= HTT_DATA_TX_DESC_FLAGS1_CKSUM_L3_OFFLOAD;
1471 flags1 |= HTT_DATA_TX_DESC_FLAGS1_CKSUM_L4_OFFLOAD;
1472 if (ar->hw_params.continuous_frag_desc) {
1473 memset(ext_desc->tso_flag, 0, sizeof(ext_desc->tso_flag));
1474 ext_desc->tso_flag[3] |=
1475 __cpu_to_le32(HTT_MSDU_CHECKSUM_ENABLE_64);
1476 }
1477 }
1478
1479 /* Prevent firmware from sending up tx inspection requests. There's
1480 * nothing ath10k can do with frames requested for inspection so force
1481 * it to simply rely a regular tx completion with discard status.
1482 */
1483 flags1 |= HTT_DATA_TX_DESC_FLAGS1_POSTPONED;
1484
1485 txbuf->cmd_hdr.msg_type = HTT_H2T_MSG_TYPE_TX_FRM;
1486 txbuf->cmd_tx.flags0 = flags0;
1487 txbuf->cmd_tx.flags1 = __cpu_to_le16(flags1);
1488 txbuf->cmd_tx.len = __cpu_to_le16(msdu->len);
1489 txbuf->cmd_tx.id = __cpu_to_le16(msdu_id);
1490
1491 /* fill fragment descriptor */
1492 txbuf->cmd_tx.frags_paddr = __cpu_to_le64(frags_paddr);
1493 if (ath10k_mac_tx_frm_has_freq(ar)) {
1494 txbuf->cmd_tx.offchan_tx.peerid =
1495 __cpu_to_le16(HTT_INVALID_PEERID);
1496 txbuf->cmd_tx.offchan_tx.freq =
1497 __cpu_to_le16(freq);
1498 } else {
1499 txbuf->cmd_tx.peerid =
1500 __cpu_to_le32(HTT_INVALID_PEERID);
1501 }
1502
1503 trace_ath10k_htt_tx(ar, msdu_id, msdu->len, vdev_id, tid);
1504 ath10k_dbg(ar, ATH10K_DBG_HTT,
1505 "htt tx flags0 %hhu flags1 %hu len %d id %hu frags_paddr %pad, msdu_paddr %pad vdev %hhu tid %hhu freq %hu\n",
1506 flags0, flags1, msdu->len, msdu_id, &frags_paddr,
1507 &skb_cb->paddr, vdev_id, tid, freq);
1508 ath10k_dbg_dump(ar, ATH10K_DBG_HTT_DUMP, NULL, "htt tx msdu: ",
1509 msdu->data, msdu->len);
1510 trace_ath10k_tx_hdr(ar, msdu->data, msdu->len);
1511 trace_ath10k_tx_payload(ar, msdu->data, msdu->len);
1512
1513 sg_items[0].transfer_id = 0;
1514 sg_items[0].transfer_context = NULL;
1515 sg_items[0].vaddr = &txbuf->htc_hdr;
1516 sg_items[0].paddr = txbuf_paddr +
1517 sizeof(txbuf->frags);
1518 sg_items[0].len = sizeof(txbuf->htc_hdr) +
1519 sizeof(txbuf->cmd_hdr) +
1520 sizeof(txbuf->cmd_tx);
1521
1522 sg_items[1].transfer_id = 0;
1523 sg_items[1].transfer_context = NULL;
1524 sg_items[1].vaddr = msdu->data;
1525 sg_items[1].paddr = skb_cb->paddr;
1526 sg_items[1].len = prefetch_len;
1527
1528 res = ath10k_hif_tx_sg(htt->ar,
1529 htt->ar->htc.endpoint[htt->eid].ul_pipe_id,
1530 sg_items, ARRAY_SIZE(sg_items));
1531 if (res)
1532 goto err_unmap_msdu;
1533
1534 return 0;
1535
1536 err_unmap_msdu:
1537 dma_unmap_single(dev, skb_cb->paddr, msdu->len, DMA_TO_DEVICE);
1538 err_free_msdu_id:
1539 ath10k_htt_tx_free_msdu_id(htt, msdu_id);
1540 err:
1541 return res;
1542 }
1543
1544 static const struct ath10k_htt_tx_ops htt_tx_ops_32 = {
1545 .htt_send_rx_ring_cfg = ath10k_htt_send_rx_ring_cfg_32,
1546 .htt_send_frag_desc_bank_cfg = ath10k_htt_send_frag_desc_bank_cfg_32,
1547 .htt_alloc_frag_desc = ath10k_htt_tx_alloc_cont_frag_desc_32,
1548 .htt_free_frag_desc = ath10k_htt_tx_free_cont_frag_desc_32,
1549 .htt_tx = ath10k_htt_tx_32,
1550 .htt_alloc_txbuff = ath10k_htt_tx_alloc_cont_txbuf_32,
1551 .htt_free_txbuff = ath10k_htt_tx_free_cont_txbuf_32,
1552 };
1553
1554 static const struct ath10k_htt_tx_ops htt_tx_ops_64 = {
1555 .htt_send_rx_ring_cfg = ath10k_htt_send_rx_ring_cfg_64,
1556 .htt_send_frag_desc_bank_cfg = ath10k_htt_send_frag_desc_bank_cfg_64,
1557 .htt_alloc_frag_desc = ath10k_htt_tx_alloc_cont_frag_desc_64,
1558 .htt_free_frag_desc = ath10k_htt_tx_free_cont_frag_desc_64,
1559 .htt_tx = ath10k_htt_tx_64,
1560 .htt_alloc_txbuff = ath10k_htt_tx_alloc_cont_txbuf_64,
1561 .htt_free_txbuff = ath10k_htt_tx_free_cont_txbuf_64,
1562 };
1563
ath10k_htt_set_tx_ops(struct ath10k_htt * htt)1564 void ath10k_htt_set_tx_ops(struct ath10k_htt *htt)
1565 {
1566 struct ath10k *ar = htt->ar;
1567
1568 if (ar->hw_params.target_64bit)
1569 htt->tx_ops = &htt_tx_ops_64;
1570 else
1571 htt->tx_ops = &htt_tx_ops_32;
1572 }
1573