linux-2.6-microblaze.git
2 years agomt76: mt7915: add support for passing chip/firmware debug data to user space
Felix Fietkau [Sun, 26 Dec 2021 21:18:32 +0000 (22:18 +0100)]
mt76: mt7915: add support for passing chip/firmware debug data to user space

This can be used to assist in debugging driver or firmware tx/rx issues.
The data is streamed to user space using a relay file in debugfs

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7615e: process txfree and txstatus without allocating skbs
Lorenzo Bianconi [Tue, 28 Dec 2021 14:33:57 +0000 (15:33 +0100)]
mt76: mt7615e: process txfree and txstatus without allocating skbs

Similar to mt7915 driver, process txfree and txstatus without allocating
skbs in order to reduce pressure on the memory allocator

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7915: update bss_info with cipher after setting the group key
Felix Fietkau [Wed, 29 Dec 2021 11:21:46 +0000 (12:21 +0100)]
mt76: mt7915: update bss_info with cipher after setting the group key

In some cases, the WA firmware needs to know if encryption is used, in order
to set the protection bit of packets

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7615: update bss_info with cipher after setting the group key
Felix Fietkau [Wed, 29 Dec 2021 11:21:00 +0000 (12:21 +0100)]
mt76: mt7615: update bss_info with cipher after setting the group key

In some cases, the WA firmware needs to know if encryption is used, in order
to set the protection bit of packets

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: connac: add support for passing the cipher field in bss_info
Felix Fietkau [Wed, 29 Dec 2021 11:19:37 +0000 (12:19 +0100)]
mt76: connac: add support for passing the cipher field in bss_info

Initialize it from a field in struct mt76_vif

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7921e: process txfree and txstatus without allocating skbs
Lorenzo Bianconi [Tue, 28 Dec 2021 12:01:19 +0000 (13:01 +0100)]
mt76: mt7921e: process txfree and txstatus without allocating skbs

Similar to mt7915 driver, process txfree and txstatus without allocating
skbs in order to reduce pressure on the memory allocator

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7615: fix a possible race enabling/disabling runtime-pm
Lorenzo Bianconi [Mon, 27 Dec 2021 13:08:52 +0000 (14:08 +0100)]
mt76: mt7615: fix a possible race enabling/disabling runtime-pm

Similar to mt7921 driver, fix a possible race enabling/disabling
runtime-pm between mt7615_pm_set() and mt7615_poll_rx().
mt7615_pm_wake_work() always schedules rx-napi callback and it will
trigger mt7615_pm_power_save_work routine putting the chip in low-power
state even if we are disabling runtime-pm deferring the actual chip wake
at the next access.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7921: set EDCA parameters with the MCU CE command
Sean Wang [Fri, 24 Dec 2021 08:33:56 +0000 (16:33 +0800)]
mt76: mt7921: set EDCA parameters with the MCU CE command

The command MCU_EXT_CMD_EDCA_UPDATE is not fully supported by the MT7921
firmware, so we apply CE command MCU_CE_CMD_SET_EDCA_PARAMS instead which
is supported even in the oldest firmware to properly set up EDCA parameters
for each AC.

Fixes: 1c099ab44727 ("mt76: mt7921: add MCU support")
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt76_connac: fix MCU_CE_CMD_SET_ROC definition error
Sean Wang [Fri, 24 Dec 2021 08:33:55 +0000 (16:33 +0800)]
mt76: mt76_connac: fix MCU_CE_CMD_SET_ROC definition error

Fixed an MCU_CE_CMD_SET_ROC definition error that occurred from a previous
refactor work.

Fixes: d0e274af2f2e4 ("mt76: mt76_connac: create mcu library")
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7921: forbid the doze mode when coredump is in progress
YN Chen [Fri, 24 Dec 2021 08:32:49 +0000 (16:32 +0800)]
mt76: mt7921: forbid the doze mode when coredump is in progress

We forbid the doze mode while the collecting core dump is going because
that doesn't make sense and the firmware possibly stays in the abnormal
state where cannot handle the doze request from the driver anymore until
the WiFi reset procedure is completed.

Co-developed-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: YN Chen <YN.Chen@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7921e: make dev->fw_assert usage consistent
Sean Wang [Fri, 24 Dec 2021 08:32:48 +0000 (16:32 +0800)]
mt76: mt7921e: make dev->fw_assert usage consistent

Clear dev->fw_assert flag in mt7921s to be consistent with mt7921s driver.

Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: connac: move mt76_connac_mcu_rdd_cmd in mt76-connac module
Lorenzo Bianconi [Fri, 24 Dec 2021 10:58:11 +0000 (11:58 +0100)]
mt76: connac: move mt76_connac_mcu_rdd_cmd in mt76-connac module

Move mt76_connac_mcu_rdd_cmd routine in mt76-connac module and remove
duplicated code.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7915: rely on mt76_connac_mcu_set_rts_thresh
Lorenzo Bianconi [Fri, 24 Dec 2021 10:58:10 +0000 (11:58 +0100)]
mt76: mt7915: rely on mt76_connac_mcu_set_rts_thresh

Rely on mt76_connac_mcu_set_rts_thresh routine in mt7915 driver and
remove duplicated code.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: connac: move mt76_connac_mcu_gen_dl_mode in mt76-connac module
Lorenzo Bianconi [Fri, 24 Dec 2021 10:58:09 +0000 (11:58 +0100)]
mt76: connac: move mt76_connac_mcu_gen_dl_mode in mt76-connac module

Move mt76_connac_mcu_gen_dl_mode utility routine in mt76_connac_mcu.h
since it is shared by all drivers.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7915: rely on mt76_connac_mcu_init_download
Lorenzo Bianconi [Fri, 24 Dec 2021 10:58:08 +0000 (11:58 +0100)]
mt76: mt7915: rely on mt76_connac_mcu_init_download

Rely on mt76_connac_mcu_init_download routine in mt7915 driver and
remove duplicated code.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7915: rely on mt76_connac_mcu_patch_sem_ctrl/mt76_connac_mcu_start_patch
Lorenzo Bianconi [Fri, 24 Dec 2021 10:58:07 +0000 (11:58 +0100)]
mt76: mt7915: rely on mt76_connac_mcu_patch_sem_ctrl/mt76_connac_mcu_start_patch

Rely on mt76_connac_mcu_patch_sem_ctrl/mt76_connac_mcu_start_patch
routine in mt7915 driver and remove duplicated code.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: connac: move mt76_connac_mcu_restart in common module
Lorenzo Bianconi [Fri, 24 Dec 2021 10:58:06 +0000 (11:58 +0100)]
mt76: connac: move mt76_connac_mcu_restart in common module

Move mt76_connac_mcu_restart routine in mt76-connac since it is shared
between mt7921 and mt7915.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7915: rely on mt76_connac_mcu_start_firmware
Lorenzo Bianconi [Fri, 24 Dec 2021 10:58:05 +0000 (11:58 +0100)]
mt76: mt7915: rely on mt76_connac_mcu_start_firmware

Rely on mt76_connac_mcu_start_firmware and remove duplicated code.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7921: get rid of mt7921_mcu_get_eeprom
Lorenzo Bianconi [Fri, 24 Dec 2021 10:58:04 +0000 (11:58 +0100)]
mt76: mt7921: get rid of mt7921_mcu_get_eeprom

Remove mt7921_mcu_get_eeprom since it is no longer used.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: connac: move mt76_connac_mcu_set_pm in connac module
Lorenzo Bianconi [Fri, 24 Dec 2021 10:58:03 +0000 (11:58 +0100)]
mt76: connac: move mt76_connac_mcu_set_pm in connac module

Move mt76_connac_mcu_set_pm utility routine in connac module since it is
shared between mt7615 and mt7915 drivers.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: connac: introduce is_connac_v1 utility routine
Lorenzo Bianconi [Fri, 24 Dec 2021 10:58:02 +0000 (11:58 +0100)]
mt76: connac: introduce is_connac_v1 utility routine

Introduce is_connac_v1 inline utility routine to check if the device is
generation v1.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: connac: move mt76_connac_mcu_wtbl_update_hdr_trans in connac module
Lorenzo Bianconi [Thu, 23 Dec 2021 12:07:42 +0000 (13:07 +0100)]
mt76: connac: move mt76_connac_mcu_wtbl_update_hdr_trans in connac module

Move mt76_connac_mcu_wtbl_update_hdr_trans routine in mt76-connac module
since it is shared between mt7915 and mt7615 drivers.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7915: rely on mt76_connac_mcu_wtbl_hdr_trans_tlv
Lorenzo Bianconi [Thu, 23 Dec 2021 12:07:41 +0000 (13:07 +0100)]
mt76: mt7915: rely on mt76_connac_mcu_wtbl_hdr_trans_tlv

Rely on mt76_connac_mcu_wtbl_hdr_trans_tlv routine and
remove duplicated code.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7915: rely on mt76_connac_mcu_wtbl_ht_tlv
Lorenzo Bianconi [Thu, 23 Dec 2021 12:07:40 +0000 (13:07 +0100)]
mt76: mt7915: rely on mt76_connac_mcu_wtbl_ht_tlv

Rely on mt76_connac_mcu_wtbl_ht_tlv routine and
remove duplicated code.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7915: rely on mt76_connac_mcu_wtbl_smps_tlv
Lorenzo Bianconi [Thu, 23 Dec 2021 12:07:39 +0000 (13:07 +0100)]
mt76: mt7915: rely on mt76_connac_mcu_wtbl_smps_tlv

Rely on mt76_connac_mcu_wtbl_smps_tlv routine in mt7915
and remove duplicated code.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7915: rely on mt76_connac_mcu_sta_uapsd
Lorenzo Bianconi [Thu, 23 Dec 2021 12:07:38 +0000 (13:07 +0100)]
mt76: mt7915: rely on mt76_connac_mcu_sta_uapsd

Rely on mt76_connac_mcu_sta_uapsd routine in mt7915 and remove
duplicated code.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7915: rely on mt76_connac_mcu_sta_basic_tlv
Lorenzo Bianconi [Thu, 23 Dec 2021 12:07:37 +0000 (13:07 +0100)]
mt76: mt7915: rely on mt76_connac_mcu_sta_basic_tlv

Rely on mt76_connac_mcu_sta_basic_tlv routine in mt7915 and remove
duplicated code.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7915: rely on mt76_connac_mcu_wtbl_generic_tlv
Lorenzo Bianconi [Thu, 23 Dec 2021 12:07:36 +0000 (13:07 +0100)]
mt76: mt7915: rely on mt76_connac_mcu_wtbl_generic_tlv

Rely on mt76_connac_mcu_wtbl_generic_tlv routine in mt7915 and remove
duplicated code.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7915: rely on mt76_connac_mcu_sta_ba
Lorenzo Bianconi [Thu, 23 Dec 2021 12:07:35 +0000 (13:07 +0100)]
mt76: mt7915: rely on mt76_connac_mcu_sta_ba

Rely on mt76_connac_mcu_sta_ba routine in mt7915 and remove duplicated
code.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7915: rely on mt76_connac_mcu_wtbl_ba_tlv
Lorenzo Bianconi [Thu, 23 Dec 2021 12:07:34 +0000 (13:07 +0100)]
mt76: mt7915: rely on mt76_connac_mcu_wtbl_ba_tlv

Rely on mt76_connac_mcu_wtbl_ba_tlv routine in mt7915 and remove
duplicated code.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7915: rely on mt76_connac_mcu_sta_ba_tlv
Lorenzo Bianconi [Thu, 23 Dec 2021 12:07:33 +0000 (13:07 +0100)]
mt76: mt7915: rely on mt76_connac_mcu_sta_ba_tlv

Rely on mt76_connac_mcu_sta_ba_tlv routine in mt7915 and remove
duplicated code.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: connac: move mt76_connac_mcu_bss_basic_tlv in connac module
Lorenzo Bianconi [Thu, 23 Dec 2021 12:07:32 +0000 (13:07 +0100)]
mt76: connac: move mt76_connac_mcu_bss_basic_tlv in connac module

Move mt7615_mcu_bss_basic_tlv/mt7915_mcu_bss_basic_tlv in connac
module since it is shared between mt7615 and mt7915 drivers.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: connac: move mt76_connac_mcu_bss_ext_tlv in connac module
Lorenzo Bianconi [Thu, 23 Dec 2021 12:07:31 +0000 (13:07 +0100)]
mt76: connac: move mt76_connac_mcu_bss_ext_tlv in connac module

Move mt7915_mcu_bss_ext_tlv/mt7615_mcu_bss_ext_tlv in connac module
since it is shared between mt7615 and mt7915 drivers.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: connac: move mt76_connac_mcu_bss_omac_tlv in connac module
Lorenzo Bianconi [Thu, 23 Dec 2021 12:07:30 +0000 (13:07 +0100)]
mt76: connac: move mt76_connac_mcu_bss_omac_tlv in connac module

Move mt7915_mcu_bss_omac_tlv/mt7615_mcu_bss_omac_tlv in connac module
since it is shared between mt7615 and mt7915 drivers.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7915: remove duplicated defs in mcu.h
Lorenzo Bianconi [Thu, 23 Dec 2021 12:07:29 +0000 (13:07 +0100)]
mt76: mt7915: remove duplicated defs in mcu.h

Remove duplicated definitions in mt7915/mcu.h

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7915: move pci specific code back to pci.c
Felix Fietkau [Wed, 22 Dec 2021 22:00:47 +0000 (23:00 +0100)]
mt76: mt7915: move pci specific code back to pci.c

This avoids the need to check for the device type in mmio.c and makes the code
cleaner

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7921s: update mt7921s_wfsys_reset sequence
YN Chen [Wed, 22 Dec 2021 05:58:18 +0000 (13:58 +0800)]
mt76: mt7921s: update mt7921s_wfsys_reset sequence

MT7921S firmware expects driver to clear out the firmware download state
before FW is downloaded again in WiFi reset procedure.

Co-developed-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: YN Chen <YN.Chen@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7921s: clear MT76_STATE_MCU_RUNNING immediately after reset
Sean Wang [Wed, 22 Dec 2021 05:58:17 +0000 (13:58 +0800)]
mt76: mt7921s: clear MT76_STATE_MCU_RUNNING immediately after reset

clear the flag MT76_STATE_MCU_RUNNING immediately after reset to indicate
the MCU has already stopped working at the point. That is a preliminary
patch for the following patch to perform the register access in the
remaining reset handler using SDIO mailbox way instead of MCU command
because the RAM firmware is cleared out.

Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: sdio: lock sdio when it is needed
Sean Wang [Wed, 22 Dec 2021 05:56:28 +0000 (13:56 +0800)]
mt76: sdio: lock sdio when it is needed

Acquire the SDIO as needed as possible because either MT7663S or MT7921S
is a multiple-function device that always includes Bluetooth that would
share with the same SDIO bus. So not to avoid breaking Bluetooth pairing,
audio, and HID such kind of time critical application on that, we only
lock sdio bus when it is necessary in WiFi driver.

Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7915: use proper aid value in mt7915_mcu_sta_basic_tlv
Lorenzo Bianconi [Wed, 22 Dec 2021 16:06:36 +0000 (17:06 +0100)]
mt76: mt7915: use proper aid value in mt7915_mcu_sta_basic_tlv

Similar to mt7915_mcu_wtbl_generic_tlv, rely on vif->bss_conf.aid for
aid in sta mode and not on sta->aid.

Fixes: e57b7901469fc ("mt76: add mac80211 driver for MT7915 PCIe-based chipsets")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7915: use proper aid value in mt7915_mcu_wtbl_generic_tlv in sta mode
Lorenzo Bianconi [Wed, 22 Dec 2021 11:52:17 +0000 (12:52 +0100)]
mt76: mt7915: use proper aid value in mt7915_mcu_wtbl_generic_tlv in sta mode

mac80211 provides aid in vif->bss_conf.aid for sta mode and not in
sta->aid. Fix mt7915_mcu_wtbl_generic_tlv routine using proper value for
aid in sta mode.

Fixes: e57b7901469fc ("mt76: add mac80211 driver for MT7915 PCIe-based chipsets")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: make mt76_sar_capa static
Lorenzo Bianconi [Tue, 21 Dec 2021 08:25:57 +0000 (09:25 +0100)]
mt76: make mt76_sar_capa static

Fix the following sparse warning:
drivers/net/wireless/mediatek/mt76/mac80211.c:183:32:
warning: symbol 'mt76_sar_capa' was not declared. Should it be static?

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7915: add device id for mt7916
Bo Jiao [Mon, 20 Dec 2021 02:18:04 +0000 (10:18 +0800)]
mt76: mt7915: add device id for mt7916

Add pci_device_id to enable mt7916. Note that MT_HW_CHIPID is no
longer used for further chips, so drop it accordingly.

Co-developed-by: Sujuan Chen <sujuan.chen@mediatek.com>
Signed-off-by: Sujuan Chen <sujuan.chen@mediatek.com>
Co-developed-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Bo Jiao <Bo.Jiao@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: set wlan_idx_hi on mt7916
Bo Jiao [Wed, 22 Dec 2021 12:29:16 +0000 (20:29 +0800)]
mt76: set wlan_idx_hi on mt7916

Since mt7916 supports up to 544 wcid entries, wlan_idx_hi needs to be set
in order to support wcid index >= 256

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Bo Jiao <Bo.Jiao@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: connac: move mt76_connac_mcu_add_key in connac module
Lorenzo Bianconi [Sun, 19 Dec 2021 17:40:14 +0000 (18:40 +0100)]
mt76: connac: move mt76_connac_mcu_add_key in connac module

Move key configuration code shared between mt7921 and mt7915 in
mt76-connac module and remove duplicated code.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7915: rely on mt76_connac_get_phy utilities
Lorenzo Bianconi [Sun, 19 Dec 2021 17:40:13 +0000 (18:40 +0100)]
mt76: mt7915: rely on mt76_connac_get_phy utilities

Rely on mt76_connac_get_phy_mode and mt76_connac_get_he_phy_cap utility
routines in mt7915 driver and remove duplicated code.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: connac: move mt76_connac_chan_bw in common code
Lorenzo Bianconi [Sun, 19 Dec 2021 17:40:12 +0000 (18:40 +0100)]
mt76: connac: move mt76_connac_chan_bw in common code

Move mt76_connac_chan_bw in mt76-connac code and remove
duplicated code from mt7921 and mt7915 driver.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: connac: move mt76_connac_mcu_get_cipher in common code
Lorenzo Bianconi [Sun, 19 Dec 2021 17:40:11 +0000 (18:40 +0100)]
mt76: connac: move mt76_connac_mcu_get_cipher in common code

Move mt76_connac_mcu_get_cipher in mt76-connac code and remove
duplicated code from mt7921 and mt7915 driver.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7915: rely on mt76_connac_mcu_add_tlv routine
Lorenzo Bianconi [Sun, 19 Dec 2021 17:40:10 +0000 (18:40 +0100)]
mt76: mt7915: rely on mt76_connac_mcu_add_tlv routine

Rely on common code available in mt76-connac module and remove
mt7915_mcu_add_tlv/mt7915_mcu_add_nested_tlv in mt7915 driver.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7915: rely on mt76_connac_mcu_alloc_wtbl_req
Lorenzo Bianconi [Sun, 19 Dec 2021 17:40:09 +0000 (18:40 +0100)]
mt76: mt7915: rely on mt76_connac_mcu_alloc_wtbl_req

Rely on mt76_connac_mcu_alloc_wtbl_req routine and remove
duplicated code.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7915: rely on mt76_connac_mcu_alloc_sta_req
Lorenzo Bianconi [Sun, 19 Dec 2021 17:40:08 +0000 (18:40 +0100)]
mt76: mt7915: rely on mt76_connac_mcu_alloc_sta_req

Rely on mt76_connac_mcu_alloc_sta_req routine and remove
duplicated code.
Add MT76_CONNAC_LIB module dependency in mt7915 module

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: connac: fix sta_rec_wtbl tag len
Lorenzo Bianconi [Sun, 19 Dec 2021 17:40:06 +0000 (18:40 +0100)]
mt76: connac: fix sta_rec_wtbl tag len

Similar to mt7915 driver, fix tag len error for sta_rec_wtbl, which
causes fw parsing error for the tags placed behind it.

Fixes: d0e274af2f2e4 ("mt76: mt76_connac: create mcu library")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7915: add mt7916 calibrated data support
Bo Jiao [Mon, 20 Dec 2021 02:18:03 +0000 (10:18 +0800)]
mt76: mt7915: add mt7916 calibrated data support

Adjust proper eeprom size and add default calibrated data support
for mt7916.

Co-developed-by: Shayne Chen <shayne.chen@mediatek.com>
Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
Co-developed-by: Sujuan Chen <sujuan.chen@mediatek.com>
Signed-off-by: Sujuan Chen <sujuan.chen@mediatek.com>
Signed-off-by: Bo Jiao <Bo.Jiao@mediatek.com>
Reviewed-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7915: update mt7915_chan_mib_offs for mt7916
Bo Jiao [Mon, 20 Dec 2021 02:18:02 +0000 (10:18 +0800)]
mt76: mt7915: update mt7915_chan_mib_offs for mt7916

Update v2 offset. This is an intermediate patch to add mt7916 support.

Co-developed-by: Sujuan Chen <sujuan.chen@mediatek.com>
Signed-off-by: Sujuan Chen <sujuan.chen@mediatek.com>
Co-developed-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Bo Jiao <Bo.Jiao@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7915: update rx rate reporting for mt7916
Bo Jiao [Mon, 20 Dec 2021 02:18:01 +0000 (10:18 +0800)]
mt76: mt7915: update rx rate reporting for mt7916

mt7916 reports rx rate from rxd group3 directly.

Co-developed-by: Sujuan Chen <sujuan.chen@mediatek.com>
Signed-off-by: Sujuan Chen <sujuan.chen@mediatek.com>
Co-developed-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Bo Jiao <Bo.Jiao@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7915: add txfree event v3
Bo Jiao [Mon, 20 Dec 2021 02:18:00 +0000 (10:18 +0800)]
mt76: mt7915: add txfree event v3

Update txfree v3 format.
This is an intermediate patch to add mt7916 support.

Co-developed-by: Sujuan Chen <sujuan.chen@mediatek.com>
Signed-off-by: Sujuan Chen <sujuan.chen@mediatek.com>
Co-developed-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Bo Jiao <Bo.Jiao@mediatek.com>
Reviewed-by: Shayne Chen <shayne.chen@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7915: enlarge wcid size to 544
Bo Jiao [Mon, 20 Dec 2021 02:17:59 +0000 (10:17 +0800)]
mt76: mt7915: enlarge wcid size to 544

The mt7916 can support up to 544 wcid entries.
This is an intermediate patch to add mt7916 support.

Co-developed-by: Sujuan Chen <sujuan.chen@mediatek.com>
Signed-off-by: Sujuan Chen <sujuan.chen@mediatek.com>
Co-developed-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Bo Jiao <Bo.Jiao@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7915: rework eeprom.c to adapt mt7916 changes
Bo Jiao [Mon, 20 Dec 2021 02:17:58 +0000 (10:17 +0800)]
mt76: mt7915: rework eeprom.c to adapt mt7916 changes

This is an intermediate patch to add mt7916 support.

Co-developed-by: Sujuan Chen <sujuan.chen@mediatek.com>
Signed-off-by: Sujuan Chen <sujuan.chen@mediatek.com>
Co-developed-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Bo Jiao <Bo.Jiao@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7915: add firmware support for mt7916
Bo Jiao [Mon, 20 Dec 2021 02:17:57 +0000 (10:17 +0800)]
mt76: mt7915: add firmware support for mt7916

Update firmware initialization for mt7916.
This is an intermediate patch to add mt7916 support.

Co-developed-by: Sujuan Chen <sujuan.chen@mediatek.com>
Signed-off-by: Sujuan Chen <sujuan.chen@mediatek.com>
Co-developed-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Bo Jiao <Bo.Jiao@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7915: rework dma.c to adapt mt7916 changes
Bo Jiao [Mon, 20 Dec 2021 02:17:56 +0000 (10:17 +0800)]
mt76: mt7915: rework dma.c to adapt mt7916 changes

The RXQ of mt7916 are separated to MT_RXQ_MAIN_WA and MT_RXQ_MCU_WA,
so, add initialization and preftech setting for the queue MT_RXQ_MAIN_WA.

This is an intermediate patch to add mt7916 support.

Co-developed-by: Sujuan Chen <sujuan.chen@mediatek.com>
Signed-off-by: Sujuan Chen <sujuan.chen@mediatek.com>
Co-developed-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Bo Jiao <Bo.Jiao@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: add MT_RXQ_MAIN_WA for mt7916
Bo Jiao [Mon, 20 Dec 2021 02:17:55 +0000 (10:17 +0800)]
mt76: add MT_RXQ_MAIN_WA for mt7916

mt7916 add MT_RXQ_MAIN_WA to receive tx free event separately
This is an intermediate patch to add mt7916 support.

Co-developed-by: Sujuan Chen <sujuan.chen@mediatek.com>
Signed-off-by: Sujuan Chen <sujuan.chen@mediatek.com>
Co-developed-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Bo Jiao <Bo.Jiao@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7915: refine register definition
Bo Jiao [Mon, 20 Dec 2021 02:17:54 +0000 (10:17 +0800)]
mt76: mt7915: refine register definition

Add mt7915_reg_desc to differentiate chip generations.
This is an intermediate patch to introduce mt7916 support.

Co-developed-by: Sujuan Chen <sujuan.chen@mediatek.com>
Signed-off-by: Sujuan Chen <sujuan.chen@mediatek.com>
Co-developed-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Bo Jiao <Bo.Jiao@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7915: add mt7915_mmio_probe() as a common probing function
Bo Jiao [Mon, 20 Dec 2021 02:17:53 +0000 (10:17 +0800)]
mt76: mt7915: add mt7915_mmio_probe() as a common probing function

Add mt7915_mmio_probe() which will be used for the upcoming devices.
This is an intermediate patch to add mt7916 support.

Co-developed-by: Sujuan Chen <sujuan.chen@mediatek.com>
Signed-off-by: Sujuan Chen <sujuan.chen@mediatek.com>
Co-developed-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Bo Jiao <Bo.Jiao@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agomt76: mt7915: fix polling firmware-own status
Felix Fietkau [Mon, 23 Nov 2020 13:06:50 +0000 (14:06 +0100)]
mt76: mt7915: fix polling firmware-own status

Check the register status bit instead of the trigger bit

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2 years agobrcmfmac: pcie: Read the console on init and shutdown
Hector Martin [Mon, 31 Jan 2022 16:07:13 +0000 (01:07 +0900)]
brcmfmac: pcie: Read the console on init and shutdown

This allows us to get console messages if the firmware crashed during
early init, or if an operation failed and we're about to shut down.

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Arend van Spriel <arend.vanspriel@broadcom.com>
Signed-off-by: Hector Martin <marcan@marcan.st>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220131160713.245637-10-marcan@marcan.st
2 years agobrcmfmac: fwil: Constify iovar name arguments
Hector Martin [Mon, 31 Jan 2022 16:07:12 +0000 (01:07 +0900)]
brcmfmac: fwil: Constify iovar name arguments

Make all the iovar name arguments const char * instead of just char *.

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Arend van Spriel <arend.vanspriel@broadcom.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hector Martin <marcan@marcan.st>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220131160713.245637-9-marcan@marcan.st
2 years agobrcmfmac: of: Use devm_kstrdup for board_type & check for errors
Hector Martin [Mon, 31 Jan 2022 16:07:11 +0000 (01:07 +0900)]
brcmfmac: of: Use devm_kstrdup for board_type & check for errors

This was missing a NULL check, and we can collapse the strlen/alloc/copy
into a devm_kstrdup().

Reviewed-by: Arend van Spriel <arend.vanspriel@broadcom.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hector Martin <marcan@marcan.st>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220131160713.245637-8-marcan@marcan.st
2 years agobrcmfmac: pcie: Fix crashes due to early IRQs
Hector Martin [Mon, 31 Jan 2022 16:07:10 +0000 (01:07 +0900)]
brcmfmac: pcie: Fix crashes due to early IRQs

The driver was enabling IRQs before the message processing was
initialized. This could cause IRQs to come in too early and crash the
driver. Instead, move the IRQ enable and hostready to a bus preinit
function, at which point everything is properly initialized.

Fixes: 9e37f045d5e7 ("brcmfmac: Adding PCIe bus layer support.")
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Arend van Spriel <arend.vanspriel@broadcom.com>
Cc: stable@vger.kernel.org
Signed-off-by: Hector Martin <marcan@marcan.st>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220131160713.245637-7-marcan@marcan.st
2 years agobrcmfmac: pcie: Replace brcmf_pcie_copy_mem_todev with memcpy_toio
Hector Martin [Mon, 31 Jan 2022 16:07:09 +0000 (01:07 +0900)]
brcmfmac: pcie: Replace brcmf_pcie_copy_mem_todev with memcpy_toio

The alignment check was wrong (e.g. & 4 instead of & 3), and the logic
was also inefficient if the length was not a multiple of 4, since it
would needlessly fall back to copying the entire buffer bytewise.

We already have a perfectly good memcpy_toio function, so just call that
instead of rolling our own copy logic here. brcmf_pcie_init_ringbuffers
was already using it anyway.

Fixes: 9e37f045d5e7 ("brcmfmac: Adding PCIe bus layer support.")
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Arend van Spriel <arend.vanspriel@broadcom.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: stable@vger.kernel.org
Signed-off-by: Hector Martin <marcan@marcan.st>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220131160713.245637-6-marcan@marcan.st
2 years agobrcmfmac: pcie: Declare missing firmware files in pcie.c
Hector Martin [Mon, 31 Jan 2022 16:07:08 +0000 (01:07 +0900)]
brcmfmac: pcie: Declare missing firmware files in pcie.c

Move one of the declarations from sdio.c to pcie.c, since it makes no
sense in the former (SDIO support is optional), and add missing ones.

Fixes: 75729e110e68 ("brcmfmac: expose firmware config files through modinfo")
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Arend van Spriel <arend.vanspriel@broadcom.com>
Cc: stable@vger.kernel.org
Signed-off-by: Hector Martin <marcan@marcan.st>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220131160713.245637-5-marcan@marcan.st
2 years agobrcmfmac: firmware: Allocate space for default boardrev in nvram
Hector Martin [Mon, 31 Jan 2022 16:07:06 +0000 (01:07 +0900)]
brcmfmac: firmware: Allocate space for default boardrev in nvram

If boardrev is missing from the NVRAM we add a default one, but this
might need more space in the output buffer than was allocated. Ensure
we have enough padding for this in the buffer.

Fixes: 46f2b38a91b0 ("brcmfmac: insert default boardrev in nvram data if missing")
Reviewed-by: Arend van Spriel <arend.vanspriel@broadcom.com>
Cc: stable@vger.kernel.org
Signed-off-by: Hector Martin <marcan@marcan.st>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220131160713.245637-3-marcan@marcan.st
2 years agobrcmfmac: pcie: Release firmwares in the brcmf_pcie_setup error path
Hector Martin [Mon, 31 Jan 2022 16:07:05 +0000 (01:07 +0900)]
brcmfmac: pcie: Release firmwares in the brcmf_pcie_setup error path

This avoids leaking memory if brcmf_chip_get_raminfo fails. Note that
the CLM blob is released in the device remove path.

Fixes: 82f93cf46d60 ("brcmfmac: get chip's default RAM info during PCIe setup")
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Arend van Spriel <arend.vanspriel@broadcom.com>
Cc: stable@vger.kernel.org
Signed-off-by: Hector Martin <marcan@marcan.st>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220131160713.245637-2-marcan@marcan.st
2 years agortlwifi: remove redundant initialization of variable ul_encalgo
Colin Ian King [Sun, 30 Jan 2022 22:37:14 +0000 (22:37 +0000)]
rtlwifi: remove redundant initialization of variable ul_encalgo

Variable ul_encalgo is initialized with a value that is never read,
it is being re-assigned a new value in every case in the following
switch statement. The initialization is redundant and can be removed.

Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
Acked-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220130223714.6999-1-colin.i.king@gmail.com
2 years agossb: fix boolreturn.cocci warning
Yang Guang [Fri, 14 Jan 2022 00:11:02 +0000 (08:11 +0800)]
ssb: fix boolreturn.cocci warning

The coccinelle report
./include/linux/ssb/ssb_driver_gige.h:98:8-9:
WARNING: return of 0/1 in function
'ssb_gige_must_flush_posted_writes' with return type bool

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

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Yang Guang <yang.guang5@zte.com.cn>
Signed-off-by: David Yang <davidcomponentone@gmail.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/fa4f1fa737e715eb62a85229ac5f12bae21145cf.1642065490.git.davidcomponentone@gmail.com
2 years agoray_cs: Check ioremap return value
Jiasheng Jiang [Thu, 30 Dec 2021 02:29:26 +0000 (10:29 +0800)]
ray_cs: Check ioremap return value

As the possible failure of the ioremap(), the 'local->sram' and other
two could be NULL.
Therefore it should be better to check it in order to avoid the later
dev_dbg.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20211230022926.1846757-1-jiasheng@iscas.ac.cn
2 years agocw1200: wsm: make array queue_id_to_wmm_aci static const
Colin Ian King [Sun, 9 Jan 2022 23:09:21 +0000 (23:09 +0000)]
cw1200: wsm: make array queue_id_to_wmm_aci static const

Don't populate the read-only array queue_id_to_wmm_aci on the stack
but instead make it static. Also makes the object code a little smaller.

Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220109230921.58766-1-colin.i.king@gmail.com
2 years agowilc1000: use min_t() to make code cleaner
Changcheng Deng [Wed, 22 Dec 2021 07:08:15 +0000 (07:08 +0000)]
wilc1000: use min_t() to make code cleaner

Use min_t() in order to make code cleaner.

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Changcheng Deng <deng.changcheng@zte.com.cn>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20211222070815.483009-1-deng.changcheng@zte.com.cn
2 years agortw88: rtw8821c: enable rfe 6 devices
Ping-Ke Shih [Fri, 7 Jan 2022 02:47:39 +0000 (20:47 -0600)]
rtw88: rtw8821c: enable rfe 6 devices

Ping-Ke Shih answered[1] a question for a user about an rtl8821ce device that
reported RFE 6, which the driver did not support. Ping-Ke suggested a possible
fix, but the user never reported back.

A second user discovered the above thread and tested the proposed fix.
Accordingly, I am pushing this change, even though I am not the author.

[1] https://lore.kernel.org/linux-wireless/3f5e2f6eac344316b5dd518ebfea2f95@realtek.com/

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Reported-and-tested-by: masterzorag <masterzorag@gmail.com>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220107024739.20967-1-Larry.Finger@lwfinger.net
2 years agortw88: fix memory overrun and memory leak during hw_scan
Po-Hao Huang [Fri, 21 Jan 2022 07:08:13 +0000 (15:08 +0800)]
rtw88: fix memory overrun and memory leak during hw_scan

Previously we allocated less memory than actual required, overwrite
to the buffer causes the mm module to complaint and raise access
violation faults. Along with potential memory leaks when returned
early. Fix these by passing the correct size and proper deinit flow.

Fixes: 10d162b2ed39 ("rtw88: 8822c: add ieee80211_ops::hw_scan")
Signed-off-by: Po-Hao Huang <phhuang@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/20220121070813.9656-4-pkshih@realtek.com
2 years agortw88: fix idle mode flow for hw scan
Po-Hao Huang [Fri, 21 Jan 2022 07:08:12 +0000 (15:08 +0800)]
rtw88: fix idle mode flow for hw scan

Upon hw scan completion, idle mode is not re-entered. This might
increase power consumption under no link mode. Fix this by adding the
re-enter flow. We need another work for this since enter_ips waits
for c2h_work to finish, which might lead to deadlock if caller is in
the same work.

Fixes: 10d162b2ed39 ("rtw88: 8822c: add ieee80211_ops::hw_scan")
Signed-off-by: Po-Hao Huang <phhuang@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/20220121070813.9656-3-pkshih@realtek.com
2 years agortw88: check for validity before using a pointer
Muhammad Usama Anjum [Fri, 21 Jan 2022 07:08:11 +0000 (15:08 +0800)]
rtw88: check for validity before using a pointer

ieee80211_probereq_get() can return NULL. Pointer skb should be checked
for validty before use. If it is not valid, list of skbs needs to be
freed.

Fixes: 10d162b2ed39 ("rtw88: 8822c: add ieee80211_ops::hw_scan")
Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220121070813.9656-2-pkshih@realtek.com
2 years agobrcmfmac: add CYW43570 PCIE device
Soontak Lee [Wed, 29 Dec 2021 03:51:44 +0000 (21:51 -0600)]
brcmfmac: add CYW43570 PCIE device

CYW43570 is a 3-antenna, 2x2 MIMO,802.11a/b/g/n/ac, PCIe 3.0 for WLAN.
It is BT/WIFI combo.

Signed-off-by: Soontak Lee <soontak.lee@cypress.com>
Signed-off-by: Chi-Hsien Lin <chi-hsien.lin@infineon.com>
Signed-off-by: Ian Lin <ian.lin-ee@infineon.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20211229035144.9205-1-ian.lin-ee@infineon.com
2 years agobrcmfmac: use ISO3166 country code and 0 rev as fallback on some devices
Hans de Goede [Sat, 18 Dec 2021 18:56:43 +0000 (19:56 +0100)]
brcmfmac: use ISO3166 country code and 0 rev as fallback on some devices

This is a second attempt at honering the country code send out by access
points. This was first added in commit b0b524f079a2 ("brcmfmac: use
ISO3166 country code and 0 rev as fallback").

Subsequently this was reverted in commit 151a7c12c4fc ("Revert "brcmfmac:
use ISO3166 country code and 0 rev as fallback""), because it was causing
issues with AP mode on some brcmfmac models (specifically on BCM4359/9).

Many devices ship with a nvram ccode value of X2/XT/XU/XV/ALL which are
all special world-wide compatibility ccode-s. Most of these world-wide
ccode-s allow passive scan mode only for 2.4GHz channels 12-14,
only enabling them when an AP is seen on them.

But at least on brcmfmac43455 devices this is not working correctly, these
do not see accesspoints on channels 12-14 unless the ccode is changes to
a country where these channels are allowed.

Translating received country codes to an ISO3166 country code and 0 rev
ccreq fixes devices using a brcmfmac43455 with a X2/XT/XU/XV/ALL ccode
not seeing accesspoints on channels 12-14.

To avoid this causing issues on other brcmfmac models again, the
fallback is limited to only brcmfmac4345* chips this time.

Cc: Shawn Guo <shawn.guo@linaro.org>
Cc: Soeren Moch <smoch@web.de>
Cc: Fabio Aiuto <fabioaiuto83@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Tested-by: Soeren Moch <smoch@web.de>  # on BCM4359/9
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20211218185643.158182-1-hdegoede@redhat.com
2 years agortw89: use pci_read/write_config instead of dbi read/write
Chin-Yen Lee [Fri, 21 Jan 2022 07:55:55 +0000 (15:55 +0800)]
rtw89: use pci_read/write_config instead of dbi read/write

In the past we use dbi function of wifi mac to read/write
pci config space, but the function will be remove in new
chip. So use kernel api pci_read/write_config_byte instead.

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/20220121075555.12457-2-pkshih@realtek.com
2 years agortw89: refine DIG feature to support 160M and CCK PD
Johnson Lin [Fri, 21 Jan 2022 07:55:54 +0000 (15:55 +0800)]
rtw89: refine DIG feature to support 160M and CCK PD

DIG, which is short for dynamic initial gain, is used to adjust gain to get
good RX performance. CCK PD feature, a mechanism that adjusts 802.11b CCK
packet detection(PD) power threshold based on environment noisy level in
order to avoid false alarm. Also, refine related variable naming.

Signed-off-by: Johnson Lin <johnson.lin@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/20220121075555.12457-1-pkshih@realtek.com
2 years agortw89: fix maybe uninitialized `qempty` variable
Íñigo Huguet [Thu, 13 Jan 2022 09:42:53 +0000 (10:42 +0100)]
rtw89: fix maybe uninitialized `qempty` variable

Call to dle_dfi_qempty might fail, leaving qempty.qempty untouched, which
is latter used to control the for loop. If that happens, it's not
initialized anywhere.

Initialize it so the loop doesn't iterate unless it's modified by the
call to dle_dfi_qempty.

Signed-off-by: Íñigo Huguet <ihuguet@redhat.com>
Acked-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220113094253.73370-1-ihuguet@redhat.com
2 years agortw89: include subband type in channel params
Zong-Zhe Yang [Thu, 13 Jan 2022 01:10:42 +0000 (09:10 +0800)]
rtw89: include subband type in channel params

Make stuffs related to channel be collected in channel_params,
and encapsulate the corresponding decision in get_channel_params().
Then, functions that takes channel_params can also notice subband type.

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/20220113011042.6705-2-pkshih@realtek.com
2 years agortw89: handle 6G band if supported by a chipset
Zong-Zhe Yang [Thu, 13 Jan 2022 01:10:41 +0000 (09:10 +0800)]
rtw89: handle 6G band if supported by a chipset

For next chipset which can support 6G band, we add the handling
of ieee80211_supported_band for 6G band in advance. And a bitmap,
support_bands, is added to rtw89_chip_info to declare which
NL80211_BAND_* are supported. With the chipset's declaration,
we register the corresponding instances of ieee80211_supported_band
with wiphy.

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/20220113011042.6705-1-pkshih@realtek.com
2 years agortw89: separate {init,deinit}_addr_cam functions
Ping-Ke Shih [Fri, 7 Jan 2022 03:42:32 +0000 (11:42 +0800)]
rtw89: separate {init,deinit}_addr_cam functions

Each stations connected to AP needs to set an address CAM, so don't combine
address and BSSID CAM.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220107034239.22002-13-pkshih@realtek.com
2 years agortw89: set mac_id and port ID to TXWD
Ping-Ke Shih [Fri, 7 Jan 2022 03:42:31 +0000 (11:42 +0800)]
rtw89: set mac_id and port ID to TXWD

One mac_id is corresponding to one connected station, and port ID is a
ID of virtual interfaces. With proper mac_id and port ID, firmware and
hardware can handle a packet with correct context.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220107034239.22002-12-pkshih@realtek.com
2 years agortw89: send broadcast/multicast packets via HIQ if STAs are in sleep mode
Ping-Ke Shih [Fri, 7 Jan 2022 03:42:30 +0000 (11:42 +0800)]
rtw89: send broadcast/multicast packets via HIQ if STAs are in sleep mode

If a packet we are going to send is broadcast/multicast and certain STAs
are in sleep mode, a flag IEEE80211_TX_CTL_SEND_AFTER_DTIM is added to
txinfo. Then, this kind of packets must be sent via HIQ instead of regular
AC queues, because they should be sent right after beacon.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220107034239.22002-11-pkshih@realtek.com
2 years agortw89: configure mac port HIQ registers
Ping-Ke Shih [Fri, 7 Jan 2022 03:42:29 +0000 (11:42 +0800)]
rtw89: configure mac port HIQ registers

HIQ is short for high queue that is used to send broadcast/multicast
packets right after TBTT in AP mode. Two registers, DTIM and window size,
are configured accordingly.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220107034239.22002-10-pkshih@realtek.com
2 years agortw89: rename vif_maintain to role_maintain
Ping-Ke Shih [Fri, 7 Jan 2022 03:42:28 +0000 (11:42 +0800)]
rtw89: rename vif_maintain to role_maintain

The H2C_FUNC_MAC_FWROLE_MAINTAIN also maintains the roles of all connected
stations; not just the role of VIF. So, I correct the name, but don't
change the 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/20220107034239.22002-9-pkshih@realtek.com
2 years agortw89: extend firmware commands on states of sta_assoc and sta_disconnect
Ping-Ke Shih [Fri, 7 Jan 2022 03:42:27 +0000 (11:42 +0800)]
rtw89: extend firmware commands on states of sta_assoc and sta_disconnect

The h2c_join firmware command is used to indicate a station is connected,
and the assoc_cmac_tbl firmware command is used to set CMAC table
corresponding to a mac_id. Both commands must work in both station and AP
modes. Use the mac_id of rtw89_sta naturally and intuitively.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220107034239.22002-8-pkshih@realtek.com
2 years agortw89: allocate mac_id for each station in AP mode
Ping-Ke Shih [Fri, 7 Jan 2022 03:42:26 +0000 (11:42 +0800)]
rtw89: allocate mac_id for each station in AP mode

In station mode, mac_id of station is the same as rtwvif's one.
In AP mode, each station uses individual mac_id.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220107034239.22002-7-pkshih@realtek.com
2 years agortw89: implement mac80211_ops::set_tim to indicate STA to receive packets
Ping-Ke Shih [Fri, 7 Jan 2022 03:42:25 +0000 (11:42 +0800)]
rtw89: implement mac80211_ops::set_tim to indicate STA to receive packets

Update beacon content if TIM bitmap maintained by mac80211 is changed.
Since .set_tim must be atomic but driver uses mutex lock, we add a work.
Otherwise, kernel says "sched: RT throttling activated" and lock down.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220107034239.22002-6-pkshih@realtek.com
2 years agortw89: add C2H handle of BCN_CNT
Ping-Ke Shih [Fri, 7 Jan 2022 03:42:24 +0000 (11:42 +0800)]
rtw89: add C2H handle of BCN_CNT

This C2H notify driver the beacon count we send out. We don't handle the
content for now, so add a dummy handler to avoid messages, like
  rtw89_pci 0000:03:00.0: c2h class 0 func 3 not support
  C2H: 00000000: 01 03 01 3f 0f 00 00 00 80 0a 00 00 00 00 a0
  rtw89_pci 0000:03:00.0: c2h class 0 func 3 not support
  C2H: 00000000: 01 03 01 40 0f 00 00 00 00 03 20 00 00 00 a5

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220107034239.22002-5-pkshih@realtek.com
2 years agortw89: download beacon content to firmware
Ping-Ke Shih [Fri, 7 Jan 2022 03:42:23 +0000 (11:42 +0800)]
rtw89: download beacon content to firmware

Firmware sends out beacon content generated by mac80211, and then stations
can receive beacon and work with this AP properly. Also, we download
beacon content again if TIM is changed.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220107034239.22002-4-pkshih@realtek.com
2 years agortw89: use hardware SSN to TX management frame
Ping-Ke Shih [Fri, 7 Jan 2022 03:42:22 +0000 (11:42 +0800)]
rtw89: use hardware SSN to TX management frame

Since firmware transmits beacon by hardware SSN, driver does it with the
same setting, then packets in the air have continual sequence number.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220107034239.22002-3-pkshih@realtek.com
2 years agortw89: configure rx_filter according to FIF_PROBE_REQ
Ping-Ke Shih [Fri, 7 Jan 2022 03:42:21 +0000 (11:42 +0800)]
rtw89: configure rx_filter according to FIF_PROBE_REQ

With this patch, we can receive probe_req and reply probe_resp, and STA
can find us.

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