Skip to content

Commit eb19d5f

Browse files
nbd168gregkh
authored andcommitted
wifi: mt76: mt7996: disable beacons when going offchannel
[ Upstream commit f30906c ] 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> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 731ea9b commit eb19d5f

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
@@ -1696,43 +1696,53 @@ mt7996_wait_reset_state(struct mt7996_dev *dev, u32 state)
16961696
static void
16971697
mt7996_update_vif_beacon(void *priv, u8 *mac, struct ieee80211_vif *vif)
16981698
{
1699-
struct ieee80211_hw *hw = priv;
1699+
struct ieee80211_bss_conf *link_conf;
1700+
struct mt7996_phy *phy = priv;
1701+
struct mt7996_dev *dev = phy->dev;
1702+
unsigned int link_id;
1703+
17001704

17011705
switch (vif->type) {
17021706
case NL80211_IFTYPE_MESH_POINT:
17031707
case NL80211_IFTYPE_ADHOC:
17041708
case NL80211_IFTYPE_AP:
1705-
mt7996_mcu_add_beacon(hw, vif, &vif->bss_conf);
17061709
break;
17071710
default:
1708-
break;
1711+
return;
1712+
}
1713+
1714+
for_each_vif_active_link(vif, link_conf, link_id) {
1715+
struct mt7996_vif_link *link;
1716+
1717+
link = mt7996_vif_link(dev, vif, link_id);
1718+
if (!link || link->phy != phy)
1719+
continue;
1720+
1721+
mt7996_mcu_add_beacon(dev->mt76.hw, vif, link_conf);
17091722
}
17101723
}
17111724

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

1717-
ieee80211_iterate_active_interfaces(dev->mt76.hw,
1718-
IEEE80211_IFACE_ITER_RESUME_ALL,
1719-
mt7996_update_vif_beacon, dev->mt76.hw);
1737+
mt7996_mac_update_beacons(&dev->phy);
17201738

17211739
phy2 = dev->mt76.phys[MT_BAND1];
1722-
if (!phy2)
1723-
return;
1724-
1725-
ieee80211_iterate_active_interfaces(phy2->hw,
1726-
IEEE80211_IFACE_ITER_RESUME_ALL,
1727-
mt7996_update_vif_beacon, phy2->hw);
1740+
if (phy2)
1741+
mt7996_mac_update_beacons(phy2->priv);
17281742

17291743
phy3 = dev->mt76.phys[MT_BAND2];
1730-
if (!phy3)
1731-
return;
1732-
1733-
ieee80211_iterate_active_interfaces(phy3->hw,
1734-
IEEE80211_IFACE_ITER_RESUME_ALL,
1735-
mt7996_update_vif_beacon, phy3->hw);
1744+
if (phy3)
1745+
mt7996_mac_update_beacons(phy3->priv);
17361746
}
17371747

17381748
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)