if (mlink)
mlink->mvif->roc_phy = NULL;
if (phy->chanctx && phy->main_chandef.chan && phy->offchannel &&
- !test_bit(MT76_MCU_RESET, &dev->phy.state))
+ !test_bit(MT76_MCU_RESET, &dev->phy.state)) {
__mt76_set_channel(phy, &phy->main_chandef, false);
+ mt76_offchannel_notify(phy, false);
+ }
mt76_put_vif_phy_link(phy, phy->roc_vif, phy->roc_link);
phy->roc_vif = NULL;
phy->roc_link = NULL;
struct mt76_phy *phy = hw->priv;
struct mt76_dev *dev = phy->dev;
struct mt76_vif_link *mlink;
+ bool offchannel;
int ret = 0;
phy = dev->band_phys[chan->band];
mlink->mvif->roc_phy = phy;
phy->roc_vif = vif;
phy->roc_link = mlink;
- ret = __mt76_set_channel(phy, &chandef,
- mt76_offchannel_chandef(phy, chan, &chandef));
+
+ offchannel = mt76_offchannel_chandef(phy, chan, &chandef);
+ if (offchannel)
+ mt76_offchannel_notify(phy, true);
+ ret = __mt76_set_channel(phy, &chandef, offchannel);
if (ret) {
mlink->mvif->roc_phy = NULL;
phy->roc_vif = NULL;
return sel_links;
}
EXPORT_SYMBOL_GPL(mt76_select_links);
+
+struct mt76_offchannel_cb_data {
+ struct mt76_phy *phy;
+ bool offchannel;
+};
+
+static void
+mt76_offchannel_send_nullfunc(struct mt76_offchannel_cb_data *data,
+ struct ieee80211_vif *vif, int link_id)
+{
+ struct mt76_phy *phy = data->phy;
+ struct ieee80211_tx_info *info;
+ struct ieee80211_sta *sta = NULL;
+ struct ieee80211_hdr *hdr;
+ struct mt76_wcid *wcid;
+ struct sk_buff *skb;
+
+ skb = ieee80211_nullfunc_get(phy->hw, vif, link_id, true);
+ if (!skb)
+ return;
+
+ hdr = (struct ieee80211_hdr *)skb->data;
+ if (data->offchannel)
+ hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_PM);
+
+ skb->priority = 7;
+ skb_set_queue_mapping(skb, IEEE80211_AC_VO);
+
+ if (!ieee80211_tx_prepare_skb(phy->hw, vif, skb,
+ phy->main_chandef.chan->band,
+ &sta))
+ return;
+
+ if (sta)
+ wcid = (struct mt76_wcid *)sta->drv_priv;
+ else
+ wcid = ((struct mt76_vif_link *)vif->drv_priv)->wcid;
+
+ if (link_id >= 0) {
+ info = IEEE80211_SKB_CB(skb);
+ info->control.flags &= ~IEEE80211_TX_CTRL_MLO_LINK;
+ info->control.flags |=
+ u32_encode_bits(link_id, IEEE80211_TX_CTRL_MLO_LINK);
+ }
+
+ mt76_tx(phy, sta, wcid, skb);
+}
+
+static void
+mt76_offchannel_notify_iter(void *_data, u8 *mac, struct ieee80211_vif *vif)
+{
+ struct mt76_offchannel_cb_data *data = _data;
+ struct mt76_vif_link *mlink;
+ struct mt76_vif_data *mvif;
+ int link_id;
+
+ if (vif->type != NL80211_IFTYPE_STATION || !vif->cfg.assoc)
+ return;
+
+ mlink = (struct mt76_vif_link *)vif->drv_priv;
+ mvif = mlink->mvif;
+
+ if (!ieee80211_vif_is_mld(vif)) {
+ if (mt76_vif_link_phy(mlink) == data->phy)
+ mt76_offchannel_send_nullfunc(data, vif, -1);
+ 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)
+ continue;
+ if (mt76_vif_link_phy(mlink) != data->phy)
+ continue;
+
+ mt76_offchannel_send_nullfunc(data, vif, link_id);
+ }
+}
+
+void mt76_offchannel_notify(struct mt76_phy *phy, bool offchannel)
+{
+ struct mt76_offchannel_cb_data data = {
+ .phy = phy,
+ .offchannel = offchannel,
+ };
+
+ if (!phy->num_sta)
+ return;
+
+ local_bh_disable();
+ ieee80211_iterate_active_interfaces_atomic(phy->hw,
+ IEEE80211_IFACE_ITER_NORMAL,
+ mt76_offchannel_notify_iter, &data);
+ local_bh_enable();
+}
+EXPORT_SYMBOL_GPL(mt76_offchannel_notify);
clear_bit(MT76_SCANNING, &phy->state);
if (dev->scan.chan && phy->main_chandef.chan && phy->offchannel &&
- !test_bit(MT76_MCU_RESET, &dev->phy.state))
+ !test_bit(MT76_MCU_RESET, &dev->phy.state)) {
mt76_set_channel(phy, &phy->main_chandef, false);
+ mt76_offchannel_notify(phy, false);
+ }
mt76_put_vif_phy_link(phy, dev->scan.vif, dev->scan.mlink);
memset(&dev->scan, 0, sizeof(dev->scan));
if (!test_bit(MT76_MCU_RESET, &dev->phy.state))
if (dev->scan.chan && phy->num_sta && phy->offchannel) {
dev->scan.chan = NULL;
mt76_set_channel(phy, &phy->main_chandef, false);
+ mt76_offchannel_notify(phy, false);
goto out;
}
dev->scan.chan = req->channels[dev->scan.chan_idx++];
offchannel = mt76_offchannel_chandef(phy, dev->scan.chan, &chandef);
+ if (offchannel)
+ mt76_offchannel_notify(phy, true);
mt76_set_channel(phy, &chandef, offchannel);
if (!req->n_ssids)