0039-wifi-ath11k-push-MU-MIMO-params-from-hostapd-to-hard.patch 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  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. In the previous behaviour only HE IE in management frames are changed
  6. regarding MU-MIMO configurations and not in hardware. Adding push of
  7. MU-MIMO configurations to the hardware as well.
  8. Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.4.0.1-00356-QCAHKSWPL_SILICONZ-1
  9. Co-developed-by: Anilkumar Kolli <quic_akolli@quicinc.com>
  10. Signed-off-by: Anilkumar Kolli <quic_akolli@quicinc.com>
  11. Signed-off-by: Muna Sinada <quic_msinada@quicinc.com>
  12. Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
  13. Link: https://lore.kernel.org/r/1666128501-12364-3-git-send-email-quic_msinada@quicinc.com
  14. ---
  15. drivers/net/wireless/ath/ath11k/mac.c | 200 ++++++++++++++++----------
  16. drivers/net/wireless/ath/ath11k/wmi.h | 3 +
  17. 2 files changed, 130 insertions(+), 73 deletions(-)
  18. --- a/drivers/net/wireless/ath/ath11k/mac.c
  19. +++ b/drivers/net/wireless/ath/ath11k/mac.c
  20. @@ -2699,6 +2699,117 @@ static int ath11k_setup_peer_smps(struct
  21. ath11k_smps_map[smps]);
  22. }
  23. +static bool ath11k_mac_set_he_txbf_conf(struct ath11k_vif *arvif)
  24. +{
  25. + struct ath11k *ar = arvif->ar;
  26. + u32 param, value;
  27. + int ret;
  28. +
  29. + if (!arvif->vif->bss_conf.he_support)
  30. + return true;
  31. +
  32. + param = WMI_VDEV_PARAM_SET_HEMU_MODE;
  33. + value = 0;
  34. + if (arvif->vif->bss_conf.he_su_beamformer) {
  35. + value |= FIELD_PREP(HE_MODE_SU_TX_BFER, HE_SU_BFER_ENABLE);
  36. + if (arvif->vif->bss_conf.he_mu_beamformer &&
  37. + arvif->vdev_type == WMI_VDEV_TYPE_AP)
  38. + value |= FIELD_PREP(HE_MODE_MU_TX_BFER, HE_MU_BFER_ENABLE);
  39. + }
  40. +
  41. + if (arvif->vif->type != NL80211_IFTYPE_MESH_POINT) {
  42. + value |= FIELD_PREP(HE_MODE_DL_OFDMA, HE_DL_MUOFDMA_ENABLE) |
  43. + FIELD_PREP(HE_MODE_UL_OFDMA, HE_UL_MUOFDMA_ENABLE);
  44. +
  45. + if (arvif->vif->bss_conf.he_full_ul_mumimo)
  46. + value |= FIELD_PREP(HE_MODE_UL_MUMIMO, HE_UL_MUMIMO_ENABLE);
  47. +
  48. + if (arvif->vif->bss_conf.he_su_beamformee)
  49. + value |= FIELD_PREP(HE_MODE_SU_TX_BFEE, HE_SU_BFEE_ENABLE);
  50. + }
  51. +
  52. + ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, param, value);
  53. + if (ret) {
  54. + ath11k_warn(ar->ab, "failed to set vdev %d HE MU mode: %d\n",
  55. + arvif->vdev_id, ret);
  56. + return false;
  57. + }
  58. +
  59. + param = WMI_VDEV_PARAM_SET_HE_SOUNDING_MODE;
  60. + value = FIELD_PREP(HE_VHT_SOUNDING_MODE, HE_VHT_SOUNDING_MODE_ENABLE) |
  61. + FIELD_PREP(HE_TRIG_NONTRIG_SOUNDING_MODE,
  62. + HE_TRIG_NONTRIG_SOUNDING_MODE_ENABLE);
  63. + ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id,
  64. + param, value);
  65. + if (ret) {
  66. + ath11k_warn(ar->ab, "failed to set vdev %d sounding mode: %d\n",
  67. + arvif->vdev_id, ret);
  68. + return false;
  69. + }
  70. + return true;
  71. +}
  72. +
  73. +static bool ath11k_mac_vif_recalc_sta_he_txbf(struct ath11k *ar,
  74. + struct ieee80211_vif *vif,
  75. + struct ieee80211_sta_he_cap *he_cap)
  76. +{
  77. + struct ath11k_vif *arvif = (void *)vif->drv_priv;
  78. + struct ieee80211_he_cap_elem he_cap_elem = {0};
  79. + struct ieee80211_sta_he_cap *cap_band = NULL;
  80. + struct cfg80211_chan_def def;
  81. + u32 param = WMI_VDEV_PARAM_SET_HEMU_MODE;
  82. + u32 hemode = 0;
  83. + int ret;
  84. +
  85. + if (!vif->bss_conf.he_support)
  86. + return true;
  87. +
  88. + if (vif->type != NL80211_IFTYPE_STATION)
  89. + return false;
  90. +
  91. + if (WARN_ON(ath11k_mac_vif_chan(vif, &def)))
  92. + return false;
  93. +
  94. + if (def.chan->band == NL80211_BAND_2GHZ)
  95. + cap_band = &ar->mac.iftype[NL80211_BAND_2GHZ][vif->type].he_cap;
  96. + else
  97. + cap_band = &ar->mac.iftype[NL80211_BAND_5GHZ][vif->type].he_cap;
  98. +
  99. + memcpy(&he_cap_elem, &cap_band->he_cap_elem, sizeof(he_cap_elem));
  100. +
  101. + if (HECAP_PHY_SUBFME_GET(he_cap_elem.phy_cap_info)) {
  102. + if (HECAP_PHY_SUBFMR_GET(he_cap->he_cap_elem.phy_cap_info))
  103. + hemode |= FIELD_PREP(HE_MODE_SU_TX_BFEE, HE_SU_BFEE_ENABLE);
  104. + if (HECAP_PHY_MUBFMR_GET(he_cap->he_cap_elem.phy_cap_info))
  105. + hemode |= FIELD_PREP(HE_MODE_MU_TX_BFEE, HE_MU_BFEE_ENABLE);
  106. + }
  107. +
  108. + if (vif->type != NL80211_IFTYPE_MESH_POINT) {
  109. + hemode |= FIELD_PREP(HE_MODE_DL_OFDMA, HE_DL_MUOFDMA_ENABLE) |
  110. + FIELD_PREP(HE_MODE_UL_OFDMA, HE_UL_MUOFDMA_ENABLE);
  111. +
  112. + if (HECAP_PHY_ULMUMIMO_GET(he_cap_elem.phy_cap_info))
  113. + if (HECAP_PHY_ULMUMIMO_GET(he_cap->he_cap_elem.phy_cap_info))
  114. + hemode |= FIELD_PREP(HE_MODE_UL_MUMIMO,
  115. + HE_UL_MUMIMO_ENABLE);
  116. +
  117. + if (FIELD_GET(HE_MODE_MU_TX_BFEE, hemode))
  118. + hemode |= FIELD_PREP(HE_MODE_SU_TX_BFEE, HE_SU_BFEE_ENABLE);
  119. +
  120. + if (FIELD_GET(HE_MODE_MU_TX_BFER, hemode))
  121. + hemode |= FIELD_PREP(HE_MODE_SU_TX_BFER, HE_SU_BFER_ENABLE);
  122. + }
  123. +
  124. + ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, param, hemode);
  125. + if (ret) {
  126. + ath11k_warn(ar->ab, "failed to submit vdev param txbf 0x%x: %d\n",
  127. + hemode, ret);
  128. + return false;
  129. + }
  130. +
  131. + return true;
  132. +}
  133. +
  134. static void ath11k_bss_assoc(struct ieee80211_hw *hw,
  135. struct ieee80211_vif *vif,
  136. struct ieee80211_bss_conf *bss_conf)
  137. @@ -2709,6 +2820,7 @@ static void ath11k_bss_assoc(struct ieee
  138. struct ieee80211_sta *ap_sta;
  139. struct ath11k_peer *peer;
  140. bool is_auth = false;
  141. + struct ieee80211_sta_he_cap he_cap;
  142. int ret;
  143. lockdep_assert_held(&ar->conf_mutex);
  144. @@ -2726,6 +2838,9 @@ static void ath11k_bss_assoc(struct ieee
  145. return;
  146. }
  147. + /* he_cap here is updated at assoc success for sta mode only */
  148. + he_cap = ap_sta->deflink.he_cap;
  149. +
  150. ath11k_peer_assoc_prepare(ar, vif, ap_sta, &peer_arg, false);
  151. rcu_read_unlock();
  152. @@ -2753,6 +2868,12 @@ static void ath11k_bss_assoc(struct ieee
  153. return;
  154. }
  155. + if (!ath11k_mac_vif_recalc_sta_he_txbf(ar, vif, &he_cap)) {
  156. + ath11k_warn(ar->ab, "failed to recalc he txbf for vdev %i on bss %pM\n",
  157. + arvif->vdev_id, bss_conf->bssid);
  158. + return;
  159. + }
  160. +
  161. WARN_ON(arvif->is_up);
  162. arvif->aid = vif->cfg.aid;
  163. @@ -3202,6 +3323,8 @@ static void ath11k_mac_op_bss_info_chang
  164. ether_addr_copy(arvif->bssid, info->bssid);
  165. if (changed & BSS_CHANGED_BEACON_ENABLED) {
  166. + if (info->enable_beacon)
  167. + ath11k_mac_set_he_txbf_conf(arvif);
  168. ath11k_control_beaconing(arvif, info);
  169. if (arvif->is_up && vif->bss_conf.he_support &&
  170. @@ -5392,6 +5515,10 @@ static int ath11k_mac_copy_he_cap(struct
  171. he_cap_elem->mac_cap_info[1] &=
  172. IEEE80211_HE_MAC_CAP1_TF_MAC_PAD_DUR_MASK;
  173. + he_cap_elem->phy_cap_info[0] &=
  174. + ~IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_160MHZ_IN_5G;
  175. + he_cap_elem->phy_cap_info[0] &=
  176. + ~IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_80PLUS80_MHZ_IN_5G;
  177. he_cap_elem->phy_cap_info[5] &=
  178. ~IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_UNDER_80MHZ_MASK;
  179. @@ -6026,69 +6153,6 @@ ath11k_mac_setup_vdev_create_params(stru
  180. }
  181. }
  182. -static u32
  183. -ath11k_mac_prepare_he_mode(struct ath11k_pdev *pdev, u32 viftype)
  184. -{
  185. - struct ath11k_pdev_cap *pdev_cap = &pdev->cap;
  186. - struct ath11k_band_cap *cap_band = NULL;
  187. - u32 *hecap_phy_ptr = NULL;
  188. - u32 hemode = 0;
  189. -
  190. - if (pdev->cap.supported_bands & WMI_HOST_WLAN_2G_CAP)
  191. - cap_band = &pdev_cap->band[NL80211_BAND_2GHZ];
  192. - else
  193. - cap_band = &pdev_cap->band[NL80211_BAND_5GHZ];
  194. -
  195. - hecap_phy_ptr = &cap_band->he_cap_phy_info[0];
  196. -
  197. - hemode = FIELD_PREP(HE_MODE_SU_TX_BFEE, HE_SU_BFEE_ENABLE) |
  198. - FIELD_PREP(HE_MODE_SU_TX_BFER, HECAP_PHY_SUBFMR_GET(hecap_phy_ptr)) |
  199. - FIELD_PREP(HE_MODE_UL_MUMIMO, HECAP_PHY_ULMUMIMO_GET(hecap_phy_ptr));
  200. -
  201. - /* TODO WDS and other modes */
  202. - if (viftype == NL80211_IFTYPE_AP) {
  203. - hemode |= FIELD_PREP(HE_MODE_MU_TX_BFER,
  204. - HECAP_PHY_MUBFMR_GET(hecap_phy_ptr)) |
  205. - FIELD_PREP(HE_MODE_DL_OFDMA, HE_DL_MUOFDMA_ENABLE) |
  206. - FIELD_PREP(HE_MODE_UL_OFDMA, HE_UL_MUOFDMA_ENABLE);
  207. - } else {
  208. - hemode |= FIELD_PREP(HE_MODE_MU_TX_BFEE, HE_MU_BFEE_ENABLE);
  209. - }
  210. -
  211. - return hemode;
  212. -}
  213. -
  214. -static int ath11k_set_he_mu_sounding_mode(struct ath11k *ar,
  215. - struct ath11k_vif *arvif)
  216. -{
  217. - u32 param_id, param_value;
  218. - struct ath11k_base *ab = ar->ab;
  219. - int ret = 0;
  220. -
  221. - param_id = WMI_VDEV_PARAM_SET_HEMU_MODE;
  222. - param_value = ath11k_mac_prepare_he_mode(ar->pdev, arvif->vif->type);
  223. - ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id,
  224. - param_id, param_value);
  225. - if (ret) {
  226. - ath11k_warn(ab, "failed to set vdev %d HE MU mode: %d param_value %x\n",
  227. - arvif->vdev_id, ret, param_value);
  228. - return ret;
  229. - }
  230. - param_id = WMI_VDEV_PARAM_SET_HE_SOUNDING_MODE;
  231. - param_value =
  232. - FIELD_PREP(HE_VHT_SOUNDING_MODE, HE_VHT_SOUNDING_MODE_ENABLE) |
  233. - FIELD_PREP(HE_TRIG_NONTRIG_SOUNDING_MODE,
  234. - HE_TRIG_NONTRIG_SOUNDING_MODE_ENABLE);
  235. - ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id,
  236. - param_id, param_value);
  237. - if (ret) {
  238. - ath11k_warn(ab, "failed to set vdev %d HE MU mode: %d\n",
  239. - arvif->vdev_id, ret);
  240. - return ret;
  241. - }
  242. - return ret;
  243. -}
  244. -
  245. static void ath11k_mac_op_update_vif_offload(struct ieee80211_hw *hw,
  246. struct ieee80211_vif *vif)
  247. {
  248. @@ -6757,7 +6821,6 @@ ath11k_mac_vdev_start_restart(struct ath
  249. struct ath11k_base *ab = ar->ab;
  250. struct wmi_vdev_start_req_arg arg = {};
  251. const struct cfg80211_chan_def *chandef = &ctx->def;
  252. - int he_support = arvif->vif->bss_conf.he_support;
  253. int ret = 0;
  254. lockdep_assert_held(&ar->conf_mutex);
  255. @@ -6798,15 +6861,6 @@ ath11k_mac_vdev_start_restart(struct ath
  256. spin_lock_bh(&ab->base_lock);
  257. arg.regdomain = ar->ab->dfs_region;
  258. spin_unlock_bh(&ab->base_lock);
  259. -
  260. - if (he_support) {
  261. - ret = ath11k_set_he_mu_sounding_mode(ar, arvif);
  262. - if (ret) {
  263. - ath11k_warn(ar->ab, "failed to set he mode vdev %i\n",
  264. - arg.vdev_id);
  265. - return ret;
  266. - }
  267. - }
  268. }
  269. arg.channel.passive |= !!(chandef->chan->flags & IEEE80211_CHAN_NO_IR);
  270. --- a/drivers/net/wireless/ath/ath11k/wmi.h
  271. +++ b/drivers/net/wireless/ath/ath11k/wmi.h
  272. @@ -2897,8 +2897,11 @@ struct rx_reorder_queue_remove_params {
  273. #define HE_DL_MUOFDMA_ENABLE 1
  274. #define HE_UL_MUOFDMA_ENABLE 1
  275. #define HE_DL_MUMIMO_ENABLE 1
  276. +#define HE_UL_MUMIMO_ENABLE 1
  277. #define HE_MU_BFEE_ENABLE 1
  278. #define HE_SU_BFEE_ENABLE 1
  279. +#define HE_MU_BFER_ENABLE 1
  280. +#define HE_SU_BFER_ENABLE 1
  281. #define HE_VHT_SOUNDING_MODE_ENABLE 1
  282. #define HE_SU_MU_SOUNDING_MODE_ENABLE 1