From 480c865ed9e34c2e9362723c094e10b62068b8e4 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:45 +0200 Subject: [PATCH] staging: rtl8723au: rtw_mlme.c: Clean up mess Clean up spaghetti formatting and avoid NULL initializing variables where it isn't needed. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme.c | 1045 +++++++++++---------- 1 file changed, 568 insertions(+), 477 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index 8c11fa18fe89..8bb368499ce2 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -53,8 +53,11 @@ int _rtw_init_mlme_priv23a(struct rtw_adapter *padapter) pmlmepriv->nic_hdl = padapter; pmlmepriv->fw_state = 0; - pmlmepriv->cur_network.network.InfrastructureMode = Ndis802_11AutoUnknown; - pmlmepriv->scan_mode=SCAN_ACTIVE;/* 1: active, 0: pasive. Maybe someday we should rename this varable to "active_mode" (Jeff) */ + pmlmepriv->cur_network.network.InfrastructureMode = + Ndis802_11AutoUnknown; + /* 1: active, 0: pasive. Maybe someday we should rename this + varable to "active_mode" (Jeff) */ + pmlmepriv->scan_mode = SCAN_ACTIVE; spin_lock_init(&pmlmepriv->lock); _rtw_init_queue23a(&pmlmepriv->scanned_queue); @@ -72,11 +75,10 @@ int _rtw_init_mlme_priv23a(struct rtw_adapter *padapter) #ifdef CONFIG_8723AU_AP_MODE static void rtw_free_mlme_ie_data(u8 **ppie, u32 *plen) { - if(*ppie) - { + if (*ppie) { kfree(*ppie); *plen = 0; - *ppie=NULL; + *ppie = NULL; } } #endif @@ -86,30 +88,42 @@ void rtw23a_free_mlme_priv_ie_data(struct mlme_priv *pmlmepriv) #ifdef CONFIG_8723AU_AP_MODE kfree(pmlmepriv->assoc_req); kfree(pmlmepriv->assoc_rsp); - rtw_free_mlme_ie_data(&pmlmepriv->wps_beacon_ie, &pmlmepriv->wps_beacon_ie_len); - rtw_free_mlme_ie_data(&pmlmepriv->wps_probe_req_ie, &pmlmepriv->wps_probe_req_ie_len); - rtw_free_mlme_ie_data(&pmlmepriv->wps_probe_resp_ie, &pmlmepriv->wps_probe_resp_ie_len); - rtw_free_mlme_ie_data(&pmlmepriv->wps_assoc_resp_ie, &pmlmepriv->wps_assoc_resp_ie_len); - - rtw_free_mlme_ie_data(&pmlmepriv->p2p_beacon_ie, &pmlmepriv->p2p_beacon_ie_len); - rtw_free_mlme_ie_data(&pmlmepriv->p2p_probe_req_ie, &pmlmepriv->p2p_probe_req_ie_len); - rtw_free_mlme_ie_data(&pmlmepriv->p2p_probe_resp_ie, &pmlmepriv->p2p_probe_resp_ie_len); - rtw_free_mlme_ie_data(&pmlmepriv->p2p_go_probe_resp_ie, &pmlmepriv->p2p_go_probe_resp_ie_len); - rtw_free_mlme_ie_data(&pmlmepriv->p2p_assoc_req_ie, &pmlmepriv->p2p_assoc_req_ie_len); - - rtw_free_mlme_ie_data(&pmlmepriv->wfd_beacon_ie, &pmlmepriv->wfd_beacon_ie_len); - rtw_free_mlme_ie_data(&pmlmepriv->wfd_probe_req_ie, &pmlmepriv->wfd_probe_req_ie_len); - rtw_free_mlme_ie_data(&pmlmepriv->wfd_probe_resp_ie, &pmlmepriv->wfd_probe_resp_ie_len); - rtw_free_mlme_ie_data(&pmlmepriv->wfd_go_probe_resp_ie, &pmlmepriv->wfd_go_probe_resp_ie_len); - rtw_free_mlme_ie_data(&pmlmepriv->wfd_assoc_req_ie, &pmlmepriv->wfd_assoc_req_ie_len); + rtw_free_mlme_ie_data(&pmlmepriv->wps_beacon_ie, + &pmlmepriv->wps_beacon_ie_len); + rtw_free_mlme_ie_data(&pmlmepriv->wps_probe_req_ie, + &pmlmepriv->wps_probe_req_ie_len); + rtw_free_mlme_ie_data(&pmlmepriv->wps_probe_resp_ie, + &pmlmepriv->wps_probe_resp_ie_len); + rtw_free_mlme_ie_data(&pmlmepriv->wps_assoc_resp_ie, + &pmlmepriv->wps_assoc_resp_ie_len); + + rtw_free_mlme_ie_data(&pmlmepriv->p2p_beacon_ie, + &pmlmepriv->p2p_beacon_ie_len); + rtw_free_mlme_ie_data(&pmlmepriv->p2p_probe_req_ie, + &pmlmepriv->p2p_probe_req_ie_len); + rtw_free_mlme_ie_data(&pmlmepriv->p2p_probe_resp_ie, + &pmlmepriv->p2p_probe_resp_ie_len); + rtw_free_mlme_ie_data(&pmlmepriv->p2p_go_probe_resp_ie, + &pmlmepriv->p2p_go_probe_resp_ie_len); + rtw_free_mlme_ie_data(&pmlmepriv->p2p_assoc_req_ie, + &pmlmepriv->p2p_assoc_req_ie_len); + + rtw_free_mlme_ie_data(&pmlmepriv->wfd_beacon_ie, + &pmlmepriv->wfd_beacon_ie_len); + rtw_free_mlme_ie_data(&pmlmepriv->wfd_probe_req_ie, + &pmlmepriv->wfd_probe_req_ie_len); + rtw_free_mlme_ie_data(&pmlmepriv->wfd_probe_resp_ie, + &pmlmepriv->wfd_probe_resp_ie_len); + rtw_free_mlme_ie_data(&pmlmepriv->wfd_go_probe_resp_ie, + &pmlmepriv->wfd_go_probe_resp_ie_len); + rtw_free_mlme_ie_data(&pmlmepriv->wfd_assoc_req_ie, + &pmlmepriv->wfd_assoc_req_ie_len); #endif } void _rtw_free_mlme_priv23a(struct mlme_priv *pmlmepriv) { - rtw23a_free_mlme_priv_ie_data(pmlmepriv); - } struct wlan_network *rtw_alloc_network(struct mlme_priv *pmlmepriv) @@ -150,10 +164,9 @@ void _rtw_free_network23a(struct mlme_priv *pmlmepriv, } void _rtw_free_network23a_nolock23a(struct mlme_priv *pmlmepriv, - struct wlan_network *pnetwork) + struct wlan_network *pnetwork) { - - if (pnetwork == NULL) + if (!pnetwork) return; if (pnetwork->fixed == true) @@ -165,9 +178,9 @@ void _rtw_free_network23a_nolock23a(struct mlme_priv *pmlmepriv, } /* - return the wlan_network with the matching addr + return the wlan_network with the matching addr - Shall be calle under atomic context... to avoid possible racing condition... + Shall be calle under atomic context... to avoid possible racing condition... */ struct wlan_network * _rtw_find_network23a(struct rtw_queue *scanned_queue, u8 *addr) @@ -194,7 +207,7 @@ _rtw_find_network23a(struct rtw_queue *scanned_queue, u8 *addr) plist = plist->next; } - if(plist == phead) + if (plist == phead) pnetwork = NULL; /* spin_unlock_bh(&scanned_queue->lock); */ @@ -208,7 +221,7 @@ void _rtw_free_network23a_queue23a(struct rtw_adapter *padapter, u8 isfreeall) { struct list_head *phead, *plist, *ptmp; struct wlan_network *pnetwork; - struct mlme_priv* pmlmepriv = &padapter->mlmepriv; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct rtw_queue *scanned_queue = &pmlmepriv->scanned_queue; spin_lock_bh(&scanned_queue->lock); @@ -222,20 +235,21 @@ void _rtw_free_network23a_queue23a(struct rtw_adapter *padapter, u8 isfreeall) } spin_unlock_bh(&scanned_queue->lock); - } -int rtw_if_up23a(struct rtw_adapter *padapter) { - +int rtw_if_up23a(struct rtw_adapter *padapter) +{ int res; - if(padapter->bDriverStopped || padapter->bSurpriseRemoved || - (check_fwstate(&padapter->mlmepriv, _FW_LINKED)== false)) { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_if_up23a:bDriverStopped(%d) OR bSurpriseRemoved(%d)", padapter->bDriverStopped, padapter->bSurpriseRemoved)); - res=false; - } - else - res= true; + if (padapter->bDriverStopped || padapter->bSurpriseRemoved || + check_fwstate(&padapter->mlmepriv, _FW_LINKED) == false) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, + ("rtw_if_up23a:bDriverStopped(%d) OR " + "bSurpriseRemoved(%d)", padapter->bDriverStopped, + padapter->bSurpriseRemoved)); + res = false; + } else + res = true; return res; } @@ -247,9 +261,9 @@ void rtw_generate_random_ibss23a(u8* pibss) pibss[0] = 0x02; /* in ad-hoc mode bit1 must set to 1 */ pibss[1] = 0x11; pibss[2] = 0x87; - pibss[3] = (u8)(curtime & 0xff) ;/* p[0]; */ - pibss[4] = (u8)((curtime>>8) & 0xff) ;/* p[1]; */ - pibss[5] = (u8)((curtime>>16) & 0xff) ;/* p[2]; */ + pibss[3] = curtime & 0xff;/* p[0]; */ + pibss[4] = (curtime >> 8) & 0xff;/* p[1]; */ + pibss[5] = (curtime >> 16) & 0xff;/* p[2]; */ return; } @@ -261,9 +275,9 @@ u8 *rtw_get_capability23a_from_ie(u8 *ie) u16 rtw_get_capability23a(struct wlan_bssid_ex *bss) { - u16 val; + u16 val; - memcpy((u8 *)&val, rtw_get_capability23a_from_ie(bss->IEs), 2); + memcpy(&val, rtw_get_capability23a_from_ie(bss->IEs), 2); return le16_to_cpu(val); } @@ -278,41 +292,35 @@ u8 *rtw_get_beacon_interval23a_from_ie(u8 *ie) return ie + 8; } -int rtw_init_mlme_priv23a (struct rtw_adapter *padapter)/* struct mlme_priv *pmlmepriv) */ +int rtw_init_mlme_priv23a (struct rtw_adapter *padapter) { int res; - res = _rtw_init_mlme_priv23a(padapter);/* (pmlmepriv); */ + res = _rtw_init_mlme_priv23a(padapter); return res; } void rtw_free_mlme_priv23a (struct mlme_priv *pmlmepriv) { - - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("rtw_free_mlme_priv23a\n")); + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, + ("rtw_free_mlme_priv23a\n")); _rtw_free_mlme_priv23a(pmlmepriv); - } -void rtw_free_network(struct mlme_priv *pmlmepriv, struct wlan_network *pnetwork, u8 is_freeall); -void rtw_free_network(struct mlme_priv *pmlmepriv, struct wlan_network *pnetwork, u8 is_freeall)/* struct wlan_network *pnetwork, _queue *free_queue) */ +void rtw_free_network(struct mlme_priv *pmlmepriv, + struct wlan_network *pnetwork, u8 is_freeall) { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("rtw_free_network ==> ssid = %s\n\n" , pnetwork->network.Ssid.ssid)); _rtw_free_network23a(pmlmepriv, pnetwork, is_freeall); - } -void rtw_free_network_nolock(struct mlme_priv *pmlmepriv, struct wlan_network *pnetwork); -void rtw_free_network_nolock(struct mlme_priv *pmlmepriv, struct wlan_network *pnetwork) +void rtw_free_network_nolock(struct mlme_priv *pmlmepriv, + struct wlan_network *pnetwork) { - - /* RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("rtw_free_network ==> ssid = %s\n\n" , pnetwork->network.Ssid.ssid)); */ _rtw_free_network23a_nolock23a(pmlmepriv, pnetwork); - } void rtw_free_network_queue23a(struct rtw_adapter* dev, u8 isfreeall) @@ -323,9 +331,9 @@ void rtw_free_network_queue23a(struct rtw_adapter* dev, u8 isfreeall) } /* - return the wlan_network with the matching addr + return the wlan_network with the matching addr - Shall be calle under atomic context... to avoid possible racing condition... + Shall be calle under atomic context... to avoid possible racing condition... */ struct wlan_network * rtw_find_network23a(struct rtw_queue *scanned_queue, u8 *addr) @@ -337,25 +345,20 @@ rtw_find_network23a(struct rtw_queue *scanned_queue, u8 *addr) return pnetwork; } -int rtw_is_same_ibss23a(struct rtw_adapter *adapter, struct wlan_network *pnetwork) +int rtw_is_same_ibss23a(struct rtw_adapter *adapter, + struct wlan_network *pnetwork) { int ret = true; struct security_priv *psecuritypriv = &adapter->securitypriv; - if ((psecuritypriv->dot11PrivacyAlgrthm != _NO_PRIVACY_) && - (pnetwork->network.Privacy == 0)) - { + if (psecuritypriv->dot11PrivacyAlgrthm != _NO_PRIVACY_ && + pnetwork->network.Privacy == 0) ret = false; - } - else if ((psecuritypriv->dot11PrivacyAlgrthm == _NO_PRIVACY_) && - (pnetwork->network.Privacy == 1)) - { + else if (psecuritypriv->dot11PrivacyAlgrthm == _NO_PRIVACY_ && + pnetwork->network.Privacy == 1) ret = false; - } else - { ret = true; - } return ret; } @@ -363,18 +366,16 @@ int rtw_is_same_ibss23a(struct rtw_adapter *adapter, struct wlan_network *pnetwo inline int is_same_ess(struct wlan_bssid_ex *a, struct wlan_bssid_ex *b); inline int is_same_ess(struct wlan_bssid_ex *a, struct wlan_bssid_ex *b) { - /* RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("(%s,%d)(%s,%d)\n", */ - /* a->Ssid.Ssid, a->Ssid.SsidLength, b->Ssid.Ssid, b->Ssid.SsidLength)); */ return (a->Ssid.ssid_len == b->Ssid.ssid_len) && !memcmp(a->Ssid.ssid, b->Ssid.ssid, a->Ssid.ssid_len); } int is_same_network23a(struct wlan_bssid_ex *src, struct wlan_bssid_ex *dst) { - u16 s_cap, d_cap; + u16 s_cap, d_cap; - memcpy((u8 *)&s_cap, rtw_get_capability23a_from_ie(src->IEs), 2); - memcpy((u8 *)&d_cap, rtw_get_capability23a_from_ie(dst->IEs), 2); + memcpy(&s_cap, rtw_get_capability23a_from_ie(src->IEs), 2); + memcpy(&d_cap, rtw_get_capability23a_from_ie(dst->IEs), 2); s_cap = le16_to_cpu(s_cap); d_cap = le16_to_cpu(d_cap); @@ -389,10 +390,10 @@ int is_same_network23a(struct wlan_bssid_ex *src, struct wlan_bssid_ex *dst) (d_cap & WLAN_CAPABILITY_ESS))); } -struct wlan_network *rtw_get_oldest_wlan_network23a(struct rtw_queue *scanned_queue) +struct wlan_network * +rtw_get_oldest_wlan_network23a(struct rtw_queue *scanned_queue) { struct list_head *plist, *phead; - struct wlan_network *pwlan; struct wlan_network *oldest = NULL; @@ -412,7 +413,7 @@ struct wlan_network *rtw_get_oldest_wlan_network23a(struct rtw_queue *scanned_qu } void update_network23a(struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src, - struct rtw_adapter * padapter, bool update_ie) + struct rtw_adapter *padapter, bool update_ie) { u8 ss_ori = dst->PhyInfo.SignalStrength; u8 sq_ori = dst->PhyInfo.SignalQuality; @@ -426,30 +427,35 @@ void update_network23a(struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src, u8 sq_final; long rssi_final; - DBG_8723A("%s %s(%pM, ch%u) ss_ori:%3u, sq_ori:%3u, rssi_ori:%3ld, ss_smp:%3u, sq_smp:%3u, rssi_smp:%3ld\n", + DBG_8723A("%s %s(%pM, ch%u) ss_ori:%3u, sq_ori:%3u, rssi_ori:%3ld, " + "ss_smp:%3u, sq_smp:%3u, rssi_smp:%3ld\n", __func__, src->Ssid.ssid, src->MacAddress, src->Configuration.DSConfig, ss_ori, sq_ori, rssi_ori, ss_smp, sq_smp, rssi_smp ); /* The rule below is 1/5 for sample value, 4/5 for history value */ - if (check_fwstate(&padapter->mlmepriv, _FW_LINKED) && is_same_network23a(&padapter->mlmepriv.cur_network.network, src)) { + if (check_fwstate(&padapter->mlmepriv, _FW_LINKED) && + is_same_network23a(&padapter->mlmepriv.cur_network.network, src)) { /* Take the recvpriv's value for the connected AP*/ ss_final = padapter->recvpriv.signal_strength; sq_final = padapter->recvpriv.signal_qual; - /* the rssi value here is undecorated, and will be used for antenna diversity */ + /* the rssi value here is undecorated, and will be + used for antenna diversity */ if (sq_smp != 101) /* from the right channel */ rssi_final = (src->Rssi+dst->Rssi*4)/5; else rssi_final = rssi_ori; - } - else { + } else { if (sq_smp != 101) { /* from the right channel */ - ss_final = ((u32)(src->PhyInfo.SignalStrength)+(u32)(dst->PhyInfo.SignalStrength)*4)/5; - sq_final = ((u32)(src->PhyInfo.SignalQuality)+(u32)(dst->PhyInfo.SignalQuality)*4)/5; - rssi_final = (src->Rssi+dst->Rssi*4)/5; + ss_final = ((u32)src->PhyInfo.SignalStrength + + (u32)dst->PhyInfo.SignalStrength * 4) / 5; + sq_final = ((u32)src->PhyInfo.SignalQuality + + (u32)dst->PhyInfo.SignalQuality * 4) / 5; + rssi_final = src->Rssi+dst->Rssi * 4 / 5; } else { - /* bss info not receving from the right channel, use the original RX signal infos */ + /* bss info not receving from the right channel, use + the original RX signal infos */ ss_final = dst->PhyInfo.SignalStrength; sq_final = dst->PhyInfo.SignalQuality; rssi_final = dst->Rssi; @@ -458,35 +464,32 @@ void update_network23a(struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src, } if (update_ie) - memcpy((u8 *)dst, (u8 *)src, get_wlan_bssid_ex_sz(src)); + memcpy(dst, src, get_wlan_bssid_ex_sz(src)); dst->PhyInfo.SignalStrength = ss_final; dst->PhyInfo.SignalQuality = sq_final; dst->Rssi = rssi_final; - DBG_8723A("%s %s(%pM), SignalStrength:%u, SignalQuality:%u, RawRSSI:%ld\n", - __func__, dst->Ssid.ssid, dst->MacAddress, + DBG_8723A("%s %s(%pM), SignalStrength:%u, SignalQuality:%u, " + "RawRSSI:%ld\n", __func__, dst->Ssid.ssid, dst->MacAddress, dst->PhyInfo.SignalStrength, dst->PhyInfo.SignalQuality, dst->Rssi); - } -static void update_current_network(struct rtw_adapter *adapter, struct wlan_bssid_ex *pnetwork) +static void update_current_network(struct rtw_adapter *adapter, + struct wlan_bssid_ex *pnetwork) { - struct mlme_priv *pmlmepriv = &adapter->mlmepriv; - - if ((check_fwstate(pmlmepriv, _FW_LINKED)== true) && (is_same_network23a(&pmlmepriv->cur_network.network, pnetwork))) - { - /* RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_,"Same Network\n"); */ + struct mlme_priv *pmlmepriv = &adapter->mlmepriv; - /* if(pmlmepriv->cur_network.network.IELength<= pnetwork->IELength) */ - { - update_network23a(&pmlmepriv->cur_network.network, pnetwork,adapter, true); - rtw_update_protection23a(adapter, (pmlmepriv->cur_network.network.IEs) + sizeof (struct ndis_802_11_fixed_ies), - pmlmepriv->cur_network.network.IELength); - } + if (check_fwstate(pmlmepriv, _FW_LINKED) && + is_same_network23a(&pmlmepriv->cur_network.network, pnetwork)) { + update_network23a(&pmlmepriv->cur_network.network, + pnetwork,adapter, true); + rtw_update_protection23a(adapter, + pmlmepriv->cur_network.network.IEs + + sizeof (struct ndis_802_11_fixed_ies), + pmlmepriv->cur_network.network.IELength); } - } /* @@ -494,7 +497,8 @@ static void update_current_network(struct rtw_adapter *adapter, struct wlan_bssi Caller must hold pmlmepriv->lock first. */ -void rtw_update_scanned_network23a(struct rtw_adapter *adapter, struct wlan_bssid_ex *target) +void rtw_update_scanned_network23a(struct rtw_adapter *adapter, + struct wlan_bssid_ex *target) { struct list_head *plist, *phead; struct mlme_priv *pmlmepriv = &adapter->mlmepriv; @@ -561,19 +565,20 @@ void rtw_update_scanned_network23a(struct rtw_adapter *adapter, struct wlan_bssi /* target.reserved == 1, means that scanned network is * a bcn frame. */ - if ((pnetwork->network.IELength>target->IELength) && - (target->reserved == 1)) + if (pnetwork->network.IELength > target->IELength && + target->reserved == 1) update_ie = false; - update_network23a(&pnetwork->network, target,adapter, update_ie); + update_network23a(&pnetwork->network, target,adapter, + update_ie); } exit: spin_unlock_bh(&queue->lock); - } -void rtw_add_network(struct rtw_adapter *adapter, struct wlan_bssid_ex *pnetwork) +void rtw_add_network(struct rtw_adapter *adapter, + struct wlan_bssid_ex *pnetwork) { update_current_network(adapter, pnetwork); rtw_update_scanned_network23a(adapter, pnetwork); @@ -585,7 +590,8 @@ void rtw_add_network(struct rtw_adapter *adapter, struct wlan_bssid_ex *pnetwork /* (3) WMM */ /* (4) HT */ /* (5) others */ -int rtw_is_desired_network(struct rtw_adapter *adapter, struct wlan_network *pnetwork) +int rtw_is_desired_network(struct rtw_adapter *adapter, + struct wlan_network *pnetwork) { struct security_priv *psecuritypriv = &adapter->securitypriv; struct mlme_priv *pmlmepriv = &adapter->mlmepriv; @@ -600,31 +606,31 @@ int rtw_is_desired_network(struct rtw_adapter *adapter, struct wlan_network *pne desired_encmode = psecuritypriv->ndisencryptstatus; privacy = pnetwork->network.Privacy; - if (check_fwstate(pmlmepriv, WIFI_UNDER_WPS)) - { - if (rtw_get_wps_ie23a(pnetwork->network.IEs+_FIXED_IE_LENGTH_, pnetwork->network.IELength-_FIXED_IE_LENGTH_, NULL, &wps_ielen)!= NULL) - { + if (check_fwstate(pmlmepriv, WIFI_UNDER_WPS)) { + if (rtw_get_wps_ie23a(pnetwork->network.IEs + _FIXED_IE_LENGTH_, + pnetwork->network.IELength - + _FIXED_IE_LENGTH_, NULL, &wps_ielen)) return true; - } else - { return false; - } } - if (adapter->registrypriv.wifi_spec == 1) /* for correct flow of 8021X to do.... */ - { - if ((desired_encmode == Ndis802_11EncryptionDisabled) && (privacy != 0)) + if (adapter->registrypriv.wifi_spec == 1) { + /* for correct flow of 8021X to do.... */ + if (desired_encmode == Ndis802_11EncryptionDisabled && + privacy != 0) bselected = false; } - if ((desired_encmode != Ndis802_11EncryptionDisabled) && (privacy == 0)) { - DBG_8723A("desired_encmode: %d, privacy: %d\n", desired_encmode, privacy); + if (desired_encmode != Ndis802_11EncryptionDisabled && + privacy == 0) { + DBG_8723A("desired_encmode: %d, privacy: %d\n", + desired_encmode, privacy); bselected = false; } - if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true) - { - if (pnetwork->network.InfrastructureMode != pmlmepriv->cur_network.network.InfrastructureMode) + if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) { + if (pnetwork->network.InfrastructureMode != + pmlmepriv->cur_network.network.InfrastructureMode) bselected = false; } @@ -632,15 +638,14 @@ int rtw_is_desired_network(struct rtw_adapter *adapter, struct wlan_network *pne } /* TODO: Perry : For Power Management */ -void rtw_atimdone_event_callback23a(struct rtw_adapter *adapter , u8 *pbuf) +void rtw_atimdone_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf) { - RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_,("receive atimdone_evet\n")); return; } -void rtw_survey_event_cb23a(struct rtw_adapter *adapter, u8 *pbuf) +void rtw_survey_event_cb23a(struct rtw_adapter *adapter, u8 *pbuf) { u32 len; struct wlan_bssid_ex *pnetwork; @@ -648,31 +653,36 @@ void rtw_survey_event_cb23a(struct rtw_adapter *adapter, u8 *pbuf) pnetwork = (struct wlan_bssid_ex *)pbuf; - RT_TRACE(_module_rtl871x_mlme_c_,_drv_info_,("rtw_survey_event_cb23a, ssid=%s\n", pnetwork->Ssid.ssid)); + RT_TRACE(_module_rtl871x_mlme_c_,_drv_info_, + ("rtw_survey_event_cb23a, ssid=%s\n", pnetwork->Ssid.ssid)); len = get_wlan_bssid_ex_sz(pnetwork); - if(len > (sizeof(struct wlan_bssid_ex))) - { - RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_,("\n ****rtw_survey_event_cb23a: return a wrong bss ***\n")); + if (len > (sizeof(struct wlan_bssid_ex))) { + RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_, + ("\n ****rtw_survey_event_cb23a: return a wrong " + "bss ***\n")); return; } spin_lock_bh(&pmlmepriv->lock); /* update IBSS_network 's timestamp */ - if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) == true) - { - /* RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_,"rtw_survey_event_cb23a : WIFI_ADHOC_MASTER_STATE\n\n"); */ + if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) { + /* RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, + "rtw_survey_event_cb23a : WIFI_ADHOC_MASTER_STATE\n\n"); */ if (ether_addr_equal(pmlmepriv->cur_network.network.MacAddress, pnetwork->MacAddress)) { - struct wlan_network* ibss_wlan = NULL; + struct wlan_network* ibss_wlan; - memcpy(pmlmepriv->cur_network.network.IEs, pnetwork->IEs, 8); + memcpy(pmlmepriv->cur_network.network.IEs, + pnetwork->IEs, 8); spin_lock_bh(&pmlmepriv->scanned_queue.lock); - ibss_wlan = rtw_find_network23a(&pmlmepriv->scanned_queue, pnetwork->MacAddress); - if (ibss_wlan) - { - memcpy(ibss_wlan->network.IEs , pnetwork->IEs, 8); + ibss_wlan = rtw_find_network23a( + &pmlmepriv->scanned_queue, + pnetwork->MacAddress); + if (ibss_wlan) { + memcpy(ibss_wlan->network.IEs, + pnetwork->IEs, 8); spin_unlock_bh(&pmlmepriv->scanned_queue.lock); goto exit; } @@ -681,8 +691,7 @@ void rtw_survey_event_cb23a(struct rtw_adapter *adapter, u8 *pbuf) } /* lock pmlmepriv->lock when you accessing network_q */ - if ((check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) == false) - { + if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING) == false) { if (pnetwork->Ssid.ssid[0] == 0) pnetwork->Ssid.ssid_len = 0; @@ -696,10 +705,12 @@ exit: return; } -void rtw_surveydone_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf) +void rtw_surveydone_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf) { struct mlme_priv *pmlmepriv = &adapter->mlmepriv; struct mlme_ext_priv *pmlmeext = &adapter->mlmeextpriv; + struct wlan_bssid_ex *pdev_network; + u8 *pibss; spin_lock_bh(&pmlmepriv->lock); @@ -709,7 +720,9 @@ void rtw_surveydone_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf) pmlmepriv->wps_probe_req_ie = NULL; } - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_surveydone_event_callback23a: fw_state:%x\n\n", get_fwstate(pmlmepriv))); + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, + ("rtw_surveydone_event_callback23a: fw_state:%x\n\n", + get_fwstate(pmlmepriv))); if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY)) { del_timer_sync(&pmlmepriv->scan_to_timer); @@ -717,39 +730,53 @@ void rtw_surveydone_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf) _clr_fwstate_(pmlmepriv, _FW_UNDER_SURVEY); } else { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("nic status =%x, survey done event comes too late!\n", get_fwstate(pmlmepriv))); + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, + ("nic status =%x, survey done event comes too late!\n", + get_fwstate(pmlmepriv))); } rtw_set_signal_stat_timer(&adapter->recvpriv); if (pmlmepriv->to_join == true) { - if ((check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true)) { + if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) { if (check_fwstate(pmlmepriv, _FW_LINKED) == false) { set_fwstate(pmlmepriv, _FW_UNDER_LINKING); - if (rtw_select_and_join_from_scanned_queue23a(pmlmepriv) == _SUCCESS) { + if (rtw_select_and_join_from_scanned_queue23a( + pmlmepriv) == _SUCCESS) { mod_timer(&pmlmepriv->assoc_timer, jiffies + msecs_to_jiffies(MAX_JOIN_TIMEOUT)); } else { - struct wlan_bssid_ex *pdev_network = &adapter->registrypriv.dev_network; - u8 *pibss = adapter->registrypriv.dev_network.MacAddress; + pdev_network = &adapter->registrypriv.dev_network; + pibss = adapter->registrypriv.dev_network.MacAddress; - _clr_fwstate_(pmlmepriv, _FW_UNDER_SURVEY); + _clr_fwstate_(pmlmepriv, + _FW_UNDER_SURVEY); - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("switching to adhoc master\n")); + RT_TRACE(_module_rtl871x_mlme_c_, + _drv_err_, + ("switching to adhoc " + "master\n")); - memset(&pdev_network->Ssid, 0, sizeof(struct cfg80211_ssid)); - memcpy(&pdev_network->Ssid, &pmlmepriv->assoc_ssid, sizeof(struct cfg80211_ssid)); + memset(&pdev_network->Ssid, 0, + sizeof(struct cfg80211_ssid)); + memcpy(&pdev_network->Ssid, + &pmlmepriv->assoc_ssid, + sizeof(struct cfg80211_ssid)); - rtw_update_registrypriv_dev_network23a(adapter); + rtw_update_registrypriv_dev_network23a( + adapter); rtw_generate_random_ibss23a(pibss); - pmlmepriv->fw_state = WIFI_ADHOC_MASTER_STATE; + pmlmepriv->fw_state = + WIFI_ADHOC_MASTER_STATE; - if (rtw_createbss_cmd23a(adapter)!= _SUCCESS) - { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Error =>rtw_createbss_cmd23a status FAIL\n")); - } + if (rtw_createbss_cmd23a(adapter) != + _SUCCESS) + RT_TRACE(_module_rtl871x_mlme_c_, + _drv_err_, + ("Error =>rtw_createbss_cmd23a" + " status FAIL\n")); pmlmepriv->to_join = false; } @@ -758,27 +785,32 @@ void rtw_surveydone_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf) int ret; set_fwstate(pmlmepriv, _FW_UNDER_LINKING); pmlmepriv->to_join = false; - ret = rtw_select_and_join_from_scanned_queue23a(pmlmepriv); + ret = rtw_select_and_join_from_scanned_queue23a( + pmlmepriv); if (ret == _SUCCESS) { unsigned long e; e = msecs_to_jiffies(MAX_JOIN_TIMEOUT); mod_timer(&pmlmepriv->assoc_timer, jiffies + e); - } else if (ret == 2)/* there is no need to wait for join */ - { + } else if (ret == 2) {/* there is no need to wait */ _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING); rtw_indicate_connect23a(adapter); } else { - DBG_8723A("try_to_join, but select scanning queue fail, to_roaming:%d\n", rtw_to_roaming(adapter)); + DBG_8723A("try_to_join, but select scanning " + "queue fail, to_roaming:%d\n", + rtw_to_roaming(adapter)); if (rtw_to_roaming(adapter) != 0) { - if (--pmlmepriv->to_roaming == 0 - || _SUCCESS != rtw_sitesurvey_cmd23a(adapter, &pmlmepriv->assoc_ssid, 1, NULL, 0) - ) { + if (--pmlmepriv->to_roaming == 0 || + rtw_sitesurvey_cmd23a( + adapter, + &pmlmepriv->assoc_ssid, 1, + NULL, 0) != _SUCCESS) { rtw_set_roaming(adapter, 0); - rtw_free_assoc_resources23a(adapter, 1); - rtw_indicate_disconnect23a(adapter); - } else { + rtw_free_assoc_resources23a( + adapter, 1); + rtw_indicate_disconnect23a( + adapter); + } else pmlmepriv->to_join = true; - } } _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING); } @@ -789,11 +821,10 @@ void rtw_surveydone_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf) rtw_os_xmit_schedule23a(adapter); - if(pmlmeext->sitesurvey_res.bss_cnt == 0) + if (pmlmeext->sitesurvey_res.bss_cnt == 0) rtw_hal_sreset_reset23a(adapter); rtw_cfg80211_surveydone_event_callback(adapter); - } void rtw_dummy_event_callback23a(struct rtw_adapter *adapter , u8 *pbuf) @@ -804,7 +835,7 @@ void rtw23a_fwdbg_event_callback(struct rtw_adapter *adapter , u8 *pbuf) { } -static void free_scanqueue(struct mlme_priv *pmlmepriv) +static void free_scanqueue(struct mlme_priv *pmlmepriv) { struct wlan_network *pnetwork; struct rtw_queue *scan_queue = &pmlmepriv->scanned_queue; @@ -822,42 +853,38 @@ static void free_scanqueue(struct mlme_priv *pmlmepriv) } spin_unlock_bh(&scan_queue->lock); - } /* -*rtw_free_assoc_resources23a: the caller has to lock pmlmepriv->lock -*/ -void rtw_free_assoc_resources23a(struct rtw_adapter *adapter, int lock_scanned_queue) + *rtw_free_assoc_resources23a: the caller has to lock pmlmepriv->lock + */ +void rtw_free_assoc_resources23a(struct rtw_adapter *adapter, + int lock_scanned_queue) { - struct wlan_network* pwlan = NULL; - struct mlme_priv *pmlmepriv = &adapter->mlmepriv; - struct sta_priv *pstapriv = &adapter->stapriv; + struct wlan_network* pwlan; + struct mlme_priv *pmlmepriv = &adapter->mlmepriv; + struct sta_priv *pstapriv = &adapter->stapriv; struct wlan_network *tgt_network = &pmlmepriv->cur_network; + struct sta_info* psta; - RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, ("+rtw_free_assoc_resources23a\n")); - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("tgt_network->network.MacAddress="MAC_FMT" ssid=%s\n", - MAC_ARG(tgt_network->network.MacAddress), tgt_network->network.Ssid.ssid)); - - if(check_fwstate(pmlmepriv, WIFI_STATION_STATE|WIFI_AP_STATE)) - { - struct sta_info* psta; - - psta = rtw_get_stainfo23a(&adapter->stapriv, tgt_network->network.MacAddress); + RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, + ("+rtw_free_assoc_resources23a\n")); + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, + ("tgt_network->network.MacAddress="MAC_FMT" ssid=%s\n", + MAC_ARG(tgt_network->network.MacAddress), + tgt_network->network.Ssid.ssid)); - { - spin_lock_bh(&pstapriv->sta_hash_lock); - rtw_free_stainfo23a(adapter, psta); - } + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE|WIFI_AP_STATE)) { + psta = rtw_get_stainfo23a(&adapter->stapriv, + tgt_network->network.MacAddress); + spin_lock_bh(&pstapriv->sta_hash_lock); + rtw_free_stainfo23a(adapter, psta); spin_unlock_bh(&pstapriv->sta_hash_lock); - } - if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE|WIFI_ADHOC_MASTER_STATE|WIFI_AP_STATE)) - { - struct sta_info* psta; - + if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE | + WIFI_ADHOC_MASTER_STATE|WIFI_AP_STATE)) { rtw_free_all_stainfo23a(adapter); psta = rtw_get_bcmc_stainfo23a(adapter); @@ -868,23 +895,25 @@ void rtw_free_assoc_resources23a(struct rtw_adapter *adapter, int lock_scanned_q rtw_init_bcmc_stainfo23a(adapter); } - if(lock_scanned_queue) + if (lock_scanned_queue) spin_lock_bh(&pmlmepriv->scanned_queue.lock); - pwlan = rtw_find_network23a(&pmlmepriv->scanned_queue, tgt_network->network.MacAddress); - if(pwlan) + pwlan = rtw_find_network23a(&pmlmepriv->scanned_queue, + tgt_network->network.MacAddress); + if (pwlan) pwlan->fixed = false; else - RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_,("rtw_free_assoc_resources23a : pwlan== NULL\n\n")); + RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_, + ("rtw_free_assoc_resources23a : pwlan== NULL\n")); - if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) && (adapter->stapriv.asoc_sta_count == 1)) + if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) && + adapter->stapriv.asoc_sta_count == 1) rtw_free_network_nolock(pmlmepriv, pwlan); - if(lock_scanned_queue) + if (lock_scanned_queue) spin_unlock_bh(&pmlmepriv->scanned_queue.lock); pmlmepriv->key_mask = 0; - } /* @@ -892,13 +921,14 @@ void rtw_free_assoc_resources23a(struct rtw_adapter *adapter, int lock_scanned_q */ void rtw_indicate_connect23a(struct rtw_adapter *padapter) { - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("+rtw_indicate_connect23a\n")); + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, + ("+rtw_indicate_connect23a\n")); pmlmepriv->to_join = false; - if(!check_fwstate(&padapter->mlmepriv, _FW_LINKED)) { + if (!check_fwstate(&padapter->mlmepriv, _FW_LINKED)) { set_fwstate(pmlmepriv, _FW_LINKED); rtw_led_control(padapter, LED_CTL_LINK); @@ -915,18 +945,20 @@ void rtw_indicate_connect23a(struct rtw_adapter *padapter) rtw_set_scan_deny(padapter, 3000); - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("-rtw_indicate_connect23a: fw_state=0x%08x\n", get_fwstate(pmlmepriv))); - + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, + ("-rtw_indicate_connect23a: fw_state=0x%08x\n", + get_fwstate(pmlmepriv))); } /* -*rtw_indicate_disconnect23a: the caller has to lock pmlmepriv->lock -*/ + *rtw_indicate_disconnect23a: the caller has to lock pmlmepriv->lock + */ void rtw_indicate_disconnect23a(struct rtw_adapter *padapter) { struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("+rtw_indicate_disconnect23a\n")); + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, + ("+rtw_indicate_disconnect23a\n")); _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING|WIFI_UNDER_WPS); @@ -936,7 +968,7 @@ void rtw_indicate_disconnect23a(struct rtw_adapter *padapter) _clr_fwstate_(pmlmepriv, _FW_LINKED); if (check_fwstate(&padapter->mlmepriv, _FW_LINKED) || - (rtw_to_roaming(padapter) <= 0)) { + rtw_to_roaming(padapter) <= 0) { rtw_os_indicate_disconnect23a(padapter); /* set ips_deny_time to avoid enter IPS before LPS leave */ @@ -952,7 +984,6 @@ void rtw_indicate_disconnect23a(struct rtw_adapter *padapter) } rtw_lps_ctrl_wk_cmd23a(padapter, LPS_CTRL_DISCONNECT, 1); - } void rtw_scan_abort23a(struct rtw_adapter *adapter) @@ -965,37 +996,39 @@ void rtw_scan_abort23a(struct rtw_adapter *adapter) pmlmeext->scan_abort = true; while (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) && jiffies_to_msecs(jiffies - start) <= 200) { - if (adapter->bDriverStopped || adapter->bSurpriseRemoved) break; - DBG_8723A(FUNC_NDEV_FMT"fw_state = _FW_UNDER_SURVEY!\n", FUNC_NDEV_ARG(adapter->pnetdev)); + DBG_8723A(FUNC_NDEV_FMT "fw_state = _FW_UNDER_SURVEY!\n", + FUNC_NDEV_ARG(adapter->pnetdev)); msleep(20); } if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY)) { if (!adapter->bDriverStopped && !adapter->bSurpriseRemoved) - DBG_8723A(FUNC_NDEV_FMT"waiting for scan_abort time out!\n", FUNC_NDEV_ARG(adapter->pnetdev)); + DBG_8723A(FUNC_NDEV_FMT "waiting for scan_abort time " + "out!\n", FUNC_NDEV_ARG(adapter->pnetdev)); rtw_cfg80211_indicate_scan_done(wdev_to_priv(adapter->rtw_wdev), true); } pmlmeext->scan_abort = false; } -static struct sta_info *rtw_joinbss_update_stainfo(struct rtw_adapter *padapter, struct wlan_network *pnetwork) +static struct sta_info * +rtw_joinbss_update_stainfo(struct rtw_adapter *padapter, + struct wlan_network *pnetwork) { int i; - struct sta_info *bmc_sta, *psta = NULL; + struct sta_info *bmc_sta, *psta; struct recv_reorder_ctrl *preorder_ctrl; struct sta_priv *pstapriv = &padapter->stapriv; psta = rtw_get_stainfo23a(pstapriv, pnetwork->network.MacAddress); - if (psta == NULL) { - psta = rtw_alloc_stainfo23a(pstapriv, pnetwork->network.MacAddress); - } + if (!psta) + psta = rtw_alloc_stainfo23a(pstapriv, + pnetwork->network.MacAddress); - if (psta) /* update ptarget_sta */ - { + if (psta) { /* update ptarget_sta */ DBG_8723A("%s\n", __func__); psta->aid = pnetwork->join_res; @@ -1005,57 +1038,63 @@ static struct sta_info *rtw_joinbss_update_stainfo(struct rtw_adapter *padapter, rtw_hal_set_odm_var23a(padapter, HAL_ODM_STA_INFO, psta, true); /* security related */ - if (padapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) - { + if (padapter->securitypriv.dot11AuthAlgrthm == + dot11AuthAlgrthm_8021X) { padapter->securitypriv.binstallGrpkey = false; padapter->securitypriv.busetkipkey = false; padapter->securitypriv.bgrpkey_handshake = false; psta->ieee8021x_blocked = true; - psta->dot118021XPrivacy = padapter->securitypriv.dot11PrivacyAlgrthm; + psta->dot118021XPrivacy = + padapter->securitypriv.dot11PrivacyAlgrthm; - memset((u8 *)&psta->dot118021x_UncstKey, 0, sizeof (union Keytype)); + memset(&psta->dot118021x_UncstKey, 0, + sizeof (union Keytype)); - memset((u8 *)&psta->dot11tkiprxmickey, 0, sizeof (union Keytype)); - memset((u8 *)&psta->dot11tkiptxmickey, 0, sizeof (union Keytype)); + memset(&psta->dot11tkiprxmickey, 0, + sizeof (union Keytype)); + memset(&psta->dot11tkiptxmickey, 0, + sizeof (union Keytype)); - memset((u8 *)&psta->dot11txpn, 0, sizeof (union pn48)); - memset((u8 *)&psta->dot11rxpn, 0, sizeof (union pn48)); + memset(&psta->dot11txpn, 0, sizeof (union pn48)); + memset(&psta->dot11rxpn, 0, sizeof (union pn48)); } /* Commented by Albert 2012/07/21 */ /* When doing the WPS, the wps_ie_len won't equal to 0 */ - /* And the Wi-Fi driver shouldn't allow the data packet to be tramsmitted. */ - if (padapter->securitypriv.wps_ie_len != 0) - { + /* And the Wi-Fi driver shouldn't allow the data packet + to be tramsmitted. */ + if (padapter->securitypriv.wps_ie_len != 0) { psta->ieee8021x_blocked = true; padapter->securitypriv.wps_ie_len = 0; } - /* for A-MPDU Rx reordering buffer control for bmc_sta & sta_info */ - /* if A-MPDU Rx is enabled, reseting rx_ordering_ctrl wstart_b(indicate_seq) to default value = 0xffff */ + /* for A-MPDU Rx reordering buffer control for bmc_sta & + * sta_info */ + /* if A-MPDU Rx is enabled, reseting + rx_ordering_ctrl wstart_b(indicate_seq) to default + value = 0xffff */ /* todo: check if AP can send A-MPDU packets */ - for (i = 0; i < 16 ; i++) - { + for (i = 0; i < 16 ; i++) { /* preorder_ctrl = &precvpriv->recvreorder_ctrl[i]; */ preorder_ctrl = &psta->recvreorder_ctrl[i]; preorder_ctrl->enable = false; preorder_ctrl->indicate_seq = 0xffff; preorder_ctrl->wend_b = 0xffff; - preorder_ctrl->wsize_b = 64;/* max_ampdu_sz; ex. 32(kbytes) -> wsize_b = 32 */ + /* max_ampdu_sz; ex. 32(kbytes) -> wsize_b = 32 */ + preorder_ctrl->wsize_b = 64; } bmc_sta = rtw_get_bcmc_stainfo23a(padapter); - if (bmc_sta) - { - for (i = 0; i < 16 ; i++) - { - /* preorder_ctrl = &precvpriv->recvreorder_ctrl[i]; */ + if (bmc_sta) { + for (i = 0; i < 16 ; i++) { preorder_ctrl = &bmc_sta->recvreorder_ctrl[i]; preorder_ctrl->enable = false; preorder_ctrl->indicate_seq = 0xffff; preorder_ctrl->wend_b = 0xffff; - preorder_ctrl->wsize_b = 64;/* max_ampdu_sz; ex. 32(kbytes) -> wsize_b = 32 */ + /* max_ampdu_sz; ex. 32(kbytes) -> + wsize_b = 32 */ + preorder_ctrl->wsize_b = 64; } } @@ -1069,29 +1108,41 @@ static struct sta_info *rtw_joinbss_update_stainfo(struct rtw_adapter *padapter, /* pnetwork : returns from rtw23a_joinbss_event_cb */ /* ptarget_wlan: found from scanned_queue */ -static void rtw_joinbss_update_network23a(struct rtw_adapter *padapter, struct wlan_network *ptarget_wlan, struct wlan_network *pnetwork) +static void +rtw_joinbss_update_network23a(struct rtw_adapter *padapter, + struct wlan_network *ptarget_wlan, + struct wlan_network *pnetwork) { struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct wlan_network *cur_network = &pmlmepriv->cur_network; DBG_8723A("%s\n", __func__); - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("\nfw_state:%x, BSSID:"MAC_FMT"\n" - , get_fwstate(pmlmepriv), MAC_ARG(pnetwork->network.MacAddress))); + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, + ("\nfw_state:%x, BSSID:"MAC_FMT"\n", get_fwstate(pmlmepriv), + MAC_ARG(pnetwork->network.MacAddress))); /* why not use ptarget_wlan?? */ - memcpy(&cur_network->network, &pnetwork->network, pnetwork->network.Length); + memcpy(&cur_network->network, &pnetwork->network, + pnetwork->network.Length); /* some IEs in pnetwork is wrong, so we should use ptarget_wlan IEs */ cur_network->network.IELength = ptarget_wlan->network.IELength; - memcpy(&cur_network->network.IEs[0], &ptarget_wlan->network.IEs[0], MAX_IE_SZ); + memcpy(&cur_network->network.IEs[0], &ptarget_wlan->network.IEs[0], + MAX_IE_SZ); cur_network->aid = pnetwork->join_res; rtw_set_signal_stat_timer(&padapter->recvpriv); - padapter->recvpriv.signal_strength = ptarget_wlan->network.PhyInfo.SignalStrength; - padapter->recvpriv.signal_qual = ptarget_wlan->network.PhyInfo.SignalQuality; - /* the ptarget_wlan->network.Rssi is raw data, we use ptarget_wlan->network.PhyInfo.SignalStrength instead (has scaled) */ - padapter->recvpriv.rssi = translate_percentage_to_dbm(ptarget_wlan->network.PhyInfo.SignalStrength); + padapter->recvpriv.signal_strength = + ptarget_wlan->network.PhyInfo.SignalStrength; + padapter->recvpriv.signal_qual = + ptarget_wlan->network.PhyInfo.SignalQuality; + /* + * the ptarget_wlan->network.Rssi is raw data, we use + * ptarget_wlan->network.PhyInfo.SignalStrength instead (has scaled) + */ + padapter->recvpriv.rssi = translate_percentage_to_dbm( + ptarget_wlan->network.PhyInfo.SignalStrength); DBG_8723A("%s signal_strength:%3u, rssi:%3d, signal_qual:%3u\n", __func__, padapter->recvpriv.signal_strength, padapter->recvpriv.rssi, padapter->recvpriv.signal_qual); @@ -1110,40 +1161,51 @@ static void rtw_joinbss_update_network23a(struct rtw_adapter *padapter, struct w break; default: pmlmepriv->fw_state = WIFI_NULL_STATE; - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Invalid network_mode\n")); + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, + ("Invalid network_mode\n")); break; } - rtw_update_protection23a(padapter, (cur_network->network.IEs) + sizeof (struct ndis_802_11_fixed_ies), - (cur_network->network.IELength)); + rtw_update_protection23a(padapter, cur_network->network.IEs + + sizeof (struct ndis_802_11_fixed_ies), + cur_network->network.IELength); - rtw_update_ht_cap23a(padapter, cur_network->network.IEs, cur_network->network.IELength); + rtw_update_ht_cap23a(padapter, cur_network->network.IEs, + cur_network->network.IELength); } -/* Notes: the fucntion could be > passive_level (the same context as Rx tasklet) */ -/* pnetwork : returns from rtw23a_joinbss_event_cb */ -/* ptarget_wlan: found from scanned_queue */ -/* if join_res > 0, for (fw_state==WIFI_STATION_STATE), we check if "ptarget_sta" & "ptarget_wlan" exist. */ -/* if join_res > 0, for (fw_state==WIFI_ADHOC_STATE), we only check if "ptarget_wlan" exist. */ -/* if join_res > 0, update "cur_network->network" from "pnetwork->network" if (ptarget_wlan !=NULL). */ +/* + * Notes: + * the fucntion could be > passive_level (the same context as Rx tasklet) + * pnetwork : returns from rtw23a_joinbss_event_cb + * ptarget_wlan: found from scanned_queue + * if join_res > 0, for (fw_state==WIFI_STATION_STATE), + * we check if "ptarget_sta" & "ptarget_wlan" exist. + * if join_res > 0, for (fw_state==WIFI_ADHOC_STATE), + * we only check if "ptarget_wlan" exist. + * if join_res > 0, update "cur_network->network" from "pnetwork->network" + * if (ptarget_wlan !=NULL). + */ void rtw_joinbss_event_prehandle23a(struct rtw_adapter *adapter, u8 *pbuf) { - static u8 retry=0; - struct sta_info *ptarget_sta= NULL, *pcur_sta = NULL; - struct sta_priv *pstapriv = &adapter->stapriv; - struct mlme_priv *pmlmepriv = &adapter->mlmepriv; - struct wlan_network *pnetwork = (struct wlan_network *)pbuf; + struct sta_info *ptarget_sta, *pcur_sta; + struct sta_priv *pstapriv = &adapter->stapriv; + struct mlme_priv *pmlmepriv = &adapter->mlmepriv; + struct wlan_network *pnetwork = (struct wlan_network *)pbuf; struct wlan_network *cur_network = &pmlmepriv->cur_network; - struct wlan_network *pcur_wlan = NULL, *ptarget_wlan = NULL; - unsigned int the_same_macaddr = false; + struct wlan_network *pcur_wlan, *ptarget_wlan = NULL; + bool the_same_macaddr; - RT_TRACE(_module_rtl871x_mlme_c_,_drv_info_,("joinbss event call back received with res=%d\n", pnetwork->join_res)); + RT_TRACE(_module_rtl871x_mlme_c_,_drv_info_, + ("joinbss event call back received with res=%d\n", + pnetwork->join_res)); rtw_get_encrypt_decrypt_from_registrypriv23a(adapter); if (pmlmepriv->assoc_ssid.ssid_len == 0) { - RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_,("@@@@@ joinbss event call back for Any SSid\n")); + RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_, + ("@@@@@ joinbss event call back for Any SSid\n")); } else { RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_, ("@@@@@ rtw23a_joinbss_event_cb for SSid:%s\n", @@ -1157,93 +1219,102 @@ void rtw_joinbss_event_prehandle23a(struct rtw_adapter *adapter, u8 *pbuf) the_same_macaddr = false; pnetwork->network.Length = get_wlan_bssid_ex_sz(&pnetwork->network); - if(pnetwork->network.Length > sizeof(struct wlan_bssid_ex)) - { - RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_,("\n\n ***joinbss_evt_callback return a wrong bss ***\n\n")); + if (pnetwork->network.Length > sizeof(struct wlan_bssid_ex)) { + RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_, + ("\n\n ***joinbss_evt_callback return a wrong bss " + "***\n\n")); return; } spin_lock_bh(&pmlmepriv->lock); - RT_TRACE(_module_rtl871x_mlme_c_,_drv_info_,("\n rtw23a_joinbss_event_cb !! _enter_critical\n")); + RT_TRACE(_module_rtl871x_mlme_c_,_drv_info_, + ("\n rtw23a_joinbss_event_cb !! _enter_critical\n")); - if(pnetwork->join_res > 0) - { + if (pnetwork->join_res > 0) { spin_lock_bh(&pmlmepriv->scanned_queue.lock); - retry = 0; - if (check_fwstate(pmlmepriv,_FW_UNDER_LINKING)) - { + if (check_fwstate(pmlmepriv,_FW_UNDER_LINKING)) { /* s1. find ptarget_wlan */ - if(check_fwstate(pmlmepriv, _FW_LINKED)) - { - if(the_same_macaddr == true) - { + if (check_fwstate(pmlmepriv, _FW_LINKED)) { + if (the_same_macaddr == true) { ptarget_wlan = rtw_find_network23a(&pmlmepriv->scanned_queue, cur_network->network.MacAddress); - } - else - { + } else { pcur_wlan = rtw_find_network23a(&pmlmepriv->scanned_queue, cur_network->network.MacAddress); - if(pcur_wlan) pcur_wlan->fixed = false; + if (pcur_wlan) + pcur_wlan->fixed = false; pcur_sta = rtw_get_stainfo23a(pstapriv, cur_network->network.MacAddress); - if(pcur_sta) { + if (pcur_sta) { spin_lock_bh(&pstapriv->sta_hash_lock); - rtw_free_stainfo23a(adapter, pcur_sta); + rtw_free_stainfo23a(adapter, + pcur_sta); spin_unlock_bh(&pstapriv->sta_hash_lock); } ptarget_wlan = rtw_find_network23a(&pmlmepriv->scanned_queue, pnetwork->network.MacAddress); - if(check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) { - if(ptarget_wlan) ptarget_wlan->fixed = true; + if (check_fwstate(pmlmepriv, + WIFI_STATION_STATE)) { + if (ptarget_wlan) + ptarget_wlan->fixed = + true; } } - } - else - { - ptarget_wlan = rtw_find_network23a(&pmlmepriv->scanned_queue, pnetwork->network.MacAddress); - if(check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) { - if(ptarget_wlan) ptarget_wlan->fixed = true; + } else { + ptarget_wlan = rtw_find_network23a( + &pmlmepriv->scanned_queue, + pnetwork->network.MacAddress); + if (check_fwstate(pmlmepriv, + WIFI_STATION_STATE)) { + if (ptarget_wlan) + ptarget_wlan->fixed = true; } } /* s2. update cur_network */ - if(ptarget_wlan) - { - rtw_joinbss_update_network23a(adapter, ptarget_wlan, pnetwork); - } - else - { - RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_,("Can't find ptarget_wlan when joinbss_event callback\n")); + if (ptarget_wlan) + rtw_joinbss_update_network23a(adapter, + ptarget_wlan, + pnetwork); + else { + RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_, + ("Can't find ptarget_wlan when " + "joinbss_event callback\n")); spin_unlock_bh(&pmlmepriv->scanned_queue.lock); goto ignore_joinbss_callback; } - /* s3. find ptarget_sta & update ptarget_sta after update cur_network only for station mode */ - if(check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) - { - ptarget_sta = rtw_joinbss_update_stainfo(adapter, pnetwork); - if(ptarget_sta==NULL) - { - RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_,("Can't update stainfo when joinbss_event callback\n")); + /* s3. find ptarget_sta & update ptarget_sta after + update cur_network only for station mode */ + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { + ptarget_sta = rtw_joinbss_update_stainfo( + adapter, pnetwork); + if (!ptarget_sta) { + RT_TRACE(_module_rtl871x_mlme_c_, + _drv_err_, + ("Can't update stainfo when " + "joinbss_event callback\n")); spin_unlock_bh(&pmlmepriv->scanned_queue.lock); goto ignore_joinbss_callback; } } /* s4. indicate connect */ - if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) - { + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) rtw_indicate_connect23a(adapter); - } else { - /* adhoc mode will rtw_indicate_connect23a when rtw_stassoc_event_callback23a */ - RT_TRACE(_module_rtl871x_mlme_c_,_drv_info_,("adhoc mode, fw_state:%x", get_fwstate(pmlmepriv))); + else { + /* adhoc mode will rtw_indicate_connect23a + when rtw_stassoc_event_callback23a */ + RT_TRACE(_module_rtl871x_mlme_c_,_drv_info_, + ("adhoc mode, fw_state:%x", + get_fwstate(pmlmepriv))); } /* s5. Cancle assoc_timer */ del_timer_sync(&pmlmepriv->assoc_timer); - RT_TRACE(_module_rtl871x_mlme_c_,_drv_info_,("Cancle assoc_timer\n")); + RT_TRACE(_module_rtl871x_mlme_c_,_drv_info_, + ("Cancle assoc_timer\n")); } else { RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("rtw23a_joinbss_event_cb err: fw_state:%x", @@ -1252,20 +1323,19 @@ void rtw_joinbss_event_prehandle23a(struct rtw_adapter *adapter, u8 *pbuf) goto ignore_joinbss_callback; } spin_unlock_bh(&pmlmepriv->scanned_queue.lock); - } else if(pnetwork->join_res == -4) { + } else if (pnetwork->join_res == -4) { rtw_reset_securitypriv23a(adapter); mod_timer(&pmlmepriv->assoc_timer, jiffies + msecs_to_jiffies(1)); /* rtw_free_assoc_resources23a(adapter, 1); */ - if((check_fwstate(pmlmepriv, _FW_UNDER_LINKING))) { + if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) { RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, - ("fail! clear _FW_UNDER_LINKING ^^^fw_state=%x\n", - get_fwstate(pmlmepriv))); + ("fail! clear _FW_UNDER_LINKING ^^^fw_state=" + "%x\n", get_fwstate(pmlmepriv))); _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING); } - } else { /* if join_res < 0 (join fails), then try again */ mod_timer(&pmlmepriv->assoc_timer, @@ -1280,28 +1350,26 @@ ignore_joinbss_callback: void rtw23a_joinbss_event_cb(struct rtw_adapter *adapter, u8 *pbuf) { - struct wlan_network *pnetwork = (struct wlan_network *)pbuf; + struct wlan_network *pnetwork = (struct wlan_network *)pbuf; mlmeext_joinbss_event_callback23a(adapter, pnetwork->join_res); rtw_os_xmit_schedule23a(adapter); - } void rtw_stassoc_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf) { struct sta_info *psta; struct mlme_priv *pmlmepriv = &adapter->mlmepriv; - struct stassoc_event *pstassoc = (struct stassoc_event*)pbuf; + struct stassoc_event *pstassoc = (struct stassoc_event*)pbuf; struct wlan_network *cur_network = &pmlmepriv->cur_network; - struct wlan_network *ptarget_wlan = NULL; + struct wlan_network *ptarget_wlan; - if(rtw_access_ctrl23a(adapter, pstassoc->macaddr) == false) + if (rtw_access_ctrl23a(adapter, pstassoc->macaddr) == false) return; #ifdef CONFIG_8723AU_AP_MODE - if(check_fwstate(pmlmepriv, WIFI_AP_STATE)) - { + if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { psta = rtw_get_stainfo23a(&adapter->stapriv, pstassoc->macaddr); if (psta) { /* bss_cap_update_on_sta_join23a(adapter, psta); */ @@ -1315,13 +1383,19 @@ void rtw_stassoc_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf) psta = rtw_get_stainfo23a(&adapter->stapriv, pstassoc->macaddr); if (psta != NULL) { /* the sta have been in sta_info_queue => do nothing */ - RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_,("Error: rtw_stassoc_event_callback23a: sta has been in sta_hash_queue\n")); - return; /* between drv has received this event before and fw have not yet to set key to CAM_ENTRY) */ + RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_, + ("Error: rtw_stassoc_event_callback23a: sta has " + "been in sta_hash_queue\n")); + /* between drv has received this event before and + fw have not yet to set key to CAM_ENTRY) */ + return; } psta = rtw_alloc_stainfo23a(&adapter->stapriv, pstassoc->macaddr); - if (psta == NULL) { - RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_,("Can't alloc sta_info when rtw_stassoc_event_callback23a\n")); + if (!psta) { + RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_, + ("Can't alloc sta_info when " + "rtw_stassoc_event_callback23a\n")); return; } @@ -1331,23 +1405,25 @@ void rtw_stassoc_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf) /* psta->aid = (uint)pstassoc->cam_id; */ DBG_8723A("%s\n",__func__); /* for ad-hoc mode */ - rtw_hal_set_odm_var23a(adapter,HAL_ODM_STA_INFO,psta,true); + rtw_hal_set_odm_var23a(adapter, HAL_ODM_STA_INFO, psta, true); - if(adapter->securitypriv.dot11AuthAlgrthm==dot11AuthAlgrthm_8021X) - psta->dot118021XPrivacy = adapter->securitypriv.dot11PrivacyAlgrthm; + if (adapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) + psta->dot118021XPrivacy = + adapter->securitypriv.dot11PrivacyAlgrthm; psta->ieee8021x_blocked = false; spin_lock_bh(&pmlmepriv->lock); - if ( (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)==true ) || - (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)==true ) ) - { - if(adapter->stapriv.asoc_sta_count== 2) - { + if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) || + check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) { + if (adapter->stapriv.asoc_sta_count == 2) { spin_lock_bh(&pmlmepriv->scanned_queue.lock); - ptarget_wlan = rtw_find_network23a(&pmlmepriv->scanned_queue, cur_network->network.MacAddress); - if(ptarget_wlan) ptarget_wlan->fixed = true; + ptarget_wlan = + rtw_find_network23a(&pmlmepriv->scanned_queue, + cur_network->network.MacAddress); + if (ptarget_wlan) + ptarget_wlan->fixed = true; spin_unlock_bh(&pmlmepriv->scanned_queue.lock); /* a sta + bc/mc_stainfo (not Ibss_stainfo) */ rtw_indicate_connect23a(adapter); @@ -1361,40 +1437,40 @@ void rtw_stassoc_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf) void rtw_stadel_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf) { - int mac_id=-1; + int mac_id; struct sta_info *psta; - struct wlan_network* pwlan = NULL; - struct wlan_bssid_ex *pdev_network=NULL; - u8* pibss = NULL; - struct mlme_priv *pmlmepriv = &adapter->mlmepriv; - struct stadel_event *pstadel = (struct stadel_event*)pbuf; - struct sta_priv *pstapriv = &adapter->stapriv; + struct wlan_network* pwlan; + struct wlan_bssid_ex *pdev_network; + u8 *pibss; + struct mlme_priv *pmlmepriv = &adapter->mlmepriv; + struct stadel_event *pstadel = (struct stadel_event *)pbuf; + struct sta_priv *pstapriv = &adapter->stapriv; struct wlan_network *tgt_network = &pmlmepriv->cur_network; psta = rtw_get_stainfo23a(&adapter->stapriv, pstadel->macaddr); - if(psta) + if (psta) mac_id = psta->mac_id; else mac_id = pstadel->mac_id; - DBG_8723A("%s(mac_id=%d)=" MAC_FMT "\n", __func__, mac_id, MAC_ARG(pstadel->macaddr)); + DBG_8723A("%s(mac_id=%d)=" MAC_FMT "\n", __func__, mac_id, + MAC_ARG(pstadel->macaddr)); if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) - { return; - } mlmeext_sta_del_event_callback23a(adapter); spin_lock_bh(&pmlmepriv->lock); - if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) - { - if (rtw_to_roaming(adapter) > 0) - pmlmepriv->to_roaming--; /* this stadel_event is caused by roaming, decrease to_roaming */ - else if (rtw_to_roaming(adapter) == 0) + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { + if (rtw_to_roaming(adapter) > 0) { + /* this stadel_event is caused by roaming, + decrease to_roaming */ + pmlmepriv->to_roaming--; + } else if (rtw_to_roaming(adapter) == 0) rtw_set_roaming(adapter, adapter->registrypriv.max_roaming_times); - if (*((unsigned short *)(pstadel->rsvd)) != WLAN_REASON_EXPIRATION_CHK) + if (*((u16 *)pstadel->rsvd) != WLAN_REASON_EXPIRATION_CHK) rtw_set_roaming(adapter, 0); /* don't roam */ rtw_free_uc_swdec_pending_queue23a(adapter); @@ -1403,7 +1479,8 @@ void rtw_stadel_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf) rtw_indicate_disconnect23a(adapter); spin_lock_bh(&pmlmepriv->scanned_queue.lock); /* remove the network entry in scanned_queue */ - pwlan = rtw_find_network23a(&pmlmepriv->scanned_queue, tgt_network->network.MacAddress); + pwlan = rtw_find_network23a(&pmlmepriv->scanned_queue, + tgt_network->network.MacAddress); if (pwlan) { pwlan->fixed = false; rtw_free_network_nolock(pmlmepriv, pwlan); @@ -1414,21 +1491,21 @@ void rtw_stadel_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf) } if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) || - check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) - { + check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) { spin_lock_bh(&pstapriv->sta_hash_lock); rtw_free_stainfo23a(adapter, psta); spin_unlock_bh(&pstapriv->sta_hash_lock); - if (adapter->stapriv.asoc_sta_count == 1) /* a sta + bc/mc_stainfo (not Ibss_stainfo) */ - { + /* a sta + bc/mc_stainfo (not Ibss_stainfo) */ + if (adapter->stapriv.asoc_sta_count == 1) { spin_lock_bh(&pmlmepriv->scanned_queue.lock); /* free old ibss network */ - /* pwlan = rtw_find_network23a(&pmlmepriv->scanned_queue, pstadel->macaddr); */ - pwlan = rtw_find_network23a(&pmlmepriv->scanned_queue, tgt_network->network.MacAddress); - if (pwlan) - { + /* pwlan = rtw_find_network23a( + &pmlmepriv->scanned_queue, pstadel->macaddr); */ + pwlan = rtw_find_network23a(&pmlmepriv->scanned_queue, + tgt_network->network.MacAddress); + if (pwlan) { pwlan->fixed = false; rtw_free_network_nolock(pmlmepriv, pwlan); } @@ -1437,7 +1514,8 @@ void rtw_stadel_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf) pdev_network = &adapter->registrypriv.dev_network; pibss = adapter->registrypriv.dev_network.MacAddress; - memcpy(pdev_network, &tgt_network->network, get_wlan_bssid_ex_sz(&tgt_network->network)); + memcpy(pdev_network, &tgt_network->network, + get_wlan_bssid_ex_sz(&tgt_network->network)); memset(&pdev_network->Ssid, 0, sizeof(struct cfg80211_ssid)); @@ -1448,32 +1526,28 @@ void rtw_stadel_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf) rtw_generate_random_ibss23a(pibss); - if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) - { + if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) { set_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE); _clr_fwstate_(pmlmepriv, WIFI_ADHOC_STATE); } - if (rtw_createbss_cmd23a(adapter)!= _SUCCESS) - { - - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("***Error =>stadel_event_callback: rtw_createbss_cmd23a status FAIL***\n ")); - + if (rtw_createbss_cmd23a(adapter) != _SUCCESS) { + RT_TRACE(_module_rtl871x_ioctl_set_c_, + _drv_err_, + ("***Error =>stadel_event_callback: " + "rtw_createbss_cmd23a status " + "FAIL***\n")); } - } - } spin_unlock_bh(&pmlmepriv->lock); - } void rtw_cpwm_event_callback23a(struct rtw_adapter *padapter, u8 *pbuf) { - - RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_,("+rtw_cpwm_event_callback23a !!!\n")); - + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, + ("+rtw_cpwm_event_callback23a !!!\n")); } /* @@ -1488,23 +1562,26 @@ void rtw23a_join_to_handler (unsigned long data) DBG_8723A("%s, fw_state=%x\n", __func__, get_fwstate(pmlmepriv)); - if(adapter->bDriverStopped ||adapter->bSurpriseRemoved) + if (adapter->bDriverStopped ||adapter->bSurpriseRemoved) return; spin_lock_bh(&pmlmepriv->lock); if (rtw_to_roaming(adapter) > 0) { /* join timeout caused by roaming */ - while(1) { + while (1) { pmlmepriv->to_roaming--; if (rtw_to_roaming(adapter) != 0) { /* try another */ DBG_8723A("%s try another roaming\n", __func__); - if (_SUCCESS!= (do_join_r = rtw_do_join23a(adapter))) { - DBG_8723A("%s roaming do_join return %d\n", __func__ , do_join_r); + do_join_r = rtw_do_join23a(adapter); + if (do_join_r != _SUCCESS) { + DBG_8723A("%s roaming do_join return " + "%d\n", __func__ , do_join_r); continue; } break; } else { - DBG_8723A("%s We've try roaming but fail\n", __func__); + DBG_8723A("%s We've try roaming but fail\n", + __func__); rtw_indicate_disconnect23a(adapter); break; } @@ -1513,7 +1590,8 @@ void rtw23a_join_to_handler (unsigned long data) rtw_indicate_disconnect23a(adapter); free_scanqueue(pmlmepriv);/* */ - /* indicate disconnect for the case that join_timeout and check_fwstate != FW_LINKED */ + /* indicate disconnect for the case that join_timeout and + check_fwstate != FW_LINKED */ rtw_cfg80211_indicate_disconnect(adapter); } @@ -1530,7 +1608,8 @@ void rtw_scan_timeout_handler23a(unsigned long data) struct rtw_adapter *adapter = (struct rtw_adapter *)data; struct mlme_priv *pmlmepriv = &adapter->mlmepriv; - DBG_8723A(FUNC_ADPT_FMT" fw_state =%x\n", FUNC_ADPT_ARG(adapter), get_fwstate(pmlmepriv)); + DBG_8723A(FUNC_ADPT_FMT" fw_state =%x\n", FUNC_ADPT_ARG(adapter), + get_fwstate(pmlmepriv)); spin_lock_bh(&pmlmepriv->lock); @@ -1551,7 +1630,8 @@ static void rtw_auto_scan_handler(struct rtw_adapter *padapter) if (pmlmepriv->scan_interval == 0) { DBG_8723A("%s\n", __func__); rtw_set_802_11_bssid23a_list_scan(padapter, NULL, 0); - pmlmepriv->scan_interval = SCAN_INTERVAL;/* 30*2 sec = 60sec */ + /* 30*2 sec = 60sec */ + pmlmepriv->scan_interval = SCAN_INTERVAL; } } } @@ -1564,7 +1644,8 @@ void rtw_dynamic_check_timer_handler(unsigned long data) if (adapter->hw_init_completed == false) goto out; - if ((adapter->bDriverStopped == true)||(adapter->bSurpriseRemoved == true)) + if (adapter->bDriverStopped == true || + adapter->bSurpriseRemoved == true) goto out; if (adapter->net_closed == true) @@ -1615,15 +1696,19 @@ void rtw_set_scan_deny(struct rtw_adapter *adapter, u32 ms) #endif /* -* Select a new join candidate from the original @param candidate and @param competitor +* Select a new join candidate from the original @param candidate and +* @param competitor * @return true: candidate is updated * @return false: candidate is not updated */ -static int rtw_check_join_candidate(struct mlme_priv *pmlmepriv - , struct wlan_network **candidate, struct wlan_network *competitor) +static int rtw_check_join_candidate(struct mlme_priv *pmlmepriv, + struct wlan_network **candidate, + struct wlan_network *competitor) { int updated = false; - struct rtw_adapter *adapter = container_of(pmlmepriv, struct rtw_adapter, mlmepriv); + struct rtw_adapter *adapter; + + adapter = container_of(pmlmepriv, struct rtw_adapter, mlmepriv); /* check bssid, if needed */ if (pmlmepriv->assoc_by_bssid == true) { @@ -1642,7 +1727,7 @@ static int rtw_check_join_candidate(struct mlme_priv *pmlmepriv goto exit; } - if (rtw_is_desired_network(adapter, competitor) == false) + if (rtw_is_desired_network(adapter, competitor) == false) goto exit; if (rtw_to_roaming(adapter) > 0) { @@ -1655,19 +1740,21 @@ static int rtw_check_join_candidate(struct mlme_priv *pmlmepriv goto exit; } - if (*candidate == NULL ||(*candidate)->network.Rssinetwork.Rssi) { + if (!*candidate || + (*candidate)->network.Rssinetwork.Rssi) { *candidate = competitor; updated = true; } if (updated) { - DBG_8723A("[by_bssid:%u][assoc_ssid:%s][to_roaming:%u] new candidate: %s("MAC_FMT") rssi:%d\n", - pmlmepriv->assoc_by_bssid, - pmlmepriv->assoc_ssid.ssid, - rtw_to_roaming(adapter), - (*candidate)->network.Ssid.ssid, - MAC_ARG((*candidate)->network.MacAddress), - (int)(*candidate)->network.Rssi); + DBG_8723A("[by_bssid:%u][assoc_ssid:%s][to_roaming:%u] " + "new candidate: %s("MAC_FMT") rssi:%d\n", + pmlmepriv->assoc_by_bssid, + pmlmepriv->assoc_ssid.ssid, + rtw_to_roaming(adapter), + (*candidate)->network.Ssid.ssid, + MAC_ARG((*candidate)->network.MacAddress), + (int)(*candidate)->network.Rssi); } exit: @@ -1690,8 +1777,8 @@ int rtw_select_and_join_from_scanned_queue23a(struct mlme_priv *pmlmepriv) struct list_head *phead, *plist, *ptmp; struct rtw_adapter *adapter; struct rtw_queue *queue = &pmlmepriv->scanned_queue; - struct wlan_network *pnetwork = NULL; - struct wlan_network *candidate = NULL; + struct wlan_network *pnetwork; + struct wlan_network *candidate = NULL; spin_lock_bh(&pmlmepriv->scanned_queue.lock); phead = get_list_head(queue); @@ -1722,7 +1809,7 @@ int rtw_select_and_join_from_scanned_queue23a(struct mlme_priv *pmlmepriv) } /* check for situation of _FW_LINKED */ - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) { + if (check_fwstate(pmlmepriv, _FW_LINKED)) { DBG_8723A("%s: _FW_LINKED while ask_for_joinbss!!!\n", __func__); @@ -1740,7 +1827,7 @@ exit: } int rtw_set_auth23a(struct rtw_adapter * adapter, - struct security_priv *psecuritypriv) + struct security_priv *psecuritypriv) { struct cmd_obj* pcmd; struct setauth_parm *psetauthparm; @@ -1783,7 +1870,7 @@ exit: } int rtw_set_key23a(struct rtw_adapter *adapter, - struct security_priv *psecuritypriv, int keyid, u8 set_tx) + struct security_priv *psecuritypriv, int keyid, u8 set_tx) { u8 keylen; struct cmd_obj *pcmd; @@ -1808,9 +1895,9 @@ int rtw_set_key23a(struct rtw_adapter *adapter, psetkeyparm->algorithm = (unsigned char) psecuritypriv->dot118021XGrpPrivacy; RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, - ("\n rtw_set_key23a: psetkeyparm->algorithm = (unsigned " - "char)psecuritypriv->dot118021XGrpPrivacy =%d\n", - psetkeyparm->algorithm)); + ("\n rtw_set_key23a: psetkeyparm->algorithm = " + "(unsigned char)psecuritypriv->dot118021XGrpPrivacy " + "=%d\n", psetkeyparm->algorithm)); } else { psetkeyparm->algorithm = (u8)psecuritypriv->dot11PrivacyAlgrthm; RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, @@ -1855,8 +1942,8 @@ int rtw_set_key23a(struct rtw_adapter *adapter, break; default: RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, - ("\n rtw_set_key23a:psecuritypriv->dot11PrivacyAlgrthm = " - "%x (must be 1 or 2 or 4 or 5)\n", + ("\n rtw_set_key23a:psecuritypriv->dot11PrivacyAlgrthm" + " = %x (must be 1 or 2 or 4 or 5)\n", psecuritypriv->dot11PrivacyAlgrthm)); res = _FAIL; kfree(pcmd); @@ -1889,7 +1976,7 @@ int rtw_restruct_wmm_ie23a(struct rtw_adapter *adapter, u8 *in_ie, unsigned int i, j; i = 12; /* after the fixed IE */ - while(i < in_len) { + while (i < in_len) { ielength = initial_out_len; /* WMM element ID and OUI */ @@ -1940,11 +2027,11 @@ static int SecIsInPMKIDList(struct rtw_adapter *Adapter, u8 *bssid) i++; /* continue; */ } - } while(i < NUM_PMKID_CACHE); + } while (i < NUM_PMKID_CACHE); - if (i == NUM_PMKID_CACHE) { + if (i == NUM_PMKID_CACHE) i = -1;/* Could not find. */ - } else { + else { /* There is one Pre-Authentication Key for the specific BSSID. */ } @@ -1983,7 +2070,7 @@ static int rtw_append_pmkid(struct rtw_adapter *Adapter, int iEntry, } int rtw_restruct_sec_ie23a(struct rtw_adapter *adapter, u8 *in_ie, u8 *out_ie, - uint in_len) + uint in_len) { u8 authmode; uint ielength; @@ -1994,26 +2081,26 @@ int rtw_restruct_sec_ie23a(struct rtw_adapter *adapter, u8 *in_ie, u8 *out_ie, uint ndissecuritytype = psecuritypriv->ndisencryptstatus; RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, - ("+rtw_restruct_sec_ie23a: ndisauthmode=%d ndissecuritytype=%d\n", - ndisauthmode, ndissecuritytype)); + ("+rtw_restruct_sec_ie23a: ndisauthmode=%d " + "ndissecuritytype=%d\n", ndisauthmode, ndissecuritytype)); /* copy fixed ie only */ memcpy(out_ie, in_ie, 12); ielength = 12; - if ((ndisauthmode==Ndis802_11AuthModeWPA) || - (ndisauthmode==Ndis802_11AuthModeWPAPSK)) + if (ndisauthmode == Ndis802_11AuthModeWPA || + ndisauthmode == Ndis802_11AuthModeWPAPSK) authmode = WLAN_EID_VENDOR_SPECIFIC; - if ((ndisauthmode==Ndis802_11AuthModeWPA2) || - (ndisauthmode==Ndis802_11AuthModeWPA2PSK)) - authmode=_WPA2_IE_ID_; + if (ndisauthmode == Ndis802_11AuthModeWPA2 || + ndisauthmode == Ndis802_11AuthModeWPA2PSK) + authmode = _WPA2_IE_ID_; if (check_fwstate(pmlmepriv, WIFI_UNDER_WPS)) { memcpy(out_ie + ielength, psecuritypriv->wps_ie, psecuritypriv->wps_ie_len); ielength += psecuritypriv->wps_ie_len; - } else if ((authmode == WLAN_EID_VENDOR_SPECIFIC) || - (authmode==_WPA2_IE_ID_)) { + } else if (authmode == WLAN_EID_VENDOR_SPECIFIC || + authmode == _WPA2_IE_ID_) { /* copy RSN or SSN */ memcpy(&out_ie[ielength], &psecuritypriv->supplicant_ie[0], psecuritypriv->supplicant_ie[1] + 2); @@ -2021,13 +2108,12 @@ int rtw_restruct_sec_ie23a(struct rtw_adapter *adapter, u8 *in_ie, u8 *out_ie, } iEntry = SecIsInPMKIDList(adapter, pmlmepriv->assoc_bssid); - if (iEntry < 0) { + if (iEntry < 0) return ielength; - } else { - if (authmode == _WPA2_IE_ID_) { - ielength=rtw_append_pmkid(adapter, iEntry, - out_ie, ielength); - } + else { + if (authmode == _WPA2_IE_ID_) + ielength = rtw_append_pmkid(adapter, iEntry, + out_ie, ielength); } return ielength; @@ -2120,7 +2206,6 @@ void rtw_update_registrypriv_dev_network23a(struct rtw_adapter* adapter) /* notes: translate IELength & Length after assign the Length to cmdsz in createbss_cmd(); */ /* pdev_network->IELength = cpu_to_le32(sz); */ - } void rtw_get_encrypt_decrypt_from_registrypriv23a(struct rtw_adapter* adapter) @@ -2285,8 +2370,8 @@ void rtw_update_ht_cap23a(struct rtw_adapter *padapter, u8 *pie, uint ie_len) /* update cur_bwmode & cur_ch_offset */ if (pregistrypriv->cbw40_enable && - (pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info & BIT(1)) && - (pmlmeinfo->HT_info.infos[0] & BIT(2))) { + pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info & BIT(1) && + pmlmeinfo->HT_info.infos[0] & BIT(2)) { int i; u8 rf_type; @@ -2294,7 +2379,7 @@ void rtw_update_ht_cap23a(struct rtw_adapter *padapter, u8 *pie, uint ie_len) /* update the MCS rates */ for (i = 0; i < 16; i++) { - if ((rf_type == RF_1T1R) || (rf_type == RF_1T2R)) + if (rf_type == RF_1T1R || rf_type == RF_1T2R) pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate[i] &= MCS_rate_1R23A[i]; else pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate[i] &= MCS_rate_2R23A[i]; @@ -2332,52 +2417,52 @@ void rtw_update_ht_cap23a(struct rtw_adapter *padapter, u8 *pie, uint ie_len) pmlmeinfo->HT_protection = pmlmeinfo->HT_info.infos[1] & 0x3; } -void rtw_issue_addbareq_cmd23a(struct rtw_adapter *padapter, struct xmit_frame *pxmitframe) +void rtw_issue_addbareq_cmd23a(struct rtw_adapter *padapter, + struct xmit_frame *pxmitframe) { u8 issued; int priority; - struct sta_info *psta = NULL; + struct sta_info *psta; struct ht_priv *phtpriv; struct pkt_attrib *pattrib = &pxmitframe->attrib; s32 bmcst = is_multicast_ether_addr(pattrib->ra); - if (bmcst || (padapter->mlmepriv.LinkDetectInfo.NumTxOkInPeriod<100)) + if (bmcst || padapter->mlmepriv.LinkDetectInfo.NumTxOkInPeriod < 100) return; priority = pattrib->priority; if (pattrib->psta) psta = pattrib->psta; - else - { + else { DBG_8723A("%s, call rtw_get_stainfo23a()\n", __func__); psta = rtw_get_stainfo23a(&padapter->stapriv, pattrib->ra); } - if (psta == NULL) - { + if (!psta) { DBG_8723A("%s, psta == NUL\n", __func__); return; } - if (!(psta->state &_FW_LINKED)) - { - DBG_8723A("%s, psta->state(0x%x) != _FW_LINKED\n", __func__, psta->state); + if (!(psta->state &_FW_LINKED)) { + DBG_8723A("%s, psta->state(0x%x) != _FW_LINKED\n", + __func__, psta->state); return; } phtpriv = &psta->htpriv; - if ((phtpriv->ht_option == true) && (phtpriv->ampdu_enable == true)) - { + if (phtpriv->ht_option == true && phtpriv->ampdu_enable == true) { issued = (phtpriv->agg_enable_bitmap>>priority)&0x1; issued |= (phtpriv->candidate_tid_bitmap>>priority)&0x1; - if (0 == issued) - { - DBG_8723A("rtw_issue_addbareq_cmd23a, p =%d\n", priority); - psta->htpriv.candidate_tid_bitmap |= CHKBIT((u8)priority); - rtw_addbareq_cmd23a(padapter, (u8) priority, pattrib->ra); + if (issued == 0) { + DBG_8723A("rtw_issue_addbareq_cmd23a, p =%d\n", + priority); + psta->htpriv.candidate_tid_bitmap |= + CHKBIT((u8)priority); + rtw_addbareq_cmd23a(padapter, (u8) priority, + pattrib->ra); } } } @@ -2394,21 +2479,23 @@ inline u8 rtw_to_roaming(struct rtw_adapter *adapter) return adapter->mlmepriv.to_roaming; } -void rtw23a_roaming(struct rtw_adapter *padapter, struct wlan_network *tgt_network) +void rtw23a_roaming(struct rtw_adapter *padapter, + struct wlan_network *tgt_network) { - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; spin_lock_bh(&pmlmepriv->lock); _rtw23a_roaming(padapter, tgt_network); spin_unlock_bh(&pmlmepriv->lock); } -void _rtw23a_roaming(struct rtw_adapter *padapter, struct wlan_network *tgt_network) +void _rtw23a_roaming(struct rtw_adapter *padapter, + struct wlan_network *tgt_network) { - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct wlan_network *pnetwork; int do_join_r; - if (tgt_network != NULL) + if (tgt_network) pnetwork = tgt_network; else pnetwork = &pmlmepriv->cur_network; @@ -2423,17 +2510,21 @@ void _rtw23a_roaming(struct rtw_adapter *padapter, struct wlan_network *tgt_netw pmlmepriv->assoc_by_bssid = false; - while(1) { - if (_SUCCESS == (do_join_r = rtw_do_join23a(padapter))) { + while (1) { + do_join_r = rtw_do_join23a(padapter); + if (do_join_r == _SUCCESS) break; - } else { - DBG_8723A("roaming do_join return %d\n", do_join_r); + else { + DBG_8723A("roaming do_join return %d\n", + do_join_r); pmlmepriv->to_roaming--; - if (0 < rtw_to_roaming(padapter)) { + if (0 < rtw_to_roaming(padapter)) continue; - } else { - DBG_8723A("%s(%d) -to roaming fail, indicate_disconnect\n", __func__, __LINE__); + else { + DBG_8723A("%s(%d) -to roaming fail, " + "indicate_disconnect\n", + __func__, __LINE__); rtw_indicate_disconnect23a(padapter); break; } -- 2.20.1