1 // SPDX-License-Identifier: GPL-2.0
2 /******************************************************************************
4 * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
6 ******************************************************************************/
7 #define _RTW_IOCTL_SET_C_
9 #include <osdep_service.h>
10 #include <drv_types.h>
11 #include <rtw_ioctl_set.h>
14 extern void indicate_wx_scan_complete_event(struct adapter *padapter);
16 u8 rtw_do_join(struct adapter *padapter)
18 struct list_head *plist, *phead;
20 struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
21 struct __queue *queue = &(pmlmepriv->scanned_queue);
24 spin_lock_bh(&(pmlmepriv->scanned_queue.lock));
25 phead = get_list_head(queue);
28 RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("\n rtw_do_join: phead = %p; plist = %p\n\n\n", phead, plist));
30 pmlmepriv->cur_network.join_res = -2;
32 set_fwstate(pmlmepriv, _FW_UNDER_LINKING);
34 pmlmepriv->pscanned = plist;
36 pmlmepriv->to_join = true;
38 if (list_empty(&queue->queue)) {
39 spin_unlock_bh(&(pmlmepriv->scanned_queue.lock));
40 _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING);
42 /* when set_ssid/set_bssid for rtw_do_join(), but scanning queue is empty */
43 /* we try to issue sitesurvey firstly */
45 if (!pmlmepriv->LinkDetectInfo.bBusyTraffic ||
46 pmlmepriv->to_roaming > 0) {
47 RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("rtw_do_join(): site survey if scanned_queue is empty\n."));
48 /* submit site_survey_cmd */
49 ret = rtw_sitesurvey_cmd(padapter, &pmlmepriv->assoc_ssid, 1, NULL, 0);
50 if (ret != _SUCCESS) {
51 pmlmepriv->to_join = false;
52 RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("rtw_do_join(): site survey return error\n."));
55 pmlmepriv->to_join = false;
63 spin_unlock_bh(&(pmlmepriv->scanned_queue.lock));
64 select_ret = rtw_select_and_join_from_scanned_queue(pmlmepriv);
65 if (select_ret == _SUCCESS) {
66 pmlmepriv->to_join = false;
67 mod_timer(&pmlmepriv->assoc_timer,
68 jiffies + msecs_to_jiffies(MAX_JOIN_TIMEOUT));
70 if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true) {
71 /* submit createbss_cmd to change to a ADHOC_MASTER */
73 /* pmlmepriv->lock has been acquired by caller... */
74 struct wlan_bssid_ex *pdev_network = &(padapter->registrypriv.dev_network);
76 pmlmepriv->fw_state = WIFI_ADHOC_MASTER_STATE;
78 pibss = padapter->registrypriv.dev_network.MacAddress;
80 memcpy(&pdev_network->Ssid, &pmlmepriv->assoc_ssid, sizeof(struct ndis_802_11_ssid));
82 rtw_update_registrypriv_dev_network(padapter);
84 rtw_generate_random_ibss(pibss);
86 if (rtw_createbss_cmd(padapter) != _SUCCESS) {
87 RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("***Error =>do_goin: rtw_createbss_cmd status FAIL***\n "));
91 pmlmepriv->to_join = false;
93 RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_,
94 ("***Error => rtw_select_and_join_from_scanned_queue FAIL under STA_Mode***\n "));
96 /* can't associate ; reset under-linking */
97 _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING);
99 /* when set_ssid/set_bssid for rtw_do_join(), but there are no desired bss in scanning queue */
100 /* we try to issue sitesurvey firstly */
101 if (!pmlmepriv->LinkDetectInfo.bBusyTraffic ||
102 pmlmepriv->to_roaming > 0) {
103 ret = rtw_sitesurvey_cmd(padapter, &pmlmepriv->assoc_ssid, 1, NULL, 0);
104 if (ret != _SUCCESS) {
105 pmlmepriv->to_join = false;
106 RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("do_join(): site survey return error\n."));
110 pmlmepriv->to_join = false;
120 u8 rtw_set_802_11_bssid(struct adapter *padapter, u8 *bssid)
122 u8 status = _SUCCESS;
124 struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
126 DBG_88E_LEVEL(_drv_info_, "set bssid:%pM\n", bssid);
128 if ((bssid[0] == 0x00 && bssid[1] == 0x00 && bssid[2] == 0x00 &&
129 bssid[3] == 0x00 && bssid[4] == 0x00 && bssid[5] == 0x00) ||
130 (bssid[0] == 0xFF && bssid[1] == 0xFF && bssid[2] == 0xFF &&
131 bssid[3] == 0xFF && bssid[4] == 0xFF && bssid[5] == 0xFF)) {
136 spin_lock_bh(&pmlmepriv->lock);
138 DBG_88E("Set BSSID under fw_state = 0x%08x\n", get_fwstate(pmlmepriv));
139 if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) == true)
140 goto handle_tkip_countermeasure;
141 else if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING))
142 goto release_mlme_lock;
144 if (check_fwstate(pmlmepriv, _FW_LINKED|WIFI_ADHOC_MASTER_STATE)) {
145 RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("set_bssid: _FW_LINKED||WIFI_ADHOC_MASTER_STATE\n"));
147 if (!memcmp(&pmlmepriv->cur_network.network.MacAddress, bssid, ETH_ALEN)) {
148 if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == false)
149 goto release_mlme_lock;/* it means driver is in WIFI_ADHOC_MASTER_STATE, we needn't create bss again. */
151 RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("Set BSSID not the same bssid\n"));
152 RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("set_bssid =%pM\n", (bssid)));
153 RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("cur_bssid =%pM\n", (pmlmepriv->cur_network.network.MacAddress)));
155 rtw_disassoc_cmd(padapter, 0, true);
157 if (check_fwstate(pmlmepriv, _FW_LINKED) == true)
158 rtw_indicate_disconnect(padapter);
160 rtw_free_assoc_resources(padapter);
162 if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true)) {
163 _clr_fwstate_(pmlmepriv, WIFI_ADHOC_MASTER_STATE);
164 set_fwstate(pmlmepriv, WIFI_ADHOC_STATE);
169 handle_tkip_countermeasure:
170 /* should we add something here...? */
172 if (padapter->securitypriv.btkip_countermeasure) {
175 if ((cur_time - padapter->securitypriv.btkip_countermeasure_time) > 60 * HZ) {
176 padapter->securitypriv.btkip_countermeasure = false;
177 padapter->securitypriv.btkip_countermeasure_time = 0;
180 goto release_mlme_lock;
184 memcpy(&pmlmepriv->assoc_bssid, bssid, ETH_ALEN);
185 pmlmepriv->assoc_by_bssid = true;
187 if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY))
188 pmlmepriv->to_join = true;
190 status = rtw_do_join(padapter);
193 spin_unlock_bh(&pmlmepriv->lock);
196 RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_,
197 ("%s: status=%d\n", __func__, status));
202 u8 rtw_set_802_11_ssid(struct adapter *padapter, struct ndis_802_11_ssid *ssid)
204 u8 status = _SUCCESS;
207 struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
208 struct wlan_network *pnetwork = &pmlmepriv->cur_network;
210 DBG_88E_LEVEL(_drv_info_, "set ssid [%s] fw_state=0x%08x\n",
211 ssid->Ssid, get_fwstate(pmlmepriv));
213 if (!padapter->hw_init_completed) {
214 RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_,
215 ("set_ssid: hw_init_completed == false =>exit!!!\n"));
220 spin_lock_bh(&pmlmepriv->lock);
222 DBG_88E("Set SSID under fw_state = 0x%08x\n", get_fwstate(pmlmepriv));
223 if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) == true)
224 goto handle_tkip_countermeasure;
225 else if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING) == true)
226 goto release_mlme_lock;
228 if (check_fwstate(pmlmepriv, _FW_LINKED|WIFI_ADHOC_MASTER_STATE)) {
229 RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_,
230 ("set_ssid: _FW_LINKED||WIFI_ADHOC_MASTER_STATE\n"));
232 if ((pmlmepriv->assoc_ssid.SsidLength == ssid->SsidLength) &&
233 (!memcmp(&pmlmepriv->assoc_ssid.Ssid, ssid->Ssid, ssid->SsidLength))) {
234 if ((check_fwstate(pmlmepriv, WIFI_STATION_STATE) == false)) {
235 RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_,
236 ("Set SSID is the same ssid, fw_state = 0x%08x\n",
237 get_fwstate(pmlmepriv)));
239 if (!rtw_is_same_ibss(padapter, pnetwork)) {
240 /* if in WIFI_ADHOC_MASTER_STATE | WIFI_ADHOC_STATE, create bss or rejoin again */
241 rtw_disassoc_cmd(padapter, 0, true);
243 if (check_fwstate(pmlmepriv, _FW_LINKED) == true)
244 rtw_indicate_disconnect(padapter);
246 rtw_free_assoc_resources(padapter);
248 if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true) {
249 _clr_fwstate_(pmlmepriv, WIFI_ADHOC_MASTER_STATE);
250 set_fwstate(pmlmepriv, WIFI_ADHOC_STATE);
253 goto release_mlme_lock;/* it means driver is in WIFI_ADHOC_MASTER_STATE, we needn't create bss again. */
256 rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_JOINBSS, 1);
259 RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("Set SSID not the same ssid\n"));
260 RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("set_ssid =[%s] len = 0x%x\n", ssid->Ssid, (unsigned int)ssid->SsidLength));
261 RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("assoc_ssid =[%s] len = 0x%x\n", pmlmepriv->assoc_ssid.Ssid, (unsigned int)pmlmepriv->assoc_ssid.SsidLength));
263 rtw_disassoc_cmd(padapter, 0, true);
265 if (check_fwstate(pmlmepriv, _FW_LINKED) == true)
266 rtw_indicate_disconnect(padapter);
268 rtw_free_assoc_resources(padapter);
270 if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true) {
271 _clr_fwstate_(pmlmepriv, WIFI_ADHOC_MASTER_STATE);
272 set_fwstate(pmlmepriv, WIFI_ADHOC_STATE);
277 handle_tkip_countermeasure:
279 if (padapter->securitypriv.btkip_countermeasure) {
282 if ((cur_time - padapter->securitypriv.btkip_countermeasure_time) > 60 * HZ) {
283 padapter->securitypriv.btkip_countermeasure = false;
284 padapter->securitypriv.btkip_countermeasure_time = 0;
287 goto release_mlme_lock;
291 memcpy(&pmlmepriv->assoc_ssid, ssid, sizeof(struct ndis_802_11_ssid));
292 pmlmepriv->assoc_by_bssid = false;
294 if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) == true)
295 pmlmepriv->to_join = true;
297 status = rtw_do_join(padapter);
300 spin_unlock_bh(&pmlmepriv->lock);
303 RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_,
304 ("-%s: status =%d\n", __func__, status));
308 u8 rtw_set_802_11_infrastructure_mode(struct adapter *padapter,
309 enum ndis_802_11_network_infra networktype)
311 struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
312 struct wlan_network *cur_network = &pmlmepriv->cur_network;
313 enum ndis_802_11_network_infra *pold_state = &(cur_network->network.InfrastructureMode);
315 RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_notice_,
316 ("+rtw_set_802_11_infrastructure_mode: old =%d new =%d fw_state = 0x%08x\n",
317 *pold_state, networktype, get_fwstate(pmlmepriv)));
319 if (*pold_state != networktype) {
320 spin_lock_bh(&pmlmepriv->lock);
322 RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, (" change mode!"));
323 /* DBG_88E("change mode, old_mode =%d, new_mode =%d, fw_state = 0x%x\n", *pold_state, networktype, get_fwstate(pmlmepriv)); */
325 if (*pold_state == Ndis802_11APMode) {
326 /* change to other mode from Ndis802_11APMode */
327 cur_network->join_res = -1;
329 #ifdef CONFIG_88EU_AP_MODE
330 stop_ap_mode(padapter);
334 if ((check_fwstate(pmlmepriv, _FW_LINKED)) ||
335 (*pold_state == Ndis802_11IBSS))
336 rtw_disassoc_cmd(padapter, 0, true);
338 if ((check_fwstate(pmlmepriv, _FW_LINKED)) ||
339 (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)))
340 rtw_free_assoc_resources(padapter);
342 if ((*pold_state == Ndis802_11Infrastructure) || (*pold_state == Ndis802_11IBSS)) {
343 if (check_fwstate(pmlmepriv, _FW_LINKED) == true)
344 rtw_indicate_disconnect(padapter); /* will clr Linked_state; before this function, we must have checked whether issue dis-assoc_cmd or not */
347 *pold_state = networktype;
349 _clr_fwstate_(pmlmepriv, ~WIFI_NULL_STATE);
351 switch (networktype) {
353 set_fwstate(pmlmepriv, WIFI_ADHOC_STATE);
355 case Ndis802_11Infrastructure:
356 set_fwstate(pmlmepriv, WIFI_STATION_STATE);
358 case Ndis802_11APMode:
359 set_fwstate(pmlmepriv, WIFI_AP_STATE);
360 #ifdef CONFIG_88EU_AP_MODE
361 start_ap_mode(padapter);
364 case Ndis802_11AutoUnknown:
365 case Ndis802_11InfrastructureMax:
368 spin_unlock_bh(&pmlmepriv->lock);
374 u8 rtw_set_802_11_disassociate(struct adapter *padapter)
376 struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
378 spin_lock_bh(&pmlmepriv->lock);
380 if (check_fwstate(pmlmepriv, _FW_LINKED)) {
381 RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_,
382 ("MgntActrtw_set_802_11_disassociate: rtw_indicate_disconnect\n"));
384 rtw_disassoc_cmd(padapter, 0, true);
385 rtw_indicate_disconnect(padapter);
386 rtw_free_assoc_resources(padapter);
387 rtw_pwr_wakeup(padapter);
390 spin_unlock_bh(&pmlmepriv->lock);
395 u8 rtw_set_802_11_bssid_list_scan(struct adapter *padapter, struct ndis_802_11_ssid *pssid, int ssid_max_num)
397 struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
400 RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("+%s(), fw_state =%x\n", __func__, get_fwstate(pmlmepriv)));
406 if (!padapter->hw_init_completed) {
408 RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("\n === %s:hw_init_completed == false ===\n", __func__));
412 if ((check_fwstate(pmlmepriv, _FW_UNDER_SURVEY|_FW_UNDER_LINKING)) ||
413 (pmlmepriv->LinkDetectInfo.bBusyTraffic)) {
414 /* Scan or linking is in progress, do nothing. */
415 RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("%s fail since fw_state = %x\n", __func__, get_fwstate(pmlmepriv)));
418 if (check_fwstate(pmlmepriv,
419 (_FW_UNDER_SURVEY|_FW_UNDER_LINKING)) == true)
420 RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("\n###_FW_UNDER_SURVEY|_FW_UNDER_LINKING\n\n"));
422 RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("\n###pmlmepriv->sitesurveyctrl.traffic_busy == true\n\n"));
425 if (rtw_is_scan_deny(padapter)) {
426 DBG_88E(FUNC_ADPT_FMT": scan deny\n", FUNC_ADPT_ARG(padapter));
427 indicate_wx_scan_complete_event(padapter);
431 spin_lock_bh(&pmlmepriv->lock);
433 res = rtw_sitesurvey_cmd(padapter, pssid, ssid_max_num, NULL, 0);
435 spin_unlock_bh(&pmlmepriv->lock);
441 u8 rtw_set_802_11_authentication_mode(struct adapter *padapter, enum ndis_802_11_auth_mode authmode)
443 struct security_priv *psecuritypriv = &padapter->securitypriv;
447 RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("set_802_11_auth.mode(): mode =%x\n", authmode));
449 psecuritypriv->ndisauthtype = authmode;
451 RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_,
452 ("%s:psecuritypriv->ndisauthtype=%d", __func__,
453 psecuritypriv->ndisauthtype));
455 if (psecuritypriv->ndisauthtype > 3)
456 psecuritypriv->dot11AuthAlgrthm = dot11AuthAlgrthm_8021X;
458 res = rtw_set_auth(padapter, psecuritypriv);
468 u8 rtw_set_802_11_add_wep(struct adapter *padapter, struct ndis_802_11_wep *wep)
471 struct security_priv *psecuritypriv = &(padapter->securitypriv);
474 keyid = wep->KeyIndex & 0x3fffffff;
477 RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("MgntActrtw_set_802_11_add_wep:keyid>4 =>fail\n"));
482 switch (wep->KeyLength) {
484 psecuritypriv->dot11PrivacyAlgrthm = _WEP40_;
485 RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("MgntActrtw_set_802_11_add_wep:wep->KeyLength = 5\n"));
488 psecuritypriv->dot11PrivacyAlgrthm = _WEP104_;
489 RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("MgntActrtw_set_802_11_add_wep:wep->KeyLength = 13\n"));
492 psecuritypriv->dot11PrivacyAlgrthm = _NO_PRIVACY_;
493 RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("MgntActrtw_set_802_11_add_wep:wep->KeyLength!= 5 or 13\n"));
496 RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_,
497 ("rtw_set_802_11_add_wep:before memcpy, wep->KeyLength = 0x%x wep->KeyIndex = 0x%x keyid =%x\n",
498 wep->KeyLength, wep->KeyIndex, keyid));
500 memcpy(&(psecuritypriv->dot11DefKey[keyid].skey[0]), &(wep->KeyMaterial), wep->KeyLength);
502 psecuritypriv->dot11DefKeylen[keyid] = wep->KeyLength;
504 psecuritypriv->dot11PrivacyKeyIndex = keyid;
506 RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_,
507 ("rtw_set_802_11_add_wep:security key material : %x %x %x %x %x %x %x %x %x %x %x %x %x\n",
508 psecuritypriv->dot11DefKey[keyid].skey[0],
509 psecuritypriv->dot11DefKey[keyid].skey[1],
510 psecuritypriv->dot11DefKey[keyid].skey[2],
511 psecuritypriv->dot11DefKey[keyid].skey[3],
512 psecuritypriv->dot11DefKey[keyid].skey[4],
513 psecuritypriv->dot11DefKey[keyid].skey[5],
514 psecuritypriv->dot11DefKey[keyid].skey[6],
515 psecuritypriv->dot11DefKey[keyid].skey[7],
516 psecuritypriv->dot11DefKey[keyid].skey[8],
517 psecuritypriv->dot11DefKey[keyid].skey[9],
518 psecuritypriv->dot11DefKey[keyid].skey[10],
519 psecuritypriv->dot11DefKey[keyid].skey[11],
520 psecuritypriv->dot11DefKey[keyid].skey[12]));
522 res = rtw_set_key(padapter, psecuritypriv, keyid, 1);
531 * rtw_get_cur_max_rate -
532 * @adapter: pointer to struct adapter structure
534 * Return 0 or 100Kbps
536 u16 rtw_get_cur_max_rate(struct adapter *adapter)
540 u16 rate = 0, max_rate = 0;
541 struct mlme_ext_priv *pmlmeext = &adapter->mlmeextpriv;
542 struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
543 struct registry_priv *pregistrypriv = &adapter->registrypriv;
544 struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
545 struct wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network;
546 u8 bw_40MHz = 0, short_GI_20 = 0, short_GI_40 = 0;
549 if ((!check_fwstate(pmlmepriv, _FW_LINKED)) &&
550 (!check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)))
553 if (pmlmeext->cur_wireless_mode & (WIRELESS_11_24N|WIRELESS_11_5N)) {
554 p = rtw_get_ie(&pcur_bss->ies[12], _HT_CAPABILITY_IE_, &ht_ielen, pcur_bss->ie_length-12);
555 if (p && ht_ielen > 0) {
556 /* cur_bwmod is updated by beacon, pmlmeinfo is updated by association response */
557 bw_40MHz = (pmlmeext->cur_bwmode && (HT_INFO_HT_PARAM_REC_TRANS_CHNL_WIDTH & pmlmeinfo->HT_info.infos[0])) ? 1 : 0;
559 short_GI_20 = (le16_to_cpu(pmlmeinfo->HT_caps.cap_info) & IEEE80211_HT_CAP_SGI_20) ? 1 : 0;
560 short_GI_40 = (le16_to_cpu(pmlmeinfo->HT_caps.cap_info) & IEEE80211_HT_CAP_SGI_40) ? 1 : 0;
562 max_rate = rtw_mcs_rate(
564 bw_40MHz & (pregistrypriv->cbw40_enable),
567 pmlmeinfo->HT_caps.mcs.rx_mask
571 while ((pcur_bss->SupportedRates[i] != 0) && (pcur_bss->SupportedRates[i] != 0xFF)) {
572 rate = pcur_bss->SupportedRates[i]&0x7F;
578 max_rate = max_rate*10/2;
586 * @adapter: pointer to struct adapter structure
587 * @country_code: string of country code
589 * Return _SUCCESS or _FAIL
591 int rtw_set_country(struct adapter *adapter, const char *country_code)
594 int channel_plan = RT_CHANNEL_DOMAIN_WORLD_WIDE_5G;
596 DBG_88E("%s country_code:%s\n", __func__, country_code);
597 for (i = 0; i < ARRAY_SIZE(channel_table); i++) {
598 if (strcmp(channel_table[i].name, country_code) == 0) {
599 channel_plan = channel_table[i].channel_plan;
604 if (i == ARRAY_SIZE(channel_table))
605 DBG_88E("%s unknown country_code:%s\n", __func__, country_code);
607 return rtw_set_chplan_cmd(adapter, channel_plan, 1);