staging: rtl8723au: Move rtw_set_802_11_ssid23a() to ioctl_cfg80211.c
authorJes Sorensen <Jes.Sorensen@redhat.com>
Mon, 9 Jun 2014 13:16:39 +0000 (15:16 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 18 Jun 2014 21:00:20 +0000 (14:00 -0700)
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/rtl8723au/core/rtw_ioctl_set.c
drivers/staging/rtl8723au/include/rtw_ioctl_set.h
drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c

index 5c3b561..7b0d3db 100644 (file)
@@ -151,141 +151,6 @@ exit:
        return ret;
 }
 
-int rtw_set_802_11_ssid23a(struct rtw_adapter* padapter,
-                          struct cfg80211_ssid *ssid)
-{
-       int status = _SUCCESS;
-       u32 cur_time = 0;
-
-       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-       struct wlan_network *pnetwork = &pmlmepriv->cur_network;
-
-
-
-       DBG_8723A_LEVEL(_drv_always_, "set ssid [%s] fw_state = 0x%08x\n",
-                       ssid->ssid, get_fwstate(pmlmepriv));
-
-       if (padapter->hw_init_completed == false) {
-               RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_,
-                        ("set_ssid: hw_init_completed == false =>exit!!!\n"));
-               status = _FAIL;
-               goto exit;
-       }
-
-       spin_lock_bh(&pmlmepriv->lock);
-
-       DBG_8723A("Set SSID under fw_state = 0x%08x\n", get_fwstate(pmlmepriv));
-       if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY))
-               goto handle_tkip_countermeasure;
-       else if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING))
-               goto release_mlme_lock;
-
-       if (check_fwstate(pmlmepriv, _FW_LINKED|WIFI_ADHOC_MASTER_STATE)) {
-               RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_,
-                        ("set_ssid: _FW_LINKED||WIFI_ADHOC_MASTER_STATE\n"));
-
-               if ((pmlmepriv->assoc_ssid.ssid_len == ssid->ssid_len) &&
-                   !memcmp(&pmlmepriv->assoc_ssid.ssid, ssid->ssid,
-                           ssid->ssid_len)) {
-                       if (!check_fwstate(pmlmepriv, WIFI_STATION_STATE)) {
-                               RT_TRACE(_module_rtl871x_ioctl_set_c_,
-                                        _drv_err_, ("New SSID is same SSID, "
-                                                    "fw_state = 0x%08x\n",
-                                                    get_fwstate(pmlmepriv)));
-
-                               if (rtw_is_same_ibss23a(padapter, pnetwork)) {
-                                       /*
-                                        * it means driver is in
-                                        * WIFI_ADHOC_MASTER_STATE, we needn't
-                                        * create bss again.
-                                        */
-                                       goto release_mlme_lock;
-                               }
-
-                               /*
-                                * if in WIFI_ADHOC_MASTER_STATE |
-                                * WIFI_ADHOC_STATE, create bss or
-                                * rejoin again
-                                */
-                               rtw_disassoc_cmd23a(padapter, 0, true);
-
-                               if (check_fwstate(pmlmepriv, _FW_LINKED))
-                                       rtw_indicate_disconnect23a(padapter);
-
-                               rtw_free_assoc_resources23a(padapter, 1);
-
-                               if (check_fwstate(pmlmepriv,
-                                                 WIFI_ADHOC_MASTER_STATE)) {
-                                       _clr_fwstate_(pmlmepriv,
-                                                     WIFI_ADHOC_MASTER_STATE);
-                                       set_fwstate(pmlmepriv,
-                                                   WIFI_ADHOC_STATE);
-                               }
-                       } else {
-                               rtw_lps_ctrl_wk_cmd23a(padapter, LPS_CTRL_JOINBSS, 1);
-                       }
-               } else {
-                       RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_,
-                                ("Set SSID not the same ssid\n"));
-                       RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_,
-                                ("set_ssid =[%s] len = 0x%x\n", ssid->ssid,
-                                 (unsigned int)ssid->ssid_len));
-                       RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_,
-                                ("assoc_ssid =[%s] len = 0x%x\n",
-                                 pmlmepriv->assoc_ssid.ssid,
-                                 (unsigned int)pmlmepriv->assoc_ssid.ssid_len));
-
-                       rtw_disassoc_cmd23a(padapter, 0, true);
-
-                       if (check_fwstate(pmlmepriv, _FW_LINKED))
-                               rtw_indicate_disconnect23a(padapter);
-
-                       rtw_free_assoc_resources23a(padapter, 1);
-
-                       if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) {
-                               _clr_fwstate_(pmlmepriv, WIFI_ADHOC_MASTER_STATE);
-                               set_fwstate(pmlmepriv, WIFI_ADHOC_STATE);
-                       }
-               }
-       }
-
-handle_tkip_countermeasure:
-
-       if (padapter->securitypriv.btkip_countermeasure == true) {
-               cur_time = jiffies;
-
-               if ((cur_time - padapter->securitypriv.btkip_countermeasure_time) > 60 * HZ)
-               {
-                       padapter->securitypriv.btkip_countermeasure = false;
-                       padapter->securitypriv.btkip_countermeasure_time = 0;
-               }
-               else
-               {
-                       status = _FAIL;
-                       goto release_mlme_lock;
-               }
-       }
-
-       memcpy(&pmlmepriv->assoc_ssid, ssid, sizeof(struct cfg80211_ssid));
-       pmlmepriv->assoc_by_bssid = false;
-
-       if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY))
-               pmlmepriv->to_join = true;
-       else
-               status = rtw_do_join23a(padapter);
-
-release_mlme_lock:
-       spin_unlock_bh(&pmlmepriv->lock);
-
-exit:
-       RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_,
-               ("-rtw_set_802_11_ssid23a: status =%d\n", status));
-
-
-
-       return status;
-}
-
 int rtw_set_802_11_bssid23a_list_scan(struct rtw_adapter *padapter,
                                      struct cfg80211_ssid *pssid,
                                      int ssid_max_num)
index bc5805a..14a36f5 100644 (file)
@@ -20,8 +20,6 @@
 int rtw_set_802_11_bssid23a_list_scan(struct rtw_adapter *padapter,
                                      struct cfg80211_ssid *pssid,
                                      int ssid_max_num);
-int rtw_set_802_11_ssid23a(struct rtw_adapter * padapter,
-                          struct cfg80211_ssid * ssid);
 
 u16 rtw_get_cur_max_rate23a(struct rtw_adapter *adapter);
 s32 FillH2CCmd(struct rtw_adapter *padapter, u8 ElementID, u32 CmdLen, u8 *pCmdBuffer);
index 0628416..30473d0 100644 (file)
@@ -1981,6 +1981,136 @@ exit:
        return res;
 }
 
+static int rtw_set_ssid(struct rtw_adapter* padapter,
+                       struct cfg80211_ssid *ssid)
+{
+       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
+       struct wlan_network *pnetwork = &pmlmepriv->cur_network;
+       int status = _SUCCESS;
+       u32 cur_time = 0;
+
+       DBG_8723A_LEVEL(_drv_always_, "set ssid [%s] fw_state = 0x%08x\n",
+                       ssid->ssid, get_fwstate(pmlmepriv));
+
+       if (padapter->hw_init_completed == false) {
+               RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_,
+                        ("set_ssid: hw_init_completed == false =>exit!!!\n"));
+               status = _FAIL;
+               goto exit;
+       }
+
+       spin_lock_bh(&pmlmepriv->lock);
+
+       DBG_8723A("Set SSID under fw_state = 0x%08x\n", get_fwstate(pmlmepriv));
+       if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY))
+               goto handle_tkip_countermeasure;
+       else if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING))
+               goto release_mlme_lock;
+
+       if (check_fwstate(pmlmepriv, _FW_LINKED|WIFI_ADHOC_MASTER_STATE)) {
+               RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_,
+                        ("set_ssid: _FW_LINKED||WIFI_ADHOC_MASTER_STATE\n"));
+
+               if (pmlmepriv->assoc_ssid.ssid_len == ssid->ssid_len &&
+                   !memcmp(&pmlmepriv->assoc_ssid.ssid, ssid->ssid,
+                           ssid->ssid_len)) {
+                       if (!check_fwstate(pmlmepriv, WIFI_STATION_STATE)) {
+                               RT_TRACE(_module_rtl871x_ioctl_set_c_,
+                                        _drv_err_, ("New SSID is same SSID, "
+                                                    "fw_state = 0x%08x\n",
+                                                    get_fwstate(pmlmepriv)));
+
+                               if (rtw_is_same_ibss23a(padapter, pnetwork)) {
+                                       /*
+                                        * it means driver is in
+                                        * WIFI_ADHOC_MASTER_STATE, we needn't
+                                        * create bss again.
+                                        */
+                                       goto release_mlme_lock;
+                               }
+
+                               /*
+                                * if in WIFI_ADHOC_MASTER_STATE |
+                                * WIFI_ADHOC_STATE, create bss or
+                                * rejoin again
+                                */
+                               rtw_disassoc_cmd23a(padapter, 0, true);
+
+                               if (check_fwstate(pmlmepriv, _FW_LINKED))
+                                       rtw_indicate_disconnect23a(padapter);
+
+                               rtw_free_assoc_resources23a(padapter, 1);
+
+                               if (check_fwstate(pmlmepriv,
+                                                 WIFI_ADHOC_MASTER_STATE)) {
+                                       _clr_fwstate_(pmlmepriv,
+                                                     WIFI_ADHOC_MASTER_STATE);
+                                       set_fwstate(pmlmepriv,
+                                                   WIFI_ADHOC_STATE);
+                               }
+                       } else {
+                               rtw_lps_ctrl_wk_cmd23a(padapter,
+                                                      LPS_CTRL_JOINBSS, 1);
+                       }
+               } else {
+                       RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_,
+                                ("Set SSID not the same ssid\n"));
+                       RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_,
+                                ("set_ssid =[%s] len = 0x%x\n", ssid->ssid,
+                                 ssid->ssid_len));
+                       RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_,
+                                ("assoc_ssid =[%s] len = 0x%x\n",
+                                 pmlmepriv->assoc_ssid.ssid,
+                                 pmlmepriv->assoc_ssid.ssid_len));
+
+                       rtw_disassoc_cmd23a(padapter, 0, true);
+
+                       if (check_fwstate(pmlmepriv, _FW_LINKED))
+                               rtw_indicate_disconnect23a(padapter);
+
+                       rtw_free_assoc_resources23a(padapter, 1);
+
+                       if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) {
+                               _clr_fwstate_(pmlmepriv, WIFI_ADHOC_MASTER_STATE);
+                               set_fwstate(pmlmepriv, WIFI_ADHOC_STATE);
+                       }
+               }
+       }
+
+handle_tkip_countermeasure:
+
+       if (padapter->securitypriv.btkip_countermeasure == true) {
+               cur_time = jiffies;
+
+               if ((cur_time -
+                    padapter->securitypriv.btkip_countermeasure_time) >
+                   60 * HZ) {
+                       padapter->securitypriv.btkip_countermeasure = false;
+                       padapter->securitypriv.btkip_countermeasure_time = 0;
+               } else {
+                       status = _FAIL;
+                       goto release_mlme_lock;
+               }
+       }
+
+       memcpy(&pmlmepriv->assoc_ssid, ssid, sizeof(struct cfg80211_ssid));
+       pmlmepriv->assoc_by_bssid = false;
+
+       if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY))
+               pmlmepriv->to_join = true;
+       else
+               status = rtw_do_join23a(padapter);
+
+release_mlme_lock:
+       spin_unlock_bh(&pmlmepriv->lock);
+
+exit:
+       RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_,
+                ("-%s: status =%d\n", __func__, status));
+
+       return status;
+}
+
 static int cfg80211_rtw_connect(struct wiphy *wiphy, struct net_device *ndev,
                                struct cfg80211_connect_params *sme)
 {
@@ -2208,8 +2338,8 @@ static int cfg80211_rtw_connect(struct wiphy *wiphy, struct net_device *ndev,
        /* rtw_set_802_11_encryption_mode(padapter,
           padapter->securitypriv.ndisencryptstatus); */
 
-       if (rtw_set_802_11_ssid23a(padapter, &ndis_ssid) != _SUCCESS) {
-               ret = -1;
+       if (rtw_set_ssid(padapter, &ndis_ssid) != _SUCCESS) {
+               ret = -EBUSY;
                goto exit;
        }