Commit | Line | Data |
---|---|---|
818255ea MP |
1 | /* |
2 | * VHT handling | |
3 | * | |
4 | * This program is free software; you can redistribute it and/or modify | |
5 | * it under the terms of the GNU General Public License version 2 as | |
6 | * published by the Free Software Foundation. | |
7 | */ | |
8 | ||
9 | #include <linux/ieee80211.h> | |
10 | #include <linux/export.h> | |
11 | #include <net/mac80211.h> | |
12 | #include "ieee80211_i.h" | |
0af83d3d | 13 | #include "rate.h" |
818255ea MP |
14 | |
15 | ||
dd5ecfea JB |
16 | static void __check_vhtcap_disable(struct ieee80211_sub_if_data *sdata, |
17 | struct ieee80211_sta_vht_cap *vht_cap, | |
18 | u32 flag) | |
19 | { | |
20 | __le32 le_flag = cpu_to_le32(flag); | |
21 | ||
22 | if (sdata->u.mgd.vht_capa_mask.vht_cap_info & le_flag && | |
23 | !(sdata->u.mgd.vht_capa.vht_cap_info & le_flag)) | |
24 | vht_cap->cap &= ~flag; | |
25 | } | |
26 | ||
27 | void ieee80211_apply_vhtcap_overrides(struct ieee80211_sub_if_data *sdata, | |
28 | struct ieee80211_sta_vht_cap *vht_cap) | |
29 | { | |
30 | int i; | |
31 | u16 rxmcs_mask, rxmcs_cap, rxmcs_n, txmcs_mask, txmcs_cap, txmcs_n; | |
32 | ||
33 | if (!vht_cap->vht_supported) | |
34 | return; | |
35 | ||
36 | if (sdata->vif.type != NL80211_IFTYPE_STATION) | |
37 | return; | |
38 | ||
39 | __check_vhtcap_disable(sdata, vht_cap, | |
40 | IEEE80211_VHT_CAP_RXLDPC); | |
41 | __check_vhtcap_disable(sdata, vht_cap, | |
42 | IEEE80211_VHT_CAP_SHORT_GI_80); | |
43 | __check_vhtcap_disable(sdata, vht_cap, | |
44 | IEEE80211_VHT_CAP_SHORT_GI_160); | |
45 | __check_vhtcap_disable(sdata, vht_cap, | |
46 | IEEE80211_VHT_CAP_TXSTBC); | |
47 | __check_vhtcap_disable(sdata, vht_cap, | |
48 | IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE); | |
49 | __check_vhtcap_disable(sdata, vht_cap, | |
50 | IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE); | |
51 | __check_vhtcap_disable(sdata, vht_cap, | |
52 | IEEE80211_VHT_CAP_RX_ANTENNA_PATTERN); | |
53 | __check_vhtcap_disable(sdata, vht_cap, | |
54 | IEEE80211_VHT_CAP_TX_ANTENNA_PATTERN); | |
55 | ||
56 | /* Allow user to decrease AMPDU length exponent */ | |
57 | if (sdata->u.mgd.vht_capa_mask.vht_cap_info & | |
58 | cpu_to_le32(IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK)) { | |
59 | u32 cap, n; | |
60 | ||
61 | n = le32_to_cpu(sdata->u.mgd.vht_capa.vht_cap_info) & | |
62 | IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK; | |
63 | n >>= IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT; | |
64 | cap = vht_cap->cap & IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK; | |
65 | cap >>= IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT; | |
66 | ||
67 | if (n < cap) { | |
68 | vht_cap->cap &= | |
69 | ~IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK; | |
70 | vht_cap->cap |= | |
71 | n << IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT; | |
72 | } | |
73 | } | |
74 | ||
75 | /* Allow the user to decrease MCSes */ | |
76 | rxmcs_mask = | |
77 | le16_to_cpu(sdata->u.mgd.vht_capa_mask.supp_mcs.rx_mcs_map); | |
78 | rxmcs_n = le16_to_cpu(sdata->u.mgd.vht_capa.supp_mcs.rx_mcs_map); | |
79 | rxmcs_n &= rxmcs_mask; | |
80 | rxmcs_cap = le16_to_cpu(vht_cap->vht_mcs.rx_mcs_map); | |
81 | ||
82 | txmcs_mask = | |
83 | le16_to_cpu(sdata->u.mgd.vht_capa_mask.supp_mcs.tx_mcs_map); | |
84 | txmcs_n = le16_to_cpu(sdata->u.mgd.vht_capa.supp_mcs.tx_mcs_map); | |
85 | txmcs_n &= txmcs_mask; | |
86 | txmcs_cap = le16_to_cpu(vht_cap->vht_mcs.tx_mcs_map); | |
87 | for (i = 0; i < 8; i++) { | |
88 | u8 m, n, c; | |
89 | ||
90 | m = (rxmcs_mask >> 2*i) & IEEE80211_VHT_MCS_NOT_SUPPORTED; | |
91 | n = (rxmcs_n >> 2*i) & IEEE80211_VHT_MCS_NOT_SUPPORTED; | |
92 | c = (rxmcs_cap >> 2*i) & IEEE80211_VHT_MCS_NOT_SUPPORTED; | |
93 | ||
94 | if (m && ((c != IEEE80211_VHT_MCS_NOT_SUPPORTED && n < c) || | |
95 | n == IEEE80211_VHT_MCS_NOT_SUPPORTED)) { | |
96 | rxmcs_cap &= ~(3 << 2*i); | |
97 | rxmcs_cap |= (rxmcs_n & (3 << 2*i)); | |
98 | } | |
99 | ||
100 | m = (txmcs_mask >> 2*i) & IEEE80211_VHT_MCS_NOT_SUPPORTED; | |
101 | n = (txmcs_n >> 2*i) & IEEE80211_VHT_MCS_NOT_SUPPORTED; | |
102 | c = (txmcs_cap >> 2*i) & IEEE80211_VHT_MCS_NOT_SUPPORTED; | |
103 | ||
104 | if (m && ((c != IEEE80211_VHT_MCS_NOT_SUPPORTED && n < c) || | |
105 | n == IEEE80211_VHT_MCS_NOT_SUPPORTED)) { | |
106 | txmcs_cap &= ~(3 << 2*i); | |
107 | txmcs_cap |= (txmcs_n & (3 << 2*i)); | |
108 | } | |
109 | } | |
110 | vht_cap->vht_mcs.rx_mcs_map = cpu_to_le16(rxmcs_cap); | |
111 | vht_cap->vht_mcs.tx_mcs_map = cpu_to_le16(txmcs_cap); | |
112 | } | |
113 | ||
4a3cb702 JB |
114 | void |
115 | ieee80211_vht_cap_ie_to_sta_vht_cap(struct ieee80211_sub_if_data *sdata, | |
116 | struct ieee80211_supported_band *sband, | |
117 | const struct ieee80211_vht_cap *vht_cap_ie, | |
118 | struct sta_info *sta) | |
818255ea | 119 | { |
4a34215e | 120 | struct ieee80211_sta_vht_cap *vht_cap = &sta->sta.vht_cap; |
55d942f4 JB |
121 | struct ieee80211_sta_vht_cap own_cap; |
122 | u32 cap_info, i; | |
818255ea MP |
123 | |
124 | memset(vht_cap, 0, sizeof(*vht_cap)); | |
125 | ||
4a34215e JB |
126 | if (!sta->sta.ht_cap.ht_supported) |
127 | return; | |
128 | ||
818255ea MP |
129 | if (!vht_cap_ie || !sband->vht_cap.vht_supported) |
130 | return; | |
131 | ||
4a817aa7 JB |
132 | /* |
133 | * A VHT STA must support 40 MHz, but if we verify that here | |
134 | * then we break a few things - some APs (e.g. Netgear R6300v2 | |
135 | * and others based on the BCM4360 chipset) will unset this | |
136 | * capability bit when operating in 20 MHz. | |
137 | */ | |
e1a0c6b3 | 138 | |
818255ea MP |
139 | vht_cap->vht_supported = true; |
140 | ||
55d942f4 JB |
141 | own_cap = sband->vht_cap; |
142 | /* | |
143 | * If user has specified capability overrides, take care | |
144 | * of that if the station we're setting up is the AP that | |
145 | * we advertised a restricted capability set to. Override | |
146 | * our own capabilities and then use those below. | |
147 | */ | |
148 | if (sdata->vif.type == NL80211_IFTYPE_STATION && | |
149 | !test_sta_flag(sta, WLAN_STA_TDLS_PEER)) | |
150 | ieee80211_apply_vhtcap_overrides(sdata, &own_cap); | |
151 | ||
152 | /* take some capabilities as-is */ | |
153 | cap_info = le32_to_cpu(vht_cap_ie->vht_cap_info); | |
154 | vht_cap->cap = cap_info; | |
155 | vht_cap->cap &= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_3895 | | |
156 | IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_7991 | | |
157 | IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454 | | |
158 | IEEE80211_VHT_CAP_RXLDPC | | |
159 | IEEE80211_VHT_CAP_VHT_TXOP_PS | | |
160 | IEEE80211_VHT_CAP_HTC_VHT | | |
161 | IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK | | |
162 | IEEE80211_VHT_CAP_VHT_LINK_ADAPTATION_VHT_UNSOL_MFB | | |
163 | IEEE80211_VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB | | |
164 | IEEE80211_VHT_CAP_RX_ANTENNA_PATTERN | | |
165 | IEEE80211_VHT_CAP_TX_ANTENNA_PATTERN; | |
166 | ||
167 | /* and some based on our own capabilities */ | |
168 | switch (own_cap.cap & IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_MASK) { | |
169 | case IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ: | |
170 | vht_cap->cap |= cap_info & | |
171 | IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ; | |
172 | break; | |
173 | case IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ: | |
174 | vht_cap->cap |= cap_info & | |
175 | IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_MASK; | |
176 | break; | |
177 | default: | |
178 | /* nothing */ | |
179 | break; | |
180 | } | |
181 | ||
182 | /* symmetric capabilities */ | |
183 | vht_cap->cap |= cap_info & own_cap.cap & | |
184 | (IEEE80211_VHT_CAP_SHORT_GI_80 | | |
185 | IEEE80211_VHT_CAP_SHORT_GI_160); | |
186 | ||
187 | /* remaining ones */ | |
fbdd90ea | 188 | if (own_cap.cap & IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE) |
55d942f4 JB |
189 | vht_cap->cap |= cap_info & |
190 | (IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE | | |
fbdd90ea | 191 | IEEE80211_VHT_CAP_SOUNDING_DIMENSIONS_MASK); |
55d942f4 JB |
192 | |
193 | if (own_cap.cap & IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE) | |
194 | vht_cap->cap |= cap_info & | |
5eb7906b | 195 | (IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE | |
fbdd90ea | 196 | IEEE80211_VHT_CAP_BEAMFORMEE_STS_MASK); |
55d942f4 JB |
197 | |
198 | if (own_cap.cap & IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE) | |
199 | vht_cap->cap |= cap_info & | |
200 | IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE; | |
201 | ||
202 | if (own_cap.cap & IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE) | |
203 | vht_cap->cap |= cap_info & | |
204 | IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE; | |
205 | ||
206 | if (own_cap.cap & IEEE80211_VHT_CAP_TXSTBC) | |
207 | vht_cap->cap |= cap_info & IEEE80211_VHT_CAP_RXSTBC_MASK; | |
208 | ||
209 | if (own_cap.cap & IEEE80211_VHT_CAP_RXSTBC_MASK) | |
210 | vht_cap->cap |= cap_info & IEEE80211_VHT_CAP_TXSTBC; | |
818255ea MP |
211 | |
212 | /* Copy peer MCS info, the driver might need them. */ | |
213 | memcpy(&vht_cap->vht_mcs, &vht_cap_ie->supp_mcs, | |
214 | sizeof(struct ieee80211_vht_mcs_info)); | |
e1a0c6b3 | 215 | |
55d942f4 JB |
216 | /* but also restrict MCSes */ |
217 | for (i = 0; i < 8; i++) { | |
218 | u16 own_rx, own_tx, peer_rx, peer_tx; | |
219 | ||
220 | own_rx = le16_to_cpu(own_cap.vht_mcs.rx_mcs_map); | |
221 | own_rx = (own_rx >> i * 2) & IEEE80211_VHT_MCS_NOT_SUPPORTED; | |
222 | ||
223 | own_tx = le16_to_cpu(own_cap.vht_mcs.tx_mcs_map); | |
224 | own_tx = (own_tx >> i * 2) & IEEE80211_VHT_MCS_NOT_SUPPORTED; | |
225 | ||
226 | peer_rx = le16_to_cpu(vht_cap->vht_mcs.rx_mcs_map); | |
227 | peer_rx = (peer_rx >> i * 2) & IEEE80211_VHT_MCS_NOT_SUPPORTED; | |
228 | ||
229 | peer_tx = le16_to_cpu(vht_cap->vht_mcs.tx_mcs_map); | |
230 | peer_tx = (peer_tx >> i * 2) & IEEE80211_VHT_MCS_NOT_SUPPORTED; | |
231 | ||
232 | if (peer_tx != IEEE80211_VHT_MCS_NOT_SUPPORTED) { | |
233 | if (own_rx == IEEE80211_VHT_MCS_NOT_SUPPORTED) | |
234 | peer_tx = IEEE80211_VHT_MCS_NOT_SUPPORTED; | |
235 | else if (own_rx < peer_tx) | |
236 | peer_tx = own_rx; | |
237 | } | |
238 | ||
239 | if (peer_rx != IEEE80211_VHT_MCS_NOT_SUPPORTED) { | |
240 | if (own_tx == IEEE80211_VHT_MCS_NOT_SUPPORTED) | |
241 | peer_rx = IEEE80211_VHT_MCS_NOT_SUPPORTED; | |
242 | else if (own_tx < peer_rx) | |
243 | peer_rx = own_tx; | |
244 | } | |
245 | ||
246 | vht_cap->vht_mcs.rx_mcs_map &= | |
247 | ~cpu_to_le16(IEEE80211_VHT_MCS_NOT_SUPPORTED << i * 2); | |
248 | vht_cap->vht_mcs.rx_mcs_map |= cpu_to_le16(peer_rx << i * 2); | |
249 | ||
250 | vht_cap->vht_mcs.tx_mcs_map &= | |
251 | ~cpu_to_le16(IEEE80211_VHT_MCS_NOT_SUPPORTED << i * 2); | |
252 | vht_cap->vht_mcs.tx_mcs_map |= cpu_to_le16(peer_tx << i * 2); | |
253 | } | |
254 | ||
255 | /* finally set up the bandwidth */ | |
0af83d3d JB |
256 | switch (vht_cap->cap & IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_MASK) { |
257 | case IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ: | |
258 | case IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ: | |
259 | sta->cur_max_bandwidth = IEEE80211_STA_RX_BW_160; | |
260 | break; | |
261 | default: | |
262 | sta->cur_max_bandwidth = IEEE80211_STA_RX_BW_80; | |
263 | } | |
264 | ||
e1a0c6b3 JB |
265 | sta->sta.bandwidth = ieee80211_sta_cur_vht_bw(sta); |
266 | } | |
267 | ||
1c45c5ce | 268 | enum ieee80211_sta_rx_bandwidth ieee80211_sta_cap_rx_bw(struct sta_info *sta) |
e1a0c6b3 | 269 | { |
1c45c5ce EP |
270 | struct ieee80211_sta_vht_cap *vht_cap = &sta->sta.vht_cap; |
271 | u32 cap_width; | |
e1a0c6b3 | 272 | |
1c45c5ce EP |
273 | if (!vht_cap->vht_supported) |
274 | return sta->sta.ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40 ? | |
275 | IEEE80211_STA_RX_BW_40 : | |
276 | IEEE80211_STA_RX_BW_20; | |
e1a0c6b3 | 277 | |
1c45c5ce EP |
278 | cap_width = vht_cap->cap & IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_MASK; |
279 | ||
280 | if (cap_width == IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ || | |
281 | cap_width == IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ) | |
282 | return IEEE80211_STA_RX_BW_160; | |
283 | ||
284 | return IEEE80211_STA_RX_BW_80; | |
285 | } | |
286 | ||
287 | static enum ieee80211_sta_rx_bandwidth | |
288 | ieee80211_chan_width_to_rx_bw(enum nl80211_chan_width width) | |
289 | { | |
290 | switch (width) { | |
e1a0c6b3 JB |
291 | case NL80211_CHAN_WIDTH_20_NOHT: |
292 | case NL80211_CHAN_WIDTH_20: | |
1c45c5ce | 293 | return IEEE80211_STA_RX_BW_20; |
e1a0c6b3 | 294 | case NL80211_CHAN_WIDTH_40: |
1c45c5ce EP |
295 | return IEEE80211_STA_RX_BW_40; |
296 | case NL80211_CHAN_WIDTH_80: | |
297 | return IEEE80211_STA_RX_BW_80; | |
e1a0c6b3 | 298 | case NL80211_CHAN_WIDTH_160: |
e1a0c6b3 | 299 | case NL80211_CHAN_WIDTH_80P80: |
1c45c5ce EP |
300 | return IEEE80211_STA_RX_BW_160; |
301 | default: | |
302 | WARN_ON_ONCE(1); | |
303 | return IEEE80211_STA_RX_BW_20; | |
e1a0c6b3 | 304 | } |
1c45c5ce EP |
305 | } |
306 | ||
307 | enum ieee80211_sta_rx_bandwidth ieee80211_sta_cur_vht_bw(struct sta_info *sta) | |
308 | { | |
309 | struct ieee80211_sub_if_data *sdata = sta->sdata; | |
310 | enum ieee80211_sta_rx_bandwidth bw; | |
b98fb44f | 311 | enum nl80211_chan_width bss_width = sdata->vif.bss_conf.chandef.width; |
1c45c5ce | 312 | |
b98fb44f | 313 | bw = ieee80211_sta_cap_rx_bw(sta); |
1c45c5ce | 314 | bw = min(bw, sta->cur_max_bandwidth); |
0af83d3d | 315 | |
b98fb44f AN |
316 | /* do not cap the BW of TDLS WIDER_BW peers by the bss */ |
317 | if (!test_sta_flag(sta, WLAN_STA_TDLS_WIDER_BW)) | |
318 | bw = min(bw, ieee80211_chan_width_to_rx_bw(bss_width)); | |
319 | ||
0af83d3d | 320 | return bw; |
818255ea | 321 | } |
8921d04e JB |
322 | |
323 | void ieee80211_sta_set_rx_nss(struct sta_info *sta) | |
324 | { | |
325 | u8 ht_rx_nss = 0, vht_rx_nss = 0; | |
326 | ||
327 | /* if we received a notification already don't overwrite it */ | |
328 | if (sta->sta.rx_nss) | |
329 | return; | |
330 | ||
331 | if (sta->sta.ht_cap.ht_supported) { | |
332 | if (sta->sta.ht_cap.mcs.rx_mask[0]) | |
333 | ht_rx_nss++; | |
334 | if (sta->sta.ht_cap.mcs.rx_mask[1]) | |
335 | ht_rx_nss++; | |
336 | if (sta->sta.ht_cap.mcs.rx_mask[2]) | |
337 | ht_rx_nss++; | |
338 | if (sta->sta.ht_cap.mcs.rx_mask[3]) | |
339 | ht_rx_nss++; | |
340 | /* FIXME: consider rx_highest? */ | |
341 | } | |
342 | ||
343 | if (sta->sta.vht_cap.vht_supported) { | |
344 | int i; | |
345 | u16 rx_mcs_map; | |
346 | ||
347 | rx_mcs_map = le16_to_cpu(sta->sta.vht_cap.vht_mcs.rx_mcs_map); | |
348 | ||
349 | for (i = 7; i >= 0; i--) { | |
350 | u8 mcs = (rx_mcs_map >> (2 * i)) & 3; | |
351 | ||
352 | if (mcs != IEEE80211_VHT_MCS_NOT_SUPPORTED) { | |
353 | vht_rx_nss = i + 1; | |
354 | break; | |
355 | } | |
356 | } | |
357 | /* FIXME: consider rx_highest? */ | |
358 | } | |
359 | ||
360 | ht_rx_nss = max(ht_rx_nss, vht_rx_nss); | |
361 | sta->sta.rx_nss = max_t(u8, 1, ht_rx_nss); | |
362 | } | |
0af83d3d | 363 | |
b1bce14a MK |
364 | u32 __ieee80211_vht_handle_opmode(struct ieee80211_sub_if_data *sdata, |
365 | struct sta_info *sta, u8 opmode, | |
366 | enum ieee80211_band band, bool nss_only) | |
0af83d3d JB |
367 | { |
368 | struct ieee80211_local *local = sdata->local; | |
369 | struct ieee80211_supported_band *sband; | |
370 | enum ieee80211_sta_rx_bandwidth new_bw; | |
371 | u32 changed = 0; | |
372 | u8 nss; | |
373 | ||
374 | sband = local->hw.wiphy->bands[band]; | |
375 | ||
376 | /* ignore - no support for BF yet */ | |
377 | if (opmode & IEEE80211_OPMODE_NOTIF_RX_NSS_TYPE_BF) | |
b1bce14a | 378 | return 0; |
0af83d3d JB |
379 | |
380 | nss = opmode & IEEE80211_OPMODE_NOTIF_RX_NSS_MASK; | |
381 | nss >>= IEEE80211_OPMODE_NOTIF_RX_NSS_SHIFT; | |
382 | nss += 1; | |
383 | ||
384 | if (sta->sta.rx_nss != nss) { | |
385 | sta->sta.rx_nss = nss; | |
386 | changed |= IEEE80211_RC_NSS_CHANGED; | |
387 | } | |
388 | ||
bee7f586 | 389 | if (nss_only) |
b1bce14a | 390 | return changed; |
bee7f586 | 391 | |
0af83d3d JB |
392 | switch (opmode & IEEE80211_OPMODE_NOTIF_CHANWIDTH_MASK) { |
393 | case IEEE80211_OPMODE_NOTIF_CHANWIDTH_20MHZ: | |
394 | sta->cur_max_bandwidth = IEEE80211_STA_RX_BW_20; | |
395 | break; | |
396 | case IEEE80211_OPMODE_NOTIF_CHANWIDTH_40MHZ: | |
397 | sta->cur_max_bandwidth = IEEE80211_STA_RX_BW_40; | |
398 | break; | |
399 | case IEEE80211_OPMODE_NOTIF_CHANWIDTH_80MHZ: | |
400 | sta->cur_max_bandwidth = IEEE80211_STA_RX_BW_80; | |
401 | break; | |
402 | case IEEE80211_OPMODE_NOTIF_CHANWIDTH_160MHZ: | |
403 | sta->cur_max_bandwidth = IEEE80211_STA_RX_BW_160; | |
404 | break; | |
405 | } | |
406 | ||
407 | new_bw = ieee80211_sta_cur_vht_bw(sta); | |
408 | if (new_bw != sta->sta.bandwidth) { | |
409 | sta->sta.bandwidth = new_bw; | |
38745c74 | 410 | changed |= IEEE80211_RC_BW_CHANGED; |
0af83d3d JB |
411 | } |
412 | ||
b1bce14a MK |
413 | return changed; |
414 | } | |
415 | ||
416 | void ieee80211_vht_handle_opmode(struct ieee80211_sub_if_data *sdata, | |
417 | struct sta_info *sta, u8 opmode, | |
418 | enum ieee80211_band band, bool nss_only) | |
419 | { | |
420 | struct ieee80211_local *local = sdata->local; | |
421 | struct ieee80211_supported_band *sband = local->hw.wiphy->bands[band]; | |
422 | ||
423 | u32 changed = __ieee80211_vht_handle_opmode(sdata, sta, opmode, | |
424 | band, nss_only); | |
425 | ||
426 | if (changed > 0) | |
0af83d3d JB |
427 | rate_control_rate_update(local, sband, sta, changed); |
428 | } | |
b119ad6e LB |
429 | |
430 | void ieee80211_get_vht_mask_from_cap(__le16 vht_cap, | |
431 | u16 vht_mask[NL80211_VHT_NSS_MAX]) | |
432 | { | |
433 | int i; | |
434 | u16 mask, cap = le16_to_cpu(vht_cap); | |
435 | ||
436 | for (i = 0; i < NL80211_VHT_NSS_MAX; i++) { | |
437 | mask = (cap >> i * 2) & IEEE80211_VHT_MCS_NOT_SUPPORTED; | |
438 | switch (mask) { | |
439 | case IEEE80211_VHT_MCS_SUPPORT_0_7: | |
440 | vht_mask[i] = 0x00FF; | |
441 | break; | |
442 | case IEEE80211_VHT_MCS_SUPPORT_0_8: | |
443 | vht_mask[i] = 0x01FF; | |
444 | break; | |
445 | case IEEE80211_VHT_MCS_SUPPORT_0_9: | |
446 | vht_mask[i] = 0x03FF; | |
447 | break; | |
448 | case IEEE80211_VHT_MCS_NOT_SUPPORTED: | |
449 | default: | |
450 | vht_mask[i] = 0; | |
451 | break; | |
452 | } | |
453 | } | |
454 | } |