wifi: iwlwifi: mvm: add an assign_vif_chanctx() callback for MLD mode
authorMiri Korenblit <miriam.rachel.korenblit@intel.com>
Tue, 14 Mar 2023 17:49:24 +0000 (19:49 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Wed, 15 Mar 2023 12:25:14 +0000 (13:25 +0100)
This is another patch in the series adding all the ops
for the new MLD ieee80211_ops.
The callback added here uses the new MLD FW API.

Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20230314194113.d3753975e720.I45f89cc81370d2cf8d4f51748ccb3ec675eff1bd@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
drivers/net/wireless/intel/iwlwifi/mvm/mld-mac80211.c
drivers/net/wireless/intel/iwlwifi/mvm/mvm.h

index 8123dad..d4a3d92 100644 (file)
@@ -4411,11 +4411,10 @@ out_unlock:
  * Returns true if we're done assigning the chanctx
  * (either on failure or success)
  */
-static bool __iwl_mvm_assign_vif_chanctx_common(struct iwl_mvm *mvm,
-                                               struct ieee80211_vif *vif,
-                                               struct ieee80211_chanctx_conf *ctx,
-                                               bool switching_chanctx,
-                                               int *ret)
+bool __iwl_mvm_assign_vif_chanctx_common(struct iwl_mvm *mvm,
+                                        struct ieee80211_vif *vif,
+                                        struct ieee80211_chanctx_conf *ctx,
+                                        bool switching_chanctx, int *ret)
 {
        u16 *phy_ctxt_id = (u16 *)ctx->drv_priv;
        struct iwl_mvm_phy_ctxt *phy_ctxt = &mvm->phy_ctxts[*phy_ctxt_id];
index 8dca72e..81f88d1 100644 (file)
@@ -146,7 +146,67 @@ out:
        mutex_unlock(&mvm->mutex);
 }
 
+static int __iwl_mvm_mld_assign_vif_chanctx(struct iwl_mvm *mvm,
+                                           struct ieee80211_vif *vif,
+                                           struct ieee80211_chanctx_conf *ctx,
+                                           bool switching_chanctx)
+{
+       struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
+       int ret;
+
+       if (__iwl_mvm_assign_vif_chanctx_common(mvm, vif, ctx,
+                                               switching_chanctx, &ret))
+               goto out;
+
+       ret = iwl_mvm_add_link(mvm, vif);
+       if (ret)
+               goto out;
+       ret = iwl_mvm_link_changed(mvm, vif, LINK_CONTEXT_MODIFY_ACTIVE,
+                                  true);
+       if (ret)
+               goto out_remove_link;
+
+       /*
+        * Power state must be updated before quotas,
+        * otherwise fw will complain.
+        */
+       iwl_mvm_power_update_mac(mvm);
+
+       if (vif->type == NL80211_IFTYPE_MONITOR) {
+               ret = iwl_mvm_mld_add_snif_sta(mvm, vif);
+               if (ret)
+                       goto out_remove_link;
+       }
+
+       goto out;
+
+out_remove_link:
+       /* Link needs to be deactivated before removal */
+       iwl_mvm_link_changed(mvm, vif, LINK_CONTEXT_MODIFY_ACTIVE, false);
+       iwl_mvm_remove_link(mvm, vif);
+       iwl_mvm_power_update_mac(mvm);
+out:
+       if (ret)
+               mvmvif->phy_ctxt = NULL;
+       return ret;
+}
+
+static int iwl_mvm_mld_assign_vif_chanctx(struct ieee80211_hw *hw,
+                                         struct ieee80211_vif *vif,
+                                         struct ieee80211_bss_conf *link_conf,
+                                         struct ieee80211_chanctx_conf *ctx)
+{
+       struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
+       int ret;
+
+       mutex_lock(&mvm->mutex);
+       ret = __iwl_mvm_mld_assign_vif_chanctx(mvm, vif, ctx, false);
+       mutex_unlock(&mvm->mutex);
+
+       return ret;
+}
 const struct ieee80211_ops iwl_mvm_mld_hw_ops = {
        .add_interface = iwl_mvm_mld_mac_add_interface,
        .remove_interface = iwl_mvm_mld_mac_remove_interface,
+       .assign_vif_chanctx = iwl_mvm_mld_assign_vif_chanctx,
 };
index 32e0af8..1221a07 100644 (file)
@@ -2168,6 +2168,12 @@ static inline u8 iwl_mvm_phy_band_from_nl80211(enum nl80211_band band)
 /* Channel Switch */
 void iwl_mvm_channel_switch_disconnect_wk(struct work_struct *wk);
 
+/* Channel Context */
+bool __iwl_mvm_assign_vif_chanctx_common(struct iwl_mvm *mvm,
+                                        struct ieee80211_vif *vif,
+                                        struct ieee80211_chanctx_conf *ctx,
+                                        bool switching_chanctx, int *ret);
+
 /* Channel info utils */
 static inline bool iwl_mvm_has_ultra_hb_channel(struct iwl_mvm *mvm)
 {