60 Commits
Author SHA1 Message Date
Felix Fietkau 9e9da427b8 mt76: mt7915: fix polling firmware-own status
Check the register status bit instead of the trigger bit

Signed-off-by: Felix Fietkau <[email protected]>
2020-11-23 14:06:53 +01:00
Shayne ChenandFelix Fietkau 19c9e277ef mt76: mt7915: fix memory leak in mt7915_mcu_get_rx_rate()
Free the skb to prevent memory leak.

Signed-off-by: Shayne Chen <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2020-11-18 11:28:04 +01:00
Lorenzo BianconiandFelix Fietkau b436da4d9d mt76: mt7915: introduce dbdc support
Introduce mt7915 dbdc support. If dbdc is available, mt7915 primary phy
will work on 2.4GHz band, while secondary one on 5GHz band.

Co-developed-by: Shayne Chen <[email protected]>
Signed-off-by: Shayne Chen <[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]>
2020-11-13 11:19:28 +01:00
Felix Fietkau 576647f2ec mt76: mt7915: fix endian issues
Multiple MCU messages were using u16/u32 fields without endian annotations
or conversions

Signed-off-by: Felix Fietkau <[email protected]>
2020-11-12 15:23:30 +01:00
Lorenzo BianconiandFelix Fietkau ccd62467d0 mt76: move mcu queues to mt76_dev q_mcu array
Move mcu queue to a dedicated array q_mcu in mt76_dev structure.
This is a preliminary patch to move data queues in mt76_phy and properly
support dbdc

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2020-11-12 14:59:29 +01:00
Lorenzo BianconiandFelix Fietkau b0eb7edcc6 mt76: rely on mt76_queue in tx_queue_skb_raw signature
This is a preliminary patch to move data queues in mt76_phy and properly
support dbdc

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2020-11-12 14:59:29 +01:00
Lorenzo BianconiandFelix Fietkau 216cf8b285 mt76: dma: rely on mt76_queue in mt76_dma_tx_cleanup signature
This is a preliminary patch to move data queues in mt76_phy and properly
support dbdc

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2020-11-12 14:59:29 +01:00
Ryder LeeandFelix Fietkau 27227fd57e mt76: mt7915: remove unused mt7915_mcu_bss_sync_tlv()
mt7915_mcu_bss_sync_tlv() is no longer used, so remove it.

Signed-off-by: Ryder Lee <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2020-11-10 13:55:37 +01:00
Shayne ChenandFelix Fietkau 03ed0909f9 mt76: mt7915: implement testmode tx support
Support testmode tx for MT7915A, including tx streams and HE rate
settings.

Reviewed-by: Ryder Lee <[email protected]>
Signed-off-by: Shayne Chen <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2020-11-10 13:48:06 +01:00
Lorenzo BianconiandFelix Fietkau 01b9432957 mt76: move mt76_mcu_send_firmware in common module
Move mt76_mcu_send_firmware routine in common code since it is actually
shared between mt7615, mt7663, mt7603 and mt7915 devices

Signed-off-by: Lorenzo Bianconi <[email protected]>
2020-11-10 13:19:53 +01:00
Felix Fietkau 4d019c9672 sync with upstream changes
Signed-off-by: Felix Fietkau <[email protected]>
2020-10-23 11:38:05 +02:00
Ryder LeeandFelix Fietkau 8884a5def5 mt76: mt7915: rename mt7915_mcu_get_rate_info to mt7915_mcu_get_tx_rate
Avoid confusion with rx rate query function.

Signed-off-by: Ryder Lee <[email protected]>
Signed-off-by: Shayne Chen <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2020-10-11 21:48:37 +02:00
Felix Fietkau d33943baac mt76: mt7915: query station rx rate from firmware
When per-packet rate reporting is enabled, the hardware can get stuck under
some conditions. It self-recovers quickly, but in practice this leads to
reduced performance.
In order to avoid running into this issue, disable per-packet rate reporting
by default and query the rx rate from firmware instead, unless monitor mode
is enabled.

Signed-off-by: Felix Fietkau <[email protected]>
2020-09-30 11:39:05 +02:00
Felix Fietkau ee40800df2 mt76: mt7915: move eeprom parsing out of mt7915_mcu_parse_response
Use the new mt76_mcu_send_and_get_msg function

Signed-off-by: Felix Fietkau <[email protected]>
2020-09-30 06:34:51 +02:00
Felix Fietkau a4d71501ba mt76: make mcu_ops->mcu_send_msg optional
Remove it from mt7615 and mt7915 and implement it in core code instead

Signed-off-by: Felix Fietkau <[email protected]>
2020-09-30 05:35:49 +02:00
Felix Fietkau 477caa196f mt76: move waiting and locking out of mcu_ops->mcu_skb_send_msg
This removes some code duplication and prepares the code for making
the MCU API more flexible

Signed-off-by: Felix Fietkau <[email protected]>
2020-09-30 05:35:49 +02:00
Felix Fietkau fcfbb046c2 mt76: move mcu timeout handling to .mcu_parse_response
Preparation for further cleanup

Signed-off-by: Felix Fietkau <[email protected]>
2020-09-30 04:01:03 +02:00
Felix Fietkau 8c73f3b15a mt76: implement .mcu_parse_response in struct mt76_mcu_ops
Do not free skb inside that function
Preparation for further cleanup

Signed-off-by: Felix Fietkau <[email protected]>
2020-09-30 03:54:03 +02:00
Felix Fietkau eb9afae96b mt76: rename __mt76_mcu_skb_send_msg to mt76_mcu_skb_send_msg
Preparation for further cleanup

Signed-off-by: Felix Fietkau <[email protected]>
2020-09-30 03:11:06 +02:00
Felix Fietkau 6cdebe8058 mt76: rename __mt76_mcu_send_msg to mt76_mcu_send_msg
Preparation for further cleanup

Signed-off-by: Felix Fietkau <[email protected]>
2020-09-30 03:09:22 +02:00
Felix Fietkau 75977a85e8 mt76: mt7915: disable OFDMA/MU-MIMO UL
The feature is not ready in firmware yet, and it leads to hangs

Signed-off-by: Felix Fietkau <[email protected]>
2020-09-29 08:48:20 +02:00
Felix Fietkau 9cb12f7042 mt76: mt7915: fix DRR sta bss group index
The firmware/hardware supports only 16 entries. Trying to use more can lead
to timeouts on some firmware versions

Signed-off-by: Felix Fietkau <[email protected]>
2020-09-28 15:15:20 +02:00
Felix Fietkau 2741fd071b mt76: mt7915: support 32 station interfaces
When looking for a MAC address slot, start by using main BSSID slots 1-3,
afterwards use 16 repeater mode BSSID slots, then start using the slots
usually used for AP mode.
This search order should prevent unnecessary conflicts with AP mode interfaces
on the same PHY

Signed-off-by: Felix Fietkau <[email protected]>
2020-09-27 15:26:48 +02:00
Shayne ChenandFelix Fietkau 8c47ed12c2 mt76: mt7915: add offchannel condition in switch channel command
Add a missing offchannel condition for channel switch reason, which
bypasses DPD calibration to reduce scanning time.

Signed-off-by: Shayne Chen <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2020-09-23 08:16:55 +02:00
Liu ShixinandFelix Fietkau ec84891a4d mt76: mt7915: convert to use le16_add_cpu()
Convert cpu_to_le16(le16_to_cpu(E1) + E2) to use le16_add_cpu().

Signed-off-by: Liu Shixin <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2020-09-16 11:04:05 +02:00
Lorenzo BianconiandFelix Fietkau fee1f4a8e8 mt76: mt7915: fix possible memory leak in mt7915_mcu_add_beacon
Release mcu message memory in case of failure in mt7915_mcu_add_beacon
routine

Fixes: e57b7901469fc ("mt76: add mac80211 driver for MT7915 PCIe-based chipsets")
Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2020-09-16 11:04:05 +02:00
Gustavo A. R. SilvaandFelix Fietkau 1ccd31bbe1 mt76: Use fallthrough pseudo-keyword
Replace the existing /* fall through */ comments and its variants with
the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary
fall-through markings when it is the case.

[1] https://www.kernel.org/doc/html/v5.7/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through

Signed-off-by: Gustavo A. R. Silva <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2020-09-08 23:44:29 +02:00
Felix Fietkau b1f4256861 mt76: mt7915: fix VHT LDPC capability
The MCU field should contain a boolean 0/1, not the flag itself

Signed-off-by: Felix Fietkau <[email protected]>
2020-09-04 19:31:36 +02:00
Felix Fietkau c4c8b6a20d mt76: mt7915: fix HE BSS info
he_pe_duration and he_rts_thres have the same unit as the fields in the HE
operation IE

Signed-off-by: Felix Fietkau <[email protected]>
2020-08-27 09:05:49 +02:00
Felix Fietkau 90c8422d3f mt76: mt7915: fix typo in function name
Signed-off-by: Felix Fietkau <[email protected]>
2020-08-24 06:49:14 +02:00
Felix Fietkau 795b772cd3 mt76: mt7915: add encap offload for 4-address mode stations
Enable MWDS mode in firmware as well and fix txp->rept_wds_wcid for wcid >= 255

Signed-off-by: Felix Fietkau <[email protected]>
2020-08-22 15:56:57 +02:00
Felix Fietkau 3a3306e408 mt76: mt7915: add 802.11 encap offload support
It is currently limited to 3-address mode AP and STA interfaces

Signed-off-by: Felix Fietkau <[email protected]>
2020-08-22 15:56:57 +02:00
Felix Fietkau 692065b4c9 mt76: mt7915: only enable hw amsdu for AP and station
Signed-off-by: Felix Fietkau <[email protected]>
2020-08-22 12:17:15 +02:00
Felix Fietkau efc8669db5 mt76: mt7615: fix max_mpdu_size field for A-MSDU
Signed-off-by: Felix Fietkau <[email protected]>
2020-08-13 09:52:37 +02:00
Ryder LeeandFelix Fietkau 21182f90d9 mt76: mt7915: add Tx A-MSDU offloading support
This disables the software A-MSDU aggregation in mac80211 and enables hardware
offloading

Suggested-by: Yiwei Chung <[email protected]>
Suggested-by: YF Luo <[email protected]>
Signed-off-by: Ryder Lee <[email protected]>
Signed-off-by: Shayne Chen <[email protected]>
Co-developed-by: Felix Fietkau <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2020-08-12 09:44:38 +02:00
Felix Fietkau 21f7734cbb mt76: mt7915: add missing flags in WMM parameter settings
Indicate the filled parameter to the firmware

Signed-off-by: Felix Fietkau <[email protected]>
2020-08-11 12:13:34 +02:00
Ryder LeeandFelix Fietkau 43d6127d88 mt76: mt7915: enable U-APSD on AP side
Enable U-APSD support for AP interface.

Signed-off-by: Ryder Lee <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2020-08-05 11:33:02 +02:00
Felix Fietkau 8d9a62e4de mt76: mt7915: fix crash on tx rate report for invalid stations
Check wcid RCU pointer before using it

Signed-off-by: Felix Fietkau <[email protected]>
2020-07-24 16:14:42 +02:00
Ryder LeeandFelix Fietkau 9a3723c8fe mt76: mt7915: fix potential memory leak in mcu message handler
Fix potential memory leak in mcu message handler on error condition.

Fixes: c6b002bcdf ("mt76: add mac80211 driver for MT7915 PCIe-based chipsets")
Signed-off-by: Ryder Lee <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2020-07-22 11:13:06 +02:00
Dan CarpenterandFelix Fietkau 379445b4aa mt76: mt7915: potential array overflow in mt7915_mcu_tx_rate_report()
Smatch complains that "wcidx" value comes from the network and thus
cannot be trusted.  In this case, it actually seems to come from the
firmware.  If your wireless firmware is malicious then probably no
amount of carefulness can protect you.

On the other hand, these days we still try to check the firmware as much
as possible.  Verifying that the index is within bounds will silence a
static checker warning.  And it's harmless and a good exercise in kernel
hardening.  So I suggest that we do add a bounds check.

Fixes: e57b7901469f ("mt76: add mac80211 driver for MT7915 PCIe-based chipsets")
Signed-off-by: Dan Carpenter <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2020-07-11 18:17:14 +02:00
Shayne ChenandFelix Fietkau b3a4d78914 mt76: mt7915: rework the flow of txpower setting
Clean up the flow of per-rate txpower limit setting to get rid of
dulplicate work since it has already been handled by firmware, and set
proper max_power based on different channels and regdomains.

Signed-off-by: Shayne Chen <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2020-06-22 21:26:16 +02:00
Shayne ChenandFelix Fietkau 53891242a6 mt76: mt7915: add support for DT rate power limits
Enable to limit per-rate max txpower from DT.

Tested-by: Evelyn Tsai <[email protected]>
Signed-off-by: Shayne Chen <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2020-06-22 21:26:16 +02:00
Ryder LeeandFelix Fietkau 1ce4660a0e mt76: mt7915: use ieee80211_tx_queue_params to avoid open coded
This is easy to add MU EDCA parameters in the future. This patch
also fixes a wrong cw_min assignment.

Signed-off-by: Ryder Lee <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2020-06-22 21:26:16 +02:00
Ryder LeeandFelix Fietkau dacc2d2967 mt76: mt7915: add MU-MIMO support
Enable MU-MIMO DL/UL and add relative counters in debugfs.

Currently MU modules read WTBL first to notify BA changes to
other cross modules, so adjust mt7915_mcu_sta_ba() accordingly.

Tested-by: Evelyn Tsai <[email protected]>
Signed-off-by: Ryder Lee <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2020-06-22 21:26:16 +02:00
YueHaibingandFelix Fietkau 85c5160813 mt76: mt7915: remove set but not used variable 'msta'
Fixes gcc '-Wunused-but-set-variable' warning:

drivers/net/wireless/mediatek/mt76/mt7915/mcu.c: In function 'mt7915_mcu_sta_txbf_type':
drivers/net/wireless/mediatek/mt76/mt7915/mcu.c:1805:21: warning:
 variable 'msta' set but not used [-Wunused-but-set-variable]

It is never used, so can be removed.

Reported-by: Hulk Robot <[email protected]>
Signed-off-by: YueHaibing <[email protected]>
2020-05-29 18:23:59 +02:00
YueHaibingandFelix Fietkau ed3a244fb6 mt76: mt7915: Fix build error
In file included from ./include/linux/firmware.h:6:0,
                 from drivers/net/wireless/mediatek/mt76/mt7915/mcu.c:4:
In function ‘__mt7915_mcu_msg_send’,
    inlined from ‘mt7915_mcu_send_message’ at drivers/net/wireless/mediatek/mt76/mt7915/mcu.c:370:6:
./include/linux/compiler.h:396:38: error: call to ‘__compiletime_assert_545’ declared with attribute error: BUILD_BUG_ON failed: cmd == MCU_EXT_CMD_EFUSE_ACCESS && mcu_txd->set_query != MCU_Q_QUERY
  _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
                                      ^
./include/linux/compiler.h:377:4: note: in definition of macro ‘__compiletime_assert’
    prefix ## suffix();    \
    ^~~~~~
./include/linux/compiler.h:396:2: note: in expansion of macro ‘_compiletime_assert’
  _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
  ^~~~~~~~~~~~~~~~~~~
./include/linux/build_bug.h:39:37: note: in expansion of macro ‘compiletime_assert’
 #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
                                     ^~~~~~~~~~~~~~~~~~
./include/linux/build_bug.h:50:2: note: in expansion of macro ‘BUILD_BUG_ON_MSG’
  BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
  ^~~~~~~~~~~~~~~~
drivers/net/wireless/mediatek/mt76/mt7915/mcu.c:280:2: note: in expansion of macro ‘BUILD_BUG_ON’
  BUILD_BUG_ON(cmd == MCU_EXT_CMD_EFUSE_ACCESS &&
  ^~~~~~~~~~~~

BUILD_BUG_ON is meaningless here, chang it to WARN_ON.

Fixes: e57b7901469f ("mt76: add mac80211 driver for MT7915 PCIe-based chipsets")
Signed-off-by: YueHaibing <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2020-05-22 14:42:27 +02:00
Ryder LeeandFelix Fietkau 01b784174c mt76: mt7915: fix sparse warnings: incorrect type initializer
drivers/net/wireless/mediatek/mt76/mt7915/mcu.c:2317:31: sparse: sparse:
incorrect type in initializer (different base types)

Fixes: 5517f78b0063 ("mt76: mt7915: enable firmware module debug support")
Reported-by: kbuild test robot <[email protected]>
Signed-off-by: Ryder Lee <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2020-05-20 10:37:17 +02:00
Ryder LeeandFelix Fietkau 1e3dc5b766 mt76: mt7915: fix some sparse warnings
This fixes the following sparse warning:

drivers/net/wireless/mediatek/mt76/mt7915/mcu.c:253:16: sparse: sparse: mixing different enum types:
drivers/net/wireless/mediatek/mt76/mt7915/mcu.c:253:16: sparse:    unsigned int enum mt7915_txq_id
drivers/net/wireless/mediatek/mt76/mt7915/mcu.c:253:16: sparse:    unsigned int enum mt76_txq_id
drivers/net/wireless/mediatek/mt76/mt7915/mcu.c:758:63: sparse: sparse: incorrect type in argument 2 (different address spaces)
drivers/net/wireless/mediatek/mt76/mt7915/mcu.c:758:63: sparse:    expected unsigned char const [usertype] *ies
drivers/net/wireless/mediatek/mt76/mt7915/mcu.c:758:63: sparse:    got unsigned char const [noderef] <asn:4> *
drivers/net/wireless/mediatek/mt76/mt7915/mcu.c:1390:23: sparse: sparse: incorrect type in argument 1 (different base types)
drivers/net/wireless/mediatek/mt76/mt7915/mcu.c:1390:23: sparse:    expected unsigned int w
drivers/net/wireless/mediatek/mt76/mt7915/mcu.c:1390:23: sparse:    got restricted __le32 [usertype] supp_ht_mcs
drivers/net/wireless/mediatek/mt76/mt7915/mcu.c:1390:23: sparse: sparse: restricted __le32 degrades to integer
drivers/net/wireless/mediatek/mt76/mt7915/mcu.c:1429:60: sparse: sparse: bad assignment (>>=) to restricted __le16
drivers/net/wireless/mediatek/mt76/mt7915/mcu.c:1773:16: sparse: sparse: restricted __le32 degrades to integer

Fixes: 6094f86fb371 ("mt76: mt7915: add HE bss_conf support for interfaces")
Reported-by: kbuild test robot <[email protected]>
Signed-off-by: Ryder Lee <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2020-05-20 10:37:17 +02:00
Ryder LeeandFelix Fietkau 7005aa8914 mt76: mt7915: add spatial reuse support
Enable or disable OBSS PD when the bss config changes or we
assoc to an AP that broadcasts the IE.

With this patch, we can get ~20% gain in OBSS OTA environment.

Tested-by: Evelyn Tsai <[email protected]>
Signed-off-by: Ryder Lee <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2020-05-20 10:37:17 +02:00
Ryder LeeandFelix Fietkau 9590db0254 mt76: mt7915: allocate proper size for tlv tags
Allocating proper memory size according to tlv usage.

Signed-off-by: Ryder Lee <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2020-05-12 19:19:02 +02:00