1 /** @file wifi_nxp_internal.c
2 *
3 * @brief This file provides Core Wi-Fi definition for wpa supplicant rtos driver.
4 *
5 * Copyright 2008-2024 NXP
6 *
7 * SPDX-License-Identifier: BSD-3-Clause
8 *
9 */
10
11 #include <stdlib.h>
12 #include <string.h>
13 #include <osa.h>
14 #include <wm_net.h>
15 #include <wifi.h>
16 #include <wifi_nxp.h>
17 #include <wifi-internal.h>
18 #include <wifi-debug.h>
19
20 #if CONFIG_WPA_SUPP
21
22 #include <rtos_wpa_supp_if.h>
23 #include "supp_main.h"
24
wifi_survey_result_get(struct wifi_message * msg)25 void wifi_survey_result_get(struct wifi_message *msg)
26 {
27 nxp_wifi_trigger_op_t *wifi_survey_params = (nxp_wifi_trigger_op_t *)msg->data;
28
29 #if CONFIG_WPA_SUPP_AP
30 wm_wifi.hostapd_op = false;
31
32 if (wifi_survey_params->hostapd)
33 {
34 wm_wifi.hostapd_op = true;
35 }
36 #endif
37
38 wifi_nxp_survey_res_get();
39 OSA_MemoryFree(wifi_survey_params);
40 }
41
42 /* Event handlers*/
wifi_scan_start(struct wifi_message * msg)43 void wifi_scan_start(struct wifi_message *msg)
44 {
45 struct wifi_nxp_ctx_rtos *wifi_if_ctx_rtos = (struct wifi_nxp_ctx_rtos *)wm_wifi.if_priv;
46
47 if (!wifi_if_ctx_rtos || !wm_wifi.supp_if_callbk_fns)
48 return;
49
50 if (wifi_if_ctx_rtos->scan_in_progress)
51 {
52 if (msg->reason == WIFI_EVENT_REASON_SUCCESS)
53 {
54 if (wm_wifi.supp_if_callbk_fns->scan_start_callbk_fn)
55 {
56 wm_wifi.supp_if_callbk_fns->scan_start_callbk_fn(wm_wifi.if_priv);
57 }
58 }
59 }
60 }
61
wifi_scan_done(struct wifi_message * msg)62 void wifi_scan_done(struct wifi_message *msg)
63 {
64 struct wifi_nxp_ctx_rtos *wifi_if_ctx_rtos = NULL;
65
66 #if CONFIG_WPA_SUPP_AP
67 if (wm_wifi.hostapd_op)
68 {
69 wifi_if_ctx_rtos = (struct wifi_nxp_ctx_rtos *)wm_wifi.hapd_if_priv;
70
71 wm_wifi.hostapd_op = false;
72 }
73 else
74 #endif
75 {
76 wifi_if_ctx_rtos = (struct wifi_nxp_ctx_rtos *)wm_wifi.if_priv;
77 }
78
79 if (!wifi_if_ctx_rtos || !wm_wifi.supp_if_callbk_fns)
80 return;
81
82 if (msg->reason == WIFI_EVENT_REASON_FAILURE)
83 {
84 if (wm_wifi.supp_if_callbk_fns->scan_done_callbk_fn)
85 {
86 wm_wifi.supp_if_callbk_fns->scan_done_callbk_fn(wm_wifi.if_priv, 1, 0);
87 }
88 }
89
90 if (msg->reason == WIFI_EVENT_REASON_SUCCESS)
91 {
92 if (wm_wifi.supp_if_callbk_fns->scan_done_callbk_fn)
93 {
94 #if CONFIG_WPA_SUPP_AP
95 if (wifi_if_ctx_rtos->hostapd)
96 {
97 wm_wifi.supp_if_callbk_fns->scan_done_callbk_fn(wm_wifi.hapd_if_priv, 0, wm_wifi.external_scan);
98 }
99 else
100 #endif
101 {
102 wm_wifi.supp_if_callbk_fns->scan_done_callbk_fn(wm_wifi.if_priv, 0, wm_wifi.external_scan);
103 }
104 }
105 }
106
107 wm_wifi.external_scan = false;
108 }
109
wifi_process_remain_on_channel(struct wifi_message * msg)110 void wifi_process_remain_on_channel(struct wifi_message *msg)
111 {
112 struct wifi_nxp_ctx_rtos *wifi_if_ctx_rtos = (struct wifi_nxp_ctx_rtos *)wm_wifi.if_priv;
113
114 if (!wifi_if_ctx_rtos || !wm_wifi.supp_if_callbk_fns)
115 return;
116
117 if (wifi_if_ctx_rtos->supp_called_remain_on_chan == true)
118 {
119 if ((msg->reason == WIFI_EVENT_REASON_SUCCESS) &&
120 (wm_wifi.supp_if_callbk_fns->remain_on_channel_callbk_fn != NULL))
121 {
122 if (*(t_u8 *)(msg->data) == true)
123 {
124 wm_wifi.supp_if_callbk_fns->remain_on_channel_callbk_fn(wifi_if_ctx_rtos, 1);
125 }
126 else
127 {
128 wm_wifi.supp_if_callbk_fns->remain_on_channel_callbk_fn(wifi_if_ctx_rtos, 0);
129 }
130 }
131 wifi_if_ctx_rtos->supp_called_remain_on_chan = false;
132 }
133 if (msg->data)
134 {
135 OSA_MemoryFree(msg->data);
136 msg->data = NULL;
137 }
138 }
139
wifi_process_mgmt_tx_status(struct wifi_message * msg)140 void wifi_process_mgmt_tx_status(struct wifi_message *msg)
141 {
142 nxp_wifi_event_mlme_t *resp = &wm_wifi.mgmt_resp;
143 resp->frame.frame_len = 0;
144
145 if (msg->reason == WIFI_EVENT_REASON_SUCCESS)
146 {
147 if (wm_wifi.supp_if_callbk_fns->mgmt_tx_status_callbk_fn)
148 {
149 if ((t_u32)(msg->data) == MLAN_BSS_TYPE_UAP)
150 {
151 wm_wifi.supp_if_callbk_fns->mgmt_tx_status_callbk_fn(wm_wifi.hapd_if_priv, resp, resp->frame.frame_len);
152 }
153 else
154 {
155 wm_wifi.supp_if_callbk_fns->mgmt_tx_status_callbk_fn(wm_wifi.if_priv, resp, resp->frame.frame_len);
156 }
157 }
158 }
159 }
160
wifi_setup_ht_cap(t_u16 * ht_capab,t_u8 * pmcs_set,t_u8 * a_mpdu_params,t_u8 band)161 int wifi_setup_ht_cap(t_u16 *ht_capab, t_u8 *pmcs_set, t_u8 *a_mpdu_params, t_u8 band)
162 {
163 mlan_adapter *pmadapter = (mlan_adapter *)mlan_adap;
164 t_u32 usr_dot_11n_dev_cap;
165 int rx_mcs_supp;
166 t_u8 mcs_set[NUM_MCS_FIELD];
167
168 ENTER();
169
170 *ht_capab = HT_CAP_INFO_DSSS_CCK40MHZ;
171
172 *a_mpdu_params = 3;
173
174 #if CONFIG_5GHz_SUPPORT
175 if (band == BAND_5GHZ)
176 {
177 usr_dot_11n_dev_cap = pmadapter->usr_dot_11n_dev_cap_a;
178 }
179 else
180 #endif
181 {
182 usr_dot_11n_dev_cap = pmadapter->usr_dot_11n_dev_cap_bg;
183 }
184
185 if (ISSUPP_RXLDPC(usr_dot_11n_dev_cap))
186 {
187 *ht_capab |= HT_CAP_INFO_LDPC_CODING_CAP;
188 }
189 if (ISSUPP_CHANWIDTH40(usr_dot_11n_dev_cap))
190 {
191 *ht_capab |= HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET;
192 }
193 else
194 {
195 *ht_capab &= ~(HT_CAP_INFO_DSSS_CCK40MHZ);
196 }
197 if ((usr_dot_11n_dev_cap >> 20) & 0x03) /* Delayed ACK supported */
198 {
199 *ht_capab |= HT_CAP_INFO_DELAYED_BA;
200 }
201 if (ISSUPP_GREENFIELD(usr_dot_11n_dev_cap))
202 {
203 *ht_capab |= HT_CAP_INFO_GREEN_FIELD;
204 }
205 if (ISSUPP_SHORTGI20(usr_dot_11n_dev_cap))
206 {
207 *ht_capab |= HT_CAP_INFO_SHORT_GI20MHZ;
208 }
209 if (ISSUPP_SHORTGI40(usr_dot_11n_dev_cap))
210 {
211 *ht_capab |= HT_CAP_INFO_SHORT_GI40MHZ;
212 }
213 if (ISSUPP_TXSTBC(usr_dot_11n_dev_cap))
214 {
215 *ht_capab |= HT_CAP_INFO_TX_STBC;
216 }
217 if (ISSUPP_RXSTBC(usr_dot_11n_dev_cap))
218 {
219 *ht_capab |= HT_CAP_INFO_RX_STBC_1;
220 }
221 if (ISSUPP_MIMOPS(usr_dot_11n_dev_cap))
222 {
223 *ht_capab |= HT_CAP_INFO_SMPS_STATIC;
224 }
225 else
226 {
227 *ht_capab |= HT_CAP_INFO_SMPS_DISABLED;
228 }
229 if (ISSUPP_MAXAMSDU(usr_dot_11n_dev_cap))
230 {
231 *ht_capab |= HT_CAP_INFO_MAX_AMSDU_SIZE;
232 }
233 if (ISENABLED_40MHZ_INTOLARENT(usr_dot_11n_dev_cap))
234 {
235 *ht_capab |= HT_CAP_INFO_40MHZ_INTOLERANT;
236 }
237
238 rx_mcs_supp = GET_RXMCSSUPP(pmadapter->usr_dev_mcs_support);
239 /* Set MCS for 1x1/2x2 */
240 memset((t_u8 *)mcs_set, 0xff, rx_mcs_supp);
241 /* Clear all the other values */
242 memset((t_u8 *)&mcs_set[rx_mcs_supp], 0, NUM_MCS_FIELD - rx_mcs_supp);
243 /* Set MCS32 with 40MHz support */
244 if (ISSUPP_CHANWIDTH40(usr_dot_11n_dev_cap))
245 SETHT_MCS32(mcs_set);
246
247 memcpy(pmcs_set, mcs_set, NUM_MCS_FIELD);
248
249 LEAVE();
250
251 return WM_SUCCESS;
252 }
253
wifi_setup_channel_flag(void * channels,int num_chan,region_chan_t * region,t_u8 band)254 static void wifi_setup_channel_flag(void *channels, int num_chan, region_chan_t *region, t_u8 band)
255 {
256 int i;
257 int set_idx = 0;
258 int get_idx = 0;
259 const chan_freq_power_t *pchans_get = region->pcfp;
260 struct wifi_nxp_event_channel *pchans_set = (struct wifi_nxp_event_channel *)channels;
261
262 for (i = 0; i < MAX(num_chan, region->num_cfp); i++)
263 {
264 if (set_idx >= num_chan)
265 break;
266
267 if (get_idx >= region->num_cfp)
268 {
269 pchans_set[set_idx].wifi_nxp_flags |= WIFI_NXP_CHAN_FLAG_FREQUENCY_DISABLED;
270
271 set_idx++;
272 }
273 else
274 {
275 pchans_set[set_idx].center_frequency = pchans_get[get_idx].freq;
276 pchans_set[set_idx].ch_valid = 1;
277 pchans_set[set_idx].wifi_nxp_max_power = pchans_get[get_idx].max_tx_power;
278 pchans_set[set_idx].wifi_nxp_flags &= (~WIFI_NXP_CHAN_FLAG_FREQUENCY_DISABLED);
279
280 if (band == BAND_2GHZ)
281 {
282 pchans_set[set_idx].wifi_nxp_flags |= WIFI_NXP_CHAN_FLAG_FREQUENCY_ATTR_NO_80MHZ;
283 }
284
285 pchans_set[set_idx].wifi_nxp_flags |= WIFI_NXP_CHAN_FLAG_FREQUENCY_ATTR_NO_160MHZ;
286
287 /* set passive scan or radar detect flag */
288 if (pchans_get[get_idx].passive_scan_or_radar_detect == MTRUE)
289 {
290 pchans_set[set_idx].wifi_nxp_flags |= WIFI_NXP_CHAN_FLAG_FREQUENCY_ATTR_RADAR;
291 pchans_set[set_idx].wifi_nxp_flags |= WIFI_NXP_CHAN_DFS_VALID;
292 }
293
294 set_idx++;
295 get_idx++;
296 }
297 }
298 }
299
wifi_setup_channel_info(void * channels,int num_channels,t_u8 band)300 void wifi_setup_channel_info(void *channels, int num_channels, t_u8 band)
301 {
302 mlan_adapter *pmadapter = (mlan_adapter *)mlan_adap;
303 region_chan_t *region = NULL;
304
305 if (band == BAND_2GHZ)
306 {
307 if (pmadapter->region_channel[0].valid)
308 region = &pmadapter->region_channel[0];
309 else if (pmadapter->universal_channel[0].valid)
310 region = &pmadapter->universal_channel[0];
311 else
312 return;
313
314 wifi_setup_channel_flag(channels, num_channels, region, band);
315 }
316 else if (band == BAND_5GHZ)
317 {
318 if (pmadapter->region_channel[1].valid)
319 region = &pmadapter->region_channel[1];
320 else if (pmadapter->universal_channel[1].valid)
321 region = &pmadapter->universal_channel[1];
322 else
323 return;
324
325 wifi_setup_channel_flag(channels, num_channels, region, band);
326 }
327 else
328 {
329 wuap_e("wifi_setup_channel_info unsupported band %d", band);
330 }
331 }
332
333 #if CONFIG_11AC
wifi_setup_vht_cap(t_u32 * vht_capab,t_u8 * vht_mcs_set,t_u8 band)334 int wifi_setup_vht_cap(t_u32 *vht_capab, t_u8 *vht_mcs_set, t_u8 band)
335 {
336 mlan_adapter *pmadapter = (mlan_adapter *)mlan_adap;
337 t_u16 vht_tx_mcs, vht_rx_mcs;
338
339 ENTER();
340
341 *vht_capab = pmadapter->usr_dot_11ac_dev_cap_a;
342
343 *vht_capab &= ~DEFALUT_11AC_CAP_BEAMFORMING_RESET_MASK;
344 #ifdef RW610
345 *vht_capab &= ~DEFALUT_11AC_CAP_SHORTGI_80MHZ_RESET_MASK;
346 #endif
347
348 if ((GET_VHTCAP_MAXMPDULEN(*vht_capab)) != 0U)
349 {
350 RESET_11ACMAXMPDULEN(*vht_capab);
351 }
352 else
353 {
354 /** Do Nothing */
355 }
356
357 vht_tx_mcs = pmadapter->usr_dot_11ac_mcs_support >> 16;
358 vht_rx_mcs = pmadapter->usr_dot_11ac_mcs_support & 0xffff;
359
360 memcpy(&vht_mcs_set[0], &vht_rx_mcs, sizeof(t_u16));
361
362 memcpy(&vht_mcs_set[4], &vht_tx_mcs, sizeof(t_u16));
363
364 LEAVE();
365
366 return WM_SUCCESS;
367 }
368 #endif
369
370 #if CONFIG_11AX
371 /*
372 ===============
373 11AX CAP for uAP
374 ===============
375 Note: bits not mentioned below are set to 0.
376
377 5G
378 ===
379 HE MAC Cap:
380 Bit0: 1 (+HTC HE Support)
381 Bit25: 1 (OM Control Support. But uAP does not support
382 Tx OM received from the STA, as it does not support UL OFDMA)
383
384 HE PHY Cap:
385 Bit1-7: 0x2 (Supported Channel Width Set.
386 Note it would be changed after 80+80 MHz is supported)
387 Bit8-11: 0x3 (Punctured Preamble Rx.
388 Note: it would be changed after 80+80 MHz is supported)
389 Bit12: 0x0 (Device Class)
390 Bit13: 0x1 (LDPC coding in Payload)
391 Bit17: 0x1 (NDP with 4xHE-LTF+3.2usGI)
392 Bit18: 0x1 (STBC Tx <= 80 MHz)
393 Bit19: 0x1 (STBC Rx <= 80 MHz)
394 Bit20: 0x1 (Doppler Tx)
395 Bit21: 0x1 (Doppler Rx)
396 Bit24-25: 0x1 (DCM Max Constellation Tx)
397 Bit27-28: 0x1 (DCM Max Constellation Rx)
398 Bit31: 0x1 (SU Beamformer)
399 Bit32: 0x1 (SU BeamFormee)
400 Bit34-36: 0x7 (Beamformee STS <= 80 MHz)
401 Bit40-42: 0x1 (Number of Sounding Dimentions <= 80 MHz)
402 Bit53: 0x1 (Partial Bandwidth Extended Range)
403 Bit55: 0x1 (PPE Threshold Present.
404 Note: PPE threshold may have some changes later)
405 Bit58: 0x1 (HE SU PPDU and HE MU PPDU with 4xHE-LTF+0.8usGI)
406 Bit59-61: 0x1 (Max Nc)
407 Bit64: 0x1 (HE ER SU PPDU with 4xHE-LTF+0.8usGI)
408 Bit75: 0x1 (Rx 1024-QAM Support < 242-tone RU)
409 */
410
411 #define UAP_HE_MAC_CAP0_MASK 0x04
412 #define UAP_HE_MAC_CAP1_MASK 0x00
413 #define UAP_HE_MAC_CAP2_MASK 0x10
414 #define UAP_HE_MAC_CAP3_MASK 0x02
415 #define UAP_HE_MAC_CAP4_MASK 0x00
416 #define UAP_HE_MAC_CAP5_MASK 0x00
417 #define UAP_HE_PHY_CAP0_MASK 0x04
418 #define UAP_HE_PHY_CAP1_MASK 0x23
419 #define UAP_HE_PHY_CAP2_MASK 0x3E
420 #define UAP_HE_PHY_CAP3_MASK 0x89
421 #define UAP_HE_PHY_CAP4_MASK 0x1D
422 #define UAP_HE_PHY_CAP5_MASK 0x01
423 #define UAP_HE_PHY_CAP6_MASK 0xA0
424 #define UAP_HE_PHY_CAP7_MASK 0x0C
425 #define UAP_HE_PHY_CAP8_MASK 0x01
426 #define UAP_HE_PHY_CAP9_MASK 0x08
427 #define UAP_HE_PHY_CAP10_MASK 0x00
428
429 /*
430 2G
431 ===
432 HE MAC Cap:
433 Bit0: 1 (+HTC HE Support)
434 Bit25: 1 (OM Control Support. Note: uAP does not support
435 Tx OM received from the STA, as it does not support UL OFDMA)
436
437 HE PHY Cap:
438 Bit1-7: 0x1 (Supported Channel Width Set)
439 Bit8-11: 0x0 (Punctured Preamble Rx)
440 Bit12: 0x0 (Device Class)
441 Bit13: 0x1 (LDPC coding in Payload)
442 Bit17: 0x1 (NDP with 4xLTF+3.2usGI)
443 Bit18: 0x1 (STBC Tx <= 80 MHz)
444 Bit19: 0x1 (STBC Rx <= 80 MHz)
445 Bit20: 0x1 (Doppler Tx)
446 Bit21: 0x1 (Doppler Rx)
447 Bit24-25: 0x1 (DCM Max Constellation Tx)
448 Bit27-28: 0x1 (DCM Max Constellation Rx)
449 Bit31: 0x1 (SU Beamformer)
450 Bit32: 0x1 (SU BeamFormee)
451 Bit34-36: 0x7 (Beamformee STS <= 80 MHz)
452 Bit40-42: 0x1 (Number of Sounding Dimentions <= 80 MHz)
453 Bit53: 0x1 (Partial Bandwidth Extended Range)
454 Bit55: 0x1 (PPE Threshold Present.
455 Note: PPE threshold may have some changes later)
456 Bit58: 0x1 (HE SU PPDU and HE MU PPDU with 4xHE-LTF+0.8usGI)
457 Bit59-61: 0x1 (Max Nc)
458 Bit64: 0x1 (HE ER SU PPDU with 4xHE-LTF+0.8usGI)
459 Bit75: 0x1 (Rx 1024-QAM Support < 242-tone RU)
460 */
461 #define UAP_HE_2G_MAC_CAP0_MASK 0x04
462 #define UAP_HE_2G_MAC_CAP1_MASK 0x00
463 #define UAP_HE_2G_MAC_CAP2_MASK 0x10
464 #define UAP_HE_2G_MAC_CAP3_MASK 0x02
465 #define UAP_HE_2G_MAC_CAP4_MASK 0x00
466 #define UAP_HE_2G_MAC_CAP5_MASK 0x00
467 #define UAP_HE_2G_PHY_CAP0_MASK 0x02
468 #define UAP_HE_2G_PHY_CAP1_MASK 0x20
469 #define UAP_HE_2G_PHY_CAP2_MASK 0x3E
470 #define UAP_HE_2G_PHY_CAP3_MASK 0x89
471 #define UAP_HE_2G_PHY_CAP4_MASK 0x1D
472 #define UAP_HE_2G_PHY_CAP5_MASK 0x01
473 #define UAP_HE_2G_PHY_CAP6_MASK 0xA0
474 #define UAP_HE_2G_PHY_CAP7_MASK 0x0C
475 #define UAP_HE_2G_PHY_CAP8_MASK 0x01
476 #define UAP_HE_2G_PHY_CAP9_MASK 0x08
477 #define UAP_HE_2G_PHY_CAP10_MASK 0x00
478
479 /**
480 * @brief update 11ax ie for AP mode *
481 * @param band channel band
482 * @hecap_ie a pointer to mlan_ds_11ax_he_capa
483 *
484 * @return 0--success, otherwise failure
485 */
wifi_uap_update_11ax_ie(t_u8 band,mlan_ds_11ax_he_capa * hecap_ie)486 static void wifi_uap_update_11ax_ie(t_u8 band, mlan_ds_11ax_he_capa *hecap_ie)
487 {
488 if (band == BAND_5GHZ
489 #ifdef ENABLE_802_116E
490 || band == BAND_6GHZ
491 #endif
492 )
493 {
494 hecap_ie->he_mac_cap[0] &= UAP_HE_MAC_CAP0_MASK;
495 hecap_ie->he_mac_cap[1] &= UAP_HE_MAC_CAP1_MASK;
496 hecap_ie->he_mac_cap[2] &= UAP_HE_MAC_CAP2_MASK;
497 hecap_ie->he_mac_cap[3] &= UAP_HE_MAC_CAP3_MASK;
498 hecap_ie->he_mac_cap[4] &= UAP_HE_MAC_CAP4_MASK;
499 hecap_ie->he_mac_cap[5] &= UAP_HE_MAC_CAP5_MASK;
500 hecap_ie->he_phy_cap[0] &= UAP_HE_PHY_CAP0_MASK;
501 hecap_ie->he_phy_cap[1] &= UAP_HE_PHY_CAP1_MASK;
502 hecap_ie->he_phy_cap[2] &= UAP_HE_PHY_CAP2_MASK;
503 hecap_ie->he_phy_cap[3] &= UAP_HE_PHY_CAP3_MASK;
504 hecap_ie->he_phy_cap[4] &= UAP_HE_PHY_CAP4_MASK;
505 hecap_ie->he_phy_cap[5] &= UAP_HE_PHY_CAP5_MASK;
506 hecap_ie->he_phy_cap[6] &= UAP_HE_PHY_CAP6_MASK;
507 hecap_ie->he_phy_cap[7] &= UAP_HE_PHY_CAP7_MASK;
508 hecap_ie->he_phy_cap[8] &= UAP_HE_PHY_CAP8_MASK;
509 hecap_ie->he_phy_cap[9] &= UAP_HE_PHY_CAP9_MASK;
510 hecap_ie->he_phy_cap[10] &= UAP_HE_PHY_CAP10_MASK;
511 }
512 else
513 {
514 hecap_ie->he_mac_cap[0] &= UAP_HE_2G_MAC_CAP0_MASK;
515 hecap_ie->he_mac_cap[1] &= UAP_HE_2G_MAC_CAP1_MASK;
516 hecap_ie->he_mac_cap[2] &= UAP_HE_2G_MAC_CAP2_MASK;
517 hecap_ie->he_mac_cap[3] &= UAP_HE_2G_MAC_CAP3_MASK;
518 hecap_ie->he_mac_cap[4] &= UAP_HE_2G_MAC_CAP4_MASK;
519 hecap_ie->he_mac_cap[5] &= UAP_HE_2G_MAC_CAP5_MASK;
520 hecap_ie->he_phy_cap[0] &= UAP_HE_2G_PHY_CAP0_MASK;
521 hecap_ie->he_phy_cap[1] &= UAP_HE_2G_PHY_CAP1_MASK;
522 hecap_ie->he_phy_cap[2] &= UAP_HE_2G_PHY_CAP2_MASK;
523 hecap_ie->he_phy_cap[3] &= UAP_HE_2G_PHY_CAP3_MASK;
524 hecap_ie->he_phy_cap[4] &= UAP_HE_2G_PHY_CAP4_MASK;
525 hecap_ie->he_phy_cap[5] &= UAP_HE_2G_PHY_CAP5_MASK;
526 hecap_ie->he_phy_cap[6] &= UAP_HE_2G_PHY_CAP6_MASK;
527 hecap_ie->he_phy_cap[7] &= UAP_HE_2G_PHY_CAP7_MASK;
528 hecap_ie->he_phy_cap[8] &= UAP_HE_2G_PHY_CAP8_MASK;
529 hecap_ie->he_phy_cap[9] &= UAP_HE_2G_PHY_CAP9_MASK;
530 hecap_ie->he_phy_cap[10] &= UAP_HE_2G_PHY_CAP10_MASK;
531 }
532 return;
533 }
534
535 /**
536 * @brief Sets up the CFG802.11 specific HE capability fields * with default
537 * values
538 *
539 * @param priv A pointer to moal private structure
540 * @param iftype_data A pointer to ieee80211_sband_iftype_data structure
541 *
542 * @return N/A
543 */
wifi_setup_he_cap(nxp_wifi_he_capabilities * he_cap,t_u8 band)544 int wifi_setup_he_cap(nxp_wifi_he_capabilities *he_cap, t_u8 band)
545 {
546 mlan_private *priv = (mlan_private *)mlan_adap->priv[0];
547 mlan_fw_info fw_info;
548 t_u8 extra_mcs_size = 0;
549 int ppe_threshold_len = 0;
550 mlan_ds_11ax_he_capa *phe_cap = NULL;
551 t_u8 hw_hecap_len = 0;
552
553 memset(&fw_info, 0, sizeof(mlan_fw_info));
554
555 wifi_request_get_fw_info(priv, &fw_info);
556
557 #if CONFIG_5GHz_SUPPORT
558 if (band == BAND_5GHZ)
559 {
560 phe_cap = (mlan_ds_11ax_he_capa *)fw_info.hw_he_cap;
561 hw_hecap_len = fw_info.hw_hecap_len;
562 wifi_uap_update_11ax_ie(BAND_5GHZ, phe_cap);
563 }
564 else
565 #endif
566 #ifdef ENABLE_802_116E
567 if (band == BAND_6GHZ)
568 {
569 phe_cap = (mlan_ds_11ax_he_capa *)fw_info.hw_he_cap;
570 hw_hecap_len = fw_info.hw_hecap_len;
571 wifi_uap_update_11ax_ie(BAND_6GHZ, phe_cap);
572 }
573 else
574 #endif
575 {
576 phe_cap = (mlan_ds_11ax_he_capa *)fw_info.hw_2g_he_cap;
577 hw_hecap_len = fw_info.hw_2g_hecap_len;
578 wifi_uap_update_11ax_ie(BAND_2GHZ, phe_cap);
579 }
580
581 if (!hw_hecap_len)
582 return -WM_FAIL;
583
584 he_cap->he_supported = 1;
585 memcpy(he_cap->mac_cap, phe_cap->he_mac_cap, sizeof(phe_cap->he_mac_cap));
586 memcpy(he_cap->phy_cap, phe_cap->he_phy_cap, sizeof(phe_cap->he_phy_cap));
587 memset(&he_cap->mcs, 0xff, WIFI_HE_MAX_MCS_CAPAB_SIZE);
588 memcpy(&he_cap->mcs, phe_cap->he_txrx_mcs_support, sizeof(phe_cap->he_txrx_mcs_support));
589
590 // Support 160Mhz
591 if (phe_cap->he_phy_cap[0] & MBIT(3))
592 extra_mcs_size += 4;
593
594 // Support 80+80
595 if (phe_cap->he_phy_cap[0] & MBIT(4))
596 extra_mcs_size += 4;
597 if (extra_mcs_size)
598 memcpy((t_u8 *)&he_cap->mcs + sizeof(phe_cap->he_txrx_mcs_support), phe_cap->val, extra_mcs_size);
599
600 #define HE_CAP_FIX_SIZE 22
601 // Support PPE threshold
602 ppe_threshold_len = phe_cap->len - HE_CAP_FIX_SIZE - extra_mcs_size;
603 if (phe_cap->he_phy_cap[6] & MBIT(7) && ppe_threshold_len)
604 {
605 memcpy(he_cap->ppet, &phe_cap->val[extra_mcs_size], ppe_threshold_len);
606 }
607 else
608 {
609 he_cap->phy_cap[6] &= ~MBIT(7);
610 wifi_d("Clear PPE threshold 0x%x\r\n", he_cap->phy_cap[7]);
611 }
612 #ifdef ENABLE_802_116E
613 if (band->band == BAND_6GHZ)
614 iftype_data->he_6ghz_capa.capa = fw_info.hw_he_6g_cap;
615 #endif
616 LEAVE();
617
618 return WM_SUCCESS;
619 }
620 #endif
621
wifi_get_bandwidth()622 int wifi_get_bandwidth()
623 {
624 #if UAP_SUPPORT
625 return wifi_uap_get_bandwidth();
626 #else
627 return BANDWIDTH_20MHZ;
628 #endif
629 }
630 #endif /* CONFIG_WPA_SUPP */
631