1 /** @file mlan_11ac.c
2 *
3 * @brief This file contains the functions for station ioctl.
4 *
5 *
6 * Copyright 2011-2021 NXP
7 *
8 * This software file (the File) is distributed by NXP
9 * under the terms of the GNU General Public License Version 2, June 1991
10 * (the License). You may use, redistribute and/or modify the File in
11 * accordance with the terms and conditions of the License, a copy of which
12 * is available by writing to the Free Software Foundation, Inc.,
13 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
14 * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
15 *
16 * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
18 * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
19 * this warranty disclaimer.
20 *
21 */
22
23 #include "mlan.h"
24 #include "mlan_join.h"
25 #include "mlan_util.h"
26 #include "mlan_fw.h"
27 #include "mlan_main.h"
28 #include "mlan_wmm.h"
29 #include "mlan_11n.h"
30 #include "mlan_11ac.h"
31
32 /********************************************************
33 Local Variables
34 ********************************************************/
35
36 /********************************************************
37 Global Variables
38 ********************************************************/
39
40 /********************************************************
41 Local Functions
42 ********************************************************/
43 t_u16 wlan_convert_mcsmap_to_maxrate(mlan_private *priv, t_u16 bands,
44 t_u16 mcs_map);
45 /**
46 * @brief determine the center frquency center index for bandwidth
47 * of 80 MHz and 160 MHz
48 *
49 * @param pmpriv A pointer to mlan_private structure
50 * @param band band
51 * @param pri_chan primary channel
52 * @param chan_bw channel bandwidth
53 *
54 * @return channel center frequency center, if found; O, otherwise
55 */
56
wlan_get_center_freq_idx(mlan_private * pmpriv,t_u16 band,t_u32 pri_chan,t_u8 chan_bw)57 t_u8 wlan_get_center_freq_idx(mlan_private *pmpriv, t_u16 band, t_u32 pri_chan,
58 t_u8 chan_bw)
59 {
60 t_u8 center_freq_idx = 0;
61
62 if (band & BAND_AAC) {
63 switch (pri_chan) {
64 case 36:
65 case 40:
66 case 44:
67 case 48:
68 if (chan_bw == CHANNEL_BW_80MHZ) {
69 center_freq_idx = 42;
70 break;
71 }
72 /* fall through */
73 case 52:
74 case 56:
75 case 60:
76 case 64:
77 if (chan_bw == CHANNEL_BW_80MHZ) {
78 center_freq_idx = 58;
79 break;
80 } else if (chan_bw == CHANNEL_BW_160MHZ) {
81 center_freq_idx = 50;
82 break;
83 }
84 /* fall through */
85 case 100:
86 case 104:
87 case 108:
88 case 112:
89 if (chan_bw == CHANNEL_BW_80MHZ) {
90 center_freq_idx = 106;
91 break;
92 }
93 /* fall through */
94 case 116:
95 case 120:
96 case 124:
97 case 128:
98 if (chan_bw == CHANNEL_BW_80MHZ) {
99 center_freq_idx = 122;
100 break;
101 } else if (chan_bw == CHANNEL_BW_160MHZ) {
102 center_freq_idx = 114;
103 break;
104 }
105 /* fall through */
106 case 132:
107 case 136:
108 case 140:
109 case 144:
110 if (chan_bw == CHANNEL_BW_80MHZ) {
111 center_freq_idx = 138;
112 break;
113 }
114 /* fall through */
115 case 149:
116 case 153:
117 case 157:
118 case 161:
119 if (chan_bw == CHANNEL_BW_80MHZ) {
120 center_freq_idx = 155;
121 break;
122 }
123 /* fall through */
124 case 165:
125 case 169:
126 case 173:
127 case 177:
128 if (chan_bw == CHANNEL_BW_80MHZ) {
129 center_freq_idx = 171;
130 break;
131 }
132 /* fall through */
133 case 184:
134 case 188:
135 case 192:
136 case 196:
137 if (chan_bw == CHANNEL_BW_80MHZ) {
138 center_freq_idx = 190;
139 break;
140 }
141 /* fall through */
142 default: /* error. go to the default */
143 center_freq_idx = 42;
144 }
145 }
146 return center_freq_idx;
147 }
148
149 /**
150 * @brief This function gets the bitmap of nss which supports VHT mcs
151 *
152 * @param mcs_map_set VHT mcs map
153 *
154 * @return The bitmap of supported nss
155 */
wlan_get_nss_vht_mcs(t_u16 mcs_map_set)156 static t_u8 wlan_get_nss_vht_mcs(t_u16 mcs_map_set)
157 {
158 t_u8 nss, nss_map = 0;
159 for (nss = 1; nss <= 8; nss++) {
160 if (GET_VHTNSSMCS(mcs_map_set, nss) != NO_NSS_SUPPORT)
161 nss_map |= 1 << (nss - 1);
162 }
163 PRINTM(MCMND, "Supported nss bit map:0x%02x\n", nss_map);
164 return nss_map;
165 }
166
167 /**
168 * @brief This function gets the bitmap of nss which supports VHT mcs
169 *
170 * @param mcs_map_set VHT mcs map
171 *
172 * @return The bitmap of supported nss
173 */
wlan_get_nss_num_vht_mcs(t_u16 mcs_map_set)174 static t_u8 wlan_get_nss_num_vht_mcs(t_u16 mcs_map_set)
175 {
176 t_u8 nss, nss_num = 0;
177 for (nss = 1; nss <= 8; nss++) {
178 if (GET_VHTNSSMCS(mcs_map_set, nss) != NO_NSS_SUPPORT)
179 nss_num++;
180 }
181 PRINTM(MCMND, "Supported nss:%d\n", nss_num);
182 return nss_num;
183 }
184
185 /**
186 * @brief This function fills the cap info
187 *
188 * @param priv A pointer to mlan_private structure
189 * @param pht_cap A pointer to MrvlIETypes_HTCap_t structure
190 * @param bands Band configuration
191 *
192 * @return N/A
193 */
wlan_fill_cap_info(mlan_private * priv,VHT_capa_t * vht_cap,t_u16 bands)194 static void wlan_fill_cap_info(mlan_private *priv, VHT_capa_t *vht_cap,
195 t_u16 bands)
196 {
197 t_u32 usr_dot_11ac_dev_cap;
198 ENTER();
199
200 if (bands & BAND_A)
201 usr_dot_11ac_dev_cap = priv->usr_dot_11ac_dev_cap_a;
202 else
203 usr_dot_11ac_dev_cap = priv->usr_dot_11ac_dev_cap_bg;
204
205 vht_cap->vht_cap_info = usr_dot_11ac_dev_cap;
206
207 RESET_VHTCAP_MAXMPDULEN(vht_cap->vht_cap_info);
208 LEAVE();
209 }
210
211 /**
212 * @brief Set/get 11ac configuration
213 *
214 * @param pmadapter A pointer to mlan_adapter structure
215 * @param pioctl_req A pointer to ioctl request buffer
216 *
217 * @return MLAN_STATUS_PENDING --success, otherwise fail
218 */
wlan_11ac_ioctl_vhtcfg(pmlan_adapter pmadapter,pmlan_ioctl_req pioctl_req)219 static mlan_status wlan_11ac_ioctl_vhtcfg(pmlan_adapter pmadapter,
220 pmlan_ioctl_req pioctl_req)
221 {
222 mlan_status ret = MLAN_STATUS_SUCCESS;
223 mlan_private *pmpriv = pmadapter->priv[pioctl_req->bss_index];
224 mlan_ds_11ac_cfg *cfg = MNULL;
225 t_u16 cmd_action = 0;
226 t_u32 usr_vht_cap_info = 0;
227 t_u32 cfg_value = 0;
228 t_u32 hw_value = 0;
229 t_u8 nss = 0;
230 #if defined(PCIE9098) || defined(SD9098) || defined(USB9098) || \
231 defined(PCIE9097) || defined(USB9097) || defined(SDNW62X) || \
232 defined(PCIENW62X) || defined(USBNW62X) || defined(SD9097)
233 t_u16 rx_nss = 0;
234 t_u16 tx_nss = 0;
235 #endif
236
237 ENTER();
238
239 #define VHT_CAP_INFO_BIT_FIELDS \
240 (MBIT(4) | MBIT(5) | MBIT(6) | MBIT(7) | MBIT(11) | MBIT(12) | \
241 MBIT(19) | MBIT(20) | MBIT(21) | MBIT(22) | MBIT(28) | MBIT(29))
242
243 cfg = (mlan_ds_11ac_cfg *)pioctl_req->pbuf;
244
245 if (pioctl_req->action == MLAN_ACT_SET) {
246 /** SET operation */
247 /** validate the user input and correct it if necessary */
248 if (pmpriv->bss_role == MLAN_BSS_ROLE_STA) {
249 if (cfg->param.vht_cfg.txrx == 3) {
250 PRINTM(MERROR,
251 "Configuration of VHT capabilities for TX/RX 3 is not supported in STA mode!\n");
252 return MLAN_STATUS_FAILURE;
253 }
254 }
255 if (pmpriv->bss_role == MLAN_BSS_ROLE_UAP) {
256 if (cfg->param.vht_cfg.txrx != 3) {
257 PRINTM(MERROR,
258 "Configuration of VHT capabilities for TX/RX %d is not supported in UAP mode!\n",
259 cfg->param.vht_cfg.txrx);
260 return MLAN_STATUS_FAILURE;
261 }
262 }
263 /** set bit fileds */
264 usr_vht_cap_info = VHT_CAP_INFO_BIT_FIELDS &
265 cfg->param.vht_cfg.vht_cap_info &
266 pmadapter->hw_dot_11ac_dev_cap;
267 /** set MAX MPDU LEN field (bit 0 - bit 1) */
268 cfg_value =
269 GET_VHTCAP_MAXMPDULEN(cfg->param.vht_cfg.vht_cap_info);
270 hw_value =
271 GET_VHTCAP_MAXMPDULEN(pmadapter->hw_dot_11ac_dev_cap);
272 SET_VHTCAP_MAXMPDULEN(usr_vht_cap_info,
273 MIN(cfg_value, hw_value));
274 /** set CHAN Width Set field (bit 2 - bit 3) */
275 cfg_value = GET_VHTCAP_CHWDSET(cfg->param.vht_cfg.vht_cap_info);
276 hw_value = GET_VHTCAP_CHWDSET(pmadapter->hw_dot_11ac_dev_cap);
277 SET_VHTCAP_CHWDSET(usr_vht_cap_info, MIN(cfg_value, hw_value));
278 /** set Rx STBC field (bit 8 - bit 10) */
279 cfg_value = GET_VHTCAP_RXSTBC(cfg->param.vht_cfg.vht_cap_info);
280 hw_value = GET_VHTCAP_RXSTBC(pmadapter->hw_dot_11ac_dev_cap);
281 SET_VHTCAP_RXSTBC(usr_vht_cap_info, MIN(cfg_value, hw_value));
282 /** set Steering Number of BFer Ant (bit 13 - bit 15) */
283 cfg_value =
284 GET_VHTCAP_SNBFERANT(cfg->param.vht_cfg.vht_cap_info);
285 hw_value = GET_VHTCAP_SNBFERANT(pmadapter->hw_dot_11ac_dev_cap);
286 SET_VHTCAP_SNBFERANT(usr_vht_cap_info,
287 MIN(cfg_value, hw_value));
288 /** set Number of Sounding Dimension (bit 16 - bit 18) */
289 cfg_value =
290 GET_VHTCAP_NUMSNDDM(cfg->param.vht_cfg.vht_cap_info);
291 hw_value = GET_VHTCAP_NUMSNDDM(pmadapter->hw_dot_11ac_dev_cap);
292 SET_VHTCAP_NUMSNDDM(usr_vht_cap_info, MIN(cfg_value, hw_value));
293 /** set Number of Max AMPDU Length Exponent (bit 23 - bit 25) */
294 cfg_value = GET_VHTCAP_MAXAMPDULENEXP(
295 cfg->param.vht_cfg.vht_cap_info);
296 hw_value = GET_VHTCAP_MAXAMPDULENEXP(
297 pmadapter->hw_dot_11ac_dev_cap);
298 SET_VHTCAP_MAXAMPDULENEXP(usr_vht_cap_info,
299 MIN(cfg_value, hw_value));
300 /** set VHT Link Adaptation Capable (bit 26 - bit 27) */
301 cfg_value =
302 GET_VHTCAP_LINKADPCAP(cfg->param.vht_cfg.vht_cap_info);
303 hw_value =
304 GET_VHTCAP_LINKADPCAP(pmadapter->hw_dot_11ac_dev_cap);
305 SET_VHTCAP_LINKADPCAP(usr_vht_cap_info,
306 MIN(cfg_value, hw_value));
307 /** update the user setting if it is beyond the hw capabiliteis
308 */
309 cfg->param.vht_cfg.vht_cap_info = usr_vht_cap_info;
310 PRINTM(MINFO, "Set: vht cap info 0x%x\n", usr_vht_cap_info);
311
312 /** update the RX MCS map */
313 if (cfg->param.vht_cfg.txrx & MLAN_RADIO_RX) {
314 #if defined(PCIE9098) || defined(SD9098) || defined(USB9098) || \
315 defined(PCIE9097) || defined(SD9097) || defined(USB9097) || \
316 defined(SDNW62X) || defined(PCIENW62X) || defined(USBNW62X)
317 if (IS_CARD9098(pmadapter->card_type) ||
318 IS_CARDNW62X(pmadapter->card_type) ||
319 IS_CARD9097(pmadapter->card_type)) {
320 if (cfg->param.vht_cfg.band == BAND_SELECT_A) {
321 rx_nss = GET_RXMCSSUPP(
322 pmadapter->user_htstream >> 8);
323 tx_nss =
324 GET_TXMCSSUPP(
325 pmadapter->user_htstream >>
326 8) &
327 0x0f;
328 } else {
329 rx_nss = GET_RXMCSSUPP(
330 pmadapter->user_htstream);
331 tx_nss =
332 GET_TXMCSSUPP(
333 pmadapter->user_htstream) &
334 0x0f;
335 }
336 }
337 #endif
338 /* use the previous user value */
339 if (cfg->param.vht_cfg.vht_rx_mcs == 0xffffffff)
340 cfg->param.vht_cfg.vht_rx_mcs = GET_VHTMCS(
341 pmpriv->usr_dot_11ac_mcs_support);
342 for (nss = 1; nss <= 8; nss++) {
343 cfg_value = GET_VHTNSSMCS(
344 cfg->param.vht_cfg.vht_rx_mcs, nss);
345 hw_value = GET_DEVNSSRXMCS(
346 pmadapter->hw_dot_11ac_mcs_support,
347 nss);
348 #if defined(PCIE9098) || defined(SD9098) || defined(USB9098) || \
349 defined(PCIE9097) || defined(SD9097) || defined(USB9097) || \
350 defined(SDNW62X) || defined(PCIENW62X) || defined(USBNW62X)
351 if ((rx_nss != 0) && (nss > rx_nss))
352 cfg_value = NO_NSS_SUPPORT;
353 #endif
354 if ((hw_value == NO_NSS_SUPPORT) ||
355 (cfg_value == NO_NSS_SUPPORT))
356 SET_VHTNSSMCS(
357 cfg->param.vht_cfg.vht_rx_mcs,
358 nss, NO_NSS_SUPPORT);
359 else
360 SET_VHTNSSMCS(
361 cfg->param.vht_cfg.vht_rx_mcs,
362 nss, MIN(cfg_value, hw_value));
363 }
364 PRINTM(MINFO, "Set: vht rx mcs set 0x%08x\n",
365 cfg->param.vht_cfg.vht_rx_mcs);
366 /* use the previous user value */
367 if (cfg->param.vht_cfg.vht_tx_mcs == 0xffffffff)
368 cfg->param.vht_cfg.vht_tx_mcs = GET_VHTMCS(
369 pmpriv->usr_dot_11ac_mcs_support >> 16);
370 for (nss = 1; nss <= 8; nss++) {
371 cfg_value = GET_VHTNSSMCS(
372 cfg->param.vht_cfg.vht_tx_mcs, nss);
373 hw_value = GET_DEVNSSTXMCS(
374 pmadapter->hw_dot_11ac_mcs_support,
375 nss);
376 #if defined(PCIE9098) || defined(SD9098) || defined(USB9098) || \
377 defined(PCIE9097) || defined(SD9097) || defined(USB9097) || \
378 defined(SDNW62X) || defined(PCIENW62X) || defined(USBNW62X)
379 if ((tx_nss != 0) && (nss > tx_nss))
380 cfg_value = NO_NSS_SUPPORT;
381 #endif
382 if ((hw_value == NO_NSS_SUPPORT) ||
383 (cfg_value == NO_NSS_SUPPORT))
384 SET_VHTNSSMCS(
385 cfg->param.vht_cfg.vht_tx_mcs,
386 nss, NO_NSS_SUPPORT);
387 else
388 SET_VHTNSSMCS(
389 cfg->param.vht_cfg.vht_tx_mcs,
390 nss, MIN(cfg_value, hw_value));
391 }
392 PRINTM(MINFO, "Set: vht tx mcs set 0x%08x\n",
393 cfg->param.vht_cfg.vht_tx_mcs);
394 if (!cfg->param.vht_cfg.skip_usr_11ac_mcs_cfg) {
395 RESET_DEVRXMCSMAP(
396 pmpriv->usr_dot_11ac_mcs_support);
397 pmpriv->usr_dot_11ac_mcs_support |= GET_VHTMCS(
398 cfg->param.vht_cfg.vht_rx_mcs);
399 RESET_DEVTXMCSMAP(
400 pmpriv->usr_dot_11ac_mcs_support);
401 pmpriv->usr_dot_11ac_mcs_support |=
402 (GET_VHTMCS(
403 cfg->param.vht_cfg.vht_tx_mcs)
404 << 16);
405 PRINTM(MINFO, "Set: vht mcs set 0x%08x\n",
406 pmpriv->usr_dot_11ac_mcs_support);
407 } else {
408 PRINTM(MINFO,
409 "Skipped user 11ac mcs configuration\n");
410 cfg->param.vht_cfg.skip_usr_11ac_mcs_cfg =
411 MFALSE;
412 }
413 }
414 }
415
416 if (pmpriv->bss_role == MLAN_BSS_ROLE_STA) {
417 if (cfg->param.vht_cfg.txrx & MLAN_RADIO_RX) {
418 /* maximum VHT configuration used in association */
419 if (pioctl_req->action == MLAN_ACT_SET) {
420 if (cfg->param.vht_cfg.band == BAND_SELECT_BG)
421 pmpriv->usr_dot_11ac_dev_cap_bg =
422 usr_vht_cap_info;
423 else if (cfg->param.vht_cfg.band ==
424 BAND_SELECT_A)
425 pmpriv->usr_dot_11ac_dev_cap_a =
426 usr_vht_cap_info;
427 else {
428 pmpriv->usr_dot_11ac_dev_cap_bg =
429 usr_vht_cap_info;
430 pmpriv->usr_dot_11ac_dev_cap_a =
431 usr_vht_cap_info;
432 }
433 pmpriv->usr_dot_11ac_bw =
434 cfg->param.vht_cfg.bwcfg;
435
436 } else {
437 /** GET operation */
438 if (cfg->param.vht_cfg.band == BAND_SELECT_BG) {
439 cfg->param.vht_cfg.vht_cap_info =
440 pmpriv->usr_dot_11ac_dev_cap_bg;
441 PRINTM(MINFO,
442 "Get: vht cap info for 2.4GHz 0x%x\n",
443 pmpriv->usr_dot_11ac_dev_cap_bg);
444 } else if (cfg->param.vht_cfg.band ==
445 BAND_SELECT_A) {
446 cfg->param.vht_cfg.vht_cap_info =
447 pmpriv->usr_dot_11ac_dev_cap_a;
448 PRINTM(MINFO,
449 "Get: vht cap info for 5GHz 0x%x\n",
450 pmpriv->usr_dot_11ac_dev_cap_a);
451 } else {
452 PRINTM(MINFO,
453 "Get: invalid band selection for vht cap info\n");
454 ret = MLAN_STATUS_FAILURE;
455 }
456 cfg->param.vht_cfg.bwcfg =
457 pmpriv->usr_dot_11ac_bw;
458 cfg->param.vht_cfg.vht_rx_mcs = GET_DEVRXMCSMAP(
459 pmpriv->usr_dot_11ac_mcs_support);
460 cfg->param.vht_cfg.vht_tx_mcs = GET_DEVTXMCSMAP(
461 pmpriv->usr_dot_11ac_mcs_support);
462 cfg->param.vht_cfg.vht_rx_max_rate =
463 wlan_convert_mcsmap_to_maxrate(
464 pmpriv, cfg->param.vht_cfg.band,
465 cfg->param.vht_cfg.vht_rx_mcs);
466 cfg->param.vht_cfg.vht_tx_max_rate =
467 wlan_convert_mcsmap_to_maxrate(
468 pmpriv, cfg->param.vht_cfg.band,
469 cfg->param.vht_cfg.vht_tx_mcs);
470 }
471 LEAVE();
472 return ret;
473 }
474 }
475
476 if (pioctl_req->action == MLAN_ACT_SET)
477 cmd_action = HostCmd_ACT_GEN_SET;
478 else
479 cmd_action = HostCmd_ACT_GEN_GET;
480
481 /* Send request to firmware */
482 ret = wlan_prepare_cmd(pmpriv, HostCmd_CMD_11AC_CFG, cmd_action, 0,
483 (t_void *)pioctl_req,
484 (t_void *)&cfg->param.vht_cfg);
485 if (ret == MLAN_STATUS_SUCCESS)
486 ret = MLAN_STATUS_PENDING;
487
488 LEAVE();
489 return ret;
490 }
491
492 /**
493 * @brief Get/Set Operating Mode Notification cfg
494 *
495 * @param pmadapter A pointer to mlan_adapter structure
496 * @param pioctl_req A pointer to ioctl request buffer
497 *
498 * @return MLAN_STATUS_SUCCESS --success, otherwise fail
499 */
wlan_11ac_ioctl_opermodecfg(pmlan_adapter pmadapter,pmlan_ioctl_req pioctl_req)500 static mlan_status wlan_11ac_ioctl_opermodecfg(pmlan_adapter pmadapter,
501 pmlan_ioctl_req pioctl_req)
502 {
503 mlan_ds_11ac_cfg *cfg = MNULL;
504 mlan_private *pmpriv = pmadapter->priv[pioctl_req->bss_index];
505 t_u8 hw_bw_160or8080 = 0;
506 t_u8 hw_rx_nss = 0;
507
508 ENTER();
509
510 cfg = (mlan_ds_11ac_cfg *)pioctl_req->pbuf;
511 if (pioctl_req->action == MLAN_ACT_GET) {
512 cfg->param.opermode_cfg.bw = pmpriv->usr_dot_11ac_opermode_bw;
513 cfg->param.opermode_cfg.nss = pmpriv->usr_dot_11ac_opermode_nss;
514 } else if (pioctl_req->action == MLAN_ACT_SET) {
515 hw_bw_160or8080 =
516 GET_VHTCAP_CHWDSET(pmadapter->hw_dot_11ac_dev_cap);
517 hw_rx_nss = wlan_get_nss_num_vht_mcs(
518 GET_DEVRXMCSMAP(pmadapter->hw_dot_11ac_mcs_support));
519 if ((((cfg->param.opermode_cfg.bw - 1) > BW_80MHZ) &&
520 !hw_bw_160or8080) ||
521 (cfg->param.opermode_cfg.nss > hw_rx_nss)) {
522 PRINTM(MERROR,
523 "bw or nss NOT supported. HW support bw_160or8080=%d rx_nss=%d.\n",
524 hw_bw_160or8080, hw_rx_nss);
525 LEAVE();
526 return MLAN_STATUS_FAILURE;
527 }
528 pmpriv->usr_dot_11ac_opermode_bw = cfg->param.opermode_cfg.bw;
529 pmpriv->usr_dot_11ac_opermode_nss = cfg->param.opermode_cfg.nss;
530 }
531
532 LEAVE();
533 return MLAN_STATUS_SUCCESS;
534 }
535
536 /**
537 * @brief Get supported MCS set
538 *
539 * @param pmadapter A pointer to mlan_adapter structure
540 * @param pioctl_req A pointer to ioctl request buffer
541 *
542 * @return MLAN_STATUS_SUCCESS --success, otherwise fail
543 */
wlan_11ac_ioctl_supported_mcs_set(pmlan_adapter pmadapter,pmlan_ioctl_req pioctl_req)544 static mlan_status wlan_11ac_ioctl_supported_mcs_set(pmlan_adapter pmadapter,
545 pmlan_ioctl_req pioctl_req)
546 {
547 /*mlan_ds_11ac_cfg *cfg= MNULL;*/
548 /*int rx_mcs_supp;*/
549 /*t_u8 mcs_set[NUM_MCS_SUPP];*/
550
551 ENTER();
552 #if 0
553 if (pioctl_req->action == MLAN_ACT_SET) {
554 PRINTM(MERROR, "Set operation is not supported\n");
555 pioctl_req->status_code = MLAN_ERROR_IOCTL_INVALID;
556 LEAVE();
557 return MLAN_STATUS_FAILURE;
558 }
559 rx_mcs_supp = GET_11ACRXMCSSUPP(pmadapter->usr_dot_11ac_mcs_support);
560 /* Set MCS */
561 memset(pmadapter, (t_u8 *) mcs_set, 0xff, rx_mcs_supp);
562 /* Clear all the other values */
563 memset(pmadapter, (t_u8 *) &mcs_set[rx_mcs_supp], 0,
564 NUM_MCS_FIELD - rx_mcs_supp);
565 /* Set MCS32 with 40MHz support */
566 if (ISSUPP_CHANWIDTH80(pmadapter->usr_dot_11ac_dev_cap_bg)
567 || ISSUPP_CHANWIDTH80(pmadapter->usr_dot_11ac_dev_cap_a)
568 )
569 SETHT_MCS32(mcs_set);
570
571 cfg = (mlan_ds_11ac_cfg *)pioctl_req->pbuf;
572 memcpy_ext(pmadapter, cfg->param.supported_mcs_set, mcs_set,
573 NUM_MCS_SUPP, sizeof(cfg->param.supported_mcs_set));
574
575 #endif
576 LEAVE();
577 return MLAN_STATUS_SUCCESS;
578 }
579
580 /********************************************************
581 Global Functions
582 ********************************************************/
583
584 /**
585 * @brief This function prints the 802.11ac device capability
586 *
587 * @param pmadapter A pointer to mlan_adapter structure
588 * @param cap Capability value
589 *
590 * @return N/A
591 */
wlan_show_dot11acdevcap(pmlan_adapter pmadapter,t_u32 cap)592 void wlan_show_dot11acdevcap(pmlan_adapter pmadapter, t_u32 cap)
593 {
594 ENTER();
595
596 switch (GET_VHTCAP_MAXMPDULEN(cap)) {
597 case 0x0:
598 PRINTM(MINFO,
599 "GET_HW_SPEC: Maximum MPDU length = 3895 octets\n");
600 break;
601 case 0x1:
602 PRINTM(MINFO,
603 "GET_HW_SPEC: Maximum MPDU length = 7991 octets\n");
604 break;
605 case 0x2:
606 PRINTM(MINFO,
607 "GET_HW_SPEC: Maximum MPDU length = 11454 octets\n");
608 break;
609 default:
610 PRINTM(MINFO, "Unsupport value\n");
611 break;
612 }
613
614 PRINTM(MINFO, "GET_HW_SPEC: HTC-VHT %s\n",
615 (ISSUPP_11ACVHTHTCVHT(cap) ? "supported" : "not supported"));
616 PRINTM(MINFO, "GET_HW_SPEC: VHT TXOP PS %s\n",
617 (ISSUPP_11ACVHTTXOPPS(cap) ? "supported" : "not supported"));
618 PRINTM(MINFO, "GET_HW_SPEC: MU RX beamformee %s\n",
619 (ISSUPP_11ACMURXBEAMFORMEE(cap) ? "supported" :
620 "not supported"));
621 PRINTM(MINFO, "GET_HW_SPEC: MU TX beamformee %s\n",
622 (ISSUPP_11ACMUTXBEAMFORMEE(cap) ? "supported" :
623 "not supported"));
624 PRINTM(MINFO, "GET_HW_SPEC: SU RX Beamformee %s\n",
625 (ISSUPP_11ACSUBEAMFORMEE(cap) ? "supported" : "not supported"));
626 PRINTM(MINFO, "GET_HW_SPEC: SU TX Beamformer %s\n",
627 (ISSUPP_11ACSUBEAMFORMER(cap) ? "supported" : "not supported"));
628 PRINTM(MINFO, "GET_HW_SPEC: Rx STBC %s\n",
629 (ISSUPP_11ACRXSTBC(cap) ? "supported" : "not supported"));
630 PRINTM(MINFO, "GET_HW_SPEC: Tx STBC %s\n",
631 (ISSUPP_11ACTXSTBC(cap) ? "supported" : "not supported"));
632 PRINTM(MINFO, "GET_HW_SPEC: Short GI %s for 160MHz BW\n",
633 (ISSUPP_11ACSGI160(cap) ? "supported" : "not supported"));
634 PRINTM(MINFO, "GET_HW_SPEC: Short GI %s for 80MHz BW\n",
635 (ISSUPP_11ACSGI80(cap) ? "supported" : "not supported"));
636 PRINTM(MINFO, "GET_HW_SPEC: LDPC coding %s\n",
637 (ISSUPP_11ACLDPC(cap) ? "supported" : "not supported"));
638 PRINTM(MINFO, "GET_HW_SPEC: Channel BW 20/40/80/160/80+80 MHz %s\n",
639 (ISSUPP_11ACBW8080(cap) ? "supported" : "not supported"));
640 PRINTM(MINFO, "GET_HW_SPEC: Channel BW 20/40/80/160 MHz %s\n",
641 (ISSUPP_11ACBW160(cap) ? "supported" : "not supported"));
642
643 LEAVE();
644 return;
645 }
646
647 /**
648 * @brief This function prints the 802.11ac device MCS
649 *
650 * @param pmadapter A pointer to mlan_adapter structure
651 * @param support Support value
652 *
653 * @return N/A
654 */
wlan_show_dot11acmcssupport(pmlan_adapter pmadapter,t_u32 support)655 void wlan_show_dot11acmcssupport(pmlan_adapter pmadapter, t_u32 support)
656 {
657 ENTER();
658
659 PRINTM(MINFO, "GET_HW_SPEC: MCSs for %2dx%2d MIMO\n",
660 GET_DEVRXMCSMAP(support), GET_DEVTXMCSMAP(support));
661
662 LEAVE();
663 return;
664 }
665
666 /**
667 * @brief This function converts the 2-bit MCS map to the highest long GI
668 * VHT PPDU data rate
669 *
670 * @param priv A pointer to mlan_private structure
671 * @param bands Supported bands
672 * @param mcs_map 2-bit MCS map
673 *
674 * @return the max data rate for long GI
675 */
wlan_convert_mcsmap_to_maxrate(mlan_private * priv,t_u16 bands,t_u16 mcs_map)676 t_u16 wlan_convert_mcsmap_to_maxrate(mlan_private *priv, t_u16 bands,
677 t_u16 mcs_map)
678 {
679 t_u8 i;
680 t_u8 nss;
681 t_u8 max_mcs;
682 t_u16 max_rate = 0;
683 t_u32 usr_vht_cap_info = 0;
684 t_u32 usr_dot_11n_dev_cap;
685
686 /* tables of the MCS map to the highest data rate (in Mbps)
687 * supported for long GI */
688 t_u16 max_rate_lgi_20MHZ[8][3] = {
689 {0x41, 0x4E, 0x0}, /* NSS = 1 */
690 {0x82, 0x9C, 0x0}, /* NSS = 2 */
691 {0xC3, 0xEA, 0x104}, /* NSS = 3 */
692 {0x104, 0x138, 0x0}, /* NSS = 4 */
693 {0x145, 0x186, 0x0}, /* NSS = 5 */
694 {0x186, 0x1D4, 0x208}, /* NSS = 6 */
695 {0x1C7, 0x222, 0x0}, /* NSS = 7 */
696 {0x208, 0x270, 0x0} /* NSS = 8 */
697 };
698
699 t_u16 max_rate_lgi_40MHZ[8][3] = {
700 {0x87, 0xA2, 0xB4}, /* NSS = 1 */
701 {0x10E, 0x144, 0x168}, /* NSS = 2 */
702 {0x195, 0x1E6, 0x21C}, /* NSS = 3 */
703 {0x21C, 0x288, 0x2D0}, /* NSS = 4 */
704 {0x2A3, 0x32A, 0x384}, /* NSS = 5 */
705 {0x32A, 0x3CC, 0x438}, /* NSS = 6 */
706 {0x3B1, 0x46E, 0x4EC}, /* NSS = 7 */
707 {0x438, 0x510, 0x5A0} /* NSS = 8 */
708 };
709
710 t_u16 max_rate_lgi_80MHZ[8][3] = {
711 {0x124, 0x15F, 0x186}, /* NSS = 1 */
712 {0x249, 0x2BE, 0x30C}, /* NSS = 2 */
713 {0x36D, 0x41D, 0x492}, /* NSS = 3 */
714 {0x492, 0x57C, 0x618}, /* NSS = 4 */
715 {0x5B6, 0x6DB, 0x79E}, /* NSS = 5 */
716 {0x6DB, 0x83A, 0x0}, /* NSS = 6 */
717 {0x7FF, 0x999, 0xAAA}, /* NSS = 7 */
718 {0x924, 0xAF8, 0xC30} /* NSS = 8 */
719 };
720 t_u16 max_rate_lgi_160MHZ[8][3] = {
721 {0x249, 0x2BE, 0x30C}, /* NSS = 1 */
722 {0x492, 0x57C, 0x618}, /* NSS = 2 */
723 {0x6DB, 0x83A, 0x0}, /* NSS = 3 */
724 {0x924, 0xAF8, 0xC30}, /* NSS = 4 */
725 {0xB6D, 0xDB6, 0xF3C}, /* NSS = 5 */
726 {0xDB6, 0x1074, 0x1248}, /* NSS = 6 */
727 {0xFFF, 0x1332, 0x1554}, /* NSS = 7 */
728 {0x1248, 0x15F0, 0x1860} /* NSS = 8 */
729 };
730
731 if (bands & BAND_AAC) {
732 usr_vht_cap_info = priv->usr_dot_11ac_dev_cap_a;
733 usr_dot_11n_dev_cap = priv->usr_dot_11n_dev_cap_a;
734 } else {
735 usr_vht_cap_info = priv->usr_dot_11ac_dev_cap_bg;
736 usr_dot_11n_dev_cap = priv->usr_dot_11n_dev_cap_bg;
737 }
738
739 /* find the max NSS supported */
740 nss = 0;
741 for (i = 0; i < 8; i++) {
742 max_mcs = (mcs_map >> (2 * i)) & 0x3;
743 if (max_mcs < 3)
744 nss = i;
745 }
746
747 max_mcs = (mcs_map >> (2 * nss)) & 0x3;
748 /* if max_mcs is 3, nss must be 0 (SS = 1). Thus, max mcs is MCS 9*/
749 if (max_mcs >= 3)
750 max_mcs = 2;
751
752 if (GET_VHTCAP_CHWDSET(usr_vht_cap_info)) {
753 /* support 160 MHz */
754 max_rate = max_rate_lgi_160MHZ[nss][max_mcs];
755 if (max_mcs >= 1 && max_rate == 0)
756 /* MCS9 is not supported in NSS6 */
757 max_rate = max_rate_lgi_160MHZ[nss][max_mcs - 1];
758
759 } else {
760 if (priv->usr_dot_11ac_bw == BW_FOLLOW_VHTCAP) {
761 max_rate = max_rate_lgi_80MHZ[nss][max_mcs];
762 if (max_mcs >= 1 && max_rate == 0)
763 /* MCS9 is not supported in NSS3 */
764 max_rate = max_rate_lgi_80MHZ[nss][max_mcs - 1];
765 } else {
766 if (ISSUPP_CHANWIDTH40(usr_dot_11n_dev_cap)) {
767 max_rate = max_rate_lgi_40MHZ[nss][max_mcs];
768 } else {
769 max_rate = max_rate_lgi_20MHZ[nss][max_mcs];
770 /* MCS9 is not supported in NSS1/2/4/5/7/8 */
771 if (max_mcs >= 1 && max_rate == 0)
772 max_rate =
773 max_rate_lgi_20MHZ[nss]
774 [max_mcs - 1];
775 }
776 }
777 }
778 PRINTM(MCMND, "max_rate=%dM\n", max_rate);
779 return max_rate;
780 }
781
782 /**
783 * @brief This function fills the VHT cap tlv out put format is LE, not CPU
784 *
785 * @param priv A pointer to mlan_private structure
786 * @param pvht_cap A pointer to MrvlIETypes_HTCap_t structure
787 * @param bands Band configuration
788 * @param flag TREU--pvht_cap has the setting for resp
789 * MFALSE -- pvht_cap is clean
790 * @param bw_80p80 TRUE -- enable 80p80
791 * @return N/A
792 */
wlan_fill_vht_cap_tlv(mlan_private * priv,MrvlIETypes_VHTCap_t * pvht_cap,t_u16 bands,t_u8 flag,t_u8 bw_80p80)793 void wlan_fill_vht_cap_tlv(mlan_private *priv, MrvlIETypes_VHTCap_t *pvht_cap,
794 t_u16 bands, t_u8 flag, t_u8 bw_80p80)
795 {
796 t_u16 mcs_map_user = 0;
797 t_u16 mcs_map_resp = 0;
798 t_u16 mcs_map_result = 0;
799 t_u16 mcs_user = 0;
800 t_u16 mcs_resp = 0;
801 t_u16 nss;
802 #if defined(PCIE9098) || defined(SD9098) || defined(USB9098) || \
803 defined(PCIE9097) || defined(SD9097) || defined(USB9097) || \
804 defined(SDNW62X) || defined(PCIENW62X) || defined(USBNW62X)
805 t_u16 rx_nss = 0, tx_nss = 0;
806 #endif
807 ENTER();
808
809 /* Fill VHT cap info */
810 wlan_fill_cap_info(priv, &pvht_cap->vht_cap, bands);
811 /* clear 80p80 in vht_cap_info */
812 if (!bw_80p80)
813 pvht_cap->vht_cap.vht_cap_info &= ~(MBIT(2) | MBIT(3));
814 pvht_cap->vht_cap.vht_cap_info =
815 wlan_cpu_to_le32(pvht_cap->vht_cap.vht_cap_info);
816
817 /* Fill VHT MCS Set */
818 /* rx MCS Set, find the minimum of the user rx mcs and ap rx mcs*/
819 mcs_map_resp = mcs_map_user =
820 GET_DEVRXMCSMAP(priv->usr_dot_11ac_mcs_support);
821 if (flag)
822 mcs_map_resp =
823 wlan_le16_to_cpu(pvht_cap->vht_cap.mcs_sets.rx_mcs_map);
824 #if defined(PCIE9098) || defined(SD9098) || defined(USB9098) || \
825 defined(PCIE9097) || defined(SD9097) || defined(USB9097) || \
826 defined(SDNW62X) || defined(PCIENW62X) || defined(USBNW62X)
827 if (IS_CARD9098(priv->adapter->card_type) ||
828 IS_CARDNW62X(priv->adapter->card_type) ||
829 IS_CARD9097(priv->adapter->card_type)) {
830 if (bands & BAND_A) {
831 rx_nss = GET_RXMCSSUPP(priv->adapter->user_htstream >>
832 8);
833 tx_nss = GET_TXMCSSUPP(priv->adapter->user_htstream >>
834 8) &
835 0x0f;
836 } else {
837 rx_nss = GET_RXMCSSUPP(priv->adapter->user_htstream);
838 tx_nss = GET_TXMCSSUPP(priv->adapter->user_htstream) &
839 0x0f;
840 }
841 /** force 1x1 when enable 80P80 */
842 if (bw_80p80)
843 rx_nss = tx_nss = 1;
844 }
845 #endif
846 mcs_map_result = 0;
847 for (nss = 1; nss <= 8; nss++) {
848 mcs_user = GET_VHTNSSMCS(mcs_map_user, nss);
849 mcs_resp = GET_VHTNSSMCS(mcs_map_resp, nss);
850 #if defined(PCIE9098) || defined(SD9098) || defined(USB9098) || \
851 defined(PCIE9097) || defined(SD9097) || defined(USB9097) || \
852 defined(SDNW62X) || defined(PCIENW62X) || defined(USBNW62X)
853 if ((rx_nss != 0) && (nss > rx_nss))
854 mcs_user = NO_NSS_SUPPORT;
855 #endif
856 if ((mcs_user == NO_NSS_SUPPORT) ||
857 (mcs_resp == NO_NSS_SUPPORT))
858 SET_VHTNSSMCS(mcs_map_result, nss, NO_NSS_SUPPORT);
859 else
860 SET_VHTNSSMCS(mcs_map_result, nss,
861 MIN(mcs_user, mcs_resp));
862 }
863 /* rx MCS map */
864 pvht_cap->vht_cap.mcs_sets.rx_mcs_map =
865 wlan_cpu_to_le16(mcs_map_result);
866
867 /* rx highest rate */
868 pvht_cap->vht_cap.mcs_sets.rx_max_rate =
869 wlan_convert_mcsmap_to_maxrate(priv, bands, mcs_map_result);
870 pvht_cap->vht_cap.mcs_sets.rx_max_rate =
871 wlan_cpu_to_le16(pvht_cap->vht_cap.mcs_sets.rx_max_rate);
872
873 /* tx MCS Set find the minimum of the user tx mcs and ap tx mcs */
874 mcs_map_resp = mcs_map_user =
875 GET_DEVTXMCSMAP(priv->usr_dot_11ac_mcs_support);
876 if (flag)
877 mcs_map_resp =
878 wlan_le16_to_cpu(pvht_cap->vht_cap.mcs_sets.tx_mcs_map);
879 mcs_map_result = 0;
880 for (nss = 1; nss <= 8; nss++) {
881 mcs_user = GET_VHTNSSMCS(mcs_map_user, nss);
882 mcs_resp = GET_VHTNSSMCS(mcs_map_resp, nss);
883 #if defined(PCIE9098) || defined(SD9098) || defined(USB9098) || \
884 defined(PCIE9097) || defined(SD9097) || defined(USB9097) || \
885 defined(SDNW62X) || defined(PCIENW62X) || defined(USBNW62X)
886 if ((tx_nss != 0) && (nss > tx_nss))
887 mcs_user = NO_NSS_SUPPORT;
888 #endif
889 if ((mcs_user == NO_NSS_SUPPORT) ||
890 (mcs_resp == NO_NSS_SUPPORT))
891 SET_VHTNSSMCS(mcs_map_result, nss, NO_NSS_SUPPORT);
892 else
893 SET_VHTNSSMCS(mcs_map_result, nss,
894 MIN(mcs_user, mcs_resp));
895 }
896
897 /* tx MCS map */
898 pvht_cap->vht_cap.mcs_sets.tx_mcs_map =
899 wlan_cpu_to_le16(mcs_map_result);
900 /* tx highest rate */
901 pvht_cap->vht_cap.mcs_sets.tx_max_rate =
902 wlan_convert_mcsmap_to_maxrate(priv, bands, mcs_map_result);
903 pvht_cap->vht_cap.mcs_sets.tx_max_rate =
904 wlan_cpu_to_le16(pvht_cap->vht_cap.mcs_sets.tx_max_rate);
905
906 LEAVE();
907 return;
908 }
909
910 /**
911 * @brief This function fills the VHT cap tlv out put format is CPU
912 *
913 * @param priv A pointer to mlan_private structure
914 * @param pvht_cap A pointer to MrvlIETypes_HTCap_t structure
915 * @param bands Band configuration
916 *
917 * @return N/A
918 */
wlan_fill_vht_cap_ie(mlan_private * priv,IEEEtypes_VHTCap_t * pvht_cap,t_u16 bands)919 void wlan_fill_vht_cap_ie(mlan_private *priv, IEEEtypes_VHTCap_t *pvht_cap,
920 t_u16 bands)
921 {
922 ENTER();
923
924 pvht_cap->ieee_hdr.element_id = VHT_CAPABILITY;
925 pvht_cap->ieee_hdr.len = sizeof(VHT_capa_t);
926
927 /* Fill VHT cap info */
928 wlan_fill_cap_info(priv, &pvht_cap->vht_cap, bands);
929
930 /* rx MCS map */
931 pvht_cap->vht_cap.mcs_sets.rx_mcs_map =
932 GET_DEVRXMCSMAP(priv->usr_dot_11ac_mcs_support);
933
934 /* rx highest rate */
935 pvht_cap->vht_cap.mcs_sets.rx_max_rate = wlan_convert_mcsmap_to_maxrate(
936 priv, bands, pvht_cap->vht_cap.mcs_sets.rx_mcs_map);
937
938 /* tx MCS map */
939 pvht_cap->vht_cap.mcs_sets.tx_mcs_map =
940 GET_DEVTXMCSMAP(priv->usr_dot_11ac_mcs_support);
941 /* tx highest rate */
942 pvht_cap->vht_cap.mcs_sets.tx_max_rate = wlan_convert_mcsmap_to_maxrate(
943 priv, bands, pvht_cap->vht_cap.mcs_sets.tx_mcs_map);
944
945 LEAVE();
946 return;
947 }
948
949 /*
950 * @brief This function check if AP is in 11ac mode
951 *
952 * @param priv A pointer to mlan_private structure
953 *
954 * @return MTRUE/MFALSE
955 */
wlan_is_ap_in_11ac_mode(mlan_private * priv)956 t_u8 wlan_is_ap_in_11ac_mode(mlan_private *priv)
957 {
958 BSSDescriptor_t *pbss_desc;
959 IEEEtypes_VHTOprat_t *vht_oprat = MNULL;
960 pbss_desc = &priv->curr_bss_params.bss_descriptor;
961 vht_oprat = pbss_desc->pvht_oprat;
962 if (!pbss_desc->pvht_cap)
963 return MFALSE;
964 if (vht_oprat && (vht_oprat->ieee_hdr.element_id == VHT_OPERATION)) {
965 if (vht_oprat->chan_width == VHT_OPER_CHWD_20_40MHZ)
966 return MFALSE;
967 else
968 return MTRUE;
969 } else
970 return MFALSE;
971 }
972
973 /**
974 * @brief This function fills the VHTOperation ie out put format is CPU
975 *
976 * @param priv A pointer to mlan_private structure
977 * @param vht_oprat A pointer to IEEEtypes_VHTOprat_t structure
978 * @param sta_ptr A pointer to sta_node
979 *
980 * @return N/A
981 */
wlan_fill_tdls_vht_oprat_ie(mlan_private * priv,IEEEtypes_VHTOprat_t * vht_oprat,sta_node * sta_ptr)982 void wlan_fill_tdls_vht_oprat_ie(mlan_private *priv,
983 IEEEtypes_VHTOprat_t *vht_oprat,
984 sta_node *sta_ptr)
985 {
986 t_u8 supp_chwd_set;
987 t_u8 peer_supp_chwd_set;
988 t_u8 ap_supp_chwd_set;
989 t_u32 usr_vht_cap_info;
990
991 t_u16 mcs_map_user = 0;
992 t_u16 mcs_map_resp = 0;
993 t_u16 mcs_map_result = 0;
994 t_u16 mcs_user = 0;
995 t_u16 mcs_resp = 0;
996 t_u16 nss;
997 t_u8 chan_bw = 0;
998 BSSDescriptor_t *pbss_desc;
999 IEEEtypes_VHTCap_t *pvht_cap = &sta_ptr->vht_cap;
1000 IEEEtypes_VHTCap_t *ap_vht_cap = MNULL;
1001 ENTER();
1002
1003 pbss_desc = &priv->curr_bss_params.bss_descriptor;
1004
1005 /* Check if AP is in 11ac mode */
1006 if (MFALSE == wlan_is_ap_in_11ac_mode(priv)) {
1007 if (sta_ptr->ExtCap.ieee_hdr.element_id != EXT_CAPABILITY) {
1008 PRINTM(MMSG, "No Peer's Ext_cap info\n");
1009 return;
1010 }
1011 if (!ISSUPP_EXTCAP_TDLS_WIDER_BANDWIDTH(
1012 sta_ptr->ExtCap.ext_cap)) {
1013 PRINTM(MMSG,
1014 "Peer don't support Wider Bandwitch in Ext_cap\n");
1015 return;
1016 }
1017 } else {
1018 ap_vht_cap = pbss_desc->pvht_cap;
1019 }
1020
1021 vht_oprat->ieee_hdr.element_id = VHT_OPERATION;
1022 vht_oprat->ieee_hdr.len =
1023 sizeof(IEEEtypes_VHTOprat_t) - sizeof(IEEEtypes_Header_t);
1024
1025 if (pbss_desc->bss_band & BAND_A)
1026 usr_vht_cap_info = priv->usr_dot_11ac_dev_cap_a;
1027 else
1028 usr_vht_cap_info = priv->usr_dot_11ac_dev_cap_bg;
1029
1030 /* find the minmum bandwith between AP/TDLS peers */
1031 supp_chwd_set = GET_VHTCAP_CHWDSET(usr_vht_cap_info);
1032 peer_supp_chwd_set = GET_VHTCAP_CHWDSET(pvht_cap->vht_cap.vht_cap_info);
1033 supp_chwd_set = MIN(supp_chwd_set, peer_supp_chwd_set);
1034
1035 /* We need check AP's bandwidth when TDLS_WIDER_BANDWIDTH is off */
1036 if (ap_vht_cap &&
1037 !ISSUPP_EXTCAP_TDLS_WIDER_BANDWIDTH(sta_ptr->ExtCap.ext_cap)) {
1038 ap_supp_chwd_set =
1039 GET_VHTCAP_CHWDSET(ap_vht_cap->vht_cap.vht_cap_info);
1040 supp_chwd_set = MIN(supp_chwd_set, ap_supp_chwd_set);
1041 }
1042 switch (supp_chwd_set) {
1043 case VHT_CAP_CHWD_80MHZ:
1044 vht_oprat->chan_width = VHT_OPER_CHWD_80MHZ;
1045 break;
1046 case VHT_CAP_CHWD_160MHZ:
1047 vht_oprat->chan_width = VHT_OPER_CHWD_160MHZ;
1048 break;
1049 case VHT_CAP_CHWD_80_80MHZ:
1050 vht_oprat->chan_width = VHT_OPER_CHWD_80_80MHZ;
1051 break;
1052 }
1053
1054 /* Fill BASIC VHT MCS and NSS Set */
1055 /* rx MCS Set, find the minimum of the user rx mcs and peer rx mcs*/
1056 mcs_map_user = GET_DEVRXMCSMAP(priv->usr_dot_11ac_mcs_support);
1057 mcs_map_resp = pvht_cap->vht_cap.mcs_sets.rx_mcs_map;
1058 mcs_map_result = 0;
1059 for (nss = 1; nss <= 8; nss++) {
1060 mcs_user = GET_VHTNSSMCS(mcs_map_user, nss);
1061 mcs_resp = GET_VHTNSSMCS(mcs_map_resp, nss);
1062 if ((mcs_user == NO_NSS_SUPPORT) ||
1063 (mcs_resp == NO_NSS_SUPPORT))
1064 SET_VHTNSSMCS(mcs_map_result, nss, NO_NSS_SUPPORT);
1065 else
1066 SET_VHTNSSMCS(mcs_map_result, nss,
1067 MIN(mcs_user, mcs_resp));
1068 }
1069 /* Basic MCS map */
1070 vht_oprat->basic_MCS_map = mcs_map_result;
1071 switch (vht_oprat->chan_width) {
1072 case VHT_OPER_CHWD_80MHZ:
1073 chan_bw = CHANNEL_BW_80MHZ;
1074 break;
1075 case VHT_OPER_CHWD_160MHZ:
1076 chan_bw = CHANNEL_BW_160MHZ;
1077 break;
1078 case VHT_OPER_CHWD_80_80MHZ:
1079 chan_bw = CHANNEL_BW_80MHZ;
1080 break;
1081 }
1082 vht_oprat->chan_center_freq_1 = wlan_get_center_freq_idx(
1083 priv, BAND_AAC, pbss_desc->channel, chan_bw);
1084
1085 LEAVE();
1086 return;
1087 }
1088
1089 /**
1090 * @brief This function would check whether support 80+80Mhz
1091 *
1092 * @param pmpriv A pointer to mlan_private structure
1093 * @param pbss_desc A pointer to BSSDescriptor_t structure
1094 *
1095 * @return ret suport 80+80Mhz or not
1096 */
wlan_is_80_80_support(mlan_private * pmpriv,BSSDescriptor_t * pbss_desc)1097 t_u8 wlan_is_80_80_support(mlan_private *pmpriv, BSSDescriptor_t *pbss_desc)
1098 {
1099 t_u8 ret = MFALSE;
1100 #if defined(PCIE9098) || defined(SD9098) || defined(USB9098) || \
1101 defined(PCIE9097) || defined(SD9097) || defined(USB9097) || \
1102 defined(SDNW62X) || defined(PCIENW62X) || defined(USBNW62X)
1103 t_u16 rx_nss = 0, tx_nss = 0;
1104 IEEEtypes_VHTCap_t *pvht_cap = pbss_desc->pvht_cap;
1105 MrvlIEtypes_He_cap_t *phecap = MNULL;
1106 IEEEtypes_HECap_t *pBsshecap = MNULL;
1107 #endif
1108
1109 ENTER();
1110
1111 #if defined(PCIE9098) || defined(SD9098) || defined(USB9098) || \
1112 defined(PCIE9097) || defined(SD9097) || defined(USB9097) || \
1113 defined(SDNW62X) || defined(PCIENW62X) || defined(USBNW62X)
1114 if (!IS_CARD9098(pmpriv->adapter->card_type) &&
1115 !IS_CARDNW62X(pmpriv->adapter->card_type) &&
1116 !IS_CARD9097(pmpriv->adapter->card_type))
1117 return ret;
1118 /** check band A */
1119 if (!(pbss_desc->bss_band & BAND_A))
1120 return ret;
1121
1122 /** check band A antenna setting */
1123 rx_nss = GET_RXMCSSUPP(pmpriv->adapter->user_htstream >> 8);
1124 tx_nss = GET_TXMCSSUPP(pmpriv->adapter->user_htstream >> 8) & 0x0f;
1125 /** check if support 2*2 */
1126 if (rx_nss != 2 || tx_nss != 2)
1127 return ret;
1128 /** check if AP support AC 80P80 */
1129 if (ISSUPP_11ACBW8080(pmpriv->usr_dot_11ac_dev_cap_a) && pvht_cap &&
1130 ISSUPP_11ACBW8080(pvht_cap->vht_cap.vht_cap_info))
1131 ret = MTRUE;
1132 /** check if AP support AX 80P80 */
1133 if (pbss_desc->phe_cap) {
1134 pBsshecap = (IEEEtypes_HECap_t *)pbss_desc->phe_cap;
1135 phecap = (MrvlIEtypes_He_cap_t *)pmpriv->user_he_cap;
1136 if (ret && (phecap->he_phy_cap[0] & MBIT(4)) &&
1137 (pBsshecap->he_phy_cap[0] & MBIT(4)))
1138 ret = MTRUE;
1139 else
1140 ret = MFALSE;
1141 }
1142 #endif
1143 LEAVE();
1144 return ret;
1145 }
1146
1147 /**
1148 * @brief This function append the 802_11N tlv
1149 *
1150 * @param pmpriv A pointer to mlan_private structure
1151 * @param pbss_desc A pointer to BSSDescriptor_t structure
1152 * @param ppbuffer A Pointer to command buffer pointer
1153 *
1154 * @return bytes added to the buffer
1155 */
wlan_cmd_append_11ac_tlv(mlan_private * pmpriv,BSSDescriptor_t * pbss_desc,t_u8 ** ppbuffer)1156 int wlan_cmd_append_11ac_tlv(mlan_private *pmpriv, BSSDescriptor_t *pbss_desc,
1157 t_u8 **ppbuffer)
1158 {
1159 pmlan_adapter pmadapter = pmpriv->adapter;
1160 MrvlIETypes_VHTCap_t *pvht_cap;
1161 MrvlIETypes_OperModeNtf_t *pmrvl_oper_mode;
1162 t_u16 mcs_map_user = 0;
1163 t_u16 nss;
1164 int ret_len = 0;
1165 t_u8 bw_80p80 = MFALSE;
1166 #if defined(PCIE9098) || defined(SD9098) || defined(USB9098) || \
1167 defined(PCIE9097) || defined(USB9097) || defined(SDNW62X) || \
1168 defined(PCIENW62X) || defined(USBNW62X) || defined(SD9097)
1169 t_u16 rx_nss = 0;
1170 #endif
1171
1172 ENTER();
1173
1174 /* Null Checks */
1175 if (ppbuffer == MNULL) {
1176 LEAVE();
1177 return 0;
1178 }
1179 if (*ppbuffer == MNULL) {
1180 LEAVE();
1181 return 0;
1182 }
1183
1184 /* VHT Capabilities IE */
1185 if (pbss_desc->pvht_cap &&
1186 wlan_get_nss_vht_mcs(
1187 pbss_desc->pvht_cap->vht_cap.mcs_sets.rx_mcs_map)) {
1188 pvht_cap = (MrvlIETypes_VHTCap_t *)*ppbuffer;
1189 memset(pmadapter, pvht_cap, 0, sizeof(MrvlIETypes_VHTCap_t));
1190 pvht_cap->header.type = wlan_cpu_to_le16(VHT_CAPABILITY);
1191 pvht_cap->header.len = sizeof(VHT_capa_t);
1192 memcpy_ext(pmadapter,
1193 (t_u8 *)pvht_cap + sizeof(MrvlIEtypesHeader_t),
1194 (t_u8 *)pbss_desc->pvht_cap +
1195 sizeof(IEEEtypes_Header_t),
1196 pvht_cap->header.len, sizeof(VHT_capa_t));
1197 bw_80p80 = wlan_is_80_80_support(pmpriv, pbss_desc);
1198 wlan_fill_vht_cap_tlv(pmpriv, pvht_cap, pbss_desc->bss_band,
1199 MFALSE, bw_80p80);
1200
1201 HEXDUMP("VHT_CAPABILITIES IE", (t_u8 *)pvht_cap,
1202 sizeof(MrvlIETypes_VHTCap_t));
1203 *ppbuffer += sizeof(MrvlIETypes_VHTCap_t);
1204 ret_len += sizeof(MrvlIETypes_VHTCap_t);
1205 pvht_cap->header.len = wlan_cpu_to_le16(pvht_cap->header.len);
1206 } else {
1207 LEAVE();
1208 return 0;
1209 }
1210
1211 /* Operating Mode Notification IE */
1212 pmrvl_oper_mode = (MrvlIETypes_OperModeNtf_t *)*ppbuffer;
1213 memset(pmadapter, pmrvl_oper_mode, 0,
1214 sizeof(MrvlIETypes_OperModeNtf_t));
1215 pmrvl_oper_mode->header.type = wlan_cpu_to_le16(OPER_MODE_NTF);
1216 pmrvl_oper_mode->header.len = sizeof(t_u8);
1217
1218 if (pmpriv->usr_dot_11ac_opermode_bw ||
1219 pmpriv->usr_dot_11ac_opermode_nss) {
1220 pmrvl_oper_mode->oper_mode |=
1221 (pmpriv->usr_dot_11ac_opermode_nss - 1) << 4;
1222 pmrvl_oper_mode->oper_mode |=
1223 pmpriv->usr_dot_11ac_opermode_bw - 1;
1224 if (pbss_desc->bss_band & BAND_G) {
1225 if (!(IS_OPER_MODE_20M(pmrvl_oper_mode->oper_mode))) {
1226 if (pbss_desc->pht_cap->ht_cap.ht_cap_info &
1227 MBIT(1))
1228 SET_OPER_MODE_40M(
1229 pmrvl_oper_mode->oper_mode);
1230 else
1231 SET_OPER_MODE_20M(
1232 pmrvl_oper_mode->oper_mode);
1233 }
1234 }
1235 } else {
1236 /** set default bandwidth:80M*/
1237 SET_OPER_MODE_80M(pmrvl_oper_mode->oper_mode);
1238 #if defined(PCIE9098) || defined(SD9098) || defined(USB9098) || \
1239 defined(PCIE9097) || defined(SD9097) || defined(USB9097) || \
1240 defined(SDNW62X) || defined(PCIENW62X) || defined(USBNW62X)
1241 if (IS_CARD9098(pmadapter->card_type) ||
1242 IS_CARDNW62X(pmadapter->card_type) ||
1243 IS_CARD9097(pmadapter->card_type)) {
1244 if (pbss_desc->bss_band & BAND_A)
1245 rx_nss = GET_RXMCSSUPP(
1246 pmadapter->user_htstream >> 8);
1247 else
1248 rx_nss =
1249 GET_RXMCSSUPP(pmadapter->user_htstream);
1250 }
1251 #endif
1252 mcs_map_user =
1253 GET_DEVRXMCSMAP(pmpriv->usr_dot_11ac_mcs_support);
1254 nss = wlan_get_nss_num_vht_mcs(mcs_map_user);
1255
1256 #if defined(PCIE9098) || defined(SD9098) || defined(USB9098) || \
1257 defined(PCIE9097) || defined(SD9097) || defined(USB9097) || \
1258 defined(SDNW62X) || defined(PCIENW62X) || defined(USBNW62X)
1259 if (IS_CARD9098(pmadapter->card_type) ||
1260 IS_CARDNW62X(pmadapter->card_type) ||
1261 IS_CARD9097(pmadapter->card_type)) {
1262 PRINTM(MCMND, "rx_nss=%d nss=%d\n", rx_nss, nss);
1263 nss = MIN(rx_nss, nss);
1264 }
1265 #endif
1266
1267 pmrvl_oper_mode->oper_mode |= (nss - 1) << 4;
1268
1269 switch (pbss_desc->curr_bandwidth) {
1270 case BW_20MHZ:
1271 SET_OPER_MODE_20M(pmrvl_oper_mode->oper_mode);
1272 break;
1273 case BW_40MHZ:
1274 SET_OPER_MODE_40M(pmrvl_oper_mode->oper_mode);
1275 break;
1276 case BW_80MHZ:
1277 default:
1278 break;
1279 }
1280 }
1281 HEXDUMP("OPER MODE NTF IE", (t_u8 *)pmrvl_oper_mode,
1282 sizeof(MrvlIETypes_OperModeNtf_t));
1283 *ppbuffer += sizeof(MrvlIETypes_OperModeNtf_t);
1284 ret_len += sizeof(MrvlIETypes_OperModeNtf_t);
1285 pmrvl_oper_mode->header.len =
1286 wlan_cpu_to_le16(pmrvl_oper_mode->header.len);
1287
1288 LEAVE();
1289 return ret_len;
1290 }
1291
1292 /**
1293 * @brief 11ac configuration handler
1294 *
1295 * @param pmadapter A pointer to mlan_adapter structure
1296 * @param pioctl_req A pointer to ioctl request buffer
1297 *
1298 * @return MLAN_STATUS_SUCCESS --success, otherwise fail
1299 */
wlan_11ac_cfg_ioctl(pmlan_adapter pmadapter,pmlan_ioctl_req pioctl_req)1300 mlan_status wlan_11ac_cfg_ioctl(pmlan_adapter pmadapter,
1301 pmlan_ioctl_req pioctl_req)
1302 {
1303 mlan_status status = MLAN_STATUS_SUCCESS;
1304 mlan_ds_11ac_cfg *cfg = MNULL;
1305
1306 ENTER();
1307
1308 if (pioctl_req->buf_len < sizeof(mlan_ds_11ac_cfg)) {
1309 PRINTM(MINFO, "MLAN bss IOCTL length is too short.\n");
1310 pioctl_req->data_read_written = 0;
1311 pioctl_req->buf_len_needed = sizeof(mlan_ds_11ac_cfg);
1312 pioctl_req->status_code = MLAN_ERROR_INVALID_PARAMETER;
1313 LEAVE();
1314 return MLAN_STATUS_RESOURCE;
1315 }
1316 cfg = (mlan_ds_11ac_cfg *)pioctl_req->pbuf;
1317 switch (cfg->sub_command) {
1318 case MLAN_OID_11AC_VHT_CFG:
1319 status = wlan_11ac_ioctl_vhtcfg(pmadapter, pioctl_req);
1320 break;
1321 case MLAN_OID_11AC_CFG_SUPPORTED_MCS_SET:
1322 status = wlan_11ac_ioctl_supported_mcs_set(pmadapter,
1323 pioctl_req);
1324 break;
1325 case MLAN_OID_11AC_OPERMODE_CFG:
1326 status = wlan_11ac_ioctl_opermodecfg(pmadapter, pioctl_req);
1327 break;
1328 default:
1329 pioctl_req->status_code = MLAN_ERROR_IOCTL_INVALID;
1330 status = MLAN_STATUS_FAILURE;
1331 break;
1332 }
1333 LEAVE();
1334 return status;
1335 }
1336
1337 /**
1338 * @brief This function prepares 11ac cfg command
1339 *
1340 * @param pmpriv A pointer to mlan_private structure
1341 * @param cmd A pointer to HostCmd_DS_COMMAND structure
1342 * @param cmd_action the action: GET or SET
1343 * @param pdata_buf A pointer to data buffer
1344 * @return MLAN_STATUS_SUCCESS
1345 */
wlan_cmd_11ac_cfg(pmlan_private pmpriv,HostCmd_DS_COMMAND * cmd,t_u16 cmd_action,t_void * pdata_buf)1346 mlan_status wlan_cmd_11ac_cfg(pmlan_private pmpriv, HostCmd_DS_COMMAND *cmd,
1347 t_u16 cmd_action, t_void *pdata_buf)
1348 {
1349 pmlan_adapter pmadapter = pmpriv->adapter;
1350 HostCmd_DS_11AC_CFG *vhtcfg = &cmd->params.vhtcfg;
1351 mlan_ds_11ac_vht_cfg *vht_cfg = (mlan_ds_11ac_vht_cfg *)pdata_buf;
1352
1353 ENTER();
1354 cmd->command = wlan_cpu_to_le16(HostCmd_CMD_11AC_CFG);
1355 cmd->size = wlan_cpu_to_le16(sizeof(HostCmd_DS_11AC_CFG) + S_DS_GEN);
1356 vhtcfg->action = wlan_cpu_to_le16(cmd_action);
1357 vhtcfg->band_config = vht_cfg->band & 0xFF;
1358 // block user enable 80MHZ
1359 if (IS_FW_SUPPORT_NO_80MHZ(pmadapter))
1360 vht_cfg->bwcfg = 0;
1361
1362 vhtcfg->misc_config = vht_cfg->txrx & 0x3;
1363 if (vhtcfg->misc_config != 2)
1364 vhtcfg->misc_config |= (vht_cfg->bwcfg << 2);
1365
1366 vhtcfg->vht_cap_info = wlan_cpu_to_le32(vht_cfg->vht_cap_info);
1367 vht_cfg->vht_rx_mcs = wlan_cpu_to_le32(vht_cfg->vht_rx_mcs);
1368 memcpy_ext(pmadapter, &vhtcfg->vht_supp_mcs_set[0],
1369 &vht_cfg->vht_rx_mcs, sizeof(t_u32), sizeof(t_u32));
1370 vht_cfg->vht_tx_mcs = wlan_cpu_to_le32(vht_cfg->vht_tx_mcs);
1371 memcpy_ext(pmadapter, &vhtcfg->vht_supp_mcs_set[4],
1372 &vht_cfg->vht_tx_mcs, sizeof(t_u32), sizeof(t_u32));
1373 LEAVE();
1374 return MLAN_STATUS_SUCCESS;
1375 }
1376
1377 /**
1378 * @brief This function handles the command response of 11accfg
1379 *
1380 * @param pmpriv A pointer to mlan_private structure
1381 * @param resp A pointer to HostCmd_DS_COMMAND
1382 * @param pioctl_buf A pointer to mlan_ioctl_req structure
1383 *
1384 * @return MLAN_STATUS_SUCCESS
1385 */
wlan_ret_11ac_cfg(pmlan_private pmpriv,HostCmd_DS_COMMAND * resp,mlan_ioctl_req * pioctl_buf)1386 mlan_status wlan_ret_11ac_cfg(pmlan_private pmpriv, HostCmd_DS_COMMAND *resp,
1387 mlan_ioctl_req *pioctl_buf)
1388 {
1389 pmlan_adapter pmadapter = pmpriv->adapter;
1390 mlan_ds_11ac_cfg *cfg = MNULL;
1391 HostCmd_DS_11AC_CFG *vhtcfg = &resp->params.vhtcfg;
1392
1393 ENTER();
1394 if (pioctl_buf &&
1395 (wlan_le16_to_cpu(vhtcfg->action) == HostCmd_ACT_GEN_GET)) {
1396 cfg = (mlan_ds_11ac_cfg *)pioctl_buf->pbuf;
1397 cfg->param.vht_cfg.band = vhtcfg->band_config;
1398 cfg->param.vht_cfg.txrx = vhtcfg->misc_config & 0x03;
1399 if (cfg->param.vht_cfg.txrx & 0x1)
1400 cfg->param.vht_cfg.bwcfg =
1401 (vhtcfg->misc_config & 0x04) >> 2;
1402 else
1403 cfg->param.vht_cfg.bwcfg = 0;
1404
1405 cfg->param.vht_cfg.vht_cap_info =
1406 wlan_le32_to_cpu(vhtcfg->vht_cap_info);
1407 memcpy_ext(pmadapter, &cfg->param.vht_cfg.vht_rx_mcs,
1408 &vhtcfg->vht_supp_mcs_set[0], sizeof(t_u32),
1409 sizeof(t_u32));
1410 cfg->param.vht_cfg.vht_rx_mcs =
1411 wlan_le32_to_cpu(cfg->param.vht_cfg.vht_rx_mcs);
1412 memcpy_ext(pmadapter, &cfg->param.vht_cfg.vht_tx_mcs,
1413 &vhtcfg->vht_supp_mcs_set[4], sizeof(t_u32),
1414 sizeof(t_u32));
1415 cfg->param.vht_cfg.vht_tx_mcs =
1416 wlan_le32_to_cpu(cfg->param.vht_cfg.vht_tx_mcs);
1417 cfg->param.vht_cfg.vht_rx_max_rate =
1418 wlan_convert_mcsmap_to_maxrate(
1419 pmpriv, cfg->param.vht_cfg.band,
1420 cfg->param.vht_cfg.vht_rx_mcs);
1421 cfg->param.vht_cfg.vht_tx_max_rate =
1422 wlan_convert_mcsmap_to_maxrate(
1423 pmpriv, cfg->param.vht_cfg.band,
1424 cfg->param.vht_cfg.vht_tx_mcs);
1425 }
1426 LEAVE();
1427 return MLAN_STATUS_SUCCESS;
1428 }
1429
wlan_update_11ac_cap(mlan_private * pmpriv)1430 void wlan_update_11ac_cap(mlan_private *pmpriv)
1431 {
1432 mlan_adapter *pmadapter = pmpriv->adapter;
1433
1434 pmpriv->usr_dot_11ac_mcs_support = pmadapter->hw_dot_11ac_mcs_support;
1435 pmpriv->usr_dot_11ac_dev_cap_bg =
1436 pmadapter->hw_dot_11ac_dev_cap &
1437 ~DEFALUT_11AC_CAP_BEAMFORMING_RESET_MASK;
1438 pmpriv->usr_dot_11ac_dev_cap_a =
1439 pmadapter->hw_dot_11ac_dev_cap &
1440 ~DEFALUT_11AC_CAP_BEAMFORMING_RESET_MASK;
1441 pmpriv->usr_dot_11ac_bw = BW_FOLLOW_VHTCAP;
1442 }
1443
1444 /**
1445 * @brief This function check if 11AC is allowed in bandcfg
1446 *
1447 * @param pmpriv A pointer to mlan_private structure
1448 * @param bss_band bss band
1449 *
1450 * @return 0--not allowed, other value allowed
1451 */
wlan_11ac_bandconfig_allowed(mlan_private * pmpriv,t_u16 bss_band)1452 t_u8 wlan_11ac_bandconfig_allowed(mlan_private *pmpriv, t_u16 bss_band)
1453 {
1454 if (pmpriv->bss_mode == MLAN_BSS_MODE_IBSS) {
1455 if (bss_band & BAND_G)
1456 return (pmpriv->adapter->adhoc_start_band & BAND_GAC);
1457 else if (bss_band & BAND_A)
1458 return (pmpriv->adapter->adhoc_start_band & BAND_AAC);
1459 } else {
1460 if (bss_band & BAND_G)
1461 return (pmpriv->config_bands & BAND_GAC);
1462 else if (bss_band & BAND_A)
1463 return (pmpriv->config_bands & BAND_AAC);
1464 }
1465 return 0;
1466 }
1467