]> www.infradead.org Git - users/griffoul/linux.git/commitdiff
wifi: mt76: mt7996: disable beacons when going offchannel
authorFelix Fietkau <nbd@nbd.name>
Wed, 13 Aug 2025 12:11:05 +0000 (14:11 +0200)
committerFelix Fietkau <nbd@nbd.name>
Wed, 27 Aug 2025 09:20:34 +0000 (11:20 +0200)
Avoid leaking beacons on unrelated channels during scanning/roc

Fixes: c56d6edebc1f ("wifi: mt76: mt7996: use emulated hardware scan support")
Reported-by: Chad Monroe <chad.monroe@adtran.com>
Link: https://patch.msgid.link/20250813121106.81559-1-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 22653449079245c78bfcd0edbe5bcc55d6179929..a9f7e5626dcdda5b18a8544fdd75c07adb132926 100644 (file)
@@ -1694,43 +1694,53 @@ mt7996_wait_reset_state(struct mt7996_dev *dev, u32 state)
 static void
 mt7996_update_vif_beacon(void *priv, u8 *mac, struct ieee80211_vif *vif)
 {
-       struct ieee80211_hw *hw = priv;
+       struct ieee80211_bss_conf *link_conf;
+       struct mt7996_phy *phy = priv;
+       struct mt7996_dev *dev = phy->dev;
+       unsigned int link_id;
+
 
        switch (vif->type) {
        case NL80211_IFTYPE_MESH_POINT:
        case NL80211_IFTYPE_ADHOC:
        case NL80211_IFTYPE_AP:
-               mt7996_mcu_add_beacon(hw, vif, &vif->bss_conf);
                break;
        default:
-               break;
+               return;
+       }
+
+       for_each_vif_active_link(vif, link_conf, link_id) {
+               struct mt7996_vif_link *link;
+
+               link = mt7996_vif_link(dev, vif, link_id);
+               if (!link || link->phy != phy)
+                       continue;
+
+               mt7996_mcu_add_beacon(dev->mt76.hw, vif, link_conf);
        }
 }
 
+void mt7996_mac_update_beacons(struct mt7996_phy *phy)
+{
+       ieee80211_iterate_active_interfaces(phy->mt76->hw,
+                                           IEEE80211_IFACE_ITER_RESUME_ALL,
+                                           mt7996_update_vif_beacon, phy);
+}
+
 static void
 mt7996_update_beacons(struct mt7996_dev *dev)
 {
        struct mt76_phy *phy2, *phy3;
 
-       ieee80211_iterate_active_interfaces(dev->mt76.hw,
-                                           IEEE80211_IFACE_ITER_RESUME_ALL,
-                                           mt7996_update_vif_beacon, dev->mt76.hw);
+       mt7996_mac_update_beacons(&dev->phy);
 
        phy2 = dev->mt76.phys[MT_BAND1];
-       if (!phy2)
-               return;
-
-       ieee80211_iterate_active_interfaces(phy2->hw,
-                                           IEEE80211_IFACE_ITER_RESUME_ALL,
-                                           mt7996_update_vif_beacon, phy2->hw);
+       if (phy2)
+               mt7996_mac_update_beacons(phy2->priv);
 
        phy3 = dev->mt76.phys[MT_BAND2];
-       if (!phy3)
-               return;
-
-       ieee80211_iterate_active_interfaces(phy3->hw,
-                                           IEEE80211_IFACE_ITER_RESUME_ALL,
-                                           mt7996_update_vif_beacon, phy3->hw);
+       if (phy3)
+               mt7996_mac_update_beacons(phy3->priv);
 }
 
 void mt7996_tx_token_put(struct mt7996_dev *dev)
index 92b57bcce749245d62ad831e6e26a3a56d3b5bed..84f731b387d20aae35477e59ca5c6496f894dd40 100644 (file)
@@ -516,6 +516,9 @@ int mt7996_set_channel(struct mt76_phy *mphy)
        struct mt7996_phy *phy = mphy->priv;
        int ret;
 
+       if (mphy->offchannel)
+               mt7996_mac_update_beacons(phy);
+
        ret = mt7996_mcu_set_chan_info(phy, UNI_CHANNEL_SWITCH);
        if (ret)
                goto out;
@@ -533,6 +536,8 @@ int mt7996_set_channel(struct mt76_phy *mphy)
 
        mt7996_mac_reset_counters(phy);
        phy->noise = 0;
+       if (!mphy->offchannel)
+               mt7996_mac_update_beacons(phy);
 
 out:
        ieee80211_queue_delayed_work(mphy->hw, &mphy->mac_work,
index fe1b34386de232fd9c5a0f3609baec1e46fe113c..0be03eb3cf46135b661acf03aa11b682c815657b 100644 (file)
@@ -2755,13 +2755,15 @@ int mt7996_mcu_add_beacon(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
                          struct ieee80211_bss_conf *link_conf)
 {
        struct mt7996_dev *dev = mt7996_hw_dev(hw);
-       struct mt76_vif_link *mlink = mt76_vif_conf_link(&dev->mt76, vif, link_conf);
+       struct mt7996_vif_link *link = mt7996_vif_conf_link(dev, vif, link_conf);
+       struct mt76_vif_link *mlink = link ? &link->mt76 : NULL;
        struct ieee80211_mutable_offsets offs;
        struct ieee80211_tx_info *info;
        struct sk_buff *skb, *rskb;
        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;
@@ -2769,13 +2771,16 @@ int mt7996_mcu_add_beacon(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
        if (!mlink)
                return -EINVAL;
 
+       if (link->phy && link->phy->mt76->offchannel)
+               enabled = false;
+
        rskb = __mt7996_mcu_alloc_bss_req(&dev->mt76, mlink,
                                          MT7996_MAX_BSS_OFFLOAD_SIZE);
        if (IS_ERR(rskb))
                return PTR_ERR(rskb);
 
        skb = ieee80211_beacon_get_template(hw, vif, &offs, link_conf->link_id);
-       if (link_conf->enable_beacon && !skb) {
+       if (enabled && !skb) {
                dev_kfree_skb(rskb);
                return -EINVAL;
        }
@@ -2794,7 +2799,7 @@ int mt7996_mcu_add_beacon(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
        len = ALIGN(sizeof(*bcn) + MT_TXD_SIZE + extra_len, 4);
        tlv = mt7996_mcu_add_uni_tlv(rskb, UNI_BSS_INFO_BCN_CONTENT, len);
        bcn = (struct bss_bcn_content_tlv *)tlv;
-       bcn->enable = link_conf->enable_beacon;
+       bcn->enable = enabled;
        if (!bcn->enable)
                goto out;
 
index 33ac16b64ef113eff3f7749963e34a49b3c67ac3..8509d508e1e19c077d05e03d813b496c668d0682 100644 (file)
@@ -732,6 +732,7 @@ void mt7996_mac_write_txwi(struct mt7996_dev *dev, __le32 *txwi,
                           struct sk_buff *skb, struct mt76_wcid *wcid,
                           struct ieee80211_key_conf *key, int pid,
                           enum mt76_txq_id qid, u32 changed);
+void mt7996_mac_update_beacons(struct mt7996_phy *phy);
 void mt7996_mac_set_coverage_class(struct mt7996_phy *phy);
 void mt7996_mac_work(struct work_struct *work);
 void mt7996_mac_reset_work(struct work_struct *work);