platform/kernel/linux-starfive.git
2 years agomt76: mt7915: add tx mu/su counters to mib
Ben Greear [Wed, 4 Aug 2021 13:43:32 +0000 (06:43 -0700)]
mt76: mt7915: add tx mu/su counters to mib

These counters are clear-on-read, so we need to accumulate
them in the update_stats poll logic, and read the accumulated
values instead of directly doing register reads when reporting
to debugfs and ethtool stats.

Signed-off-by: Ben Greear <greearb@candelatech.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7915: add some per-station tx stats to ethtool
Ben Greear [Wed, 4 Aug 2021 13:43:31 +0000 (06:43 -0700)]
mt76: mt7915: add some per-station tx stats to ethtool

The tx status callback is not called for every frame, so
those specific counters under-count, but at least they give
some idea of what is going on.

Signed-off-by: Ben Greear <greearb@candelatech.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7915: add tx stats gathered from tx-status callbacks
Ben Greear [Wed, 4 Aug 2021 13:43:30 +0000 (06:43 -0700)]
mt76: mt7915: add tx stats gathered from tx-status callbacks

Add tx-mode (ofdma, ht, vht, HE) histogram,
tx-ru-idx histogram, and tx-bandwidth histogram.
Also add tx attempts and tx success counters.

All of this is per-station.

Signed-off-by: Ben Greear <greearb@candelatech.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7915: add ethtool stats support
Ben Greear [Wed, 4 Aug 2021 13:43:29 +0000 (06:43 -0700)]
mt76: mt7915: add ethtool stats support

This exposes some tx-path stats to the ethtool API, so that
ethtool -S wlanX provides some more useful info.

Signed-off-by: Ben Greear <greearb@candelatech.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7921: fix retrying release semaphore without end
Sean Wang [Tue, 14 Sep 2021 15:50:22 +0000 (23:50 +0800)]
mt76: mt7921: fix retrying release semaphore without end

We should pass the error code to the caller immediately
to avoid the possible infinite retry to release the semaphore.

Fixes: 1c099ab44727 ("mt76: mt7921: add MCU 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>
2 years agomt76: mt7921: robustify hardware initialization flow
Sean Wang [Tue, 14 Sep 2021 15:50:21 +0000 (23:50 +0800)]
mt76: mt7921: robustify hardware initialization flow

Robustify hardware initialization in the current driver probing flow
to get rid of the device is possibly lost after the machine boot due
to possible firmware abnormal state by trying to recover the failure
with more chances.

Tested-by: Leon Yen <Leon.Yen@mediatek.com>
Tested-by: YN Chen <YN.Chen@mediatek.com>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7915: fix possible infinite loop release semaphore
Lorenzo Bianconi [Tue, 14 Sep 2021 16:42:51 +0000 (18:42 +0200)]
mt76: mt7915: fix possible infinite loop release semaphore

Fix possible infinite loop in mt7915_load_patch if
mt7915_mcu_patch_sem_ctrl always returns an error.

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>
2 years agomt76: mt7915: honor all possible error conditions in mt7915_mcu_init()
Lorenzo Bianconi [Sun, 12 Sep 2021 15:49:50 +0000 (17:49 +0200)]
mt76: mt7915: honor all possible error conditions in mt7915_mcu_init()

Check all possible errors returned in mt7915_mcu_init routine.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: move spin_lock_bh to spin_lock in tasklet
Xingbang Liu [Fri, 10 Sep 2021 05:39:28 +0000 (13:39 +0800)]
mt76: move spin_lock_bh to spin_lock in tasklet

as you are already in a tasklet, it is unnecessary to call spin_lock_bh.

Signed-off-by: Xingbang Liu <liu.airalert@gmail.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7921: remove mt7921_sta_stats
Lorenzo Bianconi [Sat, 4 Sep 2021 10:16:47 +0000 (12:16 +0200)]
mt76: mt7921: remove mt7921_sta_stats

mt7921_sta_stats is no longer needed

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7921: remove mcu rate reporting code
Lorenzo Bianconi [Sat, 4 Sep 2021 10:16:46 +0000 (12:16 +0200)]
mt76: mt7921: remove mcu rate reporting code

Remove unused tx rate reporting through mcu tx done event since
now tx status is fully supported

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7921: report tx rate directly from tx status
Lorenzo Bianconi [Sat, 4 Sep 2021 10:16:45 +0000 (12:16 +0200)]
mt76: mt7921: report tx rate directly from tx status

Report tx rate from tx status packets instead of receiving periodic mcu
event. This improves flexibility, accuracy and AQL performance, and
simplifies code flow for better readability.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7921: add support for tx status reporting
Lorenzo Bianconi [Sat, 4 Sep 2021 10:16:44 +0000 (12:16 +0200)]
mt76: mt7921: add support for tx status reporting

Introduce infrastructure support for tx status reporting

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7921: start reworking tx rate reporting
Lorenzo Bianconi [Sat, 4 Sep 2021 10:16:43 +0000 (12:16 +0200)]
mt76: mt7921: start reworking tx rate reporting

Similar to mt7915, introduce mt7921_txwi_free to report tx rate to
mac80211. This is a preliminary patch to add proper tx status report.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7615: fix hwmon temp sensor mem use-after-free
Ryder Lee [Thu, 2 Sep 2021 05:52:04 +0000 (13:52 +0800)]
mt76: mt7615: fix hwmon temp sensor mem use-after-free

Without this change, garbage is seen in the hwmon name and sensors output
for mt7615 is garbled.

Fixes: 109e505ad944 ("mt76: mt7615: add thermal sensor device support")
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7915: fix hwmon temp sensor mem use-after-free
Ben Greear [Thu, 2 Sep 2021 05:52:03 +0000 (13:52 +0800)]
mt76: mt7915: fix hwmon temp sensor mem use-after-free

Without this change, garbage is seen in the hwmon name and sensors output
for mt7915 is garbled. It appears that the hwmon logic does not make a
copy of the incoming string, but instead just copies a char* and expects
it to never go away.

Fixes: 33fe9c639c13 ("mt76: mt7915: add thermal sensor device support")
Signed-off-by: Ben Greear <greearb@candelatech.com>
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7915: enable configured beacon tx rate
Ryder Lee [Sat, 28 Aug 2021 20:01:02 +0000 (04:01 +0800)]
mt76: mt7915: enable configured beacon tx rate

The user is allowed to change beacon tx rate (HT/VHT/HE) from hostapd.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: disable BH around napi_schedule() calls
Felix Fietkau [Fri, 24 Sep 2021 15:54:40 +0000 (17:54 +0200)]
mt76: disable BH around napi_schedule() calls

napi_schedule() can call __raise_softirq_irqoff(), which can perform softirq
handling, so it must not be called in a pure process context with BH enabled.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: fill boottime_ns in Rx path
Ryder Lee [Tue, 24 Aug 2021 20:35:16 +0000 (04:35 +0800)]
mt76: fill boottime_ns in Rx path

Give a proper boottime_ns value for netlink RX to avoid scan
issues with Android.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: switch from 'pci_' to 'dma_' API
Christophe JAILLET [Sun, 22 Aug 2021 07:39:45 +0000 (09:39 +0200)]
mt76: switch from 'pci_' to 'dma_' API

The wrappers in include/linux/pci-dma-compat.h should go away.

The patch has been generated with the coccinelle script below.

It has been compile tested.

@@
@@
-    PCI_DMA_BIDIRECTIONAL
+    DMA_BIDIRECTIONAL

@@
@@
-    PCI_DMA_TODEVICE
+    DMA_TO_DEVICE

@@
@@
-    PCI_DMA_FROMDEVICE
+    DMA_FROM_DEVICE

@@
@@
-    PCI_DMA_NONE
+    DMA_NONE

@@
expression e1, e2, e3;
@@
-    pci_alloc_consistent(e1, e2, e3)
+    dma_alloc_coherent(&e1->dev, e2, e3, GFP_)

@@
expression e1, e2, e3;
@@
-    pci_zalloc_consistent(e1, e2, e3)
+    dma_alloc_coherent(&e1->dev, e2, e3, GFP_)

@@
expression e1, e2, e3, e4;
@@
-    pci_free_consistent(e1, e2, e3, e4)
+    dma_free_coherent(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-    pci_map_single(e1, e2, e3, e4)
+    dma_map_single(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-    pci_unmap_single(e1, e2, e3, e4)
+    dma_unmap_single(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4, e5;
@@
-    pci_map_page(e1, e2, e3, e4, e5)
+    dma_map_page(&e1->dev, e2, e3, e4, e5)

@@
expression e1, e2, e3, e4;
@@
-    pci_unmap_page(e1, e2, e3, e4)
+    dma_unmap_page(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-    pci_map_sg(e1, e2, e3, e4)
+    dma_map_sg(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-    pci_unmap_sg(e1, e2, e3, e4)
+    dma_unmap_sg(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-    pci_dma_sync_single_for_cpu(e1, e2, e3, e4)
+    dma_sync_single_for_cpu(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-    pci_dma_sync_single_for_device(e1, e2, e3, e4)
+    dma_sync_single_for_device(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-    pci_dma_sync_sg_for_cpu(e1, e2, e3, e4)
+    dma_sync_sg_for_cpu(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-    pci_dma_sync_sg_for_device(e1, e2, e3, e4)
+    dma_sync_sg_for_device(&e1->dev, e2, e3, e4)

@@
expression e1, e2;
@@
-    pci_dma_mapping_error(e1, e2)
+    dma_mapping_error(&e1->dev, e2)

@@
expression e1, e2;
@@
-    pci_set_dma_mask(e1, e2)
+    dma_set_mask(&e1->dev, e2)

@@
expression e1, e2;
@@
-    pci_set_consistent_dma_mask(e1, e2)
+    dma_set_coherent_mask(&e1->dev, e2)

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: fix boolreturn.cocci warnings
jing yangyang [Fri, 20 Aug 2021 02:41:17 +0000 (19:41 -0700)]
mt76: fix boolreturn.cocci warnings

./drivers/net/wireless/mediatek/mt76/mt7615/usb_sdio.c:172:8-9:WARNING:
return of 0/1 in function 'mt7663_usb_sdio_tx_status_data' with return
type bool

Return statements in functions returning bool should use true/false
instead of 1/0.

Generated by: scripts/coccinelle/misc/boolreturn.cocci

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: jing yangyang <jing.yangyang@zte.com.cn>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7921: update mib counters dumping phy stats
Lorenzo Bianconi [Wed, 18 Aug 2021 08:23:14 +0000 (10:23 +0200)]
mt76: mt7921: update mib counters dumping phy stats

mt7921 mac work can be idle for a long time due to runtime-pm so
update mib counters dumping phy stats

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7921: always wake device if necessary in debugfs
Lorenzo Bianconi [Wed, 18 Aug 2021 08:20:57 +0000 (10:20 +0200)]
mt76: mt7921: always wake device if necessary in debugfs

Add missing device wakeup in debugfs code if we are accessing chip
registers.

Fixes: 1d8efc741df8 ("mt76: mt7921: introduce Runtime PM support")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7915: rename debugfs tx-queues
Ryder Lee [Mon, 16 Aug 2021 18:37:35 +0000 (02:37 +0800)]
mt76: mt7915: rename debugfs tx-queues

Rename "queues" to "tx-queues" to reflect its meaning.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7915: rework debugfs queue info
Ryder Lee [Mon, 16 Aug 2021 18:37:34 +0000 (02:37 +0800)]
mt76: mt7915: rework debugfs queue info

Complete PSE/PLE queue statistics, including per-sta AC queue
information.

Co-developed-by: Sujuan Chen <sujuan.chen@mediatek.com>
Signed-off-by: Sujuan Chen <sujuan.chen@mediatek.com>
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7921: move mt7921_queue_rx_skb to mac.c
Lorenzo Bianconi [Mon, 16 Aug 2021 13:11:24 +0000 (15:11 +0200)]
mt76: mt7921: move mt7921_queue_rx_skb to mac.c

As for 7915 moving mt7921_queue_rx_skb makes it possible to make
some functions in mac.c static

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7915: fix WMM index on DBDC cards
Felix Fietkau [Wed, 8 Sep 2021 15:46:44 +0000 (17:46 +0200)]
mt76: mt7915: fix WMM index on DBDC cards

WMM index range needs to be split between both PHYs if a second PHY exists.
The condition for that was accidentally written as checking if the vif PHY
is the secondary one

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7915: improve code readability in mt7915_mcu_sta_bfer_ht
Lorenzo Bianconi [Sat, 31 Jul 2021 16:12:14 +0000 (18:12 +0200)]
mt76: mt7915: improve code readability in mt7915_mcu_sta_bfer_ht

Even if it is a not real issue, add missing brackets in
mt7915_mcu_sta_bfer_ht routine in order to improve code readability

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7915: introduce bss coloring support
Lorenzo Bianconi [Fri, 2 Jul 2021 17:44:09 +0000 (19:44 +0200)]
mt76: mt7915: introduce bss coloring support

Introduce mcu APIs to configure bss coloring and to report bss coloring
collisions. Add support to report coloring countdown in beacon sent by
the device.

Co-developed-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7915: add LED support
MeiChia Chiu [Sat, 28 Aug 2021 17:02:38 +0000 (01:02 +0800)]
mt76: mt7915: add LED support

Initialize brightness_set and blink_set callbacks to enable LED support.
The base 0x7c000000 is MCU space so driver can't touch it, and should
map the LED base to 0x18000000 host's view.

Signed-off-by: MeiChia Chiu <meichia.chiu@mediatek.com>
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Money Wang <money.wang@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7915: fix potential NPE in TXS processing
Ben Greear [Thu, 19 Aug 2021 20:49:43 +0000 (13:49 -0700)]
mt76: mt7915: fix potential NPE in TXS processing

If skb is null, then don't try to dereference it.

Signed-off-by: Ben Greear <greearb@candelatech.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7915: fix he_mcs capabilities for 160mhz
Ben Greear [Wed, 4 Aug 2021 13:43:33 +0000 (06:43 -0700)]
mt76: mt7915: fix he_mcs capabilities for 160mhz

At 160, this chip can only do 2x2 NSS.  Fix the features
accordingly, verified it shows up properly in iw phy foo info
now.

Signed-off-by: Ben Greear <greearb@candelatech.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: use IEEE80211_OFFLOAD_ENCAP_ENABLED instead of MT_DRV_AMSDU_OFFLOAD
Ryder Lee [Thu, 17 Jun 2021 20:39:00 +0000 (04:39 +0800)]
mt76: use IEEE80211_OFFLOAD_ENCAP_ENABLED instead of MT_DRV_AMSDU_OFFLOAD

Drop MT_DRV_AMSDU_OFFLOAD after introducing IEEE80211_OFFLOAD_ENCAP_ENABLED
flag in mac80211. Driver now checks vif->offload_flags to know encap offload
status of each interface.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7915: update mac timing settings
Ryder Lee [Mon, 16 Aug 2021 00:32:26 +0000 (08:32 +0800)]
mt76: mt7915: update mac timing settings

1. EIFS has been divided into OFDM/CCK fields after 11ax generation.
2. For 5G/6G SIFS setting, hardware counts extra 6us for OFDM.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7921: fix endianness warnings in mt7921_mac_decode_he_mu_radiotap
Lorenzo Bianconi [Fri, 13 Aug 2021 11:26:53 +0000 (13:26 +0200)]
mt76: mt7921: fix endianness warnings in mt7921_mac_decode_he_mu_radiotap

Fix the following sparse endianness warnings

drivers/net/wireless/mediatek/mt76/mt7921/mac.c:212:28: warning: cast from restricted __le32
drivers/net/wireless/mediatek/mt76/mt7921/mac.c:212:28: warning: cast to restricted __le32
drivers/net/wireless/mediatek/mt76/mt7921/mac.c:212:28: warning: restricted __le32 degrades to integer
drivers/net/wireless/mediatek/mt76/mt7921/mac.c:212:28: warning: cast from restricted __le32
drivers/net/wireless/mediatek/mt76/mt7921/mac.c:212:28: warning: restricted __le32 degrades to integer
drivers/net/wireless/mediatek/mt76/mt7921/mac.c:217:25: warning: cast from restricted __le32
drivers/net/wireless/mediatek/mt76/mt7921/mac.c:217:25: warning: restricted __le32 degrades to integer
drivers/net/wireless/mediatek/mt76/mt7921/mac.c:217:25: warning: cast from restricted __le32
drivers/net/wireless/mediatek/mt76/mt7921/mac.c:217:25: warning: restricted __le32 degrades to integer
drivers/net/wireless/mediatek/mt76/mt7921/mac.c:222:25: warning: cast from restricted __le32
drivers/net/wireless/mediatek/mt76/mt7921/mac.c:222:25: warning: cast to restricted __le32
drivers/net/wireless/mediatek/mt76/mt7921/mac.c:222:25: warning: restricted __le32 degrades to integer
drivers/net/wireless/mediatek/mt76/mt7921/mac.c:222:25: warning: cast from restricted __le32
drivers/net/wireless/mediatek/mt76/mt7921/mac.c:222:25: warning: restricted __le32 degrades to integer
drivers/net/wireless/mediatek/mt76/mt7921/mac.c:224:25: warning: cast from restricted __le32
drivers/net/wireless/mediatek/mt76/mt7921/mac.c:224:25: warning: cast to restricted __le32
drivers/net/wireless/mediatek/mt76/mt7921/mac.c:224:25: warning: restricted __le32 degrades to integer
drivers/net/wireless/mediatek/mt76/mt7921/mac.c:224:25: warning: cast from restricted __le32
drivers/net/wireless/mediatek/mt76/mt7921/mac.c:224:25: warning: restricted __le32 degrades to integer
drivers/net/wireless/mediatek/mt76/mt7921/mac.c:259:13: warning: cast from restricted __le32
drivers/net/wireless/mediatek/mt76/mt7921/mac.c:259:13: warning: restricted __le32 degrades to integer

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7921: fix kernel warning from cfg80211_calculate_bitrate
Sean Wang [Fri, 13 Aug 2021 18:09:18 +0000 (02:09 +0800)]
mt76: mt7921: fix kernel warning from cfg80211_calculate_bitrate

Fix the kernel warning from cfg80211_calculate_bitrate
due to the legacy rate is not parsed well in the current driver.

Also, zeros struct rate_info before we fill it out to avoid the old value
is kept such as rate->legacy.

[  790.921560] WARNING: CPU: 7 PID: 970 at net/wireless/util.c:1298 cfg80211_calculate_bitrate+0x354/0x35c [cfg80211]
[  790.987738] Hardware name: MediaTek Asurada rev1 board (DT)
[  790.993298] pstate: a0400009 (NzCv daif +PAN -UAO)
[  790.998104] pc : cfg80211_calculate_bitrate+0x354/0x35c [cfg80211]
[  791.004295] lr : cfg80211_calculate_bitrate+0x180/0x35c [cfg80211]
[  791.010462] sp : ffffffc0129c3880
[  791.013765] x29: ffffffc0129c3880 x28: ffffffd38305bea8
[  791.019065] x27: ffffffc0129c3970 x26: 0000000000000013
[  791.024364] x25: 00000000000003ca x24: 000000000000002f
[  791.029664] x23: 00000000000000d0 x22: ffffff8d108bc000
[  791.034964] x21: ffffff8d108bc0d0 x20: ffffffc0129c39a8
[  791.040264] x19: ffffffc0129c39a8 x18: 00000000ffff0a10
[  791.045563] x17: 0000000000000050 x16: 00000000000000ec
[  791.050910] x15: ffffffd3f9ebed9c x14: 0000000000000006
[  791.056211] x13: 00000000000b2eea x12: 0000000000000000
[  791.061511] x11: 00000000ffffffff x10: 0000000000000000
[  791.066811] x9 : 0000000000000000 x8 : 0000000000000000
[  791.072110] x7 : 0000000000000000 x6 : ffffffd3fafa5a7b
[  791.077409] x5 : 0000000000000000 x4 : 0000000000000000
[  791.082708] x3 : 0000000000000000 x2 : 0000000000000000
[  791.088008] x1 : ffffff8d3f79c918 x0 : 0000000000000000
[  791.093308] Call trace:
[  791.095770]  cfg80211_calculate_bitrate+0x354/0x35c [cfg80211]
[  791.101615]  nl80211_put_sta_rate+0x6c/0x2c0 [cfg80211]
[  791.106853]  nl80211_send_station+0x980/0xaa4 [cfg80211]
[  791.112178]  nl80211_get_station+0xb4/0x134 [cfg80211]
[  791.117308]  genl_rcv_msg+0x3a0/0x440
[  791.120960]  netlink_rcv_skb+0xcc/0x118
[  791.124785]  genl_rcv+0x34/0x48
[  791.127916]  netlink_unicast+0x144/0x1dc

Fixes: 1c099ab44727 ("mt76: mt7921: add MCU support")
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7921: fix firmware usage of RA info using legacy rates
Sean Wang [Wed, 11 Aug 2021 05:58:24 +0000 (13:58 +0800)]
mt76: mt7921: fix firmware usage of RA info using legacy rates

According to the firmware usage, OFDM rates should fill out bit 6 - 13
while CCK rates should fill out bit 0 - 3 in legacy field of RA info to
make the rate adaption runs propertly. Otherwise, a unicast frame might be
picking up the unsupported rate to send out.

Fixes: 1c099ab44727 ("mt76: mt7921: add MCU support")
Reported-by: Joshua Emele <jemele@chromium.org>
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>
2 years agomt76: mt7915: add HE-LTF into fixed rate command
Ryder Lee [Sat, 7 Aug 2021 03:14:23 +0000 (11:14 +0800)]
mt76: mt7915: add HE-LTF into fixed rate command

Add HE-LTF control.

Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7921: report HE MU radiotap
Sean Wang [Thu, 12 Aug 2021 22:48:24 +0000 (06:48 +0800)]
mt76: mt7921: report HE MU radiotap

Report HE MU/BF radiotap.

That fixed HE MU packets dropped by mac80211 because they are missing the
ieee80211_radiotap_he_mu header.

Fixes: 163f4d22c118d ("mt76: mt7921: add MAC support")
Co-developed-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Co-developed-by: Eric-SY Chang <Eric-SY.Chang@mediatek.com>
Signed-off-by: Eric-SY Chang <Eric-SY.Chang@mediatek.com>
Tested-by: Eric-SY Chang <Eric-SY.Chang@mediatek.com>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7615: move mt7615_mcu_set_p2p_oppps in mt76_connac module
Lorenzo Bianconi [Sat, 7 Aug 2021 07:40:30 +0000 (09:40 +0200)]
mt76: mt7615: move mt7615_mcu_set_p2p_oppps in mt76_connac module

Move mt7615_mcu_set_p2p_oppps routine in mt76_connac_lib module in order
to be reused in mt7921 driver

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: overwrite default reg_ops if necessary
Lorenzo Bianconi [Sun, 8 Aug 2021 19:11:49 +0000 (21:11 +0200)]
mt76: overwrite default reg_ops if necessary

Introduce mt76_register_debugfs_fops routine in order to
define per-driver regs file operations and make sure the
device is up before reading or writing its registers

Fixes: 1d8efc741df8 ("mt76: mt7921: introduce Runtime PM support")
Fixes: de5ff3c9d1a2 ("mt76: mt7615: introduce pm_power_save delayed work")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7921: introduce mt7921_mcu_set_beacon_filter utility routine
Lorenzo Bianconi [Mon, 9 Aug 2021 10:37:22 +0000 (12:37 +0200)]
mt76: mt7921: introduce mt7921_mcu_set_beacon_filter utility routine

Introduce mt7921_mcu_set_beacon_filter utility routine in order to
remove duplicated code for hw beacon filtering.
Move mt7921_pm_interface_iter in debugfs since it is just used there.
Make the following routine static:
- mt7921_pm_interface_iter
- mt7921_mcu_uni_bss_bcnft
- mt7921_mcu_set_bss_pm

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7921: get rid of mt7921_mac_set_beacon_filter
Lorenzo Bianconi [Mon, 9 Aug 2021 08:38:03 +0000 (10:38 +0200)]
mt76: mt7921: get rid of mt7921_mac_set_beacon_filter

Remove mt7921_mac_set_beacon_filter routine since it is no longer used.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7921: get rid of monitor_vif
Lorenzo Bianconi [Mon, 9 Aug 2021 07:38:07 +0000 (09:38 +0200)]
mt76: mt7921: get rid of monitor_vif

Remove monitor_vif pointer from mt7921 since it is just a leftover of
initial porting.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: connac: add support for limiting to maximum regulatory Tx power
YN Chen [Wed, 4 Aug 2021 22:23:00 +0000 (06:23 +0800)]
mt76: connac: add support for limiting to maximum regulatory Tx power

Consider .max_reg_power in struct ieee80211_channel to limit the
maximum power the wireless device allowed to transmit on the
corresponding channel according to the regulatory domain.

Co-developed-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: YN Chen <YN.Chen@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: connac: fix GTK rekey offload failure on WPA mixed mode
Leon Yen [Tue, 27 Jul 2021 22:59:16 +0000 (06:59 +0800)]
mt76: connac: fix GTK rekey offload failure on WPA mixed mode

Update the proper firmware programming sequence to fix GTK rekey
offload failure on WPA mixed mode.

In the mt76_connac_mcu_key_iter,
gtk_tlv->proto should be only set up on pairwise key
and gtk_tlk->group_cipher should be only set up on the group key.

Otherwise, those parameters required by firmware would be set
incorrectly to cause GTK rekey offload failure on WPA mixed mode
and then disconnection follows.

Fixes: b47e21e75c80 ("mt76: mt7615: add gtk rekey offload support")
Co-developed-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Leon Yen <Leon.Yen@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7921: fix dma hang in rmmod
Deren Wu [Tue, 27 Jul 2021 09:47:09 +0000 (17:47 +0800)]
mt76: mt7921: fix dma hang in rmmod

The dma would be broken after rmmod flow. There are two different
cases causing this issue.
1. dma access without privilege.
2. hw access sequence borken by another context.

This patch handle both cases to avoid hw crash.

Fixes: 2b9ea5a8cf1bd ("mt76: mt7921: add mt7921_dma_cleanup in mt7921_unregister_device")
Signed-off-by: Deren Wu <deren.wu@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: add support for setting mcast rate
Ryder Lee [Wed, 21 Jul 2021 02:03:52 +0000 (10:03 +0800)]
mt76: add support for setting mcast rate

Mesh and ad-hoc interfaces allow users to set mcast rate through
NL80211_ATTR_MCAST_RATE, so rework mt76_default_basic_rate() to
adapt that.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7915: fix bit fields for HT rate idx
Shayne Chen [Tue, 20 Jul 2021 13:00:14 +0000 (21:00 +0800)]
mt76: mt7915: fix bit fields for HT rate idx

The bit fields of tx rate idx should be 6 bits, otherwise it might be
incorrect in HT mode.
For VHT/HE rates, only 4 bits are actually used by rate idx, the other
2 bits are used for other functions.

Fixes: c31d94af1843 ("mt76: mt7915: fix tx rate related fields in tx descriptor")
Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7915: switch proper tx arbiter mode in testmode
Shayne Chen [Tue, 20 Jul 2021 13:00:13 +0000 (21:00 +0800)]
mt76: mt7915: switch proper tx arbiter mode in testmode

Switch proper tx arbiter mode during testmode tx to prevent from
entering the flow of normal tx in FW.
Also, testmode SU and MU tx need to use different arbiter mode.

Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7915: fix potential overflow of eeprom page index
Shayne Chen [Tue, 20 Jul 2021 02:48:32 +0000 (10:48 +0800)]
mt76: mt7915: fix potential overflow of eeprom page index

If total eeprom size is divisible by per-page size, the i in for loop
will exceed max page index, which happens in our newer chipset.

Fixes: 26f18380e6ca ("mt76: mt7915: add support for flash mode")
Signed-off-by: Bo Jiao <bo.jiao@mediatek.com>
Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7921: send EAPOL frames at lowest rate
Ryder Lee [Sat, 17 Jul 2021 05:05:49 +0000 (13:05 +0800)]
mt76: mt7921: send EAPOL frames at lowest rate

The firmware rate control may choose the high rate for EAPOL frames,
so checking IEEE80211_TX_CTL_USE_MINRATE to use the lowest TX rate.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7915: send EAPOL frames at lowest rate
Ryder Lee [Sat, 17 Jul 2021 05:05:48 +0000 (13:05 +0800)]
mt76: mt7915: send EAPOL frames at lowest rate

The firmware rate control may choose the high rate for EAPOL frames,
so checking IEEE80211_TX_CTL_USE_MINRATE to use the lowest TX rate.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7915: add control knobs for thermal throttling
Ryder Lee [Sat, 17 Jul 2021 00:18:25 +0000 (08:18 +0800)]
mt76: mt7915: add control knobs for thermal throttling

With this patch, users can set the trigger/restore temperature for
thermal service according to their use cases.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7921: Add mt7922 support
Deren Wu [Thu, 15 Jul 2021 17:34:19 +0000 (01:34 +0800)]
mt76: mt7921: Add mt7922 support

Add new chip mt7922 in mt7921 module with following items
1. new chip ID / fw bin name
2. is_mt7922()
check chip type for different fw files
3. mt7921_get_data_mode()
check security type of fw (backward compatible)

Co-developed-by: Jimmy Hu <Jimmy.Hu@mediatek.com>
Signed-off-by: Jimmy Hu <Jimmy.Hu@mediatek.com>
Signed-off-by: Deren Wu <deren.wu@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7615: fix skb use-after-free on mac reset
Felix Fietkau [Wed, 21 Jul 2021 05:23:46 +0000 (07:23 +0200)]
mt76: mt7615: fix skb use-after-free on mac reset

When clearing all existing pending tx slots, mt76_tx_complete_skb needs to
be used to free the skbs, to ensure that they are cleared from the status
list as well.

Cc: stable@vger.kernel.org
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7921: Fix out of order process by invalid event pkt
Deren Wu [Wed, 14 Jul 2021 15:50:52 +0000 (23:50 +0800)]
mt76: mt7921: Fix out of order process by invalid event pkt

The acceptable event report should inlcude original CMD-ID. Otherwise,
drop unexpected result from fw.

Fixes: 1c099ab44727c ("mt76: mt7921: add MCU support")
Signed-off-by: Jimmy Hu <Jimmy.Hu@mediatek.com>
Signed-off-by: Deren Wu <deren.wu@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7915: fix mgmt frame using unexpected bitrate
Sean Wang [Tue, 13 Jul 2021 20:16:01 +0000 (04:16 +0800)]
mt76: mt7915: fix mgmt frame using unexpected bitrate

Fix the current driver mgmt frame is not respecting the basic rates field
provided by the AP and then unconditionally is using the lowest (1 or 6
Mbps) rate.

For example, if the AP only supported basic rate {24, 36, 48, 54} Mbps,
mt7921 cannot send mgmt frame with the rate not in the group. So,
instead, we pick up the lowest basic rate the AP can support to send.

Fixes: e57b7901469f ("mt76: add mac80211 driver for MT7915 PCIe-based chipsets")
Suggested-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7921: fix mgmt frame using unexpected bitrate
Sean Wang [Tue, 13 Jul 2021 20:16:00 +0000 (04:16 +0800)]
mt76: mt7921: fix mgmt frame using unexpected bitrate

Fix the current driver mgmt frame is not respecting the basic rates field
provided by the AP and then unconditionally is using the lowest (1 or 6
Mbps) rate.

For example, if the AP only supported basic rate {24, 36, 48, 54} Mbps,
mt7921 cannot send mgmt frame with the rate not in the group. So,
instead, we pick up the lowest basic rate the AP can support to send.

Fixes: 163f4d22c118 ("mt76: mt7921: add MAC support")
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: add mt76_default_basic_rate more devices can rely on
Sean Wang [Tue, 13 Jul 2021 20:15:59 +0000 (04:15 +0800)]
mt76: add mt76_default_basic_rate more devices can rely on

add mt76_default_basic_rate to mt76 core more devices can rely on
to send frames which require the rate in the basic rates.

Suggested-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7921: introduce testmode support
Lorenzo Bianconi [Mon, 21 Jun 2021 09:23:26 +0000 (11:23 +0200)]
mt76: mt7921: introduce testmode support

We add the testmode support to access the testmode feature provided
by the MT7921 firmware.

Tested-by: Sean Wang <sean.wang@mediatek.com>
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>
2 years agomt76: mt7915: remove mt7915_sta_stats
Ryder Lee [Wed, 14 Jul 2021 09:18:51 +0000 (17:18 +0800)]
mt76: mt7915: remove mt7915_sta_stats

mt7915_sta_stats is no longer needed after tx rate reworking.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7915: report tx rate directly from tx status
Ryder Lee [Wed, 14 Jul 2021 09:18:50 +0000 (17:18 +0800)]
mt76: mt7915: report tx rate directly from tx status

Report tx rate from tx status packets instead of receving periodic mcu
event. This improves flexibility, accuracy and AQL performance, and
simplifies code flow for better readability.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7915: cleanup -Wunused-but-set-variable
Ryder Lee [Wed, 14 Jul 2021 09:18:49 +0000 (17:18 +0800)]
mt76: mt7915: cleanup -Wunused-but-set-variable

Cleanup -Wunused-but-set-variable everywhere in driver.

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7915: take RCU read lock when calling ieee80211_bss_get_elem()
Ryder Lee [Wed, 14 Jul 2021 09:18:48 +0000 (17:18 +0800)]
mt76: mt7915: take RCU read lock when calling ieee80211_bss_get_elem()

As ieee80211_bss_get_elem() derefences an RCU to return ie, both
the call to this function and any operation on this variable need
protection by the RCU read lock.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7915: fix an off-by-one bound check
Ryder Lee [Wed, 14 Jul 2021 07:56:10 +0000 (15:56 +0800)]
mt76: mt7915: fix an off-by-one bound check

The bounds check on datalen is off-by-one, so fix it.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7921: add .set_sar_specs support
YN Chen [Mon, 28 Jun 2021 23:05:53 +0000 (07:05 +0800)]
mt76: mt7921: add .set_sar_specs support

add .set_sar_specs to allow configuring SAR power limitations on the
frequency ranges from the userland.

Co-developed-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: YN Chen <YN.Chen@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7915: adapt new firmware to update BA winsize for Rx session
Bo Jiao [Tue, 6 Jul 2021 10:04:26 +0000 (18:04 +0800)]
mt76: mt7915: adapt new firmware to update BA winsize for Rx session

The newer firmware requires host driver to set BA winsize
on both Tx/Rx sessions, so modify it for the long run.

Signed-off-by: Bo Jiao <Bo.Jiao@mediatek.com>
Signed-off-by: Sujuan Chen <sujuan.chen@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7915: report HE MU radiotap
Ryder Lee [Tue, 22 Jun 2021 17:35:39 +0000 (01:35 +0800)]
mt76: mt7915: report HE MU radiotap

Report HE MU/BF radiotap.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt76x02: fix endianness warnings in mt76x02_mac.c
Lorenzo Bianconi [Tue, 22 Jun 2021 07:48:30 +0000 (09:48 +0200)]
mt76: mt76x02: fix endianness warnings in mt76x02_mac.c

Fix the following sparse warning in mt76x02_mac_write_txwi and
mt76x02_mac_tx_rate_val routines:
drivers/net/wireless/mediatek/mt76/mt76x02_mac.c:237:19:
warning: restricted __le16 degrades to intege
warning: cast from restricted __le16
drivers/net/wireless/mediatek/mt76/mt76x02_mac.c:383:28:
warning: incorrect type in assignment (different base types)
expected restricted __le16 [usertype] rate
got unsigned long

Fixes: db9f11d3433f7 ("mt76: store wcid tx rate info in one u32 reduce locking")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7921: fix survey-dump reporting
Lorenzo Bianconi [Wed, 23 Jun 2021 13:19:19 +0000 (15:19 +0200)]
mt76: mt7921: fix survey-dump reporting

Fix MIB tx-rx MIB counters for survey-dump reporting.

Fixes: 163f4d22c118d ("mt76: mt7921: add MAC support")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: fix build error implicit enumeration conversion
Sean Wang [Sun, 20 Jun 2021 07:48:07 +0000 (15:48 +0800)]
mt76: fix build error implicit enumeration conversion

drivers/net/wireless/mediatek/mt76/mt7915/mcu.c:114:10: error: implicit
conversion from enumeration type 'enum mt76_cipher_type' to different
enumeration type 'enum mcu_cipher_type' [-Werror,-Wenum-conversion]
                return MT_CIPHER_NONE;
                ~~~~~~ ^~~~~~~~~~~~~~

drivers/net/wireless/mediatek/mt76/mt7921/mcu.c:114:10: error: implicit
conversion from enumeration type 'enum mt76_cipher_type' to different
enumeration type 'enum mcu_cipher_type' [-Werror,-Wenum-conversion]
                return MT_CIPHER_NONE;
                ~~~~~~ ^~~~~~~~~~~~~~

Fixes: c368362c36d3 ("mt76: fix iv and CCMP header insertion")
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7921: enable aspm by default
Sean Wang [Sun, 20 Jun 2021 07:48:06 +0000 (15:48 +0800)]
mt76: mt7921: enable aspm by default

mt7921 is mainly used in NB, CE and IoT application where battery life is
much concerned so the patch enabled PCIe ASPM by default to shut off the
clocks related PCIe as much as possible when MT7921 is either in suspend
state or in runtime pm to lower power consumption.

We still leave disable aspm as an option with module_param for users to
disable ASPM if necessary.

Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: connac: fix mt76_connac_gtk_rekey_tlv usage
Leon Yen [Thu, 8 Jul 2021 04:29:06 +0000 (12:29 +0800)]
mt76: connac: fix mt76_connac_gtk_rekey_tlv usage

The mistaken structure is introduced since we added the GTK rekey offload
to mt7663. The patch fixes mt76_connac_gtk_rekey_tlv structure according
to the MT7663 and MT7921 firmware we have submitted into
linux-firmware.git.

Fixes: b47e21e75c80 ("mt76: mt7615: add gtk rekey offload support")
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Leon Yen <Leon.Yen@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7915: fix calling mt76_wcid_alloc with incorrect parameter
Bo Jiao [Tue, 6 Jul 2021 10:56:54 +0000 (18:56 +0800)]
mt76: mt7915: fix calling mt76_wcid_alloc with incorrect parameter

It will cause maximum connectable STA to be one less
when calling mt76_wcid_alloc with parameter MT7915_WTBL_STA - 1.

Signed-off-by: Bo Jiao <Bo.Jiao@mediatek.com>
Signed-off-by: Sujuan Chen <sujuan.chen@mediatek.com>
Reviewed-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7915: fix info leak in mt7915_mcu_set_pre_cal()
Dan Carpenter [Fri, 25 Jun 2021 14:58:54 +0000 (17:58 +0300)]
mt76: mt7915: fix info leak in mt7915_mcu_set_pre_cal()

Zero out all the unused members of "req" so that we don't disclose
stack information.

Fixes: 495184ac91bb ("mt76: mt7915: add support for applying pre-calibration data")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7615: fix endianness warning in mt7615_mac_write_txwi
Lorenzo Bianconi [Mon, 21 Jun 2021 21:53:22 +0000 (23:53 +0200)]
mt76: mt7615: fix endianness warning in mt7615_mac_write_txwi

Fix the following sparse warning in mt7615_mac_write_txwi routine:
drivers/net/wireless/mediatek/mt76/mt7615/mac.c:758:17:
warning: incorrect type in assignment
expected restricted __le32 [usertype]
got unsigned long

Fixes: 04b8e65922f63 ("mt76: add mac80211 driver for MT7615 PCIe-based chipsets")
Fixes: d4bf77bd74930 ("mt76: mt7615: introduce mt7663u support to mt7615_write_txwi")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7921: fix endianness warning in mt7921_update_txs
Lorenzo Bianconi [Mon, 21 Jun 2021 09:18:58 +0000 (11:18 +0200)]
mt76: mt7921: fix endianness warning in mt7921_update_txs

Fix the following sparse warning in mt7921_update_txs routine:
drivers/net/wireless/mediatek/mt76/mt7921/mac.c:752:31:
warning: cast to restricted __le32
drivers/net/wireless/mediatek/mt76/mt7921/mac.c:752:31:
warning: restricted __le32 degrades to integer

Fixes: e5bca8c5d2cd3 ("mt76: mt7921: improve code readability for mt7921_update_txs")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7915: fix endianness warning in mt7915_mac_add_txs_skb
Lorenzo Bianconi [Mon, 21 Jun 2021 08:21:31 +0000 (10:21 +0200)]
mt76: mt7915: fix endianness warning in mt7915_mac_add_txs_skb

Fix the following sparse warning in mt7915_mac_add_txs_skb routine:

drivers/net/wireless/mediatek/mt76/mt7915/mac.c:1235:29:
warning: cast to restricted __le32
drivers/net/wireless/mediatek/mt76/mt7915/mac.c:1235:23:
warning: restricted __le32 degrades to integer

Fixes: 3de4cb1756565 ("mt76: mt7915: add support for tx status reporting")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7921: avoid unnecessary spin_lock/spin_unlock in mt7921_mcu_tx_done_event
Lorenzo Bianconi [Sat, 19 Jun 2021 18:19:58 +0000 (20:19 +0200)]
mt76: mt7921: avoid unnecessary spin_lock/spin_unlock in mt7921_mcu_tx_done_event

Do not grab the spinlock in mt7921_mcu_tx_done_event routine if not
necessary.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7921: fix endianness in mt7921_mcu_tx_done_event
Lorenzo Bianconi [Sat, 19 Jun 2021 18:18:19 +0000 (20:18 +0200)]
mt76: mt7921: fix endianness in mt7921_mcu_tx_done_event

Fix endianness in mt7921_mcu_tx_done_event event reported by the
firmware.

Fixes: 3cce2b98e0241 ("mt76: mt7921: introduce mac tx done handling")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agortw89: Remove redundant check of ret after call to rtw89_mac_enable_bb_rf
Colin Ian King [Fri, 15 Oct 2021 15:21:13 +0000 (16:21 +0100)]
rtw89: Remove redundant check of ret after call to rtw89_mac_enable_bb_rf

The function rtw89_mac_enable_bb_rf is a void return type, so there is
no return error code to ret, so the following check for an error in ret
is redundant dead code and can be removed.

Addresses-Coverity: ("Logically dead code")
Fixes: e3ec7017f6a2 ("rtw89: add Realtek 802.11ax driver")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Acked-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20211015152113.33179-1-colin.king@canonical.com
2 years agortw89: Fix two spelling mistakes in debug messages
Colin Ian King [Fri, 15 Oct 2021 10:50:04 +0000 (11:50 +0100)]
rtw89: Fix two spelling mistakes in debug messages

There are two spelling mistakes in rtw89_debug messages. Fix them.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Acked-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20211015105004.11817-1-colin.king@canonical.com
2 years agoMAINTAINERS: add rtw89 wireless driver
Ping-Ke Shih [Wed, 13 Oct 2021 09:28:27 +0000 (17:28 +0800)]
MAINTAINERS: add rtw89 wireless driver

Add maintainer and email to MAINTAINERS file.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20211013092827.43642-1-pkshih@realtek.com
2 years agomwifiex: Try waking the firmware until we get an interrupt
Jonas Dreßler [Mon, 11 Oct 2021 13:32:24 +0000 (15:32 +0200)]
mwifiex: Try waking the firmware until we get an interrupt

It seems that the PCIe+USB firmware (latest version 15.68.19.p21) of the
88W8897 card sometimes ignores or misses when we try to wake it up by
writing to the firmware status register. This leads to the firmware
wakeup timeout expiring and the driver resetting the card because we
assume the firmware has hung up or crashed.

Turns out that the firmware actually didn't hang up, but simply "missed"
our wakeup request and didn't send us an interrupt with an AWAKE event.

Trying again to read the firmware status register after a short timeout
usually makes the firmware wake up as expected, so add a small retry
loop to mwifiex_pm_wakeup_card() that looks at the interrupt status to
check whether the card woke up.

The number of tries and timeout lengths for this were determined
experimentally: The firmware usually takes about 500 us to wake up
after we attempt to read the status register. In some cases where the
firmware is very busy (for example while doing a bluetooth scan) it
might even miss our requests for multiple milliseconds, which is why
after 15 tries the waiting time gets increased to 10 ms. The maximum
number of tries it took to wake the firmware when testing this was
around 20, so a maximum number of 50 tries should give us plenty of
safety margin.

Here's a reproducer for those firmware wakeup failures I've found:

1) Make sure wifi powersaving is enabled (iw dev wlp1s0 set power_save on)
2) Connect to any wifi network (makes firmware go into wifi powersaving
mode, not deep sleep)
3) Make sure bluetooth is turned off (to ensure the firmware actually
enters powersave mode and doesn't keep the radio active doing bluetooth
stuff)
4) To confirm that wifi powersaving is entered ping a device on the LAN,
pings should be a few ms higher than without powersaving
5) Run "while true; do iwconfig; sleep 0.0001; done", this wakes and
suspends the firmware extremely often
6) Wait until things explode, for me it consistently takes <5 minutes

BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=109681
Cc: stable@vger.kernel.org
Signed-off-by: Jonas Dreßler <verdre@v0yd.nl>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20211011133224.15561-3-verdre@v0yd.nl
2 years agomwifiex: Read a PCI register after writing the TX ring write pointer
Jonas Dreßler [Mon, 11 Oct 2021 13:32:23 +0000 (15:32 +0200)]
mwifiex: Read a PCI register after writing the TX ring write pointer

On the 88W8897 PCIe+USB card the firmware randomly crashes after setting
the TX ring write pointer. The issue is present in the latest firmware
version 15.68.19.p21 of the PCIe+USB card.

Those firmware crashes can be worked around by reading any PCI register
of the card after setting that register, so read the PCI_VENDOR_ID
register here. The reason this works is probably because we keep the bus
from entering an ASPM state for a bit longer, because that's what causes
the cards firmware to crash.

This fixes a bug where during RX/TX traffic and with ASPM L1 substates
enabled (the specific substates where the issue happens appear to be
platform dependent), the firmware crashes and eventually a command
timeout appears in the logs.

BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=109681
Cc: stable@vger.kernel.org
Signed-off-by: Jonas Dreßler <verdre@v0yd.nl>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20211011133224.15561-2-verdre@v0yd.nl
2 years agowireless: Remove redundant 'flush_workqueue()' calls
Christophe JAILLET [Sun, 10 Oct 2021 07:09:11 +0000 (09:09 +0200)]
wireless: Remove redundant 'flush_workqueue()' calls

'destroy_workqueue()' already drains the queue before destroying it, so
there is no need to flush it explicitly.

Remove the redundant 'flush_workqueue()' calls.

This was generated with coccinelle:

@@
expression E;
@@
-  flush_workqueue(E);
destroy_workqueue(E);

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/0855d51423578ad019c0264dad3fe47a2e8af9c7.1633849511.git.christophe.jaillet@wanadoo.fr
2 years agomt7601u: Remove redundant initialization of variable ret
Colin Ian King [Thu, 7 Oct 2021 23:41:53 +0000 (00:41 +0100)]
mt7601u: Remove redundant initialization of variable ret

The variable ret is being initialized with a value that is never read,
it is assigned later on with a different value. The initialization is
redundant and can be removed.

Addresses-Coverity: ("Unused value")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Acked-by: Jakub Kicinski <kubakici@wp.pl>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20211007234153.31222-1-colin.king@canonical.com
2 years agortlwifi: rtl8192ee: Remove redundant initialization of variable version
Colin Ian King [Thu, 7 Oct 2021 16:37:22 +0000 (17:37 +0100)]
rtlwifi: rtl8192ee: Remove redundant initialization of variable version

The variable version is being initialized with a value that is
never read, it is being updated afterwards in both branches of
an if statement. The assignment is redundant and can be removed.

Addresses-Coverity: ("Unused value")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Acked-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20211007163722.20165-1-colin.king@canonical.com
2 years agortw89: add Realtek 802.11ax driver
Ping-Ke Shih [Mon, 11 Oct 2021 11:47:27 +0000 (14:47 +0300)]
rtw89: add Realtek 802.11ax driver

This driver named rtw89, which is the next generation of rtw88, supports
Realtek 8852AE 802.11ax 2x2 chip whose new features are OFDMA, DBCC,
Spatial reuse, TWT and BSS coloring; now some of them aren't implemented
though.

The chip architecture is entirely different from the chips supported by
rtw88 like RTL8822CE 802.11ac chip. First of all, register address ranges
are totally redefined, so it's impossible to reuse register definition. To
communicate with firmware, new H2C/C2H format is proposed. In order to have
better utilization, TX DMA flow is changed to two stages DMA. To provide
rich RX status information, additional RX PPDU packets are added.

Since there are so many differences mentioned above, we decide to propose
a new driver. It has many authors, they are listed in alphabetic order:

Chin-Yen Lee <timlee@realtek.com>
Ping-Ke Shih <pkshih@realtek.com>
Po Hao Huang <phhuang@realtek.com>
Tzu-En Huang <tehuang@realtek.com>
Vincent Fann <vincent_fann@realtek.com>
Yan-Hsuan Chuang <tony0620emma@gmail.com>
Zong-Zhe Yang <kevin_yang@realtek.com>

Tested-by: Aaron Ma <aaron.ma@canonical.com>
Tested-by: Brian Norris <briannorris@chromium.org>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20211008035627.19463-1-pkshih@realtek.com
2 years agob43: fix a lower bounds test
Dan Carpenter [Wed, 6 Oct 2021 07:36:22 +0000 (10:36 +0300)]
b43: fix a lower bounds test

The problem is that "channel" is an unsigned int, when it's less 5 the
value of "channel - 5" is not a negative number as one would expect but
is very high positive value instead.

This means that "start" becomes a very high positive value.  The result
of that is that we never enter the "for (i = start; i <= end; i++) {"
loop.  Instead of storing the result from b43legacy_radio_aci_detect()
it just uses zero.

Fixes: ef1a628d83fc ("b43: Implement dynamic PHY API")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Michael Büsch <m@bues.ch>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20211006073621.GE8404@kili
2 years agob43legacy: fix a lower bounds test
Dan Carpenter [Wed, 6 Oct 2021 07:35:42 +0000 (10:35 +0300)]
b43legacy: fix a lower bounds test

The problem is that "channel" is an unsigned int, when it's less 5 the
value of "channel - 5" is not a negative number as one would expect but
is very high positive value instead.

This means that "start" becomes a very high positive value.  The result
of that is that we never enter the "for (i = start; i <= end; i++) {"
loop.  Instead of storing the result from b43legacy_radio_aci_detect()
it just uses zero.

Fixes: 75388acd0cd8 ("[B43LEGACY]: add mac80211-based driver for legacy BCM43xx devices")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Michael Büsch <m@bues.ch>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20211006073542.GD8404@kili
2 years agoocteontx2-pf: Simplify the receive buffer size calculation
Subbaraya Sundeep [Sun, 10 Oct 2021 10:09:35 +0000 (15:39 +0530)]
octeontx2-pf: Simplify the receive buffer size calculation

This patch separates the logic of configuring hardware
maximum transmit frame size and receive frame size.
This simplifies the logic to calculate receive buffer
size and using cqe descriptor of different size.
Also additional size of skb_shared_info structure is
allocated for each receive buffer pointer given to
hardware which is not necessary. Hence change the
size calculation to remove the size of
skb_shared_info. Add a check for array out of
bounds while adding fragments to the network stack.

Signed-off-by: Subbaraya Sundeep <sbhatta@marvell.com>
Signed-off-by: Hariprasad Kelam <hkelam@marvell.com>
Signed-off-by: Sunil Goutham <sgoutham@marvell.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2 years agoethernet: Remove redundant 'flush_workqueue()' calls
Christophe JAILLET [Sun, 10 Oct 2021 07:01:32 +0000 (09:01 +0200)]
ethernet: Remove redundant 'flush_workqueue()' calls

'destroy_workqueue()' already drains the queue before destroying it, so
there is no need to flush it explicitly.

Remove the redundant 'flush_workqueue()' calls.

This was generated with coccinelle:

@@
expression E;
@@
-  flush_workqueue(E);
destroy_workqueue(E);

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Leon Romanovsky <leonro@nvidia.com> #mlx*
Signed-off-by: David S. Miller <davem@davemloft.net>
2 years agovirtio_net: skip RCU read lock by checking xdp_enabled of vi
Li RongQing [Sat, 9 Oct 2021 09:32:43 +0000 (17:32 +0800)]
virtio_net: skip RCU read lock by checking xdp_enabled of vi

networking benchmark shows that __rcu_read_lock and
__rcu_read_unlock takes some cpu cycles, and we can avoid
calling them partially in virtio rx path by check xdp_enabled
of vi, and xdp is disabled most of time

Signed-off-by: Li RongQing <lirongqing@baidu.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2 years agonet: make dev_get_port_parent_id slightly more readable
Antoine Tenart [Fri, 8 Oct 2021 14:21:03 +0000 (16:21 +0200)]
net: make dev_get_port_parent_id slightly more readable

Cosmetic commit making dev_get_port_parent_id slightly more readable.
There is no need to split the condition to return after calling
devlink_compat_switch_id_get and after that 'recurse' is always true.

Signed-off-by: Antoine Tenart <atenart@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
2 years agonet: phy: at803x: better describe debug regs
Ansuel Smith [Sat, 9 Oct 2021 22:46:18 +0000 (00:46 +0200)]
net: phy: at803x: better describe debug regs

Give a name to known debug regs from Documentation instead of using
unknown hex values.

Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
2 years agonet: phy: at803x: enable prefer master for 83xx internal phy
Ansuel Smith [Sat, 9 Oct 2021 22:46:17 +0000 (00:46 +0200)]
net: phy: at803x: enable prefer master for 83xx internal phy

From original QCA source code the port was set to prefer master as port
type in 1000BASE-T mode. Apply the same settings also here.

Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
2 years agonet: phy: at803x: add DAC amplitude fix for 8327 phy
Ansuel Smith [Sat, 9 Oct 2021 22:46:16 +0000 (00:46 +0200)]
net: phy: at803x: add DAC amplitude fix for 8327 phy

QCA8327 internal phy require DAC amplitude adjustement set to +6% with
100m speed. Also add additional define to report a change of the same
reg in QCA8337. (different scope it does set 1000m voltage)
Add link_change_notify function to set the proper amplitude adjustement
on PHY_RUNNING state and disable on any other state.

Fixes: b4df02b562f4 ("net: phy: at803x: add support for qca 8327 A variant internal phy")
Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2 years agonet: phy: at803x: fix resume for QCA8327 phy
Ansuel Smith [Sat, 9 Oct 2021 22:46:15 +0000 (00:46 +0200)]
net: phy: at803x: fix resume for QCA8327 phy

From Documentation phy resume triggers phy reset and restart
auto-negotiation. Add a dedicated function to wait reset to finish as
it was notice a regression where port sometime are not reliable after a
suspend/resume session. The reset wait logic is copied from phy_poll_reset.
Add dedicated suspend function to use genphy_suspend only with QCA8337
phy and set only additional debug settings for QCA8327. With more test
it was reported that QCA8327 doesn't proprely support this mode and
using this cause the unreliability of the switch ports, especially the
malfunction of the port0.

Fixes: 15b9df4ece17 ("net: phy: at803x: add resume/suspend function to qca83xx phy")
Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>