Commit Graph
1797 Commits
Author SHA1 Message Date
Felix Fietkau 0a53dcda52 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 <[email protected]>
2020-02-22 10:04:37 +01:00
Lorenzo BianconiandFelix Fietkau fd892bc033 mt76: mt76u: rely only on data buffer for usb control messagges
Starting from commit 'a6bfb6d13f33 ("mt76: usb: use max packet length
for m76u_copy")' reg_val does not share memory with usb data buffer.
On non-coherent devices this approach can corrupt data pointer since data
and reg_val share the same cache-line, resulting in the following crash:

[  371.544901] CPU 0 Unable to handle kernel paging request at virtual address 00000000, epc == 8042fbb0
[  371.558521] CPU: 0 PID: 11 Comm: kworker/u2:2 Not tainted 4.14.160 #0
[  371.565204] Workqueue: mt76u mt76u_deinit [mt76_usb]
[  371.570331] task: 83823ac0 task.stack: 8386c000
[  371.575004] $ 0   : 00000000 80590000 00000000 00000000
[  371.580407] $ 4   : 82edaad0 00000002 83823ac0 fffffff8
[  371.585810] $ 8   : fffffffd 0000fc00 8052da00 00000000
[  371.591212] $12   : 000b2285 ae53a1a9 00108845 89da44c4
[  371.596615] $16   : 82edaad0 82ed9d20 00001798 832edf00
[  371.602019] $20   : 00000000 8386dda8 80530000 fffffffe
[  371.607421] $24   : 8051d040 76274d1b
[  371.612824] $28   : 8386c000 8386dd88 82edaad4 830d4d50
[  371.618228] Hi    : 000000f7
[  371.621203] Lo    : 33333371
[  371.624196] epc   : 8042fbb0 __mutex_lock.isra.2+0x134/0x378
[  371.630043] ra    : 830d4d50 mt76u_deinit+0x418/0xa6c [mt76_usb]
[  371.636237] Status: 1000fc03KERNEL EXL IE
[  371.640557] Cause : 0080000c (ExcCode 03)
[  371.644696] BadVA : 00000000
[  371.647671] PrId  : 00019374 (MIPS 24Kc)
[  371.726123]  usbcore nls_base usb_common
[  371.730180] Process kworker/u2:2 (pid: 11, threadinfo=8386c000, task=83823ac0, tls=00000000)
[  371.738884] Stack : 833d009c 83210b4c 82ed8bc0 8386ddac 000001ff 8008ac50 8386ddac 83b74b00
[  371.747519]         82edaad4 00000000 83b74b48 83210c38 82edaad0 82ed9d20 00001798 832edf00
[  371.756157]         00000000 00000000 80530000 fffffffe 80530000 830d4d50 00000040 8389d850
[  371.764794]         8052d9d8 8389d850 8386de30 82ed9d20 8386de5f 831c27bc 833d48ec 8052d9d8
[  371.773431]         83823ac0 83823af0 82edab00 82ed9d20 8386de5f 831c5c30 00000000 8052d9a8
[  371.782069]         ...
[  371.784598] Call Trace:
[  371.787130] [<8042fbb0>] __mutex_lock.isra.2+0x134/0x378
[  371.792622] [<830d4d50>] mt76u_deinit+0x418/0xa6c [mt76_usb]
[  371.808546]
[  371.810920] ---[ end trace c62f0601f6730eb0 ]---
[  371.818101] Kernel panic - not syncing: Fatal exception
[  371.824420] Rebooting in 3 seconds..

Fix the issue relying only on data buffer to send/receive usb control messages

Fixes: a6bfb6d13f33 ("mt76: usb: use max packet length for m76u_copy")
Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2020-02-20 14:33:22 +01:00
Lorenzo BianconiandFelix Fietkau 5b9f949cb7 mt76: mt76u: fix a possible memory leak in mt76u_init
Remove usb workqueue if mt76u_set_endpoints fails.

Fixes: 284efb473ef5 ("mt76: mt76u: rely on a dedicated stats workqueue")
Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2020-02-20 13:03:45 +01:00
Lorenzo BianconiandFelix Fietkau f4415afce2 mt76: mt76u: loop over all possible rx queues in mt76u_rx_tasklet
Loop over all possible hw rx queues in mt76u_rx_tasklet since new
devices will report mcu events through mcu hw queue

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2020-02-20 13:03:45 +01:00
Felix Fietkau 8f8e9161b3 mt76: fix array overflow on receiving too many fragments for a packet
If the hardware receives an oversized packet with too many rx fragments,
skb_shinfo(skb)->frags can overflow and corrupt memory of adjacent pages.
This becomes especially visible if it corrupts the freelist pointer of
a slab page.

Cc: [email protected]
Signed-off-by: Felix Fietkau <[email protected]>
2020-02-19 13:55:52 +01:00
Felix Fietkau 284e9fd729 mt76: mt7615: fix monitor injection of beacon frames
When injecting beacon frames via monitor interface, they must not be sent to
the beacon hardware queue, because they don't follow normal hardware beacon tx
rules.
Fix sending them by adding a flag to mt7615_mac_write_txwi that selects the
beacon queue for tx, and use it only from mt7615_mcu_set_bcn.

Signed-off-by: Felix Fietkau <[email protected]>
2020-02-17 17:46:33 +01:00
Felix Fietkau 17ecf07625 mt76: mt76x02: fix handling MCU timeouts during hw restart
If a MCU timeout occurs before a hw restart completes, another hw restart
is scheduled, and the station state gets corrupted.
To speed up dealing with that, do not issue any MCU commands after the first
timeout, and defer handling timeouts until the reset has completed.
Also ignore errors in MCU commands during start/config to avoid making user
space fail on this condition. If it happens, another restart is scheduled
quickly, and that usually recovers the hardware properly.

Signed-off-by: Felix Fietkau <[email protected]>
2020-02-16 16:09:00 +01:00
Lorenzo BianconiandFelix Fietkau f408a2b756 mt76: Introduce mt76_mcu data structure
Introduce mt76_mcu data structure to contain common fields between
mt76u_mcu and mt76e_mcu.
Initialize mcu common fields in mt76_alloc_device().
Rely on mt76_mcu in mt76_mcu_rx_event and in mt76_mcu_get_response
in order to reuse them in usb code

Signed-off-by: Lorenzo Bianconi <[email protected]>
2020-02-14 10:16:16 +01:00
Lorenzo BianconiandFelix Fietkau 2bbffd2cb3 mt76: mt7615: remove rx_mask in mt7615_eeprom_parse_hw_cap
Get rid of rx_mask in mt7615_eeprom_parse_hw_cap routine since it is not
actually used

Signed-off-by: Lorenzo Bianconi <[email protected]>
2020-02-14 10:16:16 +01:00
Lorenzo BianconiandFelix Fietkau dfc24bc504 mt76: mt76u: rename stat_wq in wq
Rename usb stat_wq in wq in order to be reused not just for gathering hw
tx statistics

Signed-off-by: Lorenzo Bianconi <[email protected]>
2020-02-14 10:16:16 +01:00
Sean WangandFelix Fietkau c6a0253180 mt76: mt76u: extend RX scatter gather number
Set RX scatter gather number to 4 in order to extend the maximum AMSDU
size to 11,454.

Signed-off-by: Sean Wang <[email protected]>
Co-developed-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Lorenzo Bianconi <[email protected]>
2020-02-14 10:16:16 +01:00
Lorenzo BianconiandFelix Fietkau e226309c4b mt76: mt7615: rely on mt76_queues_read for mt7622
As previous devices, mt7622 relies on multiple hw queues while for
mt7615 we have just on per band hw queue and the mcu demux the traffic
according to the packet AC. In order to dump all configured hw queues,
rely on mt76_queues_read for mt7622 in mt7615 debugfs

Signed-off-by: Lorenzo Bianconi <[email protected]>
2020-02-14 10:16:16 +01:00
Lorenzo BianconiandFelix Fietkau 4dbd56b869 mt76: mt76x0u: add support to TP-Link T2UHP
Introduce support to TP-Link T2UHP
https://wikidevi.com/wiki/TP-LINK_Archer_T2UHP

Tested-by: Sid Hayn <[email protected]>
Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2020-02-14 10:09:09 +01:00
Arnd BergmannandFelix Fietkau cc56c40016 mt76: fix LED link time failure
The mt76_led_cleanup() function is called unconditionally, which
leads to a link error when CONFIG_LEDS is a loadable module or
disabled but mt76 is built-in:

drivers/net/wireless/mediatek/mt76/mac80211.o: In function `mt76_unregister_device':
mac80211.c:(.text+0x2ac): undefined reference to `led_classdev_unregister'

Use the same trick that is guarding the registration, using an
IS_ENABLED() check for the CONFIG_MT76_LEDS symbol that indicates
whether LEDs can be used or not.

Fixes: 36f7e2b2bb1d ("mt76: do not use devm API for led classdev")
Signed-off-by: Arnd Bergmann <[email protected]>
Acked-by: Felix Fietkau <[email protected]>
Signed-off-by: Kalle Valo <[email protected]>
2020-02-14 10:07:05 +01:00
Felix Fietkau c75cf513c6 mt76: do not set HOST_BROADCAST_PS_BUFFERING for mt7615
mt7615 handles powersave buffering in firmware

Signed-off-by: Felix Fietkau <[email protected]>
2020-02-13 22:56:34 +01:00
Felix Fietkau 457a932036 mt76: mt7615: fix MT_TX_HW_QUEUE_EXT_PHY to deal with mac80211 changes
The size of info->hw_queue was reduced to 4 bits

Signed-off-by: Felix Fietkau <[email protected]>
2020-02-13 22:51:34 +01:00
Felix Fietkau a205ce3e3e mt76: mt7615: fix ext_phy flag for stations
Signed-off-by: Felix Fietkau <[email protected]>
2020-02-13 22:10:05 +01:00
Felix Fietkau fa14e7f331 mt76: mt7615: rework rx phy index handling
Overwriting the RMAC_CHFREQ register is not reliable enough, as the firmware
could potentially write it again.
Since there is no PHY index indication in the rx info, we need to use another
way:

If both PHYs are using different channels, find the PHY where chfreq matches
the register value.

The only corner case remaining is when both PHYs are using the same channel.
In that case, the per-packet noise value on the primary PHY will have
information belonging to the chains of the secondary PHY from the previous
received packet of that PHY. The secondary PHY will set noise to 0 for extra
chains.

Signed-off-by: Felix Fietkau <[email protected]>
2020-02-13 21:25:11 +01:00
Felix Fietkau 1881241c7e mt76: fix rounding issues on converting per-chain and combined txpower
Unify code converting between the different txpower values. Always add/remove
the combined txpower delta before dividing half-dB values.
Also fix the combined txpower delta values. The correct half-dB delta for
3 chains is 9, not 8.

Signed-off-by: Felix Fietkau <[email protected]>
2020-02-11 21:01:03 +01:00
Felix Fietkau 764e1d208a mt76: mt7615: fix tx power reporting
Signed-off-by: Felix Fietkau <[email protected]>
2020-02-11 20:13:11 +01:00
Lorenzo BianconiandFelix Fietkau 9c43417db1 mt76: mt7615: fix max_nss in mt7615_eeprom_parse_hw_cap
Fix u8 cast reading max_nss from MT_TOP_STRAP_STA register in
mt7615_eeprom_parse_hw_cap routine

Fixes: acf5457fd99db ("mt76: mt7615: read {tx,rx} mask from eeprom")
Signed-off-by: Lorenzo Bianconi <[email protected]>
2020-02-07 17:57:50 +01:00
Ryder LeeandFelix Fietkau d3af8bd3c7 mt76: mt7615: set proper length in strncmp
Use sizeof(hdr->fw_ver) as max len.

Signed-off-by: Ryder Lee <[email protected]>
2020-02-07 17:56:56 +01:00
Lorenzo BianconiandFelix Fietkau a67e42990d mt76: mt7615: fix msdu_id endianness in mt7615_write_hw_txp
Fix the following sparse warning in mt7615_write_hw_txp:

warning: incorrect type in assignment (different base types)
   expected restricted __le16
   got unsigned long

Signed-off-by: Lorenzo Bianconi <[email protected]>
2020-02-07 17:55:46 +01:00
Felix Fietkau d5a5e97b67 mt76: mt76x2: avoid starting the MAC too early
Do not set the tx/rx start bits in MT_MAC_SYS_CTRL from within initvals.
The driver sets these later when the hardware is ready

Signed-off-by: Felix Fietkau <[email protected]>
2020-02-07 12:33:17 +01:00
Felix Fietkau bd0df1b017 mt76: avoid extra RCU synchronization on station removal
Use sta_pre_rcu_remove callback to clear wcid pointer earlier

Signed-off-by: Felix Fietkau <[email protected]>
2020-02-07 12:33:17 +01:00
Ryder LeeandFelix Fietkau 721673759d mt76: mt7615: switch mt7615_mcu_set_rx_ba to v2 format
To adapt new firmware version.

Signed-off-by: Ryder Lee <[email protected]>
Tested-by: Shayne Chen <[email protected]>
2020-02-02 17:19:07 +01:00
Ryder LeeandFelix Fietkau 648ce1aaa4 mt76: mt7615: switch mt7615_mcu_set_tx_ba to v2 format
To adapt new firmware version.

Signed-off-by: Ryder Lee <[email protected]>
Tested-by: Shayne Chen <[email protected]>
2020-02-02 17:19:07 +01:00
Ryder LeeandFelix Fietkau 170b21f9ec mt76: mt7615: use new tag sta_rec_wtbl
In order to reduce command/event times, newer firmware adds a tag
sta_rec_wtbl to take care of WTBL operations.

MCU_EXT_CMD_WTBL_UPDATE is deprecated.

Signed-off-by: Ryder Lee <[email protected]>
Signed-off-by: Shayne Chen <[email protected]>
Tested-by: Sean Wang <[email protected]>
2020-02-02 17:19:07 +01:00
Ryder LeeandFelix Fietkau 77b9d85863 mt76: mt7615: add starec operating flow for firmware v2
Add fw_ver in mt7615_dev to check firmware version, and adjust
mt7615_mcu_send_sta_rec() to adapt firmware v2 changes.

Signed-off-by: Ryder Lee <[email protected]>
Signed-off-by: Shayne Chen <[email protected]>
Tested-by: Sean Wang <[email protected]>
2020-02-02 17:19:07 +01:00
Ryder LeeandFelix Fietkau f16433cd78 mt76: mt7615: add a helper to encapsulate sta_rec operation
Operating command is simpler and just as clear

Signed-off-by: Ryder Lee <[email protected]>
Signed-off-by: Shayne Chen <[email protected]>
Tested-by: Sean Wang <[email protected]>
2020-02-02 17:19:07 +01:00
Ryder LeeandFelix Fietkau ff32af25f8 mt76: mt7615: simplify mcu_set_sta flow
Move mcu_add_wtbl and mcu_set_ht_cap into mcu_set_sta to simplify flow.

Signed-off-by: Ryder Lee <[email protected]>
2020-02-02 17:19:07 +01:00
Ryder LeeandFelix Fietkau 9f8c6c4a20 mt76: mt7615: simplify mcu_set_bmc flow
Move set_bmc_wtbl into sta_rec function to simplify flow.

Signed-off-by: Ryder Lee <[email protected]>
2020-02-02 17:19:07 +01:00
Felix Fietkau 269de7c229 firmware: fix version number for upcoming mt7615 mcu v2 support patches
Signed-off-by: Felix Fietkau <[email protected]>
2020-02-02 17:11:59 +01:00
Felix Fietkau fd216cb5b2 mt76: mt7615: fix monitor mode on second PHY
The second PHY receives no packets unless there is an active vif present.
Set the WANT_MONITOR_VIF flag to deal with that

Signed-off-by: Felix Fietkau <[email protected]>
2020-02-02 16:24:11 +01:00
Felix Fietkau b9d9f91b15 mt76: mt7615: fix adding active monitor interfaces
Treat them the same as AP iftype internally for MCU commands

Signed-off-by: Felix Fietkau <[email protected]>
2020-02-02 16:13:04 +01:00
Felix Fietkau db97358df4 mt76: mt7615: add support for testing hardware reset
Send an undersized corrupt packet to the DMA queue, which causes the
firmware to issue a full chip reset

Signed-off-by: Felix Fietkau <[email protected]>
2020-01-31 16:37:02 +01:00
Felix Fietkau 0f06914acf mt76: mt7615: implement hardware reset support
When the firmware detects a problem, it needs the host to stop/reset DMA and
resume it again when the hardware state has been reset.

Signed-off-by: Felix Fietkau <[email protected]>
2020-01-31 16:37:02 +01:00
Felix Fietkau 7882bbd25c mt76: mt7615: fix and rework tx power handling
Setting the tx power by manipulating EEPROM may in some cases not be enough,
since it only covers the base target power and not per-rate offsets.
In other cases, it could limit tx power of rates too much, possibly reducing
throughput or range.
Use firmware support for applying per-rate limit and power offsets for
different values of Nss.

Signed-off-by: Felix Fietkau <[email protected]>
2020-01-30 14:12:44 +01:00
Shayne ChenandFelix Fietkau 68f38eea39 firmware: add firmware for MT7622 built-in WiFi
Signed-off-by: Felix Fietkau <[email protected]>
2020-01-30 14:04:38 +01:00
Felix Fietkau f66b480434 mt76: mt7615: add Kconfig entry for MT7622
This enables building support for the MT7622 SoC built-in WLAN chip

Signed-off-by: Felix Fietkau <[email protected]>
2020-01-30 14:04:38 +01:00
Felix Fietkau 6cd5c381ea mt76: mt7615: disable DBDC on MT7622
It is only supported on MT7615

Signed-off-by: Felix Fietkau <[email protected]>
2020-01-30 14:04:38 +01:00
Felix Fietkau bddcbb25cd mt76: mt7615: decrease rx ring size for MT7622
Since it's 2.4 GHz only, it needs fewer buffers

Signed-off-by: Felix Fietkau <[email protected]>
2020-01-30 14:04:38 +01:00
Felix Fietkau 79808e6232 mt76: mt7615: implement DMA support for MT7622
MT7622 does not have the CR4 microcontroller sitting in the data path.
Because of that, it uses the chip's native tx descriptor format instead of
something parsed and converted by the firmware.

Co-developed-by: Shayne Chen <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2020-01-30 14:04:38 +01:00
Felix Fietkau 80d3681b40 mt76: mt7615: implement probing and firmware loading on MT7622
MT7622 does not have a CR4 microcontroller, so it only uses its own N9
firmware.

Co-developed-by: Shayne Chen <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2020-01-30 14:04:37 +01:00
Felix Fietkau fd3ae9a342 mt76: mt7615: disable 5 GHz on MT7622
It is not supported by the chip, so avoid issues with potentially wrong
EEPROM configurations.

Signed-off-by: Felix Fietkau <[email protected]>
2020-01-30 13:34:40 +01:00
Felix Fietkau f0b02d8115 mt76: mt7615: add calibration free support for MT7622
MT7622 uses fewer efuse overrides than MT7615

Signed-off-by: Felix Fietkau <[email protected]>
2020-01-30 13:34:40 +01:00
Felix Fietkau ab94a85efb mt76: mt7615: add eeprom support for MT7622
When sending EEPROM data to the MCU, MT7622 uses a longer buffer

Co-developed-by: Shayne Chen <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2020-01-30 13:34:33 +01:00
Felix Fietkau 13a4269a1b mt76: mt7615: add dma and tx queue initialization for MT7622
MT7622 queue mapping is different from MT7615 and requires an extra dma
scheduler init and a few register tweaks

Co-developed-by: Shayne Chen <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2020-01-30 13:34:20 +01:00
Felix Fietkau 92bafd4b1b mt76: mt7615: fix MT_INT_TX_DONE_ALL definition for MT7622
MT7622 uses more interrupt bits for queue tx completion events.
Enabling those extra bits is harmless on MT7615

Co-developed-by: Shayne Chen <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2020-01-30 13:33:18 +01:00
Felix Fietkau f84b590b64 mt76: mt7615: store N9 firmware version instead of CR4
CR4 is used very little, N9 is the main firmware that the driver interacts with

Signed-off-by: Felix Fietkau <[email protected]>
2020-01-29 17:18:19 +01:00