]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
wifi: mt76: mt7996: fix updating beacon protection with beacons enabled
authorFelix Fietkau <nbd@nbd.name>
Mon, 15 Sep 2025 07:59:03 +0000 (09:59 +0200)
committerFelix Fietkau <nbd@nbd.name>
Mon, 15 Sep 2025 11:23:01 +0000 (13:23 +0200)
Disable and re-enable beacon after beacon protection key change, in order
to fully apply the changes.

Link: https://patch.msgid.link/20250915075910.47558-8-nbd@nbd.name
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt7996/mac.c
drivers/net/wireless/mediatek/mt76/mt7996/main.c
drivers/net/wireless/mediatek/mt76/mt7996/mcu.c
drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h

index fd57569a7da7cb6a1f6d176a4fbba9a9a8537528..289f69cc2bdffa6417f3b9c259a9a834a3f6f98e 100644 (file)
@@ -2176,7 +2176,8 @@ mt7996_update_vif_beacon(void *priv, u8 *mac, struct ieee80211_vif *vif)
                if (!link || link->phy != phy)
                        continue;
 
-               mt7996_mcu_add_beacon(dev->mt76.hw, vif, link_conf);
+               mt7996_mcu_add_beacon(dev->mt76.hw, vif, link_conf,
+                                     link_conf->enable_beacon);
        }
 }
 
index d706b8bb244e21c0705b705732cb6cca2b844e67..581314368c5ba566f6050bee86696c4654619176 100644 (file)
@@ -185,10 +185,13 @@ mt7996_set_hw_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
                  unsigned int link_id, struct ieee80211_key_conf *key)
 {
        struct mt7996_dev *dev = mt7996_hw_dev(hw);
+       struct ieee80211_bss_conf *link_conf;
        struct mt7996_sta_link *msta_link;
        struct mt7996_vif_link *link;
        int idx = key->keyidx;
        u8 *wcid_keyidx;
+       bool is_bigtk;
+       int err;
 
        link = mt7996_vif_link(dev, vif, link_id);
        if (!link)
@@ -213,12 +216,13 @@ mt7996_set_hw_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
        }
        wcid_keyidx = &msta_link->wcid.hw_key_idx;
 
+       is_bigtk = key->keyidx == 6 || key->keyidx == 7;
        switch (key->cipher) {
        case WLAN_CIPHER_SUITE_AES_CMAC:
        case WLAN_CIPHER_SUITE_BIP_CMAC_256:
        case WLAN_CIPHER_SUITE_BIP_GMAC_128:
        case WLAN_CIPHER_SUITE_BIP_GMAC_256:
-               if (key->keyidx == 6 || key->keyidx == 7) {
+               if (is_bigtk) {
                        wcid_keyidx = &msta_link->wcid.hw_key_idx2;
                        key->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIE;
                }
@@ -227,14 +231,11 @@ mt7996_set_hw_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
                break;
        }
 
-       if (cmd == SET_KEY && !sta && !link->mt76.cipher) {
-               struct ieee80211_bss_conf *link_conf;
-
-               link_conf = link_conf_dereference_protected(vif,
-                                                           link_id);
-               if (!link_conf)
-                       link_conf = &vif->bss_conf;
+       link_conf = link_conf_dereference_protected(vif, link_id);
+       if (!link_conf)
+               link_conf = &vif->bss_conf;
 
+       if (cmd == SET_KEY && !sta && !link->mt76.cipher) {
                link->mt76.cipher =
                        mt76_connac_mcu_get_cipher(key->cipher);
                mt7996_mcu_add_bss_info(link->phy, vif, link_conf,
@@ -251,9 +252,17 @@ mt7996_set_hw_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
 
        mt76_wcid_key_setup(&dev->mt76, &msta_link->wcid, key);
 
-       return mt7996_mcu_add_key(&dev->mt76, vif, key,
-                                 MCU_WMWA_UNI_CMD(STA_REC_UPDATE),
-                                 &msta_link->wcid, cmd);
+       err = mt7996_mcu_add_key(&dev->mt76, vif, key,
+                                MCU_WMWA_UNI_CMD(STA_REC_UPDATE),
+                                &msta_link->wcid, cmd);
+
+       /* remove and add beacon in order to enable beacon protection */
+       if (cmd == SET_KEY && is_bigtk && link_conf->enable_beacon) {
+               mt7996_mcu_add_beacon(hw, vif, link_conf, false);
+               mt7996_mcu_add_beacon(hw, vif, link_conf, true);
+       }
+
+       return err;
 }
 
 struct mt7996_key_iter_data {
@@ -900,7 +909,7 @@ mt7996_link_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
                link->mt76.beacon_rates_idx =
                        mt7996_get_rates_table(phy, info, true, false);
 
-               mt7996_mcu_add_beacon(hw, vif, info);
+               mt7996_mcu_add_beacon(hw, vif, info, info->enable_beacon);
        }
 
        if (changed & (BSS_CHANGED_UNSOL_BCAST_PROBE_RESP |
@@ -928,7 +937,7 @@ mt7996_channel_switch_beacon(struct ieee80211_hw *hw,
        struct mt7996_dev *dev = mt7996_hw_dev(hw);
 
        mutex_lock(&dev->mt76.mutex);
-       mt7996_mcu_add_beacon(hw, vif, &vif->bss_conf);
+       mt7996_mcu_add_beacon(hw, vif, &vif->bss_conf, vif->bss_conf.enable_beacon);
        mutex_unlock(&dev->mt76.mutex);
 }
 
index 5707e6b59aeaf064d4076f3abc2dab2959312aa3..07a1e542571c578d1eaa54e0f09923693a5d091f 100644 (file)
@@ -2760,7 +2760,7 @@ mt7996_mcu_beacon_cont(struct mt7996_dev *dev,
 }
 
 int mt7996_mcu_add_beacon(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
-                         struct ieee80211_bss_conf *link_conf)
+                         struct ieee80211_bss_conf *link_conf, bool enabled)
 {
        struct mt7996_dev *dev = mt7996_hw_dev(hw);
        struct mt7996_vif_link *link = mt7996_vif_conf_link(dev, vif, link_conf);
@@ -2771,7 +2771,6 @@ int mt7996_mcu_add_beacon(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
        struct tlv *tlv;
        struct bss_bcn_content_tlv *bcn;
        int len, extra_len = 0;
-       bool enabled = link_conf->enable_beacon;
 
        if (link_conf->nontransmitted)
                return 0;
index fa10aa6f517a97d5d74c57b0520c2c9145ea8c25..8ec2acdb33193752a51ecbb28014545015724b5c 100644 (file)
@@ -682,7 +682,7 @@ int mt7996_mcu_update_bss_color(struct mt7996_dev *dev,
                                struct mt76_vif_link *mlink,
                                struct cfg80211_he_bss_color *he_bss_color);
 int mt7996_mcu_add_beacon(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
-                         struct ieee80211_bss_conf *link_conf);
+                         struct ieee80211_bss_conf *link_conf, bool enabled);
 int mt7996_mcu_beacon_inband_discov(struct mt7996_dev *dev,
                                    struct ieee80211_bss_conf *link_conf,
                                    struct mt7996_vif_link *link, u32 changed);