wifi: mt76: mt7996: Add vif_cfg_changed callback
authorLorenzo Bianconi <lorenzo@kernel.org>
Tue, 11 Mar 2025 17:45:03 +0000 (18:45 +0100)
committerFelix Fietkau <nbd@nbd.name>
Wed, 19 Mar 2025 13:47:05 +0000 (14:47 +0100)
Introduce vif_cfg_changed mac80211 callback as preliminary patch to
enable MLO support in MT7996 driver.

Co-developed-by: Bo Jiao <Bo.Jiao@mediatek.com>
Signed-off-by: Bo Jiao <Bo.Jiao@mediatek.com>
Co-developed-by: Peter Chiu <chui-hao.chiu@mediatek.com>
Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com>
Co-developed-by: Shayne Chen <shayne.chen@mediatek.com>
Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Link: https://patch.msgid.link/20250311-mt7996-mlo-v2-4-31df6972519b@kernel.org
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt7996/main.c

index 34f984387c00714fbe72af5220ec067760510bb8..59a1e5e52450accc5b01fbe0c3af7e84bcc87df6 100644 (file)
@@ -679,6 +679,39 @@ mt7996_update_mu_group(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
        mt76_wr(dev, MT_WF_PHYRX_BAND_GID_TAB_POS3(band), mu[3]);
 }
 
+static void
+mt7996_vif_cfg_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
+                      u64 changed)
+{
+       struct mt7996_dev *dev = mt7996_hw_dev(hw);
+
+       mutex_lock(&dev->mt76.mutex);
+
+       if ((changed & BSS_CHANGED_ASSOC) && vif->cfg.assoc) {
+               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)
+                               continue;
+
+                       if (!link->phy)
+                               continue;
+
+                       mt7996_mcu_add_bss_info(link->phy, vif, link_conf,
+                                               &link->mt76, true);
+                       mt7996_mcu_add_sta(dev, vif, &link->mt76, NULL,
+                                          CONN_STATE_PORT_SECURE,
+                                          !!(changed & BSS_CHANGED_BSSID));
+               }
+       }
+
+       mutex_unlock(&dev->mt76.mutex);
+}
+
 static void mt7996_bss_info_changed(struct ieee80211_hw *hw,
                                    struct ieee80211_vif *vif,
                                    struct ieee80211_bss_conf *info,
@@ -705,7 +738,6 @@ static void mt7996_bss_info_changed(struct ieee80211_hw *hw,
         * and then peer references bss_info_rfch to set bandwidth cap.
         */
        if ((changed & BSS_CHANGED_BSSID && !is_zero_ether_addr(info->bssid)) ||
-           (changed & BSS_CHANGED_ASSOC && vif->cfg.assoc) ||
            (changed & BSS_CHANGED_BEACON_ENABLED && info->enable_beacon)) {
                mt7996_mcu_add_bss_info(phy, vif, info, mvif, true);
                mt7996_mcu_add_sta(dev, vif, mvif, NULL, CONN_STATE_PORT_SECURE,
@@ -1688,6 +1720,7 @@ const struct ieee80211_ops mt7996_ops = {
        .conf_tx = mt7996_conf_tx,
        .configure_filter = mt7996_configure_filter,
        .bss_info_changed = mt7996_bss_info_changed,
+       .vif_cfg_changed = mt7996_vif_cfg_changed,
        .sta_state = mt76_sta_state,
        .sta_pre_rcu_remove = mt76_sta_pre_rcu_remove,
        .link_sta_rc_update = mt7996_sta_rc_update,