Commit Graph
2619 Commits
Author SHA1 Message Date
Ryder LeeandFelix Fietkau 3c90f35ddd mt76: mt7915: add thermal sensor device support
This provides userspace with a unified interface, hwmon sysfs, to monitor
temperature in the hardware and can be adapted to system monitoring tools.

For reading temperature, cat /sys/class/ieee80211/phy*/hwmon*/temp1_input

Signed-off-by: Ryder Lee <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-05-28 10:14:15 +02:00
Felix Fietkau bddc1db76d mt76: mt7915: drop the use of repeater entries for station interfaces
There are firmware or hardware issues, which are currently causing tx hangs
when attempting to use these interfaces

Signed-off-by: Felix Fietkau <[email protected]>
2021-05-25 18:45:09 +02:00
Felix Fietkau 9d736545bb mt76: mt7915: disable pre-calibration support for now
It needs more testing and more bugfixes until it is ready

Signed-off-by: Felix Fietkau <[email protected]>
2021-05-15 09:09:22 +02:00
Felix Fietkau 28b162366d mt76: fix calling mt76_get_of_eeprom with an offset for pre-cal data
The device tree partition offset needs to be added to the function argument,
instead of overwriting it.
Fixes an issue where wrong EEPROM data was sent to the firmware as
pre-calibration data on MT7915.

Fixes: 495184ac91bb ("mt76: mt7915: add support for applying pre-calibration data")
Signed-off-by: Felix Fietkau <[email protected]>
2021-05-15 08:07:54 +02:00
Sean WangandFelix Fietkau e969ab10a0 mt76: mt7921: add back connection monitor support
Hw beacon cmd to the mt7921 firmware doesn't only filter out the beacon,
but also performs its own connection monitoring, including periodic
keep-alives to the AP and probing the AP on beacon loss. Will indicate
the host with the event when the firmware detects the connection is lost.

Fixes: 1d8efc741df8 ("mt76: mt7921: introduce Runtime PM support")
Reviewed-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Deren Wu <[email protected]>
Signed-off-by: YN Chen <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-05-13 10:18:25 +02:00
Sean WangandFelix Fietkau 56518f4a12 mt76: mt7921: consider the invalid value for to_rssi
It is possible the RCPI from the certain antenna is an invalid value,
especially packets are receiving while the system is frequently entering
deep sleep mode, so consider calculating RSSI with the reasonable upper
bound to avoid report the wrong value to the mac80211 layer.

Fixes: 163f4d22c118 ("mt76: mt7921: add MAC support")
Reviewed-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-05-13 10:18:25 +02:00
YN ChenandFelix Fietkau 30bcb2338c mt76: connac: fix WoW with disconnetion and bitmap pattern
Update MCU command usage to fix WoW configuration with disconnection
and bitmap pattern and to avoid magic number.

Fixes: ffa1bf97425 ("mt76: mt7921: introduce PM support")
Reviewed-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: YN Chen <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-05-13 10:18:25 +02:00
Sean WangandFelix Fietkau 2e6e999509 mt76: mt7921: add deep sleep control to runtime-pm knob
Add addtional the deep sleep control to runtime-pm knob to
allow us to control driver switching between the full power
mode and the deep sleep mode the firmware is able to support.

Reviewed-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-05-13 10:18:25 +02:00
Sean WangandFelix Fietkau a747b0bb49 mt76: mt7921: enable deep sleep at runtime
Enable the deep sleep mode with that firmware is able to trap into
the doze state at runtime to reduce the power consumption further.

The deep sleep mode is not allowed in the STA state transition with
the firmware to have the fast connection experience as we've done in
the full power mode

Reviewed-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-05-13 10:18:25 +02:00
Sean WangandFelix Fietkau 8ab8c77471 mt76: connac: fw_own rely on all packet memory all being free
If the device is MMIO-based, we must ensure all TxD/TxP on the host
memory all being consumed by the device prior to safely switching to
fw_own state.

Fixes: ec7bd7b4a9c0 ("mt76: connac: check wake refcount in mcu_fw_pmctrl")
Reviewed-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-05-13 10:18:25 +02:00
Sean WangandFelix Fietkau ce5f32d84f mt76: mt7921: Don't alter Rx path classifier
Keep Rx path classifier the mt7921 firmware prefers to allow frames pass
through MCU.

Fixes: 5c14a5f944b9 ("mt76: mt7921: introduce mt7921e support")
Reviewed-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-05-13 10:18:25 +02:00
Sean WangandFelix Fietkau d2713a5d9d mt76: mt7921: fix mt7921_wfsys_reset sequence
WiFi subsytem reset should control MT_WFSYS_SW_RST_B and then poll the
same register until the bit WFSYS_SW_INIT_DONE bit is set.

Fixes: 0c1ce9884607 ("mt76: mt7921: add wifi reset support")
Reviewed-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-05-13 10:18:25 +02:00
Lorenzo BianconiandFelix Fietkau f2d0da8da9 mt76: mt7663: enable hw rx header translation
As already done for mt7615 and mt7915, enable rx header translation
offload for mt7663 in order to reduce cpu load in the rx path.

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-05-13 10:18:25 +02:00
Lorenzo BianconiandFelix Fietkau e423c16f16 mt76: mt7615: free irq if mt7615_mmio_probe fails
As already done for mt7915 and mt7921, free registered irq line if
mt7615_mmio_probe routine fails

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-05-13 10:18:25 +02:00
Lorenzo BianconiandFelix Fietkau af21659ee8 mt76: mt76x0: use dev_debug instead of dev_err for hw_rf_ctrl
BIT(0) in MT_EE_NIC_CONF_1 is use to notify the driver if the radio RF
switch is controlled through a gpio. Use dev_debug instead of dev_err
to log this info.

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-05-13 10:18:25 +02:00
Lorenzo BianconiandFelix Fietkau 5c2baab92c mt76: mt7615: fix NULL pointer dereference in tx_prepare_skb()
Fix theoretical NULL pointer dereference in mt7615_tx_prepare_skb and
mt7663_usb_sdio_tx_prepare_skb routines. This issue has been identified
by code analysis.

Fixes: 6aa4ed7927f11 ("mt76: mt7615: implement DMA support for MT7622")
Fixes: 4bb586bc33b98 ("mt76: mt7663u: sync probe sampling with rate configuration")
Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-05-13 10:18:25 +02:00
Lorenzo BianconiandFelix Fietkau aedc3145de mt76: fix possible NULL pointer dereference in mt76_tx
Even if this is not a real issue since mt76_tx is never run with wcid set
to NULL, fix a theoretical NULL pointer dereference in mt76_tx routine

Fixes: db9f11d3433f7 ("mt76: store wcid tx rate info in one u32 reduce locking")
Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-05-13 10:18:25 +02:00
Felix Fietkau 3511fd4303 mt76: validate rx A-MSDU subframes
Mitigate A-MSDU injection attacks (CVE-2020-24588) by detecting if the
destination address of a subframe equals an RFC1042 (i.e., LLC/SNAP)
header, and if so dropping the complete A-MSDU frame. This mitigates
known attacks, although new (unknown) aggregation-based attacks may
remain possible.

This defense works because in A-MSDU aggregation injection attacks, a
normal encrypted Wi-Fi frame is turned into an A-MSDU frame. This means
the first 6 bytes of the first A-MSDU subframe correspond to an RFC1042
header. In other words, the destination MAC address of the first A-MSDU
subframe contains the start of an RFC1042 header during an aggregation
attack. We can detect this and thereby prevent this specific attack.
For details, see Section 7.2 of "Fragment and Forge: Breaking Wi-Fi
Through Frame Aggregation and Fragmentation".

Signed-off-by: Felix Fietkau <[email protected]>
2021-05-13 09:00:04 +02:00
Felix Fietkau c7dd54a22e mt76: connac: skip wtbl reset on sta disconnect
It should only be done on adding entries

Signed-off-by: Felix Fietkau <[email protected]>
2021-05-10 14:10:54 +02:00
Ryder LeeandFelix Fietkau ff8bbe22dd mt76: mt7915: add .set_bitrate_mask() callback
Add runtime configuration for bitrate mask. This update firmware rate
control to add a boundary on top of table to limit the rate selection
for each peer, so when user set bitrates vht-mcs-5 1:9, which actually
means nss = 1 mcs = 0~9. This only applies to data frames as for other
mgmt, mcast, bcast still use legacy rates as it is.

Note that driver does not support GI configuration.

Example:
iw dev wlan0 set bitrates vht-mcs-5 1:9 he-mcs-5 2:7
iw dev wlan0 set bitrates legacy-5 6 he-mcs-5 2:0-11

Signed-off-by: Ryder Lee <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-05-10 12:29:55 +02:00
Ryder LeeandFelix Fietkau 535025d65d mt76: mt7915: cleanup mt7915_mcu_sta_rate_ctrl_tlv()
Remove obsoleted codes. This is the preparation for .set_bitrate_mask().

Signed-off-by: Ryder Lee <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-05-10 12:29:55 +02:00
Dan CarpenterandFelix Fietkau 7dd24b3cfa mt76: mt7915: fix a signedness bug in mt7915_mcu_apply_tx_dpd()
"idx" needs to be signed for the error handling to work.

Fixes: 495184ac91bb ("mt76: mt7915: add support for applying pre-calibration data")
Signed-off-by: Dan Carpenter <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-05-10 12:27:05 +02:00
Evelyn TsaiandFelix Fietkau 998ca8af7d mt76: mt7915: fix tssi indication field of DBDC NICs
Correct the bitfield which indicates TSSI on/off for MT7915D NIC.

Signed-off-by: Evelyn Tsai <[email protected]>
Signed-off-by: Shayne Chen <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-05-10 12:27:04 +02:00
Felix Fietkau a9bc4d94b7 mt76: intialize tx queue entry wcid to 0xffff by default
Avoid accidentally mapping them to WCID 0 on completion

Signed-off-by: Felix Fietkau <[email protected]>
2021-05-09 22:49:09 +02:00
Felix Fietkau 628eee9c38 mt76: fill queue entry wcid for all skbs with a station
Fixes issues with tx completion

Signed-off-by: Felix Fietkau <[email protected]>
2021-05-09 22:48:36 +02:00
Felix Fietkau 9e928ac1ea mt76: dma: use ieee80211_tx_status_ext to free packets when tx fails
Fixes AQL issues on full queues, especially with 802.3 encap offload

Signed-off-by: Felix Fietkau <[email protected]>
2021-05-09 20:26:08 +02:00
Felix Fietkau 35f189cf81 mt76: mt7915: fix uninitialized variable in MSI error handling
Signed-off-by: Felix Fietkau <[email protected]>
2021-05-07 20:01:01 +02:00
Felix Fietkau 18513ba5fb mt76: mt7915: add support for tx status reporting
For now, this only reports ACK status

Signed-off-by: Felix Fietkau <[email protected]>
2021-05-07 19:50:30 +02:00
Felix Fietkau e1f07d7f1c mt76: mt7603: avoid use of ieee80211_tx_info_clear_status
It overwrites mt76_tx_cb data in the skb

Signed-off-by: Felix Fietkau <[email protected]>
2021-05-07 19:50:30 +02:00
Felix Fietkau 3b4ca5b09e mt76: mt7615: avoid use of ieee80211_tx_info_clear_status
It overwrites mt76_tx_cb data in the skb

Signed-off-by: Felix Fietkau <[email protected]>
2021-05-07 19:50:30 +02:00
Felix Fietkau 27d468d094 mt76: mt7915: rework tx rate reporting
Instead of attaching the last reported rate to tx packets, use
ieee80211_tx_status_ext to immediately pass the rate to mac80211 after
receiving it from the firmware.
Preparation for implementing full tx status reporting

Signed-off-by: Felix Fietkau <[email protected]>
2021-05-07 18:51:43 +02:00
Felix Fietkau c6ae95d43e mt76: improve tx status codepath
Use ieee80211_tx_status_ext instead of ieee80211_free_skb and
ieee80211_tx_status. This makes it compatible with 802.3 encap offload
and improves performance by removing a redundant sta lookup

Signed-off-by: Felix Fietkau <[email protected]>
2021-05-07 17:15:27 +02:00
Felix Fietkau caedb4c4ee mt76: mt7615: fix fixed-rate tx status reporting
Rely on the txs fixed-rate bit instead of info->control.rates

Signed-off-by: Felix Fietkau <[email protected]>
2021-05-07 14:07:54 +02:00
Felix Fietkau c9ab76dd93 mt76: mt7915: move mt7915_queue_rx_skb to mac.c
It is not really DMA specific, and moving it makes it possible to make some
functions in mac.c static

Signed-off-by: Felix Fietkau <[email protected]>
2021-05-07 12:52:43 +02:00
Lorenzo BianconiandFelix Fietkau 01441f67d8 mt76: mt7921: enable rx csum offload
As already done for mt7615 and mt7915, enable hw rx checksum offload.

Signed-off-by: Lorenzo Bianconi <[email protected]>
2021-05-07 12:06:02 +02:00
Lorenzo BianconiandFelix Fietkau 55921e57b3 mt76: mt7921: enable rx header traslation offload
As already done for mt7615 and mt7915, enable rx header translation
offload for mt7921 in order to reduce cpu load in the rx path.

Signed-off-by: Lorenzo Bianconi <[email protected]>
2021-05-07 12:05:17 +02:00
Lorenzo BianconiandFelix Fietkau c8cbcb87be mt76: connac: add missing configuration in mt76_connac_mcu_wtbl_hdr_trans_tlv
Add missing configuration parameters in mt76_connac_mcu_wtbl_hdr_trans_tlv
routine

Signed-off-by: Lorenzo Bianconi <[email protected]>
2021-05-07 12:05:13 +02:00
Lorenzo BianconiandFelix Fietkau 5a387a0a30 mt76: mt7921: enable rx hw de-amsdu
Enable hw rx-amsdu de-aggregation support available in 7921 devices.
This is a preliminary patch to enable rx checksum offload.

Signed-off-by: Lorenzo Bianconi <[email protected]>
2021-05-07 12:05:08 +02:00
Felix Fietkau 43b9c0a838 mt76: mt7921: fix max aggregation subframes setting
The hardware can only handle 64 subframes in rx direction and 128 for tx.
Improves throughput with APs that can handle more than that

Signed-off-by: Felix Fietkau <[email protected]>
2021-05-07 11:56:24 +02:00
Felix Fietkau 554b50dabf mt76: connac: fix uninitialized HT A-MPDU setting field in STA_REC_PHY
The MT7921 firmware needs this to enable tx A-MPDU properly

Signed-off-by: Felix Fietkau <[email protected]>
2021-05-07 11:55:12 +02:00
Felix Fietkau 5231e7300f mt7915: disable ASPM
The same is done on the other chips already, so it is very likely needed
on MT7915 as well

Signed-off-by: Felix Fietkau <[email protected]>
2021-05-06 19:03:04 +02:00
Felix Fietkau e693f3e23e mt76: mt7915: add MSI support
Move IRQ processing to a tasklet, similar to MT7615/MT7663

Signed-off-by: Felix Fietkau <[email protected]>
2021-05-06 18:59:30 +02:00
Felix Fietkau 0fc2136a61 mt76_connac_mcu: move mt76_connac_mcu_update_arp_filter outside of CONFIG_PM
Signed-off-by: Felix Fietkau <[email protected]>
2021-05-05 13:03:28 +02:00
Lorenzo BianconiandFelix Fietkau e5b19336c5 mt76: mt7615: do not set MT76_STATE_PM at bootstrap
Remove MT76_STATE_PM in mt7615_init_device() and introduce
__mt7663s_mcu_drv_pmctrl for fw loading in mt7663s.
This patch fixes a crash at bootstrap for device (e.g. mt7622) that do
not support runtime-pm

Fixes: 129fac01ffe85 ("mt76: connac: introduce wake counter for fw_pmctrl synchronization")
Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-04-29 13:18:09 +02:00
Lorenzo BianconiandFelix Fietkau 23fe1bdcf1 mt76: connac: do not schedule mac_work if the device is not running
Do not run ieee80211_queue_delayed_work for mac work if the worqueue is
not initialized yet

Fixes: b1bd7bb8121d ("mt76: connac: unschedule mac_work before going to sleep")
Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-04-23 16:41:16 +02:00
Lorenzo BianconiandFelix Fietkau 53d915a23b mt76: connac: do not schedule wake_work if the runtime-pm is disabled
Fix the following crash due to a call to mt7921_pm_wake_work if the
device has pm disabled or does not support runtime-pm

[    8.412590] mt7921e 0000:01:00.0: HW/SW Version: 0x8a108a10, Build
[    8.413660] WARNING: CPU: 0 PID: 20 at __queue_delayed_work+0x84/0xb0
[    8.481831] CPU: 0 PID: 20 Comm: kworker/u4:1 Not tainted 5.10.31 #0
[    8.488175] Hardware name: MediaTek MT7622 RFB1 board (DT)
[    8.493663] Workqueue: mt76 mt7921_pm_wake_work [mt7921e]
[    8.499055] pstate: 60000085 (nZCv daIf -PAN -UAO -TCO BTYPE=--)
[    8.505052] pc : __queue_delayed_work+0x84/0xb0
[    8.509574] lr : queue_delayed_work_on+0x54/0x78
[    8.514180] sp : ffffffc010bcbd20
[    8.517485] x29: ffffffc010bcbd20 x28: 0000000000000000
[    8.522790] x27: ffffff800015a148 x26: ffffffc0108acae0
[    8.528094] x25: 0000000000000000 x24: ffffff80056b4208
[    8.533399] x23: ffffff80056b26e0 x22: ffffff80056b26e0
[    8.538703] x21: ffffff80056b45f8 x20: ffffff80056b5dc8
[    8.544006] x19: 0000000000000000 x18: 000000000000000e
[    8.549310] x17: 0000000000000001 x16: 0000000000000019
[    8.554614] x15: 0000000000000033 x14: ffffffffffffffff
[    8.559919] x13: ffffffffffffffff x12: 0000000000000000
[    8.565223] x11: 0000000000000040 x10: 0000000000000820
[    8.570528] x9 : 0000b3c738feafd6 x8 : ffffff801feb7c80
[    8.575832] x7 : ffffff80056b4808 x6 : 0000000000000000
[    8.581136] x5 : ffffff80056b2888 x4 : 0000000fffffffe0
[    8.586441] x3 : 000000000000003e x2 : ffffff80056b2868
[    8.591745] x1 : 0000000000000000 x0 : 0000000000000002
[    8.597049] Call trace:
[    8.599488]  __queue_delayed_work+0x84/0xb0
[    8.603662]  queue_delayed_work_on+0x54/0x78
[    8.607947]  ieee80211_queue_delayed_work+0x30/0x50 [mac80211]
[    8.613774]  mt7921_pm_wake_work+0xa0/0xe0 [mt7921e]
[    8.618730]  process_one_work+0x1fc/0x398
[    8.622730]  worker_thread+0x150/0x4e0
[    8.626472]  kthread+0x120/0x128
[    8.629693]  ret_from_fork+0x10/0x18

Fixes: 129fac01ffe85 ("mt76: connac: introduce wake counter for fw_pmctrl synchronization")
Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-04-23 16:41:16 +02:00
Lorenzo BianconiandFelix Fietkau 92fb81e085 mt76: mt7921: fix possible AOOB issue in mt7921_mcu_tx_rate_report
Fix possible array out of bound access in mt7921_mcu_tx_rate_report.
Remove unnecessary varibable in mt7921_mcu_tx_rate_report

Fixes: 1c099ab44727c ("mt76: mt7921: add MCU support")
Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-04-23 16:41:16 +02:00
Lorenzo BianconiandFelix Fietkau ed41ed73a4 mt76: mt7921: reinit wpdma during drv_own if necessary
Check dummy reg to reinitialized WPDMA during driver_own operation

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-04-21 17:33:55 +02:00
Lorenzo BianconiandFelix Fietkau 757af5c67d mt76: move mt76_token_init in mt76_alloc_device
In order to remove duplicated code, move mt76_token_init in
mt76_alloc_device routine

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-04-21 17:33:55 +02:00
Dan CarpenterandFelix Fietkau aaf0d254f9 mt76: mt7921: fix a precision vs width bug in printk
Precision %.*s was intended instead of width %*s.  The original code
is potentially an information leak.

Fixes: c7cc5ec57303 ("mt76: mt7921: rework mt7921_mcu_debug_msg_event routine")
Signed-off-by: Dan Carpenter <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-04-21 17:33:55 +02:00