1
0

0079-wifi-ath11k-Send-HT-fixed-rate-in-WMI-peer-fixed-par.patch 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. From df8e3729ffc0aa645839693f74ee7b6d999cdf64 Mon Sep 17 00:00:00 2001
  2. From: Maharaja Kennadyrajan <quic_mkenna@quicinc.com>
  3. Date: Tue, 9 May 2023 20:07:24 +0300
  4. Subject: [PATCH] wifi: ath11k: Send HT fixed rate in WMI peer fixed param
  5. Due to the firmware behavior with HT fixed rate setting,
  6. HT fixed rate MCS with NSS > 1 are treated as NSS = 1
  7. HT rates in the firmware and enables the HT fixed rate of
  8. NSS = 1.
  9. This leads to HT fixed rate is always configured for NSS = 1
  10. even though the user sets NSS = 2 or > 1 HT fixed MCS in the
  11. set bitrate command.
  12. Currently HT fixed MCS is sent via WMI peer assoc command.
  13. Fix this issue, by sending the HT fixed rate MCS in WMI peer
  14. fixed param instead of sending in peer assoc command.
  15. Tested-on: QCN9074 hw1.0 PCI WLAN.HK.2.7.0.1-01744-QCAHKSWPL_SILICONZ-1
  16. Signed-off-by: Maharaja Kennadyrajan <quic_mkenna@quicinc.com>
  17. Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
  18. Link: https://lore.kernel.org/r/20230504092033.3542456-3-quic_mkenna@quicinc.com
  19. ---
  20. drivers/net/wireless/ath/ath11k/mac.c | 63 ++++++++++++++++++++++++++-
  21. 1 file changed, 61 insertions(+), 2 deletions(-)
  22. --- a/drivers/net/wireless/ath/ath11k/mac.c
  23. +++ b/drivers/net/wireless/ath/ath11k/mac.c
  24. @@ -4480,6 +4480,54 @@ ath11k_mac_set_peer_he_fixed_rate(struct
  25. return ret;
  26. }
  27. +static int
  28. +ath11k_mac_set_peer_ht_fixed_rate(struct ath11k_vif *arvif,
  29. + struct ieee80211_sta *sta,
  30. + const struct cfg80211_bitrate_mask *mask,
  31. + enum nl80211_band band)
  32. +{
  33. + struct ath11k *ar = arvif->ar;
  34. + u8 ht_rate, nss = 0;
  35. + u32 rate_code;
  36. + int ret, i;
  37. +
  38. + lockdep_assert_held(&ar->conf_mutex);
  39. +
  40. + for (i = 0; i < ARRAY_SIZE(mask->control[band].ht_mcs); i++) {
  41. + if (hweight8(mask->control[band].ht_mcs[i]) == 1) {
  42. + nss = i + 1;
  43. + ht_rate = ffs(mask->control[band].ht_mcs[i]) - 1;
  44. + }
  45. + }
  46. +
  47. + if (!nss) {
  48. + ath11k_warn(ar->ab, "No single HT Fixed rate found to set for %pM",
  49. + sta->addr);
  50. + return -EINVAL;
  51. + }
  52. +
  53. + /* Avoid updating invalid nss as fixed rate*/
  54. + if (nss > sta->deflink.rx_nss)
  55. + return -EINVAL;
  56. +
  57. + ath11k_dbg(ar->ab, ATH11K_DBG_MAC,
  58. + "Setting Fixed HT Rate for peer %pM. Device will not switch to any other selected rates",
  59. + sta->addr);
  60. +
  61. + rate_code = ATH11K_HW_RATE_CODE(ht_rate, nss - 1,
  62. + WMI_RATE_PREAMBLE_HT);
  63. + ret = ath11k_wmi_set_peer_param(ar, sta->addr,
  64. + arvif->vdev_id,
  65. + WMI_PEER_PARAM_FIXED_RATE,
  66. + rate_code);
  67. + if (ret)
  68. + ath11k_warn(ar->ab,
  69. + "failed to update STA %pM HT Fixed Rate %d: %d\n",
  70. + sta->addr, rate_code, ret);
  71. +
  72. + return ret;
  73. +}
  74. +
  75. static int ath11k_station_assoc(struct ath11k *ar,
  76. struct ieee80211_vif *vif,
  77. struct ieee80211_sta *sta,
  78. @@ -4491,7 +4539,7 @@ static int ath11k_station_assoc(struct a
  79. struct cfg80211_chan_def def;
  80. enum nl80211_band band;
  81. struct cfg80211_bitrate_mask *mask;
  82. - u8 num_vht_rates, num_he_rates;
  83. + u8 num_ht_rates, num_vht_rates, num_he_rates;
  84. lockdep_assert_held(&ar->conf_mutex);
  85. @@ -4519,6 +4567,7 @@ static int ath11k_station_assoc(struct a
  86. num_vht_rates = ath11k_mac_bitrate_mask_num_vht_rates(ar, band, mask);
  87. num_he_rates = ath11k_mac_bitrate_mask_num_he_rates(ar, band, mask);
  88. + num_ht_rates = ath11k_mac_bitrate_mask_num_ht_rates(ar, band, mask);
  89. /* If single VHT/HE rate is configured (by set_bitrate_mask()),
  90. * peer_assoc will disable VHT/HE. This is now enabled by a peer specific
  91. @@ -4535,6 +4584,11 @@ static int ath11k_station_assoc(struct a
  92. band);
  93. if (ret)
  94. return ret;
  95. + } else if (sta->deflink.ht_cap.ht_supported && num_ht_rates == 1) {
  96. + ret = ath11k_mac_set_peer_ht_fixed_rate(arvif, sta, mask,
  97. + band);
  98. + if (ret)
  99. + return ret;
  100. }
  101. /* Re-assoc is run only to update supported rates for given station. It
  102. @@ -4608,7 +4662,7 @@ static void ath11k_sta_rc_update_wk(stru
  103. const u16 *vht_mcs_mask;
  104. const u16 *he_mcs_mask;
  105. u32 changed, bw, nss, smps, bw_prev;
  106. - int err, num_vht_rates, num_he_rates;
  107. + int err, num_ht_rates, num_vht_rates, num_he_rates;
  108. const struct cfg80211_bitrate_mask *mask;
  109. struct peer_assoc_params peer_arg;
  110. enum wmi_phy_mode peer_phymode;
  111. @@ -4724,6 +4778,8 @@ static void ath11k_sta_rc_update_wk(stru
  112. if (changed & IEEE80211_RC_SUPP_RATES_CHANGED) {
  113. mask = &arvif->bitrate_mask;
  114. + num_ht_rates = ath11k_mac_bitrate_mask_num_ht_rates(ar, band,
  115. + mask);
  116. num_vht_rates = ath11k_mac_bitrate_mask_num_vht_rates(ar, band,
  117. mask);
  118. num_he_rates = ath11k_mac_bitrate_mask_num_he_rates(ar, band,
  119. @@ -4746,6 +4802,9 @@ static void ath11k_sta_rc_update_wk(stru
  120. } else if (sta->deflink.he_cap.has_he && num_he_rates == 1) {
  121. ath11k_mac_set_peer_he_fixed_rate(arvif, sta, mask,
  122. band);
  123. + } else if (sta->deflink.ht_cap.ht_supported && num_ht_rates == 1) {
  124. + ath11k_mac_set_peer_ht_fixed_rate(arvif, sta, mask,
  125. + band);
  126. } else {
  127. /* If the peer is non-VHT/HE or no fixed VHT/HE rate
  128. * is provided in the new bitrate mask we set the