All of lore.kernel.org
 help / color / mirror / Atom feed
From: gregory.greenman@intel.com
To: johannes@sipsolutions.net
Cc: linux-wireless@vger.kernel.org,
	Gregory Greenman <gregory.greenman@intel.com>
Subject: [PATCH 18/31] wifi: iwlwifi: mvm: adjust some PS and PM methods to MLD
Date: Tue, 28 Mar 2023 10:58:58 +0300	[thread overview]
Message-ID: <20230328104949.8d9e18f7d74b.I048fc17405ecdddc1f6fe72859013cc4878b2a3b@changeid> (raw)
In-Reply-To: <20230328075911.2370108-1-gregory.greenman@intel.com>

From: Gregory Greenman <gregory.greenman@intel.com>

When using mvm vif PS/PM related properties, consider all links.

Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
---
 .../net/wireless/intel/iwlwifi/mvm/mac80211.c |  4 +--
 drivers/net/wireless/intel/iwlwifi/mvm/mvm.h  |  6 ++++
 .../net/wireless/intel/iwlwifi/mvm/power.c    | 16 +++++----
 .../net/wireless/intel/iwlwifi/mvm/utils.c    | 33 +++++++++++++++++++
 4 files changed, 50 insertions(+), 9 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
index d9caf326535f..2989285d451a 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
@@ -1278,8 +1278,8 @@ struct iwl_mvm_phy_ctxt *iwl_mvm_get_free_phy_ctxt(struct iwl_mvm *mvm)
 	return NULL;
 }
 
-static int iwl_mvm_set_tx_power(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
-				s16 tx_power)
+int iwl_mvm_set_tx_power(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
+			 s16 tx_power)
 {
 	u32 cmd_id = REDUCE_TX_POWER_CMD;
 	int len;
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h b/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h
index 9c5e772d619e..ae9c165197e8 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h
@@ -2599,4 +2599,10 @@ int iwl_mvm_start_pmsr(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
 		       struct cfg80211_pmsr_request *request);
 void iwl_mvm_abort_pmsr(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
 			struct cfg80211_pmsr_request *request);
+
+bool iwl_mvm_have_links_same_channel(struct iwl_mvm_vif *vif1,
+				     struct iwl_mvm_vif *vif2);
+bool iwl_mvm_vif_is_active(struct iwl_mvm_vif *mvmvif);
+int iwl_mvm_set_tx_power(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
+			 s16 tx_power);
 #endif /* __IWL_MVM_H__ */
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/power.c b/drivers/net/wireless/intel/iwlwifi/mvm/power.c
index 6e2e3127843f..45a652cce491 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/power.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/power.c
@@ -553,8 +553,7 @@ static void iwl_mvm_power_ps_disabled_iterator(void *_data, u8* mac,
 	struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
 	bool *disable_ps = _data;
 
-	if (mvmvif->deflink.phy_ctxt &&
-	    mvmvif->deflink.phy_ctxt->id < NUM_PHY_CTX)
+	if (iwl_mvm_vif_is_active(mvmvif))
 		*disable_ps |= mvmvif->ps_disabled;
 }
 
@@ -563,11 +562,13 @@ static void iwl_mvm_power_get_vifs_iterator(void *_data, u8 *mac,
 {
 	struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
 	struct iwl_power_vifs *power_iterator = _data;
-	bool active = mvmvif->deflink.phy_ctxt && mvmvif->deflink.phy_ctxt->id < NUM_PHY_CTX;
+	bool active;
 
 	if (!mvmvif->uploaded)
 		return;
 
+	active = iwl_mvm_vif_is_active(mvmvif);
+
 	switch (ieee80211_vif_type_p2p(vif)) {
 	case NL80211_IFTYPE_P2P_DEVICE:
 		break;
@@ -651,11 +652,12 @@ static void iwl_mvm_power_set_pm(struct iwl_mvm *mvm,
 	}
 
 	if (vifs->bss_active && vifs->p2p_active)
-		client_same_channel = (bss_mvmvif->deflink.phy_ctxt->id ==
-				       p2p_mvmvif->deflink.phy_ctxt->id);
+		client_same_channel =
+			iwl_mvm_have_links_same_channel(bss_mvmvif, p2p_mvmvif);
+
 	if (vifs->bss_active && vifs->ap_active)
-		ap_same_channel = (bss_mvmvif->deflink.phy_ctxt->id ==
-				   ap_mvmvif->deflink.phy_ctxt->id);
+		ap_same_channel =
+			iwl_mvm_have_links_same_channel(bss_mvmvif, ap_mvmvif);
 
 	/* clients are not stand alone: enable PM if DCM */
 	if (!(client_same_channel || ap_same_channel)) {
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/utils.c b/drivers/net/wireless/intel/iwlwifi/mvm/utils.c
index c1f6dd8f7d10..026856c8f5f2 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/utils.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/utils.c
@@ -1138,3 +1138,36 @@ void iwl_mvm_get_sync_time(struct iwl_mvm *mvm, int clock_type,
 		iwl_mvm_power_update_device(mvm);
 	}
 }
+
+/* Find if at least two links from different vifs use same channel
+ * FIXME: consider having a refcount array in struct iwl_mvm_vif for
+ * used phy_ctxt ids.
+ */
+bool iwl_mvm_have_links_same_channel(struct iwl_mvm_vif *vif1,
+				     struct iwl_mvm_vif *vif2)
+{
+	unsigned int i, j;
+
+	for_each_mvm_vif_valid_link(vif1, i) {
+		for_each_mvm_vif_valid_link(vif2, j) {
+			if (vif1->link[i]->phy_ctxt == vif2->link[j]->phy_ctxt)
+				return true;
+		}
+	}
+
+	return false;
+}
+
+bool iwl_mvm_vif_is_active(struct iwl_mvm_vif *mvmvif)
+{
+	unsigned int i;
+
+	/* FIXME: can it fail when phy_ctxt is assigned? */
+	for_each_mvm_vif_valid_link(mvmvif, i) {
+		if (mvmvif->link[i]->phy_ctxt &&
+		    mvmvif->link[i]->phy_ctxt->id < NUM_PHY_CTX)
+			return true;
+	}
+
+	return false;
+}
-- 
2.38.1


  parent reply	other threads:[~2023-03-28  8:00 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 ` [PATCH 06/31] wifi: iwlwifi: mvm: refactor iwl_mvm_roc() gregory.greenman
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 ` gregory.greenman [this message]
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=20230328104949.8d9e18f7d74b.I048fc17405ecdddc1f6fe72859013cc4878b2a3b@changeid \
    --to=gregory.greenman@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.