Skip to content

Commit f30906c

Browse files
committed
wifi: mt76: mt7996: disable beacons when going offchannel
Avoid leaking beacons on unrelated channels during scanning/roc Fixes: c56d6ed ("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>
1 parent 4c23345 commit f30906c

File tree

4 files changed

+42
-21
lines changed

4 files changed

+42
-21
lines changed

drivers/net/wireless/mediatek/mt76/mt7996/mac.c

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1694,43 +1694,53 @@ mt7996_wait_reset_state(struct mt7996_dev *dev, u32 state)
16941694
static void
16951695
mt7996_update_vif_beacon(void *priv, u8 *mac, struct ieee80211_vif *vif)
16961696
{
1697-
struct ieee80211_hw *hw = priv;
1697+
struct ieee80211_bss_conf *link_conf;
1698+
struct mt7996_phy *phy = priv;
1699+
struct mt7996_dev *dev = phy->dev;
1700+
unsigned int link_id;
1701+
16981702

16991703
switch (vif->type) {
17001704
case NL80211_IFTYPE_MESH_POINT:
17011705
case NL80211_IFTYPE_ADHOC:
17021706
case NL80211_IFTYPE_AP:
1703-
mt7996_mcu_add_beacon(hw, vif, &vif->bss_conf);
17041707
break;
17051708
default:
1706-
break;
1709+
return;
1710+
}
1711+
1712+
for_each_vif_active_link(vif, link_conf, link_id) {
1713+
struct mt7996_vif_link *link;
1714+
1715+
link = mt7996_vif_link(dev, vif, link_id);
1716+
if (!link || link->phy != phy)
1717+
continue;
1718+
1719+
mt7996_mcu_add_beacon(dev->mt76.hw, vif, link_conf);
17071720
}
17081721
}
17091722

1723+
void mt7996_mac_update_beacons(struct mt7996_phy *phy)
1724+
{
1725+
ieee80211_iterate_active_interfaces(phy->mt76->hw,
1726+
IEEE80211_IFACE_ITER_RESUME_ALL,
1727+
mt7996_update_vif_beacon, phy);
1728+
}
1729+
17101730
static void
17111731
mt7996_update_beacons(struct mt7996_dev *dev)
17121732
{
17131733
struct mt76_phy *phy2, *phy3;
17141734

1715-
ieee80211_iterate_active_interfaces(dev->mt76.hw,
1716-
IEEE80211_IFACE_ITER_RESUME_ALL,
1717-
mt7996_update_vif_beacon, dev->mt76.hw);
1735+
mt7996_mac_update_beacons(&dev->phy);
17181736

17191737
phy2 = dev->mt76.phys[MT_BAND1];
1720-
if (!phy2)
1721-
return;
1722-
1723-
ieee80211_iterate_active_interfaces(phy2->hw,
1724-
IEEE80211_IFACE_ITER_RESUME_ALL,
1725-
mt7996_update_vif_beacon, phy2->hw);
1738+
if (phy2)
1739+
mt7996_mac_update_beacons(phy2->priv);
17261740

17271741
phy3 = dev->mt76.phys[MT_BAND2];
1728-
if (!phy3)
1729-
return;
1730-
1731-
ieee80211_iterate_active_interfaces(phy3->hw,
1732-
IEEE80211_IFACE_ITER_RESUME_ALL,
1733-
mt7996_update_vif_beacon, phy3->hw);
1742+
if (phy3)
1743+
mt7996_mac_update_beacons(phy3->priv);
17341744
}
17351745

17361746
void mt7996_tx_token_put(struct mt7996_dev *dev)

drivers/net/wireless/mediatek/mt76/mt7996/main.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,9 @@ int mt7996_set_channel(struct mt76_phy *mphy)
516516
struct mt7996_phy *phy = mphy->priv;
517517
int ret;
518518

519+
if (mphy->offchannel)
520+
mt7996_mac_update_beacons(phy);
521+
519522
ret = mt7996_mcu_set_chan_info(phy, UNI_CHANNEL_SWITCH);
520523
if (ret)
521524
goto out;
@@ -533,6 +536,8 @@ int mt7996_set_channel(struct mt76_phy *mphy)
533536

534537
mt7996_mac_reset_counters(phy);
535538
phy->noise = 0;
539+
if (!mphy->offchannel)
540+
mt7996_mac_update_beacons(phy);
536541

537542
out:
538543
ieee80211_queue_delayed_work(mphy->hw, &mphy->mac_work,

drivers/net/wireless/mediatek/mt76/mt7996/mcu.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2755,27 +2755,32 @@ int mt7996_mcu_add_beacon(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
27552755
struct ieee80211_bss_conf *link_conf)
27562756
{
27572757
struct mt7996_dev *dev = mt7996_hw_dev(hw);
2758-
struct mt76_vif_link *mlink = mt76_vif_conf_link(&dev->mt76, vif, link_conf);
2758+
struct mt7996_vif_link *link = mt7996_vif_conf_link(dev, vif, link_conf);
2759+
struct mt76_vif_link *mlink = link ? &link->mt76 : NULL;
27592760
struct ieee80211_mutable_offsets offs;
27602761
struct ieee80211_tx_info *info;
27612762
struct sk_buff *skb, *rskb;
27622763
struct tlv *tlv;
27632764
struct bss_bcn_content_tlv *bcn;
27642765
int len, extra_len = 0;
2766+
bool enabled = link_conf->enable_beacon;
27652767

27662768
if (link_conf->nontransmitted)
27672769
return 0;
27682770

27692771
if (!mlink)
27702772
return -EINVAL;
27712773

2774+
if (link->phy && link->phy->mt76->offchannel)
2775+
enabled = false;
2776+
27722777
rskb = __mt7996_mcu_alloc_bss_req(&dev->mt76, mlink,
27732778
MT7996_MAX_BSS_OFFLOAD_SIZE);
27742779
if (IS_ERR(rskb))
27752780
return PTR_ERR(rskb);
27762781

27772782
skb = ieee80211_beacon_get_template(hw, vif, &offs, link_conf->link_id);
2778-
if (link_conf->enable_beacon && !skb) {
2783+
if (enabled && !skb) {
27792784
dev_kfree_skb(rskb);
27802785
return -EINVAL;
27812786
}
@@ -2794,7 +2799,7 @@ int mt7996_mcu_add_beacon(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
27942799
len = ALIGN(sizeof(*bcn) + MT_TXD_SIZE + extra_len, 4);
27952800
tlv = mt7996_mcu_add_uni_tlv(rskb, UNI_BSS_INFO_BCN_CONTENT, len);
27962801
bcn = (struct bss_bcn_content_tlv *)tlv;
2797-
bcn->enable = link_conf->enable_beacon;
2802+
bcn->enable = enabled;
27982803
if (!bcn->enable)
27992804
goto out;
28002805

drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,7 @@ void mt7996_mac_write_txwi(struct mt7996_dev *dev, __le32 *txwi,
732732
struct sk_buff *skb, struct mt76_wcid *wcid,
733733
struct ieee80211_key_conf *key, int pid,
734734
enum mt76_txq_id qid, u32 changed);
735+
void mt7996_mac_update_beacons(struct mt7996_phy *phy);
735736
void mt7996_mac_set_coverage_class(struct mt7996_phy *phy);
736737
void mt7996_mac_work(struct work_struct *work);
737738
void mt7996_mac_reset_work(struct work_struct *work);

0 commit comments

Comments
 (0)