2019-07-24 08:58:20 +00:00
|
|
|
/* SPDX-License-Identifier: ISC */
|
2017-11-21 09:50:52 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2016 Felix Fietkau <nbd@nbd.name>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __MT76_H
|
|
|
|
#define __MT76_H
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/io.h>
|
|
|
|
#include <linux/spinlock.h>
|
|
|
|
#include <linux/skbuff.h>
|
|
|
|
#include <linux/leds.h>
|
2018-07-31 08:09:19 +00:00
|
|
|
#include <linux/usb.h>
|
2018-12-05 16:06:58 +00:00
|
|
|
#include <linux/average.h>
|
2017-11-21 09:50:52 +00:00
|
|
|
#include <net/mac80211.h>
|
|
|
|
#include "util.h"
|
2020-06-18 19:12:24 +00:00
|
|
|
#include "testmode.h"
|
2017-11-21 09:50:52 +00:00
|
|
|
|
|
|
|
#define MT_MCU_RING_SIZE 32
|
|
|
|
#define MT_RX_BUF_SIZE 2048
|
2019-06-15 14:03:32 +00:00
|
|
|
#define MT_SKB_HEAD_LEN 128
|
2017-11-21 09:50:52 +00:00
|
|
|
|
2020-08-23 19:22:20 +00:00
|
|
|
#define MT_MAX_NON_AQL_PKT 16
|
|
|
|
#define MT_TXQ_FREE_THR 32
|
|
|
|
|
2017-11-21 09:50:52 +00:00
|
|
|
struct mt76_dev;
|
2019-10-12 17:46:40 +00:00
|
|
|
struct mt76_phy;
|
2018-07-31 08:09:11 +00:00
|
|
|
struct mt76_wcid;
|
2017-11-21 09:50:52 +00:00
|
|
|
|
2018-09-09 20:32:39 +00:00
|
|
|
struct mt76_reg_pair {
|
|
|
|
u32 reg;
|
|
|
|
u32 value;
|
|
|
|
};
|
|
|
|
|
2018-10-04 10:04:53 +00:00
|
|
|
enum mt76_bus_type {
|
|
|
|
MT76_BUS_MMIO,
|
|
|
|
MT76_BUS_USB,
|
2020-07-15 12:46:30 +00:00
|
|
|
MT76_BUS_SDIO,
|
2018-10-04 10:04:53 +00:00
|
|
|
};
|
|
|
|
|
2017-11-21 09:50:52 +00:00
|
|
|
struct mt76_bus_ops {
|
|
|
|
u32 (*rr)(struct mt76_dev *dev, u32 offset);
|
|
|
|
void (*wr)(struct mt76_dev *dev, u32 offset, u32 val);
|
|
|
|
u32 (*rmw)(struct mt76_dev *dev, u32 offset, u32 mask, u32 val);
|
2019-07-13 15:09:06 +00:00
|
|
|
void (*write_copy)(struct mt76_dev *dev, u32 offset, const void *data,
|
|
|
|
int len);
|
|
|
|
void (*read_copy)(struct mt76_dev *dev, u32 offset, void *data,
|
|
|
|
int len);
|
2018-09-09 20:32:39 +00:00
|
|
|
int (*wr_rp)(struct mt76_dev *dev, u32 base,
|
|
|
|
const struct mt76_reg_pair *rp, int len);
|
|
|
|
int (*rd_rp)(struct mt76_dev *dev, u32 base,
|
|
|
|
struct mt76_reg_pair *rp, int len);
|
2018-10-04 10:04:53 +00:00
|
|
|
enum mt76_bus_type type;
|
2017-11-21 09:50:52 +00:00
|
|
|
};
|
|
|
|
|
2019-10-29 13:34:44 +00:00
|
|
|
#define mt76_is_usb(dev) ((dev)->bus->type == MT76_BUS_USB)
|
|
|
|
#define mt76_is_mmio(dev) ((dev)->bus->type == MT76_BUS_MMIO)
|
2020-07-15 12:46:30 +00:00
|
|
|
#define mt76_is_sdio(dev) ((dev)->bus->type == MT76_BUS_SDIO)
|
2018-10-04 10:04:53 +00:00
|
|
|
|
2017-11-21 09:50:52 +00:00
|
|
|
enum mt76_txq_id {
|
|
|
|
MT_TXQ_VO = IEEE80211_AC_VO,
|
|
|
|
MT_TXQ_VI = IEEE80211_AC_VI,
|
|
|
|
MT_TXQ_BE = IEEE80211_AC_BE,
|
|
|
|
MT_TXQ_BK = IEEE80211_AC_BK,
|
|
|
|
MT_TXQ_PSD,
|
|
|
|
MT_TXQ_BEACON,
|
|
|
|
MT_TXQ_CAB,
|
|
|
|
__MT_TXQ_MAX
|
|
|
|
};
|
|
|
|
|
2020-11-11 13:47:29 +00:00
|
|
|
enum mt76_mcuq_id {
|
2020-11-11 13:47:31 +00:00
|
|
|
MT_MCUQ_WM,
|
|
|
|
MT_MCUQ_WA,
|
|
|
|
MT_MCUQ_FWDL,
|
2020-11-11 13:47:29 +00:00
|
|
|
__MT_MCUQ_MAX
|
|
|
|
};
|
|
|
|
|
2017-11-21 09:50:52 +00:00
|
|
|
enum mt76_rxq_id {
|
|
|
|
MT_RXQ_MAIN,
|
|
|
|
MT_RXQ_MCU,
|
2020-04-24 19:32:26 +00:00
|
|
|
MT_RXQ_MCU_WA,
|
2020-11-13 10:11:31 +00:00
|
|
|
MT_RXQ_EXT,
|
2017-11-21 09:50:52 +00:00
|
|
|
__MT_RXQ_MAX
|
|
|
|
};
|
|
|
|
|
|
|
|
struct mt76_queue_buf {
|
|
|
|
dma_addr_t addr;
|
2020-07-25 12:44:07 +00:00
|
|
|
u16 len;
|
|
|
|
bool skip_unmap;
|
2017-11-21 09:50:52 +00:00
|
|
|
};
|
|
|
|
|
2019-03-14 13:54:12 +00:00
|
|
|
struct mt76_tx_info {
|
|
|
|
struct mt76_queue_buf buf[32];
|
2019-04-02 09:47:57 +00:00
|
|
|
struct sk_buff *skb;
|
2019-03-14 13:54:12 +00:00
|
|
|
int nbuf;
|
|
|
|
u32 info;
|
|
|
|
};
|
|
|
|
|
2017-11-21 09:50:52 +00:00
|
|
|
struct mt76_queue_entry {
|
|
|
|
union {
|
|
|
|
void *buf;
|
|
|
|
struct sk_buff *skb;
|
|
|
|
};
|
2018-07-31 08:09:19 +00:00
|
|
|
union {
|
|
|
|
struct mt76_txwi_cache *txwi;
|
2019-03-21 15:25:32 +00:00
|
|
|
struct urb *urb;
|
2020-07-15 12:46:30 +00:00
|
|
|
int buf_sz;
|
2018-07-31 08:09:19 +00:00
|
|
|
};
|
2020-08-27 05:58:32 +00:00
|
|
|
u32 dma_addr[2];
|
|
|
|
u16 dma_len[2];
|
2020-08-23 19:22:20 +00:00
|
|
|
u16 wcid;
|
2019-10-27 19:53:09 +00:00
|
|
|
bool skip_buf0:1;
|
2020-07-25 12:44:07 +00:00
|
|
|
bool skip_buf1:1;
|
2019-10-27 19:53:09 +00:00
|
|
|
bool done:1;
|
2017-11-21 09:50:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct mt76_queue_regs {
|
|
|
|
u32 desc_base;
|
|
|
|
u32 ring_size;
|
|
|
|
u32 cpu_idx;
|
|
|
|
u32 dma_idx;
|
|
|
|
} __packed __aligned(4);
|
|
|
|
|
|
|
|
struct mt76_queue {
|
|
|
|
struct mt76_queue_regs __iomem *regs;
|
|
|
|
|
|
|
|
spinlock_t lock;
|
2020-11-21 17:23:35 +00:00
|
|
|
spinlock_t cleanup_lock;
|
2017-11-21 09:50:52 +00:00
|
|
|
struct mt76_queue_entry *entry;
|
|
|
|
struct mt76_desc *desc;
|
|
|
|
|
2018-07-31 08:09:19 +00:00
|
|
|
u16 first;
|
2017-11-21 09:50:52 +00:00
|
|
|
u16 head;
|
|
|
|
u16 tail;
|
|
|
|
int ndesc;
|
|
|
|
int queued;
|
|
|
|
int buf_size;
|
2019-02-28 13:31:31 +00:00
|
|
|
bool stopped;
|
2020-11-21 13:00:47 +00:00
|
|
|
bool blocked;
|
2017-11-21 09:50:52 +00:00
|
|
|
|
|
|
|
u8 buf_offset;
|
|
|
|
u8 hw_idx;
|
2020-11-11 13:47:23 +00:00
|
|
|
u8 qid;
|
2017-11-21 09:50:52 +00:00
|
|
|
|
|
|
|
dma_addr_t desc_dma;
|
|
|
|
struct sk_buff *rx_head;
|
2018-07-13 14:26:15 +00:00
|
|
|
struct page_frag_cache rx_page;
|
2017-11-21 09:50:52 +00:00
|
|
|
};
|
|
|
|
|
2018-09-09 20:32:37 +00:00
|
|
|
struct mt76_mcu_ops {
|
2020-04-02 18:18:48 +00:00
|
|
|
u32 headroom;
|
|
|
|
u32 tailroom;
|
|
|
|
|
2018-10-26 12:00:26 +00:00
|
|
|
int (*mcu_send_msg)(struct mt76_dev *dev, int cmd, const void *data,
|
|
|
|
int len, bool wait_resp);
|
2020-03-17 16:41:13 +00:00
|
|
|
int (*mcu_skb_send_msg)(struct mt76_dev *dev, struct sk_buff *skb,
|
2020-09-30 02:35:11 +00:00
|
|
|
int cmd, int *seq);
|
2020-09-30 01:53:59 +00:00
|
|
|
int (*mcu_parse_response)(struct mt76_dev *dev, int cmd,
|
|
|
|
struct sk_buff *skb, int seq);
|
2020-07-15 12:46:30 +00:00
|
|
|
u32 (*mcu_rr)(struct mt76_dev *dev, u32 offset);
|
|
|
|
void (*mcu_wr)(struct mt76_dev *dev, u32 offset, u32 val);
|
2018-09-09 20:32:39 +00:00
|
|
|
int (*mcu_wr_rp)(struct mt76_dev *dev, u32 base,
|
|
|
|
const struct mt76_reg_pair *rp, int len);
|
|
|
|
int (*mcu_rd_rp)(struct mt76_dev *dev, u32 base,
|
|
|
|
struct mt76_reg_pair *rp, int len);
|
2019-02-27 18:42:39 +00:00
|
|
|
int (*mcu_restart)(struct mt76_dev *dev);
|
2018-09-09 20:32:37 +00:00
|
|
|
};
|
|
|
|
|
2017-11-21 09:50:52 +00:00
|
|
|
struct mt76_queue_ops {
|
|
|
|
int (*init)(struct mt76_dev *dev);
|
|
|
|
|
2019-02-28 16:54:32 +00:00
|
|
|
int (*alloc)(struct mt76_dev *dev, struct mt76_queue *q,
|
|
|
|
int idx, int n_desc, int bufsize,
|
|
|
|
u32 ring_base);
|
2017-11-21 09:50:52 +00:00
|
|
|
|
2020-11-11 13:47:28 +00:00
|
|
|
int (*tx_queue_skb)(struct mt76_dev *dev, struct mt76_queue *q,
|
2018-07-31 08:09:11 +00:00
|
|
|
struct sk_buff *skb, struct mt76_wcid *wcid,
|
|
|
|
struct ieee80211_sta *sta);
|
|
|
|
|
2020-11-11 13:47:30 +00:00
|
|
|
int (*tx_queue_skb_raw)(struct mt76_dev *dev, struct mt76_queue *q,
|
2019-02-07 10:10:57 +00:00
|
|
|
struct sk_buff *skb, u32 tx_info);
|
|
|
|
|
2017-11-21 09:50:52 +00:00
|
|
|
void *(*dequeue)(struct mt76_dev *dev, struct mt76_queue *q, bool flush,
|
|
|
|
int *len, u32 *info, bool *more);
|
|
|
|
|
|
|
|
void (*rx_reset)(struct mt76_dev *dev, enum mt76_rxq_id qid);
|
|
|
|
|
2020-11-11 13:47:27 +00:00
|
|
|
void (*tx_cleanup)(struct mt76_dev *dev, struct mt76_queue *q,
|
2017-11-21 09:50:52 +00:00
|
|
|
bool flush);
|
|
|
|
|
|
|
|
void (*kick)(struct mt76_dev *dev, struct mt76_queue *q);
|
|
|
|
};
|
|
|
|
|
2018-01-27 15:02:03 +00:00
|
|
|
enum mt76_wcid_flags {
|
|
|
|
MT_WCID_FLAG_CHECK_PS,
|
|
|
|
MT_WCID_FLAG_PS,
|
2020-08-21 06:42:46 +00:00
|
|
|
MT_WCID_FLAG_4ADDR,
|
2018-01-27 15:02:03 +00:00
|
|
|
};
|
|
|
|
|
2020-04-24 19:32:25 +00:00
|
|
|
#define MT76_N_WCIDS 288
|
2018-09-04 14:40:54 +00:00
|
|
|
|
2019-10-11 20:57:08 +00:00
|
|
|
/* stored in ieee80211_tx_info::hw_queue */
|
|
|
|
#define MT_TX_HW_QUEUE_EXT_PHY BIT(3)
|
|
|
|
|
2018-12-05 16:06:58 +00:00
|
|
|
DECLARE_EWMA(signal, 10, 8);
|
|
|
|
|
2019-03-13 13:20:06 +00:00
|
|
|
#define MT_WCID_TX_INFO_RATE GENMASK(15, 0)
|
|
|
|
#define MT_WCID_TX_INFO_NSS GENMASK(17, 16)
|
|
|
|
#define MT_WCID_TX_INFO_TXPWR_ADJ GENMASK(25, 18)
|
|
|
|
#define MT_WCID_TX_INFO_SET BIT(31)
|
|
|
|
|
2017-11-21 09:50:52 +00:00
|
|
|
struct mt76_wcid {
|
2018-01-24 15:19:14 +00:00
|
|
|
struct mt76_rx_tid __rcu *aggr[IEEE80211_NUM_TIDS];
|
|
|
|
|
2020-08-23 19:22:20 +00:00
|
|
|
atomic_t non_aql_packets;
|
2018-01-27 15:02:03 +00:00
|
|
|
unsigned long flags;
|
|
|
|
|
2018-12-05 16:06:58 +00:00
|
|
|
struct ewma_signal rssi;
|
|
|
|
int inactive_count;
|
|
|
|
|
2020-04-24 19:32:25 +00:00
|
|
|
u16 idx;
|
2017-11-21 09:50:52 +00:00
|
|
|
u8 hw_key_idx;
|
|
|
|
|
2018-01-24 15:19:13 +00:00
|
|
|
u8 sta:1;
|
2019-11-04 14:16:59 +00:00
|
|
|
u8 ext_phy:1;
|
2020-08-11 07:59:57 +00:00
|
|
|
u8 amsdu:1;
|
2018-01-24 15:19:13 +00:00
|
|
|
|
2018-01-25 10:44:24 +00:00
|
|
|
u8 rx_check_pn;
|
|
|
|
u8 rx_key_pn[IEEE80211_NUM_TIDS][6];
|
2019-08-20 14:56:25 +00:00
|
|
|
u16 cipher;
|
2018-01-25 10:44:24 +00:00
|
|
|
|
2019-03-13 13:20:06 +00:00
|
|
|
u32 tx_info;
|
2018-01-18 18:01:43 +00:00
|
|
|
bool sw_iv;
|
2018-10-25 14:11:34 +00:00
|
|
|
|
|
|
|
u8 packet_id;
|
2017-11-21 09:50:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct mt76_txq {
|
|
|
|
struct mt76_wcid *wcid;
|
|
|
|
|
|
|
|
u16 agg_ssn;
|
|
|
|
bool send_bar;
|
|
|
|
bool aggr;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct mt76_txwi_cache {
|
|
|
|
struct list_head list;
|
2019-04-02 09:47:56 +00:00
|
|
|
dma_addr_t dma_addr;
|
2019-04-02 09:47:58 +00:00
|
|
|
|
|
|
|
struct sk_buff *skb;
|
2017-11-21 09:50:52 +00:00
|
|
|
};
|
|
|
|
|
2018-01-24 15:19:14 +00:00
|
|
|
struct mt76_rx_tid {
|
|
|
|
struct rcu_head rcu_head;
|
|
|
|
|
|
|
|
struct mt76_dev *dev;
|
|
|
|
|
|
|
|
spinlock_t lock;
|
|
|
|
struct delayed_work reorder_work;
|
|
|
|
|
|
|
|
u16 head;
|
2020-04-24 19:32:22 +00:00
|
|
|
u16 size;
|
|
|
|
u16 nframes;
|
2018-01-24 15:19:14 +00:00
|
|
|
|
2019-12-14 09:58:59 +00:00
|
|
|
u8 num;
|
|
|
|
|
2018-01-24 15:19:14 +00:00
|
|
|
u8 started:1, stopped:1, timer_pending:1;
|
|
|
|
|
|
|
|
struct sk_buff *reorder_buf[];
|
|
|
|
};
|
|
|
|
|
2018-10-25 14:11:34 +00:00
|
|
|
#define MT_TX_CB_DMA_DONE BIT(0)
|
|
|
|
#define MT_TX_CB_TXS_DONE BIT(1)
|
|
|
|
#define MT_TX_CB_TXS_FAILED BIT(2)
|
|
|
|
|
mt76: mt76x02: fix tx status reporting issues
When the hardware falls back to lower rates for a transmit attempt, only the
first status report will show the number of retries correctly. The frames
that follow will report the correct final rate, but number of retries set to 0.
This can cause the rate control module to vastly underestimate the number of
retransmissions per rate.
To fix this, we need to keep track of the initial requested tx rate per packet
and pass it to the status information.
For frames with tx status requested, this is simple: use the rate configured
in info->control.rates[0] as reference.
For no-skb tx status information, we have to encode the requested tx rate in
the packet id (and make it possible to distinguish it from real packet ids).
To do that, reduce the packet id field size by one bit, and use that bit to
indicate packet id vs rate.
This change also improves reporting by filling the status rate array with
rates from first rate to final rate, taking the same steps as the hardware
fallback table. This matters in corner cases like MCS8 on HT, where the
fallback target is MCS0, not MCS7.
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2019-06-05 18:50:52 +00:00
|
|
|
#define MT_PACKET_ID_MASK GENMASK(6, 0)
|
2019-01-11 12:37:43 +00:00
|
|
|
#define MT_PACKET_ID_NO_ACK 0
|
|
|
|
#define MT_PACKET_ID_NO_SKB 1
|
|
|
|
#define MT_PACKET_ID_FIRST 2
|
mt76: mt76x02: fix tx status reporting issues
When the hardware falls back to lower rates for a transmit attempt, only the
first status report will show the number of retries correctly. The frames
that follow will report the correct final rate, but number of retries set to 0.
This can cause the rate control module to vastly underestimate the number of
retransmissions per rate.
To fix this, we need to keep track of the initial requested tx rate per packet
and pass it to the status information.
For frames with tx status requested, this is simple: use the rate configured
in info->control.rates[0] as reference.
For no-skb tx status information, we have to encode the requested tx rate in
the packet id (and make it possible to distinguish it from real packet ids).
To do that, reduce the packet id field size by one bit, and use that bit to
indicate packet id vs rate.
This change also improves reporting by filling the status rate array with
rates from first rate to final rate, taking the same steps as the hardware
fallback table. This matters in corner cases like MCS8 on HT, where the
fallback target is MCS0, not MCS7.
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2019-06-05 18:50:52 +00:00
|
|
|
#define MT_PACKET_ID_HAS_RATE BIT(7)
|
2018-10-25 14:11:34 +00:00
|
|
|
|
|
|
|
#define MT_TX_STATUS_SKB_TIMEOUT HZ
|
|
|
|
|
|
|
|
struct mt76_tx_cb {
|
|
|
|
unsigned long jiffies;
|
2020-04-24 19:32:25 +00:00
|
|
|
u16 wcid;
|
2018-10-25 14:11:34 +00:00
|
|
|
u8 pktid;
|
|
|
|
u8 flags;
|
|
|
|
};
|
|
|
|
|
2017-11-21 09:50:52 +00:00
|
|
|
enum {
|
|
|
|
MT76_STATE_INITIALIZED,
|
|
|
|
MT76_STATE_RUNNING,
|
2018-07-31 12:41:01 +00:00
|
|
|
MT76_STATE_MCU_RUNNING,
|
2017-11-21 09:50:52 +00:00
|
|
|
MT76_SCANNING,
|
2020-04-02 13:06:38 +00:00
|
|
|
MT76_HW_SCANNING,
|
2020-04-02 13:06:39 +00:00
|
|
|
MT76_HW_SCHED_SCANNING,
|
2020-02-16 15:08:58 +00:00
|
|
|
MT76_RESTART,
|
2017-11-21 09:50:52 +00:00
|
|
|
MT76_RESET,
|
2020-01-30 16:42:55 +00:00
|
|
|
MT76_MCU_RESET,
|
2018-07-31 08:09:19 +00:00
|
|
|
MT76_REMOVED,
|
|
|
|
MT76_READING_STATS,
|
2020-04-16 14:32:51 +00:00
|
|
|
MT76_STATE_POWER_OFF,
|
2020-05-01 10:36:13 +00:00
|
|
|
MT76_STATE_SUSPEND,
|
2020-05-15 17:03:42 +00:00
|
|
|
MT76_STATE_ROC,
|
2020-07-03 08:15:42 +00:00
|
|
|
MT76_STATE_PM,
|
2017-11-21 09:50:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct mt76_hw_cap {
|
|
|
|
bool has_2ghz;
|
|
|
|
bool has_5ghz;
|
|
|
|
};
|
|
|
|
|
2019-08-31 10:41:59 +00:00
|
|
|
#define MT_DRV_TXWI_NO_FREE BIT(0)
|
|
|
|
#define MT_DRV_TX_ALIGNED4_SKBS BIT(1)
|
2019-09-04 15:45:02 +00:00
|
|
|
#define MT_DRV_SW_RX_AIRTIME BIT(2)
|
2020-01-15 10:58:58 +00:00
|
|
|
#define MT_DRV_RX_DMA_HDR BIT(3)
|
2020-06-01 07:45:33 +00:00
|
|
|
#define MT_DRV_HW_MGMT_TXQ BIT(4)
|
2020-08-11 07:59:57 +00:00
|
|
|
#define MT_DRV_AMSDU_OFFLOAD BIT(5)
|
2019-04-02 09:47:58 +00:00
|
|
|
|
2017-11-21 09:50:52 +00:00
|
|
|
struct mt76_driver_ops {
|
2019-08-31 10:41:59 +00:00
|
|
|
u32 drv_flags;
|
2019-09-04 18:50:14 +00:00
|
|
|
u32 survey_flags;
|
2017-11-21 09:50:52 +00:00
|
|
|
u16 txwi_size;
|
|
|
|
|
|
|
|
void (*update_survey)(struct mt76_dev *dev);
|
|
|
|
|
|
|
|
int (*tx_prepare_skb)(struct mt76_dev *dev, void *txwi_ptr,
|
2019-04-02 09:47:57 +00:00
|
|
|
enum mt76_txq_id qid, struct mt76_wcid *wcid,
|
2019-03-14 13:54:12 +00:00
|
|
|
struct ieee80211_sta *sta,
|
|
|
|
struct mt76_tx_info *tx_info);
|
2017-11-21 09:50:52 +00:00
|
|
|
|
2020-08-23 13:08:02 +00:00
|
|
|
void (*tx_complete_skb)(struct mt76_dev *dev,
|
2019-03-02 13:47:40 +00:00
|
|
|
struct mt76_queue_entry *e);
|
2017-11-21 09:50:52 +00:00
|
|
|
|
2018-07-31 08:09:19 +00:00
|
|
|
bool (*tx_status_data)(struct mt76_dev *dev, u8 *update);
|
|
|
|
|
2017-11-21 09:50:52 +00:00
|
|
|
void (*rx_skb)(struct mt76_dev *dev, enum mt76_rxq_id q,
|
|
|
|
struct sk_buff *skb);
|
|
|
|
|
|
|
|
void (*rx_poll_complete)(struct mt76_dev *dev, enum mt76_rxq_id q);
|
2018-01-27 15:02:03 +00:00
|
|
|
|
|
|
|
void (*sta_ps)(struct mt76_dev *dev, struct ieee80211_sta *sta,
|
|
|
|
bool ps);
|
2018-11-16 09:49:14 +00:00
|
|
|
|
|
|
|
int (*sta_add)(struct mt76_dev *dev, struct ieee80211_vif *vif,
|
|
|
|
struct ieee80211_sta *sta);
|
|
|
|
|
2019-01-30 11:17:20 +00:00
|
|
|
void (*sta_assoc)(struct mt76_dev *dev, struct ieee80211_vif *vif,
|
|
|
|
struct ieee80211_sta *sta);
|
|
|
|
|
2018-11-16 09:49:14 +00:00
|
|
|
void (*sta_remove)(struct mt76_dev *dev, struct ieee80211_vif *vif,
|
|
|
|
struct ieee80211_sta *sta);
|
2017-11-21 09:50:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct mt76_channel_state {
|
|
|
|
u64 cc_active;
|
|
|
|
u64 cc_busy;
|
2019-09-18 10:58:02 +00:00
|
|
|
u64 cc_rx;
|
2019-09-04 15:45:02 +00:00
|
|
|
u64 cc_bss_rx;
|
2019-09-04 18:50:14 +00:00
|
|
|
u64 cc_tx;
|
2019-12-14 19:08:59 +00:00
|
|
|
|
|
|
|
s8 noise;
|
2017-11-21 09:50:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct mt76_sband {
|
|
|
|
struct ieee80211_supported_band sband;
|
|
|
|
struct mt76_channel_state *chan;
|
|
|
|
};
|
|
|
|
|
2018-09-22 11:45:29 +00:00
|
|
|
struct mt76_rate_power {
|
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
s8 cck[4];
|
|
|
|
s8 ofdm[8];
|
|
|
|
s8 stbc[10];
|
|
|
|
s8 ht[16];
|
|
|
|
s8 vht[10];
|
|
|
|
};
|
|
|
|
s8 all[48];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2018-07-31 08:09:19 +00:00
|
|
|
/* addr req mask */
|
|
|
|
#define MT_VEND_TYPE_EEPROM BIT(31)
|
|
|
|
#define MT_VEND_TYPE_CFG BIT(30)
|
|
|
|
#define MT_VEND_TYPE_MASK (MT_VEND_TYPE_EEPROM | MT_VEND_TYPE_CFG)
|
|
|
|
|
|
|
|
#define MT_VEND_ADDR(type, n) (MT_VEND_TYPE_##type | (n))
|
|
|
|
enum mt_vendor_req {
|
|
|
|
MT_VEND_DEV_MODE = 0x1,
|
|
|
|
MT_VEND_WRITE = 0x2,
|
2020-01-15 10:58:54 +00:00
|
|
|
MT_VEND_POWER_ON = 0x4,
|
2018-07-31 08:09:19 +00:00
|
|
|
MT_VEND_MULTI_WRITE = 0x6,
|
|
|
|
MT_VEND_MULTI_READ = 0x7,
|
|
|
|
MT_VEND_READ_EEPROM = 0x9,
|
|
|
|
MT_VEND_WRITE_FCE = 0x42,
|
|
|
|
MT_VEND_WRITE_CFG = 0x46,
|
|
|
|
MT_VEND_READ_CFG = 0x47,
|
2020-01-15 10:58:54 +00:00
|
|
|
MT_VEND_READ_EXT = 0x63,
|
|
|
|
MT_VEND_WRITE_EXT = 0x66,
|
2020-05-01 10:36:14 +00:00
|
|
|
MT_VEND_FEATURE_SET = 0x91,
|
2018-07-31 08:09:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum mt76u_in_ep {
|
|
|
|
MT_EP_IN_PKT_RX,
|
|
|
|
MT_EP_IN_CMD_RESP,
|
|
|
|
__MT_EP_IN_MAX,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum mt76u_out_ep {
|
|
|
|
MT_EP_OUT_INBAND_CMD,
|
|
|
|
MT_EP_OUT_AC_BE,
|
2019-11-17 12:26:14 +00:00
|
|
|
MT_EP_OUT_AC_BK,
|
2018-07-31 08:09:19 +00:00
|
|
|
MT_EP_OUT_AC_VI,
|
|
|
|
MT_EP_OUT_AC_VO,
|
|
|
|
MT_EP_OUT_HCCA,
|
|
|
|
__MT_EP_OUT_MAX,
|
|
|
|
};
|
|
|
|
|
2020-02-08 12:44:28 +00:00
|
|
|
struct mt76_mcu {
|
|
|
|
struct mutex mutex;
|
|
|
|
u32 msg_seq;
|
2020-09-30 02:35:11 +00:00
|
|
|
int timeout;
|
2020-02-08 12:44:28 +00:00
|
|
|
|
|
|
|
struct sk_buff_head res_q;
|
|
|
|
wait_queue_head_t wait;
|
|
|
|
};
|
|
|
|
|
2019-06-20 10:39:36 +00:00
|
|
|
#define MT_TX_SG_MAX_SIZE 8
|
2020-02-10 10:34:00 +00:00
|
|
|
#define MT_RX_SG_MAX_SIZE 4
|
2018-07-31 08:09:19 +00:00
|
|
|
#define MT_NUM_TX_ENTRIES 256
|
|
|
|
#define MT_NUM_RX_ENTRIES 128
|
|
|
|
#define MCU_RESP_URB_SIZE 1024
|
|
|
|
struct mt76_usb {
|
|
|
|
struct mutex usb_ctrl_mtx;
|
2019-11-29 12:32:26 +00:00
|
|
|
u8 *data;
|
|
|
|
u16 data_len;
|
2018-07-31 08:09:19 +00:00
|
|
|
|
2020-10-20 09:13:11 +00:00
|
|
|
struct mt76_worker status_worker;
|
2020-10-20 09:13:10 +00:00
|
|
|
struct mt76_worker rx_worker;
|
2020-10-20 09:13:11 +00:00
|
|
|
|
2019-10-28 16:38:05 +00:00
|
|
|
struct work_struct stat_work;
|
2018-07-31 08:09:19 +00:00
|
|
|
|
|
|
|
u8 out_ep[__MT_EP_OUT_MAX];
|
|
|
|
u8 in_ep[__MT_EP_IN_MAX];
|
2019-02-12 13:42:39 +00:00
|
|
|
bool sg_en;
|
2018-07-31 08:09:19 +00:00
|
|
|
|
|
|
|
struct mt76u_mcu {
|
2019-02-20 16:15:19 +00:00
|
|
|
u8 *data;
|
2018-08-25 10:40:44 +00:00
|
|
|
/* multiple reads */
|
|
|
|
struct mt76_reg_pair *rp;
|
|
|
|
int rp_len;
|
|
|
|
u32 base;
|
|
|
|
bool burst;
|
2018-07-31 08:09:19 +00:00
|
|
|
} mcu;
|
|
|
|
};
|
|
|
|
|
2020-09-05 09:26:06 +00:00
|
|
|
#define MT76S_XMIT_BUF_SZ (16 * PAGE_SIZE)
|
2020-07-15 12:46:30 +00:00
|
|
|
struct mt76_sdio {
|
2020-09-26 15:06:23 +00:00
|
|
|
struct mt76_worker txrx_worker;
|
2020-09-26 15:06:25 +00:00
|
|
|
struct mt76_worker status_worker;
|
|
|
|
struct mt76_worker net_worker;
|
|
|
|
|
2020-07-30 14:09:50 +00:00
|
|
|
struct work_struct stat_work;
|
2020-07-30 14:09:48 +00:00
|
|
|
|
2020-11-11 13:47:26 +00:00
|
|
|
u8 *xmit_buf[IEEE80211_NUM_ACS + 2];
|
2020-09-05 09:26:06 +00:00
|
|
|
|
2020-07-15 12:46:30 +00:00
|
|
|
struct sdio_func *func;
|
mt76: mt7663s: fix unable to handle kernel paging request
Use buffer allocated with kmalloc instead of with stack to fix kernel
crash due to Unable to handle kernel paging request at virtual address
ffffffc0095cbce8.
[ 156.977349] Unable to handle kernel paging request at virtual address ffffffc0095cbce8
[ 156.985270] Mem abort info:
[ 156.988059] ESR = 0x96000045
[ 156.991104] Exception class = DABT (current EL), IL = 32 bits
[ 156.997013] SET = 0, FnV = 0
[ 157.000057] EA = 0, S1PTW = 0
[ 157.003190] Data abort info:
[ 157.006061] ISV = 0, ISS = 0x00000045
[ 157.009887] CM = 0, WnR = 1
[ 157.012850] swapper pgtable: 4k pages, 39-bit VAs, pgdp = 0000000042adcba2
[ 157.019715] [ffffffc0095cbce8] pgd=0000000000000000, pud=0000000000000000
[ 157.026499] Internal error: Oops: 96000045 [#1] PREEMPT SMP
[ 157.032065] Modules linked in: mt7663s mt7663_usb_sdio_common mt7615_common
...
[ 157.073007] Process CompositorTileW (pid: 1625, stack limit = 0x000000003f2389fc)
[ 157.080484] CPU: 0 PID: 1625 Comm: CompositorTileW Not tainted 4.19.137 #36
[ 157.092219] pstate: 80000085 (Nzcv daIf -PAN -UAO)
[ 157.097012] pc : __memcpy+0xc0/0x180
[ 157.100585] lr : swiotlb_tbl_unmap_single+0x84/0x14c
[ 157.105540] sp : ffffff8008003cb0
[ 157.108845] x29: ffffff8008003cb0 x28: ffffff9c1a211f60
[ 157.114149] x27: ffffff9c19ecc018 x26: 0000000000001000
[ 157.119452] x25: ffffff9c1a378000 x24: 0000000000000001
[ 157.124755] x23: ffffff9c1a378000 x22: 00000000000001ff
[ 157.130058] x21: 0000000000000000 x20: 00000000fbefe800
[ 157.135360] x19: 0000000000000070 x18: 0000000000000000
[ 157.140663] x17: 0000000000000000 x16: 0000000000000000
[ 157.145965] x15: 0000000000000000 x14: 0000000000000000
[ 157.151267] x13: 0000000000000000 x12: 000000000000000d
[ 157.156569] x11: 000000000000000c x10: 0000000a7befe800
[ 157.161873] x9 : fffffff680000000 x8 : 0000000000000000
[ 157.167175] x7 : 0000000100000003 x6 : ffffffc0095cbce8
[ 157.172479] x5 : 0000000000000000 x4 : 0000000000000000
[ 157.177781] x3 : 0000000000000002 x2 : fffffffffffffff0
[ 157.183085] x1 : ffffffca7befe810 x0 : ffffffc0095cbce8
[ 157.188389] Call trace:
[ 157.190832] __memcpy+0xc0/0x180
[ 157.194053] swiotlb_unmap_sg_attrs+0xa8/0xb0
[ 157.198406] __swiotlb_unmap_sg_attrs+0x8c/0xa4
[ 157.202931] msdc_unprepare_data+0x6c/0x84
[ 157.207019] msdc_request_done+0x58/0x98
[ 157.210934] msdc_data_xfer_done+0x1a8/0x1d0
[ 157.215195] msdc_irq+0x12c/0x17c
[ 157.218505] __handle_irq_event_percpu+0xd8/0x298
[ 157.223202] handle_irq_event+0x60/0xdc
[ 157.227031] handle_fasteoi_irq+0xa4/0x1d4
[ 157.231120] __handle_domain_irq+0x84/0xc4
[ 157.235210] gic_handle_irq+0x124/0x1a4
[ 157.239038] el0_irq_naked+0x4c/0x54
[ 157.242608] Code: 14000028 f1020042 5400024a a8c12027 (a88120c7)
[ 157.248693] ---[ end trace 28b8090135b0a2e1 ]---
[ 157.265589] Kernel panic - not syncing: Fatal exception in interrupt
[ 157.271944] SMP: stopping secondary CPUs
[ 157.275865] Kernel Offset: 0x1c10e00000 from 0xffffff8008000000
[ 157.281779] CPU features: 0x0,2188200c
[ 157.285519] Memory Limit: none
Fixes: a66cbdd6573d ("mt76: mt7615: introduce mt7663s support")
Co-developed-by: YN Chen <YN.Chen@mediatek.com>
Signed-off-by: YN Chen <YN.Chen@mediatek.com>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-08-18 04:12:28 +00:00
|
|
|
void *intr_data;
|
2020-07-15 12:46:30 +00:00
|
|
|
|
|
|
|
struct {
|
|
|
|
int pse_data_quota;
|
|
|
|
int ple_data_quota;
|
|
|
|
int pse_mcu_quota;
|
|
|
|
int deficit;
|
|
|
|
} sched;
|
|
|
|
};
|
|
|
|
|
2018-09-09 21:57:57 +00:00
|
|
|
struct mt76_mmio {
|
2018-09-09 21:57:58 +00:00
|
|
|
void __iomem *regs;
|
2018-09-28 11:38:47 +00:00
|
|
|
spinlock_t irq_lock;
|
|
|
|
u32 irqmask;
|
2018-09-09 21:57:57 +00:00
|
|
|
};
|
|
|
|
|
2019-09-04 15:45:02 +00:00
|
|
|
struct mt76_rx_status {
|
|
|
|
union {
|
|
|
|
struct mt76_wcid *wcid;
|
2020-04-24 19:32:25 +00:00
|
|
|
u16 wcid_idx;
|
2019-09-04 15:45:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
unsigned long reorder_time;
|
|
|
|
|
|
|
|
u32 ampdu_ref;
|
|
|
|
|
|
|
|
u8 iv[6];
|
|
|
|
|
2019-10-11 20:30:47 +00:00
|
|
|
u8 ext_phy:1;
|
2019-09-04 15:45:02 +00:00
|
|
|
u8 aggr:1;
|
|
|
|
u8 tid;
|
|
|
|
u16 seqno;
|
|
|
|
|
|
|
|
u16 freq;
|
|
|
|
u32 flag;
|
|
|
|
u8 enc_flags;
|
2020-04-24 19:32:23 +00:00
|
|
|
u8 encoding:2, bw:3, he_ru:3;
|
|
|
|
u8 he_gi:2, he_dcm:1;
|
2019-09-04 15:45:02 +00:00
|
|
|
u8 rate_idx;
|
|
|
|
u8 nss;
|
|
|
|
u8 band;
|
|
|
|
s8 signal;
|
|
|
|
u8 chains;
|
|
|
|
s8 chain_signal[IEEE80211_MAX_CHAINS];
|
|
|
|
};
|
|
|
|
|
2020-06-18 19:12:24 +00:00
|
|
|
struct mt76_testmode_ops {
|
|
|
|
int (*set_state)(struct mt76_dev *dev, enum mt76_testmode_state state);
|
|
|
|
int (*set_params)(struct mt76_dev *dev, struct nlattr **tb,
|
|
|
|
enum mt76_testmode_state new_state);
|
|
|
|
int (*dump_stats)(struct mt76_dev *dev, struct sk_buff *msg);
|
|
|
|
};
|
|
|
|
|
|
|
|
struct mt76_testmode_data {
|
|
|
|
enum mt76_testmode_state state;
|
|
|
|
|
|
|
|
u32 param_set[DIV_ROUND_UP(NUM_MT76_TM_ATTRS, 32)];
|
|
|
|
struct sk_buff *tx_skb;
|
|
|
|
|
|
|
|
u32 tx_count;
|
|
|
|
u16 tx_msdu_len;
|
|
|
|
|
|
|
|
u8 tx_rate_mode;
|
|
|
|
u8 tx_rate_idx;
|
|
|
|
u8 tx_rate_nss;
|
|
|
|
u8 tx_rate_sgi;
|
|
|
|
u8 tx_rate_ldpc;
|
2020-10-22 02:28:13 +00:00
|
|
|
u8 tx_rate_stbc;
|
2020-10-22 02:28:14 +00:00
|
|
|
u8 tx_ltf;
|
2020-06-18 19:12:24 +00:00
|
|
|
|
|
|
|
u8 tx_antenna_mask;
|
|
|
|
|
|
|
|
u32 freq_offset;
|
|
|
|
|
|
|
|
u8 tx_power[4];
|
|
|
|
u8 tx_power_control;
|
|
|
|
|
|
|
|
const char *mtd_name;
|
|
|
|
u32 mtd_offset;
|
|
|
|
|
|
|
|
u32 tx_pending;
|
|
|
|
u32 tx_queued;
|
|
|
|
u32 tx_done;
|
|
|
|
struct {
|
|
|
|
u64 packets[__MT_RXQ_MAX];
|
|
|
|
u64 fcs_error[__MT_RXQ_MAX];
|
|
|
|
} rx_stats;
|
|
|
|
};
|
|
|
|
|
2019-09-30 20:09:06 +00:00
|
|
|
struct mt76_phy {
|
|
|
|
struct ieee80211_hw *hw;
|
|
|
|
struct mt76_dev *dev;
|
2019-10-30 19:33:05 +00:00
|
|
|
void *priv;
|
2019-10-12 17:46:40 +00:00
|
|
|
|
2019-10-16 10:09:22 +00:00
|
|
|
unsigned long state;
|
|
|
|
|
2020-11-11 13:47:32 +00:00
|
|
|
struct mt76_queue *q_tx[__MT_TXQ_MAX];
|
|
|
|
|
2019-10-12 17:46:40 +00:00
|
|
|
struct cfg80211_chan_def chandef;
|
|
|
|
struct ieee80211_channel *main_chan;
|
|
|
|
|
|
|
|
struct mt76_channel_state *chan_state;
|
|
|
|
ktime_t survey_time;
|
|
|
|
|
2020-11-12 09:56:56 +00:00
|
|
|
struct mt76_hw_cap cap;
|
2019-10-12 17:46:40 +00:00
|
|
|
struct mt76_sband sband_2g;
|
|
|
|
struct mt76_sband sband_5g;
|
2019-10-16 10:41:48 +00:00
|
|
|
|
2020-11-13 10:11:30 +00:00
|
|
|
u8 macaddr[ETH_ALEN];
|
|
|
|
|
2020-06-11 15:45:58 +00:00
|
|
|
u32 vif_mask;
|
|
|
|
|
2019-10-16 10:41:48 +00:00
|
|
|
int txpower_cur;
|
|
|
|
u8 antenna_mask;
|
2019-09-30 20:09:06 +00:00
|
|
|
};
|
|
|
|
|
2017-11-21 09:50:52 +00:00
|
|
|
struct mt76_dev {
|
2019-09-30 20:09:06 +00:00
|
|
|
struct mt76_phy phy; /* must be first */
|
|
|
|
|
2019-10-11 20:30:47 +00:00
|
|
|
struct mt76_phy *phy2;
|
|
|
|
|
2017-11-21 09:50:52 +00:00
|
|
|
struct ieee80211_hw *hw;
|
|
|
|
|
|
|
|
spinlock_t lock;
|
|
|
|
spinlock_t cc_lock;
|
2018-08-29 11:16:35 +00:00
|
|
|
|
2019-09-04 15:45:02 +00:00
|
|
|
u32 cur_cc_bss_rx;
|
|
|
|
|
|
|
|
struct mt76_rx_status rx_ampdu_status;
|
|
|
|
u32 rx_ampdu_len;
|
|
|
|
u32 rx_ampdu_ref;
|
|
|
|
|
2018-08-29 11:16:35 +00:00
|
|
|
struct mutex mutex;
|
|
|
|
|
2017-11-21 09:50:52 +00:00
|
|
|
const struct mt76_bus_ops *bus;
|
|
|
|
const struct mt76_driver_ops *drv;
|
2018-09-09 20:32:37 +00:00
|
|
|
const struct mt76_mcu_ops *mcu_ops;
|
2017-11-21 09:50:52 +00:00
|
|
|
struct device *dev;
|
|
|
|
|
2020-02-08 12:44:28 +00:00
|
|
|
struct mt76_mcu mcu;
|
|
|
|
|
2017-11-21 09:50:52 +00:00
|
|
|
struct net_device napi_dev;
|
2018-04-25 09:11:21 +00:00
|
|
|
spinlock_t rx_lock;
|
2017-11-21 09:50:52 +00:00
|
|
|
struct napi_struct napi[__MT_RXQ_MAX];
|
|
|
|
struct sk_buff_head rx_skb[__MT_RXQ_MAX];
|
|
|
|
|
|
|
|
struct list_head txwi_cache;
|
2020-11-11 13:47:29 +00:00
|
|
|
struct mt76_queue *q_mcu[__MT_MCUQ_MAX];
|
2017-11-21 09:50:52 +00:00
|
|
|
struct mt76_queue q_rx[__MT_RXQ_MAX];
|
|
|
|
const struct mt76_queue_ops *queue_ops;
|
2018-12-28 14:44:09 +00:00
|
|
|
int tx_dma_idx[4];
|
2017-11-21 09:50:52 +00:00
|
|
|
|
2020-07-24 14:11:52 +00:00
|
|
|
struct mt76_worker tx_worker;
|
2019-05-01 14:06:20 +00:00
|
|
|
struct napi_struct tx_napi;
|
2019-03-18 10:21:44 +00:00
|
|
|
struct delayed_work mac_work;
|
2019-03-13 19:17:45 +00:00
|
|
|
|
2018-05-20 05:43:48 +00:00
|
|
|
wait_queue_head_t tx_wait;
|
2018-10-25 14:11:34 +00:00
|
|
|
struct sk_buff_head status_list;
|
2018-05-20 05:43:48 +00:00
|
|
|
|
2020-05-23 12:40:57 +00:00
|
|
|
u32 wcid_mask[DIV_ROUND_UP(MT76_N_WCIDS, 32)];
|
|
|
|
u32 wcid_phy_mask[DIV_ROUND_UP(MT76_N_WCIDS, 32)];
|
2018-09-04 14:40:54 +00:00
|
|
|
|
|
|
|
struct mt76_wcid global_wcid;
|
|
|
|
struct mt76_wcid __rcu *wcid[MT76_N_WCIDS];
|
|
|
|
|
2017-11-21 09:50:52 +00:00
|
|
|
u32 rev;
|
|
|
|
|
2019-09-13 07:05:52 +00:00
|
|
|
u32 aggr_stats[32];
|
|
|
|
|
2019-04-30 13:12:01 +00:00
|
|
|
struct tasklet_struct pre_tbtt_tasklet;
|
2019-04-29 08:12:59 +00:00
|
|
|
int beacon_int;
|
2019-04-29 08:13:00 +00:00
|
|
|
u8 beacon_mask;
|
2019-04-29 08:12:59 +00:00
|
|
|
|
2017-11-21 09:50:52 +00:00
|
|
|
struct debugfs_blob_wrapper eeprom;
|
|
|
|
struct debugfs_blob_wrapper otp;
|
|
|
|
|
2018-09-22 11:45:29 +00:00
|
|
|
struct mt76_rate_power rate_power;
|
|
|
|
|
2019-06-21 20:31:28 +00:00
|
|
|
enum nl80211_dfs_regions region;
|
|
|
|
|
2017-11-21 09:50:52 +00:00
|
|
|
u32 debugfs_reg;
|
|
|
|
|
|
|
|
struct led_classdev led_cdev;
|
|
|
|
char led_name[32];
|
|
|
|
bool led_al;
|
|
|
|
u8 led_pin;
|
2018-07-31 08:09:19 +00:00
|
|
|
|
2019-01-15 13:26:53 +00:00
|
|
|
u8 csa_complete;
|
|
|
|
|
2018-08-29 11:16:35 +00:00
|
|
|
u32 rxfilter;
|
|
|
|
|
2020-06-18 19:12:24 +00:00
|
|
|
#ifdef CONFIG_NL80211_TESTMODE
|
|
|
|
const struct mt76_testmode_ops *test_ops;
|
|
|
|
struct mt76_testmode_data test;
|
|
|
|
#endif
|
|
|
|
|
2020-07-03 08:15:41 +00:00
|
|
|
struct workqueue_struct *wq;
|
|
|
|
|
2018-09-09 21:57:57 +00:00
|
|
|
union {
|
|
|
|
struct mt76_mmio mmio;
|
|
|
|
struct mt76_usb usb;
|
2020-07-15 12:46:30 +00:00
|
|
|
struct mt76_sdio sdio;
|
2018-09-09 21:57:57 +00:00
|
|
|
};
|
2017-11-21 09:50:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum mt76_phy_type {
|
|
|
|
MT_PHY_TYPE_CCK,
|
|
|
|
MT_PHY_TYPE_OFDM,
|
|
|
|
MT_PHY_TYPE_HT,
|
|
|
|
MT_PHY_TYPE_HT_GF,
|
|
|
|
MT_PHY_TYPE_VHT,
|
2020-04-24 19:32:26 +00:00
|
|
|
MT_PHY_TYPE_HE_SU = 8,
|
|
|
|
MT_PHY_TYPE_HE_EXT_SU,
|
|
|
|
MT_PHY_TYPE_HE_TB,
|
|
|
|
MT_PHY_TYPE_HE_MU,
|
2017-11-21 09:50:52 +00:00
|
|
|
};
|
|
|
|
|
2018-08-29 11:16:37 +00:00
|
|
|
#define __mt76_rr(dev, ...) (dev)->bus->rr((dev), __VA_ARGS__)
|
|
|
|
#define __mt76_wr(dev, ...) (dev)->bus->wr((dev), __VA_ARGS__)
|
|
|
|
#define __mt76_rmw(dev, ...) (dev)->bus->rmw((dev), __VA_ARGS__)
|
2019-07-13 15:09:06 +00:00
|
|
|
#define __mt76_wr_copy(dev, ...) (dev)->bus->write_copy((dev), __VA_ARGS__)
|
|
|
|
#define __mt76_rr_copy(dev, ...) (dev)->bus->read_copy((dev), __VA_ARGS__)
|
2018-08-29 11:16:37 +00:00
|
|
|
|
2018-09-04 14:40:58 +00:00
|
|
|
#define __mt76_set(dev, offset, val) __mt76_rmw(dev, offset, 0, val)
|
|
|
|
#define __mt76_clear(dev, offset, val) __mt76_rmw(dev, offset, val, 0)
|
|
|
|
|
2017-11-21 09:50:52 +00:00
|
|
|
#define mt76_rr(dev, ...) (dev)->mt76.bus->rr(&((dev)->mt76), __VA_ARGS__)
|
|
|
|
#define mt76_wr(dev, ...) (dev)->mt76.bus->wr(&((dev)->mt76), __VA_ARGS__)
|
|
|
|
#define mt76_rmw(dev, ...) (dev)->mt76.bus->rmw(&((dev)->mt76), __VA_ARGS__)
|
2019-07-13 15:09:06 +00:00
|
|
|
#define mt76_wr_copy(dev, ...) (dev)->mt76.bus->write_copy(&((dev)->mt76), __VA_ARGS__)
|
|
|
|
#define mt76_rr_copy(dev, ...) (dev)->mt76.bus->read_copy(&((dev)->mt76), __VA_ARGS__)
|
2018-09-09 20:32:39 +00:00
|
|
|
#define mt76_wr_rp(dev, ...) (dev)->mt76.bus->wr_rp(&((dev)->mt76), __VA_ARGS__)
|
|
|
|
#define mt76_rd_rp(dev, ...) (dev)->mt76.bus->rd_rp(&((dev)->mt76), __VA_ARGS__)
|
2017-11-21 09:50:52 +00:00
|
|
|
|
2020-03-17 16:41:13 +00:00
|
|
|
|
2019-04-13 14:01:27 +00:00
|
|
|
#define mt76_mcu_restart(dev, ...) (dev)->mt76.mcu_ops->mcu_restart(&((dev)->mt76))
|
|
|
|
#define __mt76_mcu_restart(dev, ...) (dev)->mcu_ops->mcu_restart((dev))
|
2018-09-09 20:32:37 +00:00
|
|
|
|
2017-11-21 09:50:52 +00:00
|
|
|
#define mt76_set(dev, offset, val) mt76_rmw(dev, offset, 0, val)
|
|
|
|
#define mt76_clear(dev, offset, val) mt76_rmw(dev, offset, val, 0)
|
|
|
|
|
|
|
|
#define mt76_get_field(_dev, _reg, _field) \
|
|
|
|
FIELD_GET(_field, mt76_rr(dev, _reg))
|
|
|
|
|
|
|
|
#define mt76_rmw_field(_dev, _reg, _field, _val) \
|
|
|
|
mt76_rmw(_dev, _reg, _field, FIELD_PREP(_field, _val))
|
|
|
|
|
2018-08-29 11:16:39 +00:00
|
|
|
#define __mt76_rmw_field(_dev, _reg, _field, _val) \
|
|
|
|
__mt76_rmw(_dev, _reg, _field, FIELD_PREP(_field, _val))
|
|
|
|
|
2019-09-30 20:09:06 +00:00
|
|
|
#define mt76_hw(dev) (dev)->mphy.hw
|
2017-11-21 09:50:52 +00:00
|
|
|
|
2019-10-12 15:42:00 +00:00
|
|
|
static inline struct ieee80211_hw *
|
2020-04-24 19:32:25 +00:00
|
|
|
mt76_wcid_hw(struct mt76_dev *dev, u16 wcid)
|
2019-10-12 15:42:00 +00:00
|
|
|
{
|
|
|
|
if (wcid <= MT76_N_WCIDS &&
|
|
|
|
mt76_wcid_mask_test(dev->wcid_phy_mask, wcid))
|
|
|
|
return dev->phy2->hw;
|
|
|
|
|
|
|
|
return dev->phy.hw;
|
|
|
|
}
|
|
|
|
|
2017-11-21 09:50:52 +00:00
|
|
|
bool __mt76_poll(struct mt76_dev *dev, u32 offset, u32 mask, u32 val,
|
|
|
|
int timeout);
|
|
|
|
|
|
|
|
#define mt76_poll(dev, ...) __mt76_poll(&((dev)->mt76), __VA_ARGS__)
|
|
|
|
|
|
|
|
bool __mt76_poll_msec(struct mt76_dev *dev, u32 offset, u32 mask, u32 val,
|
|
|
|
int timeout);
|
|
|
|
|
|
|
|
#define mt76_poll_msec(dev, ...) __mt76_poll_msec(&((dev)->mt76), __VA_ARGS__)
|
|
|
|
|
|
|
|
void mt76_mmio_init(struct mt76_dev *dev, void __iomem *regs);
|
2019-10-27 19:53:08 +00:00
|
|
|
void mt76_pci_disable_aspm(struct pci_dev *pdev);
|
2017-11-21 09:50:52 +00:00
|
|
|
|
|
|
|
static inline u16 mt76_chip(struct mt76_dev *dev)
|
|
|
|
{
|
|
|
|
return dev->rev >> 16;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline u16 mt76_rev(struct mt76_dev *dev)
|
|
|
|
{
|
|
|
|
return dev->rev & 0xffff;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define mt76xx_chip(dev) mt76_chip(&((dev)->mt76))
|
|
|
|
#define mt76xx_rev(dev) mt76_rev(&((dev)->mt76))
|
|
|
|
|
2018-10-05 08:28:36 +00:00
|
|
|
#define mt76_init_queues(dev) (dev)->mt76.queue_ops->init(&((dev)->mt76))
|
|
|
|
#define mt76_queue_alloc(dev, ...) (dev)->mt76.queue_ops->alloc(&((dev)->mt76), __VA_ARGS__)
|
2019-02-07 10:10:57 +00:00
|
|
|
#define mt76_tx_queue_skb_raw(dev, ...) (dev)->mt76.queue_ops->tx_queue_skb_raw(&((dev)->mt76), __VA_ARGS__)
|
2019-03-07 14:45:43 +00:00
|
|
|
#define mt76_tx_queue_skb(dev, ...) (dev)->mt76.queue_ops->tx_queue_skb(&((dev)->mt76), __VA_ARGS__)
|
2017-11-21 09:50:52 +00:00
|
|
|
#define mt76_queue_rx_reset(dev, ...) (dev)->mt76.queue_ops->rx_reset(&((dev)->mt76), __VA_ARGS__)
|
2020-11-11 13:47:27 +00:00
|
|
|
#define mt76_queue_tx_cleanup(dev, ...) (dev)->mt76.queue_ops->tx_cleanup(&((dev)->mt76), __VA_ARGS__)
|
2017-11-21 09:50:52 +00:00
|
|
|
#define mt76_queue_kick(dev, ...) (dev)->mt76.queue_ops->kick(&((dev)->mt76), __VA_ARGS__)
|
|
|
|
|
2020-05-24 12:44:52 +00:00
|
|
|
#define mt76_for_each_q_rx(dev, i) \
|
|
|
|
for (i = 0; i < ARRAY_SIZE((dev)->q_rx) && \
|
|
|
|
(dev)->q_rx[i].ndesc; i++)
|
|
|
|
|
2019-01-31 16:55:54 +00:00
|
|
|
struct mt76_dev *mt76_alloc_device(struct device *pdev, unsigned int size,
|
|
|
|
const struct ieee80211_ops *ops,
|
|
|
|
const struct mt76_driver_ops *drv_ops);
|
2017-11-21 09:50:52 +00:00
|
|
|
int mt76_register_device(struct mt76_dev *dev, bool vht,
|
|
|
|
struct ieee80211_rate *rates, int n_rates);
|
|
|
|
void mt76_unregister_device(struct mt76_dev *dev);
|
2019-03-27 11:41:03 +00:00
|
|
|
void mt76_free_device(struct mt76_dev *dev);
|
2019-10-30 20:54:41 +00:00
|
|
|
void mt76_unregister_phy(struct mt76_phy *phy);
|
|
|
|
|
|
|
|
struct mt76_phy *mt76_alloc_phy(struct mt76_dev *dev, unsigned int size,
|
|
|
|
const struct ieee80211_ops *ops);
|
2020-11-12 09:56:58 +00:00
|
|
|
int mt76_register_phy(struct mt76_phy *phy, bool vht,
|
|
|
|
struct ieee80211_rate *rates, int n_rates);
|
2017-11-21 09:50:52 +00:00
|
|
|
|
|
|
|
struct dentry *mt76_register_debugfs(struct mt76_dev *dev);
|
2019-09-13 07:05:50 +00:00
|
|
|
int mt76_queues_read(struct seq_file *s, void *data);
|
2018-09-20 09:11:48 +00:00
|
|
|
void mt76_seq_puts_array(struct seq_file *file, const char *str,
|
|
|
|
s8 *val, int len);
|
2017-11-21 09:50:52 +00:00
|
|
|
|
|
|
|
int mt76_eeprom_init(struct mt76_dev *dev, int len);
|
2020-11-13 10:11:30 +00:00
|
|
|
void mt76_eeprom_override(struct mt76_phy *phy);
|
2017-11-21 09:50:52 +00:00
|
|
|
|
2020-11-11 13:47:29 +00:00
|
|
|
struct mt76_queue *
|
|
|
|
mt76_init_queue(struct mt76_dev *dev, int qid, int idx, int n_desc,
|
|
|
|
int ring_base);
|
|
|
|
static inline int mt76_init_tx_queue(struct mt76_phy *phy, int qid, int idx,
|
|
|
|
int n_desc, int ring_base)
|
|
|
|
{
|
|
|
|
struct mt76_queue *q;
|
|
|
|
|
|
|
|
q = mt76_init_queue(phy->dev, qid, idx, n_desc, ring_base);
|
|
|
|
if (IS_ERR(q))
|
|
|
|
return PTR_ERR(q);
|
|
|
|
|
|
|
|
q->qid = qid;
|
2020-11-11 13:47:32 +00:00
|
|
|
phy->q_tx[qid] = q;
|
2020-11-11 13:47:29 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int mt76_init_mcu_queue(struct mt76_dev *dev, int qid, int idx,
|
|
|
|
int n_desc, int ring_base)
|
|
|
|
{
|
|
|
|
struct mt76_queue *q;
|
|
|
|
|
|
|
|
q = mt76_init_queue(dev, qid, idx, n_desc, ring_base);
|
|
|
|
if (IS_ERR(q))
|
|
|
|
return PTR_ERR(q);
|
|
|
|
|
2020-11-11 13:47:31 +00:00
|
|
|
q->qid = __MT_TXQ_MAX + qid;
|
2020-11-11 13:47:29 +00:00
|
|
|
dev->q_mcu[qid] = q;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2020-11-11 13:47:23 +00:00
|
|
|
|
2019-10-16 10:09:22 +00:00
|
|
|
static inline struct mt76_phy *
|
|
|
|
mt76_dev_phy(struct mt76_dev *dev, bool phy_ext)
|
|
|
|
{
|
|
|
|
if (phy_ext && dev->phy2)
|
|
|
|
return dev->phy2;
|
|
|
|
return &dev->phy;
|
|
|
|
}
|
|
|
|
|
2019-10-11 20:30:47 +00:00
|
|
|
static inline struct ieee80211_hw *
|
|
|
|
mt76_phy_hw(struct mt76_dev *dev, bool phy_ext)
|
|
|
|
{
|
2019-10-16 10:09:22 +00:00
|
|
|
return mt76_dev_phy(dev, phy_ext)->hw;
|
2019-10-11 20:30:47 +00:00
|
|
|
}
|
|
|
|
|
2019-04-02 09:47:56 +00:00
|
|
|
static inline u8 *
|
|
|
|
mt76_get_txwi_ptr(struct mt76_dev *dev, struct mt76_txwi_cache *t)
|
|
|
|
{
|
|
|
|
return (u8 *)t - dev->drv->txwi_size;
|
|
|
|
}
|
|
|
|
|
2018-06-29 11:40:52 +00:00
|
|
|
/* increment with wrap-around */
|
|
|
|
static inline int mt76_incr(int val, int size)
|
|
|
|
{
|
|
|
|
return (val + 1) & (size - 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* decrement with wrap-around */
|
|
|
|
static inline int mt76_decr(int val, int size)
|
|
|
|
{
|
|
|
|
return (val - 1) & (size - 1);
|
|
|
|
}
|
|
|
|
|
2018-09-04 14:41:01 +00:00
|
|
|
u8 mt76_ac_to_hwq(u8 ac);
|
2018-07-31 08:09:19 +00:00
|
|
|
|
2017-11-21 09:50:52 +00:00
|
|
|
static inline struct ieee80211_txq *
|
|
|
|
mtxq_to_txq(struct mt76_txq *mtxq)
|
|
|
|
{
|
|
|
|
void *ptr = mtxq;
|
|
|
|
|
|
|
|
return container_of(ptr, struct ieee80211_txq, drv_priv);
|
|
|
|
}
|
|
|
|
|
2018-01-24 15:19:13 +00:00
|
|
|
static inline struct ieee80211_sta *
|
|
|
|
wcid_to_sta(struct mt76_wcid *wcid)
|
|
|
|
{
|
|
|
|
void *ptr = wcid;
|
|
|
|
|
|
|
|
if (!wcid || !wcid->sta)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return container_of(ptr, struct ieee80211_sta, drv_priv);
|
|
|
|
}
|
|
|
|
|
2018-10-25 14:11:34 +00:00
|
|
|
static inline struct mt76_tx_cb *mt76_tx_skb_cb(struct sk_buff *skb)
|
|
|
|
{
|
|
|
|
BUILD_BUG_ON(sizeof(struct mt76_tx_cb) >
|
|
|
|
sizeof(IEEE80211_SKB_CB(skb)->status.status_driver_data));
|
2019-08-21 03:11:15 +00:00
|
|
|
return ((void *)IEEE80211_SKB_CB(skb)->status.status_driver_data);
|
2018-10-25 14:11:34 +00:00
|
|
|
}
|
|
|
|
|
2020-04-24 19:32:24 +00:00
|
|
|
static inline void *mt76_skb_get_hdr(struct sk_buff *skb)
|
|
|
|
{
|
|
|
|
struct mt76_rx_status mstat;
|
|
|
|
u8 *data = skb->data;
|
|
|
|
|
|
|
|
/* Alignment concerns */
|
|
|
|
BUILD_BUG_ON(sizeof(struct ieee80211_radiotap_he) % 4);
|
|
|
|
BUILD_BUG_ON(sizeof(struct ieee80211_radiotap_he_mu) % 4);
|
|
|
|
|
|
|
|
mstat = *((struct mt76_rx_status *)skb->cb);
|
|
|
|
|
|
|
|
if (mstat.flag & RX_FLAG_RADIOTAP_HE)
|
|
|
|
data += sizeof(struct ieee80211_radiotap_he);
|
|
|
|
if (mstat.flag & RX_FLAG_RADIOTAP_HE_MU)
|
|
|
|
data += sizeof(struct ieee80211_radiotap_he_mu);
|
|
|
|
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
2019-03-14 13:54:09 +00:00
|
|
|
static inline void mt76_insert_hdr_pad(struct sk_buff *skb)
|
|
|
|
{
|
|
|
|
int len = ieee80211_get_hdrlen_from_skb(skb);
|
|
|
|
|
|
|
|
if (len % 4 == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
skb_push(skb, 2);
|
|
|
|
memmove(skb->data, skb->data + 2, len);
|
|
|
|
|
|
|
|
skb->data[len] = 0;
|
|
|
|
skb->data[len + 1] = 0;
|
|
|
|
}
|
|
|
|
|
mt76: mt76x02: fix tx status reporting issues
When the hardware falls back to lower rates for a transmit attempt, only the
first status report will show the number of retries correctly. The frames
that follow will report the correct final rate, but number of retries set to 0.
This can cause the rate control module to vastly underestimate the number of
retransmissions per rate.
To fix this, we need to keep track of the initial requested tx rate per packet
and pass it to the status information.
For frames with tx status requested, this is simple: use the rate configured
in info->control.rates[0] as reference.
For no-skb tx status information, we have to encode the requested tx rate in
the packet id (and make it possible to distinguish it from real packet ids).
To do that, reduce the packet id field size by one bit, and use that bit to
indicate packet id vs rate.
This change also improves reporting by filling the status rate array with
rates from first rate to final rate, taking the same steps as the hardware
fallback table. This matters in corner cases like MCS8 on HT, where the
fallback target is MCS0, not MCS7.
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2019-06-05 18:50:52 +00:00
|
|
|
static inline bool mt76_is_skb_pktid(u8 pktid)
|
|
|
|
{
|
|
|
|
if (pktid & MT_PACKET_ID_HAS_RATE)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return pktid >= MT_PACKET_ID_FIRST;
|
|
|
|
}
|
|
|
|
|
2020-02-11 20:00:56 +00:00
|
|
|
static inline u8 mt76_tx_power_nss_delta(u8 nss)
|
|
|
|
{
|
|
|
|
static const u8 nss_delta[4] = { 0, 6, 9, 12 };
|
|
|
|
|
|
|
|
return nss_delta[nss - 1];
|
|
|
|
}
|
|
|
|
|
2020-06-18 19:12:24 +00:00
|
|
|
static inline bool mt76_testmode_enabled(struct mt76_dev *dev)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_NL80211_TESTMODE
|
|
|
|
return dev->test.state != MT76_TM_STATE_OFF;
|
|
|
|
#else
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2017-11-21 09:50:52 +00:00
|
|
|
void mt76_rx(struct mt76_dev *dev, enum mt76_rxq_id q, struct sk_buff *skb);
|
2019-10-11 21:27:20 +00:00
|
|
|
void mt76_tx(struct mt76_phy *dev, struct ieee80211_sta *sta,
|
2017-11-21 09:50:52 +00:00
|
|
|
struct mt76_wcid *wcid, struct sk_buff *skb);
|
|
|
|
void mt76_wake_tx_queue(struct ieee80211_hw *hw, struct ieee80211_txq *txq);
|
2020-11-11 13:47:32 +00:00
|
|
|
void mt76_stop_tx_queues(struct mt76_phy *phy, struct ieee80211_sta *sta,
|
2017-11-21 09:50:52 +00:00
|
|
|
bool send_bar);
|
2020-07-28 18:41:09 +00:00
|
|
|
void mt76_tx_check_agg_ssn(struct ieee80211_sta *sta, struct sk_buff *skb);
|
2019-10-11 21:27:20 +00:00
|
|
|
void mt76_txq_schedule(struct mt76_phy *phy, enum mt76_txq_id qid);
|
|
|
|
void mt76_txq_schedule_all(struct mt76_phy *phy);
|
2020-07-24 14:11:52 +00:00
|
|
|
void mt76_tx_worker(struct mt76_worker *w);
|
2017-11-21 09:50:52 +00:00
|
|
|
void mt76_release_buffered_frames(struct ieee80211_hw *hw,
|
|
|
|
struct ieee80211_sta *sta,
|
|
|
|
u16 tids, int nframes,
|
|
|
|
enum ieee80211_frame_release_type reason,
|
|
|
|
bool more_data);
|
2019-10-14 08:57:03 +00:00
|
|
|
bool mt76_has_tx_pending(struct mt76_phy *phy);
|
2019-10-12 17:46:40 +00:00
|
|
|
void mt76_set_channel(struct mt76_phy *phy);
|
2019-09-04 15:45:02 +00:00
|
|
|
void mt76_update_survey(struct mt76_dev *dev);
|
2020-07-03 08:15:47 +00:00
|
|
|
void mt76_update_survey_active_time(struct mt76_phy *phy, ktime_t time);
|
2017-11-21 09:50:52 +00:00
|
|
|
int mt76_get_survey(struct ieee80211_hw *hw, int idx,
|
|
|
|
struct survey_info *survey);
|
2020-04-24 19:32:39 +00:00
|
|
|
void mt76_set_stream_caps(struct mt76_phy *phy, bool vht);
|
2017-11-21 09:50:52 +00:00
|
|
|
|
2018-01-24 15:19:14 +00:00
|
|
|
int mt76_rx_aggr_start(struct mt76_dev *dev, struct mt76_wcid *wcid, u8 tid,
|
2020-04-24 19:32:22 +00:00
|
|
|
u16 ssn, u16 size);
|
2018-01-24 15:19:14 +00:00
|
|
|
void mt76_rx_aggr_stop(struct mt76_dev *dev, struct mt76_wcid *wcid, u8 tid);
|
|
|
|
|
2018-01-25 10:44:24 +00:00
|
|
|
void mt76_wcid_key_setup(struct mt76_dev *dev, struct mt76_wcid *wcid,
|
|
|
|
struct ieee80211_key_conf *key);
|
2018-11-05 20:11:39 +00:00
|
|
|
|
|
|
|
void mt76_tx_status_lock(struct mt76_dev *dev, struct sk_buff_head *list)
|
|
|
|
__acquires(&dev->status_list.lock);
|
|
|
|
void mt76_tx_status_unlock(struct mt76_dev *dev, struct sk_buff_head *list)
|
|
|
|
__releases(&dev->status_list.lock);
|
|
|
|
|
2018-10-25 14:11:34 +00:00
|
|
|
int mt76_tx_status_skb_add(struct mt76_dev *dev, struct mt76_wcid *wcid,
|
|
|
|
struct sk_buff *skb);
|
|
|
|
struct sk_buff *mt76_tx_status_skb_get(struct mt76_dev *dev,
|
2018-11-05 20:11:39 +00:00
|
|
|
struct mt76_wcid *wcid, int pktid,
|
|
|
|
struct sk_buff_head *list);
|
|
|
|
void mt76_tx_status_skb_done(struct mt76_dev *dev, struct sk_buff *skb,
|
|
|
|
struct sk_buff_head *list);
|
2020-08-23 19:22:20 +00:00
|
|
|
void mt76_tx_complete_skb(struct mt76_dev *dev, u16 wcid, struct sk_buff *skb);
|
2018-11-05 20:11:39 +00:00
|
|
|
void mt76_tx_status_check(struct mt76_dev *dev, struct mt76_wcid *wcid,
|
|
|
|
bool flush);
|
2018-11-16 09:49:14 +00:00
|
|
|
int mt76_sta_state(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
|
|
|
|
struct ieee80211_sta *sta,
|
|
|
|
enum ieee80211_sta_state old_state,
|
|
|
|
enum ieee80211_sta_state new_state);
|
2019-03-11 13:24:35 +00:00
|
|
|
void __mt76_sta_remove(struct mt76_dev *dev, struct ieee80211_vif *vif,
|
|
|
|
struct ieee80211_sta *sta);
|
2020-02-06 17:30:08 +00:00
|
|
|
void mt76_sta_pre_rcu_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
|
|
|
|
struct ieee80211_sta *sta);
|
2018-01-25 10:44:24 +00:00
|
|
|
|
2019-10-16 14:14:12 +00:00
|
|
|
int mt76_get_min_avg_rssi(struct mt76_dev *dev, bool ext_phy);
|
2018-12-05 16:06:58 +00:00
|
|
|
|
2018-12-06 13:27:34 +00:00
|
|
|
int mt76_get_txpower(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
|
|
|
|
int *dbm);
|
|
|
|
|
2019-01-15 13:26:53 +00:00
|
|
|
void mt76_csa_check(struct mt76_dev *dev);
|
|
|
|
void mt76_csa_finish(struct mt76_dev *dev);
|
|
|
|
|
2019-11-14 15:12:07 +00:00
|
|
|
int mt76_get_antenna(struct ieee80211_hw *hw, u32 *tx_ant, u32 *rx_ant);
|
2019-03-19 10:37:46 +00:00
|
|
|
int mt76_set_tim(struct ieee80211_hw *hw, struct ieee80211_sta *sta, bool set);
|
2019-05-14 12:48:31 +00:00
|
|
|
void mt76_insert_ccmp_hdr(struct sk_buff *skb, u8 key_id);
|
2019-05-29 08:25:55 +00:00
|
|
|
int mt76_get_rate(struct mt76_dev *dev,
|
|
|
|
struct ieee80211_supported_band *sband,
|
|
|
|
int idx, bool cck);
|
2019-08-21 08:00:19 +00:00
|
|
|
void mt76_sw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
|
|
|
|
const u8 *mac);
|
|
|
|
void mt76_sw_scan_complete(struct ieee80211_hw *hw,
|
|
|
|
struct ieee80211_vif *vif);
|
2020-06-18 19:12:24 +00:00
|
|
|
int mt76_testmode_cmd(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
|
|
|
|
void *data, int len);
|
|
|
|
int mt76_testmode_dump(struct ieee80211_hw *hw, struct sk_buff *skb,
|
|
|
|
struct netlink_callback *cb, void *data, int len);
|
|
|
|
int mt76_testmode_set_state(struct mt76_dev *dev, enum mt76_testmode_state state);
|
|
|
|
|
|
|
|
static inline void mt76_testmode_reset(struct mt76_dev *dev, bool disable)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_NL80211_TESTMODE
|
|
|
|
enum mt76_testmode_state state = MT76_TM_STATE_IDLE;
|
|
|
|
|
|
|
|
if (disable || dev->test.state == MT76_TM_STATE_OFF)
|
|
|
|
state = MT76_TM_STATE_OFF;
|
|
|
|
|
|
|
|
mt76_testmode_set_state(dev, state);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2019-03-19 10:37:46 +00:00
|
|
|
|
2017-11-21 09:50:52 +00:00
|
|
|
/* internal */
|
2019-10-11 20:57:08 +00:00
|
|
|
static inline struct ieee80211_hw *
|
|
|
|
mt76_tx_status_get_hw(struct mt76_dev *dev, struct sk_buff *skb)
|
|
|
|
{
|
|
|
|
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
|
|
|
|
struct ieee80211_hw *hw = dev->phy.hw;
|
|
|
|
|
|
|
|
if ((info->hw_queue & MT_TX_HW_QUEUE_EXT_PHY) && dev->phy2)
|
|
|
|
hw = dev->phy2->hw;
|
|
|
|
|
|
|
|
info->hw_queue &= ~MT_TX_HW_QUEUE_EXT_PHY;
|
|
|
|
|
|
|
|
return hw;
|
|
|
|
}
|
|
|
|
|
2017-11-21 09:50:52 +00:00
|
|
|
void mt76_put_txwi(struct mt76_dev *dev, struct mt76_txwi_cache *t);
|
2018-01-24 15:19:15 +00:00
|
|
|
void mt76_rx_complete(struct mt76_dev *dev, struct sk_buff_head *frames,
|
2018-07-31 08:09:08 +00:00
|
|
|
struct napi_struct *napi);
|
|
|
|
void mt76_rx_poll_complete(struct mt76_dev *dev, enum mt76_rxq_id q,
|
|
|
|
struct napi_struct *napi);
|
2018-01-24 15:19:14 +00:00
|
|
|
void mt76_rx_aggr_reorder(struct sk_buff *skb, struct sk_buff_head *frames);
|
2020-06-18 19:12:24 +00:00
|
|
|
void mt76_testmode_tx_pending(struct mt76_dev *dev);
|
2020-08-23 12:50:13 +00:00
|
|
|
void mt76_queue_tx_complete(struct mt76_dev *dev, struct mt76_queue *q,
|
|
|
|
struct mt76_queue_entry *e);
|
2017-11-21 09:50:52 +00:00
|
|
|
|
2018-07-31 08:09:19 +00:00
|
|
|
/* usb */
|
|
|
|
static inline bool mt76u_urb_error(struct urb *urb)
|
|
|
|
{
|
|
|
|
return urb->status &&
|
|
|
|
urb->status != -ECONNRESET &&
|
|
|
|
urb->status != -ESHUTDOWN &&
|
|
|
|
urb->status != -ENOENT;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Map hardware queues to usb endpoints */
|
|
|
|
static inline u8 q2ep(u8 qid)
|
|
|
|
{
|
|
|
|
/* TODO: take management packets to queue 5 */
|
|
|
|
return qid + 1;
|
|
|
|
}
|
|
|
|
|
2019-02-11 08:16:14 +00:00
|
|
|
static inline int
|
2019-02-20 16:15:18 +00:00
|
|
|
mt76u_bulk_msg(struct mt76_dev *dev, void *data, int len, int *actual_len,
|
2020-01-15 10:58:57 +00:00
|
|
|
int timeout, int ep)
|
2019-02-11 08:16:14 +00:00
|
|
|
{
|
2019-10-28 15:21:41 +00:00
|
|
|
struct usb_interface *uintf = to_usb_interface(dev->dev);
|
|
|
|
struct usb_device *udev = interface_to_usbdev(uintf);
|
2019-02-11 08:16:14 +00:00
|
|
|
struct mt76_usb *usb = &dev->usb;
|
|
|
|
unsigned int pipe;
|
|
|
|
|
2019-02-20 16:15:18 +00:00
|
|
|
if (actual_len)
|
2020-01-15 10:58:57 +00:00
|
|
|
pipe = usb_rcvbulkpipe(udev, usb->in_ep[ep]);
|
2019-02-20 16:15:18 +00:00
|
|
|
else
|
2020-01-15 10:58:57 +00:00
|
|
|
pipe = usb_sndbulkpipe(udev, usb->out_ep[ep]);
|
2019-02-20 16:15:18 +00:00
|
|
|
|
|
|
|
return usb_bulk_msg(udev, pipe, data, len, actual_len, timeout);
|
2019-02-11 08:16:14 +00:00
|
|
|
}
|
|
|
|
|
2020-09-05 09:26:04 +00:00
|
|
|
int mt76_skb_adjust_pad(struct sk_buff *skb, int pad);
|
2018-07-31 08:09:19 +00:00
|
|
|
int mt76u_vendor_request(struct mt76_dev *dev, u8 req,
|
|
|
|
u8 req_type, u16 val, u16 offset,
|
|
|
|
void *buf, size_t len);
|
|
|
|
void mt76u_single_wr(struct mt76_dev *dev, const u8 req,
|
|
|
|
const u16 offset, const u32 val);
|
2020-01-15 10:58:54 +00:00
|
|
|
int mt76u_init(struct mt76_dev *dev, struct usb_interface *intf,
|
|
|
|
bool ext);
|
2020-01-15 10:58:53 +00:00
|
|
|
int mt76u_alloc_mcu_queue(struct mt76_dev *dev);
|
2018-07-31 08:09:19 +00:00
|
|
|
int mt76u_alloc_queues(struct mt76_dev *dev);
|
2019-04-26 07:58:41 +00:00
|
|
|
void mt76u_stop_tx(struct mt76_dev *dev);
|
|
|
|
void mt76u_stop_rx(struct mt76_dev *dev);
|
|
|
|
int mt76u_resume_rx(struct mt76_dev *dev);
|
2018-07-31 08:09:19 +00:00
|
|
|
void mt76u_queues_deinit(struct mt76_dev *dev);
|
|
|
|
|
2020-07-15 12:46:30 +00:00
|
|
|
int mt76s_init(struct mt76_dev *dev, struct sdio_func *func,
|
|
|
|
const struct mt76_bus_ops *bus_ops);
|
|
|
|
int mt76s_alloc_queues(struct mt76_dev *dev);
|
|
|
|
void mt76s_deinit(struct mt76_dev *dev);
|
|
|
|
|
2019-02-04 16:51:27 +00:00
|
|
|
struct sk_buff *
|
2020-04-02 18:18:48 +00:00
|
|
|
mt76_mcu_msg_alloc(struct mt76_dev *dev, const void *data,
|
|
|
|
int data_len);
|
2019-02-04 16:51:29 +00:00
|
|
|
void mt76_mcu_rx_event(struct mt76_dev *dev, struct sk_buff *skb);
|
2019-02-04 16:51:28 +00:00
|
|
|
struct sk_buff *mt76_mcu_get_response(struct mt76_dev *dev,
|
|
|
|
unsigned long expires);
|
2020-09-30 03:03:21 +00:00
|
|
|
int mt76_mcu_send_and_get_msg(struct mt76_dev *dev, int cmd, const void *data,
|
|
|
|
int len, bool wait_resp, struct sk_buff **ret);
|
|
|
|
int mt76_mcu_skb_send_and_get_msg(struct mt76_dev *dev, struct sk_buff *skb,
|
|
|
|
int cmd, bool wait_resp, struct sk_buff **ret);
|
2020-10-14 10:03:58 +00:00
|
|
|
int mt76_mcu_send_firmware(struct mt76_dev *dev, int cmd, const void *data,
|
|
|
|
int len);
|
2020-09-30 03:03:21 +00:00
|
|
|
static inline int
|
|
|
|
mt76_mcu_send_msg(struct mt76_dev *dev, int cmd, const void *data, int len,
|
|
|
|
bool wait_resp)
|
|
|
|
{
|
|
|
|
return mt76_mcu_send_and_get_msg(dev, cmd, data, len, wait_resp, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int
|
|
|
|
mt76_mcu_skb_send_msg(struct mt76_dev *dev, struct sk_buff *skb, int cmd,
|
|
|
|
bool wait_resp)
|
|
|
|
{
|
|
|
|
return mt76_mcu_skb_send_and_get_msg(dev, skb, cmd, wait_resp, NULL);
|
|
|
|
}
|
2019-02-04 16:51:27 +00:00
|
|
|
|
2019-02-28 16:54:31 +00:00
|
|
|
void mt76_set_irq_mask(struct mt76_dev *dev, u32 addr, u32 clear, u32 set);
|
|
|
|
|
2017-11-21 09:50:52 +00:00
|
|
|
#endif
|