298ce1a612b6a19adc9bd62f41159b3bd798c4ed
[librecmc/librecmc.git] /
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
5
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.
9
10 Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.4.0.1-00356-QCAHKSWPL_SILICONZ-1
11
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
17 ---
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(-)
21
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]);
26  }
27  
28 +static bool ath11k_mac_set_he_txbf_conf(struct ath11k_vif *arvif)
29 +{
30 +       struct ath11k *ar = arvif->ar;
31 +       u32 param, value;
32 +       int ret;
33 +
34 +       if (!arvif->vif->bss_conf.he_support)
35 +               return true;
36 +
37 +       param = WMI_VDEV_PARAM_SET_HEMU_MODE;
38 +       value = 0;
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);
44 +       }
45 +
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);
49 +
50 +               if (arvif->vif->bss_conf.he_full_ul_mumimo)
51 +                       value |= FIELD_PREP(HE_MODE_UL_MUMIMO, HE_UL_MUMIMO_ENABLE);
52 +
53 +               if (arvif->vif->bss_conf.he_su_beamformee)
54 +                       value |= FIELD_PREP(HE_MODE_SU_TX_BFEE, HE_SU_BFEE_ENABLE);
55 +       }
56 +
57 +       ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, param, value);
58 +       if (ret) {
59 +               ath11k_warn(ar->ab, "failed to set vdev %d HE MU mode: %d\n",
60 +                           arvif->vdev_id, ret);
61 +               return false;
62 +       }
63 +
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,
69 +                                           param, value);
70 +       if (ret) {
71 +               ath11k_warn(ar->ab, "failed to set vdev %d sounding mode: %d\n",
72 +                           arvif->vdev_id, ret);
73 +               return false;
74 +       }
75 +       return true;
76 +}
77 +
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)
81 +{
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;
87 +       u32 hemode = 0;
88 +       int ret;
89 +
90 +       if (!vif->bss_conf.he_support)
91 +               return true;
92 +
93 +       if (vif->type != NL80211_IFTYPE_STATION)
94 +               return false;
95 +
96 +       if (WARN_ON(ath11k_mac_vif_chan(vif, &def)))
97 +               return false;
98 +
99 +       if (def.chan->band == NL80211_BAND_2GHZ)
100 +               cap_band = &ar->mac.iftype[NL80211_BAND_2GHZ][vif->type].he_cap;
101 +       else
102 +               cap_band = &ar->mac.iftype[NL80211_BAND_5GHZ][vif->type].he_cap;
103 +
104 +       memcpy(&he_cap_elem, &cap_band->he_cap_elem, sizeof(he_cap_elem));
105 +
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);
111 +       }
112 +
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);
116 +
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);
121 +
122 +               if (FIELD_GET(HE_MODE_MU_TX_BFEE, hemode))
123 +                       hemode |= FIELD_PREP(HE_MODE_SU_TX_BFEE, HE_SU_BFEE_ENABLE);
124 +
125 +               if (FIELD_GET(HE_MODE_MU_TX_BFER, hemode))
126 +                       hemode |= FIELD_PREP(HE_MODE_SU_TX_BFER, HE_SU_BFER_ENABLE);
127 +       }
128 +
129 +       ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, param, hemode);
130 +       if (ret) {
131 +               ath11k_warn(ar->ab, "failed to submit vdev param txbf 0x%x: %d\n",
132 +                           hemode, ret);
133 +               return false;
134 +       }
135 +
136 +       return true;
137 +}
138 +
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;
147         int ret;
148  
149         lockdep_assert_held(&ar->conf_mutex);
150 @@ -2726,6 +2838,9 @@ static void ath11k_bss_assoc(struct ieee
151                 return;
152         }
153  
154 +       /* he_cap here is updated at assoc success for sta mode only */
155 +       he_cap  = ap_sta->deflink.he_cap;
156 +
157         ath11k_peer_assoc_prepare(ar, vif, ap_sta, &peer_arg, false);
158  
159         rcu_read_unlock();
160 @@ -2753,6 +2868,12 @@ static void ath11k_bss_assoc(struct ieee
161                 return;
162         }
163  
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);
167 +               return;
168 +       }
169 +
170         WARN_ON(arvif->is_up);
171  
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);
175  
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);
180  
181                 if (arvif->is_up && vif->bss_conf.he_support &&
182 @@ -5392,6 +5515,10 @@ static int ath11k_mac_copy_he_cap(struct
183  
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;
190  
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
194         }
195  }
196  
197 -static u32
198 -ath11k_mac_prepare_he_mode(struct ath11k_pdev *pdev, u32 viftype)
199 -{
200 -       struct ath11k_pdev_cap *pdev_cap = &pdev->cap;
201 -       struct ath11k_band_cap *cap_band = NULL;
202 -       u32 *hecap_phy_ptr = NULL;
203 -       u32 hemode = 0;
204 -
205 -       if (pdev->cap.supported_bands & WMI_HOST_WLAN_2G_CAP)
206 -               cap_band = &pdev_cap->band[NL80211_BAND_2GHZ];
207 -       else
208 -               cap_band = &pdev_cap->band[NL80211_BAND_5GHZ];
209 -
210 -       hecap_phy_ptr = &cap_band->he_cap_phy_info[0];
211 -
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));
215 -
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);
222 -       } else {
223 -               hemode |= FIELD_PREP(HE_MODE_MU_TX_BFEE, HE_MU_BFEE_ENABLE);
224 -       }
225 -
226 -       return hemode;
227 -}
228 -
229 -static int ath11k_set_he_mu_sounding_mode(struct ath11k *ar,
230 -                                         struct ath11k_vif *arvif)
231 -{
232 -       u32 param_id, param_value;
233 -       struct ath11k_base *ab = ar->ab;
234 -       int ret = 0;
235 -
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);
240 -       if (ret) {
241 -               ath11k_warn(ab, "failed to set vdev %d HE MU mode: %d param_value %x\n",
242 -                           arvif->vdev_id, ret, param_value);
243 -               return ret;
244 -       }
245 -       param_id = WMI_VDEV_PARAM_SET_HE_SOUNDING_MODE;
246 -       param_value =
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);
252 -       if (ret) {
253 -               ath11k_warn(ab, "failed to set vdev %d HE MU mode: %d\n",
254 -                           arvif->vdev_id, ret);
255 -               return ret;
256 -       }
257 -       return ret;
258 -}
259 -
260  static void ath11k_mac_op_update_vif_offload(struct ieee80211_hw *hw,
261                                              struct ieee80211_vif *vif)
262  {
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;
268         int ret = 0;
269  
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);
275 -
276 -               if (he_support) {
277 -                       ret = ath11k_set_he_mu_sounding_mode(ar, arvif);
278 -                       if (ret) {
279 -                               ath11k_warn(ar->ab, "failed to set he mode vdev %i\n",
280 -                                           arg.vdev_id);
281 -                               return ret;
282 -                       }
283 -               }
284         }
285  
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
298  
299  #define HE_VHT_SOUNDING_MODE_ENABLE            1
300  #define HE_SU_MU_SOUNDING_MODE_ENABLE          1