1 From 38dfe775d0abf511341f37c1cb77b919a3ad410b Mon Sep 17 00:00:00 2001
2 From: Muna Sinada <quic_msinada@quicinc.com>
3 Date: Fri, 24 Feb 2023 12:28:04 +0200
4 Subject: [PATCH] wifi: ath11k: push MU-MIMO params from hostapd to hardware
6 In the previous behaviour only HE IE in management frames are changed
7 regarding MU-MIMO configurations and not in hardware. Adding push of
8 MU-MIMO configurations to the hardware as well.
10 Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.4.0.1-00356-QCAHKSWPL_SILICONZ-1
12 Co-developed-by: Anilkumar Kolli <quic_akolli@quicinc.com>
13 Signed-off-by: Anilkumar Kolli <quic_akolli@quicinc.com>
14 Signed-off-by: Muna Sinada <quic_msinada@quicinc.com>
15 Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
16 Link: https://lore.kernel.org/r/1666128501-12364-3-git-send-email-quic_msinada@quicinc.com
18 drivers/net/wireless/ath/ath11k/mac.c | 200 ++++++++++++++++----------
19 drivers/net/wireless/ath/ath11k/wmi.h | 3 +
20 2 files changed, 130 insertions(+), 73 deletions(-)
22 --- a/drivers/net/wireless/ath/ath11k/mac.c
23 +++ b/drivers/net/wireless/ath/ath11k/mac.c
24 @@ -2699,6 +2699,117 @@ static int ath11k_setup_peer_smps(struct
25 ath11k_smps_map[smps]);
28 +static bool ath11k_mac_set_he_txbf_conf(struct ath11k_vif *arvif)
30 + struct ath11k *ar = arvif->ar;
34 + if (!arvif->vif->bss_conf.he_support)
37 + param = WMI_VDEV_PARAM_SET_HEMU_MODE;
39 + if (arvif->vif->bss_conf.he_su_beamformer) {
40 + value |= FIELD_PREP(HE_MODE_SU_TX_BFER, HE_SU_BFER_ENABLE);
41 + if (arvif->vif->bss_conf.he_mu_beamformer &&
42 + arvif->vdev_type == WMI_VDEV_TYPE_AP)
43 + value |= FIELD_PREP(HE_MODE_MU_TX_BFER, HE_MU_BFER_ENABLE);
46 + if (arvif->vif->type != NL80211_IFTYPE_MESH_POINT) {
47 + value |= FIELD_PREP(HE_MODE_DL_OFDMA, HE_DL_MUOFDMA_ENABLE) |
48 + FIELD_PREP(HE_MODE_UL_OFDMA, HE_UL_MUOFDMA_ENABLE);
50 + if (arvif->vif->bss_conf.he_full_ul_mumimo)
51 + value |= FIELD_PREP(HE_MODE_UL_MUMIMO, HE_UL_MUMIMO_ENABLE);
53 + if (arvif->vif->bss_conf.he_su_beamformee)
54 + value |= FIELD_PREP(HE_MODE_SU_TX_BFEE, HE_SU_BFEE_ENABLE);
57 + ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, param, value);
59 + ath11k_warn(ar->ab, "failed to set vdev %d HE MU mode: %d\n",
60 + arvif->vdev_id, ret);
64 + param = WMI_VDEV_PARAM_SET_HE_SOUNDING_MODE;
65 + value = FIELD_PREP(HE_VHT_SOUNDING_MODE, HE_VHT_SOUNDING_MODE_ENABLE) |
66 + FIELD_PREP(HE_TRIG_NONTRIG_SOUNDING_MODE,
67 + HE_TRIG_NONTRIG_SOUNDING_MODE_ENABLE);
68 + ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id,
71 + ath11k_warn(ar->ab, "failed to set vdev %d sounding mode: %d\n",
72 + arvif->vdev_id, ret);
78 +static bool ath11k_mac_vif_recalc_sta_he_txbf(struct ath11k *ar,
79 + struct ieee80211_vif *vif,
80 + struct ieee80211_sta_he_cap *he_cap)
82 + struct ath11k_vif *arvif = (void *)vif->drv_priv;
83 + struct ieee80211_he_cap_elem he_cap_elem = {0};
84 + struct ieee80211_sta_he_cap *cap_band = NULL;
85 + struct cfg80211_chan_def def;
86 + u32 param = WMI_VDEV_PARAM_SET_HEMU_MODE;
90 + if (!vif->bss_conf.he_support)
93 + if (vif->type != NL80211_IFTYPE_STATION)
96 + if (WARN_ON(ath11k_mac_vif_chan(vif, &def)))
99 + if (def.chan->band == NL80211_BAND_2GHZ)
100 + cap_band = &ar->mac.iftype[NL80211_BAND_2GHZ][vif->type].he_cap;
102 + cap_band = &ar->mac.iftype[NL80211_BAND_5GHZ][vif->type].he_cap;
104 + memcpy(&he_cap_elem, &cap_band->he_cap_elem, sizeof(he_cap_elem));
106 + if (HECAP_PHY_SUBFME_GET(he_cap_elem.phy_cap_info)) {
107 + if (HECAP_PHY_SUBFMR_GET(he_cap->he_cap_elem.phy_cap_info))
108 + hemode |= FIELD_PREP(HE_MODE_SU_TX_BFEE, HE_SU_BFEE_ENABLE);
109 + if (HECAP_PHY_MUBFMR_GET(he_cap->he_cap_elem.phy_cap_info))
110 + hemode |= FIELD_PREP(HE_MODE_MU_TX_BFEE, HE_MU_BFEE_ENABLE);
113 + if (vif->type != NL80211_IFTYPE_MESH_POINT) {
114 + hemode |= FIELD_PREP(HE_MODE_DL_OFDMA, HE_DL_MUOFDMA_ENABLE) |
115 + FIELD_PREP(HE_MODE_UL_OFDMA, HE_UL_MUOFDMA_ENABLE);
117 + if (HECAP_PHY_ULMUMIMO_GET(he_cap_elem.phy_cap_info))
118 + if (HECAP_PHY_ULMUMIMO_GET(he_cap->he_cap_elem.phy_cap_info))
119 + hemode |= FIELD_PREP(HE_MODE_UL_MUMIMO,
120 + HE_UL_MUMIMO_ENABLE);
122 + if (FIELD_GET(HE_MODE_MU_TX_BFEE, hemode))
123 + hemode |= FIELD_PREP(HE_MODE_SU_TX_BFEE, HE_SU_BFEE_ENABLE);
125 + if (FIELD_GET(HE_MODE_MU_TX_BFER, hemode))
126 + hemode |= FIELD_PREP(HE_MODE_SU_TX_BFER, HE_SU_BFER_ENABLE);
129 + ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, param, hemode);
131 + ath11k_warn(ar->ab, "failed to submit vdev param txbf 0x%x: %d\n",
139 static void ath11k_bss_assoc(struct ieee80211_hw *hw,
140 struct ieee80211_vif *vif,
141 struct ieee80211_bss_conf *bss_conf)
142 @@ -2709,6 +2820,7 @@ static void ath11k_bss_assoc(struct ieee
143 struct ieee80211_sta *ap_sta;
144 struct ath11k_peer *peer;
145 bool is_auth = false;
146 + struct ieee80211_sta_he_cap he_cap;
149 lockdep_assert_held(&ar->conf_mutex);
150 @@ -2726,6 +2838,9 @@ static void ath11k_bss_assoc(struct ieee
154 + /* he_cap here is updated at assoc success for sta mode only */
155 + he_cap = ap_sta->deflink.he_cap;
157 ath11k_peer_assoc_prepare(ar, vif, ap_sta, &peer_arg, false);
160 @@ -2753,6 +2868,12 @@ static void ath11k_bss_assoc(struct ieee
164 + if (!ath11k_mac_vif_recalc_sta_he_txbf(ar, vif, &he_cap)) {
165 + ath11k_warn(ar->ab, "failed to recalc he txbf for vdev %i on bss %pM\n",
166 + arvif->vdev_id, bss_conf->bssid);
170 WARN_ON(arvif->is_up);
172 arvif->aid = vif->cfg.aid;
173 @@ -3202,6 +3323,8 @@ static void ath11k_mac_op_bss_info_chang
174 ether_addr_copy(arvif->bssid, info->bssid);
176 if (changed & BSS_CHANGED_BEACON_ENABLED) {
177 + if (info->enable_beacon)
178 + ath11k_mac_set_he_txbf_conf(arvif);
179 ath11k_control_beaconing(arvif, info);
181 if (arvif->is_up && vif->bss_conf.he_support &&
182 @@ -5392,6 +5515,10 @@ static int ath11k_mac_copy_he_cap(struct
184 he_cap_elem->mac_cap_info[1] &=
185 IEEE80211_HE_MAC_CAP1_TF_MAC_PAD_DUR_MASK;
186 + he_cap_elem->phy_cap_info[0] &=
187 + ~IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_160MHZ_IN_5G;
188 + he_cap_elem->phy_cap_info[0] &=
189 + ~IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_80PLUS80_MHZ_IN_5G;
191 he_cap_elem->phy_cap_info[5] &=
192 ~IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_UNDER_80MHZ_MASK;
193 @@ -6026,69 +6153,6 @@ ath11k_mac_setup_vdev_create_params(stru
198 -ath11k_mac_prepare_he_mode(struct ath11k_pdev *pdev, u32 viftype)
200 - struct ath11k_pdev_cap *pdev_cap = &pdev->cap;
201 - struct ath11k_band_cap *cap_band = NULL;
202 - u32 *hecap_phy_ptr = NULL;
205 - if (pdev->cap.supported_bands & WMI_HOST_WLAN_2G_CAP)
206 - cap_band = &pdev_cap->band[NL80211_BAND_2GHZ];
208 - cap_band = &pdev_cap->band[NL80211_BAND_5GHZ];
210 - hecap_phy_ptr = &cap_band->he_cap_phy_info[0];
212 - hemode = FIELD_PREP(HE_MODE_SU_TX_BFEE, HE_SU_BFEE_ENABLE) |
213 - FIELD_PREP(HE_MODE_SU_TX_BFER, HECAP_PHY_SUBFMR_GET(hecap_phy_ptr)) |
214 - FIELD_PREP(HE_MODE_UL_MUMIMO, HECAP_PHY_ULMUMIMO_GET(hecap_phy_ptr));
216 - /* TODO WDS and other modes */
217 - if (viftype == NL80211_IFTYPE_AP) {
218 - hemode |= FIELD_PREP(HE_MODE_MU_TX_BFER,
219 - HECAP_PHY_MUBFMR_GET(hecap_phy_ptr)) |
220 - FIELD_PREP(HE_MODE_DL_OFDMA, HE_DL_MUOFDMA_ENABLE) |
221 - FIELD_PREP(HE_MODE_UL_OFDMA, HE_UL_MUOFDMA_ENABLE);
223 - hemode |= FIELD_PREP(HE_MODE_MU_TX_BFEE, HE_MU_BFEE_ENABLE);
229 -static int ath11k_set_he_mu_sounding_mode(struct ath11k *ar,
230 - struct ath11k_vif *arvif)
232 - u32 param_id, param_value;
233 - struct ath11k_base *ab = ar->ab;
236 - param_id = WMI_VDEV_PARAM_SET_HEMU_MODE;
237 - param_value = ath11k_mac_prepare_he_mode(ar->pdev, arvif->vif->type);
238 - ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id,
239 - param_id, param_value);
241 - ath11k_warn(ab, "failed to set vdev %d HE MU mode: %d param_value %x\n",
242 - arvif->vdev_id, ret, param_value);
245 - param_id = WMI_VDEV_PARAM_SET_HE_SOUNDING_MODE;
247 - FIELD_PREP(HE_VHT_SOUNDING_MODE, HE_VHT_SOUNDING_MODE_ENABLE) |
248 - FIELD_PREP(HE_TRIG_NONTRIG_SOUNDING_MODE,
249 - HE_TRIG_NONTRIG_SOUNDING_MODE_ENABLE);
250 - ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id,
251 - param_id, param_value);
253 - ath11k_warn(ab, "failed to set vdev %d HE MU mode: %d\n",
254 - arvif->vdev_id, ret);
260 static void ath11k_mac_op_update_vif_offload(struct ieee80211_hw *hw,
261 struct ieee80211_vif *vif)
263 @@ -6757,7 +6821,6 @@ ath11k_mac_vdev_start_restart(struct ath
264 struct ath11k_base *ab = ar->ab;
265 struct wmi_vdev_start_req_arg arg = {};
266 const struct cfg80211_chan_def *chandef = &ctx->def;
267 - int he_support = arvif->vif->bss_conf.he_support;
270 lockdep_assert_held(&ar->conf_mutex);
271 @@ -6798,15 +6861,6 @@ ath11k_mac_vdev_start_restart(struct ath
272 spin_lock_bh(&ab->base_lock);
273 arg.regdomain = ar->ab->dfs_region;
274 spin_unlock_bh(&ab->base_lock);
277 - ret = ath11k_set_he_mu_sounding_mode(ar, arvif);
279 - ath11k_warn(ar->ab, "failed to set he mode vdev %i\n",
286 arg.channel.passive |= !!(chandef->chan->flags & IEEE80211_CHAN_NO_IR);
287 --- a/drivers/net/wireless/ath/ath11k/wmi.h
288 +++ b/drivers/net/wireless/ath/ath11k/wmi.h
289 @@ -2897,8 +2897,11 @@ struct rx_reorder_queue_remove_params {
290 #define HE_DL_MUOFDMA_ENABLE 1
291 #define HE_UL_MUOFDMA_ENABLE 1
292 #define HE_DL_MUMIMO_ENABLE 1
293 +#define HE_UL_MUMIMO_ENABLE 1
294 #define HE_MU_BFEE_ENABLE 1
295 #define HE_SU_BFEE_ENABLE 1
296 +#define HE_MU_BFER_ENABLE 1
297 +#define HE_SU_BFER_ENABLE 1
299 #define HE_VHT_SOUNDING_MODE_ENABLE 1
300 #define HE_SU_MU_SOUNDING_MODE_ENABLE 1