wifi: mt76: support upgrading passive scans to active

On channels with NO_IR or RADAR flags, wait for beacon before sending
probe requests. Allows active scanning and WPS on restricted channels
if another AP is already present.

Fixes: c56d6edebc1f ("wifi: mt76: mt7996: use emulated hardware scan support")
Signed-off-by: Chad Monroe <[email protected]>
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Felix Fietkau <[email protected]>
This commit is contained in:
Chad Monroe
2026-01-28 11:18:24 +00:00
committed by Felix Fietkau
parent 2596285c6a
commit 86abd922a4
3 changed files with 41 additions and 2 deletions
+35 -2
View File
@@ -79,6 +79,23 @@ out:
rcu_read_unlock();
}
void mt76_scan_rx_beacon(struct mt76_dev *dev, struct ieee80211_channel *chan)
{
struct mt76_phy *phy;
if (!dev->scan.beacon_wait || dev->scan.beacon_received ||
dev->scan.chan != chan)
return;
phy = dev->scan.phy;
if (!phy)
return;
dev->scan.beacon_received = true;
ieee80211_queue_delayed_work(phy->hw, &dev->scan_work, 0);
}
EXPORT_SYMBOL_GPL(mt76_scan_rx_beacon);
void mt76_scan_work(struct work_struct *work)
{
struct mt76_dev *dev = container_of(work, struct mt76_dev,
@@ -87,8 +104,18 @@ void mt76_scan_work(struct work_struct *work)
struct cfg80211_chan_def chandef = {};
struct mt76_phy *phy = dev->scan.phy;
int duration = HZ / 9; /* ~110 ms */
bool beacon_rx;
int i;
if (!phy || !req)
return;
beacon_rx = dev->scan.beacon_wait && dev->scan.beacon_received;
dev->scan.beacon_wait = false;
if (beacon_rx)
goto probe;
if (dev->scan.chan_idx >= req->n_channels) {
mt76_scan_complete(dev, false);
return;
@@ -105,10 +132,16 @@ void mt76_scan_work(struct work_struct *work)
if (dev->scan.chan != phy->main_chandef.chan)
mt76_set_channel(phy, &chandef, true);
if (!req->n_ssids ||
chandef.chan->flags & (IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_RADAR))
if (!req->n_ssids)
goto out;
if (chandef.chan->flags & (IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_RADAR)) {
dev->scan.beacon_received = false;
dev->scan.beacon_wait = true;
goto out;
}
probe:
if (phy->offchannel)
duration = HZ / 16; /* ~60 ms */
local_bh_disable();