lantiq: fix a race condition in the SPI driver leading to rx FIFO overflows (and...
[openwrt/svn-archive/archive.git] / package / kernel / mac80211 / patches / 312-ath10k-move-static-HT-VHT-capability-setup-functions.patch
1 From: Rajkumar Manoharan <rmanohar@qti.qualcomm.com>
2 Date: Tue, 27 Oct 2015 17:51:13 +0530
3 Subject: [PATCH] ath10k: move static HT/VHT capability setup functions
4
5 Move HT and VHT capabiltity setup static functions to avoid
6 forward declaration.
7
8 Signed-off-by: Rajkumar Manoharan <rmanohar@qti.qualcomm.com>
9 Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
10 ---
11
12 --- a/drivers/net/wireless/ath/ath10k/mac.c
13 +++ b/drivers/net/wireless/ath/ath10k/mac.c
14 @@ -3757,6 +3757,146 @@ static void ath10k_check_chain_mask(stru
15 dbg, cm);
16 }
17
18 +static int ath10k_mac_get_vht_cap_bf_sts(struct ath10k *ar)
19 +{
20 + int nsts = ar->vht_cap_info;
21 +
22 + nsts &= IEEE80211_VHT_CAP_BEAMFORMEE_STS_MASK;
23 + nsts >>= IEEE80211_VHT_CAP_BEAMFORMEE_STS_SHIFT;
24 +
25 + /* If firmware does not deliver to host number of space-time
26 + * streams supported, assume it support up to 4 BF STS and return
27 + * the value for VHT CAP: nsts-1)
28 + */
29 + if (nsts == 0)
30 + return 3;
31 +
32 + return nsts;
33 +}
34 +
35 +static int ath10k_mac_get_vht_cap_bf_sound_dim(struct ath10k *ar)
36 +{
37 + int sound_dim = ar->vht_cap_info;
38 +
39 + sound_dim &= IEEE80211_VHT_CAP_SOUNDING_DIMENSIONS_MASK;
40 + sound_dim >>= IEEE80211_VHT_CAP_SOUNDING_DIMENSIONS_SHIFT;
41 +
42 + /* If the sounding dimension is not advertised by the firmware,
43 + * let's use a default value of 1
44 + */
45 + if (sound_dim == 0)
46 + return 1;
47 +
48 + return sound_dim;
49 +}
50 +
51 +static struct ieee80211_sta_vht_cap ath10k_create_vht_cap(struct ath10k *ar)
52 +{
53 + struct ieee80211_sta_vht_cap vht_cap = {0};
54 + u16 mcs_map;
55 + u32 val;
56 + int i;
57 +
58 + vht_cap.vht_supported = 1;
59 + vht_cap.cap = ar->vht_cap_info;
60 +
61 + if (ar->vht_cap_info & (IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE |
62 + IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE)) {
63 + val = ath10k_mac_get_vht_cap_bf_sts(ar);
64 + val <<= IEEE80211_VHT_CAP_BEAMFORMEE_STS_SHIFT;
65 + val &= IEEE80211_VHT_CAP_BEAMFORMEE_STS_MASK;
66 +
67 + vht_cap.cap |= val;
68 + }
69 +
70 + if (ar->vht_cap_info & (IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE |
71 + IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE)) {
72 + val = ath10k_mac_get_vht_cap_bf_sound_dim(ar);
73 + val <<= IEEE80211_VHT_CAP_SOUNDING_DIMENSIONS_SHIFT;
74 + val &= IEEE80211_VHT_CAP_SOUNDING_DIMENSIONS_MASK;
75 +
76 + vht_cap.cap |= val;
77 + }
78 +
79 + mcs_map = 0;
80 + for (i = 0; i < 8; i++) {
81 + if ((i < ar->num_rf_chains) && (ar->cfg_tx_chainmask & BIT(i)))
82 + mcs_map |= IEEE80211_VHT_MCS_SUPPORT_0_9 << (i * 2);
83 + else
84 + mcs_map |= IEEE80211_VHT_MCS_NOT_SUPPORTED << (i * 2);
85 + }
86 +
87 + vht_cap.vht_mcs.rx_mcs_map = cpu_to_le16(mcs_map);
88 + vht_cap.vht_mcs.tx_mcs_map = cpu_to_le16(mcs_map);
89 +
90 + return vht_cap;
91 +}
92 +
93 +static struct ieee80211_sta_ht_cap ath10k_get_ht_cap(struct ath10k *ar)
94 +{
95 + int i;
96 + struct ieee80211_sta_ht_cap ht_cap = {0};
97 +
98 + if (!(ar->ht_cap_info & WMI_HT_CAP_ENABLED))
99 + return ht_cap;
100 +
101 + ht_cap.ht_supported = 1;
102 + ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K;
103 + ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_8;
104 + ht_cap.cap |= IEEE80211_HT_CAP_SUP_WIDTH_20_40;
105 + ht_cap.cap |= IEEE80211_HT_CAP_DSSSCCK40;
106 + ht_cap.cap |= WLAN_HT_CAP_SM_PS_STATIC << IEEE80211_HT_CAP_SM_PS_SHIFT;
107 +
108 + if (ar->ht_cap_info & WMI_HT_CAP_HT20_SGI)
109 + ht_cap.cap |= IEEE80211_HT_CAP_SGI_20;
110 +
111 + if (ar->ht_cap_info & WMI_HT_CAP_HT40_SGI)
112 + ht_cap.cap |= IEEE80211_HT_CAP_SGI_40;
113 +
114 + if (ar->ht_cap_info & WMI_HT_CAP_DYNAMIC_SMPS) {
115 + u32 smps;
116 +
117 + smps = WLAN_HT_CAP_SM_PS_DYNAMIC;
118 + smps <<= IEEE80211_HT_CAP_SM_PS_SHIFT;
119 +
120 + ht_cap.cap |= smps;
121 + }
122 +
123 + if (ar->ht_cap_info & WMI_HT_CAP_TX_STBC)
124 + ht_cap.cap |= IEEE80211_HT_CAP_TX_STBC;
125 +
126 + if (ar->ht_cap_info & WMI_HT_CAP_RX_STBC) {
127 + u32 stbc;
128 +
129 + stbc = ar->ht_cap_info;
130 + stbc &= WMI_HT_CAP_RX_STBC;
131 + stbc >>= WMI_HT_CAP_RX_STBC_MASK_SHIFT;
132 + stbc <<= IEEE80211_HT_CAP_RX_STBC_SHIFT;
133 + stbc &= IEEE80211_HT_CAP_RX_STBC;
134 +
135 + ht_cap.cap |= stbc;
136 + }
137 +
138 + if (ar->ht_cap_info & WMI_HT_CAP_LDPC)
139 + ht_cap.cap |= IEEE80211_HT_CAP_LDPC_CODING;
140 +
141 + if (ar->ht_cap_info & WMI_HT_CAP_L_SIG_TXOP_PROT)
142 + ht_cap.cap |= IEEE80211_HT_CAP_LSIG_TXOP_PROT;
143 +
144 + /* max AMSDU is implicitly taken from vht_cap_info */
145 + if (ar->vht_cap_info & WMI_VHT_CAP_MAX_MPDU_LEN_MASK)
146 + ht_cap.cap |= IEEE80211_HT_CAP_MAX_AMSDU;
147 +
148 + for (i = 0; i < ar->num_rf_chains; i++) {
149 + if (ar->cfg_rx_chainmask & BIT(i))
150 + ht_cap.mcs.rx_mask[i] = 0xFF;
151 + }
152 +
153 + ht_cap.mcs.tx_params |= IEEE80211_HT_MCS_TX_DEFINED;
154 +
155 + return ht_cap;
156 +}
157 +
158 static int __ath10k_set_antenna(struct ath10k *ar, u32 tx_ant, u32 rx_ant)
159 {
160 int ret;
161 @@ -4068,39 +4208,6 @@ static u32 get_nss_from_chainmask(u16 ch
162 return 1;
163 }
164
165 -static int ath10k_mac_get_vht_cap_bf_sts(struct ath10k *ar)
166 -{
167 - int nsts = ar->vht_cap_info;
168 -
169 - nsts &= IEEE80211_VHT_CAP_BEAMFORMEE_STS_MASK;
170 - nsts >>= IEEE80211_VHT_CAP_BEAMFORMEE_STS_SHIFT;
171 -
172 - /* If firmware does not deliver to host number of space-time
173 - * streams supported, assume it support up to 4 BF STS and return
174 - * the value for VHT CAP: nsts-1)
175 - * */
176 - if (nsts == 0)
177 - return 3;
178 -
179 - return nsts;
180 -}
181 -
182 -static int ath10k_mac_get_vht_cap_bf_sound_dim(struct ath10k *ar)
183 -{
184 - int sound_dim = ar->vht_cap_info;
185 -
186 - sound_dim &= IEEE80211_VHT_CAP_SOUNDING_DIMENSIONS_MASK;
187 - sound_dim >>= IEEE80211_VHT_CAP_SOUNDING_DIMENSIONS_SHIFT;
188 -
189 - /* If the sounding dimension is not advertised by the firmware,
190 - * let's use a default value of 1
191 - */
192 - if (sound_dim == 0)
193 - return 1;
194 -
195 - return sound_dim;
196 -}
197 -
198 static int ath10k_mac_set_txbf_conf(struct ath10k_vif *arvif)
199 {
200 u32 value = 0;
201 @@ -6954,113 +7061,6 @@ static const struct ieee80211_iface_comb
202 },
203 };
204
205 -static struct ieee80211_sta_vht_cap ath10k_create_vht_cap(struct ath10k *ar)
206 -{
207 - struct ieee80211_sta_vht_cap vht_cap = {0};
208 - u16 mcs_map;
209 - u32 val;
210 - int i;
211 -
212 - vht_cap.vht_supported = 1;
213 - vht_cap.cap = ar->vht_cap_info;
214 -
215 - if (ar->vht_cap_info & (IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE |
216 - IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE)) {
217 - val = ath10k_mac_get_vht_cap_bf_sts(ar);
218 - val <<= IEEE80211_VHT_CAP_BEAMFORMEE_STS_SHIFT;
219 - val &= IEEE80211_VHT_CAP_BEAMFORMEE_STS_MASK;
220 -
221 - vht_cap.cap |= val;
222 - }
223 -
224 - if (ar->vht_cap_info & (IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE |
225 - IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE)) {
226 - val = ath10k_mac_get_vht_cap_bf_sound_dim(ar);
227 - val <<= IEEE80211_VHT_CAP_SOUNDING_DIMENSIONS_SHIFT;
228 - val &= IEEE80211_VHT_CAP_SOUNDING_DIMENSIONS_MASK;
229 -
230 - vht_cap.cap |= val;
231 - }
232 -
233 - mcs_map = 0;
234 - for (i = 0; i < 8; i++) {
235 - if ((i < ar->num_rf_chains) && (ar->cfg_tx_chainmask & BIT(i)))
236 - mcs_map |= IEEE80211_VHT_MCS_SUPPORT_0_9 << (i*2);
237 - else
238 - mcs_map |= IEEE80211_VHT_MCS_NOT_SUPPORTED << (i*2);
239 - }
240 -
241 - vht_cap.vht_mcs.rx_mcs_map = cpu_to_le16(mcs_map);
242 - vht_cap.vht_mcs.tx_mcs_map = cpu_to_le16(mcs_map);
243 -
244 - return vht_cap;
245 -}
246 -
247 -static struct ieee80211_sta_ht_cap ath10k_get_ht_cap(struct ath10k *ar)
248 -{
249 - int i;
250 - struct ieee80211_sta_ht_cap ht_cap = {0};
251 -
252 - if (!(ar->ht_cap_info & WMI_HT_CAP_ENABLED))
253 - return ht_cap;
254 -
255 - ht_cap.ht_supported = 1;
256 - ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K;
257 - ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_8;
258 - ht_cap.cap |= IEEE80211_HT_CAP_SUP_WIDTH_20_40;
259 - ht_cap.cap |= IEEE80211_HT_CAP_DSSSCCK40;
260 - ht_cap.cap |= WLAN_HT_CAP_SM_PS_STATIC << IEEE80211_HT_CAP_SM_PS_SHIFT;
261 -
262 - if (ar->ht_cap_info & WMI_HT_CAP_HT20_SGI)
263 - ht_cap.cap |= IEEE80211_HT_CAP_SGI_20;
264 -
265 - if (ar->ht_cap_info & WMI_HT_CAP_HT40_SGI)
266 - ht_cap.cap |= IEEE80211_HT_CAP_SGI_40;
267 -
268 - if (ar->ht_cap_info & WMI_HT_CAP_DYNAMIC_SMPS) {
269 - u32 smps;
270 -
271 - smps = WLAN_HT_CAP_SM_PS_DYNAMIC;
272 - smps <<= IEEE80211_HT_CAP_SM_PS_SHIFT;
273 -
274 - ht_cap.cap |= smps;
275 - }
276 -
277 - if (ar->ht_cap_info & WMI_HT_CAP_TX_STBC)
278 - ht_cap.cap |= IEEE80211_HT_CAP_TX_STBC;
279 -
280 - if (ar->ht_cap_info & WMI_HT_CAP_RX_STBC) {
281 - u32 stbc;
282 -
283 - stbc = ar->ht_cap_info;
284 - stbc &= WMI_HT_CAP_RX_STBC;
285 - stbc >>= WMI_HT_CAP_RX_STBC_MASK_SHIFT;
286 - stbc <<= IEEE80211_HT_CAP_RX_STBC_SHIFT;
287 - stbc &= IEEE80211_HT_CAP_RX_STBC;
288 -
289 - ht_cap.cap |= stbc;
290 - }
291 -
292 - if (ar->ht_cap_info & WMI_HT_CAP_LDPC)
293 - ht_cap.cap |= IEEE80211_HT_CAP_LDPC_CODING;
294 -
295 - if (ar->ht_cap_info & WMI_HT_CAP_L_SIG_TXOP_PROT)
296 - ht_cap.cap |= IEEE80211_HT_CAP_LSIG_TXOP_PROT;
297 -
298 - /* max AMSDU is implicitly taken from vht_cap_info */
299 - if (ar->vht_cap_info & WMI_VHT_CAP_MAX_MPDU_LEN_MASK)
300 - ht_cap.cap |= IEEE80211_HT_CAP_MAX_AMSDU;
301 -
302 - for (i = 0; i < ar->num_rf_chains; i++) {
303 - if (ar->cfg_rx_chainmask & BIT(i))
304 - ht_cap.mcs.rx_mask[i] = 0xFF;
305 - }
306 -
307 - ht_cap.mcs.tx_params |= IEEE80211_HT_MCS_TX_DEFINED;
308 -
309 - return ht_cap;
310 -}
311 -
312 static void ath10k_get_arvif_iter(void *data, u8 *mac,
313 struct ieee80211_vif *vif)
314 {