Skip to contentSkip to conversation

wifi: mt76: clear cipher state on key removal for WED offload

PATCH Superseded Joshua Klinesmith 1 participant 3 messages Apr 6

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover wifi: mt76: clear cipher state on key removal for WED offload

When switching WiFi encryption from WPA-PSK/SAE to open/none with WED hardware offload enabled, throughput drops to zero. The BSS cipher state is set when group keys are installed but never cleared when they are removed. The WA firmware retains the stale cipher value and keeps the protection bit set on WED-offloaded packets, causing all plaintext frames to be dropped.

Found via reverse engineering of the vendor MediaTek SDK mt_wifi.ko driver.

Joshua Klinesmith (2):
wifi: mt76: mt7915: clear cipher state on key removal for WED offload
wifi: mt76: mt7996: clear cipher state on key removal for WED offload

 drivers/net/wireless/mediatek/mt76/mt7915/main.c | 14 +++++---------
 drivers/net/wireless/mediatek/mt76/mt7996/main.c | 15 +++++++++++++++
 2 files changed, 20 insertions(+), 9 deletions(-)

base-commit: 024906a6d4d43554a0b9076dd25d8b35f5eaf0bb

Signature · 1 line
2.43.0
#1 lore raw

PATCH 1/2 wifi: mt76: mt7915: clear cipher state on key removal for WED offload

When switching from WPA-PSK/SAE to open/no encryption, the DISABLE_KEY path never resets mvif->mt76.cipher back to zero. The stale cipher value is sent to the WA firmware via BSS_INFO updates, causing the firmware to keep the protection bit set on WED-offloaded packets. The hardware then drops all plaintext frames, resulting in zero throughput.

Reset mvif->mt76.cipher to zero and notify the firmware via mt7915_mcu_add_bss_info() when the last group key is removed.

Fixes 3fd2dbd6a1d3 ("mt76: mt7915: update bss_info with cipher after setting the group key")
---
 drivers/net/wireless/mediatek/mt76/mt7915/main.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7915/main.c +5 -9
index fe0639c14b..8d32729a58 100644
@@ -414,7 +414,11 @@ static int mt7915_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
 	} else {
 		if (idx == *wcid_keyidx)
 			*wcid_keyidx = -1;
-		goto out;
+
+		if (!sta && mvif->mt76.cipher) {
+			mvif->mt76.cipher = 0;
+			mt7915_mcu_add_bss_info(phy, vif, true);
+		}
 	}
 
 	mt76_wcid_key_setup(&dev->mt76, wcid, key);
@@ -486,10 +490,6 @@ static int mt7915_config(struct ieee80211_hw *hw, int radio_idx,
 		if (!enabled) {
 			rxfilter |= MT_WF_RFCR_DROP_OTHER_UC;
 			dev->monitor_mask &= ~BIT(band);
-		} else {
-			rxfilter &= ~MT_WF_RFCR_DROP_OTHER_UC;
-			dev->monitor_mask |= BIT(band);
-		}
 
 		mt76_rmw_field(dev, MT_DMA_DCR0(band), MT_DMA_DCR0_RXD_G5_EN,
 			       enabled);
@@ -1166,10 +1166,6 @@ static void mt7915_sta_statistics(struct ieee80211_hw *hw,
 	if (txrate->legacy || txrate->flags) {
 		if (txrate->legacy) {
 			sinfo->txrate.legacy = txrate->legacy;
-		} else {
-			sinfo->txrate.mcs = txrate->mcs;
-			sinfo->txrate.nss = txrate->nss;
-			sinfo->txrate.bw = txrate->bw;
 			sinfo->txrate.he_gi = txrate->he_gi;
 			sinfo->txrate.he_dcm = txrate->he_dcm;
 			sinfo->txrate.he_ru_alloc = txrate->he_ru_alloc;
Signature · 1 line
2.43.0
#2 lore raw

PATCH 2/2 wifi: mt76: mt7996: clear cipher state on key removal for WED offload

In reply to Joshua Klinesmith

Same issue as mt7915: link->mt76.cipher is set on key installation but never cleared on removal. The WA firmware retains the stale cipher in BSS_INFO, sets the protection bit on WED-offloaded frames, and drops all plaintext traffic when encryption is switched to open/none.

Reset link->mt76.cipher to zero and call mt7996_mcu_add_bss_info() when the last group key is removed.

Fixes 98686cd21624 ("wifi: mt76: mt7996: add driver for MediaTek Wi-Fi 7 (802.11be) devices")
---
 drivers/net/wireless/mediatek/mt76/mt7996/main.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
drivers/net/wireless/mediatek/mt76/mt7996/main.c +15 -0
index 84f731b387..bf5fda6925 100644
@@ -235,6 +235,21 @@ mt7996_set_hw_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
 		} else {
 			if (idx == *wcid_keyidx)
 				*wcid_keyidx = -1;
+
+			if (!sta && link->mt76.cipher) {
+				struct ieee80211_bss_conf *lc;
+
+				lc = link_conf_dereference_protected(vif,
+								     link_id);
+				if (!lc)
+					lc = &vif->bss_conf;
+
+				link->mt76.cipher = 0;
+				mt7996_mcu_add_bss_info(link->phy, vif, lc,
+							&link->mt76,
+							msta_link, true);
+			}
+
 			continue;
 		}
 
Signature · 1 line
2.43.0