Commit Graph
2886 Commits
Author SHA1 Message Date
Sean WangandFelix Fietkau 29a8a08827 mt76: mt7921: fix MT7921E reset failure
There is a missing mt7921e_driver_own in the MT7921E reset procedure
since the mt7921 mcu.c has been refactored for MT7921S, that will
result in MT7921E reset failure, so add it back now.

Fixes: dfc7743de1eb ("mt76: mt7921: refactor mcu.c to be bus independent")
Reported-by: YN Chen <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-11-12 13:13:18 +01:00
Peter ChiuandFelix Fietkau f5ad840ca5 mt76: mt7615: fix possible deadlock while mt7615_register_ext_phy()
ieee80211_register_hw() is called with rtnl_lock held, and this could be
caused lockdep from a work item that's on a workqueue that is flushed
with the rtnl held.

Move mt7615_register_ext_phy() outside the init_work().

Signed-off-by: Peter Chiu <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-11-12 13:13:18 +01:00
Sean WangandFelix Fietkau f5cfaaff3d mt76: mt7921: drop offload_flags overwritten
offload_flags have to be dropped for mt7921 because mt76.omac_idx 0 would
always run as station mode that would cause Tx encapsulation setting
is not applied to mac80211.

Also, drop IEEE80211_OFFLOAD_ENCAP_4ADDR too because it is not really
being supported.

Fixes: e0f9fdda81bd ("mt76: mt7921: add ieee80211_ops")
Signed-off-by: Sean Wang <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-11-12 13:13:18 +01:00
Lorenzo BianconiandFelix Fietkau 5dd32475c8 mt76: mt7915: get rid of mt7915_mcu_set_fixed_rate routine
Fix the following sparse warning removing mt7915_mcu_set_fixed_rate
since it is no longer used:
warning: symbol 'mt7915_mcu_set_fixed_rate' was not declared.
Should it be static?

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-11-12 13:13:18 +01:00
Felix Fietkau f6bde7ba82 mt76: connac: fix unresolved symbols when CONFIG_PM is unset
mt76_connac_mcu_reg_* functions are always needed by connac based drivers

Fixes: 87f9bf24ea84 ("mt76: connac: move mcu reg access utility routines in mt76_connac_lib module")
Signed-off-by: Felix Fietkau <[email protected]>
2021-10-23 13:24:17 +02:00
Randy DunlapandFelix Fietkau 1d01257662 wireless: mediatek: mt7921: fix Wformat build warning
ARRAY_SIZE() is of type size_t, so the format specfier should
be %zu instead of %lu.

Fixes this build warning:

../drivers/net/wireless/mediatek/mt76/mt7921/main.c: In function ‘mt7921_get_et_stats’:
../drivers/net/wireless/mediatek/mt76/mt7921/main.c:1024:26: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 4 has type ‘unsigned int’ [-Wformat=]
   dev_err(dev->mt76.dev, "ei: %d  SSTATS_LEN: %lu",

Signed-off-by: Randy Dunlap <[email protected]>
Cc: Sean Wang <[email protected]>
Cc: [email protected]
Cc: Felix Fietkau <[email protected]>
Cc: Lorenzo Bianconi <[email protected]>
Cc: Ryder Lee <[email protected]>
Cc: Kalle Valo <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-10-23 07:27:31 +02:00
Cai HuoqingandFelix Fietkau fd25a55096 mt76: Make use of the helper macro kthread_run()
Repalce kthread_create/wake_up_process() with kthread_run()
to simplify the code.

Signed-off-by: Cai Huoqing <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-10-23 07:27:31 +02:00
Hauke MehrtensandFelix Fietkau f81f42fe87 mt76: Print error message when reading EEPROM from mtd failed
When the EEPROM data is stored on a MTD partition print an error message
when reading this MTD partition failed. This is currently happening
often in OpenWrt because the initial data was written with using a flash
driver which ignores the error detection data and now OpenWrt uses a
driver which checks it.

With this patch a better error message is shown:
[    8.986988] mt7915e 0000:01:00.0: WA Firmware Version: DEV_000000, Build Time: 20201105222323
[    9.100508] mt7915e 0000:01:00.0: reading EEPROM from mtd factory failed: -117
[    9.144289] mt7915e: probe of 0000:01:00.0 failed with error -22

mt7915 does not work without an EEPROM, MT7922 still works.

Signed-off-by: Hauke Mehrtens <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-10-23 07:27:31 +02:00
Lorenzo BianconiandFelix Fietkau 754d4a37ab mt76: mt7921: fix mt7921s Kconfig
Add missing MMC dependency in mt7921s Kconfig

Fixes: 48fab5bbef409 ("mt76: mt7921: introduce mt7921s support")
Reported-by: Randy Dunlap <[email protected]>
Tested-by: Randy Dunlap <[email protected]>
Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-10-23 07:27:06 +02:00
Lorenzo BianconiandFelix Fietkau 0f49a22314 mt76: mt7921: disable 4addr capability
4addr is not supported by the driver/firmware yet

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-10-23 07:27:06 +02:00
Shayne ChenandFelix Fietkau ed3d8569c4 mt76: mt7915: add debugfs knobs for MCU utilization
Add debugfs knobs to read MCU utilization, which helps user know
firmware status more easily to narrow down CPU bottleneck issues.

Co-developed-by: Ryder Lee <[email protected]>
Signed-off-by: Ryder Lee <[email protected]>
Signed-off-by: Shayne Chen <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-10-23 07:27:06 +02:00
Shayne ChenandFelix Fietkau b52adf9815 mt76: mt7915: add WA firmware log support
Support to turn on/off WA firmware log from debugfs.

Signed-off-by: Shayne Chen <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-10-23 07:27:06 +02:00
Lorenzo BianconiandFelix Fietkau b68af355f7 mt76: mt7915: fix endiannes warning mt7915_mcu_beacon_check_caps
Fix the following sparse warning mt7915_mcu_beacon_check_caps routine:
warning: cast to restricted __le32
warning: cast from restricted __le16

Fixes: 22dffbddf0167 ("mt76: mt7915: introduce mt7915_mcu_beacon_check_caps()")
Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-10-23 07:27:06 +02:00
Ryder LeeandFelix Fietkau 577d45f6e4 mt76: mt7915: rework debugfs fixed-rate knob
Switch to use new mt7915_mcu_set_fixed_rate_ctrl().

Signed-off-by: Ryder Lee <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-10-23 07:27:06 +02:00
Ryder LeeandFelix Fietkau 2c8c3bcd76 mt76: mt7915: rework .set_bitrate_mask() to support more options
With this patch, driver can support single rate, (HE)GI and HE_LTF
configuration through .set_bitrate_mask().

Tested-by: MeiChia Chiu <[email protected]>
Signed-off-by: Ryder Lee <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-10-23 07:27:06 +02:00
Ryder LeeandFelix Fietkau 4d2e81d9ec mt76: mt7915: remove mt7915_mcu_add_he()
Make mt7915_mcu_sta_he_tlv() as a part of mt7915_mcu_add_rate_ctrl() as
firmware rate control should get HE rate information from sta_rec_he,
and reduce a global function accordingly.

Signed-off-by: Ryder Lee <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-10-23 07:27:06 +02:00
Ryder LeeandFelix Fietkau 9d288d7c0c mt76: mt7615: apply cached RF data for DBDC
Band0 and band1 share the same hardware, so band0 will stop Tx/Rx when
band1 performs Rx calibration. cal_cache is introduced to solve such
corner cases by moving necessary datas from channel_switch to bootup.

Co-developed-by: Peter Chiu <[email protected]>
Signed-off-by: Peter Chiu <[email protected]>
Signed-off-by: Ryder Lee <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-10-23 07:27:06 +02:00
Shayne ChenandFelix Fietkau b649678c18 mt76: mt7915: change max rx len limit of hw modules
Update max rx len of some hw modules, which aligns out vendor SDK.
In normal modes, we exchange MPDU 7991 cap with peers; however, this
won't play a part in sniffer mode.
To prevent packets which exceed the max MPDU size from entering specific
rx path in hw, we need to set a proper limit to filter them out.

Signed-off-by: Shayne Chen <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-10-20 10:32:31 +02:00
Shayne ChenandFelix Fietkau 5fbb686e9c mt76: mt7915: fix missing HE phy cap
Fix missing HE phy cap related to vif and starec setting.

Signed-off-by: Shayne Chen <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-10-20 10:32:31 +02:00
Shayne ChenandFelix Fietkau a0b94987df mt76: mt7915: rework mt7915_mcu_sta_muru_tlv()
Re-order and modify conditions for MU DL/UL and ofdma DL fields, and
also clean up some unnecessary zero settings.

Signed-off-by: Shayne Chen <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-10-20 10:32:31 +02:00
Shayne ChenandFelix Fietkau cfbbd861eb mt76: mt7915: enable HE UL MU-MIMO
Enable HE UL MU-MIMO in sta_rec_muru, which works on both ap and station
mode.

For sending trigger frames, one of the conditions fw uses is to check if
mib rx airtime meets the threshold.
There's a main control of mib rx airtime report register in fw, so we
need to enable the register by mcu cmd instead of directly writing it,
otherwise it will still be disabled by fw.

Signed-off-by: Shayne Chen <[email protected]>
Signed-off-by: Ryder Lee <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-10-20 10:32:31 +02:00
Lorenzo BianconiandFelix Fietkau 35b8025f46 mt76: mt7921: add per-vif counters in ethtool
Similar to mt7915 driver, add per-vif tx counters in ethtool.

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-10-19 12:33:21 +02:00
Lorenzo BianconiandFelix Fietkau 4b65fbc4e2 mt76: mt7921: move tx amsdu stats in mib_stats
Move tx_amsdu histogram stats in mib_stats structure since registers are
clear-on-read

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-10-19 12:33:21 +02:00
Lorenzo BianconiandFelix Fietkau 69154ae23f mt76: mt7921: add sta stats accounting in mt7921_mac_add_txs_skb
This is a preliminary patch to add ethtool stats to mt7921 driver.

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-10-19 12:33:21 +02:00
Lorenzo BianconiandFelix Fietkau 5ffe086fcd mt76: mt7921: introduce stats reporting through ethtool
Similar to mt7915 driver, add tx/rx statistics reporting through ethtool.

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-10-19 12:33:21 +02:00
Lorenzo BianconiandFelix Fietkau d8837b7c8d mt76: mt7921: add some more MIB counters
This is a preliminary patch to introduce ethtool stats support to mt7921
driver.

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-10-19 12:33:21 +02:00
Lorenzo BianconiandFelix Fietkau 486da6fa25 mt76: do not reset MIB counters in get_stats callback
MIB counters are used for ethtool stats as well

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-10-19 12:33:21 +02:00
Lorenzo BianconiandFelix Fietkau 4a11cb67dc mt76: mt7915: move tx amsdu stats in mib_stats
Move tx_amsdu histogram stats in mib_stats structure since registers are
clear-on-read

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-10-19 12:33:21 +02:00
Lorenzo BianconiandFelix Fietkau f80ab6dde6 mt76: mt7915: run mt7915_get_et_stats holding mt76 mutex
Since it can run in parallel with mac_work, hold mutex lock in
mt7915_get_et_stats. Moreover update mib counters running
mt7915_get_et_stats.

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-10-19 12:33:21 +02:00
Lorenzo BianconiandFelix Fietkau 094e085abf mt76: move mt76_ethtool_worker_info in mt76 module
Move mt76_ethtool_worker_info in common code in order to be reused in
mt7921 driver.

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-10-19 12:33:21 +02:00
Lorenzo BianconiandFelix Fietkau d54796787c mt76: move mt76_sta_stats in mt76.h
This is a preliminary patch to add ethtool stats to mt7921 driver.

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-10-19 12:33:21 +02:00
Richard HuynhandFelix Fietkau 645eac64be mt76: mt76x0: correct VHT MCS 8/9 tx power eeprom offset
Appears to have incorrectly offset 0x120 + 0x12 instead of 12 decimal,
leading to bogus power values being used.

Signed-off-by: Richard Huynh <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-10-19 12:30:30 +02:00
Sean WangandFelix Fietkau 3143118baf mt76: mt7921s: add reset support
Introduce wifi chip reset support for mt7921 device to recover
mcu hangs or abnormal wifi system.

Tested-by: Deren Wu <[email protected]>
Acked-by: Lorenzo Bianconi <[email protected]>
Co-developed-by: Deren Wu <[email protected]>
Signed-off-by: Deren Wu <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-10-19 12:15:59 +02:00
Sean WangandFelix Fietkau ce3706a65c mt76: mt7921: introduce mt7921s support
Introduce support for mt7921s 802.11ax (Wi-Fi 6) 2x2:2SS chipset.

Tested-by: Deren Wu <[email protected]>
Co-developed-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-10-19 12:15:59 +02:00
Sean WangandFelix Fietkau e6ce5d9cbd mt76: mt7921: refactor mt7921_mcu_send_message
This is a preliminary patch to introduce mt7921s support.

Refactor mt7921_mcu_send_message to be sharable between mt7921s and
mt7921e.

Tested-by: Deren Wu <[email protected]>
Acked-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-10-19 12:15:59 +02:00
Sean WangandFelix Fietkau b2d9a1748a mt76: mt7921: rely on mcu_get_nic_capability
Rely on mcu_get_nic_capability to obtain Tx quota information
for the SDIO device, get PHY capability, MAC address and then we can
totally drop mt7921/eeprom.c and any unnecessary code.

Noting that mt76_connac_mcu_get_nic_capability should be run before set
flag MT76_STATE_MCU_RUNNING being set to setup the proper parameters
like Tx quota control before the device is started to running.

Tested-by: Deren Wu <[email protected]>
Acked-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-10-19 12:15:59 +02:00
Sean WangandFelix Fietkau ddab3dd25f mt76: connac: extend mcu_get_nic_capability
Extend mcu_get_nic_capability to obtain tx resource for SDIO device,
MAC address, and PHY capability.

Tested-by: Deren Wu <[email protected]>
Acked-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-10-19 12:15:59 +02:00
Sean WangandFelix Fietkau e353424f1b mt76: sdio: extend sdio module to support CONNAC2
Extend sdio module to support CONNAC2 hw that mt7921s rely on.

Tested-by: Deren Wu <[email protected]>
Co-developed-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Lorenzo Bianconi <[email protected]>
Co-developed-by: Deren Wu <[email protected]>
Signed-off-by: Deren Wu <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-10-19 12:15:59 +02:00
Lorenzo BianconiandFelix Fietkau 2625759439 mt76: sdio: introduce parse_irq callback
Add parse_irq to handle that interrupt status structure is
different between mt7663s and mt7921s.

This is a preliminary patch to introduce mt7921s driver

Tested-by: Sean Wang <[email protected]>
Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-10-19 12:15:59 +02:00
Lorenzo BianconiandFelix Fietkau 5079d5b0b1 mt76: sdio: move common code in mt76_sdio module
Move sdio common code in mt76_sdio module.
This is a preliminary patch to support mt7921s devices.

Co-developed-by: Sean Wang <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-10-19 12:15:59 +02:00
Sean WangandFelix Fietkau f0dedcf6aa mt76: mt7921: use physical addr to unify register access
Use physical address to unify the register access and reorder the
entries in fixed_map table to accelerate the address lookup for
MT7921e. Cosmetics the patch with adding an extra space to make all
entries in the array style consistent.

Tested-by: Deren Wu <[email protected]>
Acked-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-10-19 12:15:59 +02:00
Sean WangandFelix Fietkau 956206bb55 mt76: mt7921: make all event parser reusable between mt7921s and mt7921e
The longer event such as the event for mcu_get_nic_capability would hold
the data in paged fragment skb for the SDIO device so we turn the skb to
be linearized skb before accessing it to reuse the same event parser
betweem mt7921s and mt7921e.

Tested-by: Deren Wu <[email protected]>
Acked-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-10-19 12:15:59 +02:00
Sean WangandFelix Fietkau 65362a00d0 mt76: mt7663s: rely on mcu reg access utility
rely on mcu reg access utility and drop the duplicated code.

Acked-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-10-19 12:15:59 +02:00
Sean WangandFelix Fietkau 77600b0c10 mt76: connac: move mcu reg access utility routines in mt76_connac_lib module
Move mcu reg access shared between mt7663s and mt7921s in mt76_connac_lib
module.

Tested-by: Deren Wu <[email protected]>
Acked-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-10-19 12:15:59 +02:00
Sean WangandFelix Fietkau 6cf8248c1a mt76: mt7921: add MT7921_COMMON module
This is a preliminary patch to introduce mt7921s support.

MT7921_COMMON module grouping bus independent objects the both mt7921e and
mt7921s can share with and have to rely on.

Tested-by: Deren Wu <[email protected]>
Acked-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-10-19 12:15:59 +02:00
Sean WangandFelix Fietkau 1c8418207c mt76: mt7921: refactor init.c to be bus independent
This is a preliminary patch to introduce mt7921s support.

Make init.c reusable between mt7921s and mt7921e

Tested-by: Deren Wu <[email protected]>
Acked-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-10-19 12:15:27 +02:00
Sean WangandFelix Fietkau 6556bddf26 mt76: mt7921: refactor mcu.c to be bus independent
This is a preliminary patch to introduce mt7921s support.

Make mcu.c reusable between mt7921s and mt7921e

Tested-by: Deren Wu <[email protected]>
Acked-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-10-19 12:15:27 +02:00
Sean WangandFelix Fietkau bfa909c833 mt76: mt7921: refactor dma.c to be pcie specific
This is a preliminary patch to introduce mt7921s support.

make dma.c be used dedicately for mt7921e.

by moving out mt7921_tx_cleanup from dma.c to mcu.c and then renaming
mt7921_tx_cleanup to refect the exact thing the function actually does.

Finally, dma.c totally become pcie specific one, only needed to
be compiled only when CONFIG_MT7921E is enabled.

Tested-by: Deren Wu <[email protected]>
Acked-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-10-19 12:15:27 +02:00
Sean WangandFelix Fietkau c062f69203 mt76: mt7921: refactor mac.c to be bus independent
This is a preliminary patch to introduce mt7921s support.

Split out a new pci_mac.c from mac.c to make mac.c reusable between
mt7921s and mt7921e.

Tested-by: Deren Wu <[email protected]>
Acked-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-10-19 12:15:27 +02:00
Sean WangandFelix Fietkau ce74fc020d mt76: mt7921: add MU EDCA cmd support
Add MU EDCA MCU command support to update MU AC parameter record field
from the access point.

Co-developed-by: Eric-SY Chang <[email protected]>
Signed-off-by: Eric-SY Chang <[email protected]>
Tested-by: Eric-SY Chang <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2021-10-19 12:13:41 +02:00