platform/kernel/linux-starfive.git
19 months agowifi: mt76: mt7915: mmio: fix naming convention
Lorenzo Bianconi [Thu, 1 Dec 2022 08:51:55 +0000 (09:51 +0100)]
wifi: mt76: mt7915: mmio: fix naming convention

Rename mt7915_wed_release_rx_buf in mt7915_mmio_wed_release_rx_buf,
mt7915_wed_init_rx_buf in mt7915_mmio_wed_init_rx_buf and
mt7915_wed_release_rx_buf in mt7915_mmio_wed_release_rx_buf

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 months agowifi: mt76: mt7996: add support to configure spatial reuse parameter set
Ryder Lee [Thu, 1 Dec 2022 08:03:32 +0000 (16:03 +0800)]
wifi: mt76: mt7996: add support to configure spatial reuse parameter set

The SPR parameter set comprises OBSS PD threshold for SRG and
non SRG and Bitmap of BSS color and partial BSSID. This adds
support to configure fields of SPR element to firmware.

User can disable firmware SR algorithms by turning sr_scene_detect off.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 months agowifi: mt76: mt7996: enable ack signal support
Ryder Lee [Thu, 1 Dec 2022 03:44:43 +0000 (11:44 +0800)]
wifi: mt76: mt7996: enable ack signal support

This reports signal strength of ACK packets from the peer as measured
at each interface.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 months agowifi: mt76: mt7996: enable use_cts_prot support
Ryder Lee [Thu, 1 Dec 2022 03:44:42 +0000 (11:44 +0800)]
wifi: mt76: mt7996: enable use_cts_prot support

This adds selectable RTC/CTS enablement for each interface.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 months agowifi: mt76: mt7915: rely on band_idx of mt76_phy
Ryder Lee [Thu, 1 Dec 2022 03:44:41 +0000 (11:44 +0800)]
wifi: mt76: mt7915: rely on band_idx of mt76_phy

The commit dc44c45c8cd0 added band_idx into mt76_phy, so switching to
rely on that.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 months agowifi: mt76: mt7915: enable per bandwidth power limit support
Ryder Lee [Wed, 23 Nov 2022 19:59:11 +0000 (03:59 +0800)]
wifi: mt76: mt7915: enable per bandwidth power limit support

This power should override the per bandwidth max power that the
device emits.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 months agowifi: mt76: mt7915: introduce mt7915_get_power_bound()
Ryder Lee [Wed, 23 Nov 2022 19:59:10 +0000 (03:59 +0800)]
wifi: mt76: mt7915: introduce mt7915_get_power_bound()

Add a helper for common boundary check. This is a preliminary patch
to add per bandwidth power control.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 months agomt76: mt7915: Fix PCI device refcount leak in mt7915_pci_init_hif2()
Xiongfeng Wang [Fri, 25 Nov 2022 02:58:31 +0000 (10:58 +0800)]
mt76: mt7915: Fix PCI device refcount leak in mt7915_pci_init_hif2()

As comment of pci_get_device() says, it returns a pci_device with its
refcount increased. We need to call pci_dev_put() to decrease the
refcount. Save the return value of pci_get_device() and call
pci_dev_put() to decrease the refcount.

Fixes: 9093cfff72e3 ("mt76: mt7915: add support for using a secondary PCIe link for gen1")
Fixes: 2e30db0dde61 ("mt76: mt7915: add device id for mt7916")
Signed-off-by: Xiongfeng Wang <wangxiongfeng2@huawei.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 months agowifi: mt76: do not send firmware FW_FEATURE_NON_DL region
Deren Wu [Thu, 24 Nov 2022 14:20:38 +0000 (22:20 +0800)]
wifi: mt76: do not send firmware FW_FEATURE_NON_DL region

skip invalid section to avoid potential risks

Fixes: 23bdc5d8cadf ("wifi: mt76: mt7921: introduce Country Location Control support")
Signed-off-by: Deren Wu <deren.wu@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 months agowifi: mt76: mt7921: Add missing __packed annotation of struct mt7921_clc
Deren Wu [Mon, 28 Nov 2022 07:04:21 +0000 (15:04 +0800)]
wifi: mt76: mt7921: Add missing __packed annotation of struct mt7921_clc

Add __packed annotation to avoid potential CLC parsing error

Fixes: 23bdc5d8cadf ("wifi: mt76: mt7921: introduce Country Location Control support")
Signed-off-by: Deren Wu <deren.wu@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 months agowifi: mt76: fix coverity overrun-call in mt76_get_txpower()
Deren Wu [Sun, 27 Nov 2022 02:35:37 +0000 (10:35 +0800)]
wifi: mt76: fix coverity overrun-call in mt76_get_txpower()

Make sure the nss is valid for nss_delta array. Return zero
if the index is invalid.

Coverity message:
Event overrun-call: Overrunning callee's array of size 4 by passing
argument "n_chains" (which evaluates to 15) in call to
"mt76_tx_power_nss_delta".
int delta = mt76_tx_power_nss_delta(n_chains);

Fixes: 07cda406308b ("mt76: fix rounding issues on converting per-chain and combined txpower")
Signed-off-by: Deren Wu <deren.wu@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 months agowifi: mt76: mt7996: add driver for MediaTek Wi-Fi 7 (802.11be) devices
Shayne Chen [Tue, 22 Nov 2022 08:45:46 +0000 (16:45 +0800)]
wifi: mt76: mt7996: add driver for MediaTek Wi-Fi 7 (802.11be) devices

The driver first supports Filogic 680 PCI device, which is a Wi-Fi 7
chipset supporting concurrent tri-band operation at 6 GHz, 5 GHz, and
2.4 GHz with 4x4 antennas on each band.

Currently, mt7996 only supports tri-band HE or older mode.
EHT mode and more variants of Filogic 680 support will be introduced
in further patches.

Reviewed-by: Ryder Lee <ryder.lee@mediatek.com>
Co-developed-by: Peter Chiu <chui-hao.chiu@mediatek.com>
Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com>
Co-developed-by: Bo Jiao <Bo.Jiao@mediatek.com>
Signed-off-by: Bo Jiao <Bo.Jiao@mediatek.com>
Co-developed-by: Howard Hsu <howard-yh.hsu@mediatek.com>
Signed-off-by: Howard Hsu <howard-yh.hsu@mediatek.com>
Co-developed-by: MeiChia Chiu <meichia.chiu@mediatek.com>
Signed-off-by: MeiChia Chiu <meichia.chiu@mediatek.com>
Co-developed-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
Co-developed-by: Money Wang <Money.Wang@mediatek.com>
Signed-off-by: Money Wang <Money.Wang@mediatek.com>
Co-developed-by: Evelyn Tsai <evelyn.tsai@mediatek.com>
Signed-off-by: Evelyn Tsai <evelyn.tsai@mediatek.com>
Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 months agowifi: mt76: mt76x0: remove dead code in mt76x0_phy_get_target_power
Lorenzo Bianconi [Tue, 22 Nov 2022 13:52:08 +0000 (14:52 +0100)]
wifi: mt76: mt76x0: remove dead code in mt76x0_phy_get_target_power

tx_rate can't be greater than 3 in mt76x0_phy_get_target_power routine
for cck rates. Get rid of dead code.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 months agowifi: mt76: mt7915: fix band_idx usage
Ryder Lee [Tue, 22 Nov 2022 07:53:12 +0000 (15:53 +0800)]
wifi: mt76: mt7915: fix band_idx usage

The commit 006b9d4ad5bf introduced phy->band_idx to accommodate the
band definition change for mt7986 so that the band_idx of main_phy
can be 0 or 1. Accordingly, the source of band_idx 1 has switched to
"phy != &dev->phy" or "dev->phy.band_idx = 1".

We still use ext_phy to represent band 1 somewhere in driver, so fix it.
Also, band_idx sounds more reasonable than dbdc_idx, so change it.

Fixes: 006b9d4ad5bf ("mt76: mt7915: introduce band_idx in mt7915_phy")
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 months agowifi: mt76: mt7915: enable .sta_set_txpwr support
Ryder Lee [Tue, 22 Nov 2022 07:53:11 +0000 (15:53 +0800)]
wifi: mt76: mt7915: enable .sta_set_txpwr support

This adds support for adjusting the Txpower level while pushing
traffic to an associated station. The allowed range is from 0 to
the maximum power of channel.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 months agowifi: mt76: mt7915: add basedband Txpower info into debugfs
Ryder Lee [Tue, 22 Nov 2022 07:53:10 +0000 (15:53 +0800)]
wifi: mt76: mt7915: add basedband Txpower info into debugfs

This helps user to debug Txpower propagation path easily.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 months agowifi: mt76: mt7915: add support to configure spatial reuse parameter set
Ryder Lee [Thu, 17 Nov 2022 17:09:47 +0000 (01:09 +0800)]
wifi: mt76: mt7915: add support to configure spatial reuse parameter set

The SPR parameter set comprises OBSS PD threshold for SRG and
non SRG and Bitmap of BSS color and partial BSSID. This adds
support to configure fields of SPR element to firmware.

User can disable firmware SR algorithms by turning sr_scene_detect off.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 months agowifi: mt76: mt7915: add missing MODULE_PARM_DESC
Ryder Lee [Thu, 17 Nov 2022 17:09:46 +0000 (01:09 +0800)]
wifi: mt76: mt7915: add missing MODULE_PARM_DESC

Add documentation for module_param so that they're visible with
modinfo command.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 months agowifi: mt76: mt7915: enable WED RX stats
Sujuan Chen [Sat, 12 Nov 2022 15:40:41 +0000 (16:40 +0100)]
wifi: mt76: mt7915: enable WED RX stats

Introduce the capability to report WED RX stats to mac80211.

Tested-by: Daniel Golle <daniel@makrotopia.org>
Co-developed-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Sujuan Chen <sujuan.chen@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 months agowifi: mt76: mt7915: enable WED RX support
Lorenzo Bianconi [Sat, 12 Nov 2022 15:40:40 +0000 (16:40 +0100)]
wifi: mt76: mt7915: enable WED RX support

Enable RX Wireless Ethernet Dispatch available on MT7986 Soc in oreder
to offlad traffic received by WLAN NIC and forwarded to LAN/WAN one.

Tested-by: Daniel Golle <daniel@makrotopia.org>
Co-developed-by: Sujuan Chen <sujuan.chen@mediatek.com>
Signed-off-by: Sujuan Chen <sujuan.chen@mediatek.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 months agowifi: mt76: connac: introduce mt76_connac_mcu_sta_wed_update utility routine
Sujuan Chen [Sat, 12 Nov 2022 15:40:39 +0000 (16:40 +0100)]
wifi: mt76: connac: introduce mt76_connac_mcu_sta_wed_update utility routine

This is a preliminary patch to introduce WED RX support for mt7915.

Tested-by: Daniel Golle <daniel@makrotopia.org>
Co-developed-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Sujuan Chen <sujuan.chen@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 months agowifi: mt76: add info parameter to rx_skb signature
Sujuan Chen [Sat, 12 Nov 2022 15:40:38 +0000 (16:40 +0100)]
wifi: mt76: add info parameter to rx_skb signature

This is a preliminary patch to introduce WED RX support for mt7915.

Tested-by: Daniel Golle <daniel@makrotopia.org>
Co-developed-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Sujuan Chen <sujuan.chen@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 months agowifi: mt76: add WED RX support to dma queue alloc
Lorenzo Bianconi [Sat, 12 Nov 2022 15:40:37 +0000 (16:40 +0100)]
wifi: mt76: add WED RX support to dma queue alloc

Introduce the capability to allocate WED RX buffers in
mt76_dma_wed_setup routine.

Tested-by: Daniel Golle <daniel@makrotopia.org>
Co-developed-by: Sujuan Chen <sujuan.chen@mediatek.com>
Signed-off-by: Sujuan Chen <sujuan.chen@mediatek.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 months agowifi: mt76: add WED RX support to mt76_dma_rx_fill
Lorenzo Bianconi [Sat, 12 Nov 2022 15:40:36 +0000 (16:40 +0100)]
wifi: mt76: add WED RX support to mt76_dma_rx_fill

Introduce the capability to refill WED RX buffers in mt76_dma_rx_fill
utility routine.

Tested-by: Daniel Golle <daniel@makrotopia.org>
Co-developed-by: Sujuan Chen <sujuan.chen@mediatek.com>
Signed-off-by: Sujuan Chen <sujuan.chen@mediatek.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 months agowifi: mt76: add WED RX support to mt76_dma_{add,get}_buf
Lorenzo Bianconi [Sat, 12 Nov 2022 15:40:35 +0000 (16:40 +0100)]
wifi: mt76: add WED RX support to mt76_dma_{add,get}_buf

Introduce the capability to configure RX WED in mt76_dma_{add,get}_buf
utility routines.

Tested-by: Daniel Golle <daniel@makrotopia.org>
Co-developed-by: Sujuan Chen <sujuan.chen@mediatek.com>
Signed-off-by: Sujuan Chen <sujuan.chen@mediatek.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 months agowifi: mt76: introduce rxwi and rx token utility routines
Sujuan Chen [Sat, 12 Nov 2022 15:40:34 +0000 (16:40 +0100)]
wifi: mt76: introduce rxwi and rx token utility routines

This is a preliminary patch to introduce WED RX support for mt7915.

Tested-by: Daniel Golle <daniel@makrotopia.org>
Co-developed-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Sujuan Chen <sujuan.chen@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 months agowifi: mt76: mt7921: fix wrong power after multiple SAR set
YN Chen [Wed, 16 Nov 2022 14:43:02 +0000 (22:43 +0800)]
wifi: mt76: mt7921: fix wrong power after multiple SAR set

We should update CLC config before SAR set to synchronize all
related settings.

Fixes: 23bdc5d8cadf ("wifi: mt76: mt7921: introduce Country Location Control support")
Signed-off-by: YN Chen <YN.Chen@mediatek.com>
Signed-off-by: Deren Wu <deren.wu@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 months agowifi: mt76: connac: introduce helper for mt7996 chipset
Shayne Chen [Thu, 10 Nov 2022 09:35:24 +0000 (17:35 +0800)]
wifi: mt76: connac: introduce helper for mt7996 chipset

Introduce is_mt7996() helper for new chipset.
This is a preliminary patch to support mt7996 driver.

Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 months agowifi: mt76: connac: add more starec command tags
Shayne Chen [Thu, 10 Nov 2022 09:35:23 +0000 (17:35 +0800)]
wifi: mt76: connac: add more starec command tags

Add starec tags which will be used in new chipset.
This is a preliminary patch to add mt7996 chipset support.

Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 months agowifi: mt76: connac: add more bss info command tags
Shayne Chen [Thu, 10 Nov 2022 09:35:22 +0000 (17:35 +0800)]
wifi: mt76: connac: add more bss info command tags

Add bss info tags which will be used in new chipset.
This is a preliminary patch to add mt7996 chipset support.

Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 months agowifi: mt76: connac: introduce unified event table
Shayne Chen [Thu, 10 Nov 2022 09:35:21 +0000 (17:35 +0800)]
wifi: mt76: connac: introduce unified event table

Add event IDs and related bit fields for unified event support.
This is a preliminary patch to add mt7996 chipset support.

Signed-off-by: Bo Jiao <Bo.Jiao@mediatek.com>
Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com>
Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 months agowifi: mt76: connac: add more unified command IDs
Shayne Chen [Thu, 10 Nov 2022 09:35:20 +0000 (17:35 +0800)]
wifi: mt76: connac: add more unified command IDs

Add more unified command IDs which will be used in new chipset.
This is the preliminary patch for mt7996 support.

Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 months agowifi: mt76: connac: rework fields for larger bandwidth support in sta_rec_bf
Shayne Chen [Thu, 10 Nov 2022 09:35:19 +0000 (17:35 +0800)]
wifi: mt76: connac: rework fields for larger bandwidth support in sta_rec_bf

Rename nrow_bw160 and ncol_bw160 since channel width 320 MHz will share
the same field.
This is a preliminary patch to add mt7996 chipset support.

Signed-off-by: MeiChia Chiu <meichia.chiu@mediatek.com>
Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 months agowifi: mt76: connac: update struct sta_rec_phy
Shayne Chen [Thu, 10 Nov 2022 09:35:18 +0000 (17:35 +0800)]
wifi: mt76: connac: update struct sta_rec_phy

For connac3 generation, max_ampdu_len should be filled in
struct sta_rec_phy.
This is a preliminary patch to add mt7996 chipset support.

Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com>
Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 months agowifi: mt76: connac: rework macros for unified command
Shayne Chen [Thu, 10 Nov 2022 09:35:17 +0000 (17:35 +0800)]
wifi: mt76: connac: rework macros for unified command

Rework some macros for connac3 unified command.
This is a preliminary patch to add mt7996 chipset support.

Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com>
Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 months agowifi: mt76: mt7921: introduce chanctx support
Sean Wang [Tue, 15 Nov 2022 00:11:24 +0000 (08:11 +0800)]
wifi: mt76: mt7921: introduce chanctx support

The firmware can have the capability to manage the channel context
scheduling on multiple roles running on the device including Station,
AP and P2P GC/GO mode (will be extended based on the future patchset)
to help users sharing the network with others on a single device.

The firmware is able to support the channel chanctx up to 2 interface
simultaneously running on the different channels.

Another thing to be noted is that before the driver is going sent out the
management frames, the driver has to get the privilege from the firmware
to occupy the current channel context until the frame handshake is
completed and then get the privilege back to the firmware.

Co-developed-by: Deren Wu <deren.wu@mediatek.com>
Signed-off-by: Deren Wu <deren.wu@mediatek.com>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 months agowifi: mt76: mt7921: introduce remain_on_channel support
Sean Wang [Tue, 15 Nov 2022 00:11:23 +0000 (08:11 +0800)]
wifi: mt76: mt7921: introduce remain_on_channel support

Introduce remain_on_channel support. Additionally, we add
mt7921_check_offload_capability to disable .remain_on_channel and
.cancel_remain_on_channel and related configuration because those
operations would rely on the fundamental MCU commands that will be only
supported with newer firmware.

Co-developed-by: Deren Wu <deren.wu@mediatek.com>
Signed-off-by: Deren Wu <deren.wu@mediatek.com>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 months agowifi: mt76: connac: accept hw scan request at a time
Sean Wang [Thu, 10 Nov 2022 21:23:47 +0000 (05:23 +0800)]
wifi: mt76: connac: accept hw scan request at a time

The current hw scan cannot accept multiple hw scan requests at a time, we
return the proper error code when the hw scan is still undergoing.

Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 months agowifi: mt76: mt7921: drop ieee80211_[start, stop]_queues in driver
Sean Wang [Thu, 10 Nov 2022 21:23:46 +0000 (05:23 +0800)]
wifi: mt76: mt7921: drop ieee80211_[start, stop]_queues in driver

The firmware would be in charge of braking and continuing the traffic while
the channel contexts are switching between different BSS and HW SCAN in the
background.

Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 months agowifi: mt76: mt7921: add unified ROC cmd/event support
Quan Zhou [Thu, 10 Nov 2022 21:23:45 +0000 (05:23 +0800)]
wifi: mt76: mt7921: add unified ROC cmd/event support

Add unified ROC cmd/event which is only supported by the newer fw.

Co-developed-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Co-developed-by: Deren Wu <deren.wu@mediatek.com>
Signed-off-by: Deren Wu <deren.wu@mediatek.com>
Co-developed-by: Kaikai Hu <kaikai.hu@mediatek.com>
Signed-off-by: Kaikai Hu <kaikai.hu@mediatek.com>
Signed-off-by: Quan Zhou <quan.zhou@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 months agowifi: mt76: mt7921: add chanctx parameter to mt76_connac_mcu_uni_add_bss signature
Sean Wang [Thu, 10 Nov 2022 21:23:44 +0000 (05:23 +0800)]
wifi: mt76: mt7921: add chanctx parameter to mt76_connac_mcu_uni_add_bss signature

Add a chanctx parameter to mt76_connac_mcu_uni_add_bss signature to allow
the firmware binds the BSS into the specific channel context.

Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 months agowifi: mt76: connac: add mt76_connac_mcu_uni_set_chctx
Sean Wang [Thu, 10 Nov 2022 21:23:43 +0000 (05:23 +0800)]
wifi: mt76: connac: add mt76_connac_mcu_uni_set_chctx

add mt76_connac_mcu_uni_set_chctx to set up the channel context per BSS
in the firmware

Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 months agowifi: mt76: do not run mt76u_status_worker if the device is not running
Lorenzo Bianconi [Thu, 13 Oct 2022 19:07:37 +0000 (21:07 +0200)]
wifi: mt76: do not run mt76u_status_worker if the device is not running

Fix the following NULL pointer dereference avoiding to run
mt76u_status_worker thread if the device is not running yet.

KASAN: null-ptr-deref in range
[0x0000000000000000-0x0000000000000007]
CPU: 0 PID: 98 Comm: kworker/u2:2 Not tainted 5.14.0+ #78 Hardware
name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS
rel-1.12.1-0-ga5cab58e9a3f-prebuilt.qemu.org 04/01/2014
Workqueue: mt76 mt76u_tx_status_data
RIP: 0010:mt76x02_mac_fill_tx_status.isra.0+0x82c/0x9e0
Code: c5 48 b8 00 00 00 00 00 fc ff df 80 3c 02 00 0f 85 94 01 00 00
48 b8 00 00 00 00 00 fc ff df 4d 8b 34 24 4c 89 f2 48 c1 ea 03 <0f>
b6
04 02 84 c0 74 08 3c 03 0f 8e 89 01 00 00 41 8b 16 41 0f b7
RSP: 0018:ffffc900005af988 EFLAGS: 00010246
RAX: dffffc0000000000 RBX: ffffc900005afae8 RCX: 0000000000000000
RDX: 0000000000000000 RSI: ffffffff832fc661 RDI: ffffc900005afc2a
RBP: ffffc900005afae0 R08: 0000000000000001 R09: fffff520000b5f3c
R10: 0000000000000003 R11: fffff520000b5f3b R12: ffff88810b6132d8
R13: 000000000000ffff R14: 0000000000000000 R15: ffffc900005afc28
FS:  0000000000000000(0000) GS:ffff88811aa00000(0000)
knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007fa0eda6a000 CR3: 0000000118f17000 CR4: 0000000000750ef0
PKRU: 55555554
Call Trace:
 mt76x02_send_tx_status+0x1d2/0xeb0
 mt76x02_tx_status_data+0x8e/0xd0
 mt76u_tx_status_data+0xe1/0x240
 process_one_work+0x92b/0x1460
 worker_thread+0x95/0xe00
 kthread+0x3a1/0x480
 ret_from_fork+0x1f/0x30
Modules linked in:
--[ end trace 8df5d20fc5040f65 ]--
RIP: 0010:mt76x02_mac_fill_tx_status.isra.0+0x82c/0x9e0
Code: c5 48 b8 00 00 00 00 00 fc ff df 80 3c 02 00 0f 85 94 01 00 00
48 b8 00 00 00 00 00 fc ff df 4d 8b 34 24 4c 89 f2 48 c1 ea 03 <0f>
b6
04 02 84 c0 74 08 3c 03 0f 8e 89 01 00 00 41 8b 16 41 0f b7
RSP: 0018:ffffc900005af988 EFLAGS: 00010246
RAX: dffffc0000000000 RBX: ffffc900005afae8 RCX: 0000000000000000
RDX: 0000000000000000 RSI: ffffffff832fc661 RDI: ffffc900005afc2a
RBP: ffffc900005afae0 R08: 0000000000000001 R09: fffff520000b5f3c
R10: 0000000000000003 R11: fffff520000b5f3b R12: ffff88810b6132d8
R13: 000000000000ffff R14: 0000000000000000 R15: ffffc900005afc28
FS:  0000000000000000(0000) GS:ffff88811aa00000(0000)
knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007fa0eda6a000 CR3: 0000000118f17000 CR4: 0000000000750ef0
PKRU: 55555554

Moreover move stat_work schedule out of the for loop.

Reported-by: Dokyung Song <dokyungs@yonsei.ac.kr>
Co-developed-by: Deren Wu <deren.wu@mediatek.com>
Signed-off-by: Deren Wu <deren.wu@mediatek.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 months agowifi: mt76: connac: update nss calculation in txs
Evelyn Tsai [Fri, 11 Nov 2022 07:36:15 +0000 (15:36 +0800)]
wifi: mt76: connac: update nss calculation in txs

The hardware reports the number of transmitting antennas not the actual
number of spatial streams

Co-developed-by: Peter Chiu <chui-hao.chiu@mediatek.com>
Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com>
Signed-off-by: Evelyn Tsai <evelyn.tsai@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 months agowifi: mt76: mt7915: don't claim 160MHz support with mt7915 DBDC
Nicolas Cavallari [Thu, 10 Nov 2022 15:39:53 +0000 (16:39 +0100)]
wifi: mt76: mt7915: don't claim 160MHz support with mt7915 DBDC

The hardware simply does not support this in DBDC mode.  Remove it from
the HE capabilities.

Signed-off-by: Nicolas Cavallari <nicolas.cavallari@green-communications.fr>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 months agowifi: mt76: mt7915: Fix VHT beamforming capabilities with DBDC
Nicolas Cavallari [Thu, 10 Nov 2022 15:39:52 +0000 (16:39 +0100)]
wifi: mt76: mt7915: Fix VHT beamforming capabilities with DBDC

Do not hardcode beamformee 4 space-time streams support, because
DBDC can only support up to 2.

Fixes: 00b2e16e0063 ("mt76: mt7915: add TxBF capabilities")
Signed-off-by: Nicolas Cavallari <nicolas.cavallari@green-communications.fr>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 months agowifi: mt76: mt7915: Fix chainmask calculation on mt7915 DBDC
Nicolas Cavallari [Thu, 10 Nov 2022 15:39:51 +0000 (16:39 +0100)]
wifi: mt76: mt7915: Fix chainmask calculation on mt7915 DBDC

mt7915 does not have a per-band number of chains unlike the other chips,
it only has a total number of chains.  Yet the current code would
consider the total number as a per-band number.

For example, it would report that a 2x2 + 2x2 DBDC card have 4 chains on
each band and set chainmask to 0b1111 for the first interface and
0b11110000 for the second.

Fixes: 99ad32a4ca3a ("mt76: mt7915: add support for MT7986")
Co-developed-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Nicolas Cavallari <nicolas.cavallari@green-communications.fr>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 months agowifi: mt76: mt7915: enable coredump support
Ryder Lee [Wed, 9 Nov 2022 20:36:34 +0000 (04:36 +0800)]
wifi: mt76: mt7915: enable coredump support

Host triggered and catastrophic event triggered firmware core dumping
for basic firmware issues triage, including state reporting, task/irq
info, function calltrace and MCU memory dump.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 months agowifi: mt76: mt7915: add full system reset into debugfs
Ryder Lee [Wed, 9 Nov 2022 20:36:33 +0000 (04:36 +0800)]
wifi: mt76: mt7915: add full system reset into debugfs

Trigger firmware crash and enable full system recovery through debugfs.
This also renames knob "fw_ser" to a clear-cut name "sys_recovery".

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 months agowifi: mt76: mt7915: enable full system reset support
Bo Jiao [Wed, 9 Nov 2022 20:36:32 +0000 (04:36 +0800)]
wifi: mt76: mt7915: enable full system reset support

Add mt7915_reset() and refactor mt7915_mac_reset_work() to support
full system recovery.

Co-developed-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Bo Jiao <bo.jiao@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 months agowifi: mt76: mt7915: rework mt7915_dma_reset()
Bo Jiao [Wed, 9 Nov 2022 20:36:31 +0000 (04:36 +0800)]
wifi: mt76: mt7915: rework mt7915_dma_reset()

Reuse mt7915_dma_disable() to reduce duplicated code.
This is a preliminary patch to enable full system reset.

Co-developed-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Bo Jiao <Bo.Jiao@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 months agowifi: mt76: move aggr_stats array in mt76_phy
Lorenzo Bianconi [Wed, 2 Nov 2022 22:29:15 +0000 (23:29 +0100)]
wifi: mt76: move aggr_stats array in mt76_phy

Move aggregation stats array per-phy instead of share it between multiple
interfaces. This is a preliminary patch to add mt7996 driver support.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 months agowifi: mt76: mt7615: rely on mt7615_phy in mt7615_mac_reset_counters
Lorenzo Bianconi [Wed, 2 Nov 2022 22:29:14 +0000 (23:29 +0100)]
wifi: mt76: mt7615: rely on mt7615_phy in mt7615_mac_reset_counters

This is a preliminary patch to move aggr_stats array in mt76_phy
structure.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 months agowifi: mt76: mt7921: fix reporting of TX AGGR histogram
Lorenzo Bianconi [Wed, 2 Nov 2022 12:46:50 +0000 (13:46 +0100)]
wifi: mt76: mt7921: fix reporting of TX AGGR histogram

Similar to mt7915, fix stats clash between bins [4-7] in 802.11 tx
aggregation histogram.

Fixes: 163f4d22c118d ("mt76: mt7921: add MAC support")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 months agowifi: mt76: mt7915: fix reporting of TX AGGR histogram
Lorenzo Bianconi [Wed, 2 Nov 2022 12:35:01 +0000 (13:35 +0100)]
wifi: mt76: mt7915: fix reporting of TX AGGR histogram

Fix stats clash between bins [4-7] in 802.11 tx aggregation histogram.

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>
19 months agowifi: mt76: mt7615: enable use_cts_prot support
Ryder Lee [Tue, 25 Oct 2022 00:31:01 +0000 (08:31 +0800)]
wifi: mt76: mt7615: enable use_cts_prot support

This adds selectable RTC/CTS enablement for each interface.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 months agowifi: mt76: mt7915: enable use_cts_prot support
Ryder Lee [Tue, 25 Oct 2022 00:31:00 +0000 (08:31 +0800)]
wifi: mt76: mt7915: enable use_cts_prot support

This adds selectable RTC/CTS enablement for each interface.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 months agowifi: mt76: fix bandwidth 80MHz link fail in 6GHz band
Ming Yen Hsieh [Mon, 24 Oct 2022 12:45:08 +0000 (20:45 +0800)]
wifi: mt76: fix bandwidth 80MHz link fail in 6GHz band

Due to information missing, the firmware may be fail on bandwidth
related settings in mt7921/mt7922. Add new cmd STA_REC_HE_V2 to apply
additional capabilities in 6GHz band.

Tested-by: Ben Greear <greearb@candelatech.com>
Co-developed-by: Deren Wu <deren.wu@mediatek.com>
Signed-off-by: Deren Wu <deren.wu@mediatek.com>
Signed-off-by: Ming Yen Hsieh <mingyen.hsieh@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 months agowifi: mt76: mt7915: add ack signal support
Ryder Lee [Fri, 14 Oct 2022 02:57:48 +0000 (10:57 +0800)]
wifi: mt76: mt7915: add ack signal support

This reports signal strength of ACK packets from the peer as measured
at each interface.

Tested-by: Shurong Wen <shurong.wen@mediatek.com>
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 months agowifi: mt76: mt7915: improve accuracy of time_busy calculation
Ryder Lee [Fri, 14 Oct 2022 02:57:47 +0000 (10:57 +0800)]
wifi: mt76: mt7915: improve accuracy of time_busy calculation

The MIB INFO command is fetching MIB_BUSY_TIME, MIB_TX_TIME, MIB_RX_TIME and
MIB_OBSS_AIRTIME from the radio and filling out cc_busy, cc_tx, cc_bss_rx
and cc_rx respectively.

busy should be >= tx + rx >= tx + bss_rx but we don’t always quite see this.
Sometimes tx + rx is a bit higher than busy due to inaccurate accounting,
so this patch recalculates numbers to make them more reasonable.

Reported-By: Kevin Schneider <kevin.schneider@adtran.com>
Tested-by: Kevin Schneider <kevin.schneider@adtran.com>
Tested-by: Chad Monroe <chad.monroe@smartrg.com>
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 months agoRevert "mt76: use IEEE80211_OFFLOAD_ENCAP_ENABLED instead of MT_DRV_AMSDU_OFFLOAD"
Ben Greear [Sat, 1 Oct 2022 14:19:20 +0000 (07:19 -0700)]
Revert "mt76: use IEEE80211_OFFLOAD_ENCAP_ENABLED instead of MT_DRV_AMSDU_OFFLOAD"

This reverts commit f17f4864504d754bcbf31e4c89412cdf9946c409 and adds the
MT_DRV_AMSDU_OFFLOAD flag for MT7921 USB/SDIO

The reverted commit significantly decreases performance when running
a test where two MT7915 radios have 16 station vdevs each, configured
for AC mode, and transmitting UDP traffic to AP.

Co-developed-by: Felix Fietkau <nbd@nbd.name>
Reported-by: Carson Vandegriffe <carson.vandegriffe@candelatech.com>
Signed-off-by: Ben Greear <greearb@candelatech.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 months agowifi: mt76: mt7915: enable wed for mt7986-wmac chipset
Lorenzo Bianconi [Wed, 28 Sep 2022 09:19:43 +0000 (11:19 +0200)]
wifi: mt76: mt7915: enable wed for mt7986-wmac chipset

Enable WED tx support for mt7986-wmac chipset available on mt7986 board.

Tested-by: Daniel Golle <daniel@makrotopia.org>
Co-developed-by: Bo Jiao <Bo.Jiao@mediatek.com>
Signed-off-by: Bo Jiao <Bo.Jiao@mediatek.com>
Co-developed-by: Sujuan Chen <sujuan.chen@mediatek.com>
Signed-off-by: Sujuan Chen <sujuan.chen@mediatek.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 months agowifi: mt76: mt7915: enable wed for mt7986 chipset
Lorenzo Bianconi [Wed, 28 Sep 2022 09:19:42 +0000 (11:19 +0200)]
wifi: mt76: mt7915: enable wed for mt7986 chipset

Introduce wed tx support for MT7986 chipset

Tested-by: Daniel Golle <daniel@makrotopia.org>
Co-developed-by: Bo Jiao <Bo.Jiao@mediatek.com>
Signed-off-by: Bo Jiao <Bo.Jiao@mediatek.com>
Co-developed-by: Sujuan Chen <sujuan.chen@mediatek.com>
Signed-off-by: Sujuan Chen <sujuan.chen@mediatek.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 months agowifi: mt76: mt7915: move wed init routines in mmio.c
Lorenzo Bianconi [Wed, 28 Sep 2022 09:19:41 +0000 (11:19 +0200)]
wifi: mt76: mt7915: move wed init routines in mmio.c

This is a preliminary patch to enable wed support for mt7986-wmac
chipset.

Tested-by: Daniel Golle <daniel@makrotopia.org>
Co-developed-by: Bo Jiao <Bo.Jiao@mediatek.com>
Signed-off-by: Bo Jiao <Bo.Jiao@mediatek.com>
Co-developed-by: Sujuan Chen <sujuan.chen@mediatek.com>
Signed-off-by: Sujuan Chen <sujuan.chen@mediatek.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 months agowifi: mt76: mt7915: fix mt7915_mac_set_timing()
Ryder Lee [Sat, 1 Oct 2022 01:42:44 +0000 (09:42 +0800)]
wifi: mt76: mt7915: fix mt7915_mac_set_timing()

Correct mac timiing settings for different hardware generations.
This improves 40-60Mbps performance.

Fixes: 9aac2969fe5f ("mt76: mt7915: update mac timing settings")
Reported-By: Carson Vandegriffe <carson.vandegriffe@candelatech.com>
Tested-by: Chad Monroe <chad.monroe@smartrg.com>
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 months agowifi: mt76: mt7915: set correct antenna for radar detection on MT7915D
Shayne Chen [Fri, 30 Sep 2022 15:13:15 +0000 (23:13 +0800)]
wifi: mt76: mt7915: set correct antenna for radar detection on MT7915D

For MT7915D, correct antenna index should be set to let DFS radar
detection work on the 5 GHz band.

Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 months agowifi: mt76: mt7915: add spatial extension index support
Shayne Chen [Fri, 30 Sep 2022 15:13:14 +0000 (23:13 +0800)]
wifi: mt76: mt7915: add spatial extension index support

In previous, we only allow user to configure tx antenna mask
contiguously (e.g. 0x3, 0xf).
This patch allows user to configure tx antenna mask interleavingly
(e.g. 0x5, 0x8). By setting proper antenna mask and nss, user can
prioritized the signal of different antennas, which helps to test
their performance in normal mode.

Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 months agowifi: mt76: connac: introduce mt76_connac_spe_idx()
Shayne Chen [Fri, 30 Sep 2022 15:13:13 +0000 (23:13 +0800)]
wifi: mt76: connac: introduce mt76_connac_spe_idx()

Add mt76_connac_spe_idx() for antenna mask to spatial extension
index conversion. This is used to support flexible control of
tx antenna.

Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 months agowifi: mt76: mt7915: rework testmode tx antenna setting
Shayne Chen [Fri, 30 Sep 2022 15:13:12 +0000 (23:13 +0800)]
wifi: mt76: mt7915: rework testmode tx antenna setting

Let the configuration of testmode antenna mask on both band0 and band1
become antenna_mask rather than chainmask. This could simplify the
settings for user and get rid of the conversion when sending fw command.

Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 months agowifi: mt76: mt7915: deal with special variant of mt7916
Peter Chiu [Fri, 30 Sep 2022 15:13:11 +0000 (23:13 +0800)]
wifi: mt76: mt7915: deal with special variant of mt7916

A variant of mt7916 supports up to 3 tx/rx paths but with only
2 spatial streams. An example usage of the 3rd path is to server as
an auxiliary for beamforming.
In order to deal with this case, this patch reworks some parts to
correctly use paths or streams.

Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com>
Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 months agowifi: mt76: mt7915: rework eeprom tx paths and streams init
Shayne Chen [Fri, 30 Sep 2022 15:13:10 +0000 (23:13 +0800)]
wifi: mt76: mt7915: rework eeprom tx paths and streams init

Rework tx paths and streams init part to improve readability, and make
sure that the available tx streams should be smaller than or equal to
the available tx paths.

Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 months agowifi: mt76: mt7915: reserve 8 bits for the index of rf registers
Evelyn Tsai [Fri, 30 Sep 2022 14:14:41 +0000 (22:14 +0800)]
wifi: mt76: mt7915: reserve 8 bits for the index of rf registers

The value of regidx of rf registers is combined with WF selection and
offset. Extend the WF selection field from 4 to 8 bits since the
adie index should also be specified.

Signed-off-by: Evelyn Tsai <evelyn.tsai@mediatek.com>
Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 months agowifi: mt76: mt7915: fix bounds checking for tx-free-done command
Ben Greear [Thu, 29 Sep 2022 15:15:25 +0000 (08:15 -0700)]
wifi: mt76: mt7915: fix bounds checking for tx-free-done command

According to the tx-free-done documentation, the DW4 can be repeated,
so have to be more careful about how we test for walking off the
end of the array.

Signed-off-by: Ben Greear <greearb@candelatech.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 months agowifi: mt76: Remove unused inline function mt76_wcid_mask_test()
Gaosheng Cui [Thu, 22 Sep 2022 07:47:11 +0000 (15:47 +0800)]
wifi: mt76: Remove unused inline function mt76_wcid_mask_test()

All uses of mt76_wcid_mask_test() have
been removed since commit 8950a62f19c9 ("mt76: get rid of
mt76_wcid_hw routine"), so remove it.

Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 months agowifi: mt76: mt7921: fix antenna signal are way off in monitor mode
Sean Wang [Fri, 16 Sep 2022 22:46:45 +0000 (06:46 +0800)]
wifi: mt76: mt7921: fix antenna signal are way off in monitor mode

Group 3 in RxD is disabled in monitor mode. We should use the group 5 in
RxD instead to fix antenna signal way off issue, e.g we would see the
incorrect antenna signal value in wireshark. On the other hand, Group 5
wouldn't be used in STA or AP mode, so the patch shouldn't cause any
harm to those modes.

Fixes: cbaa0a404f8d ("mt76: mt7921: fix up the monitor mode")
Reported-by: Adrian Granados <agranados@gmail.com>
Co-developed-by: Deren Wu <deren.wu@mediatek.com>
Signed-off-by: Deren Wu <deren.wu@mediatek.com>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 months agowifi: mt76: mt76x02: simplify struct mt76x02_rate_power
Felix Fietkau [Wed, 28 Sep 2022 09:29:45 +0000 (11:29 +0200)]
wifi: mt76: mt76x02: simplify struct mt76x02_rate_power

- remove stbc, because mt76x0 doesn't support it and mt76x2 uses the same
  values as HT/VHT
- reduce vht array to 2 elements, because VHT MCS0-7 are the same as HT

Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 months agowifi: mt76: move mt76_rate_power from core to mt76x02 driver code
Felix Fietkau [Wed, 28 Sep 2022 08:49:11 +0000 (10:49 +0200)]
wifi: mt76: move mt76_rate_power from core to mt76x02 driver code

Its layout and code is mt76x02 specific

Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 months agowifi: mac80211: fix and simplify unencrypted drop check for mesh
Felix Fietkau [Thu, 1 Dec 2022 13:57:30 +0000 (14:57 +0100)]
wifi: mac80211: fix and simplify unencrypted drop check for mesh

ieee80211_drop_unencrypted is called from ieee80211_rx_h_mesh_fwding and
ieee80211_frame_allowed.

Since ieee80211_rx_h_mesh_fwding can forward packets for other mesh nodes
and is called earlier, it needs to check the decryptions status and if the
packet is using the control protocol on its own, instead of deferring to
the later call from ieee80211_frame_allowed.

Because of that, ieee80211_drop_unencrypted has a mesh specific check
that skips over the mesh header in order to check the payload protocol.
This code is invalid when called from ieee80211_frame_allowed, since that
happens after the 802.11->802.3 conversion.

Fix this by moving the mesh specific check directly into
ieee80211_rx_h_mesh_fwding.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
Link: https://lore.kernel.org/r/20221201135730.19723-1-nbd@nbd.name
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
19 months agowifi: mac80211: add support for restricting netdev features per vif
Felix Fietkau [Mon, 10 Oct 2022 09:43:38 +0000 (11:43 +0200)]
wifi: mac80211: add support for restricting netdev features per vif

This can be used to selectively disable feature flags for checksum offload,
scatter/gather or GSO by changing vif->netdev_features.
Removing features from vif->netdev_features does not affect the netdev
features themselves, but instead fixes up skbs in the tx path so that the
offloads are not needed in the driver.

Aside from making it easier to deal with vif type based hardware limitations,
this also makes it possible to optimize performance on hardware without native
GSO support by declaring GSO support in hw->netdev_features and removing it
from vif->netdev_features. This allows mac80211 to handle GSO segmentation
after the sta lookup, but before itxq enqueue, thus reducing the number of
unnecessary sta lookups, as well as some other per-packet processing.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
Link: https://lore.kernel.org/r/20221010094338.78070-1-nbd@nbd.name
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
19 months agowifi: mac80211: update TIM for S1G specification changes
Kieran Frewen [Sun, 6 Nov 2022 22:16:02 +0000 (11:16 +1300)]
wifi: mac80211: update TIM for S1G specification changes

Updates to the TIM information element to match changes made in the
IEEE Std 802.11ah-2020.

Signed-off-by: Kieran Frewen <kieran.frewen@morsemicro.com>
Co-developed-by: Gilad Itzkovitch <gilad.itzkovitch@morsemicro.com>
Signed-off-by: Gilad Itzkovitch <gilad.itzkovitch@morsemicro.com>
Link: https://lore.kernel.org/r/20221106221602.25714-1-gilad.itzkovitch@morsemicro.com
[use skb_put_data/skb_put_u8]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
19 months agowifi: mac80211: don't parse multi-BSSID in assoc resp
Johannes Berg [Fri, 14 Oct 2022 16:56:11 +0000 (18:56 +0200)]
wifi: mac80211: don't parse multi-BSSID in assoc resp

It's not valid to have the multiple BSSID element in the
association response (per 802.11 REVme D1.0), so don't
try to parse it there, but only in the fallback beacon
elements if needed.

The other case that was parsing association requests was
already changed in a previous commit.

Change-Id: I659d2ef1253e079cc71c46a017044e116e31c024
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
19 months agowifi: cfg80211: use bss_from_pub() instead of container_of()
Johannes Berg [Mon, 17 Oct 2022 07:03:48 +0000 (09:03 +0200)]
wifi: cfg80211: use bss_from_pub() instead of container_of()

There's no need to open-code container_of() when we have
bss_from_pub(). Use it.

Change-Id: I074723717909ba211a40e6499f0c36df0e2ba4be
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
19 months agowifi: mac80211: remove unnecessary synchronize_net()
Johannes Berg [Wed, 2 Nov 2022 08:47:47 +0000 (09:47 +0100)]
wifi: mac80211: remove unnecessary synchronize_net()

The call to ieee80211_do_stop() right after will also do
synchronize_rcu() to ensure the SDATA_STATE_RUNNING bit
is cleared, so we don't need to synchronize_net() here.

Change-Id: Id9f9ffcf195002013e5d9fde288877d219780864
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
19 months agowifi: mac80211: Drop not needed check for NULL
Alexander Wetzel [Mon, 7 Nov 2022 16:13:28 +0000 (17:13 +0100)]
wifi: mac80211: Drop not needed check for NULL

ieee80211_get_txq() can only be called with vif != NULL.
Remove not needed NULL test in function.

Signed-off-by: Alexander Wetzel <alexander@wetzel-home.de>
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <error27@gmail.com>
Link: https://lore.kernel.org/r/20221107161328.2883-1-alexander@wetzel-home.de
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
19 months agowifi: cfg80211: Fix not unregister reg_pdev when load_builtin_regdb_keys() fails
Chen Zhongjin [Wed, 9 Nov 2022 09:02:37 +0000 (17:02 +0800)]
wifi: cfg80211: Fix not unregister reg_pdev when load_builtin_regdb_keys() fails

In regulatory_init_db(), when it's going to return a error, reg_pdev
should be unregistered. When load_builtin_regdb_keys() fails it doesn't
do it and makes cfg80211 can't be reload with report:

sysfs: cannot create duplicate filename '/devices/platform/regulatory.0'
 ...
 <TASK>
 dump_stack_lvl+0x79/0x9b
 sysfs_warn_dup.cold+0x1c/0x29
 sysfs_create_dir_ns+0x22d/0x290
 kobject_add_internal+0x247/0x800
 kobject_add+0x135/0x1b0
 device_add+0x389/0x1be0
 platform_device_add+0x28f/0x790
 platform_device_register_full+0x376/0x4b0
 regulatory_init+0x9a/0x4b2 [cfg80211]
 cfg80211_init+0x84/0x113 [cfg80211]
 ...

Fixes: 90a53e4432b1 ("cfg80211: implement regdb signature checking")
Signed-off-by: Chen Zhongjin <chenzhongjin@huawei.com>
Link: https://lore.kernel.org/r/20221109090237.214127-1-chenzhongjin@huawei.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
19 months agowifi: cfg80211: fix comparison of BSS frequencies
JUN-KYU SHIN [Fri, 11 Nov 2022 02:33:04 +0000 (11:33 +0900)]
wifi: cfg80211: fix comparison of BSS frequencies

If the "channel->freq_offset" comparison is omitted in cmp_bss(),
BSS with different kHz units cannot be distinguished in the S1G Band.
So "freq_offset" should also be included in the comparison.

Signed-off-by: JUN-KYU SHIN <jk.shin@newratek.com>
Link: https://lore.kernel.org/r/20221111023301.6395-1-jk.shin@newratek.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
19 months agowifi: mac80211: fix maybe-unused warning
Íñigo Huguet [Fri, 11 Nov 2022 15:36:22 +0000 (16:36 +0100)]
wifi: mac80211: fix maybe-unused warning

In ieee80211_lookup_key, the variable named `local` is unused if
compiled without lockdep, getting this warning:

net/mac80211/cfg.c: In function ‘ieee80211_lookup_key’:
net/mac80211/cfg.c:542:26: error: unused variable ‘local’ [-Werror=unused-variable]
  struct ieee80211_local *local = sdata->local;
                          ^~~~~

Fix it with __maybe_unused.

Fixes: 8cbf0c2ab6df ("wifi: mac80211: refactor some key code")
Signed-off-by: Íñigo Huguet <ihuguet@redhat.com>
Link: https://lore.kernel.org/r/20221111153622.29016-1-ihuguet@redhat.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
19 months agowifi: cfg80211: Correct example of ieee80211_iface_limit
Philipp Hortmann [Mon, 14 Nov 2022 20:01:35 +0000 (21:01 +0100)]
wifi: cfg80211: Correct example of ieee80211_iface_limit

Correct wrong closing bracket.

Signed-off-by: Philipp Hortmann <philipp.g.hortmann@gmail.com>
Link: https://lore.kernel.org/r/20221114200135.GA100176@matrix-ESPRIMO-P710
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
19 months agowifi: mac80211: fix memory leak in ieee80211_if_add()
Zhengchao Shao [Thu, 17 Nov 2022 06:45:00 +0000 (14:45 +0800)]
wifi: mac80211: fix memory leak in ieee80211_if_add()

When register_netdevice() failed in ieee80211_if_add(), ndev->tstats
isn't released. Fix it.

Fixes: 5a490510ba5f ("mac80211: use per-CPU TX/RX statistics")
Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
Link: https://lore.kernel.org/r/20221117064500.319983-1-shaozhengchao@huawei.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
19 months agowifi: nl80211: Add checks for nla_nest_start() in nl80211_send_iface()
Yuan Can [Tue, 29 Nov 2022 01:42:11 +0000 (01:42 +0000)]
wifi: nl80211: Add checks for nla_nest_start() in nl80211_send_iface()

As the nla_nest_start() may fail with NULL returned, the return value needs
to be checked.

Fixes: ce08cd344a00 ("wifi: nl80211: expose link information for interfaces")
Signed-off-by: Yuan Can <yuancan@huawei.com>
Link: https://lore.kernel.org/r/20221129014211.56558-1-yuancan@huawei.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
19 months agowifi: ieee80211: Do not open-code qos address offsets
Kees Cook [Wed, 30 Nov 2022 21:26:45 +0000 (13:26 -0800)]
wifi: ieee80211: Do not open-code qos address offsets

When building with -Wstringop-overflow, GCC's KASAN implementation does
not correctly perform bounds checking within some complex structures
when faced with literal offsets, and can get very confused. For example,
this warning is seen due to literal offsets into sturct ieee80211_hdr
that may or may not be large enough:

drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c: In function 'iwl_mvm_rx_mpdu_mq':
drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c:2022:29: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
 2022 |                         *qc &= ~IEEE80211_QOS_CTL_A_MSDU_PRESENT;
In file included from drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h:32,
                 from drivers/net/wireless/intel/iwlwifi/mvm/sta.h:15,
                 from drivers/net/wireless/intel/iwlwifi/mvm/mvm.h:27,
                 from drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c:10:
drivers/net/wireless/intel/iwlwifi/mvm/../fw/api/rx.h:559:16: note: at offset [78, 166] into destination object 'mpdu_len' of size 2
  559 |         __le16 mpdu_len;
      |                ^~~~~~~~

Refactor ieee80211_get_qos_ctl() to avoid using literal offsets,
requiring the creation of the actual structure that is described in the
comments. Explicitly choose the desired offset, making the code more
human-readable too. This is one of the last remaining warning to fix
before enabling -Wstringop-overflow globally.

Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97490
Link: https://github.com/KSPP/linux/issues/181
Cc: Johannes Berg <johannes@sipsolutions.net>
Cc: Kalle Valo <kvalo@kernel.org>
Cc: Gregory Greenman <gregory.greenman@intel.com>
Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org>
Cc: linux-wireless@vger.kernel.org
Cc: netdev@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/20221130212641.never.627-kees@kernel.org
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
19 months agowifi: rtw89: link rtw89_vif and chanctx stuffs
Zong-Zhe Yang [Tue, 29 Nov 2022 08:31:30 +0000 (16:31 +0800)]
wifi: rtw89: link rtw89_vif and chanctx stuffs

First, introduce struct rtw89_sub_entity for chanctx related stuffs.
Second, add enum rtw89_sub_entity_idx to rtw89_vif for vif operation
to access its/right chanctx stuffs after future multi-channel support.

Besides, RTW89_SUB_ENTITY_0 is the default chanctx entry throughout
driver, i.e. it's used for things which may not have a target chanctx
yet. So, we need to ensure that RTW89_SUB_ENTITY_0 is always working.
If there is at least one alive chanctx, then one of them must take
RTW89_SUB_ENTITY_0. If no alive chanctx, RTW89_SUB_ENTITY_0 will be
filled by rtw89_config_default_chandef().

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20221129083130.45708-7-pkshih@realtek.com
19 months agowifi: rtw89: fw: implement MCC related H2C
Zong-Zhe Yang [Tue, 29 Nov 2022 08:31:29 +0000 (16:31 +0800)]
wifi: rtw89: fw: implement MCC related H2C

These MCC H2C(s) require to wait for MCC C2H to determine if the
execution is successful. Through rtw89_wait_for_cond(), we make
them wait for either a completion with data from MCC C2H handlers,
which calls rtw89_complete_cond(), or timeout.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20221129083130.45708-6-pkshih@realtek.com
19 months agowifi: rtw89: mac: process MCC related C2H
Zong-Zhe Yang [Tue, 29 Nov 2022 08:31:28 +0000 (16:31 +0800)]
wifi: rtw89: mac: process MCC related C2H

Process C2H(s) related to MCC (multi-channel concurrency). These handling,
which either call rtw89_complete_cond() or show message in debug mode, can
be considered atomic/lock-free. So, they should be safe to be processed
directly after C2H pre-check in previous patch.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20221129083130.45708-5-pkshih@realtek.com
19 months agowifi: rtw89: introduce helpers to wait/complete on condition
Zong-Zhe Yang [Tue, 29 Nov 2022 08:31:27 +0000 (16:31 +0800)]
wifi: rtw89: introduce helpers to wait/complete on condition

MCC (multi-channel concurrency) related H2Cs (host to chip commands)
require to wait for C2H (chip to host events) responses to judge the
execution result and data. We introduce helpers to assist this process.
Besides, we would like the helpers to be generic for use in driver even
outside of MCC H2C/C2H, so we make a independent patch for them.

In the following, I describe the things first.
```
(A) C2H is generated by FW, and then transferred upto driver. Hence,
driver cannot get it immediately without a bit waitting/blocking.
For this, we choose to use wait_for_completion_*() instead of
busy polling.
(B) From the driver management perspective, a scenario, e.g. MCC,
may have mulitple kind of H2C functions requiring this process
to wait for corresponding C2Hs. But, the driver management flow
uses mutex to protect each behavior. So, one scenario triggers
one H2C function at one time. To avoid rampant instances of
struct completion for each H2C function, we choose to use one
struct completion with one condition flag for one scenario.
(C) C2Hs, which H2Cs will be waitting for, cannot be ordered with
driver management flow, i.e. cannot enqueue work to the same
ordered workqueue and cannot lock by the same mutex, to prevent
H2C side from getting no C2H responses. So, those C2Hs are parsed
in interrupt context directly as done in previous commit.
(D) Following (C), the above underline H2Cs and C2Hs will be handled
in different contexts without sync. So, we use atomic_cmpxchg()
to compare and change the condition in atomic.
```

So, we introduce struct rtw89_wait_info which combines struct completion
and atomic_t. Then, the below are the descriptions for helper functions.
* rtw89_wait_for_cond() to wait for a completion based on a condition.
* rtw89_complete_cond() to complete a given condition and carry data.
Each rtw89_wait_info instance independently determines the meaning of
its waitting conditions. But, RTW89_WAIT_COND_IDLE (UINT_MAX) is reserved.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20221129083130.45708-4-pkshih@realtek.com
19 months agowifi: rtw89: check if atomic before queuing c2h
Zong-Zhe Yang [Tue, 29 Nov 2022 08:31:26 +0000 (16:31 +0800)]
wifi: rtw89: check if atomic before queuing c2h

Before queuing C2H work, we check atomicity of the C2H's handler first now.
If atomic or lock-free, handle it directly; otherwise, handle it with mutex
in work as previous. This prepares for MAC MCC C2Hs which require to be
processed directly. And, their handlers will be functions which can be
considered atomic.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20221129083130.45708-3-pkshih@realtek.com
19 months agowifi: rtw89: rfk: rename rtw89_mcc_info to rtw89_rfk_mcc_info
Zong-Zhe Yang [Tue, 29 Nov 2022 08:31:25 +0000 (16:31 +0800)]
wifi: rtw89: rfk: rename rtw89_mcc_info to rtw89_rfk_mcc_info

The `rtw89_mcc_info mcc` is only for RFK MCC stuffs instead of common
MCC management info. Replace it with `rtw89_rfk_mcc_info rfk_mcc` to
avoid confusion and reserve `struct rtw89_mcc_info mcc` for MCC management
code.

(No logic changes.)

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20221129083130.45708-2-pkshih@realtek.com
19 months agowifi: rtw88: 8821c: enable BT device recovery mechanism
Ping-Ke Shih [Mon, 28 Nov 2022 07:56:53 +0000 (15:56 +0800)]
wifi: rtw88: 8821c: enable BT device recovery mechanism

8821ce is a combo card, and BT is a USB device that could get card lost
during stress test, and need WiFi firmware to detect and recover it, so
driver sends a H2C to enable this mechanism.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20221128075653.5221-1-pkshih@realtek.com
19 months agowifi: rtw89: 8852b: turn off PoP function in monitor mode
Ping-Ke Shih [Fri, 25 Nov 2022 07:24:16 +0000 (15:24 +0800)]
wifi: rtw89: 8852b: turn off PoP function in monitor mode

PoP stands for Packet on Packet that can improve performance in noisy
environment, but it could get RX stuck suddenly. In normal mode, firmware
can help to resolve the stuck, but firmware doesn't work in monitor mode.
Therefore, turn off PoP to avoid RX stuck.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20221125072416.94752-4-pkshih@realtek.com
19 months agowifi: rtw89: add HE radiotap for monitor mode
Ping-Ke Shih [Fri, 25 Nov 2022 07:24:15 +0000 (15:24 +0800)]
wifi: rtw89: add HE radiotap for monitor mode

With basic HE radiotap, we can check data rate in sniffer data. To store
the radiotap data, we reserve headroom of aligned 64 bytes, and then
update HE radiotap in monitor mode, so it doesn't affect performance in
normal mode.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20221125072416.94752-3-pkshih@realtek.com