Commit Graph
636 Commits
Author SHA1 Message Date
Sujuan ChenandFelix Fietkau 1af4a911eb wifi: mt76: mt7915: release rxwi in mt7915_wed_release_rx_buf
Free rxwi cache releasing WED rx buffers in mt7915_wed_release_rx_buf
routine

Tested-by: Daniel Golle <[email protected]>
Co-developed-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Sujuan Chen <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2023-01-25 20:12:27 +01:00
Lorenzo BianconiandFelix Fietkau 04da4eaa82 wifi: mt76: enable page_pool stats
Enable page_pool ethtool statistics for mt7915 and mt7921 chipsets.

Tested-by: Felix Fietkau <[email protected]>
Tested-by: Deren Wu <[email protected]>
Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2023-01-25 20:12:27 +01:00
Lorenzo BianconiandFelix Fietkau 9686cd7cc6 wifi: mt76: switch to page_pool allocator
In order to reduce possible memory allocation failures due to memory
fragmentation caused by page_frag_cache allocator, switch to page_pool
allocator for dma and usb mt76 drivers.
Remove per rx-queue page_frag_cache

Co-developed-by: Felix Fietkau <[email protected]>
Tested-by: Deren Wu <[email protected]>
Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2023-01-25 20:11:29 +01:00
Lorenzo BianconiandFelix Fietkau c6794954a7 wifi: mt76: mt7915: fix memory leak in mt7915_mmio_wed_init_rx_buf
Free mt76_txwi_cache pointer in mt7915_mmio_wed_init_rx_buf routine in
case of failure.

Fixes: 4f831d18d12d ("wifi: mt76: mt7915: enable WED RX support")
Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2023-01-23 10:50:59 +01:00
Ryder LeeandFelix Fietkau 724a337cae wifi: mt76: mt7915: fix WED TxS reporting
The previous commit forgot to remove a leftover check.

Fixes: 43eaa3689507 ("wifi: mt76: add PPDU based TxS support for WED device")
Reported-By: Sujuan Chen <[email protected]>
Signed-off-by: Ryder Lee <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2023-01-23 10:50:59 +01:00
Peter ChiuandFelix Fietkau 06a8904e95 wifi: mt76: mt7915: wed: enable red per-band token drop
Enable RED to limit the number of token used by each band. If single band
uses too many tokens, it would hurt the throughput of the other bands.The
software path can solve this problem by AQL so enable RED for HW path only.

Reviewed-by: Shayne Chen <[email protected]>
Signed-off-by: Peter Chiu <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2023-01-23 10:50:59 +01:00
Peter ChiuandFelix Fietkau ddbf4e933d wifi: mt76: mt7915: set sku initial value to zero
Set sku initial value before mcu starts to prevent mcu from getting an
invalid value.

Signed-off-by: Peter Chiu <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2023-01-23 10:50:59 +01:00
Lorenzo BianconiandFelix Fietkau 9df89143bf wifi: mt76: mt7915: get rid of wed rx_buf_ring page_frag_cache
Since wed rx_buf_ring page_frag_cache is no longer used in a hot path,
remove it and rely on page allocation APIs in
mt7915_mmio_wed_init_rx_buf() and mt7915_mmio_wed_release_rx_buf()

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2023-01-23 10:50:07 +01:00
Lorenzo BianconiandFelix Fietkau 5de9ae29be wifi: mt76: mt7915: avoid mcu_restart function pointer
Run mt76_connac_mcu_restart routine directly and avoid mcu_restart
function pointer whenever it is possible.

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2023-01-23 10:32:49 +01:00
Lorenzo BianconiandFelix Fietkau a409a94545 wifi: mt76: mt7915: fix memory leak in mt7915_mcu_exit
Always purge mcu skb queues in mt7915_mcu_exit routine even if
mt7915_firmware_state fails.

Fixes: e57b7901469f ("mt76: add mac80211 driver for MT7915 PCIe-based chipsets")
Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2023-01-23 10:32:48 +01:00
Lorenzo BianconiandFelix Fietkau 3c162384d8 wifi: mt76: introduce mt76_queue_is_wed_rx utility routine
This patch does not change any logic, just improve code readability.

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2023-01-23 10:32:48 +01:00
MeiChia ChiuandFelix Fietkau 98aa346042 wifi: mt76: mt7915: remove BW160 and BW80+80 support
Remove BW160 and BW80+80 capability in mt7915.

Tested-by: AngeloGioacchino Del Regno <[email protected]>
Reviewed-by: Ryder Lee <[email protected]>
Reviewed-by: Shayne Chen <[email protected]>
Signed-off-by: Money Wang<[email protected]>
Signed-off-by: MeiChia Chiu <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2023-01-23 10:32:48 +01:00
Shayne ChenandFelix Fietkau 99e96b89ee wifi: mt76: mt7915: add chip id condition in mt7915_check_eeprom()
When flash mode is enabled, and the eeprom data in the flash is not for
the current chipset, it'll still be checked valid, and the default
eeprom bin won't be loaded.
(e.g., mt7915 NIC inserted with mt7916 eeprom data in the flash.)

Fix this kind of case by adding chip id into consideration in
mt7915_check_eeprom().

Reported-by: Cheng-Ji Li <[email protected]>
Signed-off-by: Shayne Chen <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2023-01-23 10:32:48 +01:00
Howard HsuandFelix Fietkau c6f24b83eb wifi: mt76: mt7915: add error message in mt7915_thermal_set_cur_throttle_state()
Add dev_err so that it is easier to see invalid setting while looking at
dmesg.

Co-developed-by: Ryder Lee <[email protected]>
Signed-off-by: Ryder Lee <[email protected]>
Signed-off-by: Howard Hsu <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2023-01-23 10:32:48 +01:00
Howard HsuandFelix Fietkau 87cb74fe42 wifi: mt76: mt7915: rework mt7915_thermal_temp_store()
Call mt7915_mcu_set_thermal_protect() through
mt7915_thermal_temp_store() to update firmware trigger/restore temp
directly.

Fixes: 02ee68b95d81 ("mt76: mt7915: add control knobs for thermal throttling")
Reviewed-by: Ryder Lee <[email protected]>
Signed-off-by: Howard Hsu <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2023-01-23 10:32:48 +01:00
Howard HsuandFelix Fietkau 8e5c21fe7c wifi: mt76: mt7915: rework mt7915_mcu_set_thermal_throttling
This patch includes 2 changes:
1. Firmware expects to disable thermal protect first before
reconfiguring.
2. Separate setting thermal_protect and setting thermal_tx_duty into
different functions. These two firmware commands do not need to send
together.

Fixes: 34b877d972be ("mt76: mt7915: add thermal cooling device support")
Reviewed-by: Ryder Lee <[email protected]>
Signed-off-by: Howard Hsu <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2023-01-23 10:32:48 +01:00
Howard HsuandFelix Fietkau 15b9dd6b1b wifi: mt76: mt7915: call mt7915_mcu_set_thermal_throttling() only after init_work
Enable thermal management by default shall not be executed during mcu
init. This causes thermal configuration being reset to the firmware
default settings.

Fixes: 0063b86c9120 ("mt76: mt7915e: Enable thermal management by default")
Reviewed-by: Ryder Lee <[email protected]>
Signed-off-by: Howard Hsu <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2023-01-23 10:32:48 +01:00
ZnevnaandFelix Fietkau 679254c50f mt7915: add CONFIG_MT76_LEDS to cflags
As we have for mt7615.

Signed-off-by: Marian Sarcinschi <[email protected]>
2023-01-06 19:39:08 +01:00
Lorenzo BianconiandFelix Fietkau 95c66d6511 wifi: mt76: handle possible mt76_rx_token_consume failures
Take into account possible error conditions of mt76_rx_token_consume
routine in mt7915_mmio_wed_init_rx_buf() and mt76_dma_add_buf()

Fixes: cd372b8c99c5 ("wifi: mt76: add WED RX support to mt76_dma_{add,get}_buf")
Fixes: 4f831d18d12d ("wifi: mt76: mt7915: enable WED RX support")
Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2022-12-10 13:11:05 +01:00
Lorenzo BianconiandFelix Fietkau 81edc468fc wifi: mt76: mt7915: enable per-phy led support
Introduce the capability to support per-phy led blinking. This is needed
for devices supporting dbdc.

Tested-by: Frank Wunderlich <[email protected]>
Co-developed-by: Ryder Lee <[email protected]>
Signed-off-by: Ryder Lee <[email protected]>
Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2022-12-10 13:11:05 +01:00
Lorenzo BianconiandFelix Fietkau 14fbb6d6e8 wifi: mt76: move leds struct in mt76_phy
Move leds struct in mt76_phy in order to have leds associated to phy
(e.g. in dbdc mode) instead of per device.

Tested-by: Frank Wunderlich <[email protected]>
Co-developed-by: Ryder Lee <[email protected]>
Signed-off-by: Ryder Lee <[email protected]>
Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2022-12-10 13:11:05 +01:00
Lorenzo BianconiandFelix Fietkau 551201379e wifi: mt76: move leds field in leds struct
This is a preliminary patch to support per-phy leds.

Tested-by: Frank Wunderlich <[email protected]>
Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2022-12-10 13:11:05 +01:00
Ryder LeeandFelix Fietkau be5dbb7810 wifi: mt76: mt7915: fix unintended sign extension of mt7915_hw_queue_read()
In the expression "map[i].qid << 24" starts as u8, but is promoted to
"signed int", then sign-extended to type "unsigned long", which is not
intended. Cast to u32 to avoid the sign extension.

Fixes: 776ec4e77aa6 ("mt76: mt7915: rework debugfs queue info")
Signed-off-by: Ryder Lee <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2022-12-10 13:11:05 +01:00
Ryder LeeandFelix Fietkau 35843a1670 wifi: mt76: mt7915: drop always true condition of __mt7915_reg_addr()
smatch warnings:
addr <= MT_CBTOP2_PHY_END(0xffffffff) is always true (<= u32max),
so drop it.

Fixes: cd4c314a65d3 ("mt76: mt7915: refine register definition")
Reported-by: kernel test robot <[email protected]>
Signed-off-by: Ryder Lee <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2022-12-10 13:11:05 +01:00
Ryder LeeandFelix Fietkau b94ba58fa6 wifi: mt76: mt7915: check the correctness of event data
The mcu event might not be reliable, so check the correctness of data
before handling it.

Signed-off-by: Ryder Lee <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2022-12-10 13:11:05 +01:00
Ryder LeeandFelix Fietkau b252d94bd7 wifi: mt76: mt7915: check return value before accessing free_block_num
Check return value of mt7915_mcu_get_eeprom_free_block() first before
accessing free_block_num.

Fixes: bbc1d4154ec1 ("mt76: mt7915: add default calibrated data support")
Signed-off-by: Ryder Lee <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2022-12-10 13:11:05 +01:00
Ryder LeeandFelix Fietkau f9598e6d4c wifi: mt76: mt7915: split mcu chan_mib array up
The current flow confuses coverity check that leads to false reporting,
so split the offs[] into two pieces according to chipset revision to
silence coverity tool.

Signed-off-by: Ryder Lee <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2022-12-10 13:11:04 +01:00
Ryder LeeandFelix Fietkau 1ce4970d79 wifi: mt76: mt7915: fix mt7915_rate_txpower_get() resource leaks
Coverity message: variable "buf" going out of scope leaks the storage.

Reported-by: coverity-bot <[email protected]>
Addresses-Coverity-ID: 1527799 ("Resource leaks")
Fixes: e3296759f347 ("wifi: mt76: mt7915: enable per bandwidth power limit support")
Signed-off-by: Ryder Lee <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2022-12-10 13:11:04 +01:00
Wang YufenandFelix Fietkau 194cb33928 mt76: mt7915: add missing of_node_put()
Add missing of_node_put() after of_reserved_mem_lookup()

Fixes: 99ad32a4ca3a ("mt76: mt7915: add support for MT7986")
Signed-off-by: Wang Yufen <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2022-12-10 13:11:04 +01:00
Felix Fietkau ec46d7486a sync with upstream
Signed-off-by: Felix Fietkau <[email protected]>
2022-12-10 13:11:04 +01:00
Lorenzo BianconiandFelix Fietkau cdd7229e76 wifi: mt76: mt7915: mmio: fix naming convention
Rename mt7915_wed_release_rx_buf in mt7915_mmio_wed_release_rx_buf,
mt7915_wed_init_rx_buf in mt7915_mmio_wed_init_rx_buf and
mt7915_wed_release_rx_buf in mt7915_mmio_wed_release_rx_buf

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2022-12-01 12:33:42 +01:00
Ryder LeeandFelix Fietkau 525592c28d wifi: mt76: mt7915: rely on band_idx of mt76_phy
The commit dc44c45c8cd0 added band_idx into mt76_phy, so switching to
rely on that.

Signed-off-by: Ryder Lee <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2022-12-01 12:33:42 +01:00
Ryder LeeandFelix Fietkau a7b9153021 wifi: mt76: mt7915: fix scene detection flow of spatial reuse
Firmware is in the driving seat while sr_scene_detect is enabled,
so driver needs to skip operation to avoid mangling scene detection
algorithm.

Fixes: a633503 ("wifi: mt76: mt7915: add support to configure spatial reuse parameter set")
Signed-off-by: Ryder Lee <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2022-12-01 12:33:42 +01:00
Ryder LeeandFelix Fietkau 5082a58f80 wifi: mt76: mt7915: enable per bandwidth power limit support
This power should override the per bandwidth max power that the
device emits.

Signed-off-by: Ryder Lee <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2022-12-01 12:33:42 +01:00
Ryder LeeandFelix Fietkau ff94604b2e wifi: mt76: mt7915: introduce mt7915_get_power_bound()
Add a helper for common boundary check. This is a preliminary patch
to add per bandwidth power control.

Signed-off-by: Ryder Lee <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2022-12-01 12:10:51 +01:00
Xiongfeng WangandFelix Fietkau fa79eeeadc mt76: mt7915: Fix PCI device refcount leak in mt7915_pci_init_hif2()
As comment of pci_get_device() says, it returns a pci_device with its
refcount increased. We need to call pci_dev_put() to decrease the
refcount. Save the return value of pci_get_device() and call
pci_dev_put() to decrease the refcount.

Fixes: 9093cfff72e3 ("mt76: mt7915: add support for using a secondary PCIe link for gen1")
Fixes: 2e30db0dde61 ("mt76: mt7915: add device id for mt7916")
Signed-off-by: Xiongfeng Wang <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2022-12-01 12:10:50 +01:00
Ryder LeeandFelix Fietkau aa7132da03 wifi: mt76: mt7915: fix endianness of mt7915_mcu_set_obss_spr_pd()
Fix sparse: sparse: incorrect type in assignment (different base types).

Fixes: a6335031eb96 ("wifi: mt76: mt7915: add support to configure spatial reuse parameter set")
Signed-off-by: Ryder Lee <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2022-11-28 10:18:09 +01:00
Felix Fietkau e7a9f7a044 wifi: mt76: mt7915: fix unused-but-set warning
Signed-off-by: Felix Fietkau <[email protected]>
2022-11-25 15:05:23 +01:00
Ryder LeeandFelix Fietkau 2c172bb6cd wifi: mt76: mt7915: fix band_idx usage
The commit 006b9d4ad5bf introduced phy->band_idx to accommodate the
band definition change for mt7986 so that the band_idx of main_phy
can be 0 or 1. Accordingly, the source of band_idx 1 has switched to
"phy != &dev->phy" or "dev->phy.band_idx = 1".

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

Fixes: 006b9d4ad5bf ("mt76: mt7915: introduce band_idx in mt7915_phy")
Signed-off-by: Ryder Lee <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2022-11-23 13:38:55 +01:00
Ryder LeeandFelix Fietkau a9c88ded5c wifi: mt76: mt7915: enable .sta_set_txpwr support
This adds support for adjusting the Txpower level while pushing
traffic to an associated station. The allowed range is from 0 to
the maximum power of channel.

Signed-off-by: Ryder Lee <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2022-11-23 13:38:55 +01:00
Ryder LeeandFelix Fietkau 4c23061ebc wifi: mt76: mt7915: add basedband Txpower info into debugfs
This helps user to debug Txpower propagation path easily.

Signed-off-by: Ryder Lee <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2022-11-23 13:18:05 +01:00
Sujuan ChenandFelix Fietkau a887a5feb3 wifi: mt76: mt7915: enable WED RX stats
Introduce the capability to report WED RX stats to mac80211.

Tested-by: Daniel Golle <[email protected]>
Co-developed-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Sujuan Chen <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2022-11-23 13:16:11 +01:00
Lorenzo BianconiandFelix Fietkau f38faf2943 wifi: mt76: mt7915: enable WED RX support
Enable RX Wireless Ethernet Dispatch available on MT7986 Soc in oreder
to offlad traffic received by WLAN NIC and forwarded to LAN/WAN one.

Tested-by: Daniel Golle <[email protected]>
Co-developed-by: Sujuan Chen <[email protected]>
Signed-off-by: Sujuan Chen <[email protected]>
Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2022-11-23 13:16:11 +01:00
Sujuan ChenandFelix Fietkau 1361519851 wifi: mt76: add info parameter to rx_skb signature
This is a preliminary patch to introduce WED RX support for mt7915.

Tested-by: Daniel Golle <[email protected]>
Co-developed-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Sujuan Chen <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2022-11-23 13:11:29 +01:00
Ryder LeeandFelix Fietkau 3b8eed9c38 wifi: mt76: mt7915: add support to configure spatial reuse parameter set
The SPR parameter set comprises OBSS PD threshold for SRG and
non SRG and Bitmap of BSS color and partial BSSID. This adds
support to configure fields of SPR element to firmware.

User can disable firmware SR algorithms by turning sr_scene_detect off.

Signed-off-by: Ryder Lee <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2022-11-19 18:15:55 +01:00
Ryder LeeandFelix Fietkau d791ed1f58 wifi: mt76: mt7915: add missing MODULE_PARM_DESC
Add documentation for module_param so that they're visible with
modinfo command.

Signed-off-by: Ryder Lee <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2022-11-19 18:09:57 +01:00
Shayne ChenandFelix Fietkau c4d46cb1dd wifi: mt76: connac: rework fields for larger bandwidth support in sta_rec_bf
Rename nrow_bw160 and ncol_bw160 since channel width 320 MHz will share
the same field.
This is a preliminary patch to add mt7996 chipset support.

Signed-off-by: MeiChia Chiu <[email protected]>
Signed-off-by: Shayne Chen <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2022-11-19 17:56:40 +01:00
Ryder LeeandFelix Fietkau 3deafbad70 wifi: mt76: mt7915: fix uninitialized irq_mask
It should use dev->mt76.mmio.irqmask instead.

Fixes: 337acff38223 ("wifi: mt76: mt7915: enable full system reset support")
Signed-off-by: Ryder Lee <[email protected]>
2022-11-14 12:49:37 +01:00
Felix Fietkau 4bf2607362 wifi: mt76: fix dbdc number of spatial streams limit
Limit per-band streams to 2 instead of unconditionally dividing by 2

Fixes: 869815e5ef ("wifi: mt76: mt7915: Fix chainmask calculation on mt7915 DBDC")
Signed-off-by: Felix Fietkau <[email protected]>
2022-11-12 19:13:25 +01:00
Felix Fietkau f5034abea8 mt76: mt7915: fix format string
Signed-off-by: Felix Fietkau <[email protected]>
2022-11-11 18:15:39 +01:00