linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Miri Korenblit <miriam.rachel.korenblit@intel.com>
To: johannes@sipsolutions.net
Cc: linux-wireless@vger.kernel.org, Johannes Berg <johannes.berg@intel.com>
Subject: [PATCH 06/16] wifi: iwlwifi: mvm: check if EMLSR is allowed before selecting links
Date: Tue, 16 Apr 2024 13:54:01 +0300	[thread overview]
Message-ID: <20240416134215.3578a93feb1a.I1cd91608bb73fbe19b8dfdf90e14ce40b98c3430@changeid> (raw)
In-Reply-To: <20240416105411.706221-1-miriam.rachel.korenblit@intel.com>

Currenty iwl_mvm_mld_select_links() doesn't fully check that
EMLSR is allowed before selecting the 2 best links.
Although it will fail in ieee80211_set_active_links(), it is preferred
to avoid the redundent calculations.

Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Reviewed-by: Johannes Berg <johannes.berg@intel.com>
---
 .../wireless/intel/iwlwifi/mvm/mld-mac80211.c | 44 ++++++++++++-------
 drivers/net/wireless/intel/iwlwifi/mvm/mvm.h  |  4 +-
 2 files changed, 29 insertions(+), 19 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mld-mac80211.c b/drivers/net/wireless/intel/iwlwifi/mvm/mld-mac80211.c
index 797c088ea0c8..33440fff762c 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/mld-mac80211.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/mld-mac80211.c
@@ -697,6 +697,30 @@ iwl_mvm_set_link_selection_data(struct ieee80211_vif *vif,
 	return n_data;
 }
 
+static bool iwl_mvm_esr_allowed_on_vif(struct iwl_mvm *mvm,
+				       struct ieee80211_vif *vif)
+{
+	struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
+	const struct wiphy_iftype_ext_capab *ext_capa;
+
+	lockdep_assert_held(&mvm->mutex);
+
+	if (!ieee80211_vif_is_mld(vif) || !vif->cfg.assoc ||
+	    hweight16(ieee80211_vif_usable_links(vif)) == 1)
+		return false;
+
+	if (!(vif->cfg.eml_cap & IEEE80211_EML_CAP_EMLSR_SUPP))
+		return false;
+
+	ext_capa = cfg80211_get_iftype_ext_capa(mvm->hw->wiphy,
+						ieee80211_vif_type_p2p(vif));
+	if (!ext_capa ||
+	    !(ext_capa->eml_capabilities & IEEE80211_EML_CAP_EMLSR_SUPP))
+		return false;
+
+	return !(mvmvif->esr_disable_reason & ~IWL_MVM_ESR_DISABLE_COEX);
+}
+
 void iwl_mvm_mld_select_links(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 			      bool valid_links_changed)
 {
@@ -709,9 +733,6 @@ void iwl_mvm_mld_select_links(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 	if (!IWL_MVM_AUTO_EML_ENABLE)
 		return;
 
-	if (!ieee80211_vif_is_mld(vif) || usable_links == 1)
-		return;
-
 	/* The logic below is a simple version that doesn't suit more than 2
 	 * links
 	 */
@@ -729,6 +750,9 @@ void iwl_mvm_mld_select_links(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 	if (hweight16(vif->active_links) == max_active_links)
 		return;
 
+	if (!iwl_mvm_esr_allowed_on_vif(mvm, vif))
+		return;
+
 	n_data = iwl_mvm_set_link_selection_data(vif, data, usable_links);
 
 	/* this is expected to be the current active link */
@@ -1367,22 +1391,10 @@ static bool iwl_mvm_can_enter_esr(struct iwl_mvm *mvm,
 				  struct ieee80211_vif *vif,
 				  unsigned long desired_links)
 {
-	u16 usable_links = ieee80211_vif_usable_links(vif);
 	struct iwl_mvm_link_sel_data data[IEEE80211_MLD_MAX_NUM_LINKS];
-	const struct wiphy_iftype_ext_capab *ext_capa;
 	u8 n_data;
 
-	if (!ieee80211_vif_is_mld(vif) || !vif->cfg.assoc ||
-	    hweight16(usable_links) <= 1)
-		return false;
-
-	if (!(vif->cfg.eml_cap & IEEE80211_EML_CAP_EMLSR_SUPP))
-		return false;
-
-	ext_capa = cfg80211_get_iftype_ext_capa(mvm->hw->wiphy,
-						ieee80211_vif_type_p2p(vif));
-	if (!ext_capa ||
-	    !(ext_capa->eml_capabilities & IEEE80211_EML_CAP_EMLSR_SUPP))
+	if (!iwl_mvm_esr_allowed_on_vif(mvm, vif))
 		return false;
 
 	n_data = iwl_mvm_set_link_selection_data(vif, data, desired_links);
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h b/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h
index 6ac20d42a09c..c887263a2159 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h
@@ -1587,14 +1587,12 @@ static inline int iwl_mvm_max_active_links(struct iwl_mvm *mvm,
 					   struct ieee80211_vif *vif)
 {
 	struct iwl_trans *trans = mvm->fwrt.trans;
-	struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
 
 	if (vif->type == NL80211_IFTYPE_AP)
 		return mvm->fw->ucode_capa.num_beacons;
 
 	/* Check if HW supports eSR or STR */
-	if ((iwl_mvm_is_esr_supported(trans) &&
-	     !(mvmvif->esr_disable_reason & ~IWL_MVM_ESR_DISABLE_COEX)) ||
+	if (iwl_mvm_is_esr_supported(trans) ||
 	    (CSR_HW_RFID_TYPE(trans->hw_rf_id) == IWL_CFG_RF_TYPE_FM &&
 	     CSR_HW_RFID_IS_CDB(trans->hw_rf_id)))
 		return IWL_MVM_FW_MAX_ACTIVE_LINKS_NUM;
-- 
2.34.1


  parent reply	other threads:[~2024-04-16 10:54 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-16 10:53 [PATCH 00/16] wifi: iwlwifi: updates - 2024-04-16 Miri Korenblit
2024-04-16 10:53 ` [PATCH 01/16] wifi: iwlwifi: mvm: introduce esr_disable_reason Miri Korenblit
2024-04-16 10:53 ` [PATCH 02/16] wifi: iwlwifi: mvm: send ap_tx_power_constraints cmd to FW in AP mode Miri Korenblit
2024-04-16 10:53 ` [PATCH 03/16] wifi: iwlwifi: mvm: implement link grading Miri Korenblit
2024-04-16 10:53 ` [PATCH 04/16] wifi: iwlwifi: mvm: calculate EMLSR mode after connection Miri Korenblit
2024-04-16 10:54 ` [PATCH 05/16] wifi: iwlwifi: mvm: don't always disable EMLSR due to BT coex Miri Korenblit
2024-04-16 10:54 ` Miri Korenblit [this message]
2024-04-16 10:54 ` [PATCH 07/16] wifi: iwlwifi: mvm: move EMLSR/links code Miri Korenblit
2024-04-16 10:54 ` [PATCH 08/16] wifi: iwlwifi: mvm: Implement new link selection algorithm Miri Korenblit
2024-04-16 10:54 ` [PATCH 09/16] wifi: iwlwifi: mvm: Add helper functions to update EMLSR status Miri Korenblit
2024-04-16 10:54 ` [PATCH 10/16] wifi: iwlwifi: mvm: init vif works only once Miri Korenblit
2024-04-16 10:54 ` [PATCH 11/16] wifi: iwlwifi: mvm: exit EMLSR upon missed beacon Miri Korenblit
2024-04-16 10:54 ` [PATCH 12/16] wifi: iwlwifi: mvm: implement EMLSR prevention mechanism Miri Korenblit
2024-04-16 10:54 ` [PATCH 13/16] wifi: iwlwifi: mvm: don't recompute EMLSR mode in can_activate_links Miri Korenblit
2024-04-16 10:54 ` [PATCH 14/16] wifi: iwlwifi: mvm: get periodic statistics in EMLSR Miri Korenblit
2024-04-16 10:54 ` [PATCH 15/16] wifi: iwlwifi: mvm: disable EMLSR when we suspend with wowlan Miri Korenblit
2024-04-16 10:54 ` [PATCH 16/16] wifi: iwlwifi: mvm: Don't allow EMLSR when the RSSI is low Miri Korenblit

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=20240416134215.3578a93feb1a.I1cd91608bb73fbe19b8dfdf90e14ce40b98c3430@changeid \
    --to=miriam.rachel.korenblit@intel.com \
    --cc=johannes.berg@intel.com \
    --cc=johannes@sipsolutions.net \
    --cc=linux-wireless@vger.kernel.org \
    /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).