linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: gregory.greenman@intel.com
To: johannes@sipsolutions.net
Cc: linux-wireless@vger.kernel.org,
	Miri Korenblit <miriam.rachel.korenblit@intel.com>,
	Gregory Greenman <gregory.greenman@intel.com>
Subject: [PATCH 06/31] wifi: iwlwifi: mvm: refactor iwl_mvm_roc()
Date: Tue, 28 Mar 2023 10:58:46 +0300	[thread overview]
Message-ID: <20230328104948.61bc077a7f3c.Ia3aa81d3293792bf8f80528dbc67a711ce334b32@changeid> (raw)
In-Reply-To: <20230328075911.2370108-1-gregory.greenman@intel.com>

From: Miri Korenblit <miriam.rachel.korenblit@intel.com>

This flow is almost the same for both MLD and non-MLD modes,
except for some function calls. Therefore there is no reason to
add an MLD version of this flow. Instead - put the parts that are unique
for each mode in helper functions, and in the next patch each version of
this flow will call the common part with pointers to its specific
helper functions.

Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
---
 .../net/wireless/intel/iwlwifi/mvm/mac80211.c | 100 ++++++++++--------
 1 file changed, 56 insertions(+), 44 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
index dae5e1b7d1cc..bb7e4e26d99f 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
@@ -4258,6 +4258,52 @@ static int iwl_mvm_send_aux_roc_cmd(struct iwl_mvm *mvm,
 	return res;
 }
 
+static int iwl_mvm_add_aux_sta_for_hs20(struct iwl_mvm *mvm, u32 lmac_id)
+{
+	int ret = 0;
+
+	lockdep_assert_held(&mvm->mutex);
+
+	if (!fw_has_capa(&mvm->fw->ucode_capa,
+			 IWL_UCODE_TLV_CAPA_HOTSPOT_SUPPORT)) {
+		IWL_ERR(mvm, "hotspot not supported\n");
+		return -EINVAL;
+	}
+
+	if (iwl_fw_lookup_cmd_ver(mvm->fw, ADD_STA, 0) >= 12) {
+		ret = iwl_mvm_add_aux_sta(mvm, lmac_id);
+		WARN(ret, "Failed to allocate aux station");
+	}
+
+	return ret;
+}
+
+static int iwl_mvm_roc_switch_binding(struct iwl_mvm *mvm,
+				      struct ieee80211_vif *vif,
+				      struct iwl_mvm_phy_ctxt *new_phy_ctxt)
+{
+	struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
+	int ret = 0;
+
+	lockdep_assert_held(&mvm->mutex);
+
+	/* Unbind the P2P_DEVICE from the current PHY context,
+	 * and if the PHY context is not used remove it.
+	 */
+	ret = iwl_mvm_binding_remove_vif(mvm, vif);
+	if (WARN(ret, "Failed unbinding P2P_DEVICE\n"))
+		return ret;
+
+	iwl_mvm_phy_ctxt_unref(mvm, mvmvif->deflink.phy_ctxt);
+
+	/* Bind the P2P_DEVICE to the current PHY Context */
+	mvmvif->deflink.phy_ctxt = new_phy_ctxt;
+
+	ret = iwl_mvm_binding_add_vif(mvm, vif);
+	WARN(ret, "Failed binding P2P_DEVICE\n");
+	return ret;
+}
+
 static int iwl_mvm_roc(struct ieee80211_hw *hw,
 		       struct ieee80211_vif *vif,
 		       struct ieee80211_channel *channel,
@@ -4270,6 +4316,7 @@ static int iwl_mvm_roc(struct ieee80211_hw *hw,
 	struct iwl_mvm_phy_ctxt *phy_ctxt;
 	bool band_change_removal;
 	int ret, i;
+	u32 lmac_id;
 
 	IWL_DEBUG_MAC80211(mvm, "enter (%d, %d, %d)\n", channel->hw_value,
 			   duration, type);
@@ -4284,25 +4331,13 @@ static int iwl_mvm_roc(struct ieee80211_hw *hw,
 
 	switch (vif->type) {
 	case NL80211_IFTYPE_STATION:
-		if (fw_has_capa(&mvm->fw->ucode_capa,
-				IWL_UCODE_TLV_CAPA_HOTSPOT_SUPPORT)) {
-			/* Use aux roc framework (HS20) */
-			if (iwl_fw_lookup_cmd_ver(mvm->fw, ADD_STA, 0) >= 12) {
-				u32 lmac_id;
-
-				lmac_id = iwl_mvm_get_lmac_id(mvm->fw,
-							      channel->band);
-				ret = iwl_mvm_add_aux_sta(mvm, lmac_id);
-				if (WARN(ret,
-					 "Failed to allocate aux station"))
-					goto out_unlock;
-			}
+		lmac_id = iwl_mvm_get_lmac_id(mvm->fw, channel->band);
+
+		/* Use aux roc framework (HS20) */
+		ret = iwl_mvm_add_aux_sta_for_hs20(mvm, lmac_id);
+		if (!ret)
 			ret = iwl_mvm_send_aux_roc_cmd(mvm, channel,
 						       vif, duration);
-			goto out_unlock;
-		}
-		IWL_ERR(mvm, "hotspot not supported\n");
-		ret = -EINVAL;
 		goto out_unlock;
 	case NL80211_IFTYPE_P2P_DEVICE:
 		/* handle below */
@@ -4319,21 +4354,8 @@ static int iwl_mvm_roc(struct ieee80211_hw *hw,
 			continue;
 
 		if (phy_ctxt->ref && channel == phy_ctxt->channel) {
-			/*
-			 * Unbind the P2P_DEVICE from the current PHY context,
-			 * and if the PHY context is not used remove it.
-			 */
-			ret = iwl_mvm_binding_remove_vif(mvm, vif);
-			if (WARN(ret, "Failed unbinding P2P_DEVICE\n"))
-				goto out_unlock;
-
-			iwl_mvm_phy_ctxt_unref(mvm, mvmvif->deflink.phy_ctxt);
-
-			/* Bind the P2P_DEVICE to the current PHY Context */
-			mvmvif->deflink.phy_ctxt = phy_ctxt;
-
-			ret = iwl_mvm_binding_add_vif(mvm, vif);
-			if (WARN(ret, "Failed binding P2P_DEVICE\n"))
+			ret = iwl_mvm_roc_switch_binding(mvm, vif, phy_ctxt);
+			if (ret)
 				goto out_unlock;
 
 			iwl_mvm_phy_ctxt_ref(mvm, mvmvif->deflink.phy_ctxt);
@@ -4386,18 +4408,8 @@ static int iwl_mvm_roc(struct ieee80211_hw *hw,
 			goto out_unlock;
 		}
 
-		/* Unbind the P2P_DEVICE from the current PHY context */
-		ret = iwl_mvm_binding_remove_vif(mvm, vif);
-		if (WARN(ret, "Failed unbinding P2P_DEVICE\n"))
-			goto out_unlock;
-
-		iwl_mvm_phy_ctxt_unref(mvm, mvmvif->deflink.phy_ctxt);
-
-		/* Bind the P2P_DEVICE to the new allocated PHY context */
-		mvmvif->deflink.phy_ctxt = phy_ctxt;
-
-		ret = iwl_mvm_binding_add_vif(mvm, vif);
-		if (WARN(ret, "Failed binding P2P_DEVICE\n"))
+		ret = iwl_mvm_roc_switch_binding(mvm, vif, phy_ctxt);
+		if (ret)
 			goto out_unlock;
 
 		iwl_mvm_phy_ctxt_ref(mvm, mvmvif->deflink.phy_ctxt);
-- 
2.38.1


  parent reply	other threads:[~2023-03-28  7:59 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-28  7:58 [PATCH 00/31] wifi: iwlwifi: updates intended for v6.4 2023-03-28 gregory.greenman
2023-03-28  7:58 ` [PATCH 01/31] wifi: iwlwifi: mvm: vif preparation for MLO gregory.greenman
2023-03-28  7:58 ` [PATCH 02/31] wifi: iwlwifi: mvm: sta " gregory.greenman
2023-03-28  7:58 ` [PATCH 03/31] wifi: iwlwifi: mvm: add an indication that the new MLD API is used gregory.greenman
2023-03-28  7:58 ` [PATCH 04/31] wifi: iwlwifi: mvm: add sta handling flows for MLD mode gregory.greenman
2023-03-28  7:58 ` [PATCH 05/31] wifi: iwlwifi: mvm: add some new MLD ops gregory.greenman
2023-03-28  7:58 ` gregory.greenman [this message]
2023-03-28  7:58 ` [PATCH 07/31] wifi: iwlwifi: mvm: add cancel/remain_on_channel for MLD mode gregory.greenman
2023-03-28  7:58 ` [PATCH 08/31] wifi: iwlwifi: mvm: unite sta_modify_disable_tx flows gregory.greenman
2023-03-28  7:58 ` [PATCH 09/31] wifi: iwlwifi: mvm: add support for post_channel_switch in MLD mode gregory.greenman
2023-03-28  7:58 ` [PATCH 10/31] wifi: iwlwifi: mvm: add all missing ops to iwl_mvm_mld_ops gregory.greenman
2023-03-28  7:58 ` [PATCH 11/31] wifi: iwlwifi: mvm: fix "modify_mask" value in the link cmd gregory.greenman
2023-03-28  7:58 ` [PATCH 12/31] wifi: iwlwifi: mvm: fix crash on queue removal for MLD API too gregory.greenman
2023-03-28  7:58 ` [PATCH 13/31] wifi: iwlwifi: mvm: modify link instead of removing it during csa gregory.greenman
2023-03-28  7:58 ` [PATCH 14/31] wifi: iwlwifi: mvm: always use the sta->addr as the peers addr gregory.greenman
2023-03-28  7:58 ` [PATCH 15/31] wifi: iwlwifi: mvm: align to the LINK cmd update in the FW gregory.greenman
2023-03-28  7:58 ` [PATCH 16/31] wifi: iwlwifi: mvm: adjust smart fifo configuration to MLO gregory.greenman
2023-03-28  7:58 ` [PATCH 17/31] wifi: iwlwifi: mvm: adjust mld_mac_ctxt_/beacon_changed() for MLO gregory.greenman
2023-03-28  7:58 ` [PATCH 18/31] wifi: iwlwifi: mvm: adjust some PS and PM methods to MLD gregory.greenman
2023-03-28  7:58 ` [PATCH 19/31] wifi: iwlwifi: mvm: add link to firmware earlier gregory.greenman
2023-03-28  7:59 ` [PATCH 20/31] wifi: iwlwifi: mvm: add set_hw_timestamp to mld ops gregory.greenman
2023-03-28  7:59 ` [PATCH 21/31] wifi: iwlwifi: mvm: adjust SMPS for MLO gregory.greenman
2023-03-28  7:59 ` [PATCH 22/31] wifi: iwlwifi: mvm: don't check dtim_period in new API gregory.greenman
2023-03-28  7:59 ` [PATCH 23/31] wifi: iwlwifi: mvm: add link_conf parameter for add/remove/change link gregory.greenman
2023-03-28  7:59 ` [PATCH 24/31] wifi: iwlwifi: mvm: replace bss_info_changed() with vif_cfg/link_info_changed() gregory.greenman
2023-03-28  7:59 ` [PATCH 25/31] wifi: iwlwifi: mvm: adjust internal stations to MLO gregory.greenman
2023-03-28  7:59 ` [PATCH 26/31] wifi: iwlwifi: mvm: add fw link id allocation gregory.greenman
2023-03-28  7:59 ` [PATCH 27/31] wifi: iwlwifi: mvm: adjust to MLO assign/unassign/switch_vif_chanctx() gregory.greenman
2023-03-28  7:59 ` [PATCH 28/31] wifi: iwlwifi: mvm: update iwl_mvm_tx_reclaim() for MLO gregory.greenman
2023-03-28  7:59 ` [PATCH 29/31] wifi: iwlwifi: mvm: refactor iwl_mvm_mac_sta_state_common() gregory.greenman
2023-03-28  7:59 ` [PATCH 30/31] wifi: iwlwifi: mvm: adjust some cleanup functions to MLO gregory.greenman
2023-03-28  7:59 ` [PATCH 31/31] wifi: iwlwifi: mvm: implement link change ops gregory.greenman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230328104948.61bc077a7f3c.Ia3aa81d3293792bf8f80528dbc67a711ce334b32@changeid \
    --to=gregory.greenman@intel.com \
    --cc=johannes@sipsolutions.net \
    --cc=linux-wireless@vger.kernel.org \
    --cc=miriam.rachel.korenblit@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).