Commit f30906c5 authored by Felix Fietkau's avatar Felix Fietkau
Browse files

wifi: mt76: mt7996: disable beacons when going offchannel



Avoid leaking beacons on unrelated channels during scanning/roc

Fixes: c56d6ede ("wifi: mt76: mt7996: use emulated hardware scan support")
Reported-by: default avatarChad Monroe <chad.monroe@adtran.com>
Link: https://patch.msgid.link/20250813121106.81559-1-nbd@nbd.name


Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent 4c233458
Loading
Loading
Loading
Loading
+28 −18
Original line number Diff line number Diff line
@@ -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)
+5 −0
Original line number Diff line number Diff line
@@ -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,
+8 −3
Original line number Diff line number Diff line
@@ -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;

+1 −0
Original line number Diff line number Diff line
@@ -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);