linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ath11k: Add HE UL MU fixed rate setting
@ 2021-07-29 22:25 Muna Sinada
  2021-12-08 15:44 ` Kalle Valo
  0 siblings, 1 reply; 2+ messages in thread
From: Muna Sinada @ 2021-07-29 22:25 UTC (permalink / raw)
  To: ath11k; +Cc: linux-wireless, Muna Sinada

This patch adds ath11k support for setting HE UL MU fixed rate.
HE UL MU fixed rate is informed to HE STA by HE Basic Trigger frame.
The added code is reusing parts of the existing code path used for
HE fixed rate.

Utilizing iw command, HE UL MU fixed rate can be set:
	iw dev wlanX set bitrates he-ul-mcs-<5/2.4> <NSS:MCS>

	Example: iw dev wlan0 set bitrates he-ul-mcs-5 2:5

Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.4.0.1-00356-QCAHKSWPL_SILICONZ-1

Signed-off-by: Muna Sinada <msinada@codeaurora.org>
---
 drivers/net/wireless/ath/ath11k/mac.c | 74 ++++++++++++++++++++++++++++++++---
 drivers/net/wireless/ath/ath11k/wmi.h |  1 +
 2 files changed, 69 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/ath/ath11k/mac.c b/drivers/net/wireless/ath/ath11k/mac.c
index 0a65ff4e9091..8651dcff0a25 100644
--- a/drivers/net/wireless/ath/ath11k/mac.c
+++ b/drivers/net/wireless/ath/ath11k/mac.c
@@ -3021,6 +3021,20 @@ ath11k_mac_bitrate_mask_num_he_rates(struct ath11k *ar,
 }
 
 static int
+ath11k_mac_bitrate_mask_num_he_ul_rates(struct ath11k *ar,
+					enum nl80211_band band,
+				       const struct cfg80211_bitrate_mask *mask)
+{
+	int num_rates = 0;
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(mask->control[band].he_ul_mcs); i++)
+		num_rates += hweight16(mask->control[band].he_ul_mcs[i]);
+
+	return num_rates;
+}
+
+static int
 ath11k_mac_set_peer_vht_fixed_rate(struct ath11k_vif *arvif,
 				   struct ieee80211_sta *sta,
 				   const struct cfg80211_bitrate_mask *mask,
@@ -6029,10 +6043,11 @@ ath11k_mac_get_single_legacy_rate(struct ath11k *ar,
 
 static int ath11k_mac_set_fixed_rate_params(struct ath11k_vif *arvif,
 					    u32 rate, u8 nss, u8 sgi, u8 ldpc,
-					    u8 he_gi, u8 he_ltf)
+					    u8 he_gi, u8 he_ltf, u32 he_ul_rate,
+					    u8 he_ul_nss)
 {
 	struct ath11k *ar = arvif->ar;
-	u32 vdev_param;
+	u32 vdev_param, rate_code;
 	int ret;
 
 	lockdep_assert_held(&ar->conf_mutex);
@@ -6105,6 +6120,17 @@ static int ath11k_mac_set_fixed_rate_params(struct ath11k_vif *arvif,
 		}
 	}
 
+	rate_code = ATH11K_HW_RATE_CODE(he_ul_rate, he_ul_nss - 1,
+					WMI_RATE_PREAMBLE_HE);
+	vdev_param = WMI_VDEV_PARAM_UL_FIXED_RATE;
+	ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, vdev_param,
+					    rate_code);
+
+	if (ret) {
+		ath11k_warn(ar->ab, "failed to set HE UL fixed rate %d: %d\n",
+			    rate_code, ret);
+	}
+
 	return 0;
 }
 
@@ -6158,6 +6184,22 @@ ath11k_mac_he_mcs_range_present(struct ath11k *ar,
 	return true;
 }
 
+static bool
+ath11k_mac_he_ul_mcs_present(struct ath11k *ar,
+			     enum nl80211_band band,
+			     const struct cfg80211_bitrate_mask *mask)
+{
+	int i;
+
+	for (i = 0; i < NL80211_HE_NSS_MAX; i++) {
+		if (mask->control[band].he_ul_mcs[i])
+			return true;
+	}
+
+	return false;
+}
+
+
 static void ath11k_mac_set_bitrate_mask_iter(void *data,
 					     struct ieee80211_sta *sta)
 {
@@ -6203,12 +6245,12 @@ ath11k_mac_op_set_bitrate_mask(struct ieee80211_hw *hw,
 	const u16 *he_mcs_mask;
 	u8 he_ltf = 0;
 	u8 he_gi = 0;
-	u32 rate;
-	u8 nss;
+	u32 rate, he_ul_rate;
+	u8 nss, he_ul_nss;
 	u8 sgi;
 	u8 ldpc;
 	int single_nss;
-	int ret;
+	int ret, i;
 	int num_rates;
 
 	if (ath11k_mac_vif_chan(vif, &def))
@@ -6227,6 +6269,15 @@ ath11k_mac_op_set_bitrate_mask(struct ieee80211_hw *hw,
 	he_gi = mask->control[band].he_gi;
 	he_ltf = mask->control[band].he_ltf;
 
+	for (i = 0; i < ARRAY_SIZE(mask->control[band].he_ul_mcs); i++) {
+		if (hweight16(mask->control[band].he_ul_mcs[i]) == 1) {
+			he_ul_nss = i + 1;
+			he_ul_rate = ffs((int)
+					 mask->control[band].he_ul_mcs[i]) - 1;
+			break;
+		}
+	}
+
 	/* mac80211 doesn't support sending a fixed HT/VHT MCS alone, rather it
 	 * requires passing atleast one of used basic rates along with them.
 	 * Fixed rate setting across different preambles(legacy, HT, VHT) is
@@ -6300,6 +6351,16 @@ ath11k_mac_op_set_bitrate_mask(struct ieee80211_hw *hw,
 			return -EINVAL;
 		}
 
+		num_rates = ath11k_mac_bitrate_mask_num_he_ul_rates(ar, band,
+								    mask);
+
+		if (ath11k_mac_he_ul_mcs_present(ar, band, mask) &&
+		    num_rates != 1) {
+			ath11k_warn(ar->ab,
+				    "Setting HE UL MCS Fixed Rate range is not supported in fw.\n");
+			return -EINVAL;
+		}
+
 		ieee80211_iterate_stations_atomic(ar->hw,
 						  ath11k_mac_disable_peer_fixed_rate,
 						  arvif);
@@ -6317,7 +6378,8 @@ ath11k_mac_op_set_bitrate_mask(struct ieee80211_hw *hw,
 	mutex_lock(&ar->conf_mutex);
 
 	ret = ath11k_mac_set_fixed_rate_params(arvif, rate, nss, sgi, ldpc,
-					       he_gi, he_ltf);
+					       he_gi, he_ltf, he_ul_rate,
+					       he_ul_nss);
 	if (ret) {
 		ath11k_warn(ar->ab, "failed to set fixed rate params on vdev %i: %d\n",
 			    arvif->vdev_id, ret);
diff --git a/drivers/net/wireless/ath/ath11k/wmi.h b/drivers/net/wireless/ath/ath11k/wmi.h
index 5ff52f5649da..98e7ef7e6459 100644
--- a/drivers/net/wireless/ath/ath11k/wmi.h
+++ b/drivers/net/wireless/ath/ath11k/wmi.h
@@ -1047,6 +1047,7 @@ enum wmi_tlv_vdev_param {
 	WMI_VDEV_PARAM_HE_LTF = 0x74,
 	WMI_VDEV_PARAM_BA_MODE = 0x7e,
 	WMI_VDEV_PARAM_SET_HE_SOUNDING_MODE = 0x87,
+	WMI_VDEV_PARAM_UL_FIXED_RATE,
 	WMI_VDEV_PARAM_6GHZ_PARAMS = 0x99,
 	WMI_VDEV_PARAM_PROTOTYPE = 0x8000,
 	WMI_VDEV_PARAM_BSS_COLOR,
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-12-08 15:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-29 22:25 [PATCH] ath11k: Add HE UL MU fixed rate setting Muna Sinada
2021-12-08 15:44 ` Kalle Valo

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).