From 8414aef8bdb802347d7bb225281b8d8590d06c39 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Sat, 10 Aug 2013 11:56:55 -0500 Subject: [PATCH] rtl8188eu: Fix checkpatch errors in os_dep/ioctl_linux.c Signed-off-by: Larry Finger --- os_dep/ioctl_linux.c | 7412 +++++++++++++++++------------------------- 1 file changed, 2971 insertions(+), 4441 deletions(-) diff --git a/os_dep/ioctl_linux.c b/os_dep/ioctl_linux.c index 834e906..aa40c4b 100644 --- a/os_dep/ioctl_linux.c +++ b/os_dep/ioctl_linux.c @@ -38,19 +38,18 @@ #include #include -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)) +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 27)) #define iwe_stream_add_event(a, b, c, d, e) iwe_stream_add_event(b, c, d, e) #define iwe_stream_add_point(a, b, c, d, e) iwe_stream_add_point(b, c, d, e) #endif - -#define RTL_IOCTL_WPA_SUPPLICANT SIOCIWFIRSTPRIV+30 +#define RTL_IOCTL_WPA_SUPPLICANT (SIOCIWFIRSTPRIV + 30) #define SCAN_ITEM_SIZE 768 #define MAX_CUSTOM_LEN 64 #define RATE_COUNT 4 -// combo scan +/* combo scan */ #define WEXT_CSCAN_AMOUNT 9 #define WEXT_CSCAN_BUF_LEN 360 #define WEXT_CSCAN_HEADER "CSCAN S\x01\x00\x00S\x00" @@ -65,15 +64,17 @@ static u8 convert_ip_addr(u8 hch, u8 mch, u8 lch) { - return ((key_char2num(hch) * 100) + (key_char2num(mch) * 10 ) + key_char2num(lch)); + return (key_char2num(hch) * 100) + (key_char2num(mch) * 10) + + key_char2num(lch); } -static u32 rtw_rates[] = {1000000,2000000,5500000,11000000, - 6000000,9000000,12000000,18000000,24000000,36000000,48000000,54000000}; +static u32 rtw_rates[] = {1000000, 2000000, 5500000, 11000000, + 6000000, 9000000, 12000000, 18000000, 24000000, 36000000, + 48000000, 54000000}; -static const char * const iw_operation_mode[] = -{ - "Auto", "Ad-Hoc", "Managed", "Master", "Repeater", "Secondary", "Monitor" +static const char * const iw_operation_mode[] = { + "Auto", "Ad-Hoc", "Managed", "Master", "Repeater", + "Secondary", "Monitor" }; static int hex2num_i(char c) @@ -132,7 +133,7 @@ static void indicate_wx_custom_event(struct adapter *padapter, char *msg) union iwreq_data wrqu; if (strlen(msg) > IW_CUSTOM_MAX) { - DBG_88E("%s strlen(msg):%zu > IW_CUSTOM_MAX:%u\n", __func__ , strlen(msg), IW_CUSTOM_MAX); + DBG_88E("%s strlen(msg):%zu > IW_CUSTOM_MAX:%u\n", __func__, strlen(msg), IW_CUSTOM_MAX); return; } @@ -142,7 +143,7 @@ static void indicate_wx_custom_event(struct adapter *padapter, char *msg) _rtw_memcpy(buff, msg, strlen(msg)); - _rtw_memset(&wrqu,0,sizeof(wrqu)); + _rtw_memset(&wrqu, 0, sizeof(wrqu)); wrqu.data.length = strlen(msg); DBG_88E("%s %s\n", __func__, buff); @@ -156,35 +157,21 @@ static void request_wps_pbc_event(struct adapter *padapter) u8 *buff, *p; union iwreq_data wrqu; - buff = rtw_malloc(IW_CUSTOM_MAX); if (!buff) return; - _rtw_memset(buff, 0, IW_CUSTOM_MAX); - - p=buff; - - p+=sprintf(p, "WPS_PBC_START.request=true"); - - _rtw_memset(&wrqu,0,sizeof(wrqu)); - + p = buff; + p += sprintf(p, "WPS_PBC_START.request = true"); + _rtw_memset(&wrqu, 0, sizeof(wrqu)); wrqu.data.length = p-buff; - - wrqu.data.length = (wrqu.data.lengthpnetdev, IWEVCUSTOM, &wrqu, buff); - if (buff) - { rtw_mfree(buff, IW_CUSTOM_MAX); - } - } - void indicate_wx_scan_complete_event(struct adapter *padapter) { union iwreq_data wrqu; @@ -195,7 +182,6 @@ void indicate_wx_scan_complete_event(struct adapter *padapter) wireless_send_event(padapter->pnetdev, SIOCGIWSCAN, &wrqu, NULL); } - void rtw_indicate_wx_assoc_event(struct adapter *padapter) { union iwreq_data wrqu; @@ -224,41 +210,10 @@ void rtw_indicate_wx_disassoc_event(struct adapter *padapter) wireless_send_event(padapter->pnetdev, SIOCGIWAP, &wrqu, NULL); } -/* -uint rtw_is_cckrates_included(u8 *rate) -{ - u32 i = 0; - - while (rate[i]!=0) - { - if ( (((rate[i]) & 0x7f) == 2) || (((rate[i]) & 0x7f) == 4) || - (((rate[i]) & 0x7f) == 11) || (((rate[i]) & 0x7f) == 22)) - return true; - i++; - } - - return false; -} - -uint rtw_is_cckratesonly_included(u8 *rate) -{ - u32 i = 0; - - while (rate[i]!=0) - { - if ( (((rate[i]) & 0x7f) != 2) && (((rate[i]) & 0x7f) != 4) && - (((rate[i]) & 0x7f) != 11) && (((rate[i]) & 0x7f) != 22)) - return false; - i++; - } - - return true; -} -*/ - static char *translate_scan(struct adapter *padapter, - struct iw_request_info* info, struct wlan_network *pnetwork, - char *start, char *stop) + struct iw_request_info *info, + struct wlan_network *pnetwork, + char *start, char *stop) { struct iw_event iwe; u16 cap; @@ -266,52 +221,44 @@ static char *translate_scan(struct adapter *padapter, u32 ht_ielen = 0; char custom[MAX_CUSTOM_LEN]; char *p; - u16 max_rate=0, rate, ht_cap=false; + u16 max_rate = 0, rate, ht_cap = false; u32 i = 0; char *current_val; long rssi; - u8 bw_40MHz=0, short_GI=0; - u16 mcs_rate=0; + u8 bw_40MHz = 0, short_GI = 0; + u16 mcs_rate = 0; struct registry_priv *pregpriv = &padapter->registrypriv; #ifdef CONFIG_P2P - struct wifidirect_info *pwdinfo = &padapter->wdinfo; -#endif //CONFIG_P2P + struct wifidirect_info *pwdinfo = &padapter->wdinfo; +#endif /* CONFIG_P2P */ #ifdef CONFIG_P2P - if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) - { + if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) { u32 blnGotP2PIE = false; - // User is doing the P2P device discovery - // The prefix of SSID should be "DIRECT-" and the IE should contains the P2P IE. - // If not, the driver should ignore this AP and go to the next AP. + /* User is doing the P2P device discovery */ + /* The prefix of SSID should be "DIRECT-" and the IE should contains the P2P IE. */ + /* If not, the driver should ignore this AP and go to the next AP. */ - // Verifying the SSID - if (!memcmp(pnetwork->network.Ssid.Ssid, pwdinfo->p2p_wildcard_ssid, P2P_WILDCARD_SSID_LEN)) - { + /* Verifying the SSID */ + if (!memcmp(pnetwork->network.Ssid.Ssid, pwdinfo->p2p_wildcard_ssid, P2P_WILDCARD_SSID_LEN)) { u32 p2pielen = 0; - if (pnetwork->network.Reserved[0] == 2) { // Probe Request - // Verifying the P2P IE + if (pnetwork->network.Reserved[0] == 2) {/* Probe Request */ + /* Verifying the P2P IE */ if (rtw_get_p2p_ie(pnetwork->network.IEs, pnetwork->network.IELength, NULL, &p2pielen)) - { blnGotP2PIE = true; - } - } else { // Beacon or Probe Respones - // Verifying the P2P IE + } else {/* Beacon or Probe Respones */ + /* Verifying the P2P IE */ if (rtw_get_p2p_ie(&pnetwork->network.IEs[12], pnetwork->network.IELength - 12, NULL, &p2pielen)) - { blnGotP2PIE = true; - } } } - if (blnGotP2PIE == false) - { + if (!blnGotP2PIE) return start; - } } -#endif //CONFIG_P2P +#endif /* CONFIG_P2P */ /* AP MAC address */ iwe.cmd = SIOCGIWAP; @@ -323,50 +270,41 @@ static char *translate_scan(struct adapter *padapter, /* Add the ESSID */ iwe.cmd = SIOCGIWESSID; iwe.u.data.flags = 1; - iwe.u.data.length = min((u16)pnetwork->network.Ssid.SsidLength, (u16)32); + iwe.u.data.length = min_t(u16, pnetwork->network.Ssid.SsidLength, 32); start = iwe_stream_add_point(info, start, stop, &iwe, pnetwork->network.Ssid.Ssid); - //parsing HT_CAP_IE + /* parsing HT_CAP_IE */ p = rtw_get_ie(&pnetwork->network.IEs[12], _HT_CAPABILITY_IE_, &ht_ielen, pnetwork->network.IELength-12); - if (p && ht_ielen>0) - { + if (p && ht_ielen > 0) { struct rtw_ieee80211_ht_cap *pht_capie; ht_cap = true; pht_capie = (struct rtw_ieee80211_ht_cap *)(p+2); - _rtw_memcpy(&mcs_rate , pht_capie->supp_mcs_set, 2); - bw_40MHz = (pht_capie->cap_info&IEEE80211_HT_CAP_SUP_WIDTH) ? 1:0; - short_GI = (pht_capie->cap_info&(IEEE80211_HT_CAP_SGI_20|IEEE80211_HT_CAP_SGI_40)) ? 1:0; + _rtw_memcpy(&mcs_rate, pht_capie->supp_mcs_set, 2); + bw_40MHz = (pht_capie->cap_info&IEEE80211_HT_CAP_SUP_WIDTH) ? 1 : 0; + short_GI = (pht_capie->cap_info&(IEEE80211_HT_CAP_SGI_20|IEEE80211_HT_CAP_SGI_40)) ? 1 : 0; } /* Add the protocol name */ iwe.cmd = SIOCGIWNAME; - if ((rtw_is_cckratesonly_included((u8*)&pnetwork->network.SupportedRates)) == true) - { - if (ht_cap == true) + if ((rtw_is_cckratesonly_included((u8 *)&pnetwork->network.SupportedRates))) { + if (ht_cap) snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11bn"); else snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11b"); - } - else if ((rtw_is_cckrates_included((u8*)&pnetwork->network.SupportedRates)) == true) - { - if (ht_cap == true) + } else if ((rtw_is_cckrates_included((u8 *)&pnetwork->network.SupportedRates))) { + if (ht_cap) snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11bgn"); else - snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11bg"); - } - else - { - if (pnetwork->network.Configuration.DSConfig > 14) - { - if (ht_cap == true) + snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11bg"); + } else { + if (pnetwork->network.Configuration.DSConfig > 14) { + if (ht_cap) snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11an"); else snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11a"); - } - else - { - if (ht_cap == true) + } else { + if (ht_cap) snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11gn"); else snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11g"); @@ -376,12 +314,12 @@ static char *translate_scan(struct adapter *padapter, start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_CHAR_LEN); /* Add mode */ - iwe.cmd = SIOCGIWMODE; + iwe.cmd = SIOCGIWMODE; _rtw_memcpy((u8 *)&le_tmp, rtw_get_capability_from_ie(pnetwork->network.IEs), 2); cap = le16_to_cpu(le_tmp); - if (cap & (WLAN_CAPABILITY_IBSS |WLAN_CAPABILITY_BSS)){ + if (cap & (WLAN_CAPABILITY_IBSS | WLAN_CAPABILITY_BSS)) { if (cap & WLAN_CAPABILITY_BSS) iwe.u.mode = IW_MODE_MASTER; else @@ -390,7 +328,7 @@ static char *translate_scan(struct adapter *padapter, start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_UINT_LEN); } - if (pnetwork->network.Configuration.DSConfig<1 /*|| pnetwork->network.Configuration.DSConfig>14*/) + if (pnetwork->network.Configuration.DSConfig < 1) pnetwork->network.Configuration.DSConfig = 1; /* Add frequency/channel */ @@ -413,8 +351,7 @@ static char *translate_scan(struct adapter *padapter, max_rate = 0; p = custom; p += snprintf(p, MAX_CUSTOM_LEN - (p - custom), " Rates (Mb/s): "); - while (pnetwork->network.SupportedRates[i]!=0) - { + while (pnetwork->network.SupportedRates[i] != 0) { rate = pnetwork->network.SupportedRates[i]&0x7F; if (rate > max_rate) max_rate = rate; @@ -423,99 +360,85 @@ static char *translate_scan(struct adapter *padapter, i++; } - if (ht_cap == true) - { - if (mcs_rate&0x8000)//MCS15 - { - max_rate = (bw_40MHz) ? ((short_GI)?300:270):((short_GI)?144:130); + if (ht_cap) { + if (mcs_rate&0x8000)/* MCS15 */ + max_rate = (bw_40MHz) ? ((short_GI) ? 300 : 270) : ((short_GI) ? 144 : 130); + else if (mcs_rate&0x0080)/* MCS7 */ + ; + else/* default MCS7 */ + max_rate = (bw_40MHz) ? ((short_GI) ? 150 : 135) : ((short_GI) ? 72 : 65); - } - else if (mcs_rate&0x0080)//MCS7 - { - max_rate = (bw_40MHz) ? ((short_GI)?150:135):((short_GI)?72:65); - } - else//default MCS7 - { - //DBG_88E("wx_get_scan, mcs_rate_bitmap=0x%x\n", mcs_rate); - max_rate = (bw_40MHz) ? ((short_GI)?150:135):((short_GI)?72:65); - } - - max_rate = max_rate*2;//Mbps/2; + max_rate = max_rate*2;/* Mbps/2; */ } iwe.cmd = SIOCGIWRATE; - iwe.u.bitrate.fixed = iwe.u.bitrate.disabled = 0; + iwe.u.bitrate.fixed = 0; + iwe.u.bitrate.disabled = 0; iwe.u.bitrate.value = max_rate * 500000; start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_PARAM_LEN); - //parsing WPA/WPA2 IE + /* parsing WPA/WPA2 IE */ { u8 buf[MAX_WPA_IE_LEN]; - u8 wpa_ie[255],rsn_ie[255]; - u16 wpa_len=0,rsn_len=0; + u8 wpa_ie[255], rsn_ie[255]; + u16 wpa_len = 0, rsn_len = 0; u8 *p; - rtw_get_sec_ie(pnetwork->network.IEs ,pnetwork->network.IELength,rsn_ie,&rsn_len,wpa_ie,&wpa_len); - RT_TRACE(_module_rtl871x_mlme_c_,_drv_info_,("rtw_wx_get_scan: ssid=%s\n",pnetwork->network.Ssid.Ssid)); - RT_TRACE(_module_rtl871x_mlme_c_,_drv_info_,("rtw_wx_get_scan: wpa_len=%d rsn_len=%d\n",wpa_len,rsn_len)); + rtw_get_sec_ie(pnetwork->network.IEs, pnetwork->network.IELength, rsn_ie, &rsn_len, wpa_ie, &wpa_len); + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_wx_get_scan: ssid =%s\n", pnetwork->network.Ssid.Ssid)); + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_wx_get_scan: wpa_len =%d rsn_len =%d\n", wpa_len, rsn_len)); - if (wpa_len > 0) - { - p=buf; + if (wpa_len > 0) { + p = buf; _rtw_memset(buf, 0, MAX_WPA_IE_LEN); - p += sprintf(p, "wpa_ie="); - for (i = 0; i < wpa_len; i++) { + p += sprintf(p, "wpa_ie ="); + for (i = 0; i < wpa_len; i++) p += sprintf(p, "%02x", wpa_ie[i]); - } _rtw_memset(&iwe, 0, sizeof(iwe)); iwe.cmd = IWEVCUSTOM; iwe.u.data.length = strlen(buf); - start = iwe_stream_add_point(info, start, stop, &iwe,buf); + start = iwe_stream_add_point(info, start, stop, &iwe, buf); _rtw_memset(&iwe, 0, sizeof(iwe)); - iwe.cmd =IWEVGENIE; + iwe.cmd = IWEVGENIE; iwe.u.data.length = wpa_len; start = iwe_stream_add_point(info, start, stop, &iwe, wpa_ie); } - if (rsn_len > 0) - { + if (rsn_len > 0) { p = buf; _rtw_memset(buf, 0, MAX_WPA_IE_LEN); - p += sprintf(p, "rsn_ie="); - for (i = 0; i < rsn_len; i++) { + p += sprintf(p, "rsn_ie ="); + for (i = 0; i < rsn_len; i++) p += sprintf(p, "%02x", rsn_ie[i]); - } _rtw_memset(&iwe, 0, sizeof(iwe)); iwe.cmd = IWEVCUSTOM; iwe.u.data.length = strlen(buf); - start = iwe_stream_add_point(info, start, stop, &iwe,buf); + start = iwe_stream_add_point(info, start, stop, &iwe, buf); _rtw_memset(&iwe, 0, sizeof(iwe)); - iwe.cmd =IWEVGENIE; + iwe.cmd = IWEVGENIE; iwe.u.data.length = rsn_len; start = iwe_stream_add_point(info, start, stop, &iwe, rsn_ie); } } - { //parsing WPS IE - uint cnt = 0,total_ielen; - u8 *wpsie_ptr=NULL; + {/* parsing WPS IE */ + uint cnt = 0, total_ielen; + u8 *wpsie_ptr = NULL; uint wps_ielen = 0; - u8 *ie_ptr = pnetwork->network.IEs +_FIXED_IE_LENGTH_; - total_ielen= pnetwork->network.IELength - _FIXED_IE_LENGTH_; + u8 *ie_ptr = pnetwork->network.IEs + _FIXED_IE_LENGTH_; + total_ielen = pnetwork->network.IELength - _FIXED_IE_LENGTH_; - while (cnt < total_ielen) - { - if (rtw_is_wps_ie(&ie_ptr[cnt], &wps_ielen) && (wps_ielen>2)) - { + while (cnt < total_ielen) { + if (rtw_is_wps_ie(&ie_ptr[cnt], &wps_ielen) && (wps_ielen > 2)) { wpsie_ptr = &ie_ptr[cnt]; - iwe.cmd =IWEVGENIE; + iwe.cmd = IWEVGENIE; iwe.u.data.length = (u16)wps_ielen; start = iwe_stream_add_point(info, start, stop, &iwe, wpsie_ptr); } - cnt+=ie_ptr[cnt+1]+2; //goto next + cnt += ie_ptr[cnt+1]+2; /* goto next */ } } @@ -527,8 +450,8 @@ static char *translate_scan(struct adapter *padapter, iwe.cmd = IWEVQUAL; iwe.u.qual.updated = IW_QUAL_QUAL_UPDATED | IW_QUAL_LEVEL_UPDATED | IW_QUAL_NOISE_INVALID; - if (check_fwstate(pmlmepriv, _FW_LINKED)== true && - is_same_network(&pmlmepriv->cur_network.network, &pnetwork->network)) { + if (check_fwstate(pmlmepriv, _FW_LINKED) == true && + is_same_network(&pmlmepriv->cur_network.network, &pnetwork->network)) { ss = padapter->recvpriv.signal_strength; sq = padapter->recvpriv.signal_qual; } else { @@ -536,14 +459,14 @@ static char *translate_scan(struct adapter *padapter, sq = pnetwork->network.PhyInfo.SignalQuality; } - iwe.u.qual.level = (u8)ss;//% + iwe.u.qual.level = (u8)ss; #ifdef CONFIG_BT_COEXIST BT_SignalCompensation(padapter, &iwe.u.qual.level, NULL); - #endif // CONFIG_BT_COEXIST + #endif /* CONFIG_BT_COEXIST */ - iwe.u.qual.qual = (u8)sq; // signal quality + iwe.u.qual.qual = (u8)sq; /* signal quality */ - iwe.u.qual.noise = 0; // noise level + iwe.u.qual.noise = 0; /* noise level */ start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_QUAL_LEN); } @@ -553,78 +476,61 @@ static char *translate_scan(struct adapter *padapter, static int wpa_set_auth_algs(struct net_device *dev, u32 value) { - struct adapter *padapter = (struct adapter *) rtw_netdev_priv(dev); + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); int ret = 0; - if ((value & AUTH_ALG_SHARED_KEY)&&(value & AUTH_ALG_OPEN_SYSTEM)) - { - DBG_88E("wpa_set_auth_algs, AUTH_ALG_SHARED_KEY and AUTH_ALG_OPEN_SYSTEM [value:0x%x]\n",value); + if ((value & AUTH_ALG_SHARED_KEY) && (value & AUTH_ALG_OPEN_SYSTEM)) { + DBG_88E("wpa_set_auth_algs, AUTH_ALG_SHARED_KEY and AUTH_ALG_OPEN_SYSTEM [value:0x%x]\n", value); padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeAutoSwitch; padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Auto; - } - else if (value & AUTH_ALG_SHARED_KEY) - { - DBG_88E("wpa_set_auth_algs, AUTH_ALG_SHARED_KEY [value:0x%x]\n",value); + } else if (value & AUTH_ALG_SHARED_KEY) { + DBG_88E("wpa_set_auth_algs, AUTH_ALG_SHARED_KEY [value:0x%x]\n", value); padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeShared; padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Shared; - } - else if (value & AUTH_ALG_OPEN_SYSTEM) - { + } else if (value & AUTH_ALG_OPEN_SYSTEM) { DBG_88E("wpa_set_auth_algs, AUTH_ALG_OPEN_SYSTEM\n"); - //padapter->securitypriv.ndisencryptstatus = Ndis802_11EncryptionDisabled; - if (padapter->securitypriv.ndisauthtype < Ndis802_11AuthModeWPAPSK) - { + if (padapter->securitypriv.ndisauthtype < Ndis802_11AuthModeWPAPSK) { padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeOpen; padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Open; } - - } - else if (value & AUTH_ALG_LEAP) - { + } else if (value & AUTH_ALG_LEAP) { DBG_88E("wpa_set_auth_algs, AUTH_ALG_LEAP\n"); - } - else - { + } else { DBG_88E("wpa_set_auth_algs, error!\n"); ret = -EINVAL; } - return ret; - } static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param, u32 param_len) { int ret = 0; - u32 wep_key_idx, wep_key_len,wep_total_len; + u32 wep_key_idx, wep_key_len, wep_total_len; struct ndis_802_11_wep *pwep = NULL; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct security_priv *psecuritypriv = &padapter->securitypriv; #ifdef CONFIG_P2P - struct wifidirect_info* pwdinfo = &padapter->wdinfo; -#endif //CONFIG_P2P + struct wifidirect_info *pwdinfo = &padapter->wdinfo; +#endif /* CONFIG_P2P */ _func_enter_; param->u.crypt.err = 0; param->u.crypt.alg[IEEE_CRYPT_ALG_NAME_LEN - 1] = '\0'; - if (param_len < (u32) ((u8 *) param->u.crypt.key - (u8 *) param) + param->u.crypt.key_len) - { + if (param_len < (u32) ((u8 *)param->u.crypt.key - (u8 *)param) + param->u.crypt.key_len) { ret = -EINVAL; goto exit; } if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff && param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff && - param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) - { - if (param->u.crypt.idx >= WEP_KEYS) - { + param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) { + if (param->u.crypt.idx >= WEP_KEYS) { ret = -EINVAL; goto exit; } @@ -633,175 +539,127 @@ _func_enter_; goto exit; } - if (strcmp(param->u.crypt.alg, "WEP") == 0) - { - RT_TRACE(_module_rtl871x_ioctl_os_c,_drv_err_,("wpa_set_encryption, crypt.alg = WEP\n")); + if (strcmp(param->u.crypt.alg, "WEP") == 0) { + RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_err_, ("wpa_set_encryption, crypt.alg = WEP\n")); DBG_88E("wpa_set_encryption, crypt.alg = WEP\n"); padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; - padapter->securitypriv.dot11PrivacyAlgrthm=_WEP40_; - padapter->securitypriv.dot118021XGrpPrivacy=_WEP40_; + padapter->securitypriv.dot11PrivacyAlgrthm = _WEP40_; + padapter->securitypriv.dot118021XGrpPrivacy = _WEP40_; wep_key_idx = param->u.crypt.idx; wep_key_len = param->u.crypt.key_len; - RT_TRACE(_module_rtl871x_ioctl_os_c,_drv_info_,("(1)wep_key_idx=%d\n", wep_key_idx)); - DBG_88E("(1)wep_key_idx=%d\n", wep_key_idx); + RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, ("(1)wep_key_idx =%d\n", wep_key_idx)); + DBG_88E("(1)wep_key_idx =%d\n", wep_key_idx); if (wep_key_idx > WEP_KEYS) return -EINVAL; - RT_TRACE(_module_rtl871x_ioctl_os_c,_drv_info_,("(2)wep_key_idx=%d\n", wep_key_idx)); + RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, ("(2)wep_key_idx =%d\n", wep_key_idx)); - if (wep_key_len > 0) - { + if (wep_key_len > 0) { wep_key_len = wep_key_len <= 5 ? 5 : 13; wep_total_len = wep_key_len + FIELD_OFFSET(struct ndis_802_11_wep, KeyMaterial); - pwep =(struct ndis_802_11_wep *) rtw_malloc(wep_total_len); - if (pwep == NULL){ - RT_TRACE(_module_rtl871x_ioctl_os_c,_drv_err_,(" wpa_set_encryption: pwep allocate fail !!!\n")); + pwep = (struct ndis_802_11_wep *)rtw_malloc(wep_total_len); + if (pwep == NULL) { + RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_err_, (" wpa_set_encryption: pwep allocate fail !!!\n")); goto exit; } - _rtw_memset(pwep, 0, wep_total_len); - pwep->KeyLength = wep_key_len; pwep->Length = wep_total_len; - - if (wep_key_len==13) - { - padapter->securitypriv.dot11PrivacyAlgrthm=_WEP104_; - padapter->securitypriv.dot118021XGrpPrivacy=_WEP104_; + if (wep_key_len == 13) { + padapter->securitypriv.dot11PrivacyAlgrthm = _WEP104_; + padapter->securitypriv.dot118021XGrpPrivacy = _WEP104_; } - } - else { + } else { ret = -EINVAL; goto exit; } - pwep->KeyIndex = wep_key_idx; pwep->KeyIndex |= 0x80000000; - _rtw_memcpy(pwep->KeyMaterial, param->u.crypt.key, pwep->KeyLength); - - if (param->u.crypt.set_tx) - { - DBG_88E("wep, set_tx=1\n"); - + if (param->u.crypt.set_tx) { + DBG_88E("wep, set_tx = 1\n"); if (rtw_set_802_11_add_wep(padapter, pwep) == (u8)_FAIL) - { - ret = -EOPNOTSUPP ; - } - } - else - { - DBG_88E("wep, set_tx=0\n"); - - //don't update "psecuritypriv->dot11PrivacyAlgrthm" and - //"psecuritypriv->dot11PrivacyKeyIndex=keyid", but can rtw_set_key to fw/cam - + ret = -EOPNOTSUPP; + } else { + DBG_88E("wep, set_tx = 0\n"); if (wep_key_idx >= WEP_KEYS) { - ret = -EOPNOTSUPP ; + ret = -EOPNOTSUPP; goto exit; } - _rtw_memcpy(&(psecuritypriv->dot11DefKey[wep_key_idx].skey[0]), pwep->KeyMaterial, pwep->KeyLength); - psecuritypriv->dot11DefKeylen[wep_key_idx]=pwep->KeyLength; + psecuritypriv->dot11DefKeylen[wep_key_idx] = pwep->KeyLength; rtw_set_key(padapter, psecuritypriv, wep_key_idx, 0); } - goto exit; } - if (padapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) // 802_1x - { - struct sta_info * psta,*pbcmc_sta; - struct sta_priv * pstapriv = &padapter->stapriv; + if (padapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) { /* 802_1x */ + struct sta_info *psta, *pbcmc_sta; + struct sta_priv *pstapriv = &padapter->stapriv; - if (check_fwstate(pmlmepriv, WIFI_STATION_STATE | WIFI_MP_STATE) == true) //sta mode - { + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE | WIFI_MP_STATE)) { /* sta mode */ psta = rtw_get_stainfo(pstapriv, get_bssid(pmlmepriv)); if (psta == NULL) { - //DEBUG_ERR(("Set wpa_set_encryption: Obtain Sta_info fail\n")); - } - else - { - //Jeff: don't disable ieee8021x_blocked while clearing key + ; + } else { if (strcmp(param->u.crypt.alg, "none") != 0) psta->ieee8021x_blocked = false; - if ((padapter->securitypriv.ndisencryptstatus == Ndis802_11Encryption2Enabled)|| - (padapter->securitypriv.ndisencryptstatus == Ndis802_11Encryption3Enabled)) - { + if ((padapter->securitypriv.ndisencryptstatus == Ndis802_11Encryption2Enabled) || + (padapter->securitypriv.ndisencryptstatus == Ndis802_11Encryption3Enabled)) psta->dot118021XPrivacy = padapter->securitypriv.dot11PrivacyAlgrthm; - } - if (param->u.crypt.set_tx ==1)//pairwise key - { - _rtw_memcpy(psta->dot118021x_UncstKey.skey, param->u.crypt.key, (param->u.crypt.key_len>16 ?16:param->u.crypt.key_len)); + if (param->u.crypt.set_tx == 1) { /* pairwise key */ + _rtw_memcpy(psta->dot118021x_UncstKey.skey, param->u.crypt.key, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len)); - if (strcmp(param->u.crypt.alg, "TKIP") == 0)//set mic key - { - //DEBUG_ERR(("\nset key length :param->u.crypt.key_len=%d\n", param->u.crypt.key_len)); + if (strcmp(param->u.crypt.alg, "TKIP") == 0) { /* set mic key */ _rtw_memcpy(psta->dot11tkiptxmickey.skey, &(param->u.crypt.key[16]), 8); _rtw_memcpy(psta->dot11tkiprxmickey.skey, &(param->u.crypt.key[24]), 8); - - padapter->securitypriv.busetkipkey=false; - //_set_timer(&padapter->securitypriv.tkip_timer, 50); + padapter->securitypriv.busetkipkey = false; } - //DEBUG_ERR((" param->u.crypt.key_len=%d\n",param->u.crypt.key_len)); DBG_88E(" ~~~~set sta key:unicastkey\n"); rtw_setstakey_cmd(padapter, (unsigned char *)psta, true); - } - else//group key - { - _rtw_memcpy(padapter->securitypriv.dot118021XGrpKey[param->u.crypt.idx].skey, param->u.crypt.key,(param->u.crypt.key_len>16 ?16:param->u.crypt.key_len)); - _rtw_memcpy(padapter->securitypriv.dot118021XGrptxmickey[param->u.crypt.idx].skey,&(param->u.crypt.key[16]),8); - _rtw_memcpy(padapter->securitypriv.dot118021XGrprxmickey[param->u.crypt.idx].skey,&(param->u.crypt.key[24]),8); - padapter->securitypriv.binstallGrpkey = true; - //DEBUG_ERR((" param->u.crypt.key_len=%d\n", param->u.crypt.key_len)); + } else { /* group key */ + _rtw_memcpy(padapter->securitypriv.dot118021XGrpKey[param->u.crypt.idx].skey, param->u.crypt.key, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len)); + _rtw_memcpy(padapter->securitypriv.dot118021XGrptxmickey[param->u.crypt.idx].skey, &(param->u.crypt.key[16]), 8); + _rtw_memcpy(padapter->securitypriv.dot118021XGrprxmickey[param->u.crypt.idx].skey, &(param->u.crypt.key[24]), 8); + padapter->securitypriv.binstallGrpkey = true; DBG_88E(" ~~~~set sta key:groupkey\n"); padapter->securitypriv.dot118021XGrpKeyid = param->u.crypt.idx; - rtw_set_key(padapter,&padapter->securitypriv,param->u.crypt.idx, 1); + rtw_set_key(padapter, &padapter->securitypriv, param->u.crypt.idx, 1); #ifdef CONFIG_P2P if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_PROVISIONING_ING)) - { rtw_p2p_set_state(pwdinfo, P2P_STATE_PROVISIONING_DONE); - } -#endif //CONFIG_P2P - +#endif /* CONFIG_P2P */ } } - - pbcmc_sta=rtw_get_bcmc_stainfo(padapter); - if (pbcmc_sta==NULL) - { - //DEBUG_ERR(("Set OID_802_11_ADD_KEY: bcmc stainfo is null\n")); - } - else - { - //Jeff: don't disable ieee8021x_blocked while clearing key + pbcmc_sta = rtw_get_bcmc_stainfo(padapter); + if (pbcmc_sta == NULL) { + ; + } else { + /* Jeff: don't disable ieee8021x_blocked while clearing key */ if (strcmp(param->u.crypt.alg, "none") != 0) pbcmc_sta->ieee8021x_blocked = false; - if ((padapter->securitypriv.ndisencryptstatus == Ndis802_11Encryption2Enabled)|| - (padapter->securitypriv.ndisencryptstatus == Ndis802_11Encryption3Enabled)) - { + if ((padapter->securitypriv.ndisencryptstatus == Ndis802_11Encryption2Enabled) || + (padapter->securitypriv.ndisencryptstatus == Ndis802_11Encryption3Enabled)) pbcmc_sta->dot118021XPrivacy = padapter->securitypriv.dot11PrivacyAlgrthm; - } } } } exit: - if (pwep) { + if (pwep) rtw_mfree((u8 *)pwep, wep_total_len); - } _func_exit_; @@ -810,15 +668,15 @@ _func_exit_; static int rtw_set_wpa_ie(struct adapter *padapter, char *pie, unsigned short ielen) { - u8 *buf=NULL; + u8 *buf = NULL; u32 left; int group_cipher = 0, pairwise_cipher = 0; int ret = 0; #ifdef CONFIG_P2P - struct wifidirect_info* pwdinfo = &padapter->wdinfo; -#endif //CONFIG_P2P + struct wifidirect_info *pwdinfo = &padapter->wdinfo; +#endif /* CONFIG_P2P */ - if ((ielen > MAX_WPA_IE_LEN) || (pie == NULL)){ + if ((ielen > MAX_WPA_IE_LEN) || (pie == NULL)) { _clr_fwstate_(&padapter->mlmepriv, WIFI_UNDER_WPS); if (pie == NULL) return ret; @@ -826,135 +684,121 @@ static int rtw_set_wpa_ie(struct adapter *padapter, char *pie, unsigned short ie return -EINVAL; } - if (ielen) - { + if (ielen) { buf = rtw_zmalloc(ielen); - if (buf == NULL){ + if (buf == NULL) { ret = -ENOMEM; goto exit; } - _rtw_memcpy(buf, pie , ielen); + _rtw_memcpy(buf, pie, ielen); - //dump + /* dump */ { int i; DBG_88E("\n wpa_ie(length:%d):\n", ielen); - for (i=0;isecuritypriv.dot11AuthAlgrthm= dot11AuthAlgrthm_8021X; - padapter->securitypriv.ndisauthtype=Ndis802_11AuthModeWPAPSK; + if (rtw_parse_wpa_ie(buf, ielen, &group_cipher, &pairwise_cipher, NULL) == _SUCCESS) { + padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_8021X; + padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeWPAPSK; _rtw_memcpy(padapter->securitypriv.supplicant_ie, &buf[0], ielen); } - if (rtw_parse_wpa2_ie(buf, ielen, &group_cipher, &pairwise_cipher, NULL) == _SUCCESS) - { - padapter->securitypriv.dot11AuthAlgrthm= dot11AuthAlgrthm_8021X; - padapter->securitypriv.ndisauthtype=Ndis802_11AuthModeWPA2PSK; + if (rtw_parse_wpa2_ie(buf, ielen, &group_cipher, &pairwise_cipher, NULL) == _SUCCESS) { + padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_8021X; + padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeWPA2PSK; _rtw_memcpy(padapter->securitypriv.supplicant_ie, &buf[0], ielen); } - switch (group_cipher) - { - case WPA_CIPHER_NONE: - padapter->securitypriv.dot118021XGrpPrivacy=_NO_PRIVACY_; - padapter->securitypriv.ndisencryptstatus=Ndis802_11EncryptionDisabled; - break; - case WPA_CIPHER_WEP40: - padapter->securitypriv.dot118021XGrpPrivacy=_WEP40_; - padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; - break; - case WPA_CIPHER_TKIP: - padapter->securitypriv.dot118021XGrpPrivacy=_TKIP_; - padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption2Enabled; - break; - case WPA_CIPHER_CCMP: - padapter->securitypriv.dot118021XGrpPrivacy=_AES_; - padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption3Enabled; - break; - case WPA_CIPHER_WEP104: - padapter->securitypriv.dot118021XGrpPrivacy=_WEP104_; - padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; - break; + switch (group_cipher) { + case WPA_CIPHER_NONE: + padapter->securitypriv.dot118021XGrpPrivacy = _NO_PRIVACY_; + padapter->securitypriv.ndisencryptstatus = Ndis802_11EncryptionDisabled; + break; + case WPA_CIPHER_WEP40: + padapter->securitypriv.dot118021XGrpPrivacy = _WEP40_; + padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; + break; + case WPA_CIPHER_TKIP: + padapter->securitypriv.dot118021XGrpPrivacy = _TKIP_; + padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption2Enabled; + break; + case WPA_CIPHER_CCMP: + padapter->securitypriv.dot118021XGrpPrivacy = _AES_; + padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption3Enabled; + break; + case WPA_CIPHER_WEP104: + padapter->securitypriv.dot118021XGrpPrivacy = _WEP104_; + padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; + break; } - switch (pairwise_cipher) - { - case WPA_CIPHER_NONE: - padapter->securitypriv.dot11PrivacyAlgrthm=_NO_PRIVACY_; - padapter->securitypriv.ndisencryptstatus=Ndis802_11EncryptionDisabled; - break; - case WPA_CIPHER_WEP40: - padapter->securitypriv.dot11PrivacyAlgrthm=_WEP40_; - padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; - break; - case WPA_CIPHER_TKIP: - padapter->securitypriv.dot11PrivacyAlgrthm=_TKIP_; - padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption2Enabled; - break; - case WPA_CIPHER_CCMP: - padapter->securitypriv.dot11PrivacyAlgrthm=_AES_; - padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption3Enabled; - break; - case WPA_CIPHER_WEP104: - padapter->securitypriv.dot11PrivacyAlgrthm=_WEP104_; - padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; - break; + switch (pairwise_cipher) { + case WPA_CIPHER_NONE: + padapter->securitypriv.dot11PrivacyAlgrthm = _NO_PRIVACY_; + padapter->securitypriv.ndisencryptstatus = Ndis802_11EncryptionDisabled; + break; + case WPA_CIPHER_WEP40: + padapter->securitypriv.dot11PrivacyAlgrthm = _WEP40_; + padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; + break; + case WPA_CIPHER_TKIP: + padapter->securitypriv.dot11PrivacyAlgrthm = _TKIP_; + padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption2Enabled; + break; + case WPA_CIPHER_CCMP: + padapter->securitypriv.dot11PrivacyAlgrthm = _AES_; + padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption3Enabled; + break; + case WPA_CIPHER_WEP104: + padapter->securitypriv.dot11PrivacyAlgrthm = _WEP104_; + padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; + break; } _clr_fwstate_(&padapter->mlmepriv, WIFI_UNDER_WPS); - {//set wps_ie + {/* set wps_ie */ u16 cnt = 0; - u8 eid, wps_oui[4]={0x0,0x50,0xf2,0x04}; + u8 eid, wps_oui[4] = {0x0, 0x50, 0xf2, 0x04}; - while (cnt < ielen) - { + while (cnt < ielen) { eid = buf[cnt]; - - if ((eid==_VENDOR_SPECIFIC_IE_)&&(!memcmp(&buf[cnt+2], wps_oui, 4)==true)) - { + if ((eid == _VENDOR_SPECIFIC_IE_) && (!memcmp(&buf[cnt+2], wps_oui, 4))) { DBG_88E("SET WPS_IE\n"); - padapter->securitypriv.wps_ie_len = ((buf[cnt+1]+2) < (MAX_WPA_IE_LEN<<2)) ? (buf[cnt+1]+2):(MAX_WPA_IE_LEN<<2); + padapter->securitypriv.wps_ie_len = ((buf[cnt+1]+2) < (MAX_WPA_IE_LEN<<2)) ? (buf[cnt+1]+2) : (MAX_WPA_IE_LEN<<2); _rtw_memcpy(padapter->securitypriv.wps_ie, &buf[cnt], padapter->securitypriv.wps_ie_len); set_fwstate(&padapter->mlmepriv, WIFI_UNDER_WPS); - #ifdef CONFIG_P2P if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_GONEGO_OK)) - { rtw_p2p_set_state(pwdinfo, P2P_STATE_PROVISIONING_ING); - } -#endif //CONFIG_P2P +#endif /* CONFIG_P2P */ cnt += buf[cnt+1]+2; - break; } else { - cnt += buf[cnt+1]+2; //goto next + cnt += buf[cnt+1]+2; /* goto next */ } } } } RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, - ("rtw_set_wpa_ie: pairwise_cipher=0x%08x padapter->securitypriv.ndisencryptstatus=%d padapter->securitypriv.ndisauthtype=%d\n", - pairwise_cipher, padapter->securitypriv.ndisencryptstatus, padapter->securitypriv.ndisauthtype)); - + ("rtw_set_wpa_ie: pairwise_cipher = 0x%08x padapter->securitypriv.ndisencryptstatus =%d padapter->securitypriv.ndisauthtype =%d\n", + pairwise_cipher, padapter->securitypriv.ndisencryptstatus, padapter->securitypriv.ndisauthtype)); exit: - - if (buf) rtw_mfree(buf, ielen); - + if (buf) + rtw_mfree(buf, ielen); return ret; } @@ -968,41 +812,41 @@ static int rtw_wx_get_name(struct net_device *dev, u16 cap; u32 ht_ielen = 0; char *p; - u8 ht_cap=false; + u8 ht_cap = false; struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); struct wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network; - NDIS_802_11_RATES_EX* prates = NULL; + NDIS_802_11_RATES_EX *prates = NULL; - RT_TRACE(_module_rtl871x_mlme_c_,_drv_info_,("cmd_code=%x\n", info->cmd)); + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("cmd_code =%x\n", info->cmd)); _func_enter_; if (check_fwstate(pmlmepriv, _FW_LINKED|WIFI_ADHOC_MASTER_STATE) == true) { - //parsing HT_CAP_IE + /* parsing HT_CAP_IE */ p = rtw_get_ie(&pcur_bss->IEs[12], _HT_CAPABILITY_IE_, &ht_ielen, pcur_bss->IELength-12); - if (p && ht_ielen>0) + if (p && ht_ielen > 0) ht_cap = true; prates = &pcur_bss->SupportedRates; - if (rtw_is_cckratesonly_included((u8*)prates) == true) { - if (ht_cap == true) + if (rtw_is_cckratesonly_included((u8 *)prates) == true) { + if (ht_cap) snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11bn"); else snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11b"); - } else if ((rtw_is_cckrates_included((u8*)prates)) == true) { - if (ht_cap == true) + } else if ((rtw_is_cckrates_included((u8 *)prates)) == true) { + if (ht_cap) snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11bgn"); else snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11bg"); } else { if (pcur_bss->Configuration.DSConfig > 14) { - if (ht_cap == true) + if (ht_cap) snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11an"); else snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11a"); } else { - if (ht_cap == true) + if (ht_cap) snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11gn"); else snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11g"); @@ -1038,15 +882,12 @@ static int rtw_wx_get_freq(struct net_device *dev, struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); struct wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network; - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) - { - //wrqu->freq.m = ieee80211_wlan_frequencies[pcur_bss->Configuration.DSConfig-1] * 100000; + if (check_fwstate(pmlmepriv, _FW_LINKED)) { + /* wrqu->freq.m = ieee80211_wlan_frequencies[pcur_bss->Configuration.DSConfig-1] * 100000; */ wrqu->freq.m = rtw_ch2freq(pcur_bss->Configuration.DSConfig) * 100000; wrqu->freq.e = 1; wrqu->freq.i = pcur_bss->Configuration.DSConfig; - - } - else{ + } else { wrqu->freq.m = rtw_ch2freq(padapter->mlmeextpriv.cur_channel) * 100000; wrqu->freq.e = 1; wrqu->freq.i = padapter->mlmeextpriv.cur_channel; @@ -1059,73 +900,51 @@ static int rtw_wx_set_mode(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - enum ndis_802_11_network_infra networkType ; + enum ndis_802_11_network_infra networkType; int ret = 0; _func_enter_; if (_FAIL == rtw_pwr_wakeup(padapter)) { - ret= -EPERM; - goto exit; - } - - if (padapter->hw_init_completed==false){ ret = -EPERM; goto exit; } - switch (wrqu->mode) - { - case IW_MODE_AUTO: - networkType = Ndis802_11AutoUnknown; - DBG_88E("set_mode = IW_MODE_AUTO\n"); - break; - case IW_MODE_ADHOC: - networkType = Ndis802_11IBSS; - DBG_88E("set_mode = IW_MODE_ADHOC\n"); - break; - case IW_MODE_MASTER: - networkType = Ndis802_11APMode; - DBG_88E("set_mode = IW_MODE_MASTER\n"); - //rtw_setopmode_cmd(padapter, networkType); - break; - case IW_MODE_INFRA: - networkType = Ndis802_11Infrastructure; - DBG_88E("set_mode = IW_MODE_INFRA\n"); - break; - - default : - ret = -EINVAL;; - RT_TRACE(_module_rtl871x_ioctl_os_c,_drv_err_,("\n Mode: %s is not supported\n", iw_operation_mode[wrqu->mode])); - goto exit; - } - -/* - if (Ndis802_11APMode == networkType) - { - rtw_setopmode_cmd(padapter, networkType); - } - else - { - rtw_setopmode_cmd(padapter, Ndis802_11AutoUnknown); - } -*/ - - if (rtw_set_802_11_infrastructure_mode(padapter, networkType) ==false){ - + if (!padapter->hw_init_completed) { ret = -EPERM; goto exit; - } + switch (wrqu->mode) { + case IW_MODE_AUTO: + networkType = Ndis802_11AutoUnknown; + DBG_88E("set_mode = IW_MODE_AUTO\n"); + break; + case IW_MODE_ADHOC: + networkType = Ndis802_11IBSS; + DBG_88E("set_mode = IW_MODE_ADHOC\n"); + break; + case IW_MODE_MASTER: + networkType = Ndis802_11APMode; + DBG_88E("set_mode = IW_MODE_MASTER\n"); + break; + case IW_MODE_INFRA: + networkType = Ndis802_11Infrastructure; + DBG_88E("set_mode = IW_MODE_INFRA\n"); + break; + default: + ret = -EINVAL; + RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_err_, ("\n Mode: %s is not supported\n", iw_operation_mode[wrqu->mode])); + goto exit; + } + if (rtw_set_802_11_infrastructure_mode(padapter, networkType) == false) { + ret = -EPERM; + goto exit; + } rtw_setopmode_cmd(padapter, networkType); - exit: - _func_exit_; - return ret; - } static int rtw_wx_get_mode(struct net_device *dev, struct iw_request_info *a, @@ -1134,131 +953,91 @@ static int rtw_wx_get_mode(struct net_device *dev, struct iw_request_info *a, struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); - RT_TRACE(_module_rtl871x_mlme_c_,_drv_info_,(" rtw_wx_get_mode\n")); + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, (" rtw_wx_get_mode\n")); _func_enter_; - if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) - { + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) wrqu->mode = IW_MODE_INFRA; - } - else if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true) || - (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true)) - - { + else if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) || + (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE))) wrqu->mode = IW_MODE_ADHOC; - } - else if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) - { + else if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) wrqu->mode = IW_MODE_MASTER; - } else - { wrqu->mode = IW_MODE_AUTO; - } _func_exit_; return 0; - } - static int rtw_wx_set_pmkid(struct net_device *dev, - struct iw_request_info *a, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *a, + union iwreq_data *wrqu, char *extra) { struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - u8 j,blInserted = false; - int intReturn = false; + u8 j, blInserted = false; + int ret = false; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct security_priv *psecuritypriv = &padapter->securitypriv; - struct iw_pmksa* pPMK = (struct iw_pmksa*) extra; - u8 strZeroMacAddress[ ETH_ALEN ] = { 0x00 }; - u8 strIssueBssid[ ETH_ALEN ] = { 0x00 }; - -/* - struct iw_pmksa - { - __u32 cmd; - struct sockaddr bssid; - __u8 pmkid[IW_PMKID_LEN]; //IW_PMKID_LEN=16 - } - There are the BSSID information in the bssid.sa_data array. - If cmd is IW_PMKSA_FLUSH, it means the wpa_suppplicant wants to clear all the PMKID information. - If cmd is IW_PMKSA_ADD, it means the wpa_supplicant wants to add a PMKID/BSSID to driver. - If cmd is IW_PMKSA_REMOVE, it means the wpa_supplicant wants to remove a PMKID/BSSID from driver. - */ + struct iw_pmksa *pPMK = (struct iw_pmksa *)extra; + u8 strZeroMacAddress[ETH_ALEN] = {0x00}; + u8 strIssueBssid[ETH_ALEN] = {0x00}; _rtw_memcpy(strIssueBssid, pPMK->bssid.sa_data, ETH_ALEN); - if (pPMK->cmd == IW_PMKSA_ADD) - { - DBG_88E("[rtw_wx_set_pmkid] IW_PMKSA_ADD!\n"); - if (!memcmp(strIssueBssid, strZeroMacAddress, ETH_ALEN) == true) - { - return(intReturn); - } - else - { - intReturn = true; - } + if (pPMK->cmd == IW_PMKSA_ADD) { + DBG_88E("[rtw_wx_set_pmkid] IW_PMKSA_ADD!\n"); + if (!memcmp(strIssueBssid, strZeroMacAddress, ETH_ALEN) == true) + return ret; + else + ret = true; blInserted = false; - //overwrite PMKID - for (j=0 ; jPMKIDList[j].Bssid, strIssueBssid, ETH_ALEN) ==true) - { // BSSID is matched, the same AP => rewrite with new PMKID. - - DBG_88E("[rtw_wx_set_pmkid] BSSID exists in the PMKList.\n"); - + /* overwrite PMKID */ + for (j = 0; j < NUM_PMKID_CACHE; j++) { + if (!memcmp(psecuritypriv->PMKIDList[j].Bssid, strIssueBssid, ETH_ALEN)) { + /* BSSID is matched, the same AP => rewrite with new PMKID. */ + DBG_88E("[rtw_wx_set_pmkid] BSSID exists in the PMKList.\n"); _rtw_memcpy(psecuritypriv->PMKIDList[j].PMKID, pPMK->pmkid, IW_PMKID_LEN); - psecuritypriv->PMKIDList[ j ].bUsed = true; + psecuritypriv->PMKIDList[j].bUsed = true; psecuritypriv->PMKIDIndex = j+1; blInserted = true; break; } - } - - if (!blInserted) - { - // Find a new entry - DBG_88E("[rtw_wx_set_pmkid] Use the new entry index = %d for this PMKID.\n", - psecuritypriv->PMKIDIndex); - - _rtw_memcpy(psecuritypriv->PMKIDList[psecuritypriv->PMKIDIndex].Bssid, strIssueBssid, ETH_ALEN); - _rtw_memcpy(psecuritypriv->PMKIDList[psecuritypriv->PMKIDIndex].PMKID, pPMK->pmkid, IW_PMKID_LEN); - - psecuritypriv->PMKIDList[ psecuritypriv->PMKIDIndex ].bUsed = true; - psecuritypriv->PMKIDIndex++ ; - if (psecuritypriv->PMKIDIndex==16) - { - psecuritypriv->PMKIDIndex =0; - } } - } - else if (pPMK->cmd == IW_PMKSA_REMOVE) - { - DBG_88E("[rtw_wx_set_pmkid] IW_PMKSA_REMOVE!\n"); - intReturn = true; - for (j=0 ; jPMKIDList[j].Bssid, strIssueBssid, ETH_ALEN) ==true) - { // BSSID is matched, the same AP => Remove this PMKID information and reset it. - _rtw_memset(psecuritypriv->PMKIDList[ j ].Bssid, 0x00, ETH_ALEN); - psecuritypriv->PMKIDList[ j ].bUsed = false; + + if (!blInserted) { + /* Find a new entry */ + DBG_88E("[rtw_wx_set_pmkid] Use the new entry index = %d for this PMKID.\n", + psecuritypriv->PMKIDIndex); + + _rtw_memcpy(psecuritypriv->PMKIDList[psecuritypriv->PMKIDIndex].Bssid, strIssueBssid, ETH_ALEN); + _rtw_memcpy(psecuritypriv->PMKIDList[psecuritypriv->PMKIDIndex].PMKID, pPMK->pmkid, IW_PMKID_LEN); + + psecuritypriv->PMKIDList[psecuritypriv->PMKIDIndex].bUsed = true; + psecuritypriv->PMKIDIndex++; + if (psecuritypriv->PMKIDIndex == 16) + psecuritypriv->PMKIDIndex = 0; + } + } else if (pPMK->cmd == IW_PMKSA_REMOVE) { + DBG_88E("[rtw_wx_set_pmkid] IW_PMKSA_REMOVE!\n"); + ret = true; + for (j = 0; j < NUM_PMKID_CACHE; j++) { + if (!memcmp(psecuritypriv->PMKIDList[j].Bssid, strIssueBssid, ETH_ALEN)) { + /* BSSID is matched, the same AP => Remove this PMKID information and reset it. */ + _rtw_memset(psecuritypriv->PMKIDList[j].Bssid, 0x00, ETH_ALEN); + psecuritypriv->PMKIDList[j].bUsed = false; break; } - } - } - else if (pPMK->cmd == IW_PMKSA_FLUSH) - { - DBG_88E("[rtw_wx_set_pmkid] IW_PMKSA_FLUSH!\n"); - _rtw_memset(&psecuritypriv->PMKIDList[ 0 ], 0x00, sizeof(struct rt_pmkid_list) * NUM_PMKID_CACHE); - psecuritypriv->PMKIDIndex = 0; - intReturn = true; - } - return(intReturn); + } + } else if (pPMK->cmd == IW_PMKSA_FLUSH) { + DBG_88E("[rtw_wx_set_pmkid] IW_PMKSA_FLUSH!\n"); + _rtw_memset(&psecuritypriv->PMKIDList[0], 0x00, sizeof(struct rt_pmkid_list) * NUM_PMKID_CACHE); + psecuritypriv->PMKIDIndex = 0; + ret = true; + } + return ret; } static int rtw_wx_get_sens(struct net_device *dev, @@ -1284,7 +1063,7 @@ static int rtw_wx_get_range(struct net_device *dev, _func_enter_; - RT_TRACE(_module_rtl871x_mlme_c_,_drv_info_,("rtw_wx_get_range. cmd_code=%x\n", info->cmd)); + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_wx_get_range. cmd_code =%x\n", info->cmd)); wrqu->data.length = sizeof(*range); _rtw_memset(range, 0, sizeof(*range)); @@ -1300,25 +1079,14 @@ static int rtw_wx_get_range(struct net_device *dev, /* ~5 Mb/s real (802.11b) */ range->throughput = 5 * 1000 * 1000; - // TODO: Not used in 802.11b? -// range->min_nwid; /* Minimal NWID we are able to set */ - // TODO: Not used in 802.11b? -// range->max_nwid; /* Maximal NWID we are able to set */ - - /* Old Frequency (backward compat - moved lower) */ -// range->old_num_channels; -// range->old_num_frequency; -// range->old_freq[6]; /* Filler to keep "version" at the same offset */ - /* signal level threshold range */ - //percent values between 0 and 100. + /* percent values between 0 and 100. */ range->max_qual.qual = 100; range->max_qual.level = 100; range->max_qual.noise = 100; range->max_qual.updated = 7; /* Updated all three */ - range->avg_qual.qual = 92; /* > 8% missed beacons is 'bad' */ /* TODO: Find real 'good' to 'bad' threshol value for RSSI */ range->avg_qual.level = 20 + -98; @@ -1327,9 +1095,8 @@ static int rtw_wx_get_range(struct net_device *dev, range->num_bitrates = RATE_COUNT; - for (i = 0; i < RATE_COUNT && i < IW_MAX_BITRATES; i++) { + for (i = 0; i < RATE_COUNT && i < IW_MAX_BITRATES; i++) range->bitrate[i] = rtw_rates[i]; - } range->min_frag = MIN_FRAG_THRESHOLD; range->max_frag = MAX_FRAG_THRESHOLD; @@ -1339,19 +1106,9 @@ static int rtw_wx_get_range(struct net_device *dev, range->we_version_compiled = WIRELESS_EXT; range->we_version_source = 16; -// range->retry_capa; /* What retry options are supported */ -// range->retry_flags; /* How to decode max/min retry limit */ -// range->r_time_flags; /* How to decode max/min retry life */ -// range->min_retry; /* Minimal number of retries */ -// range->max_retry; /* Maximal number of retries */ -// range->min_r_time; /* Minimal retry lifetime */ -// range->max_r_time; /* Maximal retry lifetime */ - for (i = 0, val = 0; i < MAX_CHANNEL_NUM; i++) { - - // Include only legal frequencies for some countries - if (pmlmeext->channel_set[i].ChannelNum != 0) - { + /* Include only legal frequencies for some countries */ + if (pmlmeext->channel_set[i].ChannelNum != 0) { range->freq[val].i = pmlmeext->channel_set[i].ChannelNum; range->freq[val].m = rtw_ch2freq(pmlmeext->channel_set[i].ChannelNum) * 100000; range->freq[val].e = 1; @@ -1365,16 +1122,16 @@ static int rtw_wx_get_range(struct net_device *dev, range->num_channels = val; range->num_frequency = val; -// Commented by Albert 2009/10/13 -// The following code will proivde the security capability to network manager. -// If the driver doesn't provide this capability to network manager, -// the WPA/WPA2 routers can't be choosen in the network manager. +/* Commented by Albert 2009/10/13 */ +/* The following code will proivde the security capability to network manager. */ +/* If the driver doesn't provide this capability to network manager, */ +/* the WPA/WPA2 routers can't be choosen in the network manager. */ /* #define IW_SCAN_CAPA_NONE 0x00 #define IW_SCAN_CAPA_ESSID 0x01 #define IW_SCAN_CAPA_BSSID 0x02 -#define IW_SCAN_CAPA_CHANNEL 0x04 +#define IW_SCAN_CAPA_CHANNEL 0x04 #define IW_SCAN_CAPA_MODE 0x08 #define IW_SCAN_CAPA_RATE 0x10 #define IW_SCAN_CAPA_TYPE 0x20 @@ -1382,22 +1139,23 @@ static int rtw_wx_get_range(struct net_device *dev, */ #if WIRELESS_EXT > 17 - range->enc_capa = IW_ENC_CAPA_WPA|IW_ENC_CAPA_WPA2| - IW_ENC_CAPA_CIPHER_TKIP|IW_ENC_CAPA_CIPHER_CCMP; + range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 | + IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP; #endif - range->scan_capa = IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE |IW_SCAN_CAPA_BSSID| - IW_SCAN_CAPA_CHANNEL|IW_SCAN_CAPA_MODE|IW_SCAN_CAPA_RATE; + range->scan_capa = IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | + IW_SCAN_CAPA_BSSID | IW_SCAN_CAPA_CHANNEL | + IW_SCAN_CAPA_MODE | IW_SCAN_CAPA_RATE; _func_exit_; return 0; } -//set bssid flow -//s1. rtw_set_802_11_infrastructure_mode() -//s2. rtw_set_802_11_authentication_mode() -//s3. set_802_11_encryption_mode() -//s4. rtw_set_802_11_bssid() +/* set bssid flow */ +/* s1. rtw_set_802_11_infrastructure_mode() */ +/* s2. rtw_set_802_11_authentication_mode() */ +/* s3. set_802_11_encryption_mode() */ +/* s4. rtw_set_802_11_bssid() */ static int rtw_wx_set_wap(struct net_device *dev, struct iw_request_info *info, union iwreq_data *awrq, @@ -1416,27 +1174,25 @@ static int rtw_wx_set_wap(struct net_device *dev, _func_enter_; - if (_FAIL == rtw_pwr_wakeup(padapter)) - { - ret= -1; - goto exit; - } - - if (!padapter->bup){ + if (_FAIL == rtw_pwr_wakeup(padapter)) { ret = -1; goto exit; } + if (!padapter->bup) { + ret = -1; + goto exit; + } - if (temp->sa_family != ARPHRD_ETHER){ + if (temp->sa_family != ARPHRD_ETHER) { ret = -EINVAL; goto exit; } authmode = padapter->securitypriv.ndisauthtype; _enter_critical_bh(&queue->lock, &irqL); - phead = get_list_head(queue); - pmlmepriv->pscanned = get_next(phead); + phead = get_list_head(queue); + pmlmepriv->pscanned = get_next(phead); while (1) { if ((rtw_end_of_queue_search(phead, pmlmepriv->pscanned)) == true) @@ -1450,10 +1206,8 @@ static int rtw_wx_set_wap(struct net_device *dev, src_bssid = temp->sa_data; - if ((!memcmp(dst_bssid, src_bssid, ETH_ALEN)) == true) - { - if (!rtw_set_802_11_infrastructure_mode(padapter, pnetwork->network.InfrastructureMode)) - { + if ((!memcmp(dst_bssid, src_bssid, ETH_ALEN))) { + if (!rtw_set_802_11_infrastructure_mode(padapter, pnetwork->network.InfrastructureMode)) { ret = -1; _exit_critical_bh(&queue->lock, &irqL); goto exit; @@ -1461,12 +1215,11 @@ static int rtw_wx_set_wap(struct net_device *dev, break; } - } _exit_critical_bh(&queue->lock, &irqL); rtw_set_802_11_authentication_mode(padapter, authmode); - //set_802_11_encryption_mode(padapter, padapter->securitypriv.ndisencryptstatus); + /* set_802_11_encryption_mode(padapter, padapter->securitypriv.ndisencryptstatus); */ if (rtw_set_802_11_bssid(padapter, temp->sa_data) == false) { ret = -1; goto exit; @@ -1483,7 +1236,6 @@ static int rtw_wx_get_wap(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); struct wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network; @@ -1492,46 +1244,39 @@ static int rtw_wx_get_wap(struct net_device *dev, _rtw_memset(wrqu->ap_addr.sa_data, 0, ETH_ALEN); - RT_TRACE(_module_rtl871x_mlme_c_,_drv_info_,("rtw_wx_get_wap\n")); + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_wx_get_wap\n")); _func_enter_; - if (((check_fwstate(pmlmepriv, _FW_LINKED)) == true) || - ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) == true) || - ((check_fwstate(pmlmepriv, WIFI_AP_STATE)) == true)) - { - + if (((check_fwstate(pmlmepriv, _FW_LINKED)) == true) || + ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) == true) || + ((check_fwstate(pmlmepriv, WIFI_AP_STATE)) == true)) _rtw_memcpy(wrqu->ap_addr.sa_data, pcur_bss->MacAddress, ETH_ALEN); - } else - { _rtw_memset(wrqu->ap_addr.sa_data, 0, ETH_ALEN); - } _func_exit_; return 0; - } static int rtw_wx_set_mlme(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - int ret=0; + int ret = 0; u16 reason; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct iw_mlme *mlme = (struct iw_mlme *) extra; + struct iw_mlme *mlme = (struct iw_mlme *)extra; - - if (mlme==NULL) + if (mlme == NULL) return -1; DBG_88E("%s\n", __func__); reason = mlme->reason_code; - DBG_88E("%s, cmd=%d, reason=%d\n", __func__, mlme->cmd, reason); + DBG_88E("%s, cmd =%d, reason =%d\n", __func__, mlme->cmd, reason); switch (mlme->cmd) { case IW_MLME_DEAUTH: @@ -1554,56 +1299,51 @@ static int rtw_wx_set_scan(struct net_device *dev, struct iw_request_info *a, u8 _status = false; int ret = 0; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct mlme_priv *pmlmepriv= &padapter->mlmepriv; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct ndis_802_11_ssid ssid[RTW_SSID_SCAN_AMOUNT]; unsigned long irqL; #ifdef CONFIG_P2P - struct wifidirect_info *pwdinfo= &(padapter->wdinfo); -#endif //CONFIG_P2P - RT_TRACE(_module_rtl871x_mlme_c_,_drv_info_,("rtw_wx_set_scan\n")); + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); +#endif /* CONFIG_P2P */ + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_wx_set_scan\n")); _func_enter_; - if (padapter->registrypriv.mp_mode == 1) - { - if (check_fwstate(pmlmepriv, WIFI_MP_STATE) == true) - { + if (padapter->registrypriv.mp_mode == 1) { + if (check_fwstate(pmlmepriv, WIFI_MP_STATE)) { ret = -1; goto exit; } } - if (_FAIL == rtw_pwr_wakeup(padapter)) - { - ret= -1; - goto exit; - } - - if (padapter->bDriverStopped){ - DBG_88E("bDriverStopped=%d\n", padapter->bDriverStopped); - ret= -1; - goto exit; - } - - if (!padapter->bup){ + if (_FAIL == rtw_pwr_wakeup(padapter)) { ret = -1; goto exit; } - if (padapter->hw_init_completed==false){ + if (padapter->bDriverStopped) { + DBG_88E("bDriverStopped =%d\n", padapter->bDriverStopped); ret = -1; goto exit; } - // When Busy Traffic, driver do not site survey. So driver return success. - // wpa_supplicant will not issue SIOCSIWSCAN cmd again after scan timeout. - // modify by thomas 2011-02-22. - if (pmlmepriv->LinkDetectInfo.bBusyTraffic == true) - { + if (!padapter->bup) { + ret = -1; + goto exit; + } + + if (!padapter->hw_init_completed) { + ret = -1; + goto exit; + } + + /* When Busy Traffic, driver do not site survey. So driver return success. */ + /* wpa_supplicant will not issue SIOCSIWSCAN cmd again after scan timeout. */ + /* modify by thomas 2011-02-22. */ + if (pmlmepriv->LinkDetectInfo.bBusyTraffic) { indicate_wx_scan_complete_event(padapter); goto exit; } - if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY|_FW_UNDER_LINKING) == true) - { + if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY|_FW_UNDER_LINKING)) { indicate_wx_scan_complete_event(padapter); goto exit; } @@ -1612,12 +1352,11 @@ _func_enter_; { u32 curr_time, delta_time; - // under DHCP(Special packet) + /* under DHCP(Special packet) */ curr_time = rtw_get_current_time(); delta_time = curr_time - padapter->pwrctrlpriv.DelayLPSLastTimeStamp; delta_time = rtw_systime_to_ms(delta_time); - if (delta_time < 500) // 500ms - { + if (delta_time < 500) { /* 500ms */ DBG_88E("%s: send DHCP pkt before %d ms, Skip scan\n", __func__, delta_time); ret = -1; goto exit; @@ -1625,126 +1364,95 @@ _func_enter_; } #endif -// Mareded by Albert 20101103 -// For the DMP WiFi Display project, the driver won't to scan because -// the pmlmepriv->scan_interval is always equal to 3. -// So, the wpa_supplicant won't find out the WPS SoftAP. +/* Mareded by Albert 20101103 */ +/* For the DMP WiFi Display project, the driver won't to scan because */ +/* the pmlmepriv->scan_interval is always equal to 3. */ +/* So, the wpa_supplicant won't find out the WPS SoftAP. */ #ifdef CONFIG_P2P - if (pwdinfo->p2p_state != P2P_STATE_NONE) - { + if (pwdinfo->p2p_state != P2P_STATE_NONE) { rtw_p2p_set_pre_state(pwdinfo, rtw_p2p_state(pwdinfo)); rtw_p2p_set_state(pwdinfo, P2P_STATE_FIND_PHASE_SEARCH); rtw_p2p_findphase_ex_set(pwdinfo, P2P_FINDPHASE_EX_FULL); rtw_free_network_queue(padapter, true); } -#endif //CONFIG_P2P +#endif /* CONFIG_P2P */ _rtw_memset(ssid, 0, sizeof(struct ndis_802_11_ssid)*RTW_SSID_SCAN_AMOUNT); #if WIRELESS_EXT >= 17 - if (wrqu->data.length == sizeof(struct iw_scan_req)) - { + if (wrqu->data.length == sizeof(struct iw_scan_req)) { struct iw_scan_req *req = (struct iw_scan_req *)extra; - if (wrqu->data.flags & IW_SCAN_THIS_ESSID) - { + if (wrqu->data.flags & IW_SCAN_THIS_ESSID) { int len = min((int)req->essid_len, IW_ESSID_MAX_SIZE); _rtw_memcpy(ssid[0].Ssid, req->essid, len); ssid[0].SsidLength = len; - DBG_88E("IW_SCAN_THIS_ESSID, ssid=%s, len=%d\n", req->essid, req->essid_len); + DBG_88E("IW_SCAN_THIS_ESSID, ssid =%s, len =%d\n", req->essid, req->essid_len); _enter_critical_bh(&pmlmepriv->lock, &irqL); _status = rtw_sitesurvey_cmd(padapter, ssid, 1, NULL, 0); _exit_critical_bh(&pmlmepriv->lock, &irqL); - - } - else if (req->scan_type == IW_SCAN_TYPE_PASSIVE) - { + } else if (req->scan_type == IW_SCAN_TYPE_PASSIVE) { DBG_88E("rtw_wx_set_scan, req->scan_type == IW_SCAN_TYPE_PASSIVE\n"); } - - } - else + } else #endif - if ( wrqu->data.length >= WEXT_CSCAN_HEADER_SIZE - && !memcmp(extra, WEXT_CSCAN_HEADER, WEXT_CSCAN_HEADER_SIZE) == true - ) - { - int len = wrqu->data.length -WEXT_CSCAN_HEADER_SIZE; + if (wrqu->data.length >= WEXT_CSCAN_HEADER_SIZE && + !memcmp(extra, WEXT_CSCAN_HEADER, WEXT_CSCAN_HEADER_SIZE)) { + int len = wrqu->data.length - WEXT_CSCAN_HEADER_SIZE; char *pos = extra+WEXT_CSCAN_HEADER_SIZE; char section; char sec_len; int ssid_index = 0; - //DBG_88E("%s COMBO_SCAN header is recognized\n", __func__); - while (len >= 1) { - section = *(pos++); len-=1; + section = *(pos++); + len -= 1; switch (section) { - case WEXT_CSCAN_SSID_SECTION: - //DBG_88E("WEXT_CSCAN_SSID_SECTION\n"); - if (len < 1) { - len = 0; - break; - } - - sec_len = *(pos++); len-=1; - - if (sec_len>0 && sec_len<=len) { - ssid[ssid_index].SsidLength = sec_len; - _rtw_memcpy(ssid[ssid_index].Ssid, pos, ssid[ssid_index].SsidLength); - //DBG_88E("%s COMBO_SCAN with specific ssid:%s, %d\n", __func__ - // , ssid[ssid_index].Ssid, ssid[ssid_index].SsidLength); - ssid_index++; - } - - pos+=sec_len; len-=sec_len; + case WEXT_CSCAN_SSID_SECTION: + if (len < 1) { + len = 0; break; - - - case WEXT_CSCAN_CHANNEL_SECTION: - //DBG_88E("WEXT_CSCAN_CHANNEL_SECTION\n"); - pos+=1; len-=1; - break; - case WEXT_CSCAN_ACTV_DWELL_SECTION: - //DBG_88E("WEXT_CSCAN_ACTV_DWELL_SECTION\n"); - pos+=2; len-=2; - break; - case WEXT_CSCAN_PASV_DWELL_SECTION: - //DBG_88E("WEXT_CSCAN_PASV_DWELL_SECTION\n"); - pos+=2; len-=2; - break; - case WEXT_CSCAN_HOME_DWELL_SECTION: - //DBG_88E("WEXT_CSCAN_HOME_DWELL_SECTION\n"); - pos+=2; len-=2; - break; - case WEXT_CSCAN_TYPE_SECTION: - //DBG_88E("WEXT_CSCAN_TYPE_SECTION\n"); - pos+=1; len-=1; - break; - default: - len = 0; // stop parsing + } + sec_len = *(pos++); len -= 1; + if (sec_len > 0 && sec_len <= len) { + ssid[ssid_index].SsidLength = sec_len; + _rtw_memcpy(ssid[ssid_index].Ssid, pos, ssid[ssid_index].SsidLength); + ssid_index++; + } + pos += sec_len; + len -= sec_len; + break; + case WEXT_CSCAN_TYPE_SECTION: + case WEXT_CSCAN_CHANNEL_SECTION: + pos += 1; + len -= 1; + break; + case WEXT_CSCAN_PASV_DWELL_SECTION: + case WEXT_CSCAN_HOME_DWELL_SECTION: + case WEXT_CSCAN_ACTV_DWELL_SECTION: + pos += 2; + len -= 2; + break; + default: + len = 0; /* stop parsing */ } - } - //jeff: it has still some scan paramater to parse, we only do this now... + /* jeff: it has still some scan paramater to parse, we only do this now... */ _status = rtw_set_802_11_bssid_list_scan(padapter, ssid, RTW_SSID_SCAN_AMOUNT); - - } else - - { + } else { _status = rtw_set_802_11_bssid_list_scan(padapter, NULL, 0); } - if (_status == false) + if (!_status) ret = -1; exit: @@ -1765,47 +1473,42 @@ static int rtw_wx_get_scan(struct net_device *dev, struct iw_request_info *a, char *ev = extra; char *stop = ev + wrqu->data.length; u32 ret = 0; - u32 cnt=0; + u32 cnt = 0; u32 wait_for_surveydone; int wait_status; #ifdef CONFIG_P2P - struct wifidirect_info* pwdinfo = &padapter->wdinfo; -#endif //CONFIG_P2P - RT_TRACE(_module_rtl871x_mlme_c_,_drv_info_,("rtw_wx_get_scan\n")); - RT_TRACE(_module_rtl871x_ioctl_os_c,_drv_info_, (" Start of Query SIOCGIWSCAN .\n")); + struct wifidirect_info *pwdinfo = &padapter->wdinfo; +#endif /* CONFIG_P2P */ + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_wx_get_scan\n")); + RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, (" Start of Query SIOCGIWSCAN .\n")); _func_enter_; - if (padapter->pwrctrlpriv.brfoffbyhw && padapter->bDriverStopped) - { + if (padapter->pwrctrlpriv.brfoffbyhw && padapter->bDriverStopped) { ret = -EINVAL; goto exit; } #ifdef CONFIG_P2P - if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) - { - // P2P is enabled + if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) { + /* P2P is enabled */ if (padapter->chip_type == RTL8192D) - wait_for_surveydone = 300; // Because the 8192du supports more channels. + wait_for_surveydone = 300; /* Because the 8192du supports more channels. */ else wait_for_surveydone = 200; - } - else - { - // P2P is disabled + } else { + /* P2P is disabled */ wait_for_surveydone = 100; } #else { wait_for_surveydone = 100; } -#endif //CONFIG_P2P +#endif /* CONFIG_P2P */ wait_status = _FW_UNDER_SURVEY | _FW_UNDER_LINKING; - while (check_fwstate(pmlmepriv, wait_status) == true) - { + while (check_fwstate(pmlmepriv, wait_status)) { rtw_msleep_os(30); cnt++; if (cnt > wait_for_surveydone) @@ -1817,9 +1520,8 @@ static int rtw_wx_get_scan(struct net_device *dev, struct iw_request_info *a, phead = get_list_head(queue); plist = get_next(phead); - while (1) - { - if (rtw_end_of_queue_search(phead,plist)== true) + while (1) { + if (rtw_end_of_queue_search(phead, plist)) break; if ((stop - ev) < SCAN_ITEM_SIZE) { @@ -1829,9 +1531,9 @@ static int rtw_wx_get_scan(struct net_device *dev, struct iw_request_info *a, pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); - //report network only if the current channel set contains the channel to which this network belongs + /* report network only if the current channel set contains the channel to which this network belongs */ if (rtw_ch_set_search_ch(padapter->mlmeextpriv.channel_set, pnetwork->network.Configuration.DSConfig) >= 0) - ev=translate_scan(padapter, a, pnetwork, ev, stop); + ev = translate_scan(padapter, a, pnetwork, ev, stop); plist = get_next(plist); } @@ -1843,14 +1545,14 @@ static int rtw_wx_get_scan(struct net_device *dev, struct iw_request_info *a, exit: _func_exit_; - return ret ; + return ret; } -//set ssid flow -//s1. rtw_set_802_11_infrastructure_mode() -//s2. set_802_11_authenticaion_mode() -//s3. set_802_11_encryption_mode() -//s4. rtw_set_802_11_ssid() +/* set ssid flow */ +/* s1. rtw_set_802_11_infrastructure_mode() */ +/* s2. set_802_11_authenticaion_mode() */ +/* s3. set_802_11_encryption_mode() */ +/* s4. rtw_set_802_11_ssid() */ static int rtw_wx_set_essid(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *extra) @@ -1872,24 +1574,23 @@ static int rtw_wx_set_essid(struct net_device *dev, _func_enter_; RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, - ("+rtw_wx_set_essid: fw_state=0x%08x\n", get_fwstate(pmlmepriv))); - if (_FAIL == rtw_pwr_wakeup(padapter)) - { + ("+rtw_wx_set_essid: fw_state = 0x%08x\n", get_fwstate(pmlmepriv))); + if (_FAIL == rtw_pwr_wakeup(padapter)) { ret = -1; goto exit; } - if (!padapter->bup){ + if (!padapter->bup) { ret = -1; goto exit; } #if WIRELESS_EXT <= 20 - if ((wrqu->essid.length-1) > IW_ESSID_MAX_SIZE){ + if ((wrqu->essid.length-1) > IW_ESSID_MAX_SIZE) { #else - if (wrqu->essid.length > IW_ESSID_MAX_SIZE){ + if (wrqu->essid.length > IW_ESSID_MAX_SIZE) { #endif - ret= -E2BIG; + ret = -E2BIG; goto exit; } @@ -1899,17 +1600,16 @@ static int rtw_wx_set_essid(struct net_device *dev, } authmode = padapter->securitypriv.ndisauthtype; - DBG_88E("=>%s\n",__func__); - if (wrqu->essid.flags && wrqu->essid.length) - { - // Commented by Albert 20100519 - // We got the codes in "set_info" function of iwconfig source code. - // ========================================= - // wrq.u.essid.length = strlen(essid) + 1; - // if (we_kernel_version > 20) - // wrq.u.essid.length--; - // ========================================= - // That means, if the WIRELESS_EXT less than or equal to 20, the correct ssid len should subtract 1. + DBG_88E("=>%s\n", __func__); + if (wrqu->essid.flags && wrqu->essid.length) { + /* Commented by Albert 20100519 */ + /* We got the codes in "set_info" function of iwconfig source code. */ + /* ========================================= */ + /* wrq.u.essid.length = strlen(essid) + 1; */ + /* if (we_kernel_version > 20) */ + /* wrq.u.essid.length--; */ + /* ========================================= */ + /* That means, if the WIRELESS_EXT less than or equal to 20, the correct ssid len should subtract 1. */ #if WIRELESS_EXT <= 20 len = ((wrqu->essid.length-1) < IW_ESSID_MAX_SIZE) ? (wrqu->essid.length-1) : IW_ESSID_MAX_SIZE; #else @@ -1917,21 +1617,21 @@ static int rtw_wx_set_essid(struct net_device *dev, #endif if (wrqu->essid.length != 33) - DBG_88E("ssid=%s, len=%d\n", extra, wrqu->essid.length); + DBG_88E("ssid =%s, len =%d\n", extra, wrqu->essid.length); _rtw_memset(&ndis_ssid, 0, sizeof(struct ndis_802_11_ssid)); ndis_ssid.SsidLength = len; _rtw_memcpy(ndis_ssid.Ssid, extra, len); src_ssid = ndis_ssid.Ssid; - RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, ("rtw_wx_set_essid: ssid=[%s]\n", src_ssid)); + RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, ("rtw_wx_set_essid: ssid =[%s]\n", src_ssid)); _enter_critical_bh(&queue->lock, &irqL); phead = get_list_head(queue); - pmlmepriv->pscanned = get_next(phead); + pmlmepriv->pscanned = get_next(phead); while (1) { if (rtw_end_of_queue_search(phead, pmlmepriv->pscanned) == true) { - RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_warning_, + RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_warning_, ("rtw_wx_set_essid: scan_q is empty, set ssid to check if scanning again!\n")); break; @@ -1944,23 +1644,20 @@ static int rtw_wx_set_essid(struct net_device *dev, dst_ssid = pnetwork->network.Ssid.Ssid; RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, - ("rtw_wx_set_essid: dst_ssid=%s\n", + ("rtw_wx_set_essid: dst_ssid =%s\n", pnetwork->network.Ssid.Ssid)); - if ((!memcmp(dst_ssid, src_ssid, ndis_ssid.SsidLength) == true) && - (pnetwork->network.Ssid.SsidLength==ndis_ssid.SsidLength)) - { + if ((!memcmp(dst_ssid, src_ssid, ndis_ssid.SsidLength)) && + (pnetwork->network.Ssid.SsidLength == ndis_ssid.SsidLength)) { RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, ("rtw_wx_set_essid: find match, set infra mode\n")); - if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true) - { + if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true) { if (pnetwork->network.InfrastructureMode != pmlmepriv->cur_network.network.InfrastructureMode) continue; } - if (rtw_set_802_11_infrastructure_mode(padapter, pnetwork->network.InfrastructureMode) == false) - { + if (!rtw_set_802_11_infrastructure_mode(padapter, pnetwork->network.InfrastructureMode)) { ret = -1; _exit_critical_bh(&queue->lock, &irqL); goto exit; @@ -1971,9 +1668,8 @@ static int rtw_wx_set_essid(struct net_device *dev, } _exit_critical_bh(&queue->lock, &irqL); RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, - ("set ssid: set_802_11_auth. mode=%d\n", authmode)); + ("set ssid: set_802_11_auth. mode =%d\n", authmode)); rtw_set_802_11_authentication_mode(padapter, authmode); - //set_802_11_encryption_mode(padapter, padapter->securitypriv.ndisencryptstatus); if (rtw_set_802_11_ssid(padapter, &ndis_ssid) == false) { ret = -1; goto exit; @@ -1982,7 +1678,7 @@ static int rtw_wx_set_essid(struct net_device *dev, exit: - DBG_88E("<=%s, ret %d\n",__func__, ret); + DBG_88E("<=%s, ret %d\n", __func__, ret); _func_exit_; @@ -1993,18 +1689,17 @@ static int rtw_wx_get_essid(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *extra) { - u32 len,ret = 0; + u32 len, ret = 0; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); struct wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network; - RT_TRACE(_module_rtl871x_mlme_c_,_drv_info_,("rtw_wx_get_essid\n")); + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_wx_get_essid\n")); _func_enter_; - if ((check_fwstate(pmlmepriv, _FW_LINKED) == true) || - (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true)) - { + if ((check_fwstate(pmlmepriv, _FW_LINKED)) || + (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE))) { len = pcur_bss->Ssid.SsidLength; wrqu->essid.length = len; @@ -2012,9 +1707,7 @@ static int rtw_wx_get_essid(struct net_device *dev, _rtw_memcpy(extra, pcur_bss->Ssid.Ssid, len); wrqu->essid.flags = 1; - } - else - { + } else { ret = -1; goto exit; } @@ -2024,93 +1717,89 @@ exit: _func_exit_; return ret; - } static int rtw_wx_set_rate(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *extra) { - int i, ret = 0; + int i, ret = 0; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - u8 datarates[NumRates]; + u8 datarates[NumRates]; u32 target_rate = wrqu->bitrate.value; u32 fixed = wrqu->bitrate.fixed; u32 ratevalue = 0; - u8 mpdatarate[NumRates]={11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0xff}; + u8 mpdatarate[NumRates] = {11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0xff}; _func_enter_; - RT_TRACE(_module_rtl871x_mlme_c_,_drv_info_,(" rtw_wx_set_rate\n")); - RT_TRACE(_module_rtl871x_ioctl_os_c,_drv_info_,("target_rate = %d, fixed = %d\n",target_rate,fixed)); + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, (" rtw_wx_set_rate\n")); + RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, ("target_rate = %d, fixed = %d\n", target_rate, fixed)); - if (target_rate == -1){ + if (target_rate == -1) { ratevalue = 11; goto set_rate; } target_rate = target_rate/100000; - switch (target_rate){ - case 10: - ratevalue = 0; - break; - case 20: - ratevalue = 1; - break; - case 55: - ratevalue = 2; - break; - case 60: - ratevalue = 3; - break; - case 90: - ratevalue = 4; - break; - case 110: - ratevalue = 5; - break; - case 120: - ratevalue = 6; - break; - case 180: - ratevalue = 7; - break; - case 240: - ratevalue = 8; - break; - case 360: - ratevalue = 9; - break; - case 480: - ratevalue = 10; - break; - case 540: - ratevalue = 11; - break; - default: - ratevalue = 11; - break; + switch (target_rate) { + case 10: + ratevalue = 0; + break; + case 20: + ratevalue = 1; + break; + case 55: + ratevalue = 2; + break; + case 60: + ratevalue = 3; + break; + case 90: + ratevalue = 4; + break; + case 110: + ratevalue = 5; + break; + case 120: + ratevalue = 6; + break; + case 180: + ratevalue = 7; + break; + case 240: + ratevalue = 8; + break; + case 360: + ratevalue = 9; + break; + case 480: + ratevalue = 10; + break; + case 540: + ratevalue = 11; + break; + default: + ratevalue = 11; + break; } set_rate: - for (i=0; irts.disabled) + if (wrqu->rts.disabled) { padapter->registrypriv.rts_thresh = 2347; - else { + } else { if (wrqu->rts.value < 0 || wrqu->rts.value > 2347) return -EINVAL; @@ -2154,12 +1843,11 @@ static int rtw_wx_set_rts(struct net_device *dev, padapter->registrypriv.rts_thresh = wrqu->rts.value; } - DBG_88E("%s, rts_thresh=%d\n", __func__, padapter->registrypriv.rts_thresh); + DBG_88E("%s, rts_thresh =%d\n", __func__, padapter->registrypriv.rts_thresh); _func_exit_; return 0; - } static int rtw_wx_get_rts(struct net_device *dev, @@ -2170,11 +1858,11 @@ static int rtw_wx_get_rts(struct net_device *dev, _func_enter_; - DBG_88E("%s, rts_thresh=%d\n", __func__, padapter->registrypriv.rts_thresh); + DBG_88E("%s, rts_thresh =%d\n", __func__, padapter->registrypriv.rts_thresh); wrqu->rts.value = padapter->registrypriv.rts_thresh; wrqu->rts.fixed = 0; /* no auto select */ - //wrqu->rts.disabled = (wrqu->rts.value == DEFAULT_RTS_THRESHOLD); + /* wrqu->rts.disabled = (wrqu->rts.value == DEFAULT_RTS_THRESHOLD); */ _func_exit_; @@ -2189,9 +1877,9 @@ static int rtw_wx_set_frag(struct net_device *dev, _func_enter_; - if (wrqu->frag.disabled) + if (wrqu->frag.disabled) { padapter->xmitpriv.frag_len = MAX_FRAG_THRESHOLD; - else { + } else { if (wrqu->frag.value < MIN_FRAG_THRESHOLD || wrqu->frag.value > MAX_FRAG_THRESHOLD) return -EINVAL; @@ -2199,12 +1887,11 @@ static int rtw_wx_set_frag(struct net_device *dev, padapter->xmitpriv.frag_len = wrqu->frag.value & ~0x1; } - DBG_88E("%s, frag_len=%d\n", __func__, padapter->xmitpriv.frag_len); + DBG_88E("%s, frag_len =%d\n", __func__, padapter->xmitpriv.frag_len); _func_exit_; return 0; - } static int rtw_wx_get_frag(struct net_device *dev, @@ -2215,11 +1902,10 @@ static int rtw_wx_get_frag(struct net_device *dev, _func_enter_; - DBG_88E("%s, frag_len=%d\n", __func__, padapter->xmitpriv.frag_len); + DBG_88E("%s, frag_len =%d\n", __func__, padapter->xmitpriv.frag_len); wrqu->frag.value = padapter->xmitpriv.frag_len; wrqu->frag.fixed = 0; /* no auto select */ - //wrqu->frag.disabled = (wrqu->frag.value == DEFAULT_FRAG_THRESHOLD); _func_exit_; @@ -2230,15 +1916,11 @@ static int rtw_wx_get_retry(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - //struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - - wrqu->retry.value = 7; wrqu->retry.fixed = 0; /* no auto select */ wrqu->retry.disabled = 1; return 0; - } static int rtw_wx_set_enc(struct net_device *dev, @@ -2253,7 +1935,7 @@ static int rtw_wx_set_enc(struct net_device *dev, struct iw_point *erq = &(wrqu->encoding); struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; - DBG_88E("+rtw_wx_set_enc, flags=0x%x\n", erq->flags); + DBG_88E("+rtw_wx_set_enc, flags = 0x%x\n", erq->flags); _rtw_memset(&wep, 0, sizeof(struct ndis_802_11_wep)); @@ -2261,15 +1943,14 @@ static int rtw_wx_set_enc(struct net_device *dev, _func_enter_; - if (erq->flags & IW_ENCODE_DISABLED) - { + if (erq->flags & IW_ENCODE_DISABLED) { DBG_88E("EncryptionDisabled\n"); padapter->securitypriv.ndisencryptstatus = Ndis802_11EncryptionDisabled; - padapter->securitypriv.dot11PrivacyAlgrthm=_NO_PRIVACY_; - padapter->securitypriv.dot118021XGrpPrivacy=_NO_PRIVACY_; - padapter->securitypriv.dot11AuthAlgrthm= dot11AuthAlgrthm_Open; //open system + padapter->securitypriv.dot11PrivacyAlgrthm = _NO_PRIVACY_; + padapter->securitypriv.dot118021XGrpPrivacy = _NO_PRIVACY_; + padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Open; /* open system */ authmode = Ndis802_11AuthModeOpen; - padapter->securitypriv.ndisauthtype=authmode; + padapter->securitypriv.ndisauthtype = authmode; goto exit; } @@ -2279,81 +1960,68 @@ static int rtw_wx_set_enc(struct net_device *dev, return -EINVAL; key--; keyindex_provided = 1; - } - else - { + } else { keyindex_provided = 0; key = padapter->securitypriv.dot11PrivacyKeyIndex; - DBG_88E("rtw_wx_set_enc, key=%d\n", key); + DBG_88E("rtw_wx_set_enc, key =%d\n", key); } - //set authentication mode - if (erq->flags & IW_ENCODE_OPEN) - { + /* set authentication mode */ + if (erq->flags & IW_ENCODE_OPEN) { DBG_88E("rtw_wx_set_enc():IW_ENCODE_OPEN\n"); - padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled;//Ndis802_11EncryptionDisabled; - padapter->securitypriv.dot11AuthAlgrthm= dot11AuthAlgrthm_Open; - padapter->securitypriv.dot11PrivacyAlgrthm=_NO_PRIVACY_; - padapter->securitypriv.dot118021XGrpPrivacy=_NO_PRIVACY_; + padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled;/* Ndis802_11EncryptionDisabled; */ + padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Open; + padapter->securitypriv.dot11PrivacyAlgrthm = _NO_PRIVACY_; + padapter->securitypriv.dot118021XGrpPrivacy = _NO_PRIVACY_; authmode = Ndis802_11AuthModeOpen; - padapter->securitypriv.ndisauthtype=authmode; - } - else if (erq->flags & IW_ENCODE_RESTRICTED) - { + padapter->securitypriv.ndisauthtype = authmode; + } else if (erq->flags & IW_ENCODE_RESTRICTED) { DBG_88E("rtw_wx_set_enc():IW_ENCODE_RESTRICTED\n"); padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; - padapter->securitypriv.dot11AuthAlgrthm= dot11AuthAlgrthm_Shared; - padapter->securitypriv.dot11PrivacyAlgrthm=_WEP40_; - padapter->securitypriv.dot118021XGrpPrivacy=_WEP40_; + padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Shared; + padapter->securitypriv.dot11PrivacyAlgrthm = _WEP40_; + padapter->securitypriv.dot118021XGrpPrivacy = _WEP40_; authmode = Ndis802_11AuthModeShared; - padapter->securitypriv.ndisauthtype=authmode; - } - else - { - DBG_88E("rtw_wx_set_enc():erq->flags=0x%x\n", erq->flags); + padapter->securitypriv.ndisauthtype = authmode; + } else { + DBG_88E("rtw_wx_set_enc():erq->flags = 0x%x\n", erq->flags); - padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled;//Ndis802_11EncryptionDisabled; - padapter->securitypriv.dot11AuthAlgrthm= dot11AuthAlgrthm_Open; //open system - padapter->securitypriv.dot11PrivacyAlgrthm=_NO_PRIVACY_; - padapter->securitypriv.dot118021XGrpPrivacy=_NO_PRIVACY_; + padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled;/* Ndis802_11EncryptionDisabled; */ + padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Open; /* open system */ + padapter->securitypriv.dot11PrivacyAlgrthm = _NO_PRIVACY_; + padapter->securitypriv.dot118021XGrpPrivacy = _NO_PRIVACY_; authmode = Ndis802_11AuthModeOpen; - padapter->securitypriv.ndisauthtype=authmode; + padapter->securitypriv.ndisauthtype = authmode; } wep.KeyIndex = key; - if (erq->length > 0) - { + if (erq->length > 0) { wep.KeyLength = erq->length <= 5 ? 5 : 13; wep.Length = wep.KeyLength + FIELD_OFFSET(struct ndis_802_11_wep, KeyMaterial); - } - else - { - wep.KeyLength = 0 ; + } else { + wep.KeyLength = 0; - if (keyindex_provided == 1)// set key_id only, no given KeyMaterial(erq->length==0). - { + if (keyindex_provided == 1) { + /* set key_id only, no given KeyMaterial(erq->length == 0). */ padapter->securitypriv.dot11PrivacyKeyIndex = key; - DBG_88E("(keyindex_provided == 1), keyid=%d, key_len=%d\n", key, padapter->securitypriv.dot11DefKeylen[key]); + DBG_88E("(keyindex_provided == 1), keyid =%d, key_len =%d\n", key, padapter->securitypriv.dot11DefKeylen[key]); - switch (padapter->securitypriv.dot11DefKeylen[key]) - { - case 5: - padapter->securitypriv.dot11PrivacyAlgrthm=_WEP40_; - break; - case 13: - padapter->securitypriv.dot11PrivacyAlgrthm=_WEP104_; - break; - default: - padapter->securitypriv.dot11PrivacyAlgrthm=_NO_PRIVACY_; - break; + switch (padapter->securitypriv.dot11DefKeylen[key]) { + case 5: + padapter->securitypriv.dot11PrivacyAlgrthm = _WEP40_; + break; + case 13: + padapter->securitypriv.dot11PrivacyAlgrthm = _WEP104_; + break; + default: + padapter->securitypriv.dot11PrivacyAlgrthm = _NO_PRIVACY_; + break; } goto exit; - } - } wep.KeyIndex |= 0x80000000; @@ -2371,30 +2039,26 @@ exit: _func_exit_; return ret; - } static int rtw_wx_get_enc(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *keybuf) { - uint key, ret =0; + uint key, ret = 0; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); struct iw_point *erq = &(wrqu->encoding); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); _func_enter_; - if (check_fwstate(pmlmepriv, _FW_LINKED) != true) - { - if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) != true) - { - erq->length = 0; - erq->flags |= IW_ENCODE_DISABLED; - return 0; + if (check_fwstate(pmlmepriv, _FW_LINKED) != true) { + if (!check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) { + erq->length = 0; + erq->flags |= IW_ENCODE_DISABLED; + return 0; + } } - } - key = erq->flags & IW_ENCODE_INDEX; @@ -2402,89 +2066,58 @@ static int rtw_wx_get_enc(struct net_device *dev, if (key > WEP_KEYS) return -EINVAL; key--; - } else - { + } else { key = padapter->securitypriv.dot11PrivacyKeyIndex; } erq->flags = key + 1; - //if (padapter->securitypriv.ndisauthtype == Ndis802_11AuthModeOpen) - //{ - // erq->flags |= IW_ENCODE_OPEN; - //} - - switch (padapter->securitypriv.ndisencryptstatus) - { - case Ndis802_11EncryptionNotSupported: - case Ndis802_11EncryptionDisabled: - + switch (padapter->securitypriv.ndisencryptstatus) { + case Ndis802_11EncryptionNotSupported: + case Ndis802_11EncryptionDisabled: erq->length = 0; erq->flags |= IW_ENCODE_DISABLED; - break; - - case Ndis802_11Encryption1Enabled: - + case Ndis802_11Encryption1Enabled: erq->length = padapter->securitypriv.dot11DefKeylen[key]; - - if (erq->length) - { + if (erq->length) { _rtw_memcpy(keybuf, padapter->securitypriv.dot11DefKey[key].skey, padapter->securitypriv.dot11DefKeylen[key]); - erq->flags |= IW_ENCODE_ENABLED; + erq->flags |= IW_ENCODE_ENABLED; if (padapter->securitypriv.ndisauthtype == Ndis802_11AuthModeOpen) - { erq->flags |= IW_ENCODE_OPEN; - } else if (padapter->securitypriv.ndisauthtype == Ndis802_11AuthModeShared) - { - erq->flags |= IW_ENCODE_RESTRICTED; - } - } - else - { + erq->flags |= IW_ENCODE_RESTRICTED; + } else { erq->length = 0; erq->flags |= IW_ENCODE_DISABLED; } - break; - - case Ndis802_11Encryption2Enabled: - case Ndis802_11Encryption3Enabled: - + case Ndis802_11Encryption2Enabled: + case Ndis802_11Encryption3Enabled: erq->length = 16; erq->flags |= (IW_ENCODE_ENABLED | IW_ENCODE_OPEN | IW_ENCODE_NOKEY); - break; - - default: + default: erq->length = 0; erq->flags |= IW_ENCODE_DISABLED; - break; - } - _func_exit_; return ret; - } static int rtw_wx_get_power(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - //struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - wrqu->power.value = 0; wrqu->power.fixed = 0; /* no auto select */ wrqu->power.disabled = 1; return 0; - } static int rtw_wx_set_gen_ie(struct net_device *dev, @@ -2494,8 +2127,7 @@ static int rtw_wx_set_gen_ie(struct net_device *dev, int ret; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - ret = rtw_set_wpa_ie(padapter, extra, wrqu->data.length); - + ret = rtw_set_wpa_ie(padapter, extra, wrqu->data.length); return ret; } @@ -2504,16 +2136,15 @@ static int rtw_wx_set_auth(struct net_device *dev, union iwreq_data *wrqu, char *extra) { struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct iw_param *param = (struct iw_param*)&(wrqu->param); + struct iw_param *param = (struct iw_param *)&(wrqu->param); struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct security_priv *psecuritypriv = &padapter->securitypriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); u32 value = param->value; int ret = 0; switch (param->flags & IW_AUTH_INDEX) { - case IW_AUTH_WPA_VERSION: break; case IW_AUTH_CIPHER_PAIRWISE: @@ -2528,48 +2159,40 @@ static int rtw_wx_set_auth(struct net_device *dev, */ break; case IW_AUTH_TKIP_COUNTERMEASURES: - { - if (param->value) - { // wpa_supplicant is enabling the tkip countermeasure. - padapter->securitypriv.btkip_countermeasure = true; - } - else - { // wpa_supplicant is disabling the tkip countermeasure. - padapter->securitypriv.btkip_countermeasure = false; - } + if (param->value) { + /* wpa_supplicant is enabling the tkip countermeasure. */ + padapter->securitypriv.btkip_countermeasure = true; + } else { + /* wpa_supplicant is disabling the tkip countermeasure. */ + padapter->securitypriv.btkip_countermeasure = false; + } break; - } case IW_AUTH_DROP_UNENCRYPTED: - { - /* HACK: - * - * wpa_supplicant calls set_wpa_enabled when the driver - * is loaded and unloaded, regardless of if WPA is being - * used. No other calls are made which can be used to - * determine if encryption will be used or not prior to - * association being expected. If encryption is not being - * used, drop_unencrypted is set to false, else true -- we - * can use this to determine if the CAP_PRIVACY_ON bit should - * be set. - */ + /* HACK: + * + * wpa_supplicant calls set_wpa_enabled when the driver + * is loaded and unloaded, regardless of if WPA is being + * used. No other calls are made which can be used to + * determine if encryption will be used or not prior to + * association being expected. If encryption is not being + * used, drop_unencrypted is set to false, else true -- we + * can use this to determine if the CAP_PRIVACY_ON bit should + * be set. + */ - if (padapter->securitypriv.ndisencryptstatus == Ndis802_11Encryption1Enabled) - { - break;//it means init value, or using wep, ndisencryptstatus = Ndis802_11Encryption1Enabled, - // then it needn't reset it; - } + if (padapter->securitypriv.ndisencryptstatus == Ndis802_11Encryption1Enabled) + break;/* it means init value, or using wep, ndisencryptstatus = Ndis802_11Encryption1Enabled, */ + /* then it needn't reset it; */ - if (param->value){ - padapter->securitypriv.ndisencryptstatus = Ndis802_11EncryptionDisabled; - padapter->securitypriv.dot11PrivacyAlgrthm=_NO_PRIVACY_; - padapter->securitypriv.dot118021XGrpPrivacy=_NO_PRIVACY_; - padapter->securitypriv.dot11AuthAlgrthm= dot11AuthAlgrthm_Open; //open system - padapter->securitypriv.ndisauthtype=Ndis802_11AuthModeOpen; - } - - break; + if (param->value) { + padapter->securitypriv.ndisencryptstatus = Ndis802_11EncryptionDisabled; + padapter->securitypriv.dot11PrivacyAlgrthm = _NO_PRIVACY_; + padapter->securitypriv.dot118021XGrpPrivacy = _NO_PRIVACY_; + padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Open; /* open system */ + padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeOpen; } + break; case IW_AUTH_80211_AUTH_ALG: /* * It's the starting point of a link layer connection using wpa_supplicant @@ -2577,7 +2200,7 @@ static int rtw_wx_set_auth(struct net_device *dev, if (check_fwstate(&padapter->mlmepriv, _FW_LINKED)) { LeaveAllPowerSaveMode(padapter); rtw_disassoc_cmd(padapter, 500, false); - DBG_88E("%s...call rtw_indicate_disconnect\n ",__func__); + DBG_88E("%s...call rtw_indicate_disconnect\n ", __func__); rtw_indicate_disconnect(padapter); rtw_free_assoc_resources(padapter, 1); } @@ -2594,7 +2217,6 @@ static int rtw_wx_set_auth(struct net_device *dev, } return ret; - } static int rtw_wx_set_enc_ext(struct net_device *dev, @@ -2606,7 +2228,7 @@ static int rtw_wx_set_enc_ext(struct net_device *dev, struct ieee_param *param = NULL; struct iw_point *pencoding = &wrqu->encoding; struct iw_encode_ext *pext = (struct iw_encode_ext *)extra; - int ret=0; + int ret = 0; param_len = sizeof(struct ieee_param) + pext->key_len; param = (struct ieee_param *)rtw_malloc(param_len); @@ -2618,11 +2240,10 @@ static int rtw_wx_set_enc_ext(struct net_device *dev, param->cmd = IEEE_CMD_SET_ENCRYPTION; _rtw_memset(param->sta_addr, 0xff, ETH_ALEN); - switch (pext->alg) { case IW_ENCODE_ALG_NONE: - //todo: remove key - //remove = 1; + /* todo: remove key */ + /* remove = 1; */ alg_name = "none"; break; case IW_ENCODE_ALG_WEP: @@ -2641,74 +2262,52 @@ static int rtw_wx_set_enc_ext(struct net_device *dev, strncpy((char *)param->u.crypt.alg, alg_name, IEEE_CRYPT_ALG_NAME_LEN); if (pext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) - { param->u.crypt.set_tx = 1; - } /* cliW: WEP does not have group key * just not checking GROUP key setting */ if ((pext->alg != IW_ENCODE_ALG_WEP) && - (pext->ext_flags & IW_ENCODE_EXT_GROUP_KEY)) - { + (pext->ext_flags & IW_ENCODE_EXT_GROUP_KEY)) param->u.crypt.set_tx = 0; - } - param->u.crypt.idx = (pencoding->flags&0x00FF) -1 ; + param->u.crypt.idx = (pencoding->flags&0x00FF) - 1; if (pext->ext_flags & IW_ENCODE_EXT_RX_SEQ_VALID) _rtw_memcpy(param->u.crypt.seq, pext->rx_seq, 8); - if (pext->key_len) - { + if (pext->key_len) { param->u.crypt.key_len = pext->key_len; - //_rtw_memcpy(param + 1, pext + 1, pext->key_len); _rtw_memcpy(param->u.crypt.key, pext + 1, pext->key_len); } - if (pencoding->flags & IW_ENCODE_DISABLED) - { - //todo: remove key - //remove = 1; - } - ret = wpa_set_encryption(dev, param, param_len); if (param) - { - rtw_mfree((u8*)param, param_len); - } + rtw_mfree((u8 *)param, param_len); return ret; } - static int rtw_wx_get_nick(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { - //struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - //struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); - //struct security_priv *psecuritypriv = &padapter->securitypriv; - - if (extra) - { + if (extra) { wrqu->data.length = 14; wrqu->data.flags = 1; _rtw_memcpy(extra, "", 14); } - //rtw_signal_process(pid, SIGUSR1); //for test - - //dump debug info here + /* dump debug info here */ return 0; } static int rtw_wx_read32(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { - struct adapter * padapter; + struct adapter *padapter; struct iw_point *p; u16 len; u32 addr; @@ -2716,11 +2315,10 @@ static int rtw_wx_read32(struct net_device *dev, u32 bytes; u8 *ptmp; - padapter = (struct adapter *)rtw_netdev_priv(dev); p = &wrqu->data; len = p->length; - ptmp = (u8*)rtw_malloc(len); + ptmp = (u8 *)rtw_malloc(len); if (NULL == ptmp) return -ENOMEM; @@ -2734,23 +2332,23 @@ static int rtw_wx_read32(struct net_device *dev, sscanf(ptmp, "%d,%x", &bytes, &addr); switch (bytes) { - case 1: - data32 = rtw_read8(padapter, addr); - sprintf(extra, "0x%02X", data32); - break; - case 2: - data32 = rtw_read16(padapter, addr); - sprintf(extra, "0x%04X", data32); - break; - case 4: - data32 = rtw_read32(padapter, addr); - sprintf(extra, "0x%08X", data32); - break; - default: - DBG_88E(KERN_INFO "%s: usage> read [bytes],[address(hex)]\n", __func__); - return -EINVAL; + case 1: + data32 = rtw_read8(padapter, addr); + sprintf(extra, "0x%02X", data32); + break; + case 2: + data32 = rtw_read16(padapter, addr); + sprintf(extra, "0x%04X", data32); + break; + case 4: + data32 = rtw_read32(padapter, addr); + sprintf(extra, "0x%08X", data32); + break; + default: + DBG_88E(KERN_INFO "%s: usage> read [bytes],[address(hex)]\n", __func__); + return -EINVAL; } - DBG_88E(KERN_INFO "%s: addr=0x%08X data=%s\n", __func__, addr, extra); + DBG_88E(KERN_INFO "%s: addr = 0x%08X data =%s\n", __func__, addr, extra); rtw_mfree(ptmp, len); @@ -2758,54 +2356,51 @@ static int rtw_wx_read32(struct net_device *dev, } static int rtw_wx_write32(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { - struct adapter * padapter = (struct adapter *)rtw_netdev_priv(dev); + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); u32 addr; u32 data32; u32 bytes; - bytes = 0; addr = 0; data32 = 0; sscanf(extra, "%d,%x,%x", &bytes, &addr, &data32); switch (bytes) { - case 1: - rtw_write8(padapter, addr, (u8)data32); - DBG_88E(KERN_INFO "%s: addr=0x%08X data=0x%02X\n", __func__, addr, (u8)data32); - break; - case 2: - rtw_write16(padapter, addr, (u16)data32); - DBG_88E(KERN_INFO "%s: addr=0x%08X data=0x%04X\n", __func__, addr, (u16)data32); - break; - case 4: - rtw_write32(padapter, addr, data32); - DBG_88E(KERN_INFO "%s: addr=0x%08X data=0x%08X\n", __func__, addr, data32); - break; - default: - DBG_88E(KERN_INFO "%s: usage> write [bytes],[address(hex)],[data(hex)]\n", __func__); - return -EINVAL; + case 1: + rtw_write8(padapter, addr, (u8)data32); + DBG_88E(KERN_INFO "%s: addr = 0x%08X data = 0x%02X\n", __func__, addr, (u8)data32); + break; + case 2: + rtw_write16(padapter, addr, (u16)data32); + DBG_88E(KERN_INFO "%s: addr = 0x%08X data = 0x%04X\n", __func__, addr, (u16)data32); + break; + case 4: + rtw_write32(padapter, addr, data32); + DBG_88E(KERN_INFO "%s: addr = 0x%08X data = 0x%08X\n", __func__, addr, data32); + break; + default: + DBG_88E(KERN_INFO "%s: usage> write [bytes],[address(hex)],[data(hex)]\n", __func__); + return -EINVAL; } return 0; } static int rtw_wx_read_rf(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); u32 path, addr, data32; - - path = *(u32*)extra; - addr = *((u32*)extra + 1); + path = *(u32 *)extra; + addr = *((u32 *)extra + 1); data32 = rtw_hal_read_rfreg(padapter, path, addr, 0xFFFFF); -// DBG_88E("%s: path=%d addr=0x%02x data=0x%05x\n", __func__, path, addr, data32); /* * IMPORTANT!! * Only when wireless private ioctl is at odd order, @@ -2817,17 +2412,15 @@ static int rtw_wx_read_rf(struct net_device *dev, } static int rtw_wx_write_rf(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); u32 path, addr, data32; - - path = *(u32*)extra; - addr = *((u32*)extra + 1); - data32 = *((u32*)extra + 2); -// DBG_88E("%s: path=%d addr=0x%02x data=0x%05x\n", __func__, path, addr, data32); + path = *(u32 *)extra; + addr = *((u32 *)extra + 1); + data32 = *((u32 *)extra + 2); rtw_hal_write_rfreg(padapter, path, addr, 0xFFFFF, data32); return 0; @@ -2842,27 +2435,21 @@ static int rtw_wx_priv_null(struct net_device *dev, struct iw_request_info *a, static int dummy(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - //struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - //struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); - - //DBG_88E("cmd_code=%x, fwstate=0x%x\n", a->cmd, get_fwstate(pmlmepriv)); - return -1; - } static int rtw_wx_set_channel_plan(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); struct registry_priv *pregistrypriv = &padapter->registrypriv; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; u8 channel_plan_req = (u8) (*((int *)wrqu)); - if (_SUCCESS == rtw_set_chplan_cmd(padapter, channel_plan_req, 1)) { + if (_SUCCESS == rtw_set_chplan_cmd(padapter, channel_plan_req, 1)) DBG_88E("%s set channel_plan = 0x%02X\n", __func__, pmlmepriv->ChannelPlan); - } else + else return -EPERM; return 0; @@ -2901,7 +2488,7 @@ static int rtw_drvext_hdl(struct net_device *dev, struct iw_request_info *info, static void rtw_dbg_mode_hdl(struct adapter *padapter, u32 id, u8 *pdata, u32 len) { - struct mp_rw_reg * RegRWStruct; + struct mp_rw_reg *RegRWStruct; struct rf_reg_param *prfreg; u8 path; u8 offset; @@ -2909,89 +2496,86 @@ static void rtw_dbg_mode_hdl(struct adapter *padapter, u32 id, u8 *pdata, u32 le DBG_88E("%s\n", __func__); - switch (id) - { - case GEN_MP_IOCTL_SUBCODE(MP_START): - DBG_88E("871x_driver is only for normal mode, can't enter mp mode\n"); + switch (id) { + case GEN_MP_IOCTL_SUBCODE(MP_START): + DBG_88E("871x_driver is only for normal mode, can't enter mp mode\n"); + break; + case GEN_MP_IOCTL_SUBCODE(READ_REG): + RegRWStruct = (struct mp_rw_reg *)pdata; + switch (RegRWStruct->width) { + case 1: + RegRWStruct->value = rtw_read8(padapter, RegRWStruct->offset); break; - case GEN_MP_IOCTL_SUBCODE(READ_REG): - RegRWStruct = (struct mp_rw_reg *)pdata; - switch (RegRWStruct->width) - { - case 1: - RegRWStruct->value = rtw_read8(padapter, RegRWStruct->offset); - break; - case 2: - RegRWStruct->value = rtw_read16(padapter, RegRWStruct->offset); - break; - case 4: - RegRWStruct->value = rtw_read32(padapter, RegRWStruct->offset); - break; - default: - break; - } - + case 2: + RegRWStruct->value = rtw_read16(padapter, RegRWStruct->offset); break; - case GEN_MP_IOCTL_SUBCODE(WRITE_REG): - RegRWStruct = (struct mp_rw_reg *)pdata; - switch (RegRWStruct->width) - { - case 1: - rtw_write8(padapter, RegRWStruct->offset, (u8)RegRWStruct->value); - break; - case 2: - rtw_write16(padapter, RegRWStruct->offset, (u16)RegRWStruct->value); - break; - case 4: - rtw_write32(padapter, RegRWStruct->offset, (u32)RegRWStruct->value); - break; - default: - break; - } - - break; - case GEN_MP_IOCTL_SUBCODE(READ_RF_REG): - - prfreg = (struct rf_reg_param *)pdata; - - path = (u8)prfreg->path; - offset = (u8)prfreg->offset; - - value = rtw_hal_read_rfreg(padapter, path, offset, 0xffffffff); - - prfreg->value = value; - - break; - case GEN_MP_IOCTL_SUBCODE(WRITE_RF_REG): - - prfreg = (struct rf_reg_param *)pdata; - - path = (u8)prfreg->path; - offset = (u8)prfreg->offset; - value = prfreg->value; - - rtw_hal_write_rfreg(padapter, path, offset, 0xffffffff, value); - - break; - case GEN_MP_IOCTL_SUBCODE(TRIGGER_GPIO): - DBG_88E("==> trigger gpio 0\n"); - rtw_hal_set_hwreg(padapter, HW_VAR_TRIGGER_GPIO_0, NULL); - break; -#ifdef CONFIG_BT_COEXIST - case GEN_MP_IOCTL_SUBCODE(SET_DM_BT): - DBG_88E("==> set dm_bt_coexist:%x\n",*(u8 *)pdata); - rtw_hal_set_hwreg(padapter, HW_VAR_BT_SET_COEXIST, pdata); - break; - case GEN_MP_IOCTL_SUBCODE(DEL_BA): - DBG_88E("==> delete ba:%x\n",*(u8 *)pdata); - rtw_hal_set_hwreg(padapter, HW_VAR_BT_ISSUE_DELBA, pdata); - break; -#endif - case GEN_MP_IOCTL_SUBCODE(GET_WIFI_STATUS): - *pdata = rtw_hal_sreset_get_wifi_status(padapter); + case 4: + RegRWStruct->value = rtw_read32(padapter, RegRWStruct->offset); break; default: break; + } + + break; + case GEN_MP_IOCTL_SUBCODE(WRITE_REG): + RegRWStruct = (struct mp_rw_reg *)pdata; + switch (RegRWStruct->width) { + case 1: + rtw_write8(padapter, RegRWStruct->offset, (u8)RegRWStruct->value); + break; + case 2: + rtw_write16(padapter, RegRWStruct->offset, (u16)RegRWStruct->value); + break; + case 4: + rtw_write32(padapter, RegRWStruct->offset, (u32)RegRWStruct->value); + break; + default: + break; + } + + break; + case GEN_MP_IOCTL_SUBCODE(READ_RF_REG): + + prfreg = (struct rf_reg_param *)pdata; + + path = (u8)prfreg->path; + offset = (u8)prfreg->offset; + + value = rtw_hal_read_rfreg(padapter, path, offset, 0xffffffff); + + prfreg->value = value; + + break; + case GEN_MP_IOCTL_SUBCODE(WRITE_RF_REG): + + prfreg = (struct rf_reg_param *)pdata; + + path = (u8)prfreg->path; + offset = (u8)prfreg->offset; + value = prfreg->value; + + rtw_hal_write_rfreg(padapter, path, offset, 0xffffffff, value); + + break; + case GEN_MP_IOCTL_SUBCODE(TRIGGER_GPIO): + DBG_88E("==> trigger gpio 0\n"); + rtw_hal_set_hwreg(padapter, HW_VAR_TRIGGER_GPIO_0, NULL); + break; +#ifdef CONFIG_BT_COEXIST + case GEN_MP_IOCTL_SUBCODE(SET_DM_BT): + DBG_88E("==> set dm_bt_coexist:%x\n", *(u8 *)pdata); + rtw_hal_set_hwreg(padapter, HW_VAR_BT_SET_COEXIST, pdata); + break; + case GEN_MP_IOCTL_SUBCODE(DEL_BA): + DBG_88E("==> delete ba:%x\n", *(u8 *)pdata); + rtw_hal_set_hwreg(padapter, HW_VAR_BT_ISSUE_DELBA, pdata); + break; +#endif + case GEN_MP_IOCTL_SUBCODE(GET_WIFI_STATUS): + *pdata = rtw_hal_sreset_get_wifi_status(padapter); + break; + default: + break; } } @@ -3003,26 +2587,21 @@ static int rtw_mp_ioctl_hdl(struct net_device *dev, struct iw_request_info *info struct oid_par_priv oid_par; struct mp_ioctl_handler *phandler; struct mp_ioctl_param *poidparam; - uint status=0; + uint status = 0; u16 len; u8 *pparmbuf = NULL, bset; - struct adapter * padapter = (struct adapter *)rtw_netdev_priv(dev); + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); struct iw_point *p = &wrqu->data; - //DBG_88E("+rtw_mp_ioctl_hdl\n"); - - //mutex_lock(&ioctl_mutex); - if ((!p->length) || (!p->pointer)) { ret = -EINVAL; goto _rtw_mp_ioctl_hdl_exit; } - pparmbuf = NULL; bset = (u8)(p->flags & 0xFFFF); len = p->length; - pparmbuf = (u8*)rtw_malloc(len); - if (pparmbuf == NULL){ + pparmbuf = (u8 *)rtw_malloc(len); + if (pparmbuf == NULL) { ret = -ENOMEM; goto _rtw_mp_ioctl_hdl_exit; } @@ -3043,57 +2622,49 @@ static int rtw_mp_ioctl_hdl(struct net_device *dev, struct iw_request_info *info goto _rtw_mp_ioctl_hdl_exit; } -if (padapter->registrypriv.mp_mode == 1) -{ - phandler = mp_ioctl_hdl + poidparam->subcode; + if (padapter->registrypriv.mp_mode == 1) { + phandler = mp_ioctl_hdl + poidparam->subcode; - if ((phandler->paramsize != 0) && (poidparam->len < phandler->paramsize)) - { - RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_err_, - ("no matching drvext param size %d vs %d\r\n", - poidparam->len, phandler->paramsize)); - ret = -EINVAL; - goto _rtw_mp_ioctl_hdl_exit; - } - - if (phandler->handler) - { - oid_par.adapter_context = padapter; - oid_par.oid = phandler->oid; - oid_par.information_buf = poidparam->data; - oid_par.information_buf_len = poidparam->len; - oid_par.dbg = 0; - - BytesWritten = 0; - BytesNeeded = 0; - - if (bset) { - oid_par.bytes_rw = &BytesRead; - oid_par.bytes_needed = &BytesNeeded; - oid_par.type_of_oid = SET_OID; - } else { - oid_par.bytes_rw = &BytesWritten; - oid_par.bytes_needed = &BytesNeeded; - oid_par.type_of_oid = QUERY_OID; + if ((phandler->paramsize != 0) && (poidparam->len < phandler->paramsize)) { + RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_err_, + ("no matching drvext param size %d vs %d\r\n", + poidparam->len, phandler->paramsize)); + ret = -EINVAL; + goto _rtw_mp_ioctl_hdl_exit; } - status = phandler->handler(&oid_par); + if (phandler->handler) { + oid_par.adapter_context = padapter; + oid_par.oid = phandler->oid; + oid_par.information_buf = poidparam->data; + oid_par.information_buf_len = poidparam->len; + oid_par.dbg = 0; - //todo:check status, BytesNeeded, etc. - } - else { - DBG_88E("rtw_mp_ioctl_hdl(): err!, subcode=%d, oid=%d, handler=%p\n", - poidparam->subcode, phandler->oid, phandler->handler); - ret = -EFAULT; - goto _rtw_mp_ioctl_hdl_exit; - } -} -else - { + BytesWritten = 0; + BytesNeeded = 0; + + if (bset) { + oid_par.bytes_rw = &BytesRead; + oid_par.bytes_needed = &BytesNeeded; + oid_par.type_of_oid = SET_OID; + } else { + oid_par.bytes_rw = &BytesWritten; + oid_par.bytes_needed = &BytesNeeded; + oid_par.type_of_oid = QUERY_OID; + } + + status = phandler->handler(&oid_par); + } else { + DBG_88E("rtw_mp_ioctl_hdl(): err!, subcode =%d, oid =%d, handler =%p\n", + poidparam->subcode, phandler->oid, phandler->handler); + ret = -EFAULT; + goto _rtw_mp_ioctl_hdl_exit; + } + } else { rtw_dbg_mode_hdl(padapter, poidparam->subcode, poidparam->data, poidparam->len); -} + } - if (bset == 0x00) {//query info + if (bset == 0x00) {/* query info */ if (copy_to_user(p->pointer, pparmbuf, len)) ret = -EFAULT; } @@ -3107,18 +2678,15 @@ _rtw_mp_ioctl_hdl_exit: if (pparmbuf) rtw_mfree(pparmbuf, len); - - //mutex_unlock(&ioctl_mutex); - return ret; } static int rtw_get_ap_info(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { int bssid_match, ret = 0; - u32 cnt=0, wpa_ielen; + u32 cnt = 0, wpa_ielen; unsigned long irqL; struct list_head *plist, *phead; unsigned char *pbuf; @@ -3132,34 +2700,25 @@ static int rtw_get_ap_info(struct net_device *dev, DBG_88E("+rtw_get_aplist_info\n"); - if ((padapter->bDriverStopped) || (pdata==NULL)) - { - ret= -EINVAL; + if ((padapter->bDriverStopped) || (pdata == NULL)) { + ret = -EINVAL; goto exit; } - while ((check_fwstate(pmlmepriv, (_FW_UNDER_SURVEY|_FW_UNDER_LINKING))) == true) - { + while ((check_fwstate(pmlmepriv, (_FW_UNDER_SURVEY|_FW_UNDER_LINKING)))) { rtw_msleep_os(30); cnt++; if (cnt > 100) break; } - - - //pdata->length = 0;//? pdata->flags = 0; - if (pdata->length>=32) - { - if (copy_from_user(data, pdata->pointer, 32)) - { - ret= -EINVAL; + if (pdata->length >= 32) { + if (copy_from_user(data, pdata->pointer, 32)) { + ret = -EINVAL; goto exit; } - } - else - { - ret= -EINVAL; + } else { + ret = -EINVAL; goto exit; } @@ -3168,54 +2727,43 @@ static int rtw_get_ap_info(struct net_device *dev, phead = get_list_head(queue); plist = get_next(phead); - while (1) - { - if (rtw_end_of_queue_search(phead,plist)== true) + while (1) { + if (rtw_end_of_queue_search(phead, plist) == true) break; - pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); - //if (hwaddr_aton_i(pdata->pointer, bssid)) - if (hwaddr_aton_i(data, bssid)) - { - DBG_88E("Invalid BSSID '%s'.\n", (u8*)data); + if (hwaddr_aton_i(data, bssid)) { + DBG_88E("Invalid BSSID '%s'.\n", (u8 *)data); _exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); return -EINVAL; } - - if (!memcmp(bssid, pnetwork->network.MacAddress, ETH_ALEN) == true)//BSSID match, then check if supporting wpa/wpa2 - { + if (!memcmp(bssid, pnetwork->network.MacAddress, ETH_ALEN) == true) { + /* BSSID match, then check if supporting wpa/wpa2 */ DBG_88E("BSSID:%pM\n", (bssid)); pbuf = rtw_get_wpa_ie(&pnetwork->network.IEs[12], &wpa_ielen, pnetwork->network.IELength-12); - if (pbuf && (wpa_ielen>0)) - { + if (pbuf && (wpa_ielen > 0)) { pdata->flags = 1; break; } pbuf = rtw_get_wpa2_ie(&pnetwork->network.IEs[12], &wpa_ielen, pnetwork->network.IELength-12); - if (pbuf && (wpa_ielen>0)) - { + if (pbuf && (wpa_ielen > 0)) { pdata->flags = 2; break; } - } plist = get_next(plist); - } _exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); - if (pdata->length>=34) - { - if (copy_to_user(pdata->pointer+32, (u8*)&pdata->flags, 1)) - { - ret= -EINVAL; + if (pdata->length >= 34) { + if (copy_to_user(pdata->pointer+32, (u8 *)&pdata->flags, 1)) { + ret = -EINVAL; goto exit; } } @@ -3223,58 +2771,51 @@ static int rtw_get_ap_info(struct net_device *dev, exit: return ret; - } static int rtw_set_pid(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { - int ret = 0; struct adapter *padapter = rtw_netdev_priv(dev); int *pdata = (int *)wrqu; int selector; - if ((padapter->bDriverStopped) || (pdata==NULL)) - { - ret= -EINVAL; + if ((padapter->bDriverStopped) || (pdata == NULL)) { + ret = -EINVAL; goto exit; } selector = *pdata; - if (selector < 3 && selector >=0) { + if (selector < 3 && selector >= 0) { padapter->pid[selector] = *(pdata+1); ui_pid[selector] = *(pdata+1); - DBG_88E("%s set pid[%d]=%d\n", __func__, selector ,padapter->pid[selector]); - } - else + DBG_88E("%s set pid[%d] =%d\n", __func__, selector, padapter->pid[selector]); + } else { DBG_88E("%s selector %d error\n", __func__, selector); - + } exit: - return ret; - } static int rtw_wps_start(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { - int ret = 0; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); struct iw_point *pdata = &wrqu->data; u32 u32wps_start = 0; - ret = copy_from_user((void*) &u32wps_start, pdata->pointer, 4); + ret = copy_from_user((void *)&u32wps_start, pdata->pointer, 4); if (ret) { - ret= -EINVAL; + ret = -EINVAL; goto exit; } - if ((padapter->bDriverStopped) || (pdata==NULL)) { - ret= -EINVAL; + if ((padapter->bDriverStopped) || (pdata == NULL)) { + ret = -EINVAL; goto exit; } @@ -3283,11 +2824,11 @@ static int rtw_wps_start(struct net_device *dev, DBG_88E("[%s] wps_start = %d\n", __func__, u32wps_start); - if (u32wps_start == 1) // WPS Start + if (u32wps_start == 1) /* WPS Start */ rtw_led_control(padapter, LED_CTL_START_WPS); - else if (u32wps_start == 2) // WPS Stop because of wps success + else if (u32wps_start == 2) /* WPS Stop because of wps success */ rtw_led_control(padapter, LED_CTL_STOP_WPS); - else if (u32wps_start == 3) // WPS Stop because of wps fail + else if (u32wps_start == 3) /* WPS Stop because of wps fail */ rtw_led_control(padapter, LED_CTL_STOP_WPS_FAIL); exit: @@ -3296,15 +2837,14 @@ exit: #ifdef CONFIG_P2P static int rtw_wext_p2p_enable(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { - int ret = 0; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); struct iw_point *pdata = &wrqu->data; - struct wifidirect_info *pwdinfo= &(padapter->wdinfo); + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; enum P2P_ROLE init_role = P2P_ROLE_DISABLE; @@ -3318,21 +2858,18 @@ static int rtw_wext_p2p_enable(struct net_device *dev, else if (*extra == '3') init_role = P2P_ROLE_GO; - if (_FAIL == rtw_p2p_enable(padapter, init_role)) - { + if (_FAIL == rtw_p2p_enable(padapter, init_role)) { ret = -EFAULT; goto exit; } - //set channel/bandwidth - if (init_role != P2P_ROLE_DISABLE) - { + /* set channel/bandwidth */ + if (init_role != P2P_ROLE_DISABLE) { u8 channel, ch_offset; u16 bwmode; - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_LISTEN)) - { - // Stay at the listen state and wait for discovery. + if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_LISTEN)) { + /* Stay at the listen state and wait for discovery. */ channel = pwdinfo->listen_channel; pwdinfo->operating_channel = pwdinfo->listen_channel; ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; @@ -3353,469 +2890,379 @@ exit: } static int rtw_p2p_set_go_nego_ssid(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { - int ret = 0; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); struct iw_point *pdata = &wrqu->data; - struct wifidirect_info *pwdinfo= &(padapter->wdinfo); + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); DBG_88E("[%s] ssid = %s, len = %zu\n", __func__, extra, strlen(extra)); _rtw_memcpy(pwdinfo->nego_ssid, extra, strlen(extra)); pwdinfo->nego_ssidlen = strlen(extra); return ret; - } - static int rtw_p2p_set_intent(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { - int ret = 0; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct wifidirect_info *pwdinfo= &(padapter->wdinfo); - u8 intent = pwdinfo->intent; + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + u8 intent = pwdinfo->intent; - switch (wrqu->data.length) - { - case 1: - { - intent = extra[ 0 ] - '0'; - break; - } - case 2: - { - intent = str_2char2num(extra[ 0 ], extra[ 1 ]); - break; - } + switch (wrqu->data.length) { + case 1: + intent = extra[0] - '0'; + break; + case 2: + intent = str_2char2num(extra[0], extra[1]); + break; } - if (intent <= 15) - { - pwdinfo->intent= intent; - } + pwdinfo->intent = intent; else - { ret = -1; - } - DBG_88E("[%s] intent = %d\n", __func__, intent); - return ret; - } static int rtw_p2p_set_listen_ch(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { - int ret = 0; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct wifidirect_info *pwdinfo= &(padapter->wdinfo); - u8 listen_ch = pwdinfo->listen_channel; // Listen channel number + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + u8 listen_ch = pwdinfo->listen_channel; /* Listen channel number */ - switch (wrqu->data.length) - { - case 1: - { - listen_ch = extra[ 0 ] - '0'; - break; - } - case 2: - { - listen_ch = str_2char2num(extra[ 0 ], extra[ 1 ]); - break; - } + switch (wrqu->data.length) { + case 1: + listen_ch = extra[0] - '0'; + break; + case 2: + listen_ch = str_2char2num(extra[0], extra[1]); + break; } - if ((listen_ch == 1) || (listen_ch == 6) || (listen_ch == 11)) - { + if ((listen_ch == 1) || (listen_ch == 6) || (listen_ch == 11)) { pwdinfo->listen_channel = listen_ch; set_channel_bwmode(padapter, pwdinfo->listen_channel, HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20); - } - else - { + } else { ret = -1; } DBG_88E("[%s] listen_ch = %d\n", __func__, pwdinfo->listen_channel); return ret; - } static int rtw_p2p_set_op_ch(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { -// Commented by Albert 20110524 -// This function is used to set the operating channel if the driver will become the group owner +/* Commented by Albert 20110524 */ +/* This function is used to set the operating channel if the driver will become the group owner */ int ret = 0; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct wifidirect_info *pwdinfo= &(padapter->wdinfo); - u8 op_ch = pwdinfo->operating_channel; // Operating channel number + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + u8 op_ch = pwdinfo->operating_channel; /* Operating channel number */ - switch (wrqu->data.length) - { - case 1: - { - op_ch = extra[ 0 ] - '0'; - break; - } - case 2: - { - op_ch = str_2char2num(extra[ 0 ], extra[ 1 ]); - break; - } + switch (wrqu->data.length) { + case 1: + op_ch = extra[0] - '0'; + break; + case 2: + op_ch = str_2char2num(extra[0], extra[1]); + break; } if (op_ch > 0) - { pwdinfo->operating_channel = op_ch; - } else - { ret = -1; - } DBG_88E("[%s] op_ch = %d\n", __func__, pwdinfo->operating_channel); return ret; - } - static int rtw_p2p_profilefound(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { - int ret = 0; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct wifidirect_info *pwdinfo= &(padapter->wdinfo); + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); - // Comment by Albert 2010/10/13 - // Input data format: - // Ex: 0 - // Ex: 1XX:XX:XX:XX:XX:XXYYSSID - // 0 => Reflush the profile record list. - // 1 => Add the profile list - // XX:XX:XX:XX:XX:XX => peer's MAC Address (ex: 00:E0:4C:00:00:01) - // YY => SSID Length - // SSID => SSID for persistence group + /* Comment by Albert 2010/10/13 */ + /* Input data format: */ + /* Ex: 0 */ + /* Ex: 1XX:XX:XX:XX:XX:XXYYSSID */ + /* 0 => Reflush the profile record list. */ + /* 1 => Add the profile list */ + /* XX:XX:XX:XX:XX:XX => peer's MAC Address (ex: 00:E0:4C:00:00:01) */ + /* YY => SSID Length */ + /* SSID => SSID for persistence group */ - DBG_88E("[%s] In value = %s, len = %d\n", __func__, extra, wrqu->data.length -1); + DBG_88E("[%s] In value = %s, len = %d\n", __func__, extra, wrqu->data.length - 1); - - // The upper application should pass the SSID to driver by using this rtw_p2p_profilefound function. - if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) - { - if (extra[ 0 ] == '0') - { - // Remove all the profile information of wifidirect_info structure. - _rtw_memset(&pwdinfo->profileinfo[ 0 ], 0x00, sizeof(struct profile_info) * P2P_MAX_PERSISTENT_GROUP_NUM); + /* The upper application should pass the SSID to driver by using this rtw_p2p_profilefound function. */ + if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) { + if (extra[0] == '0') { + /* Remove all the profile information of wifidirect_info structure. */ + _rtw_memset(&pwdinfo->profileinfo[0], 0x00, sizeof(struct profile_info) * P2P_MAX_PERSISTENT_GROUP_NUM); pwdinfo->profileindex = 0; - } - else - { - if (pwdinfo->profileindex >= P2P_MAX_PERSISTENT_GROUP_NUM) - { + } else { + if (pwdinfo->profileindex >= P2P_MAX_PERSISTENT_GROUP_NUM) { ret = -1; - } - else - { + } else { int jj, kk; - // Add this profile information into pwdinfo->profileinfo - // Ex: 1XX:XX:XX:XX:XX:XXYYSSID + /* Add this profile information into pwdinfo->profileinfo */ + /* Ex: 1XX:XX:XX:XX:XX:XXYYSSID */ for (jj = 0, kk = 1; jj < ETH_ALEN; jj++, kk += 3) - { - pwdinfo->profileinfo[ pwdinfo->profileindex ].peermac[ jj ] = key_2char2num(extra[ kk ], extra[ kk+ 1 ]); - } + pwdinfo->profileinfo[pwdinfo->profileindex].peermac[jj] = key_2char2num(extra[kk], extra[kk + 1]); - pwdinfo->profileinfo[ pwdinfo->profileindex ].ssidlen = (extra[18] - '0') * 10 + (extra[ 19 ] - '0'); - _rtw_memcpy(pwdinfo->profileinfo[ pwdinfo->profileindex ].ssid, &extra[ 20 ], pwdinfo->profileinfo[ pwdinfo->profileindex ].ssidlen); + pwdinfo->profileinfo[pwdinfo->profileindex].ssidlen = (extra[18] - '0') * 10 + (extra[19] - '0'); + _rtw_memcpy(pwdinfo->profileinfo[pwdinfo->profileindex].ssid, &extra[20], pwdinfo->profileinfo[pwdinfo->profileindex].ssidlen); pwdinfo->profileindex++; } } } return ret; - } static int rtw_p2p_setDN(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { - int ret = 0; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct wifidirect_info *pwdinfo= &(padapter->wdinfo); + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); - - DBG_88E("[%s] %s %d\n", __func__, extra, wrqu->data.length -1 ); + DBG_88E("[%s] %s %d\n", __func__, extra, wrqu->data.length - 1); _rtw_memset(pwdinfo->device_name, 0x00, WPS_MAX_DEVICE_NAME_LEN); _rtw_memcpy(pwdinfo->device_name, extra, wrqu->data.length - 1); pwdinfo->device_name_len = wrqu->data.length - 1; return ret; - } - static int rtw_p2p_get_status(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { - int ret = 0; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); struct iw_point *pdata = &wrqu->data; - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); if (padapter->bShowGetP2PState) - { DBG_88E("[%s] Role = %d, Status = %d, peer addr = %.2X:%.2X:%.2X:%.2X:%.2X:%.2X\n", __func__, rtw_p2p_role(pwdinfo), rtw_p2p_state(pwdinfo), - pwdinfo->p2p_peer_interface_addr[ 0 ], pwdinfo->p2p_peer_interface_addr[ 1 ], pwdinfo->p2p_peer_interface_addr[ 2 ], - pwdinfo->p2p_peer_interface_addr[ 3 ], pwdinfo->p2p_peer_interface_addr[ 4 ], pwdinfo->p2p_peer_interface_addr[ 5 ]); - } + pwdinfo->p2p_peer_interface_addr[0], pwdinfo->p2p_peer_interface_addr[1], pwdinfo->p2p_peer_interface_addr[2], + pwdinfo->p2p_peer_interface_addr[3], pwdinfo->p2p_peer_interface_addr[4], pwdinfo->p2p_peer_interface_addr[5]); - // Commented by Albert 2010/10/12 - // Because of the output size limitation, I had removed the "Role" information. - // About the "Role" information, we will use the new private IOCTL to get the "Role" information. - sprintf(extra, "\n\nStatus=%.2d\n", rtw_p2p_state(pwdinfo)); + /* Commented by Albert 2010/10/12 */ + /* Because of the output size limitation, I had removed the "Role" information. */ + /* About the "Role" information, we will use the new private IOCTL to get the "Role" information. */ + sprintf(extra, "\n\nStatus =%.2d\n", rtw_p2p_state(pwdinfo)); wrqu->data.length = strlen(extra); return ret; - } -// Commented by Albert 20110520 -// This function will return the config method description -// This config method description will show us which config method the remote P2P device is intented to use -// by sending the provisioning discovery request frame. +/* Commented by Albert 20110520 */ +/* This function will return the config method description */ +/* This config method description will show us which config method the remote P2P device is intented to use */ +/* by sending the provisioning discovery request frame. */ static int rtw_p2p_get_req_cm(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { - int ret = 0; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); struct iw_point *pdata = &wrqu->data; - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); - sprintf(extra, "\n\nCM=%s\n", pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req); + sprintf(extra, "\n\nCM =%s\n", pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req); wrqu->data.length = strlen(extra); return ret; - } - static int rtw_p2p_get_role(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { - int ret = 0; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); struct iw_point *pdata = &wrqu->data; - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); - + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); DBG_88E("[%s] Role = %d, Status = %d, peer addr = %.2X:%.2X:%.2X:%.2X:%.2X:%.2X\n", __func__, rtw_p2p_role(pwdinfo), rtw_p2p_state(pwdinfo), - pwdinfo->p2p_peer_interface_addr[ 0 ], pwdinfo->p2p_peer_interface_addr[ 1 ], pwdinfo->p2p_peer_interface_addr[ 2 ], - pwdinfo->p2p_peer_interface_addr[ 3 ], pwdinfo->p2p_peer_interface_addr[ 4 ], pwdinfo->p2p_peer_interface_addr[ 5 ]); + pwdinfo->p2p_peer_interface_addr[0], pwdinfo->p2p_peer_interface_addr[1], pwdinfo->p2p_peer_interface_addr[2], + pwdinfo->p2p_peer_interface_addr[3], pwdinfo->p2p_peer_interface_addr[4], pwdinfo->p2p_peer_interface_addr[5]); - sprintf(extra, "\n\nRole=%.2d\n", rtw_p2p_role(pwdinfo)); + sprintf(extra, "\n\nRole =%.2d\n", rtw_p2p_role(pwdinfo)); wrqu->data.length = strlen(extra); return ret; - } - static int rtw_p2p_get_peer_ifaddr(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { - int ret = 0; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); struct iw_point *pdata = &wrqu->data; - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); - - DBG_88E("[%s] Role = %d, Status = %d, peer addr = %.2X:%.2X:%.2X:%.2X:%.2X:%.2X\n", __func__, rtw_p2p_role(pwdinfo), rtw_p2p_state(pwdinfo), - pwdinfo->p2p_peer_interface_addr[ 0 ], pwdinfo->p2p_peer_interface_addr[ 1 ], pwdinfo->p2p_peer_interface_addr[ 2 ], - pwdinfo->p2p_peer_interface_addr[ 3 ], pwdinfo->p2p_peer_interface_addr[ 4 ], pwdinfo->p2p_peer_interface_addr[ 5 ]); - - sprintf(extra, "\nMAC %.2X:%.2X:%.2X:%.2X:%.2X:%.2X", - pwdinfo->p2p_peer_interface_addr[ 0 ], pwdinfo->p2p_peer_interface_addr[ 1 ], pwdinfo->p2p_peer_interface_addr[ 2 ], - pwdinfo->p2p_peer_interface_addr[ 3 ], pwdinfo->p2p_peer_interface_addr[ 4 ], pwdinfo->p2p_peer_interface_addr[ 5 ]); + DBG_88E("[%s] Role = %d, Status = %d, peer addr = %pM\n", __func__, + rtw_p2p_role(pwdinfo), rtw_p2p_state(pwdinfo), + pwdinfo->p2p_peer_interface_addr); + sprintf(extra, "\nMAC %pM", + pwdinfo->p2p_peer_interface_addr); wrqu->data.length = strlen(extra); return ret; - } static int rtw_p2p_get_peer_devaddr(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { - int ret = 0; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); struct iw_point *pdata = &wrqu->data; - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); - DBG_88E("[%s] Role = %d, Status = %d, peer addr = %.2X:%.2X:%.2X:%.2X:%.2X:%.2X\n", __func__, rtw_p2p_role(pwdinfo), rtw_p2p_state(pwdinfo), - pwdinfo->rx_prov_disc_info.peerDevAddr[ 0 ], pwdinfo->rx_prov_disc_info.peerDevAddr[ 1 ], - pwdinfo->rx_prov_disc_info.peerDevAddr[ 2 ], pwdinfo->rx_prov_disc_info.peerDevAddr[ 3 ], - pwdinfo->rx_prov_disc_info.peerDevAddr[ 4 ], pwdinfo->rx_prov_disc_info.peerDevAddr[ 5 ]); - sprintf(extra, "\n%.2X%.2X%.2X%.2X%.2X%.2X", - pwdinfo->rx_prov_disc_info.peerDevAddr[ 0 ], pwdinfo->rx_prov_disc_info.peerDevAddr[ 1 ], - pwdinfo->rx_prov_disc_info.peerDevAddr[ 2 ], pwdinfo->rx_prov_disc_info.peerDevAddr[ 3 ], - pwdinfo->rx_prov_disc_info.peerDevAddr[ 4 ], pwdinfo->rx_prov_disc_info.peerDevAddr[ 5 ]); + DBG_88E("[%s] Role = %d, Status = %d, peer addr = %pM\n", __func__, + rtw_p2p_role(pwdinfo), rtw_p2p_state(pwdinfo), + pwdinfo->rx_prov_disc_info.peerDevAddr); + sprintf(extra, "\n%pM", + pwdinfo->rx_prov_disc_info.peerDevAddr); wrqu->data.length = strlen(extra); return ret; - } static int rtw_p2p_get_peer_devaddr_by_invitation(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { - int ret = 0; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); struct iw_point *pdata = &wrqu->data; - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); - DBG_88E("[%s] Role = %d, Status = %d, peer addr = %.2X:%.2X:%.2X:%.2X:%.2X:%.2X\n", __func__, rtw_p2p_role(pwdinfo), rtw_p2p_state(pwdinfo), - pwdinfo->p2p_peer_device_addr[ 0 ], pwdinfo->p2p_peer_device_addr[ 1 ], - pwdinfo->p2p_peer_device_addr[ 2 ], pwdinfo->p2p_peer_device_addr[ 3 ], - pwdinfo->p2p_peer_device_addr[ 4 ], pwdinfo->p2p_peer_device_addr[ 5 ]); - sprintf(extra, "\nMAC %.2X:%.2X:%.2X:%.2X:%.2X:%.2X", - pwdinfo->p2p_peer_device_addr[ 0 ], pwdinfo->p2p_peer_device_addr[ 1 ], - pwdinfo->p2p_peer_device_addr[ 2 ], pwdinfo->p2p_peer_device_addr[ 3 ], - pwdinfo->p2p_peer_device_addr[ 4 ], pwdinfo->p2p_peer_device_addr[ 5 ]); + DBG_88E("[%s] Role = %d, Status = %d, peer addr = %pM\n", + __func__, rtw_p2p_role(pwdinfo), rtw_p2p_state(pwdinfo), + pwdinfo->p2p_peer_device_addr); + sprintf(extra, "\nMAC %pM", + pwdinfo->p2p_peer_device_addr); wrqu->data.length = strlen(extra); return ret; - } static int rtw_p2p_get_groupid(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { - int ret = 0; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); struct iw_point *pdata = &wrqu->data; - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); sprintf(extra, "\n%.2X:%.2X:%.2X:%.2X:%.2X:%.2X %s", - pwdinfo->groupid_info.go_device_addr[ 0 ], pwdinfo->groupid_info.go_device_addr[ 1 ], - pwdinfo->groupid_info.go_device_addr[ 2 ], pwdinfo->groupid_info.go_device_addr[ 3 ], - pwdinfo->groupid_info.go_device_addr[ 4 ], pwdinfo->groupid_info.go_device_addr[ 5 ], - pwdinfo->groupid_info.ssid); + pwdinfo->groupid_info.go_device_addr[0], pwdinfo->groupid_info.go_device_addr[1], + pwdinfo->groupid_info.go_device_addr[2], pwdinfo->groupid_info.go_device_addr[3], + pwdinfo->groupid_info.go_device_addr[4], pwdinfo->groupid_info.go_device_addr[5], + pwdinfo->groupid_info.ssid); wrqu->data.length = strlen(extra); return ret; - } static int rtw_p2p_get_op_ch(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { - int ret = 0; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); struct iw_point *pdata = &wrqu->data; - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); - + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); DBG_88E("[%s] Op_ch = %02x\n", __func__, pwdinfo->operating_channel); - sprintf(extra, "\n\nOp_ch=%.2d\n", pwdinfo->operating_channel); + sprintf(extra, "\n\nOp_ch =%.2d\n", pwdinfo->operating_channel); wrqu->data.length = strlen(extra); return ret; - } static int rtw_p2p_get_wps_configmethod(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { - int ret = 0; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct iw_point *pdata = &wrqu->data; - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); - u8 peerMAC[ ETH_ALEN ] = { 0x00 }; - int jj,kk; - u8 peerMACStr[ 17 ] = { 0x00 }; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct iw_point *pdata = &wrqu->data; + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + u8 peerMAC[ETH_ALEN] = {0x00}; + int jj, kk; + u8 peerMACStr[17] = {0x00}; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; unsigned long irqL; struct list_head *plist, *phead; struct __queue *queue = &(pmlmepriv->scanned_queue); struct wlan_network *pnetwork = NULL; - u8 blnMatch = 0; + u8 blnMatch = 0; u16 attr_content = 0; - uint attr_contentlen = 0; - //6 is the string "wpsCM=", 17 is the MAC addr, we have to clear it at wrqu->data.pointer - u8 attr_content_str[ 6 + 17 ] = { 0x00 }; + uint attr_contentlen = 0; + /* 6 is the string "wpsCM =", 17 is the MAC addr, we have to clear it at wrqu->data.pointer */ + u8 attr_content_str[6 + 17] = {0x00}; - // Commented by Albert 20110727 - // The input data is the MAC address which the application wants to know its WPS config method. - // After knowing its WPS config method, the application can decide the config method for provisioning discovery. - // Format: iwpriv wlanx p2p_get_wpsCM 00:E0:4C:00:00:05 + /* Commented by Albert 20110727 */ + /* The input data is the MAC address which the application wants to know its WPS config method. */ + /* After knowing its WPS config method, the application can decide the config method for provisioning discovery. */ + /* Format: iwpriv wlanx p2p_get_wpsCM 00:E0:4C:00:00:05 */ - DBG_88E("[%s] data = %s\n", __func__, (char*) extra); - if (copy_from_user(peerMACStr, wrqu->data.pointer + 6 , 17)) { + DBG_88E("[%s] data = %s\n", __func__, (char *)extra); + if (copy_from_user(peerMACStr, wrqu->data.pointer + 6, 17)) return -EFAULT; - } - for (jj = 0, kk = 0; jj < ETH_ALEN; jj++, kk += 3) - { - peerMAC[ jj ] = key_2char2num(peerMACStr[kk], peerMACStr[kk+ 1]); - } + peerMAC[jj] = key_2char2num(peerMACStr[kk], peerMACStr[kk + 1]); _enter_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); phead = get_list_head(queue); plist = get_next(phead); - while (1) - { - if (rtw_end_of_queue_search(phead,plist)== true) + while (1) { + if (rtw_end_of_queue_search(phead, plist) == true) break; pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); - if (!memcmp(pnetwork->network.MacAddress, peerMAC, ETH_ALEN)) - { + if (!memcmp(pnetwork->network.MacAddress, peerMAC, ETH_ALEN)) { u8 *wpsie; - uint wpsie_len = 0; + uint wpsie_len = 0; __be16 be_tmp; - // The mac address is matched. - if ((wpsie=rtw_get_wps_ie(&pnetwork->network.IEs[ 12 ], pnetwork->network.IELength - 12, NULL, &wpsie_len))) { - rtw_get_wps_attr_content(wpsie, wpsie_len, WPS_ATTR_CONF_METHOD, (u8*) &be_tmp, &attr_contentlen); + /* The mac address is matched. */ + wpsie = rtw_get_wps_ie(&pnetwork->network.IEs[12], pnetwork->network.IELength - 12, NULL, &wpsie_len); + if (wpsie) { + rtw_get_wps_attr_content(wpsie, wpsie_len, WPS_ATTR_CONF_METHOD, (u8 *) &be_tmp, &attr_contentlen); if (attr_contentlen) { attr_content = be16_to_cpu(be_tmp); - sprintf(attr_content_str, "\n\nM=%.4d", attr_content); + sprintf(attr_content_str, "\n\nM =%.4d", attr_content); blnMatch = 1; } } @@ -3827,7 +3274,7 @@ static int rtw_p2p_get_wps_configmethod(struct net_device *dev, _exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); if (!blnMatch) - sprintf(attr_content_str, "\n\nM=0000"); + sprintf(attr_content_str, "\n\nM = 0000"); if (copy_to_user(wrqu->data.pointer, attr_content_str, 6 + 17)) return -EFAULT; @@ -3835,171 +3282,147 @@ static int rtw_p2p_get_wps_configmethod(struct net_device *dev, } static int rtw_p2p_get_go_device_address(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { - int ret = 0; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct iw_point *pdata = &wrqu->data; - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); - u8 peerMAC[ ETH_ALEN ] = { 0x00 }; - int jj,kk; - u8 peerMACStr[ 17 ] = { 0x00 }; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct iw_point *pdata = &wrqu->data; + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + u8 peerMAC[ETH_ALEN] = {0x00}; + int jj, kk; + u8 peerMACStr[17] = {0x00}; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; unsigned long irqL; struct list_head *plist, *phead; struct __queue *queue = &(pmlmepriv->scanned_queue); struct wlan_network *pnetwork = NULL; - u8 blnMatch = 0; - u8 *p2pie; - uint p2pielen = 0, attr_contentlen = 0; - u8 attr_content[100] = { 0x00 }; + u8 blnMatch = 0; + u8 *p2pie; + uint p2pielen = 0, attr_contentlen = 0; + u8 attr_content[100] = {0x00}; - u8 go_devadd_str[ 17 + 10 ] = { 0x00 }; - // +10 is for the str "go_devadd=", we have to clear it at wrqu->data.pointer + u8 go_devadd_str[17 + 10] = {0x00}; + /* +10 is for the str "go_devadd =", we have to clear it at wrqu->data.pointer */ - // Commented by Albert 20121209 - // The input data is the GO's interface address which the application wants to know its device address. - // Format: iwpriv wlanx p2p_get2 go_devadd=00:E0:4C:00:00:05 + /* Commented by Albert 20121209 */ + /* The input data is the GO's interface address which the application wants to know its device address. */ + /* Format: iwpriv wlanx p2p_get2 go_devadd = 00:E0:4C:00:00:05 */ - DBG_88E("[%s] data = %s\n", __func__, (char*) extra); - if (copy_from_user(peerMACStr, wrqu->data.pointer + 10 , 17)) { - return -EFAULT; - } + DBG_88E("[%s] data = %s\n", __func__, (char *)extra); + if (copy_from_user(peerMACStr, wrqu->data.pointer + 10, 17)) + return -EFAULT; for (jj = 0, kk = 0; jj < ETH_ALEN; jj++, kk += 3) - { - peerMAC[ jj ] = key_2char2num(peerMACStr[kk], peerMACStr[kk+ 1]); - } + peerMAC[jj] = key_2char2num(peerMACStr[kk], peerMACStr[kk + 1]); _enter_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); phead = get_list_head(queue); plist = get_next(phead); - while (1) - { - if (rtw_end_of_queue_search(phead,plist)== true) + while (1) { + if (rtw_end_of_queue_search(phead, plist) == true) break; pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); - if (!memcmp(pnetwork->network.MacAddress, peerMAC, ETH_ALEN)) - { - // Commented by Albert 2011/05/18 - // Match the device address located in the P2P IE - // This is for the case that the P2P device address is not the same as the P2P interface address. + if (!memcmp(pnetwork->network.MacAddress, peerMAC, ETH_ALEN)) { + /* Commented by Albert 2011/05/18 */ + /* Match the device address located in the P2P IE */ + /* This is for the case that the P2P device address is not the same as the P2P interface address. */ - if ((p2pie=rtw_get_p2p_ie(&pnetwork->network.IEs[12], pnetwork->network.IELength - 12, NULL, &p2pielen))) - { - while (p2pie) - { - // The P2P Device ID attribute is included in the Beacon frame. - // The P2P Device Info attribute is included in the probe response frame. + p2pie = rtw_get_p2p_ie(&pnetwork->network.IEs[12], pnetwork->network.IELength - 12, NULL, &p2pielen); + if (p2pie) { + while (p2pie) { + /* The P2P Device ID attribute is included in the Beacon frame. */ + /* The P2P Device Info attribute is included in the probe response frame. */ _rtw_memset(attr_content, 0x00, 100); - if (rtw_get_p2p_attr_content(p2pie, p2pielen, P2P_ATTR_DEVICE_ID, attr_content, &attr_contentlen)) - { - // Handle the P2P Device ID attribute of Beacon first + if (rtw_get_p2p_attr_content(p2pie, p2pielen, P2P_ATTR_DEVICE_ID, attr_content, &attr_contentlen)) { + /* Handle the P2P Device ID attribute of Beacon first */ blnMatch = 1; break; - - } - else if (rtw_get_p2p_attr_content(p2pie, p2pielen, P2P_ATTR_DEVICE_INFO, attr_content, &attr_contentlen)) - { - // Handle the P2P Device Info attribute of probe response + } else if (rtw_get_p2p_attr_content(p2pie, p2pielen, P2P_ATTR_DEVICE_INFO, attr_content, &attr_contentlen)) { + /* Handle the P2P Device Info attribute of probe response */ blnMatch = 1; break; } - //Get the next P2P IE - p2pie = rtw_get_p2p_ie(p2pie+p2pielen, pnetwork->network.IELength - 12 -(p2pie -&pnetwork->network.IEs[12] + p2pielen), NULL, &p2pielen); + /* Get the next P2P IE */ + p2pie = rtw_get_p2p_ie(p2pie+p2pielen, pnetwork->network.IELength - 12 - (p2pie - &pnetwork->network.IEs[12] + p2pielen), NULL, &p2pielen); } } - } + } plist = get_next(plist); - } _exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); if (!blnMatch) - { - sprintf(go_devadd_str, "\n\ndev_add=NULL"); - } + sprintf(go_devadd_str, "\n\ndev_add = NULL"); else - { - sprintf(go_devadd_str, "\n\ndev_add=%.2X:%.2X:%.2X:%.2X:%.2X:%.2X", - attr_content[ 0 ], attr_content[ 1 ], attr_content[ 2 ], attr_content[ 3 ], attr_content[ 4 ], attr_content[ 5 ]); - } + sprintf(go_devadd_str, "\n\ndev_add =%.2X:%.2X:%.2X:%.2X:%.2X:%.2X", + attr_content[0], attr_content[1], attr_content[2], attr_content[3], attr_content[4], attr_content[5]); - if (copy_to_user(wrqu->data.pointer, go_devadd_str, 10 + 17)) { + if (copy_to_user(wrqu->data.pointer, go_devadd_str, 10 + 17)) return -EFAULT; - } - return ret; - } static int rtw_p2p_get_device_type(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { - int ret = 0; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct iw_point *pdata = &wrqu->data; - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); - u8 peerMAC[ ETH_ALEN ] = { 0x00 }; - int jj,kk; - u8 peerMACStr[ 17 ] = { 0x00 }; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct iw_point *pdata = &wrqu->data; + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + u8 peerMAC[ETH_ALEN] = {0x00}; + int jj, kk; + u8 peerMACStr[17] = {0x00}; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; unsigned long irqL; struct list_head *plist, *phead; struct __queue *queue = &(pmlmepriv->scanned_queue); struct wlan_network *pnetwork = NULL; - u8 blnMatch = 0; - u8 dev_type[ 8 ] = { 0x00 }; - uint dev_type_len = 0; - u8 dev_type_str[ 17 + 9 ] = { 0x00 }; // +9 is for the str "dev_type=", we have to clear it at wrqu->data.pointer + u8 blnMatch = 0; + u8 dev_type[8] = {0x00}; + uint dev_type_len = 0; + u8 dev_type_str[17 + 9] = {0x00}; /* +9 is for the str "dev_type =", we have to clear it at wrqu->data.pointer */ - // Commented by Albert 20121209 - // The input data is the MAC address which the application wants to know its device type. - // Such user interface could know the device type. - // Format: iwpriv wlanx p2p_get2 dev_type=00:E0:4C:00:00:05 + /* Commented by Albert 20121209 */ + /* The input data is the MAC address which the application wants to know its device type. */ + /* Such user interface could know the device type. */ + /* Format: iwpriv wlanx p2p_get2 dev_type = 00:E0:4C:00:00:05 */ - DBG_88E("[%s] data = %s\n", __func__, (char*) extra); - if (copy_from_user(peerMACStr, wrqu->data.pointer + 9 , 17)) { - return -EFAULT; - } + DBG_88E("[%s] data = %s\n", __func__, (char *)extra); + if (copy_from_user(peerMACStr, wrqu->data.pointer + 9, 17)) + return -EFAULT; for (jj = 0, kk = 0; jj < ETH_ALEN; jj++, kk += 3) - { - peerMAC[ jj ] = key_2char2num(peerMACStr[kk], peerMACStr[kk+ 1]); - } + peerMAC[jj] = key_2char2num(peerMACStr[kk], peerMACStr[kk + 1]); _enter_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); phead = get_list_head(queue); plist = get_next(phead); - while (1) - { - if (rtw_end_of_queue_search(phead,plist)== true) + while (1) { + if (rtw_end_of_queue_search(phead, plist) == true) break; pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); - if (!memcmp(pnetwork->network.MacAddress, peerMAC, ETH_ALEN)) - { + if (!memcmp(pnetwork->network.MacAddress, peerMAC, ETH_ALEN)) { u8 *wpsie; - uint wpsie_len = 0; + uint wpsie_len = 0; - // The mac address is matched. + /* The mac address is matched. */ - if ((wpsie=rtw_get_wps_ie(&pnetwork->network.IEs[ 12 ], - pnetwork->network.IELength - 12, - NULL, &wpsie_len))) { + wpsie = rtw_get_wps_ie(&pnetwork->network.IEs[12], + pnetwork->network.IELength - 12, + NULL, &wpsie_len); + if (wpsie) { rtw_get_wps_attr_content(wpsie, wpsie_len, WPS_ATTR_PRIMARY_DEV_TYPE, dev_type, &dev_type_len); if (dev_type_len) { u16 type = 0; @@ -4007,299 +3430,250 @@ static int rtw_p2p_get_device_type(struct net_device *dev, memcpy(&be_tmp, dev_type, 2); type = be16_to_cpu(be_tmp); - sprintf(dev_type_str, "\n\nN=%.2d", type); + sprintf(dev_type_str, "\n\nN =%.2d", type); blnMatch = 1; } } break; - } + } plist = get_next(plist); - } _exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); if (!blnMatch) - { - sprintf(dev_type_str, "\n\nN=00"); - } + sprintf(dev_type_str, "\n\nN = 00"); if (copy_to_user(wrqu->data.pointer, dev_type_str, 9 + 17)) { return -EFAULT; } return ret; - } static int rtw_p2p_get_device_name(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { - int ret = 0; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct iw_point *pdata = &wrqu->data; - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); - u8 peerMAC[ ETH_ALEN ] = { 0x00 }; - int jj,kk; - u8 peerMACStr[ 17 ] = { 0x00 }; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct iw_point *pdata = &wrqu->data; + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + u8 peerMAC[ETH_ALEN] = {0x00}; + int jj, kk; + u8 peerMACStr[17] = {0x00}; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; unsigned long irqL; struct list_head *plist, *phead; struct __queue *queue = &(pmlmepriv->scanned_queue); struct wlan_network *pnetwork = NULL; - u8 blnMatch = 0; - u8 dev_name[ WPS_MAX_DEVICE_NAME_LEN ] = { 0x00 }; - uint dev_len = 0; - u8 dev_name_str[ WPS_MAX_DEVICE_NAME_LEN + 5 ] = { 0x00 }; // +5 is for the str "devN=", we have to clear it at wrqu->data.pointer + u8 blnMatch = 0; + u8 dev_name[WPS_MAX_DEVICE_NAME_LEN] = {0x00}; + uint dev_len = 0; + u8 dev_name_str[WPS_MAX_DEVICE_NAME_LEN + 5] = {0x00}; /* +5 is for the str "devN =", we have to clear it at wrqu->data.pointer */ - // Commented by Albert 20121225 - // The input data is the MAC address which the application wants to know its device name. - // Such user interface could show peer device's device name instead of ssid. - // Format: iwpriv wlanx p2p_get2 devN=00:E0:4C:00:00:05 + /* Commented by Albert 20121225 */ + /* The input data is the MAC address which the application wants to know its device name. */ + /* Such user interface could show peer device's device name instead of ssid. */ + /* Format: iwpriv wlanx p2p_get2 devN = 00:E0:4C:00:00:05 */ - DBG_88E("[%s] data = %s\n", __func__, (char*) extra); - if (copy_from_user(peerMACStr, wrqu->data.pointer + 5 , 17)) { + DBG_88E("[%s] data = %s\n", __func__, (char *)extra); + if (copy_from_user(peerMACStr, wrqu->data.pointer + 5, 17)) return -EFAULT; - } for (jj = 0, kk = 0; jj < ETH_ALEN; jj++, kk += 3) - { - peerMAC[ jj ] = key_2char2num(peerMACStr[kk], peerMACStr[kk+ 1]); - } + peerMAC[jj] = key_2char2num(peerMACStr[kk], peerMACStr[kk + 1]); _enter_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); phead = get_list_head(queue); plist = get_next(phead); - while (1) - { - if (rtw_end_of_queue_search(phead,plist)== true) + while (1) { + if (rtw_end_of_queue_search(phead, plist) == true) break; pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); - if (!memcmp(pnetwork->network.MacAddress, peerMAC, ETH_ALEN)) - { + if (!memcmp(pnetwork->network.MacAddress, peerMAC, ETH_ALEN)) { u8 *wpsie; - uint wpsie_len = 0; + uint wpsie_len = 0; - // The mac address is matched. - - if ((wpsie=rtw_get_wps_ie(&pnetwork->network.IEs[ 12 ], pnetwork->network.IELength - 12, NULL, &wpsie_len))) - { + /* The mac address is matched. */ + wpsie = rtw_get_wps_ie(&pnetwork->network.IEs[12], pnetwork->network.IELength - 12, NULL, &wpsie_len); + if (wpsie) { rtw_get_wps_attr_content(wpsie, wpsie_len, WPS_ATTR_DEVICE_NAME, dev_name, &dev_len); - if (dev_len) - { - sprintf(dev_name_str, "\n\nN=%s", dev_name); + if (dev_len) { + sprintf(dev_name_str, "\n\nN =%s", dev_name); blnMatch = 1; } } break; - } + } plist = get_next(plist); - } _exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); if (!blnMatch) - { - sprintf(dev_name_str, "\n\nN=0000"); - } + sprintf(dev_name_str, "\n\nN = 0000"); - if (copy_to_user(wrqu->data.pointer, dev_name_str, 5+ ((dev_len > 17)? dev_len : 17))) { + if (copy_to_user(wrqu->data.pointer, dev_name_str, 5 + ((dev_len > 17) ? dev_len : 17))) return -EFAULT; - } - return ret; - } static int rtw_p2p_get_invitation_procedure(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { - int ret = 0; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct iw_point *pdata = &wrqu->data; - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); - u8 peerMAC[ ETH_ALEN ] = { 0x00 }; - int jj,kk; - u8 peerMACStr[ 17 ] = { 0x00 }; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct iw_point *pdata = &wrqu->data; + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + u8 peerMAC[ETH_ALEN] = {0x00}; + int jj, kk; + u8 peerMACStr[17] = {0x00}; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; unsigned long irqL; struct list_head *plist, *phead; struct __queue *queue = &(pmlmepriv->scanned_queue); struct wlan_network *pnetwork = NULL; - u8 blnMatch = 0; - u8 *p2pie; - uint p2pielen = 0, attr_contentlen = 0; - u8 attr_content[2] = { 0x00 }; + u8 blnMatch = 0; + u8 *p2pie; + uint p2pielen = 0, attr_contentlen = 0; + u8 attr_content[2] = {0x00}; - u8 inv_proc_str[ 17 + 8 ] = { 0x00 }; - // +8 is for the str "InvProc=", we have to clear it at wrqu->data.pointer + u8 inv_proc_str[17 + 8] = {0x00}; + /* +8 is for the str "InvProc =", we have to clear it at wrqu->data.pointer */ - // Commented by Ouden 20121226 - // The application wants to know P2P initation procedure is support or not. - // Format: iwpriv wlanx p2p_get2 InvProc=00:E0:4C:00:00:05 + /* Commented by Ouden 20121226 */ + /* The application wants to know P2P initation procedure is support or not. */ + /* Format: iwpriv wlanx p2p_get2 InvProc = 00:E0:4C:00:00:05 */ - DBG_88E("[%s] data = %s\n", __func__, (char*) extra); - if (copy_from_user(peerMACStr, wrqu->data.pointer + 8 , 17)) { + DBG_88E("[%s] data = %s\n", __func__, (char *)extra); + if (copy_from_user(peerMACStr, wrqu->data.pointer + 8, 17)) return -EFAULT; - } for (jj = 0, kk = 0; jj < ETH_ALEN; jj++, kk += 3) - { - peerMAC[ jj ] = key_2char2num(peerMACStr[kk], peerMACStr[kk+ 1]); - } + peerMAC[jj] = key_2char2num(peerMACStr[kk], peerMACStr[kk + 1]); _enter_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); phead = get_list_head(queue); plist = get_next(phead); - while (1) - { - if (rtw_end_of_queue_search(phead,plist)== true) + while (1) { + if (rtw_end_of_queue_search(phead, plist) == true) break; pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); - if (!memcmp(pnetwork->network.MacAddress, peerMAC, ETH_ALEN)) - { - // Commented by Albert 20121226 - // Match the device address located in the P2P IE - // This is for the case that the P2P device address is not the same as the P2P interface address. + if (!memcmp(pnetwork->network.MacAddress, peerMAC, ETH_ALEN)) { + /* Commented by Albert 20121226 */ + /* Match the device address located in the P2P IE */ + /* This is for the case that the P2P device address is not the same as the P2P interface address. */ - if ((p2pie=rtw_get_p2p_ie(&pnetwork->network.IEs[12], pnetwork->network.IELength - 12, NULL, &p2pielen))) - { - while (p2pie) - { - //_rtw_memset(attr_content, 0x00, 2); - if (rtw_get_p2p_attr_content(p2pie, p2pielen, P2P_ATTR_CAPABILITY, attr_content, &attr_contentlen)) - { - // Handle the P2P capability attribute + p2pie = rtw_get_p2p_ie(&pnetwork->network.IEs[12], pnetwork->network.IELength - 12, NULL, &p2pielen); + if (p2pie) { + while (p2pie) { + if (rtw_get_p2p_attr_content(p2pie, p2pielen, P2P_ATTR_CAPABILITY, attr_content, &attr_contentlen)) { + /* Handle the P2P capability attribute */ blnMatch = 1; break; - } - //Get the next P2P IE - p2pie = rtw_get_p2p_ie(p2pie+p2pielen, pnetwork->network.IELength - 12 -(p2pie -&pnetwork->network.IEs[12] + p2pielen), NULL, &p2pielen); + /* Get the next P2P IE */ + p2pie = rtw_get_p2p_ie(p2pie+p2pielen, pnetwork->network.IELength - 12 - (p2pie - &pnetwork->network.IEs[12] + p2pielen), NULL, &p2pielen); } } } - plist = get_next(plist); - } _exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); - if (!blnMatch) - { - sprintf(inv_proc_str, "\nIP=-1"); + if (!blnMatch) { + sprintf(inv_proc_str, "\nIP =-1"); + } else { + if (attr_content[0] & 0x20) + sprintf(inv_proc_str, "\nIP = 1"); + else + sprintf(inv_proc_str, "\nIP = 0"); } - else - { - if (attr_content[0] && 0x20) { - sprintf(inv_proc_str, "\nIP=1"); - } else { - sprintf(inv_proc_str, "\nIP=0"); - } - } - - if (copy_to_user(wrqu->data.pointer, inv_proc_str, 8 + 17)) { + if (copy_to_user(wrqu->data.pointer, inv_proc_str, 8 + 17)) return -EFAULT; - } - return ret; - } static int rtw_p2p_connect(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { - int ret = 0; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); - u8 peerMAC[ ETH_ALEN ] = { 0x00 }; - int jj,kk; - u8 peerMACStr[ ETH_ALEN * 2 ] = { 0x00 }; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + u8 peerMAC[ETH_ALEN] = {0x00}; + int jj, kk; + u8 peerMACStr[ETH_ALEN * 2] = {0x00}; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; unsigned long irqL; struct list_head *plist, *phead; struct __queue *queue = &(pmlmepriv->scanned_queue); struct wlan_network *pnetwork = NULL; - uint uintPeerChannel = 0; + uint uintPeerChannel = 0; - // Commented by Albert 20110304 - // The input data contains two informations. - // 1. First information is the MAC address which wants to formate with - // 2. Second information is the WPS PINCode or "pbc" string for push button method - // Format: 00:E0:4C:00:00:05 - // Format: 00:E0:4C:00:00:05 + /* Commented by Albert 20110304 */ + /* The input data contains two informations. */ + /* 1. First information is the MAC address which wants to formate with */ + /* 2. Second information is the WPS PINCode or "pbc" string for push button method */ + /* Format: 00:E0:4C:00:00:05 */ + /* Format: 00:E0:4C:00:00:05 */ DBG_88E("[%s] data = %s\n", __func__, extra); - if (pwdinfo->p2p_state == P2P_STATE_NONE) - { + if (pwdinfo->p2p_state == P2P_STATE_NONE) { DBG_88E("[%s] WiFi Direct is disable!\n", __func__); return ret; } if (pwdinfo->ui_got_wps_info == P2P_NO_WPSINFO) - { return -1; - } for (jj = 0, kk = 0; jj < ETH_ALEN; jj++, kk += 3) - { - peerMAC[ jj ] = key_2char2num(extra[kk], extra[kk+ 1]); - } + peerMAC[jj] = key_2char2num(extra[kk], extra[kk + 1]); _enter_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); phead = get_list_head(queue); plist = get_next(phead); - while (1) - { - if (rtw_end_of_queue_search(phead,plist)== true) + while (1) { + if (rtw_end_of_queue_search(phead, plist) == true) break; pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); - if (!memcmp(pnetwork->network.MacAddress, peerMAC, ETH_ALEN)) - { + if (!memcmp(pnetwork->network.MacAddress, peerMAC, ETH_ALEN)) { uintPeerChannel = pnetwork->network.Configuration.DSConfig; break; } plist = get_next(plist); - } _exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); - if (uintPeerChannel) - { + if (uintPeerChannel) { _rtw_memset(&pwdinfo->nego_req_info, 0x00, sizeof(struct tx_nego_req_info)); _rtw_memset(&pwdinfo->groupid_info, 0x00, sizeof(struct group_id_info)); - pwdinfo->nego_req_info.peer_channel_num[ 0 ] = uintPeerChannel; + pwdinfo->nego_req_info.peer_channel_num[0] = uintPeerChannel; _rtw_memcpy(pwdinfo->nego_req_info.peerDevAddr, pnetwork->network.MacAddress, ETH_ALEN); pwdinfo->nego_req_info.benable = true; _cancel_timer_ex(&pwdinfo->restore_p2p_state_timer); - if (rtw_p2p_state(pwdinfo) != P2P_STATE_GONEGO_OK) - { - // Restore to the listen state if the current p2p state is not nego OK + if (rtw_p2p_state(pwdinfo) != P2P_STATE_GONEGO_OK) { + /* Restore to the listen state if the current p2p state is not nego OK */ rtw_p2p_set_state(pwdinfo, P2P_STATE_LISTEN); } @@ -4309,9 +3683,7 @@ static int rtw_p2p_connect(struct net_device *dev, DBG_88E("[%s] Start PreTx Procedure!\n", __func__); _set_timer(&pwdinfo->pre_tx_scan_timer, P2P_TX_PRESCAN_TIMEOUT); _set_timer(&pwdinfo->restore_p2p_state_timer, P2P_GO_NEGO_TIMEOUT); - } - else - { + } else { DBG_88E("[%s] Not Found in Scanning Queue~\n", __func__); ret = -1; } @@ -4320,49 +3692,44 @@ exit: } static int rtw_p2p_invite_req(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { - int ret = 0; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct iw_point *pdata = &wrqu->data; - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); - int jj,kk; - u8 peerMACStr[ ETH_ALEN * 2 ] = { 0x00 }; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct iw_point *pdata = &wrqu->data; + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + int jj, kk; + u8 peerMACStr[ETH_ALEN * 2] = {0x00}; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct list_head *plist, *phead; struct __queue *queue = &(pmlmepriv->scanned_queue); - struct wlan_network *pnetwork = NULL; - uint uintPeerChannel = 0; - u8 attr_content[50] = { 0x00 }, _status = 0; - u8 *p2pie; - uint p2pielen = 0, attr_contentlen = 0; - unsigned long irqL; - struct tx_invite_req_info* pinvite_req_info = &pwdinfo->invitereq_info; + struct wlan_network *pnetwork = NULL; + uint uintPeerChannel = 0; + u8 attr_content[50] = {0x00}, _status = 0; + u8 *p2pie; + uint p2pielen = 0, attr_contentlen = 0; + unsigned long irqL; + struct tx_invite_req_info *pinvite_req_info = &pwdinfo->invitereq_info; - // The input data contains two informations. - // 1. First information is the P2P device address which you want to send to. - // 2. Second information is the group id which combines with GO's mac address, space and GO's ssid. - // Command line sample: iwpriv wlan0 p2p_set invite="00:11:22:33:44:55 00:E0:4C:00:00:05 DIRECT-xy" - // Format: 00:11:22:33:44:55 00:E0:4C:00:00:05 DIRECT-xy + /* The input data contains two informations. */ + /* 1. First information is the P2P device address which you want to send to. */ + /* 2. Second information is the group id which combines with GO's mac address, space and GO's ssid. */ + /* Command line sample: iwpriv wlan0 p2p_set invite ="00:11:22:33:44:55 00:E0:4C:00:00:05 DIRECT-xy" */ + /* Format: 00:11:22:33:44:55 00:E0:4C:00:00:05 DIRECT-xy */ DBG_88E("[%s] data = %s\n", __func__, extra); - if (wrqu->data.length <= 37) - { + if (wrqu->data.length <= 37) { DBG_88E("[%s] Wrong format!\n", __func__); return ret; } - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) - { + if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) { DBG_88E("[%s] WiFi Direct is disable!\n", __func__); return ret; - } - else - { - // Reset the content of struct tx_invite_req_info + } else { + /* Reset the content of struct tx_invite_req_info */ pinvite_req_info->benable = false; _rtw_memset(pinvite_req_info->go_bssid, 0x00, ETH_ALEN); _rtw_memset(pinvite_req_info->go_ssid, 0x00, WLAN_SSID_MAXLEN); @@ -4373,69 +3740,55 @@ static int rtw_p2p_invite_req(struct net_device *dev, } for (jj = 0, kk = 0; jj < ETH_ALEN; jj++, kk += 3) - { - pinvite_req_info->peer_macaddr[ jj ] = key_2char2num(extra[kk], extra[kk+ 1]); - } + pinvite_req_info->peer_macaddr[jj] = key_2char2num(extra[kk], extra[kk + 1]); _enter_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); phead = get_list_head(queue); plist = get_next(phead); - while (1) - { - if (rtw_end_of_queue_search(phead,plist)== true) + while (1) { + if (rtw_end_of_queue_search(phead, plist) == true) break; pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); - // Commented by Albert 2011/05/18 - // Match the device address located in the P2P IE - // This is for the case that the P2P device address is not the same as the P2P interface address. + /* Commented by Albert 2011/05/18 */ + /* Match the device address located in the P2P IE */ + /* This is for the case that the P2P device address is not the same as the P2P interface address. */ - if ((p2pie=rtw_get_p2p_ie(&pnetwork->network.IEs[12], pnetwork->network.IELength - 12, NULL, &p2pielen))) - { - // The P2P Device ID attribute is included in the Beacon frame. - // The P2P Device Info attribute is included in the probe response frame. + p2pie = rtw_get_p2p_ie(&pnetwork->network.IEs[12], pnetwork->network.IELength - 12, NULL, &p2pielen); + if (p2pie) { + /* The P2P Device ID attribute is included in the Beacon frame. */ + /* The P2P Device Info attribute is included in the probe response frame. */ - if (rtw_get_p2p_attr_content(p2pie, p2pielen, P2P_ATTR_DEVICE_ID, attr_content, &attr_contentlen)) - { - // Handle the P2P Device ID attribute of Beacon first - if (!memcmp(attr_content, pinvite_req_info->peer_macaddr, ETH_ALEN)) - { + if (rtw_get_p2p_attr_content(p2pie, p2pielen, P2P_ATTR_DEVICE_ID, attr_content, &attr_contentlen)) { + /* Handle the P2P Device ID attribute of Beacon first */ + if (!memcmp(attr_content, pinvite_req_info->peer_macaddr, ETH_ALEN)) { + uintPeerChannel = pnetwork->network.Configuration.DSConfig; + break; + } + } else if (rtw_get_p2p_attr_content(p2pie, p2pielen, P2P_ATTR_DEVICE_INFO, attr_content, &attr_contentlen)) { + /* Handle the P2P Device Info attribute of probe response */ + if (!memcmp(attr_content, pinvite_req_info->peer_macaddr, ETH_ALEN)) { uintPeerChannel = pnetwork->network.Configuration.DSConfig; break; } } - else if (rtw_get_p2p_attr_content(p2pie, p2pielen, P2P_ATTR_DEVICE_INFO, attr_content, &attr_contentlen)) - { - // Handle the P2P Device Info attribute of probe response - if (!memcmp(attr_content, pinvite_req_info->peer_macaddr, ETH_ALEN)) - { - uintPeerChannel = pnetwork->network.Configuration.DSConfig; - break; - } - } - } - plist = get_next(plist); - } _exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); - if (uintPeerChannel) - { - // Store the GO's bssid + if (uintPeerChannel) { + /* Store the GO's bssid */ for (jj = 0, kk = 18; jj < ETH_ALEN; jj++, kk += 3) - { - pinvite_req_info->go_bssid[ jj ] = key_2char2num(extra[kk], extra[kk+ 1]); - } + pinvite_req_info->go_bssid[jj] = key_2char2num(extra[kk], extra[kk + 1]); - // Store the GO's ssid + /* Store the GO's ssid */ pinvite_req_info->ssidlen = wrqu->data.length - 36; - _rtw_memcpy(pinvite_req_info->go_ssid, &extra[ 36 ], (u32) pinvite_req_info->ssidlen); + _rtw_memcpy(pinvite_req_info->go_ssid, &extra[36], (u32) pinvite_req_info->ssidlen); pinvite_req_info->benable = true; pinvite_req_info->peer_ch = uintPeerChannel; @@ -4447,144 +3800,115 @@ static int rtw_p2p_invite_req(struct net_device *dev, _set_timer(&pwdinfo->pre_tx_scan_timer, P2P_TX_PRESCAN_TIMEOUT); _set_timer(&pwdinfo->restore_p2p_state_timer, P2P_INVITE_TIMEOUT); - } - else - { + } else { DBG_88E("[%s] NOT Found in the Scanning Queue!\n", __func__); } -exit: - +xit: return ret; - } static int rtw_p2p_set_persistent(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { - int ret = 0; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct iw_point *pdata = &wrqu->data; - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); - int jj,kk; - u8 peerMACStr[ ETH_ALEN * 2 ] = { 0x00 }; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct iw_point *pdata = &wrqu->data; + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + int jj, kk; + u8 peerMACStr[ETH_ALEN * 2] = {0x00}; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct list_head *plist, *phead; struct __queue *queue = &(pmlmepriv->scanned_queue); struct wlan_network *pnetwork = NULL; - uint uintPeerChannel = 0; - u8 attr_content[50] = { 0x00 }, _status = 0; - u8 *p2pie; - uint p2pielen = 0, attr_contentlen = 0; + uint uintPeerChannel = 0; + u8 attr_content[50] = {0x00}, _status = 0; + u8 *p2pie; + uint p2pielen = 0, attr_contentlen = 0; unsigned long irqL; - struct tx_invite_req_info* pinvite_req_info = &pwdinfo->invitereq_info; + struct tx_invite_req_info *pinvite_req_info = &pwdinfo->invitereq_info; - // The input data is 0 or 1 - // 0: disable persistent group functionality - // 1: enable persistent group founctionality + /* The input data is 0 or 1 */ + /* 0: disable persistent group functionality */ + /* 1: enable persistent group founctionality */ DBG_88E("[%s] data = %s\n", __func__, extra); - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) - { + if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) { DBG_88E("[%s] WiFi Direct is disable!\n", __func__); return ret; - } - else - { - if (extra[ 0 ] == '0') // Disable the persistent group function. - { + } else { + if (extra[0] == '0') /* Disable the persistent group function. */ pwdinfo->persistent_supported = false; - } - else if (extra[ 0 ] == '1') // Enable the persistent group function. - { + else if (extra[0] == '1') /* Enable the persistent group function. */ pwdinfo->persistent_supported = true; - } else - { pwdinfo->persistent_supported = false; - } } - printk("[%s] persistent_supported = %d\n", __func__, pwdinfo->persistent_supported); + pr_info("[%s] persistent_supported = %d\n", __func__, pwdinfo->persistent_supported); exit: return ret; - } static int rtw_p2p_prov_disc(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { int ret = 0; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); - u8 peerMAC[ ETH_ALEN ] = { 0x00 }; - int jj,kk; - u8 peerMACStr[ ETH_ALEN * 2 ] = { 0x00 }; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + u8 peerMAC[ETH_ALEN] = {0x00}; + int jj, kk; + u8 peerMACStr[ETH_ALEN * 2] = {0x00}; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct list_head *plist, *phead; struct __queue *queue = &(pmlmepriv->scanned_queue); struct wlan_network *pnetwork = NULL; - uint uintPeerChannel = 0; - u8 attr_content[100] = { 0x00 }, _status = 0; + uint uintPeerChannel = 0; + u8 attr_content[100] = {0x00}, _status = 0; u8 *p2pie; - uint p2pielen = 0, attr_contentlen = 0; + uint p2pielen = 0, attr_contentlen = 0; unsigned long irqL; - // The input data contains two informations. - // 1. First information is the MAC address which wants to issue the provisioning discovery request frame. - // 2. Second information is the WPS configuration method which wants to discovery - // Format: 00:E0:4C:00:00:05_display - // Format: 00:E0:4C:00:00:05_keypad - // Format: 00:E0:4C:00:00:05_pbc - // Format: 00:E0:4C:00:00:05_label + /* The input data contains two informations. */ + /* 1. First information is the MAC address which wants to issue the provisioning discovery request frame. */ + /* 2. Second information is the WPS configuration method which wants to discovery */ + /* Format: 00:E0:4C:00:00:05_display */ + /* Format: 00:E0:4C:00:00:05_keypad */ + /* Format: 00:E0:4C:00:00:05_pbc */ + /* Format: 00:E0:4C:00:00:05_label */ DBG_88E("[%s] data = %s\n", __func__, extra); - if (pwdinfo->p2p_state == P2P_STATE_NONE) - { + if (pwdinfo->p2p_state == P2P_STATE_NONE) { DBG_88E("[%s] WiFi Direct is disable!\n", __func__); return ret; - } - else - { - // Reset the content of struct tx_provdisc_req_info excluded the wps_config_method_request. + } else { + /* Reset the content of struct tx_provdisc_req_info excluded the wps_config_method_request. */ _rtw_memset(pwdinfo->tx_prov_disc_info.peerDevAddr, 0x00, ETH_ALEN); _rtw_memset(pwdinfo->tx_prov_disc_info.peerIFAddr, 0x00, ETH_ALEN); _rtw_memset(&pwdinfo->tx_prov_disc_info.ssid, 0x00, sizeof(struct ndis_802_11_ssid)); - pwdinfo->tx_prov_disc_info.peer_channel_num[ 0 ] = 0; - pwdinfo->tx_prov_disc_info.peer_channel_num[ 1 ] = 0; + pwdinfo->tx_prov_disc_info.peer_channel_num[0] = 0; + pwdinfo->tx_prov_disc_info.peer_channel_num[1] = 0; pwdinfo->tx_prov_disc_info.benable = false; } for (jj = 0, kk = 0; jj < ETH_ALEN; jj++, kk += 3) - { - peerMAC[ jj ] = key_2char2num(extra[kk], extra[kk+ 1]); - } + peerMAC[jj] = key_2char2num(extra[kk], extra[kk + 1]); - if (!memcmp(&extra[ 18 ], "display", 7)) - { + if (!memcmp(&extra[18], "display", 7)) { pwdinfo->tx_prov_disc_info.wps_config_method_request = WPS_CM_DISPLYA; - } - else if (!memcmp(&extra[ 18 ], "keypad", 7)) - { + } else if (!memcmp(&extra[18], "keypad", 7)) { pwdinfo->tx_prov_disc_info.wps_config_method_request = WPS_CM_KEYPAD; - } - else if (!memcmp(&extra[ 18 ], "pbc", 3)) - { + } else if (!memcmp(&extra[18], "pbc", 3)) { pwdinfo->tx_prov_disc_info.wps_config_method_request = WPS_CM_PUSH_BUTTON; - } - else if (!memcmp(&extra[ 18 ], "label", 5)) - { + } else if (!memcmp(&extra[18], "label", 5)) { pwdinfo->tx_prov_disc_info.wps_config_method_request = WPS_CM_LABEL; - } - else - { + } else { DBG_88E("[%s] Unknown WPS config methodn", __func__); - return(ret); + return ret; } _enter_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); @@ -4592,9 +3916,8 @@ static int rtw_p2p_prov_disc(struct net_device *dev, phead = get_list_head(queue); plist = get_next(phead); - while (1) - { - if (rtw_end_of_queue_search(phead,plist)== true) + while (1) { + if (rtw_end_of_queue_search(phead, plist) == true) break; if (uintPeerChannel != 0) @@ -4602,51 +3925,41 @@ static int rtw_p2p_prov_disc(struct net_device *dev, pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); - // Commented by Albert 2011/05/18 - // Match the device address located in the P2P IE - // This is for the case that the P2P device address is not the same as the P2P interface address. + /* Commented by Albert 2011/05/18 */ + /* Match the device address located in the P2P IE */ + /* This is for the case that the P2P device address is not the same as the P2P interface address. */ - if ((p2pie=rtw_get_p2p_ie(&pnetwork->network.IEs[12], pnetwork->network.IELength - 12, NULL, &p2pielen))) - { - while (p2pie) - { - // The P2P Device ID attribute is included in the Beacon frame. - // The P2P Device Info attribute is included in the probe response frame. + p2pie = rtw_get_p2p_ie(&pnetwork->network.IEs[12], pnetwork->network.IELength - 12, NULL, &p2pielen); + if (p2pie) { + while (p2pie) { + /* The P2P Device ID attribute is included in the Beacon frame. */ + /* The P2P Device Info attribute is included in the probe response frame. */ - if (rtw_get_p2p_attr_content(p2pie, p2pielen, P2P_ATTR_DEVICE_ID, attr_content, &attr_contentlen)) - { - // Handle the P2P Device ID attribute of Beacon first - if (!memcmp(attr_content, peerMAC, ETH_ALEN)) - { + if (rtw_get_p2p_attr_content(p2pie, p2pielen, P2P_ATTR_DEVICE_ID, attr_content, &attr_contentlen)) { + /* Handle the P2P Device ID attribute of Beacon first */ + if (!memcmp(attr_content, peerMAC, ETH_ALEN)) { uintPeerChannel = pnetwork->network.Configuration.DSConfig; break; } - } - else if (rtw_get_p2p_attr_content(p2pie, p2pielen, P2P_ATTR_DEVICE_INFO, attr_content, &attr_contentlen)) - { - // Handle the P2P Device Info attribute of probe response - if (!memcmp(attr_content, peerMAC, ETH_ALEN)) - { + } else if (rtw_get_p2p_attr_content(p2pie, p2pielen, P2P_ATTR_DEVICE_INFO, attr_content, &attr_contentlen)) { + /* Handle the P2P Device Info attribute of probe response */ + if (!memcmp(attr_content, peerMAC, ETH_ALEN)) { uintPeerChannel = pnetwork->network.Configuration.DSConfig; break; } } - //Get the next P2P IE - p2pie = rtw_get_p2p_ie(p2pie+p2pielen, pnetwork->network.IELength - 12 -(p2pie -&pnetwork->network.IEs[12] + p2pielen), NULL, &p2pielen); + /* Get the next P2P IE */ + p2pie = rtw_get_p2p_ie(p2pie+p2pielen, pnetwork->network.IELength - 12 - (p2pie - &pnetwork->network.IEs[12] + p2pielen), NULL, &p2pielen); } - } plist = get_next(plist); - } _exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); - if (uintPeerChannel) - { - + if (uintPeerChannel) { DBG_88E("[%s] peer channel: %d!\n", __func__, uintPeerChannel); _rtw_memcpy(pwdinfo->tx_prov_disc_info.peerIFAddr, pnetwork->network.MacAddress, ETH_ALEN); _rtw_memcpy(pwdinfo->tx_prov_disc_info.peerDevAddr, peerMAC, ETH_ALEN); @@ -4655,14 +3968,11 @@ static int rtw_p2p_prov_disc(struct net_device *dev, rtw_p2p_set_pre_state(pwdinfo, rtw_p2p_state(pwdinfo)); rtw_p2p_set_state(pwdinfo, P2P_STATE_TX_PROVISION_DIS_REQ); - if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_CLIENT)) - { + if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_CLIENT)) { _rtw_memcpy(&pwdinfo->tx_prov_disc_info.ssid, &pnetwork->network.Ssid, sizeof(struct ndis_802_11_ssid)); - } - else if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_DEVICE) || rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) - { + } else if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_DEVICE) || rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) { _rtw_memcpy(pwdinfo->tx_prov_disc_info.ssid.Ssid, pwdinfo->p2p_wildcard_ssid, P2P_WILDCARD_SSID_LEN); - pwdinfo->tx_prov_disc_info.ssid.SsidLength= P2P_WILDCARD_SSID_LEN; + pwdinfo->tx_prov_disc_info.ssid.SsidLength = P2P_WILDCARD_SSID_LEN; } set_channel_bwmode(padapter, uintPeerChannel, HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20); @@ -4670,158 +3980,116 @@ static int rtw_p2p_prov_disc(struct net_device *dev, _set_timer(&pwdinfo->pre_tx_scan_timer, P2P_TX_PRESCAN_TIMEOUT); _set_timer(&pwdinfo->restore_p2p_state_timer, P2P_PROVISION_TIMEOUT); - } - else - { + } else { DBG_88E("[%s] NOT Found in the Scanning Queue!\n", __func__); } exit: return ret; - } -// This function is used to inform the driver the user had specified the pin code value or pbc -// to application. +/* This function is used to inform the driver the user had specified the pin code value or pbc */ +/* to application. */ static int rtw_p2p_got_wpsinfo(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { - int ret = 0; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); - + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); DBG_88E("[%s] data = %s\n", __func__, extra); - // Added by Albert 20110328 - // if the input data is P2P_NO_WPSINFO -> reset the wpsinfo - // if the input data is P2P_GOT_WPSINFO_PEER_DISPLAY_PIN -> the utility just input the PIN code got from the peer P2P device. - // if the input data is P2P_GOT_WPSINFO_SELF_DISPLAY_PIN -> the utility just got the PIN code from itself. - // if the input data is P2P_GOT_WPSINFO_PBC -> the utility just determine to use the PBC + /* Added by Albert 20110328 */ + /* if the input data is P2P_NO_WPSINFO -> reset the wpsinfo */ + /* if the input data is P2P_GOT_WPSINFO_PEER_DISPLAY_PIN -> the utility just input the PIN code got from the peer P2P device. */ + /* if the input data is P2P_GOT_WPSINFO_SELF_DISPLAY_PIN -> the utility just got the PIN code from itself. */ + /* if the input data is P2P_GOT_WPSINFO_PBC -> the utility just determine to use the PBC */ if (*extra == '0') - { pwdinfo->ui_got_wps_info = P2P_NO_WPSINFO; - } else if (*extra == '1') - { pwdinfo->ui_got_wps_info = P2P_GOT_WPSINFO_PEER_DISPLAY_PIN; - } else if (*extra == '2') - { pwdinfo->ui_got_wps_info = P2P_GOT_WPSINFO_SELF_DISPLAY_PIN; - } else if (*extra == '3') - { pwdinfo->ui_got_wps_info = P2P_GOT_WPSINFO_PBC; - } else - { pwdinfo->ui_got_wps_info = P2P_NO_WPSINFO; - } - return ret; - } -#endif //CONFIG_P2P +#endif /* CONFIG_P2P */ static int rtw_p2p_set(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { - int ret = 0; #ifdef CONFIG_P2P struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); struct iw_point *pdata = &wrqu->data; - struct wifidirect_info *pwdinfo= &(padapter->wdinfo); + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; DBG_88E("[%s] extra = %s\n", __func__, extra); - if (!memcmp(extra, "enable=", 7)) - { + if (!memcmp(extra, "enable =", 7)) { rtw_wext_p2p_enable(dev, info, wrqu, &extra[7]); - } - else if (!memcmp(extra, "setDN=", 6)) - { + } else if (!memcmp(extra, "setDN =", 6)) { wrqu->data.length -= 6; rtw_p2p_setDN(dev, info, wrqu, &extra[6]); - } - else if (!memcmp(extra, "profilefound=", 13)) - { + } else if (!memcmp(extra, "profilefound =", 13)) { wrqu->data.length -= 13; rtw_p2p_profilefound(dev, info, wrqu, &extra[13]); - } - else if (!memcmp(extra, "prov_disc=", 10)) - { + } else if (!memcmp(extra, "prov_disc =", 10)) { wrqu->data.length -= 10; rtw_p2p_prov_disc(dev, info, wrqu, &extra[10]); - } - else if (!memcmp(extra, "nego=", 5)) - { + } else if (!memcmp(extra, "nego =", 5)) { wrqu->data.length -= 5; rtw_p2p_connect(dev, info, wrqu, &extra[5]); - } - else if (!memcmp(extra, "intent=", 7)) - { - // Commented by Albert 2011/03/23 - // The wrqu->data.length will include the null character - // So, we will decrease 7 + 1 + } else if (!memcmp(extra, "intent =", 7)) { + /* Commented by Albert 2011/03/23 */ + /* The wrqu->data.length will include the null character */ + /* So, we will decrease 7 + 1 */ wrqu->data.length -= 8; rtw_p2p_set_intent(dev, info, wrqu, &extra[7]); - } - else if (!memcmp(extra, "ssid=", 5)) - { + } else if (!memcmp(extra, "ssid =", 5)) { wrqu->data.length -= 5; rtw_p2p_set_go_nego_ssid(dev, info, wrqu, &extra[5]); - } - else if (!memcmp(extra, "got_wpsinfo=", 12)) - { + } else if (!memcmp(extra, "got_wpsinfo =", 12)) { wrqu->data.length -= 12; rtw_p2p_got_wpsinfo(dev, info, wrqu, &extra[12]); - } - else if (!memcmp(extra, "listen_ch=", 10)) - { - // Commented by Albert 2011/05/24 - // The wrqu->data.length will include the null character - // So, we will decrease (10 + 1) + } else if (!memcmp(extra, "listen_ch =", 10)) { + /* Commented by Albert 2011/05/24 */ + /* The wrqu->data.length will include the null character */ + /* So, we will decrease (10 + 1) */ wrqu->data.length -= 11; rtw_p2p_set_listen_ch(dev, info, wrqu, &extra[10]); - } - else if (!memcmp(extra, "op_ch=", 6)) - { - // Commented by Albert 2011/05/24 - // The wrqu->data.length will include the null character - // So, we will decrease (6 + 1) + } else if (!memcmp(extra, "op_ch =", 6)) { + /* Commented by Albert 2011/05/24 */ + /* The wrqu->data.length will include the null character */ + /* So, we will decrease (6 + 1) */ wrqu->data.length -= 7; rtw_p2p_set_op_ch(dev, info, wrqu, &extra[6]); - } - else if (!memcmp(extra, "invite=", 7)) - { + } else if (!memcmp(extra, "invite =", 7)) { wrqu->data.length -= 8; rtw_p2p_invite_req(dev, info, wrqu, &extra[7]); - } - else if (!memcmp(extra, "persistent=", 11)) - { + } else if (!memcmp(extra, "persistent =", 11)) { wrqu->data.length -= 11; rtw_p2p_set_persistent(dev, info, wrqu, &extra[11]); } -#endif //CONFIG_P2P +#endif /* CONFIG_P2P */ return ret; } static int rtw_p2p_get(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { - int ret = 0; #ifdef CONFIG_P2P @@ -4829,7 +4097,7 @@ static int rtw_p2p_get(struct net_device *dev, struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); struct iw_point *pdata = &wrqu->data; - struct wifidirect_info *pwdinfo= &(padapter->wdinfo); + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; if (padapter->bShowGetP2PState) @@ -4844,26 +4112,25 @@ static int rtw_p2p_get(struct net_device *dev, } else if (!memcmp(wrqu->data.pointer, "req_cm", 6)) { rtw_p2p_get_req_cm(dev, info, wrqu, extra); } else if (!memcmp(wrqu->data.pointer, "peer_deva", 9)) { - // Get the P2P device address when receiving the provision discovery request frame. + /* Get the P2P device address when receiving the provision discovery request frame. */ rtw_p2p_get_peer_devaddr(dev, info, wrqu, extra); } else if (!memcmp(wrqu->data.pointer, "group_id", 8)) { rtw_p2p_get_groupid(dev, info, wrqu, extra); } else if (!memcmp(wrqu->data.pointer, "peer_deva_inv", 9)) { - // Get the P2P device address when receiving the P2P Invitation request frame. + /* Get the P2P device address when receiving the P2P Invitation request frame. */ rtw_p2p_get_peer_devaddr_by_invitation(dev, info, wrqu, extra); } else if (!memcmp(wrqu->data.pointer, "op_ch", 5)) { rtw_p2p_get_op_ch(dev, info, wrqu, extra); } -#endif //CONFIG_P2P +#endif /* CONFIG_P2P */ return ret; } static int rtw_p2p_get2(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { - int ret = 0; #ifdef CONFIG_P2P @@ -4871,29 +4138,29 @@ static int rtw_p2p_get2(struct net_device *dev, struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); struct iw_point *pdata = &wrqu->data; - struct wifidirect_info *pwdinfo= &(padapter->wdinfo); + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; DBG_88E("[%s] extra = %s\n", __func__, (char *)wrqu->data.pointer); - if (!memcmp(extra, "wpsCM=", 6)) { + if (!memcmp(extra, "wpsCM =", 6)) { wrqu->data.length -= 6; rtw_p2p_get_wps_configmethod(dev, info, wrqu, &extra[6]); - } else if (!memcmp(extra, "devN=", 5)) { + } else if (!memcmp(extra, "devN =", 5)) { wrqu->data.length -= 5; rtw_p2p_get_device_name(dev, info, wrqu, &extra[5]); - } else if (!memcmp(extra, "dev_type=", 9)) { + } else if (!memcmp(extra, "dev_type =", 9)) { wrqu->data.length -= 9; rtw_p2p_get_device_type(dev, info, wrqu, &extra[9]); - } else if (!memcmp(extra, "go_devadd=", 10)) { + } else if (!memcmp(extra, "go_devadd =", 10)) { wrqu->data.length -= 10; rtw_p2p_get_go_device_address(dev, info, wrqu, &extra[10]); - } else if (!memcmp(extra, "InvProc=", 8)) { + } else if (!memcmp(extra, "InvProc =", 8)) { wrqu->data.length -= 8; rtw_p2p_get_invitation_procedure(dev, info, wrqu, &extra[8]); } -#endif //CONFIG_P2P +#endif /* CONFIG_P2P */ return ret; } @@ -4903,24 +4170,21 @@ static int rtw_cta_test_start(struct net_device *dev, union iwreq_data *wrqu, char *extra) { int ret = 0; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); DBG_88E("%s %s\n", __func__, extra); if (!strcmp(extra, "1")) padapter->in_cta_test = 1; else padapter->in_cta_test = 0; - if (padapter->in_cta_test) - { + if (padapter->in_cta_test) { u32 v = rtw_read32(padapter, REG_RCR); - v &= ~(RCR_CBSSID_DATA | RCR_CBSSID_BCN);//| RCR_ADF + v &= ~(RCR_CBSSID_DATA | RCR_CBSSID_BCN);/* RCR_ADF */ rtw_write32(padapter, REG_RCR, v); DBG_88E("enable RCR_ADF\n"); - } - else - { + } else { u32 v = rtw_read32(padapter, REG_RCR); - v |= RCR_CBSSID_DATA | RCR_CBSSID_BCN ;//| RCR_ADF + v |= RCR_CBSSID_DATA | RCR_CBSSID_BCN;/* RCR_ADF */ rtw_write32(padapter, REG_RCR, v); DBG_88E("disable RCR_ADF\n"); } @@ -4928,8 +4192,8 @@ static int rtw_cta_test_start(struct net_device *dev, } static int rtw_rereg_nd_name(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { int ret = 0; struct adapter *padapter = rtw_netdev_priv(dev); @@ -4944,25 +4208,22 @@ static int rtw_rereg_nd_name(struct net_device *dev, rereg_priv->old_ifname[IFNAMSIZ-1] = 0; } - //DBG_88E("%s wrqu->data.length:%d\n", __func__, wrqu->data.length); if (wrqu->data.length > IFNAMSIZ) return -EFAULT; - if (copy_from_user(new_ifname, wrqu->data.pointer, IFNAMSIZ)) { + if (copy_from_user(new_ifname, wrqu->data.pointer, IFNAMSIZ)) return -EFAULT; - } - if (0 == strcmp(rereg_priv->old_ifname, new_ifname)) { + if (0 == strcmp(rereg_priv->old_ifname, new_ifname)) return ret; - } DBG_88E("%s new_ifname:%s\n", __func__, new_ifname); - if (0 != (ret = rtw_change_ifname(padapter, new_ifname))) { + ret = rtw_change_ifname(padapter, new_ifname); + if (0 != ret) goto exit; - } if (!memcmp(rereg_priv->old_ifname, "disable%d", 9) == true) { - padapter->ledpriv.bRegUseLed= rereg_priv->old_bRegUseLed; + padapter->ledpriv.bRegUseLed = rereg_priv->old_bRegUseLed; rtw_hal_sw_led_init(padapter); rtw_ips_mode_req(&padapter->pwrctrlpriv, rereg_priv->old_ips_mode); } @@ -4971,86 +4232,87 @@ static int rtw_rereg_nd_name(struct net_device *dev, rereg_priv->old_ifname[IFNAMSIZ-1] = 0; if (!memcmp(new_ifname, "disable%d", 9) == true) { - DBG_88E("%s disable\n", __func__); - // free network queue for Android's timming issue + /* free network queue for Android's timming issue */ rtw_free_network_queue(padapter, true); - // close led + /* close led */ rtw_led_control(padapter, LED_CTL_POWER_OFF); rereg_priv->old_bRegUseLed = padapter->ledpriv.bRegUseLed; - padapter->ledpriv.bRegUseLed= false; + padapter->ledpriv.bRegUseLed = false; rtw_hal_sw_led_deinit(padapter); - // the interface is being "disabled", we can do deeper IPS + /* the interface is being "disabled", we can do deeper IPS */ rereg_priv->old_ips_mode = rtw_get_ips_mode_req(&padapter->pwrctrlpriv); rtw_ips_mode_req(&padapter->pwrctrlpriv, IPS_NORMAL); } exit: return ret; - } static void mac_reg_dump(struct adapter *padapter) { - int i,j=1; - printk("\n======= MAC REG =======\n"); - for (i=0x0;i<0x300;i+=4) - { - if (j%4==1) printk("0x%02x",i); - printk(" 0x%08x ",rtw_read32(padapter,i)); - if ((j++)%4 == 0) printk("\n"); + int i, j = 1; + pr_info("\n ======= MAC REG =======\n"); + for (i = 0x0; i < 0x300; i += 4) { + if (j%4 == 1) + pr_info("0x%02x", i); + pr_info(" 0x%08x ", rtw_read32(padapter, i)); + if ((j++)%4 == 0) + pr_info("\n"); } - for (i=0x400;i<0x800;i+=4) - { - if (j%4==1) printk("0x%02x",i); - printk(" 0x%08x ",rtw_read32(padapter,i)); - if ((j++)%4 == 0) printk("\n"); + for (i = 0x400; i < 0x800; i += 4) { + if (j%4 == 1) + pr_info("0x%02x", i); + pr_info(" 0x%08x ", rtw_read32(padapter, i)); + if ((j++)%4 == 0) + pr_info("\n"); } } static void bb_reg_dump(struct adapter *padapter) { - int i,j=1; - printk("\n======= BB REG =======\n"); - for (i=0x800;i<0x1000;i+=4) - { - if (j%4==1) printk("0x%02x",i); + int i, j = 1; + pr_info("\n ======= BB REG =======\n"); + for (i = 0x800; i < 0x1000; i += 4) { + if (j%4 == 1) + pr_info("0x%02x", i); - printk(" 0x%08x ",rtw_read32(padapter,i)); - if ((j++)%4 == 0) printk("\n"); + pr_info(" 0x%08x ", rtw_read32(padapter, i)); + if ((j++)%4 == 0) + pr_info("\n"); } } static void rf_reg_dump(struct adapter *padapter) { - int i,j=1,path; + int i, j = 1, path; u32 value; - u8 rf_type,path_nums = 0; + u8 rf_type, path_nums = 0; rtw_hal_get_hwreg(padapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type)); - printk("\n======= RF REG =======\n"); - if ((RF_1T2R == rf_type) ||(RF_1T1R ==rf_type)) + pr_info("\n ======= RF REG =======\n"); + if ((RF_1T2R == rf_type) || (RF_1T1R == rf_type)) path_nums = 1; else path_nums = 2; - for (path=0;pathmlmepriv); struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); struct security_priv *psecuritypriv = &padapter->securitypriv; struct wlan_network *cur_network = &(pmlmepriv->cur_network); struct sta_priv *pstapriv = &padapter->stapriv; - - pdata = (u32*)&wrqu->data; + pdata = (u32 *)&wrqu->data; val32 = *pdata; - arg = (u16)(val32&0x0000ffff); - major_cmd = (u8)(val32>>24); - minor_cmd = (u8)((val32>>16)&0x00ff); + arg = (u16)(val32 & 0x0000ffff); + major_cmd = (u8)(val32 >> 24); + minor_cmd = (u8)((val32 >> 16) & 0x00ff); extra_arg = *(pdata+1); - switch (major_cmd) - { - case 0x70://read_reg - switch (minor_cmd) - { - case 1: - DBG_88E("rtw_read8(0x%x)=0x%02x\n", arg, rtw_read8(padapter, arg)); - break; - case 2: - DBG_88E("rtw_read16(0x%x)=0x%04x\n", arg, rtw_read16(padapter, arg)); - break; - case 4: - DBG_88E("rtw_read32(0x%x)=0x%08x\n", arg, rtw_read32(padapter, arg)); - break; + switch (major_cmd) { + case 0x70:/* read_reg */ + switch (minor_cmd) { + case 1: + DBG_88E("rtw_read8(0x%x) = 0x%02x\n", arg, rtw_read8(padapter, arg)); + break; + case 2: + DBG_88E("rtw_read16(0x%x) = 0x%04x\n", arg, rtw_read16(padapter, arg)); + break; + case 4: + DBG_88E("rtw_read32(0x%x) = 0x%08x\n", arg, rtw_read32(padapter, arg)); + break; + } + break; + case 0x71:/* write_reg */ + switch (minor_cmd) { + case 1: + rtw_write8(padapter, arg, extra_arg); + DBG_88E("rtw_write8(0x%x) = 0x%02x\n", arg, rtw_read8(padapter, arg)); + break; + case 2: + rtw_write16(padapter, arg, extra_arg); + DBG_88E("rtw_write16(0x%x) = 0x%04x\n", arg, rtw_read16(padapter, arg)); + break; + case 4: + rtw_write32(padapter, arg, extra_arg); + DBG_88E("rtw_write32(0x%x) = 0x%08x\n", arg, rtw_read32(padapter, arg)); + break; + } + break; + case 0x72:/* read_bb */ + DBG_88E("read_bbreg(0x%x) = 0x%x\n", arg, rtw_hal_read_bbreg(padapter, arg, 0xffffffff)); + break; + case 0x73:/* write_bb */ + rtw_hal_write_bbreg(padapter, arg, 0xffffffff, extra_arg); + DBG_88E("write_bbreg(0x%x) = 0x%x\n", arg, rtw_hal_read_bbreg(padapter, arg, 0xffffffff)); + break; + case 0x74:/* read_rf */ + DBG_88E("read RF_reg path(0x%02x), offset(0x%x), value(0x%08x)\n", minor_cmd, arg, rtw_hal_read_rfreg(padapter, minor_cmd, arg, 0xffffffff)); + break; + case 0x75:/* write_rf */ + rtw_hal_write_rfreg(padapter, minor_cmd, arg, 0xffffffff, extra_arg); + DBG_88E("write RF_reg path(0x%02x), offset(0x%x), value(0x%08x)\n", minor_cmd, arg, rtw_hal_read_rfreg(padapter, minor_cmd, arg, 0xffffffff)); + break; + + case 0x76: + switch (minor_cmd) { + case 0x00: /* normal mode, */ + padapter->recvpriv.is_signal_dbg = 0; + break; + case 0x01: /* dbg mode */ + padapter->recvpriv.is_signal_dbg = 1; + extra_arg = extra_arg > 100 ? 100 : extra_arg; + extra_arg = extra_arg < 0 ? 0 : extra_arg; + padapter->recvpriv.signal_strength_dbg = extra_arg; + break; + } + break; + case 0x78: /* IOL test */ + switch (minor_cmd) { + case 0x04: /* LLT table initialization test */ + { + u8 page_boundary = 0xf9; + struct xmit_frame *xmit_frame; + + xmit_frame = rtw_IOL_accquire_xmit_frame(padapter); + if (xmit_frame == NULL) { + ret = -ENOMEM; + break; + } + + rtw_IOL_append_LLT_cmd(xmit_frame, page_boundary); + + if (_SUCCESS != rtw_IOL_exec_cmds_sync(padapter, xmit_frame, 500, 0)) + ret = -EPERM; + } + break; + case 0x05: /* blink LED test */ + { + u16 reg = 0x4c; + u32 blink_num = 50; + u32 blink_delay_ms = 200; + int i; + struct xmit_frame *xmit_frame; + + xmit_frame = rtw_IOL_accquire_xmit_frame(padapter); + if (xmit_frame == NULL) { + ret = -ENOMEM; + break; + } + + for (i = 0; i < blink_num; i++) { + rtw_IOL_append_WB_cmd(xmit_frame, reg, 0x00, 0xff); + rtw_IOL_append_DELAY_MS_cmd(xmit_frame, blink_delay_ms); + rtw_IOL_append_WB_cmd(xmit_frame, reg, 0x08, 0xff); + rtw_IOL_append_DELAY_MS_cmd(xmit_frame, blink_delay_ms); + } + if (_SUCCESS != rtw_IOL_exec_cmds_sync(padapter, xmit_frame, (blink_delay_ms*blink_num*2)+200, 0)) + ret = -EPERM; + } + break; + + case 0x06: /* continuous write byte test */ + { + u16 reg = arg; + u16 start_value = 0; + u32 write_num = extra_arg; + int i; + u8 final; + struct xmit_frame *xmit_frame; + + xmit_frame = rtw_IOL_accquire_xmit_frame(padapter); + if (xmit_frame == NULL) { + ret = -ENOMEM; + break; + } + + for (i = 0; i < write_num; i++) + rtw_IOL_append_WB_cmd(xmit_frame, reg, i+start_value, 0xFF); + if (_SUCCESS != rtw_IOL_exec_cmds_sync(padapter, xmit_frame, 5000, 0)) + ret = -EPERM; + + final = rtw_read8(padapter, reg); + if (start_value+write_num-1 == final) + DBG_88E("continuous IOL_CMD_WB_REG to 0x%x %u times Success, start:%u, final:%u\n", reg, write_num, start_value, final); + else + DBG_88E("continuous IOL_CMD_WB_REG to 0x%x %u times Fail, start:%u, final:%u\n", reg, write_num, start_value, final); + } + break; + + case 0x07: /* continuous write word test */ + { + u16 reg = arg; + u16 start_value = 200; + u32 write_num = extra_arg; + + int i; + u16 final; + struct xmit_frame *xmit_frame; + + xmit_frame = rtw_IOL_accquire_xmit_frame(padapter); + if (xmit_frame == NULL) { + ret = -ENOMEM; + break; + } + + for (i = 0; i < write_num; i++) + rtw_IOL_append_WW_cmd(xmit_frame, reg, i+start_value, 0xFFFF); + if (_SUCCESS != rtw_IOL_exec_cmds_sync(padapter, xmit_frame, 5000, 0)) + ret = -EPERM; + + final = rtw_read16(padapter, reg); + if (start_value+write_num-1 == final) + DBG_88E("continuous IOL_CMD_WW_REG to 0x%x %u times Success, start:%u, final:%u\n", reg, write_num, start_value, final); + else + DBG_88E("continuous IOL_CMD_WW_REG to 0x%x %u times Fail, start:%u, final:%u\n", reg, write_num, start_value, final); + } + break; + case 0x08: /* continuous write dword test */ + { + u16 reg = arg; + u32 start_value = 0x110000c7; + u32 write_num = extra_arg; + + int i; + u32 final; + struct xmit_frame *xmit_frame; + + xmit_frame = rtw_IOL_accquire_xmit_frame(padapter); + if (xmit_frame == NULL) { + ret = -ENOMEM; + break; + } + + for (i = 0; i < write_num; i++) + rtw_IOL_append_WD_cmd(xmit_frame, reg, i+start_value, 0xFFFFFFFF); + if (_SUCCESS != rtw_IOL_exec_cmds_sync(padapter, xmit_frame, 5000, 0)) + ret = -EPERM; + + final = rtw_read32(padapter, reg); + if (start_value+write_num-1 == final) + DBG_88E("continuous IOL_CMD_WD_REG to 0x%x %u times Success, start:%u, final:%u\n", + reg, write_num, start_value, final); + else + DBG_88E("continuous IOL_CMD_WD_REG to 0x%x %u times Fail, start:%u, final:%u\n", + reg, write_num, start_value, final); + } + break; + } + break; + case 0x79: + { + /* + * dbg 0x79000000 [value], set RESP_TXAGC to + value, value:0~15 + * dbg 0x79010000 [value], set RESP_TXAGC to - value, value:0~15 + */ + u8 value = extra_arg & 0x0f; + u8 sign = minor_cmd; + u16 write_value = 0; + + DBG_88E("%s set RESP_TXAGC to %s %u\n", __func__, sign ? "minus" : "plus", value); + + if (sign) + value = value | 0x10; + + write_value = value | (value << 5); + rtw_write16(padapter, 0x6d9, write_value); + } + break; + case 0x7a: + receive_disconnect(padapter, pmlmeinfo->network.MacAddress + , WLAN_REASON_EXPIRATION_CHK); + break; + case 0x7F: + switch (minor_cmd) { + case 0x0: + DBG_88E("fwstate = 0x%x\n", get_fwstate(pmlmepriv)); + break; + case 0x01: + DBG_88E("auth_alg = 0x%x, enc_alg = 0x%x, auth_type = 0x%x, enc_type = 0x%x\n", + psecuritypriv->dot11AuthAlgrthm, psecuritypriv->dot11PrivacyAlgrthm, + psecuritypriv->ndisauthtype, psecuritypriv->ndisencryptstatus); + break; + case 0x02: + DBG_88E("pmlmeinfo->state = 0x%x\n", pmlmeinfo->state); + break; + case 0x03: + DBG_88E("qos_option =%d\n", pmlmepriv->qospriv.qos_option); + DBG_88E("ht_option =%d\n", pmlmepriv->htpriv.ht_option); + break; + case 0x04: + DBG_88E("cur_ch =%d\n", pmlmeext->cur_channel); + DBG_88E("cur_bw =%d\n", pmlmeext->cur_bwmode); + DBG_88E("cur_ch_off =%d\n", pmlmeext->cur_ch_offset); + break; + case 0x05: + psta = rtw_get_stainfo(pstapriv, cur_network->network.MacAddress); + if (psta) { + int i; + struct recv_reorder_ctrl *preorder_ctrl; + + DBG_88E("SSID =%s\n", cur_network->network.Ssid.Ssid); + DBG_88E("sta's macaddr: %pM\n", psta->hwaddr); + DBG_88E("cur_channel =%d, cur_bwmode =%d, cur_ch_offset =%d\n", pmlmeext->cur_channel, pmlmeext->cur_bwmode, pmlmeext->cur_ch_offset); + DBG_88E("rtsen =%d, cts2slef =%d\n", psta->rtsen, psta->cts2self); + DBG_88E("state = 0x%x, aid =%d, macid =%d, raid =%d\n", psta->state, psta->aid, psta->mac_id, psta->raid); + DBG_88E("qos_en =%d, ht_en =%d, init_rate =%d\n", psta->qos_option, psta->htpriv.ht_option, psta->init_rate); + DBG_88E("bwmode =%d, ch_offset =%d, sgi =%d\n", psta->htpriv.bwmode, psta->htpriv.ch_offset, psta->htpriv.sgi); + DBG_88E("ampdu_enable = %d\n", psta->htpriv.ampdu_enable); + DBG_88E("agg_enable_bitmap =%x, candidate_tid_bitmap =%x\n", psta->htpriv.agg_enable_bitmap, psta->htpriv.candidate_tid_bitmap); + for (i = 0; i < 16; i++) { + preorder_ctrl = &psta->recvreorder_ctrl[i]; + if (preorder_ctrl->enable) + DBG_88E("tid =%d, indicate_seq =%d\n", i, preorder_ctrl->indicate_seq); + } + } else { + DBG_88E("can't get sta's macaddr, cur_network's macaddr:%pM\n", (cur_network->network.MacAddress)); } break; - case 0x71://write_reg - switch (minor_cmd) + case 0x06: { - case 1: - rtw_write8(padapter, arg, extra_arg); - DBG_88E("rtw_write8(0x%x)=0x%02x\n", arg, rtw_read8(padapter, arg)); - break; - case 2: - rtw_write16(padapter, arg, extra_arg); - DBG_88E("rtw_write16(0x%x)=0x%04x\n", arg, rtw_read16(padapter, arg)); - break; - case 4: - rtw_write32(padapter, arg, extra_arg); - DBG_88E("rtw_write32(0x%x)=0x%08x\n", arg, rtw_read32(padapter, arg)); - break; + u32 ODMFlag; + rtw_hal_get_hwreg(padapter, HW_VAR_DM_FLAG, (u8 *)(&ODMFlag)); + DBG_88E("(B)DMFlag = 0x%x, arg = 0x%x\n", ODMFlag, arg); + ODMFlag = (u32)(0x0f&arg); + DBG_88E("(A)DMFlag = 0x%x\n", ODMFlag); + rtw_hal_set_hwreg(padapter, HW_VAR_DM_FLAG, (u8 *)(&ODMFlag)); } break; - case 0x72://read_bb - DBG_88E("read_bbreg(0x%x)=0x%x\n", arg, rtw_hal_read_bbreg(padapter, arg, 0xffffffff)); + case 0x07: + DBG_88E("bSurpriseRemoved =%d, bDriverStopped =%d\n", + padapter->bSurpriseRemoved, padapter->bDriverStopped); break; - case 0x73://write_bb - rtw_hal_write_bbreg(padapter, arg, 0xffffffff, extra_arg); - DBG_88E("write_bbreg(0x%x)=0x%x\n", arg, rtw_hal_read_bbreg(padapter, arg, 0xffffffff)); - break; - case 0x74://read_rf - DBG_88E("read RF_reg path(0x%02x),offset(0x%x),value(0x%08x)\n",minor_cmd,arg,rtw_hal_read_rfreg(padapter, minor_cmd, arg, 0xffffffff)); - break; - case 0x75://write_rf - rtw_hal_write_rfreg(padapter, minor_cmd, arg, 0xffffffff, extra_arg); - DBG_88E("write RF_reg path(0x%02x),offset(0x%x),value(0x%08x)\n",minor_cmd,arg, rtw_hal_read_rfreg(padapter, minor_cmd, arg, 0xffffffff)); - break; - - case 0x76: - switch (minor_cmd) + case 0x08: { - case 0x00: //normal mode, - padapter->recvpriv.is_signal_dbg = 0; - break; - case 0x01: //dbg mode - padapter->recvpriv.is_signal_dbg = 1; - extra_arg = extra_arg>100?100:extra_arg; - extra_arg = extra_arg<0?0:extra_arg; - padapter->recvpriv.signal_strength_dbg=extra_arg; - break; + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct recv_priv *precvpriv = &padapter->recvpriv; + + DBG_88E("free_xmitbuf_cnt =%d, free_xmitframe_cnt =%d, free_xmit_extbuf_cnt =%d\n", + pxmitpriv->free_xmitbuf_cnt, pxmitpriv->free_xmitframe_cnt, pxmitpriv->free_xmit_extbuf_cnt); + DBG_88E("rx_urb_pending_cn =%d\n", precvpriv->rx_pending_cnt); } break; - case 0x78: //IOL test - switch (minor_cmd) + case 0x09: { - case 0x04: //LLT table initialization test - { - u8 page_boundary = 0xf9; - { - struct xmit_frame *xmit_frame; - - if ((xmit_frame=rtw_IOL_accquire_xmit_frame(padapter)) == NULL) { - ret = -ENOMEM; - break; - } - - rtw_IOL_append_LLT_cmd(xmit_frame, page_boundary); - - - if (_SUCCESS != rtw_IOL_exec_cmds_sync(padapter, xmit_frame, 500,0)) - ret = -EPERM; - } - } - break; - case 0x05: //blink LED test - { - u16 reg = 0x4c; - u32 blink_num = 50; - u32 blink_delay_ms = 200; - int i; - - { - struct xmit_frame *xmit_frame; - - if ((xmit_frame=rtw_IOL_accquire_xmit_frame(padapter)) == NULL) { - ret = -ENOMEM; - break; - } - - for (i=0;inetwork.MacAddress - , WLAN_REASON_EXPIRATION_CHK); - break; - case 0x7F: - switch (minor_cmd) - { - case 0x0: - DBG_88E("fwstate=0x%x\n", get_fwstate(pmlmepriv)); - break; - case 0x01: - DBG_88E("auth_alg=0x%x, enc_alg=0x%x, auth_type=0x%x, enc_type=0x%x\n", - psecuritypriv->dot11AuthAlgrthm, psecuritypriv->dot11PrivacyAlgrthm, - psecuritypriv->ndisauthtype, psecuritypriv->ndisencryptstatus); - break; - case 0x02: - DBG_88E("pmlmeinfo->state=0x%x\n", pmlmeinfo->state); - break; - case 0x03: - DBG_88E("qos_option=%d\n", pmlmepriv->qospriv.qos_option); - DBG_88E("ht_option=%d\n", pmlmepriv->htpriv.ht_option); - break; - case 0x04: - DBG_88E("cur_ch=%d\n", pmlmeext->cur_channel); - DBG_88E("cur_bw=%d\n", pmlmeext->cur_bwmode); - DBG_88E("cur_ch_off=%d\n", pmlmeext->cur_ch_offset); - break; - case 0x05: - psta = rtw_get_stainfo(pstapriv, cur_network->network.MacAddress); - if (psta) - { - int i; - struct recv_reorder_ctrl *preorder_ctrl; - - DBG_88E("SSID=%s\n", cur_network->network.Ssid.Ssid); - DBG_88E("sta's macaddr: %pM\n", psta->hwaddr); - DBG_88E("cur_channel=%d, cur_bwmode=%d, cur_ch_offset=%d\n", pmlmeext->cur_channel, pmlmeext->cur_bwmode, pmlmeext->cur_ch_offset); - DBG_88E("rtsen=%d, cts2slef=%d\n", psta->rtsen, psta->cts2self); - DBG_88E("state=0x%x, aid=%d, macid=%d, raid=%d\n", psta->state, psta->aid, psta->mac_id, psta->raid); - DBG_88E("qos_en=%d, ht_en=%d, init_rate=%d\n", psta->qos_option, psta->htpriv.ht_option, psta->init_rate); - DBG_88E("bwmode=%d, ch_offset=%d, sgi=%d\n", psta->htpriv.bwmode, psta->htpriv.ch_offset, psta->htpriv.sgi); - DBG_88E("ampdu_enable = %d\n", psta->htpriv.ampdu_enable); - DBG_88E("agg_enable_bitmap=%x, candidate_tid_bitmap=%x\n", psta->htpriv.agg_enable_bitmap, psta->htpriv.candidate_tid_bitmap); - for (i=0;i<16;i++) - { - preorder_ctrl = &psta->recvreorder_ctrl[i]; - if (preorder_ctrl->enable) - { - DBG_88E("tid=%d, indicate_seq=%d\n", i, preorder_ctrl->indicate_seq); - } - } - - } - else - { - DBG_88E("can't get sta's macaddr, cur_network's macaddr:%pM\n", (cur_network->network.MacAddress)); - } - break; - case 0x06: - { - u32 ODMFlag; - rtw_hal_get_hwreg(padapter, HW_VAR_DM_FLAG, (u8*)(&ODMFlag)); - DBG_88E("(B)DMFlag=0x%x, arg=0x%x\n", ODMFlag, arg); - ODMFlag = (u32)(0x0f&arg); - DBG_88E("(A)DMFlag=0x%x\n", ODMFlag); - rtw_hal_set_hwreg(padapter, HW_VAR_DM_FLAG, (u8 *)(&ODMFlag)); - } - break; - case 0x07: - DBG_88E("bSurpriseRemoved=%d, bDriverStopped=%d\n", - padapter->bSurpriseRemoved, padapter->bDriverStopped); - break; - case 0x08: - { - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - struct recv_priv *precvpriv = &padapter->recvpriv; - - DBG_88E("free_xmitbuf_cnt=%d, free_xmitframe_cnt=%d, free_xmit_extbuf_cnt=%d\n", - pxmitpriv->free_xmitbuf_cnt, pxmitpriv->free_xmitframe_cnt, pxmitpriv->free_xmit_extbuf_cnt); - DBG_88E("rx_urb_pending_cn=%d\n", precvpriv->rx_pending_cnt); - } - break; - case 0x09: - { - int i, j; - struct list_head *plist, *phead; - struct recv_reorder_ctrl *preorder_ctrl; + int i, j; + struct list_head *plist, *phead; + struct recv_reorder_ctrl *preorder_ctrl; #ifdef CONFIG_AP_MODE - DBG_88E("sta_dz_bitmap=0x%x, tim_bitmap=0x%x\n", pstapriv->sta_dz_bitmap, pstapriv->tim_bitmap); + DBG_88E("sta_dz_bitmap = 0x%x, tim_bitmap = 0x%x\n", pstapriv->sta_dz_bitmap, pstapriv->tim_bitmap); #endif - _enter_critical_bh(&pstapriv->sta_hash_lock, &irqL); + _enter_critical_bh(&pstapriv->sta_hash_lock, &irqL); - for (i=0; i< NUM_STA; i++) - { - phead = &(pstapriv->sta_hash[i]); - plist = get_next(phead); + for (i = 0; i < NUM_STA; i++) { + phead = &(pstapriv->sta_hash[i]); + plist = get_next(phead); - while ((rtw_end_of_queue_search(phead, plist)) == false) - { - psta = LIST_CONTAINOR(plist, struct sta_info, hash_list); + while ((rtw_end_of_queue_search(phead, plist)) == false) { + psta = LIST_CONTAINOR(plist, struct sta_info, hash_list); - plist = get_next(plist); + plist = get_next(plist); - if (extra_arg == psta->aid) - { - DBG_88E("sta's macaddr:%pM\n", (psta->hwaddr)); - DBG_88E("rtsen=%d, cts2slef=%d\n", psta->rtsen, psta->cts2self); - DBG_88E("state=0x%x, aid=%d, macid=%d, raid=%d\n", psta->state, psta->aid, psta->mac_id, psta->raid); - DBG_88E("qos_en=%d, ht_en=%d, init_rate=%d\n", psta->qos_option, psta->htpriv.ht_option, psta->init_rate); - DBG_88E("bwmode=%d, ch_offset=%d, sgi=%d\n", psta->htpriv.bwmode, psta->htpriv.ch_offset, psta->htpriv.sgi); - DBG_88E("ampdu_enable = %d\n", psta->htpriv.ampdu_enable); - DBG_88E("agg_enable_bitmap=%x, candidate_tid_bitmap=%x\n", psta->htpriv.agg_enable_bitmap, psta->htpriv.candidate_tid_bitmap); + if (extra_arg == psta->aid) { + DBG_88E("sta's macaddr:%pM\n", (psta->hwaddr)); + DBG_88E("rtsen =%d, cts2slef =%d\n", psta->rtsen, psta->cts2self); + DBG_88E("state = 0x%x, aid =%d, macid =%d, raid =%d\n", psta->state, psta->aid, psta->mac_id, psta->raid); + DBG_88E("qos_en =%d, ht_en =%d, init_rate =%d\n", psta->qos_option, psta->htpriv.ht_option, psta->init_rate); + DBG_88E("bwmode =%d, ch_offset =%d, sgi =%d\n", psta->htpriv.bwmode, psta->htpriv.ch_offset, psta->htpriv.sgi); + DBG_88E("ampdu_enable = %d\n", psta->htpriv.ampdu_enable); + DBG_88E("agg_enable_bitmap =%x, candidate_tid_bitmap =%x\n", psta->htpriv.agg_enable_bitmap, psta->htpriv.candidate_tid_bitmap); #ifdef CONFIG_AP_MODE - DBG_88E("capability=0x%x\n", psta->capability); - DBG_88E("flags=0x%x\n", psta->flags); - DBG_88E("wpa_psk=0x%x\n", psta->wpa_psk); - DBG_88E("wpa2_group_cipher=0x%x\n", psta->wpa2_group_cipher); - DBG_88E("wpa2_pairwise_cipher=0x%x\n", psta->wpa2_pairwise_cipher); - DBG_88E("qos_info=0x%x\n", psta->qos_info); + DBG_88E("capability = 0x%x\n", psta->capability); + DBG_88E("flags = 0x%x\n", psta->flags); + DBG_88E("wpa_psk = 0x%x\n", psta->wpa_psk); + DBG_88E("wpa2_group_cipher = 0x%x\n", psta->wpa2_group_cipher); + DBG_88E("wpa2_pairwise_cipher = 0x%x\n", psta->wpa2_pairwise_cipher); + DBG_88E("qos_info = 0x%x\n", psta->qos_info); #endif - DBG_88E("dot118021XPrivacy=0x%x\n", psta->dot118021XPrivacy); - - - - for (j=0;j<16;j++) - { - preorder_ctrl = &psta->recvreorder_ctrl[j]; - if (preorder_ctrl->enable) - { - DBG_88E("tid=%d, indicate_seq=%d\n", j, preorder_ctrl->indicate_seq); - } - } - - } + DBG_88E("dot118021XPrivacy = 0x%x\n", psta->dot118021XPrivacy); + for (j = 0; j < 16; j++) { + preorder_ctrl = &psta->recvreorder_ctrl[j]; + if (preorder_ctrl->enable) + DBG_88E("tid =%d, indicate_seq =%d\n", j, preorder_ctrl->indicate_seq); } } - - _exit_critical_bh(&pstapriv->sta_hash_lock, &irqL); - - } - break; - - case 0x0c://dump rx/tx packet - { - if (arg == 0){ - DBG_88E("dump rx packet (%d)\n",extra_arg); - //pHalData->bDumpRxPkt =extra_arg; - rtw_hal_set_def_var(padapter, HAL_DEF_DBG_DUMP_RXPKT, &(extra_arg)); - } - else if (arg==1){ - DBG_88E("dump tx packet (%d)\n",extra_arg); - rtw_hal_set_def_var(padapter, HAL_DEF_DBG_DUMP_TXPKT, &(extra_arg)); - } - } - break; - case 0x0f: - if (extra_arg == 0){ - DBG_88E("###### silent reset test.......#####\n"); - rtw_hal_sreset_reset(padapter); - } - break; - case 0x15: - { - struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; - DBG_88E("==>silent resete cnts:%d\n",pwrpriv->ips_enter_cnts); - } - break; - - - case 0x10:// driver version display - DBG_88E("rtw driver version=%s\n", DRIVERVERSION); - break; - case 0x11: - { - DBG_88E("turn %s Rx RSSI display function\n",(extra_arg==1)?"on":"off"); - padapter->bRxRSSIDisplay = extra_arg ; - rtw_hal_set_def_var(padapter, HW_DEF_FA_CNT_DUMP,&extra_arg); - } - break; - case 0x12: //set rx_stbc - { - struct registry_priv *pregpriv = &padapter->registrypriv; - // 0: disable, bit(0):enable 2.4g, bit(1):enable 5g, 0x3: enable both 2.4g and 5g - //default is set to enable 2.4GHZ for IOT issue with bufflao's AP at 5GHZ - if (pregpriv && (extra_arg == 0 || extra_arg == 1|| extra_arg == 2 || extra_arg == 3)) - { - pregpriv->rx_stbc= extra_arg; - DBG_88E("set rx_stbc=%d\n",pregpriv->rx_stbc); - } - else - DBG_88E("get rx_stbc=%d\n",pregpriv->rx_stbc); - - } - break; - case 0x13: //set ampdu_enable - { - struct registry_priv *pregpriv = &padapter->registrypriv; - // 0: disable, 0x1:enable (but wifi_spec should be 0), 0x2: force enable (don't care wifi_spec) - if (pregpriv && extra_arg >= 0 && extra_arg < 3) - { - pregpriv->ampdu_enable= extra_arg; - DBG_88E("set ampdu_enable=%d\n",pregpriv->ampdu_enable); - } - else - DBG_88E("get ampdu_enable=%d\n",pregpriv->ampdu_enable); - - } - break; - case 0x14: //get wifi_spec - { - struct registry_priv *pregpriv = &padapter->registrypriv; - DBG_88E("get wifi_spec=%d\n",pregpriv->wifi_spec); - - } - break; - case 0x16: - { - if (arg == 0xff){ - printk("ODM_COMP_DIG\t\tBIT0\n"); - printk("ODM_COMP_RA_MASK\t\tBIT1\n"); - printk("ODM_COMP_DYNAMIC_TXPWR\tBIT2\n"); - printk("ODM_COMP_FA_CNT\t\tBIT3\n"); - printk("ODM_COMP_RSSI_MONITOR\tBIT4\n"); - printk("ODM_COMP_CCK_PD\t\tBIT5\n"); - printk("ODM_COMP_ANT_DIV\t\tBIT6\n"); - printk("ODM_COMP_PWR_SAVE\t\tBIT7\n"); - printk("ODM_COMP_PWR_TRAIN\tBIT8\n"); - printk("ODM_COMP_RATE_ADAPTIVE\tBIT9\n"); - printk("ODM_COMP_PATH_DIV\t\tBIT10\n"); - printk("ODM_COMP_PSD \tBIT11\n"); - printk("ODM_COMP_DYNAMIC_PRICCA\tBIT12\n"); - printk("ODM_COMP_RXHP\t\tBIT13\n"); - printk("ODM_COMP_EDCA_TURBO\tBIT16\n"); - printk("ODM_COMP_EARLY_MODE\tBIT17\n"); - printk("ODM_COMP_TX_PWR_TRACK\tBIT24\n"); - printk("ODM_COMP_RX_GAIN_TRACK\tBIT25\n"); - printk("ODM_COMP_CALIBRATION\tBIT26\n"); - rtw_hal_get_def_var(padapter, HW_DEF_ODM_DBG_FLAG,&extra_arg); - } - else{ - rtw_hal_set_def_var(padapter, HW_DEF_ODM_DBG_FLAG,&extra_arg); } } - break; - case 0x23: - { - DBG_88E("turn %s the bNotifyChannelChange Variable\n",(extra_arg==1)?"on":"off"); - padapter->bNotifyChannelChange = extra_arg; - break; - } - case 0x24: - { + _exit_critical_bh(&pstapriv->sta_hash_lock, &irqL); + } + break; + case 0x0c:/* dump rx/tx packet */ + if (arg == 0) { + DBG_88E("dump rx packet (%d)\n", extra_arg); + rtw_hal_set_def_var(padapter, HAL_DEF_DBG_DUMP_RXPKT, &(extra_arg)); + } else if (arg == 1) { + DBG_88E("dump tx packet (%d)\n", extra_arg); + rtw_hal_set_def_var(padapter, HAL_DEF_DBG_DUMP_TXPKT, &(extra_arg)); + } + break; + case 0x0f: + if (extra_arg == 0) { + DBG_88E("###### silent reset test.......#####\n"); + rtw_hal_sreset_reset(padapter); + } + break; + case 0x15: + { + struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; + DBG_88E("==>silent resete cnts:%d\n", pwrpriv->ips_enter_cnts); + } + break; + case 0x10:/* driver version display */ + DBG_88E("rtw driver version =%s\n", DRIVERVERSION); + break; + case 0x11: + DBG_88E("turn %s Rx RSSI display function\n", (extra_arg == 1) ? "on" : "off"); + padapter->bRxRSSIDisplay = extra_arg; + rtw_hal_set_def_var(padapter, HW_DEF_FA_CNT_DUMP, &extra_arg); + break; + case 0x12: /* set rx_stbc */ + { + struct registry_priv *pregpriv = &padapter->registrypriv; + /* 0: disable, bit(0):enable 2.4g, bit(1):enable 5g, 0x3: enable both 2.4g and 5g */ + /* default is set to enable 2.4GHZ for IOT issue with bufflao's AP at 5GHZ */ + if (pregpriv && + (extra_arg == 0 || + extra_arg == 1 || + extra_arg == 2 || + extra_arg == 3)) { + pregpriv->rx_stbc = extra_arg; + DBG_88E("set rx_stbc =%d\n", pregpriv->rx_stbc); + } else { + DBG_88E("get rx_stbc =%d\n", pregpriv->rx_stbc); + } + } + break; + case 0x13: /* set ampdu_enable */ + { + struct registry_priv *pregpriv = &padapter->registrypriv; + /* 0: disable, 0x1:enable (but wifi_spec should be 0), 0x2: force enable (don't care wifi_spec) */ + if (pregpriv && extra_arg >= 0 && extra_arg < 3) { + pregpriv->ampdu_enable = extra_arg; + DBG_88E("set ampdu_enable =%d\n", pregpriv->ampdu_enable); + } else { + DBG_88E("get ampdu_enable =%d\n", pregpriv->ampdu_enable); + } + } + break; + case 0x14: /* get wifi_spec */ + { + struct registry_priv *pregpriv = &padapter->registrypriv; + DBG_88E("get wifi_spec =%d\n", pregpriv->wifi_spec); + } + break; + case 0x16: + if (arg == 0xff) { + pr_info("ODM_COMP_DIG\t\tBIT0\n"); + pr_info("ODM_COMP_RA_MASK\t\tBIT1\n"); + pr_info("ODM_COMP_DYNAMIC_TXPWR\tBIT2\n"); + pr_info("ODM_COMP_FA_CNT\t\tBIT3\n"); + pr_info("ODM_COMP_RSSI_MONITOR\tBIT4\n"); + pr_info("ODM_COMP_CCK_PD\t\tBIT5\n"); + pr_info("ODM_COMP_ANT_DIV\t\tBIT6\n"); + pr_info("ODM_COMP_PWR_SAVE\t\tBIT7\n"); + pr_info("ODM_COMP_PWR_TRAIN\tBIT8\n"); + pr_info("ODM_COMP_RATE_ADAPTIVE\tBIT9\n"); + pr_info("ODM_COMP_PATH_DIV\t\tBIT10\n"); + pr_info("ODM_COMP_PSD \tBIT11\n"); + pr_info("ODM_COMP_DYNAMIC_PRICCA\tBIT12\n"); + pr_info("ODM_COMP_RXHP\t\tBIT13\n"); + pr_info("ODM_COMP_EDCA_TURBO\tBIT16\n"); + pr_info("ODM_COMP_EARLY_MODE\tBIT17\n"); + pr_info("ODM_COMP_TX_PWR_TRACK\tBIT24\n"); + pr_info("ODM_COMP_RX_GAIN_TRACK\tBIT25\n"); + pr_info("ODM_COMP_CALIBRATION\tBIT26\n"); + rtw_hal_get_def_var(padapter, HW_DEF_ODM_DBG_FLAG, &extra_arg); + } else { + rtw_hal_set_def_var(padapter, HW_DEF_ODM_DBG_FLAG, &extra_arg); + } + break; + case 0x23: + DBG_88E("turn %s the bNotifyChannelChange Variable\n", (extra_arg == 1) ? "on" : "off"); + padapter->bNotifyChannelChange = extra_arg; + break; + case 0x24: #ifdef CONFIG_P2P - DBG_88E("turn %s the bShowGetP2PState Variable\n",(extra_arg==1)?"on":"off"); - padapter->bShowGetP2PState = extra_arg; -#endif // CONFIG_P2P - break; - } - case 0xaa: - { - if (extra_arg> 0x13) extra_arg = 0xFF; - DBG_88E("chang data rate to :0x%02x\n",extra_arg); - padapter->fix_rate = extra_arg; - } - break; - case 0xdd://registers dump , 0 for mac reg,1 for bb reg, 2 for rf reg - { - if (extra_arg==0){ - mac_reg_dump(padapter); - } - else if (extra_arg==1){ - bb_reg_dump(padapter); - } - else if (extra_arg==2){ - rf_reg_dump(padapter); - } + DBG_88E("turn %s the bShowGetP2PState Variable\n", (extra_arg == 1) ? "on" : "off"); + padapter->bShowGetP2PState = extra_arg; +#endif /* CONFIG_P2P */ + break; + case 0xaa: + if (extra_arg > 0x13) + extra_arg = 0xFF; + DBG_88E("chang data rate to :0x%02x\n", extra_arg); + padapter->fix_rate = extra_arg; + break; + case 0xdd:/* registers dump, 0 for mac reg, 1 for bb reg, 2 for rf reg */ + if (extra_arg == 0) + mac_reg_dump(padapter); + else if (extra_arg == 1) + bb_reg_dump(padapter); + else if (extra_arg == 2) + rf_reg_dump(padapter); + break; + case 0xee:/* turn on/off dynamic funcs */ + { + u32 odm_flag; - } - break; - - case 0xee://turn on/off dynamic funcs - { - u32 odm_flag; - - if (0xf==extra_arg){ - rtw_hal_get_def_var(padapter, HAL_DEF_DBG_DM_FUNC,&odm_flag); - DBG_88E(" === DMFlag(0x%08x) ===\n",odm_flag); - DBG_88E("extra_arg = 0 - disable all dynamic func\n"); - DBG_88E("extra_arg = 1 - disable DIG- BIT(0)\n"); - DBG_88E("extra_arg = 2 - disable High power - BIT(1)\n"); - DBG_88E("extra_arg = 3 - disable tx power tracking - BIT(2)\n"); - DBG_88E("extra_arg = 4 - disable BT coexistence - BIT(3)\n"); - DBG_88E("extra_arg = 5 - disable antenna diversity - BIT(4)\n"); - DBG_88E("extra_arg = 6 - enable all dynamic func\n"); - } - else{ - /* extra_arg = 0 - disable all dynamic func - extra_arg = 1 - disable DIG - extra_arg = 2 - disable tx power tracking - extra_arg = 3 - turn on all dynamic func - */ - rtw_hal_set_def_var(padapter, HAL_DEF_DBG_DM_FUNC, &(extra_arg)); - rtw_hal_get_def_var(padapter, HAL_DEF_DBG_DM_FUNC,&odm_flag); - DBG_88E(" === DMFlag(0x%08x) ===\n",odm_flag); - } - } - break; - - case 0xfd: - rtw_write8(padapter, 0xc50, arg); - DBG_88E("wr(0xc50)=0x%x\n", rtw_read8(padapter, 0xc50)); - rtw_write8(padapter, 0xc58, arg); - DBG_88E("wr(0xc58)=0x%x\n", rtw_read8(padapter, 0xc58)); - break; - case 0xfe: - DBG_88E("rd(0xc50)=0x%x\n", rtw_read8(padapter, 0xc50)); - DBG_88E("rd(0xc58)=0x%x\n", rtw_read8(padapter, 0xc58)); - break; - case 0xff: - { - DBG_88E("dbg(0x210)=0x%x\n", rtw_read32(padapter, 0x210)); - DBG_88E("dbg(0x608)=0x%x\n", rtw_read32(padapter, 0x608)); - DBG_88E("dbg(0x280)=0x%x\n", rtw_read32(padapter, 0x280)); - DBG_88E("dbg(0x284)=0x%x\n", rtw_read32(padapter, 0x284)); - DBG_88E("dbg(0x288)=0x%x\n", rtw_read32(padapter, 0x288)); - - DBG_88E("dbg(0x664)=0x%x\n", rtw_read32(padapter, 0x664)); - - - DBG_88E("\n"); - - DBG_88E("dbg(0x430)=0x%x\n", rtw_read32(padapter, 0x430)); - DBG_88E("dbg(0x438)=0x%x\n", rtw_read32(padapter, 0x438)); - - DBG_88E("dbg(0x440)=0x%x\n", rtw_read32(padapter, 0x440)); - - DBG_88E("dbg(0x458)=0x%x\n", rtw_read32(padapter, 0x458)); - - DBG_88E("dbg(0x484)=0x%x\n", rtw_read32(padapter, 0x484)); - DBG_88E("dbg(0x488)=0x%x\n", rtw_read32(padapter, 0x488)); - - DBG_88E("dbg(0x444)=0x%x\n", rtw_read32(padapter, 0x444)); - DBG_88E("dbg(0x448)=0x%x\n", rtw_read32(padapter, 0x448)); - DBG_88E("dbg(0x44c)=0x%x\n", rtw_read32(padapter, 0x44c)); - DBG_88E("dbg(0x450)=0x%x\n", rtw_read32(padapter, 0x450)); - } - break; + if (0xf == extra_arg) { + rtw_hal_get_def_var(padapter, HAL_DEF_DBG_DM_FUNC, &odm_flag); + DBG_88E(" === DMFlag(0x%08x) ===\n", odm_flag); + DBG_88E("extra_arg = 0 - disable all dynamic func\n"); + DBG_88E("extra_arg = 1 - disable DIG- BIT(0)\n"); + DBG_88E("extra_arg = 2 - disable High power - BIT(1)\n"); + DBG_88E("extra_arg = 3 - disable tx power tracking - BIT(2)\n"); + DBG_88E("extra_arg = 4 - disable BT coexistence - BIT(3)\n"); + DBG_88E("extra_arg = 5 - disable antenna diversity - BIT(4)\n"); + DBG_88E("extra_arg = 6 - enable all dynamic func\n"); + } else { + /* extra_arg = 0 - disable all dynamic func + extra_arg = 1 - disable DIG + extra_arg = 2 - disable tx power tracking + extra_arg = 3 - turn on all dynamic func + */ + rtw_hal_set_def_var(padapter, HAL_DEF_DBG_DM_FUNC, &(extra_arg)); + rtw_hal_get_def_var(padapter, HAL_DEF_DBG_DM_FUNC, &odm_flag); + DBG_88E(" === DMFlag(0x%08x) ===\n", odm_flag); + } } break; - default: - DBG_88E("error dbg cmd!\n"); + + case 0xfd: + rtw_write8(padapter, 0xc50, arg); + DBG_88E("wr(0xc50) = 0x%x\n", rtw_read8(padapter, 0xc50)); + rtw_write8(padapter, 0xc58, arg); + DBG_88E("wr(0xc58) = 0x%x\n", rtw_read8(padapter, 0xc58)); break; + case 0xfe: + DBG_88E("rd(0xc50) = 0x%x\n", rtw_read8(padapter, 0xc50)); + DBG_88E("rd(0xc58) = 0x%x\n", rtw_read8(padapter, 0xc58)); + break; + case 0xff: + DBG_88E("dbg(0x210) = 0x%x\n", rtw_read32(padapter, 0x210)); + DBG_88E("dbg(0x608) = 0x%x\n", rtw_read32(padapter, 0x608)); + DBG_88E("dbg(0x280) = 0x%x\n", rtw_read32(padapter, 0x280)); + DBG_88E("dbg(0x284) = 0x%x\n", rtw_read32(padapter, 0x284)); + DBG_88E("dbg(0x288) = 0x%x\n", rtw_read32(padapter, 0x288)); + + DBG_88E("dbg(0x664) = 0x%x\n", rtw_read32(padapter, 0x664)); + + DBG_88E("\n"); + + DBG_88E("dbg(0x430) = 0x%x\n", rtw_read32(padapter, 0x430)); + DBG_88E("dbg(0x438) = 0x%x\n", rtw_read32(padapter, 0x438)); + + DBG_88E("dbg(0x440) = 0x%x\n", rtw_read32(padapter, 0x440)); + + DBG_88E("dbg(0x458) = 0x%x\n", rtw_read32(padapter, 0x458)); + + DBG_88E("dbg(0x484) = 0x%x\n", rtw_read32(padapter, 0x484)); + DBG_88E("dbg(0x488) = 0x%x\n", rtw_read32(padapter, 0x488)); + + DBG_88E("dbg(0x444) = 0x%x\n", rtw_read32(padapter, 0x444)); + DBG_88E("dbg(0x448) = 0x%x\n", rtw_read32(padapter, 0x448)); + DBG_88E("dbg(0x44c) = 0x%x\n", rtw_read32(padapter, 0x44c)); + DBG_88E("dbg(0x450) = 0x%x\n", rtw_read32(padapter, 0x450)); + break; + } + break; + default: + DBG_88E("error dbg cmd!\n"); + break; } - - return ret; - } static int wpa_set_param(struct net_device *dev, u8 name, u32 value) { - uint ret=0; + uint ret = 0; u32 flags; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - switch (name){ + switch (name) { case IEEE_PARAM_WPA_ENABLED: - - padapter->securitypriv.dot11AuthAlgrthm= dot11AuthAlgrthm_8021X; //802.1x - - //ret = ieee80211_wpa_enable(ieee, value); - - switch ((value)&0xff) - { - case 1 : //WPA - padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeWPAPSK; //WPA_PSK + padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_8021X; /* 802.1x */ + switch ((value)&0xff) { + case 1: /* WPA */ + padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeWPAPSK; /* WPA_PSK */ padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption2Enabled; - break; - case 2: //WPA2 - padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeWPA2PSK; //WPA2_PSK + break; + case 2: /* WPA2 */ + padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeWPA2PSK; /* WPA2_PSK */ padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption3Enabled; - break; + break; } - - RT_TRACE(_module_rtl871x_ioctl_os_c,_drv_info_,("wpa_set_param:padapter->securitypriv.ndisauthtype=%d\n", padapter->securitypriv.ndisauthtype)); - + RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, + ("wpa_set_param:padapter->securitypriv.ndisauthtype =%d\n", padapter->securitypriv.ndisauthtype)); break; - case IEEE_PARAM_TKIP_COUNTERMEASURES: - //ieee->tkip_countermeasures=value; break; - - case IEEE_PARAM_DROP_UNENCRYPTED: - { + case IEEE_PARAM_DROP_UNENCRYPTED: { /* HACK: * * wpa_supplicant calls set_wpa_enabled when the driver @@ -5711,52 +4895,22 @@ static int wpa_set_param(struct net_device *dev, u8 name, u32 value) */ break; - } case IEEE_PARAM_PRIVACY_INVOKED: - - //ieee->privacy_invoked=value; - break; case IEEE_PARAM_AUTH_ALGS: - ret = wpa_set_auth_algs(dev, value); - break; - case IEEE_PARAM_IEEE_802_1X: - - //ieee->ieee802_1x=value; - break; - case IEEE_PARAM_WPAX_SELECT: - - // added for WPA2 mixed mode - //DBG_88E(KERN_WARNING "------------------------>wpax value = %x\n", value); - /* - spin_lock_irqsave(&ieee->wpax_suitlist_lock,flags); - ieee->wpax_type_set = 1; - ieee->wpax_type_notify = value; - spin_unlock_irqrestore(&ieee->wpax_suitlist_lock,flags); - */ - break; - default: - - - ret = -EOPNOTSUPP; - - break; - } - return ret; - } static int wpa_mlme(struct net_device *dev, u32 command, u32 reason) @@ -5764,66 +4918,53 @@ static int wpa_mlme(struct net_device *dev, u32 command, u32 reason) int ret = 0; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - switch (command) - { - case IEEE_MLME_STA_DEAUTH: - - if (!rtw_set_802_11_disassociate(padapter)) - ret = -1; - - break; - - case IEEE_MLME_STA_DISASSOC: - - if (!rtw_set_802_11_disassociate(padapter)) - ret = -1; - - break; - - default: - ret = -EOPNOTSUPP; - break; + switch (command) { + case IEEE_MLME_STA_DEAUTH: + if (!rtw_set_802_11_disassociate(padapter)) + ret = -1; + break; + case IEEE_MLME_STA_DISASSOC: + if (!rtw_set_802_11_disassociate(padapter)) + ret = -1; + break; + default: + ret = -EOPNOTSUPP; + break; } return ret; - } static int wpa_supplicant_ioctl(struct net_device *dev, struct iw_point *p) { struct ieee_param *param; - uint ret=0; + uint ret = 0; - //down(&ieee->wx_sem); - - if (p->length < sizeof(struct ieee_param) || !p->pointer){ + if (p->length < sizeof(struct ieee_param) || !p->pointer) { ret = -EINVAL; goto out; } param = (struct ieee_param *)rtw_malloc(p->length); - if (param == NULL) - { + if (param == NULL) { ret = -ENOMEM; goto out; } - if (copy_from_user(param, p->pointer, p->length)) - { - rtw_mfree((u8*)param, p->length); + if (copy_from_user(param, p->pointer, p->length)) { + rtw_mfree((u8 *)param, p->length); ret = -EFAULT; goto out; } switch (param->cmd) { - case IEEE_CMD_SET_WPA_PARAM: ret = wpa_set_param(dev, param->u.wpa_param.name, param->u.wpa_param.value); break; case IEEE_CMD_SET_WPA_IE: - //ret = wpa_set_wpa_ie(dev, param, p->length); - ret = rtw_set_wpa_ie((struct adapter *)rtw_netdev_priv(dev), (char*)param->u.wpa_ie.data, (u16)param->u.wpa_ie.len); + ret = rtw_set_wpa_ie((struct adapter *)rtw_netdev_priv(dev), + (char *)param->u.wpa_ie.data, (u16)param->u.wpa_ie.len); break; case IEEE_CMD_SET_ENCRYPTION: @@ -5838,7 +4979,6 @@ static int wpa_supplicant_ioctl(struct net_device *dev, struct iw_point *p) DBG_88E("Unknown WPA supplicant request: %d\n", param->cmd); ret = -EOPNOTSUPP; break; - } if (ret == 0 && copy_to_user(p->pointer, param, p->length)) @@ -5848,95 +4988,88 @@ static int wpa_supplicant_ioctl(struct net_device *dev, struct iw_point *p) out: - //up(&ieee->wx_sem); - return ret; - } #ifdef CONFIG_AP_MODE static u8 set_pairwise_key(struct adapter *padapter, struct sta_info *psta) { - struct cmd_obj* ph2c; + struct cmd_obj *ph2c; struct set_stakey_parm *psetstakey_para; - struct cmd_priv *pcmdpriv=&padapter->cmdpriv; - u8 res=_SUCCESS; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + u8 res = _SUCCESS; - ph2c = (struct cmd_obj*)rtw_zmalloc(sizeof(struct cmd_obj)); - if (ph2c == NULL){ - res= _FAIL; + ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (ph2c == NULL) { + res = _FAIL; goto exit; } - psetstakey_para = (struct set_stakey_parm*)rtw_zmalloc(sizeof(struct set_stakey_parm)); - if (psetstakey_para==NULL){ - rtw_mfree((u8 *) ph2c, sizeof(struct cmd_obj)); - res=_FAIL; + psetstakey_para = (struct set_stakey_parm *)rtw_zmalloc(sizeof(struct set_stakey_parm)); + if (psetstakey_para == NULL) { + rtw_mfree((u8 *)ph2c, sizeof(struct cmd_obj)); + res = _FAIL; goto exit; } init_h2fwcmd_w_parm_no_rsp(ph2c, psetstakey_para, _SetStaKey_CMD_); - psetstakey_para->algorithm = (u8)psta->dot118021XPrivacy; _rtw_memcpy(psetstakey_para->addr, psta->hwaddr, ETH_ALEN); _rtw_memcpy(psetstakey_para->key, &psta->dot118021x_UncstKey, 16); - res = rtw_enqueue_cmd(pcmdpriv, ph2c); exit: return res; - } static int set_group_key(struct adapter *padapter, u8 *key, u8 alg, int keyid) { u8 keylen; - struct cmd_obj* pcmd; + struct cmd_obj *pcmd; struct setkey_parm *psetkeyparm; - struct cmd_priv *pcmdpriv=&(padapter->cmdpriv); - int res=_SUCCESS; + struct cmd_priv *pcmdpriv = &(padapter->cmdpriv); + int res = _SUCCESS; DBG_88E("%s\n", __func__); - pcmd = (struct cmd_obj*)rtw_zmalloc(sizeof(struct cmd_obj)); - if (pcmd==NULL){ - res= _FAIL; + pcmd = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (pcmd == NULL) { + res = _FAIL; goto exit; } - psetkeyparm=(struct setkey_parm*)rtw_zmalloc(sizeof(struct setkey_parm)); - if (psetkeyparm==NULL){ + psetkeyparm = (struct setkey_parm *)rtw_zmalloc(sizeof(struct setkey_parm)); + if (psetkeyparm == NULL) { rtw_mfree((unsigned char *)pcmd, sizeof(struct cmd_obj)); - res= _FAIL; + res = _FAIL; goto exit; } _rtw_memset(psetkeyparm, 0, sizeof(struct setkey_parm)); - psetkeyparm->keyid=(u8)keyid; + psetkeyparm->keyid = (u8)keyid; psetkeyparm->algorithm = alg; psetkeyparm->set_tx = 1; - switch (alg) - { - case _WEP40_: - keylen = 5; - break; - case _WEP104_: - keylen = 13; - break; - case _TKIP_: - case _TKIP_WTMIC_: - case _AES_: - keylen = 16; - default: - keylen = 16; + switch (alg) { + case _WEP40_: + keylen = 5; + break; + case _WEP104_: + keylen = 13; + break; + case _TKIP_: + case _TKIP_WTMIC_: + case _AES_: + keylen = 16; + default: + keylen = 16; } _rtw_memcpy(&(psetkeyparm->key[0]), key, keylen); @@ -5947,7 +5080,6 @@ static int set_group_key(struct adapter *padapter, u8 *key, u8 alg, int keyid) pcmd->rsp = NULL; pcmd->rspsz = 0; - _rtw_init_listhead(&pcmd->list); res = rtw_enqueue_cmd(pcmdpriv, pcmd); @@ -5955,108 +5087,80 @@ static int set_group_key(struct adapter *padapter, u8 *key, u8 alg, int keyid) exit: return res; - - } static int set_wep_key(struct adapter *padapter, u8 *key, u8 keylen, int keyid) { u8 alg; - switch (keylen) - { - case 5: - alg =_WEP40_; - break; - case 13: - alg =_WEP104_; - break; - default: - alg =_NO_PRIVACY_; + switch (keylen) { + case 5: + alg = _WEP40_; + break; + case 13: + alg = _WEP104_; + break; + default: + alg = _NO_PRIVACY_; } return set_group_key(padapter, key, alg, keyid); - } - static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param, u32 param_len) { int ret = 0; - u32 wep_key_idx, wep_key_len,wep_total_len; + u32 wep_key_idx, wep_key_len, wep_total_len; struct ndis_802_11_wep *pwep = NULL; struct sta_info *psta = NULL, *pbcmc_sta = NULL; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct security_priv* psecuritypriv=&(padapter->securitypriv); + struct security_priv *psecuritypriv = &(padapter->securitypriv); struct sta_priv *pstapriv = &padapter->stapriv; DBG_88E("%s\n", __func__); - param->u.crypt.err = 0; param->u.crypt.alg[IEEE_CRYPT_ALG_NAME_LEN - 1] = '\0'; - - //sizeof(struct ieee_param) = 64 bytes; - //if (param_len != (u32) ((u8 *) param->u.crypt.key - (u8 *) param) + param->u.crypt.key_len) - if (param_len != sizeof(struct ieee_param) + param->u.crypt.key_len) - { + if (param_len != sizeof(struct ieee_param) + param->u.crypt.key_len) { ret = -EINVAL; goto exit; } - if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff && param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff && - param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) - { - if (param->u.crypt.idx >= WEP_KEYS) - { + param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) { + if (param->u.crypt.idx >= WEP_KEYS) { ret = -EINVAL; goto exit; } - } - else - { + } else { psta = rtw_get_stainfo(pstapriv, param->sta_addr); - if (!psta) - { - //ret = -EINVAL; + if (!psta) { DBG_88E("rtw_set_encryption(), sta has already been removed or never been added\n"); goto exit; } } - if (strcmp(param->u.crypt.alg, "none") == 0 && (psta==NULL)) - { - //todo:clear default encryption keys - - DBG_88E("clear default encryption keys, keyid=%d\n", param->u.crypt.idx); + if (strcmp(param->u.crypt.alg, "none") == 0 && (psta == NULL)) { + /* todo:clear default encryption keys */ + DBG_88E("clear default encryption keys, keyid =%d\n", param->u.crypt.idx); goto exit; } - - - if (strcmp(param->u.crypt.alg, "WEP") == 0 && (psta==NULL)) - { + if (strcmp(param->u.crypt.alg, "WEP") == 0 && (psta == NULL)) { DBG_88E("r871x_set_encryption, crypt.alg = WEP\n"); - wep_key_idx = param->u.crypt.idx; wep_key_len = param->u.crypt.key_len; - DBG_88E("r871x_set_encryption, wep_key_idx=%d, len=%d\n", wep_key_idx, wep_key_len); - - if ((wep_key_idx >= WEP_KEYS) || (wep_key_len<=0)) - { + if ((wep_key_idx >= WEP_KEYS) || (wep_key_len <= 0)) { ret = -EINVAL; goto exit; } - - if (wep_key_len > 0) - { + if (wep_key_len > 0) { wep_key_len = wep_key_len <= 5 ? 5 : 13; wep_total_len = wep_key_len + FIELD_OFFSET(struct ndis_802_11_wep, KeyMaterial); - pwep =(struct ndis_802_11_wep *)rtw_malloc(wep_total_len); - if (pwep == NULL){ + pwep = (struct ndis_802_11_wep *)rtw_malloc(wep_total_len); + if (pwep == NULL) { DBG_88E(" r871x_set_encryption: pwep allocate fail !!!\n"); goto exit; } @@ -6065,168 +5169,116 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param, pwep->KeyLength = wep_key_len; pwep->Length = wep_total_len; - } pwep->KeyIndex = wep_key_idx; _rtw_memcpy(pwep->KeyMaterial, param->u.crypt.key, pwep->KeyLength); - if (param->u.crypt.set_tx) - { - DBG_88E("wep, set_tx=1\n"); + if (param->u.crypt.set_tx) { + DBG_88E("wep, set_tx = 1\n"); psecuritypriv->ndisencryptstatus = Ndis802_11Encryption1Enabled; - psecuritypriv->dot11PrivacyAlgrthm=_WEP40_; - psecuritypriv->dot118021XGrpPrivacy=_WEP40_; + psecuritypriv->dot11PrivacyAlgrthm = _WEP40_; + psecuritypriv->dot118021XGrpPrivacy = _WEP40_; - if (pwep->KeyLength==13) - { - psecuritypriv->dot11PrivacyAlgrthm=_WEP104_; - psecuritypriv->dot118021XGrpPrivacy=_WEP104_; + if (pwep->KeyLength == 13) { + psecuritypriv->dot11PrivacyAlgrthm = _WEP104_; + psecuritypriv->dot118021XGrpPrivacy = _WEP104_; } - psecuritypriv->dot11PrivacyKeyIndex = wep_key_idx; _rtw_memcpy(&(psecuritypriv->dot11DefKey[wep_key_idx].skey[0]), pwep->KeyMaterial, pwep->KeyLength); - psecuritypriv->dot11DefKeylen[wep_key_idx]=pwep->KeyLength; + psecuritypriv->dot11DefKeylen[wep_key_idx] = pwep->KeyLength; set_wep_key(padapter, pwep->KeyMaterial, pwep->KeyLength, wep_key_idx); + } else { + DBG_88E("wep, set_tx = 0\n"); - - } - else - { - DBG_88E("wep, set_tx=0\n"); - - //don't update "psecuritypriv->dot11PrivacyAlgrthm" and - //"psecuritypriv->dot11PrivacyKeyIndex=keyid", but can rtw_set_key to cam + /* don't update "psecuritypriv->dot11PrivacyAlgrthm" and */ + /* psecuritypriv->dot11PrivacyKeyIndex = keyid", but can rtw_set_key to cam */ _rtw_memcpy(&(psecuritypriv->dot11DefKey[wep_key_idx].skey[0]), pwep->KeyMaterial, pwep->KeyLength); psecuritypriv->dot11DefKeylen[wep_key_idx] = pwep->KeyLength; set_wep_key(padapter, pwep->KeyMaterial, pwep->KeyLength, wep_key_idx); - } goto exit; - } - - if (!psta && check_fwstate(pmlmepriv, WIFI_AP_STATE)) // //group key - { - if (param->u.crypt.set_tx ==1) - { - if (strcmp(param->u.crypt.alg, "WEP") == 0) - { + if (!psta && check_fwstate(pmlmepriv, WIFI_AP_STATE)) { /* group key */ + if (param->u.crypt.set_tx == 1) { + if (strcmp(param->u.crypt.alg, "WEP") == 0) { DBG_88E("%s, set group_key, WEP\n", __func__); - _rtw_memcpy(psecuritypriv->dot118021XGrpKey[param->u.crypt.idx].skey, param->u.crypt.key, (param->u.crypt.key_len>16 ?16:param->u.crypt.key_len)); + _rtw_memcpy(psecuritypriv->dot118021XGrpKey[param->u.crypt.idx].skey, + param->u.crypt.key, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len)); psecuritypriv->dot118021XGrpPrivacy = _WEP40_; - if (param->u.crypt.key_len==13) - { + if (param->u.crypt.key_len == 13) psecuritypriv->dot118021XGrpPrivacy = _WEP104_; - } - - } - else if (strcmp(param->u.crypt.alg, "TKIP") == 0) - { + } else if (strcmp(param->u.crypt.alg, "TKIP") == 0) { DBG_88E("%s, set group_key, TKIP\n", __func__); - psecuritypriv->dot118021XGrpPrivacy = _TKIP_; - - _rtw_memcpy(psecuritypriv->dot118021XGrpKey[param->u.crypt.idx].skey, param->u.crypt.key, (param->u.crypt.key_len>16 ?16:param->u.crypt.key_len)); - - //DEBUG_ERR("set key length :param->u.crypt.key_len=%d\n", param->u.crypt.key_len); - //set mic key + _rtw_memcpy(psecuritypriv->dot118021XGrpKey[param->u.crypt.idx].skey, + param->u.crypt.key, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len)); + /* set mic key */ _rtw_memcpy(psecuritypriv->dot118021XGrptxmickey[param->u.crypt.idx].skey, &(param->u.crypt.key[16]), 8); _rtw_memcpy(psecuritypriv->dot118021XGrprxmickey[param->u.crypt.idx].skey, &(param->u.crypt.key[24]), 8); psecuritypriv->busetkipkey = true; - - } - else if (strcmp(param->u.crypt.alg, "CCMP") == 0) - { + } else if (strcmp(param->u.crypt.alg, "CCMP") == 0) { DBG_88E("%s, set group_key, CCMP\n", __func__); - psecuritypriv->dot118021XGrpPrivacy = _AES_; - - _rtw_memcpy(psecuritypriv->dot118021XGrpKey[param->u.crypt.idx].skey, param->u.crypt.key, (param->u.crypt.key_len>16 ?16:param->u.crypt.key_len)); - } - else - { + _rtw_memcpy(psecuritypriv->dot118021XGrpKey[param->u.crypt.idx].skey, + param->u.crypt.key, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len)); + } else { DBG_88E("%s, set group_key, none\n", __func__); - psecuritypriv->dot118021XGrpPrivacy = _NO_PRIVACY_; } - psecuritypriv->dot118021XGrpKeyid = param->u.crypt.idx; - psecuritypriv->binstallGrpkey = true; - - psecuritypriv->dot11PrivacyAlgrthm = psecuritypriv->dot118021XGrpPrivacy;//!!! - + psecuritypriv->dot11PrivacyAlgrthm = psecuritypriv->dot118021XGrpPrivacy;/* */ set_group_key(padapter, param->u.crypt.key, psecuritypriv->dot118021XGrpPrivacy, param->u.crypt.idx); - - pbcmc_sta=rtw_get_bcmc_stainfo(padapter); - if (pbcmc_sta) - { + pbcmc_sta = rtw_get_bcmc_stainfo(padapter); + if (pbcmc_sta) { pbcmc_sta->ieee8021x_blocked = false; - pbcmc_sta->dot118021XPrivacy= psecuritypriv->dot118021XGrpPrivacy;//rx will use bmc_sta's dot118021XPrivacy + pbcmc_sta->dot118021XPrivacy = psecuritypriv->dot118021XGrpPrivacy;/* rx will use bmc_sta's dot118021XPrivacy */ } - } - goto exit; - } - if (psecuritypriv->dot11AuthAlgrthm == dot11AuthAlgrthm_8021X && psta) // psk/802_1x - { - if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) - { - if (param->u.crypt.set_tx ==1) - { - _rtw_memcpy(psta->dot118021x_UncstKey.skey, param->u.crypt.key, (param->u.crypt.key_len>16 ?16:param->u.crypt.key_len)); + if (psecuritypriv->dot11AuthAlgrthm == dot11AuthAlgrthm_8021X && psta) { /* psk/802_1x */ + if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { + if (param->u.crypt.set_tx == 1) { + _rtw_memcpy(psta->dot118021x_UncstKey.skey, param->u.crypt.key, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len)); - if (strcmp(param->u.crypt.alg, "WEP") == 0) - { + if (strcmp(param->u.crypt.alg, "WEP") == 0) { DBG_88E("%s, set pairwise key, WEP\n", __func__); psta->dot118021XPrivacy = _WEP40_; - if (param->u.crypt.key_len==13) - { + if (param->u.crypt.key_len == 13) psta->dot118021XPrivacy = _WEP104_; - } - } - else if (strcmp(param->u.crypt.alg, "TKIP") == 0) - { + } else if (strcmp(param->u.crypt.alg, "TKIP") == 0) { DBG_88E("%s, set pairwise key, TKIP\n", __func__); psta->dot118021XPrivacy = _TKIP_; - //DEBUG_ERR("set key length :param->u.crypt.key_len=%d\n", param->u.crypt.key_len); - //set mic key + /* set mic key */ _rtw_memcpy(psta->dot11tkiptxmickey.skey, &(param->u.crypt.key[16]), 8); _rtw_memcpy(psta->dot11tkiprxmickey.skey, &(param->u.crypt.key[24]), 8); psecuritypriv->busetkipkey = true; - - } - else if (strcmp(param->u.crypt.alg, "CCMP") == 0) - { - + } else if (strcmp(param->u.crypt.alg, "CCMP") == 0) { DBG_88E("%s, set pairwise key, CCMP\n", __func__); psta->dot118021XPrivacy = _AES_; - } - else - { + } else { DBG_88E("%s, set pairwise key, none\n", __func__); psta->dot118021XPrivacy = _NO_PRIVACY_; @@ -6235,42 +5287,30 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param, set_pairwise_key(padapter, psta); psta->ieee8021x_blocked = false; - - } - else//group key??? - { - if (strcmp(param->u.crypt.alg, "WEP") == 0) - { - _rtw_memcpy(psecuritypriv->dot118021XGrpKey[param->u.crypt.idx].skey, param->u.crypt.key, (param->u.crypt.key_len>16 ?16:param->u.crypt.key_len)); - + } else { /* group key??? */ + if (strcmp(param->u.crypt.alg, "WEP") == 0) { + _rtw_memcpy(psecuritypriv->dot118021XGrpKey[param->u.crypt.idx].skey, + param->u.crypt.key, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len)); psecuritypriv->dot118021XGrpPrivacy = _WEP40_; - if (param->u.crypt.key_len==13) - { + if (param->u.crypt.key_len == 13) psecuritypriv->dot118021XGrpPrivacy = _WEP104_; - } - } - else if (strcmp(param->u.crypt.alg, "TKIP") == 0) - { + } else if (strcmp(param->u.crypt.alg, "TKIP") == 0) { psecuritypriv->dot118021XGrpPrivacy = _TKIP_; - _rtw_memcpy(psecuritypriv->dot118021XGrpKey[param->u.crypt.idx].skey, param->u.crypt.key, (param->u.crypt.key_len>16 ?16:param->u.crypt.key_len)); + _rtw_memcpy(psecuritypriv->dot118021XGrpKey[param->u.crypt.idx].skey, + param->u.crypt.key, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len)); - //DEBUG_ERR("set key length :param->u.crypt.key_len=%d\n", param->u.crypt.key_len); - //set mic key + /* set mic key */ _rtw_memcpy(psecuritypriv->dot118021XGrptxmickey[param->u.crypt.idx].skey, &(param->u.crypt.key[16]), 8); _rtw_memcpy(psecuritypriv->dot118021XGrprxmickey[param->u.crypt.idx].skey, &(param->u.crypt.key[24]), 8); psecuritypriv->busetkipkey = true; - - } - else if (strcmp(param->u.crypt.alg, "CCMP") == 0) - { + } else if (strcmp(param->u.crypt.alg, "CCMP") == 0) { psecuritypriv->dot118021XGrpPrivacy = _AES_; - _rtw_memcpy(psecuritypriv->dot118021XGrpKey[param->u.crypt.idx].skey, param->u.crypt.key, (param->u.crypt.key_len>16 ?16:param->u.crypt.key_len)); - } - else - { + _rtw_memcpy(psecuritypriv->dot118021XGrpKey[param->u.crypt.idx].skey, + param->u.crypt.key, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len)); + } else { psecuritypriv->dot118021XGrpPrivacy = _NO_PRIVACY_; } @@ -6278,55 +5318,46 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param, psecuritypriv->binstallGrpkey = true; - psecuritypriv->dot11PrivacyAlgrthm = psecuritypriv->dot118021XGrpPrivacy;//!!! + psecuritypriv->dot11PrivacyAlgrthm = psecuritypriv->dot118021XGrpPrivacy;/* */ set_group_key(padapter, param->u.crypt.key, psecuritypriv->dot118021XGrpPrivacy, param->u.crypt.idx); - pbcmc_sta=rtw_get_bcmc_stainfo(padapter); - if (pbcmc_sta) - { + pbcmc_sta = rtw_get_bcmc_stainfo(padapter); + if (pbcmc_sta) { pbcmc_sta->ieee8021x_blocked = false; - pbcmc_sta->dot118021XPrivacy= psecuritypriv->dot118021XGrpPrivacy;//rx will use bmc_sta's dot118021XPrivacy + pbcmc_sta->dot118021XPrivacy = psecuritypriv->dot118021XGrpPrivacy;/* rx will use bmc_sta's dot118021XPrivacy */ } - } - } - } exit: if (pwep) - { rtw_mfree((u8 *)pwep, wep_total_len); - } return ret; - } static int rtw_set_beacon(struct net_device *dev, struct ieee_param *param, int len) { - int ret=0; + int ret = 0; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); struct sta_priv *pstapriv = &padapter->stapriv; unsigned char *pbuf = param->u.bcn_ie.buf; - - DBG_88E("%s, len=%d\n", __func__, len); + DBG_88E("%s, len =%d\n", __func__, len); if (check_fwstate(pmlmepriv, WIFI_AP_STATE) != true) return -EINVAL; _rtw_memcpy(&pstapriv->max_num_sta, param->u.bcn_ie.reserved, 2); - if ((pstapriv->max_num_sta>NUM_STA) || (pstapriv->max_num_sta<=0)) + if ((pstapriv->max_num_sta > NUM_STA) || (pstapriv->max_num_sta <= 0)) pstapriv->max_num_sta = NUM_STA; - - if (rtw_check_beacon_data(padapter, pbuf, (len-12-2)) == _SUCCESS)// 12 = param header, 2:no packed + if (rtw_check_beacon_data(padapter, pbuf, (len-12-2)) == _SUCCESS)/* 12 = param header, 2:no packed */ ret = 0; else ret = -EINVAL; @@ -6336,12 +5367,12 @@ static int rtw_set_beacon(struct net_device *dev, struct ieee_param *param, int static int rtw_hostapd_sta_flush(struct net_device *dev) { - int ret=0; + int ret = 0; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); DBG_88E("%s\n", __func__); - flush_all_cam_entry(padapter); //clear CAM + flush_all_cam_entry(padapter); /* clear CAM */ ret = rtw_sta_flush(padapter); @@ -6351,52 +5382,31 @@ static int rtw_hostapd_sta_flush(struct net_device *dev) static int rtw_add_sta(struct net_device *dev, struct ieee_param *param) { unsigned long irqL; - int ret=0; + int ret = 0; struct sta_info *psta = NULL; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); struct sta_priv *pstapriv = &padapter->stapriv; - DBG_88E("rtw_add_sta(aid=%d)=%pM\n", param->u.add_sta.aid, (param->sta_addr)); + DBG_88E("rtw_add_sta(aid =%d) =%pM\n", param->u.add_sta.aid, (param->sta_addr)); - if (check_fwstate(pmlmepriv, (_FW_LINKED|WIFI_AP_STATE)) != true) - { + if (!check_fwstate(pmlmepriv, (_FW_LINKED|WIFI_AP_STATE))) return -EINVAL; - } if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff && param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff && param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) - { return -EINVAL; - } -/* psta = rtw_get_stainfo(pstapriv, param->sta_addr); - if (psta) - { - DBG_88E("rtw_add_sta(), free has been added psta=%p\n", psta); - _enter_critical_bh(&(pstapriv->sta_hash_lock), &irqL); - rtw_free_stainfo(padapter, psta); - _exit_critical_bh(&(pstapriv->sta_hash_lock), &irqL); - - psta = NULL; - } -*/ - //psta = rtw_alloc_stainfo(pstapriv, param->sta_addr); - psta = rtw_get_stainfo(pstapriv, param->sta_addr); - if (psta) - { + if (psta) { int flags = param->u.add_sta.flags; - //DBG_88E("rtw_add_sta(), init sta's variables, psta=%p\n", psta); - - psta->aid = param->u.add_sta.aid;//aid=1~2007 + psta->aid = param->u.add_sta.aid;/* aid = 1~2007 */ _rtw_memcpy(psta->bssrateset, param->u.add_sta.tx_supp_rates, 16); - - //check wmm cap. + /* check wmm cap. */ if (WLAN_STA_WME&flags) psta->qos_option = 1; else @@ -6405,96 +5415,68 @@ static int rtw_add_sta(struct net_device *dev, struct ieee_param *param) if (pmlmepriv->qospriv.qos_option == 0) psta->qos_option = 0; - - //chec 802.11n ht cap. - if (WLAN_STA_HT&flags) - { + /* chec 802.11n ht cap. */ + if (WLAN_STA_HT&flags) { psta->htpriv.ht_option = true; psta->qos_option = 1; - _rtw_memcpy((void*)&psta->htpriv.ht_cap, (void*)¶m->u.add_sta.ht_cap, sizeof(struct rtw_ieee80211_ht_cap)); - } - else - { + _rtw_memcpy((void *)&psta->htpriv.ht_cap, (void *)¶m->u.add_sta.ht_cap, sizeof(struct rtw_ieee80211_ht_cap)); + } else { psta->htpriv.ht_option = false; } if (pmlmepriv->htpriv.ht_option == false) psta->htpriv.ht_option = false; - update_sta_info_apmode(padapter, psta); - - - } - else - { + } else { ret = -ENOMEM; } return ret; - } static int rtw_del_sta(struct net_device *dev, struct ieee_param *param) { unsigned long irqL; - int ret=0; + int ret = 0; struct sta_info *psta = NULL; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); struct sta_priv *pstapriv = &padapter->stapriv; - DBG_88E("rtw_del_sta=%pM\n", (param->sta_addr)); + DBG_88E("rtw_del_sta =%pM\n", (param->sta_addr)); if (check_fwstate(pmlmepriv, (_FW_LINKED|WIFI_AP_STATE)) != true) - { return -EINVAL; - } if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff && param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff && param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) - { return -EINVAL; - } psta = rtw_get_stainfo(pstapriv, param->sta_addr); - if (psta) - { + if (psta) { u8 updated; - //DBG_88E("free psta=%p, aid=%d\n", psta, psta->aid); - _enter_critical_bh(&pstapriv->asoc_list_lock, &irqL); - if (rtw_is_list_empty(&psta->asoc_list)==false) - { + if (!rtw_is_list_empty(&psta->asoc_list)) { rtw_list_delete(&psta->asoc_list); pstapriv->asoc_list_cnt--; updated = ap_free_sta(padapter, psta, true, WLAN_REASON_DEAUTH_LEAVING); - } _exit_critical_bh(&pstapriv->asoc_list_lock, &irqL); - associated_clients_update(padapter, updated); - psta = NULL; - - } - else - { + } else { DBG_88E("rtw_del_sta(), sta has already been removed or never been added\n"); - - //ret = -1; } - return ret; - } static int rtw_ioctl_get_sta_data(struct net_device *dev, struct ieee_param *param, int len) { - int ret=0; + int ret = 0; struct sta_info *psta = NULL; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); @@ -6505,20 +5487,15 @@ static int rtw_ioctl_get_sta_data(struct net_device *dev, struct ieee_param *par DBG_88E("rtw_ioctl_get_sta_info, sta_addr: %pM\n", (param_ex->sta_addr)); if (check_fwstate(pmlmepriv, (_FW_LINKED|WIFI_AP_STATE)) != true) - { return -EINVAL; - } if (param_ex->sta_addr[0] == 0xff && param_ex->sta_addr[1] == 0xff && param_ex->sta_addr[2] == 0xff && param_ex->sta_addr[3] == 0xff && param_ex->sta_addr[4] == 0xff && param_ex->sta_addr[5] == 0xff) - { return -EINVAL; - } psta = rtw_get_stainfo(pstapriv, param_ex->sta_addr); - if (psta) - { + if (psta) { psta_data->aid = (u16)psta->aid; psta_data->capability = psta->capability; psta_data->flags = psta->flags; @@ -6532,38 +5509,31 @@ static int rtw_ioctl_get_sta_data(struct net_device *dev, struct ieee_param *par ht_20mhz_set : BIT(5) */ - psta_data->sta_set =((psta->nonerp_set) | - (psta->no_short_slot_time_set <<1) | - (psta->no_short_preamble_set <<2) | - (psta->no_ht_gf_set <<3) | - (psta->no_ht_set <<4) | - (psta->ht_20mhz_set <<5)); - + psta_data->sta_set = ((psta->nonerp_set) | + (psta->no_short_slot_time_set << 1) | + (psta->no_short_preamble_set << 2) | + (psta->no_ht_gf_set << 3) | + (psta->no_ht_set << 4) | + (psta->ht_20mhz_set << 5)); psta_data->tx_supp_rates_len = psta->bssratelen; _rtw_memcpy(psta_data->tx_supp_rates, psta->bssrateset, psta->bssratelen); _rtw_memcpy(&psta_data->ht_cap, &psta->htpriv.ht_cap, sizeof(struct rtw_ieee80211_ht_cap)); psta_data->rx_pkts = psta->sta_stats.rx_data_pkts; psta_data->rx_bytes = psta->sta_stats.rx_bytes; psta_data->rx_drops = psta->sta_stats.rx_drops; - psta_data->tx_pkts = psta->sta_stats.tx_pkts; psta_data->tx_bytes = psta->sta_stats.tx_bytes; psta_data->tx_drops = psta->sta_stats.tx_drops; - - - } - else - { + } else { ret = -1; } return ret; - } static int rtw_get_sta_wpaie(struct net_device *dev, struct ieee_param *param) { - int ret=0; + int ret = 0; struct sta_info *psta = NULL; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); @@ -6572,74 +5542,56 @@ static int rtw_get_sta_wpaie(struct net_device *dev, struct ieee_param *param) DBG_88E("rtw_get_sta_wpaie, sta_addr: %pM\n", (param->sta_addr)); if (check_fwstate(pmlmepriv, (_FW_LINKED|WIFI_AP_STATE)) != true) - { return -EINVAL; - } if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff && param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff && param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) - { return -EINVAL; - } psta = rtw_get_stainfo(pstapriv, param->sta_addr); - if (psta) - { - if ((psta->wpa_ie[0] == WLAN_EID_RSN) || (psta->wpa_ie[0] == WLAN_EID_GENERIC)) - { + if (psta) { + if ((psta->wpa_ie[0] == WLAN_EID_RSN) || (psta->wpa_ie[0] == WLAN_EID_GENERIC)) { int wpa_ie_len; int copy_len; wpa_ie_len = psta->wpa_ie[1]; - - copy_len = ((wpa_ie_len+2) > sizeof(psta->wpa_ie)) ? (sizeof(psta->wpa_ie)):(wpa_ie_len+2); - + copy_len = ((wpa_ie_len+2) > sizeof(psta->wpa_ie)) ? (sizeof(psta->wpa_ie)) : (wpa_ie_len+2); param->u.wpa_ie.len = copy_len; - _rtw_memcpy(param->u.wpa_ie.reserved, psta->wpa_ie, copy_len); - } - else - { - //ret = -1; + } else { DBG_88E("sta's wpa_ie is NONE\n"); } - } - else - { + } else { ret = -1; } return ret; - } static int rtw_set_wps_beacon(struct net_device *dev, struct ieee_param *param, int len) { - int ret=0; - unsigned char wps_oui[4]={0x0,0x50,0xf2,0x04}; + int ret = 0; + unsigned char wps_oui[4] = {0x0, 0x50, 0xf2, 0x04}; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); int ie_len; - DBG_88E("%s, len=%d\n", __func__, len); + DBG_88E("%s, len =%d\n", __func__, len); if (check_fwstate(pmlmepriv, WIFI_AP_STATE) != true) return -EINVAL; - ie_len = len-12-2;// 12 = param header, 2:no packed + ie_len = len-12-2;/* 12 = param header, 2:no packed */ - - if (pmlmepriv->wps_beacon_ie) - { + if (pmlmepriv->wps_beacon_ie) { rtw_mfree(pmlmepriv->wps_beacon_ie, pmlmepriv->wps_beacon_ie_len); pmlmepriv->wps_beacon_ie = NULL; } - if (ie_len>0) - { + if (ie_len > 0) { pmlmepriv->wps_beacon_ie = rtw_malloc(ie_len); pmlmepriv->wps_beacon_ie_len = ie_len; if (pmlmepriv->wps_beacon_ie == NULL) { @@ -6652,37 +5604,31 @@ static int rtw_set_wps_beacon(struct net_device *dev, struct ieee_param *param, update_beacon(padapter, _VENDOR_SPECIFIC_IE_, wps_oui, true); pmlmeext->bstart_bss = true; - } - return ret; - } static int rtw_set_wps_probe_resp(struct net_device *dev, struct ieee_param *param, int len) { - int ret=0; + int ret = 0; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); int ie_len; - DBG_88E("%s, len=%d\n", __func__, len); + DBG_88E("%s, len =%d\n", __func__, len); if (check_fwstate(pmlmepriv, WIFI_AP_STATE) != true) return -EINVAL; - ie_len = len-12-2;// 12 = param header, 2:no packed + ie_len = len-12-2;/* 12 = param header, 2:no packed */ - - if (pmlmepriv->wps_probe_resp_ie) - { + if (pmlmepriv->wps_probe_resp_ie) { rtw_mfree(pmlmepriv->wps_probe_resp_ie, pmlmepriv->wps_probe_resp_ie_len); pmlmepriv->wps_probe_resp_ie = NULL; } - if (ie_len>0) - { + if (ie_len > 0) { pmlmepriv->wps_probe_resp_ie = rtw_malloc(ie_len); pmlmepriv->wps_probe_resp_ie_len = ie_len; if (pmlmepriv->wps_probe_resp_ie == NULL) { @@ -6692,34 +5638,29 @@ static int rtw_set_wps_probe_resp(struct net_device *dev, struct ieee_param *par _rtw_memcpy(pmlmepriv->wps_probe_resp_ie, param->u.bcn_ie.buf, ie_len); } - return ret; - } static int rtw_set_wps_assoc_resp(struct net_device *dev, struct ieee_param *param, int len) { - int ret=0; + int ret = 0; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); int ie_len; - DBG_88E("%s, len=%d\n", __func__, len); + DBG_88E("%s, len =%d\n", __func__, len); if (check_fwstate(pmlmepriv, WIFI_AP_STATE) != true) return -EINVAL; - ie_len = len-12-2;// 12 = param header, 2:no packed + ie_len = len-12-2;/* 12 = param header, 2:no packed */ - - if (pmlmepriv->wps_assoc_resp_ie) - { + if (pmlmepriv->wps_assoc_resp_ie) { rtw_mfree(pmlmepriv->wps_assoc_resp_ie, pmlmepriv->wps_assoc_resp_ie_len); pmlmepriv->wps_assoc_resp_ie = NULL; } - if (ie_len>0) - { + if (ie_len > 0) { pmlmepriv->wps_assoc_resp_ie = rtw_malloc(ie_len); pmlmepriv->wps_assoc_resp_ie_len = ie_len; if (pmlmepriv->wps_assoc_resp_ie == NULL) { @@ -6730,45 +5671,37 @@ static int rtw_set_wps_assoc_resp(struct net_device *dev, struct ieee_param *par _rtw_memcpy(pmlmepriv->wps_assoc_resp_ie, param->u.bcn_ie.buf, ie_len); } - return ret; - } static int rtw_set_hidden_ssid(struct net_device *dev, struct ieee_param *param, int len) { - int ret=0; + int ret = 0; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); u8 value; if (check_fwstate(pmlmepriv, WIFI_AP_STATE) != true) return -EINVAL; - if (param->u.wpa_param.name != 0) //dummy test... - { + if (param->u.wpa_param.name != 0) /* dummy test... */ DBG_88E("%s name(%u) != 0\n", __func__, param->u.wpa_param.name); - } - value = param->u.wpa_param.value; - //use the same definition of hostapd's ignore_broadcast_ssid + /* use the same definition of hostapd's ignore_broadcast_ssid */ if (value != 1 && value != 2) value = 0; - DBG_88E("%s value(%u)\n", __func__, value); pmlmeinfo->hidden_ssid_mode = value; - return ret; - } static int rtw_ioctl_acl_remove_sta(struct net_device *dev, struct ieee_param *param, int len) { - int ret=0; + int ret = 0; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); @@ -6778,19 +5711,14 @@ static int rtw_ioctl_acl_remove_sta(struct net_device *dev, struct ieee_param *p if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff && param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff && param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) - { return -EINVAL; - } - ret = rtw_acl_remove_sta(padapter, param->sta_addr); - return ret; - } static int rtw_ioctl_acl_add_sta(struct net_device *dev, struct ieee_param *param, int len) { - int ret=0; + int ret = 0; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); @@ -6800,19 +5728,14 @@ static int rtw_ioctl_acl_add_sta(struct net_device *dev, struct ieee_param *para if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff && param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff && param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) - { return -EINVAL; - } - ret = rtw_acl_add_sta(padapter, param->sta_addr); - return ret; - } static int rtw_ioctl_set_macaddr_acl(struct net_device *dev, struct ieee_param *param, int len) { - int ret=0; + int ret = 0; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); @@ -6827,147 +5750,93 @@ static int rtw_ioctl_set_macaddr_acl(struct net_device *dev, struct ieee_param * static int rtw_hostapd_ioctl(struct net_device *dev, struct iw_point *p) { struct ieee_param *param; - int ret=0; + int ret = 0; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - //DBG_88E("%s\n", __func__); - /* * this function is expect to call in master mode, which allows no power saving * so, we just check hw_init_completed */ - if (padapter->hw_init_completed==false){ + if (!padapter->hw_init_completed) { ret = -EPERM; goto out; } - - //if (p->length < sizeof(struct ieee_param) || !p->pointer){ - if (!p->pointer){ + if (!p->pointer) { ret = -EINVAL; goto out; } param = (struct ieee_param *)rtw_malloc(p->length); - if (param == NULL) - { + if (param == NULL) { ret = -ENOMEM; goto out; } - if (copy_from_user(param, p->pointer, p->length)) - { - rtw_mfree((u8*)param, p->length); + if (copy_from_user(param, p->pointer, p->length)) { + rtw_mfree((u8 *)param, p->length); ret = -EFAULT; goto out; } - //DBG_88E("%s, cmd=%d\n", __func__, param->cmd); - - switch (param->cmd) - { - case RTL871X_HOSTAPD_FLUSH: - - ret = rtw_hostapd_sta_flush(dev); - - break; - - case RTL871X_HOSTAPD_ADD_STA: - - ret = rtw_add_sta(dev, param); - - break; - - case RTL871X_HOSTAPD_REMOVE_STA: - - ret = rtw_del_sta(dev, param); - - break; - - case RTL871X_HOSTAPD_SET_BEACON: - - ret = rtw_set_beacon(dev, param, p->length); - - break; - - case RTL871X_SET_ENCRYPTION: - - ret = rtw_set_encryption(dev, param, p->length); - - break; - - case RTL871X_HOSTAPD_GET_WPAIE_STA: - - ret = rtw_get_sta_wpaie(dev, param); - - break; - - case RTL871X_HOSTAPD_SET_WPS_BEACON: - - ret = rtw_set_wps_beacon(dev, param, p->length); - - break; - - case RTL871X_HOSTAPD_SET_WPS_PROBE_RESP: - - ret = rtw_set_wps_probe_resp(dev, param, p->length); - - break; - - case RTL871X_HOSTAPD_SET_WPS_ASSOC_RESP: - - ret = rtw_set_wps_assoc_resp(dev, param, p->length); - - break; - - case RTL871X_HOSTAPD_SET_HIDDEN_SSID: - - ret = rtw_set_hidden_ssid(dev, param, p->length); - - break; - - case RTL871X_HOSTAPD_GET_INFO_STA: - - ret = rtw_ioctl_get_sta_data(dev, param, p->length); - - break; - - case RTL871X_HOSTAPD_SET_MACADDR_ACL: - - ret = rtw_ioctl_set_macaddr_acl(dev, param, p->length); - - break; - - case RTL871X_HOSTAPD_ACL_ADD_STA: - - ret = rtw_ioctl_acl_add_sta(dev, param, p->length); - - break; - - case RTL871X_HOSTAPD_ACL_REMOVE_STA: - - ret = rtw_ioctl_acl_remove_sta(dev, param, p->length); - - break; - - default: - DBG_88E("Unknown hostapd request: %d\n", param->cmd); - ret = -EOPNOTSUPP; - break; - + switch (param->cmd) { + case RTL871X_HOSTAPD_FLUSH: + ret = rtw_hostapd_sta_flush(dev); + break; + case RTL871X_HOSTAPD_ADD_STA: + ret = rtw_add_sta(dev, param); + break; + case RTL871X_HOSTAPD_REMOVE_STA: + ret = rtw_del_sta(dev, param); + break; + case RTL871X_HOSTAPD_SET_BEACON: + ret = rtw_set_beacon(dev, param, p->length); + break; + case RTL871X_SET_ENCRYPTION: + ret = rtw_set_encryption(dev, param, p->length); + break; + case RTL871X_HOSTAPD_GET_WPAIE_STA: + ret = rtw_get_sta_wpaie(dev, param); + break; + case RTL871X_HOSTAPD_SET_WPS_BEACON: + ret = rtw_set_wps_beacon(dev, param, p->length); + break; + case RTL871X_HOSTAPD_SET_WPS_PROBE_RESP: + ret = rtw_set_wps_probe_resp(dev, param, p->length); + break; + case RTL871X_HOSTAPD_SET_WPS_ASSOC_RESP: + ret = rtw_set_wps_assoc_resp(dev, param, p->length); + break; + case RTL871X_HOSTAPD_SET_HIDDEN_SSID: + ret = rtw_set_hidden_ssid(dev, param, p->length); + break; + case RTL871X_HOSTAPD_GET_INFO_STA: + ret = rtw_ioctl_get_sta_data(dev, param, p->length); + break; + case RTL871X_HOSTAPD_SET_MACADDR_ACL: + ret = rtw_ioctl_set_macaddr_acl(dev, param, p->length); + break; + case RTL871X_HOSTAPD_ACL_ADD_STA: + ret = rtw_ioctl_acl_add_sta(dev, param, p->length); + break; + case RTL871X_HOSTAPD_ACL_REMOVE_STA: + ret = rtw_ioctl_acl_remove_sta(dev, param, p->length); + break; + default: + DBG_88E("Unknown hostapd request: %d\n", param->cmd); + ret = -EOPNOTSUPP; + break; } if (ret == 0 && copy_to_user(p->pointer, param, p->length)) ret = -EFAULT; - rtw_mfree((u8 *)param, p->length); out: return ret; - } #endif @@ -6981,16 +5850,15 @@ static int rtw_wx_set_priv(struct net_device *dev, int len = 0; char *ext; int i; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct iw_point *dwrq = (struct iw_point*)awrq; + struct iw_point *dwrq = (struct iw_point *)awrq; - //RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_notice_, ("+rtw_wx_set_priv\n")); if (dwrq->length == 0) return -EFAULT; len = dwrq->length; - if (!(ext = rtw_vmalloc(len))) + ext = rtw_vmalloc(len); + if (!ext) return -ENOMEM; if (copy_from_user(ext, dwrq->pointer, len)) { @@ -6998,22 +5866,19 @@ static int rtw_wx_set_priv(struct net_device *dev, return -EFAULT; } - //added for wps2.0 @20110524 - if (dwrq->flags == 0x8766 && len > 8) - { + /* added for wps2.0 @20110524 */ + if (dwrq->flags == 0x8766 && len > 8) { u32 cp_sz; struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); u8 *probereq_wpsie = ext; int probereq_wpsie_len = len; - u8 wps_oui[4]={0x0,0x50,0xf2,0x04}; + u8 wps_oui[4] = {0x0, 0x50, 0xf2, 0x04}; if ((_VENDOR_SPECIFIC_IE_ == probereq_wpsie[0]) && - (!memcmp(&probereq_wpsie[2], wps_oui, 4) ==true)) - { - cp_sz = probereq_wpsie_len>MAX_WPS_IE_LEN ? MAX_WPS_IE_LEN:probereq_wpsie_len; + (!memcmp(&probereq_wpsie[2], wps_oui, 4))) { + cp_sz = probereq_wpsie_len > MAX_WPS_IE_LEN ? MAX_WPS_IE_LEN : probereq_wpsie_len; - if (pmlmepriv->wps_probe_req_ie) - { + if (pmlmepriv->wps_probe_req_ie) { u32 free_len = pmlmepriv->wps_probe_req_ie_len; pmlmepriv->wps_probe_req_ie_len = 0; rtw_mfree(pmlmepriv->wps_probe_req_ie, free_len); @@ -7022,24 +5887,18 @@ static int rtw_wx_set_priv(struct net_device *dev, pmlmepriv->wps_probe_req_ie = rtw_malloc(cp_sz); if (pmlmepriv->wps_probe_req_ie == NULL) { - printk("%s()-%d: rtw_malloc() ERROR!\n", __func__, __LINE__); + pr_info("%s()-%d: rtw_malloc() ERROR!\n", __func__, __LINE__); ret = -EINVAL; goto FREE_EXT; - } - _rtw_memcpy(pmlmepriv->wps_probe_req_ie, probereq_wpsie, cp_sz); pmlmepriv->wps_probe_req_ie_len = cp_sz; - } - goto FREE_EXT; - } - if ( len >= WEXT_CSCAN_HEADER_SIZE - && !memcmp(ext, WEXT_CSCAN_HEADER, WEXT_CSCAN_HEADER_SIZE) == true - ){ + if (len >= WEXT_CSCAN_HEADER_SIZE && + !memcmp(ext, WEXT_CSCAN_HEADER, WEXT_CSCAN_HEADER_SIZE)) { ret = rtw_wx_set_scan(dev, info, awrq, ext); goto FREE_EXT; } @@ -7052,8 +5911,8 @@ FREE_EXT: } static int rtw_pm_set(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { int ret = 0; unsigned mode = 0; @@ -7061,17 +5920,13 @@ static int rtw_pm_set(struct net_device *dev, DBG_88E("[%s] extra = %s\n", __func__, extra); - if (!memcmp(extra, "lps=", 4)) - { + if (!memcmp(extra, "lps =", 4)) { sscanf(extra+4, "%u", &mode); - ret = rtw_pm_set_lps(padapter,mode); - } - else if (!memcmp(extra, "ips=", 4)) - { + ret = rtw_pm_set_lps(padapter, mode); + } else if (!memcmp(extra, "ips =", 4)) { sscanf(extra+4, "%u", &mode); - ret = rtw_pm_set_ips(padapter,mode); - } - else{ + ret = rtw_pm_set_ips(padapter, mode); + } else { ret = -EINVAL; } @@ -7082,204 +5937,153 @@ static int rtw_mp_efuse_get(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wdata, char *extra) { - struct adapter * padapter = rtw_netdev_priv(dev); + struct adapter *padapter = rtw_netdev_priv(dev); struct eeprom_priv *pEEPROM = GET_EEPROM_EFUSE_PRIV(padapter); - struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter); + struct hal_data_8188e *haldata = GET_HAL_DATA(padapter); struct efuse_hal *pEfuseHal; struct iw_point *wrqu; - u8 *PROMContent = pEEPROM->efuse_eeprom_data; - u8 ips_mode,lps_mode; - struct pwrctrl_priv *pwrctrlpriv ; + u8 *PROMContent = pEEPROM->efuse_eeprom_data; + u8 ips_mode, lps_mode; + struct pwrctrl_priv *pwrctrlpriv; u8 *data = NULL; u8 *rawdata = NULL; - char *pch, *ptmp, *token, *tmp[3]={NULL, NULL, NULL}; - u16 i=0, j=0, mapLen=0, addr=0, cnts=0; - u16 max_available_size=0, raw_cursize=0, raw_maxsize=0; + char *pch, *ptmp, *token, *tmp[3] = {NULL, NULL, NULL}; + u16 i = 0, j = 0, mapLen = 0, addr = 0, cnts = 0; + u16 max_available_size = 0, raw_cursize = 0, raw_maxsize = 0; int err; - u8 org_fw_iol = padapter->registrypriv.fw_iol;// 0:Disable, 1:enable, 2:by usb speed + u8 org_fw_iol = padapter->registrypriv.fw_iol;/* 0:Disable, 1:enable, 2:by usb speed */ - wrqu = (struct iw_point*)wdata; + wrqu = (struct iw_point *)wdata; pwrctrlpriv = &padapter->pwrctrlpriv; - pEfuseHal = &pHalData->EfuseHal; + pEfuseHal = &haldata->EfuseHal; err = 0; data = _rtw_zmalloc(EFUSE_BT_MAX_MAP_LEN); - if (data == NULL) - { + if (data == NULL) { err = -ENOMEM; goto exit; } rawdata = _rtw_zmalloc(EFUSE_BT_MAX_MAP_LEN); - if (rawdata == NULL) - { + if (rawdata == NULL) { err = -ENOMEM; goto exit; } - if (copy_from_user(extra, wrqu->pointer, wrqu->length)) - { + if (copy_from_user(extra, wrqu->pointer, wrqu->length)) { err = -EFAULT; goto exit; } - lps_mode = pwrctrlpriv->power_mgnt;//keep org value - rtw_pm_set_lps(padapter,PS_MODE_ACTIVE); + lps_mode = pwrctrlpriv->power_mgnt;/* keep org value */ + rtw_pm_set_lps(padapter, PS_MODE_ACTIVE); - ips_mode = pwrctrlpriv->ips_mode;//keep org value - rtw_pm_set_ips(padapter,IPS_NONE); + ips_mode = pwrctrlpriv->ips_mode;/* keep org value */ + rtw_pm_set_ips(padapter, IPS_NONE); pch = extra; - DBG_88E("%s: in=%s\n", __func__, extra); + DBG_88E("%s: in =%s\n", __func__, extra); i = 0; - //mac 16 "00e04c871200" rmap,00,2 - while ((token = strsep(&pch, ",")) != NULL) - { - if (i > 2) break; + /* mac 16 "00e04c871200" rmap, 00, 2 */ + while ((token = strsep(&pch, ",")) != NULL) { + if (i > 2) + break; tmp[i] = token; i++; } - padapter->registrypriv.fw_iol = 0;// 0:Disable, 1:enable, 2:by usb speed + padapter->registrypriv.fw_iol = 0;/* 0:Disable, 1:enable, 2:by usb speed */ - if (strcmp(tmp[0], "status") == 0){ - sprintf(extra, "Load File efuse=%s,Load File MAC=%s",(pEEPROM->bloadfile_fail_flag? "FAIL" : "OK"),(pEEPROM->bloadmac_fail_flag? "FAIL" : "OK")); + if (strcmp(tmp[0], "status") == 0) { + sprintf(extra, "Load File efuse =%s, Load File MAC =%s", (pEEPROM->bloadfile_fail_flag ? "FAIL" : "OK"), (pEEPROM->bloadmac_fail_flag ? "FAIL" : "OK")); goto exit; - } - else if (strcmp(tmp[0], "filemap") == 0) - { + } else if (strcmp(tmp[0], "filemap") == 0) { mapLen = EFUSE_MAP_SIZE; sprintf(extra, "\n"); - for (i = 0; i < EFUSE_MAP_SIZE; i += 16) - { -// DBG_88E("0x%02x\t", i); + for (i = 0; i < EFUSE_MAP_SIZE; i += 16) { sprintf(extra, "%s0x%02x\t", extra, i); - for (j=0; j<8; j++) { -// DBG_88E("%02X ", data[i+j]); + for (j = 0; j < 8; j++) sprintf(extra, "%s%02X ", extra, PROMContent[i+j]); - } -// DBG_88E("\t"); sprintf(extra, "%s\t", extra); - for (; j<16; j++) { -// DBG_88E("%02X ", data[i+j]); + for (; j < 16; j++) sprintf(extra, "%s%02X ", extra, PROMContent[i+j]); - } -// DBG_88E("\n"); - sprintf(extra,"%s\n",extra); + sprintf(extra, "%s\n", extra); } -// DBG_88E("\n"); - } - else if (strcmp(tmp[0], "realmap") == 0) - { + } else if (strcmp(tmp[0], "realmap") == 0) { mapLen = EFUSE_MAP_SIZE; - if (rtw_efuse_map_read(padapter, 0, mapLen, pEfuseHal->fakeEfuseInitMap) == _FAIL) - { + if (rtw_efuse_map_read(padapter, 0, mapLen, pEfuseHal->fakeEfuseInitMap) == _FAIL) { DBG_88E("%s: read realmap Fail!!\n", __func__); err = -EFAULT; goto exit; } -// DBG_88E("OFFSET\tVALUE(hex)\n"); sprintf(extra, "\n"); - for (i = 0; i < EFUSE_MAP_SIZE; i += 16) - { -// DBG_88E("0x%02x\t", i); + for (i = 0; i < EFUSE_MAP_SIZE; i += 16) { sprintf(extra, "%s0x%02x\t", extra, i); - for (j=0; j<8; j++) { -// DBG_88E("%02X ", data[i+j]); + for (j = 0; j < 8; j++) sprintf(extra, "%s%02X ", extra, pEfuseHal->fakeEfuseInitMap[i+j]); - } -// DBG_88E("\t"); sprintf(extra, "%s\t", extra); - for (; j<16; j++) { -// DBG_88E("%02X ", data[i+j]); + for (; j < 16; j++) sprintf(extra, "%s%02X ", extra, pEfuseHal->fakeEfuseInitMap[i+j]); - } -// DBG_88E("\n"); - sprintf(extra,"%s\n",extra); + sprintf(extra, "%s\n", extra); } -// DBG_88E("\n"); - } - else if (strcmp(tmp[0], "rmap") == 0) - { - if ((tmp[1]==NULL) || (tmp[2]==NULL)) - { + } else if (strcmp(tmp[0], "rmap") == 0) { + if ((tmp[1] == NULL) || (tmp[2] == NULL)) { DBG_88E("%s: rmap Fail!! Parameters error!\n", __func__); err = -EINVAL; goto exit; } - // rmap addr cnts + /* rmap addr cnts */ addr = simple_strtoul(tmp[1], &ptmp, 16); - DBG_88E("%s: addr=%x\n", __func__, addr); + DBG_88E("%s: addr =%x\n", __func__, addr); cnts = simple_strtoul(tmp[2], &ptmp, 10); - if (cnts == 0) - { + if (cnts == 0) { DBG_88E("%s: rmap Fail!! cnts error!\n", __func__); err = -EINVAL; goto exit; } - DBG_88E("%s: cnts=%d\n", __func__, cnts); + DBG_88E("%s: cnts =%d\n", __func__, cnts); EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_available_size, false); - if ((addr + cnts) > max_available_size) - { + if ((addr + cnts) > max_available_size) { DBG_88E("%s: addr(0x%X)+cnts(%d) parameter error!\n", __func__, addr, cnts); err = -EINVAL; goto exit; } - if (rtw_efuse_map_read(padapter, addr, cnts, data) == _FAIL) - { + if (rtw_efuse_map_read(padapter, addr, cnts, data) == _FAIL) { DBG_88E("%s: rtw_efuse_map_read error!\n", __func__); err = -EFAULT; goto exit; } -// DBG_88E("%s: data={", __func__); *extra = 0; - for (i=0; i max_available_size) - { + if ((addr + cnts) > max_available_size) { DBG_88E("%s: addr(0x%02x)+cnts(%d) parameter error!\n", __func__, addr, cnts); err = -EFAULT; goto exit; } - if (rtw_efuse_map_read(padapter, addr, cnts, data) == _FAIL) - { + if (rtw_efuse_map_read(padapter, addr, cnts, data) == _FAIL) { DBG_88E("%s: rtw_efuse_access error!!\n", __func__); err = -EFAULT; goto exit; } -// DBG_88E("%s: {VID,PID}={", __func__); *extra = 0; - for (i=0; iBTEfuseInitMap) == _FAIL) - { + if (rtw_BT_efuse_map_read(padapter, 0, mapLen, pEfuseHal->BTEfuseInitMap) == _FAIL) { DBG_88E("%s: rtw_BT_efuse_map_read Fail!!\n", __func__); err = -EFAULT; goto exit; } -// DBG_88E("OFFSET\tVALUE(hex)\n"); sprintf(extra, "\n"); - for (i=0; i<512; i+=16) // set 512 because the iwpriv's extra size have limit 0x7FF - { -// DBG_88E("0x%03x\t", i); + for (i = 0; i < 512; i += 16) { + /* set 512 because the iwpriv's extra size have limit 0x7FF */ sprintf(extra, "%s0x%03x\t", extra, i); - for (j=0; j<8; j++) { -// DBG_88E("%02X ", pEfuseHal->BTEfuseInitMap[i+j]); + for (j = 0; j < 8; j++) sprintf(extra, "%s%02X ", extra, pEfuseHal->BTEfuseInitMap[i+j]); - } -// DBG_88E("\t"); - sprintf(extra,"%s\t",extra); - for (; j<16; j++) { -// DBG_88E("%02X ", pEfuseHal->BTEfuseInitMap[i+j]); + sprintf(extra, "%s\t", extra); + for (; j < 16; j++) sprintf(extra, "%s%02X ", extra, pEfuseHal->BTEfuseInitMap[i+j]); - } -// DBG_88E("\n"); sprintf(extra, "%s\n", extra); } -// DBG_88E("\n"); - } - else if (strcmp(tmp[0],"btbmap") == 0) - { + } else if (strcmp(tmp[0], "btbmap") == 0) { mapLen = EFUSE_BT_MAX_MAP_LEN; - if (rtw_BT_efuse_map_read(padapter, 0, mapLen, pEfuseHal->BTEfuseInitMap) == _FAIL) - { + if (rtw_BT_efuse_map_read(padapter, 0, mapLen, pEfuseHal->BTEfuseInitMap) == _FAIL) { DBG_88E("%s: rtw_BT_efuse_map_read Fail!!\n", __func__); err = -EFAULT; goto exit; } -// DBG_88E("OFFSET\tVALUE(hex)\n"); sprintf(extra, "\n"); - for (i=512; i<1024 ; i+=16) - { -// DBG_88E("0x%03x\t", i); + for (i = 512; i < 1024; i += 16) { sprintf(extra, "%s0x%03x\t", extra, i); - for (j=0; j<8; j++) - { -// DBG_88E("%02X ", data[i+j]); + for (j = 0; j < 8; j++) sprintf(extra, "%s%02X ", extra, pEfuseHal->BTEfuseInitMap[i+j]); - } -// DBG_88E("\t"); - sprintf(extra,"%s\t",extra); - for (; j<16; j++) { -// DBG_88E("%02X ", data[i+j]); + sprintf(extra, "%s\t", extra); + for (; j < 16; j++) sprintf(extra, "%s%02X ", extra, pEfuseHal->BTEfuseInitMap[i+j]); - } -// DBG_88E("\n"); sprintf(extra, "%s\n", extra); } -// DBG_88E("\n"); - } - else if (strcmp(tmp[0],"btrmap") == 0) - { - if ((tmp[1]==NULL) || (tmp[2]==NULL)) - { + } else if (strcmp(tmp[0], "btrmap") == 0) { + if ((tmp[1] == NULL) || (tmp[2] == NULL)) { err = -EINVAL; goto exit; } - // rmap addr cnts + /* rmap addr cnts */ addr = simple_strtoul(tmp[1], &ptmp, 16); - DBG_88E("%s: addr=0x%X\n", __func__, addr); + DBG_88E("%s: addr = 0x%X\n", __func__, addr); cnts = simple_strtoul(tmp[2], &ptmp, 10); - if (cnts == 0) - { + if (cnts == 0) { DBG_88E("%s: btrmap Fail!! cnts error!\n", __func__); err = -EINVAL; goto exit; } - DBG_88E("%s: cnts=%d\n", __func__, cnts); + DBG_88E("%s: cnts =%d\n", __func__, cnts); EFUSE_GetEfuseDefinition(padapter, EFUSE_BT, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_available_size, false); - if ((addr + cnts) > max_available_size) - { + if ((addr + cnts) > max_available_size) { DBG_88E("%s: addr(0x%X)+cnts(%d) parameter error!\n", __func__, addr, cnts); err = -EFAULT; goto exit; } - if (rtw_BT_efuse_map_read(padapter, addr, cnts, data) == _FAIL) - { + if (rtw_BT_efuse_map_read(padapter, addr, cnts, data) == _FAIL) { DBG_88E("%s: rtw_BT_efuse_map_read error!!\n", __func__); err = -EFAULT; goto exit; } *extra = 0; -// DBG_88E("%s: bt efuse data={", __func__); - for (i=0; ifakeBTEfuseModifiedMap[i+j]); + for (j = 0; j < 8; j++) sprintf(extra, "%s%02X ", extra, pEfuseHal->fakeBTEfuseModifiedMap[i+j]); - } -// DBG_88E("\t"); sprintf(extra, "%s\t", extra); - for (; j<16; j++) { -// DBG_88E("%02X ", pEfuseHal->fakeBTEfuseModifiedMap[i+j]); + for (; j < 16; j++) sprintf(extra, "%s%02X ", extra, pEfuseHal->fakeBTEfuseModifiedMap[i+j]); - } -// DBG_88E("\n"); sprintf(extra, "%s\n", extra); } -// DBG_88E("\n"); - } - else if (strcmp(tmp[0],"btbfake") == 0) - { -// DBG_88E("OFFSET\tVALUE(hex)\n"); + } else if (strcmp(tmp[0], "btbfake") == 0) { sprintf(extra, "\n"); - for (i=512; i<1024; i+=16) - { -// DBG_88E("0x%03x\t", i); + for (i = 512; i < 1024; i += 16) { sprintf(extra, "%s0x%03x\t", extra, i); - for (j=0; j<8; j++) { -// DBG_88E("%02X ", pEfuseHal->fakeBTEfuseModifiedMap[i+j]); + for (j = 0; j < 8; j++) sprintf(extra, "%s%02X ", extra, pEfuseHal->fakeBTEfuseModifiedMap[i+j]); - } -// DBG_88E("\t"); sprintf(extra, "%s\t", extra); - for (; j<16; j++) { -// DBG_88E("%02X ", pEfuseHal->fakeBTEfuseModifiedMap[i+j]); + for (; j < 16; j++) sprintf(extra, "%s%02X ", extra, pEfuseHal->fakeBTEfuseModifiedMap[i+j]); - } -// DBG_88E("\n"); sprintf(extra, "%s\n", extra); } -// DBG_88E("\n"); - } - else if (strcmp(tmp[0],"wlrfkmap")== 0) - { -// DBG_88E("OFFSET\tVALUE(hex)\n"); + } else if (strcmp(tmp[0], "wlrfkmap") == 0) { sprintf(extra, "\n"); - for (i=0; ifakeEfuseModifiedMap[i+j]); + for (j = 0; j < 8; j++) sprintf(extra, "%s%02X ", extra, pEfuseHal->fakeEfuseModifiedMap[i+j]); - } -// DBG_88E("\t"); sprintf(extra, "%s\t", extra); - for (; j<16; j++) { -// DBG_88E("%02X ", pEfuseHal->fakeEfuseModifiedMap[i+j]); + for (; j < 16; j++) sprintf(extra, "%s %02X", extra, pEfuseHal->fakeEfuseModifiedMap[i+j]); - } -// DBG_88E("\n"); sprintf(extra, "%s\n", extra); } -// DBG_88E("\n"); - } - else - { + } else { sprintf(extra, "Command not found!"); } @@ -7540,7 +6248,7 @@ exit: rtw_pm_set_ips(padapter, ips_mode); rtw_pm_set_lps(padapter, lps_mode); - padapter->registrypriv.fw_iol = org_fw_iol;// 0:Disable, 1:enable, 2:by usb speed + padapter->registrypriv.fw_iol = org_fw_iol;/* 0:Disable, 1:enable, 2:by usb speed */ return err; } @@ -7548,26 +6256,25 @@ static int rtw_mp_efuse_set(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wdata, char *extra) { - struct adapter * padapter; - struct pwrctrl_priv *pwrctrlpriv ; - struct hal_data_8188e *pHalData; + struct adapter *padapter; + struct pwrctrl_priv *pwrctrlpriv; + struct hal_data_8188e *haldata; struct efuse_hal *pEfuseHal; - u8 ips_mode,lps_mode; + u8 ips_mode, lps_mode; u32 i, jj, kk; u8 *setdata = NULL; u8 *ShadowMapBT = NULL; u8 *ShadowMapWiFi = NULL; u8 *setrawdata = NULL; char *pch, *ptmp, *token, *tmp[3] = {NULL, NULL, NULL}; - u16 addr=0, cnts=0, max_available_size=0; + u16 addr = 0, cnts = 0, max_available_size = 0; int err; - padapter = rtw_netdev_priv(dev); pwrctrlpriv = &padapter->pwrctrlpriv; - pHalData = GET_HAL_DATA(padapter); - pEfuseHal = &pHalData->EfuseHal; + haldata = GET_HAL_DATA(padapter); + pEfuseHal = &haldata->EfuseHal; err = 0; setdata = _rtw_zmalloc(1024); if (setdata == NULL) { @@ -7590,14 +6297,14 @@ static int rtw_mp_efuse_set(struct net_device *dev, goto exit; } - lps_mode = pwrctrlpriv->power_mgnt;//keep org value - rtw_pm_set_lps(padapter,PS_MODE_ACTIVE); + lps_mode = pwrctrlpriv->power_mgnt;/* keep org value */ + rtw_pm_set_lps(padapter, PS_MODE_ACTIVE); - ips_mode = pwrctrlpriv->ips_mode;//keep org value - rtw_pm_set_ips(padapter,IPS_NONE); + ips_mode = pwrctrlpriv->ips_mode;/* keep org value */ + rtw_pm_set_ips(padapter, IPS_NONE); pch = extra; - DBG_88E("%s: in=%s\n", __func__, extra); + DBG_88E("%s: in =%s\n", __func__, extra); i = 0; while ((token = strsep(&pch, ",")) != NULL) { @@ -7607,10 +6314,10 @@ static int rtw_mp_efuse_set(struct net_device *dev, i++; } - // tmp[0],[1],[2] - // wmap,addr,00e04c871200 + /* tmp[0],[1],[2] */ + /* wmap, addr, 00e04c871200 */ if (strcmp(tmp[0], "wmap") == 0) { - if ((tmp[1]==NULL) || (tmp[2]==NULL)) { + if ((tmp[1] == NULL) || (tmp[2] == NULL)) { err = -EINVAL; goto exit; } @@ -7629,13 +6336,13 @@ static int rtw_mp_efuse_set(struct net_device *dev, goto exit; } - DBG_88E("%s: addr=0x%X\n", __func__, addr); - DBG_88E("%s: cnts=%d\n", __func__, cnts); - DBG_88E("%s: map data=%s\n", __func__, tmp[2]); + DBG_88E("%s: addr = 0x%X\n", __func__, addr); + DBG_88E("%s: cnts =%d\n", __func__, cnts); + DBG_88E("%s: map data =%s\n", __func__, tmp[2]); - for (jj=0, kk=0; jj max_available_size) { DBG_88E("%s: addr(0x%X)+cnts(%d) parameter error!\n", __func__, addr, cnts); @@ -7668,12 +6375,12 @@ static int rtw_mp_efuse_set(struct net_device *dev, goto exit; } - DBG_88E("%s: addr=0x%X\n", __func__, addr); - DBG_88E("%s: cnts=%d\n", __func__, cnts); - DBG_88E("%s: raw data=%s\n", __func__, tmp[2]); + DBG_88E("%s: addr = 0x%X\n", __func__, addr); + DBG_88E("%s: cnts =%d\n", __func__, cnts); + DBG_88E("%s: raw data =%s\n", __func__, tmp[2]); - for (jj=0, kk=0; jj 6) - { - DBG_88E("%s: error data for mac addr=\"%s\"\n", __func__, tmp[1]); + if (cnts > 6) { + DBG_88E("%s: error data for mac addr =\"%s\"\n", __func__, tmp[1]); err = -EFAULT; goto exit; } - DBG_88E("%s: addr=0x%X\n", __func__, addr); - DBG_88E("%s: cnts=%d\n", __func__, cnts); - DBG_88E("%s: MAC address=%s\n", __func__, tmp[1]); + DBG_88E("%s: addr = 0x%X\n", __func__, addr); + DBG_88E("%s: cnts =%d\n", __func__, cnts); + DBG_88E("%s: MAC address =%s\n", __func__, tmp[1]); - for (jj=0, kk=0; jj max_available_size) - { + if ((addr+cnts) > max_available_size) { DBG_88E("%s: addr(0x%X)+cnts(%d) parameter error!\n", __func__, addr, cnts); err = -EFAULT; goto exit; } - if (rtw_efuse_map_write(padapter, addr, cnts, setdata) == _FAIL) - { + if (rtw_efuse_map_write(padapter, addr, cnts, setdata) == _FAIL) { DBG_88E("%s: rtw_efuse_map_write error!!\n", __func__); err = -EFAULT; goto exit; } - } - else if (strcmp(tmp[0], "vidpid") == 0) - { - if (tmp[1]==NULL) - { + } else if (strcmp(tmp[0], "vidpid") == 0) { + if (tmp[1] == NULL) { err = -EINVAL; goto exit; } - // pidvid,da0b7881 + /* pidvid, da0b7881 */ addr = EEPROM_VID_88EE; cnts = strlen(tmp[1]); - if (cnts%2) - { + if (cnts%2) { err = -EINVAL; goto exit; } cnts /= 2; - if (cnts == 0) - { + if (cnts == 0) { err = -EINVAL; goto exit; } - DBG_88E("%s: addr=0x%X\n", __func__, addr); - DBG_88E("%s: cnts=%d\n", __func__, cnts); - DBG_88E("%s: VID/PID=%s\n", __func__, tmp[1]); + DBG_88E("%s: addr = 0x%X\n", __func__, addr); + DBG_88E("%s: cnts =%d\n", __func__, cnts); + DBG_88E("%s: VID/PID =%s\n", __func__, tmp[1]); - for (jj=0, kk=0; jj max_available_size) - { + if ((addr+cnts) > max_available_size) { DBG_88E("%s: addr(0x%X)+cnts(%d) parameter error!\n", __func__, addr, cnts); err = -EFAULT; goto exit; } - if (rtw_efuse_map_write(padapter, addr, cnts, setdata) == _FAIL) - { + if (rtw_efuse_map_write(padapter, addr, cnts, setdata) == _FAIL) { DBG_88E("%s: rtw_efuse_map_write error!!\n", __func__); err = -EFAULT; goto exit; } - } - else if (strcmp(tmp[0], "btwmap") == 0) - { - if ((tmp[1]==NULL) || (tmp[2]==NULL)) - { + } else if (strcmp(tmp[0], "btwmap") == 0) { + if ((tmp[1] == NULL) || (tmp[2] == NULL)) { err = -EINVAL; goto exit; } @@ -7790,46 +6478,37 @@ static int rtw_mp_efuse_set(struct net_device *dev, addr &= 0xFFF; cnts = strlen(tmp[2]); - if (cnts%2) - { + if (cnts%2) { err = -EINVAL; goto exit; } cnts /= 2; - if (cnts == 0) - { + if (cnts == 0) { err = -EINVAL; goto exit; } - DBG_88E("%s: addr=0x%X\n", __func__, addr); - DBG_88E("%s: cnts=%d\n", __func__, cnts); - DBG_88E("%s: BT data=%s\n", __func__, tmp[2]); + DBG_88E("%s: addr = 0x%X\n", __func__, addr); + DBG_88E("%s: cnts =%d\n", __func__, cnts); + DBG_88E("%s: BT data =%s\n", __func__, tmp[2]); - for (jj=0, kk=0; jj max_available_size) - { + if ((addr+cnts) > max_available_size) { DBG_88E("%s: addr(0x%X)+cnts(%d) parameter error!\n", __func__, addr, cnts); err = -EFAULT; goto exit; } - if (rtw_BT_efuse_map_write(padapter, addr, cnts, setdata) == _FAIL) - { + if (rtw_BT_efuse_map_write(padapter, addr, cnts, setdata) == _FAIL) { DBG_88E("%s: rtw_BT_efuse_map_write error!!\n", __func__); err = -EFAULT; goto exit; } - } - else if (strcmp(tmp[0], "btwfake") == 0) - { - if ((tmp[1]==NULL) || (tmp[2]==NULL)) - { + } else if (strcmp(tmp[0], "btwfake") == 0) { + if ((tmp[1] == NULL) || (tmp[2] == NULL)) { err = -EINVAL; goto exit; } @@ -7838,83 +6517,64 @@ static int rtw_mp_efuse_set(struct net_device *dev, addr &= 0xFFF; cnts = strlen(tmp[2]); - if (cnts%2) - { + if (cnts%2) { err = -EINVAL; goto exit; } cnts /= 2; - if (cnts == 0) - { + if (cnts == 0) { err = -EINVAL; goto exit; } - DBG_88E("%s: addr=0x%X\n", __func__, addr); - DBG_88E("%s: cnts=%d\n", __func__, cnts); - DBG_88E("%s: BT tmp data=%s\n", __func__, tmp[2]); + DBG_88E("%s: addr = 0x%X\n", __func__, addr); + DBG_88E("%s: cnts =%d\n", __func__, cnts); + DBG_88E("%s: BT tmp data =%s\n", __func__, tmp[2]); - for (jj=0, kk=0; jjfakeBTEfuseModifiedMap[addr+jj] = key_2char2num(tmp[2][kk], tmp[2][kk+1]); - } - } - else if (strcmp(tmp[0], "btdumpfake") == 0) - { + for (jj = 0, kk = 0; jj < cnts; jj++, kk += 2) + pEfuseHal->fakeBTEfuseModifiedMap[addr+jj] = key_2char2num(tmp[2][kk], tmp[2][kk + 1]); + } else if (strcmp(tmp[0], "btdumpfake") == 0) { if (rtw_BT_efuse_map_read(padapter, 0, EFUSE_BT_MAX_MAP_LEN, pEfuseHal->fakeBTEfuseModifiedMap) == _SUCCESS) { DBG_88E("%s: BT read all map success\n", __func__); } else { DBG_88E("%s: BT read all map Fail!\n", __func__); err = -EFAULT; } - } - else if (strcmp(tmp[0], "wldumpfake") == 0) - { + } else if (strcmp(tmp[0], "wldumpfake") == 0) { if (rtw_efuse_map_read(padapter, 0, EFUSE_BT_MAX_MAP_LEN, pEfuseHal->fakeEfuseModifiedMap) == _SUCCESS) { DBG_88E("%s: BT read all map success\n", __func__); } else { DBG_88E("%s: BT read all map Fail\n", __func__); err = -EFAULT; } - } - else if (strcmp(tmp[0], "btfk2map") == 0) - { + } else if (strcmp(tmp[0], "btfk2map") == 0) { _rtw_memcpy(pEfuseHal->BTEfuseModifiedMap, pEfuseHal->fakeBTEfuseModifiedMap, EFUSE_BT_MAX_MAP_LEN); EFUSE_GetEfuseDefinition(padapter, EFUSE_BT, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_available_size, false); - if (max_available_size < 1) - { + if (max_available_size < 1) { err = -EFAULT; goto exit; } - if (rtw_BT_efuse_map_write(padapter, 0x00, EFUSE_BT_MAX_MAP_LEN, pEfuseHal->fakeBTEfuseModifiedMap) == _FAIL) - { + if (rtw_BT_efuse_map_write(padapter, 0x00, EFUSE_BT_MAX_MAP_LEN, pEfuseHal->fakeBTEfuseModifiedMap) == _FAIL) { DBG_88E("%s: rtw_BT_efuse_map_write error!\n", __func__); err = -EFAULT; goto exit; } - } - else if (strcmp(tmp[0], "wlfk2map") == 0) - { + } else if (strcmp(tmp[0], "wlfk2map") == 0) { EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_available_size, false); - if (max_available_size < 1) - { + if (max_available_size < 1) { err = -EFAULT; goto exit; } - if (rtw_efuse_map_write(padapter, 0x00, EFUSE_MAX_MAP_LEN, pEfuseHal->fakeEfuseModifiedMap) == _FAIL) - { + if (rtw_efuse_map_write(padapter, 0x00, EFUSE_MAX_MAP_LEN, pEfuseHal->fakeEfuseModifiedMap) == _FAIL) { DBG_88E("%s: rtw_efuse_map_write error!\n", __func__); err = -EFAULT; goto exit; } - } - else if (strcmp(tmp[0], "wlwfake") == 0) - { - if ((tmp[1]==NULL) || (tmp[2]==NULL)) - { + } else if (strcmp(tmp[0], "wlwfake") == 0) { + if ((tmp[1] == NULL) || (tmp[2] == NULL)) { err = -EINVAL; goto exit; } @@ -7923,26 +6583,22 @@ static int rtw_mp_efuse_set(struct net_device *dev, addr &= 0xFFF; cnts = strlen(tmp[2]); - if (cnts%2) - { + if (cnts%2) { err = -EINVAL; goto exit; } cnts /= 2; - if (cnts == 0) - { + if (cnts == 0) { err = -EINVAL; goto exit; } - DBG_88E("%s: addr=0x%X\n", __func__, addr); - DBG_88E("%s: cnts=%d\n", __func__, cnts); - DBG_88E("%s: map tmp data=%s\n", __func__, tmp[2]); + DBG_88E("%s: addr = 0x%X\n", __func__, addr); + DBG_88E("%s: cnts =%d\n", __func__, cnts); + DBG_88E("%s: map tmp data =%s\n", __func__, tmp[2]); - for (jj=0, kk=0; jjfakeEfuseModifiedMap[addr+jj] = key_2char2num(tmp[2][kk], tmp[2][kk+1]); - } + for (jj = 0, kk = 0; jj < cnts; jj++, kk += 2) + pEfuseHal->fakeEfuseModifiedMap[addr+jj] = key_2char2num(tmp[2][kk], tmp[2][kk + 1]); } exit: @@ -7979,30 +6635,34 @@ static int rtw_mp_write_reg(struct net_device *dev, char width; u32 addr, data; int ret; - struct adapter * padapter = rtw_netdev_priv(dev); + struct adapter *padapter = rtw_netdev_priv(dev); pch = extra; - pnext = strpbrk(pch, " ,.-"); - if (pnext == NULL) return -EINVAL; + pnext = strpbrk(pch, ",.-"); + if (pnext == NULL) + return -EINVAL; *pnext = 0; width_str = pch; pch = pnext + 1; - pnext = strpbrk(pch, " ,.-"); - if (pnext == NULL) return -EINVAL; + pnext = strpbrk(pch, ",.-"); + if (pnext == NULL) + return -EINVAL; *pnext = 0; addr = simple_strtoul(pch, &ptmp, 16); - if (addr > 0x3FFF) return -EINVAL; + if (addr > 0x3FFF) + return -EINVAL; pch = pnext + 1; - if ((pch - extra) >= wrqu->length) return -EINVAL; + if ((pch - extra) >= wrqu->length) + return -EINVAL; data = simple_strtoul(pch, &ptmp, 16); ret = 0; width = width_str[0]; switch (width) { case 'b': - // 1 byte + /* 1 byte */ if (data > 0xFF) { ret = -EINVAL; break; @@ -8010,7 +6670,7 @@ static int rtw_mp_write_reg(struct net_device *dev, rtw_write8(padapter, addr, data); break; case 'w': - // 2 bytes + /* 2 bytes */ if (data > 0xFFFF) { ret = -EINVAL; break; @@ -8018,7 +6678,7 @@ static int rtw_mp_write_reg(struct net_device *dev, rtw_write16(padapter, addr, data); break; case 'd': - // 4 bytes + /* 4 bytes */ rtw_write32(padapter, addr, data); break; default: @@ -8044,14 +6704,14 @@ static int rtw_mp_read_reg(struct net_device *dev, struct iw_request_info *info, struct iw_point *wrqu, char *extra) { - struct adapter * padapter = rtw_netdev_priv(dev); + struct adapter *padapter = rtw_netdev_priv(dev); char *input = kmalloc(wrqu->length, GFP_KERNEL); char *pch, *pnext, *ptmp; char *width_str; char width; - char data[20],tmp[20]; + char data[20], tmp[20]; u32 addr; - u32 ret, i=0, j=0, strtout=0; + u32 ret, i = 0, j = 0, strtout = 0; if (!input) return -ENOMEM; @@ -8064,7 +6724,7 @@ static int rtw_mp_read_reg(struct net_device *dev, _rtw_memset(extra, 0, wrqu->length); pch = input; - pnext = strpbrk(pch, " ,.-"); + pnext = strpbrk(pch, ",.-"); if (pnext == NULL) { kfree(input); return -EINVAL; @@ -8086,16 +6746,16 @@ static int rtw_mp_read_reg(struct net_device *dev, width = width_str[0]; switch (width) { case 'b': - // 1 byte + /* 1 byte */ sprintf(extra, "%d\n", rtw_read8(padapter, addr)); wrqu->length = strlen(extra); break; case 'w': - // 2 bytes + /* 2 bytes */ sprintf(data, "%04x\n", rtw_read16(padapter, addr)); - for (i=0 ; i <= strlen(data) ; i++) { - if (i%2==0) { - tmp[j]=' '; + for (i = 0; i <= strlen(data); i++) { + if (i%2 == 0) { + tmp[j] = ' '; j++; } if (data[i] != '\0') @@ -8103,7 +6763,7 @@ static int rtw_mp_read_reg(struct net_device *dev, j++; } pch = tmp; - DBG_88E("pch=%s",pch); + DBG_88E("pch =%s", pch); while (*pch != '\0') { pnext = strpbrk(pch, " "); @@ -8112,8 +6772,8 @@ static int rtw_mp_read_reg(struct net_device *dev, pnext++; if (*pnext != '\0') { - strtout = simple_strtoul (pnext , &ptmp, 16); - sprintf(extra, "%s %d" ,extra ,strtout); + strtout = simple_strtoul(pnext, &ptmp, 16); + sprintf(extra, "%s %d", extra, strtout); } else { break; } @@ -8122,21 +6782,21 @@ static int rtw_mp_read_reg(struct net_device *dev, wrqu->length = 6; break; case 'd': - // 4 bytes + /* 4 bytes */ sprintf(data, "%08x", rtw_read32(padapter, addr)); - //add read data format blank - for (i=0 ; i <= strlen(data) ; i++) { - if (i%2==0) { - tmp[j]=' '; - j++; - } - if (data[i] != '\0') - tmp[j] = data[i]; + /* add read data format blank */ + for (i = 0; i <= strlen(data); i++) { + if (i%2 == 0) { + tmp[j] = ' '; + j++; + } + if (data[i] != '\0') + tmp[j] = data[i]; - j++; + j++; } pch = tmp; - DBG_88E("pch=%s",pch); + DBG_88E("pch =%s", pch); while (*pch != '\0') { pnext = strpbrk(pch, " "); @@ -8144,8 +6804,8 @@ static int rtw_mp_read_reg(struct net_device *dev, break; pnext++; if (*pnext != '\0') { - strtout = simple_strtoul (pnext , &ptmp, 16); - sprintf(extra, "%s %d" ,extra ,strtout); + strtout = simple_strtoul(pnext, &ptmp, 16); + sprintf(extra, "%s %d", extra, strtout); } else { break; } @@ -8169,20 +6829,23 @@ static int rtw_mp_read_reg(struct net_device *dev, * 2st %x is data to write */ static int rtw_mp_write_rf(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *wrqu, char *extra) + struct iw_request_info *info, + struct iw_point *wrqu, char *extra) { u32 path, addr, data; int ret; - struct adapter * padapter = rtw_netdev_priv(dev); - + struct adapter *padapter = rtw_netdev_priv(dev); ret = sscanf(extra, "%d,%x,%x", &path, &addr, &data); - if (ret < 3) return -EINVAL; + if (ret < 3) + return -EINVAL; - if (path >= MAX_RF_PATH_NUMS) return -EINVAL; - if (addr > 0xFF) return -EINVAL; - if (data > 0xFFFFF) return -EINVAL; + if (path >= MAX_RF_PATH_NUMS) + return -EINVAL; + if (addr > 0xFF) + return -EINVAL; + if (data > 0xFFFFF) + return -EINVAL; _rtw_memset(extra, 0, wrqu->length); @@ -8208,11 +6871,10 @@ static int rtw_mp_read_rf(struct net_device *dev, { char *input = kmalloc(wrqu->length, GFP_KERNEL); char *pch, *pnext, *ptmp; - char data[20],tmp[20]; - //u32 *data = (u32*)extra; + char data[20], tmp[20]; u32 path, addr; - u32 ret,i=0 ,j=0,strtou=0; - struct adapter * padapter = rtw_netdev_priv(dev); + u32 ret, i = 0, j = 0, strtou = 0; + struct adapter *padapter = rtw_netdev_priv(dev); if (!input) return -ENOMEM; @@ -8233,25 +6895,25 @@ static int rtw_mp_read_rf(struct net_device *dev, _rtw_memset(extra, 0, wrqu->length); sprintf(data, "%08x", read_rfreg(padapter, path, addr)); - //add read data format blank - for (i=0 ; i <= strlen(data) ; i++) { - if (i%2==0) { - tmp[j]=' '; - j++; - } - tmp[j] = data[i]; - j++; + /* add read data format blank */ + for (i = 0; i <= strlen(data); i++) { + if (i%2 == 0) { + tmp[j] = ' '; + j++; + } + tmp[j] = data[i]; + j++; } pch = tmp; - DBG_88E("pch=%s",pch); + DBG_88E("pch =%s", pch); while (*pch != '\0') { pnext = strpbrk(pch, " "); pnext++; if (*pnext != '\0') { - strtou = simple_strtoul (pnext , &ptmp, 16); - sprintf(extra, "%s %d" ,extra ,strtou); - } else{ + strtou = simple_strtoul(pnext, &ptmp, 16); + sprintf(extra, "%s %d", extra, strtou); + } else { break; } pch = pnext; @@ -8265,13 +6927,12 @@ static int rtw_mp_start(struct net_device *dev, struct iw_point *wrqu, char *extra) { u8 val8; - struct adapter * padapter = rtw_netdev_priv(dev); + struct adapter *padapter = rtw_netdev_priv(dev); - if (padapter->registrypriv.mp_mode ==0) - { - padapter->registrypriv.mp_mode =1; + if (padapter->registrypriv.mp_mode == 0) { + padapter->registrypriv.mp_mode = 1; - rtw_pm_set_ips(padapter,IPS_NONE); + rtw_pm_set_ips(padapter, IPS_NONE); LeaveAllPowerSaveMode(padapter); MPT_InitializeAdapter(padapter, 1); @@ -8293,12 +6954,11 @@ static int rtw_mp_stop(struct net_device *dev, struct iw_request_info *info, struct iw_point *wrqu, char *extra) { - struct adapter * padapter = rtw_netdev_priv(dev); + struct adapter *padapter = rtw_netdev_priv(dev); - if (padapter->registrypriv.mp_mode ==1) - { + if (padapter->registrypriv.mp_mode == 1) { MPT_DeInitAdapter(padapter); - padapter->registrypriv.mp_mode=0; + padapter->registrypriv.mp_mode = 0; } if (padapter->mppriv.mode != MP_OFF) { @@ -8317,7 +6977,7 @@ static int rtw_mp_rate(struct net_device *dev, { u32 rate = MPT_RATE_1M; char *input = kmalloc(wrqu->length, GFP_KERNEL); - struct adapter * padapter = rtw_netdev_priv(dev); + struct adapter *padapter = rtw_netdev_priv(dev); if (!input) return -ENOMEM; @@ -8326,12 +6986,12 @@ static int rtw_mp_rate(struct net_device *dev, return -EFAULT; } rate = rtw_atoi(input); - sprintf(extra, "Set data rate to %d" , rate); + sprintf(extra, "Set data rate to %d", rate); kfree(input); if (rate <= 0x7f) rate = wifirate2_ratetbl_inx((u8)rate); else - rate =(rate-0x80+MPT_RATE_MCS0); + rate = (rate-0x80+MPT_RATE_MCS0); if (rate >= MPT_RATE_LAST) return -EINVAL; @@ -8347,8 +7007,7 @@ static int rtw_mp_channel(struct net_device *dev, struct iw_request_info *info, struct iw_point *wrqu, char *extra) { - - struct adapter * padapter = rtw_netdev_priv(dev); + struct adapter *padapter = rtw_netdev_priv(dev); char *input = kmalloc(wrqu->length, GFP_KERNEL); u32 channel = 1; @@ -8359,7 +7018,7 @@ static int rtw_mp_channel(struct net_device *dev, return -EFAULT; } channel = rtw_atoi(input); - sprintf(extra, "Change channel %d to channel %d", padapter->mppriv.channel , channel); + sprintf(extra, "Change channel %d to channel %d", padapter->mppriv.channel, channel); padapter->mppriv.channel = channel; Hal_SetChannel(padapter); @@ -8373,21 +7032,14 @@ static int rtw_mp_bandwidth(struct net_device *dev, struct iw_request_info *info, struct iw_point *wrqu, char *extra) { - u32 bandwidth=0, sg=0; - //u8 buffer[40]; - struct adapter * padapter = rtw_netdev_priv(dev); - //if (copy_from_user(buffer, (void*)wrqu->data.pointer, wrqu->data.length)) - // return -EFAULT; + u32 bandwidth = 0, sg = 0; + struct adapter *padapter = rtw_netdev_priv(dev); - //DBG_88E("%s:iwpriv in=%s\n", __func__, extra); - - sscanf(extra, "40M=%d,shortGI=%d", &bandwidth, &sg); + sscanf(extra, "40M =%d, shortGI =%d", &bandwidth, &sg); if (bandwidth != HT_CHANNEL_WIDTH_40) bandwidth = HT_CHANNEL_WIDTH_20; - //DBG_88E("%s: bw=%d sg=%d\n", __func__, bandwidth , sg); - padapter->mppriv.bandwidth = (u8)bandwidth; padapter->mppriv.preamble = sg; @@ -8400,9 +7052,9 @@ static int rtw_mp_txpower(struct net_device *dev, struct iw_request_info *info, struct iw_point *wrqu, char *extra) { - u32 idx_a=0,idx_b=0; + u32 idx_a = 0, idx_b = 0; char *input = kmalloc(wrqu->length, GFP_KERNEL); - struct adapter * padapter = rtw_netdev_priv(dev); + struct adapter *padapter = rtw_netdev_priv(dev); if (!input) return -ENOMEM; @@ -8410,9 +7062,9 @@ static int rtw_mp_txpower(struct net_device *dev, kfree(input); return -EFAULT; } - sscanf(input,"patha=%d,pathb=%d",&idx_a,&idx_b); + sscanf(input, "patha =%d, pathb =%d", &idx_a, &idx_b); - sprintf(extra, "Set power level path_A:%d path_B:%d", idx_a , idx_b); + sprintf(extra, "Set power level path_A:%d path_B:%d", idx_a, idx_b); padapter->mppriv.txpoweridx = (u8)idx_a; padapter->mppriv.txpoweridx_b = (u8)idx_b; padapter->mppriv.bSetTxPower = 1; @@ -8430,7 +7082,7 @@ static int rtw_mp_ant_tx(struct net_device *dev, u8 i; char *input = kmalloc(wrqu->length, GFP_KERNEL); u16 antenna = 0; - struct adapter * padapter = rtw_netdev_priv(dev); + struct adapter *padapter = rtw_netdev_priv(dev); if (!input) return -ENOMEM; @@ -8441,13 +7093,13 @@ static int rtw_mp_ant_tx(struct net_device *dev, sprintf(extra, "switch Tx antenna to %s", input); - for (i=0; i < strlen(input); i++) { + for (i = 0; i < strlen(input); i++) { switch (input[i]) { case 'a': - antenna|=ANTENNA_A; + antenna |= ANTENNA_A; break; case 'b': - antenna|=ANTENNA_B; + antenna |= ANTENNA_B; break; } } @@ -8467,7 +7119,7 @@ static int rtw_mp_ant_rx(struct net_device *dev, u8 i; u16 antenna = 0; char *input = kmalloc(wrqu->length, GFP_KERNEL); - struct adapter * padapter = rtw_netdev_priv(dev); + struct adapter *padapter = rtw_netdev_priv(dev); if (!input) return -ENOMEM; @@ -8479,13 +7131,13 @@ static int rtw_mp_ant_rx(struct net_device *dev, sprintf(extra, "switch Rx antenna to %s", input); - for (i=0; i < strlen(input); i++) { + for (i = 0; i < strlen(input); i++) { switch (input[i]) { - case 'a' : - antenna|=ANTENNA_A; + case 'a': + antenna |= ANTENNA_A; break; case 'b': - antenna|=ANTENNA_B; + antenna |= ANTENNA_B; break; } } @@ -8507,29 +7159,28 @@ static int rtw_mp_ctx(struct net_device *dev, struct mp_priv *pmp_priv; struct pkt_attrib *pattrib; - struct adapter * padapter = rtw_netdev_priv(dev); - + struct adapter *padapter = rtw_netdev_priv(dev); pmp_priv = &padapter->mppriv; if (copy_from_user(extra, wrqu->pointer, wrqu->length)) return -EFAULT; - DBG_88E("%s: in=%s\n", __func__, extra); + DBG_88E("%s: in =%s\n", __func__, extra); - countPkTx = strncmp(extra, "count=", 5); // strncmp true is 0 + countPkTx = strncmp(extra, "count =", 5); /* strncmp true is 0 */ cotuTx = strncmp(extra, "background", 20); - CarrSprTx = strncmp(extra, "background,cs", 20); - scTx = strncmp(extra, "background,sc", 20); - sgleTx = strncmp(extra, "background,stone", 20); - pkTx = strncmp(extra, "background,pkt", 20); + CarrSprTx = strncmp(extra, "background, cs", 20); + scTx = strncmp(extra, "background, sc", 20); + sgleTx = strncmp(extra, "background, stone", 20); + pkTx = strncmp(extra, "background, pkt", 20); stop = strncmp(extra, "stop", 4); - sscanf(extra, "count=%d,pkt", &count); + sscanf(extra, "count =%d, pkt", &count); _rtw_memset(extra, '\0', sizeof(extra)); if (stop == 0) { - bStartTest = 0; // To set Stop + bStartTest = 0; /* To set Stop */ pmp_priv->tx.stop = 1; sprintf(extra, "Stop continuous Tx"); } else { @@ -8553,83 +7204,60 @@ static int rtw_mp_ctx(struct net_device *dev, if (scTx == 0) pmp_priv->mode = MP_SINGLE_CARRIER_TX; - switch (pmp_priv->mode) - { - case MP_PACKET_TX: - - //DBG_88E("%s:pkTx %d\n", __func__,bStartTest); - if (bStartTest == 0) - { - pmp_priv->tx.stop = 1; - pmp_priv->mode = MP_ON; - sprintf(extra, "Stop continuous Tx"); - } - else if (pmp_priv->tx.stop == 1) - { - sprintf(extra, "Start continuous DA=ffffffffffff len=1500 count=%u,\n",count); - //DBG_88E("%s:countPkTx %d\n", __func__,count); - pmp_priv->tx.stop = 0; - pmp_priv->tx.count = count; - pmp_priv->tx.payload = 2; - pattrib = &pmp_priv->tx.attrib; - pattrib->pktlen = 1500; - _rtw_memset(pattrib->dst, 0xFF, ETH_ALEN); - SetPacketTx(padapter); - } - else { - //DBG_88E("%s: pkTx not stop\n", __func__); - return -EFAULT; - } - wrqu->length = strlen(extra); - return 0; - - case MP_SINGLE_TONE_TX: - //DBG_88E("%s: sgleTx %d\n", __func__, bStartTest); - if (bStartTest != 0){ - sprintf(extra, "Start continuous DA=ffffffffffff len=1500\n infinite=yes."); - } - Hal_SetSingleToneTx(padapter, (u8)bStartTest); - break; - - case MP_CONTINUOUS_TX: - //DBG_88E("%s: cotuTx %d\n", __func__, bStartTest); - if (bStartTest != 0){ - sprintf(extra, "Start continuous DA=ffffffffffff len=1500\n infinite=yes."); - } - Hal_SetContinuousTx(padapter, (u8)bStartTest); - break; - - case MP_CARRIER_SUPPRISSION_TX: - //DBG_88E("%s: CarrSprTx %d\n", __func__, bStartTest); - if (bStartTest != 0){ - if (pmp_priv->rateidx <= MPT_RATE_11M) - { - sprintf(extra, "Start continuous DA=ffffffffffff len=1500\n infinite=yes."); - Hal_SetCarrierSuppressionTx(padapter, (u8)bStartTest); - }else - sprintf(extra, "Specify carrier suppression but not CCK rate"); - } - break; - - case MP_SINGLE_CARRIER_TX: - //DBG_88E("%s: scTx %d\n", __func__, bStartTest); - if (bStartTest != 0){ - sprintf(extra, "Start continuous DA=ffffffffffff len=1500\n infinite=yes."); - } - Hal_SetSingleCarrierTx(padapter, (u8)bStartTest); - break; - - default: - //DBG_88E("%s:No Match MP_MODE\n", __func__); - sprintf(extra, "Error! Continuous-Tx is not on-going."); + switch (pmp_priv->mode) { + case MP_PACKET_TX: + if (bStartTest == 0) { + pmp_priv->tx.stop = 1; + pmp_priv->mode = MP_ON; + sprintf(extra, "Stop continuous Tx"); + } else if (pmp_priv->tx.stop == 1) { + sprintf(extra, "Start continuous DA = ffffffffffff len = 1500 count =%u,\n", count); + pmp_priv->tx.stop = 0; + pmp_priv->tx.count = count; + pmp_priv->tx.payload = 2; + pattrib = &pmp_priv->tx.attrib; + pattrib->pktlen = 1500; + _rtw_memset(pattrib->dst, 0xFF, ETH_ALEN); + SetPacketTx(padapter); + } else { return -EFAULT; + } + wrqu->length = strlen(extra); + return 0; + case MP_SINGLE_TONE_TX: + if (bStartTest != 0) + sprintf(extra, "Start continuous DA = ffffffffffff len = 1500\n infinite = yes."); + Hal_SetSingleToneTx(padapter, (u8)bStartTest); + break; + case MP_CONTINUOUS_TX: + if (bStartTest != 0) + sprintf(extra, "Start continuous DA = ffffffffffff len = 1500\n infinite = yes."); + Hal_SetContinuousTx(padapter, (u8)bStartTest); + break; + case MP_CARRIER_SUPPRISSION_TX: + if (bStartTest != 0) { + if (pmp_priv->rateidx <= MPT_RATE_11M) { + sprintf(extra, "Start continuous DA = ffffffffffff len = 1500\n infinite = yes."); + Hal_SetCarrierSuppressionTx(padapter, (u8)bStartTest); + } else { + sprintf(extra, "Specify carrier suppression but not CCK rate"); + } + } + break; + case MP_SINGLE_CARRIER_TX: + if (bStartTest != 0) + sprintf(extra, "Start continuous DA = ffffffffffff len = 1500\n infinite = yes."); + Hal_SetSingleCarrierTx(padapter, (u8)bStartTest); + break; + default: + sprintf(extra, "Error! Continuous-Tx is not on-going."); + return -EFAULT; } - if (bStartTest==1 && pmp_priv->mode != MP_ON) { + if (bStartTest == 1 && pmp_priv->mode != MP_ON) { struct mp_priv *pmp_priv = &padapter->mppriv; if (pmp_priv->tx.stop == 0) { pmp_priv->tx.stop = 1; - //DBG_88E("%s: pkt tx is running...\n", __func__); rtw_msleep_os(5); } pmp_priv->tx.stop = 0; @@ -8647,10 +7275,10 @@ static int rtw_mp_arx(struct net_device *dev, struct iw_request_info *info, struct iw_point *wrqu, char *extra) { - u8 bStartRx=0,bStopRx=0,bQueryPhy; - u32 cckok=0,cckcrc=0,ofdmok=0,ofdmcrc=0,htok=0,htcrc=0,OFDM_FA=0,CCK_FA=0; + u8 bStartRx = 0, bStopRx = 0, bQueryPhy; + u32 cckok = 0, cckcrc = 0, ofdmok = 0, ofdmcrc = 0, htok = 0, htcrc = 0, OFDM_FA = 0, CCK_FA = 0; char *input = kmalloc(wrqu->length, GFP_KERNEL); - struct adapter * padapter = rtw_netdev_priv(dev); + struct adapter *padapter = rtw_netdev_priv(dev); if (!input) return -ENOMEM; @@ -8661,16 +7289,16 @@ static int rtw_mp_arx(struct net_device *dev, } DBG_88E("%s: %s\n", __func__, input); - bStartRx = (strncmp(input, "start", 5)==0)?1:0; // strncmp true is 0 - bStopRx = (strncmp(input, "stop", 5)==0)?1:0; // strncmp true is 0 - bQueryPhy = (strncmp(input, "phy", 3)==0)?1:0; // strncmp true is 0 + bStartRx = (strncmp(input, "start", 5) == 0) ? 1 : 0; /* strncmp true is 0 */ + bStopRx = (strncmp(input, "stop", 5) == 0) ? 1 : 0; /* strncmp true is 0 */ + bQueryPhy = (strncmp(input, "phy", 3) == 0) ? 1 : 0; /* strncmp true is 0 */ if (bStartRx) { sprintf(extra, "start"); SetPacketRx(padapter, bStartRx); } else if (bStopRx) { SetPacketRx(padapter, 0); - sprintf(extra, "Received packet OK:%d CRC error:%d",padapter->mppriv.rx_pktcount,padapter->mppriv.rx_crcerrpktcount); + sprintf(extra, "Received packet OK:%d CRC error:%d", padapter->mppriv.rx_pktcount, padapter->mppriv.rx_crcerrpktcount); } else if (bQueryPhy) { /* OFDM FA @@ -8686,19 +7314,19 @@ static int rtw_mp_arx(struct net_device *dev, cckok = read_bbreg(padapter, 0xf88, 0xffffffff); cckcrc = read_bbreg(padapter, 0xf84, 0xffffffff); ofdmok = read_bbreg(padapter, 0xf94, 0x0000FFFF); - ofdmcrc = read_bbreg(padapter, 0xf94 , 0xFFFF0000); + ofdmcrc = read_bbreg(padapter, 0xf94, 0xFFFF0000); htok = read_bbreg(padapter, 0xf90, 0x0000FFFF); - htcrc = read_bbreg(padapter,0xf90, 0xFFFF0000); + htcrc = read_bbreg(padapter, 0xf90, 0xFFFF0000); - OFDM_FA=+read_bbreg(padapter, 0xcf0, 0x0000FFFF); - OFDM_FA=+read_bbreg(padapter, 0xcf2, 0xFFFF0000); - OFDM_FA=+read_bbreg(padapter, 0xda0, 0xFFFF0000); - OFDM_FA=+read_bbreg(padapter, 0xda4, 0x0000FFFF); - OFDM_FA=+read_bbreg(padapter, 0xda4, 0xFFFF0000); - OFDM_FA=+read_bbreg(padapter, 0xda8, 0x0000FFFF); - CCK_FA=(rtw_read8(padapter, 0xa5b)<<8) | (rtw_read8(padapter, 0xa5c)); + OFDM_FA = read_bbreg(padapter, 0xcf0, 0x0000FFFF); + OFDM_FA = read_bbreg(padapter, 0xcf2, 0xFFFF0000); + OFDM_FA = read_bbreg(padapter, 0xda0, 0xFFFF0000); + OFDM_FA = read_bbreg(padapter, 0xda4, 0x0000FFFF); + OFDM_FA = read_bbreg(padapter, 0xda4, 0xFFFF0000); + OFDM_FA = read_bbreg(padapter, 0xda8, 0x0000FFFF); + CCK_FA = (rtw_read8(padapter, 0xa5b)<<8) | (rtw_read8(padapter, 0xa5c)); - sprintf(extra, "Phy Received packet OK:%d CRC error:%d FA Counter: %d",cckok+ofdmok+htok,cckcrc+ofdmcrc+htcrc,OFDM_FA+CCK_FA); + sprintf(extra, "Phy Received packet OK:%d CRC error:%d FA Counter: %d", cckok+ofdmok+htok, cckcrc+ofdmcrc+htcrc, OFDM_FA+CCK_FA); } wrqu->length = strlen(extra) + 1; kfree(input); @@ -8709,21 +7337,19 @@ static int rtw_mp_trx_query(struct net_device *dev, struct iw_request_info *info, struct iw_point *wrqu, char *extra) { - u32 txok,txfail,rxok,rxfail; - struct adapter * padapter = rtw_netdev_priv(dev); - //if (copy_from_user(extra, wrqu->data.pointer, wrqu->data.length)) - // return -EFAULT; + u32 txok, txfail, rxok, rxfail; + struct adapter *padapter = rtw_netdev_priv(dev); - txok=padapter->mppriv.tx.sended; - txfail=0; + txok = padapter->mppriv.tx.sended; + txfail = 0; rxok = padapter->mppriv.rx_pktcount; rxfail = padapter->mppriv.rx_crcerrpktcount; _rtw_memset(extra, '\0', 128); - sprintf(extra, "Tx OK:%d, Tx Fail:%d, Rx OK:%d, CRC error:%d ", txok, txfail,rxok,rxfail); + sprintf(extra, "Tx OK:%d, Tx Fail:%d, Rx OK:%d, CRC error:%d ", txok, txfail, rxok, rxfail); - wrqu->length=strlen(extra)+1; + wrqu->length = strlen(extra)+1; return 0; } @@ -8735,7 +7361,7 @@ static int rtw_mp_pwrtrk(struct net_device *dev, u8 enable; u32 thermal; s32 ret; - struct adapter * padapter = rtw_netdev_priv(dev); + struct adapter *padapter = rtw_netdev_priv(dev); char *input = kmalloc(wrqu->length, GFP_KERNEL); if (!input) @@ -8747,14 +7373,15 @@ static int rtw_mp_pwrtrk(struct net_device *dev, _rtw_memset(extra, 0, wrqu->length); enable = 1; - if (wrqu->length > 1) { // not empty string + if (wrqu->length > 1) {/* not empty string */ if (strncmp(input, "stop", 4) == 0) { enable = 0; sprintf(extra, "mp tx power tracking stop"); - } else if (sscanf(input, "ther=%d", &thermal)) { + } else if (sscanf(input, "ther =%d", &thermal)) { ret = Hal_SetThermalMeter(padapter, (u8)thermal); - if (ret == _FAIL) return -EPERM; - sprintf(extra, "mp tx power tracking start,target value=%d ok ",thermal); + if (ret == _FAIL) + return -EPERM; + sprintf(extra, "mp tx power tracking start, target value =%d ok ", thermal); } else { kfree(input); return -EINVAL; @@ -8774,7 +7401,7 @@ static int rtw_mp_psd(struct net_device *dev, struct iw_request_info *info, struct iw_point *wrqu, char *extra) { - struct adapter * padapter = rtw_netdev_priv(dev); + struct adapter *padapter = rtw_netdev_priv(dev); char *input = kmalloc(wrqu->length, GFP_KERNEL); if (!input) @@ -8784,7 +7411,7 @@ static int rtw_mp_psd(struct net_device *dev, return -EFAULT; } - strcpy(extra,input); + strcpy(extra, input); wrqu->length = mp_query_psd(padapter, extra); kfree(input); @@ -8792,49 +7419,39 @@ static int rtw_mp_psd(struct net_device *dev, } static int rtw_mp_thermal(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *wrqu, char *extra) + struct iw_request_info *info, + struct iw_point *wrqu, char *extra) { u8 val; - u16 bwrite=1; - u16 addr=EEPROM_THERMAL_METER_88E; + u16 bwrite = 1; + u16 addr = EEPROM_THERMAL_METER_88E; - u16 cnt=1; - u16 max_available_size=0; - struct adapter * padapter = rtw_netdev_priv(dev); + u16 cnt = 1; + u16 max_available_size = 0; + struct adapter *padapter = rtw_netdev_priv(dev); if (copy_from_user(extra, wrqu->pointer, wrqu->length)) return -EFAULT; - //DBG_88E("print extra %s\n",extra); - - bwrite = strncmp(extra, "write", 6); // strncmp true is 0 + bwrite = strncmp(extra, "write", 6); /* strncmp true is 0 */ Hal_GetThermalMeter(padapter, &val); - if (bwrite == 0) - { - //DBG_88E("to write val:%d",val); + if (bwrite == 0) { EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_available_size, false); - if (2 > max_available_size) - { + if (2 > max_available_size) { DBG_88E("no available efuse!\n"); return -EFAULT; } - if (rtw_efuse_map_write(padapter, addr, cnt, &val) == _FAIL) - { + if (rtw_efuse_map_write(padapter, addr, cnt, &val) == _FAIL) { DBG_88E("rtw_efuse_map_write error\n"); return -EFAULT; - } - else - { + } else { sprintf(extra, " efuse write ok :%d", val); } - } - else - { + } else { sprintf(extra, "%d", val); - } + } wrqu->length = strlen(extra); return 0; @@ -8846,7 +7463,7 @@ static int rtw_mp_reset_stats(struct net_device *dev, { struct mp_priv *pmp_priv; struct pkt_attrib *pattrib; - struct adapter * padapter = rtw_netdev_priv(dev); + struct adapter *padapter = rtw_netdev_priv(dev); pmp_priv = &padapter->mppriv; @@ -8855,58 +7472,58 @@ static int rtw_mp_reset_stats(struct net_device *dev, pmp_priv->rx_pktcount = 0; pmp_priv->rx_crcerrpktcount = 0; - //reset phy counter - write_bbreg(padapter,0xf14,BIT16,0x1); + /* reset phy counter */ + write_bbreg(padapter, 0xf14, BIT16, 0x1); rtw_msleep_os(10); - write_bbreg(padapter,0xf14,BIT16,0x0); + write_bbreg(padapter, 0xf14, BIT16, 0x0); return 0; } static int rtw_mp_dump(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *wrqu, char *extra) + struct iw_request_info *info, + struct iw_point *wrqu, char *extra) { struct pkt_attrib *pattrib; - u32 value; - u8 rf_type,path_nums = 0; - u32 i,j=1,path; - struct adapter * padapter = rtw_netdev_priv(dev); + u32 value; + u8 rf_type, path_nums = 0; + u32 i, j = 1, path; + struct adapter *padapter = rtw_netdev_priv(dev); - //if (copy_from_user(extra, wrqu->data.pointer, wrqu->data.length)) - // return -EFAULT; - - if (strncmp(extra, "all", 4)==0) - { - DBG_88E("\n======= MAC REG =======\n"); - for (i=0x0;i<0x300;i+=4) - { - if (j%4==1) DBG_88E("0x%02x",i); - DBG_88E(" 0x%08x ",rtw_read32(padapter,i)); - if ((j++)%4 == 0) DBG_88E("\n"); + if (strncmp(extra, "all", 4) == 0) { + DBG_88E("\n ======= MAC REG =======\n"); + for (i = 0x0; i < 0x300; i += 4) { + if (j%4 == 1) + DBG_88E("0x%02x", i); + DBG_88E(" 0x%08x ", rtw_read32(padapter, i)); + if ((j++)%4 == 0) + DBG_88E("\n"); } - for (i=0x400;i<0x1000;i+=4) - { - if (j%4==1) DBG_88E("0x%02x",i); - DBG_88E(" 0x%08x ",rtw_read32(padapter,i)); - if ((j++)%4 == 0) DBG_88E("\n"); + for (i = 0x400; i < 0x1000; i += 4) { + if (j%4 == 1) + DBG_88E("0x%02x", i); + DBG_88E(" 0x%08x ", rtw_read32(padapter, i)); + if ((j++)%4 == 0) + DBG_88E("\n"); } - i,j=1; + i, j = 1; rtw_hal_get_hwreg(padapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type)); - DBG_88E("\n======= RF REG =======\n"); - if ((RF_1T2R == rf_type) ||(RF_1T1R ==rf_type)) + DBG_88E("\n ======= RF REG =======\n"); + if ((RF_1T2R == rf_type) || (RF_1T1R == rf_type)) path_nums = 1; else path_nums = 2; - for (path=0;pathlength, GFP_KERNEL); u32 valxcap; @@ -8929,14 +7545,14 @@ static int rtw_mp_phypara(struct net_device *dev, return -EFAULT; } - DBG_88E("%s:iwpriv in=%s\n", __func__, input); + DBG_88E("%s:iwpriv in =%s\n", __func__, input); - sscanf(input, "xcap=%d", &valxcap); + sscanf(input, "xcap =%d", &valxcap); kfree(input); if (!IS_HARDWARE_TYPE_8192D(padapter)) return 0; - sprintf(extra, "Set xcap=%d",valxcap); + sprintf(extra, "Set xcap =%d", valxcap); wrqu->length = strlen(extra) + 1; return 0; } @@ -8945,28 +7561,25 @@ static int rtw_mp_SetRFPath(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct adapter * padapter = rtw_netdev_priv(dev); + struct adapter *padapter = rtw_netdev_priv(dev); char *input = kmalloc(wrqu->data.length, GFP_KERNEL); - u8 bMain=1,bTurnoff=1; + u8 bMain = 1, bTurnoff = 1; if (!input) return -ENOMEM; if (copy_from_user(input, wrqu->data.pointer, wrqu->data.length)) return -EFAULT; - DBG_88E("%s:iwpriv in=%s\n", __func__, input); + DBG_88E("%s:iwpriv in =%s\n", __func__, input); - bMain = strncmp(input, "1", 2); // strncmp true is 0 - bTurnoff = strncmp(input, "0", 3); // strncmp true is 0 + bMain = strncmp(input, "1", 2); /* strncmp true is 0 */ + bTurnoff = strncmp(input, "0", 3); /* strncmp true is 0 */ - if (bMain==0) - { - MP_PHY_SetRFPathSwitch(padapter,true); - DBG_88E("%s:PHY_SetRFPathSwitch=true\n", __func__); - } - else if (bTurnoff==0) - { - MP_PHY_SetRFPathSwitch(padapter,false); - DBG_88E("%s:PHY_SetRFPathSwitch=false\n", __func__); + if (bMain == 0) { + MP_PHY_SetRFPathSwitch(padapter, true); + DBG_88E("%s:PHY_SetRFPathSwitch = true\n", __func__); + } else if (bTurnoff == 0) { + MP_PHY_SetRFPathSwitch(padapter, false); + DBG_88E("%s:PHY_SetRFPathSwitch = false\n", __func__); } kfree(input); return 0; @@ -8976,9 +7589,9 @@ static int rtw_mp_QueryDrv(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct adapter * padapter = rtw_netdev_priv(dev); + struct adapter *padapter = rtw_netdev_priv(dev); char *input = kmalloc(wrqu->data.length, GFP_KERNEL); - u8 qAutoLoad=1; + u8 qAutoLoad = 1; struct eeprom_priv *pEEPROM = GET_EEPROM_EFUSE_PRIV(padapter); if (!input) @@ -8986,17 +7599,17 @@ static int rtw_mp_QueryDrv(struct net_device *dev, if (copy_from_user(input, wrqu->data.pointer, wrqu->data.length)) return -EFAULT; - DBG_88E("%s:iwpriv in=%s\n", __func__, input); + DBG_88E("%s:iwpriv in =%s\n", __func__, input); - qAutoLoad = strncmp(input, "autoload", 8); // strncmp true is 0 + qAutoLoad = strncmp(input, "autoload", 8); /* strncmp true is 0 */ - if (qAutoLoad==0) { + if (qAutoLoad == 0) { DBG_88E("%s:qAutoLoad\n", __func__); if (pEEPROM->bautoload_fail_flag) sprintf(extra, "fail"); else - sprintf(extra, "ok"); + sprintf(extra, "ok"); } wrqu->data.length = strlen(extra) + 1; kfree(input); @@ -9008,189 +7621,152 @@ static int rtw_mp_antBdiff(struct net_device *dev, struct iw_request_info *info, struct iw_point *wrqu, char *extra) { - - - // MPT_ProSetTxAGCOffset + /* MPT_ProSetTxAGCOffset */ return 0; } static int rtw_mp_set(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wdata, char *extra) + struct iw_request_info *info, + union iwreq_data *wdata, char *extra) { struct iw_point *wrqu = (struct iw_point *)wdata; u32 subcmd = wrqu->flags; - struct adapter * padapter = rtw_netdev_priv(dev); + struct adapter *padapter = rtw_netdev_priv(dev); if (padapter == NULL) - { return -ENETDOWN; - } - //_rtw_memset(extra, 0x00, IW_PRIV_SIZE_MASK); - - if (extra == NULL) - { + if (extra == NULL) { wrqu->length = 0; return -EIO; } - switch (subcmd) - { + switch (subcmd) { case MP_START: - DBG_88E("set case mp_start\n"); - rtw_mp_start (dev,info,wrqu,extra); - break; - + DBG_88E("set case mp_start\n"); + rtw_mp_start(dev, info, wrqu, extra); + break; case MP_STOP: - DBG_88E("set case mp_stop\n"); - rtw_mp_stop (dev,info,wrqu,extra); - break; - + DBG_88E("set case mp_stop\n"); + rtw_mp_stop(dev, info, wrqu, extra); + break; case MP_BANDWIDTH: - DBG_88E("set case mp_bandwidth\n"); - rtw_mp_bandwidth (dev,info,wrqu,extra); - break; - + DBG_88E("set case mp_bandwidth\n"); + rtw_mp_bandwidth(dev, info, wrqu, extra); + break; case MP_RESET_STATS: - DBG_88E("set case MP_RESET_STATS\n"); - rtw_mp_reset_stats (dev,info,wrqu,extra); - break; - - + DBG_88E("set case MP_RESET_STATS\n"); + rtw_mp_reset_stats(dev, info, wrqu, extra); + break; case MP_SetRFPathSwh: - DBG_88E("set MP_SetRFPathSwitch\n"); - rtw_mp_SetRFPath (dev,info,wdata,extra); - break; + DBG_88E("set MP_SetRFPathSwitch\n"); + rtw_mp_SetRFPath(dev, info, wdata, extra); + break; case CTA_TEST: - DBG_88E("set CTA_TEST\n"); - rtw_cta_test_start (dev, info, wdata, extra); - break; + DBG_88E("set CTA_TEST\n"); + rtw_cta_test_start(dev, info, wdata, extra); + break; } - return 0; } - static int rtw_mp_get(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wdata, char *extra) { struct iw_point *wrqu = (struct iw_point *)wdata; u32 subcmd = wrqu->flags; - struct adapter * padapter = rtw_netdev_priv(dev); - - //DBG_88E("in mp_get extra= %s\n",extra); + struct adapter *padapter = rtw_netdev_priv(dev); if (padapter == NULL) - { return -ENETDOWN; - } - if (extra == NULL) - { + if (extra == NULL) { wrqu->length = 0; return -EIO; } - switch (subcmd) - { - case WRITE_REG : - rtw_mp_write_reg (dev,info,wrqu,extra); - break; - - case WRITE_RF: - rtw_mp_write_rf (dev,info,wrqu,extra); - break; - - case MP_PHYPARA: - DBG_88E("mp_get MP_PHYPARA\n"); - rtw_mp_phypara(dev,info,wrqu,extra); - break; - - case MP_CHANNEL: - DBG_88E("set case mp_channel\n"); - rtw_mp_channel (dev,info,wrqu,extra); - break; - - case READ_REG: - DBG_88E("mp_get READ_REG\n"); - rtw_mp_read_reg (dev,info,wrqu,extra); - break; - case READ_RF: - DBG_88E("mp_get READ_RF\n"); - rtw_mp_read_rf (dev,info,wrqu,extra); - break; - - case MP_RATE: - DBG_88E("set case mp_rate\n"); - rtw_mp_rate (dev,info,wrqu,extra); - break; - - case MP_TXPOWER: - DBG_88E("set case MP_TXPOWER\n"); - rtw_mp_txpower (dev,info,wrqu,extra); - break; - - case MP_ANT_TX: - DBG_88E("set case MP_ANT_TX\n"); - rtw_mp_ant_tx (dev,info,wrqu,extra); - break; - - case MP_ANT_RX: - DBG_88E("set case MP_ANT_RX\n"); - rtw_mp_ant_rx (dev,info,wrqu,extra); - break; - - case MP_QUERY: - //DBG_88E("mp_get mp_query MP_QUERY\n"); - rtw_mp_trx_query(dev,info,wrqu,extra); - break; - - case MP_CTX: - DBG_88E("set case MP_CTX\n"); - rtw_mp_ctx (dev,info,wrqu,extra); - break; - - case MP_ARX: - DBG_88E("set case MP_ARX\n"); - rtw_mp_arx (dev,info,wrqu,extra); - break; - - case EFUSE_GET: - DBG_88E("efuse get EFUSE_GET\n"); - rtw_mp_efuse_get(dev,info,wdata,extra); + switch (subcmd) { + case WRITE_REG: + rtw_mp_write_reg(dev, info, wrqu, extra); + break; + case WRITE_RF: + rtw_mp_write_rf(dev, info, wrqu, extra); + break; + case MP_PHYPARA: + DBG_88E("mp_get MP_PHYPARA\n"); + rtw_mp_phypara(dev, info, wrqu, extra); + break; + case MP_CHANNEL: + DBG_88E("set case mp_channel\n"); + rtw_mp_channel(dev, info, wrqu, extra); + break; + case READ_REG: + DBG_88E("mp_get READ_REG\n"); + rtw_mp_read_reg(dev, info, wrqu, extra); + break; + case READ_RF: + DBG_88E("mp_get READ_RF\n"); + rtw_mp_read_rf(dev, info, wrqu, extra); + break; + case MP_RATE: + DBG_88E("set case mp_rate\n"); + rtw_mp_rate(dev, info, wrqu, extra); + break; + case MP_TXPOWER: + DBG_88E("set case MP_TXPOWER\n"); + rtw_mp_txpower(dev, info, wrqu, extra); + break; + case MP_ANT_TX: + DBG_88E("set case MP_ANT_TX\n"); + rtw_mp_ant_tx(dev, info, wrqu, extra); + break; + case MP_ANT_RX: + DBG_88E("set case MP_ANT_RX\n"); + rtw_mp_ant_rx(dev, info, wrqu, extra); + break; + case MP_QUERY: + rtw_mp_trx_query(dev, info, wrqu, extra); + break; + case MP_CTX: + DBG_88E("set case MP_CTX\n"); + rtw_mp_ctx(dev, info, wrqu, extra); + break; + case MP_ARX: + DBG_88E("set case MP_ARX\n"); + rtw_mp_arx(dev, info, wrqu, extra); + break; + case EFUSE_GET: + DBG_88E("efuse get EFUSE_GET\n"); + rtw_mp_efuse_get(dev, info, wdata, extra); break; - case MP_DUMP: - DBG_88E("set case MP_DUMP\n"); - rtw_mp_dump (dev,info,wrqu,extra); + DBG_88E("set case MP_DUMP\n"); + rtw_mp_dump(dev, info, wrqu, extra); break; case MP_PSD: - DBG_88E("set case MP_PSD\n"); - rtw_mp_psd (dev,info,wrqu,extra); - break; - - case MP_THER: - DBG_88E("set case MP_THER\n"); - rtw_mp_thermal (dev,info,wrqu,extra); + DBG_88E("set case MP_PSD\n"); + rtw_mp_psd(dev, info, wrqu, extra); + break; + case MP_THER: + DBG_88E("set case MP_THER\n"); + rtw_mp_thermal(dev, info, wrqu, extra); break; - case MP_QueryDrvStats: - DBG_88E("mp_get MP_QueryDrvStats\n"); - rtw_mp_QueryDrv (dev,info,wdata,extra); - break; - case MP_PWRTRK: - DBG_88E("set case MP_PWRTRK\n"); - rtw_mp_pwrtrk (dev,info,wrqu,extra); - break; + DBG_88E("mp_get MP_QueryDrvStats\n"); + rtw_mp_QueryDrv (dev, info, wdata, extra); + break; + case MP_PWRTRK: + DBG_88E("set case MP_PWRTRK\n"); + rtw_mp_pwrtrk(dev, info, wrqu, extra); + break; case EFUSE_SET: - DBG_88E("set case efuse set\n"); - rtw_mp_efuse_set (dev,info,wdata,extra); - break; + DBG_88E("set case efuse set\n"); + rtw_mp_efuse_set(dev, info, wdata, extra); + break; } - rtw_msleep_os(10); //delay 5ms for sending pkt before exit adb shell operation + rtw_msleep_os(10); /* delay 5ms for sending pkt before exit adb shell operation */ return 0; } @@ -9208,7 +7784,6 @@ static int rtw_tdls_weaksec(struct net_device *dev, return 0; } - static int rtw_tdls_enable(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) @@ -9237,9 +7812,9 @@ static int rtw_tdls_discovery(struct net_device *dev, return 0; } -static int rtw_tdls_ch_switch (struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) +static int rtw_tdls_ch_switch(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { return 0; } @@ -9273,25 +7848,24 @@ static int rtw_tdls_getip(struct net_device *dev, } static int rtw_tdls_getport(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { return 0; - } -//WFDTDLS, for sigma test +/* WFDTDLS, for sigma test */ static int rtw_tdls_dis_result(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { return 0; } -//WFDTDLS, for sigma test +/* WFDTDLS, for sigma test */ static int rtw_wfd_tdls_status(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { return 0; } @@ -9310,7 +7884,6 @@ static int rtw_tdls(struct net_device *dev, return 0; } - static int rtw_tdls_get(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) @@ -9327,13 +7900,12 @@ static int rtw_test( u8 *pbuf, *pch; char *ptmp; u8 *delim = ","; - struct adapter * padapter = rtw_netdev_priv(dev); - + struct adapter *padapter = rtw_netdev_priv(dev); DBG_88E("+%s\n", __func__); len = wrqu->data.length; - pbuf = (u8*)rtw_zmalloc(len); + pbuf = (u8 *)rtw_zmalloc(len); if (pbuf == NULL) { DBG_88E("%s: no memory!\n", __func__); return -ENOMEM; @@ -9344,22 +7916,20 @@ static int rtw_test( DBG_88E("%s: copy from user fail!\n", __func__); return -EFAULT; } - DBG_88E("%s: string=\"%s\"\n", __func__, pbuf); + DBG_88E("%s: string =\"%s\"\n", __func__, pbuf); - ptmp = (char*)pbuf; + ptmp = (char *)pbuf; pch = strsep(&ptmp, delim); if ((pch == NULL) || (strlen(pch) == 0)) { rtw_mfree(pbuf, len); DBG_88E("%s: parameter error(level 1)!\n", __func__); return -EFAULT; } - rtw_mfree(pbuf, len); return 0; } -static iw_handler rtw_handlers[] = -{ +static iw_handler rtw_handlers[] = { NULL, /* SIOCSIWCOMMIT */ rtw_wx_get_name, /* SIOCGIWNAME */ dummy, /* SIOCSIWNWID */ @@ -9482,151 +8052,143 @@ static const struct iw_priv_args rtw_private_args[] = { }, { SIOCIWFIRSTPRIV + 0x11, - IW_PRIV_TYPE_CHAR | P2P_PRIVATE_IOCTL_SET_LEN, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | P2P_PRIVATE_IOCTL_SET_LEN , "p2p_get" + IW_PRIV_TYPE_CHAR | P2P_PRIVATE_IOCTL_SET_LEN, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | P2P_PRIVATE_IOCTL_SET_LEN, "p2p_get" }, { SIOCIWFIRSTPRIV + 0x12, - IW_PRIV_TYPE_CHAR | P2P_PRIVATE_IOCTL_SET_LEN, IW_PRIV_TYPE_CHAR | IFNAMSIZ , "p2p_get2" + IW_PRIV_TYPE_CHAR | P2P_PRIVATE_IOCTL_SET_LEN, IW_PRIV_TYPE_CHAR | IFNAMSIZ, "p2p_get2" }, - {SIOCIWFIRSTPRIV + 0x13, IW_PRIV_TYPE_CHAR | 128, 0,"NULL"}, + {SIOCIWFIRSTPRIV + 0x13, IW_PRIV_TYPE_CHAR | 128, 0, "NULL"}, { SIOCIWFIRSTPRIV + 0x14, IW_PRIV_TYPE_CHAR | 64, 0, "tdls" }, { SIOCIWFIRSTPRIV + 0x15, - IW_PRIV_TYPE_CHAR | P2P_PRIVATE_IOCTL_SET_LEN, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | P2P_PRIVATE_IOCTL_SET_LEN , "tdls_get" + IW_PRIV_TYPE_CHAR | P2P_PRIVATE_IOCTL_SET_LEN, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | P2P_PRIVATE_IOCTL_SET_LEN, "tdls_get" }, { SIOCIWFIRSTPRIV + 0x16, IW_PRIV_TYPE_CHAR | 64, 0, "pm_set" }, - {SIOCIWFIRSTPRIV + 0x18, IW_PRIV_TYPE_CHAR | IFNAMSIZ , 0 , "rereg_nd_name"}, + {SIOCIWFIRSTPRIV + 0x18, IW_PRIV_TYPE_CHAR | IFNAMSIZ, 0, "rereg_nd_name"}, {SIOCIWFIRSTPRIV + 0x1A, IW_PRIV_TYPE_CHAR | 1024, 0, "efuse_set"}, {SIOCIWFIRSTPRIV + 0x1B, IW_PRIV_TYPE_CHAR | 128, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "efuse_get"}, - { - SIOCIWFIRSTPRIV + 0x1D, - IW_PRIV_TYPE_CHAR | 40, IW_PRIV_TYPE_CHAR | 0x7FF, "test" + {SIOCIWFIRSTPRIV + 0x1D, IW_PRIV_TYPE_CHAR | 40, IW_PRIV_TYPE_CHAR | 0x7FF, "test" }, - - { SIOCIWFIRSTPRIV + 0x0E, IW_PRIV_TYPE_CHAR | 1024, 0 , ""}, //set - { SIOCIWFIRSTPRIV + 0x0F, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK , ""},//get + {SIOCIWFIRSTPRIV + 0x0E, IW_PRIV_TYPE_CHAR | 1024, 0, ""}, /* set */ + {SIOCIWFIRSTPRIV + 0x0F, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, ""},/* get */ /* --- sub-ioctls definitions --- */ - { MP_START , IW_PRIV_TYPE_CHAR | 1024, 0, "mp_start" }, //set - { MP_PHYPARA, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_phypara" },//get - { MP_STOP , IW_PRIV_TYPE_CHAR | 1024, 0, "mp_stop" }, //set - { MP_CHANNEL , IW_PRIV_TYPE_CHAR | 1024 , IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_channel" },//get - { MP_BANDWIDTH , IW_PRIV_TYPE_CHAR | 1024, 0, "mp_bandwidth"}, //set - { MP_RATE , IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_rate" },//get - { MP_RESET_STATS , IW_PRIV_TYPE_CHAR | 1024, 0, "mp_reset_stats"}, - { MP_QUERY , IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK , "mp_query"}, //get - { READ_REG , IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "read_reg" }, - { MP_RATE , IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_rate" }, - { READ_RF , IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "read_rf" }, - { MP_PSD , IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_psd"}, - { MP_DUMP, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_dump" }, - { MP_TXPOWER , IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_txpower"}, - { MP_ANT_TX , IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_ant_tx"}, - { MP_ANT_RX , IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_ant_rx"}, - { WRITE_REG , IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "write_reg" }, - { WRITE_RF , IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "write_rf" }, - { MP_CTX , IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_ctx"}, - { MP_ARX , IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_arx"}, - { MP_THER , IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_ther"}, - { EFUSE_SET, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "efuse_set" }, - { EFUSE_GET, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "efuse_get" }, - { MP_PWRTRK , IW_PRIV_TYPE_CHAR | 1024, 0, "mp_pwrtrk"}, - { MP_QueryDrvStats, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_drvquery" }, - { MP_IOCTL, IW_PRIV_TYPE_CHAR | 1024, 0, "mp_ioctl"}, // mp_ioctl - { MP_SetRFPathSwh, IW_PRIV_TYPE_CHAR | 1024, 0, "mp_setrfpath" }, - { CTA_TEST, IW_PRIV_TYPE_CHAR | 1024, 0, "cta_test"}, + {MP_START, IW_PRIV_TYPE_CHAR | 1024, 0, "mp_start"}, /* set */ + {MP_PHYPARA, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_phypara"},/* get */ + {MP_STOP, IW_PRIV_TYPE_CHAR | 1024, 0, "mp_stop"}, /* set */ + {MP_CHANNEL, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_channel"},/* get */ + {MP_BANDWIDTH, IW_PRIV_TYPE_CHAR | 1024, 0, "mp_bandwidth"}, /* set */ + {MP_RATE, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_rate"},/* get */ + {MP_RESET_STATS, IW_PRIV_TYPE_CHAR | 1024, 0, "mp_reset_stats"}, + {MP_QUERY, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_query"}, /* get */ + {READ_REG, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "read_reg"}, + {MP_RATE, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_rate"}, + {READ_RF, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "read_rf"}, + {MP_PSD, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_psd"}, + {MP_DUMP, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_dump"}, + {MP_TXPOWER, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_txpower"}, + {MP_ANT_TX, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_ant_tx"}, + {MP_ANT_RX, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_ant_rx"}, + {WRITE_REG, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "write_reg"}, + {WRITE_RF, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "write_rf"}, + {MP_CTX, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_ctx"}, + {MP_ARX, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_arx"}, + {MP_THER, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_ther"}, + {EFUSE_SET, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "efuse_set"}, + {EFUSE_GET, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "efuse_get"}, + {MP_PWRTRK, IW_PRIV_TYPE_CHAR | 1024, 0, "mp_pwrtrk"}, + {MP_QueryDrvStats, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_drvquery"}, + {MP_IOCTL, IW_PRIV_TYPE_CHAR | 1024, 0, "mp_ioctl"}, /* mp_ioctl */ + {MP_SetRFPathSwh, IW_PRIV_TYPE_CHAR | 1024, 0, "mp_setrfpath"}, + {CTA_TEST, IW_PRIV_TYPE_CHAR | 1024, 0, "cta_test"}, }; -static iw_handler rtw_private_handler[] = -{ - rtw_wx_write32, //0x00 - rtw_wx_read32, //0x01 - rtw_drvext_hdl, //0x02 - rtw_mp_ioctl_hdl, //0x03 +static iw_handler rtw_private_handler[] = { +rtw_wx_write32, /* 0x00 */ +rtw_wx_read32, /* 0x01 */ +rtw_drvext_hdl, /* 0x02 */ +rtw_mp_ioctl_hdl, /* 0x03 */ -// for MM DTV platform - rtw_get_ap_info, //0x04 +/* for MM DTV platform */ + rtw_get_ap_info, /* 0x04 */ - rtw_set_pid, //0x05 - rtw_wps_start, //0x06 + rtw_set_pid, /* 0x05 */ + rtw_wps_start, /* 0x06 */ - rtw_wx_get_sensitivity, //0x07 - rtw_wx_set_mtk_wps_probe_ie, //0x08 - rtw_wx_set_mtk_wps_ie, //0x09 + rtw_wx_get_sensitivity, /* 0x07 */ + rtw_wx_set_mtk_wps_probe_ie, /* 0x08 */ + rtw_wx_set_mtk_wps_ie, /* 0x09 */ -// Set Channel depend on the country code - rtw_wx_set_channel_plan, //0x0A +/* Set Channel depend on the country code */ + rtw_wx_set_channel_plan, /* 0x0A */ - rtw_dbg_port, //0x0B - rtw_wx_write_rf, //0x0C - rtw_wx_read_rf, //0x0D + rtw_dbg_port, /* 0x0B */ + rtw_wx_write_rf, /* 0x0C */ + rtw_wx_read_rf, /* 0x0D */ - rtw_mp_set, //0x0E - rtw_mp_get, //0x0F - rtw_p2p_set, //0x10 - rtw_p2p_get, //0x11 - rtw_p2p_get2, //0x12 + rtw_mp_set, /* 0x0E */ + rtw_mp_get, /* 0x0F */ + rtw_p2p_set, /* 0x10 */ + rtw_p2p_get, /* 0x11 */ + rtw_p2p_get2, /* 0x12 */ - NULL, //0x13 - rtw_tdls, //0x14 - rtw_tdls_get, //0x15 + NULL, /* 0x13 */ + rtw_tdls, /* 0x14 */ + rtw_tdls_get, /* 0x15 */ - rtw_pm_set, //0x16 - rtw_wx_priv_null, //0x17 - rtw_rereg_nd_name, //0x18 - rtw_wx_priv_null, //0x19 + rtw_pm_set, /* 0x16 */ + rtw_wx_priv_null, /* 0x17 */ + rtw_rereg_nd_name, /* 0x18 */ + rtw_wx_priv_null, /* 0x19 */ - rtw_mp_efuse_set, //0x1A - rtw_mp_efuse_get, //0x1B - NULL, // 0x1C is reserved for hostapd - rtw_test, // 0x1D + rtw_mp_efuse_set, /* 0x1A */ + rtw_mp_efuse_get, /* 0x1B */ + NULL, /* 0x1C is reserved for hostapd */ + rtw_test, /* 0x1D */ }; #if WIRELESS_EXT >= 17 static struct iw_statistics *rtw_get_wireless_stats(struct net_device *dev) { - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct iw_statistics *piwstats=&padapter->iwstats; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct iw_statistics *piwstats = &padapter->iwstats; int tmp_level = 0; int tmp_qual = 0; int tmp_noise = 0; - if (check_fwstate(&padapter->mlmepriv, _FW_LINKED) != true) - { + if (!check_fwstate(&padapter->mlmepriv, _FW_LINKED)) { piwstats->qual.qual = 0; piwstats->qual.level = 0; piwstats->qual.noise = 0; - //DBG_88E("No link level:%d, qual:%d, noise:%d\n", tmp_level, tmp_qual, tmp_noise); - } - else{ + } else { tmp_level = padapter->recvpriv.signal_strength; #ifdef CONFIG_BT_COEXIST { u8 signal = (u8)tmp_level; BT_SignalCompensation(padapter, &signal, NULL); - tmp_level= signal; + tmp_level = signal; } - #endif // CONFIG_BT_COEXIST + #endif /* CONFIG_BT_COEXIST */ tmp_qual = padapter->recvpriv.signal_qual; - tmp_noise =padapter->recvpriv.noise; - //DBG_88E("level:%d, qual:%d, noise:%d, rssi (%d)\n", tmp_level, tmp_qual, tmp_noise,padapter->recvpriv.rssi); + tmp_noise = padapter->recvpriv.noise; piwstats->qual.level = tmp_level; piwstats->qual.qual = tmp_qual; piwstats->qual.noise = tmp_noise; } -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,14)) - piwstats->qual.updated = IW_QUAL_ALL_UPDATED ;//|IW_QUAL_DBM; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 14)) + piwstats->qual.updated = IW_QUAL_ALL_UPDATED;/* IW_QUAL_DBM; */ #else piwstats->qual.updated = 0x0f; #endif @@ -9636,11 +8198,10 @@ static struct iw_statistics *rtw_get_wireless_stats(struct net_device *dev) #endif #ifdef CONFIG_WIRELESS_EXT -struct iw_handler_def rtw_handlers_def = -{ +struct iw_handler_def rtw_handlers_def = { .standard = rtw_handlers, .num_standard = sizeof(rtw_handlers) / sizeof(iw_handler), -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)) || defined(CONFIG_WEXT_PRIV) +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 33)) || defined(CONFIG_WEXT_PRIV) .private = rtw_private_handler, .private_args = (struct iw_priv_args *)rtw_private_args, .num_private = sizeof(rtw_private_handler) / sizeof(iw_handler), @@ -9652,20 +8213,20 @@ struct iw_handler_def rtw_handlers_def = }; #endif -// copy from net/wireless/wext.c start +/* copy from net/wireless/wext.c start */ /* ---------------------------------------------------------------- */ /* * Calculate size of private arguments */ static const char iw_priv_type_size[] = { - 0, /* IW_PRIV_TYPE_NONE */ - 1, /* IW_PRIV_TYPE_BYTE */ - 1, /* IW_PRIV_TYPE_CHAR */ - 0, /* Not defined */ - sizeof(__u32), /* IW_PRIV_TYPE_INT */ - sizeof(struct iw_freq), /* IW_PRIV_TYPE_FLOAT */ - sizeof(struct sockaddr), /* IW_PRIV_TYPE_ADDR */ - 0, /* Not defined */ + 0, /* IW_PRIV_TYPE_NONE */ + 1, /* IW_PRIV_TYPE_BYTE */ + 1, /* IW_PRIV_TYPE_CHAR */ + 0, /* Not defined */ + sizeof(__u32), /* IW_PRIV_TYPE_INT */ + sizeof(struct iw_freq), /* IW_PRIV_TYPE_FLOAT */ + sizeof(struct sockaddr), /* IW_PRIV_TYPE_ADDR */ + 0, /* Not defined */ }; static int get_priv_size(__u16 args) @@ -9675,7 +8236,7 @@ static int get_priv_size(__u16 args) return num * iw_priv_type_size[type]; } -// copy from net/wireless/wext.c end +/* copy from net/wireless/wext.c end */ static int rtw_ioctl_wext_private(struct net_device *dev, union iwreq_data *wrq_data) { @@ -9686,10 +8247,10 @@ static int rtw_ioctl_wext_private(struct net_device *dev, union iwreq_data *wrq_ u8 *output = NULL; u32 output_len = 0; u32 count = 0; - u8 *buffer= NULL; + u8 *buffer = NULL; u32 buffer_len = 0; char *ptr = NULL; - u8 cmdname[17] = {0}; // IFNAMSIZ+1 + u8 cmdname[17] = {0}; /* IFNAMSIZ+1 */ u32 cmdlen; s32 len; u8 *extra = NULL; @@ -9706,7 +8267,6 @@ static int rtw_ioctl_wext_private(struct net_device *dev, union iwreq_data *wrq_ union iwreq_data wdata; - _rtw_memcpy(&wdata, wrq_data, sizeof(wdata)); input_len = wdata.data.length; @@ -9722,14 +8282,14 @@ static int rtw_ioctl_wext_private(struct net_device *dev, union iwreq_data *wrq_ sscanf(ptr, "%16s", cmdname); cmdlen = strlen(cmdname); - DBG_88E("%s: cmd=%s\n", __func__, cmdname); + DBG_88E("%s: cmd =%s\n", __func__, cmdname); - // skip command string + /* skip command string */ if (cmdlen > 0) - cmdlen += 1; // skip one space + cmdlen += 1; /* skip one space */ ptr += cmdlen; len -= cmdlen; - DBG_88E("%s: parameters=%s\n", __func__, ptr); + DBG_88E("%s: parameters =%s\n", __func__, ptr); priv = rtw_private_handler; priv_args = rtw_private_args; @@ -9751,8 +8311,7 @@ static int rtw_ioctl_wext_private(struct net_device *dev, union iwreq_data *wrq_ } /* Watch out for sub-ioctls ! */ - if (priv_args[k].cmd < SIOCDEVPRIVATE) - { + if (priv_args[k].cmd < SIOCDEVPRIVATE) { int j = -1; /* Find the matching *real* ioctl */ @@ -9782,109 +8341,91 @@ static int rtw_ioctl_wext_private(struct net_device *dev, union iwreq_data *wrq_ /* If we have to set some data */ if ((priv_args[k].set_args & IW_PRIV_TYPE_MASK) && - (priv_args[k].set_args & IW_PRIV_SIZE_MASK)) - { + (priv_args[k].set_args & IW_PRIV_SIZE_MASK)) { u8 *str; - switch (priv_args[k].set_args & IW_PRIV_TYPE_MASK) - { - case IW_PRIV_TYPE_BYTE: - /* Fetch args */ - count = 0; - do { - str = strsep(&ptr, delim); - if (NULL == str) break; - sscanf(str, "%i", &temp); - buffer[count++] = (u8)temp; - } while (1); - buffer_len = count; - - /* Number of args to fetch */ - wdata.data.length = count; + switch (priv_args[k].set_args & IW_PRIV_TYPE_MASK) { + case IW_PRIV_TYPE_BYTE: + /* Fetch args */ + count = 0; + do { + str = strsep(&ptr, delim); + if (NULL == str) + break; + sscanf(str, "%i", &temp); + buffer[count++] = (u8)temp; + } while (1); + buffer_len = count; + /* Number of args to fetch */ + wdata.data.length = count; + if (wdata.data.length > (priv_args[k].set_args & IW_PRIV_SIZE_MASK)) + wdata.data.length = priv_args[k].set_args & IW_PRIV_SIZE_MASK; + break; + case IW_PRIV_TYPE_INT: + /* Fetch args */ + count = 0; + do { + str = strsep(&ptr, delim); + if (NULL == str) + break; + sscanf(str, "%i", &temp); + ((s32 *)buffer)[count++] = (s32)temp; + } while (1); + buffer_len = count * sizeof(s32); + /* Number of args to fetch */ + wdata.data.length = count; + if (wdata.data.length > (priv_args[k].set_args & IW_PRIV_SIZE_MASK)) + wdata.data.length = priv_args[k].set_args & IW_PRIV_SIZE_MASK; + break; + case IW_PRIV_TYPE_CHAR: + if (len > 0) { + /* Size of the string to fetch */ + wdata.data.length = len; if (wdata.data.length > (priv_args[k].set_args & IW_PRIV_SIZE_MASK)) wdata.data.length = priv_args[k].set_args & IW_PRIV_SIZE_MASK; - break; - - case IW_PRIV_TYPE_INT: - /* Fetch args */ - count = 0; - do { - str = strsep(&ptr, delim); - if (NULL == str) break; - sscanf(str, "%i", &temp); - ((s32*)buffer)[count++] = (s32)temp; - } while (1); - buffer_len = count * sizeof(s32); - - /* Number of args to fetch */ - wdata.data.length = count; - if (wdata.data.length > (priv_args[k].set_args & IW_PRIV_SIZE_MASK)) - wdata.data.length = priv_args[k].set_args & IW_PRIV_SIZE_MASK; - - break; - - case IW_PRIV_TYPE_CHAR: - if (len > 0) - { - /* Size of the string to fetch */ - wdata.data.length = len; - if (wdata.data.length > (priv_args[k].set_args & IW_PRIV_SIZE_MASK)) - wdata.data.length = priv_args[k].set_args & IW_PRIV_SIZE_MASK; - - /* Fetch string */ - _rtw_memcpy(buffer, ptr, wdata.data.length); - } - else - { - wdata.data.length = 1; - buffer[0] = '\0'; - } - buffer_len = wdata.data.length; - break; - - default: - DBG_88E("%s: Not yet implemented...\n", __func__); - err = -1; - goto exit; + /* Fetch string */ + _rtw_memcpy(buffer, ptr, wdata.data.length); + } else { + wdata.data.length = 1; + buffer[0] = '\0'; + } + buffer_len = wdata.data.length; + break; + default: + DBG_88E("%s: Not yet implemented...\n", __func__); + err = -1; + goto exit; } if ((priv_args[k].set_args & IW_PRIV_SIZE_FIXED) && - (wdata.data.length != (priv_args[k].set_args & IW_PRIV_SIZE_MASK))) - { + (wdata.data.length != (priv_args[k].set_args & IW_PRIV_SIZE_MASK))) { DBG_88E("%s: The command %s needs exactly %d argument(s)...\n", - __func__, cmdname, priv_args[k].set_args & IW_PRIV_SIZE_MASK); + __func__, cmdname, priv_args[k].set_args & IW_PRIV_SIZE_MASK); err = -EINVAL; goto exit; } - } /* if args to set */ - else - { + } else { + /* if args to set */ wdata.data.length = 0L; } /* Those two tests are important. They define how the driver * will have to handle the data */ if ((priv_args[k].set_args & IW_PRIV_SIZE_FIXED) && - ((get_priv_size(priv_args[k].set_args) + offset) <= IFNAMSIZ)) - { + ((get_priv_size(priv_args[k].set_args) + offset) <= IFNAMSIZ)) { /* First case : all SET args fit within wrq */ if (offset) wdata.mode = subcmd; _rtw_memcpy(wdata.name + offset, buffer, IFNAMSIZ - offset); - } - else - { + } else { if ((priv_args[k].set_args == 0) && - (priv_args[k].get_args & IW_PRIV_SIZE_FIXED) && - (get_priv_size(priv_args[k].get_args) <= IFNAMSIZ)) - { + (priv_args[k].get_args & IW_PRIV_SIZE_FIXED) && + (get_priv_size(priv_args[k].get_args) <= IFNAMSIZ)) { /* Second case : no SET args, GET args fit within wrq */ if (offset) wdata.mode = subcmd; - } - else - { + } else { /* Third case : args won't fit in wrq, or variable number of args */ if (copy_to_user(wdata.data.pointer, buffer, buffer_len)) { err = -EFAULT; @@ -9898,14 +8439,13 @@ static int rtw_ioctl_wext_private(struct net_device *dev, union iwreq_data *wrq_ input = NULL; extra_size = 0; - if (IW_IS_SET(priv_args[k].cmd)) - { + if (IW_IS_SET(priv_args[k].cmd)) { /* Size of set arguments */ extra_size = get_priv_size(priv_args[k].set_args); /* Does it fits in iwr ? */ if ((priv_args[k].set_args & IW_PRIV_SIZE_FIXED) && - ((extra_size + offset) <= IFNAMSIZ)) + ((extra_size + offset) <= IFNAMSIZ)) extra_size = 0; } else { /* Size of get arguments */ @@ -9913,31 +8453,31 @@ static int rtw_ioctl_wext_private(struct net_device *dev, union iwreq_data *wrq_ /* Does it fits in iwr ? */ if ((priv_args[k].get_args & IW_PRIV_SIZE_FIXED) && - (extra_size <= IFNAMSIZ)) + (extra_size <= IFNAMSIZ)) extra_size = 0; } if (extra_size == 0) { - extra = (u8*)&wdata; + extra = (u8 *)&wdata; rtw_mfree(buffer, 4096); buffer = NULL; - } else + } else { extra = buffer; + } handler = priv[priv_args[k].cmd - SIOCIWFIRSTPRIV]; err = handler(dev, NULL, &wdata, extra); /* If we have to get some data */ if ((priv_args[k].get_args & IW_PRIV_TYPE_MASK) && - (priv_args[k].get_args & IW_PRIV_SIZE_MASK)) - { + (priv_args[k].get_args & IW_PRIV_SIZE_MASK)) { int j; int n = 0; /* number of args */ u8 str[20] = {0}; /* Check where is the returned data */ if ((priv_args[k].get_args & IW_PRIV_SIZE_FIXED) && - (get_priv_size(priv_args[k].get_args) <= IFNAMSIZ)) + (get_priv_size(priv_args[k].get_args) <= IFNAMSIZ)) n = priv_args[k].get_args & IW_PRIV_SIZE_MASK; else n = wdata.data.length; @@ -9947,48 +8487,41 @@ static int rtw_ioctl_wext_private(struct net_device *dev, union iwreq_data *wrq_ err = -ENOMEM; goto exit; } - - switch (priv_args[k].get_args & IW_PRIV_TYPE_MASK) - { - case IW_PRIV_TYPE_BYTE: - /* Display args */ - for (j = 0; j < n; j++) - { - sprintf(str, "%d ", extra[j]); - len = strlen(str); - output_len = strlen(output); - if ((output_len + len + 1) > 4096) { - err = -E2BIG; - goto exit; - } - _rtw_memcpy(output+output_len, str, len); + switch (priv_args[k].get_args & IW_PRIV_TYPE_MASK) { + case IW_PRIV_TYPE_BYTE: + /* Display args */ + for (j = 0; j < n; j++) { + sprintf(str, "%d ", extra[j]); + len = strlen(str); + output_len = strlen(output); + if ((output_len + len + 1) > 4096) { + err = -E2BIG; + goto exit; } - break; - - case IW_PRIV_TYPE_INT: - /* Display args */ - for (j = 0; j < n; j++) - { - sprintf(str, "%d ", ((__s32*)extra)[j]); - len = strlen(str); - output_len = strlen(output); - if ((output_len + len + 1) > 4096) { - err = -E2BIG; - goto exit; - } - _rtw_memcpy(output+output_len, str, len); + _rtw_memcpy(output+output_len, str, len); + } + break; + case IW_PRIV_TYPE_INT: + /* Display args */ + for (j = 0; j < n; j++) { + sprintf(str, "%d ", ((__s32 *)extra)[j]); + len = strlen(str); + output_len = strlen(output); + if ((output_len + len + 1) > 4096) { + err = -E2BIG; + goto exit; } - break; - - case IW_PRIV_TYPE_CHAR: - /* Display args */ - _rtw_memcpy(output, extra, n); - break; - - default: - DBG_88E("%s: Not yet implemented...\n", __func__); - err = -1; - goto exit; + _rtw_memcpy(output+output_len, str, len); + } + break; + case IW_PRIV_TYPE_CHAR: + /* Display args */ + _rtw_memcpy(output, extra, n); + break; + default: + DBG_88E("%s: Not yet implemented...\n", __func__); + err = -1; + goto exit; } output_len = strlen(output) + 1; @@ -9997,9 +8530,8 @@ static int rtw_ioctl_wext_private(struct net_device *dev, union iwreq_data *wrq_ err = -EFAULT; goto exit; } - } /* if args to set */ - else - { + } else { + /* if args to set */ wrq_data->data.length = 0; } @@ -10018,28 +8550,26 @@ exit: int rtw_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) { struct iwreq *wrq = (struct iwreq *)rq; - int ret=0; + int ret = 0; - switch (cmd) - { - case RTL_IOCTL_WPA_SUPPLICANT: - ret = wpa_supplicant_ioctl(dev, &wrq->u.data); - break; + switch (cmd) { + case RTL_IOCTL_WPA_SUPPLICANT: + ret = wpa_supplicant_ioctl(dev, &wrq->u.data); + break; #ifdef CONFIG_AP_MODE - case RTL_IOCTL_HOSTAPD: - ret = rtw_hostapd_ioctl(dev, &wrq->u.data); - break; -#endif // CONFIG_AP_MODE - case SIOCDEVPRIVATE: - ret = rtw_ioctl_wext_private(dev, &wrq->u); - break; - case (SIOCDEVPRIVATE+1): - ret = rtw_android_priv_cmd(dev, rq, cmd); - break; - default: - ret = -EOPNOTSUPP; - break; + case RTL_IOCTL_HOSTAPD: + ret = rtw_hostapd_ioctl(dev, &wrq->u.data); + break; +#endif /* CONFIG_AP_MODE */ + case SIOCDEVPRIVATE: + ret = rtw_ioctl_wext_private(dev, &wrq->u); + break; + case (SIOCDEVPRIVATE+1): + ret = rtw_android_priv_cmd(dev, rq, cmd); + break; + default: + ret = -EOPNOTSUPP; + break; } - return ret; }