platform/kernel/linux-rpi.git
11 months agowifi: rtw89: support firmware log with formatted text
Chin-Yen Lee [Tue, 1 Aug 2023 02:11:21 +0000 (10:11 +0800)]
wifi: rtw89: support firmware log with formatted text

Original firmware log which is sent via C2H message bloats
code size of firmware and is also length-limited. So we put
some common log into format file, and firmware could use a
log ID and some variables in C2H message to map a formatted
text via pre-designed rule.

Signed-off-by: Chin-Yen Lee <timlee@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/20230801021127.15919-3-pkshih@realtek.com
11 months agowifi: rtw89: recognize log format from firmware file
Chin-Yen Lee [Tue, 1 Aug 2023 02:11:20 +0000 (10:11 +0800)]
wifi: rtw89: recognize log format from firmware file

Firmware log format is an element of multi-firmware file
and used for firmware to provide log with formatted text.
Driver needs to recognize it in advance if it exists.

Signed-off-by: Chin-Yen Lee <timlee@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/20230801021127.15919-2-pkshih@realtek.com
11 months agowifi: mwifiex: fix error recovery in PCIE buffer descriptor management
Dmitry Antipov [Mon, 31 Jul 2023 07:43:07 +0000 (10:43 +0300)]
wifi: mwifiex: fix error recovery in PCIE buffer descriptor management

Add missing 'kfree_skb()' in 'mwifiex_init_rxq_ring()' and never do
'kfree(card->rxbd_ring_vbase)' because this area is DMAed and should
be released with 'dma_free_coherent()'. The latter is performed in
'mwifiex_pcie_delete_rxbd_ring()', which is now called to recover
from possible errors in 'mwifiex_pcie_create_rxbd_ring()'. Likewise
for 'mwifiex_pcie_init_evt_ring()', 'kfree(card->evtbd_ring_vbase)'
'mwifiex_pcie_delete_evtbd_ring()' and 'mwifiex_pcie_create_rxbd_ring()'.

Fixes: d930faee141b ("mwifiex: add support for Marvell pcie8766 chipset")
Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
Acked-by: Brian Norris <briannorris@chromium.org>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230731074334.56463-1-dmantipov@yandex.ru
11 months agowifi: brcmsmac: cleanup SCB-related data types
Dmitry Antipov [Tue, 25 Jul 2023 16:23:46 +0000 (19:23 +0300)]
wifi: brcmsmac: cleanup SCB-related data types

Drop unused and set-but-unused fields of 'struct scb_ampdu_tid_ini',
'struct scb_ampdu' and 'struct scb', as well as now unused argument
of 'brcms_c_ampdu_tx_operational()', adjust related code.

Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230725162400.192357-2-dmantipov@yandex.ru
11 months agowifi: brcmsmac: remove more unused data types
Dmitry Antipov [Tue, 25 Jul 2023 16:23:45 +0000 (19:23 +0300)]
wifi: brcmsmac: remove more unused data types

Remove unused 'struct brcmu_iovar' and 'struct tx_inst_power'. This
follows commit b2090d93d4b6 ("wifi: brcmsmac: remove unused data type").

Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230725162400.192357-1-dmantipov@yandex.ru
11 months agowifi: mt76: Replace strlcpy() with strscpy()
Azeem Shaikh [Mon, 3 Jul 2023 18:12:56 +0000 (18:12 +0000)]
wifi: mt76: Replace strlcpy() with strscpy()

strlcpy() reads the entire source buffer first.
This read may exceed the destination size limit.
This is both inefficient and can lead to linear read
overflows if a source string is not NUL-terminated [1].
In an effort to remove strlcpy() completely [2], replace
strlcpy() here with strscpy().

Direct replacement is safe here since DEV_ASSIGN is only used by
TRACE macros and the return values are ignored.

[1] https://www.kernel.org/doc/html/latest/process/deprecated.html#strlcpy
[2] https://github.com/KSPP/linux/issues/89

Signed-off-by: Azeem Shaikh <azeemshaikh38@gmail.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230703181256.3712079-1-azeemshaikh38@gmail.com
11 months agoMerge tag 'mt76-for-kvalo-2023-07-31' of https://github.com/nbd168/wireless
Kalle Valo [Wed, 2 Aug 2023 09:36:37 +0000 (12:36 +0300)]
Merge tag 'mt76-for-kvalo-2023-07-31' of https://github.com/nbd168/wireless

mt76 patches for 6.6

* fixes
* preparation for mt7925 support
* mt7981 support

11 months agowifi: libertas: prefer kstrtoX() for simple integer conversions
Dmitry Antipov [Tue, 25 Jul 2023 06:04:48 +0000 (09:04 +0300)]
wifi: libertas: prefer kstrtoX() for simple integer conversions

Prefer 'kstrtoX()' family of functions over 'sscanf()' to convert
strings to integers and always check results of the conversions.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230725060531.72968-6-dmantipov@yandex.ru
11 months agowifi: libertas: handle possible spu_write_u16() errors
Dmitry Antipov [Tue, 25 Jul 2023 06:04:47 +0000 (09:04 +0300)]
wifi: libertas: handle possible spu_write_u16() errors

Check and handle (well, report at least, as it's done through the rest
of the module) possible 'spu_write_u16()' errors in 'if_spi_e2h()'.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230725060531.72968-5-dmantipov@yandex.ru
11 months agowifi: libertas: cleanup SDIO reset
Dmitry Antipov [Tue, 25 Jul 2023 06:04:46 +0000 (09:04 +0300)]
wifi: libertas: cleanup SDIO reset

Embed SDIO reset worker in 'struct if_sdio_card' and so
drop 'reset_host' and 'card_reset_work' static variables,
adjust related code. Not sure whether it's possible to do
something useful on 'mmc_add_host()' error, so just add
'dev_err()' to emit an error message.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230725060531.72968-4-dmantipov@yandex.ru
11 months agowifi: libertas: simplify list operations in free_if_spi_card()
Dmitry Antipov [Tue, 25 Jul 2023 06:04:45 +0000 (09:04 +0300)]
wifi: libertas: simplify list operations in free_if_spi_card()

Use 'list_for_each_entry_safe()' to simplify
list operations in 'free_if_spi_card()'.

Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230725060531.72968-3-dmantipov@yandex.ru
11 months agowifi: libertas: use convenient lists to manage SDIO packets
Dmitry Antipov [Tue, 25 Jul 2023 06:04:44 +0000 (09:04 +0300)]
wifi: libertas: use convenient lists to manage SDIO packets

Use convenient lists to manage SDIO packets, adjust
'struct if_sdio_packet', 'struct if_sdio_card' and
related code accordingly.

Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230725060531.72968-2-dmantipov@yandex.ru
11 months agowifi: libertas: add missing calls to cancel_work_sync()
Dmitry Antipov [Tue, 25 Jul 2023 06:04:43 +0000 (09:04 +0300)]
wifi: libertas: add missing calls to cancel_work_sync()

Add missing 'cancel_work_sync()' in 'if_sdio_remove()'
and on error handling path in 'if_sdio_probe()'.

Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
Tested-by: Dan Williams <dcbw@redhat.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230725060531.72968-1-dmantipov@yandex.ru
11 months agowifi: drivers: Explicitly include correct DT includes
Rob Herring [Mon, 24 Jul 2023 21:19:13 +0000 (15:19 -0600)]
wifi: drivers: Explicitly include correct DT includes

The DT of_device.h and of_platform.h date back to the separate
of_platform_bus_type before it as merged into the regular platform bus.
As part of that merge prepping Arm DT support 13 years ago, they
"temporarily" include each other. They also include platform_device.h
and of.h. As a result, there's a pretty much random mix of those include
files used throughout the tree. In order to detangle these headers and
replace the implicit includes with struct declarations, users need to
explicitly include the correct includes.

Signed-off-by: Rob Herring <robh@kernel.org>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230724211914.805876-1-robh@kernel.org
11 months agowifi: wilc1000: add SPI commands retry mechanism
Amisha Patel [Mon, 24 Jul 2023 16:40:00 +0000 (16:40 +0000)]
wifi: wilc1000: add SPI commands retry mechanism

In some situations like, chip wake-up with powersave enabled, SPI
commands are failing temporarily. Reissuing commands after reset helps
to overcome the failure. So, add the retry limit and reset command
sequence API for read/write SPI commands.

Signed-off-by: Amisha Patel <amisha.patel@microchip.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230724163955.4583-1-amisha.patel@microchip.com
11 months agowifi: mwifiex: Fix OOB and integer underflow when rx packets
Polaris Pi [Sun, 23 Jul 2023 07:07:41 +0000 (07:07 +0000)]
wifi: mwifiex: Fix OOB and integer underflow when rx packets

Make sure mwifiex_process_mgmt_packet,
mwifiex_process_sta_rx_packet and mwifiex_process_uap_rx_packet,
mwifiex_uap_queue_bridged_pkt and mwifiex_process_rx_packet
not out-of-bounds access the skb->data buffer.

Fixes: 2dbaf751b1de ("mwifiex: report received management frames to cfg80211")
Signed-off-by: Polaris Pi <pinkperfect2021@gmail.com>
Reviewed-by: Matthew Wang <matthewmwang@chromium.org>
Reviewed-by: Brian Norris <briannorris@chromium.org>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230723070741.1544662-1-pinkperfect2021@gmail.com
11 months agowifi: wilc1000: remove use of has_thrpt_enh3 flag
Prasurjya Rohan Saikia [Mon, 10 Jul 2023 09:44:03 +0000 (09:44 +0000)]
wifi: wilc1000: remove use of has_thrpt_enh3 flag

The 'enhance throughput flow' algorithm is used by default. So older
sections of the code are removed so as to always use this new algorithm.

Signed-off-by: Prasurjya Rohan Saikia <prasurjya.rohansaikia@microchip.com>
Acked-by: Ajay Kathat <ajay.kathat@microchip.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230710094401.235222-1-prasurjya.rohansaikia@microchip.com
11 months agowifi: rtw89: get data rate mode/NSS/MCS v1 from RX descriptor
Ping-Ke Shih [Fri, 28 Jul 2023 07:02:52 +0000 (15:02 +0800)]
wifi: rtw89: get data rate mode/NSS/MCS v1 from RX descriptor

The data rate from RX descriptor also uses hardware rate v1 for WiFi 7
chips. The rate code contains three parts -- mode, NSS and MCS. For
CCK/OFDM/HT rates, NSS/MCS parts are the same as before. VHT/HE/EHT rates
are changed and listed as below:

     mode    NSS    MCS
V0   [8:7]   [6:4]  [3:0]
V1   [10:8]  [7:5]  [4:0]

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230728070252.66525-11-pkshih@realtek.com
11 months agowifi: rtw89: add to display hardware rates v1 histogram in debugfs
Ping-Ke Shih [Fri, 28 Jul 2023 07:02:51 +0000 (15:02 +0800)]
wifi: rtw89: add to display hardware rates v1 histogram in debugfs

The upcoming WiFi 7 chips support EHT rates, and hardware rate codes are
changed too, so modify to adapt the changes. (EHT counters are still zeros
in below example)

RX count:
   Legacy: [0, 0, 0, 0]
     OFDM: [0, 0, 0, 0, 0, 0, 0, 0]
     HT 0: [0, 0, 0, 0, 0, 0, 0, 0]
     HT 1: [0, 0, 0, 0, 0, 0, 0, 0]
  VHT 1SS: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0][0, 0]
  VHT 2SS: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0][0, 0]
   HE 1SS: [0, 0, 42, 0, 43, 90, 75, 0, 26, 20, 260, 7]
   HE 2SS: [0, 96, 232, 84, 125, 184, 52, 0, 0, 0, 0, 0]
  EHT 1SS: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0][0, 0]
  EHT 2SS: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230728070252.66525-10-pkshih@realtek.com
11 months agowifi: rtw89: add C2H RA event V1 to support WiFi 7 chips
Ping-Ke Shih [Fri, 28 Jul 2023 07:02:50 +0000 (15:02 +0800)]
wifi: rtw89: add C2H RA event V1 to support WiFi 7 chips

WiFi 7 chips have more rate mode (EHT), higher MCS and more bandwidth, so
define and use reserved bits to carry these information in C2H events.
Also, the SS/MCS encoded bits of VHT and HE are changed, so define V1 masks
for them.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230728070252.66525-9-pkshih@realtek.com
11 months agowifi: rtw89: use struct to access RA report
Ping-Ke Shih [Fri, 28 Jul 2023 07:02:49 +0000 (15:02 +0800)]
wifi: rtw89: use struct to access RA report

RA (rate adaptive), a mechanism to select proper rate, is implemented in
firmware, and this report is used to tell driver TX rate it is currently
using. Use struct to access this report, and doesn't change logic at all.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230728070252.66525-8-pkshih@realtek.com
11 months agowifi: rtw89: use struct to access firmware C2H event header
Ping-Ke Shih [Fri, 28 Jul 2023 07:02:48 +0000 (15:02 +0800)]
wifi: rtw89: use struct to access firmware C2H event header

Firmware C2H events contain two-word header which can indicate category,
class, function and length of received events. Use struct to access them,
and doesn't change logic at all.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230728070252.66525-7-pkshih@realtek.com
11 months agowifi: rtw89: add H2C RA command V1 to support WiFi 7 chips
Ping-Ke Shih [Fri, 28 Jul 2023 07:02:47 +0000 (15:02 +0800)]
wifi: rtw89: add H2C RA command V1 to support WiFi 7 chips

H2C RA V1 command adds two words to support WiFi 7 chips, which can
possibly support up to 4SS rates. Because current chips have only 2SS
rates, leave the fields blank for now. The main changes are to set
extended bits of EHT mode and bandwidth -- add a bit for EHT mode; add a
bit to enumerate 320MHz channel bandwidth.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230728070252.66525-6-pkshih@realtek.com
11 months agowifi: rtw89: use struct to set RA H2C command
Ping-Ke Shih [Fri, 28 Jul 2023 07:02:46 +0000 (15:02 +0800)]
wifi: rtw89: use struct to set RA H2C command

RA (rate adaptive) H2C command is used to tell firmware which rates can
be used for specified MAC ID. Basically, this commit doesn't change result.
Only change to set two 32-bit instead of continual 8-byte rate masks one
by one. Originally, we only set 5-byte masks, because existing WiFi 6
2SS chips only need 5-byte masks. Setting two 32-bit masks will be more
efficient and also can support coming WiFi 7 2SS chips containing more
rates.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230728070252.66525-5-pkshih@realtek.com
11 months agowifi: rtw89: phy: rate pattern handles HW rate by chip gen
Zong-Zhe Yang [Fri, 28 Jul 2023 07:02:45 +0000 (15:02 +0800)]
wifi: rtw89: phy: rate pattern handles HW rate by chip gen

Rate pattern is controlled by 'iw bitrates' to fix rate as desired, and
we extend to support v1 rate.

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/20230728070252.66525-4-pkshih@realtek.com
11 months agowifi: rtw89: define hardware rate v1 for WiFi 7 chips
Ping-Ke Shih [Fri, 28 Jul 2023 07:02:44 +0000 (15:02 +0800)]
wifi: rtw89: define hardware rate v1 for WiFi 7 chips

To support EHT rate, hardware rate v1 is introduced. The CCK and OFDM rates
are persistent. HT/VHT/HE rates use different rate code from original, and
add new code for EHT rates.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230728070252.66525-3-pkshih@realtek.com
11 months agowifi: rtw89: add chip_info::chip_gen to determine chip generation
Ping-Ke Shih [Fri, 28 Jul 2023 07:02:43 +0000 (15:02 +0800)]
wifi: rtw89: add chip_info::chip_gen to determine chip generation

The coming WiFi 7 chip is 8922AE which uses different hardware rate and
register naming rule. Adding a chip_info::chip_gen field can help to
do things by generations accordingly.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230728070252.66525-2-pkshih@realtek.com
11 months agowifi: rtw89: Fix loading of compressed firmware
Larry Finger [Mon, 24 Jul 2023 18:39:27 +0000 (13:39 -0500)]
wifi: rtw89: Fix loading of compressed firmware

When using compressed firmware, the early firmware load feature will fail.
In most cases, the only downside is that if a device has more than one
firmware version available, only the last one listed will be loaded.
In at least two cases, there is no firmware loaded, and the device fails
initialization. See https://github.com/lwfinger/rtw89/issues/259 and
https://bugzilla.opensuse.org/show_bug.cgi?id=1212808 for examples of
the failure.

When firmware_class.dyndbg=+p" added to the kernel boot parameters, the
following is found:

finger@localhost:~/rtw89>sudo dmesg -t | grep rtw89
firmware_class: __allocate_fw_priv: fw-rtw89/rtw8852b_fw-1.bin fw_priv=00000000638862fb
rtw89_8852be 0000:02:00.0: loading /lib/firmware/updates/5.14.21-150500.53-default/rtw89/rtw8852b_fw-1.bin failed for no such file or directory.
rtw89_8852be 0000:02:00.0: loading /lib/firmware/updates/rtw89/rtw8852b_fw-1.bin failed for no such file or directory.
rtw89_8852be 0000:02:00.0: loading /lib/firmware/5.14.21-150500.53-default/rtw89/rtw8852b_fw-1.bin failed for no such file or directory.
rtw89_8852be 0000:02:00.0: loading /lib/firmware/rtw89/rtw8852b_fw-1.bin failed for no such file or directory.
rtw89_8852be 0000:02:00.0: Direct firmware load for rtw89/rtw8852b_fw-1.bin failed with error -2
firmware_class: __free_fw_priv: fw-rtw89/rtw8852b_fw-1.bin fw_priv=00000000638862fb data=00000000307c30c7 size=0
firmware_class: __allocate_fw_priv: fw-rtw89/rtw8852b_fw.bin fw_priv=00000000638862fb
rtw89_8852be 0000:02:00.0: loading /lib/firmware/updates/5.14.21-150500.53-default/rtw89/rtw8852b_fw.bin failed for no such file or directory.
rtw89_8852be 0000:02:00.0: loading /lib/firmware/updates/rtw89/rtw8852b_fw.bin failed for no such file or directory.
rtw89_8852be 0000:02:00.0: loading /lib/firmware/5.14.21-150500.53-default/rtw89/rtw8852b_fw.bin failed for no such file or directory.
rtw89_8852be 0000:02:00.0: loading /lib/firmware/rtw89/rtw8852b_fw.bin failed for no such file or directory.
rtw89_8852be 0000:02:00.0: Direct firmware load for rtw89/rtw8852b_fw.bin failed with error -2
firmware_class: __free_fw_priv: fw-rtw89/rtw8852b_fw.bin fw_priv=00000000638862fb data=00000000307c30c7 size=0
rtw89_8852be 0000:02:00.0: failed to early request firmware: -2
firmware_class: __allocate_fw_priv: fw-rtw89/rtw8852b_fw.bin fw_priv=00000000638862fb
rtw89_8852be 0000:02:00.0: loading /lib/firmware/updates/5.14.21-150500.53-default/rtw89/rtw8852b_fw.bin failed for no such file or directory.
rtw89_8852be 0000:02:00.0: loading /lib/firmware/updates/rtw89/rtw8852b_fw.bin failed for no such file or directory.
rtw89_8852be 0000:02:00.0: loading /lib/firmware/5.14.21-150500.53-default/rtw89/rtw8852b_fw.bin failed for no such file or directory.
rtw89_8852be 0000:02:00.0: loading /lib/firmware/rtw89/rtw8852b_fw.bin failed for no such file or directory.
rtw89_8852be 0000:02:00.0: loading /lib/firmware/updates/5.14.21-150500.53-default/rtw89/rtw8852b_fw.bin.xz failed for no such file or directory.
rtw89_8852be 0000:02:00.0: loading /lib/firmware/updates/rtw89/rtw8852b_fw.bin.xz failed for no such file or directory.
rtw89_8852be 0000:02:00.0: loading /lib/firmware/5.14.21-150500.53-default/rtw89/rtw8852b_fw.bin.xz failed for no such file or directory.
rtw89_8852be 0000:02:00.0: Loading firmware from /lib/firmware/rtw89/rtw8852b_fw.bin.xz
rtw89_8852be 0000:02:00.0: f/w decompressing rtw89/rtw8852b_fw.bin
firmware_class: fw_set_page_data: fw-rtw89/rtw8852b_fw.bin fw_priv=00000000638862fb data=000000004ed6c2f7 size=1035232
rtw89_8852be 0000:02:00.0: Firmware version 0.27.32.1, cmd version 0, type 1
rtw89_8852be 0000:02:00.0: Firmware version 0.27.32.1, cmd version 0, type 3

The key is that firmware version 0.27.32.1 is loaded.

With this patch, the following is obtained:

firmware_class: __free_fw_priv: fw-rtw89/rtw8852b_fw.bin fw_priv=000000000849addc data=00000000fd3cabe2 size=1035232
firmware_class: fw_name_devm_release: fw_name-rtw89/rtw8852b_fw.bin devm-000000002d8c3343 released
firmware_class: __allocate_fw_priv: fw-rtw89/rtw8852b_fw-1.bin fw_priv=000000009e1a6364
rtw89_8852be 0000:02:00.0: loading /lib/firmware/updates/6.4.3-1-default/rtw89/rtw8852b_fw-1.bin failed for no such file or directory.
rtw89_8852be 0000:02:00.0: loading /lib/firmware/updates/rtw89/rtw8852b_fw-1.bin failed for no such file or directory.
rtw89_8852be 0000:02:00.0: loading /lib/firmware/6.4.3-1-default/rtw89/rtw8852b_fw-1.bin failed for no such file or directory.
rtw89_8852be 0000:02:00.0: loading /lib/firmware/rtw89/rtw8852b_fw-1.bin failed for no such file or directory.
rtw89_8852be 0000:02:00.0: loading /lib/firmware/updates/6.4.3-1-default/rtw89/rtw8852b_fw-1.bin.zst failed for no such file or directory.
rtw89_8852be 0000:02:00.0: loading /lib/firmware/updates/rtw89/rtw8852b_fw-1.bin.zst failed for no such file or directory.
rtw89_8852be 0000:02:00.0: loading /lib/firmware/6.4.3-1-default/rtw89/rtw8852b_fw-1.bin.zst failed for no such file or directory.
rtw89_8852be 0000:02:00.0: loading /lib/firmware/rtw89/rtw8852b_fw-1.bin.zst failed for no such file or directory.
rtw89_8852be 0000:02:00.0: loading /lib/firmware/updates/6.4.3-1-default/rtw89/rtw8852b_fw-1.bin.xz failed for no such file or directory.
rtw89_8852be 0000:02:00.0: loading /lib/firmware/updates/rtw89/rtw8852b_fw-1.bin.xz failed for no such file or directory.
rtw89_8852be 0000:02:00.0: loading /lib/firmware/6.4.3-1-default/rtw89/rtw8852b_fw-1.bin.xz failed for no such file or directory.
rtw89_8852be 0000:02:00.0: Loading firmware from /lib/firmware/rtw89/rtw8852b_fw-1.bin.xz
rtw89_8852be 0000:02:00.0: f/w decompressing rtw89/rtw8852b_fw-1.bin
firmware_class: fw_set_page_data: fw-rtw89/rtw8852b_fw-1.bin fw_priv=000000009e1a6364 data=00000000fd3cabe2 size=1184992
rtw89_8852be 0000:02:00.0: Loaded FW: rtw89/rtw8852b_fw-1.bin, sha256: 8539efc75f513f4585cf0cd6e79e6507da47fce87225f2d0de391a03aefe9ac8
rtw89_8852be 0000:02:00.0: loaded firmware rtw89/rtw8852b_fw-1.bin
rtw89_8852be 0000:02:00.0: Firmware version 0.29.29.1, cmd version 0, type 5
rtw89_8852be 0000:02:00.0: Firmware version 0.29.29.1, cmd version 0, type 3

Now, version 0.29.29.1 is loaded.

Fixes: ffde7f3476a6 ("wifi: rtw89: add firmware format version to backward compatible with older drivers")
Cc: Ping-Ke Shih <pkshih@realtek.com>
Cc: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230724183927.28553-1-Larry.Finger@lwfinger.net
11 months agowifi: mt76: mt7915: fix power-limits while chan_switch
Ryder Lee [Wed, 26 Jul 2023 18:35:06 +0000 (02:35 +0800)]
wifi: mt76: mt7915: fix power-limits while chan_switch

If user changes the channel without completely disabling the interface the
txpower_sku values reported track the old channel the device was operating on.
If user bounces the interface the correct power tables are applied.

mt7915_sku_group_len array gets updated before the channel switch happens so it
uses data from the old channel.

Fixes: ecb187a74e18 ("mt76: mt7915: rework the flow of txpower setting")
Fixes: f1d962369d56 ("mt76: mt7915: implement HE per-rate tx power support")
Reported-By: Chad Monroe <chad.monroe@smartrg.com>
Tested-by: Chad Monroe <chad.monroe@smartrg.com>
Signed-off-by: Allen Ye <allen.ye@mediatek.com>
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
11 months agowifi: mt76: mt7915: fix tlv length of mt7915_mcu_get_chan_mib_info
Ryder Lee [Wed, 26 Jul 2023 18:35:05 +0000 (02:35 +0800)]
wifi: mt76: mt7915: fix tlv length of mt7915_mcu_get_chan_mib_info

Correct per-device TLV lengths to avoid invalid operation in firmware.
(  64.040375:28:STATS-E)statsGetSingleHWCounter: MIB counter index = 65472 not supported.
This happens on mt7916/mt7986.

Fixes: b0bfa00595be ("wifi: mt76: mt7915: improve accuracy of time_busy calculation")
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
11 months agowifi: mt76: mt76x02: fix return value check in mt76x02_mac_process_rx
Yuanjun Gong [Mon, 17 Jul 2023 14:50:08 +0000 (22:50 +0800)]
wifi: mt76: mt76x02: fix return value check in mt76x02_mac_process_rx

in mt76x02_mac_process_rx(), return an error code if an
unexpected result is returned by pskb_trim.

Signed-off-by: Yuanjun Gong <ruc_gongyuanjun@163.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>
11 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>