Commit 8a919a78 authored by Miri Korenblit's avatar Miri Korenblit Committed by Johannes Berg
Browse files

wifi: iwlwifi: mvm: refactor __iwl_mvm_assign_vif_chanctx()



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: default avatarMiri Korenblit <miriam.rachel.korenblit@intel.com>
Signed-off-by: default avatarGregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20230314194113.844755701cac.I1c650718ad2381eabc38f4103c1aac67936a1ffc@changeid


Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent 60efeca1
Loading
Loading
Loading
Loading
+36 −11
Original line number Diff line number Diff line
@@ -4405,15 +4405,21 @@ static void iwl_mvm_change_chanctx(struct ieee80211_hw *hw,
	mutex_unlock(&mvm->mutex);
}

static int __iwl_mvm_assign_vif_chanctx(struct iwl_mvm *mvm,
/*
 * This function executes the common part for MLD and non-MLD modes.
 *
 * 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)
						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];
	struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
	int ret;

	lockdep_assert_held(&mvm->mutex);

@@ -4432,20 +4438,33 @@ static int __iwl_mvm_assign_vif_chanctx(struct iwl_mvm *mvm,
		 * The AP binding flow is handled as part of the start_ap flow
		 * (in bss_info_changed), similarly for IBSS.
		 */
		ret = 0;
		goto out;
		*ret = 0;
		return true;
	case NL80211_IFTYPE_STATION:
		mvmvif->csa_bcn_pending = false;
		break;
	case NL80211_IFTYPE_MONITOR:
		/* always disable PS when a monitor interface is active */
		mvmvif->ps_disabled = true;
		break;
	default:
		ret = -EINVAL;
		goto out;
		*ret = -EINVAL;
		return true;
	}
	return false;
}

static int __iwl_mvm_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_binding_add_vif(mvm, vif);
	if (ret)
		goto out;
@@ -4478,7 +4497,12 @@ static int __iwl_mvm_assign_vif_chanctx(struct iwl_mvm *mvm,
		iwl_mvm_mac_ctxt_changed(mvm, vif, false, NULL);
	}

	if (switching_chanctx && vif->type == NL80211_IFTYPE_STATION) {
	if (vif->type == NL80211_IFTYPE_STATION) {
		if (!switching_chanctx) {
			mvmvif->csa_bcn_pending = false;
			goto out;
		}

		mvmvif->csa_bcn_pending = true;

		if (!fw_has_capa(&mvm->fw->ucode_capa,
@@ -4506,6 +4530,7 @@ static int __iwl_mvm_assign_vif_chanctx(struct iwl_mvm *mvm,
		mvmvif->phy_ctxt = NULL;
	return ret;
}

static int iwl_mvm_assign_vif_chanctx(struct ieee80211_hw *hw,
				      struct ieee80211_vif *vif,
				      struct ieee80211_bss_conf *link_conf,