linux-2.6-microblaze.git
3 years agomt76: fix potential DMA mapping leak
Felix Fietkau [Tue, 23 Mar 2021 21:47:37 +0000 (22:47 +0100)]
mt76: fix potential DMA mapping leak

With buf uninitialized in mt76_dma_tx_queue_skb_raw, its field skip_unmap
could potentially inherit a non-zero value from stack garbage.
If this happens, it will cause DMA mappings for MCU command frames to not be
unmapped after completion

Fixes: 27d5c528a7ca ("mt76: fix double DMA unmap of the first buffer on 7615/7915")
Cc: stable@vger.kernel.org
Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: mt7921: reduce the data latency during hw scan
Sean Wang [Tue, 6 Apr 2021 03:34:39 +0000 (11:34 +0800)]
mt76: mt7921: reduce the data latency during hw scan

Reduce the data latency during hw_scan by the split scan which would switch
back to operational channel right after scanning each channel done.

Suggested-by: Asda Wen <Asda.Wen@mediatek.com>
Suggested-by: Soul Huang <Soul.Huang@mediatek.com>
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>
3 years agomt76: mt7921: fix the insmod hangs
Sean Wang [Tue, 6 Apr 2021 03:34:37 +0000 (11:34 +0800)]
mt76: mt7921: fix the insmod hangs

Fix the second insert module causing the device hangs after remove module.

Fixes: 1c099ab44727 ("mt76: mt7921: add MCU support")
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: mt7921: fix kernel crash when the firmware fails to download
Sean Wang [Tue, 6 Apr 2021 03:34:36 +0000 (11:34 +0800)]
mt76: mt7921: fix kernel crash when the firmware fails to download

Fix kernel crash when the firmware is missing or fails to download.

[    9.444758] kernel BUG at drivers/pci/msi.c:375!
[    9.449363] Internal error: Oops - BUG: 0 [#1] PREEMPT SMP
[    9.501033] pstate: a0400009 (NzCv daif +PAN -UAO)
[    9.505814] pc : free_msi_irqs+0x180/0x184
[    9.509897] lr : free_msi_irqs+0x40/0x184
[    9.513893] sp : ffffffc015193870
[    9.517194] x29: ffffffc015193870 x28: 00000000f0e94fa2
[    9.522492] x27: 0000000000000acd x26: 000000000000009a
[    9.527790] x25: ffffffc0152cee58 x24: ffffffdbb383e0d8
[    9.533087] x23: ffffffdbb38628d0 x22: 0000000000040200
[    9.538384] x21: ffffff8cf7de7318 x20: ffffff8cd65a2480
[    9.543681] x19: ffffff8cf7de7000 x18: 0000000000000000
[    9.548979] x17: ffffff8cf9ca03b4 x16: ffffffdc13ad9a34
[    9.554277] x15: 0000000000000000 x14: 0000000000080800
[    9.559575] x13: ffffff8cd65a2980 x12: 0000000000000000
[    9.564873] x11: ffffff8cfa45d820 x10: ffffff8cfa45d6d0
[    9.570171] x9 : 0000000000000040 x8 : ffffff8ccef1b780
[    9.575469] x7 : aaaaaaaaaaaaaaaa x6 : 0000000000000000
[    9.580766] x5 : ffffffdc13824900 x4 : ffffff8ccefe0000
[    9.586063] x3 : 0000000000000000 x2 : 0000000000000000
[    9.591362] x1 : 0000000000000125 x0 : ffffff8ccefe0000
[    9.596660] Call trace:
[    9.599095]  free_msi_irqs+0x180/0x184
[    9.602831]  pci_disable_msi+0x100/0x130
[    9.606740]  pci_free_irq_vectors+0x24/0x30
[    9.610915]  mt7921_pci_probe+0xbc/0x250 [mt7921e]
[    9.615693]  pci_device_probe+0xd4/0x14c
[    9.619604]  really_probe+0x134/0x2ec
[    9.623252]  driver_probe_device+0x64/0xfc
[    9.627335]  device_driver_attach+0x4c/0x6c
[    9.631506]  __driver_attach+0xac/0xc0
[    9.635243]  bus_for_each_dev+0x8c/0xd4
[    9.639066]  driver_attach+0x2c/0x38
[    9.642628]  bus_add_driver+0xfc/0x1d0
[    9.646365]  driver_register+0x64/0xf8
[    9.650101]  __pci_register_driver+0x6c/0x7c
[    9.654360]  init_module+0x28/0xfdc [mt7921e]
[    9.658704]  do_one_initcall+0x13c/0x2d0
[    9.662615]  do_init_module+0x58/0x1e8
[    9.666351]  load_module+0xd80/0xeb4
[    9.669912]  __arm64_sys_finit_module+0xa8/0xe0
[    9.674430]  el0_svc_common+0xa4/0x16c
[    9.678168]  el0_svc_compat_handler+0x2c/0x40
[    9.682511]  el0_svc_compat+0x8/0x10
[    9.686076] Code: a94257f6 f9400bf7 a8c47bfd d65f03c0 (d4210000)
[    9.692155] ---[ end trace 7621f966afbf0a29 ]---
[    9.697385] Kernel panic - not syncing: Fatal exception
[    9.702599] SMP: stopping secondary CPUs
[    9.706549] Kernel Offset: 0x1c03600000 from 0xffffffc010000000
[    9.712456] PHYS_OFFSET: 0xfffffff440000000
[    9.716625] CPU features: 0x080026,2a80aa18
[    9.720795] Memory Limit: none

Fixes: 5c14a5f944b9 ("mt76: mt7921: introduce mt7921e support")
Reported-by: Claire Chang <tientzu@google.com>
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>
3 years agomt76: mt7921: fix the dwell time control
Sean Wang [Tue, 6 Apr 2021 03:34:35 +0000 (11:34 +0800)]
mt76: mt7921: fix the dwell time control

dwell time for the scan is not configurable according to the current
firmware submitted into linux-firmware.git, so leave the dwell time 0 to
indicate the dwell time always determined by the firmware.

Fixes: 399090ef9605 ("mt76: mt76_connac: move hw_scan and sched_scan routine in mt76_connac_mcu module")
Suggested-by: Soul Huang <Soul.Huang@mediatek.com>
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>
3 years agomt76: mt7921: fix inappropriate WoW setup with the missing ARP informaiton
Sean Wang [Tue, 6 Apr 2021 03:34:34 +0000 (11:34 +0800)]
mt76: mt7921: fix inappropriate WoW setup with the missing ARP informaiton

Fix the Wake-on-WoWLAN failure should rely on ARP Information is being
updated in time to the firmware.

Fixes: ffa1bf97425b ("mt76: mt7921: introduce PM support")
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: mt7921: introduce MT_WFDMA_DUMMY_CR definition
Lorenzo Bianconi [Sun, 4 Apr 2021 11:36:57 +0000 (13:36 +0200)]
mt76: mt7921: introduce MT_WFDMA_DUMMY_CR definition

Introduce MT_WFDMA_DUMMY_CR definition and remove magic numbers

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: mt7915: add wifi subsystem reset
Ryder Lee [Tue, 6 Apr 2021 04:46:09 +0000 (12:46 +0800)]
mt76: mt7915: add wifi subsystem reset

Reset wifi subsystem when MCU is already running.
Fixes firmware download failure after soft reboot on systems where the PCIe
reset could not be performed properly.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Co-developed-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: mt7915: fix mt7915_mcu_add_beacon
Ryder Lee [Sun, 4 Apr 2021 07:48:24 +0000 (15:48 +0800)]
mt76: mt7915: fix mt7915_mcu_add_beacon

ieee80211_beacon_get_template() returns NULL when beacon state is disabled.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: mt7615: fix .add_beacon_offload()
Ryder Lee [Sun, 4 Apr 2021 07:48:23 +0000 (15:48 +0800)]
mt76: mt7615: fix .add_beacon_offload()

ieee80211_beacon_get_template() returns NULL when beacon state is disabled,
so beacon_offload cannot be disabled for some devices.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: mt7921: rework mt7921_mcu_debug_msg_event routine
Lorenzo Bianconi [Sat, 3 Apr 2021 12:35:12 +0000 (14:35 +0200)]
mt76: mt7921: rework mt7921_mcu_debug_msg_event routine

Rework mt7921_mcu_debug_msg_event routing removing unnecessary
assignments and relying on wiphy_info

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: mt7921: always wake the device in mt7921_remove_interface
Lorenzo Bianconi [Sat, 3 Apr 2021 12:26:39 +0000 (14:26 +0200)]
mt76: mt7921: always wake the device in mt7921_remove_interface

Make sure the mcu is not in sleep mode before sending mcu messages in
mt7921_remove_interface routine.

Fixes: 1d8efc741df80 ("mt76: mt7921: introduce Runtime PM support")
Co-developed-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Co-developed-by: Leon Yen <leon.yen@mediatek.com>
Signed-off-by: Leon Yen <leon.yen@mediatek.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: mt7921: fix key set/delete issue
Lorenzo Bianconi [Sat, 27 Mar 2021 09:10:14 +0000 (10:10 +0100)]
mt76: mt7921: fix key set/delete issue

Similar to the mt7915 driver, deleting a key with the previous key index
deletes the current key. Rework the code to better keep track of
multiple keys and check for the key index before deleting the current
key

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: mt7915: fix txpower init for TSSI off chips
Shayne Chen [Thu, 1 Apr 2021 02:31:29 +0000 (10:31 +0800)]
mt76: mt7915: fix txpower init for TSSI off chips

Fix incorrect txpower init value for TSSI off chips which causes
too small txpower.

Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: mt7615: remove redundant dev_err call in mt7622_wmac_probe()
Guobin Huang [Sat, 27 Mar 2021 09:56:18 +0000 (17:56 +0800)]
mt76: mt7615: remove redundant dev_err call in mt7622_wmac_probe()

There is a error message within devm_ioremap_resource
already, so remove the dev_err call to avoid redundant
error message.

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Guobin Huang <huangguobin4@huawei.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agodt-bindings:net:wireless:mediatek,mt76: txt to yaml conversion
Lorenzo Bianconi [Sun, 28 Mar 2021 17:37:48 +0000 (19:37 +0200)]
dt-bindings:net:wireless:mediatek,mt76: txt to yaml conversion

Convert mt76 dts bindings from .txt to .yaml

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agodt-bindings:net:wireless:ieee80211: txt to yaml conversion
Lorenzo Bianconi [Wed, 24 Mar 2021 21:49:59 +0000 (22:49 +0100)]
dt-bindings:net:wireless:ieee80211: txt to yaml conversion

Convert generic ieee80211 dts bindings from .txt to .yaml

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: mt7915: limit firmware log message printk to buffer length
Felix Fietkau [Fri, 26 Mar 2021 09:40:55 +0000 (10:40 +0100)]
mt76: mt7915: limit firmware log message printk to buffer length

Avoid including garbage from previous rx data

Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: mt7615: limit firmware log message printk to buffer length
Felix Fietkau [Fri, 26 Mar 2021 09:38:25 +0000 (10:38 +0100)]
mt76: mt7615: limit firmware log message printk to buffer length

Avoid including garbage from previous rx data

Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: mt7615: fix chip reset on MT7622 and MT7663e
Felix Fietkau [Fri, 26 Mar 2021 20:52:11 +0000 (21:52 +0100)]
mt76: mt7615: fix chip reset on MT7622 and MT7663e

After chip reset, the DMA scheduler needs to be initialized as well.
Since the code is PCI/SoC specific, move it to pci_mac.c, so that it
can depend on a function in dma.c

Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: mt7915: cleanup mcu tx queue in mt7915_dma_reset()
Ryder Lee [Thu, 25 Mar 2021 18:28:56 +0000 (02:28 +0800)]
mt76: mt7915: cleanup mcu tx queue in mt7915_dma_reset()

Cleanup mcu queues in mt7915_mac_reset_work().

Fixes: e637763b606b ("mt76: move mcu queues to mt76_dev q_mcu array")
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: mt7915: keep mcu_add_bss_info enabled till interface removal
Ryder Lee [Thu, 25 Mar 2021 08:06:05 +0000 (16:06 +0800)]
mt76: mt7915: keep mcu_add_bss_info enabled till interface removal

The same as mt7615. Keep BSS_INFO_BASIC enabled throughout interfaces
life cycle.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: mt7615: keep mcu_add_bss_info enabled till interface removal
Ryder Lee [Thu, 25 Mar 2021 08:06:04 +0000 (16:06 +0800)]
mt76: mt7615: keep mcu_add_bss_info enabled till interface removal

BSS_INFO_BASIC is never called alone with inactive state, which always
follows beacon offload disable, so keep it enabled throughout interfaces
life cycle. Inactive state also removes sta record of all connected
stations, thurs causes connection lost which defeats the purpose of CSA.

Lastly, this is especially an unexpected behavior that keeping mt7622
failing beacon buffer recyled when scanning channels.

bss_conf change is updated with active state only, so just overwrite it.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: mt7622: trigger hif interrupt for system reset
Ryder Lee [Thu, 25 Mar 2021 08:06:03 +0000 (16:06 +0800)]
mt76: mt7622: trigger hif interrupt for system reset

hif interrupt needs to be triggered after MT_MCU_INT_EVENT.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: mt7615: cleanup mcu tx queue in mt7615_dma_reset()
Ryder Lee [Thu, 25 Mar 2021 08:06:02 +0000 (16:06 +0800)]
mt76: mt7615: cleanup mcu tx queue in mt7615_dma_reset()

With this patch, mt7615_mac_reset_work() can recover system back.

Fixes: e637763b606b ("mt76: move mcu queues to mt76_dev q_mcu array")
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: mt7615: only enable DFS test knobs for mt7615
Ryder Lee [Thu, 25 Mar 2021 08:06:01 +0000 (16:06 +0800)]
mt76: mt7615: only enable DFS test knobs for mt7615

DFS knobs should not be visible to non-DFS devices.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: mt7921: properly configure rcpi adding a sta to the fw
Lorenzo Bianconi [Wed, 24 Mar 2021 08:37:37 +0000 (09:37 +0100)]
mt76: mt7921: properly configure rcpi adding a sta to the fw

Properly configure rcpi based on association process rssi. rcpi is used
by rate controller embedded into the fw to initialize amsdu size.

Tested-by: Jayden.Kuo <jayden.kuo@mediatek.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: connac: introduce mt76_sta_cmd_info data structure
Lorenzo Bianconi [Wed, 24 Mar 2021 08:37:36 +0000 (09:37 +0100)]
mt76: connac: introduce mt76_sta_cmd_info data structure

Introduce mt76_sta_cmd_info data structure to contain parameters passed
to mt76_sta_cmd_info routine. This is preliminary patch to properly
configure rcpi for mt7921 devices.

Tested-by: Jayden.Kuo <jayden.kuo@mediatek.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: mt7921: get rid of mt7921_mac_wtbl_lmac_addr
Lorenzo Bianconi [Wed, 24 Mar 2021 08:25:22 +0000 (09:25 +0100)]
mt76: mt7921: get rid of mt7921_mac_wtbl_lmac_addr

Get rid of mt7921_mac_wtbl_lmac_addr routine since mt7921 wtbl size is
19 entries

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: mt7915: refresh repeater entry MAC address when setting BSSID
Felix Fietkau [Tue, 16 Feb 2021 14:23:13 +0000 (15:23 +0100)]
mt76: mt7915: refresh repeater entry MAC address when setting BSSID

When disassociating and clearing the BSSID of a repeater entry used by a client
mode interface, the corresponding MAC address entry can get lost too, causing
the client interface to not be able to associate anymore.
Fix this by also refreshing the MAC address when setting the BSSID

Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: mt7915: fix key set/delete issue
Felix Fietkau [Mon, 22 Mar 2021 20:39:57 +0000 (21:39 +0100)]
mt76: mt7915: fix key set/delete issue

Deleting a key with the previous key index deletes the current key
Rework the code to better keep track of multiple keys and check for the
key index before deleting the current key

Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: mt7921: remove duplicated macros in mcu.h
Lorenzo Bianconi [Mon, 15 Mar 2021 08:21:10 +0000 (09:21 +0100)]
mt76: mt7921: remove duplicated macros in mcu.h

Remove mcu definitions already available in mt76_connac_mcu.h

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: mt7921: remove redundant check on type
Colin Ian King [Fri, 12 Mar 2021 17:29:49 +0000 (17:29 +0000)]
mt76: mt7921: remove redundant check on type

Currently in the switch statement case where type is
NL80211_IFTYPE_STATION there is a check to see if type
is not NL80211_IFTYPE_STATION.  This check is always false
and is redundant dead code that can be removed.

Addresses-Coverity: ("Logically dead code")
Fixes: e0f9fdda81bd ("mt76: mt7921: add ieee80211_ops")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: mt7921: remove leftovers from dbdc configuration
Lorenzo Bianconi [Thu, 11 Mar 2021 09:46:21 +0000 (10:46 +0100)]
mt76: mt7921: remove leftovers from dbdc configuration

Remove leftovers from dbdc configuration since mt7921
does not support it.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: mt7921: add wifi reset support
Lorenzo Bianconi [Sun, 7 Mar 2021 18:20:51 +0000 (19:20 +0100)]
mt76: mt7921: add wifi reset support

Introduce wifi chip reset support for mt7921 device to recover mcu
hangs.

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>
3 years agomt76: dma: export mt76_dma_rx_cleanup routine
Lorenzo Bianconi [Sun, 7 Mar 2021 18:20:50 +0000 (19:20 +0100)]
mt76: dma: export mt76_dma_rx_cleanup routine

Export mt76_dma_rx_cleanup routine in mt76_queue_ops data structure.
This is a preliminary patch to introduce mt7921 chip reset support.

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>
3 years agomt76: dma: introduce mt76_dma_queue_reset routine
Lorenzo Bianconi [Sun, 7 Mar 2021 18:20:49 +0000 (19:20 +0100)]
mt76: dma: introduce mt76_dma_queue_reset routine

Introduce mt76_dma_queue_reset utility routine to reset a given hw
queue. This is a preliminary patch to introduce mt7921 chip reset
support.

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>
3 years agomt76: mt7921: introduce __mt7921_start utility routine
Lorenzo Bianconi [Sun, 7 Mar 2021 18:20:48 +0000 (19:20 +0100)]
mt76: mt7921: introduce __mt7921_start utility routine

This is a preliminary patch to introduce mt7921 chip reset support.

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>
3 years agomt76: mt7921: introduce mt7921_run_firmware utility routine.
Lorenzo Bianconi [Sun, 7 Mar 2021 18:20:47 +0000 (19:20 +0100)]
mt76: mt7921: introduce mt7921_run_firmware utility routine.

This is a preliminary patch to introduce chip reset for mt7921 devices.

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>
3 years agomt76: introduce mcu_reset function pointer in mt76_mcu_ops structure
Lorenzo Bianconi [Sun, 7 Mar 2021 18:20:46 +0000 (19:20 +0100)]
mt76: introduce mcu_reset function pointer in mt76_mcu_ops structure

Introduce mcu_reset function pointer in mt76_mcu_ops structure in order
to run hw related reset function for the mcu running on the chipset.
This is a preliminary patch to introduce chip reset for mt7921 devices.

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>
3 years agomt76: mt7921: reduce mcu timeouts for suspend, offload and hif_ctrl msg
Lorenzo Bianconi [Sun, 7 Mar 2021 18:20:45 +0000 (19:20 +0100)]
mt76: mt7921: reduce mcu timeouts for suspend, offload and hif_ctrl msg

Reduce mcu timeout for the following uni mcu commands:
- MCU_UNI_CMD_SUSPEND
- MCU_UNI_CMD_OFFLOAD
- MCU_UNI_CMD_HIF_CTRL

This is a preliminary patch to introduce chip reset support

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>
3 years agomt76: mt7915: fix possible deadlock while mt7915_register_ext_phy()
Ryder Lee [Fri, 5 Mar 2021 08:46:41 +0000 (16:46 +0800)]
mt76: mt7915: fix possible deadlock while mt7915_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 mt7915_register_ext_phy() outside the init_work().

Signed-off-by: Evelyn Tsai <evelyn.tsai@mediatek.com>
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: mt7615: add missing capabilities for DBDC
Ryder Lee [Fri, 5 Mar 2021 00:22:14 +0000 (08:22 +0800)]
mt76: mt7615: add missing capabilities for DBDC

This improves performance for second phy.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: mt7663s: fix the possible device hang in high traffic
Sean Wang [Thu, 4 Mar 2021 13:25:23 +0000 (21:25 +0800)]
mt76: mt7663s: fix the possible device hang in high traffic

Use the additional memory barrier to ensure the skb list up-to-date
between the skb producer and consumer to avoid the invalid skb content
written into sdio controller and then cause device hang due to mcu assert
caught by WR_TIMEOUT_INT.

Fixes: 1522ff731f84 ("mt76: mt7663s: introduce sdio tx aggregation")
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: mt7663s: make all of packets 4-bytes aligned in sdio tx aggregation
Sean Wang [Thu, 4 Mar 2021 13:25:22 +0000 (21:25 +0800)]
mt76: mt7663s: make all of packets 4-bytes aligned in sdio tx aggregation

Each packet should be padded with the additional zero to become 4-bytes
alignment in sdio tx aggregation.

Fixes: 1522ff731f84 ("mt76: mt7663s: introduce sdio tx aggregation")
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: mt7663: fix when beacon filter is being applied
Sean Wang [Thu, 4 Mar 2021 13:25:21 +0000 (21:25 +0800)]
mt76: mt7663: fix when beacon filter is being applied

HW beacon filter command is being applied until we're in associated state
because the command would rely on the associated access point's beacon
interval and DTIM information.

Fixes: 7124198ab1a4 ("mt76: mt7615: enable beacon filtering by default for offload fw")
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: mt7615: check mcu returned values in mt7615_ops
Ryder Lee [Fri, 5 Mar 2021 15:52:59 +0000 (23:52 +0800)]
mt76: mt7615: check mcu returned values in mt7615_ops

Properly check returned values from mcu utility routines in
mt7615_ops.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: mt7915: check mcu returned values in mt7915_ops
Ryder Lee [Wed, 3 Mar 2021 10:38:01 +0000 (18:38 +0800)]
mt76: mt7915: check mcu returned values in mt7915_ops

Properly check returned values from mcu utility routines in
mt7915_ops.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: mt7915: fix txrate reporting
Ryder Lee [Wed, 3 Mar 2021 10:38:00 +0000 (18:38 +0800)]
mt76: mt7915: fix txrate reporting

Properly check rate_info to fix unexpected reporting.

[ 1215.161863] Call trace:
[ 1215.164307]  cfg80211_calculate_bitrate+0x124/0x200 [cfg80211]
[ 1215.170139]  ieee80211s_update_metric+0x80/0xc0 [mac80211]
[ 1215.175624]  ieee80211_tx_status_ext+0x508/0x838 [mac80211]
[ 1215.181190]  mt7915_mcu_get_rx_rate+0x28c/0x8d0 [mt7915e]
[ 1215.186580]  mt7915_mac_tx_free+0x324/0x7c0 [mt7915e]
[ 1215.191623]  mt7915_queue_rx_skb+0xa8/0xd0 [mt7915e]
[ 1215.196582]  mt76_dma_cleanup+0x7b0/0x11d0 [mt76]
[ 1215.201276]  __napi_poll+0x38/0xf8
[ 1215.204668]  napi_workfn+0x40/0x80
[ 1215.208062]  process_one_work+0x1fc/0x390
[ 1215.212062]  worker_thread+0x48/0x4d0
[ 1215.215715]  kthread+0x120/0x128
[ 1215.218935]  ret_from_fork+0x10/0x1c

Fixes: e57b7901469f ("mt76: add mac80211 driver for MT7915 PCIe-based chipsets")
Fixes: e4c5ead632ff ("mt76: mt7915: rename mt7915_mcu_get_rate_info to mt7915_mcu_get_tx_rate")
Reported-by: Evelyn Tsai <evelyn.tsai@mediatek.com>
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: mt7915: fix rxrate reporting
Ryder Lee [Wed, 3 Mar 2021 10:37:59 +0000 (18:37 +0800)]
mt76: mt7915: fix rxrate reporting

Avoid directly updating sinfo->rxrate from firmware since rate_info might
be overwritten by wrong results even mt7915_mcu_get_rx_rate() fails check.

Add more error handlings accordingly.

Fixes: 11553d88d0b9 ("mt76: mt7915: query station rx rate from firmware")
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: mt76x0u: Add support for TP-Link T2UHP(UN) v1
Eric Y.Y. Wong [Wed, 3 Mar 2021 03:43:52 +0000 (11:43 +0800)]
mt76: mt76x0u: Add support for TP-Link T2UHP(UN) v1

There are two variants of TP-Link Archer T2UHP V1, which are US and UN:

https://www.tp-link.com/us/support/download/archer-t2uhp/
https://www.tp-link.com/hk/support/download/archer-t2uhp/v1/

From the driver source code provided by the vendor:

https://www.tp-link.com/hk/support/download/archer-t2uhp/v1/#Driver

eric@eric-VirtualBox:~/src$ grep -n USB_DEVICE.*0x2357 DPA_mt7610u_wifi_sta_v3004_rev1_20140529/NETIF/common/rtusb_dev_id.c
45: {USB_DEVICE(0x2357,0x0105)}, /* T1Uv1 */
46: {USB_DEVICE(0x2357,0x010B)}, /* T2UHP_UN_v1 */
47: {USB_DEVICE(0x2357,0x0123)}, /* T2UHP_US_v1 */

eric@eric-VirtualBox:~/src$ lsusb -d 2357:
Bus 001 Device 003: ID 2357:010b TP-Link WiFi
eric@eric-VirtualBox:~/src$ sudo modprobe mt76x0u
eric@eric-VirtualBox:~/src$ sudo sh -c "echo 2357 010b > /sys/bus/usb/drivers/mt76x0u/new_id"

[snip]

eric@eric-VirtualBox:~/src$ ifconfig -a
enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        ether 08:00:27:74:d9:ee  txqueuelen 1000  (Ethernet)
        RX packets 78  bytes 16146 (16.1 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 75  bytes 8413 (8.4 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 56  bytes 5496 (5.4 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 56  bytes 5496 (5.4 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlx18d6c71b6e3e: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.106  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::21c7:2d90:e47d:ee48  prefixlen 64  scopeid 0x20<link>
        ether 18:d6:c7:1b:6e:3e  txqueuelen 1000  (Ethernet)
        RX packets 37  bytes 5345 (5.3 KB)
        RX errors 0  dropped 7  overruns 0  frame 0
        TX packets 77  bytes 10513 (10.5 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eric@eric-VirtualBox:~/src$ dmesg | tail -n 30
               12:51:25.551584 main     Log opened 2021-03-01T12:51:25.551572000Z
[   46.855763] 12:51:25.551995 main     OS Product: Linux
[   46.855838] 12:51:25.552075 main     OS Release: 5.4.0-66-generic
[   46.855897] 12:51:25.552150 main     OS Version: #74-Ubuntu SMP Wed Jan 27 22:54:38 UTC 2021
[   46.855971] 12:51:25.552207 main     Executable: /opt/VBoxGuestAdditions-6.1.16/sbin/VBoxService
               12:51:25.552208 main     Process ID: 898
               12:51:25.552209 main     Package type: LINUX_64BITS_GENERIC
[   46.858699] 12:51:25.554921 main     6.1.16 r140961 started. Verbose level = 0
[   46.863116] 12:51:25.559319 main     vbglR3GuestCtrlDetectPeekGetCancelSupport: Supported (#1)
[  140.687550] usb 1-2: new high-speed USB device number 3 using xhci_hcd
[  140.838279] usb 1-2: New USB device found, idVendor=2357, idProduct=010b, bcdDevice= 1.00
[  140.838281] usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[  140.838283] usb 1-2: Product: WiFi
[  140.838284] usb 1-2: Manufacturer: MediaTek
[  140.838285] usb 1-2: SerialNumber: 1.0
[  178.374187] cfg80211: Loading compiled-in X.509 certificates for regulatory database
[  178.378370] cfg80211: Loaded X.509 cert 'sforshee: 00b28ddf47aef9cea7'
[  178.417507] usbcore: registered new interface driver mt76x0u
[  178.557165] usb 1-2: reset high-speed USB device number 3 using xhci_hcd
[  178.720436] mt76x0u 1-2:1.0: ASIC revision: 76100002 MAC revision: 76502000
[  180.156077] mt76x0u 1-2:1.0: EEPROM ver:02 fae:04
[  181.190558] ieee80211 phy0: Selected rate control algorithm 'minstrel_ht'
[  181.225560] mt76x0u 1-2:1.0 wlx18d6c71b6e3e: renamed from wlan0
[  188.660826] wlx18d6c71b6e3e: authenticate with d0:17:c2:e0:d7:9c
[  189.447781] wlx18d6c71b6e3e: send auth to d0:17:c2:e0:d7:9c (try 1/3)
[  189.618282] wlx18d6c71b6e3e: authenticated
[  189.619008] wlx18d6c71b6e3e: associate with d0:17:c2:e0:d7:9c (try 1/3)
[  189.715268] wlx18d6c71b6e3e: RX AssocResp from d0:17:c2:e0:d7:9c (capab=0x1011 status=0 aid=8)
[  189.734720] wlx18d6c71b6e3e: associated
[  190.233239] IPv6: ADDRCONF(NETDEV_CHANGE): wlx18d6c71b6e3e: link becomes ready

Signed-off-by: Eric Y.Y. Wong <eric.wongyeungyan@gmail.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: mt7915: fix PHY mode for DBDC
Ryder Lee [Sat, 27 Feb 2021 07:39:46 +0000 (15:39 +0800)]
mt76: mt7915: fix PHY mode for DBDC

Fix PHY mode configuration for DBDC.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: mt7915: stop ext_phy queue when mac reset happens
Ryder Lee [Sat, 27 Feb 2021 07:39:45 +0000 (15:39 +0800)]
mt76: mt7915: stop ext_phy queue when mac reset happens

Stop Tx burst for ext_phy after mac reset.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: mt7915: fix CSA notification for DBDC
Ryder Lee [Sat, 27 Feb 2021 07:39:44 +0000 (15:39 +0800)]
mt76: mt7915: fix CSA notification for DBDC

Add CSA notification for second phy.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: mt7615: stop ext_phy queue when mac reset happens
Ryder Lee [Sat, 27 Feb 2021 07:39:43 +0000 (15:39 +0800)]
mt76: mt7615: stop ext_phy queue when mac reset happens

Stop Tx burst for ext_phy after mac reset.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: mt7615: fix CSA notification for DBDC
Ryder Lee [Sat, 27 Feb 2021 07:39:42 +0000 (15:39 +0800)]
mt76: mt7615: fix CSA notification for DBDC

Add CSA notification for second phy.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: mt7915: add missing capabilities for DBDC
Ryder Lee [Fri, 26 Feb 2021 16:44:27 +0000 (00:44 +0800)]
mt76: mt7915: add missing capabilities for DBDC

This improves dbdc performance.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: mt7921: check mcu returned values in mt7921_start
Lorenzo Bianconi [Fri, 26 Feb 2021 11:17:23 +0000 (12:17 +0100)]
mt76: mt7921: check mcu returned values in mt7921_start

Properly check returned values from mcu utility routines in
mt7921_start.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: mt7921: fix the base of the dynamic remap
Sean Wang [Fri, 26 Feb 2021 08:23:27 +0000 (16:23 +0800)]
mt76: mt7921: fix the base of the dynamic remap

We should change the base for the dynamic remap into another one, because
the current base (0xe0000) have been the one used to operate the device
ownership.

Fixes: 163f4d22c118 ("mt76: mt7921: add MAC support")
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>
3 years agomt76: mt7921: fix the base of PCIe interrupt
Sean Wang [Fri, 26 Feb 2021 08:23:26 +0000 (16:23 +0800)]
mt76: mt7921: fix the base of PCIe interrupt

Should use 0x10000 as the base to operate PCIe interrupt according
to the vendor reference driver.

Fixes: ffa1bf97425b ("mt76: mt7921: introduce PM support")
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>
Tested-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: mt7921: get rid of mt7921_sta_rc_update routine
Lorenzo Bianconi [Wed, 24 Feb 2021 15:57:18 +0000 (16:57 +0100)]
mt76: mt7921: get rid of mt7921_sta_rc_update routine

Since the rate selection is currently managed by the fw, get rid of
empty mt7921_sta_rc_update routine

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: check return value of mt76_txq_send_burst in mt76_txq_schedule_list
Lorenzo Bianconi [Wed, 24 Feb 2021 11:29:34 +0000 (12:29 +0100)]
mt76: check return value of mt76_txq_send_burst in mt76_txq_schedule_list

Since mt76_txq_send_burst routine can report a negative error code,
check the returned value before incrementing the number of transmitted
frames in mt76_txq_schedule_list routine.
Return -EBUSY directly if the device is in reset or in power management.

Fixes: 90fdc1717b186 ("mt76: use mac80211 txq scheduling")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: connac: fix kernel warning adding monitor interface
Lorenzo Bianconi [Tue, 23 Feb 2021 17:28:43 +0000 (18:28 +0100)]
mt76: connac: fix kernel warning adding monitor interface

Fix the following kernel warning adding a monitor interface in
mt76_connac_mcu_uni_add_dev routine.

[  507.984882] ------------[ cut here ]------------
[  507.989515] WARNING: CPU: 1 PID: 3017 at mt76_connac_mcu_uni_add_dev+0x178/0x190 [mt76_connac_lib]
[  508.059379] CPU: 1 PID: 3017 Comm: ifconfig Not tainted 5.4.98 #0
[  508.065461] Hardware name: MT7622_MT7531 RFB (DT)
[  508.070156] pstate: 80000005 (Nzcv daif -PAN -UAO)
[  508.074939] pc : mt76_connac_mcu_uni_add_dev+0x178/0x190 [mt76_connac_lib]
[  508.081806] lr : mt7921_eeprom_init+0x1288/0x1cb8 [mt7921e]
[  508.087367] sp : ffffffc013a33930
[  508.090671] x29: ffffffc013a33930 x28: ffffff801e628ac0
[  508.095973] x27: ffffff801c7f1200 x26: ffffff801c7eb008
[  508.101275] x25: ffffff801c7eaef0 x24: ffffff801d025610
[  508.106577] x23: ffffff801d022990 x22: ffffff801d024de8
[  508.111879] x21: ffffff801d0226a0 x20: ffffff801c7eaee8
[  508.117181] x19: ffffff801d0226a0 x18: 000000005d00b000
[  508.122482] x17: 00000000ffffffff x16: 0000000000000000
[  508.127785] x15: 0000000000000080 x14: ffffff801d704000
[  508.133087] x13: 0000000000000040 x12: 0000000000000002
[  508.138389] x11: 000000000000000c x10: 0000000000000000
[  508.143691] x9 : 0000000000000020 x8 : 0000000000000001
[  508.148992] x7 : 0000000000000000 x6 : 0000000000000000
[  508.154294] x5 : ffffff801c7eaee8 x4 : 0000000000000006
[  508.159596] x3 : 0000000000000001 x2 : 0000000000000000
[  508.164898] x1 : ffffff801c7eac08 x0 : ffffff801d0226a0
[  508.170200] Call trace:
[  508.172640]  mt76_connac_mcu_uni_add_dev+0x178/0x190 [mt76_connac_lib]
[  508.179159]  mt7921_eeprom_init+0x1288/0x1cb8 [mt7921e]
[  508.184394]  drv_add_interface+0x34/0x88 [mac80211]
[  508.189271]  ieee80211_add_virtual_monitor+0xe0/0xb48 [mac80211]
[  508.195277]  ieee80211_do_open+0x86c/0x918 [mac80211]
[  508.200328]  ieee80211_do_open+0x900/0x918 [mac80211]
[  508.205372]  __dev_open+0xcc/0x150
[  508.208763]  __dev_change_flags+0x134/0x198
[  508.212937]  dev_change_flags+0x20/0x60
[  508.216764]  devinet_ioctl+0x3e8/0x748
[  508.220503]  inet_ioctl+0x1e4/0x350
[  508.223983]  sock_do_ioctl+0x48/0x2a0
[  508.227635]  sock_ioctl+0x310/0x4f8
[  508.231116]  do_vfs_ioctl+0xa4/0xac0
[  508.234681]  ksys_ioctl+0x44/0x90
[  508.237985]  __arm64_sys_ioctl+0x1c/0x48
[  508.241901]  el0_svc_common.constprop.1+0x7c/0x100
[  508.246681]  el0_svc_handler+0x18/0x20
[  508.250421]  el0_svc+0x8/0x1c8
[  508.253465] ---[ end trace c7b90fee13d72c39 ]---
[  508.261278] ------------[ cut here ]------------

Fixes: d0e274af2f2e4 ("mt76: mt76_connac: create mcu library")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: mt7915: fix mib stats counter reporting to mac80211
Ryder Lee [Tue, 23 Feb 2021 14:00:36 +0000 (22:00 +0800)]
mt76: mt7915: fix mib stats counter reporting to mac80211

In order to properly report MIB counters to mac80211, resets stats in
mt7915_get_stats routine() and hold mt76 mutex accessing MIB counters.
Sum up MIB counters in mt7915_mac_update_mib_stats routine.

Fixes: e57b7901469f ("mt76: add mac80211 driver for MT7915 PCIe-based chipsets")
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: mt7615: fix mib stats counter reporting to mac80211
Lorenzo Bianconi [Tue, 23 Feb 2021 10:42:49 +0000 (11:42 +0100)]
mt76: mt7615: fix mib stats counter reporting to mac80211

In order to properly report MIB counters to mac80211, resets stats in
mt7615_get_stats routine and hold mt76 mutex accessing MIB counters.
Sum up MIB counters in mt7615_mac_update_mib_stats routine.

Fixes: c388d8584bc83 ("mt76: mt7615: add a get_stats() callback")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: mt7615: remove hdr->fw_ver check
Ryder Lee [Tue, 23 Feb 2021 08:43:12 +0000 (16:43 +0800)]
mt76: mt7615: remove hdr->fw_ver check

Only mt7615 uses v1 version. Also, some of released firmware doesn't
have hdr->fw_ver.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: mt7615: fix TSF configuration
Ryder Lee [Tue, 23 Feb 2021 08:43:11 +0000 (16:43 +0800)]
mt76: mt7615: fix TSF configuration

The index of TSF counters should follow HWBSSID.

Fixes: d8d59f66d136 ("mt76: mt7615: support 16 interfaces")
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: mt7921: fix stats register definitions
Lorenzo Bianconi [Mon, 22 Feb 2021 18:17:49 +0000 (19:17 +0100)]
mt76: mt7921: fix stats register definitions

Fix register definitions for mac80211 stats reporting.
Move mib counter reset to mt7921_get_stats routine.

Fixes: 163f4d22c118d ("mt76: mt7921: add MAC support")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: mt7921: remove unneeded semicolon
Jiapeng Chong [Mon, 22 Feb 2021 09:03:31 +0000 (17:03 +0800)]
mt76: mt7921: remove unneeded semicolon

Fix the following coccicheck warnings:

./drivers/net/wireless/mediatek/mt76/mt7921/mac.c:1402:2-3: Unneeded
semicolon.

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: mt7915: fix aggr len debugfs node
Lorenzo Bianconi [Mon, 22 Feb 2021 01:14:36 +0000 (02:14 +0100)]
mt76: mt7915: fix aggr len debugfs node

Similar to mt7921, fix 802.11 aggr len debugfs reporting for mt7915 driver.

Fixes: e57b7901469fc ("mt76: add mac80211 driver for MT7915 PCIe-based chipsets")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: mt7921: fix aggr length histogram
Lorenzo Bianconi [Mon, 22 Feb 2021 01:12:09 +0000 (02:12 +0100)]
mt76: mt7921: fix aggr length histogram

Fix register definitions for 802.11 aggr length histogram estimation.

Fixes: 474a9f21e2e2 ("mt76: mt7921: add debugfs support")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: mt7615: fix memory leak in mt7615_coredump_work
Lorenzo Bianconi [Fri, 19 Feb 2021 17:22:11 +0000 (18:22 +0100)]
mt76: mt7615: fix memory leak in mt7615_coredump_work

Similar to the issue fixed in mt7921_coredump_work, fix a possible memory
leak in mt7615_coredump_work routine.

Fixes: d2bf7959d9c0f ("mt76: mt7663: introduce coredump support")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: mt7615: add support for rx decapsulation offload
Ryder Lee [Thu, 18 Feb 2021 01:34:40 +0000 (09:34 +0800)]
mt76: mt7615: add support for rx decapsulation offload

For AP and Client mode, the hardware can pass received packets
as 802.3 frames that can be passed to the network stack as-is.

Tested-by: Frank Wunderlich <frank-w@public-files.de>
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: mt7615: add rx checksum offload support
Ryder Lee [Thu, 18 Feb 2021 01:34:39 +0000 (09:34 +0800)]
mt76: mt7615: add rx checksum offload support

Set skb->ip_summed to CHECKSUM_UNNECESSARY if the hardware has validated
the IP and TCP/UDP checksum

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: mt7615: enable hw rx-amsdu de-aggregation
Ryder Lee [Thu, 18 Feb 2021 01:34:38 +0000 (09:34 +0800)]
mt76: mt7615: enable hw rx-amsdu de-aggregation

Enable hw rx-amsdu de-aggregation support.
This is a preliminary patch to enable rx checksum offload.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: use threaded NAPI
Felix Fietkau [Sun, 26 Jul 2020 11:09:51 +0000 (13:09 +0200)]
mt76: use threaded NAPI

With threaded NAPI, the rx handler function is no longer bound to the CPU that
fired the interrupt, which significantly helps to spread the workload over
multiple CPUs, especially when multiple devices are using threaded NAPI at the
same time.
Exclude the tx handler from threaded NAPI by using a separate dummy netdev.
The work is small and short-lived enough that it makes more sense to run it in
softirq instead of creating a dedicated thread

Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: connac: update sched_scan cmd usage
Sean Wang [Fri, 19 Feb 2021 17:28:51 +0000 (18:28 +0100)]
mt76: connac: update sched_scan cmd usage

Update sched_scan command usage according to the current firmware
submitted into linux-firmware.git.

Fixes: 80fc1e37c0eb ("mt76: mt7921: rely on mt76_connac_mcu module for sched_scan and hw_scan")
Co-developed-by: Soul Huang <Soul.Huang@mediatek.com>
Signed-off-by: Soul Huang <Soul.Huang@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>
3 years agomt76: mt7921: add flush operation
Sean Wang [Fri, 19 Feb 2021 17:28:49 +0000 (18:28 +0100)]
mt76: mt7921: add flush operation

add flush operation to make sure cfg80211_mlme_deauth is able to flush
the deauthtication frame into air immediately.

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: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: mt7921: fixup rx bitrate statistics
Sean Wang [Fri, 19 Feb 2021 17:28:48 +0000 (18:28 +0100)]
mt76: mt7921: fixup rx bitrate statistics

Since the related rx bitrate fields have been moved to group3 in Rxv,
fix rx bitrate statistics in mt7921_mac_fill_rx routine.

Fixes: 163f4d22c118d ("mt76: mt7921: add MAC support")
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>
3 years agomt76: connac: fix up the setting for ht40 mode in mt76_connac_mcu_uni_add_bss
Sean Wang [Fri, 19 Feb 2021 17:28:47 +0000 (18:28 +0100)]
mt76: connac: fix up the setting for ht40 mode in mt76_connac_mcu_uni_add_bss

Use proper value for ht40 mode configuration in mt76_connac_mcu_uni_add_bss
routine and not ht20 one

Fixes: d0e274af2f2e4 ("mt76: mt76_connac: create mcu library")
Co-developed-by: Soul Huang <Soul.Huang@mediatek.com>
Signed-off-by: Soul Huang <Soul.Huang@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>
3 years agomt76: mt7921: switch to new api for hardware beacon filter
Sean Wang [Fri, 19 Feb 2021 17:28:46 +0000 (18:28 +0100)]
mt76: mt7921: switch to new api for hardware beacon filter

Current firmware only supports new api for enabling hardware beacon filter.

Fixes: 1d8efc741df80 ("mt76: mt7921: introduce Runtime PM support")
Beacon filter cmd have to rely on the associatied access point's beacon
interval and DTIM information.

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>
3 years agomt76: mt7921: fix memory leak in mt7921_coredump_work
Sean Wang [Fri, 19 Feb 2021 17:28:45 +0000 (18:28 +0100)]
mt76: mt7921: fix memory leak in mt7921_coredump_work

Fix possible memory leak in mt7921_coredump_work.

Fixes: 1c099ab44727c ("mt76: mt7921: add MCU support")
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>
3 years agomt76: mt7921: fix suspend/resume sequence
Sean Wang [Fri, 19 Feb 2021 17:28:44 +0000 (18:28 +0100)]
mt76: mt7921: fix suspend/resume sequence

Any pcie access should happen in pci D0 state and we should give ownership
back to the device at the end of the suspend procedure.

Fixes: 1d8efc741df80 ("mt76: mt7921: introduce Runtime PM support")
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>
3 years agomt76: use PCI_VENDOR_ID_MEDIATEK to avoid open coded
Ryder Lee [Tue, 2 Feb 2021 13:57:59 +0000 (21:57 +0800)]
mt76: use PCI_VENDOR_ID_MEDIATEK to avoid open coded

Use PCI standard defines.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Acked-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: mt7915: always check return value from mt7915_mcu_alloc_wtbl_req
Lorenzo Bianconi [Fri, 12 Feb 2021 19:30:04 +0000 (20:30 +0100)]
mt76: mt7915: always check return value from mt7915_mcu_alloc_wtbl_req

As done for mt76_connac_mcu_alloc_wtbl_req, even if this is not a real
bug since mt7915_mcu_alloc_wtbl_req routine can fails just if nskb is NULL,
always check return value from mt7915_mcu_alloc_wtbl_req in order to avoid
possible future mistake.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: connac: always check return value from mt76_connac_mcu_alloc_wtbl_req
Lorenzo Bianconi [Fri, 12 Feb 2021 11:51:05 +0000 (12:51 +0100)]
mt76: connac: always check return value from mt76_connac_mcu_alloc_wtbl_req

Even if this is not a real bug since mt76_connac_mcu_alloc_wtbl_req routine
can fails just if nskb is NULL , always check return value from
mt76_connac_mcu_alloc_wtbl_req in order to avoid possible future
mistake.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: mt76x0: disable GTK offloading
David Bauer [Sun, 7 Feb 2021 15:09:17 +0000 (16:09 +0100)]
mt76: mt76x0: disable GTK offloading

When operating two VAP on a MT7610 with encryption (PSK2, SAE, OWE),
only the first one to be created will transmit properly encrypteded
frames.

All subsequently created VAPs will sent out frames with the payload left
unencrypted, breaking multicast traffic (ICMP6 NDP) and potentially
disclosing information to a third party.

Disable GTK offloading and encrypt these frames in software to
circumvent this issue. THis only seems to be necessary on MT7610 chips,
as MT7612 is not affected from our testing.

Signed-off-by: David Bauer <mail@david-bauer.net>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: always use WTBL_MAX_SIZE for tlv allocation
Ryder Lee [Fri, 5 Feb 2021 05:13:01 +0000 (13:13 +0800)]
mt76: always use WTBL_MAX_SIZE for tlv allocation

Simplify WTBL defines.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: mt7921: removed unused definitions in mcu.h
Lorenzo Bianconi [Sat, 6 Feb 2021 10:35:41 +0000 (11:35 +0100)]
mt76: mt7921: removed unused definitions in mcu.h

Get rid of the following definitions in mt7921/mcu.h since they are not
actually used:
- MT7921_WTBL_UPDATE_MAX_SIZE
- MT7921_STA_UPDATE_MAX_SIZE
- MT7921_WTBL_UPDATE_BA_SIZE

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: mt7921: remove unnecessary variable
Nigel Christian [Sun, 14 Feb 2021 03:02:37 +0000 (22:02 -0500)]
mt76: mt7921: remove unnecessary variable

In mt7921_pm_set() the variable "ret" is initialized to zero
and then returned. Remove it and return zero.

Signed-off-by: Nigel Christian <nigel.l.christian@gmail.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: mt7921: enable random mac addr during scanning
Lorenzo Bianconi [Sat, 30 Jan 2021 12:28:36 +0000 (13:28 +0100)]
mt76: mt7921: enable random mac addr during scanning

Notify mac80211 mt7921 devices support random mac address during hw
frequency scanning

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: mt7615: support loading EEPROM for MT7613BE
Sander Vanheule [Tue, 2 Feb 2021 08:59:53 +0000 (09:59 +0100)]
mt76: mt7615: support loading EEPROM for MT7613BE

EEPROM blobs for MT7613BE radios start with (little endian) 0x7663,
which is also the PCI device ID for this device. The EEPROM is required
for the radio to work at useful power levels, otherwise only the lowest
power level is available.

Suggested-by: Georgi Vlaev <georgi.vlaev@konsulko.com>
Tested-by: Stijn Segers <foss@volatilesystems.org>
Signed-off-by: Sander Vanheule <sander@svanheule.net>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: mt7915: fix tx skb dma unmap
Felix Fietkau [Sat, 13 Feb 2021 17:44:10 +0000 (18:44 +0100)]
mt76: mt7915: fix tx skb dma unmap

The first pointer in the txp needs to be unmapped as well, otherwise it will
leak DMA mapping entries

Reported-by: Ben Greear <greearb@candelatech.com>
Fixes: 27d5c528a7ca ("mt76: fix double DMA unmap of the first buffer on 7615/7915")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: mt7615: fix tx skb dma unmap
Felix Fietkau [Sat, 13 Feb 2021 17:42:15 +0000 (18:42 +0100)]
mt76: mt7615: fix tx skb dma unmap

The first pointer in the txp needs to be unmapped as well, otherwise it will
leak DMA mapping entries

Fixes: 27d5c528a7ca ("mt76: fix double DMA unmap of the first buffer on 7615/7915")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: mt7615: fix key set/delete issues
Felix Fietkau [Mon, 8 Feb 2021 16:07:27 +0000 (17:07 +0100)]
mt76: mt7615: fix key set/delete issues

There were multiple issues in the current key set/remove code:
- deleting a key with the previous key index deletes the current key
- BIP key would only be uploaded correctly initially and corrupted on rekey

Rework the code to better keep track of multiple keys and check for the
key index before deleting the current key

Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: mt7915: add support for rx decapsulation offload
Felix Fietkau [Wed, 16 Dec 2020 20:13:13 +0000 (21:13 +0100)]
mt76: mt7915: add support for rx decapsulation offload

For AP and Client mode, the hardware can pass received packets as 802.3 frames
that can be passed to the network stack as-is.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: mt7915: add rx checksum offload support
Felix Fietkau [Wed, 16 Dec 2020 18:04:24 +0000 (19:04 +0100)]
mt76: mt7915: add rx checksum offload support

Set skb->ip_summed to CHECKSUM_UNNECESSARY if the hardware has validated
the IP and TCP/UDP checksum

Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: mt7915: enable hw rx-amsdu de-aggregation
Lorenzo Bianconi [Sun, 11 Oct 2020 21:37:12 +0000 (23:37 +0200)]
mt76: mt7915: enable hw rx-amsdu de-aggregation

Enable hw rx-amsdu de-aggregation support available in 7915 devices.
This is a preliminary patch to enable rx checksum offload

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
3 years agomt76: add support for 802.3 rx frames
Felix Fietkau [Wed, 16 Dec 2020 15:05:51 +0000 (16:05 +0100)]
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>
3 years agoiwlegacy: avoid -Wempty-body warning
Arnd Bergmann [Mon, 22 Mar 2021 10:43:33 +0000 (11:43 +0100)]
iwlegacy: avoid -Wempty-body warning

There are a couple of warnings in this driver when building with W=1:

drivers/net/wireless/intel/iwlegacy/common.c: In function 'il_power_set_mode':
drivers/net/wireless/intel/iwlegacy/common.c:1195:60: error: suggest braces around empty body in an 'if' statement [-Werror=empty-body]
 1195 |                                 il->chain_noise_data.state);
      |                                                            ^
drivers/net/wireless/intel/iwlegacy/common.c: In function 'il_do_scan_abort':
drivers/net/wireless/intel/iwlegacy/common.c:1343:57: error: suggest braces around empty body in an 'else' statement [-Werror=empty-body]

Change the empty debug macros to no_printk(), which avoids the
warnings and adds useful format string checks.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Stanislaw Gruszka <stf_xl@wp.pl>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20210322104343.948660-3-arnd@kernel.org