mirror of
https://github.com/outbackdingo/mt76.git
synced 2026-10-24 13:26:48 +00:00
wifi: mt76: add per-link beacon monitoring for MLO
With chanctx drivers using hardware scan or remain-on-channel, mac80211 does not know when the radio goes off-channel, which breaks its software beacon loss detection. Implement per-link beacon monitoring in the driver. Track the last beacon timestamp per link and check for beacon loss periodically from the mac_work handler. Beacon monitoring is initialized on association and on late link activation, and cleared on disassociation. The beacon_mon_last timestamp is reset when returning from offchannel and after channel switches to prevent false beacon loss detection. Signed-off-by: Felix Fietkau <[email protected]>
This commit is contained in:
@@ -257,6 +257,8 @@ skip_link_replace:
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
mlink->ctx = vifs->new_ctx;
|
mlink->ctx = vifs->new_ctx;
|
||||||
|
if (mlink->beacon_mon_interval)
|
||||||
|
WRITE_ONCE(mlink->beacon_mon_last, jiffies);
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
|||||||
+108
-1
@@ -2202,8 +2202,11 @@ mt76_offchannel_notify_iter(void *_data, u8 *mac, struct ieee80211_vif *vif)
|
|||||||
mvif = mlink->mvif;
|
mvif = mlink->mvif;
|
||||||
|
|
||||||
if (!ieee80211_vif_is_mld(vif)) {
|
if (!ieee80211_vif_is_mld(vif)) {
|
||||||
if (mt76_vif_link_phy(mlink) == data->phy)
|
if (mt76_vif_link_phy(mlink) == data->phy) {
|
||||||
|
if (!data->offchannel && mlink->beacon_mon_interval)
|
||||||
|
WRITE_ONCE(mlink->beacon_mon_last, jiffies);
|
||||||
mt76_offchannel_send_nullfunc(data, vif, -1);
|
mt76_offchannel_send_nullfunc(data, vif, -1);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2217,6 +2220,9 @@ mt76_offchannel_notify_iter(void *_data, u8 *mac, struct ieee80211_vif *vif)
|
|||||||
if (mt76_vif_link_phy(mlink) != data->phy)
|
if (mt76_vif_link_phy(mlink) != data->phy)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (!data->offchannel && mlink->beacon_mon_interval)
|
||||||
|
WRITE_ONCE(mlink->beacon_mon_last, jiffies);
|
||||||
|
|
||||||
mt76_offchannel_send_nullfunc(data, vif, link_id);
|
mt76_offchannel_send_nullfunc(data, vif, link_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2238,3 +2244,104 @@ void mt76_offchannel_notify(struct mt76_phy *phy, bool offchannel)
|
|||||||
local_bh_enable();
|
local_bh_enable();
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(mt76_offchannel_notify);
|
EXPORT_SYMBOL_GPL(mt76_offchannel_notify);
|
||||||
|
|
||||||
|
struct mt76_rx_beacon_data {
|
||||||
|
struct mt76_phy *phy;
|
||||||
|
const u8 *bssid;
|
||||||
|
};
|
||||||
|
|
||||||
|
static void mt76_rx_beacon_iter(void *_data, u8 *mac,
|
||||||
|
struct ieee80211_vif *vif)
|
||||||
|
{
|
||||||
|
struct mt76_rx_beacon_data *data = _data;
|
||||||
|
struct mt76_vif_link *mlink = (struct mt76_vif_link *)vif->drv_priv;
|
||||||
|
struct mt76_vif_data *mvif = mlink->mvif;
|
||||||
|
int link_id;
|
||||||
|
|
||||||
|
if (vif->type != NL80211_IFTYPE_STATION || !vif->cfg.assoc)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (link_id = 0; link_id < IEEE80211_MLD_MAX_NUM_LINKS; link_id++) {
|
||||||
|
struct ieee80211_bss_conf *link_conf;
|
||||||
|
|
||||||
|
if (link_id == mvif->deflink_id)
|
||||||
|
mlink = (struct mt76_vif_link *)vif->drv_priv;
|
||||||
|
else
|
||||||
|
mlink = rcu_dereference(mvif->link[link_id]);
|
||||||
|
if (!mlink || !mlink->beacon_mon_interval)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (mt76_vif_link_phy(mlink) != data->phy)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
link_conf = rcu_dereference(vif->link_conf[link_id]);
|
||||||
|
if (!link_conf ||
|
||||||
|
!ether_addr_equal(link_conf->bssid, data->bssid))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
WRITE_ONCE(mlink->beacon_mon_last, jiffies);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void mt76_rx_beacon(struct mt76_phy *phy, struct sk_buff *skb)
|
||||||
|
{
|
||||||
|
struct mt76_rx_status *status = (struct mt76_rx_status *)skb->cb;
|
||||||
|
struct ieee80211_hdr *hdr = mt76_skb_get_hdr(skb);
|
||||||
|
struct mt76_rx_beacon_data data = {
|
||||||
|
.phy = phy,
|
||||||
|
.bssid = hdr->addr3,
|
||||||
|
};
|
||||||
|
|
||||||
|
mt76_scan_rx_beacon(phy->dev, phy->chandef.chan);
|
||||||
|
|
||||||
|
if (!phy->num_sta)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (status->flag & (RX_FLAG_FAILED_FCS_CRC | RX_FLAG_ONLY_MONITOR))
|
||||||
|
return;
|
||||||
|
|
||||||
|
ieee80211_iterate_active_interfaces_atomic(phy->hw,
|
||||||
|
IEEE80211_IFACE_ITER_RESUME_ALL,
|
||||||
|
mt76_rx_beacon_iter, &data);
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(mt76_rx_beacon);
|
||||||
|
|
||||||
|
static void mt76_beacon_mon_iter(void *data, u8 *mac,
|
||||||
|
struct ieee80211_vif *vif)
|
||||||
|
{
|
||||||
|
struct mt76_phy *phy = data;
|
||||||
|
struct mt76_vif_link *mlink = (struct mt76_vif_link *)vif->drv_priv;
|
||||||
|
struct mt76_vif_data *mvif = mlink->mvif;
|
||||||
|
int link_id;
|
||||||
|
|
||||||
|
if (vif->type != NL80211_IFTYPE_STATION || !vif->cfg.assoc)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (link_id = 0; link_id < IEEE80211_MLD_MAX_NUM_LINKS; link_id++) {
|
||||||
|
if (link_id == mvif->deflink_id)
|
||||||
|
mlink = (struct mt76_vif_link *)vif->drv_priv;
|
||||||
|
else
|
||||||
|
mlink = rcu_dereference(mvif->link[link_id]);
|
||||||
|
if (!mlink || !mlink->beacon_mon_interval)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (mt76_vif_link_phy(mlink) != phy)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (time_after(jiffies,
|
||||||
|
READ_ONCE(mlink->beacon_mon_last) +
|
||||||
|
MT76_BEACON_MON_MAX_MISS * mlink->beacon_mon_interval))
|
||||||
|
ieee80211_beacon_loss(vif);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void mt76_beacon_mon_check(struct mt76_phy *phy)
|
||||||
|
{
|
||||||
|
if (phy->offchannel)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ieee80211_iterate_active_interfaces_atomic(phy->hw,
|
||||||
|
IEEE80211_IFACE_ITER_RESUME_ALL,
|
||||||
|
mt76_beacon_mon_iter, phy);
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(mt76_beacon_mon_check);
|
||||||
|
|||||||
@@ -376,6 +376,7 @@ enum mt76_wcid_flags {
|
|||||||
};
|
};
|
||||||
|
|
||||||
#define MT76_N_WCIDS 1088
|
#define MT76_N_WCIDS 1088
|
||||||
|
#define MT76_BEACON_MON_MAX_MISS 7
|
||||||
|
|
||||||
/* stored in ieee80211_tx_info::hw_queue */
|
/* stored in ieee80211_tx_info::hw_queue */
|
||||||
#define MT_TX_HW_QUEUE_PHY GENMASK(3, 2)
|
#define MT_TX_HW_QUEUE_PHY GENMASK(3, 2)
|
||||||
@@ -845,6 +846,8 @@ struct mt76_vif_link {
|
|||||||
u8 mcast_rates_idx;
|
u8 mcast_rates_idx;
|
||||||
u8 beacon_rates_idx;
|
u8 beacon_rates_idx;
|
||||||
bool offchannel;
|
bool offchannel;
|
||||||
|
unsigned long beacon_mon_last;
|
||||||
|
u16 beacon_mon_interval;
|
||||||
struct ieee80211_chanctx_conf *ctx;
|
struct ieee80211_chanctx_conf *ctx;
|
||||||
struct mt76_wcid *wcid;
|
struct mt76_wcid *wcid;
|
||||||
struct mt76_vif_data *mvif;
|
struct mt76_vif_data *mvif;
|
||||||
@@ -1616,6 +1619,8 @@ int mt76_hw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
|
|||||||
struct ieee80211_scan_request *hw_req);
|
struct ieee80211_scan_request *hw_req);
|
||||||
void mt76_cancel_hw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif);
|
void mt76_cancel_hw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif);
|
||||||
void mt76_scan_rx_beacon(struct mt76_dev *dev, struct ieee80211_channel *chan);
|
void mt76_scan_rx_beacon(struct mt76_dev *dev, struct ieee80211_channel *chan);
|
||||||
|
void mt76_rx_beacon(struct mt76_phy *phy, struct sk_buff *skb);
|
||||||
|
void mt76_beacon_mon_check(struct mt76_phy *phy);
|
||||||
void mt76_sw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
|
void mt76_sw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
|
||||||
const u8 *mac);
|
const u8 *mac);
|
||||||
void mt76_sw_scan_complete(struct ieee80211_hw *hw,
|
void mt76_sw_scan_complete(struct ieee80211_hw *hw,
|
||||||
|
|||||||
+3
-3
@@ -515,9 +515,6 @@ mt7996_mac_fill_rx(struct mt7996_dev *dev, enum mt76_rxq_id q,
|
|||||||
qos_ctl = FIELD_GET(MT_RXD10_QOS_CTL, v2);
|
qos_ctl = FIELD_GET(MT_RXD10_QOS_CTL, v2);
|
||||||
seq_ctrl = FIELD_GET(MT_RXD10_SEQ_CTRL, v2);
|
seq_ctrl = FIELD_GET(MT_RXD10_SEQ_CTRL, v2);
|
||||||
|
|
||||||
if (ieee80211_is_beacon(fc))
|
|
||||||
mt76_scan_rx_beacon(&dev->mt76, mphy->chandef.chan);
|
|
||||||
|
|
||||||
rxd += 4;
|
rxd += 4;
|
||||||
if ((u8 *)rxd - skb->data >= skb->len)
|
if ((u8 *)rxd - skb->data >= skb->len)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
@@ -664,6 +661,8 @@ mt7996_mac_fill_rx(struct mt7996_dev *dev, enum mt76_rxq_id q,
|
|||||||
|
|
||||||
hdr = mt76_skb_get_hdr(skb);
|
hdr = mt76_skb_get_hdr(skb);
|
||||||
fc = hdr->frame_control;
|
fc = hdr->frame_control;
|
||||||
|
if (ieee80211_is_beacon(fc))
|
||||||
|
mt76_rx_beacon(mphy, skb);
|
||||||
if (ieee80211_is_data_qos(fc)) {
|
if (ieee80211_is_data_qos(fc)) {
|
||||||
u8 *qos = ieee80211_get_qos_ctl(hdr);
|
u8 *qos = ieee80211_get_qos_ctl(hdr);
|
||||||
|
|
||||||
@@ -2944,6 +2943,7 @@ void mt7996_mac_work(struct work_struct *work)
|
|||||||
|
|
||||||
mutex_unlock(&mphy->dev->mutex);
|
mutex_unlock(&mphy->dev->mutex);
|
||||||
|
|
||||||
|
mt76_beacon_mon_check(mphy);
|
||||||
mt76_tx_status_check(mphy->dev, false);
|
mt76_tx_status_check(mphy->dev, false);
|
||||||
|
|
||||||
ieee80211_queue_delayed_work(mphy->hw, &mphy->mac_work,
|
ieee80211_queue_delayed_work(mphy->hw, &mphy->mac_work,
|
||||||
|
|||||||
@@ -375,6 +375,17 @@ int mt7996_vif_link_add(struct mt76_phy *mphy, struct ieee80211_vif *vif,
|
|||||||
mvif->mt76.deflink_id = link_conf->link_id;
|
mvif->mt76.deflink_id = link_conf->link_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (vif->type == NL80211_IFTYPE_STATION) {
|
||||||
|
vif->driver_flags |= IEEE80211_VIF_BEACON_FILTER;
|
||||||
|
|
||||||
|
if (vif->cfg.assoc && link_conf->beacon_int) {
|
||||||
|
mlink->beacon_mon_interval =
|
||||||
|
msecs_to_jiffies(ieee80211_tu_to_usec(
|
||||||
|
link_conf->beacon_int) / 1000);
|
||||||
|
WRITE_ONCE(mlink->beacon_mon_last, jiffies);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -829,6 +840,13 @@ mt7996_vif_cfg_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
|
|||||||
if (!link)
|
if (!link)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (vif->type == NL80211_IFTYPE_STATION) {
|
||||||
|
link->mt76.beacon_mon_interval =
|
||||||
|
msecs_to_jiffies(ieee80211_tu_to_usec(
|
||||||
|
link_conf->beacon_int) / 1000);
|
||||||
|
WRITE_ONCE(link->mt76.beacon_mon_last, jiffies);
|
||||||
|
}
|
||||||
|
|
||||||
if (!link->phy)
|
if (!link->phy)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -841,6 +859,20 @@ mt7996_vif_cfg_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((changed & BSS_CHANGED_ASSOC) && !vif->cfg.assoc &&
|
||||||
|
vif->type == NL80211_IFTYPE_STATION) {
|
||||||
|
struct ieee80211_bss_conf *link_conf;
|
||||||
|
unsigned long link_id;
|
||||||
|
|
||||||
|
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->mt76.beacon_mon_interval = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
mutex_unlock(&dev->mt76.mutex);
|
mutex_unlock(&dev->mt76.mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -96,7 +96,6 @@ void mt76_scan_rx_beacon(struct mt76_dev *dev, struct ieee80211_channel *chan)
|
|||||||
dev->scan.beacon_received = true;
|
dev->scan.beacon_received = true;
|
||||||
ieee80211_queue_delayed_work(phy->hw, &dev->scan_work, 0);
|
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)
|
void mt76_scan_work(struct work_struct *work)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user