blob: 617df96e4ffd422e7cc12652b5d5671f259d6e31 [file] [log] [blame]
Kalle Valo5e3dd152013-06-12 20:52:10 +03001/*
2 * Copyright (c) 2005-2011 Atheros Communications Inc.
3 * Copyright (c) 2011-2013 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
Michal Kazioredb82362013-07-05 16:15:14 +030018#include "core.h"
Kalle Valo5e3dd152013-06-12 20:52:10 +030019#include "htc.h"
20#include "htt.h"
21#include "txrx.h"
22#include "debug.h"
Kalle Valoa9bf0502013-09-03 11:43:55 +030023#include "trace.h"
Kalle Valo5e3dd152013-06-12 20:52:10 +030024
25#include <linux/log2.h>
26
27/* slightly larger than one large A-MPDU */
28#define HTT_RX_RING_SIZE_MIN 128
29
30/* roughly 20 ms @ 1 Gbps of 1500B MSDUs */
31#define HTT_RX_RING_SIZE_MAX 2048
32
33#define HTT_RX_AVG_FRM_BYTES 1000
34
35/* ms, very conservative */
36#define HTT_RX_HOST_LATENCY_MAX_MS 20
37
38/* ms, conservative */
39#define HTT_RX_HOST_LATENCY_WORST_LIKELY_MS 10
40
41/* when under memory pressure rx ring refill may fail and needs a retry */
42#define HTT_RX_RING_REFILL_RETRY_MS 50
43
Michal Kaziorf6dc2092013-09-26 10:12:22 +030044
45static int ath10k_htt_rx_get_csum_state(struct sk_buff *skb);
46
47
Kalle Valo5e3dd152013-06-12 20:52:10 +030048static int ath10k_htt_rx_ring_size(struct ath10k_htt *htt)
49{
50 int size;
51
52 /*
53 * It is expected that the host CPU will typically be able to
54 * service the rx indication from one A-MPDU before the rx
55 * indication from the subsequent A-MPDU happens, roughly 1-2 ms
56 * later. However, the rx ring should be sized very conservatively,
57 * to accomodate the worst reasonable delay before the host CPU
58 * services a rx indication interrupt.
59 *
60 * The rx ring need not be kept full of empty buffers. In theory,
61 * the htt host SW can dynamically track the low-water mark in the
62 * rx ring, and dynamically adjust the level to which the rx ring
63 * is filled with empty buffers, to dynamically meet the desired
64 * low-water mark.
65 *
66 * In contrast, it's difficult to resize the rx ring itself, once
67 * it's in use. Thus, the ring itself should be sized very
68 * conservatively, while the degree to which the ring is filled
69 * with empty buffers should be sized moderately conservatively.
70 */
71
72 /* 1e6 bps/mbps / 1e3 ms per sec = 1000 */
73 size =
74 htt->max_throughput_mbps +
75 1000 /
76 (8 * HTT_RX_AVG_FRM_BYTES) * HTT_RX_HOST_LATENCY_MAX_MS;
77
78 if (size < HTT_RX_RING_SIZE_MIN)
79 size = HTT_RX_RING_SIZE_MIN;
80
81 if (size > HTT_RX_RING_SIZE_MAX)
82 size = HTT_RX_RING_SIZE_MAX;
83
84 size = roundup_pow_of_two(size);
85
86 return size;
87}
88
89static int ath10k_htt_rx_ring_fill_level(struct ath10k_htt *htt)
90{
91 int size;
92
93 /* 1e6 bps/mbps / 1e3 ms per sec = 1000 */
94 size =
95 htt->max_throughput_mbps *
96 1000 /
97 (8 * HTT_RX_AVG_FRM_BYTES) * HTT_RX_HOST_LATENCY_WORST_LIKELY_MS;
98
99 /*
100 * Make sure the fill level is at least 1 less than the ring size.
101 * Leaving 1 element empty allows the SW to easily distinguish
102 * between a full ring vs. an empty ring.
103 */
104 if (size >= htt->rx_ring.size)
105 size = htt->rx_ring.size - 1;
106
107 return size;
108}
109
110static void ath10k_htt_rx_ring_free(struct ath10k_htt *htt)
111{
112 struct sk_buff *skb;
113 struct ath10k_skb_cb *cb;
114 int i;
115
116 for (i = 0; i < htt->rx_ring.fill_cnt; i++) {
117 skb = htt->rx_ring.netbufs_ring[i];
118 cb = ATH10K_SKB_CB(skb);
119 dma_unmap_single(htt->ar->dev, cb->paddr,
120 skb->len + skb_tailroom(skb),
121 DMA_FROM_DEVICE);
122 dev_kfree_skb_any(skb);
123 }
124
125 htt->rx_ring.fill_cnt = 0;
126}
127
128static int __ath10k_htt_rx_ring_fill_n(struct ath10k_htt *htt, int num)
129{
130 struct htt_rx_desc *rx_desc;
131 struct sk_buff *skb;
132 dma_addr_t paddr;
133 int ret = 0, idx;
134
135 idx = __le32_to_cpu(*(htt->rx_ring.alloc_idx.vaddr));
136 while (num > 0) {
137 skb = dev_alloc_skb(HTT_RX_BUF_SIZE + HTT_RX_DESC_ALIGN);
138 if (!skb) {
139 ret = -ENOMEM;
140 goto fail;
141 }
142
143 if (!IS_ALIGNED((unsigned long)skb->data, HTT_RX_DESC_ALIGN))
144 skb_pull(skb,
145 PTR_ALIGN(skb->data, HTT_RX_DESC_ALIGN) -
146 skb->data);
147
148 /* Clear rx_desc attention word before posting to Rx ring */
149 rx_desc = (struct htt_rx_desc *)skb->data;
150 rx_desc->attention.flags = __cpu_to_le32(0);
151
152 paddr = dma_map_single(htt->ar->dev, skb->data,
153 skb->len + skb_tailroom(skb),
154 DMA_FROM_DEVICE);
155
156 if (unlikely(dma_mapping_error(htt->ar->dev, paddr))) {
157 dev_kfree_skb_any(skb);
158 ret = -ENOMEM;
159 goto fail;
160 }
161
162 ATH10K_SKB_CB(skb)->paddr = paddr;
163 htt->rx_ring.netbufs_ring[idx] = skb;
164 htt->rx_ring.paddrs_ring[idx] = __cpu_to_le32(paddr);
165 htt->rx_ring.fill_cnt++;
166
167 num--;
168 idx++;
169 idx &= htt->rx_ring.size_mask;
170 }
171
172fail:
173 *(htt->rx_ring.alloc_idx.vaddr) = __cpu_to_le32(idx);
174 return ret;
175}
176
177static int ath10k_htt_rx_ring_fill_n(struct ath10k_htt *htt, int num)
178{
179 lockdep_assert_held(&htt->rx_ring.lock);
180 return __ath10k_htt_rx_ring_fill_n(htt, num);
181}
182
183static void ath10k_htt_rx_msdu_buff_replenish(struct ath10k_htt *htt)
184{
185 int ret, num_to_fill;
186
187 spin_lock_bh(&htt->rx_ring.lock);
188 num_to_fill = htt->rx_ring.fill_level - htt->rx_ring.fill_cnt;
189 ret = ath10k_htt_rx_ring_fill_n(htt, num_to_fill);
190 if (ret == -ENOMEM) {
191 /*
192 * Failed to fill it to the desired level -
193 * we'll start a timer and try again next time.
194 * As long as enough buffers are left in the ring for
195 * another A-MPDU rx, no special recovery is needed.
196 */
197 mod_timer(&htt->rx_ring.refill_retry_timer, jiffies +
198 msecs_to_jiffies(HTT_RX_RING_REFILL_RETRY_MS));
199 }
200 spin_unlock_bh(&htt->rx_ring.lock);
201}
202
203static void ath10k_htt_rx_ring_refill_retry(unsigned long arg)
204{
205 struct ath10k_htt *htt = (struct ath10k_htt *)arg;
206 ath10k_htt_rx_msdu_buff_replenish(htt);
207}
208
209static unsigned ath10k_htt_rx_ring_elems(struct ath10k_htt *htt)
210{
211 return (__le32_to_cpu(*htt->rx_ring.alloc_idx.vaddr) -
212 htt->rx_ring.sw_rd_idx.msdu_payld) & htt->rx_ring.size_mask;
213}
214
215void ath10k_htt_rx_detach(struct ath10k_htt *htt)
216{
217 int sw_rd_idx = htt->rx_ring.sw_rd_idx.msdu_payld;
218
219 del_timer_sync(&htt->rx_ring.refill_retry_timer);
220
221 while (sw_rd_idx != __le32_to_cpu(*(htt->rx_ring.alloc_idx.vaddr))) {
222 struct sk_buff *skb =
223 htt->rx_ring.netbufs_ring[sw_rd_idx];
224 struct ath10k_skb_cb *cb = ATH10K_SKB_CB(skb);
225
226 dma_unmap_single(htt->ar->dev, cb->paddr,
227 skb->len + skb_tailroom(skb),
228 DMA_FROM_DEVICE);
229 dev_kfree_skb_any(htt->rx_ring.netbufs_ring[sw_rd_idx]);
230 sw_rd_idx++;
231 sw_rd_idx &= htt->rx_ring.size_mask;
232 }
233
234 dma_free_coherent(htt->ar->dev,
235 (htt->rx_ring.size *
236 sizeof(htt->rx_ring.paddrs_ring)),
237 htt->rx_ring.paddrs_ring,
238 htt->rx_ring.base_paddr);
239
240 dma_free_coherent(htt->ar->dev,
241 sizeof(*htt->rx_ring.alloc_idx.vaddr),
242 htt->rx_ring.alloc_idx.vaddr,
243 htt->rx_ring.alloc_idx.paddr);
244
245 kfree(htt->rx_ring.netbufs_ring);
246}
247
248static inline struct sk_buff *ath10k_htt_rx_netbuf_pop(struct ath10k_htt *htt)
249{
250 int idx;
251 struct sk_buff *msdu;
252
253 spin_lock_bh(&htt->rx_ring.lock);
254
255 if (ath10k_htt_rx_ring_elems(htt) == 0)
256 ath10k_warn("htt rx ring is empty!\n");
257
258 idx = htt->rx_ring.sw_rd_idx.msdu_payld;
259 msdu = htt->rx_ring.netbufs_ring[idx];
260
261 idx++;
262 idx &= htt->rx_ring.size_mask;
263 htt->rx_ring.sw_rd_idx.msdu_payld = idx;
264 htt->rx_ring.fill_cnt--;
265
266 spin_unlock_bh(&htt->rx_ring.lock);
267 return msdu;
268}
269
270static void ath10k_htt_rx_free_msdu_chain(struct sk_buff *skb)
271{
272 struct sk_buff *next;
273
274 while (skb) {
275 next = skb->next;
276 dev_kfree_skb_any(skb);
277 skb = next;
278 }
279}
280
281static int ath10k_htt_rx_amsdu_pop(struct ath10k_htt *htt,
282 u8 **fw_desc, int *fw_desc_len,
283 struct sk_buff **head_msdu,
284 struct sk_buff **tail_msdu)
285{
286 int msdu_len, msdu_chaining = 0;
287 struct sk_buff *msdu;
288 struct htt_rx_desc *rx_desc;
289
290 if (ath10k_htt_rx_ring_elems(htt) == 0)
291 ath10k_warn("htt rx ring is empty!\n");
292
293 if (htt->rx_confused) {
294 ath10k_warn("htt is confused. refusing rx\n");
295 return 0;
296 }
297
298 msdu = *head_msdu = ath10k_htt_rx_netbuf_pop(htt);
299 while (msdu) {
300 int last_msdu, msdu_len_invalid, msdu_chained;
301
302 dma_unmap_single(htt->ar->dev,
303 ATH10K_SKB_CB(msdu)->paddr,
304 msdu->len + skb_tailroom(msdu),
305 DMA_FROM_DEVICE);
306
307 ath10k_dbg_dump(ATH10K_DBG_HTT_DUMP, NULL, "htt rx: ",
308 msdu->data, msdu->len + skb_tailroom(msdu));
309
310 rx_desc = (struct htt_rx_desc *)msdu->data;
311
312 /* FIXME: we must report msdu payload since this is what caller
313 * expects now */
314 skb_put(msdu, offsetof(struct htt_rx_desc, msdu_payload));
315 skb_pull(msdu, offsetof(struct htt_rx_desc, msdu_payload));
316
317 /*
318 * Sanity check - confirm the HW is finished filling in the
319 * rx data.
320 * If the HW and SW are working correctly, then it's guaranteed
321 * that the HW's MAC DMA is done before this point in the SW.
322 * To prevent the case that we handle a stale Rx descriptor,
323 * just assert for now until we have a way to recover.
324 */
325 if (!(__le32_to_cpu(rx_desc->attention.flags)
326 & RX_ATTENTION_FLAGS_MSDU_DONE)) {
327 ath10k_htt_rx_free_msdu_chain(*head_msdu);
328 *head_msdu = NULL;
329 msdu = NULL;
330 ath10k_err("htt rx stopped. cannot recover\n");
331 htt->rx_confused = true;
332 break;
333 }
334
335 /*
336 * Copy the FW rx descriptor for this MSDU from the rx
337 * indication message into the MSDU's netbuf. HL uses the
338 * same rx indication message definition as LL, and simply
339 * appends new info (fields from the HW rx desc, and the
340 * MSDU payload itself). So, the offset into the rx
341 * indication message only has to account for the standard
342 * offset of the per-MSDU FW rx desc info within the
343 * message, and how many bytes of the per-MSDU FW rx desc
344 * info have already been consumed. (And the endianness of
345 * the host, since for a big-endian host, the rx ind
346 * message contents, including the per-MSDU rx desc bytes,
347 * were byteswapped during upload.)
348 */
349 if (*fw_desc_len > 0) {
350 rx_desc->fw_desc.info0 = **fw_desc;
351 /*
352 * The target is expected to only provide the basic
353 * per-MSDU rx descriptors. Just to be sure, verify
354 * that the target has not attached extension data
355 * (e.g. LRO flow ID).
356 */
357
358 /* or more, if there's extension data */
359 (*fw_desc)++;
360 (*fw_desc_len)--;
361 } else {
362 /*
363 * When an oversized AMSDU happened, FW will lost
364 * some of MSDU status - in this case, the FW
365 * descriptors provided will be less than the
366 * actual MSDUs inside this MPDU. Mark the FW
367 * descriptors so that it will still deliver to
368 * upper stack, if no CRC error for this MPDU.
369 *
370 * FIX THIS - the FW descriptors are actually for
371 * MSDUs in the end of this A-MSDU instead of the
372 * beginning.
373 */
374 rx_desc->fw_desc.info0 = 0;
375 }
376
377 msdu_len_invalid = !!(__le32_to_cpu(rx_desc->attention.flags)
378 & (RX_ATTENTION_FLAGS_MPDU_LENGTH_ERR |
379 RX_ATTENTION_FLAGS_MSDU_LENGTH_ERR));
380 msdu_len = MS(__le32_to_cpu(rx_desc->msdu_start.info0),
381 RX_MSDU_START_INFO0_MSDU_LENGTH);
382 msdu_chained = rx_desc->frag_info.ring2_more_count;
383
384 if (msdu_len_invalid)
385 msdu_len = 0;
386
387 skb_trim(msdu, 0);
388 skb_put(msdu, min(msdu_len, HTT_RX_MSDU_SIZE));
389 msdu_len -= msdu->len;
390
391 /* FIXME: Do chained buffers include htt_rx_desc or not? */
392 while (msdu_chained--) {
393 struct sk_buff *next = ath10k_htt_rx_netbuf_pop(htt);
394
395 dma_unmap_single(htt->ar->dev,
396 ATH10K_SKB_CB(next)->paddr,
397 next->len + skb_tailroom(next),
398 DMA_FROM_DEVICE);
399
400 ath10k_dbg_dump(ATH10K_DBG_HTT_DUMP, NULL, "htt rx: ",
401 next->data,
402 next->len + skb_tailroom(next));
403
404 skb_trim(next, 0);
405 skb_put(next, min(msdu_len, HTT_RX_BUF_SIZE));
406 msdu_len -= next->len;
407
408 msdu->next = next;
409 msdu = next;
410 msdu_chaining = 1;
411 }
412
413 if (msdu_len > 0) {
414 /* This may suggest FW bug? */
415 ath10k_warn("htt rx msdu len not consumed (%d)\n",
416 msdu_len);
417 }
418
419 last_msdu = __le32_to_cpu(rx_desc->msdu_end.info0) &
420 RX_MSDU_END_INFO0_LAST_MSDU;
421
422 if (last_msdu) {
423 msdu->next = NULL;
424 break;
425 } else {
426 struct sk_buff *next = ath10k_htt_rx_netbuf_pop(htt);
427 msdu->next = next;
428 msdu = next;
429 }
430 }
431 *tail_msdu = msdu;
432
433 /*
434 * Don't refill the ring yet.
435 *
436 * First, the elements popped here are still in use - it is not
437 * safe to overwrite them until the matching call to
438 * mpdu_desc_list_next. Second, for efficiency it is preferable to
439 * refill the rx ring with 1 PPDU's worth of rx buffers (something
440 * like 32 x 3 buffers), rather than one MPDU's worth of rx buffers
441 * (something like 3 buffers). Consequently, we'll rely on the txrx
442 * SW to tell us when it is done pulling all the PPDU's rx buffers
443 * out of the rx ring, and then refill it just once.
444 */
445
446 return msdu_chaining;
447}
448
449int ath10k_htt_rx_attach(struct ath10k_htt *htt)
450{
451 dma_addr_t paddr;
452 void *vaddr;
453 struct timer_list *timer = &htt->rx_ring.refill_retry_timer;
454
455 htt->rx_ring.size = ath10k_htt_rx_ring_size(htt);
456 if (!is_power_of_2(htt->rx_ring.size)) {
457 ath10k_warn("htt rx ring size is not power of 2\n");
458 return -EINVAL;
459 }
460
461 htt->rx_ring.size_mask = htt->rx_ring.size - 1;
462
463 /*
464 * Set the initial value for the level to which the rx ring
465 * should be filled, based on the max throughput and the
466 * worst likely latency for the host to fill the rx ring
467 * with new buffers. In theory, this fill level can be
468 * dynamically adjusted from the initial value set here, to
469 * reflect the actual host latency rather than a
470 * conservative assumption about the host latency.
471 */
472 htt->rx_ring.fill_level = ath10k_htt_rx_ring_fill_level(htt);
473
474 htt->rx_ring.netbufs_ring =
475 kmalloc(htt->rx_ring.size * sizeof(struct sk_buff *),
476 GFP_KERNEL);
477 if (!htt->rx_ring.netbufs_ring)
478 goto err_netbuf;
479
480 vaddr = dma_alloc_coherent(htt->ar->dev,
481 (htt->rx_ring.size * sizeof(htt->rx_ring.paddrs_ring)),
482 &paddr, GFP_DMA);
483 if (!vaddr)
484 goto err_dma_ring;
485
486 htt->rx_ring.paddrs_ring = vaddr;
487 htt->rx_ring.base_paddr = paddr;
488
489 vaddr = dma_alloc_coherent(htt->ar->dev,
490 sizeof(*htt->rx_ring.alloc_idx.vaddr),
491 &paddr, GFP_DMA);
492 if (!vaddr)
493 goto err_dma_idx;
494
495 htt->rx_ring.alloc_idx.vaddr = vaddr;
496 htt->rx_ring.alloc_idx.paddr = paddr;
497 htt->rx_ring.sw_rd_idx.msdu_payld = 0;
498 *htt->rx_ring.alloc_idx.vaddr = 0;
499
500 /* Initialize the Rx refill retry timer */
501 setup_timer(timer, ath10k_htt_rx_ring_refill_retry, (unsigned long)htt);
502
503 spin_lock_init(&htt->rx_ring.lock);
504
505 htt->rx_ring.fill_cnt = 0;
506 if (__ath10k_htt_rx_ring_fill_n(htt, htt->rx_ring.fill_level))
507 goto err_fill_ring;
508
Kalle Valoaad0b652013-09-08 17:56:02 +0300509 ath10k_dbg(ATH10K_DBG_BOOT, "htt rx ring size %d fill_level %d\n",
Kalle Valo5e3dd152013-06-12 20:52:10 +0300510 htt->rx_ring.size, htt->rx_ring.fill_level);
511 return 0;
512
513err_fill_ring:
514 ath10k_htt_rx_ring_free(htt);
515 dma_free_coherent(htt->ar->dev,
516 sizeof(*htt->rx_ring.alloc_idx.vaddr),
517 htt->rx_ring.alloc_idx.vaddr,
518 htt->rx_ring.alloc_idx.paddr);
519err_dma_idx:
520 dma_free_coherent(htt->ar->dev,
521 (htt->rx_ring.size *
522 sizeof(htt->rx_ring.paddrs_ring)),
523 htt->rx_ring.paddrs_ring,
524 htt->rx_ring.base_paddr);
525err_dma_ring:
526 kfree(htt->rx_ring.netbufs_ring);
527err_netbuf:
528 return -ENOMEM;
529}
530
531static int ath10k_htt_rx_crypto_param_len(enum htt_rx_mpdu_encrypt_type type)
532{
533 switch (type) {
534 case HTT_RX_MPDU_ENCRYPT_WEP40:
535 case HTT_RX_MPDU_ENCRYPT_WEP104:
536 return 4;
537 case HTT_RX_MPDU_ENCRYPT_TKIP_WITHOUT_MIC:
538 case HTT_RX_MPDU_ENCRYPT_WEP128: /* not tested */
539 case HTT_RX_MPDU_ENCRYPT_TKIP_WPA:
540 case HTT_RX_MPDU_ENCRYPT_WAPI: /* not tested */
541 case HTT_RX_MPDU_ENCRYPT_AES_CCM_WPA2:
542 return 8;
543 case HTT_RX_MPDU_ENCRYPT_NONE:
544 return 0;
545 }
546
547 ath10k_warn("unknown encryption type %d\n", type);
548 return 0;
549}
550
551static int ath10k_htt_rx_crypto_tail_len(enum htt_rx_mpdu_encrypt_type type)
552{
553 switch (type) {
554 case HTT_RX_MPDU_ENCRYPT_NONE:
555 case HTT_RX_MPDU_ENCRYPT_WEP40:
556 case HTT_RX_MPDU_ENCRYPT_WEP104:
557 case HTT_RX_MPDU_ENCRYPT_WEP128:
558 case HTT_RX_MPDU_ENCRYPT_WAPI:
559 return 0;
560 case HTT_RX_MPDU_ENCRYPT_TKIP_WITHOUT_MIC:
561 case HTT_RX_MPDU_ENCRYPT_TKIP_WPA:
562 return 4;
563 case HTT_RX_MPDU_ENCRYPT_AES_CCM_WPA2:
564 return 8;
565 }
566
567 ath10k_warn("unknown encryption type %d\n", type);
568 return 0;
569}
570
571/* Applies for first msdu in chain, before altering it. */
572static struct ieee80211_hdr *ath10k_htt_rx_skb_get_hdr(struct sk_buff *skb)
573{
574 struct htt_rx_desc *rxd;
575 enum rx_msdu_decap_format fmt;
576
577 rxd = (void *)skb->data - sizeof(*rxd);
578 fmt = MS(__le32_to_cpu(rxd->msdu_start.info1),
579 RX_MSDU_START_INFO1_DECAP_FORMAT);
580
581 if (fmt == RX_MSDU_DECAP_RAW)
582 return (void *)skb->data;
583 else
584 return (void *)skb->data - RX_HTT_HDR_STATUS_LEN;
585}
586
587/* This function only applies for first msdu in an msdu chain */
588static bool ath10k_htt_rx_hdr_is_amsdu(struct ieee80211_hdr *hdr)
589{
590 if (ieee80211_is_data_qos(hdr->frame_control)) {
591 u8 *qc = ieee80211_get_qos_ctl(hdr);
592 if (qc[0] & 0x80)
593 return true;
594 }
595 return false;
596}
597
Michal Kaziorf6dc2092013-09-26 10:12:22 +0300598struct rfc1042_hdr {
599 u8 llc_dsap;
600 u8 llc_ssap;
601 u8 llc_ctrl;
602 u8 snap_oui[3];
603 __be16 snap_type;
604} __packed;
605
606struct amsdu_subframe_hdr {
607 u8 dst[ETH_ALEN];
608 u8 src[ETH_ALEN];
609 __be16 len;
610} __packed;
611
612static void ath10k_htt_rx_amsdu(struct ath10k_htt *htt,
613 struct htt_rx_info *info)
Kalle Valo5e3dd152013-06-12 20:52:10 +0300614{
615 struct htt_rx_desc *rxd;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300616 struct sk_buff *first;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300617 struct sk_buff *skb = info->skb;
618 enum rx_msdu_decap_format fmt;
619 enum htt_rx_mpdu_encrypt_type enctype;
Michal Kaziorf6dc2092013-09-26 10:12:22 +0300620 struct ieee80211_hdr *hdr;
621 u8 hdr_buf[64];
Kalle Valo5e3dd152013-06-12 20:52:10 +0300622 unsigned int hdr_len;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300623
624 rxd = (void *)skb->data - sizeof(*rxd);
Kalle Valo5e3dd152013-06-12 20:52:10 +0300625 enctype = MS(__le32_to_cpu(rxd->mpdu_start.info0),
626 RX_MPDU_START_INFO0_ENCRYPT_TYPE);
627
Michal Kaziorf6dc2092013-09-26 10:12:22 +0300628 hdr = (struct ieee80211_hdr *)rxd->rx_hdr_status;
629 hdr_len = ieee80211_hdrlen(hdr->frame_control);
630 memcpy(hdr_buf, hdr, hdr_len);
631 hdr = (struct ieee80211_hdr *)hdr_buf;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300632
Michal Kaziorf6dc2092013-09-26 10:12:22 +0300633 /* FIXME: Hopefully this is a temporary measure.
634 *
635 * Reporting individual A-MSDU subframes means each reported frame
636 * shares the same sequence number.
637 *
638 * mac80211 drops frames it recognizes as duplicates, i.e.
639 * retransmission flag is set and sequence number matches sequence
640 * number from a previous frame (as per IEEE 802.11-2012: 9.3.2.10
641 * "Duplicate detection and recovery")
642 *
643 * To avoid frames being dropped clear retransmission flag for all
644 * received A-MSDUs.
645 *
646 * Worst case: actual duplicate frames will be reported but this should
647 * still be handled gracefully by other OSI/ISO layers. */
648 hdr->frame_control &= cpu_to_le16(~IEEE80211_FCTL_RETRY);
Kalle Valo5e3dd152013-06-12 20:52:10 +0300649
650 first = skb;
651 while (skb) {
652 void *decap_hdr;
Michal Kaziorf6dc2092013-09-26 10:12:22 +0300653 int len;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300654
655 rxd = (void *)skb->data - sizeof(*rxd);
656 fmt = MS(__le32_to_cpu(rxd->msdu_start.info1),
Michal Kaziorf6dc2092013-09-26 10:12:22 +0300657 RX_MSDU_START_INFO1_DECAP_FORMAT);
Kalle Valo5e3dd152013-06-12 20:52:10 +0300658 decap_hdr = (void *)rxd->rx_hdr_status;
659
Michal Kaziorf6dc2092013-09-26 10:12:22 +0300660 skb->ip_summed = ath10k_htt_rx_get_csum_state(skb);
661
662 /* First frame in an A-MSDU chain has more decapped data. */
Kalle Valo5e3dd152013-06-12 20:52:10 +0300663 if (skb == first) {
Michal Kaziorf6dc2092013-09-26 10:12:22 +0300664 len = round_up(ieee80211_hdrlen(hdr->frame_control), 4);
665 len += round_up(ath10k_htt_rx_crypto_param_len(enctype),
666 4);
667 decap_hdr += len;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300668 }
669
Michal Kaziorf6dc2092013-09-26 10:12:22 +0300670 switch (fmt) {
671 case RX_MSDU_DECAP_RAW:
672 skb_trim(skb, skb->len - FCS_LEN);
673 break;
674 case RX_MSDU_DECAP_NATIVE_WIFI:
675 break;
676 case RX_MSDU_DECAP_ETHERNET2_DIX:
677 len = 0;
678 len += sizeof(struct rfc1042_hdr);
679 len += sizeof(struct amsdu_subframe_hdr);
Michal Kaziordfa95b52013-08-13 07:59:37 +0200680
Michal Kaziorf6dc2092013-09-26 10:12:22 +0300681 skb_pull(skb, sizeof(struct ethhdr));
682 memcpy(skb_push(skb, len), decap_hdr, len);
683 memcpy(skb_push(skb, hdr_len), hdr, hdr_len);
684 break;
685 case RX_MSDU_DECAP_8023_SNAP_LLC:
686 memcpy(skb_push(skb, hdr_len), hdr, hdr_len);
687 break;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300688 }
689
Michal Kaziorf6dc2092013-09-26 10:12:22 +0300690 info->skb = skb;
691 info->encrypt_type = enctype;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300692 skb = skb->next;
Michal Kaziorf6dc2092013-09-26 10:12:22 +0300693 info->skb->next = NULL;
694
695 ath10k_process_rx(htt->ar, info);
Kalle Valo5e3dd152013-06-12 20:52:10 +0300696 }
697
Michal Kaziorf6dc2092013-09-26 10:12:22 +0300698 /* FIXME: It might be nice to re-assemble the A-MSDU when there's a
699 * monitor interface active for sniffing purposes. */
Kalle Valo5e3dd152013-06-12 20:52:10 +0300700}
701
Michal Kaziorf6dc2092013-09-26 10:12:22 +0300702static void ath10k_htt_rx_msdu(struct ath10k_htt *htt, struct htt_rx_info *info)
Kalle Valo5e3dd152013-06-12 20:52:10 +0300703{
704 struct sk_buff *skb = info->skb;
705 struct htt_rx_desc *rxd;
706 struct ieee80211_hdr *hdr;
707 enum rx_msdu_decap_format fmt;
708 enum htt_rx_mpdu_encrypt_type enctype;
709
710 /* This shouldn't happen. If it does than it may be a FW bug. */
711 if (skb->next) {
712 ath10k_warn("received chained non A-MSDU frame\n");
713 ath10k_htt_rx_free_msdu_chain(skb->next);
714 skb->next = NULL;
715 }
716
717 rxd = (void *)skb->data - sizeof(*rxd);
718 fmt = MS(__le32_to_cpu(rxd->msdu_start.info1),
719 RX_MSDU_START_INFO1_DECAP_FORMAT);
720 enctype = MS(__le32_to_cpu(rxd->mpdu_start.info0),
721 RX_MPDU_START_INFO0_ENCRYPT_TYPE);
722 hdr = (void *)skb->data - RX_HTT_HDR_STATUS_LEN;
723
Michal Kaziorf6dc2092013-09-26 10:12:22 +0300724 skb->ip_summed = ath10k_htt_rx_get_csum_state(skb);
725
Kalle Valo5e3dd152013-06-12 20:52:10 +0300726 switch (fmt) {
727 case RX_MSDU_DECAP_RAW:
728 /* remove trailing FCS */
729 skb_trim(skb, skb->len - 4);
730 break;
731 case RX_MSDU_DECAP_NATIVE_WIFI:
732 /* nothing to do here */
733 break;
734 case RX_MSDU_DECAP_ETHERNET2_DIX:
735 /* macaddr[6] + macaddr[6] + ethertype[2] */
736 skb_pull(skb, 6 + 6 + 2);
737 break;
738 case RX_MSDU_DECAP_8023_SNAP_LLC:
739 /* macaddr[6] + macaddr[6] + len[2] */
740 /* we don't need this for non-A-MSDU */
741 skb_pull(skb, 6 + 6 + 2);
742 break;
743 }
744
745 if (fmt == RX_MSDU_DECAP_ETHERNET2_DIX) {
746 void *llc;
747 int llclen;
748
749 llclen = 8;
750 llc = hdr;
751 llc += roundup(ieee80211_hdrlen(hdr->frame_control), 4);
752 llc += roundup(ath10k_htt_rx_crypto_param_len(enctype), 4);
753
754 skb_push(skb, llclen);
755 memcpy(skb->data, llc, llclen);
756 }
757
758 if (fmt >= RX_MSDU_DECAP_ETHERNET2_DIX) {
759 int len = ieee80211_hdrlen(hdr->frame_control);
760 skb_push(skb, len);
761 memcpy(skb->data, hdr, len);
762 }
763
764 info->skb = skb;
765 info->encrypt_type = enctype;
Michal Kaziorf6dc2092013-09-26 10:12:22 +0300766
767 ath10k_process_rx(htt->ar, info);
Kalle Valo5e3dd152013-06-12 20:52:10 +0300768}
769
770static bool ath10k_htt_rx_has_decrypt_err(struct sk_buff *skb)
771{
772 struct htt_rx_desc *rxd;
773 u32 flags;
774
775 rxd = (void *)skb->data - sizeof(*rxd);
776 flags = __le32_to_cpu(rxd->attention.flags);
777
778 if (flags & RX_ATTENTION_FLAGS_DECRYPT_ERR)
779 return true;
780
781 return false;
782}
783
784static bool ath10k_htt_rx_has_fcs_err(struct sk_buff *skb)
785{
786 struct htt_rx_desc *rxd;
787 u32 flags;
788
789 rxd = (void *)skb->data - sizeof(*rxd);
790 flags = __le32_to_cpu(rxd->attention.flags);
791
792 if (flags & RX_ATTENTION_FLAGS_FCS_ERR)
793 return true;
794
795 return false;
796}
797
Michal Kazior605f81a2013-07-31 10:47:56 +0200798static int ath10k_htt_rx_get_csum_state(struct sk_buff *skb)
799{
800 struct htt_rx_desc *rxd;
801 u32 flags, info;
802 bool is_ip4, is_ip6;
803 bool is_tcp, is_udp;
804 bool ip_csum_ok, tcpudp_csum_ok;
805
806 rxd = (void *)skb->data - sizeof(*rxd);
807 flags = __le32_to_cpu(rxd->attention.flags);
808 info = __le32_to_cpu(rxd->msdu_start.info1);
809
810 is_ip4 = !!(info & RX_MSDU_START_INFO1_IPV4_PROTO);
811 is_ip6 = !!(info & RX_MSDU_START_INFO1_IPV6_PROTO);
812 is_tcp = !!(info & RX_MSDU_START_INFO1_TCP_PROTO);
813 is_udp = !!(info & RX_MSDU_START_INFO1_UDP_PROTO);
814 ip_csum_ok = !(flags & RX_ATTENTION_FLAGS_IP_CHKSUM_FAIL);
815 tcpudp_csum_ok = !(flags & RX_ATTENTION_FLAGS_TCP_UDP_CHKSUM_FAIL);
816
817 if (!is_ip4 && !is_ip6)
818 return CHECKSUM_NONE;
819 if (!is_tcp && !is_udp)
820 return CHECKSUM_NONE;
821 if (!ip_csum_ok)
822 return CHECKSUM_NONE;
823 if (!tcpudp_csum_ok)
824 return CHECKSUM_NONE;
825
826 return CHECKSUM_UNNECESSARY;
827}
828
Kalle Valo5e3dd152013-06-12 20:52:10 +0300829static void ath10k_htt_rx_handler(struct ath10k_htt *htt,
830 struct htt_rx_indication *rx)
831{
832 struct htt_rx_info info;
833 struct htt_rx_indication_mpdu_range *mpdu_ranges;
834 struct ieee80211_hdr *hdr;
835 int num_mpdu_ranges;
836 int fw_desc_len;
837 u8 *fw_desc;
838 int i, j;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300839
840 memset(&info, 0, sizeof(info));
841
842 fw_desc_len = __le16_to_cpu(rx->prefix.fw_rx_desc_bytes);
843 fw_desc = (u8 *)&rx->fw_desc;
844
845 num_mpdu_ranges = MS(__le32_to_cpu(rx->hdr.info1),
846 HTT_RX_INDICATION_INFO1_NUM_MPDU_RANGES);
847 mpdu_ranges = htt_rx_ind_get_mpdu_ranges(rx);
848
849 ath10k_dbg_dump(ATH10K_DBG_HTT_DUMP, NULL, "htt rx ind: ",
850 rx, sizeof(*rx) +
851 (sizeof(struct htt_rx_indication_mpdu_range) *
852 num_mpdu_ranges));
853
854 for (i = 0; i < num_mpdu_ranges; i++) {
855 info.status = mpdu_ranges[i].mpdu_range_status;
856
857 for (j = 0; j < mpdu_ranges[i].mpdu_count; j++) {
858 struct sk_buff *msdu_head, *msdu_tail;
859 enum htt_rx_mpdu_status status;
860 int msdu_chaining;
861
862 msdu_head = NULL;
863 msdu_tail = NULL;
864 msdu_chaining = ath10k_htt_rx_amsdu_pop(htt,
865 &fw_desc,
866 &fw_desc_len,
867 &msdu_head,
868 &msdu_tail);
869
870 if (!msdu_head) {
871 ath10k_warn("htt rx no data!\n");
872 continue;
873 }
874
875 if (msdu_head->len == 0) {
876 ath10k_dbg(ATH10K_DBG_HTT,
877 "htt rx dropping due to zero-len\n");
878 ath10k_htt_rx_free_msdu_chain(msdu_head);
879 continue;
880 }
881
882 if (ath10k_htt_rx_has_decrypt_err(msdu_head)) {
883 ath10k_htt_rx_free_msdu_chain(msdu_head);
884 continue;
885 }
886
887 status = info.status;
888
889 /* Skip mgmt frames while we handle this in WMI */
890 if (status == HTT_RX_IND_MPDU_STATUS_MGMT_CTRL) {
891 ath10k_htt_rx_free_msdu_chain(msdu_head);
892 continue;
893 }
894
895 if (status != HTT_RX_IND_MPDU_STATUS_OK &&
896 status != HTT_RX_IND_MPDU_STATUS_TKIP_MIC_ERR &&
897 !htt->ar->monitor_enabled) {
898 ath10k_dbg(ATH10K_DBG_HTT,
899 "htt rx ignoring frame w/ status %d\n",
900 status);
901 ath10k_htt_rx_free_msdu_chain(msdu_head);
902 continue;
903 }
904
905 /* FIXME: we do not support chaining yet.
906 * this needs investigation */
907 if (msdu_chaining) {
908 ath10k_warn("msdu_chaining is true\n");
909 ath10k_htt_rx_free_msdu_chain(msdu_head);
910 continue;
911 }
912
913 info.skb = msdu_head;
914 info.fcs_err = ath10k_htt_rx_has_fcs_err(msdu_head);
915 info.signal = ATH10K_DEFAULT_NOISE_FLOOR;
916 info.signal += rx->ppdu.combined_rssi;
917
918 info.rate.info0 = rx->ppdu.info0;
919 info.rate.info1 = __le32_to_cpu(rx->ppdu.info1);
920 info.rate.info2 = __le32_to_cpu(rx->ppdu.info2);
921
922 hdr = ath10k_htt_rx_skb_get_hdr(msdu_head);
923
924 if (ath10k_htt_rx_hdr_is_amsdu(hdr))
Michal Kaziorf6dc2092013-09-26 10:12:22 +0300925 ath10k_htt_rx_amsdu(htt, &info);
Kalle Valo5e3dd152013-06-12 20:52:10 +0300926 else
Michal Kaziorf6dc2092013-09-26 10:12:22 +0300927 ath10k_htt_rx_msdu(htt, &info);
Kalle Valo5e3dd152013-06-12 20:52:10 +0300928 }
929 }
930
931 ath10k_htt_rx_msdu_buff_replenish(htt);
932}
933
934static void ath10k_htt_rx_frag_handler(struct ath10k_htt *htt,
935 struct htt_rx_fragment_indication *frag)
936{
937 struct sk_buff *msdu_head, *msdu_tail;
938 struct htt_rx_desc *rxd;
939 enum rx_msdu_decap_format fmt;
940 struct htt_rx_info info = {};
941 struct ieee80211_hdr *hdr;
942 int msdu_chaining;
943 bool tkip_mic_err;
944 bool decrypt_err;
945 u8 *fw_desc;
946 int fw_desc_len, hdrlen, paramlen;
947 int trim;
948
949 fw_desc_len = __le16_to_cpu(frag->fw_rx_desc_bytes);
950 fw_desc = (u8 *)frag->fw_msdu_rx_desc;
951
952 msdu_head = NULL;
953 msdu_tail = NULL;
954 msdu_chaining = ath10k_htt_rx_amsdu_pop(htt, &fw_desc, &fw_desc_len,
955 &msdu_head, &msdu_tail);
956
957 ath10k_dbg(ATH10K_DBG_HTT_DUMP, "htt rx frag ahead\n");
958
959 if (!msdu_head) {
960 ath10k_warn("htt rx frag no data\n");
961 return;
962 }
963
964 if (msdu_chaining || msdu_head != msdu_tail) {
965 ath10k_warn("aggregation with fragmentation?!\n");
966 ath10k_htt_rx_free_msdu_chain(msdu_head);
967 return;
968 }
969
970 /* FIXME: implement signal strength */
971
972 hdr = (struct ieee80211_hdr *)msdu_head->data;
973 rxd = (void *)msdu_head->data - sizeof(*rxd);
974 tkip_mic_err = !!(__le32_to_cpu(rxd->attention.flags) &
975 RX_ATTENTION_FLAGS_TKIP_MIC_ERR);
976 decrypt_err = !!(__le32_to_cpu(rxd->attention.flags) &
977 RX_ATTENTION_FLAGS_DECRYPT_ERR);
978 fmt = MS(__le32_to_cpu(rxd->msdu_start.info1),
979 RX_MSDU_START_INFO1_DECAP_FORMAT);
980
981 if (fmt != RX_MSDU_DECAP_RAW) {
982 ath10k_warn("we dont support non-raw fragmented rx yet\n");
983 dev_kfree_skb_any(msdu_head);
984 goto end;
985 }
986
987 info.skb = msdu_head;
988 info.status = HTT_RX_IND_MPDU_STATUS_OK;
989 info.encrypt_type = MS(__le32_to_cpu(rxd->mpdu_start.info0),
990 RX_MPDU_START_INFO0_ENCRYPT_TYPE);
Michal Kazior605f81a2013-07-31 10:47:56 +0200991 info.skb->ip_summed = ath10k_htt_rx_get_csum_state(info.skb);
Kalle Valo5e3dd152013-06-12 20:52:10 +0300992
993 if (tkip_mic_err) {
994 ath10k_warn("tkip mic error\n");
995 info.status = HTT_RX_IND_MPDU_STATUS_TKIP_MIC_ERR;
996 }
997
998 if (decrypt_err) {
999 ath10k_warn("decryption err in fragmented rx\n");
1000 dev_kfree_skb_any(info.skb);
1001 goto end;
1002 }
1003
1004 if (info.encrypt_type != HTT_RX_MPDU_ENCRYPT_NONE) {
1005 hdrlen = ieee80211_hdrlen(hdr->frame_control);
1006 paramlen = ath10k_htt_rx_crypto_param_len(info.encrypt_type);
1007
1008 /* It is more efficient to move the header than the payload */
1009 memmove((void *)info.skb->data + paramlen,
1010 (void *)info.skb->data,
1011 hdrlen);
1012 skb_pull(info.skb, paramlen);
1013 hdr = (struct ieee80211_hdr *)info.skb->data;
1014 }
1015
1016 /* remove trailing FCS */
1017 trim = 4;
1018
1019 /* remove crypto trailer */
1020 trim += ath10k_htt_rx_crypto_tail_len(info.encrypt_type);
1021
1022 /* last fragment of TKIP frags has MIC */
1023 if (!ieee80211_has_morefrags(hdr->frame_control) &&
1024 info.encrypt_type == HTT_RX_MPDU_ENCRYPT_TKIP_WPA)
1025 trim += 8;
1026
1027 if (trim > info.skb->len) {
1028 ath10k_warn("htt rx fragment: trailer longer than the frame itself? drop\n");
1029 dev_kfree_skb_any(info.skb);
1030 goto end;
1031 }
1032
1033 skb_trim(info.skb, info.skb->len - trim);
1034
1035 ath10k_dbg_dump(ATH10K_DBG_HTT_DUMP, NULL, "htt frag mpdu: ",
1036 info.skb->data, info.skb->len);
1037 ath10k_process_rx(htt->ar, &info);
1038
1039end:
1040 if (fw_desc_len > 0) {
1041 ath10k_dbg(ATH10K_DBG_HTT,
1042 "expecting more fragmented rx in one indication %d\n",
1043 fw_desc_len);
1044 }
1045}
1046
1047void ath10k_htt_t2h_msg_handler(struct ath10k *ar, struct sk_buff *skb)
1048{
Michal Kazioredb82362013-07-05 16:15:14 +03001049 struct ath10k_htt *htt = &ar->htt;
Kalle Valo5e3dd152013-06-12 20:52:10 +03001050 struct htt_resp *resp = (struct htt_resp *)skb->data;
1051
1052 /* confirm alignment */
1053 if (!IS_ALIGNED((unsigned long)skb->data, 4))
1054 ath10k_warn("unaligned htt message, expect trouble\n");
1055
1056 ath10k_dbg(ATH10K_DBG_HTT, "HTT RX, msg_type: 0x%0X\n",
1057 resp->hdr.msg_type);
1058 switch (resp->hdr.msg_type) {
1059 case HTT_T2H_MSG_TYPE_VERSION_CONF: {
1060 htt->target_version_major = resp->ver_resp.major;
1061 htt->target_version_minor = resp->ver_resp.minor;
1062 complete(&htt->target_version_received);
1063 break;
1064 }
1065 case HTT_T2H_MSG_TYPE_RX_IND: {
1066 ath10k_htt_rx_handler(htt, &resp->rx_ind);
1067 break;
1068 }
1069 case HTT_T2H_MSG_TYPE_PEER_MAP: {
1070 struct htt_peer_map_event ev = {
1071 .vdev_id = resp->peer_map.vdev_id,
1072 .peer_id = __le16_to_cpu(resp->peer_map.peer_id),
1073 };
1074 memcpy(ev.addr, resp->peer_map.addr, sizeof(ev.addr));
1075 ath10k_peer_map_event(htt, &ev);
1076 break;
1077 }
1078 case HTT_T2H_MSG_TYPE_PEER_UNMAP: {
1079 struct htt_peer_unmap_event ev = {
1080 .peer_id = __le16_to_cpu(resp->peer_unmap.peer_id),
1081 };
1082 ath10k_peer_unmap_event(htt, &ev);
1083 break;
1084 }
1085 case HTT_T2H_MSG_TYPE_MGMT_TX_COMPLETION: {
1086 struct htt_tx_done tx_done = {};
1087 int status = __le32_to_cpu(resp->mgmt_tx_completion.status);
1088
1089 tx_done.msdu_id =
1090 __le32_to_cpu(resp->mgmt_tx_completion.desc_id);
1091
1092 switch (status) {
1093 case HTT_MGMT_TX_STATUS_OK:
1094 break;
1095 case HTT_MGMT_TX_STATUS_RETRY:
1096 tx_done.no_ack = true;
1097 break;
1098 case HTT_MGMT_TX_STATUS_DROP:
1099 tx_done.discard = true;
1100 break;
1101 }
1102
Michal Kazior0a89f8a2013-09-18 14:43:20 +02001103 ath10k_txrx_tx_unref(htt, &tx_done);
Kalle Valo5e3dd152013-06-12 20:52:10 +03001104 break;
1105 }
1106 case HTT_T2H_MSG_TYPE_TX_COMPL_IND: {
1107 struct htt_tx_done tx_done = {};
1108 int status = MS(resp->data_tx_completion.flags,
1109 HTT_DATA_TX_STATUS);
1110 __le16 msdu_id;
1111 int i;
1112
1113 switch (status) {
1114 case HTT_DATA_TX_STATUS_NO_ACK:
1115 tx_done.no_ack = true;
1116 break;
1117 case HTT_DATA_TX_STATUS_OK:
1118 break;
1119 case HTT_DATA_TX_STATUS_DISCARD:
1120 case HTT_DATA_TX_STATUS_POSTPONE:
1121 case HTT_DATA_TX_STATUS_DOWNLOAD_FAIL:
1122 tx_done.discard = true;
1123 break;
1124 default:
1125 ath10k_warn("unhandled tx completion status %d\n",
1126 status);
1127 tx_done.discard = true;
1128 break;
1129 }
1130
1131 ath10k_dbg(ATH10K_DBG_HTT, "htt tx completion num_msdus %d\n",
1132 resp->data_tx_completion.num_msdus);
1133
1134 for (i = 0; i < resp->data_tx_completion.num_msdus; i++) {
1135 msdu_id = resp->data_tx_completion.msdus[i];
1136 tx_done.msdu_id = __le16_to_cpu(msdu_id);
Michal Kazior0a89f8a2013-09-18 14:43:20 +02001137 ath10k_txrx_tx_unref(htt, &tx_done);
Kalle Valo5e3dd152013-06-12 20:52:10 +03001138 }
1139 break;
1140 }
1141 case HTT_T2H_MSG_TYPE_SEC_IND: {
1142 struct ath10k *ar = htt->ar;
1143 struct htt_security_indication *ev = &resp->security_indication;
1144
1145 ath10k_dbg(ATH10K_DBG_HTT,
1146 "sec ind peer_id %d unicast %d type %d\n",
1147 __le16_to_cpu(ev->peer_id),
1148 !!(ev->flags & HTT_SECURITY_IS_UNICAST),
1149 MS(ev->flags, HTT_SECURITY_TYPE));
1150 complete(&ar->install_key_done);
1151 break;
1152 }
1153 case HTT_T2H_MSG_TYPE_RX_FRAG_IND: {
1154 ath10k_dbg_dump(ATH10K_DBG_HTT_DUMP, NULL, "htt event: ",
1155 skb->data, skb->len);
1156 ath10k_htt_rx_frag_handler(htt, &resp->rx_frag_ind);
1157 break;
1158 }
1159 case HTT_T2H_MSG_TYPE_TEST:
1160 /* FIX THIS */
1161 break;
Kalle Valo5e3dd152013-06-12 20:52:10 +03001162 case HTT_T2H_MSG_TYPE_STATS_CONF:
Kalle Valoa9bf0502013-09-03 11:43:55 +03001163 trace_ath10k_htt_stats(skb->data, skb->len);
1164 break;
1165 case HTT_T2H_MSG_TYPE_TX_INSPECT_IND:
Kalle Valo5e3dd152013-06-12 20:52:10 +03001166 case HTT_T2H_MSG_TYPE_RX_ADDBA:
1167 case HTT_T2H_MSG_TYPE_RX_DELBA:
1168 case HTT_T2H_MSG_TYPE_RX_FLUSH:
1169 default:
1170 ath10k_dbg(ATH10K_DBG_HTT, "htt event (%d) not handled\n",
1171 resp->hdr.msg_type);
1172 ath10k_dbg_dump(ATH10K_DBG_HTT_DUMP, NULL, "htt event: ",
1173 skb->data, skb->len);
1174 break;
1175 };
1176
1177 /* Free the indication buffer */
1178 dev_kfree_skb_any(skb);
1179}