2013-06-13 01:52:10 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2005-2011 Atheros Communications Inc.
|
2017-12-23 00:31:13 +08:00
|
|
|
* Copyright (c) 2011-2017 Qualcomm Atheros, Inc.
|
2018-03-14 18:14:06 +08:00
|
|
|
* Copyright (c) 2018, The Linux Foundation. All rights reserved.
|
2013-06-13 01:52:10 +08:00
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and/or distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
|
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
|
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
2013-07-05 21:15:14 +08:00
|
|
|
#include "core.h"
|
2013-06-13 01:52:10 +08:00
|
|
|
#include "htc.h"
|
|
|
|
#include "htt.h"
|
|
|
|
#include "txrx.h"
|
|
|
|
#include "debug.h"
|
2013-09-03 16:43:55 +08:00
|
|
|
#include "trace.h"
|
2014-07-23 18:20:33 +08:00
|
|
|
#include "mac.h"
|
2013-06-13 01:52:10 +08:00
|
|
|
|
|
|
|
#include <linux/log2.h>
|
2018-04-10 23:01:05 +08:00
|
|
|
#include <linux/bitfield.h>
|
2013-06-13 01:52:10 +08:00
|
|
|
|
|
|
|
/* when under memory pressure rx ring refill may fail and needs a retry */
|
|
|
|
#define HTT_RX_RING_REFILL_RETRY_MS 50
|
|
|
|
|
2016-03-22 19:52:19 +08:00
|
|
|
#define HTT_RX_RING_REFILL_RESCHED_MS 5
|
|
|
|
|
2013-09-26 15:12:22 +08:00
|
|
|
static int ath10k_htt_rx_get_csum_state(struct sk_buff *skb);
|
|
|
|
|
2015-01-24 18:14:48 +08:00
|
|
|
static struct sk_buff *
|
2017-12-21 17:00:57 +08:00
|
|
|
ath10k_htt_rx_find_skb_paddr(struct ath10k *ar, u64 paddr)
|
2015-01-24 18:14:48 +08:00
|
|
|
{
|
|
|
|
struct ath10k_skb_rxcb *rxcb;
|
|
|
|
|
|
|
|
hash_for_each_possible(ar->htt.rx_ring.skb_table, rxcb, hlist, paddr)
|
|
|
|
if (rxcb->paddr == paddr)
|
|
|
|
return ATH10K_RXCB_SKB(rxcb);
|
|
|
|
|
|
|
|
WARN_ON_ONCE(1);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2013-06-13 01:52:10 +08:00
|
|
|
static void ath10k_htt_rx_ring_free(struct ath10k_htt *htt)
|
|
|
|
{
|
|
|
|
struct sk_buff *skb;
|
2015-01-24 18:14:48 +08:00
|
|
|
struct ath10k_skb_rxcb *rxcb;
|
|
|
|
struct hlist_node *n;
|
2013-06-13 01:52:10 +08:00
|
|
|
int i;
|
|
|
|
|
2015-01-24 18:14:48 +08:00
|
|
|
if (htt->rx_ring.in_ord_rx) {
|
|
|
|
hash_for_each_safe(htt->rx_ring.skb_table, i, n, rxcb, hlist) {
|
|
|
|
skb = ATH10K_RXCB_SKB(rxcb);
|
|
|
|
dma_unmap_single(htt->ar->dev, rxcb->paddr,
|
|
|
|
skb->len + skb_tailroom(skb),
|
|
|
|
DMA_FROM_DEVICE);
|
|
|
|
hash_del(&rxcb->hlist);
|
|
|
|
dev_kfree_skb_any(skb);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for (i = 0; i < htt->rx_ring.size; i++) {
|
|
|
|
skb = htt->rx_ring.netbufs_ring[i];
|
|
|
|
if (!skb)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
rxcb = ATH10K_SKB_RXCB(skb);
|
|
|
|
dma_unmap_single(htt->ar->dev, rxcb->paddr,
|
|
|
|
skb->len + skb_tailroom(skb),
|
|
|
|
DMA_FROM_DEVICE);
|
|
|
|
dev_kfree_skb_any(skb);
|
|
|
|
}
|
2013-06-13 01:52:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
htt->rx_ring.fill_cnt = 0;
|
2015-01-24 18:14:48 +08:00
|
|
|
hash_init(htt->rx_ring.skb_table);
|
|
|
|
memset(htt->rx_ring.netbufs_ring, 0,
|
|
|
|
htt->rx_ring.size * sizeof(htt->rx_ring.netbufs_ring[0]));
|
2013-06-13 01:52:10 +08:00
|
|
|
}
|
|
|
|
|
2017-12-21 17:00:57 +08:00
|
|
|
static size_t ath10k_htt_get_rx_ring_size_32(struct ath10k_htt *htt)
|
|
|
|
{
|
|
|
|
return htt->rx_ring.size * sizeof(htt->rx_ring.paddrs_ring_32);
|
|
|
|
}
|
|
|
|
|
|
|
|
static size_t ath10k_htt_get_rx_ring_size_64(struct ath10k_htt *htt)
|
|
|
|
{
|
|
|
|
return htt->rx_ring.size * sizeof(htt->rx_ring.paddrs_ring_64);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ath10k_htt_config_paddrs_ring_32(struct ath10k_htt *htt,
|
|
|
|
void *vaddr)
|
|
|
|
{
|
|
|
|
htt->rx_ring.paddrs_ring_32 = vaddr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ath10k_htt_config_paddrs_ring_64(struct ath10k_htt *htt,
|
|
|
|
void *vaddr)
|
|
|
|
{
|
|
|
|
htt->rx_ring.paddrs_ring_64 = vaddr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ath10k_htt_set_paddrs_ring_32(struct ath10k_htt *htt,
|
|
|
|
dma_addr_t paddr, int idx)
|
|
|
|
{
|
|
|
|
htt->rx_ring.paddrs_ring_32[idx] = __cpu_to_le32(paddr);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ath10k_htt_set_paddrs_ring_64(struct ath10k_htt *htt,
|
|
|
|
dma_addr_t paddr, int idx)
|
|
|
|
{
|
|
|
|
htt->rx_ring.paddrs_ring_64[idx] = __cpu_to_le64(paddr);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ath10k_htt_reset_paddrs_ring_32(struct ath10k_htt *htt, int idx)
|
|
|
|
{
|
|
|
|
htt->rx_ring.paddrs_ring_32[idx] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ath10k_htt_reset_paddrs_ring_64(struct ath10k_htt *htt, int idx)
|
|
|
|
{
|
|
|
|
htt->rx_ring.paddrs_ring_64[idx] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void *ath10k_htt_get_vaddr_ring_32(struct ath10k_htt *htt)
|
|
|
|
{
|
|
|
|
return (void *)htt->rx_ring.paddrs_ring_32;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void *ath10k_htt_get_vaddr_ring_64(struct ath10k_htt *htt)
|
|
|
|
{
|
|
|
|
return (void *)htt->rx_ring.paddrs_ring_64;
|
|
|
|
}
|
|
|
|
|
2013-06-13 01:52:10 +08:00
|
|
|
static int __ath10k_htt_rx_ring_fill_n(struct ath10k_htt *htt, int num)
|
|
|
|
{
|
|
|
|
struct htt_rx_desc *rx_desc;
|
2015-01-24 18:14:48 +08:00
|
|
|
struct ath10k_skb_rxcb *rxcb;
|
2013-06-13 01:52:10 +08:00
|
|
|
struct sk_buff *skb;
|
|
|
|
dma_addr_t paddr;
|
|
|
|
int ret = 0, idx;
|
|
|
|
|
2015-01-24 18:14:48 +08:00
|
|
|
/* The Full Rx Reorder firmware has no way of telling the host
|
|
|
|
* implicitly when it copied HTT Rx Ring buffers to MAC Rx Ring.
|
|
|
|
* To keep things simple make sure ring is always half empty. This
|
|
|
|
* guarantees there'll be no replenishment overruns possible.
|
|
|
|
*/
|
|
|
|
BUILD_BUG_ON(HTT_RX_RING_FILL_LEVEL >= HTT_RX_RING_SIZE / 2);
|
|
|
|
|
2014-09-14 17:50:39 +08:00
|
|
|
idx = __le32_to_cpu(*htt->rx_ring.alloc_idx.vaddr);
|
2013-06-13 01:52:10 +08:00
|
|
|
while (num > 0) {
|
|
|
|
skb = dev_alloc_skb(HTT_RX_BUF_SIZE + HTT_RX_DESC_ALIGN);
|
|
|
|
if (!skb) {
|
|
|
|
ret = -ENOMEM;
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!IS_ALIGNED((unsigned long)skb->data, HTT_RX_DESC_ALIGN))
|
|
|
|
skb_pull(skb,
|
|
|
|
PTR_ALIGN(skb->data, HTT_RX_DESC_ALIGN) -
|
|
|
|
skb->data);
|
|
|
|
|
|
|
|
/* Clear rx_desc attention word before posting to Rx ring */
|
|
|
|
rx_desc = (struct htt_rx_desc *)skb->data;
|
|
|
|
rx_desc->attention.flags = __cpu_to_le32(0);
|
|
|
|
|
|
|
|
paddr = dma_map_single(htt->ar->dev, skb->data,
|
|
|
|
skb->len + skb_tailroom(skb),
|
|
|
|
DMA_FROM_DEVICE);
|
|
|
|
|
|
|
|
if (unlikely(dma_mapping_error(htt->ar->dev, paddr))) {
|
|
|
|
dev_kfree_skb_any(skb);
|
|
|
|
ret = -ENOMEM;
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
2015-01-24 18:14:48 +08:00
|
|
|
rxcb = ATH10K_SKB_RXCB(skb);
|
|
|
|
rxcb->paddr = paddr;
|
2013-06-13 01:52:10 +08:00
|
|
|
htt->rx_ring.netbufs_ring[idx] = skb;
|
2018-04-15 20:22:28 +08:00
|
|
|
ath10k_htt_set_paddrs_ring(htt, paddr, idx);
|
2013-06-13 01:52:10 +08:00
|
|
|
htt->rx_ring.fill_cnt++;
|
|
|
|
|
2015-01-24 18:14:48 +08:00
|
|
|
if (htt->rx_ring.in_ord_rx) {
|
|
|
|
hash_add(htt->rx_ring.skb_table,
|
|
|
|
&ATH10K_SKB_RXCB(skb)->hlist,
|
2017-12-21 17:00:57 +08:00
|
|
|
paddr);
|
2015-01-24 18:14:48 +08:00
|
|
|
}
|
|
|
|
|
2013-06-13 01:52:10 +08:00
|
|
|
num--;
|
|
|
|
idx++;
|
|
|
|
idx &= htt->rx_ring.size_mask;
|
|
|
|
}
|
|
|
|
|
|
|
|
fail:
|
2015-01-10 01:19:46 +08:00
|
|
|
/*
|
|
|
|
* Make sure the rx buffer is updated before available buffer
|
|
|
|
* index to avoid any potential rx ring corruption.
|
|
|
|
*/
|
|
|
|
mb();
|
2014-09-14 17:50:39 +08:00
|
|
|
*htt->rx_ring.alloc_idx.vaddr = __cpu_to_le32(idx);
|
2013-06-13 01:52:10 +08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ath10k_htt_rx_ring_fill_n(struct ath10k_htt *htt, int num)
|
|
|
|
{
|
|
|
|
lockdep_assert_held(&htt->rx_ring.lock);
|
|
|
|
return __ath10k_htt_rx_ring_fill_n(htt, num);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ath10k_htt_rx_msdu_buff_replenish(struct ath10k_htt *htt)
|
|
|
|
{
|
2013-09-24 16:18:36 +08:00
|
|
|
int ret, num_deficit, num_to_fill;
|
2013-06-13 01:52:10 +08:00
|
|
|
|
2013-09-24 16:18:36 +08:00
|
|
|
/* Refilling the whole RX ring buffer proves to be a bad idea. The
|
|
|
|
* reason is RX may take up significant amount of CPU cycles and starve
|
|
|
|
* other tasks, e.g. TX on an ethernet device while acting as a bridge
|
|
|
|
* with ath10k wlan interface. This ended up with very poor performance
|
|
|
|
* once CPU the host system was overwhelmed with RX on ath10k.
|
|
|
|
*
|
|
|
|
* By limiting the number of refills the replenishing occurs
|
|
|
|
* progressively. This in turns makes use of the fact tasklets are
|
|
|
|
* processed in FIFO order. This means actual RX processing can starve
|
|
|
|
* out refilling. If there's not enough buffers on RX ring FW will not
|
|
|
|
* report RX until it is refilled with enough buffers. This
|
|
|
|
* automatically balances load wrt to CPU power.
|
|
|
|
*
|
|
|
|
* This probably comes at a cost of lower maximum throughput but
|
2017-02-20 21:39:57 +08:00
|
|
|
* improves the average and stability.
|
|
|
|
*/
|
2013-06-13 01:52:10 +08:00
|
|
|
spin_lock_bh(&htt->rx_ring.lock);
|
2013-09-24 16:18:36 +08:00
|
|
|
num_deficit = htt->rx_ring.fill_level - htt->rx_ring.fill_cnt;
|
|
|
|
num_to_fill = min(ATH10K_HTT_MAX_NUM_REFILL, num_deficit);
|
|
|
|
num_deficit -= num_to_fill;
|
2013-06-13 01:52:10 +08:00
|
|
|
ret = ath10k_htt_rx_ring_fill_n(htt, num_to_fill);
|
|
|
|
if (ret == -ENOMEM) {
|
|
|
|
/*
|
|
|
|
* Failed to fill it to the desired level -
|
|
|
|
* we'll start a timer and try again next time.
|
|
|
|
* As long as enough buffers are left in the ring for
|
|
|
|
* another A-MPDU rx, no special recovery is needed.
|
|
|
|
*/
|
|
|
|
mod_timer(&htt->rx_ring.refill_retry_timer, jiffies +
|
|
|
|
msecs_to_jiffies(HTT_RX_RING_REFILL_RETRY_MS));
|
2013-09-24 16:18:36 +08:00
|
|
|
} else if (num_deficit > 0) {
|
2016-03-22 19:52:19 +08:00
|
|
|
mod_timer(&htt->rx_ring.refill_retry_timer, jiffies +
|
|
|
|
msecs_to_jiffies(HTT_RX_RING_REFILL_RESCHED_MS));
|
2013-06-13 01:52:10 +08:00
|
|
|
}
|
|
|
|
spin_unlock_bh(&htt->rx_ring.lock);
|
|
|
|
}
|
|
|
|
|
2017-10-24 17:29:54 +08:00
|
|
|
static void ath10k_htt_rx_ring_refill_retry(struct timer_list *t)
|
2013-06-13 01:52:10 +08:00
|
|
|
{
|
2017-10-24 17:29:54 +08:00
|
|
|
struct ath10k_htt *htt = from_timer(htt, t, rx_ring.refill_retry_timer);
|
2014-09-14 17:50:17 +08:00
|
|
|
|
2013-06-13 01:52:10 +08:00
|
|
|
ath10k_htt_rx_msdu_buff_replenish(htt);
|
|
|
|
}
|
|
|
|
|
2015-01-24 18:14:48 +08:00
|
|
|
int ath10k_htt_rx_ring_refill(struct ath10k *ar)
|
2013-06-13 01:52:10 +08:00
|
|
|
{
|
2015-01-24 18:14:48 +08:00
|
|
|
struct ath10k_htt *htt = &ar->htt;
|
|
|
|
int ret;
|
2014-05-14 21:23:31 +08:00
|
|
|
|
2018-09-04 20:06:58 +08:00
|
|
|
if (ar->dev_type == ATH10K_DEV_TYPE_HL)
|
|
|
|
return 0;
|
|
|
|
|
2015-01-24 18:14:48 +08:00
|
|
|
spin_lock_bh(&htt->rx_ring.lock);
|
|
|
|
ret = ath10k_htt_rx_ring_fill_n(htt, (htt->rx_ring.fill_level -
|
|
|
|
htt->rx_ring.fill_cnt));
|
2014-05-14 21:23:31 +08:00
|
|
|
|
2015-01-24 18:14:48 +08:00
|
|
|
if (ret)
|
|
|
|
ath10k_htt_rx_ring_free(htt);
|
|
|
|
|
2018-06-18 22:00:56 +08:00
|
|
|
spin_unlock_bh(&htt->rx_ring.lock);
|
|
|
|
|
2015-01-24 18:14:48 +08:00
|
|
|
return ret;
|
2014-05-14 21:23:31 +08:00
|
|
|
}
|
2013-06-13 01:52:10 +08:00
|
|
|
|
2014-05-16 22:15:39 +08:00
|
|
|
void ath10k_htt_rx_free(struct ath10k_htt *htt)
|
2014-05-14 21:23:31 +08:00
|
|
|
{
|
2018-09-04 20:06:58 +08:00
|
|
|
if (htt->ar->dev_type == ATH10K_DEV_TYPE_HL)
|
|
|
|
return;
|
|
|
|
|
2013-06-13 01:52:10 +08:00
|
|
|
del_timer_sync(&htt->rx_ring.refill_retry_timer);
|
2014-02-28 00:50:04 +08:00
|
|
|
|
2017-12-07 22:58:05 +08:00
|
|
|
skb_queue_purge(&htt->rx_msdus_q);
|
2015-01-24 18:14:48 +08:00
|
|
|
skb_queue_purge(&htt->rx_in_ord_compl_q);
|
2016-03-06 22:14:43 +08:00
|
|
|
skb_queue_purge(&htt->tx_fetch_ind_q);
|
2013-06-13 01:52:10 +08:00
|
|
|
|
2018-06-18 22:00:56 +08:00
|
|
|
spin_lock_bh(&htt->rx_ring.lock);
|
2015-01-24 18:14:48 +08:00
|
|
|
ath10k_htt_rx_ring_free(htt);
|
2018-06-18 22:00:56 +08:00
|
|
|
spin_unlock_bh(&htt->rx_ring.lock);
|
2013-06-13 01:52:10 +08:00
|
|
|
|
|
|
|
dma_free_coherent(htt->ar->dev,
|
2018-04-15 20:22:28 +08:00
|
|
|
ath10k_htt_get_rx_ring_size(htt),
|
|
|
|
ath10k_htt_get_vaddr_ring(htt),
|
2013-06-13 01:52:10 +08:00
|
|
|
htt->rx_ring.base_paddr);
|
|
|
|
|
|
|
|
dma_free_coherent(htt->ar->dev,
|
|
|
|
sizeof(*htt->rx_ring.alloc_idx.vaddr),
|
|
|
|
htt->rx_ring.alloc_idx.vaddr,
|
|
|
|
htt->rx_ring.alloc_idx.paddr);
|
|
|
|
|
|
|
|
kfree(htt->rx_ring.netbufs_ring);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline struct sk_buff *ath10k_htt_rx_netbuf_pop(struct ath10k_htt *htt)
|
|
|
|
{
|
2014-08-25 18:09:38 +08:00
|
|
|
struct ath10k *ar = htt->ar;
|
2013-06-13 01:52:10 +08:00
|
|
|
int idx;
|
|
|
|
struct sk_buff *msdu;
|
|
|
|
|
2014-02-28 00:50:05 +08:00
|
|
|
lockdep_assert_held(&htt->rx_ring.lock);
|
2013-06-13 01:52:10 +08:00
|
|
|
|
2014-02-28 00:50:05 +08:00
|
|
|
if (htt->rx_ring.fill_cnt == 0) {
|
2014-08-25 18:09:38 +08:00
|
|
|
ath10k_warn(ar, "tried to pop sk_buff from an empty rx ring\n");
|
2014-02-28 00:50:05 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
2013-06-13 01:52:10 +08:00
|
|
|
|
|
|
|
idx = htt->rx_ring.sw_rd_idx.msdu_payld;
|
|
|
|
msdu = htt->rx_ring.netbufs_ring[idx];
|
2014-05-14 21:23:31 +08:00
|
|
|
htt->rx_ring.netbufs_ring[idx] = NULL;
|
2018-04-15 20:22:28 +08:00
|
|
|
ath10k_htt_reset_paddrs_ring(htt, idx);
|
2013-06-13 01:52:10 +08:00
|
|
|
|
|
|
|
idx++;
|
|
|
|
idx &= htt->rx_ring.size_mask;
|
|
|
|
htt->rx_ring.sw_rd_idx.msdu_payld = idx;
|
|
|
|
htt->rx_ring.fill_cnt--;
|
|
|
|
|
2014-10-23 22:04:23 +08:00
|
|
|
dma_unmap_single(htt->ar->dev,
|
2015-01-24 18:14:47 +08:00
|
|
|
ATH10K_SKB_RXCB(msdu)->paddr,
|
2014-10-23 22:04:23 +08:00
|
|
|
msdu->len + skb_tailroom(msdu),
|
|
|
|
DMA_FROM_DEVICE);
|
|
|
|
ath10k_dbg_dump(ar, ATH10K_DBG_HTT_DUMP, NULL, "htt rx netbuf pop: ",
|
|
|
|
msdu->data, msdu->len + skb_tailroom(msdu));
|
|
|
|
|
2013-06-13 01:52:10 +08:00
|
|
|
return msdu;
|
|
|
|
}
|
|
|
|
|
2014-03-25 04:23:20 +08:00
|
|
|
/* return: < 0 fatal error, 0 - non chained msdu, 1 chained msdu */
|
2013-06-13 01:52:10 +08:00
|
|
|
static int ath10k_htt_rx_amsdu_pop(struct ath10k_htt *htt,
|
2014-11-18 15:24:49 +08:00
|
|
|
struct sk_buff_head *amsdu)
|
2013-06-13 01:52:10 +08:00
|
|
|
{
|
2014-08-25 18:09:38 +08:00
|
|
|
struct ath10k *ar = htt->ar;
|
2013-06-13 01:52:10 +08:00
|
|
|
int msdu_len, msdu_chaining = 0;
|
2014-11-18 15:24:47 +08:00
|
|
|
struct sk_buff *msdu;
|
2013-06-13 01:52:10 +08:00
|
|
|
struct htt_rx_desc *rx_desc;
|
|
|
|
|
2014-02-28 00:50:05 +08:00
|
|
|
lockdep_assert_held(&htt->rx_ring.lock);
|
|
|
|
|
2014-11-18 15:24:47 +08:00
|
|
|
for (;;) {
|
2013-06-13 01:52:10 +08:00
|
|
|
int last_msdu, msdu_len_invalid, msdu_chained;
|
|
|
|
|
2014-11-18 15:24:47 +08:00
|
|
|
msdu = ath10k_htt_rx_netbuf_pop(htt);
|
|
|
|
if (!msdu) {
|
|
|
|
__skb_queue_purge(amsdu);
|
2014-11-18 15:24:48 +08:00
|
|
|
return -ENOENT;
|
2014-11-18 15:24:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
__skb_queue_tail(amsdu, msdu);
|
|
|
|
|
2013-06-13 01:52:10 +08:00
|
|
|
rx_desc = (struct htt_rx_desc *)msdu->data;
|
|
|
|
|
|
|
|
/* FIXME: we must report msdu payload since this is what caller
|
2017-02-20 21:39:57 +08:00
|
|
|
* expects now
|
|
|
|
*/
|
2013-06-13 01:52:10 +08:00
|
|
|
skb_put(msdu, offsetof(struct htt_rx_desc, msdu_payload));
|
|
|
|
skb_pull(msdu, offsetof(struct htt_rx_desc, msdu_payload));
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Sanity check - confirm the HW is finished filling in the
|
|
|
|
* rx data.
|
|
|
|
* If the HW and SW are working correctly, then it's guaranteed
|
|
|
|
* that the HW's MAC DMA is done before this point in the SW.
|
|
|
|
* To prevent the case that we handle a stale Rx descriptor,
|
|
|
|
* just assert for now until we have a way to recover.
|
|
|
|
*/
|
|
|
|
if (!(__le32_to_cpu(rx_desc->attention.flags)
|
|
|
|
& RX_ATTENTION_FLAGS_MSDU_DONE)) {
|
2014-11-18 15:24:47 +08:00
|
|
|
__skb_queue_purge(amsdu);
|
2014-11-18 15:24:48 +08:00
|
|
|
return -EIO;
|
2013-06-13 01:52:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
msdu_len_invalid = !!(__le32_to_cpu(rx_desc->attention.flags)
|
|
|
|
& (RX_ATTENTION_FLAGS_MPDU_LENGTH_ERR |
|
|
|
|
RX_ATTENTION_FLAGS_MSDU_LENGTH_ERR));
|
2015-07-16 10:01:21 +08:00
|
|
|
msdu_len = MS(__le32_to_cpu(rx_desc->msdu_start.common.info0),
|
2013-06-13 01:52:10 +08:00
|
|
|
RX_MSDU_START_INFO0_MSDU_LENGTH);
|
|
|
|
msdu_chained = rx_desc->frag_info.ring2_more_count;
|
|
|
|
|
|
|
|
if (msdu_len_invalid)
|
|
|
|
msdu_len = 0;
|
|
|
|
|
|
|
|
skb_trim(msdu, 0);
|
|
|
|
skb_put(msdu, min(msdu_len, HTT_RX_MSDU_SIZE));
|
|
|
|
msdu_len -= msdu->len;
|
|
|
|
|
2014-11-18 15:24:47 +08:00
|
|
|
/* Note: Chained buffers do not contain rx descriptor */
|
2013-06-13 01:52:10 +08:00
|
|
|
while (msdu_chained--) {
|
2014-11-18 15:24:47 +08:00
|
|
|
msdu = ath10k_htt_rx_netbuf_pop(htt);
|
|
|
|
if (!msdu) {
|
|
|
|
__skb_queue_purge(amsdu);
|
2014-11-18 15:24:48 +08:00
|
|
|
return -ENOENT;
|
2014-10-23 22:04:24 +08:00
|
|
|
}
|
|
|
|
|
2014-11-18 15:24:47 +08:00
|
|
|
__skb_queue_tail(amsdu, msdu);
|
|
|
|
skb_trim(msdu, 0);
|
|
|
|
skb_put(msdu, min(msdu_len, HTT_RX_BUF_SIZE));
|
|
|
|
msdu_len -= msdu->len;
|
2014-05-14 21:23:31 +08:00
|
|
|
msdu_chaining = 1;
|
2013-06-13 01:52:10 +08:00
|
|
|
}
|
|
|
|
|
2015-07-16 10:01:21 +08:00
|
|
|
last_msdu = __le32_to_cpu(rx_desc->msdu_end.common.info0) &
|
2013-06-13 01:52:10 +08:00
|
|
|
RX_MSDU_END_INFO0_LAST_MSDU;
|
|
|
|
|
2014-10-23 22:04:27 +08:00
|
|
|
trace_ath10k_htt_rx_desc(ar, &rx_desc->attention,
|
2014-10-03 13:02:47 +08:00
|
|
|
sizeof(*rx_desc) - sizeof(u32));
|
2014-09-14 17:50:33 +08:00
|
|
|
|
2014-11-18 15:24:47 +08:00
|
|
|
if (last_msdu)
|
|
|
|
break;
|
2013-06-13 01:52:10 +08:00
|
|
|
}
|
|
|
|
|
2014-11-18 15:24:47 +08:00
|
|
|
if (skb_queue_empty(amsdu))
|
2014-03-25 04:23:20 +08:00
|
|
|
msdu_chaining = -1;
|
|
|
|
|
2013-06-13 01:52:10 +08:00
|
|
|
/*
|
|
|
|
* Don't refill the ring yet.
|
|
|
|
*
|
|
|
|
* First, the elements popped here are still in use - it is not
|
|
|
|
* safe to overwrite them until the matching call to
|
|
|
|
* mpdu_desc_list_next. Second, for efficiency it is preferable to
|
|
|
|
* refill the rx ring with 1 PPDU's worth of rx buffers (something
|
|
|
|
* like 32 x 3 buffers), rather than one MPDU's worth of rx buffers
|
|
|
|
* (something like 3 buffers). Consequently, we'll rely on the txrx
|
|
|
|
* SW to tell us when it is done pulling all the PPDU's rx buffers
|
|
|
|
* out of the rx ring, and then refill it just once.
|
|
|
|
*/
|
|
|
|
|
|
|
|
return msdu_chaining;
|
|
|
|
}
|
|
|
|
|
2015-01-24 18:14:48 +08:00
|
|
|
static struct sk_buff *ath10k_htt_rx_pop_paddr(struct ath10k_htt *htt,
|
2017-12-21 17:00:57 +08:00
|
|
|
u64 paddr)
|
2015-01-24 18:14:48 +08:00
|
|
|
{
|
|
|
|
struct ath10k *ar = htt->ar;
|
|
|
|
struct ath10k_skb_rxcb *rxcb;
|
|
|
|
struct sk_buff *msdu;
|
|
|
|
|
|
|
|
lockdep_assert_held(&htt->rx_ring.lock);
|
|
|
|
|
|
|
|
msdu = ath10k_htt_rx_find_skb_paddr(ar, paddr);
|
|
|
|
if (!msdu)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
rxcb = ATH10K_SKB_RXCB(msdu);
|
|
|
|
hash_del(&rxcb->hlist);
|
|
|
|
htt->rx_ring.fill_cnt--;
|
|
|
|
|
|
|
|
dma_unmap_single(htt->ar->dev, rxcb->paddr,
|
|
|
|
msdu->len + skb_tailroom(msdu),
|
|
|
|
DMA_FROM_DEVICE);
|
|
|
|
ath10k_dbg_dump(ar, ATH10K_DBG_HTT_DUMP, NULL, "htt rx netbuf pop: ",
|
|
|
|
msdu->data, msdu->len + skb_tailroom(msdu));
|
|
|
|
|
|
|
|
return msdu;
|
|
|
|
}
|
|
|
|
|
2018-12-20 15:53:26 +08:00
|
|
|
static inline void ath10k_htt_append_frag_list(struct sk_buff *skb_head,
|
|
|
|
struct sk_buff *frag_list,
|
|
|
|
unsigned int frag_len)
|
|
|
|
{
|
|
|
|
skb_shinfo(skb_head)->frag_list = frag_list;
|
|
|
|
skb_head->data_len = frag_len;
|
|
|
|
skb_head->len += skb_head->data_len;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ath10k_htt_rx_handle_amsdu_mon_32(struct ath10k_htt *htt,
|
|
|
|
struct sk_buff *msdu,
|
|
|
|
struct htt_rx_in_ord_msdu_desc **msdu_desc)
|
|
|
|
{
|
|
|
|
struct ath10k *ar = htt->ar;
|
|
|
|
u32 paddr;
|
|
|
|
struct sk_buff *frag_buf;
|
|
|
|
struct sk_buff *prev_frag_buf;
|
|
|
|
u8 last_frag;
|
|
|
|
struct htt_rx_in_ord_msdu_desc *ind_desc = *msdu_desc;
|
|
|
|
struct htt_rx_desc *rxd;
|
|
|
|
int amsdu_len = __le16_to_cpu(ind_desc->msdu_len);
|
|
|
|
|
|
|
|
rxd = (void *)msdu->data;
|
|
|
|
trace_ath10k_htt_rx_desc(ar, rxd, sizeof(*rxd));
|
|
|
|
|
|
|
|
skb_put(msdu, sizeof(struct htt_rx_desc));
|
|
|
|
skb_pull(msdu, sizeof(struct htt_rx_desc));
|
|
|
|
skb_put(msdu, min(amsdu_len, HTT_RX_MSDU_SIZE));
|
|
|
|
amsdu_len -= msdu->len;
|
|
|
|
|
|
|
|
last_frag = ind_desc->reserved;
|
|
|
|
if (last_frag) {
|
|
|
|
if (amsdu_len) {
|
|
|
|
ath10k_warn(ar, "invalid amsdu len %u, left %d",
|
|
|
|
__le16_to_cpu(ind_desc->msdu_len),
|
|
|
|
amsdu_len);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
ind_desc++;
|
|
|
|
paddr = __le32_to_cpu(ind_desc->msdu_paddr);
|
|
|
|
frag_buf = ath10k_htt_rx_pop_paddr(htt, paddr);
|
|
|
|
if (!frag_buf) {
|
|
|
|
ath10k_warn(ar, "failed to pop frag-1 paddr: 0x%x", paddr);
|
|
|
|
return -ENOENT;
|
|
|
|
}
|
|
|
|
|
|
|
|
skb_put(frag_buf, min(amsdu_len, HTT_RX_BUF_SIZE));
|
|
|
|
ath10k_htt_append_frag_list(msdu, frag_buf, amsdu_len);
|
|
|
|
|
|
|
|
amsdu_len -= frag_buf->len;
|
|
|
|
prev_frag_buf = frag_buf;
|
|
|
|
last_frag = ind_desc->reserved;
|
|
|
|
while (!last_frag) {
|
|
|
|
ind_desc++;
|
|
|
|
paddr = __le32_to_cpu(ind_desc->msdu_paddr);
|
|
|
|
frag_buf = ath10k_htt_rx_pop_paddr(htt, paddr);
|
|
|
|
if (!frag_buf) {
|
|
|
|
ath10k_warn(ar, "failed to pop frag-n paddr: 0x%x",
|
|
|
|
paddr);
|
|
|
|
prev_frag_buf->next = NULL;
|
|
|
|
return -ENOENT;
|
|
|
|
}
|
|
|
|
|
|
|
|
skb_put(frag_buf, min(amsdu_len, HTT_RX_BUF_SIZE));
|
|
|
|
last_frag = ind_desc->reserved;
|
|
|
|
amsdu_len -= frag_buf->len;
|
|
|
|
|
|
|
|
prev_frag_buf->next = frag_buf;
|
|
|
|
prev_frag_buf = frag_buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (amsdu_len) {
|
|
|
|
ath10k_warn(ar, "invalid amsdu len %u, left %d",
|
|
|
|
__le16_to_cpu(ind_desc->msdu_len), amsdu_len);
|
|
|
|
}
|
|
|
|
|
|
|
|
*msdu_desc = ind_desc;
|
|
|
|
|
|
|
|
prev_frag_buf->next = NULL;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
ath10k_htt_rx_handle_amsdu_mon_64(struct ath10k_htt *htt,
|
|
|
|
struct sk_buff *msdu,
|
|
|
|
struct htt_rx_in_ord_msdu_desc_ext **msdu_desc)
|
|
|
|
{
|
|
|
|
struct ath10k *ar = htt->ar;
|
|
|
|
u64 paddr;
|
|
|
|
struct sk_buff *frag_buf;
|
|
|
|
struct sk_buff *prev_frag_buf;
|
|
|
|
u8 last_frag;
|
|
|
|
struct htt_rx_in_ord_msdu_desc_ext *ind_desc = *msdu_desc;
|
|
|
|
struct htt_rx_desc *rxd;
|
|
|
|
int amsdu_len = __le16_to_cpu(ind_desc->msdu_len);
|
|
|
|
|
|
|
|
rxd = (void *)msdu->data;
|
|
|
|
trace_ath10k_htt_rx_desc(ar, rxd, sizeof(*rxd));
|
|
|
|
|
|
|
|
skb_put(msdu, sizeof(struct htt_rx_desc));
|
|
|
|
skb_pull(msdu, sizeof(struct htt_rx_desc));
|
|
|
|
skb_put(msdu, min(amsdu_len, HTT_RX_MSDU_SIZE));
|
|
|
|
amsdu_len -= msdu->len;
|
|
|
|
|
|
|
|
last_frag = ind_desc->reserved;
|
|
|
|
if (last_frag) {
|
|
|
|
if (amsdu_len) {
|
|
|
|
ath10k_warn(ar, "invalid amsdu len %u, left %d",
|
|
|
|
__le16_to_cpu(ind_desc->msdu_len),
|
|
|
|
amsdu_len);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
ind_desc++;
|
|
|
|
paddr = __le64_to_cpu(ind_desc->msdu_paddr);
|
|
|
|
frag_buf = ath10k_htt_rx_pop_paddr(htt, paddr);
|
|
|
|
if (!frag_buf) {
|
|
|
|
ath10k_warn(ar, "failed to pop frag-1 paddr: 0x%llx", paddr);
|
|
|
|
return -ENOENT;
|
|
|
|
}
|
|
|
|
|
|
|
|
skb_put(frag_buf, min(amsdu_len, HTT_RX_BUF_SIZE));
|
|
|
|
ath10k_htt_append_frag_list(msdu, frag_buf, amsdu_len);
|
|
|
|
|
|
|
|
amsdu_len -= frag_buf->len;
|
|
|
|
prev_frag_buf = frag_buf;
|
|
|
|
last_frag = ind_desc->reserved;
|
|
|
|
while (!last_frag) {
|
|
|
|
ind_desc++;
|
|
|
|
paddr = __le64_to_cpu(ind_desc->msdu_paddr);
|
|
|
|
frag_buf = ath10k_htt_rx_pop_paddr(htt, paddr);
|
|
|
|
if (!frag_buf) {
|
|
|
|
ath10k_warn(ar, "failed to pop frag-n paddr: 0x%llx",
|
|
|
|
paddr);
|
|
|
|
prev_frag_buf->next = NULL;
|
|
|
|
return -ENOENT;
|
|
|
|
}
|
|
|
|
|
|
|
|
skb_put(frag_buf, min(amsdu_len, HTT_RX_BUF_SIZE));
|
|
|
|
last_frag = ind_desc->reserved;
|
|
|
|
amsdu_len -= frag_buf->len;
|
|
|
|
|
|
|
|
prev_frag_buf->next = frag_buf;
|
|
|
|
prev_frag_buf = frag_buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (amsdu_len) {
|
|
|
|
ath10k_warn(ar, "invalid amsdu len %u, left %d",
|
|
|
|
__le16_to_cpu(ind_desc->msdu_len), amsdu_len);
|
|
|
|
}
|
|
|
|
|
|
|
|
*msdu_desc = ind_desc;
|
|
|
|
|
|
|
|
prev_frag_buf->next = NULL;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-12-21 17:00:52 +08:00
|
|
|
static int ath10k_htt_rx_pop_paddr32_list(struct ath10k_htt *htt,
|
|
|
|
struct htt_rx_in_ord_ind *ev,
|
|
|
|
struct sk_buff_head *list)
|
2015-01-24 18:14:48 +08:00
|
|
|
{
|
|
|
|
struct ath10k *ar = htt->ar;
|
2017-12-21 17:00:52 +08:00
|
|
|
struct htt_rx_in_ord_msdu_desc *msdu_desc = ev->msdu_descs32;
|
2015-01-24 18:14:48 +08:00
|
|
|
struct htt_rx_desc *rxd;
|
|
|
|
struct sk_buff *msdu;
|
2018-12-20 15:53:26 +08:00
|
|
|
int msdu_count, ret;
|
2015-01-24 18:14:48 +08:00
|
|
|
bool is_offload;
|
|
|
|
u32 paddr;
|
|
|
|
|
|
|
|
lockdep_assert_held(&htt->rx_ring.lock);
|
|
|
|
|
|
|
|
msdu_count = __le16_to_cpu(ev->msdu_count);
|
|
|
|
is_offload = !!(ev->info & HTT_RX_IN_ORD_IND_INFO_OFFLOAD_MASK);
|
|
|
|
|
|
|
|
while (msdu_count--) {
|
|
|
|
paddr = __le32_to_cpu(msdu_desc->msdu_paddr);
|
|
|
|
|
|
|
|
msdu = ath10k_htt_rx_pop_paddr(htt, paddr);
|
|
|
|
if (!msdu) {
|
|
|
|
__skb_queue_purge(list);
|
|
|
|
return -ENOENT;
|
|
|
|
}
|
|
|
|
|
2018-12-20 15:53:26 +08:00
|
|
|
if (!is_offload && ar->monitor_arvif) {
|
|
|
|
ret = ath10k_htt_rx_handle_amsdu_mon_32(htt, msdu,
|
|
|
|
&msdu_desc);
|
|
|
|
if (ret) {
|
|
|
|
__skb_queue_purge(list);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
__skb_queue_tail(list, msdu);
|
|
|
|
msdu_desc++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2015-01-24 18:14:48 +08:00
|
|
|
__skb_queue_tail(list, msdu);
|
|
|
|
|
|
|
|
if (!is_offload) {
|
|
|
|
rxd = (void *)msdu->data;
|
|
|
|
|
|
|
|
trace_ath10k_htt_rx_desc(ar, rxd, sizeof(*rxd));
|
|
|
|
|
|
|
|
skb_put(msdu, sizeof(*rxd));
|
|
|
|
skb_pull(msdu, sizeof(*rxd));
|
|
|
|
skb_put(msdu, __le16_to_cpu(msdu_desc->msdu_len));
|
|
|
|
|
|
|
|
if (!(__le32_to_cpu(rxd->attention.flags) &
|
|
|
|
RX_ATTENTION_FLAGS_MSDU_DONE)) {
|
|
|
|
ath10k_warn(htt->ar, "tried to pop an incomplete frame, oops!\n");
|
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
msdu_desc++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-12-21 17:00:52 +08:00
|
|
|
static int ath10k_htt_rx_pop_paddr64_list(struct ath10k_htt *htt,
|
|
|
|
struct htt_rx_in_ord_ind *ev,
|
|
|
|
struct sk_buff_head *list)
|
|
|
|
{
|
|
|
|
struct ath10k *ar = htt->ar;
|
|
|
|
struct htt_rx_in_ord_msdu_desc_ext *msdu_desc = ev->msdu_descs64;
|
|
|
|
struct htt_rx_desc *rxd;
|
|
|
|
struct sk_buff *msdu;
|
2018-12-20 15:53:26 +08:00
|
|
|
int msdu_count, ret;
|
2017-12-21 17:00:52 +08:00
|
|
|
bool is_offload;
|
|
|
|
u64 paddr;
|
|
|
|
|
|
|
|
lockdep_assert_held(&htt->rx_ring.lock);
|
|
|
|
|
|
|
|
msdu_count = __le16_to_cpu(ev->msdu_count);
|
|
|
|
is_offload = !!(ev->info & HTT_RX_IN_ORD_IND_INFO_OFFLOAD_MASK);
|
|
|
|
|
|
|
|
while (msdu_count--) {
|
|
|
|
paddr = __le64_to_cpu(msdu_desc->msdu_paddr);
|
|
|
|
msdu = ath10k_htt_rx_pop_paddr(htt, paddr);
|
|
|
|
if (!msdu) {
|
|
|
|
__skb_queue_purge(list);
|
|
|
|
return -ENOENT;
|
|
|
|
}
|
|
|
|
|
2018-12-20 15:53:26 +08:00
|
|
|
if (!is_offload && ar->monitor_arvif) {
|
|
|
|
ret = ath10k_htt_rx_handle_amsdu_mon_64(htt, msdu,
|
|
|
|
&msdu_desc);
|
|
|
|
if (ret) {
|
|
|
|
__skb_queue_purge(list);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
__skb_queue_tail(list, msdu);
|
|
|
|
msdu_desc++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2017-12-21 17:00:52 +08:00
|
|
|
__skb_queue_tail(list, msdu);
|
|
|
|
|
|
|
|
if (!is_offload) {
|
|
|
|
rxd = (void *)msdu->data;
|
|
|
|
|
|
|
|
trace_ath10k_htt_rx_desc(ar, rxd, sizeof(*rxd));
|
|
|
|
|
|
|
|
skb_put(msdu, sizeof(*rxd));
|
|
|
|
skb_pull(msdu, sizeof(*rxd));
|
|
|
|
skb_put(msdu, __le16_to_cpu(msdu_desc->msdu_len));
|
|
|
|
|
|
|
|
if (!(__le32_to_cpu(rxd->attention.flags) &
|
|
|
|
RX_ATTENTION_FLAGS_MSDU_DONE)) {
|
|
|
|
ath10k_warn(htt->ar, "tried to pop an incomplete frame, oops!\n");
|
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
msdu_desc++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-05-16 22:15:39 +08:00
|
|
|
int ath10k_htt_rx_alloc(struct ath10k_htt *htt)
|
2013-06-13 01:52:10 +08:00
|
|
|
{
|
2014-08-25 18:09:38 +08:00
|
|
|
struct ath10k *ar = htt->ar;
|
2013-06-13 01:52:10 +08:00
|
|
|
dma_addr_t paddr;
|
2017-12-21 17:00:57 +08:00
|
|
|
void *vaddr, *vaddr_ring;
|
2014-09-14 17:50:00 +08:00
|
|
|
size_t size;
|
2013-06-13 01:52:10 +08:00
|
|
|
struct timer_list *timer = &htt->rx_ring.refill_retry_timer;
|
|
|
|
|
2018-09-04 20:06:58 +08:00
|
|
|
if (ar->dev_type == ATH10K_DEV_TYPE_HL)
|
|
|
|
return 0;
|
|
|
|
|
2014-10-23 22:04:24 +08:00
|
|
|
htt->rx_confused = false;
|
|
|
|
|
2014-11-27 18:12:43 +08:00
|
|
|
/* XXX: The fill level could be changed during runtime in response to
|
|
|
|
* the host processing latency. Is this really worth it?
|
|
|
|
*/
|
|
|
|
htt->rx_ring.size = HTT_RX_RING_SIZE;
|
|
|
|
htt->rx_ring.size_mask = htt->rx_ring.size - 1;
|
2017-12-21 17:00:56 +08:00
|
|
|
htt->rx_ring.fill_level = ar->hw_params.rx_ring_fill_level;
|
2014-11-27 18:12:43 +08:00
|
|
|
|
2013-06-13 01:52:10 +08:00
|
|
|
if (!is_power_of_2(htt->rx_ring.size)) {
|
2014-08-25 18:09:38 +08:00
|
|
|
ath10k_warn(ar, "htt rx ring size is not power of 2\n");
|
2013-06-13 01:52:10 +08:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
htt->rx_ring.netbufs_ring =
|
treewide: kzalloc() -> kcalloc()
The kzalloc() function has a 2-factor argument form, kcalloc(). This
patch replaces cases of:
kzalloc(a * b, gfp)
with:
kcalloc(a * b, gfp)
as well as handling cases of:
kzalloc(a * b * c, gfp)
with:
kzalloc(array3_size(a, b, c), gfp)
as it's slightly less ugly than:
kzalloc_array(array_size(a, b), c, gfp)
This does, however, attempt to ignore constant size factors like:
kzalloc(4 * 1024, gfp)
though any constants defined via macros get caught up in the conversion.
Any factors with a sizeof() of "unsigned char", "char", and "u8" were
dropped, since they're redundant.
The Coccinelle script used for this was:
// Fix redundant parens around sizeof().
@@
type TYPE;
expression THING, E;
@@
(
kzalloc(
- (sizeof(TYPE)) * E
+ sizeof(TYPE) * E
, ...)
|
kzalloc(
- (sizeof(THING)) * E
+ sizeof(THING) * E
, ...)
)
// Drop single-byte sizes and redundant parens.
@@
expression COUNT;
typedef u8;
typedef __u8;
@@
(
kzalloc(
- sizeof(u8) * (COUNT)
+ COUNT
, ...)
|
kzalloc(
- sizeof(__u8) * (COUNT)
+ COUNT
, ...)
|
kzalloc(
- sizeof(char) * (COUNT)
+ COUNT
, ...)
|
kzalloc(
- sizeof(unsigned char) * (COUNT)
+ COUNT
, ...)
|
kzalloc(
- sizeof(u8) * COUNT
+ COUNT
, ...)
|
kzalloc(
- sizeof(__u8) * COUNT
+ COUNT
, ...)
|
kzalloc(
- sizeof(char) * COUNT
+ COUNT
, ...)
|
kzalloc(
- sizeof(unsigned char) * COUNT
+ COUNT
, ...)
)
// 2-factor product with sizeof(type/expression) and identifier or constant.
@@
type TYPE;
expression THING;
identifier COUNT_ID;
constant COUNT_CONST;
@@
(
- kzalloc
+ kcalloc
(
- sizeof(TYPE) * (COUNT_ID)
+ COUNT_ID, sizeof(TYPE)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(TYPE) * COUNT_ID
+ COUNT_ID, sizeof(TYPE)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(TYPE) * (COUNT_CONST)
+ COUNT_CONST, sizeof(TYPE)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(TYPE) * COUNT_CONST
+ COUNT_CONST, sizeof(TYPE)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(THING) * (COUNT_ID)
+ COUNT_ID, sizeof(THING)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(THING) * COUNT_ID
+ COUNT_ID, sizeof(THING)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(THING) * (COUNT_CONST)
+ COUNT_CONST, sizeof(THING)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(THING) * COUNT_CONST
+ COUNT_CONST, sizeof(THING)
, ...)
)
// 2-factor product, only identifiers.
@@
identifier SIZE, COUNT;
@@
- kzalloc
+ kcalloc
(
- SIZE * COUNT
+ COUNT, SIZE
, ...)
// 3-factor product with 1 sizeof(type) or sizeof(expression), with
// redundant parens removed.
@@
expression THING;
identifier STRIDE, COUNT;
type TYPE;
@@
(
kzalloc(
- sizeof(TYPE) * (COUNT) * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
kzalloc(
- sizeof(TYPE) * (COUNT) * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
kzalloc(
- sizeof(TYPE) * COUNT * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
kzalloc(
- sizeof(TYPE) * COUNT * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
kzalloc(
- sizeof(THING) * (COUNT) * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
|
kzalloc(
- sizeof(THING) * (COUNT) * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
|
kzalloc(
- sizeof(THING) * COUNT * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
|
kzalloc(
- sizeof(THING) * COUNT * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
)
// 3-factor product with 2 sizeof(variable), with redundant parens removed.
@@
expression THING1, THING2;
identifier COUNT;
type TYPE1, TYPE2;
@@
(
kzalloc(
- sizeof(TYPE1) * sizeof(TYPE2) * COUNT
+ array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
, ...)
|
kzalloc(
- sizeof(TYPE1) * sizeof(THING2) * (COUNT)
+ array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
, ...)
|
kzalloc(
- sizeof(THING1) * sizeof(THING2) * COUNT
+ array3_size(COUNT, sizeof(THING1), sizeof(THING2))
, ...)
|
kzalloc(
- sizeof(THING1) * sizeof(THING2) * (COUNT)
+ array3_size(COUNT, sizeof(THING1), sizeof(THING2))
, ...)
|
kzalloc(
- sizeof(TYPE1) * sizeof(THING2) * COUNT
+ array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
, ...)
|
kzalloc(
- sizeof(TYPE1) * sizeof(THING2) * (COUNT)
+ array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
, ...)
)
// 3-factor product, only identifiers, with redundant parens removed.
@@
identifier STRIDE, SIZE, COUNT;
@@
(
kzalloc(
- (COUNT) * STRIDE * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kzalloc(
- COUNT * (STRIDE) * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kzalloc(
- COUNT * STRIDE * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kzalloc(
- (COUNT) * (STRIDE) * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kzalloc(
- COUNT * (STRIDE) * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kzalloc(
- (COUNT) * STRIDE * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kzalloc(
- (COUNT) * (STRIDE) * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kzalloc(
- COUNT * STRIDE * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
)
// Any remaining multi-factor products, first at least 3-factor products,
// when they're not all constants...
@@
expression E1, E2, E3;
constant C1, C2, C3;
@@
(
kzalloc(C1 * C2 * C3, ...)
|
kzalloc(
- (E1) * E2 * E3
+ array3_size(E1, E2, E3)
, ...)
|
kzalloc(
- (E1) * (E2) * E3
+ array3_size(E1, E2, E3)
, ...)
|
kzalloc(
- (E1) * (E2) * (E3)
+ array3_size(E1, E2, E3)
, ...)
|
kzalloc(
- E1 * E2 * E3
+ array3_size(E1, E2, E3)
, ...)
)
// And then all remaining 2 factors products when they're not all constants,
// keeping sizeof() as the second factor argument.
@@
expression THING, E1, E2;
type TYPE;
constant C1, C2, C3;
@@
(
kzalloc(sizeof(THING) * C2, ...)
|
kzalloc(sizeof(TYPE) * C2, ...)
|
kzalloc(C1 * C2 * C3, ...)
|
kzalloc(C1 * C2, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(TYPE) * (E2)
+ E2, sizeof(TYPE)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(TYPE) * E2
+ E2, sizeof(TYPE)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(THING) * (E2)
+ E2, sizeof(THING)
, ...)
|
- kzalloc
+ kcalloc
(
- sizeof(THING) * E2
+ E2, sizeof(THING)
, ...)
|
- kzalloc
+ kcalloc
(
- (E1) * E2
+ E1, E2
, ...)
|
- kzalloc
+ kcalloc
(
- (E1) * (E2)
+ E1, E2
, ...)
|
- kzalloc
+ kcalloc
(
- E1 * E2
+ E1, E2
, ...)
)
Signed-off-by: Kees Cook <keescook@chromium.org>
2018-06-13 05:03:40 +08:00
|
|
|
kcalloc(htt->rx_ring.size, sizeof(struct sk_buff *),
|
2013-06-13 01:52:10 +08:00
|
|
|
GFP_KERNEL);
|
|
|
|
if (!htt->rx_ring.netbufs_ring)
|
|
|
|
goto err_netbuf;
|
|
|
|
|
2018-04-15 20:22:28 +08:00
|
|
|
size = ath10k_htt_get_rx_ring_size(htt);
|
2014-09-14 17:50:00 +08:00
|
|
|
|
2017-12-21 17:00:57 +08:00
|
|
|
vaddr_ring = dma_alloc_coherent(htt->ar->dev, size, &paddr, GFP_KERNEL);
|
|
|
|
if (!vaddr_ring)
|
2013-06-13 01:52:10 +08:00
|
|
|
goto err_dma_ring;
|
|
|
|
|
2018-04-15 20:22:28 +08:00
|
|
|
ath10k_htt_config_paddrs_ring(htt, vaddr_ring);
|
2013-06-13 01:52:10 +08:00
|
|
|
htt->rx_ring.base_paddr = paddr;
|
|
|
|
|
|
|
|
vaddr = dma_alloc_coherent(htt->ar->dev,
|
|
|
|
sizeof(*htt->rx_ring.alloc_idx.vaddr),
|
2015-11-24 18:36:52 +08:00
|
|
|
&paddr, GFP_KERNEL);
|
2013-06-13 01:52:10 +08:00
|
|
|
if (!vaddr)
|
|
|
|
goto err_dma_idx;
|
|
|
|
|
|
|
|
htt->rx_ring.alloc_idx.vaddr = vaddr;
|
|
|
|
htt->rx_ring.alloc_idx.paddr = paddr;
|
2015-01-24 18:14:48 +08:00
|
|
|
htt->rx_ring.sw_rd_idx.msdu_payld = htt->rx_ring.size_mask;
|
2013-06-13 01:52:10 +08:00
|
|
|
*htt->rx_ring.alloc_idx.vaddr = 0;
|
|
|
|
|
|
|
|
/* Initialize the Rx refill retry timer */
|
2017-10-24 17:29:54 +08:00
|
|
|
timer_setup(timer, ath10k_htt_rx_ring_refill_retry, 0);
|
2013-06-13 01:52:10 +08:00
|
|
|
|
|
|
|
spin_lock_init(&htt->rx_ring.lock);
|
|
|
|
|
|
|
|
htt->rx_ring.fill_cnt = 0;
|
2015-01-24 18:14:48 +08:00
|
|
|
htt->rx_ring.sw_rd_idx.msdu_payld = 0;
|
|
|
|
hash_init(htt->rx_ring.skb_table);
|
2013-06-13 01:52:10 +08:00
|
|
|
|
2017-12-07 22:58:05 +08:00
|
|
|
skb_queue_head_init(&htt->rx_msdus_q);
|
2015-01-24 18:14:48 +08:00
|
|
|
skb_queue_head_init(&htt->rx_in_ord_compl_q);
|
2016-03-06 22:14:43 +08:00
|
|
|
skb_queue_head_init(&htt->tx_fetch_ind_q);
|
2016-03-22 19:52:15 +08:00
|
|
|
atomic_set(&htt->num_mpdus_ready, 0);
|
2014-02-28 00:50:04 +08:00
|
|
|
|
2014-08-25 18:09:38 +08:00
|
|
|
ath10k_dbg(ar, ATH10K_DBG_BOOT, "htt rx ring size %d fill_level %d\n",
|
2013-06-13 01:52:10 +08:00
|
|
|
htt->rx_ring.size, htt->rx_ring.fill_level);
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
err_dma_idx:
|
|
|
|
dma_free_coherent(htt->ar->dev,
|
2018-04-15 20:22:28 +08:00
|
|
|
ath10k_htt_get_rx_ring_size(htt),
|
2017-12-21 17:00:57 +08:00
|
|
|
vaddr_ring,
|
2013-06-13 01:52:10 +08:00
|
|
|
htt->rx_ring.base_paddr);
|
|
|
|
err_dma_ring:
|
|
|
|
kfree(htt->rx_ring.netbufs_ring);
|
|
|
|
err_netbuf:
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
2014-08-25 18:09:38 +08:00
|
|
|
static int ath10k_htt_rx_crypto_param_len(struct ath10k *ar,
|
|
|
|
enum htt_rx_mpdu_encrypt_type type)
|
2013-06-13 01:52:10 +08:00
|
|
|
{
|
|
|
|
switch (type) {
|
2014-10-23 22:04:22 +08:00
|
|
|
case HTT_RX_MPDU_ENCRYPT_NONE:
|
|
|
|
return 0;
|
2013-06-13 01:52:10 +08:00
|
|
|
case HTT_RX_MPDU_ENCRYPT_WEP40:
|
|
|
|
case HTT_RX_MPDU_ENCRYPT_WEP104:
|
2014-10-23 22:04:22 +08:00
|
|
|
return IEEE80211_WEP_IV_LEN;
|
2013-06-13 01:52:10 +08:00
|
|
|
case HTT_RX_MPDU_ENCRYPT_TKIP_WITHOUT_MIC:
|
|
|
|
case HTT_RX_MPDU_ENCRYPT_TKIP_WPA:
|
2014-10-23 22:04:22 +08:00
|
|
|
return IEEE80211_TKIP_IV_LEN;
|
2013-06-13 01:52:10 +08:00
|
|
|
case HTT_RX_MPDU_ENCRYPT_AES_CCM_WPA2:
|
2014-10-23 22:04:22 +08:00
|
|
|
return IEEE80211_CCMP_HDR_LEN;
|
2017-10-27 23:35:31 +08:00
|
|
|
case HTT_RX_MPDU_ENCRYPT_AES_CCM256_WPA2:
|
|
|
|
return IEEE80211_CCMP_256_HDR_LEN;
|
|
|
|
case HTT_RX_MPDU_ENCRYPT_AES_GCMP_WPA2:
|
|
|
|
case HTT_RX_MPDU_ENCRYPT_AES_GCMP256_WPA2:
|
|
|
|
return IEEE80211_GCMP_HDR_LEN;
|
2014-10-23 22:04:22 +08:00
|
|
|
case HTT_RX_MPDU_ENCRYPT_WEP128:
|
|
|
|
case HTT_RX_MPDU_ENCRYPT_WAPI:
|
|
|
|
break;
|
2013-06-13 01:52:10 +08:00
|
|
|
}
|
|
|
|
|
2014-10-23 22:04:22 +08:00
|
|
|
ath10k_warn(ar, "unsupported encryption type %d\n", type);
|
2013-06-13 01:52:10 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-10-23 22:04:22 +08:00
|
|
|
#define MICHAEL_MIC_LEN 8
|
|
|
|
|
2017-10-27 23:35:41 +08:00
|
|
|
static int ath10k_htt_rx_crypto_mic_len(struct ath10k *ar,
|
|
|
|
enum htt_rx_mpdu_encrypt_type type)
|
2013-06-13 01:52:10 +08:00
|
|
|
{
|
|
|
|
switch (type) {
|
|
|
|
case HTT_RX_MPDU_ENCRYPT_NONE:
|
|
|
|
case HTT_RX_MPDU_ENCRYPT_WEP40:
|
|
|
|
case HTT_RX_MPDU_ENCRYPT_WEP104:
|
|
|
|
case HTT_RX_MPDU_ENCRYPT_TKIP_WITHOUT_MIC:
|
|
|
|
case HTT_RX_MPDU_ENCRYPT_TKIP_WPA:
|
2017-10-27 23:35:41 +08:00
|
|
|
return 0;
|
2013-06-13 01:52:10 +08:00
|
|
|
case HTT_RX_MPDU_ENCRYPT_AES_CCM_WPA2:
|
2014-10-23 22:04:22 +08:00
|
|
|
return IEEE80211_CCMP_MIC_LEN;
|
2017-10-27 23:35:31 +08:00
|
|
|
case HTT_RX_MPDU_ENCRYPT_AES_CCM256_WPA2:
|
|
|
|
return IEEE80211_CCMP_256_MIC_LEN;
|
|
|
|
case HTT_RX_MPDU_ENCRYPT_AES_GCMP_WPA2:
|
|
|
|
case HTT_RX_MPDU_ENCRYPT_AES_GCMP256_WPA2:
|
|
|
|
return IEEE80211_GCMP_MIC_LEN;
|
2014-10-23 22:04:22 +08:00
|
|
|
case HTT_RX_MPDU_ENCRYPT_WEP128:
|
|
|
|
case HTT_RX_MPDU_ENCRYPT_WAPI:
|
|
|
|
break;
|
2013-06-13 01:52:10 +08:00
|
|
|
}
|
|
|
|
|
2014-10-23 22:04:22 +08:00
|
|
|
ath10k_warn(ar, "unsupported encryption type %d\n", type);
|
2013-06-13 01:52:10 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-10-27 23:35:41 +08:00
|
|
|
static int ath10k_htt_rx_crypto_icv_len(struct ath10k *ar,
|
|
|
|
enum htt_rx_mpdu_encrypt_type type)
|
|
|
|
{
|
|
|
|
switch (type) {
|
|
|
|
case HTT_RX_MPDU_ENCRYPT_NONE:
|
|
|
|
case HTT_RX_MPDU_ENCRYPT_AES_CCM_WPA2:
|
|
|
|
case HTT_RX_MPDU_ENCRYPT_AES_CCM256_WPA2:
|
|
|
|
case HTT_RX_MPDU_ENCRYPT_AES_GCMP_WPA2:
|
|
|
|
case HTT_RX_MPDU_ENCRYPT_AES_GCMP256_WPA2:
|
|
|
|
return 0;
|
|
|
|
case HTT_RX_MPDU_ENCRYPT_WEP40:
|
|
|
|
case HTT_RX_MPDU_ENCRYPT_WEP104:
|
|
|
|
return IEEE80211_WEP_ICV_LEN;
|
|
|
|
case HTT_RX_MPDU_ENCRYPT_TKIP_WITHOUT_MIC:
|
|
|
|
case HTT_RX_MPDU_ENCRYPT_TKIP_WPA:
|
|
|
|
return IEEE80211_TKIP_ICV_LEN;
|
|
|
|
case HTT_RX_MPDU_ENCRYPT_WEP128:
|
|
|
|
case HTT_RX_MPDU_ENCRYPT_WAPI:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
ath10k_warn(ar, "unsupported encryption type %d\n", type);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-09-26 15:12:22 +08:00
|
|
|
struct amsdu_subframe_hdr {
|
|
|
|
u8 dst[ETH_ALEN];
|
|
|
|
u8 src[ETH_ALEN];
|
|
|
|
__be16 len;
|
|
|
|
} __packed;
|
|
|
|
|
2015-08-27 20:47:33 +08:00
|
|
|
#define GROUP_ID_IS_SU_MIMO(x) ((x) == 0 || (x) == 63)
|
|
|
|
|
2018-03-28 17:19:55 +08:00
|
|
|
static inline u8 ath10k_bw_to_mac80211_bw(u8 bw)
|
|
|
|
{
|
|
|
|
u8 ret = 0;
|
|
|
|
|
|
|
|
switch (bw) {
|
|
|
|
case 0:
|
|
|
|
ret = RATE_INFO_BW_20;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
ret = RATE_INFO_BW_40;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
ret = RATE_INFO_BW_80;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
ret = RATE_INFO_BW_160;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2014-03-25 04:23:19 +08:00
|
|
|
static void ath10k_htt_rx_h_rates(struct ath10k *ar,
|
2014-11-18 15:24:49 +08:00
|
|
|
struct ieee80211_rx_status *status,
|
|
|
|
struct htt_rx_desc *rxd)
|
2014-03-25 04:23:15 +08:00
|
|
|
{
|
2015-03-30 14:51:56 +08:00
|
|
|
struct ieee80211_supported_band *sband;
|
|
|
|
u8 cck, rate, bw, sgi, mcs, nss;
|
2014-03-25 04:23:15 +08:00
|
|
|
u8 preamble = 0;
|
2015-08-27 20:47:33 +08:00
|
|
|
u8 group_id;
|
2014-11-18 15:24:49 +08:00
|
|
|
u32 info1, info2, info3;
|
2014-03-25 04:23:15 +08:00
|
|
|
|
2014-11-18 15:24:49 +08:00
|
|
|
info1 = __le32_to_cpu(rxd->ppdu_start.info1);
|
|
|
|
info2 = __le32_to_cpu(rxd->ppdu_start.info2);
|
|
|
|
info3 = __le32_to_cpu(rxd->ppdu_start.info3);
|
|
|
|
|
|
|
|
preamble = MS(info1, RX_PPDU_START_INFO1_PREAMBLE_TYPE);
|
2014-03-25 04:23:15 +08:00
|
|
|
|
|
|
|
switch (preamble) {
|
|
|
|
case HTT_RX_LEGACY:
|
2015-03-30 14:51:56 +08:00
|
|
|
/* To get legacy rate index band is required. Since band can't
|
|
|
|
* be undefined check if freq is non-zero.
|
|
|
|
*/
|
|
|
|
if (!status->freq)
|
|
|
|
return;
|
|
|
|
|
2014-11-18 15:24:49 +08:00
|
|
|
cck = info1 & RX_PPDU_START_INFO1_L_SIG_RATE_SELECT;
|
|
|
|
rate = MS(info1, RX_PPDU_START_INFO1_L_SIG_RATE);
|
2015-03-30 14:51:56 +08:00
|
|
|
rate &= ~RX_PPDU_START_RATE_FLAG;
|
2014-03-25 04:23:15 +08:00
|
|
|
|
2015-03-30 14:51:56 +08:00
|
|
|
sband = &ar->mac.sbands[status->band];
|
2015-11-13 02:36:10 +08:00
|
|
|
status->rate_idx = ath10k_mac_hw_rate_to_idx(sband, rate, cck);
|
2014-03-25 04:23:15 +08:00
|
|
|
break;
|
|
|
|
case HTT_RX_HT:
|
|
|
|
case HTT_RX_HT_WITH_TXBF:
|
2014-11-18 15:24:49 +08:00
|
|
|
/* HT-SIG - Table 20-11 in info2 and info3 */
|
|
|
|
mcs = info2 & 0x1F;
|
2014-03-25 04:23:15 +08:00
|
|
|
nss = mcs >> 3;
|
2014-11-18 15:24:49 +08:00
|
|
|
bw = (info2 >> 7) & 1;
|
|
|
|
sgi = (info3 >> 7) & 1;
|
2014-03-25 04:23:15 +08:00
|
|
|
|
|
|
|
status->rate_idx = mcs;
|
2017-04-26 18:14:59 +08:00
|
|
|
status->encoding = RX_ENC_HT;
|
2014-03-25 04:23:15 +08:00
|
|
|
if (sgi)
|
2017-04-26 17:13:00 +08:00
|
|
|
status->enc_flags |= RX_ENC_FLAG_SHORT_GI;
|
2014-03-25 04:23:15 +08:00
|
|
|
if (bw)
|
2017-04-26 18:14:59 +08:00
|
|
|
status->bw = RATE_INFO_BW_40;
|
2014-03-25 04:23:15 +08:00
|
|
|
break;
|
|
|
|
case HTT_RX_VHT:
|
|
|
|
case HTT_RX_VHT_WITH_TXBF:
|
2014-11-18 15:24:49 +08:00
|
|
|
/* VHT-SIG-A1 in info2, VHT-SIG-A2 in info3
|
2017-02-20 21:39:57 +08:00
|
|
|
* TODO check this
|
|
|
|
*/
|
2014-11-18 15:24:49 +08:00
|
|
|
bw = info2 & 3;
|
|
|
|
sgi = info3 & 1;
|
2015-08-27 20:47:33 +08:00
|
|
|
group_id = (info2 >> 4) & 0x3F;
|
|
|
|
|
|
|
|
if (GROUP_ID_IS_SU_MIMO(group_id)) {
|
|
|
|
mcs = (info3 >> 4) & 0x0F;
|
|
|
|
nss = ((info2 >> 10) & 0x07) + 1;
|
|
|
|
} else {
|
|
|
|
/* Hardware doesn't decode VHT-SIG-B into Rx descriptor
|
|
|
|
* so it's impossible to decode MCS. Also since
|
|
|
|
* firmware consumes Group Id Management frames host
|
|
|
|
* has no knowledge regarding group/user position
|
|
|
|
* mapping so it's impossible to pick the correct Nsts
|
|
|
|
* from VHT-SIG-A1.
|
|
|
|
*
|
|
|
|
* Bandwidth and SGI are valid so report the rateinfo
|
|
|
|
* on best-effort basis.
|
|
|
|
*/
|
|
|
|
mcs = 0;
|
|
|
|
nss = 1;
|
|
|
|
}
|
2014-03-25 04:23:15 +08:00
|
|
|
|
2015-09-02 22:05:27 +08:00
|
|
|
if (mcs > 0x09) {
|
|
|
|
ath10k_warn(ar, "invalid MCS received %u\n", mcs);
|
|
|
|
ath10k_warn(ar, "rxd %08x mpdu start %08x %08x msdu start %08x %08x ppdu start %08x %08x %08x %08x %08x\n",
|
|
|
|
__le32_to_cpu(rxd->attention.flags),
|
|
|
|
__le32_to_cpu(rxd->mpdu_start.info0),
|
|
|
|
__le32_to_cpu(rxd->mpdu_start.info1),
|
|
|
|
__le32_to_cpu(rxd->msdu_start.common.info0),
|
|
|
|
__le32_to_cpu(rxd->msdu_start.common.info1),
|
|
|
|
rxd->ppdu_start.info0,
|
|
|
|
__le32_to_cpu(rxd->ppdu_start.info1),
|
|
|
|
__le32_to_cpu(rxd->ppdu_start.info2),
|
|
|
|
__le32_to_cpu(rxd->ppdu_start.info3),
|
|
|
|
__le32_to_cpu(rxd->ppdu_start.info4));
|
|
|
|
|
|
|
|
ath10k_warn(ar, "msdu end %08x mpdu end %08x\n",
|
|
|
|
__le32_to_cpu(rxd->msdu_end.common.info0),
|
|
|
|
__le32_to_cpu(rxd->mpdu_end.info0));
|
|
|
|
|
|
|
|
ath10k_dbg_dump(ar, ATH10K_DBG_HTT_DUMP, NULL,
|
|
|
|
"rx desc msdu payload: ",
|
|
|
|
rxd->msdu_payload, 50);
|
|
|
|
}
|
|
|
|
|
2014-03-25 04:23:15 +08:00
|
|
|
status->rate_idx = mcs;
|
2017-04-26 19:51:41 +08:00
|
|
|
status->nss = nss;
|
2014-03-25 04:23:15 +08:00
|
|
|
|
|
|
|
if (sgi)
|
2017-04-26 17:13:00 +08:00
|
|
|
status->enc_flags |= RX_ENC_FLAG_SHORT_GI;
|
2014-03-25 04:23:15 +08:00
|
|
|
|
2018-03-28 17:19:55 +08:00
|
|
|
status->bw = ath10k_bw_to_mac80211_bw(bw);
|
2017-04-26 18:14:59 +08:00
|
|
|
status->encoding = RX_ENC_VHT;
|
2014-03-25 04:23:15 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-31 18:26:21 +08:00
|
|
|
static struct ieee80211_channel *
|
|
|
|
ath10k_htt_rx_h_peer_channel(struct ath10k *ar, struct htt_rx_desc *rxd)
|
|
|
|
{
|
|
|
|
struct ath10k_peer *peer;
|
|
|
|
struct ath10k_vif *arvif;
|
|
|
|
struct cfg80211_chan_def def;
|
|
|
|
u16 peer_id;
|
|
|
|
|
|
|
|
lockdep_assert_held(&ar->data_lock);
|
|
|
|
|
|
|
|
if (!rxd)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (rxd->attention.flags &
|
|
|
|
__cpu_to_le32(RX_ATTENTION_FLAGS_PEER_IDX_INVALID))
|
|
|
|
return NULL;
|
|
|
|
|
2015-07-16 10:01:21 +08:00
|
|
|
if (!(rxd->msdu_end.common.info0 &
|
2015-03-31 18:26:21 +08:00
|
|
|
__cpu_to_le32(RX_MSDU_END_INFO0_FIRST_MSDU)))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
peer_id = MS(__le32_to_cpu(rxd->mpdu_start.info0),
|
|
|
|
RX_MPDU_START_INFO0_PEER_IDX);
|
|
|
|
|
|
|
|
peer = ath10k_peer_find_by_id(ar, peer_id);
|
|
|
|
if (!peer)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
arvif = ath10k_get_arvif(ar, peer->vdev_id);
|
|
|
|
if (WARN_ON_ONCE(!arvif))
|
|
|
|
return NULL;
|
|
|
|
|
2016-06-30 00:29:24 +08:00
|
|
|
if (ath10k_mac_vif_chan(arvif->vif, &def))
|
2015-03-31 18:26:21 +08:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return def.chan;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct ieee80211_channel *
|
|
|
|
ath10k_htt_rx_h_vdev_channel(struct ath10k *ar, u32 vdev_id)
|
|
|
|
{
|
|
|
|
struct ath10k_vif *arvif;
|
|
|
|
struct cfg80211_chan_def def;
|
|
|
|
|
|
|
|
lockdep_assert_held(&ar->data_lock);
|
|
|
|
|
|
|
|
list_for_each_entry(arvif, &ar->arvifs, list) {
|
|
|
|
if (arvif->vdev_id == vdev_id &&
|
|
|
|
ath10k_mac_vif_chan(arvif->vif, &def) == 0)
|
|
|
|
return def.chan;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ath10k_htt_rx_h_any_chan_iter(struct ieee80211_hw *hw,
|
|
|
|
struct ieee80211_chanctx_conf *conf,
|
|
|
|
void *data)
|
|
|
|
{
|
|
|
|
struct cfg80211_chan_def *def = data;
|
|
|
|
|
|
|
|
*def = conf->def;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct ieee80211_channel *
|
|
|
|
ath10k_htt_rx_h_any_channel(struct ath10k *ar)
|
|
|
|
{
|
|
|
|
struct cfg80211_chan_def def = {};
|
|
|
|
|
|
|
|
ieee80211_iter_chan_contexts_atomic(ar->hw,
|
|
|
|
ath10k_htt_rx_h_any_chan_iter,
|
|
|
|
&def);
|
|
|
|
|
|
|
|
return def.chan;
|
|
|
|
}
|
|
|
|
|
2014-03-25 04:23:18 +08:00
|
|
|
static bool ath10k_htt_rx_h_channel(struct ath10k *ar,
|
2015-03-31 18:26:21 +08:00
|
|
|
struct ieee80211_rx_status *status,
|
|
|
|
struct htt_rx_desc *rxd,
|
|
|
|
u32 vdev_id)
|
2014-03-25 04:23:18 +08:00
|
|
|
{
|
|
|
|
struct ieee80211_channel *ch;
|
|
|
|
|
|
|
|
spin_lock_bh(&ar->data_lock);
|
|
|
|
ch = ar->scan_channel;
|
|
|
|
if (!ch)
|
|
|
|
ch = ar->rx_channel;
|
2015-03-31 18:26:21 +08:00
|
|
|
if (!ch)
|
|
|
|
ch = ath10k_htt_rx_h_peer_channel(ar, rxd);
|
|
|
|
if (!ch)
|
|
|
|
ch = ath10k_htt_rx_h_vdev_channel(ar, vdev_id);
|
|
|
|
if (!ch)
|
|
|
|
ch = ath10k_htt_rx_h_any_channel(ar);
|
2016-03-09 01:27:23 +08:00
|
|
|
if (!ch)
|
|
|
|
ch = ar->tgt_oper_chan;
|
2014-03-25 04:23:18 +08:00
|
|
|
spin_unlock_bh(&ar->data_lock);
|
|
|
|
|
|
|
|
if (!ch)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
status->band = ch->band;
|
|
|
|
status->freq = ch->center_freq;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-11-18 15:24:49 +08:00
|
|
|
static void ath10k_htt_rx_h_signal(struct ath10k *ar,
|
|
|
|
struct ieee80211_rx_status *status,
|
|
|
|
struct htt_rx_desc *rxd)
|
|
|
|
{
|
2017-06-12 23:03:34 +08:00
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < IEEE80211_MAX_CHAINS ; i++) {
|
|
|
|
status->chains &= ~BIT(i);
|
|
|
|
|
|
|
|
if (rxd->ppdu_start.rssi_chains[i].pri20_mhz != 0x80) {
|
|
|
|
status->chain_signal[i] = ATH10K_DEFAULT_NOISE_FLOOR +
|
|
|
|
rxd->ppdu_start.rssi_chains[i].pri20_mhz;
|
|
|
|
|
|
|
|
status->chains |= BIT(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-18 15:24:49 +08:00
|
|
|
/* FIXME: Get real NF */
|
|
|
|
status->signal = ATH10K_DEFAULT_NOISE_FLOOR +
|
|
|
|
rxd->ppdu_start.rssi_comb;
|
|
|
|
status->flag &= ~RX_FLAG_NO_SIGNAL_VAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ath10k_htt_rx_h_mactime(struct ath10k *ar,
|
|
|
|
struct ieee80211_rx_status *status,
|
|
|
|
struct htt_rx_desc *rxd)
|
|
|
|
{
|
|
|
|
/* FIXME: TSF is known only at the end of PPDU, in the last MPDU. This
|
|
|
|
* means all prior MSDUs in a PPDU are reported to mac80211 without the
|
|
|
|
* TSF. Is it worth holding frames until end of PPDU is known?
|
|
|
|
*
|
|
|
|
* FIXME: Can we get/compute 64bit TSF?
|
|
|
|
*/
|
2015-01-24 18:14:48 +08:00
|
|
|
status->mactime = __le32_to_cpu(rxd->ppdu_end.common.tsf_timestamp);
|
2014-11-18 15:24:49 +08:00
|
|
|
status->flag |= RX_FLAG_MACTIME_END;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ath10k_htt_rx_h_ppdu(struct ath10k *ar,
|
|
|
|
struct sk_buff_head *amsdu,
|
2015-03-31 18:26:21 +08:00
|
|
|
struct ieee80211_rx_status *status,
|
|
|
|
u32 vdev_id)
|
2014-11-18 15:24:49 +08:00
|
|
|
{
|
|
|
|
struct sk_buff *first;
|
|
|
|
struct htt_rx_desc *rxd;
|
|
|
|
bool is_first_ppdu;
|
|
|
|
bool is_last_ppdu;
|
|
|
|
|
|
|
|
if (skb_queue_empty(amsdu))
|
|
|
|
return;
|
|
|
|
|
|
|
|
first = skb_peek(amsdu);
|
|
|
|
rxd = (void *)first->data - sizeof(*rxd);
|
|
|
|
|
|
|
|
is_first_ppdu = !!(rxd->attention.flags &
|
|
|
|
__cpu_to_le32(RX_ATTENTION_FLAGS_FIRST_MPDU));
|
|
|
|
is_last_ppdu = !!(rxd->attention.flags &
|
|
|
|
__cpu_to_le32(RX_ATTENTION_FLAGS_LAST_MPDU));
|
|
|
|
|
|
|
|
if (is_first_ppdu) {
|
|
|
|
/* New PPDU starts so clear out the old per-PPDU status. */
|
|
|
|
status->freq = 0;
|
|
|
|
status->rate_idx = 0;
|
2017-04-26 19:51:41 +08:00
|
|
|
status->nss = 0;
|
2017-04-26 18:14:59 +08:00
|
|
|
status->encoding = RX_ENC_LEGACY;
|
|
|
|
status->bw = RATE_INFO_BW_20;
|
2017-07-28 20:15:36 +08:00
|
|
|
|
2017-04-26 17:13:00 +08:00
|
|
|
status->flag &= ~RX_FLAG_MACTIME_END;
|
2014-11-18 15:24:49 +08:00
|
|
|
status->flag |= RX_FLAG_NO_SIGNAL_VAL;
|
|
|
|
|
2017-07-28 20:15:36 +08:00
|
|
|
status->flag &= ~(RX_FLAG_AMPDU_IS_LAST);
|
|
|
|
status->flag |= RX_FLAG_AMPDU_DETAILS | RX_FLAG_AMPDU_LAST_KNOWN;
|
|
|
|
status->ampdu_reference = ar->ampdu_reference;
|
|
|
|
|
2014-11-18 15:24:49 +08:00
|
|
|
ath10k_htt_rx_h_signal(ar, status, rxd);
|
2015-03-31 18:26:21 +08:00
|
|
|
ath10k_htt_rx_h_channel(ar, status, rxd, vdev_id);
|
2014-11-18 15:24:49 +08:00
|
|
|
ath10k_htt_rx_h_rates(ar, status, rxd);
|
|
|
|
}
|
|
|
|
|
2017-07-28 20:15:36 +08:00
|
|
|
if (is_last_ppdu) {
|
2014-11-18 15:24:49 +08:00
|
|
|
ath10k_htt_rx_h_mactime(ar, status, rxd);
|
2017-07-28 20:15:36 +08:00
|
|
|
|
|
|
|
/* set ampdu last segment flag */
|
|
|
|
status->flag |= RX_FLAG_AMPDU_IS_LAST;
|
|
|
|
ar->ampdu_reference++;
|
|
|
|
}
|
2014-11-18 15:24:49 +08:00
|
|
|
}
|
|
|
|
|
2014-07-29 04:59:43 +08:00
|
|
|
static const char * const tid_to_ac[] = {
|
|
|
|
"BE",
|
|
|
|
"BK",
|
|
|
|
"BK",
|
|
|
|
"BE",
|
|
|
|
"VI",
|
|
|
|
"VI",
|
|
|
|
"VO",
|
|
|
|
"VO",
|
|
|
|
};
|
|
|
|
|
|
|
|
static char *ath10k_get_tid(struct ieee80211_hdr *hdr, char *out, size_t size)
|
|
|
|
{
|
|
|
|
u8 *qc;
|
|
|
|
int tid;
|
|
|
|
|
|
|
|
if (!ieee80211_is_data_qos(hdr->frame_control))
|
|
|
|
return "";
|
|
|
|
|
|
|
|
qc = ieee80211_get_qos_ctl(hdr);
|
|
|
|
tid = *qc & IEEE80211_QOS_CTL_TID_MASK;
|
|
|
|
if (tid < 8)
|
|
|
|
snprintf(out, size, "tid %d (%s)", tid, tid_to_ac[tid]);
|
|
|
|
else
|
|
|
|
snprintf(out, size, "tid %d", tid);
|
|
|
|
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
2017-12-07 22:58:05 +08:00
|
|
|
static void ath10k_htt_rx_h_queue_msdu(struct ath10k *ar,
|
|
|
|
struct ieee80211_rx_status *rx_status,
|
|
|
|
struct sk_buff *skb)
|
|
|
|
{
|
|
|
|
struct ieee80211_rx_status *status;
|
|
|
|
|
|
|
|
status = IEEE80211_SKB_RXCB(skb);
|
|
|
|
*status = *rx_status;
|
|
|
|
|
2018-06-21 20:25:48 +08:00
|
|
|
skb_queue_tail(&ar->htt.rx_msdus_q, skb);
|
2017-12-07 22:58:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void ath10k_process_rx(struct ath10k *ar, struct sk_buff *skb)
|
2014-03-25 04:23:15 +08:00
|
|
|
{
|
|
|
|
struct ieee80211_rx_status *status;
|
2014-07-29 04:59:43 +08:00
|
|
|
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
|
|
|
|
char tid[32];
|
2014-03-25 04:23:15 +08:00
|
|
|
|
2014-03-25 04:23:22 +08:00
|
|
|
status = IEEE80211_SKB_RXCB(skb);
|
2014-03-25 04:23:15 +08:00
|
|
|
|
2014-08-25 18:09:38 +08:00
|
|
|
ath10k_dbg(ar, ATH10K_DBG_DATA,
|
2017-04-26 17:13:00 +08:00
|
|
|
"rx skb %pK len %u peer %pM %s %s sn %u %s%s%s%s%s%s %srate_idx %u vht_nss %u freq %u band %u flag 0x%x fcs-err %i mic-err %i amsdu-more %i\n",
|
2014-03-25 04:23:22 +08:00
|
|
|
skb,
|
|
|
|
skb->len,
|
2014-07-29 04:59:43 +08:00
|
|
|
ieee80211_get_SA(hdr),
|
|
|
|
ath10k_get_tid(hdr, tid, sizeof(tid)),
|
|
|
|
is_multicast_ether_addr(ieee80211_get_DA(hdr)) ?
|
|
|
|
"mcast" : "ucast",
|
|
|
|
(__le16_to_cpu(hdr->seq_ctrl) & IEEE80211_SCTL_SEQ) >> 4,
|
2017-04-26 18:14:59 +08:00
|
|
|
(status->encoding == RX_ENC_LEGACY) ? "legacy" : "",
|
|
|
|
(status->encoding == RX_ENC_HT) ? "ht" : "",
|
|
|
|
(status->encoding == RX_ENC_VHT) ? "vht" : "",
|
|
|
|
(status->bw == RATE_INFO_BW_40) ? "40" : "",
|
|
|
|
(status->bw == RATE_INFO_BW_80) ? "80" : "",
|
|
|
|
(status->bw == RATE_INFO_BW_160) ? "160" : "",
|
2017-04-26 17:13:00 +08:00
|
|
|
status->enc_flags & RX_ENC_FLAG_SHORT_GI ? "sgi " : "",
|
2014-03-25 04:23:15 +08:00
|
|
|
status->rate_idx,
|
2017-04-26 19:51:41 +08:00
|
|
|
status->nss,
|
2014-03-25 04:23:15 +08:00
|
|
|
status->freq,
|
2014-03-25 04:23:19 +08:00
|
|
|
status->band, status->flag,
|
2014-03-25 04:23:21 +08:00
|
|
|
!!(status->flag & RX_FLAG_FAILED_FCS_CRC),
|
2014-07-29 04:59:43 +08:00
|
|
|
!!(status->flag & RX_FLAG_MMIC_ERROR),
|
|
|
|
!!(status->flag & RX_FLAG_AMSDU_MORE));
|
2014-08-25 18:09:38 +08:00
|
|
|
ath10k_dbg_dump(ar, ATH10K_DBG_HTT_DUMP, NULL, "rx skb: ",
|
2014-03-25 04:23:22 +08:00
|
|
|
skb->data, skb->len);
|
2014-11-05 21:44:31 +08:00
|
|
|
trace_ath10k_rx_hdr(ar, skb->data, skb->len);
|
|
|
|
trace_ath10k_rx_payload(ar, skb->data, skb->len);
|
2014-03-25 04:23:15 +08:00
|
|
|
|
2016-09-03 00:46:09 +08:00
|
|
|
ieee80211_rx_napi(ar->hw, NULL, skb, &ar->napi);
|
2014-03-25 04:23:15 +08:00
|
|
|
}
|
|
|
|
|
2015-05-19 20:09:34 +08:00
|
|
|
static int ath10k_htt_rx_nwifi_hdrlen(struct ath10k *ar,
|
|
|
|
struct ieee80211_hdr *hdr)
|
2014-02-25 15:29:57 +08:00
|
|
|
{
|
2015-05-19 20:09:34 +08:00
|
|
|
int len = ieee80211_hdrlen(hdr->frame_control);
|
|
|
|
|
|
|
|
if (!test_bit(ATH10K_FW_FEATURE_NO_NWIFI_DECAP_4ADDR_PADDING,
|
2016-04-21 00:45:18 +08:00
|
|
|
ar->running_fw->fw_file.fw_features))
|
2015-05-19 20:09:34 +08:00
|
|
|
len = round_up(len, 4);
|
|
|
|
|
|
|
|
return len;
|
2014-02-25 15:29:57 +08:00
|
|
|
}
|
|
|
|
|
2014-11-18 15:24:48 +08:00
|
|
|
static void ath10k_htt_rx_h_undecap_raw(struct ath10k *ar,
|
|
|
|
struct sk_buff *msdu,
|
|
|
|
struct ieee80211_rx_status *status,
|
|
|
|
enum htt_rx_mpdu_encrypt_type enctype,
|
2018-12-20 15:53:34 +08:00
|
|
|
bool is_decrypted,
|
|
|
|
const u8 first_hdr[64])
|
2013-06-13 01:52:10 +08:00
|
|
|
{
|
2014-11-18 15:24:48 +08:00
|
|
|
struct ieee80211_hdr *hdr;
|
2013-06-13 01:52:10 +08:00
|
|
|
struct htt_rx_desc *rxd;
|
2014-11-18 15:24:48 +08:00
|
|
|
size_t hdr_len;
|
|
|
|
size_t crypto_len;
|
|
|
|
bool is_first;
|
|
|
|
bool is_last;
|
2018-12-20 15:53:34 +08:00
|
|
|
bool msdu_limit_err;
|
|
|
|
int bytes_aligned = ar->hw_params.decap_align_bytes;
|
|
|
|
u8 *qos;
|
2014-11-18 15:24:48 +08:00
|
|
|
|
|
|
|
rxd = (void *)msdu->data - sizeof(*rxd);
|
2015-07-16 10:01:21 +08:00
|
|
|
is_first = !!(rxd->msdu_end.common.info0 &
|
2014-11-18 15:24:48 +08:00
|
|
|
__cpu_to_le32(RX_MSDU_END_INFO0_FIRST_MSDU));
|
2015-07-16 10:01:21 +08:00
|
|
|
is_last = !!(rxd->msdu_end.common.info0 &
|
2014-11-18 15:24:48 +08:00
|
|
|
__cpu_to_le32(RX_MSDU_END_INFO0_LAST_MSDU));
|
|
|
|
|
|
|
|
/* Delivered decapped frame:
|
|
|
|
* [802.11 header]
|
|
|
|
* [crypto param] <-- can be trimmed if !fcs_err &&
|
|
|
|
* !decrypt_err && !peer_idx_invalid
|
|
|
|
* [amsdu header] <-- only if A-MSDU
|
|
|
|
* [rfc1042/llc]
|
|
|
|
* [payload]
|
|
|
|
* [FCS] <-- at end, needs to be trimmed
|
|
|
|
*/
|
|
|
|
|
2018-12-20 15:53:34 +08:00
|
|
|
/* Some hardwares(QCA99x0 variants) limit number of msdus in a-msdu when
|
|
|
|
* deaggregate, so that unwanted MSDU-deaggregation is avoided for
|
|
|
|
* error packets. If limit exceeds, hw sends all remaining MSDUs as
|
|
|
|
* a single last MSDU with this msdu limit error set.
|
|
|
|
*/
|
|
|
|
msdu_limit_err = ath10k_rx_desc_msdu_limit_error(&ar->hw_params, rxd);
|
|
|
|
|
|
|
|
/* If MSDU limit error happens, then don't warn on, the partial raw MSDU
|
|
|
|
* without first MSDU is expected in that case, and handled later here.
|
|
|
|
*/
|
2014-11-18 15:24:48 +08:00
|
|
|
/* This probably shouldn't happen but warn just in case */
|
2018-12-20 15:53:34 +08:00
|
|
|
if (WARN_ON_ONCE(!is_first && !msdu_limit_err))
|
2014-11-18 15:24:48 +08:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* This probably shouldn't happen but warn just in case */
|
2018-12-20 15:53:34 +08:00
|
|
|
if (WARN_ON_ONCE(!(is_first && is_last) && !msdu_limit_err))
|
2014-11-18 15:24:48 +08:00
|
|
|
return;
|
|
|
|
|
|
|
|
skb_trim(msdu, msdu->len - FCS_LEN);
|
|
|
|
|
2018-12-20 15:53:34 +08:00
|
|
|
/* Push original 80211 header */
|
|
|
|
if (unlikely(msdu_limit_err)) {
|
|
|
|
hdr = (struct ieee80211_hdr *)first_hdr;
|
|
|
|
hdr_len = ieee80211_hdrlen(hdr->frame_control);
|
|
|
|
crypto_len = ath10k_htt_rx_crypto_param_len(ar, enctype);
|
|
|
|
|
|
|
|
if (ieee80211_is_data_qos(hdr->frame_control)) {
|
|
|
|
qos = ieee80211_get_qos_ctl(hdr);
|
|
|
|
qos[0] |= IEEE80211_QOS_CTL_A_MSDU_PRESENT;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (crypto_len)
|
|
|
|
memcpy(skb_push(msdu, crypto_len),
|
|
|
|
(void *)hdr + round_up(hdr_len, bytes_aligned),
|
|
|
|
crypto_len);
|
|
|
|
|
|
|
|
memcpy(skb_push(msdu, hdr_len), hdr, hdr_len);
|
|
|
|
}
|
|
|
|
|
2014-11-18 15:24:48 +08:00
|
|
|
/* In most cases this will be true for sniffed frames. It makes sense
|
ath10k: enable raw encap mode and software crypto engine
This patch enables raw Rx/Tx encap mode to support software based
crypto engine. This patch introduces a new module param 'cryptmode'.
cryptmode:
0: Use hardware crypto engine globally with native Wi-Fi mode TX/RX
encapsulation to the firmware. This is the default mode.
1: Use sofware crypto engine globally with raw mode TX/RX
encapsulation to the firmware.
Known limitation:
A-MSDU must be disabled for RAW Tx encap mode to perform well when
heavy traffic is applied.
Testing: (by Michal Kazior <michal.kazior@tieto.com>)
a) Performance Testing
cryptmode=1
ap=qca988x sta=killer1525
killer1525 -> qca988x 194.496 mbps [tcp1 ip4]
killer1525 -> qca988x 238.309 mbps [tcp5 ip4]
killer1525 -> qca988x 266.958 mbps [udp1 ip4]
killer1525 -> qca988x 477.468 mbps [udp5 ip4]
qca988x -> killer1525 301.378 mbps [tcp1 ip4]
qca988x -> killer1525 297.949 mbps [tcp5 ip4]
qca988x -> killer1525 331.351 mbps [udp1 ip4]
qca988x -> killer1525 371.528 mbps [udp5 ip4]
ap=killer1525 sta=qca988x
qca988x -> killer1525 331.447 mbps [tcp1 ip4]
qca988x -> killer1525 328.783 mbps [tcp5 ip4]
qca988x -> killer1525 375.309 mbps [udp1 ip4]
qca988x -> killer1525 403.379 mbps [udp5 ip4]
killer1525 -> qca988x 203.689 mbps [tcp1 ip4]
killer1525 -> qca988x 222.339 mbps [tcp5 ip4]
killer1525 -> qca988x 264.199 mbps [udp1 ip4]
killer1525 -> qca988x 479.371 mbps [udp5 ip4]
Note:
- only open network tested for RAW vs nwifi performance comparison
- killer1525 (qca6174 hw2.2) is 2x2 device (hence max 866mbps)
- used iperf
- OTA, devices a few cm apart from each other, no shielding
- tcpX/udpX, X - means number of threads used
Overview:
- relative Tx performance drop is seen but is within reasonable and
expected threshold (A-MSDU must be disabled with RAW Tx)
b) Connectivity Testing
cryptmode=1
ap=iwl6205 sta1=qca988x crypto=open topology-1ap1sta OK
ap=iwl6205 sta1=qca988x crypto=wep1 topology-1ap1sta OK
ap=iwl6205 sta1=qca988x crypto=wpa topology-1ap1sta OK
ap=iwl6205 sta1=qca988x crypto=wpa-ccmp topology-1ap1sta OK
ap=qca988x sta1=iwl6205 crypto=open topology-1ap1sta OK
ap=qca988x sta1=iwl6205 crypto=wep1 topology-1ap1sta OK
ap=qca988x sta1=iwl6205 crypto=wpa topology-1ap1sta OK
ap=qca988x sta1=iwl6205 crypto=wpa-ccmp topology-1ap1sta OK
ap=iwl6205 sta1=qca988x crypto=open topology-1ap1sta2br OK
ap=iwl6205 sta1=qca988x crypto=wep1 topology-1ap1sta2br OK
ap=iwl6205 sta1=qca988x crypto=wpa topology-1ap1sta2br OK
ap=iwl6205 sta1=qca988x crypto=wpa-ccmp topology-1ap1sta2br OK
ap=qca988x sta1=iwl6205 crypto=open topology-1ap1sta2br OK
ap=qca988x sta1=iwl6205 crypto=wep1 topology-1ap1sta2br OK
ap=qca988x sta1=iwl6205 crypto=wpa topology-1ap1sta2br OK
ap=qca988x sta1=iwl6205 crypto=wpa-ccmp topology-1ap1sta2br OK
ap=iwl6205 sta1=qca988x crypto=open topology-1ap1sta2br1vlan OK
ap=iwl6205 sta1=qca988x crypto=wep1 topology-1ap1sta2br1vlan OK
ap=iwl6205 sta1=qca988x crypto=wpa topology-1ap1sta2br1vlan OK
ap=iwl6205 sta1=qca988x crypto=wpa-ccmp topology-1ap1sta2br1vlan OK
ap=qca988x sta1=iwl6205 crypto=open topology-1ap1sta2br1vlan OK
ap=qca988x sta1=iwl6205 crypto=wep1 topology-1ap1sta2br1vlan OK
ap=qca988x sta1=iwl6205 crypto=wpa topology-1ap1sta2br1vlan OK
ap=qca988x sta1=iwl6205 crypto=wpa-ccmp topology-1ap1sta2br1vlan OK
Note:
- each test takes all possible endpoint pairs and pings
- each pair-ping flushes arp table
- ip6 is used
c) Testbed Topology:
1ap1sta:
[ap] ---- [sta]
endpoints: ap, sta
1ap1sta2br:
[veth0] [ap] ---- [sta] [veth2]
| | | |
[veth1] | \ [veth3]
\ / \ /
[br0] [br1]
endpoints: veth0, veth2, br0, br1
note: STA works in 4addr mode, AP has wds_sta=1
1ap1sta2br1vlan:
[veth0] [ap] ---- [sta] [veth2]
| | | |
[veth1] | \ [veth3]
\ / \ /
[br0] [br1]
| |
[vlan0_id2] [vlan1_id2]
endpoints: vlan0_id2, vlan1_id2
note: STA works in 4addr mode, AP has wds_sta=1
Credits:
Thanks to Michal Kazior <michal.kazior@tieto.com> who helped find the
amsdu issue, contributed a workaround (already squashed into this
patch), and contributed the throughput and connectivity tests results.
Signed-off-by: David Liu <cfliu.tw@gmail.com>
Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
Tested-by: Michal Kazior <michal.kazior@tieto.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
2015-07-25 01:25:32 +08:00
|
|
|
* to deliver them as-is without stripping the crypto param. This is
|
|
|
|
* necessary for software based decryption.
|
2014-11-18 15:24:48 +08:00
|
|
|
*
|
|
|
|
* If there's no error then the frame is decrypted. At least that is
|
|
|
|
* the case for frames that come in via fragmented rx indication.
|
|
|
|
*/
|
|
|
|
if (!is_decrypted)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* The payload is decrypted so strip crypto params. Start from tail
|
|
|
|
* since hdr is used to compute some stuff.
|
|
|
|
*/
|
|
|
|
|
|
|
|
hdr = (void *)msdu->data;
|
|
|
|
|
|
|
|
/* Tail */
|
2017-10-27 23:35:31 +08:00
|
|
|
if (status->flag & RX_FLAG_IV_STRIPPED) {
|
2015-11-30 20:56:59 +08:00
|
|
|
skb_trim(msdu, msdu->len -
|
2017-10-27 23:35:41 +08:00
|
|
|
ath10k_htt_rx_crypto_mic_len(ar, enctype));
|
|
|
|
|
|
|
|
skb_trim(msdu, msdu->len -
|
|
|
|
ath10k_htt_rx_crypto_icv_len(ar, enctype));
|
2017-10-27 23:35:31 +08:00
|
|
|
} else {
|
|
|
|
/* MIC */
|
2017-10-27 23:35:41 +08:00
|
|
|
if (status->flag & RX_FLAG_MIC_STRIPPED)
|
|
|
|
skb_trim(msdu, msdu->len -
|
|
|
|
ath10k_htt_rx_crypto_mic_len(ar, enctype));
|
2017-10-27 23:35:31 +08:00
|
|
|
|
|
|
|
/* ICV */
|
2017-10-27 23:35:41 +08:00
|
|
|
if (status->flag & RX_FLAG_ICV_STRIPPED)
|
2017-10-27 23:35:31 +08:00
|
|
|
skb_trim(msdu, msdu->len -
|
2017-10-27 23:35:41 +08:00
|
|
|
ath10k_htt_rx_crypto_icv_len(ar, enctype));
|
2017-10-27 23:35:31 +08:00
|
|
|
}
|
2014-11-18 15:24:48 +08:00
|
|
|
|
|
|
|
/* MMIC */
|
2015-11-30 20:56:59 +08:00
|
|
|
if ((status->flag & RX_FLAG_MMIC_STRIPPED) &&
|
|
|
|
!ieee80211_has_morefrags(hdr->frame_control) &&
|
2014-11-18 15:24:48 +08:00
|
|
|
enctype == HTT_RX_MPDU_ENCRYPT_TKIP_WPA)
|
2017-10-27 23:35:41 +08:00
|
|
|
skb_trim(msdu, msdu->len - MICHAEL_MIC_LEN);
|
2014-11-18 15:24:48 +08:00
|
|
|
|
|
|
|
/* Head */
|
2015-11-30 20:56:59 +08:00
|
|
|
if (status->flag & RX_FLAG_IV_STRIPPED) {
|
|
|
|
hdr_len = ieee80211_hdrlen(hdr->frame_control);
|
|
|
|
crypto_len = ath10k_htt_rx_crypto_param_len(ar, enctype);
|
2014-11-18 15:24:48 +08:00
|
|
|
|
2015-11-30 20:56:59 +08:00
|
|
|
memmove((void *)msdu->data + crypto_len,
|
|
|
|
(void *)msdu->data, hdr_len);
|
|
|
|
skb_pull(msdu, crypto_len);
|
|
|
|
}
|
2014-11-18 15:24:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void ath10k_htt_rx_h_undecap_nwifi(struct ath10k *ar,
|
|
|
|
struct sk_buff *msdu,
|
|
|
|
struct ieee80211_rx_status *status,
|
2017-10-27 23:35:31 +08:00
|
|
|
const u8 first_hdr[64],
|
|
|
|
enum htt_rx_mpdu_encrypt_type enctype)
|
2014-11-18 15:24:48 +08:00
|
|
|
{
|
2013-09-26 15:12:22 +08:00
|
|
|
struct ieee80211_hdr *hdr;
|
2016-09-09 22:25:29 +08:00
|
|
|
struct htt_rx_desc *rxd;
|
2014-11-18 15:24:48 +08:00
|
|
|
size_t hdr_len;
|
|
|
|
u8 da[ETH_ALEN];
|
|
|
|
u8 sa[ETH_ALEN];
|
2016-09-09 22:25:29 +08:00
|
|
|
int l3_pad_bytes;
|
2017-10-27 23:35:31 +08:00
|
|
|
int bytes_aligned = ar->hw_params.decap_align_bytes;
|
2013-06-13 01:52:10 +08:00
|
|
|
|
2014-11-18 15:24:48 +08:00
|
|
|
/* Delivered decapped frame:
|
|
|
|
* [nwifi 802.11 header] <-- replaced with 802.11 hdr
|
|
|
|
* [rfc1042/llc]
|
|
|
|
*
|
|
|
|
* Note: The nwifi header doesn't have QoS Control and is
|
|
|
|
* (always?) a 3addr frame.
|
|
|
|
*
|
|
|
|
* Note2: There's no A-MSDU subframe header. Even if it's part
|
|
|
|
* of an A-MSDU.
|
|
|
|
*/
|
2014-11-18 15:24:47 +08:00
|
|
|
|
2014-11-18 15:24:48 +08:00
|
|
|
/* pull decapped header and copy SA & DA */
|
2016-09-09 22:25:29 +08:00
|
|
|
rxd = (void *)msdu->data - sizeof(*rxd);
|
|
|
|
|
|
|
|
l3_pad_bytes = ath10k_rx_desc_get_l3_pad_bytes(&ar->hw_params, rxd);
|
|
|
|
skb_put(msdu, l3_pad_bytes);
|
|
|
|
|
|
|
|
hdr = (struct ieee80211_hdr *)(msdu->data + l3_pad_bytes);
|
2015-11-17 04:22:02 +08:00
|
|
|
|
2015-05-19 20:09:34 +08:00
|
|
|
hdr_len = ath10k_htt_rx_nwifi_hdrlen(ar, hdr);
|
2014-11-18 15:24:48 +08:00
|
|
|
ether_addr_copy(da, ieee80211_get_DA(hdr));
|
|
|
|
ether_addr_copy(sa, ieee80211_get_SA(hdr));
|
|
|
|
skb_pull(msdu, hdr_len);
|
2013-06-13 01:52:10 +08:00
|
|
|
|
2014-11-18 15:24:48 +08:00
|
|
|
/* push original 802.11 header */
|
|
|
|
hdr = (struct ieee80211_hdr *)first_hdr;
|
2013-09-26 15:12:22 +08:00
|
|
|
hdr_len = ieee80211_hdrlen(hdr->frame_control);
|
2017-10-27 23:35:31 +08:00
|
|
|
|
|
|
|
if (!(status->flag & RX_FLAG_IV_STRIPPED)) {
|
|
|
|
memcpy(skb_push(msdu,
|
|
|
|
ath10k_htt_rx_crypto_param_len(ar, enctype)),
|
|
|
|
(void *)hdr + round_up(hdr_len, bytes_aligned),
|
|
|
|
ath10k_htt_rx_crypto_param_len(ar, enctype));
|
|
|
|
}
|
|
|
|
|
2014-11-18 15:24:48 +08:00
|
|
|
memcpy(skb_push(msdu, hdr_len), hdr, hdr_len);
|
2013-06-13 01:52:10 +08:00
|
|
|
|
2014-11-18 15:24:48 +08:00
|
|
|
/* original 802.11 header has a different DA and in
|
|
|
|
* case of 4addr it may also have different SA
|
|
|
|
*/
|
|
|
|
hdr = (struct ieee80211_hdr *)msdu->data;
|
|
|
|
ether_addr_copy(ieee80211_get_DA(hdr), da);
|
|
|
|
ether_addr_copy(ieee80211_get_SA(hdr), sa);
|
|
|
|
}
|
2013-06-13 01:52:10 +08:00
|
|
|
|
2014-11-18 15:24:48 +08:00
|
|
|
static void *ath10k_htt_rx_h_find_rfc1042(struct ath10k *ar,
|
|
|
|
struct sk_buff *msdu,
|
|
|
|
enum htt_rx_mpdu_encrypt_type enctype)
|
|
|
|
{
|
|
|
|
struct ieee80211_hdr *hdr;
|
|
|
|
struct htt_rx_desc *rxd;
|
|
|
|
size_t hdr_len, crypto_len;
|
|
|
|
void *rfc1042;
|
|
|
|
bool is_first, is_last, is_amsdu;
|
2016-09-27 02:56:24 +08:00
|
|
|
int bytes_aligned = ar->hw_params.decap_align_bytes;
|
2013-09-26 15:12:23 +08:00
|
|
|
|
2014-11-18 15:24:48 +08:00
|
|
|
rxd = (void *)msdu->data - sizeof(*rxd);
|
|
|
|
hdr = (void *)rxd->rx_hdr_status;
|
2013-09-26 15:12:22 +08:00
|
|
|
|
2015-07-16 10:01:21 +08:00
|
|
|
is_first = !!(rxd->msdu_end.common.info0 &
|
2014-11-18 15:24:48 +08:00
|
|
|
__cpu_to_le32(RX_MSDU_END_INFO0_FIRST_MSDU));
|
2015-07-16 10:01:21 +08:00
|
|
|
is_last = !!(rxd->msdu_end.common.info0 &
|
2014-11-18 15:24:48 +08:00
|
|
|
__cpu_to_le32(RX_MSDU_END_INFO0_LAST_MSDU));
|
|
|
|
is_amsdu = !(is_first && is_last);
|
2013-06-13 01:52:10 +08:00
|
|
|
|
2014-11-18 15:24:48 +08:00
|
|
|
rfc1042 = hdr;
|
2013-06-13 01:52:10 +08:00
|
|
|
|
2014-11-18 15:24:48 +08:00
|
|
|
if (is_first) {
|
|
|
|
hdr_len = ieee80211_hdrlen(hdr->frame_control);
|
|
|
|
crypto_len = ath10k_htt_rx_crypto_param_len(ar, enctype);
|
2013-11-13 21:23:30 +08:00
|
|
|
|
2016-09-27 02:56:24 +08:00
|
|
|
rfc1042 += round_up(hdr_len, bytes_aligned) +
|
|
|
|
round_up(crypto_len, bytes_aligned);
|
2013-09-26 15:12:22 +08:00
|
|
|
}
|
2013-06-13 01:52:10 +08:00
|
|
|
|
2014-11-18 15:24:48 +08:00
|
|
|
if (is_amsdu)
|
|
|
|
rfc1042 += sizeof(struct amsdu_subframe_hdr);
|
|
|
|
|
|
|
|
return rfc1042;
|
2013-06-13 01:52:10 +08:00
|
|
|
}
|
|
|
|
|
2014-11-18 15:24:48 +08:00
|
|
|
static void ath10k_htt_rx_h_undecap_eth(struct ath10k *ar,
|
|
|
|
struct sk_buff *msdu,
|
|
|
|
struct ieee80211_rx_status *status,
|
|
|
|
const u8 first_hdr[64],
|
|
|
|
enum htt_rx_mpdu_encrypt_type enctype)
|
2013-06-13 01:52:10 +08:00
|
|
|
{
|
|
|
|
struct ieee80211_hdr *hdr;
|
2014-11-18 15:24:48 +08:00
|
|
|
struct ethhdr *eth;
|
|
|
|
size_t hdr_len;
|
2013-09-26 15:12:23 +08:00
|
|
|
void *rfc1042;
|
2014-11-18 15:24:48 +08:00
|
|
|
u8 da[ETH_ALEN];
|
|
|
|
u8 sa[ETH_ALEN];
|
2016-09-09 22:25:29 +08:00
|
|
|
int l3_pad_bytes;
|
|
|
|
struct htt_rx_desc *rxd;
|
2017-10-27 23:35:31 +08:00
|
|
|
int bytes_aligned = ar->hw_params.decap_align_bytes;
|
2013-06-13 01:52:10 +08:00
|
|
|
|
2014-11-18 15:24:48 +08:00
|
|
|
/* Delivered decapped frame:
|
|
|
|
* [eth header] <-- replaced with 802.11 hdr & rfc1042/llc
|
|
|
|
* [payload]
|
|
|
|
*/
|
|
|
|
|
|
|
|
rfc1042 = ath10k_htt_rx_h_find_rfc1042(ar, msdu, enctype);
|
|
|
|
if (WARN_ON_ONCE(!rfc1042))
|
|
|
|
return;
|
|
|
|
|
2016-09-09 22:25:29 +08:00
|
|
|
rxd = (void *)msdu->data - sizeof(*rxd);
|
|
|
|
l3_pad_bytes = ath10k_rx_desc_get_l3_pad_bytes(&ar->hw_params, rxd);
|
|
|
|
skb_put(msdu, l3_pad_bytes);
|
|
|
|
skb_pull(msdu, l3_pad_bytes);
|
|
|
|
|
2014-11-18 15:24:48 +08:00
|
|
|
/* pull decapped header and copy SA & DA */
|
|
|
|
eth = (struct ethhdr *)msdu->data;
|
|
|
|
ether_addr_copy(da, eth->h_dest);
|
|
|
|
ether_addr_copy(sa, eth->h_source);
|
|
|
|
skb_pull(msdu, sizeof(struct ethhdr));
|
|
|
|
|
|
|
|
/* push rfc1042/llc/snap */
|
|
|
|
memcpy(skb_push(msdu, sizeof(struct rfc1042_hdr)), rfc1042,
|
|
|
|
sizeof(struct rfc1042_hdr));
|
|
|
|
|
|
|
|
/* push original 802.11 header */
|
|
|
|
hdr = (struct ieee80211_hdr *)first_hdr;
|
|
|
|
hdr_len = ieee80211_hdrlen(hdr->frame_control);
|
2017-10-27 23:35:31 +08:00
|
|
|
|
|
|
|
if (!(status->flag & RX_FLAG_IV_STRIPPED)) {
|
|
|
|
memcpy(skb_push(msdu,
|
|
|
|
ath10k_htt_rx_crypto_param_len(ar, enctype)),
|
|
|
|
(void *)hdr + round_up(hdr_len, bytes_aligned),
|
|
|
|
ath10k_htt_rx_crypto_param_len(ar, enctype));
|
|
|
|
}
|
|
|
|
|
2014-11-18 15:24:48 +08:00
|
|
|
memcpy(skb_push(msdu, hdr_len), hdr, hdr_len);
|
|
|
|
|
|
|
|
/* original 802.11 header has a different DA and in
|
|
|
|
* case of 4addr it may also have different SA
|
|
|
|
*/
|
|
|
|
hdr = (struct ieee80211_hdr *)msdu->data;
|
|
|
|
ether_addr_copy(ieee80211_get_DA(hdr), da);
|
|
|
|
ether_addr_copy(ieee80211_get_SA(hdr), sa);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ath10k_htt_rx_h_undecap_snap(struct ath10k *ar,
|
|
|
|
struct sk_buff *msdu,
|
|
|
|
struct ieee80211_rx_status *status,
|
2017-10-27 23:35:31 +08:00
|
|
|
const u8 first_hdr[64],
|
|
|
|
enum htt_rx_mpdu_encrypt_type enctype)
|
2014-11-18 15:24:48 +08:00
|
|
|
{
|
|
|
|
struct ieee80211_hdr *hdr;
|
|
|
|
size_t hdr_len;
|
2016-09-09 22:25:29 +08:00
|
|
|
int l3_pad_bytes;
|
|
|
|
struct htt_rx_desc *rxd;
|
2017-10-27 23:35:31 +08:00
|
|
|
int bytes_aligned = ar->hw_params.decap_align_bytes;
|
2014-11-18 15:24:48 +08:00
|
|
|
|
|
|
|
/* Delivered decapped frame:
|
|
|
|
* [amsdu header] <-- replaced with 802.11 hdr
|
|
|
|
* [rfc1042/llc]
|
|
|
|
* [payload]
|
|
|
|
*/
|
|
|
|
|
2016-09-09 22:25:29 +08:00
|
|
|
rxd = (void *)msdu->data - sizeof(*rxd);
|
|
|
|
l3_pad_bytes = ath10k_rx_desc_get_l3_pad_bytes(&ar->hw_params, rxd);
|
|
|
|
|
|
|
|
skb_put(msdu, l3_pad_bytes);
|
|
|
|
skb_pull(msdu, sizeof(struct amsdu_subframe_hdr) + l3_pad_bytes);
|
2014-11-18 15:24:48 +08:00
|
|
|
|
|
|
|
hdr = (struct ieee80211_hdr *)first_hdr;
|
2013-09-26 15:12:23 +08:00
|
|
|
hdr_len = ieee80211_hdrlen(hdr->frame_control);
|
2017-10-27 23:35:31 +08:00
|
|
|
|
|
|
|
if (!(status->flag & RX_FLAG_IV_STRIPPED)) {
|
|
|
|
memcpy(skb_push(msdu,
|
|
|
|
ath10k_htt_rx_crypto_param_len(ar, enctype)),
|
|
|
|
(void *)hdr + round_up(hdr_len, bytes_aligned),
|
|
|
|
ath10k_htt_rx_crypto_param_len(ar, enctype));
|
|
|
|
}
|
|
|
|
|
2014-11-18 15:24:48 +08:00
|
|
|
memcpy(skb_push(msdu, hdr_len), hdr, hdr_len);
|
|
|
|
}
|
2013-06-13 01:52:10 +08:00
|
|
|
|
2014-11-18 15:24:48 +08:00
|
|
|
static void ath10k_htt_rx_h_undecap(struct ath10k *ar,
|
|
|
|
struct sk_buff *msdu,
|
|
|
|
struct ieee80211_rx_status *status,
|
|
|
|
u8 first_hdr[64],
|
|
|
|
enum htt_rx_mpdu_encrypt_type enctype,
|
|
|
|
bool is_decrypted)
|
|
|
|
{
|
|
|
|
struct htt_rx_desc *rxd;
|
|
|
|
enum rx_msdu_decap_format decap;
|
2013-09-26 15:12:22 +08:00
|
|
|
|
2014-11-18 15:24:48 +08:00
|
|
|
/* First msdu's decapped header:
|
|
|
|
* [802.11 header] <-- padded to 4 bytes long
|
|
|
|
* [crypto param] <-- padded to 4 bytes long
|
|
|
|
* [amsdu header] <-- only if A-MSDU
|
|
|
|
* [rfc1042/llc]
|
|
|
|
*
|
|
|
|
* Other (2nd, 3rd, ..) msdu's decapped header:
|
|
|
|
* [amsdu header] <-- only if A-MSDU
|
|
|
|
* [rfc1042/llc]
|
|
|
|
*/
|
|
|
|
|
|
|
|
rxd = (void *)msdu->data - sizeof(*rxd);
|
2015-07-16 10:01:21 +08:00
|
|
|
decap = MS(__le32_to_cpu(rxd->msdu_start.common.info1),
|
2014-11-18 15:24:48 +08:00
|
|
|
RX_MSDU_START_INFO1_DECAP_FORMAT);
|
|
|
|
|
|
|
|
switch (decap) {
|
2013-06-13 01:52:10 +08:00
|
|
|
case RX_MSDU_DECAP_RAW:
|
2014-11-18 15:24:48 +08:00
|
|
|
ath10k_htt_rx_h_undecap_raw(ar, msdu, status, enctype,
|
2018-12-20 15:53:34 +08:00
|
|
|
is_decrypted, first_hdr);
|
2013-06-13 01:52:10 +08:00
|
|
|
break;
|
|
|
|
case RX_MSDU_DECAP_NATIVE_WIFI:
|
2017-10-27 23:35:31 +08:00
|
|
|
ath10k_htt_rx_h_undecap_nwifi(ar, msdu, status, first_hdr,
|
|
|
|
enctype);
|
2013-06-13 01:52:10 +08:00
|
|
|
break;
|
|
|
|
case RX_MSDU_DECAP_ETHERNET2_DIX:
|
2014-11-18 15:24:48 +08:00
|
|
|
ath10k_htt_rx_h_undecap_eth(ar, msdu, status, first_hdr, enctype);
|
2013-09-26 15:12:23 +08:00
|
|
|
break;
|
|
|
|
case RX_MSDU_DECAP_8023_SNAP_LLC:
|
2017-10-27 23:35:31 +08:00
|
|
|
ath10k_htt_rx_h_undecap_snap(ar, msdu, status, first_hdr,
|
|
|
|
enctype);
|
2013-09-26 15:12:23 +08:00
|
|
|
break;
|
2013-06-13 01:52:10 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-31 16:47:56 +08:00
|
|
|
static int ath10k_htt_rx_get_csum_state(struct sk_buff *skb)
|
|
|
|
{
|
|
|
|
struct htt_rx_desc *rxd;
|
|
|
|
u32 flags, info;
|
|
|
|
bool is_ip4, is_ip6;
|
|
|
|
bool is_tcp, is_udp;
|
|
|
|
bool ip_csum_ok, tcpudp_csum_ok;
|
|
|
|
|
|
|
|
rxd = (void *)skb->data - sizeof(*rxd);
|
|
|
|
flags = __le32_to_cpu(rxd->attention.flags);
|
2015-07-16 10:01:21 +08:00
|
|
|
info = __le32_to_cpu(rxd->msdu_start.common.info1);
|
2013-07-31 16:47:56 +08:00
|
|
|
|
|
|
|
is_ip4 = !!(info & RX_MSDU_START_INFO1_IPV4_PROTO);
|
|
|
|
is_ip6 = !!(info & RX_MSDU_START_INFO1_IPV6_PROTO);
|
|
|
|
is_tcp = !!(info & RX_MSDU_START_INFO1_TCP_PROTO);
|
|
|
|
is_udp = !!(info & RX_MSDU_START_INFO1_UDP_PROTO);
|
|
|
|
ip_csum_ok = !(flags & RX_ATTENTION_FLAGS_IP_CHKSUM_FAIL);
|
|
|
|
tcpudp_csum_ok = !(flags & RX_ATTENTION_FLAGS_TCP_UDP_CHKSUM_FAIL);
|
|
|
|
|
|
|
|
if (!is_ip4 && !is_ip6)
|
|
|
|
return CHECKSUM_NONE;
|
|
|
|
if (!is_tcp && !is_udp)
|
|
|
|
return CHECKSUM_NONE;
|
|
|
|
if (!ip_csum_ok)
|
|
|
|
return CHECKSUM_NONE;
|
|
|
|
if (!tcpudp_csum_ok)
|
|
|
|
return CHECKSUM_NONE;
|
|
|
|
|
|
|
|
return CHECKSUM_UNNECESSARY;
|
|
|
|
}
|
|
|
|
|
2014-11-18 15:24:48 +08:00
|
|
|
static void ath10k_htt_rx_h_csum_offload(struct sk_buff *msdu)
|
|
|
|
{
|
|
|
|
msdu->ip_summed = ath10k_htt_rx_get_csum_state(msdu);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ath10k_htt_rx_h_mpdu(struct ath10k *ar,
|
|
|
|
struct sk_buff_head *amsdu,
|
2017-10-27 23:35:31 +08:00
|
|
|
struct ieee80211_rx_status *status,
|
2018-03-14 18:14:06 +08:00
|
|
|
bool fill_crypt_header,
|
|
|
|
u8 *rx_hdr,
|
|
|
|
enum ath10k_pkt_rx_err *err)
|
2014-11-18 15:24:48 +08:00
|
|
|
{
|
|
|
|
struct sk_buff *first;
|
|
|
|
struct sk_buff *last;
|
|
|
|
struct sk_buff *msdu;
|
|
|
|
struct htt_rx_desc *rxd;
|
|
|
|
struct ieee80211_hdr *hdr;
|
|
|
|
enum htt_rx_mpdu_encrypt_type enctype;
|
|
|
|
u8 first_hdr[64];
|
|
|
|
u8 *qos;
|
|
|
|
bool has_fcs_err;
|
|
|
|
bool has_crypto_err;
|
|
|
|
bool has_tkip_err;
|
|
|
|
bool has_peer_idx_invalid;
|
|
|
|
bool is_decrypted;
|
2015-11-30 20:56:59 +08:00
|
|
|
bool is_mgmt;
|
2014-11-18 15:24:48 +08:00
|
|
|
u32 attention;
|
|
|
|
|
|
|
|
if (skb_queue_empty(amsdu))
|
|
|
|
return;
|
|
|
|
|
|
|
|
first = skb_peek(amsdu);
|
|
|
|
rxd = (void *)first->data - sizeof(*rxd);
|
|
|
|
|
2015-11-30 20:56:59 +08:00
|
|
|
is_mgmt = !!(rxd->attention.flags &
|
|
|
|
__cpu_to_le32(RX_ATTENTION_FLAGS_MGMT_TYPE));
|
|
|
|
|
2014-11-18 15:24:48 +08:00
|
|
|
enctype = MS(__le32_to_cpu(rxd->mpdu_start.info0),
|
|
|
|
RX_MPDU_START_INFO0_ENCRYPT_TYPE);
|
|
|
|
|
|
|
|
/* First MSDU's Rx descriptor in an A-MSDU contains full 802.11
|
|
|
|
* decapped header. It'll be used for undecapping of each MSDU.
|
|
|
|
*/
|
|
|
|
hdr = (void *)rxd->rx_hdr_status;
|
2017-10-27 23:35:31 +08:00
|
|
|
memcpy(first_hdr, hdr, RX_HTT_HDR_STATUS_LEN);
|
2014-11-18 15:24:48 +08:00
|
|
|
|
2018-03-14 18:14:06 +08:00
|
|
|
if (rx_hdr)
|
|
|
|
memcpy(rx_hdr, hdr, RX_HTT_HDR_STATUS_LEN);
|
|
|
|
|
2014-11-18 15:24:48 +08:00
|
|
|
/* Each A-MSDU subframe will use the original header as the base and be
|
|
|
|
* reported as a separate MSDU so strip the A-MSDU bit from QoS Ctl.
|
|
|
|
*/
|
|
|
|
hdr = (void *)first_hdr;
|
2017-10-27 23:35:31 +08:00
|
|
|
|
|
|
|
if (ieee80211_is_data_qos(hdr->frame_control)) {
|
|
|
|
qos = ieee80211_get_qos_ctl(hdr);
|
|
|
|
qos[0] &= ~IEEE80211_QOS_CTL_A_MSDU_PRESENT;
|
|
|
|
}
|
2014-11-18 15:24:48 +08:00
|
|
|
|
|
|
|
/* Some attention flags are valid only in the last MSDU. */
|
|
|
|
last = skb_peek_tail(amsdu);
|
|
|
|
rxd = (void *)last->data - sizeof(*rxd);
|
|
|
|
attention = __le32_to_cpu(rxd->attention.flags);
|
|
|
|
|
|
|
|
has_fcs_err = !!(attention & RX_ATTENTION_FLAGS_FCS_ERR);
|
|
|
|
has_crypto_err = !!(attention & RX_ATTENTION_FLAGS_DECRYPT_ERR);
|
|
|
|
has_tkip_err = !!(attention & RX_ATTENTION_FLAGS_TKIP_MIC_ERR);
|
|
|
|
has_peer_idx_invalid = !!(attention & RX_ATTENTION_FLAGS_PEER_IDX_INVALID);
|
|
|
|
|
|
|
|
/* Note: If hardware captures an encrypted frame that it can't decrypt,
|
|
|
|
* e.g. due to fcs error, missing peer or invalid key data it will
|
|
|
|
* report the frame as raw.
|
|
|
|
*/
|
|
|
|
is_decrypted = (enctype != HTT_RX_MPDU_ENCRYPT_NONE &&
|
|
|
|
!has_fcs_err &&
|
|
|
|
!has_crypto_err &&
|
|
|
|
!has_peer_idx_invalid);
|
|
|
|
|
|
|
|
/* Clear per-MPDU flags while leaving per-PPDU flags intact. */
|
|
|
|
status->flag &= ~(RX_FLAG_FAILED_FCS_CRC |
|
|
|
|
RX_FLAG_MMIC_ERROR |
|
|
|
|
RX_FLAG_DECRYPTED |
|
|
|
|
RX_FLAG_IV_STRIPPED |
|
2015-11-30 20:56:59 +08:00
|
|
|
RX_FLAG_ONLY_MONITOR |
|
2014-11-18 15:24:48 +08:00
|
|
|
RX_FLAG_MMIC_STRIPPED);
|
|
|
|
|
|
|
|
if (has_fcs_err)
|
|
|
|
status->flag |= RX_FLAG_FAILED_FCS_CRC;
|
|
|
|
|
|
|
|
if (has_tkip_err)
|
|
|
|
status->flag |= RX_FLAG_MMIC_ERROR;
|
|
|
|
|
2018-03-14 18:14:06 +08:00
|
|
|
if (err) {
|
|
|
|
if (has_fcs_err)
|
|
|
|
*err = ATH10K_PKT_RX_ERR_FCS;
|
|
|
|
else if (has_tkip_err)
|
|
|
|
*err = ATH10K_PKT_RX_ERR_TKIP;
|
|
|
|
else if (has_crypto_err)
|
|
|
|
*err = ATH10K_PKT_RX_ERR_CRYPT;
|
|
|
|
else if (has_peer_idx_invalid)
|
|
|
|
*err = ATH10K_PKT_RX_ERR_PEER_IDX_INVAL;
|
|
|
|
}
|
|
|
|
|
2015-11-30 20:56:59 +08:00
|
|
|
/* Firmware reports all necessary management frames via WMI already.
|
|
|
|
* They are not reported to monitor interfaces at all so pass the ones
|
|
|
|
* coming via HTT to monitor interfaces instead. This simplifies
|
|
|
|
* matters a lot.
|
|
|
|
*/
|
|
|
|
if (is_mgmt)
|
|
|
|
status->flag |= RX_FLAG_ONLY_MONITOR;
|
|
|
|
|
|
|
|
if (is_decrypted) {
|
|
|
|
status->flag |= RX_FLAG_DECRYPTED;
|
|
|
|
|
|
|
|
if (likely(!is_mgmt))
|
2017-10-27 23:35:31 +08:00
|
|
|
status->flag |= RX_FLAG_MMIC_STRIPPED;
|
|
|
|
|
|
|
|
if (fill_crypt_header)
|
|
|
|
status->flag |= RX_FLAG_MIC_STRIPPED |
|
|
|
|
RX_FLAG_ICV_STRIPPED;
|
|
|
|
else
|
|
|
|
status->flag |= RX_FLAG_IV_STRIPPED;
|
|
|
|
}
|
2014-11-18 15:24:48 +08:00
|
|
|
|
|
|
|
skb_queue_walk(amsdu, msdu) {
|
|
|
|
ath10k_htt_rx_h_csum_offload(msdu);
|
|
|
|
ath10k_htt_rx_h_undecap(ar, msdu, status, first_hdr, enctype,
|
|
|
|
is_decrypted);
|
|
|
|
|
|
|
|
/* Undecapping involves copying the original 802.11 header back
|
|
|
|
* to sk_buff. If frame is protected and hardware has decrypted
|
|
|
|
* it then remove the protected bit.
|
|
|
|
*/
|
|
|
|
if (!is_decrypted)
|
|
|
|
continue;
|
2015-11-30 20:56:59 +08:00
|
|
|
if (is_mgmt)
|
|
|
|
continue;
|
2014-11-18 15:24:48 +08:00
|
|
|
|
2017-10-27 23:35:31 +08:00
|
|
|
if (fill_crypt_header)
|
|
|
|
continue;
|
|
|
|
|
2014-11-18 15:24:48 +08:00
|
|
|
hdr = (void *)msdu->data;
|
|
|
|
hdr->frame_control &= ~__cpu_to_le16(IEEE80211_FCTL_PROTECTED);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-07 22:58:05 +08:00
|
|
|
static void ath10k_htt_rx_h_enqueue(struct ath10k *ar,
|
2014-11-18 15:24:48 +08:00
|
|
|
struct sk_buff_head *amsdu,
|
|
|
|
struct ieee80211_rx_status *status)
|
|
|
|
{
|
|
|
|
struct sk_buff *msdu;
|
2017-10-27 23:35:31 +08:00
|
|
|
struct sk_buff *first_subframe;
|
|
|
|
|
|
|
|
first_subframe = skb_peek(amsdu);
|
2014-11-18 15:24:48 +08:00
|
|
|
|
|
|
|
while ((msdu = __skb_dequeue(amsdu))) {
|
|
|
|
/* Setup per-MSDU flags */
|
|
|
|
if (skb_queue_empty(amsdu))
|
|
|
|
status->flag &= ~RX_FLAG_AMSDU_MORE;
|
|
|
|
else
|
|
|
|
status->flag |= RX_FLAG_AMSDU_MORE;
|
|
|
|
|
2017-10-27 23:35:31 +08:00
|
|
|
if (msdu == first_subframe) {
|
|
|
|
first_subframe = NULL;
|
|
|
|
status->flag &= ~RX_FLAG_ALLOW_SAME_PN;
|
|
|
|
} else {
|
|
|
|
status->flag |= RX_FLAG_ALLOW_SAME_PN;
|
|
|
|
}
|
|
|
|
|
2017-12-07 22:58:05 +08:00
|
|
|
ath10k_htt_rx_h_queue_msdu(ar, status, msdu);
|
2014-11-18 15:24:48 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-14 18:14:06 +08:00
|
|
|
static int ath10k_unchain_msdu(struct sk_buff_head *amsdu,
|
|
|
|
unsigned long int *unchain_cnt)
|
2014-03-04 06:07:09 +08:00
|
|
|
{
|
2014-11-18 15:24:47 +08:00
|
|
|
struct sk_buff *skb, *first;
|
2014-03-04 06:07:09 +08:00
|
|
|
int space;
|
|
|
|
int total_len = 0;
|
2018-03-14 18:14:06 +08:00
|
|
|
int amsdu_len = skb_queue_len(amsdu);
|
2014-03-04 06:07:09 +08:00
|
|
|
|
|
|
|
/* TODO: Might could optimize this by using
|
|
|
|
* skb_try_coalesce or similar method to
|
|
|
|
* decrease copying, or maybe get mac80211 to
|
|
|
|
* provide a way to just receive a list of
|
|
|
|
* skb?
|
|
|
|
*/
|
|
|
|
|
2014-11-18 15:24:47 +08:00
|
|
|
first = __skb_dequeue(amsdu);
|
2014-03-04 06:07:09 +08:00
|
|
|
|
|
|
|
/* Allocate total length all at once. */
|
2014-11-18 15:24:47 +08:00
|
|
|
skb_queue_walk(amsdu, skb)
|
|
|
|
total_len += skb->len;
|
2014-03-04 06:07:09 +08:00
|
|
|
|
2014-11-18 15:24:47 +08:00
|
|
|
space = total_len - skb_tailroom(first);
|
2014-03-04 06:07:09 +08:00
|
|
|
if ((space > 0) &&
|
2014-11-18 15:24:47 +08:00
|
|
|
(pskb_expand_head(first, 0, space, GFP_ATOMIC) < 0)) {
|
2014-03-04 06:07:09 +08:00
|
|
|
/* TODO: bump some rx-oom error stat */
|
|
|
|
/* put it back together so we can free the
|
|
|
|
* whole list at once.
|
|
|
|
*/
|
2014-11-18 15:24:47 +08:00
|
|
|
__skb_queue_head(amsdu, first);
|
2014-03-04 06:07:09 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Walk list again, copying contents into
|
|
|
|
* msdu_head
|
|
|
|
*/
|
2014-11-18 15:24:47 +08:00
|
|
|
while ((skb = __skb_dequeue(amsdu))) {
|
|
|
|
skb_copy_from_linear_data(skb, skb_put(first, skb->len),
|
|
|
|
skb->len);
|
|
|
|
dev_kfree_skb_any(skb);
|
2014-03-04 06:07:09 +08:00
|
|
|
}
|
|
|
|
|
2014-11-18 15:24:47 +08:00
|
|
|
__skb_queue_head(amsdu, first);
|
2018-03-14 18:14:06 +08:00
|
|
|
|
|
|
|
*unchain_cnt += amsdu_len - 1;
|
|
|
|
|
2014-03-04 06:07:09 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-11-18 15:24:48 +08:00
|
|
|
static void ath10k_htt_rx_h_unchain(struct ath10k *ar,
|
2018-03-14 18:14:06 +08:00
|
|
|
struct sk_buff_head *amsdu,
|
|
|
|
unsigned long int *drop_cnt,
|
|
|
|
unsigned long int *unchain_cnt)
|
2014-03-19 14:09:40 +08:00
|
|
|
{
|
2014-11-18 15:24:48 +08:00
|
|
|
struct sk_buff *first;
|
|
|
|
struct htt_rx_desc *rxd;
|
|
|
|
enum rx_msdu_decap_format decap;
|
2014-08-25 18:09:38 +08:00
|
|
|
|
2014-11-18 15:24:48 +08:00
|
|
|
first = skb_peek(amsdu);
|
|
|
|
rxd = (void *)first->data - sizeof(*rxd);
|
2015-07-16 10:01:21 +08:00
|
|
|
decap = MS(__le32_to_cpu(rxd->msdu_start.common.info1),
|
2014-11-18 15:24:48 +08:00
|
|
|
RX_MSDU_START_INFO1_DECAP_FORMAT);
|
2014-03-19 14:09:40 +08:00
|
|
|
|
2014-11-18 15:24:48 +08:00
|
|
|
/* FIXME: Current unchaining logic can only handle simple case of raw
|
|
|
|
* msdu chaining. If decapping is other than raw the chaining may be
|
|
|
|
* more complex and this isn't handled by the current code. Don't even
|
|
|
|
* try re-constructing such frames - it'll be pretty much garbage.
|
|
|
|
*/
|
|
|
|
if (decap != RX_MSDU_DECAP_RAW ||
|
|
|
|
skb_queue_len(amsdu) != 1 + rxd->frag_info.ring2_more_count) {
|
2018-03-14 18:14:06 +08:00
|
|
|
*drop_cnt += skb_queue_len(amsdu);
|
2014-11-18 15:24:48 +08:00
|
|
|
__skb_queue_purge(amsdu);
|
|
|
|
return;
|
2014-03-19 14:09:40 +08:00
|
|
|
}
|
|
|
|
|
2018-03-14 18:14:06 +08:00
|
|
|
ath10k_unchain_msdu(amsdu, unchain_cnt);
|
2014-11-18 15:24:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool ath10k_htt_rx_amsdu_allowed(struct ath10k *ar,
|
|
|
|
struct sk_buff_head *amsdu,
|
|
|
|
struct ieee80211_rx_status *rx_status)
|
|
|
|
{
|
|
|
|
/* FIXME: It might be a good idea to do some fuzzy-testing to drop
|
|
|
|
* invalid/dangerous frames.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (!rx_status->freq) {
|
2017-08-03 20:01:02 +08:00
|
|
|
ath10k_dbg(ar, ATH10K_DBG_HTT, "no channel configured; ignoring frame(s)!\n");
|
2014-03-25 04:23:18 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-11-18 15:24:48 +08:00
|
|
|
if (test_bit(ATH10K_CAC_RUNNING, &ar->dev_flags)) {
|
|
|
|
ath10k_dbg(ar, ATH10K_DBG_HTT, "htt rx cac running\n");
|
2014-03-19 14:09:40 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-11-18 15:24:48 +08:00
|
|
|
static void ath10k_htt_rx_h_filter(struct ath10k *ar,
|
|
|
|
struct sk_buff_head *amsdu,
|
2018-03-14 18:14:06 +08:00
|
|
|
struct ieee80211_rx_status *rx_status,
|
|
|
|
unsigned long int *drop_cnt)
|
2014-11-18 15:24:48 +08:00
|
|
|
{
|
|
|
|
if (skb_queue_empty(amsdu))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (ath10k_htt_rx_amsdu_allowed(ar, amsdu, rx_status))
|
|
|
|
return;
|
|
|
|
|
2018-03-14 18:14:06 +08:00
|
|
|
if (drop_cnt)
|
|
|
|
*drop_cnt += skb_queue_len(amsdu);
|
|
|
|
|
2014-11-18 15:24:48 +08:00
|
|
|
__skb_queue_purge(amsdu);
|
|
|
|
}
|
|
|
|
|
2016-03-22 19:52:14 +08:00
|
|
|
static int ath10k_htt_rx_handle_amsdu(struct ath10k_htt *htt)
|
2013-06-13 01:52:10 +08:00
|
|
|
{
|
2014-08-25 18:09:38 +08:00
|
|
|
struct ath10k *ar = htt->ar;
|
2016-08-19 18:37:37 +08:00
|
|
|
struct ieee80211_rx_status *rx_status = &htt->rx_status;
|
2014-11-18 15:24:47 +08:00
|
|
|
struct sk_buff_head amsdu;
|
2017-12-07 22:58:05 +08:00
|
|
|
int ret;
|
2018-03-14 18:14:06 +08:00
|
|
|
unsigned long int drop_cnt = 0;
|
|
|
|
unsigned long int unchain_cnt = 0;
|
|
|
|
unsigned long int drop_cnt_filter = 0;
|
|
|
|
unsigned long int msdus_to_queue, num_msdus;
|
|
|
|
enum ath10k_pkt_rx_err err = ATH10K_PKT_RX_ERR_MAX;
|
|
|
|
u8 first_hdr[RX_HTT_HDR_STATUS_LEN];
|
2013-06-13 01:52:10 +08:00
|
|
|
|
2016-03-22 19:52:14 +08:00
|
|
|
__skb_queue_head_init(&amsdu);
|
2014-02-28 00:50:05 +08:00
|
|
|
|
2016-03-22 19:52:14 +08:00
|
|
|
spin_lock_bh(&htt->rx_ring.lock);
|
|
|
|
if (htt->rx_confused) {
|
|
|
|
spin_unlock_bh(&htt->rx_ring.lock);
|
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
ret = ath10k_htt_rx_amsdu_pop(htt, &amsdu);
|
|
|
|
spin_unlock_bh(&htt->rx_ring.lock);
|
2014-11-18 15:24:48 +08:00
|
|
|
|
2016-03-22 19:52:14 +08:00
|
|
|
if (ret < 0) {
|
|
|
|
ath10k_warn(ar, "rx ring became corrupted: %d\n", ret);
|
|
|
|
__skb_queue_purge(&amsdu);
|
|
|
|
/* FIXME: It's probably a good idea to reboot the
|
|
|
|
* device instead of leaving it inoperable.
|
|
|
|
*/
|
|
|
|
htt->rx_confused = true;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2018-03-14 18:14:06 +08:00
|
|
|
num_msdus = skb_queue_len(&amsdu);
|
|
|
|
|
2016-08-19 18:37:37 +08:00
|
|
|
ath10k_htt_rx_h_ppdu(ar, &amsdu, rx_status, 0xffff);
|
2016-10-04 23:49:59 +08:00
|
|
|
|
|
|
|
/* only for ret = 1 indicates chained msdus */
|
|
|
|
if (ret > 0)
|
2018-03-14 18:14:06 +08:00
|
|
|
ath10k_htt_rx_h_unchain(ar, &amsdu, &drop_cnt, &unchain_cnt);
|
2016-10-04 23:49:59 +08:00
|
|
|
|
2018-03-14 18:14:06 +08:00
|
|
|
ath10k_htt_rx_h_filter(ar, &amsdu, rx_status, &drop_cnt_filter);
|
|
|
|
ath10k_htt_rx_h_mpdu(ar, &amsdu, rx_status, true, first_hdr, &err);
|
|
|
|
msdus_to_queue = skb_queue_len(&amsdu);
|
2017-12-07 22:58:05 +08:00
|
|
|
ath10k_htt_rx_h_enqueue(ar, &amsdu, rx_status);
|
2016-03-22 19:52:14 +08:00
|
|
|
|
2018-03-14 18:14:06 +08:00
|
|
|
ath10k_sta_update_rx_tid_stats(ar, first_hdr, num_msdus, err,
|
|
|
|
unchain_cnt, drop_cnt, drop_cnt_filter,
|
|
|
|
msdus_to_queue);
|
|
|
|
|
2017-12-07 22:58:05 +08:00
|
|
|
return 0;
|
2016-03-22 19:52:14 +08:00
|
|
|
}
|
|
|
|
|
2018-09-04 20:06:58 +08:00
|
|
|
static bool ath10k_htt_rx_proc_rx_ind_hl(struct ath10k_htt *htt,
|
|
|
|
struct htt_rx_indication_hl *rx,
|
|
|
|
struct sk_buff *skb)
|
|
|
|
{
|
|
|
|
struct ath10k *ar = htt->ar;
|
|
|
|
struct ath10k_peer *peer;
|
|
|
|
struct htt_rx_indication_mpdu_range *mpdu_ranges;
|
|
|
|
struct fw_rx_desc_hl *fw_desc;
|
|
|
|
struct ieee80211_hdr *hdr;
|
|
|
|
struct ieee80211_rx_status *rx_status;
|
|
|
|
u16 peer_id;
|
|
|
|
u8 rx_desc_len;
|
|
|
|
int num_mpdu_ranges;
|
|
|
|
size_t tot_hdr_len;
|
|
|
|
struct ieee80211_channel *ch;
|
|
|
|
|
|
|
|
peer_id = __le16_to_cpu(rx->hdr.peer_id);
|
|
|
|
|
|
|
|
spin_lock_bh(&ar->data_lock);
|
|
|
|
peer = ath10k_peer_find_by_id(ar, peer_id);
|
|
|
|
spin_unlock_bh(&ar->data_lock);
|
|
|
|
if (!peer)
|
|
|
|
ath10k_warn(ar, "Got RX ind from invalid peer: %u\n", peer_id);
|
|
|
|
|
|
|
|
num_mpdu_ranges = MS(__le32_to_cpu(rx->hdr.info1),
|
|
|
|
HTT_RX_INDICATION_INFO1_NUM_MPDU_RANGES);
|
|
|
|
mpdu_ranges = htt_rx_ind_get_mpdu_ranges_hl(rx);
|
|
|
|
fw_desc = &rx->fw_desc;
|
|
|
|
rx_desc_len = fw_desc->len;
|
|
|
|
|
|
|
|
/* I have not yet seen any case where num_mpdu_ranges > 1.
|
|
|
|
* qcacld does not seem handle that case either, so we introduce the
|
|
|
|
* same limitiation here as well.
|
|
|
|
*/
|
|
|
|
if (num_mpdu_ranges > 1)
|
|
|
|
ath10k_warn(ar,
|
|
|
|
"Unsupported number of MPDU ranges: %d, ignoring all but the first\n",
|
|
|
|
num_mpdu_ranges);
|
|
|
|
|
|
|
|
if (mpdu_ranges->mpdu_range_status !=
|
|
|
|
HTT_RX_IND_MPDU_STATUS_OK) {
|
|
|
|
ath10k_warn(ar, "MPDU range status: %d\n",
|
|
|
|
mpdu_ranges->mpdu_range_status);
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Strip off all headers before the MAC header before delivery to
|
|
|
|
* mac80211
|
|
|
|
*/
|
|
|
|
tot_hdr_len = sizeof(struct htt_resp_hdr) + sizeof(rx->hdr) +
|
|
|
|
sizeof(rx->ppdu) + sizeof(rx->prefix) +
|
|
|
|
sizeof(rx->fw_desc) +
|
|
|
|
sizeof(*mpdu_ranges) * num_mpdu_ranges + rx_desc_len;
|
|
|
|
skb_pull(skb, tot_hdr_len);
|
|
|
|
|
|
|
|
hdr = (struct ieee80211_hdr *)skb->data;
|
|
|
|
rx_status = IEEE80211_SKB_RXCB(skb);
|
|
|
|
rx_status->chains |= BIT(0);
|
|
|
|
rx_status->signal = ATH10K_DEFAULT_NOISE_FLOOR +
|
|
|
|
rx->ppdu.combined_rssi;
|
|
|
|
rx_status->flag &= ~RX_FLAG_NO_SIGNAL_VAL;
|
|
|
|
|
|
|
|
spin_lock_bh(&ar->data_lock);
|
|
|
|
ch = ar->scan_channel;
|
|
|
|
if (!ch)
|
|
|
|
ch = ar->rx_channel;
|
|
|
|
if (!ch)
|
|
|
|
ch = ath10k_htt_rx_h_any_channel(ar);
|
|
|
|
if (!ch)
|
|
|
|
ch = ar->tgt_oper_chan;
|
|
|
|
spin_unlock_bh(&ar->data_lock);
|
|
|
|
|
|
|
|
if (ch) {
|
|
|
|
rx_status->band = ch->band;
|
|
|
|
rx_status->freq = ch->center_freq;
|
|
|
|
}
|
|
|
|
if (rx->fw_desc.flags & FW_RX_DESC_FLAGS_LAST_MSDU)
|
|
|
|
rx_status->flag &= ~RX_FLAG_AMSDU_MORE;
|
|
|
|
else
|
|
|
|
rx_status->flag |= RX_FLAG_AMSDU_MORE;
|
|
|
|
|
|
|
|
/* Not entirely sure about this, but all frames from the chipset has
|
|
|
|
* the protected flag set even though they have already been decrypted.
|
|
|
|
* Unmasking this flag is necessary in order for mac80211 not to drop
|
|
|
|
* the frame.
|
|
|
|
* TODO: Verify this is always the case or find out a way to check
|
|
|
|
* if there has been hw decryption.
|
|
|
|
*/
|
|
|
|
if (ieee80211_has_protected(hdr->frame_control)) {
|
|
|
|
hdr->frame_control &= ~__cpu_to_le16(IEEE80211_FCTL_PROTECTED);
|
|
|
|
rx_status->flag |= RX_FLAG_DECRYPTED |
|
|
|
|
RX_FLAG_IV_STRIPPED |
|
|
|
|
RX_FLAG_MMIC_STRIPPED;
|
|
|
|
}
|
|
|
|
|
|
|
|
ieee80211_rx_ni(ar->hw, skb);
|
|
|
|
|
|
|
|
/* We have delivered the skb to the upper layers (mac80211) so we
|
|
|
|
* must not free it.
|
|
|
|
*/
|
|
|
|
return false;
|
|
|
|
err:
|
|
|
|
/* Tell the caller that it must free the skb since we have not
|
|
|
|
* consumed it
|
|
|
|
*/
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ath10k_htt_rx_proc_rx_ind_ll(struct ath10k_htt *htt,
|
|
|
|
struct htt_rx_indication *rx)
|
2013-06-13 01:52:10 +08:00
|
|
|
{
|
2014-08-25 18:09:38 +08:00
|
|
|
struct ath10k *ar = htt->ar;
|
2013-06-13 01:52:10 +08:00
|
|
|
struct htt_rx_indication_mpdu_range *mpdu_ranges;
|
|
|
|
int num_mpdu_ranges;
|
2016-03-22 19:52:14 +08:00
|
|
|
int i, mpdu_count = 0;
|
2018-03-14 18:14:06 +08:00
|
|
|
u16 peer_id;
|
|
|
|
u8 tid;
|
2013-06-13 01:52:10 +08:00
|
|
|
|
|
|
|
num_mpdu_ranges = MS(__le32_to_cpu(rx->hdr.info1),
|
|
|
|
HTT_RX_INDICATION_INFO1_NUM_MPDU_RANGES);
|
2018-03-14 18:14:06 +08:00
|
|
|
peer_id = __le16_to_cpu(rx->hdr.peer_id);
|
|
|
|
tid = MS(rx->hdr.info0, HTT_RX_INDICATION_INFO0_EXT_TID);
|
|
|
|
|
2013-06-13 01:52:10 +08:00
|
|
|
mpdu_ranges = htt_rx_ind_get_mpdu_ranges(rx);
|
|
|
|
|
2014-08-25 18:09:38 +08:00
|
|
|
ath10k_dbg_dump(ar, ATH10K_DBG_HTT_DUMP, NULL, "htt rx ind: ",
|
2013-06-13 01:52:10 +08:00
|
|
|
rx, sizeof(*rx) +
|
|
|
|
(sizeof(struct htt_rx_indication_mpdu_range) *
|
|
|
|
num_mpdu_ranges));
|
|
|
|
|
2014-11-18 15:24:47 +08:00
|
|
|
for (i = 0; i < num_mpdu_ranges; i++)
|
|
|
|
mpdu_count += mpdu_ranges[i].mpdu_count;
|
|
|
|
|
2016-03-22 19:52:15 +08:00
|
|
|
atomic_add(mpdu_count, &htt->num_mpdus_ready);
|
2018-03-14 18:14:06 +08:00
|
|
|
|
|
|
|
ath10k_sta_update_rx_tid_stats_ampdu(ar, peer_id, tid, mpdu_ranges,
|
|
|
|
num_mpdu_ranges);
|
2013-06-13 01:52:10 +08:00
|
|
|
}
|
|
|
|
|
2016-03-22 19:52:11 +08:00
|
|
|
static void ath10k_htt_rx_tx_compl_ind(struct ath10k *ar,
|
2014-02-28 00:50:04 +08:00
|
|
|
struct sk_buff *skb)
|
|
|
|
{
|
|
|
|
struct ath10k_htt *htt = &ar->htt;
|
|
|
|
struct htt_resp *resp = (struct htt_resp *)skb->data;
|
|
|
|
struct htt_tx_done tx_done = {};
|
|
|
|
int status = MS(resp->data_tx_completion.flags, HTT_DATA_TX_STATUS);
|
2018-09-04 17:52:18 +08:00
|
|
|
__le16 msdu_id, *msdus;
|
|
|
|
bool rssi_enabled = false;
|
|
|
|
u8 msdu_count = 0;
|
2014-02-28 00:50:04 +08:00
|
|
|
int i;
|
|
|
|
|
|
|
|
switch (status) {
|
|
|
|
case HTT_DATA_TX_STATUS_NO_ACK:
|
2016-03-22 19:52:11 +08:00
|
|
|
tx_done.status = HTT_TX_COMPL_STATE_NOACK;
|
2014-02-28 00:50:04 +08:00
|
|
|
break;
|
|
|
|
case HTT_DATA_TX_STATUS_OK:
|
2016-03-22 19:52:11 +08:00
|
|
|
tx_done.status = HTT_TX_COMPL_STATE_ACK;
|
2014-02-28 00:50:04 +08:00
|
|
|
break;
|
|
|
|
case HTT_DATA_TX_STATUS_DISCARD:
|
|
|
|
case HTT_DATA_TX_STATUS_POSTPONE:
|
|
|
|
case HTT_DATA_TX_STATUS_DOWNLOAD_FAIL:
|
2016-03-22 19:52:11 +08:00
|
|
|
tx_done.status = HTT_TX_COMPL_STATE_DISCARD;
|
2014-02-28 00:50:04 +08:00
|
|
|
break;
|
|
|
|
default:
|
2014-08-25 18:09:38 +08:00
|
|
|
ath10k_warn(ar, "unhandled tx completion status %d\n", status);
|
2016-03-22 19:52:11 +08:00
|
|
|
tx_done.status = HTT_TX_COMPL_STATE_DISCARD;
|
2014-02-28 00:50:04 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2014-08-25 18:09:38 +08:00
|
|
|
ath10k_dbg(ar, ATH10K_DBG_HTT, "htt tx completion num_msdus %d\n",
|
2014-02-28 00:50:04 +08:00
|
|
|
resp->data_tx_completion.num_msdus);
|
|
|
|
|
2018-09-04 17:52:18 +08:00
|
|
|
msdu_count = resp->data_tx_completion.num_msdus;
|
|
|
|
|
|
|
|
if (resp->data_tx_completion.flags2 & HTT_TX_CMPL_FLAG_DATA_RSSI)
|
|
|
|
rssi_enabled = true;
|
|
|
|
|
|
|
|
for (i = 0; i < msdu_count; i++) {
|
|
|
|
msdus = resp->data_tx_completion.msdus;
|
|
|
|
msdu_id = msdus[i];
|
2014-02-28 00:50:04 +08:00
|
|
|
tx_done.msdu_id = __le16_to_cpu(msdu_id);
|
2016-03-22 19:52:11 +08:00
|
|
|
|
2018-09-04 17:52:18 +08:00
|
|
|
if (rssi_enabled) {
|
|
|
|
/* Total no of MSDUs should be even,
|
|
|
|
* if odd MSDUs are sent firmware fills
|
|
|
|
* last msdu id with 0xffff
|
|
|
|
*/
|
|
|
|
if (msdu_count & 0x01) {
|
|
|
|
msdu_id = msdus[msdu_count + i + 1];
|
|
|
|
tx_done.ack_rssi = __le16_to_cpu(msdu_id);
|
|
|
|
} else {
|
|
|
|
msdu_id = msdus[msdu_count + i];
|
|
|
|
tx_done.ack_rssi = __le16_to_cpu(msdu_id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-22 19:52:11 +08:00
|
|
|
/* kfifo_put: In practice firmware shouldn't fire off per-CE
|
|
|
|
* interrupt and main interrupt (MSI/-X range case) for the same
|
|
|
|
* HTC service so it should be safe to use kfifo_put w/o lock.
|
|
|
|
*
|
|
|
|
* From kfifo_put() documentation:
|
|
|
|
* Note that with only one concurrent reader and one concurrent
|
|
|
|
* writer, you don't need extra locking to use these macro.
|
|
|
|
*/
|
|
|
|
if (!kfifo_put(&htt->txdone_fifo, tx_done)) {
|
|
|
|
ath10k_warn(ar, "txdone fifo overrun, msdu_id %d status %d\n",
|
|
|
|
tx_done.msdu_id, tx_done.status);
|
|
|
|
ath10k_txrx_tx_unref(htt, &tx_done);
|
|
|
|
}
|
2014-02-28 00:50:04 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-23 18:20:33 +08:00
|
|
|
static void ath10k_htt_rx_addba(struct ath10k *ar, struct htt_resp *resp)
|
|
|
|
{
|
|
|
|
struct htt_rx_addba *ev = &resp->rx_addba;
|
|
|
|
struct ath10k_peer *peer;
|
|
|
|
struct ath10k_vif *arvif;
|
|
|
|
u16 info0, tid, peer_id;
|
|
|
|
|
|
|
|
info0 = __le16_to_cpu(ev->info0);
|
|
|
|
tid = MS(info0, HTT_RX_BA_INFO0_TID);
|
|
|
|
peer_id = MS(info0, HTT_RX_BA_INFO0_PEER_ID);
|
|
|
|
|
2014-08-25 18:09:38 +08:00
|
|
|
ath10k_dbg(ar, ATH10K_DBG_HTT,
|
2014-07-23 18:20:33 +08:00
|
|
|
"htt rx addba tid %hu peer_id %hu size %hhu\n",
|
|
|
|
tid, peer_id, ev->window_size);
|
|
|
|
|
|
|
|
spin_lock_bh(&ar->data_lock);
|
|
|
|
peer = ath10k_peer_find_by_id(ar, peer_id);
|
|
|
|
if (!peer) {
|
2014-08-25 18:09:38 +08:00
|
|
|
ath10k_warn(ar, "received addba event for invalid peer_id: %hu\n",
|
2014-07-23 18:20:33 +08:00
|
|
|
peer_id);
|
|
|
|
spin_unlock_bh(&ar->data_lock);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
arvif = ath10k_get_arvif(ar, peer->vdev_id);
|
|
|
|
if (!arvif) {
|
2014-08-25 18:09:38 +08:00
|
|
|
ath10k_warn(ar, "received addba event for invalid vdev_id: %u\n",
|
2014-07-23 18:20:33 +08:00
|
|
|
peer->vdev_id);
|
|
|
|
spin_unlock_bh(&ar->data_lock);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-08-25 18:09:38 +08:00
|
|
|
ath10k_dbg(ar, ATH10K_DBG_HTT,
|
2014-07-23 18:20:33 +08:00
|
|
|
"htt rx start rx ba session sta %pM tid %hu size %hhu\n",
|
|
|
|
peer->addr, tid, ev->window_size);
|
|
|
|
|
|
|
|
ieee80211_start_rx_ba_session_offl(arvif->vif, peer->addr, tid);
|
|
|
|
spin_unlock_bh(&ar->data_lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ath10k_htt_rx_delba(struct ath10k *ar, struct htt_resp *resp)
|
|
|
|
{
|
|
|
|
struct htt_rx_delba *ev = &resp->rx_delba;
|
|
|
|
struct ath10k_peer *peer;
|
|
|
|
struct ath10k_vif *arvif;
|
|
|
|
u16 info0, tid, peer_id;
|
|
|
|
|
|
|
|
info0 = __le16_to_cpu(ev->info0);
|
|
|
|
tid = MS(info0, HTT_RX_BA_INFO0_TID);
|
|
|
|
peer_id = MS(info0, HTT_RX_BA_INFO0_PEER_ID);
|
|
|
|
|
2014-08-25 18:09:38 +08:00
|
|
|
ath10k_dbg(ar, ATH10K_DBG_HTT,
|
2014-07-23 18:20:33 +08:00
|
|
|
"htt rx delba tid %hu peer_id %hu\n",
|
|
|
|
tid, peer_id);
|
|
|
|
|
|
|
|
spin_lock_bh(&ar->data_lock);
|
|
|
|
peer = ath10k_peer_find_by_id(ar, peer_id);
|
|
|
|
if (!peer) {
|
2014-08-25 18:09:38 +08:00
|
|
|
ath10k_warn(ar, "received addba event for invalid peer_id: %hu\n",
|
2014-07-23 18:20:33 +08:00
|
|
|
peer_id);
|
|
|
|
spin_unlock_bh(&ar->data_lock);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
arvif = ath10k_get_arvif(ar, peer->vdev_id);
|
|
|
|
if (!arvif) {
|
2014-08-25 18:09:38 +08:00
|
|
|
ath10k_warn(ar, "received addba event for invalid vdev_id: %u\n",
|
2014-07-23 18:20:33 +08:00
|
|
|
peer->vdev_id);
|
|
|
|
spin_unlock_bh(&ar->data_lock);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-08-25 18:09:38 +08:00
|
|
|
ath10k_dbg(ar, ATH10K_DBG_HTT,
|
2014-07-23 18:20:33 +08:00
|
|
|
"htt rx stop rx ba session sta %pM tid %hu\n",
|
|
|
|
peer->addr, tid);
|
|
|
|
|
|
|
|
ieee80211_stop_rx_ba_session_offl(arvif->vif, peer->addr, tid);
|
|
|
|
spin_unlock_bh(&ar->data_lock);
|
|
|
|
}
|
|
|
|
|
2015-01-24 18:14:48 +08:00
|
|
|
static int ath10k_htt_rx_extract_amsdu(struct sk_buff_head *list,
|
2017-10-29 15:45:07 +08:00
|
|
|
struct sk_buff_head *amsdu)
|
2015-01-24 18:14:48 +08:00
|
|
|
{
|
|
|
|
struct sk_buff *msdu;
|
|
|
|
struct htt_rx_desc *rxd;
|
|
|
|
|
|
|
|
if (skb_queue_empty(list))
|
|
|
|
return -ENOBUFS;
|
|
|
|
|
|
|
|
if (WARN_ON(!skb_queue_empty(amsdu)))
|
|
|
|
return -EINVAL;
|
|
|
|
|
2017-10-29 15:45:07 +08:00
|
|
|
while ((msdu = __skb_dequeue(list))) {
|
2015-01-24 18:14:48 +08:00
|
|
|
__skb_queue_tail(amsdu, msdu);
|
|
|
|
|
|
|
|
rxd = (void *)msdu->data - sizeof(*rxd);
|
2015-07-16 10:01:21 +08:00
|
|
|
if (rxd->msdu_end.common.info0 &
|
2015-01-24 18:14:48 +08:00
|
|
|
__cpu_to_le32(RX_MSDU_END_INFO0_LAST_MSDU))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
msdu = skb_peek_tail(amsdu);
|
|
|
|
rxd = (void *)msdu->data - sizeof(*rxd);
|
2015-07-16 10:01:21 +08:00
|
|
|
if (!(rxd->msdu_end.common.info0 &
|
2015-01-24 18:14:48 +08:00
|
|
|
__cpu_to_le32(RX_MSDU_END_INFO0_LAST_MSDU))) {
|
|
|
|
skb_queue_splice_init(amsdu, list);
|
|
|
|
return -EAGAIN;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ath10k_htt_rx_h_rx_offload_prot(struct ieee80211_rx_status *status,
|
|
|
|
struct sk_buff *skb)
|
|
|
|
{
|
|
|
|
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
|
|
|
|
|
|
|
|
if (!ieee80211_has_protected(hdr->frame_control))
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Offloaded frames are already decrypted but firmware insists they are
|
|
|
|
* protected in the 802.11 header. Strip the flag. Otherwise mac80211
|
|
|
|
* will drop the frame.
|
|
|
|
*/
|
|
|
|
|
|
|
|
hdr->frame_control &= ~__cpu_to_le16(IEEE80211_FCTL_PROTECTED);
|
|
|
|
status->flag |= RX_FLAG_DECRYPTED |
|
|
|
|
RX_FLAG_IV_STRIPPED |
|
|
|
|
RX_FLAG_MMIC_STRIPPED;
|
|
|
|
}
|
|
|
|
|
2017-12-07 22:58:05 +08:00
|
|
|
static void ath10k_htt_rx_h_rx_offload(struct ath10k *ar,
|
|
|
|
struct sk_buff_head *list)
|
2015-01-24 18:14:48 +08:00
|
|
|
{
|
|
|
|
struct ath10k_htt *htt = &ar->htt;
|
|
|
|
struct ieee80211_rx_status *status = &htt->rx_status;
|
|
|
|
struct htt_rx_offload_msdu *rx;
|
|
|
|
struct sk_buff *msdu;
|
|
|
|
size_t offset;
|
|
|
|
|
|
|
|
while ((msdu = __skb_dequeue(list))) {
|
|
|
|
/* Offloaded frames don't have Rx descriptor. Instead they have
|
|
|
|
* a short meta information header.
|
|
|
|
*/
|
|
|
|
|
|
|
|
rx = (void *)msdu->data;
|
|
|
|
|
|
|
|
skb_put(msdu, sizeof(*rx));
|
|
|
|
skb_pull(msdu, sizeof(*rx));
|
|
|
|
|
|
|
|
if (skb_tailroom(msdu) < __le16_to_cpu(rx->msdu_len)) {
|
|
|
|
ath10k_warn(ar, "dropping frame: offloaded rx msdu is too long!\n");
|
|
|
|
dev_kfree_skb_any(msdu);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
skb_put(msdu, __le16_to_cpu(rx->msdu_len));
|
|
|
|
|
|
|
|
/* Offloaded rx header length isn't multiple of 2 nor 4 so the
|
|
|
|
* actual payload is unaligned. Align the frame. Otherwise
|
|
|
|
* mac80211 complains. This shouldn't reduce performance much
|
|
|
|
* because these offloaded frames are rare.
|
|
|
|
*/
|
|
|
|
offset = 4 - ((unsigned long)msdu->data & 3);
|
|
|
|
skb_put(msdu, offset);
|
|
|
|
memmove(msdu->data + offset, msdu->data, msdu->len);
|
|
|
|
skb_pull(msdu, offset);
|
|
|
|
|
|
|
|
/* FIXME: The frame is NWifi. Re-construct QoS Control
|
|
|
|
* if possible later.
|
|
|
|
*/
|
|
|
|
|
|
|
|
memset(status, 0, sizeof(*status));
|
|
|
|
status->flag |= RX_FLAG_NO_SIGNAL_VAL;
|
|
|
|
|
|
|
|
ath10k_htt_rx_h_rx_offload_prot(status, msdu);
|
2015-03-31 18:26:21 +08:00
|
|
|
ath10k_htt_rx_h_channel(ar, status, NULL, rx->vdev_id);
|
2017-12-07 22:58:05 +08:00
|
|
|
ath10k_htt_rx_h_queue_msdu(ar, status, msdu);
|
2015-01-24 18:14:48 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-29 15:45:07 +08:00
|
|
|
static int ath10k_htt_rx_in_ord_ind(struct ath10k *ar, struct sk_buff *skb)
|
2015-01-24 18:14:48 +08:00
|
|
|
{
|
|
|
|
struct ath10k_htt *htt = &ar->htt;
|
|
|
|
struct htt_resp *resp = (void *)skb->data;
|
|
|
|
struct ieee80211_rx_status *status = &htt->rx_status;
|
|
|
|
struct sk_buff_head list;
|
|
|
|
struct sk_buff_head amsdu;
|
|
|
|
u16 peer_id;
|
|
|
|
u16 msdu_count;
|
|
|
|
u8 vdev_id;
|
|
|
|
u8 tid;
|
|
|
|
bool offload;
|
|
|
|
bool frag;
|
2017-12-07 22:58:05 +08:00
|
|
|
int ret;
|
2015-01-24 18:14:48 +08:00
|
|
|
|
|
|
|
lockdep_assert_held(&htt->rx_ring.lock);
|
|
|
|
|
|
|
|
if (htt->rx_confused)
|
2016-09-03 00:46:09 +08:00
|
|
|
return -EIO;
|
2015-01-24 18:14:48 +08:00
|
|
|
|
|
|
|
skb_pull(skb, sizeof(resp->hdr));
|
|
|
|
skb_pull(skb, sizeof(resp->rx_in_ord_ind));
|
|
|
|
|
|
|
|
peer_id = __le16_to_cpu(resp->rx_in_ord_ind.peer_id);
|
|
|
|
msdu_count = __le16_to_cpu(resp->rx_in_ord_ind.msdu_count);
|
|
|
|
vdev_id = resp->rx_in_ord_ind.vdev_id;
|
|
|
|
tid = SM(resp->rx_in_ord_ind.info, HTT_RX_IN_ORD_IND_INFO_TID);
|
|
|
|
offload = !!(resp->rx_in_ord_ind.info &
|
|
|
|
HTT_RX_IN_ORD_IND_INFO_OFFLOAD_MASK);
|
|
|
|
frag = !!(resp->rx_in_ord_ind.info & HTT_RX_IN_ORD_IND_INFO_FRAG_MASK);
|
|
|
|
|
|
|
|
ath10k_dbg(ar, ATH10K_DBG_HTT,
|
|
|
|
"htt rx in ord vdev %i peer %i tid %i offload %i frag %i msdu count %i\n",
|
|
|
|
vdev_id, peer_id, tid, offload, frag, msdu_count);
|
|
|
|
|
2017-12-21 17:00:52 +08:00
|
|
|
if (skb->len < msdu_count * sizeof(*resp->rx_in_ord_ind.msdu_descs32)) {
|
2015-01-24 18:14:48 +08:00
|
|
|
ath10k_warn(ar, "dropping invalid in order rx indication\n");
|
2016-09-03 00:46:09 +08:00
|
|
|
return -EINVAL;
|
2015-01-24 18:14:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* The event can deliver more than 1 A-MSDU. Each A-MSDU is later
|
|
|
|
* extracted and processed.
|
|
|
|
*/
|
|
|
|
__skb_queue_head_init(&list);
|
2017-12-21 17:00:52 +08:00
|
|
|
if (ar->hw_params.target_64bit)
|
|
|
|
ret = ath10k_htt_rx_pop_paddr64_list(htt, &resp->rx_in_ord_ind,
|
|
|
|
&list);
|
|
|
|
else
|
|
|
|
ret = ath10k_htt_rx_pop_paddr32_list(htt, &resp->rx_in_ord_ind,
|
|
|
|
&list);
|
|
|
|
|
2015-01-24 18:14:48 +08:00
|
|
|
if (ret < 0) {
|
|
|
|
ath10k_warn(ar, "failed to pop paddr list: %d\n", ret);
|
|
|
|
htt->rx_confused = true;
|
2016-09-03 00:46:09 +08:00
|
|
|
return -EIO;
|
2015-01-24 18:14:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Offloaded frames are very different and need to be handled
|
|
|
|
* separately.
|
|
|
|
*/
|
|
|
|
if (offload)
|
2017-12-07 22:58:05 +08:00
|
|
|
ath10k_htt_rx_h_rx_offload(ar, &list);
|
2015-01-24 18:14:48 +08:00
|
|
|
|
2017-10-29 15:45:07 +08:00
|
|
|
while (!skb_queue_empty(&list)) {
|
2015-01-24 18:14:48 +08:00
|
|
|
__skb_queue_head_init(&amsdu);
|
2017-10-29 15:45:07 +08:00
|
|
|
ret = ath10k_htt_rx_extract_amsdu(&list, &amsdu);
|
2015-01-24 18:14:48 +08:00
|
|
|
switch (ret) {
|
|
|
|
case 0:
|
|
|
|
/* Note: The in-order indication may report interleaved
|
|
|
|
* frames from different PPDUs meaning reported rx rate
|
|
|
|
* to mac80211 isn't accurate/reliable. It's still
|
|
|
|
* better to report something than nothing though. This
|
|
|
|
* should still give an idea about rx rate to the user.
|
|
|
|
*/
|
2015-03-31 18:26:21 +08:00
|
|
|
ath10k_htt_rx_h_ppdu(ar, &amsdu, status, vdev_id);
|
2018-03-14 18:14:06 +08:00
|
|
|
ath10k_htt_rx_h_filter(ar, &amsdu, status, NULL);
|
|
|
|
ath10k_htt_rx_h_mpdu(ar, &amsdu, status, false, NULL,
|
|
|
|
NULL);
|
2017-12-07 22:58:05 +08:00
|
|
|
ath10k_htt_rx_h_enqueue(ar, &amsdu, status);
|
2015-01-24 18:14:48 +08:00
|
|
|
break;
|
|
|
|
case -EAGAIN:
|
|
|
|
/* fall through */
|
|
|
|
default:
|
|
|
|
/* Should not happen. */
|
|
|
|
ath10k_warn(ar, "failed to extract amsdu: %d\n", ret);
|
|
|
|
htt->rx_confused = true;
|
|
|
|
__skb_queue_purge(&list);
|
2016-09-03 00:46:09 +08:00
|
|
|
return -EIO;
|
2015-01-24 18:14:48 +08:00
|
|
|
}
|
|
|
|
}
|
2017-12-07 22:58:05 +08:00
|
|
|
return ret;
|
2015-01-24 18:14:48 +08:00
|
|
|
}
|
|
|
|
|
2016-03-06 22:14:32 +08:00
|
|
|
static void ath10k_htt_rx_tx_fetch_resp_id_confirm(struct ath10k *ar,
|
|
|
|
const __le32 *resp_ids,
|
|
|
|
int num_resp_ids)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
u32 resp_id;
|
|
|
|
|
|
|
|
ath10k_dbg(ar, ATH10K_DBG_HTT, "htt rx tx fetch confirm num_resp_ids %d\n",
|
|
|
|
num_resp_ids);
|
|
|
|
|
|
|
|
for (i = 0; i < num_resp_ids; i++) {
|
|
|
|
resp_id = le32_to_cpu(resp_ids[i]);
|
|
|
|
|
|
|
|
ath10k_dbg(ar, ATH10K_DBG_HTT, "htt rx tx fetch confirm resp_id %u\n",
|
|
|
|
resp_id);
|
|
|
|
|
|
|
|
/* TODO: free resp_id */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ath10k_htt_rx_tx_fetch_ind(struct ath10k *ar, struct sk_buff *skb)
|
|
|
|
{
|
2016-03-06 22:14:43 +08:00
|
|
|
struct ieee80211_hw *hw = ar->hw;
|
|
|
|
struct ieee80211_txq *txq;
|
2016-03-06 22:14:32 +08:00
|
|
|
struct htt_resp *resp = (struct htt_resp *)skb->data;
|
|
|
|
struct htt_tx_fetch_record *record;
|
|
|
|
size_t len;
|
|
|
|
size_t max_num_bytes;
|
|
|
|
size_t max_num_msdus;
|
2016-03-06 22:14:43 +08:00
|
|
|
size_t num_bytes;
|
|
|
|
size_t num_msdus;
|
2016-03-06 22:14:32 +08:00
|
|
|
const __le32 *resp_ids;
|
|
|
|
u16 num_records;
|
|
|
|
u16 num_resp_ids;
|
|
|
|
u16 peer_id;
|
|
|
|
u8 tid;
|
2016-03-06 22:14:43 +08:00
|
|
|
int ret;
|
2016-03-06 22:14:32 +08:00
|
|
|
int i;
|
|
|
|
|
|
|
|
ath10k_dbg(ar, ATH10K_DBG_HTT, "htt rx tx fetch ind\n");
|
|
|
|
|
|
|
|
len = sizeof(resp->hdr) + sizeof(resp->tx_fetch_ind);
|
|
|
|
if (unlikely(skb->len < len)) {
|
|
|
|
ath10k_warn(ar, "received corrupted tx_fetch_ind event: buffer too short\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
num_records = le16_to_cpu(resp->tx_fetch_ind.num_records);
|
|
|
|
num_resp_ids = le16_to_cpu(resp->tx_fetch_ind.num_resp_ids);
|
|
|
|
|
|
|
|
len += sizeof(resp->tx_fetch_ind.records[0]) * num_records;
|
|
|
|
len += sizeof(resp->tx_fetch_ind.resp_ids[0]) * num_resp_ids;
|
|
|
|
|
|
|
|
if (unlikely(skb->len < len)) {
|
|
|
|
ath10k_warn(ar, "received corrupted tx_fetch_ind event: too many records/resp_ids\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ath10k_dbg(ar, ATH10K_DBG_HTT, "htt rx tx fetch ind num records %hu num resps %hu seq %hu\n",
|
|
|
|
num_records, num_resp_ids,
|
|
|
|
le16_to_cpu(resp->tx_fetch_ind.fetch_seq_num));
|
|
|
|
|
2016-03-06 22:14:43 +08:00
|
|
|
if (!ar->htt.tx_q_state.enabled) {
|
|
|
|
ath10k_warn(ar, "received unexpected tx_fetch_ind event: not enabled\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ar->htt.tx_q_state.mode == HTT_TX_MODE_SWITCH_PUSH) {
|
|
|
|
ath10k_warn(ar, "received unexpected tx_fetch_ind event: in push mode\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
rcu_read_lock();
|
2016-03-06 22:14:32 +08:00
|
|
|
|
|
|
|
for (i = 0; i < num_records; i++) {
|
|
|
|
record = &resp->tx_fetch_ind.records[i];
|
|
|
|
peer_id = MS(le16_to_cpu(record->info),
|
|
|
|
HTT_TX_FETCH_RECORD_INFO_PEER_ID);
|
|
|
|
tid = MS(le16_to_cpu(record->info),
|
|
|
|
HTT_TX_FETCH_RECORD_INFO_TID);
|
|
|
|
max_num_msdus = le16_to_cpu(record->num_msdus);
|
|
|
|
max_num_bytes = le32_to_cpu(record->num_bytes);
|
|
|
|
|
|
|
|
ath10k_dbg(ar, ATH10K_DBG_HTT, "htt rx tx fetch record %i peer_id %hu tid %hhu msdus %zu bytes %zu\n",
|
|
|
|
i, peer_id, tid, max_num_msdus, max_num_bytes);
|
|
|
|
|
|
|
|
if (unlikely(peer_id >= ar->htt.tx_q_state.num_peers) ||
|
|
|
|
unlikely(tid >= ar->htt.tx_q_state.num_tids)) {
|
|
|
|
ath10k_warn(ar, "received out of range peer_id %hu tid %hhu\n",
|
|
|
|
peer_id, tid);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2016-03-06 22:14:43 +08:00
|
|
|
spin_lock_bh(&ar->data_lock);
|
|
|
|
txq = ath10k_mac_txq_lookup(ar, peer_id, tid);
|
|
|
|
spin_unlock_bh(&ar->data_lock);
|
|
|
|
|
|
|
|
/* It is okay to release the lock and use txq because RCU read
|
|
|
|
* lock is held.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (unlikely(!txq)) {
|
|
|
|
ath10k_warn(ar, "failed to lookup txq for peer_id %hu tid %hhu\n",
|
|
|
|
peer_id, tid);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
num_msdus = 0;
|
|
|
|
num_bytes = 0;
|
|
|
|
|
|
|
|
while (num_msdus < max_num_msdus &&
|
|
|
|
num_bytes < max_num_bytes) {
|
|
|
|
ret = ath10k_mac_tx_push_txq(hw, txq);
|
|
|
|
if (ret < 0)
|
|
|
|
break;
|
|
|
|
|
|
|
|
num_msdus++;
|
|
|
|
num_bytes += ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
record->num_msdus = cpu_to_le16(num_msdus);
|
|
|
|
record->num_bytes = cpu_to_le32(num_bytes);
|
|
|
|
|
|
|
|
ath10k_htt_tx_txq_recalc(hw, txq);
|
2016-03-06 22:14:32 +08:00
|
|
|
}
|
|
|
|
|
2016-03-06 22:14:43 +08:00
|
|
|
rcu_read_unlock();
|
|
|
|
|
2016-03-06 22:14:32 +08:00
|
|
|
resp_ids = ath10k_htt_get_tx_fetch_ind_resp_ids(&resp->tx_fetch_ind);
|
|
|
|
ath10k_htt_rx_tx_fetch_resp_id_confirm(ar, resp_ids, num_resp_ids);
|
|
|
|
|
2016-03-06 22:14:43 +08:00
|
|
|
ret = ath10k_htt_tx_fetch_resp(ar,
|
|
|
|
resp->tx_fetch_ind.token,
|
|
|
|
resp->tx_fetch_ind.fetch_seq_num,
|
|
|
|
resp->tx_fetch_ind.records,
|
|
|
|
num_records);
|
|
|
|
if (unlikely(ret)) {
|
|
|
|
ath10k_warn(ar, "failed to submit tx fetch resp for token 0x%08x: %d\n",
|
|
|
|
le32_to_cpu(resp->tx_fetch_ind.token), ret);
|
|
|
|
/* FIXME: request fw restart */
|
|
|
|
}
|
2015-01-24 18:14:48 +08:00
|
|
|
|
2016-03-06 22:14:43 +08:00
|
|
|
ath10k_htt_tx_txq_sync(ar);
|
2015-01-24 18:14:48 +08:00
|
|
|
}
|
|
|
|
|
2016-03-06 22:14:32 +08:00
|
|
|
static void ath10k_htt_rx_tx_fetch_confirm(struct ath10k *ar,
|
|
|
|
struct sk_buff *skb)
|
|
|
|
{
|
|
|
|
const struct htt_resp *resp = (void *)skb->data;
|
|
|
|
size_t len;
|
|
|
|
int num_resp_ids;
|
|
|
|
|
|
|
|
ath10k_dbg(ar, ATH10K_DBG_HTT, "htt rx tx fetch confirm\n");
|
|
|
|
|
|
|
|
len = sizeof(resp->hdr) + sizeof(resp->tx_fetch_confirm);
|
|
|
|
if (unlikely(skb->len < len)) {
|
|
|
|
ath10k_warn(ar, "received corrupted tx_fetch_confirm event: buffer too short\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
num_resp_ids = le16_to_cpu(resp->tx_fetch_confirm.num_resp_ids);
|
|
|
|
len += sizeof(resp->tx_fetch_confirm.resp_ids[0]) * num_resp_ids;
|
|
|
|
|
|
|
|
if (unlikely(skb->len < len)) {
|
|
|
|
ath10k_warn(ar, "received corrupted tx_fetch_confirm event: resp_ids buffer overflow\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ath10k_htt_rx_tx_fetch_resp_id_confirm(ar,
|
|
|
|
resp->tx_fetch_confirm.resp_ids,
|
|
|
|
num_resp_ids);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ath10k_htt_rx_tx_mode_switch_ind(struct ath10k *ar,
|
|
|
|
struct sk_buff *skb)
|
|
|
|
{
|
|
|
|
const struct htt_resp *resp = (void *)skb->data;
|
|
|
|
const struct htt_tx_mode_switch_record *record;
|
2016-03-06 22:14:43 +08:00
|
|
|
struct ieee80211_txq *txq;
|
|
|
|
struct ath10k_txq *artxq;
|
2016-03-06 22:14:32 +08:00
|
|
|
size_t len;
|
|
|
|
size_t num_records;
|
|
|
|
enum htt_tx_mode_switch_mode mode;
|
|
|
|
bool enable;
|
|
|
|
u16 info0;
|
|
|
|
u16 info1;
|
|
|
|
u16 threshold;
|
|
|
|
u16 peer_id;
|
|
|
|
u8 tid;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
ath10k_dbg(ar, ATH10K_DBG_HTT, "htt rx tx mode switch ind\n");
|
|
|
|
|
|
|
|
len = sizeof(resp->hdr) + sizeof(resp->tx_mode_switch_ind);
|
|
|
|
if (unlikely(skb->len < len)) {
|
|
|
|
ath10k_warn(ar, "received corrupted tx_mode_switch_ind event: buffer too short\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
info0 = le16_to_cpu(resp->tx_mode_switch_ind.info0);
|
|
|
|
info1 = le16_to_cpu(resp->tx_mode_switch_ind.info1);
|
|
|
|
|
|
|
|
enable = !!(info0 & HTT_TX_MODE_SWITCH_IND_INFO0_ENABLE);
|
|
|
|
num_records = MS(info0, HTT_TX_MODE_SWITCH_IND_INFO1_THRESHOLD);
|
|
|
|
mode = MS(info1, HTT_TX_MODE_SWITCH_IND_INFO1_MODE);
|
|
|
|
threshold = MS(info1, HTT_TX_MODE_SWITCH_IND_INFO1_THRESHOLD);
|
|
|
|
|
|
|
|
ath10k_dbg(ar, ATH10K_DBG_HTT,
|
|
|
|
"htt rx tx mode switch ind info0 0x%04hx info1 0x%04hx enable %d num records %zd mode %d threshold %hu\n",
|
|
|
|
info0, info1, enable, num_records, mode, threshold);
|
|
|
|
|
|
|
|
len += sizeof(resp->tx_mode_switch_ind.records[0]) * num_records;
|
|
|
|
|
|
|
|
if (unlikely(skb->len < len)) {
|
|
|
|
ath10k_warn(ar, "received corrupted tx_mode_switch_mode_ind event: too many records\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (mode) {
|
|
|
|
case HTT_TX_MODE_SWITCH_PUSH:
|
|
|
|
case HTT_TX_MODE_SWITCH_PUSH_PULL:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ath10k_warn(ar, "received invalid tx_mode_switch_mode_ind mode %d, ignoring\n",
|
|
|
|
mode);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!enable)
|
|
|
|
return;
|
|
|
|
|
2016-03-06 22:14:43 +08:00
|
|
|
ar->htt.tx_q_state.enabled = enable;
|
|
|
|
ar->htt.tx_q_state.mode = mode;
|
|
|
|
ar->htt.tx_q_state.num_push_allowed = threshold;
|
|
|
|
|
|
|
|
rcu_read_lock();
|
2016-03-06 22:14:32 +08:00
|
|
|
|
|
|
|
for (i = 0; i < num_records; i++) {
|
|
|
|
record = &resp->tx_mode_switch_ind.records[i];
|
|
|
|
info0 = le16_to_cpu(record->info0);
|
|
|
|
peer_id = MS(info0, HTT_TX_MODE_SWITCH_RECORD_INFO0_PEER_ID);
|
|
|
|
tid = MS(info0, HTT_TX_MODE_SWITCH_RECORD_INFO0_TID);
|
|
|
|
|
|
|
|
if (unlikely(peer_id >= ar->htt.tx_q_state.num_peers) ||
|
|
|
|
unlikely(tid >= ar->htt.tx_q_state.num_tids)) {
|
|
|
|
ath10k_warn(ar, "received out of range peer_id %hu tid %hhu\n",
|
|
|
|
peer_id, tid);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2016-03-06 22:14:43 +08:00
|
|
|
spin_lock_bh(&ar->data_lock);
|
|
|
|
txq = ath10k_mac_txq_lookup(ar, peer_id, tid);
|
|
|
|
spin_unlock_bh(&ar->data_lock);
|
|
|
|
|
|
|
|
/* It is okay to release the lock and use txq because RCU read
|
|
|
|
* lock is held.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (unlikely(!txq)) {
|
|
|
|
ath10k_warn(ar, "failed to lookup txq for peer_id %hu tid %hhu\n",
|
|
|
|
peer_id, tid);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
spin_lock_bh(&ar->htt.tx_lock);
|
|
|
|
artxq = (void *)txq->drv_priv;
|
|
|
|
artxq->num_push_allowed = le16_to_cpu(record->num_max_msdus);
|
|
|
|
spin_unlock_bh(&ar->htt.tx_lock);
|
2016-03-06 22:14:32 +08:00
|
|
|
}
|
|
|
|
|
2016-03-06 22:14:43 +08:00
|
|
|
rcu_read_unlock();
|
|
|
|
|
|
|
|
ath10k_mac_tx_push_pending(ar);
|
2016-03-06 22:14:32 +08:00
|
|
|
}
|
|
|
|
|
2016-03-22 19:52:16 +08:00
|
|
|
void ath10k_htt_htc_t2h_msg_handler(struct ath10k *ar, struct sk_buff *skb)
|
|
|
|
{
|
|
|
|
bool release;
|
|
|
|
|
|
|
|
release = ath10k_htt_t2h_msg_handler(ar, skb);
|
|
|
|
|
|
|
|
/* Free the indication buffer */
|
|
|
|
if (release)
|
|
|
|
dev_kfree_skb_any(skb);
|
|
|
|
}
|
|
|
|
|
2018-12-20 15:53:28 +08:00
|
|
|
static inline s8 ath10k_get_legacy_rate_idx(struct ath10k *ar, u8 rate)
|
2016-11-23 22:58:10 +08:00
|
|
|
{
|
|
|
|
static const u8 legacy_rates[] = {1, 2, 5, 11, 6, 9, 12,
|
|
|
|
18, 24, 36, 48, 54};
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(legacy_rates); i++) {
|
|
|
|
if (rate == legacy_rates[i])
|
2018-09-04 14:45:13 +08:00
|
|
|
return i;
|
2016-11-23 22:58:10 +08:00
|
|
|
}
|
|
|
|
|
2018-09-04 14:45:13 +08:00
|
|
|
ath10k_warn(ar, "Invalid legacy rate %hhd peer stats", rate);
|
|
|
|
return -EINVAL;
|
2016-11-23 22:58:10 +08:00
|
|
|
}
|
|
|
|
|
2018-09-04 14:45:15 +08:00
|
|
|
static void
|
|
|
|
ath10k_accumulate_per_peer_tx_stats(struct ath10k *ar,
|
|
|
|
struct ath10k_sta *arsta,
|
|
|
|
struct ath10k_per_peer_tx_stats *pstats,
|
2018-12-20 15:53:28 +08:00
|
|
|
s8 legacy_rate_idx)
|
2018-09-04 14:45:15 +08:00
|
|
|
{
|
|
|
|
struct rate_info *txrate = &arsta->txrate;
|
|
|
|
struct ath10k_htt_tx_stats *tx_stats;
|
2018-10-12 14:03:28 +08:00
|
|
|
int idx, ht_idx, gi, mcs, bw, nss;
|
2018-09-04 14:45:15 +08:00
|
|
|
|
|
|
|
if (!arsta->tx_stats)
|
|
|
|
return;
|
|
|
|
|
|
|
|
tx_stats = arsta->tx_stats;
|
|
|
|
gi = (arsta->txrate.flags & RATE_INFO_FLAGS_SHORT_GI);
|
|
|
|
ht_idx = txrate->mcs + txrate->nss * 8;
|
|
|
|
mcs = txrate->mcs;
|
|
|
|
bw = txrate->bw;
|
|
|
|
nss = txrate->nss;
|
2018-10-12 14:03:28 +08:00
|
|
|
idx = mcs * 8 + 8 * 10 * nss;
|
|
|
|
idx += bw * 2 + gi;
|
2018-09-04 14:45:15 +08:00
|
|
|
|
|
|
|
#define STATS_OP_FMT(name) tx_stats->stats[ATH10K_STATS_TYPE_##name]
|
|
|
|
|
|
|
|
if (txrate->flags == RATE_INFO_FLAGS_VHT_MCS) {
|
|
|
|
STATS_OP_FMT(SUCC).vht[0][mcs] += pstats->succ_bytes;
|
|
|
|
STATS_OP_FMT(SUCC).vht[1][mcs] += pstats->succ_pkts;
|
|
|
|
STATS_OP_FMT(FAIL).vht[0][mcs] += pstats->failed_bytes;
|
|
|
|
STATS_OP_FMT(FAIL).vht[1][mcs] += pstats->failed_pkts;
|
|
|
|
STATS_OP_FMT(RETRY).vht[0][mcs] += pstats->retry_bytes;
|
|
|
|
STATS_OP_FMT(RETRY).vht[1][mcs] += pstats->retry_pkts;
|
|
|
|
} else if (txrate->flags == RATE_INFO_FLAGS_MCS) {
|
|
|
|
STATS_OP_FMT(SUCC).ht[0][ht_idx] += pstats->succ_bytes;
|
|
|
|
STATS_OP_FMT(SUCC).ht[1][ht_idx] += pstats->succ_pkts;
|
|
|
|
STATS_OP_FMT(FAIL).ht[0][ht_idx] += pstats->failed_bytes;
|
|
|
|
STATS_OP_FMT(FAIL).ht[1][ht_idx] += pstats->failed_pkts;
|
|
|
|
STATS_OP_FMT(RETRY).ht[0][ht_idx] += pstats->retry_bytes;
|
|
|
|
STATS_OP_FMT(RETRY).ht[1][ht_idx] += pstats->retry_pkts;
|
|
|
|
} else {
|
|
|
|
mcs = legacy_rate_idx;
|
|
|
|
|
|
|
|
STATS_OP_FMT(SUCC).legacy[0][mcs] += pstats->succ_bytes;
|
|
|
|
STATS_OP_FMT(SUCC).legacy[1][mcs] += pstats->succ_pkts;
|
|
|
|
STATS_OP_FMT(FAIL).legacy[0][mcs] += pstats->failed_bytes;
|
|
|
|
STATS_OP_FMT(FAIL).legacy[1][mcs] += pstats->failed_pkts;
|
|
|
|
STATS_OP_FMT(RETRY).legacy[0][mcs] += pstats->retry_bytes;
|
|
|
|
STATS_OP_FMT(RETRY).legacy[1][mcs] += pstats->retry_pkts;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ATH10K_HW_AMPDU(pstats->flags)) {
|
|
|
|
tx_stats->ba_fails += ATH10K_HW_BA_FAIL(pstats->flags);
|
|
|
|
|
|
|
|
if (txrate->flags == RATE_INFO_FLAGS_MCS) {
|
|
|
|
STATS_OP_FMT(AMPDU).ht[0][ht_idx] +=
|
|
|
|
pstats->succ_bytes + pstats->retry_bytes;
|
|
|
|
STATS_OP_FMT(AMPDU).ht[1][ht_idx] +=
|
|
|
|
pstats->succ_pkts + pstats->retry_pkts;
|
|
|
|
} else {
|
|
|
|
STATS_OP_FMT(AMPDU).vht[0][mcs] +=
|
|
|
|
pstats->succ_bytes + pstats->retry_bytes;
|
|
|
|
STATS_OP_FMT(AMPDU).vht[1][mcs] +=
|
|
|
|
pstats->succ_pkts + pstats->retry_pkts;
|
|
|
|
}
|
|
|
|
STATS_OP_FMT(AMPDU).bw[0][bw] +=
|
|
|
|
pstats->succ_bytes + pstats->retry_bytes;
|
|
|
|
STATS_OP_FMT(AMPDU).nss[0][nss] +=
|
|
|
|
pstats->succ_bytes + pstats->retry_bytes;
|
|
|
|
STATS_OP_FMT(AMPDU).gi[0][gi] +=
|
|
|
|
pstats->succ_bytes + pstats->retry_bytes;
|
2018-10-12 14:03:28 +08:00
|
|
|
STATS_OP_FMT(AMPDU).rate_table[0][idx] +=
|
|
|
|
pstats->succ_bytes + pstats->retry_bytes;
|
2018-09-04 14:45:15 +08:00
|
|
|
STATS_OP_FMT(AMPDU).bw[1][bw] +=
|
|
|
|
pstats->succ_pkts + pstats->retry_pkts;
|
|
|
|
STATS_OP_FMT(AMPDU).nss[1][nss] +=
|
|
|
|
pstats->succ_pkts + pstats->retry_pkts;
|
|
|
|
STATS_OP_FMT(AMPDU).gi[1][gi] +=
|
|
|
|
pstats->succ_pkts + pstats->retry_pkts;
|
2018-10-12 14:03:28 +08:00
|
|
|
STATS_OP_FMT(AMPDU).rate_table[1][idx] +=
|
|
|
|
pstats->succ_pkts + pstats->retry_pkts;
|
2018-09-04 14:45:15 +08:00
|
|
|
} else {
|
|
|
|
tx_stats->ack_fails +=
|
|
|
|
ATH10K_HW_BA_FAIL(pstats->flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
STATS_OP_FMT(SUCC).bw[0][bw] += pstats->succ_bytes;
|
|
|
|
STATS_OP_FMT(SUCC).nss[0][nss] += pstats->succ_bytes;
|
|
|
|
STATS_OP_FMT(SUCC).gi[0][gi] += pstats->succ_bytes;
|
|
|
|
|
|
|
|
STATS_OP_FMT(SUCC).bw[1][bw] += pstats->succ_pkts;
|
|
|
|
STATS_OP_FMT(SUCC).nss[1][nss] += pstats->succ_pkts;
|
|
|
|
STATS_OP_FMT(SUCC).gi[1][gi] += pstats->succ_pkts;
|
|
|
|
|
|
|
|
STATS_OP_FMT(FAIL).bw[0][bw] += pstats->failed_bytes;
|
|
|
|
STATS_OP_FMT(FAIL).nss[0][nss] += pstats->failed_bytes;
|
|
|
|
STATS_OP_FMT(FAIL).gi[0][gi] += pstats->failed_bytes;
|
|
|
|
|
|
|
|
STATS_OP_FMT(FAIL).bw[1][bw] += pstats->failed_pkts;
|
|
|
|
STATS_OP_FMT(FAIL).nss[1][nss] += pstats->failed_pkts;
|
|
|
|
STATS_OP_FMT(FAIL).gi[1][gi] += pstats->failed_pkts;
|
|
|
|
|
|
|
|
STATS_OP_FMT(RETRY).bw[0][bw] += pstats->retry_bytes;
|
|
|
|
STATS_OP_FMT(RETRY).nss[0][nss] += pstats->retry_bytes;
|
|
|
|
STATS_OP_FMT(RETRY).gi[0][gi] += pstats->retry_bytes;
|
|
|
|
|
|
|
|
STATS_OP_FMT(RETRY).bw[1][bw] += pstats->retry_pkts;
|
|
|
|
STATS_OP_FMT(RETRY).nss[1][nss] += pstats->retry_pkts;
|
|
|
|
STATS_OP_FMT(RETRY).gi[1][gi] += pstats->retry_pkts;
|
2018-10-12 14:03:28 +08:00
|
|
|
|
|
|
|
if (txrate->flags >= RATE_INFO_FLAGS_MCS) {
|
|
|
|
STATS_OP_FMT(SUCC).rate_table[0][idx] += pstats->succ_bytes;
|
|
|
|
STATS_OP_FMT(SUCC).rate_table[1][idx] += pstats->succ_pkts;
|
|
|
|
STATS_OP_FMT(FAIL).rate_table[0][idx] += pstats->failed_bytes;
|
|
|
|
STATS_OP_FMT(FAIL).rate_table[1][idx] += pstats->failed_pkts;
|
|
|
|
STATS_OP_FMT(RETRY).rate_table[0][idx] += pstats->retry_bytes;
|
|
|
|
STATS_OP_FMT(RETRY).rate_table[1][idx] += pstats->retry_pkts;
|
|
|
|
}
|
2016-11-23 22:58:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ath10k_update_per_peer_tx_stats(struct ath10k *ar,
|
|
|
|
struct ieee80211_sta *sta,
|
|
|
|
struct ath10k_per_peer_tx_stats *peer_stats)
|
|
|
|
{
|
|
|
|
struct ath10k_sta *arsta = (struct ath10k_sta *)sta->drv_priv;
|
2018-12-20 15:53:28 +08:00
|
|
|
struct ieee80211_chanctx_conf *conf = NULL;
|
2018-10-06 02:42:45 +08:00
|
|
|
u8 rate = 0, sgi;
|
|
|
|
s8 rate_idx = 0;
|
2018-12-20 15:53:28 +08:00
|
|
|
bool skip_auto_rate;
|
2016-11-23 22:58:10 +08:00
|
|
|
struct rate_info txrate;
|
|
|
|
|
|
|
|
lockdep_assert_held(&ar->data_lock);
|
|
|
|
|
|
|
|
txrate.flags = ATH10K_HW_PREAMBLE(peer_stats->ratecode);
|
|
|
|
txrate.bw = ATH10K_HW_BW(peer_stats->flags);
|
|
|
|
txrate.nss = ATH10K_HW_NSS(peer_stats->ratecode);
|
|
|
|
txrate.mcs = ATH10K_HW_MCS_RATE(peer_stats->ratecode);
|
|
|
|
sgi = ATH10K_HW_GI(peer_stats->flags);
|
2018-12-20 15:53:28 +08:00
|
|
|
skip_auto_rate = ATH10K_FW_SKIPPED_RATE_CTRL(peer_stats->flags);
|
|
|
|
|
|
|
|
/* Firmware's rate control skips broadcast/management frames,
|
|
|
|
* if host has configure fixed rates and in some other special cases.
|
|
|
|
*/
|
|
|
|
if (skip_auto_rate)
|
|
|
|
return;
|
2016-11-23 22:58:10 +08:00
|
|
|
|
2017-05-19 16:54:02 +08:00
|
|
|
if (txrate.flags == WMI_RATE_PREAMBLE_VHT && txrate.mcs > 9) {
|
|
|
|
ath10k_warn(ar, "Invalid VHT mcs %hhd peer stats", txrate.mcs);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (txrate.flags == WMI_RATE_PREAMBLE_HT &&
|
|
|
|
(txrate.mcs > 7 || txrate.nss < 1)) {
|
|
|
|
ath10k_warn(ar, "Invalid HT mcs %hhd nss %hhd peer stats",
|
|
|
|
txrate.mcs, txrate.nss);
|
2016-11-23 22:58:10 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-01-13 18:30:03 +08:00
|
|
|
memset(&arsta->txrate, 0, sizeof(arsta->txrate));
|
2018-12-20 15:53:28 +08:00
|
|
|
memset(&arsta->tx_info.status, 0, sizeof(arsta->tx_info.status));
|
2016-11-23 22:58:10 +08:00
|
|
|
if (txrate.flags == WMI_RATE_PREAMBLE_CCK ||
|
|
|
|
txrate.flags == WMI_RATE_PREAMBLE_OFDM) {
|
|
|
|
rate = ATH10K_HW_LEGACY_RATE(peer_stats->ratecode);
|
|
|
|
/* This is hacky, FW sends CCK rate 5.5Mbps as 6 */
|
2018-09-04 14:45:13 +08:00
|
|
|
if (rate == 6 && txrate.flags == WMI_RATE_PREAMBLE_CCK)
|
|
|
|
rate = 5;
|
|
|
|
rate_idx = ath10k_get_legacy_rate_idx(ar, rate);
|
|
|
|
if (rate_idx < 0)
|
|
|
|
return;
|
2017-01-12 19:02:22 +08:00
|
|
|
arsta->txrate.legacy = rate;
|
2016-11-23 22:58:10 +08:00
|
|
|
} else if (txrate.flags == WMI_RATE_PREAMBLE_HT) {
|
|
|
|
arsta->txrate.flags = RATE_INFO_FLAGS_MCS;
|
2017-05-19 16:54:02 +08:00
|
|
|
arsta->txrate.mcs = txrate.mcs + 8 * (txrate.nss - 1);
|
2016-11-23 22:58:10 +08:00
|
|
|
} else {
|
|
|
|
arsta->txrate.flags = RATE_INFO_FLAGS_VHT_MCS;
|
|
|
|
arsta->txrate.mcs = txrate.mcs;
|
|
|
|
}
|
|
|
|
|
2018-12-20 15:53:28 +08:00
|
|
|
switch (txrate.flags) {
|
|
|
|
case WMI_RATE_PREAMBLE_OFDM:
|
|
|
|
if (arsta->arvif && arsta->arvif->vif)
|
|
|
|
conf = rcu_dereference(arsta->arvif->vif->chanctx_conf);
|
|
|
|
if (conf && conf->def.chan->band == NL80211_BAND_5GHZ)
|
|
|
|
arsta->tx_info.status.rates[0].idx = rate_idx - 4;
|
|
|
|
break;
|
|
|
|
case WMI_RATE_PREAMBLE_CCK:
|
|
|
|
arsta->tx_info.status.rates[0].idx = rate_idx;
|
|
|
|
if (sgi)
|
|
|
|
arsta->tx_info.status.rates[0].flags |=
|
|
|
|
(IEEE80211_TX_RC_USE_SHORT_PREAMBLE |
|
|
|
|
IEEE80211_TX_RC_SHORT_GI);
|
|
|
|
break;
|
|
|
|
case WMI_RATE_PREAMBLE_HT:
|
|
|
|
arsta->tx_info.status.rates[0].idx =
|
|
|
|
txrate.mcs + ((txrate.nss - 1) * 8);
|
|
|
|
if (sgi)
|
|
|
|
arsta->tx_info.status.rates[0].flags |=
|
|
|
|
IEEE80211_TX_RC_SHORT_GI;
|
|
|
|
arsta->tx_info.status.rates[0].flags |= IEEE80211_TX_RC_MCS;
|
|
|
|
break;
|
|
|
|
case WMI_RATE_PREAMBLE_VHT:
|
|
|
|
ieee80211_rate_set_vht(&arsta->tx_info.status.rates[0],
|
|
|
|
txrate.mcs, txrate.nss);
|
|
|
|
if (sgi)
|
|
|
|
arsta->tx_info.status.rates[0].flags |=
|
|
|
|
IEEE80211_TX_RC_SHORT_GI;
|
|
|
|
arsta->tx_info.status.rates[0].flags |= IEEE80211_TX_RC_VHT_MCS;
|
|
|
|
break;
|
|
|
|
}
|
2016-11-23 22:58:10 +08:00
|
|
|
|
|
|
|
arsta->txrate.nss = txrate.nss;
|
2018-03-28 17:19:55 +08:00
|
|
|
arsta->txrate.bw = ath10k_bw_to_mac80211_bw(txrate.bw);
|
2018-12-20 15:53:28 +08:00
|
|
|
if (sgi)
|
|
|
|
arsta->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
|
|
|
|
|
|
|
|
switch (arsta->txrate.bw) {
|
|
|
|
case RATE_INFO_BW_40:
|
|
|
|
arsta->tx_info.status.rates[0].flags |=
|
|
|
|
IEEE80211_TX_RC_40_MHZ_WIDTH;
|
|
|
|
break;
|
|
|
|
case RATE_INFO_BW_80:
|
|
|
|
arsta->tx_info.status.rates[0].flags |=
|
|
|
|
IEEE80211_TX_RC_80_MHZ_WIDTH;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (peer_stats->succ_pkts) {
|
|
|
|
arsta->tx_info.flags = IEEE80211_TX_STAT_ACK;
|
|
|
|
arsta->tx_info.status.rates[0].count = 1;
|
|
|
|
ieee80211_tx_rate_update(ar->hw, sta, &arsta->tx_info);
|
|
|
|
}
|
2018-09-04 14:45:15 +08:00
|
|
|
|
|
|
|
if (ath10k_debug_is_extd_tx_stats_enabled(ar))
|
|
|
|
ath10k_accumulate_per_peer_tx_stats(ar, arsta, peer_stats,
|
|
|
|
rate_idx);
|
2016-11-23 22:58:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void ath10k_htt_fetch_peer_stats(struct ath10k *ar,
|
|
|
|
struct sk_buff *skb)
|
|
|
|
{
|
|
|
|
struct htt_resp *resp = (struct htt_resp *)skb->data;
|
|
|
|
struct ath10k_per_peer_tx_stats *p_tx_stats = &ar->peer_tx_stats;
|
|
|
|
struct htt_per_peer_tx_stats_ind *tx_stats;
|
|
|
|
struct ieee80211_sta *sta;
|
|
|
|
struct ath10k_peer *peer;
|
|
|
|
int peer_id, i;
|
|
|
|
u8 ppdu_len, num_ppdu;
|
|
|
|
|
|
|
|
num_ppdu = resp->peer_tx_stats.num_ppdu;
|
|
|
|
ppdu_len = resp->peer_tx_stats.ppdu_len * sizeof(__le32);
|
|
|
|
|
|
|
|
if (skb->len < sizeof(struct htt_resp_hdr) + num_ppdu * ppdu_len) {
|
|
|
|
ath10k_warn(ar, "Invalid peer stats buf length %d\n", skb->len);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
tx_stats = (struct htt_per_peer_tx_stats_ind *)
|
|
|
|
(resp->peer_tx_stats.payload);
|
|
|
|
peer_id = __le16_to_cpu(tx_stats->peer_id);
|
|
|
|
|
|
|
|
rcu_read_lock();
|
|
|
|
spin_lock_bh(&ar->data_lock);
|
|
|
|
peer = ath10k_peer_find_by_id(ar, peer_id);
|
|
|
|
if (!peer) {
|
|
|
|
ath10k_warn(ar, "Invalid peer id %d peer stats buffer\n",
|
|
|
|
peer_id);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
sta = peer->sta;
|
|
|
|
for (i = 0; i < num_ppdu; i++) {
|
|
|
|
tx_stats = (struct htt_per_peer_tx_stats_ind *)
|
|
|
|
(resp->peer_tx_stats.payload + i * ppdu_len);
|
|
|
|
|
|
|
|
p_tx_stats->succ_bytes = __le32_to_cpu(tx_stats->succ_bytes);
|
|
|
|
p_tx_stats->retry_bytes = __le32_to_cpu(tx_stats->retry_bytes);
|
|
|
|
p_tx_stats->failed_bytes =
|
|
|
|
__le32_to_cpu(tx_stats->failed_bytes);
|
|
|
|
p_tx_stats->ratecode = tx_stats->ratecode;
|
|
|
|
p_tx_stats->flags = tx_stats->flags;
|
|
|
|
p_tx_stats->succ_pkts = __le16_to_cpu(tx_stats->succ_pkts);
|
|
|
|
p_tx_stats->retry_pkts = __le16_to_cpu(tx_stats->retry_pkts);
|
|
|
|
p_tx_stats->failed_pkts = __le16_to_cpu(tx_stats->failed_pkts);
|
|
|
|
|
|
|
|
ath10k_update_per_peer_tx_stats(ar, sta, p_tx_stats);
|
|
|
|
}
|
|
|
|
|
|
|
|
out:
|
|
|
|
spin_unlock_bh(&ar->data_lock);
|
|
|
|
rcu_read_unlock();
|
|
|
|
}
|
|
|
|
|
2017-12-05 21:31:25 +08:00
|
|
|
static void ath10k_fetch_10_2_tx_stats(struct ath10k *ar, u8 *data)
|
|
|
|
{
|
|
|
|
struct ath10k_pktlog_hdr *hdr = (struct ath10k_pktlog_hdr *)data;
|
|
|
|
struct ath10k_per_peer_tx_stats *p_tx_stats = &ar->peer_tx_stats;
|
|
|
|
struct ath10k_10_2_peer_tx_stats *tx_stats;
|
|
|
|
struct ieee80211_sta *sta;
|
|
|
|
struct ath10k_peer *peer;
|
|
|
|
u16 log_type = __le16_to_cpu(hdr->log_type);
|
|
|
|
u32 peer_id = 0, i;
|
|
|
|
|
|
|
|
if (log_type != ATH_PKTLOG_TYPE_TX_STAT)
|
|
|
|
return;
|
|
|
|
|
|
|
|
tx_stats = (struct ath10k_10_2_peer_tx_stats *)((hdr->payload) +
|
|
|
|
ATH10K_10_2_TX_STATS_OFFSET);
|
|
|
|
|
|
|
|
if (!tx_stats->tx_ppdu_cnt)
|
|
|
|
return;
|
|
|
|
|
|
|
|
peer_id = tx_stats->peer_id;
|
|
|
|
|
|
|
|
rcu_read_lock();
|
|
|
|
spin_lock_bh(&ar->data_lock);
|
|
|
|
peer = ath10k_peer_find_by_id(ar, peer_id);
|
|
|
|
if (!peer) {
|
|
|
|
ath10k_warn(ar, "Invalid peer id %d in peer stats buffer\n",
|
|
|
|
peer_id);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
sta = peer->sta;
|
|
|
|
for (i = 0; i < tx_stats->tx_ppdu_cnt; i++) {
|
|
|
|
p_tx_stats->succ_bytes =
|
|
|
|
__le16_to_cpu(tx_stats->success_bytes[i]);
|
|
|
|
p_tx_stats->retry_bytes =
|
|
|
|
__le16_to_cpu(tx_stats->retry_bytes[i]);
|
|
|
|
p_tx_stats->failed_bytes =
|
|
|
|
__le16_to_cpu(tx_stats->failed_bytes[i]);
|
|
|
|
p_tx_stats->ratecode = tx_stats->ratecode[i];
|
|
|
|
p_tx_stats->flags = tx_stats->flags[i];
|
|
|
|
p_tx_stats->succ_pkts = tx_stats->success_pkts[i];
|
|
|
|
p_tx_stats->retry_pkts = tx_stats->retry_pkts[i];
|
|
|
|
p_tx_stats->failed_pkts = tx_stats->failed_pkts[i];
|
|
|
|
|
|
|
|
ath10k_update_per_peer_tx_stats(ar, sta, p_tx_stats);
|
|
|
|
}
|
|
|
|
spin_unlock_bh(&ar->data_lock);
|
|
|
|
rcu_read_unlock();
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
out:
|
|
|
|
spin_unlock_bh(&ar->data_lock);
|
|
|
|
rcu_read_unlock();
|
|
|
|
}
|
|
|
|
|
2016-03-22 19:52:16 +08:00
|
|
|
bool ath10k_htt_t2h_msg_handler(struct ath10k *ar, struct sk_buff *skb)
|
2013-06-13 01:52:10 +08:00
|
|
|
{
|
2013-07-05 21:15:14 +08:00
|
|
|
struct ath10k_htt *htt = &ar->htt;
|
2013-06-13 01:52:10 +08:00
|
|
|
struct htt_resp *resp = (struct htt_resp *)skb->data;
|
2015-03-25 19:12:27 +08:00
|
|
|
enum htt_t2h_msg_type type;
|
2013-06-13 01:52:10 +08:00
|
|
|
|
|
|
|
/* confirm alignment */
|
|
|
|
if (!IS_ALIGNED((unsigned long)skb->data, 4))
|
2014-08-25 18:09:38 +08:00
|
|
|
ath10k_warn(ar, "unaligned htt message, expect trouble\n");
|
2013-06-13 01:52:10 +08:00
|
|
|
|
2014-08-25 18:09:38 +08:00
|
|
|
ath10k_dbg(ar, ATH10K_DBG_HTT, "htt rx, msg_type: 0x%0X\n",
|
2013-06-13 01:52:10 +08:00
|
|
|
resp->hdr.msg_type);
|
2015-03-25 19:12:27 +08:00
|
|
|
|
|
|
|
if (resp->hdr.msg_type >= ar->htt.t2h_msg_types_max) {
|
|
|
|
ath10k_dbg(ar, ATH10K_DBG_HTT, "htt rx, unsupported msg_type: 0x%0X\n max: 0x%0X",
|
|
|
|
resp->hdr.msg_type, ar->htt.t2h_msg_types_max);
|
2016-03-22 19:52:16 +08:00
|
|
|
return true;
|
2015-03-25 19:12:27 +08:00
|
|
|
}
|
|
|
|
type = ar->htt.t2h_msg_types[resp->hdr.msg_type];
|
|
|
|
|
|
|
|
switch (type) {
|
2013-06-13 01:52:10 +08:00
|
|
|
case HTT_T2H_MSG_TYPE_VERSION_CONF: {
|
|
|
|
htt->target_version_major = resp->ver_resp.major;
|
|
|
|
htt->target_version_minor = resp->ver_resp.minor;
|
|
|
|
complete(&htt->target_version_received);
|
|
|
|
break;
|
|
|
|
}
|
2014-02-28 00:50:04 +08:00
|
|
|
case HTT_T2H_MSG_TYPE_RX_IND:
|
2018-09-04 20:06:58 +08:00
|
|
|
if (ar->dev_type == ATH10K_DEV_TYPE_HL)
|
|
|
|
return ath10k_htt_rx_proc_rx_ind_hl(htt,
|
|
|
|
&resp->rx_ind_hl,
|
|
|
|
skb);
|
|
|
|
else
|
|
|
|
ath10k_htt_rx_proc_rx_ind_ll(htt, &resp->rx_ind);
|
2016-03-22 19:52:15 +08:00
|
|
|
break;
|
2013-06-13 01:52:10 +08:00
|
|
|
case HTT_T2H_MSG_TYPE_PEER_MAP: {
|
|
|
|
struct htt_peer_map_event ev = {
|
|
|
|
.vdev_id = resp->peer_map.vdev_id,
|
|
|
|
.peer_id = __le16_to_cpu(resp->peer_map.peer_id),
|
|
|
|
};
|
|
|
|
memcpy(ev.addr, resp->peer_map.addr, sizeof(ev.addr));
|
|
|
|
ath10k_peer_map_event(htt, &ev);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case HTT_T2H_MSG_TYPE_PEER_UNMAP: {
|
|
|
|
struct htt_peer_unmap_event ev = {
|
|
|
|
.peer_id = __le16_to_cpu(resp->peer_unmap.peer_id),
|
|
|
|
};
|
|
|
|
ath10k_peer_unmap_event(htt, &ev);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case HTT_T2H_MSG_TYPE_MGMT_TX_COMPLETION: {
|
|
|
|
struct htt_tx_done tx_done = {};
|
|
|
|
int status = __le32_to_cpu(resp->mgmt_tx_completion.status);
|
2018-04-10 23:01:05 +08:00
|
|
|
int info = __le32_to_cpu(resp->mgmt_tx_completion.info);
|
2013-06-13 01:52:10 +08:00
|
|
|
|
2016-03-22 19:52:11 +08:00
|
|
|
tx_done.msdu_id = __le32_to_cpu(resp->mgmt_tx_completion.desc_id);
|
2013-06-13 01:52:10 +08:00
|
|
|
|
|
|
|
switch (status) {
|
|
|
|
case HTT_MGMT_TX_STATUS_OK:
|
2016-03-22 19:52:11 +08:00
|
|
|
tx_done.status = HTT_TX_COMPL_STATE_ACK;
|
2018-04-10 23:01:05 +08:00
|
|
|
if (test_bit(WMI_SERVICE_HTT_MGMT_TX_COMP_VALID_FLAGS,
|
|
|
|
ar->wmi.svc_map) &&
|
|
|
|
(resp->mgmt_tx_completion.flags &
|
|
|
|
HTT_MGMT_TX_CMPL_FLAG_ACK_RSSI)) {
|
|
|
|
tx_done.ack_rssi =
|
|
|
|
FIELD_GET(HTT_MGMT_TX_CMPL_INFO_ACK_RSSI_MASK,
|
|
|
|
info);
|
|
|
|
}
|
2013-06-13 01:52:10 +08:00
|
|
|
break;
|
|
|
|
case HTT_MGMT_TX_STATUS_RETRY:
|
2016-03-22 19:52:11 +08:00
|
|
|
tx_done.status = HTT_TX_COMPL_STATE_NOACK;
|
2013-06-13 01:52:10 +08:00
|
|
|
break;
|
|
|
|
case HTT_MGMT_TX_STATUS_DROP:
|
2016-03-22 19:52:11 +08:00
|
|
|
tx_done.status = HTT_TX_COMPL_STATE_DISCARD;
|
2013-06-13 01:52:10 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-03-09 22:55:46 +08:00
|
|
|
status = ath10k_txrx_tx_unref(htt, &tx_done);
|
|
|
|
if (!status) {
|
|
|
|
spin_lock_bh(&htt->tx_lock);
|
|
|
|
ath10k_htt_tx_mgmt_dec_pending(htt);
|
|
|
|
spin_unlock_bh(&htt->tx_lock);
|
|
|
|
}
|
2013-06-13 01:52:10 +08:00
|
|
|
break;
|
|
|
|
}
|
2014-02-28 00:50:04 +08:00
|
|
|
case HTT_T2H_MSG_TYPE_TX_COMPL_IND:
|
2016-03-22 19:52:11 +08:00
|
|
|
ath10k_htt_rx_tx_compl_ind(htt->ar, skb);
|
|
|
|
break;
|
2013-06-13 01:52:10 +08:00
|
|
|
case HTT_T2H_MSG_TYPE_SEC_IND: {
|
|
|
|
struct ath10k *ar = htt->ar;
|
|
|
|
struct htt_security_indication *ev = &resp->security_indication;
|
|
|
|
|
2014-08-25 18:09:38 +08:00
|
|
|
ath10k_dbg(ar, ATH10K_DBG_HTT,
|
2013-06-13 01:52:10 +08:00
|
|
|
"sec ind peer_id %d unicast %d type %d\n",
|
|
|
|
__le16_to_cpu(ev->peer_id),
|
|
|
|
!!(ev->flags & HTT_SECURITY_IS_UNICAST),
|
|
|
|
MS(ev->flags, HTT_SECURITY_TYPE));
|
|
|
|
complete(&ar->install_key_done);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case HTT_T2H_MSG_TYPE_RX_FRAG_IND: {
|
2014-08-25 18:09:38 +08:00
|
|
|
ath10k_dbg_dump(ar, ATH10K_DBG_HTT_DUMP, NULL, "htt event: ",
|
2013-06-13 01:52:10 +08:00
|
|
|
skb->data, skb->len);
|
2016-09-03 00:46:09 +08:00
|
|
|
atomic_inc(&htt->num_mpdus_ready);
|
2013-06-13 01:52:10 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case HTT_T2H_MSG_TYPE_TEST:
|
|
|
|
break;
|
|
|
|
case HTT_T2H_MSG_TYPE_STATS_CONF:
|
2014-09-02 16:00:21 +08:00
|
|
|
trace_ath10k_htt_stats(ar, skb->data, skb->len);
|
2013-09-03 16:43:55 +08:00
|
|
|
break;
|
|
|
|
case HTT_T2H_MSG_TYPE_TX_INSPECT_IND:
|
2014-07-22 01:52:59 +08:00
|
|
|
/* Firmware can return tx frames if it's unable to fully
|
|
|
|
* process them and suspects host may be able to fix it. ath10k
|
|
|
|
* sends all tx frames as already inspected so this shouldn't
|
|
|
|
* happen unless fw has a bug.
|
|
|
|
*/
|
2014-08-25 18:09:38 +08:00
|
|
|
ath10k_warn(ar, "received an unexpected htt tx inspect event\n");
|
2014-07-22 01:52:59 +08:00
|
|
|
break;
|
2013-06-13 01:52:10 +08:00
|
|
|
case HTT_T2H_MSG_TYPE_RX_ADDBA:
|
2014-07-23 18:20:33 +08:00
|
|
|
ath10k_htt_rx_addba(ar, resp);
|
|
|
|
break;
|
2013-06-13 01:52:10 +08:00
|
|
|
case HTT_T2H_MSG_TYPE_RX_DELBA:
|
2014-07-23 18:20:33 +08:00
|
|
|
ath10k_htt_rx_delba(ar, resp);
|
|
|
|
break;
|
2014-10-03 13:02:40 +08:00
|
|
|
case HTT_T2H_MSG_TYPE_PKTLOG: {
|
|
|
|
trace_ath10k_htt_pktlog(ar, resp->pktlog_msg.payload,
|
2016-06-30 20:23:55 +08:00
|
|
|
skb->len -
|
|
|
|
offsetof(struct htt_resp,
|
|
|
|
pktlog_msg.payload));
|
2017-12-05 21:31:25 +08:00
|
|
|
|
|
|
|
if (ath10k_peer_stats_enabled(ar))
|
|
|
|
ath10k_fetch_10_2_tx_stats(ar,
|
|
|
|
resp->pktlog_msg.payload);
|
2014-10-03 13:02:40 +08:00
|
|
|
break;
|
|
|
|
}
|
2014-07-23 18:20:33 +08:00
|
|
|
case HTT_T2H_MSG_TYPE_RX_FLUSH: {
|
|
|
|
/* Ignore this event because mac80211 takes care of Rx
|
|
|
|
* aggregation reordering.
|
|
|
|
*/
|
|
|
|
break;
|
|
|
|
}
|
2015-01-24 18:14:48 +08:00
|
|
|
case HTT_T2H_MSG_TYPE_RX_IN_ORD_PADDR_IND: {
|
2018-06-21 20:25:48 +08:00
|
|
|
skb_queue_tail(&htt->rx_in_ord_compl_q, skb);
|
2016-03-22 19:52:16 +08:00
|
|
|
return false;
|
2015-01-24 18:14:48 +08:00
|
|
|
}
|
|
|
|
case HTT_T2H_MSG_TYPE_TX_CREDIT_UPDATE_IND:
|
2015-03-25 19:12:27 +08:00
|
|
|
break;
|
2016-03-09 01:27:23 +08:00
|
|
|
case HTT_T2H_MSG_TYPE_CHAN_CHANGE: {
|
|
|
|
u32 phymode = __le32_to_cpu(resp->chan_change.phymode);
|
|
|
|
u32 freq = __le32_to_cpu(resp->chan_change.freq);
|
|
|
|
|
2016-11-17 20:48:53 +08:00
|
|
|
ar->tgt_oper_chan = ieee80211_get_channel(ar->hw->wiphy, freq);
|
2016-03-09 01:27:23 +08:00
|
|
|
ath10k_dbg(ar, ATH10K_DBG_HTT,
|
|
|
|
"htt chan change freq %u phymode %s\n",
|
|
|
|
freq, ath10k_wmi_phymode_str(phymode));
|
2015-01-24 18:14:48 +08:00
|
|
|
break;
|
2016-03-09 01:27:23 +08:00
|
|
|
}
|
ath10k: enable raw encap mode and software crypto engine
This patch enables raw Rx/Tx encap mode to support software based
crypto engine. This patch introduces a new module param 'cryptmode'.
cryptmode:
0: Use hardware crypto engine globally with native Wi-Fi mode TX/RX
encapsulation to the firmware. This is the default mode.
1: Use sofware crypto engine globally with raw mode TX/RX
encapsulation to the firmware.
Known limitation:
A-MSDU must be disabled for RAW Tx encap mode to perform well when
heavy traffic is applied.
Testing: (by Michal Kazior <michal.kazior@tieto.com>)
a) Performance Testing
cryptmode=1
ap=qca988x sta=killer1525
killer1525 -> qca988x 194.496 mbps [tcp1 ip4]
killer1525 -> qca988x 238.309 mbps [tcp5 ip4]
killer1525 -> qca988x 266.958 mbps [udp1 ip4]
killer1525 -> qca988x 477.468 mbps [udp5 ip4]
qca988x -> killer1525 301.378 mbps [tcp1 ip4]
qca988x -> killer1525 297.949 mbps [tcp5 ip4]
qca988x -> killer1525 331.351 mbps [udp1 ip4]
qca988x -> killer1525 371.528 mbps [udp5 ip4]
ap=killer1525 sta=qca988x
qca988x -> killer1525 331.447 mbps [tcp1 ip4]
qca988x -> killer1525 328.783 mbps [tcp5 ip4]
qca988x -> killer1525 375.309 mbps [udp1 ip4]
qca988x -> killer1525 403.379 mbps [udp5 ip4]
killer1525 -> qca988x 203.689 mbps [tcp1 ip4]
killer1525 -> qca988x 222.339 mbps [tcp5 ip4]
killer1525 -> qca988x 264.199 mbps [udp1 ip4]
killer1525 -> qca988x 479.371 mbps [udp5 ip4]
Note:
- only open network tested for RAW vs nwifi performance comparison
- killer1525 (qca6174 hw2.2) is 2x2 device (hence max 866mbps)
- used iperf
- OTA, devices a few cm apart from each other, no shielding
- tcpX/udpX, X - means number of threads used
Overview:
- relative Tx performance drop is seen but is within reasonable and
expected threshold (A-MSDU must be disabled with RAW Tx)
b) Connectivity Testing
cryptmode=1
ap=iwl6205 sta1=qca988x crypto=open topology-1ap1sta OK
ap=iwl6205 sta1=qca988x crypto=wep1 topology-1ap1sta OK
ap=iwl6205 sta1=qca988x crypto=wpa topology-1ap1sta OK
ap=iwl6205 sta1=qca988x crypto=wpa-ccmp topology-1ap1sta OK
ap=qca988x sta1=iwl6205 crypto=open topology-1ap1sta OK
ap=qca988x sta1=iwl6205 crypto=wep1 topology-1ap1sta OK
ap=qca988x sta1=iwl6205 crypto=wpa topology-1ap1sta OK
ap=qca988x sta1=iwl6205 crypto=wpa-ccmp topology-1ap1sta OK
ap=iwl6205 sta1=qca988x crypto=open topology-1ap1sta2br OK
ap=iwl6205 sta1=qca988x crypto=wep1 topology-1ap1sta2br OK
ap=iwl6205 sta1=qca988x crypto=wpa topology-1ap1sta2br OK
ap=iwl6205 sta1=qca988x crypto=wpa-ccmp topology-1ap1sta2br OK
ap=qca988x sta1=iwl6205 crypto=open topology-1ap1sta2br OK
ap=qca988x sta1=iwl6205 crypto=wep1 topology-1ap1sta2br OK
ap=qca988x sta1=iwl6205 crypto=wpa topology-1ap1sta2br OK
ap=qca988x sta1=iwl6205 crypto=wpa-ccmp topology-1ap1sta2br OK
ap=iwl6205 sta1=qca988x crypto=open topology-1ap1sta2br1vlan OK
ap=iwl6205 sta1=qca988x crypto=wep1 topology-1ap1sta2br1vlan OK
ap=iwl6205 sta1=qca988x crypto=wpa topology-1ap1sta2br1vlan OK
ap=iwl6205 sta1=qca988x crypto=wpa-ccmp topology-1ap1sta2br1vlan OK
ap=qca988x sta1=iwl6205 crypto=open topology-1ap1sta2br1vlan OK
ap=qca988x sta1=iwl6205 crypto=wep1 topology-1ap1sta2br1vlan OK
ap=qca988x sta1=iwl6205 crypto=wpa topology-1ap1sta2br1vlan OK
ap=qca988x sta1=iwl6205 crypto=wpa-ccmp topology-1ap1sta2br1vlan OK
Note:
- each test takes all possible endpoint pairs and pings
- each pair-ping flushes arp table
- ip6 is used
c) Testbed Topology:
1ap1sta:
[ap] ---- [sta]
endpoints: ap, sta
1ap1sta2br:
[veth0] [ap] ---- [sta] [veth2]
| | | |
[veth1] | \ [veth3]
\ / \ /
[br0] [br1]
endpoints: veth0, veth2, br0, br1
note: STA works in 4addr mode, AP has wds_sta=1
1ap1sta2br1vlan:
[veth0] [ap] ---- [sta] [veth2]
| | | |
[veth1] | \ [veth3]
\ / \ /
[br0] [br1]
| |
[vlan0_id2] [vlan1_id2]
endpoints: vlan0_id2, vlan1_id2
note: STA works in 4addr mode, AP has wds_sta=1
Credits:
Thanks to Michal Kazior <michal.kazior@tieto.com> who helped find the
amsdu issue, contributed a workaround (already squashed into this
patch), and contributed the throughput and connectivity tests results.
Signed-off-by: David Liu <cfliu.tw@gmail.com>
Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
Tested-by: Michal Kazior <michal.kazior@tieto.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
2015-07-25 01:25:32 +08:00
|
|
|
case HTT_T2H_MSG_TYPE_AGGR_CONF:
|
|
|
|
break;
|
2016-03-22 19:52:12 +08:00
|
|
|
case HTT_T2H_MSG_TYPE_TX_FETCH_IND: {
|
|
|
|
struct sk_buff *tx_fetch_ind = skb_copy(skb, GFP_ATOMIC);
|
|
|
|
|
|
|
|
if (!tx_fetch_ind) {
|
|
|
|
ath10k_warn(ar, "failed to copy htt tx fetch ind\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
skb_queue_tail(&htt->tx_fetch_ind_q, tx_fetch_ind);
|
|
|
|
break;
|
|
|
|
}
|
2016-01-21 21:13:23 +08:00
|
|
|
case HTT_T2H_MSG_TYPE_TX_FETCH_CONFIRM:
|
2016-03-06 22:14:32 +08:00
|
|
|
ath10k_htt_rx_tx_fetch_confirm(ar, skb);
|
|
|
|
break;
|
2016-01-21 21:13:23 +08:00
|
|
|
case HTT_T2H_MSG_TYPE_TX_MODE_SWITCH_IND:
|
2016-03-06 22:14:32 +08:00
|
|
|
ath10k_htt_rx_tx_mode_switch_ind(ar, skb);
|
2016-01-21 21:13:27 +08:00
|
|
|
break;
|
2016-11-23 22:58:10 +08:00
|
|
|
case HTT_T2H_MSG_TYPE_PEER_STATS:
|
|
|
|
ath10k_htt_fetch_peer_stats(ar, skb);
|
|
|
|
break;
|
2016-01-21 21:13:27 +08:00
|
|
|
case HTT_T2H_MSG_TYPE_EN_STATS:
|
2013-06-13 01:52:10 +08:00
|
|
|
default:
|
2014-10-02 19:32:55 +08:00
|
|
|
ath10k_warn(ar, "htt event (%d) not handled\n",
|
|
|
|
resp->hdr.msg_type);
|
2014-08-25 18:09:38 +08:00
|
|
|
ath10k_dbg_dump(ar, ATH10K_DBG_HTT_DUMP, NULL, "htt event: ",
|
2013-06-13 01:52:10 +08:00
|
|
|
skb->data, skb->len);
|
|
|
|
break;
|
2017-02-03 01:53:42 +08:00
|
|
|
}
|
2016-03-22 19:52:16 +08:00
|
|
|
return true;
|
2013-06-13 01:52:10 +08:00
|
|
|
}
|
2015-10-12 20:57:03 +08:00
|
|
|
EXPORT_SYMBOL(ath10k_htt_t2h_msg_handler);
|
2014-02-28 00:50:04 +08:00
|
|
|
|
2015-10-30 17:27:58 +08:00
|
|
|
void ath10k_htt_rx_pktlog_completion_handler(struct ath10k *ar,
|
|
|
|
struct sk_buff *skb)
|
|
|
|
{
|
2016-02-05 23:42:48 +08:00
|
|
|
trace_ath10k_htt_pktlog(ar, skb->data, skb->len);
|
2015-10-30 17:27:58 +08:00
|
|
|
dev_kfree_skb_any(skb);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(ath10k_htt_rx_pktlog_completion_handler);
|
|
|
|
|
2017-12-07 22:58:05 +08:00
|
|
|
static int ath10k_htt_rx_deliver_msdu(struct ath10k *ar, int quota, int budget)
|
|
|
|
{
|
|
|
|
struct sk_buff *skb;
|
|
|
|
|
|
|
|
while (quota < budget) {
|
|
|
|
if (skb_queue_empty(&ar->htt.rx_msdus_q))
|
|
|
|
break;
|
|
|
|
|
2018-06-21 20:25:48 +08:00
|
|
|
skb = skb_dequeue(&ar->htt.rx_msdus_q);
|
2017-12-07 22:58:05 +08:00
|
|
|
if (!skb)
|
|
|
|
break;
|
|
|
|
ath10k_process_rx(ar, skb);
|
|
|
|
quota++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return quota;
|
|
|
|
}
|
|
|
|
|
2016-09-03 00:46:09 +08:00
|
|
|
int ath10k_htt_txrx_compl_task(struct ath10k *ar, int budget)
|
2014-02-28 00:50:04 +08:00
|
|
|
{
|
2016-09-03 00:46:09 +08:00
|
|
|
struct ath10k_htt *htt = &ar->htt;
|
2016-03-22 19:52:11 +08:00
|
|
|
struct htt_tx_done tx_done = {};
|
2016-03-06 22:14:43 +08:00
|
|
|
struct sk_buff_head tx_ind_q;
|
2014-02-28 00:50:04 +08:00
|
|
|
struct sk_buff *skb;
|
2016-01-13 21:52:52 +08:00
|
|
|
unsigned long flags;
|
2017-12-07 22:58:05 +08:00
|
|
|
int quota = 0, done, ret;
|
2016-09-03 00:46:09 +08:00
|
|
|
bool resched_napi = false;
|
2014-02-28 00:50:04 +08:00
|
|
|
|
2016-03-06 22:14:43 +08:00
|
|
|
__skb_queue_head_init(&tx_ind_q);
|
2016-02-12 14:10:59 +08:00
|
|
|
|
2017-12-07 22:58:05 +08:00
|
|
|
/* Process pending frames before dequeuing more data
|
|
|
|
* from hardware.
|
2016-09-03 00:46:09 +08:00
|
|
|
*/
|
2017-12-07 22:58:05 +08:00
|
|
|
quota = ath10k_htt_rx_deliver_msdu(ar, quota, budget);
|
|
|
|
if (quota == budget) {
|
|
|
|
resched_napi = true;
|
|
|
|
goto exit;
|
|
|
|
}
|
2016-09-03 00:46:09 +08:00
|
|
|
|
2018-06-21 20:25:48 +08:00
|
|
|
while ((skb = skb_dequeue(&htt->rx_in_ord_compl_q))) {
|
2016-09-03 00:46:09 +08:00
|
|
|
spin_lock_bh(&htt->rx_ring.lock);
|
2017-12-07 22:58:05 +08:00
|
|
|
ret = ath10k_htt_rx_in_ord_ind(ar, skb);
|
2016-09-03 00:46:09 +08:00
|
|
|
spin_unlock_bh(&htt->rx_ring.lock);
|
|
|
|
|
|
|
|
dev_kfree_skb_any(skb);
|
2017-12-07 22:58:05 +08:00
|
|
|
if (ret == -EIO) {
|
2016-09-03 00:46:09 +08:00
|
|
|
resched_napi = true;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-07 22:58:05 +08:00
|
|
|
while (atomic_read(&htt->num_mpdus_ready)) {
|
|
|
|
ret = ath10k_htt_rx_handle_amsdu(htt);
|
|
|
|
if (ret == -EIO) {
|
2016-09-03 00:46:09 +08:00
|
|
|
resched_napi = true;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
atomic_dec(&htt->num_mpdus_ready);
|
|
|
|
}
|
|
|
|
|
2017-12-07 22:58:05 +08:00
|
|
|
/* Deliver received data after processing data from hardware */
|
|
|
|
quota = ath10k_htt_rx_deliver_msdu(ar, quota, budget);
|
|
|
|
|
2016-09-03 00:46:09 +08:00
|
|
|
/* From NAPI documentation:
|
|
|
|
* The napi poll() function may also process TX completions, in which
|
|
|
|
* case if it processes the entire TX ring then it should count that
|
|
|
|
* work as the rest of the budget.
|
|
|
|
*/
|
|
|
|
if ((quota < budget) && !kfifo_is_empty(&htt->txdone_fifo))
|
|
|
|
quota = budget;
|
2016-03-06 22:14:43 +08:00
|
|
|
|
2016-03-22 19:52:11 +08:00
|
|
|
/* kfifo_get: called only within txrx_tasklet so it's neatly serialized.
|
|
|
|
* From kfifo_get() documentation:
|
|
|
|
* Note that with only one concurrent reader and one concurrent writer,
|
|
|
|
* you don't need extra locking to use these macro.
|
|
|
|
*/
|
|
|
|
while (kfifo_get(&htt->txdone_fifo, &tx_done))
|
|
|
|
ath10k_txrx_tx_unref(htt, &tx_done);
|
2014-02-28 00:50:04 +08:00
|
|
|
|
2016-09-03 00:46:10 +08:00
|
|
|
ath10k_mac_tx_push_pending(ar);
|
|
|
|
|
2016-09-03 00:46:09 +08:00
|
|
|
spin_lock_irqsave(&htt->tx_fetch_ind_q.lock, flags);
|
|
|
|
skb_queue_splice_init(&htt->tx_fetch_ind_q, &tx_ind_q);
|
|
|
|
spin_unlock_irqrestore(&htt->tx_fetch_ind_q.lock, flags);
|
|
|
|
|
2016-03-06 22:14:43 +08:00
|
|
|
while ((skb = __skb_dequeue(&tx_ind_q))) {
|
|
|
|
ath10k_htt_rx_tx_fetch_ind(ar, skb);
|
2014-02-28 00:50:04 +08:00
|
|
|
dev_kfree_skb_any(skb);
|
|
|
|
}
|
|
|
|
|
2016-09-03 00:46:09 +08:00
|
|
|
exit:
|
2016-03-22 19:52:19 +08:00
|
|
|
ath10k_htt_rx_msdu_buff_replenish(htt);
|
2016-09-03 00:46:09 +08:00
|
|
|
/* In case of rx failure or more data to read, report budget
|
|
|
|
* to reschedule NAPI poll
|
|
|
|
*/
|
|
|
|
done = resched_napi ? budget : quota;
|
|
|
|
|
|
|
|
return done;
|
2014-02-28 00:50:04 +08:00
|
|
|
}
|
2016-09-03 00:46:09 +08:00
|
|
|
EXPORT_SYMBOL(ath10k_htt_txrx_compl_task);
|
2017-12-21 17:00:57 +08:00
|
|
|
|
|
|
|
static const struct ath10k_htt_rx_ops htt_rx_ops_32 = {
|
|
|
|
.htt_get_rx_ring_size = ath10k_htt_get_rx_ring_size_32,
|
|
|
|
.htt_config_paddrs_ring = ath10k_htt_config_paddrs_ring_32,
|
|
|
|
.htt_set_paddrs_ring = ath10k_htt_set_paddrs_ring_32,
|
|
|
|
.htt_get_vaddr_ring = ath10k_htt_get_vaddr_ring_32,
|
|
|
|
.htt_reset_paddrs_ring = ath10k_htt_reset_paddrs_ring_32,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct ath10k_htt_rx_ops htt_rx_ops_64 = {
|
|
|
|
.htt_get_rx_ring_size = ath10k_htt_get_rx_ring_size_64,
|
|
|
|
.htt_config_paddrs_ring = ath10k_htt_config_paddrs_ring_64,
|
|
|
|
.htt_set_paddrs_ring = ath10k_htt_set_paddrs_ring_64,
|
|
|
|
.htt_get_vaddr_ring = ath10k_htt_get_vaddr_ring_64,
|
|
|
|
.htt_reset_paddrs_ring = ath10k_htt_reset_paddrs_ring_64,
|
|
|
|
};
|
|
|
|
|
2018-09-04 20:05:57 +08:00
|
|
|
static const struct ath10k_htt_rx_ops htt_rx_ops_hl = {
|
|
|
|
};
|
|
|
|
|
2017-12-21 17:00:57 +08:00
|
|
|
void ath10k_htt_set_rx_ops(struct ath10k_htt *htt)
|
|
|
|
{
|
|
|
|
struct ath10k *ar = htt->ar;
|
|
|
|
|
2018-09-04 20:05:57 +08:00
|
|
|
if (ar->dev_type == ATH10K_DEV_TYPE_HL)
|
|
|
|
htt->rx_ops = &htt_rx_ops_hl;
|
|
|
|
else if (ar->hw_params.target_64bit)
|
2017-12-21 17:00:57 +08:00
|
|
|
htt->rx_ops = &htt_rx_ops_64;
|
|
|
|
else
|
|
|
|
htt->rx_ops = &htt_rx_ops_32;
|
|
|
|
}
|