linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pradeep Kumar Chitrapu <quic_pradeepc@quicinc.com>
To: <ath12k@lists.infradead.org>
Cc: <linux-wireless@vger.kernel.org>,
	Pradeep Kumar Chitrapu <quic_pradeepc@quicinc.com>
Subject: [PATCH 5/6] wifi: ath12k: refactor smps configuration
Date: Mon, 25 Mar 2024 14:23:03 -0700	[thread overview]
Message-ID: <20240325212304.28241-6-quic_pradeepc@quicinc.com> (raw)
In-Reply-To: <20240325212304.28241-1-quic_pradeepc@quicinc.com>

Move fetching smps value to a new function and use u16_get_bits
to extract smps value from capabilities. This will help in
extending the functionality when SMPS support in 6 GHz band gets
added in subsequent patches.

Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1

Signed-off-by: Pradeep Kumar Chitrapu <quic_pradeepc@quicinc.com>
---
 drivers/net/wireless/ath/ath12k/mac.c | 32 ++++++++++++++++-----------
 1 file changed, 19 insertions(+), 13 deletions(-)

diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c
index 7e296140439a..b4114dd22bf0 100644
--- a/drivers/net/wireless/ath/ath12k/mac.c
+++ b/drivers/net/wireless/ath/ath12k/mac.c
@@ -1963,18 +1963,29 @@ static void ath12k_peer_assoc_h_he_6ghz(struct ath12k *ar,
 				     ampdu_factor)) - 1;
 }
 
+static inline int ath12k_get_smps_from_capa(const struct ieee80211_sta_ht_cap *ht_cap,
+					    int *smps)
+{
+	if (!ht_cap->ht_supported)
+		return -EOPNOTSUPP;
+
+	*smps = u16_get_bits(ht_cap->cap, IEEE80211_HT_CAP_SM_PS);
+
+	if (*smps >= ARRAY_SIZE(ath12k_smps_map))
+		return -EINVAL;
+
+	return 0;
+}
+
 static void ath12k_peer_assoc_h_smps(struct ieee80211_sta *sta,
 				     struct ath12k_wmi_peer_assoc_arg *arg)
 {
 	const struct ieee80211_sta_ht_cap *ht_cap = &sta->deflink.ht_cap;
 	int smps;
 
-	if (!ht_cap->ht_supported)
+	if (ath12k_get_smps_from_capa(ht_cap, &smps))
 		return;
 
-	smps = ht_cap->cap & IEEE80211_HT_CAP_SM_PS;
-	smps >>= IEEE80211_HT_CAP_SM_PS_SHIFT;
-
 	switch (smps) {
 	case WLAN_HT_CAP_SM_PS_STATIC:
 		arg->static_mimops_flag = true;
@@ -2448,16 +2459,11 @@ static int ath12k_setup_peer_smps(struct ath12k *ar, struct ath12k_vif *arvif,
 				  const u8 *addr,
 				  const struct ieee80211_sta_ht_cap *ht_cap)
 {
-	int smps;
+	int smps, ret = 0;
 
-	if (!ht_cap->ht_supported)
-		return 0;
-
-	smps = ht_cap->cap & IEEE80211_HT_CAP_SM_PS;
-	smps >>= IEEE80211_HT_CAP_SM_PS_SHIFT;
-
-	if (smps >= ARRAY_SIZE(ath12k_smps_map))
-		return -EINVAL;
+	ret = ath12k_get_smps_from_capa(ht_cap, &smps);
+	if (ret < 0)
+		return ret;
 
 	return ath12k_wmi_set_peer_param(ar, addr, arvif->vdev_id,
 					 WMI_PEER_MIMO_PS_STATE,
-- 
2.17.1


  parent reply	other threads:[~2024-03-25 21:23 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-25 21:22 [PATCH 0/6] bug fixes and enhancements to 6 GHz band support Pradeep Kumar Chitrapu
2024-03-25 21:22 ` [PATCH 1/6] wifi: ath12k: add channel 2 into 6 GHz channel list Pradeep Kumar Chitrapu
2024-03-25 21:23 ` [PATCH 2/6] wifi: ath12k: Correct 6 GHz frequency value in rx status Pradeep Kumar Chitrapu
2024-03-25 21:23 ` [PATCH 3/6] wifi: ath12k: fix survey dump collection in 6 GHz Pradeep Kumar Chitrapu
2024-03-25 21:23 ` [PATCH 4/6] wifi: ath12k: add 6 GHz params in peer assoc command Pradeep Kumar Chitrapu
2024-03-29 17:48   ` Jeff Johnson
2024-03-25 21:23 ` Pradeep Kumar Chitrapu [this message]
2024-03-25 21:23 ` [PATCH 6/6] wifi: ath12k: support SMPS configuration for 6 GHz Pradeep Kumar Chitrapu
2024-03-26  3:38   ` Baochen Qiang
2024-03-26 17:37     ` Pradeep Kumar Chitrapu
2024-03-29 17:54   ` Jeff Johnson
2024-03-26 15:23 ` [PATCH 0/6] bug fixes and enhancements to 6 GHz band support Kalle Valo
2024-03-26 17:38   ` Pradeep Kumar Chitrapu

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=20240325212304.28241-6-quic_pradeepc@quicinc.com \
    --to=quic_pradeepc@quicinc.com \
    --cc=ath12k@lists.infradead.org \
    --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).