33783 Commits

Author SHA1 Message Date
Gustavo A. R. Silva
f12758f6f9 mt76: mt7615: Fix fall-through warnings for Clang
In preparation to enable -Wimplicit-fallthrough for Clang, fix a
warning by replacing a /* fall through */ comment with the new
pseudo-keyword macro fallthrough; instead of letting the code fall
through to the next case.

Notice that Clang doesn't recognize /* fall through */ comments as
implicit fall-through markings.

Link: https://github.com/KSPP/linux/issues/115
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-12-04 22:24:54 +01:00
Shayne Chen
bacf5047bb mt76: mt7915: fix ht mcs in mt7915_mcu_get_rx_rate()
The mcs value of HT mode reported by mt7915_mcu_get_rx_rate()
has already been converted to the expected format.

Tested-by: Yiwei Chung <yiwei.chung@mediatek.com>
Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-12-04 22:24:48 +01:00
Felix Fietkau
9716ef046b mt76: attempt to free up more room when filling the tx queue
Run dma cleanup immediately if the queue is almost full, instead of waiting
for the tx interrupt

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-12-04 14:31:16 +01:00
Felix Fietkau
5342758d55 mt76: mt7915: stop queues when running out of tx tokens
Avoids packet drops under load with lots of stations

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-12-04 14:31:16 +01:00
Felix Fietkau
90d494c99a mt76: improve tx queue stop/wake
Instead of stopping and waking only a single queue, handle all phy tx queues
mapped ot the same hardware queue.
Also allow the driver to block tx queues

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-12-04 14:31:16 +01:00
Shayne Chen
d211c00338 mt76: mt7915: fix memory leak in mt7915_mcu_get_rx_rate()
Free the skb to prevent memory leak.

Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-12-04 14:31:16 +01:00
Lorenzo Bianconi
0211c282bc mt76: mt7615: fix rdd mcu cmd endianness
Similar to mt7915 driver, fix mt7615 radar mcu command endianness

Fixes: 2ce73efe0f8e5 ("mt76: mt7615: initialize radar specs from host driver")
Fixes: 70911d9638069 ("mt76: mt7615: add radar pattern test knob to debugfs")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-12-04 14:31:16 +01:00
Felix Fietkau
cee236e148 mt76: mt7915: fix endian issues
Multiple MCU messages were using u16/u32 fields without endian annotations
or conversions

Fixes: e57b7901469f ("mt76: add mac80211 driver for MT7915 PCIe-based chipsets")
Fixes: 5517f78b0063 ("mt76: mt7915: enable firmware module debug support")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-12-04 14:31:16 +01:00
Lorenzo Bianconi
af901eb4ab mt76: mt7915: get rid of dbdc debugfs knob
mt7915 automatically detects dbdc feature so drop debugfs knob.
Move if_comb, mt7915_rates, if_limits structs and mt7915_regd_notifier(),
mt7915_init_wiphy() routines at the begging of init.c in order to make
mt7915_register_ext_phy routine static

Co-developed-by: Shayne Chen <shayne.chen@mediatek.com>
Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
Co-developed-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-12-04 14:31:15 +01:00
Lorenzo Bianconi
4c430774e0 mt76: mt7915: introduce dbdc support
Introduce mt7915 dbdc support. If dbdc is available, mt7915 primary phy
will work on 2.4GHz band, while secondary one on 5GHz band.

Co-developed-by: Shayne Chen <shayne.chen@mediatek.com>
Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
Co-developed-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-12-04 14:31:15 +01:00
Lorenzo Bianconi
98df2baeb3 mt76: move hw mac_addr in mt76_phy
This is a preliminary patch to properly support mt7915 dbdc

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-12-04 14:31:15 +01:00
Lorenzo Bianconi
db78a791ca mt76: move band allocation in mt76_register_phy
This is a preliminary patch to introduce dbdc support to mt7915 devices

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-12-04 14:31:15 +01:00
Lorenzo Bianconi
77af762e42 mt76: rely on mt76_phy in mt76_init_sband_2g and mt76_init_sband_5g
This is a preliminary patch to properly support mt7915 dbdc

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-12-04 14:31:15 +01:00
Lorenzo Bianconi
48dbce5cb1 mt76: move band capabilities in mt76_phy
This is a preliminary patch to move properly support mt7915 dbdc

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-12-04 14:31:15 +01:00
Lorenzo Bianconi
9199051929 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>
2020-12-04 14:31:15 +01:00
Lorenzo Bianconi
e637763b60 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>
2020-12-04 14:31:15 +01:00
Lorenzo Bianconi
d95093a143 mt76: rely on mt76_queue in tx_queue_skb_raw 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>
2020-12-04 14:31:15 +01:00
Lorenzo Bianconi
b1cb42add6 mt76: introduce mt76_init_mcu_queue utility routine
Introduce mt76_init_mcu_queue utility routine in order to allocate
dedicate q_mcu pointers for mcu hw queues. This is a preliminary patch
to move data queues in mt76_phy and add dbdc support to mt7915 driver

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-12-04 14:31:14 +01:00
Lorenzo Bianconi
8987059475 mt76: rely on mt76_queue in tx_queue_skb signature
Rely on mt76_queue instead of qid in tx_queue_skb signature.
This is a preliminary patch to move data queues in mt76_phy and add
dbdc support to mt7915 driver

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-12-04 14:31:14 +01:00
Lorenzo Bianconi
e5655492e3 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>
2020-12-04 14:31:14 +01:00
Lorenzo Bianconi
264b7b1986 mt76: mt7663s: rely on mt76_queue in mt7663s_tx_run_queue signature
This is a preliminary patch to move data queues in mt76_phy and properly
support dbdc for mt7915

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-12-04 14:31:14 +01:00
Lorenzo Bianconi
afc2b59cb9 mt76: sdio: rely on mt76_queue in mt76s_process_tx_queue signature
This is a preliminary patch to move data queues in mt76_phy and properly
support dbdc for mt7915

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-12-04 14:31:14 +01:00
Lorenzo Bianconi
a2a93548db mt76: sdio: introduce mt76s_alloc_tx_queue
This is a preliminary patch to move hw data queues in mt76_phy for
mt7915 dbdc support

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-12-04 14:31:14 +01:00
Lorenzo Bianconi
b671da33d1 mt76: move mt76_init_tx_queue in common code
Move mt76_init_tx_queue in mac80211.c since it is shared by all
drivers.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-12-04 14:31:14 +01:00
Lorenzo Bianconi
3d51a3e993 mt76: mt7915: rely on eeprom definitions
In order to make the code more readable, rely on mt7915_eeprom_field
definitions for eeprom parsing

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-12-04 14:31:14 +01:00
Lorenzo Bianconi
d927ebb99d mt76: mt7615: refactor usb/sdio rate code
Since wtbl workqueue is used only for rate handling, refactor code to
make it more clear

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-12-04 14:31:14 +01:00
Ryder Lee
d8d59f66d1 mt76: mt7615: support 16 interfaces
When looking for a MAC address slot, start by using main BSSID slots 1-3,
afterwards use 16 repeater mode BSSID slots, then start using the slots
usually used for AP mode.

This search order should prevent unnecessary conflicts with AP mode interfaces
on the same PHY.

Note that two PHYs share global 32 omac slots with each other.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-12-04 14:31:13 +01:00
Ryder Lee
802145e2ed mt76: mt7915: remove unused mt7915_mcu_bss_sync_tlv()
mt7915_mcu_bss_sync_tlv() is no longer used, so remove it.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-12-04 14:31:13 +01:00
Ryder Lee
4812e0bc37 mt76: mt7915: use BIT_ULL for omac_idx
The omac_idx variable is u64 so we should use the 64-bit BIT_ULL().

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-12-04 14:31:13 +01:00
Lorenzo Bianconi
078b6d21b8 mt76: mt7915: make mt7915_eeprom_read static
Make mt7915_eeprom_read routine static since it is used only in eeprom.c

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-12-04 14:31:13 +01:00
Shayne Chen
ed3c9072fa mt76: mt7915: add support to set tx frequency offset in testmode
Support to set tx frequency offset in testmode, which is usally used in
the pre-calibration stage.

Reviewed-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-12-04 14:31:13 +01:00
Shayne Chen
e0852d9083 mt76: mt7915: add support to set txpower in testmode
Support tx_power setting in testmode. Note that the tx power value of
antenna 1-3 equal to antenna 0.

Reviewed-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-12-04 14:31:13 +01:00
Shayne Chen
5d8a83f099 mt76: mt7915: implement testmode rx support
Support testmode rx and display rx statistic by parsing RXV packet
type, which is currently only enabled in testmode.

Reviewed-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-12-04 14:31:13 +01:00
Shayne Chen
aadf09537c mt76: mt7915: implement testmode tx support
Support testmode tx for MT7915A, including tx streams and HE rate
settings.

Reviewed-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-12-04 14:31:13 +01:00
Shayne Chen
61fe73577d mt76: testmode: add support for HE rate modes
Extend enum mt76_testmode_tx_mode to support various HE rate modes.

Reviewed-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-12-04 14:31:13 +01:00
Shayne Chen
c31d94af18 mt76: mt7915: fix tx rate related fields in tx descriptor
Correct the bitfields of tx rateval and bw in tx descriptor.

Reviewed-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-12-04 14:31:13 +01:00
Shayne Chen
1a38c2f535 mt76: testmode: add support for LTF and GI combinations for HE mode
Prepare for setting different LTF (1x, 2x, and 4x) and GI (0.8us,
1.6us, 3.2us) combinations in HE rate mode.

Reviewed-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-12-04 14:31:12 +01:00
Shayne Chen
7f54c7425d mt76: testmode: add tx_rate_stbc parameter
Add the parameter to control STBC function in testmode.

Reviewed-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-12-04 14:31:12 +01:00
Shayne Chen
0922999223 mt76: testmode: add snr attribute in rx statistics
Support to display snr value when dumping rx statistics.

Reviewed-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-12-04 14:31:12 +01:00
Shayne Chen
8248bb58e2 mt76: testmode: switch ib and wb rssi to array type for per-antenna report
Change ib_rssi and wb_rssi into array type, since they could be reported
by per-antenna.

Reviewed-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-12-04 14:31:12 +01:00
Lorenzo Bianconi
9daf27e628 mt76: mt76u: use dedicated thread for status work
Split tx and status path in mt76-usb module relying on mt76 workers APIs

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-12-04 14:31:12 +01:00
Lorenzo Bianconi
be83a7e20c mt76: mt76u: rely on woker APIs for rx work
In order to improve parallelism, convert rx path in mt76-usb module to
mt76 workers APIs

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-12-04 14:31:12 +01:00
Lorenzo Bianconi
faa72684b4 mt76: mt7615: run key configuration in mt7615_set_key for usb/sdio devices
Since rate configuration is run holding dev mutex, we can run key
configuration in mt7615_set_key for usb/sdio devices avoiding to
schedule the workqueue

Tested-by: Tested-by: YN Chen <yn.chen@mediatek.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-12-04 14:31:12 +01:00
Lorenzo Bianconi
930e0eaddf mt76: fix tkip configuration for mt7615/7663 devices
Fix Tx-Rx MIC overwrite during TKIP hw key configuration

Fixes: 01cfc1b45421 ("mt76: mt7615: add BIP_CMAC_128 cipher support")
Tested-by: YN Chen <yn.chen@mediatek.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-12-04 14:31:12 +01:00
Lorenzo Bianconi
d3a5d89ea9 mt76: switch to wep sw crypto for mt7615/mt7915
Switch to wep sw crypto for mt7615/mt7915 since wtbl require a sta
reference and wep key is not pairwise

Tested-by: YN Chen <yn.chen@mediatek.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-12-04 14:31:12 +01:00
Sean Wang
406d99dfe2 mt76: mt7663s: introduce WoW support via GPIO
SDIO-based WiFi would rely on an additional GPIO pin to wake up the host.

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-12-04 14:31:11 +01:00
Lorenzo Bianconi
3cb43b6606 mt76: move mt76_mcu_send_firmware in common module
Move mt76_mcu_send_firmware routine in common code since it is actually
shared between mt7615, mt7663, mt7603 and mt7915 devices

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-12-04 14:31:11 +01:00
David Bauer
bf4a938ab2 mt76: mt7603: add additional EEPROM chip ID
Some newer MT7628 based routers (notably the TP-Link Archer C50 v4) are
shipped with a chip-id of 0x7600 in the on-flash EEPROM. Add this as a
possible valid ID.

Ref: https://bugs.openwrt.org/index.php?do=details&task_id=2781

Suggested-by: Ron Asimi <ron.asimi@gmail.com>
Signed-off-by: David Bauer <mail@david-bauer.net>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-12-04 14:31:11 +01:00
Lorenzo Bianconi
bc348defcc mt76: fix memory leak if device probing fails
Run mt76_free_device instead of ieee80211_free_hw if device probing
fails in order to remove the already allocated mt76 workqueue

Fixes: a86f1d01f5ce5 ("mt76: move mt76 workqueue in common code")
Fixes: f1d962369d568 ("mt76: mt7915: implement HE per-rate tx power support")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-12-04 14:31:11 +01:00
Ryder Lee
468cc93be7 mt76: mt7915: fix sparse warning cast from restricted __le16
drivers/net/wireless/mediatek/mt76/mt7915/init.c:339:26: sparse:
sparse: cast from restricted __le16

Fixes: 00b2e16e0063 ("mt76: mt7915: add TxBF capabilities")
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-12-04 14:30:49 +01:00