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