mvif = mlink->mvif;
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);
+ }
return;
}
if (mt76_vif_link_phy(mlink) != data->phy)
continue;
+ if (!data->offchannel && mlink->beacon_mon_interval)
+ WRITE_ONCE(mlink->beacon_mon_last, jiffies);
+
mt76_offchannel_send_nullfunc(data, vif, link_id);
}
}
local_bh_enable();
}
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)
+ continue;
+
+ if (!ether_addr_equal(link_conf->bssid, data->bssid) &&
+ (!link_conf->nontransmitted ||
+ !ether_addr_equal(link_conf->transmitter_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);
};
#define MT76_N_WCIDS 1088
+#define MT76_BEACON_MON_MAX_MISS 7
/* stored in ieee80211_tx_info::hw_queue */
#define MT_TX_HW_QUEUE_PHY GENMASK(3, 2)
u8 mcast_rates_idx;
u8 beacon_rates_idx;
bool offchannel;
+ unsigned long beacon_mon_last;
+ u16 beacon_mon_interval;
struct ieee80211_chanctx_conf *ctx;
struct mt76_wcid *wcid;
struct mt76_vif_data *mvif;
struct ieee80211_scan_request *hw_req);
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_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,
const u8 *mac);
void mt76_sw_scan_complete(struct ieee80211_hw *hw,
qos_ctl = FIELD_GET(MT_RXD10_QOS_CTL, 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;
if ((u8 *)rxd - skb->data >= skb->len)
return -EINVAL;
hdr = mt76_skb_get_hdr(skb);
fc = hdr->frame_control;
+ if (ieee80211_is_beacon(fc))
+ mt76_rx_beacon(mphy, skb);
if (ieee80211_is_data_qos(fc)) {
u8 *qos = ieee80211_get_qos_ctl(hdr);
mutex_unlock(&mphy->dev->mutex);
+ mt76_beacon_mon_check(mphy);
mt76_tx_status_check(mphy->dev, false);
ieee80211_queue_delayed_work(mphy->hw, &mphy->mac_work,
mtxq->wcid = idx;
}
+ 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;
}
if (!link)
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);
+ }
+
phy = mt7996_vif_link_phy(link);
if (!phy)
continue;
}
}
+ 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);
}