OSDN Git Service

Use the kernel's atomic operations directly
[android-x86/external-modules-rtl8723au.git] / os_dep / ioctl_cfg80211.c
index 6ab8cac..9c417c4 100644 (file)
@@ -695,7 +695,7 @@ static int set_group_key(_adapter *padapter, u8 *key, u8 alg, int keyid)
        pcmd->rspsz = 0;
 
 
-       _rtw_init_listhead(&pcmd->list);
+       INIT_LIST_HEAD(&pcmd->list);
 
        res = rtw_enqueue_cmd(pcmdpriv, pcmd);
 
@@ -1049,14 +1049,9 @@ _func_enter_;
                        goto exit;
                }
        } else {
-#ifdef CONFIG_WAPI_SUPPORT
-               if (strcmp(param->u.crypt.alg, "SMS4"))
-#endif
-               {
                ret = -EINVAL;
                goto exit;
        }
-       }
 
        if (strcmp(param->u.crypt.alg, "WEP") == 0)
        {
@@ -1194,73 +1189,6 @@ _func_enter_;
                }
        }
 
-#ifdef CONFIG_WAPI_SUPPORT
-       if (strcmp(param->u.crypt.alg, "SMS4") == 0)
-       {
-               PRT_WAPI_T                      pWapiInfo = &padapter->wapiInfo;
-               PRT_WAPI_STA_INFO       pWapiSta;
-               u8                                      WapiASUEPNInitialValueSrc[16] = {0x36,0x5C,0x36,0x5C,0x36,0x5C,0x36,0x5C,0x36,0x5C,0x36,0x5C,0x36,0x5C,0x36,0x5C} ;
-               u8                                      WapiAEPNInitialValueSrc[16] = {0x37,0x5C,0x36,0x5C,0x36,0x5C,0x36,0x5C,0x36,0x5C,0x36,0x5C,0x36,0x5C,0x36,0x5C} ;
-               u8                                      WapiAEMultiCastPNInitialValueSrc[16] = {0x36,0x5C,0x36,0x5C,0x36,0x5C,0x36,0x5C,0x36,0x5C,0x36,0x5C,0x36,0x5C,0x36,0x5C} ;
-
-               if(param->u.crypt.set_tx == 1)
-               {
-                       list_for_each_entry(pWapiSta, &pWapiInfo->wapiSTAUsedList, list) {
-                               if (!memcmp(pWapiSta->PeerMacAddr,
-                                           param->sta_addr, 6)) {
-                                       memcpy(pWapiSta->lastTxUnicastPN,WapiASUEPNInitialValueSrc,16);
-
-                                       pWapiSta->wapiUsk.bSet = true;
-                                       memcpy(pWapiSta->wapiUsk.dataKey,param->u.crypt.key,16);
-                                       memcpy(pWapiSta->wapiUsk.micKey,param->u.crypt.key+16,16);
-                                       pWapiSta->wapiUsk.keyId = param->u.crypt.idx ;
-                                       pWapiSta->wapiUsk.bTxEnable = true;
-
-                                       memcpy(pWapiSta->lastRxUnicastPNBEQueue,WapiAEPNInitialValueSrc,16);
-                                       memcpy(pWapiSta->lastRxUnicastPNBKQueue,WapiAEPNInitialValueSrc,16);
-                                       memcpy(pWapiSta->lastRxUnicastPNVIQueue,WapiAEPNInitialValueSrc,16);
-                                       memcpy(pWapiSta->lastRxUnicastPNVOQueue,WapiAEPNInitialValueSrc,16);
-                                       memcpy(pWapiSta->lastRxUnicastPN,WapiAEPNInitialValueSrc,16);
-                                       pWapiSta->wapiUskUpdate.bTxEnable = false;
-                                       pWapiSta->wapiUskUpdate.bSet = false;
-
-                                       if (psecuritypriv->sw_encrypt== false || psecuritypriv->sw_decrypt == false)
-                                       {
-                                               //set unicast key for ASUE
-                                               rtw_wapi_set_key(padapter, &pWapiSta->wapiUsk, pWapiSta, false, false);
-                                       }
-                               }
-                       }
-               }
-               else
-               {
-                       list_for_each_entry(pWapiSta, &pWapiInfo->wapiSTAUsedList, list) {
-                               if (!memcmp(pWapiSta->PeerMacAddr,
-                                           get_bssid(pmlmepriv), 6)) {
-                                       pWapiSta->wapiMsk.bSet = true;
-                                       memcpy(pWapiSta->wapiMsk.dataKey,param->u.crypt.key,16);
-                                       memcpy(pWapiSta->wapiMsk.micKey,param->u.crypt.key+16,16);
-                                       pWapiSta->wapiMsk.keyId = param->u.crypt.idx ;
-                                       pWapiSta->wapiMsk.bTxEnable = false;
-                                       if(!pWapiSta->bSetkeyOk)
-                                               pWapiSta->bSetkeyOk = true;
-                                       pWapiSta->bAuthenticateInProgress = false;
-
-                                       memcpy(pWapiSta->lastRxMulticastPN, WapiAEMultiCastPNInitialValueSrc, 16);
-
-                                       if (psecuritypriv->sw_decrypt == false)
-                                       {
-                                               //set rx broadcast key for ASUE
-                                               rtw_wapi_set_key(padapter, &pWapiSta->wapiMsk, pWapiSta, true, false);
-                                       }
-                               }
-
-                       }
-               }
-       }
-#endif
-
-
 exit:
 
        DBG_8723A("%s, ret=%d\n", __func__, ret);
@@ -1322,22 +1250,6 @@ static int cfg80211_rtw_add_key(struct wiphy *wiphy, struct net_device *ndev,
                alg_name = "CCMP";
                break;
 
-#ifdef CONFIG_WAPI_SUPPORT
-       case WLAN_CIPHER_SUITE_SMS4:
-               alg_name= "SMS4";
-               if(pairwise == NL80211_KEYTYPE_PAIRWISE) {
-                       if (key_index != 0 && key_index != 1) {
-                               ret = -ENOTSUPP;
-                               goto addkey_end;
-                       }
-                       memcpy((void*)param->sta_addr, (void*)mac_addr, ETH_ALEN);
-               } else {
-                       DBG_8723A("mac_addr is null \n");
-               }
-               DBG_8723A("rtw_wx_set_enc_ext: SMS4 case \n");
-               break;
-#endif
-
        default:
                ret = -ENOTSUPP;
                goto addkey_end;
@@ -2208,11 +2120,6 @@ static int rtw_cfg80211_set_auth_type(struct security_priv *psecuritypriv,
                if(psecuritypriv->ndisauthtype>Ndis802_11AuthModeWPA)
                        psecuritypriv->dot11AuthAlgrthm = dot11AuthAlgrthm_8021X;
 
-#ifdef CONFIG_WAPI_SUPPORT
-               if(psecuritypriv->ndisauthtype == Ndis802_11AuthModeWAPI)
-                       psecuritypriv->dot11AuthAlgrthm = dot11AuthAlgrthm_WAPI;
-#endif
-
                break;
        case NL80211_AUTHTYPE_SHARED_KEY:
 
@@ -2251,12 +2158,6 @@ static int rtw_cfg80211_set_cipher(struct security_priv *psecuritypriv, u32 ciph
        case IW_AUTH_CIPHER_NONE:
                *profile_cipher = _NO_PRIVACY_;
                ndisencryptstatus = Ndis802_11EncryptionDisabled;
-#ifdef CONFIG_WAPI_SUPPORT
-               if(psecuritypriv->dot11PrivacyAlgrthm ==_SMS4_ )
-               {
-                       *profile_cipher = _SMS4_;
-               }
-#endif
                break;
        case WLAN_CIPHER_SUITE_WEP40:
                *profile_cipher = _WEP40_;
@@ -2274,12 +2175,6 @@ static int rtw_cfg80211_set_cipher(struct security_priv *psecuritypriv, u32 ciph
                *profile_cipher = _AES_;
                ndisencryptstatus = Ndis802_11Encryption3Enabled;
                break;
-#ifdef CONFIG_WAPI_SUPPORT
-       case WLAN_CIPHER_SUITE_SMS4:
-               *profile_cipher = _SMS4_;
-               ndisencryptstatus = Ndis802_11_EncrypteionWAPI;
-               break;
-#endif
        default:
                DBG_8723A("Unsupported cipher: 0x%x\n", cipher);
                return -ENOTSUPP;
@@ -2305,18 +2200,7 @@ static int rtw_cfg80211_set_key_mgt(struct security_priv *psecuritypriv, u32 key
                psecuritypriv->dot11AuthAlgrthm = dot11AuthAlgrthm_8021X;
        else if (key_mgt == WLAN_AKM_SUITE_PSK) {
                psecuritypriv->dot11AuthAlgrthm = dot11AuthAlgrthm_8021X;
-       }
-#ifdef CONFIG_WAPI_SUPPORT
-       else if(key_mgt ==WLAN_AKM_SUITE_WAPI_PSK){
-               psecuritypriv->dot11AuthAlgrthm = dot11AuthAlgrthm_WAPI;
-       }
-       else if(key_mgt ==WLAN_AKM_SUITE_WAPI_CERT){
-               psecuritypriv->dot11AuthAlgrthm = dot11AuthAlgrthm_WAPI;
-       }
-#endif
-
-
-       else {
+       } else {
                DBG_8723A("Invalid key mgt: 0x%x\n", key_mgt);
                //return -EINVAL;
        }
@@ -2720,31 +2604,12 @@ static int cfg80211_rtw_connect(struct wiphy *wiphy, struct net_device *ndev,
        psecuritypriv->dot11AuthAlgrthm = dot11AuthAlgrthm_Open; //open system
        psecuritypriv->ndisauthtype = Ndis802_11AuthModeOpen;
 
-#ifdef CONFIG_WAPI_SUPPORT
-        padapter->wapiInfo.bWapiEnable = false;
-#endif
-
        ret = rtw_cfg80211_set_wpa_version(psecuritypriv, sme->crypto.wpa_versions);
        if (ret < 0)
                goto exit;
 
-#ifdef CONFIG_WAPI_SUPPORT
-       if(sme->crypto.wpa_versions & NL80211_WAPI_VERSION_1)
-       {
-               padapter->wapiInfo.bWapiEnable = true;
-               padapter->wapiInfo.extra_prefix_len = WAPI_EXT_LEN;
-               padapter->wapiInfo.extra_postfix_len = SMS4_MIC_LEN;
-       }
-#endif
-
        ret = rtw_cfg80211_set_auth_type(psecuritypriv, sme->auth_type);
 
-#ifdef CONFIG_WAPI_SUPPORT
-       if(psecuritypriv->dot11AuthAlgrthm == dot11AuthAlgrthm_WAPI)
-               padapter->mlmeextpriv.mlmext_info.auth_algo = psecuritypriv->dot11AuthAlgrthm;
-#endif
-
-
        if (ret < 0)
                goto exit;
 
@@ -2833,15 +2698,6 @@ static int cfg80211_rtw_connect(struct wiphy *wiphy, struct net_device *ndev,
                        goto exit;
        }
 
-#ifdef CONFIG_WAPI_SUPPORT
-      if(sme->crypto.akm_suites[0] ==WLAN_AKM_SUITE_WAPI_PSK){
-               padapter->wapiInfo.bWapiPSK = true;
-       }
-       else if(sme->crypto.akm_suites[0] ==WLAN_AKM_SUITE_WAPI_CERT){
-             padapter->wapiInfo.bWapiPSK = false;
-       }
-#endif
-
        authmode = psecuritypriv->ndisauthtype;
        rtw_set_802_11_authentication_mode(padapter, authmode);
 
@@ -3373,7 +3229,6 @@ static int rtw_cfg80211_monitor_if_set_mac_address(struct net_device *ndev, void
        return ret;
 }
 
-#if (LINUX_VERSION_CODE>=KERNEL_VERSION(2,6,29))
 static const struct net_device_ops rtw_cfg80211_monitor_if_ops = {
        .ndo_open = rtw_cfg80211_monitor_if_open,
        .ndo_stop = rtw_cfg80211_monitor_if_close,
@@ -3383,7 +3238,6 @@ static const struct net_device_ops rtw_cfg80211_monitor_if_ops = {
        #endif
        .ndo_set_mac_address = rtw_cfg80211_monitor_if_set_mac_address,
 };
-#endif
 
 static int rtw_cfg80211_add_monitor_if(_adapter *padapter, char *name, struct net_device **ndev)
 {
@@ -3418,14 +3272,7 @@ static int rtw_cfg80211_add_monitor_if(_adapter *padapter, char *name, struct ne
        mon_ndev->name[IFNAMSIZ - 1] = 0;
        mon_ndev->destructor = rtw_ndev_destructor;
 
-#if (LINUX_VERSION_CODE>=KERNEL_VERSION(2,6,29))
        mon_ndev->netdev_ops = &rtw_cfg80211_monitor_if_ops;
-#else
-       mon_ndev->open = rtw_cfg80211_monitor_if_open;
-       mon_ndev->stop = rtw_cfg80211_monitor_if_close;
-       mon_ndev->hard_start_xmit = rtw_cfg80211_monitor_if_xmit_entry;
-       mon_ndev->set_mac_address = rtw_cfg80211_monitor_if_set_mac_address;
-#endif
 
        pnpi = netdev_priv(mon_ndev);
        pnpi->priv = padapter;
@@ -3827,7 +3674,7 @@ static int        cfg80211_rtw_del_station(struct wiphy *wiphy, struct net_device *ndev
                        {
                                DBG_8723A("free psta=%p, aid=%d\n", psta, psta->aid);
 
-                               rtw_list_delete(&psta->asoc_list);
+                               list_del_init(&psta->asoc_list);
                                pstapriv->asoc_list_cnt--;
 
                                //spin_unlock_bh(&pstapriv->asoc_list_lock);
@@ -4281,7 +4128,7 @@ static s32 cfg80211_rtw_remain_on_channel(struct wiphy *wiphy,
                _cancel_timer_ex(&padapter->cfg80211_wdinfo.remain_on_ch_timer);
 
 #ifdef CONFIG_CONCURRENT_MODE
-                ATOMIC_SET(&pwdev_priv->ro_ch_to, 1);
+                atomic_set(&pwdev_priv->ro_ch_to, 1);
 #endif //CONFIG_CONCURRENT_MODE
 
                p2p_protocol_wk_hdl(padapter, P2P_RO_CH_WK);
@@ -4347,13 +4194,13 @@ static s32 cfg80211_rtw_remain_on_channel(struct wiphy *wiphy,
 
                        if(remain_ch != pbuddy_mlmeext->cur_channel)
                        {
-                               if(ATOMIC_READ(&pwdev_priv->switch_ch_to)==1 ||
+                               if(atomic_read(&pwdev_priv->switch_ch_to)==1 ||
                                        (remain_ch != pmlmeext->cur_channel))
                                {
                                        DBG_8723A("%s, issue nulldata pwrbit=1\n", __func__);
                                        issue_nulldata(padapter->pbuddy_adapter, NULL, 1, 3, 500);
 
-                                       ATOMIC_SET(&pwdev_priv->switch_ch_to, 0);
+                                       atomic_set(&pwdev_priv->switch_ch_to, 0);
 
                                        DBG_8723A("%s, set switch ch timer, duration=%d\n", __func__, duration-pwdinfo->ext_listen_interval);
                                        _set_timer(&pwdinfo->ap_p2p_switch_timer, duration-pwdinfo->ext_listen_interval);
@@ -4378,11 +4225,11 @@ static s32 cfg80211_rtw_remain_on_channel(struct wiphy *wiphy,
 
        //call this after other things have been done
 #ifdef CONFIG_CONCURRENT_MODE
-       if(ATOMIC_READ(&pwdev_priv->ro_ch_to)==1 ||
+       if(atomic_read(&pwdev_priv->ro_ch_to)==1 ||
                (remain_ch != pmlmeext->cur_channel))
        {
                u8 co_channel = 0xff;
-               ATOMIC_SET(&pwdev_priv->ro_ch_to, 0);
+               atomic_set(&pwdev_priv->ro_ch_to, 0);
 #endif
 
                if(ready_on_channel == _TRUE)
@@ -4434,7 +4281,7 @@ static s32 cfg80211_rtw_cancel_remain_on_channel(struct wiphy *wiphy,
                DBG_8723A("%s, cancel ro ch timer\n", __func__);
                _cancel_timer_ex(&padapter->cfg80211_wdinfo.remain_on_ch_timer);
                #ifdef CONFIG_CONCURRENT_MODE
-               ATOMIC_SET(&pwdev_priv->ro_ch_to, 1);
+               atomic_set(&pwdev_priv->ro_ch_to, 1);
                #endif
                p2p_protocol_wk_hdl(padapter, P2P_RO_CH_WK);
        }
@@ -4515,11 +4362,11 @@ static int _cfg80211_rtw_mgmt_tx(_adapter *padapter, u8 tx_ch, const u8 *buf, si
                co_channel = rtw_get_oper_ch(padapter);
 
                if (tx_ch != pbuddy_mlmeext->cur_channel) {
-                       if (ATOMIC_READ(&pwdev_priv->switch_ch_to)==1) {
+                       if (atomic_read(&pwdev_priv->switch_ch_to)==1) {
                                DBG_8723A("%s, issue nulldata pwrbit=1\n", __func__);
                                issue_nulldata(padapter->pbuddy_adapter, NULL, 1, 3, 500);
 
-                               ATOMIC_SET(&pwdev_priv->switch_ch_to, 0);
+                               atomic_set(&pwdev_priv->switch_ch_to, 0);
 
                                //DBG_8723A("%s, set switch ch timer, period=%d\n", __func__, pwdinfo->ext_listen_period);
                                //_set_timer(&pwdinfo->ap_p2p_switch_timer, pwdinfo->ext_listen_period);
@@ -5167,8 +5014,8 @@ static void rtw_cfg80211_init_ht_capab(struct ieee80211_sta_ht_cap *ht_cap, enum
        ht_cap->ht_supported = _TRUE;
 
        ht_cap->cap = IEEE80211_HT_CAP_SUP_WIDTH_20_40 |
-                                       IEEE80211_HT_CAP_SGI_40 | IEEE80211_HT_CAP_SGI_20 |
-                                       IEEE80211_HT_CAP_DSSSCCK40 | IEEE80211_HT_CAP_MAX_AMSDU;
+               IEEE80211_HT_CAP_SGI_40 | IEEE80211_HT_CAP_SGI_20 |
+               IEEE80211_HT_CAP_DSSSCCK40 | IEEE80211_HT_CAP_MAX_AMSDU;
 
        /*
         *Maximum length of AMPDU that the STA can receive.
@@ -5387,8 +5234,8 @@ int rtw_wdev_alloc(_adapter *padapter, struct device *dev)
                pwdev_priv->power_mgmt = _FALSE;
 
 #ifdef CONFIG_CONCURRENT_MODE
-       ATOMIC_SET(&pwdev_priv->switch_ch_to, 1);
-       ATOMIC_SET(&pwdev_priv->ro_ch_to, 1);
+       atomic_set(&pwdev_priv->switch_ch_to, 1);
+       atomic_set(&pwdev_priv->ro_ch_to, 1);
 #endif
 
        return ret;