History log of /linux-master/drivers/net/wireless/mediatek/mt76/mt7603/mac.c
Revision Date Author Comments
# c677dda1 28-Jul-2023 Felix Fietkau <nbd@nbd.name>

wifi: mt76: mt7603: improve watchdog reset reliablity

Only trigger PSE reset if PSE was stuck, otherwise it can cause DMA issues.
Trigger the PSE reset while DMA is fully stopped in order to improve
reliabilty.

Fixes: c8846e101502 ("mt76: add driver for MT7603E and MT7628/7688")
Signed-off-by: Felix Fietkau <nbd@nbd.name>


# baa19b2e 28-Jul-2023 Felix Fietkau <nbd@nbd.name>

wifi: mt76: mt7603: rework/fix rx pse hang check

It turns out that the code in mt7603_rx_pse_busy() does not detect actual
hardware hangs, it only checks for busy conditions in PSE.
A reset should only be performed if these conditions are true and if there
is no rx activity as well.
Reset the counter whenever a rx interrupt occurs. In order to also deal with
a fully loaded CPU that leaves interrupts disabled with continuous NAPI
polling, also check for pending rx interrupts in the function itself.

Fixes: c8846e101502 ("mt76: add driver for MT7603E and MT7628/7688")
Signed-off-by: Felix Fietkau <nbd@nbd.name>


# fe0ea395 25-Jul-2023 Felix Fietkau <nbd@nbd.name>

wifi: mt76: mt7603: fix tx filter/flush function

Setting MT_TX_ABORT does not abort any transmission for a wtbl index on its
own. Instead, it modifies the behavior of a queue flush to make it selectively
flush packets for a particular wtbl index.
Adjust powersave filtering to make use of this in order to avoid running into
unnecessary timeouts while flushing

Signed-off-by: Felix Fietkau <nbd@nbd.name>


# 2d29058e 22-Jun-2023 Lorenzo Bianconi <lorenzo@kernel.org>

wifi: mt76: mt7603: rely on shared poll_list field

Rely on poll_list field in mt76_wcid structure and get rid of
private copy.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>


# c55e898b 22-Jun-2023 Lorenzo Bianconi <lorenzo@kernel.org>

wifi: mt76: mt7603: rely on shared sta_poll_list and sta_poll_lock

Rely on sta_poll_list and sta_poll_lock fields in mt76_dev structure
and get rid of private copies.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>


# 5b8ccdfb 14-Apr-2023 Felix Fietkau <nbd@nbd.name>

wifi: mt76: add missing locking to protect against concurrent rx/status calls

According to the documentation, ieee80211_rx_list must not run concurrently
with ieee80211_tx_status (or its variants).

Cc: stable@vger.kernel.org
Fixes: 88046b2c9f6d ("mt76: add support for reporting tx status with skb")
Reported-by: Brian Coverstone <brian@mainsequence.net>
Signed-off-by: Felix Fietkau <nbd@nbd.name>


# d107501a 02-Nov-2022 Lorenzo Bianconi <lorenzo@kernel.org>

wifi: mt76: move aggr_stats array in mt76_phy

Move aggregation stats array per-phy instead of share it between multiple
interfaces. This is a preliminary patch to add mt7996 driver support.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>


# 046d2e7c 04-Apr-2022 Sriram R <quic_srirrama@quicinc.com>

mac80211: prepare sta handling for MLO support

Currently in mac80211 each STA object is represented
using sta_info datastructure with the associated
STA specific information and drivers access ieee80211_sta
part of it.

With MLO (Multi Link Operation) support being added
in 802.11be standard, though the association is logically
with a single Multi Link capable STA, at the physical level
communication can happen via different advertised
links (uniquely identified by Channel, operating class,
BSSID) and hence the need to handle multiple link
STA parameters within a composite sta_info object
called the MLD STA. The different link STA part of
MLD STA are identified using the link address which can
be same or different as the MLD STA address and unique
link id based on the link vif.

To support extension of such a model, the sta_info
datastructure is modified to hold multiple link STA
objects with link specific params currently within
sta_info moved to this new structure. Similarly this is
done for ieee80211_sta as well which will be accessed
within mac80211 as well as by drivers, hence trivial
driver changes are expected to support this.

For current non MLO supported drivers, only one link STA
is present and link information is accessed via 'deflink'
member.

For MLO drivers, we still need to define the APIs etc. to
get the correct link ID and access the correct part of
the station info.

Currently in mac80211, all link STA info are accessed directly
via deflink. These will be updated to access via link pointers
indexed by link id with MLO support patches, with link id
being 0 for non MLO supported cases.

Except for couple of macro related changes, below spatch takes
care of updating mac80211 and driver code to access to the
link STA info via deflink.

@ieee80211_sta@
struct ieee80211_sta *s;
struct sta_info *si;
identifier var = {supp_rates, ht_cap, vht_cap, he_cap, he_6ghz_capa, eht_cap, rx_nss, bandwidth, txpwr};
@@

(
s->
- var
+ deflink.var
|
si->sta.
- var
+ deflink.var
)

@sta_info@
struct sta_info *si;
identifier var = {gtk, pcpu_rx_stats, rx_stats, rx_stats_avg, status_stats, tx_stats, cur_max_bandwidth};
@@

(
si->
- var
+ deflink.var
)

Signed-off-by: Sriram R <quic_srirrama@quicinc.com>
Link: https://lore.kernel.org/r/1649086883-13246-1-git-send-email-quic_srirrama@quicinc.com
[remove MLO-drivers notes from commit message, not clear yet; run spatch]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>


# f1fe8eef 08-Mar-2022 Ryder Lee <ryder.lee@mediatek.com>

mt76: use le32/16_get_bits() whenever possible

Switch to use le32/16_get_bits() to simplfy codes and specify
the size explicitly to avoid potential issues.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>


# 4550fb9e 04-Feb-2022 Felix Fietkau <nbd@nbd.name>

mt76: improve signal strength reporting

Instead of just taking the maximum per-chain signal strength values,
add an approximation for the sum of the combined signal.
This should more accurately reflect the real signal strength, especially
if the per-chain signal strength values are close to each other

Signed-off-by: Felix Fietkau <nbd@nbd.name>


# 15965d8c 25-Nov-2021 Felix Fietkau <nbd@nbd.name>

mt76: mt7603: improve reliability of tx powersave filtering

Leave more time to abort transmissions (which could happen at low CCK rates)
Only warn if the last filter command is stuck

Signed-off-by: Felix Fietkau <nbd@nbd.name>


# dd28dea5 18-Nov-2021 Xing Song <xing.song@mediatek.com>

mt76: do not pass the received frame with decryption error

MAC80211 doesn't care any decryption error in 802.3 path, so received
frame will be dropped if HW tell us that the cipher configuration is not
matched as well as the header has been translated to 802.3. This case only
appears when IEEE80211_FCTL_PROTECTED is 0 and cipher suit is not none in
the corresponding HW entry.

The received frame is only reported to monitor interface if HW decryption
block tell us there is ICV error or CCMP/BIP/WPI MIC error. Note in this
case the reported frame is decrypted 802.11 frame and the payload may be
malformed due to mismatched key.

Signed-off-by: Xing Song <xing.song@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>


# c02f86ee 13-Sep-2021 Lorenzo Bianconi <lorenzo@kernel.org>

mt76: remove mt76_wcid pointer from mt76_tx_status_check signature

Remove mt76_wcid pointer from mt76_tx_status_check signature since it is
always set to NULL

Tested-by: mrkiko.rs@gmail.com
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>


# 970be1df 24-Sep-2021 Felix Fietkau <nbd@nbd.name>

mt76: disable BH around napi_schedule() calls

napi_schedule() can call __raise_softirq_irqoff(), which can perform softirq
handling, so it must not be called in a pure process context with BH enabled.

Signed-off-by: Felix Fietkau <nbd@nbd.name>


# c368362c 17-Jun-2021 Ryder Lee <ryder.lee@mediatek.com>

mt76: fix iv and CCMP header insertion

The iv from RXD is only for TKIP_RSC/CCMP_PN/GCMP_PN, and it needs a
check for CCMP header insertion. Move mt76_cipher_type to mt76.h to
reduce duplicated code.

Signed-off-by: Xing Song <xing.song@mediatek.com>
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>


# c560b137 10-Jun-2021 Ryder Lee <ryder.lee@mediatek.com>

mt76: make mt76_update_survey() per phy

Reduce duplicated survey for DBDC.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>


# 1d85dc67 07-May-2021 Felix Fietkau <nbd@nbd.name>

mt76: mt7603: avoid use of ieee80211_tx_info_clear_status

It overwrites mt76_tx_cb data in the skb

Signed-off-by: Felix Fietkau <nbd@nbd.name>


# 6929d1d7 13-Apr-2021 Felix Fietkau <nbd@nbd.name>

mt76: flush tx status queue on DMA reset

After DMA reset, tx status information for queued frames will never arrive.
Flush the queue to free skbs immediately instead of waiting for a timeout

Signed-off-by: Felix Fietkau <nbd@nbd.name>


# 0fda6d7b 29-Mar-2021 Ryder Lee <ryder.lee@mediatek.com>

mt76: report Rx timestamp

Frame reception timestamp (low 32-bits) that indicates the value of the
local TSF timer value at the time the first bit of the MAC header in the
received frame (PPDU unit) arriving at the MAC.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>


# e195dad1 16-Dec-2020 Felix Fietkau <nbd@nbd.name>

mt76: add support for 802.3 rx frames

Do not try to access the header when receiving them

Signed-off-by: Felix Fietkau <nbd@nbd.name>


# 17cb5465 14-Oct-2020 Felix Fietkau <nbd@nbd.name>

mt76: mt7603: fix ED/CCA monitoring with single-stream devices

Do not use the RSSI values of the unavailable chain

Signed-off-by: Felix Fietkau <nbd@nbd.name>


# a782f8bf 04-Jan-2021 Lorenzo Bianconi <lorenzo@kernel.org>

mt76: move mac_work in mt76_core module

Move mac_work delayed_work and mac_work_count in mt76_phy since it is
used by all drivers. This is a preliminary patch to create a common mcu
library used by mt7615 and mt7921 drivers

Co-developed-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>


# 91990519 11-Nov-2020 Lorenzo Bianconi <lorenzo@kernel.org>

mt76: move tx hw data queues in mt76_phy

Move hw data queues in mt76_phy from mt76_dev since mt7915 supports per
phy hw queues in dbdc mode

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>


# e637763b 11-Nov-2020 Lorenzo Bianconi <lorenzo@kernel.org>

mt76: move mcu queues to mt76_dev q_mcu array

Move mcu queue to a dedicated array q_mcu in mt76_dev structure.
This is a preliminary patch to move data queues in mt76_phy and properly
support dbdc

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>


# e5655492 11-Nov-2020 Lorenzo Bianconi <lorenzo@kernel.org>

mt76: dma: rely on mt76_queue in mt76_dma_tx_cleanup signature

This is a preliminary patch to move data queues in mt76_phy and properly
support dbdc

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>


# aab662cc 31-Aug-2020 Gustavo A. R. Silva <gustavoars@kernel.org>

mt76: Use fallthrough pseudo-keyword

Replace the existing /* fall through */ comments and its variants with
the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary
fall-through markings when it is the case.

[1] https://www.kernel.org/doc/html/v5.7/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through

Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>


# 781eef5b 24-Jul-2020 Felix Fietkau <nbd@nbd.name>

mt76: convert from tx tasklet to tx worker thread

This improves performance by allowing the scheduler to move the tx scheduling
work to idle CPUs. Since tx scheduling work is very latency sensitive and
kept short via AQL, sched_set_fifo_low is used to keep worker priority above
normal tasks

Signed-off-by: Felix Fietkau <nbd@nbd.name>


# f099c2e5 23-Aug-2020 Felix Fietkau <nbd@nbd.name>

mt76: remove struct mt76_sw_queue

All members except for the struct mt76_queue pointer have been removed

Signed-off-by: Felix Fietkau <nbd@nbd.name>


# e1378e52 23-Aug-2020 Felix Fietkau <nbd@nbd.name>

mt76: rely on AQL for burst size limits on tx queueing

Now that AQL works well on all mt76 drivers, completely replace the arbitrary
burst sizing and number of bursts logic for tx scheduling.
For the short period of time in which AQL does not work well yet, limit each
stations to 16 in-flight packets that have no estimated tx time.
This should avoid filling the queue if a station connects and queues up a
large number of packets before rate control information is available, especially
with hardware rate control

Signed-off-by: Felix Fietkau <nbd@nbd.name>


# d80e52c7 23-Aug-2020 Felix Fietkau <nbd@nbd.name>

mt76: remove qid argument to drv->tx_complete_skb

It is not needed

Signed-off-by: Felix Fietkau <nbd@nbd.name>


# c50d105a 28-Jul-2020 Felix Fietkau <nbd@nbd.name>

mt76: move mt76_check_agg_ssn to driver tx_prepare calls

mt7615 and newer drivers do not need this, since they use sequence number offload
Moving this code also reduces the number of callsites to make it easier to review

Signed-off-by: Felix Fietkau <nbd@nbd.name>


# f473b42a 24-May-2020 Felix Fietkau <nbd@nbd.name>

mt76: only iterate over initialized rx queues

Fixes the following reported crash:

[ 2.361127] BUG: spinlock bad magic on CPU#0, modprobe/456
[ 2.361583] lock: 0xffffa1287525b3b8, .magic: 00000000, .owner: <none>/-1, .owner_cpu: 0
[ 2.362250] CPU: 0 PID: 456 Comm: modprobe Not tainted 4.14.177 #5
[ 2.362751] Hardware name: HP Meep/Meep, BIOS Google_Meep.11297.75.0 06/17/2019
[ 2.363343] Call Trace:
[ 2.363552] dump_stack+0x97/0xdb
[ 2.363826] ? spin_bug+0xa6/0xb3
[ 2.364096] do_raw_spin_lock+0x6a/0x9a
[ 2.364417] mt76_dma_rx_fill+0x44/0x1de [mt76]
[ 2.364787] ? mt76_dma_kick_queue+0x18/0x18 [mt76]
[ 2.365184] mt76_dma_init+0x53/0x85 [mt76]
[ 2.365532] mt7615_dma_init+0x3d7/0x546 [mt7615e]
[ 2.365928] mt7615_register_device+0xe6/0x1a0 [mt7615e]
[ 2.366364] mt7615_mmio_probe+0x14b/0x171 [mt7615e]
[ 2.366771] mt7615_pci_probe+0x118/0x13b [mt7615e]
[ 2.367169] pci_device_probe+0xaf/0x13d
[ 2.367491] driver_probe_device+0x284/0x2ca
[ 2.367840] __driver_attach+0x7a/0x9e
[ 2.368146] ? driver_attach+0x1f/0x1f
[ 2.368451] bus_for_each_dev+0xa0/0xdb
[ 2.368765] bus_add_driver+0x132/0x204
[ 2.369078] driver_register+0x8e/0xcd
[ 2.369384] do_one_initcall+0x160/0x257
[ 2.369706] ? 0xffffffffc0240000
[ 2.369980] do_init_module+0x60/0x1bb
[ 2.370286] load_module+0x18c2/0x1a2b
[ 2.370596] ? kernel_read_file+0x141/0x1b9
[ 2.370937] ? kernel_read_file_from_fd+0x46/0x71
[ 2.371320] SyS_finit_module+0xcc/0xf0
[ 2.371636] do_syscall_64+0x6b/0xf7
[ 2.371930] entry_SYSCALL_64_after_hwframe+0x3d/0xa2
[ 2.372344] RIP: 0033:0x7da218ae4199
[ 2.372637] RSP: 002b:00007fffd0608398 EFLAGS: 00000246 ORIG_RAX: 0000000000000139
[ 2.373252] RAX: ffffffffffffffda RBX: 00005a705449df90 RCX: 00007da218ae4199
[ 2.373833] RDX: 0000000000000000 RSI: 00005a7052e73bd8 RDI: 0000000000000006
[ 2.374411] RBP: 00007fffd06083e0 R08: 0000000000000000 R09: 00005a705449d540
[ 2.374989] R10: 0000000000000006 R11: 0000000000000246 R12: 0000000000000000
[ 2.375569] R13: 00005a705449def0 R14: 00005a7052e73bd8 R15: 0000000000000000

Reported-by: Sean Wang <sean.wang@mediatek.com>
Fixes: d3377b78cec6 ("mt76: add HE phy modes and hardware queue")
Signed-off-by: Felix Fietkau <nbd@nbd.name>


# 238f5d6f 20-May-2020 Felix Fietkau <nbd@nbd.name>

mt76: fix per-driver wcid range checks after wcid array size bump

All drivers before MT7915 have a limit of 128 WCID entries. Stop relying
on ARRAY_SIZE(dev->mt76.wcid), since it no longer reflects that limit.

Fixes: 49e649c3e0a6 ("mt76: adjust wcid size to support new 802.11ax generation")
Reported-by: kbuild test robot <lkp@intel.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>


# 40a61c9b 22-Apr-2020 Felix Fietkau <nbd@nbd.name>

mt76: mt7603: fix tx status rate index calculation

A switch from one rate index to the next only happens when tx count from
the current slot is greater than MT7615_RATE_RETRY, which is 1 has to be
subtracted from count, instead of added to it.

Signed-off-by: Felix Fietkau <nbd@nbd.name>


# e0b4fe83 22-Apr-2020 Felix Fietkau <nbd@nbd.name>

mt76: mt7603: never use an 802.11b CF-End rate on 5GHz

Sometimes mt7615_mac_set_timing gets called while the slot time is still
configured to 20. Ensure that in this case it always uses the OFDM CFend
rate.

Signed-off-by: Felix Fietkau <nbd@nbd.name>


# 55961d8b 20-Apr-2020 Felix Fietkau <nbd@nbd.name>

mt76: fix A-MPDU density handling

The hardware requirements for A-MPDU density are entirely on the tx side,
not the rx side. Because of that, the IE value should stay at 0 and the
minimum value should instead be enforced in WTBL/TXWI

MT7615 has no restrictions here

Signed-off-by: Felix Fietkau <nbd@nbd.name>


# e9415009 26-Feb-2019 Felix Fietkau <nbd@nbd.name>

mt76: mt7603: make dynamic sensitivity adjustment configurable via debugfs

In some cases it may be useful for debugging to disable this feature

Signed-off-by: Felix Fietkau <nbd@nbd.name>


# 633348f2 22-Feb-2020 Felix Fietkau <nbd@nbd.name>

mt76: mt7603: add upper limit for dynamic sensitivity minimum receive power

If the minimum power is raised too much, it can make it impossible for weaker
clients to connect, and there are some scenarios where the false detects will
not go down no matter how much the sensitivity is adjusted.
Fixes connectivity issues in some rare cases

Signed-off-by: Felix Fietkau <nbd@nbd.name>


# 5498974b 29-Dec-2019 Lorenzo Bianconi <lorenzo@kernel.org>

mt76: move mac_txdone tracepoint in mt76 module

Move mac_txdone tracepoint in common code in order to
be reused by mt7603 and mt7615 drivers

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>


# 30684481 06-Nov-2019 Felix Fietkau <nbd@nbd.name>

mt76: move ampdu_ref from mt76_dev to driver struct

It is only used by the driver

Signed-off-by: Felix Fietkau <nbd@nbd.name>


# 8af63fed 16-Oct-2019 Felix Fietkau <nbd@nbd.name>

mt76: add multiple wiphy support to mt76_get_min_avg_rssi

Allow tracking clients of both wiphys separately

Signed-off-by: Felix Fietkau <nbd@nbd.name>


# beaaeb6b 15-Oct-2019 Felix Fietkau <nbd@nbd.name>

mt76: move txpower and antenna mask to struct mt76_phy

Adds multiple wiphy support to mt76_get_txpower

Signed-off-by: Felix Fietkau <nbd@nbd.name>


# 011849e0 15-Oct-2019 Felix Fietkau <nbd@nbd.name>

mt76: move state from struct mt76_dev to mt76_phy

Allows keeping per-wiphy state separate

Signed-off-by: Felix Fietkau <nbd@nbd.name>


# 5a95ca41 14-Oct-2019 Felix Fietkau <nbd@nbd.name>

mt76: keep a set of software tx queues per phy

Allows tracking tx scheduling separately per phy

Signed-off-by: Felix Fietkau <nbd@nbd.name>


# 96747a51 12-Oct-2019 Felix Fietkau <nbd@nbd.name>

mt76: move channel state to struct mt76_phy

Add support for an extra wiphy in mt76_set_channel and mt76_get_survey
This is preparation for supporting multiple wiphys per device to support the
concurrent dual-band feature of MT7615D

Signed-off-by: Felix Fietkau <nbd@nbd.name>


# 9fba6d07 11-Oct-2019 Felix Fietkau <nbd@nbd.name>

mt76: add support for an extra wiphy in the main tx path

This is preparation for supporting multiple wiphys per device to support the
concurrent dual-band feature of MT7615D

Signed-off-by: Felix Fietkau <nbd@nbd.name>


# e8b970c8 06-Nov-2019 Lorenzo Bianconi <lorenzo@kernel.org>

mt76: fix possible out-of-bound access in mt7615_fill_txs/mt7603_fill_txs

Fix possible out-of-bound access of status rates array in
mt7615_fill_txs/mt7603_fill_txs routines

Fixes: c5211e997eca ("mt76: mt7603: rework and fix tx status reporting")
Fixes: 4af81f02b49c ("mt76: mt7615: sync with mt7603 rate control changes")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>


# aec65e48 05-Sep-2019 Felix Fietkau <nbd@nbd.name>

mt76: unify channel survey update code

Host time is used to calculate the channel active time on mt7603 and mt7615.
Use the same on mt76x02 and move the lock to core code to get rid of some
duplicated code.

Signed-off-by: Felix Fietkau <nbd@nbd.name>


# dcff8d4d 04-Sep-2019 Felix Fietkau <nbd@nbd.name>

mt76: mt7603: switch to a different counter for survey busy time

MT_MIB_STAT_PSCCA only counts rx CCA busy time, which does not include
tx time. MT_MIB_STAT_CCA counts full busy time, including Rx, Tx and NAV

Signed-off-by: Felix Fietkau <nbd@nbd.name>


# ea565833 04-Sep-2019 Felix Fietkau <nbd@nbd.name>

mt76: mt7603: track tx airtime for airtime fairness and survey

Poll per-station hardware counters after tx status events

Signed-off-by: Felix Fietkau <nbd@nbd.name>


# 5ce09c1a 04-Sep-2019 Felix Fietkau <nbd@nbd.name>

mt76: track rx airtime for airtime fairness and survey

Report total rx airtime for valid stations as BSS rx time in survey

mt7615 is left out for now, it will be supported later by reading
hardware counters instead of calculating airtime in software

Signed-off-by: Felix Fietkau <nbd@nbd.name>


# 0fd0eb54 05-Sep-2019 Felix Fietkau <nbd@nbd.name>

mt76: store current channel survey_state in struct mt76_dev

Move mt76_channel_state() from mt76.h to mac80211.c
Preparation for updating channel state from more places in the drivers/core

Signed-off-by: Felix Fietkau <nbd@nbd.name>


# d515fdca 28-Aug-2019 Felix Fietkau <nbd@nbd.name>

mt76: report rx a-mpdu subframe status

This can be used in monitor mode to figure out which subframes were sent as
part of which A-MPDU

Signed-off-by: Felix Fietkau <nbd@nbd.name>


# 5a8d4678 13-Sep-2019 Lorenzo Bianconi <lorenzo@kernel.org>

mt76: mt7603: collect aggregation stats

Introduce ampdu_stat entry in mt7603 debugfs in order to dump 802.11
aggr cumulative statistics

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>


# fc98e670 05-Aug-2019 Lorenzo Bianconi <lorenzo@kernel.org>

mt76: mt7603: move survey_time in mt76_dev

Move survey_time field in mt76_dev in order to be reused adding survey
support to mt7615 driver

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>


# 7f17b86a 24-Jul-2019 Ryder Lee <ryder.lee@mediatek.com>

mt76: mt7603: fix some checkpatch warnings

This fixes the following checkpatch warnings:

WARNING: Improper SPDX comment style
CHECK: No space is necessary after a cast

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>


# 820e4da1 12-Jul-2019 Felix Fietkau <nbd@nbd.name>

mt76: mt7603: fix invalid fallback rates

Only decrement the rate index on duplicate rates if it is not already 0

Signed-off-by: Felix Fietkau <nbd@nbd.name>


# c5211e99 24-Jun-2019 Felix Fietkau <nbd@nbd.name>

mt76: mt7603: rework and fix tx status reporting

Tx status reporting on mt7603 has a number of issues:

- the hardware can alter the first rate index, but it is not reported to
the driver
- probing is very imprecise, because it alters the per-client rate set,
but only considers info->status.rates for rate selection of a single probe
packet
- short/long GI selection has limitations, which are not accurately reported
to mac80211
- if rates are changed while packets are in flight, tx status reports for
the old rate set might be processed based on the new selection

This led to very suboptimal rate selection with minstrel_ht.

This patch completely reworks tx status reporting to get rid of these
limitations:

- Store the previous and current rate set in the driver + the TSF value
at the time of the switch.
- Use the tx status TSF value to determine which rate set needs to be used
as reference.
- Report only short or long GI rates for a single status event, not a mix.
- The hardware reports the last used rate index. Use it along with the
retry count to figure out what rate was used for the first attempt.
- Use the same retry count value for all rate slots to make this calculation
work.
- Derive the probe rate from the current rateset instead of the skb cb
- Do not wait for a status report for the probe frame before removing the
probe rate from the rate table. Do it immediately after it was referenced
in a tx status report.
- Use the first half of the first rate retry budget for the probe rate
in order to avoid using too many retries on that rate

With this patch, throughput under bad link conditions is improved
significantly, and there is a lot less rate fluctuation going on.

Signed-off-by: Felix Fietkau <nbd@nbd.name>


# d3edd108 29-May-2019 YueHaibing <yuehaibing@huawei.com>

mt76: Remove set but not used variables 'pid' and 'final_mpdu'

Fixes gcc '-Wunused-but-set-variable' warnings:

drivers/net/wireless/mediatek/mt76/mt7603/mac.c: In function mt7603_fill_txs:
drivers/net/wireless/mediatek/mt76/mt7603/mac.c:969:5: warning: variable pid set but not used [-Wunused-but-set-variable]
drivers/net/wireless/mediatek/mt76/mt7603/mac.c:961:7: warning: variable final_mpdu set but not used [-Wunused-but-set-variable]
drivers/net/wireless/mediatek/mt76/mt7615/mac.c: In function mt7615_fill_txs:
drivers/net/wireless/mediatek/mt76/mt7615/mac.c:555:5: warning: variable pid set but not used [-Wunused-but-set-variable]
drivers/net/wireless/mediatek/mt76/mt7615/mac.c:552:19: warning: variable final_mpdu set but not used [-Wunused-but-set-variable]

They are never used, so can be removed.

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>


# d2679d65 29-May-2019 Lorenzo Bianconi <lorenzo@kernel.org>

mt76: move mt76_get_rate in mt76-module

Move mt7603_get_rate in mac80211.c and rename it to mt76_get_rate
since it is shared between mt7603 and mt7615 drivers

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>


# eadfd98f 14-May-2019 Lorenzo Bianconi <lorenzo@kernel.org>

mt76: move mt76_insert_ccmp_hdr in mt76-module

Move mt7615_insert_ccmp_hdr in mac80211.c and rename it in
mt76_insert_ccmp_hdr since it is shared between mt7603 and mt7615
drivers

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>


# 9e63f5e7 01-May-2019 Lorenzo Bianconi <lorenzo@kernel.org>

mt76: mt7603: use napi polling for tx cleanup

This allows tx scheduling and tx cleanup to run concurrently

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>


# dc6057f4 30-Apr-2019 Lorenzo Bianconi <lorenzo@kernel.org>

mt76: move pre_tbtt_tasklet in mt76_dev

Move pre_tbtt_tasklet tasklet in mt76_dev data structure since
it is used by all drivers

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>


# 3041c445 29-Apr-2019 Lorenzo Bianconi <lorenzo@kernel.org>

mt76: move beacon_int in mt76_dev

Move beacon_int in mt76_dev data structure since it is used by
all drivers

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>


# e8027946 26-Apr-2019 Ryder Lee <ryder.lee@mediatek.com>

mt76: fix endianness sparse warnings

Fix many warnings with incorrect endian assumptions.

Reported-by: kbuild test robot <lkp@intel.com>
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Reviewed-by: Stanislaw Gruszka <sgruszka@redhat.com
Signed-off-by: Felix Fietkau <nbd@nbd.name>


# b183878a 01-Apr-2019 Ryder Lee <ryder.lee@mediatek.com>

mt76: use macro for sn and seq_ctrl conversion

Use macro to convert sn and seq_ctrl for better readability.

Signed-off-by: Roy Luo <royluo@google.com>
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>


# cfaae9e6 02-Apr-2019 Lorenzo Bianconi <lorenzo@kernel.org>

mt76: add skb pointer to mt76_tx_info

Pass skb pointer to tx_prepare_skb through mt76_tx_info data structure.
This is a preliminary patch to properly support dma error path for
new chipsets (e.g. 7615)

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>


# 37426fb6 18-Mar-2019 Lorenzo Bianconi <lorenzo@kernel.org>

mt76: move mac_work in mt76_dev

Move mac_work delayed work in mt76_dev data structure since
it is used by all drivers and it will be reused adding mac work to
mt7615

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>


# a33b8ab8 13-Mar-2019 Felix Fietkau <nbd@nbd.name>

mt76: move tx tasklet to struct mt76_dev

Allows it to be scheduled from core code

Signed-off-by: Felix Fietkau <nbd@nbd.name>


# db9f11d3 13-Mar-2019 Felix Fietkau <nbd@nbd.name>

mt76: store wcid tx rate info in one u32 reduce locking

Signed-off-by: Felix Fietkau <nbd@nbd.name>


# d908d4ec 23-Mar-2019 Felix Fietkau <nbd@nbd.name>

mt76: use readl/writel instead of ioread32/iowrite32

Switching to readl/writel is faster because it gets rid of an unnecessary
wrapper with extra checks.

Signed-off-by: Felix Fietkau <nbd@nbd.name>


# b5903c47 14-Mar-2019 Lorenzo Bianconi <lorenzo@kernel.org>

mt76: introduce mt76_tx_info data structure

Add mt76_tx_info as auxiliary data structure to pass values
to tx_prepare_skb pointer. This is a preliminary patch to add
support for new chipsets (e.g. mt7615)

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>


# af005f26 02-Mar-2019 Lorenzo Bianconi <lorenzo@kernel.org>

mt76: introduce mt76_sw_queue data structure

Introduce mt76_sw_queue data structure in order to support new
chipsets (e.g. mt7615) that have a shared hardware queue for all traffic
identifiers. mt76_sw_queue will be used to track outstanding packets

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>


# e226ba2e 02-Mar-2019 Lorenzo Bianconi <lorenzo@kernel.org>

mt76: remove mt76_queue dependency from tx_complete_skb function pointer

Remove mt76_queue dependency from tx_complete_skb function pointer and
rely on mt76_tx_qid instead. Remove flush from tx_complete_skb
signature. This is a preliminary patch to introduce mt76_sw_queue
support

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>


# 300832ad 02-Mar-2019 Lorenzo Bianconi <lorenzo@kernel.org>

mt76: remove mt76_queue dependency from tx_prepare_skb function pointer

Remove mt76_queue dependency from tx_prepare_skb function pointer and
rely on mt76_tx_qid instead. This is a preliminary patch to introduce
mt76_sw_queue support

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>


# aa3cb24b 26-Mar-2019 Felix Fietkau <nbd@nbd.name>

mt76: mt7603: fix sequence number assignment

If the MT_TXD3_SN_VALID flag is not set in the tx descriptor, the hardware
assigns the sequence number. However, the rest of the code assumes that the
sequence number specified in the 802.11 header gets transmitted.
This was causing issues with the aggregation setup, which worked for the
initial one (where the sequence numbers were still close), but not for
further teardown/re-establishing of sessions.

Additionally, the overwrite of the TID sequence number in WTBL2 was resetting
the hardware assigned sequence numbers, causing them to drift further apart.

Fix this by using the software assigned sequence numbers

Signed-off-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>


# 76352769 03-Mar-2019 Felix Fietkau <nbd@nbd.name>

mt76: mt7603: fix tx status HT rate validation

Use the correct variable in the check. Fixes an uninitialized variable warning

Reported-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Fixes: c8846e1015022 ("mt76: add driver for MT7603E and MT7628/7688")
Signed-off-by: Felix Fietkau <nbd@nbd.name>


# c8846e10 06-Nov-2018 Felix Fietkau <nbd@nbd.name>

mt76: add driver for MT7603E and MT7628/7688

This driver is for a newer generation of 2x2 MediaTek 802.11n chipsets.
MT7603E is a PCIe chip.
MT7628 and MT7688 are MIPS SoC devices with built-in WLAN.
MT7688 is limited to 1x1

This driver fully supports AP, station, mesh, ad-hoc and monitor mode.

Signed-off-by: Felix Fietkau <nbd@nbd.name>