linux-2.6-microblaze.git
10 months agowifi: mt76: testmode: add nla_policy for MT76_TM_ATTR_TX_LENGTH
Lin Ma [Sun, 23 Jul 2023 08:03:50 +0000 (16:03 +0800)]
wifi: mt76: testmode: add nla_policy for MT76_TM_ATTR_TX_LENGTH

It seems that the nla_policy in mt76_tm_policy is missed for attribute
MT76_TM_ATTR_TX_LENGTH. This patch adds the correct description to make
sure the

  u32 val = nla_get_u32(tb[MT76_TM_ATTR_TX_LENGTH]);

in function mt76_testmode_cmd() is safe and will not result in
out-of-attribute read.

Fixes: f0efa8621550 ("mt76: add API for testmode support")
Signed-off-by: Lin Ma <linma@zju.edu.cn>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: mt7921: move mt7921u_disconnect mt792x-lib
Lorenzo Bianconi [Wed, 28 Jun 2023 07:07:24 +0000 (15:07 +0800)]
wifi: mt76: mt7921: move mt7921u_disconnect mt792x-lib

mt7921u_disconnect routine is shared between mt7921 and mt7925 so move
it in mt792x-usb module.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Deren Wu <deren.wu@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: mt7921: move mt7921_dma_init in pci.c
Lorenzo Bianconi [Wed, 28 Jun 2023 07:07:23 +0000 (15:07 +0800)]
wifi: mt76: mt7921: move mt7921_dma_init in pci.c

Move mt7921_dma_init routine in pci.c and make it static since it is run
just in mt7921_pci_probe(). Get rid of dma.c.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Deren Wu <deren.wu@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: mt792x: move MT7921_PM_TIMEOUT and MT7921_HW_SCAN_TIMEOUT in common code
Lorenzo Bianconi [Wed, 28 Jun 2023 07:07:22 +0000 (15:07 +0800)]
wifi: mt76: mt792x: move MT7921_PM_TIMEOUT and MT7921_HW_SCAN_TIMEOUT in common code

MT7921_PM_TIMEOUT is shared between mt7925 and mt7921 so move it in
mt792x module.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Deren Wu <deren.wu@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: mt76_connac3: move lmac queue enumeration in mt76_connac3_mac.h
Lorenzo Bianconi [Wed, 28 Jun 2023 07:07:21 +0000 (15:07 +0800)]
wifi: mt76: mt76_connac3: move lmac queue enumeration in mt76_connac3_mac.h

This is a preliminary patch to introduce mt7925 chip support

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Deren Wu <deren.wu@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: mt792x: move mt7921_load_firmware in mt792x-lib module
Lorenzo Bianconi [Wed, 28 Jun 2023 07:07:20 +0000 (15:07 +0800)]
wifi: mt76: mt792x: move mt7921_load_firmware in mt792x-lib module

mt7921_load_firmware routine is shared between mt7921 and mt7925 chipset
so move it in mt792x-lib module.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Deren Wu <deren.wu@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: mt792x: introduce mt792x-usb module
Lorenzo Bianconi [Wed, 28 Jun 2023 07:07:19 +0000 (15:07 +0800)]
wifi: mt76: mt792x: introduce mt792x-usb module

Add usb shared code between mt7921 and mt7925 chipset to mt792x-usb module.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Deren Wu <deren.wu@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: mt7921: move acpi_sar code in mt792x-lib module
Lorenzo Bianconi [Wed, 28 Jun 2023 07:07:18 +0000 (15:07 +0800)]
wifi: mt76: mt7921: move acpi_sar code in mt792x-lib module

Move acpi_sar code in mt792x-lib module since it is shared between
mt7921 and mt7925 driver.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Deren Wu <deren.wu@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: mt7921: move runtime-pm pci code in mt792x-lib
Lorenzo Bianconi [Wed, 28 Jun 2023 07:07:17 +0000 (15:07 +0800)]
wifi: mt76: mt7921: move runtime-pm pci code in mt792x-lib

Move the following runtime-pm pci routines in mt792x-lib since they are
shared between mt7921 and mt7925 chipsets:
- __mt7921e_mcu_drv_pmctrl
- mt7921e_mcu_drv_pmctrl
- mt7921e_mcu_fw_pmctrl

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Deren Wu <deren.wu@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: mt7921: move shared runtime-pm code on mt792x-lib
Lorenzo Bianconi [Wed, 28 Jun 2023 07:07:16 +0000 (15:07 +0800)]
wifi: mt76: mt7921: move shared runtime-pm code on mt792x-lib

Moving hif_ops marcos in mt792x.h, we can move shared runtime-pm code
between mt7925 and mt7921 in mt792x-lib module.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Deren Wu <deren.wu@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: mt7921: move hif_ops macro in mt792x.h
Lorenzo Bianconi [Wed, 28 Jun 2023 07:07:15 +0000 (15:07 +0800)]
wifi: mt76: mt7921: move hif_ops macro in mt792x.h

Move the following hif_ops macro in mt792x.h:
- mt7925_init_reset
- mt7925_dev_reset
- mt7925_mcu_init
- __mt7925_mcu_drv_pmctrl
- __mt7925_mcu_fw_pmctrl

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Deren Wu <deren.wu@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: mt792x: move more dma shared code in mt792x_dma
Lorenzo Bianconi [Wed, 28 Jun 2023 07:07:14 +0000 (15:07 +0800)]
wifi: mt76: mt792x: move more dma shared code in mt792x_dma

Rely on irq_map support, move more dma shared code between mt7921 and
mt7925 in mt792x_dma.c
Move the following dma code in mt792x-lib
- mt792x_dma_enable
- mt792x_dma_reset
- mt792x_wpdma_reset
- mt792x_wpdma_reinit_cond

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Deren Wu <deren.wu@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: mt792x: introduce mt792x_irq_map
Lorenzo Bianconi [Wed, 28 Jun 2023 07:06:02 +0000 (15:06 +0800)]
wifi: mt76: mt792x: introduce mt792x_irq_map

mt792x_irq_map will be use to share the irq code shared between mt7921
and mt7925

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Deren Wu <deren.wu@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: mt7921: move init shared code in mt792x-lib module
Lorenzo Bianconi [Wed, 28 Jun 2023 07:06:01 +0000 (15:06 +0800)]
wifi: mt76: mt7921: move init shared code in mt792x-lib module

Reduce duplicated code moving init shared code in mt792x-lib module.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Deren Wu <deren.wu@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: mt7921: move debugfs shared code in mt792x-lib module
Lorenzo Bianconi [Wed, 28 Jun 2023 07:06:00 +0000 (15:06 +0800)]
wifi: mt76: mt7921: move debugfs shared code in mt792x-lib module

Reduce duplicated code moving debugfs shared code in mt792x-lib module.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Deren Wu <deren.wu@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: mt7921: move dma shared code in mt792x-lib module
Lorenzo Bianconi [Wed, 28 Jun 2023 07:05:59 +0000 (15:05 +0800)]
wifi: mt76: mt7921: move dma shared code in mt792x-lib module

Reduce duplicated code moving dma shared code in mt792x-lib module.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Deren Wu <deren.wu@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: mt7921: move mac shared code in mt792x-lib module
Lorenzo Bianconi [Wed, 28 Jun 2023 07:05:58 +0000 (15:05 +0800)]
wifi: mt76: mt7921: move mac shared code in mt792x-lib module

Reduce duplicated code moving mac shared code in mt792x-lib module.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Deren Wu <deren.wu@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: mt792x: introduce mt792x-lib module
Lorenzo Bianconi [Wed, 28 Jun 2023 07:05:57 +0000 (15:05 +0800)]
wifi: mt76: mt792x: introduce mt792x-lib module

mt792x-lib module will contain the shared code between mt7921 and new
MT79 WiFi7 chipset

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Deren Wu <deren.wu@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: mt7921: move mt792x_hw_dev in mt792x.h
Lorenzo Bianconi [Wed, 28 Jun 2023 07:05:56 +0000 (15:05 +0800)]
wifi: mt76: mt7921: move mt792x_hw_dev in mt792x.h

This is a preliminary patch to introduce WiFi7 chipset support

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Deren Wu <deren.wu@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: mt7921: move mt792x_mutex_{acquire/release} in mt792x.h
Lorenzo Bianconi [Wed, 28 Jun 2023 07:05:55 +0000 (15:05 +0800)]
wifi: mt76: mt7921: move mt792x_mutex_{acquire/release} in mt792x.h

This is a preliminary patch to introduce WiFi7 chipset support

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Deren Wu <deren.wu@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: mt792x: move shared structure definition in mt792x.h
Lorenzo Bianconi [Wed, 28 Jun 2023 07:05:54 +0000 (15:05 +0800)]
wifi: mt76: mt792x: move shared structure definition in mt792x.h

This is a preliminary patch to introduce WiFi7 chipset support

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Deren Wu <deren.wu@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: mt7921: rename mt7921_hif_ops in mt792x_hif_ops
Lorenzo Bianconi [Wed, 28 Jun 2023 07:05:53 +0000 (15:05 +0800)]
wifi: mt76: mt7921: rename mt7921_hif_ops in mt792x_hif_ops

This is a preliminary patch to introduce WiFi7 chipset support

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Deren Wu <deren.wu@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: mt7921: rename mt7921_dev in mt792x_dev
Lorenzo Bianconi [Wed, 28 Jun 2023 07:05:52 +0000 (15:05 +0800)]
wifi: mt76: mt7921: rename mt7921_dev in mt792x_dev

This is a preliminary patch to introduce WiFi7 chipset support

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Deren Wu <deren.wu@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: mt7921: rename mt7921_phy in mt792x_phy
Lorenzo Bianconi [Wed, 28 Jun 2023 07:05:51 +0000 (15:05 +0800)]
wifi: mt76: mt7921: rename mt7921_phy in mt792x_phy

This is a preliminary patch to introduce WiFi7 chipset support

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Deren Wu <deren.wu@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: mt7921: rename mt7921_sta in mt792x_sta
Lorenzo Bianconi [Wed, 28 Jun 2023 07:05:50 +0000 (15:05 +0800)]
wifi: mt76: mt7921: rename mt7921_sta in mt792x_sta

This is a preliminary patch to introduce WiFi7 chipset support

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Deren Wu <deren.wu@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: mt7921: rename mt7921_vif in mt792x_vif
Lorenzo Bianconi [Wed, 28 Jun 2023 07:05:49 +0000 (15:05 +0800)]
wifi: mt76: mt7921: rename mt7921_vif in mt792x_vif

This is a preliminary patch to introduce WiFi7 chipset support

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Deren Wu <deren.wu@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: mt7921: convert acpisar and clc pointers to void
Lorenzo Bianconi [Wed, 28 Jun 2023 07:05:48 +0000 (15:05 +0800)]
wifi: mt76: mt7921: convert acpisar and clc pointers to void

Convert acpisar and clc pointers in mt7921_dev structure to void.
This is a preliminary patch to add WiFi7 chipset support

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Deren Wu <deren.wu@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: mt7921: move common register definition in mt792x_regs.h
Lorenzo Bianconi [Wed, 28 Jun 2023 07:05:47 +0000 (15:05 +0800)]
wifi: mt76: mt7921: move common register definition in mt792x_regs.h

This is a preliminary patch in order to support new WiFi7 chips.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Deren Wu <deren.wu@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: mt7603: fix tx filter/flush function
Felix Fietkau [Tue, 25 Jul 2023 19:06:03 +0000 (21:06 +0200)]
wifi: mt76: mt7603: fix tx filter/flush function

Setting MT_TX_ABORT does not abort any transmission for a wtbl index on its
own. Instead, it modifies the behavior of a queue flush to make it selectively
flush packets for a particular wtbl index.
Adjust powersave filtering to make use of this in order to avoid running into
unnecessary timeouts while flushing

Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: mt7603: fix beacon interval after disabling a single vif
Felix Fietkau [Tue, 25 Jul 2023 10:37:59 +0000 (12:37 +0200)]
wifi: mt76: mt7603: fix beacon interval after disabling a single vif

When disabling beacons on a vif, intval is 0. Ensure that dev->mt76.beacon_int
is not overwritten in this case, so that beacons continue to work for other
interfaces.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: mt7915: remove VHT160 capability on MT7915
Felix Fietkau [Fri, 14 Jul 2023 08:57:15 +0000 (10:57 +0200)]
wifi: mt76: mt7915: remove VHT160 capability on MT7915

The IEEE80211_VHT_CAP_EXT_NSS_BW value already indicates support for half-NSS
160 MHz support, so it is wrong to also advertise full 160 MHz support.

Fixes: c2f73eacee3b ("wifi: mt76: mt7915: add back 160MHz channel width support for MT7915")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agodt-bindings: mt76: support pointing to EEPROM using NVMEM cell
Rafał Miłecki [Mon, 8 May 2023 15:58:20 +0000 (17:58 +0200)]
dt-bindings: mt76: support pointing to EEPROM using NVMEM cell

All kind of calibration data should be described as NVMEM cells of NVMEM
devices. That is more generic solution than "mediatek,mtd-eeprom" which
is MTD specific.

Add support for EEPROM NVMEM cells and deprecate existing MTD-based
property.

Cc: Christian Marangi <ansuelsmth@gmail.com>
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: add support for providing eeprom in nvmem cells
Christian Marangi [Sat, 8 Jul 2023 18:29:36 +0000 (20:29 +0200)]
wifi: mt76: add support for providing eeprom in nvmem cells

Add support for providing eeprom in nvmem cells by adding nvmem cell as
an alternative source for mt76_get_of_eeprom().

Nvmem cells will follow standard nvmem cell definition and needs to be
called 'eeprom' to be correctly identified.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Reviewed-by: Daniel Golle <daniel@makrotopia.org>
Tested-by: Daniel Golle <daniel@makrotopia.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: split get_of_eeprom in subfunction
Christian Marangi [Sat, 8 Jul 2023 18:29:35 +0000 (20:29 +0200)]
wifi: mt76: split get_of_eeprom in subfunction

In preparation for NVMEM support, split get_of_eeprom() in subfunction
to tidy the code and facilitate the addition of alternative method to
get eeprom data. No behaviour change intended.

While at it also drop OF ifdef checks as OF have stubs and calling
of_get_property would result in the same error returned.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Reviewed-by: Daniel Golle <daniel@makrotopia.org>
Tested-by: Daniel Golle <daniel@makrotopia.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: mt7915: fix capabilities in non-AP mode
Felix Fietkau [Thu, 29 Jun 2023 20:39:30 +0000 (22:39 +0200)]
wifi: mt76: mt7915: fix capabilities in non-AP mode

Capabilities in vif->bss_conf are only initialized in AP mode.
For other modes, they should be enabled by default, in order to avoid a
mismatch.

Fixes: 885f7af7e544 ("wifi: mt76: mt7915: remove mt7915_mcu_beacon_check_caps()")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: connac: add connac3 mac library
Lorenzo Bianconi [Thu, 22 Jun 2023 16:50:32 +0000 (18:50 +0200)]
wifi: mt76: connac: add connac3 mac library

Introduce connac3_mac in mt76_connac library to reuse mac code shared
between WiFi7 chipsets. So far connac3 library contains just radiotap
parsing code.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: connac: move connac3 definitions in mt76_connac3_mac.h
Lorenzo Bianconi [Thu, 22 Jun 2023 16:50:31 +0000 (18:50 +0200)]
wifi: mt76: connac: move connac3 definitions in mt76_connac3_mac.h

Connac3 mac definitions are shared between WiFi7 chipsets so move them in
mt76_connac3_mac.h

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: move rate info in mt76_vif
Lorenzo Bianconi [Thu, 22 Jun 2023 16:50:30 +0000 (18:50 +0200)]
wifi: mt76: move rate info in mt76_vif

This is a preliminary patch to introduce mt76_connac3 mac library used
by WiFi7 chipsets (e.g. mt7996).

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agomt76: connac: move more mt7921/mt7915 mac shared code in connac lib
Lorenzo Bianconi [Thu, 22 Jun 2023 16:50:29 +0000 (18:50 +0200)]
mt76: connac: move more mt7921/mt7915 mac shared code in connac lib

Move the following routines in mt76-connac lib since they are shared
between mt7915 and mt7921:
- mt76_connac2_tx_check_aggr
- mt76_connac2_txwi_free
- mt76_connac2_tx_token_put

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: move ampdu_state in mt76_wcid
Lorenzo Bianconi [Thu, 22 Jun 2023 16:50:28 +0000 (18:50 +0200)]
wifi: mt76: move ampdu_state in mt76_wcid

ampdu_state field is used by most of the drivers, so move it in
mt76_wcid structure.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: mt7921: rely on shared poll_list field
Lorenzo Bianconi [Thu, 22 Jun 2023 16:50:27 +0000 (18:50 +0200)]
wifi: mt76: mt7921: rely on shared poll_list field

Rely on poll_list field in mt76_wcid structure and get rid of
private copy.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: mt7996: rely on shared poll_list field
Lorenzo Bianconi [Thu, 22 Jun 2023 16:50:26 +0000 (18:50 +0200)]
wifi: mt76: mt7996: rely on shared poll_list field

Rely on poll_list field in mt76_wcid  structure and get rid of
private copy.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: mt7615: rely on shared poll_list field
Lorenzo Bianconi [Thu, 22 Jun 2023 16:50:25 +0000 (18:50 +0200)]
wifi: mt76: mt7615: rely on shared poll_list field

Rely on poll_list field in mt76_wcid structure and get rid of
private copy.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: mt7603: rely on shared poll_list field
Lorenzo Bianconi [Thu, 22 Jun 2023 16:50:24 +0000 (18:50 +0200)]
wifi: mt76: mt7603: rely on shared poll_list field

Rely on poll_list field in mt76_wcid structure and get rid of
private copy.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: mt7915: move poll_list in mt76_wcid
Lorenzo Bianconi [Thu, 22 Jun 2023 16:50:23 +0000 (18:50 +0200)]
wifi: mt76: mt7915: move poll_list in mt76_wcid

poll_list field is used by most of the drivers, so move it in mt76_wcid
structure.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: mt7921: rely on shared sta_poll_list and sta_poll_lock
Lorenzo Bianconi [Thu, 22 Jun 2023 16:50:22 +0000 (18:50 +0200)]
wifi: mt76: mt7921: rely on shared sta_poll_list and sta_poll_lock

Rely on sta_poll_list and sta_poll_lock fields in mt76_dev structure
and get rid of private copies.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: mt7996: rely on shared sta_poll_list and sta_poll_lock
Lorenzo Bianconi [Thu, 22 Jun 2023 16:50:21 +0000 (18:50 +0200)]
wifi: mt76: mt7996: rely on shared sta_poll_list and sta_poll_lock

Rely on sta_poll_list and sta_poll_lock fields in mt76_dev structure
and get rid of private copies.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: mt7615: rely on shared sta_poll_list and sta_poll_lock
Lorenzo Bianconi [Thu, 22 Jun 2023 16:50:20 +0000 (18:50 +0200)]
wifi: mt76: mt7615: rely on shared sta_poll_list and sta_poll_lock

Rely on sta_poll_list and sta_poll_lock fields in mt76_dev structure
and get rid of private copies.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: mt7603: rely on shared sta_poll_list and sta_poll_lock
Lorenzo Bianconi [Thu, 22 Jun 2023 16:50:19 +0000 (18:50 +0200)]
wifi: mt76: mt7603: rely on shared sta_poll_list and sta_poll_lock

Rely on sta_poll_list and sta_poll_lock fields in mt76_dev structure
and get rid of private copies.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: mt7915: move sta_poll_list and sta_poll_lock in mt76_dev
Lorenzo Bianconi [Thu, 22 Jun 2023 16:50:18 +0000 (18:50 +0200)]
wifi: mt76: mt7915: move sta_poll_list and sta_poll_lock in mt76_dev

sta_poll_list and sta_poll_lock are used by most of the drivers, so move
them in mt76_dev structure.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: mt7996: increase tx token size
Howard Hsu [Mon, 5 Jun 2023 15:21:41 +0000 (23:21 +0800)]
wifi: mt76: mt7996: increase tx token size

Align tx token size to proprietary driver, which can improve peak
throughput under MU performance tests.

Signed-off-by: Howard Hsu <howard-yh.hsu@mediatek.com>
Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: mt7996: add muru support
MeiChia Chiu [Mon, 5 Jun 2023 15:21:40 +0000 (23:21 +0800)]
wifi: mt76: mt7996: add muru support

Add sta_rec_muru() fw command to support MU-MIMO and OFDMA features.

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>
10 months agowifi: mt76: mt7996: fix WA event ring size
StanleyYP Wang [Mon, 5 Jun 2023 15:21:39 +0000 (23:21 +0800)]
wifi: mt76: mt7996: fix WA event ring size

Fix rx ring size of WA event to get rid of event loss and queue overflow
problems.

Fixes: 98686cd21624 ("wifi: mt76: mt7996: add driver for MediaTek Wi-Fi 7 (802.11be) devices")
Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: mt7996: use correct phy for background radar event
StanleyYP Wang [Mon, 5 Jun 2023 15:21:38 +0000 (23:21 +0800)]
wifi: mt76: mt7996: use correct phy for background radar event

If driver directly uses the band_idx reported from the radar event to
access mt76_phy array, it will get the wrong phy for background radar.
Fix this by adjusting the statement.

Fixes: 98686cd21624 ("wifi: mt76: mt7996: add driver for MediaTek Wi-Fi 7 (802.11be) devices")
Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: connac: add support to set ifs time by mcu command
Peter Chiu [Mon, 5 Jun 2023 15:21:37 +0000 (23:21 +0800)]
wifi: mt76: connac: add support to set ifs time by mcu command

There's a race between driver and fw on some tx/rx control registers
when setting ifs, which will cause accidental hw queue pause problems.
Avoid this by setting ifs time with bss_info mcu command.

Reviewed-by: Shayne Chen <shayne.chen@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>
10 months agowifi: mt76: mt7996: enable VHT extended NSS BW feature
Peter Chiu [Mon, 5 Jun 2023 15:21:36 +0000 (23:21 +0800)]
wifi: mt76: mt7996: enable VHT extended NSS BW feature

Set SUPPORTS_VHT_EXT_NSS_BW to let the max BW capability correctly be
parsed by different devices.

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>
10 months agowifi: mt76: mt7996: fix bss wlan_idx when sending bss_info command
Peter Chiu [Mon, 5 Jun 2023 15:21:34 +0000 (23:21 +0800)]
wifi: mt76: mt7996: fix bss wlan_idx when sending bss_info command

The bmc_tx_wlan_idx should be the wlan_idx of the current bss rather
than peer AP's wlan_idx, otherwise there will appear some frame
decryption problems on station mode.

Fixes: 98686cd21624 ("wifi: mt76: mt7996: add driver for MediaTek Wi-Fi 7 (802.11be) devices")
Reviewed-by: Shayne Chen <shayne.chen@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>
10 months agowifi: mt76: connac: add support for dsp firmware download
Peter Chiu [Mon, 5 Jun 2023 15:21:33 +0000 (23:21 +0800)]
wifi: mt76: connac: add support for dsp firmware download

Add FW_START_WORKING_PDA_DSP for the indication of starting DSP
firmware download, which is for phy-related control.
The firmware is transparent to the driver, but it's necessary for the
firmware download process.

Reviewed-by: Shayne Chen <shayne.chen@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>
10 months agowifi: mt76: mt7996: move radio ctrl commands to proper functions
Shayne Chen [Mon, 5 Jun 2023 15:21:32 +0000 (23:21 +0800)]
wifi: mt76: mt7996: move radio ctrl commands to proper functions

Move radio enable/disable commands into functions for configuring
per-phy radio.

Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: mt7921: get rid of MT7921_RESET_TIMEOUT marco
Lorenzo Bianconi [Mon, 5 Jun 2023 06:51:43 +0000 (08:51 +0200)]
wifi: mt76: mt7921: get rid of MT7921_RESET_TIMEOUT marco

MT7921_RESET_TIMEOUT is never used, so get rid of it.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agomt76: mt7996: rely on mt76_sta_stats in mt76_wcid
Lorenzo Bianconi [Mon, 29 May 2023 14:54:32 +0000 (16:54 +0200)]
mt76: mt7996: rely on mt76_sta_stats in mt76_wcid

mt76 now accounts station stats in mt76_sta_stats available in mt76_wcid
struct. Get rid of mt7996 private copy.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: mt7915: fix command timeout in AP stop period
Rany Hany [Sun, 28 May 2023 18:04:28 +0000 (21:04 +0300)]
wifi: mt76: mt7915: fix command timeout in AP stop period

Due to AP stop improperly, mt7915 driver would face random command timeout
by chip fw problem. Migrate AP start/stop process to .start_ap/.stop_ap and
congiure BSS network settings in both hooks.

The new flow is shown below.
* AP start
    .start_ap()
      configure BSS network resource
      set BSS to connected state
    .bss_info_changed()
      enable fw beacon offload

* AP stop
    .bss_info_changed()
      disable fw beacon offload (skip this command)
    .stop_ap()
      set BSS to disconnected state (beacon offload disabled automatically)
      destroy BSS network resource

Based on "mt76: mt7921: fix command timeout in AP stop period"

Signed-off-by: Rany Hany <rany_hany@riseup.net>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: mt7921: make mt7921_mac_sta_poll static
Lorenzo Bianconi [Sat, 27 May 2023 11:23:46 +0000 (13:23 +0200)]
wifi: mt76: mt7921: make mt7921_mac_sta_poll static

Make mt7921_mac_sta_poll static since it is run just in mac.c

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: mt7996: disable WFDMA Tx/Rx during SER recovery
Bo Jiao [Mon, 22 May 2023 18:49:54 +0000 (02:49 +0800)]
wifi: mt76: mt7996: disable WFDMA Tx/Rx during SER recovery

Stop WFDMA transaction to avoid potential unexpected issue while doing
system recovery.

Signed-off-by: Bo Jiao <Bo.Jiao@mediatek.com>
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: mt7915: disable WFDMA Tx/Rx during SER recovery
Bo Jiao [Mon, 22 May 2023 18:49:53 +0000 (02:49 +0800)]
wifi: mt76: mt7915: disable WFDMA Tx/Rx during SER recovery

Stop WFDMA transaction to avoid potential unexpected issue while doing
system recovery.

Signed-off-by: Bo Jiao <Bo.Jiao@mediatek.com>
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: mt7921: Support temp sensor
Ben Greear [Fri, 2 Jun 2023 21:14:24 +0000 (14:14 -0700)]
wifi: mt76: mt7921: Support temp sensor

Allow sensors tool to read radio's temperature, example:

mt7921_phy17-pci-1800
Adapter: PCI adapter
temp1:        +72.0°C

Signed-off-by: Ben Greear <greearb@candelatech.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: mt7921: fix non-PSC channel scan fail
Ming Yen Hsieh [Thu, 18 May 2023 14:08:14 +0000 (22:08 +0800)]
wifi: mt76: mt7921: fix non-PSC channel scan fail

Due to the scan command may only request legacy bands and PSC channel
in 6GHz band, we are unable to scan the APs on non-PSC channel in this
case. Enable WIPHY_FLAG_SPLIT_SCAN_6GHZ to support non-PSC channel
(obtained during scan on legacy bands) in 6GHz scan request.

Fixes: 50ac15a511e3 ("mt76: mt7921: add 6GHz support")
Signed-off-by: Ming Yen Hsieh <mingyen.hsieh@mediatek.com>
Signed-off-by: Deren Wu <deren.wu@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: mt7915: accumulate mu-mimo ofdma muru stats
Ryder Lee [Wed, 17 May 2023 17:34:43 +0000 (01:34 +0800)]
wifi: mt76: mt7915: accumulate mu-mimo ofdma muru stats

The stats are clear-on-read, which makes it very difficult for tools
to adequately deal with wrapped stats and with keeping good totals.

So, accumulate these values when they are read from the firmware/radio
and present totals to user-space.

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>
10 months agowifi: mt76: add tx_nss histogram to ethtool stats
Ryder Lee [Wed, 17 May 2023 17:34:42 +0000 (01:34 +0800)]
wifi: mt76: add tx_nss histogram to ethtool stats

mt76_connac2_mac_fill_txs() counts tx_nss but ethtool doesn't show
stats. Add missing histogram accordingly.

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>
10 months agowifi: mt76: mt7921: fix skb leak by txs missing in AMSDU
Deren Wu [Wed, 17 May 2023 09:18:24 +0000 (17:18 +0800)]
wifi: mt76: mt7921: fix skb leak by txs missing in AMSDU

txs may be dropped if the frame is aggregated in AMSDU. When the problem
shows up, some SKBs would be hold in driver to cause network stopped
temporarily. Even if the problem can be recovered by txs timeout handling,
mt7921 still need to disable txs in AMSDU to avoid this issue.

Cc: stable@vger.kernel.org
Fixes: 163f4d22c118 ("mt76: mt7921: add MAC support")
Reviewed-by: Shayne Chen <shayne.chen@mediatek.com>
Signed-off-by: Deren Wu <deren.wu@mediatek.com>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: mt7921e: report tx retries/failed counts in tx free event
Deren Wu [Mon, 15 May 2023 15:18:50 +0000 (23:18 +0800)]
wifi: mt76: mt7921e: report tx retries/failed counts in tx free event

Get missing tx retries/failed counts from txfree done events and report
them via mt7921_sta_statistics().

Signed-off-by: Deren Wu <deren.wu@mediatek.com>
Reviewed-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: mt7915: add support for MT7981
Alexander Couzens [Mon, 15 May 2023 13:27:12 +0000 (15:27 +0200)]
wifi: mt76: mt7915: add support for MT7981

Add support for the MediaTek MT7981 SoC which is similar to the MT7986
but with a newer IP cores and only 2x ARM Cortex-A53 instead of 4x.
Unlike MT7986 the MT7981 can only connect a single wireless frontend,
usually MT7976 is used for DBDC.

Signed-off-by: Alexander Couzens <lynxis@fe80.eu>
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agodt-bindings: net: wireless: mt76: add bindings for MT7981
Daniel Golle [Mon, 15 May 2023 13:25:59 +0000 (15:25 +0200)]
dt-bindings: net: wireless: mt76: add bindings for MT7981

Add mediatek,mt7981-wmac compatible string entry.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Acked-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: mt7921: rely on mib_stats shared definition
Lorenzo Bianconi [Fri, 12 May 2023 22:29:55 +0000 (00:29 +0200)]
wifi: mt76: mt7921: rely on mib_stats shared definition

Get rid of private copy of mib_stats structure.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: mt7996: rely on mib_stats shared definition
Lorenzo Bianconi [Fri, 12 May 2023 22:29:54 +0000 (00:29 +0200)]
wifi: mt76: mt7996: rely on mib_stats shared definition

Get rid of private copy of mib_stats structure.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: mt7915: move mib_stats structure in mt76.h
Lorenzo Bianconi [Fri, 12 May 2023 22:29:53 +0000 (00:29 +0200)]
wifi: mt76: mt7915: move mib_stats structure in mt76.h

mib_stats structure is shared by mostly all chipsets. Move it to shared
code.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: mt7921: remove macro duplication in regs.h
Lorenzo Bianconi [Fri, 12 May 2023 13:11:58 +0000 (15:11 +0200)]
wifi: mt76: mt7921: remove macro duplication in regs.h

Get rid of MT_MIB_RTS_COUNT_MASK marco duplication in mt7921/regs.h

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: mt7921: do not support one stream on secondary antenna only
Deren Wu [Wed, 10 May 2023 06:51:13 +0000 (14:51 +0800)]
wifi: mt76: mt7921: do not support one stream on secondary antenna only

mt7921 support following antenna combiantions only.
* primary + secondary (2x2)
* primary only        (1x1)

Since we cannot work on secondary antenna only, return error if the
antenna bitmap is 0x2 in .set_antenna().

For example:
iw phy0 set antenna 3 3 /* valid */
iw phy0 set antenna 1 1 /* valid */
iw phy0 set antenna 2 2 /* invalid */

Cc: stable@vger.kernel.org
Fixes: e0f9fdda81bd ("mt76: mt7921: add ieee80211_ops")
Suggested-by: Knox Chiou <knoxchiou@google.com>
Signed-off-by: Deren Wu <deren.wu@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: mt7996: drop return in mt7996_sta_statistics
Ryder Lee [Wed, 10 May 2023 04:53:21 +0000 (12:53 +0800)]
wifi: mt76: mt7996: drop return in mt7996_sta_statistics

Avoid blocking other statistics sinfo->filled when txrate is
unavailable.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: mt7915: drop return in mt7915_sta_statistics
Ryder Lee [Wed, 10 May 2023 04:53:20 +0000 (12:53 +0800)]
wifi: mt76: mt7915: drop return in mt7915_sta_statistics

Avoid blocking other statistics sinfo->filled when txrate is
unavailable.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: report non-binding skb tx rate when WED is active
Peter Chiu [Wed, 10 May 2023 04:53:19 +0000 (12:53 +0800)]
wifi: mt76: report non-binding skb tx rate when WED is active

AQL relies on accurate tx rate reporting, so add this patch for
non-binding skb rate when WED is enabled.

Co-developed-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: mt7915: rework tx bytes counting when WED is active
Peter Chiu [Wed, 10 May 2023 04:53:18 +0000 (12:53 +0800)]
wifi: mt76: mt7915: rework tx bytes counting when WED is active

Concurrent binding/non-binding skbs could be handled anywhere which leads
to mixed byte counting, so switch to use PPDU TxS reporting regardless Tx
paths when WED is active.

Fixes: 43eaa3689507 ("wifi: mt76: add PPDU based TxS support for WED device")
Co-developed-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: mt7915: rework tx packets counting when WED is active
Peter Chiu [Wed, 10 May 2023 04:53:17 +0000 (12:53 +0800)]
wifi: mt76: mt7915: rework tx packets counting when WED is active

PPDU TxS can only report MPDU count whereas mac80211 requires MSDU scale
(NL80211_STA_INFO_TX_PACKETS), so switch to get MSDU counts from WA
statistic.

Note that mt7915 WA firmware only counts tx_packet for WED path, so driver
needs to take care of host path additionally.

Fixes: 43eaa3689507 ("wifi: mt76: add PPDU based TxS support for WED device")
Co-developed-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: mt7915: report tx retries/failed counts for non-WED path
Ryder Lee [Wed, 10 May 2023 04:53:16 +0000 (12:53 +0800)]
wifi: mt76: mt7915: report tx retries/failed counts for non-WED path

Get missing tx retries/failed counts from txfree done events and report
them via mt7915_sta_statistics().

Co-developed-by: Peter Chiu <chui-hao.chiu@mediatek.com>
Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com>
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: mt7915: fix background radar event being blocked
StanleyYP Wang [Tue, 9 May 2023 03:11:57 +0000 (11:11 +0800)]
wifi: mt76: mt7915: fix background radar event being blocked

The background radar uses MT_RX_SEL2 as its band indication, so fix it.

Fixes: 7a53eecd5c87 (wifi: mt76: mt7915: check the correctness of event data)
Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: enable UNII-4 channel 177 support
Ryder Lee [Sat, 6 May 2023 05:46:19 +0000 (13:46 +0800)]
wifi: mt76: enable UNII-4 channel 177 support

Enable support for the 5GHz channel 177 with center frequency 5885MHz and
operating class 125 based on IEEE Std 802.11ax-2021 Table E-4.

Signed-off-by: Himanshu Goyal <himanshu.goyal@mediatek.com>
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: mt7615: enable BSS_CHANGED_MU_GROUPS support
Ryder Lee [Tue, 2 May 2023 03:10:06 +0000 (11:10 +0800)]
wifi: mt76: mt7615: enable BSS_CHANGED_MU_GROUPS support

The Group ID Management frame is an Action frame of category VHT.
It is transmitted by the AP to assign or change the user position
of a STA for one or more group IDs.

Also, sniffer can use a given group id to monitor STA that belongs
to that group.

Notify underlying driver of changes via BSS_CHANGED_MU_GROUPS.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: mt7996: enable BSS_CHANGED_MU_GROUPS support
Ryder Lee [Tue, 2 May 2023 03:10:05 +0000 (11:10 +0800)]
wifi: mt76: mt7996: enable BSS_CHANGED_MU_GROUPS support

The Group ID Management frame is an Action frame of category VHT.
It is transmitted by the AP to assign or change the user position
of a STA for one or more group IDs.

Also, sniffer can use a given group id to monitor STA that belongs
to that group.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: mt76: mt7996: fix header translation logic
Ryder Lee [Wed, 26 Apr 2023 23:05:15 +0000 (07:05 +0800)]
wifi: mt76: mt7996: fix header translation logic

When header translation failure is indicated, the hardware will insert
an extra 2-byte field containing the data length after the protocol
type field. This happens either when the LLC-SNAP pattern did not match,
or if a VLAN header was detected.

The previous commit accidentally breaks the logic, so reverts back.

Fixes: 27db47ab1f47 (wifi: mt76: mt7996: enable mesh HW amsdu/de-amsdu support)
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agomt76: mt7921: don't assume adequate headroom for SDIO headers
Matt Whitlock [Thu, 20 Apr 2023 19:24:51 +0000 (15:24 -0400)]
mt76: mt7921: don't assume adequate headroom for SDIO headers

mt7921_usb_sdio_tx_prepare_skb() calls mt7921_usb_sdio_write_txwi() and
mt7921_skb_add_usb_sdio_hdr(), both of which blindly assume that
adequate headroom will be available in the passed skb. This assumption
typically is satisfied when the skb was allocated in the net core for
transmission via the mt7921 netdev (although even that is only an
optimization and is not strictly guaranteed), but the assumption is
sometimes not satisfied when the skb originated in the receive path of
another netdev and was passed through to the mt7921, such as by the
bridge layer. Blindly prepending bytes to an skb is always wrong.

This commit introduces a call to skb_cow_head() before the call to
mt7921_usb_sdio_write_txwi() in mt7921_usb_sdio_tx_prepare_skb() to
ensure that at least MT_SDIO_TXD_SIZE + MT_SDIO_HDR_SIZE bytes can be
pushed onto the skb.

Without this fix, I can trivially cause kernel panics by bridging an
MT7921AU-based USB 802.11ax interface with an Ethernet interface on an
Intel Atom-based x86 system using its onboard RTL8169 PCI Ethernet
adapter and also on an ARM-based Raspberry Pi 1 using its onboard
SMSC9512 USB Ethernet adapter. Note that the panics do not occur in
every system configuration, as they occur only if the receiving netdev
leaves less headroom in its received skbs than the mt7921 needs for its
SDIO headers.

Here is an example stack trace of this panic on Raspberry Pi OS Lite
2023-02-21 running kernel 6.1.24+ [1]:

 skb_panic from skb_push+0x44/0x48
 skb_push from mt7921_usb_sdio_tx_prepare_skb+0xd4/0x190 [mt7921_common]
 mt7921_usb_sdio_tx_prepare_skb [mt7921_common] from mt76u_tx_queue_skb+0x94/0x1d0 [mt76_usb]
 mt76u_tx_queue_skb [mt76_usb] from __mt76_tx_queue_skb+0x4c/0xc8 [mt76]
 __mt76_tx_queue_skb [mt76] from mt76_txq_schedule.part.0+0x13c/0x398 [mt76]
 mt76_txq_schedule.part.0 [mt76] from mt76_txq_schedule_all+0x24/0x30 [mt76]
 mt76_txq_schedule_all [mt76] from mt7921_tx_worker+0x58/0xf4 [mt7921_common]
 mt7921_tx_worker [mt7921_common] from __mt76_worker_fn+0x9c/0xec [mt76]
 __mt76_worker_fn [mt76] from kthread+0xbc/0xe0
 kthread from ret_from_fork+0x14/0x34

After this fix, bridging the mt7921 interface works fine on both of my
previously problematic systems.

[1] https://github.com/raspberrypi/firmware/tree/5c276f55a4b21345cd4d6200a504ee991851ff7a

Link: https://github.com/openwrt/openwrt/issues/11796
Signed-off-by: Matt Whitlock <kernel@mattwhitlock.name>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 months agowifi: brcmsmac: remove unused data type
Dmitry Antipov [Wed, 19 Jul 2023 08:31:55 +0000 (11:31 +0300)]
wifi: brcmsmac: remove unused data type

Remove unused 'struct gpioh_item'. It seems it was so since
commit 5b435de0d786 ("net: wireless: add brcm80211 drivers").

Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230719083232.158177-1-dmantipov@yandex.ru
10 months agowifi: mwifiex: Set WIPHY_FLAG_NETNS_OK flag
Johannes Wiesboeck [Thu, 6 Jul 2023 09:34:36 +0000 (11:34 +0200)]
wifi: mwifiex: Set WIPHY_FLAG_NETNS_OK flag

Allow moving the wiphy device for mwififex to a non-inital network
namespace. Many wireless drivers enable this flag implicitly by
initializing through the generic ieee80211_alloc_hw_nm function. As
mwifiex does not utilize this function WIPHY_FLAG_NETNS_OK must be set
explicitly.

Moving to network namespace and working connection tested using
wpa_supplicant from a network namespace as well as from a container on
GyroidOS. The hardware was the Toradex Apalis i.MX8QM Board using the
Azurewave AW-CM276NF wireless module.

Signed-off-by: Johannes Wiesboeck <johannes.wiesboeck@aisec.fraunhofer.de>
Reviewed-by: Michael Weiß <michael.weiss@aisec.fraunhofer.de>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230706093437.3380526-1-johannes.wiesboeck@aisec.fraunhofer.de
10 months agowifi: mwifiex: fix fortify warning
Dmitry Antipov [Thu, 29 Jun 2023 08:51:01 +0000 (11:51 +0300)]
wifi: mwifiex: fix fortify warning

When compiling with gcc 13.1 and CONFIG_FORTIFY_SOURCE=y,
I've noticed the following:

In function ‘fortify_memcpy_chk’,
    inlined from ‘mwifiex_construct_tdls_action_frame’ at drivers/net/wireless/marvell/mwifiex/tdls.c:765:3,
    inlined from ‘mwifiex_send_tdls_action_frame’ at drivers/net/wireless/marvell/mwifiex/tdls.c:856:6:
./include/linux/fortify-string.h:529:25: warning: call to ‘__read_overflow2_field’
declared with attribute warning: detected read beyond size of field (2nd parameter);
maybe use struct_group()? [-Wattribute-warning]
  529 |                         __read_overflow2_field(q_size_field, size);
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The compiler actually complains on:

memmove(pos + ETH_ALEN, &mgmt->u.action.category,
sizeof(mgmt->u.action.u.tdls_discover_resp));

and it happens because the fortification logic interprets this
as an attempt to overread 1-byte 'u.action.category' member of
'struct ieee80211_mgmt'. To silence this warning, it's enough
to pass an address of 'u.action' itself instead of an address
of its first member.

This also fixes an improper usage of 'sizeof()'. Since 'skb' is
extended with 'sizeof(mgmt->u.action.u.tdls_discover_resp) + 1'
bytes (where 1 is actually 'sizeof(mgmt->u.action.category)'),
I assume that the same number of bytes should be copied.

Suggested-by: Brian Norris <briannorris@chromium.org>
Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
Reviewed-by: Brian Norris <briannorris@chromium.org>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230629085115.180499-2-dmantipov@yandex.ru
10 months agowifi: mwifiex: prefer strscpy() over strlcpy()
Dmitry Antipov [Thu, 29 Jun 2023 08:51:00 +0000 (11:51 +0300)]
wifi: mwifiex: prefer strscpy() over strlcpy()

Prefer 'strscpy()' over 'strlcpy()' in 'mwifiex_init_hw_fw()'.

Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
Reviewed-by: Brian Norris <briannorris@chromium.org>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230629085115.180499-1-dmantipov@yandex.ru
10 months agowifi: rtl8xxxu: Enable AP mode for RTL8723BU
Bitterblue Smith [Mon, 10 Jul 2023 21:05:14 +0000 (00:05 +0300)]
wifi: rtl8xxxu: Enable AP mode for RTL8723BU

Theoretically this chip can handle 127 clients.

Only compile tested but it should work as well as the RTL8188FU.

Signed-off-by: Bitterblue Smith <rtl8821cerfe2@gmail.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/b2876c56-0ea7-c398-5c9b-635f9f894f2c@gmail.com
10 months agowifi: rtl8xxxu: Enable AP mode for RTL8192EU
Bitterblue Smith [Mon, 10 Jul 2023 21:04:39 +0000 (00:04 +0300)]
wifi: rtl8xxxu: Enable AP mode for RTL8192EU

Theoretically this chip can handle 127 clients.

Tested only very briefly but it should work as well as the RTL8188FU.

Signed-off-by: Bitterblue Smith <rtl8821cerfe2@gmail.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/56c9b186-ba9a-8469-652d-ce1709813e9e@gmail.com
10 months agowifi: rtl8xxxu: Enable AP mode for RTL8710BU (RTL8188GU)
Bitterblue Smith [Mon, 10 Jul 2023 21:04:05 +0000 (00:04 +0300)]
wifi: rtl8xxxu: Enable AP mode for RTL8710BU (RTL8188GU)

Theoretically this chip can handle 15 clients.

Tested only very briefly but it should work as well as the RTL8188FU.

Signed-off-by: Bitterblue Smith <rtl8821cerfe2@gmail.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/ce04a0a1-df72-ea30-f742-8834e01457f5@gmail.com
10 months agowifi: rtl8xxxu: Enable AP mode for RTL8192FU
Bitterblue Smith [Mon, 10 Jul 2023 21:02:45 +0000 (00:02 +0300)]
wifi: rtl8xxxu: Enable AP mode for RTL8192FU

Theoretically this chip can handle 127 clients.

Tested only very briefly but it should work as well as the RTL8188FU.

Signed-off-by: Bitterblue Smith <rtl8821cerfe2@gmail.com>
Reviewed-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/ffcabba5-7e9e-674c-ad03-73646b040b96@gmail.com
10 months agowifi: zd1211rw: fix typo "tranmits"
Yueh-Shun Li [Thu, 22 Jun 2023 01:26:27 +0000 (01:26 +0000)]
wifi: zd1211rw: fix typo "tranmits"

Spell "transmits" properly.

Found by searching for keyword "tranm".

Signed-off-by: Yueh-Shun Li <shamrocklee@posteo.net>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230622012627.15050-4-shamrocklee@posteo.net
10 months agowifi: rtw89: debug: Fix error handling in rtw89_debug_priv_btc_manual_set()
Zhang Shurong [Sat, 15 Jul 2023 13:42:57 +0000 (21:42 +0800)]
wifi: rtw89: debug: Fix error handling in rtw89_debug_priv_btc_manual_set()

If there is a failure during kstrtobool_from_user()
rtw89_debug_priv_btc_manual_set should return a negative error code
instead of returning the count directly.

Fix this bug by returning an error code instead of a count after
a failed call of the function "kstrtobool_from_user". Moreover
I omitted the label "out" with this source code correction.

Fixes: e3ec7017f6a2 ("rtw89: add Realtek 802.11ax driver")
Signed-off-by: Zhang Shurong <zhang_shurong@foxmail.com>
Acked-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/tencent_1C09B99BD7DA9CAD18B00C8F0F050F540607@qq.com