wifi: iwlwifi: mvm: refactor __iwl_mvm_unassign_vif_chanctx()
authorMiri Korenblit <miriam.rachel.korenblit@intel.com>
Tue, 14 Mar 2023 17:49:25 +0000 (19:49 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Wed, 15 Mar 2023 12:25:14 +0000 (13:25 +0100)
Since parts of the functionality of this function is going to be used
also by the MLD version of it, put in a separate function the parts
that are common for both MLD and non-MLD modes.
The common function will later be used in the MLD ops.

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.fa05929badb9.I2222dc86cf7d7a7bb58c6a2f2529c8089bfe58b4@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c

index d4a3d92..c006d68 100644 (file)
@@ -4545,52 +4545,69 @@ static int iwl_mvm_assign_vif_chanctx(struct ieee80211_hw *hw,
        return ret;
 }
 
-static void __iwl_mvm_unassign_vif_chanctx(struct iwl_mvm *mvm,
-                                          struct ieee80211_vif *vif,
-                                          struct ieee80211_chanctx_conf *ctx,
-                                          bool switching_chanctx)
+/*
+ * This function executes the common part for MLD and non-MLD modes.
+ *
+ * Returns if chanctx unassign chanctx is done
+ * (either on failure or success)
+ */
+static bool __iwl_mvm_unassign_vif_chanctx_common(struct iwl_mvm *mvm,
+                                                 struct ieee80211_vif *vif,
+                                                 bool switching_chanctx)
 {
        struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
-       struct ieee80211_vif *disabled_vif = NULL;
 
        lockdep_assert_held(&mvm->mutex);
        iwl_mvm_remove_time_event(mvm, mvmvif, &mvmvif->time_event_data);
 
        switch (vif->type) {
        case NL80211_IFTYPE_ADHOC:
-               goto out;
+               return true;
        case NL80211_IFTYPE_MONITOR:
                mvmvif->monitor_active = false;
                mvmvif->ps_disabled = false;
-               iwl_mvm_rm_snif_sta(mvm, vif);
                break;
        case NL80211_IFTYPE_AP:
                /* This part is triggered only during CSA */
                if (!switching_chanctx || !mvmvif->ap_ibss_active)
-                       goto out;
+                       return true;
 
                mvmvif->csa_countdown = false;
 
-               /* Set CS bit on all the stations */
-               iwl_mvm_modify_all_sta_disable_tx(mvm, mvmvif, true);
-
                /* Save blocked iface, the timeout is set on the next beacon */
                rcu_assign_pointer(mvm->csa_tx_blocked_vif, vif);
 
                mvmvif->ap_ibss_active = false;
                break;
-       case NL80211_IFTYPE_STATION:
-               if (!switching_chanctx)
-                       break;
+       default:
+               break;
+       }
+       return false;
+}
 
-               disabled_vif = vif;
+static void __iwl_mvm_unassign_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);
+       struct ieee80211_vif *disabled_vif = NULL;
+
+       if (__iwl_mvm_unassign_vif_chanctx_common(mvm, vif, switching_chanctx))
+               goto out;
 
+       if (vif->type == NL80211_IFTYPE_MONITOR)
+               iwl_mvm_rm_snif_sta(mvm, vif);
+
+       if (vif->type == NL80211_IFTYPE_AP)
+               /* Set CS bit on all the stations */
+               iwl_mvm_modify_all_sta_disable_tx(mvm, mvmvif, true);
+
+       if (vif->type == NL80211_IFTYPE_STATION && switching_chanctx) {
+               disabled_vif = vif;
                if (!fw_has_capa(&mvm->fw->ucode_capa,
                                 IWL_UCODE_TLV_CAPA_CHANNEL_SWITCH_CMD))
                        iwl_mvm_mac_ctxt_changed(mvm, vif, true, NULL);
-               break;
-       default:
-               break;
        }
 
        iwl_mvm_update_quotas(mvm, false, disabled_vif);