2024-03-29 17:39:58

by Pradeep Kumar Chitrapu

[permalink] [raw]
Subject: [PATCH v2 0/6] bug fixes and enhancements to 6 GHz band support

In 6 GHz band, add support for
1. channel 2.
2. Fix packet drop issues.
3. AMPDU aggregation
4. SMPS configuration

Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1
Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3

changes in v2:
- Disable smps for WCN7850 after review comment from Boachen
- Added Tested-on tag for WCN7850

Pradeep Kumar Chitrapu (6):
wifi: ath12k: add channel 2 into 6 GHz channel list
wifi: ath12k: Correct 6 GHz frequency value in rx status
wifi: ath12k: fix survey dump collection in 6 GHz
wifi: ath12k: add 6 GHz params in peer assoc command
wifi: ath12k: refactor smps configuration
wifi: ath12k: support SMPS configuration for 6 GHz

drivers/net/wireless/ath/ath12k/core.h | 2 +-
drivers/net/wireless/ath/ath12k/dp_rx.c | 9 +-
drivers/net/wireless/ath/ath12k/hw.c | 3 +
drivers/net/wireless/ath/ath12k/hw.h | 1 +
drivers/net/wireless/ath/ath12k/mac.c | 116 ++++++++++++++++++++----
drivers/net/wireless/ath/ath12k/wmi.c | 10 +-
6 files changed, 116 insertions(+), 25 deletions(-)


base-commit: fe7e1b830cf3c0272aa4eaf367c4c7b29c169c3d
--
2.17.1



2024-03-29 17:40:22

by Pradeep Kumar Chitrapu

[permalink] [raw]
Subject: [PATCH v2 1/6] wifi: ath12k: add channel 2 into 6 GHz channel list

Add support for the 6 GHz channel 2 with center frequency
5935 MHz and operating class 136 per IEEE Std 802.11ax-2021,
Table E-4.

Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1
Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3

Signed-off-by: Pradeep Kumar Chitrapu <[email protected]>
---
drivers/net/wireless/ath/ath12k/core.h | 2 +-
drivers/net/wireless/ath/ath12k/mac.c | 4 ++++
2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath12k/core.h b/drivers/net/wireless/ath/ath12k/core.h
index 97e5a0ccd233..ea5d0d9b54e4 100644
--- a/drivers/net/wireless/ath/ath12k/core.h
+++ b/drivers/net/wireless/ath/ath12k/core.h
@@ -430,7 +430,7 @@ struct ath12k_sta {
#define ATH12K_MIN_5G_FREQ 4150
#define ATH12K_MIN_6G_FREQ 5925
#define ATH12K_MAX_6G_FREQ 7115
-#define ATH12K_NUM_CHANS 100
+#define ATH12K_NUM_CHANS 101
#define ATH12K_MAX_5G_CHAN 173

enum ath12k_state {
diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c
index 52a5fb8b03e9..b91d34b602dd 100644
--- a/drivers/net/wireless/ath/ath12k/mac.c
+++ b/drivers/net/wireless/ath/ath12k/mac.c
@@ -90,6 +90,10 @@ static const struct ieee80211_channel ath12k_5ghz_channels[] = {
};

static const struct ieee80211_channel ath12k_6ghz_channels[] = {
+ /* Operating Class 136 */
+ CHAN6G(2, 5935, 0),
+
+ /* Operating Classes 131-135 */
CHAN6G(1, 5955, 0),
CHAN6G(5, 5975, 0),
CHAN6G(9, 5995, 0),
--
2.17.1


2024-03-29 17:40:29

by Pradeep Kumar Chitrapu

[permalink] [raw]
Subject: [PATCH v2 2/6] wifi: ath12k: Correct 6 GHz frequency value in rx status

The frequency in the rx status is currently being filled
incorrectly for the 6 GHz band. The channel number received is
invalid in this case, resulting in packet drops. Fix this
issue by correcting the frequency calculation.

Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1
Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3

Fixes: d889913205cf ("wifi: ath12k: driver for Qualcomm Wi-Fi 7 devices")
Signed-off-by: Pradeep Kumar Chitrapu <[email protected]>
---
drivers/net/wireless/ath/ath12k/dp_rx.c | 9 ++++++---
drivers/net/wireless/ath/ath12k/wmi.c | 10 +++++++---
2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/ath/ath12k/dp_rx.c b/drivers/net/wireless/ath/ath12k/dp_rx.c
index a593beecdd12..2382274dd857 100644
--- a/drivers/net/wireless/ath/ath12k/dp_rx.c
+++ b/drivers/net/wireless/ath/ath12k/dp_rx.c
@@ -2397,8 +2397,10 @@ void ath12k_dp_rx_h_ppdu(struct ath12k *ar, struct hal_rx_desc *rx_desc,
channel_num = meta_data;
center_freq = meta_data >> 16;

- if (center_freq >= 5935 && center_freq <= 7105) {
+ if (center_freq >= ATH12K_MIN_6G_FREQ &&
+ center_freq <= ATH12K_MAX_6G_FREQ) {
rx_status->band = NL80211_BAND_6GHZ;
+ rx_status->freq = center_freq;
} else if (channel_num >= 1 && channel_num <= 14) {
rx_status->band = NL80211_BAND_2GHZ;
} else if (channel_num >= 36 && channel_num <= 173) {
@@ -2416,8 +2418,9 @@ void ath12k_dp_rx_h_ppdu(struct ath12k *ar, struct hal_rx_desc *rx_desc,
rx_desc, sizeof(*rx_desc));
}

- rx_status->freq = ieee80211_channel_to_frequency(channel_num,
- rx_status->band);
+ if (rx_status->band != NL80211_BAND_6GHZ)
+ rx_status->freq = ieee80211_channel_to_frequency(channel_num,
+ rx_status->band);

ath12k_dp_rx_h_rate(ar, rx_desc, rx_status);
}
diff --git a/drivers/net/wireless/ath/ath12k/wmi.c b/drivers/net/wireless/ath/ath12k/wmi.c
index 34de3d16efc0..2f0d82d88f20 100644
--- a/drivers/net/wireless/ath/ath12k/wmi.c
+++ b/drivers/net/wireless/ath/ath12k/wmi.c
@@ -5877,8 +5877,10 @@ static void ath12k_mgmt_rx_event(struct ath12k_base *ab, struct sk_buff *skb)
if (rx_ev.status & WMI_RX_STATUS_ERR_MIC)
status->flag |= RX_FLAG_MMIC_ERROR;

- if (rx_ev.chan_freq >= ATH12K_MIN_6G_FREQ) {
+ if (rx_ev.chan_freq >= ATH12K_MIN_6G_FREQ &&
+ rx_ev.chan_freq <= ATH12K_MAX_6G_FREQ) {
status->band = NL80211_BAND_6GHZ;
+ status->freq = rx_ev.chan_freq;
} else if (rx_ev.channel >= 1 && rx_ev.channel <= 14) {
status->band = NL80211_BAND_2GHZ;
} else if (rx_ev.channel >= 36 && rx_ev.channel <= ATH12K_MAX_5G_CHAN) {
@@ -5899,8 +5901,10 @@ static void ath12k_mgmt_rx_event(struct ath12k_base *ab, struct sk_buff *skb)

sband = &ar->mac.sbands[status->band];

- status->freq = ieee80211_channel_to_frequency(rx_ev.channel,
- status->band);
+ if (status->band != NL80211_BAND_6GHZ)
+ status->freq = ieee80211_channel_to_frequency(rx_ev.channel,
+ status->band);
+
status->signal = rx_ev.snr + ATH12K_DEFAULT_NOISE_FLOOR;
status->rate_idx = ath12k_mac_bitrate_to_idx(sband, rx_ev.rate / 100);

--
2.17.1


2024-03-29 17:40:35

by Pradeep Kumar Chitrapu

[permalink] [raw]
Subject: [PATCH v2 4/6] wifi: ath12k: add 6 GHz params in peer assoc command

Currently A-MPDU aggregation parameters are not being configured
during peer association for 6 GHz band. Hence, extract these
parameters from station's capabilities received in association
request and send to firmware. Without this, A-MPDU aggregation
is not happening in 6 GHz band.

Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1
Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3

Co-developed-by: Avula Sri Charan <[email protected]>
Signed-off-by: Avula Sri Charan <[email protected]>
Signed-off-by: Pradeep Kumar Chitrapu <[email protected]>
---
drivers/net/wireless/ath/ath12k/mac.c | 56 ++++++++++++++++++++++++++-
1 file changed, 55 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c
index 6d7df18ec424..7e296140439a 100644
--- a/drivers/net/wireless/ath/ath12k/mac.c
+++ b/drivers/net/wireless/ath/ath12k/mac.c
@@ -1910,6 +1910,59 @@ static void ath12k_peer_assoc_h_he(struct ath12k *ar,
}
}

+static void ath12k_peer_assoc_h_he_6ghz(struct ath12k *ar,
+ struct ieee80211_vif *vif,
+ struct ieee80211_sta *sta,
+ struct ath12k_wmi_peer_assoc_arg *arg)
+{
+ const struct ieee80211_sta_he_cap *he_cap = &sta->deflink.he_cap;
+ struct cfg80211_chan_def def;
+ enum nl80211_band band;
+ u8 ampdu_factor;
+
+ if (WARN_ON(ath12k_mac_vif_chan(vif, &def)))
+ return;
+
+ band = def.chan->band;
+
+ if (!arg->he_flag || band != NL80211_BAND_6GHZ || !sta->deflink.he_6ghz_capa.capa)
+ return;
+
+ if (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_40)
+ arg->bw_40 = true;
+
+ if (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_80)
+ arg->bw_80 = true;
+
+ if (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_160)
+ arg->bw_160 = true;
+
+ if (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_320)
+ arg->bw_320 = true;
+
+ arg->peer_he_caps_6ghz = le16_to_cpu(sta->deflink.he_6ghz_capa.capa);
+ arg->peer_mpdu_density =
+ ath12k_parse_mpdudensity(u32_get_bits(arg->peer_he_caps_6ghz,
+ IEEE80211_HE_6GHZ_CAP_MIN_MPDU_START));
+
+ /* From IEEE Std 802.11ax-2021 - Section 10.12.2: An HE STA shall be capable of
+ * receiving A-MPDU where the A-MPDU pre-EOF padding length is up to the value
+ * indicated by the Maximum A-MPDU Length Exponent Extension field in the HE
+ * Capabilities element and the Maximum A-MPDU Length Exponent field in HE 6 GHz
+ * Band Capabilities element in the 6 GHz band.
+ *
+ * Here, we are extracting the Max A-MPDU Exponent Extension from HE caps and
+ * factor is the Maximum A-MPDU Length Exponent from HE 6 GHZ Band capability.
+ */
+ ampdu_factor = u8_get_bits(he_cap->he_cap_elem.mac_cap_info[3],
+ IEEE80211_HE_MAC_CAP3_MAX_AMPDU_LEN_EXP_MASK) +
+ u32_get_bits(arg->peer_he_caps_6ghz,
+ IEEE80211_HE_6GHZ_CAP_MAX_AMPDU_LEN_EXP);
+
+ arg->peer_max_mpdu = (1u << (IEEE80211_HE_6GHZ_MAX_AMPDU_FACTOR +
+ ampdu_factor)) - 1;
+}
+
static void ath12k_peer_assoc_h_smps(struct ieee80211_sta *sta,
struct ath12k_wmi_peer_assoc_arg *arg)
{
@@ -2382,6 +2435,7 @@ static void ath12k_peer_assoc_prepare(struct ath12k *ar,
ath12k_peer_assoc_h_ht(ar, vif, sta, arg);
ath12k_peer_assoc_h_vht(ar, vif, sta, arg);
ath12k_peer_assoc_h_he(ar, vif, sta, arg);
+ ath12k_peer_assoc_h_he_6ghz(ar, vif, sta, arg);
ath12k_peer_assoc_h_eht(ar, vif, sta, arg);
ath12k_peer_assoc_h_qos(ar, vif, sta, arg);
ath12k_peer_assoc_h_phymode(ar, vif, sta, arg);
@@ -8029,7 +8083,7 @@ static int ath12k_mac_hw_register(struct ath12k_hw *ah)
ieee80211_hw_set(hw, SUPPORTS_TX_FRAG);
ieee80211_hw_set(hw, REPORTS_LOW_ACK);

- if (ht_cap & WMI_HT_CAP_ENABLED) {
+ if ((ht_cap & WMI_HT_CAP_ENABLED) || ar->supports_6ghz) {
ieee80211_hw_set(hw, AMPDU_AGGREGATION);
ieee80211_hw_set(hw, TX_AMPDU_SETUP_IN_HW);
ieee80211_hw_set(hw, SUPPORTS_REORDERING_BUFFER);
--
2.17.1


2024-03-29 17:40:36

by Pradeep Kumar Chitrapu

[permalink] [raw]
Subject: [PATCH v2 5/6] wifi: ath12k: refactor smps configuration

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
Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3

Signed-off-by: Pradeep Kumar Chitrapu <[email protected]>
---
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


2024-03-29 17:40:42

by Pradeep Kumar Chitrapu

[permalink] [raw]
Subject: [PATCH v2 3/6] wifi: ath12k: fix survey dump collection in 6 GHz

When ath12k receives survey request, choose the 6 GHz band
when enabled. Without this, survey requests do not include
any 6 GHz band results, leading to failures in auto channel
selection.

Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1
Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3

Signed-off-by: Pradeep Kumar Chitrapu <[email protected]>
---
drivers/net/wireless/ath/ath12k/mac.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c
index b91d34b602dd..6d7df18ec424 100644
--- a/drivers/net/wireless/ath/ath12k/mac.c
+++ b/drivers/net/wireless/ath/ath12k/mac.c
@@ -7419,7 +7419,13 @@ static int ath12k_mac_op_get_survey(struct ieee80211_hw *hw, int idx,

if (!sband)
sband = hw->wiphy->bands[NL80211_BAND_5GHZ];
+ if (sband && idx >= sband->n_channels) {
+ idx -= sband->n_channels;
+ sband = NULL;
+ }

+ if (!sband)
+ sband = hw->wiphy->bands[NL80211_BAND_6GHZ];
if (!sband || idx >= sband->n_channels) {
ret = -ENOENT;
goto exit;
--
2.17.1


2024-03-29 18:05:37

by Jeff Johnson

[permalink] [raw]
Subject: Re: [PATCH v2 0/6] bug fixes and enhancements to 6 GHz band support

On 3/29/2024 10:39 AM, Pradeep Kumar Chitrapu wrote:
> In 6 GHz band, add support for
> 1. channel 2.
> 2. Fix packet drop issues.
> 3. AMPDU aggregation
> 4. SMPS configuration
>
> Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1
> Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3
>
> changes in v2:
> - Disable smps for WCN7850 after review comment from Boachen
> - Added Tested-on tag for WCN7850
>
> Pradeep Kumar Chitrapu (6):
> wifi: ath12k: add channel 2 into 6 GHz channel list
> wifi: ath12k: Correct 6 GHz frequency value in rx status
> wifi: ath12k: fix survey dump collection in 6 GHz
> wifi: ath12k: add 6 GHz params in peer assoc command
> wifi: ath12k: refactor smps configuration
> wifi: ath12k: support SMPS configuration for 6 GHz
>
> drivers/net/wireless/ath/ath12k/core.h | 2 +-
> drivers/net/wireless/ath/ath12k/dp_rx.c | 9 +-
> drivers/net/wireless/ath/ath12k/hw.c | 3 +
> drivers/net/wireless/ath/ath12k/hw.h | 1 +
> drivers/net/wireless/ath/ath12k/mac.c | 116 ++++++++++++++++++++----
> drivers/net/wireless/ath/ath12k/wmi.c | 10 +-
> 6 files changed, 116 insertions(+), 25 deletions(-)
>
>
> base-commit: fe7e1b830cf3c0272aa4eaf367c4c7b29c169c3d
Unsurprisingly since I just reported them, the two ath12k-check issues in the
v1 series are also present in this series:

drivers/net/wireless/ath/ath12k/mac.c:1946: line length of 93 exceeds 90 columns
drivers/net/wireless/ath/ath12k/mac.c:1967: line length of 94 exceeds 90 columns


2024-03-29 18:09:24

by Jeff Johnson

[permalink] [raw]
Subject: Re: [PATCH v2 1/6] wifi: ath12k: add channel 2 into 6 GHz channel list

On 3/29/2024 10:39 AM, Pradeep Kumar Chitrapu wrote:
> Add support for the 6 GHz channel 2 with center frequency
> 5935 MHz and operating class 136 per IEEE Std 802.11ax-2021,
> Table E-4.
>
> Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1
> Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3
>
> Signed-off-by: Pradeep Kumar Chitrapu <[email protected]>

Acked-by: Jeff Johnson <[email protected]>


2024-03-29 18:16:52

by Jeff Johnson

[permalink] [raw]
Subject: Re: [PATCH v2 2/6] wifi: ath12k: Correct 6 GHz frequency value in rx status

On 3/29/2024 10:39 AM, Pradeep Kumar Chitrapu wrote:
> The frequency in the rx status is currently being filled
> incorrectly for the 6 GHz band. The channel number received is
> invalid in this case, resulting in packet drops. Fix this
> issue by correcting the frequency calculation.
>
> Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1
> Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3
>
> Fixes: d889913205cf ("wifi: ath12k: driver for Qualcomm Wi-Fi 7 devices")
> Signed-off-by: Pradeep Kumar Chitrapu <[email protected]>
Acked-by: Jeff Johnson <[email protected]>


2024-03-29 18:17:30

by Jeff Johnson

[permalink] [raw]
Subject: Re: [PATCH v2 3/6] wifi: ath12k: fix survey dump collection in 6 GHz

On 3/29/2024 10:39 AM, Pradeep Kumar Chitrapu wrote:
> When ath12k receives survey request, choose the 6 GHz band
> when enabled. Without this, survey requests do not include
> any 6 GHz band results, leading to failures in auto channel
> selection.
>
> Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1
> Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3
>
> Signed-off-by: Pradeep Kumar Chitrapu <[email protected]>
Acked-by: Jeff Johnson <[email protected]>


2024-03-29 18:20:56

by Jeff Johnson

[permalink] [raw]
Subject: Re: [PATCH v2 5/6] wifi: ath12k: refactor smps configuration

On 3/29/2024 10:39 AM, Pradeep Kumar Chitrapu wrote:
> Move fetching smps value to a new function and use u16_get_bits

s/smps/SMPS/ here and in the next line

> 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
> Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3
>
> Signed-off-by: Pradeep Kumar Chitrapu <[email protected]>
> ---
> 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,

remove inline
since it is static the compiler will inline it if it makes sense to do so

(doesn't that fix the ath12k-check issue in the 6/6 patch)?

> + 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,