977-ath10k-add-support-for-configuring-management-packet.patch 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. From: Sriram R <[email protected]>
  2. Date: Mon, 10 Sep 2018 11:09:40 +0530
  3. Subject: [PATCH] ath10k: add support for configuring management packet rate
  4. By default the firmware uses 1Mbps and 6Mbps rate for management packets
  5. in 2G and 5G bands respectively. But when the user selects different
  6. basic rates from the userspace, we need to send the management
  7. packets at the lowest basic rate selected by the user.
  8. This change makes use of WMI_VDEV_PARAM_MGMT_RATE param for configuring the
  9. management packets rate to the firmware.
  10. Chipsets Tested : QCA988X, QCA9887, QCA9984
  11. FW Tested : 10.2.4-1.0-41, 10.4-3.6.104
  12. Signed-off-by: Sriram R <[email protected]>
  13. Signed-off-by: Kalle Valo <[email protected]>
  14. Origin: backport, https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=f279294e9ee22a8f306fdc8e4181cf555e6f0f70
  15. ---
  16. --- a/drivers/net/wireless/ath/ath10k/mac.c
  17. +++ b/drivers/net/wireless/ath/ath10k/mac.c
  18. @@ -158,6 +158,22 @@ u8 ath10k_mac_bitrate_to_idx(const struc
  19. return 0;
  20. }
  21. +static int ath10k_mac_get_rate_hw_value(int bitrate)
  22. +{
  23. + int i;
  24. + u8 hw_value_prefix = 0;
  25. +
  26. + if (ath10k_mac_bitrate_is_cck(bitrate))
  27. + hw_value_prefix = WMI_RATE_PREAMBLE_CCK << 6;
  28. +
  29. + for (i = 0; i < sizeof(ath10k_rates); i++) {
  30. + if (ath10k_rates[i].bitrate == bitrate)
  31. + return hw_value_prefix | ath10k_rates[i].hw_value;
  32. + }
  33. +
  34. + return -EINVAL;
  35. +}
  36. +
  37. static int ath10k_mac_get_max_vht_mcs_map(u16 mcs_map, int nss)
  38. {
  39. switch ((mcs_map >> (2 * nss)) & 0x3) {
  40. @@ -5468,9 +5484,10 @@ static void ath10k_bss_info_changed(stru
  41. struct cfg80211_chan_def def;
  42. u32 vdev_param, pdev_param, slottime, preamble;
  43. u16 bitrate, hw_value;
  44. - u8 rate;
  45. - int rateidx, ret = 0;
  46. + u8 rate, basic_rate_idx;
  47. + int rateidx, ret = 0, hw_rate_code;
  48. enum nl80211_band band;
  49. + const struct ieee80211_supported_band *sband;
  50. mutex_lock(&ar->conf_mutex);
  51. @@ -5676,6 +5693,30 @@ static void ath10k_bss_info_changed(stru
  52. arvif->vdev_id, ret);
  53. }
  54. + if (changed & BSS_CHANGED_BASIC_RATES) {
  55. + if (WARN_ON(ath10k_mac_vif_chan(vif, &def))) {
  56. + mutex_unlock(&ar->conf_mutex);
  57. + return;
  58. + }
  59. +
  60. + sband = ar->hw->wiphy->bands[def.chan->band];
  61. + basic_rate_idx = ffs(vif->bss_conf.basic_rates) - 1;
  62. + bitrate = sband->bitrates[basic_rate_idx].bitrate;
  63. +
  64. + hw_rate_code = ath10k_mac_get_rate_hw_value(bitrate);
  65. + if (hw_rate_code < 0) {
  66. + ath10k_warn(ar, "bitrate not supported %d\n", bitrate);
  67. + mutex_unlock(&ar->conf_mutex);
  68. + return;
  69. + }
  70. +
  71. + vdev_param = ar->wmi.vdev_param->mgmt_rate;
  72. + ret = ath10k_wmi_vdev_set_param(ar, arvif->vdev_id, vdev_param,
  73. + hw_rate_code);
  74. + if (ret)
  75. + ath10k_warn(ar, "failed to set mgmt tx rate %d\n", ret);
  76. + }
  77. +
  78. mutex_unlock(&ar->conf_mutex);
  79. }