staging: rtl8723au: Use nl80211_iftype instead of driver's own custom types
authorJes Sorensen <Jes.Sorensen@redhat.com>
Wed, 21 May 2014 07:37:26 +0000 (09:37 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 23 May 2014 07:27:40 +0000 (16:27 +0900)
In addition move rtw_set_802_11_infrastructure_mode23a() to
ioctl_cfg80211.c and declare it static.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/rtl8723au/core/rtw_ap.c
drivers/staging/rtl8723au/core/rtw_cmd.c
drivers/staging/rtl8723au/core/rtw_ioctl_set.c
drivers/staging/rtl8723au/core/rtw_mlme.c
drivers/staging/rtl8723au/core/rtw_mlme_ext.c
drivers/staging/rtl8723au/core/rtw_sreset.c
drivers/staging/rtl8723au/hal/rtl8723a_cmd.c
drivers/staging/rtl8723au/include/rtw_cmd.h
drivers/staging/rtl8723au/include/rtw_ioctl_set.h
drivers/staging/rtl8723au/include/wlan_bssdef.h
drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c

index 0b7a4a68b5f49b40c72605a8b9672555286c4333..5847fc5f6f36c4736e5335ad18fd1343253b391d 100644 (file)
@@ -824,7 +824,8 @@ int rtw_check_beacon_data23a(struct rtw_adapter *padapter, u8 *pbuf,
 
        memcpy(ie, pbuf, pbss_network->IELength);
 
-       if (pbss_network->InfrastructureMode!= Ndis802_11APMode)
+       if (pbss_network->ifmode != NL80211_IFTYPE_AP &&
+           pbss_network->ifmode != NL80211_IFTYPE_P2P_GO)
                return _FAIL;
 
        pbss_network->Rssi = 0;
@@ -1898,7 +1899,7 @@ void rtw_ap_restore_network(struct rtw_adapter *padapter)
        struct sta_info *chk_alive_list[NUM_STA];
        int i;
 
-       rtw_setopmode_cmd23a(padapter, Ndis802_11APMode);
+       rtw_setopmode_cmd23a(padapter, NL80211_IFTYPE_AP);
 
        set_channel_bwmode23a(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode);
 
index b9ee28a8730c21b6652fe46478a4bad5787b06a6..b28afb1b8380f8c8d93b745b573ae9c6847e5856 100644 (file)
@@ -477,11 +477,11 @@ int rtw_joinbss_cmd23a(struct rtw_adapter *padapter,
        struct security_priv *psecuritypriv = &padapter->securitypriv;
        struct registry_priv *pregistrypriv = &padapter->registrypriv;
        struct ht_priv *phtpriv = &pmlmepriv->htpriv;
-       enum ndis_802_11_net_infra ndis_network_mode;
+       enum nl80211_iftype ifmode;
        struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
        struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
 
-       ndis_network_mode = pnetwork->network.InfrastructureMode;
+       ifmode = pnetwork->network.ifmode;
 
        rtw_led_control(padapter, LED_CTL_START_TO_LINK);
 
@@ -505,16 +505,15 @@ int rtw_joinbss_cmd23a(struct rtw_adapter *padapter,
 
        /* for hidden ap to set fw_state here */
        if (!check_fwstate(pmlmepriv, WIFI_STATION_STATE|WIFI_ADHOC_STATE)) {
-               switch (ndis_network_mode) {
-               case Ndis802_11IBSS:
+               switch (ifmode) {
+               case NL80211_IFTYPE_ADHOC:
                        set_fwstate(pmlmepriv, WIFI_ADHOC_STATE);
                        break;
-               case Ndis802_11Infrastructure:
+               case NL80211_IFTYPE_P2P_CLIENT:
+               case NL80211_IFTYPE_STATION:
                        set_fwstate(pmlmepriv, WIFI_STATION_STATE);
                        break;
-               case Ndis802_11APMode:
-               case Ndis802_11AutoUnknown:
-               case Ndis802_11InfrastructureMax:
+               default:
                        break;
                }
        }
@@ -673,7 +672,7 @@ exit:
 }
 
 int rtw_setopmode_cmd23a(struct rtw_adapter *padapter,
-                        enum ndis_802_11_net_infra networktype)
+                        enum nl80211_iftype ifmode)
 {
        struct  cmd_obj *ph2c;
        struct  setopmode_parm *psetop;
@@ -694,7 +693,7 @@ int rtw_setopmode_cmd23a(struct rtw_adapter *padapter,
        }
 
        init_h2fwcmd_w_parm_no_rsp(ph2c, psetop, _SetOpMode_CMD_);
-       psetop->mode = (u8)networktype;
+       psetop->mode = ifmode;
 
        res = rtw_enqueue_cmd23a(pcmdpriv, ph2c);
 exit:
index a2dfb93b04eb6333f8d6152787c51dfcf01afa26..d496ae35095a44ce6917a9c50f85c452d91f6677 100644 (file)
@@ -279,92 +279,6 @@ exit:
        return status;
 }
 
-int rtw_set_802_11_infrastructure_mode23a(struct rtw_adapter* padapter,
-                                        enum ndis_802_11_net_infra networktype)
-{
-       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-       struct wlan_network *cur_network = &pmlmepriv->cur_network;
-       enum ndis_802_11_net_infra* pold_state;
-
-       pold_state = &cur_network->network.InfrastructureMode;
-
-       RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_notice_,
-                ("+rtw_set_802_11_infrastructure_mode23a: old =%d new =%d "
-                 "fw_state = 0x%08x\n",
-                 *pold_state, networktype, get_fwstate(pmlmepriv)));
-
-       if (*pold_state != networktype) {
-               spin_lock_bh(&pmlmepriv->lock);
-
-               RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_,
-                        (" change mode!"));
-
-               if (*pold_state == Ndis802_11APMode) {
-                       /* change to other mode from Ndis802_11APMode */
-                       cur_network->join_res = -1;
-
-#ifdef CONFIG_8723AU_AP_MODE
-                       stop_ap_mode23a(padapter);
-#endif
-               }
-
-               if (check_fwstate(pmlmepriv, _FW_LINKED) ||
-                   *pold_state == Ndis802_11IBSS)
-                       rtw_disassoc_cmd23a(padapter, 0, true);
-
-               if (check_fwstate(pmlmepriv, _FW_LINKED) ||
-                   check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE))
-                       rtw_free_assoc_resources23a(padapter, 1);
-
-               if (*pold_state == Ndis802_11Infrastructure ||
-                   *pold_state == Ndis802_11IBSS) {
-                       if (check_fwstate(pmlmepriv, _FW_LINKED)) {
-                               /* will clr Linked_state; before this function,
-                                  we must have chked whether issue
-                                  dis-assoc_cmd or not */
-                               rtw_indicate_disconnect23a(padapter);
-                       }
-              }
-
-               *pold_state = networktype;
-
-               _clr_fwstate_(pmlmepriv, ~WIFI_NULL_STATE);
-
-               switch (networktype)
-               {
-               case Ndis802_11IBSS:
-                       set_fwstate(pmlmepriv, WIFI_ADHOC_STATE);
-                       break;
-
-               case Ndis802_11Infrastructure:
-                       set_fwstate(pmlmepriv, WIFI_STATION_STATE);
-                       break;
-
-               case Ndis802_11APMode:
-                       set_fwstate(pmlmepriv, WIFI_AP_STATE);
-#ifdef CONFIG_8723AU_AP_MODE
-                       start_ap_mode23a(padapter);
-                       /* rtw_indicate_connect23a(padapter); */
-#endif
-                       break;
-
-               case Ndis802_11AutoUnknown:
-               case Ndis802_11InfrastructureMax:
-                       break;
-               }
-
-               /* SecClearAllKeys(adapter); */
-
-               /* RT_TRACE(COMP_OID_SET, DBG_LOUD,
-                  ("set_infrastructure: fw_state:%x after changing mode\n", */
-               /* get_fwstate(pmlmepriv))); */
-
-               spin_unlock_bh(&pmlmepriv->lock);
-       }
-
-       return _SUCCESS;
-}
-
 int rtw_set_802_11_bssid23a_list_scan(struct rtw_adapter *padapter,
                                      struct cfg80211_ssid *pssid,
                                      int ssid_max_num)
index a7371a8745739c091bd3edffcd275c64428dee5a..b5e548e8fa80802b6fd16981748eddc2914a1fbc 100644 (file)
@@ -52,8 +52,7 @@ int rtw_init_mlme_priv23a(struct rtw_adapter *padapter)
        pmlmepriv->nic_hdl = padapter;
 
        pmlmepriv->fw_state = 0;
-       pmlmepriv->cur_network.network.InfrastructureMode =
-               Ndis802_11AutoUnknown;
+       pmlmepriv->cur_network.network.ifmode = NL80211_IFTYPE_UNSPECIFIED;
        /*  1: active, 0: pasive. Maybe someday we should rename this
            varable to "active_mode" (Jeff) */
        pmlmepriv->scan_mode = SCAN_ACTIVE;
@@ -616,8 +615,8 @@ static int rtw_is_desired_network(struct rtw_adapter *adapter,
        }
 
        if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) {
-               if (pnetwork->network.InfrastructureMode !=
-                   pmlmepriv->cur_network.network.InfrastructureMode)
+               if (pnetwork->network.ifmode !=
+                   pmlmepriv->cur_network.network.ifmode)
                        bselected = false;
        }
 
@@ -1137,14 +1136,15 @@ rtw_joinbss_update_network23a(struct rtw_adapter *padapter,
        rtw_set_signal_stat_timer(&padapter->recvpriv);
 
        /* update fw_state will clr _FW_UNDER_LINKING here indirectly */
-       switch (pnetwork->network.InfrastructureMode) {
-       case Ndis802_11Infrastructure:
-               if (pmlmepriv->fw_state&WIFI_UNDER_WPS)
+       switch (pnetwork->network.ifmode) {
+       case NL80211_IFTYPE_P2P_CLIENT:
+       case NL80211_IFTYPE_STATION:
+               if (pmlmepriv->fw_state & WIFI_UNDER_WPS)
                        pmlmepriv->fw_state = WIFI_STATION_STATE|WIFI_UNDER_WPS;
                else
                        pmlmepriv->fw_state = WIFI_STATION_STATE;
                break;
-       case Ndis802_11IBSS:
+       case NL80211_IFTYPE_ADHOC:
                pmlmepriv->fw_state = WIFI_ADHOC_STATE;
                break;
        default:
@@ -2179,11 +2179,10 @@ void rtw_update_registrypriv_dev_network23a(struct rtw_adapter* adapter)
                  "DSConfig = 0x%x\n", pregistrypriv->channel,
                  pdev_network->Configuration.DSConfig));
 
-       if (cur_network->network.InfrastructureMode == Ndis802_11IBSS)
+       if (cur_network->network.ifmode == NL80211_IFTYPE_ADHOC)
                pdev_network->Configuration.ATIMWindow = 0;
 
-       pdev_network->InfrastructureMode =
-               cur_network->network.InfrastructureMode;
+       pdev_network->ifmode = cur_network->network.ifmode;
 
        /*  1. Supported rates */
        /*  2. IE */
index 9338cb94167cbf17ef173bde421f438fd17b4dc6..aaf4fd0e129ed4e9489efccbfbed2a2b04600109 100644 (file)
@@ -4596,7 +4596,7 @@ int collect_bss_info23a(struct rtw_adapter *padapter,
 
        if (ieee80211_is_probe_req(mgmt->frame_control)) {
                /*  FIXME */
-               bssid->InfrastructureMode = Ndis802_11Infrastructure;
+               bssid->ifmode = NL80211_IFTYPE_STATION;
                ether_addr_copy(bssid->MacAddress, mgmt->sa);
                bssid->Privacy = 1;
                return _SUCCESS;
@@ -4608,10 +4608,10 @@ int collect_bss_info23a(struct rtw_adapter *padapter,
                le32_to_cpu(bssid->Configuration.BeaconPeriod);
 
        if (capab_info & BIT(0)) {
-               bssid->InfrastructureMode = Ndis802_11Infrastructure;
+               bssid->ifmode = NL80211_IFTYPE_STATION;
                ether_addr_copy(bssid->MacAddress, mgmt->sa);
        } else {
-               bssid->InfrastructureMode = Ndis802_11IBSS;
+               bssid->ifmode = NL80211_IFTYPE_ADHOC;
                ether_addr_copy(bssid->MacAddress, mgmt->bssid);
        }
 
@@ -5814,22 +5814,32 @@ int NULL_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf)
 
 int setopmode_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf)
 {
-       u8      type;
-       struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
+       enum nl80211_iftype type;
+       struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
        struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
        const struct setopmode_parm *psetop = (struct setopmode_parm *)pbuf;
 
-       if (psetop->mode == Ndis802_11APMode) {
+       switch (psetop->mode) {
+       case NL80211_IFTYPE_P2P_GO:
+       case NL80211_IFTYPE_AP:
                pmlmeinfo->state = WIFI_FW_AP_STATE;
                type = _HW_STATE_AP_;
-       } else if (psetop->mode == Ndis802_11Infrastructure) {
-               pmlmeinfo->state &= ~(BIT(0)|BIT(1));/*  clear state */
-               pmlmeinfo->state |= WIFI_FW_STATION_STATE;/* set to     STATION_STATE */
+               break;
+       case NL80211_IFTYPE_P2P_CLIENT:
+       case NL80211_IFTYPE_STATION:
+               /*  clear state */
+               pmlmeinfo->state &= ~(BIT(0)|BIT(1));
+               /* set to STATION_STATE */
+               pmlmeinfo->state |= WIFI_FW_STATION_STATE;
                type = _HW_STATE_STATION_;
-       } else if (psetop->mode == Ndis802_11IBSS)
+               break;
+       case NL80211_IFTYPE_ADHOC:
                type = _HW_STATE_ADHOC_;
-       else
+               break;
+       default:
                type = _HW_STATE_NOLINK_;
+               break;
+       }
 
        hw_var_set_opmode(padapter, type);
        /* Set_NETYPE0_MSR(padapter, type); */
@@ -5845,11 +5855,10 @@ int createbss_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf)
        const struct wlan_bssid_ex *pparm = (struct wlan_bssid_ex *)pbuf;
        /* u32  initialgain; */
 
-       if (pparm->InfrastructureMode == Ndis802_11APMode) {
+       if (pparm->ifmode == NL80211_IFTYPE_AP ||
+           pparm->ifmode == NL80211_IFTYPE_P2P_GO) {
 #ifdef CONFIG_8723AU_AP_MODE
-
-               if (pmlmeinfo->state == WIFI_FW_AP_STATE)
-               {
+               if (pmlmeinfo->state == WIFI_FW_AP_STATE) {
                        /* todo: */
                        return H2C_SUCCESS;
                }
@@ -5857,7 +5866,7 @@ int createbss_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf)
        }
 
        /* below is for ad-hoc master */
-       if (pparm->InfrastructureMode == Ndis802_11IBSS) {
+       if (pparm->ifmode == NL80211_IFTYPE_ADHOC) {
                rtw_joinbss_reset23a(padapter);
 
                pmlmeext->cur_bwmode = HT_CHANNEL_WIDTH_20;
index 5e6d5fc9166b8361f2f32f710da159be9d3f4cfd..7e698c52443177e3da46df4e7fced1136e040907 100644 (file)
@@ -126,7 +126,7 @@ static void sreset_restore_network_station(struct rtw_adapter *padapter)
        struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
        u8 threshold;
 
-       rtw_setopmode_cmd23a(padapter, Ndis802_11Infrastructure);
+       rtw_setopmode_cmd23a(padapter, NL80211_IFTYPE_STATION);
 
        /*  TH = 1 => means that invalidate usb rx aggregation */
        /*  TH = 0 => means that validate usb rx aggregation, use init value. */
index ea344214357d3362d70af71f02bf214d9dccec24..54ef5dc30b78c5022f8dd1a770366a01d43caeb1 100644 (file)
@@ -354,8 +354,9 @@ static void ConstructNullFunctionData(
        if (bForcePowerSave)
                SetPwrMgt(fctrl);
 
-       switch (cur_network->network.InfrastructureMode) {
-       case Ndis802_11Infrastructure:
+       switch (cur_network->network.ifmode) {
+       case NL80211_IFTYPE_P2P_CLIENT:
+       case NL80211_IFTYPE_STATION:
                SetToDs(fctrl);
                memcpy(pwlanhdr->addr1,
                       get_my_bssid23a(&pmlmeinfo->network), ETH_ALEN);
@@ -363,7 +364,8 @@ static void ConstructNullFunctionData(
                       ETH_ALEN);
                memcpy(pwlanhdr->addr3, StaAddr, ETH_ALEN);
                break;
-       case Ndis802_11APMode:
+       case NL80211_IFTYPE_P2P_GO:
+       case NL80211_IFTYPE_AP:
                SetFrDs(fctrl);
                memcpy(pwlanhdr->addr1, StaAddr, ETH_ALEN);
                memcpy(pwlanhdr->addr2,
@@ -371,7 +373,7 @@ static void ConstructNullFunctionData(
                memcpy(pwlanhdr->addr3, myid(&padapter->eeprompriv),
                       ETH_ALEN);
                break;
-       case Ndis802_11IBSS:
+       case NL80211_IFTYPE_ADHOC:
        default:
                memcpy(pwlanhdr->addr1, StaAddr, ETH_ALEN);
                memcpy(pwlanhdr->addr2, myid(&padapter->eeprompriv), ETH_ALEN);
index 427596e123d9479a7f40d7bea840a9c4fa878c77..50f8106291448e561ceb2c81837b72b6363407fc 100644 (file)
@@ -170,8 +170,7 @@ struct disconnect_parm {
 };
 
 struct setopmode_parm {
-       u8      mode;
-       u8      rsvd[3];
+       enum nl80211_iftype mode;
 };
 
 /*
@@ -689,7 +688,7 @@ int rtw_setstakey_cmd23a(struct rtw_adapter  *padapter, u8 *psta, u8 unicast_key
 int rtw_clearstakey_cmd23a(struct rtw_adapter *padapter, u8 *psta, u8 entry, u8 enqueue);
 int rtw_joinbss_cmd23a(struct rtw_adapter  *padapter, struct wlan_network* pnetwork);
 int rtw_disassoc_cmd23a(struct rtw_adapter *padapter, u32 deauth_timeout_ms, bool enqueue);
-int rtw_setopmode_cmd23a(struct rtw_adapter  *padapter, enum ndis_802_11_net_infra networktype);
+int rtw_setopmode_cmd23a(struct rtw_adapter *padapter, enum nl80211_iftype ifmode);
 int rtw_setdatarate_cmd(struct rtw_adapter  *padapter, u8 *rateset);
 int rtw_setbasicrate_cmd(struct rtw_adapter  *padapter, u8 *rateset);
 int rtw_setbbreg_cmd(struct rtw_adapter * padapter, u8 offset, u8 val);
index 13f7fcb2a73a2569b02626e44e76de12b74c5fc4..637f33b0c2dcf5cda9a40aff95ef472fb5299fb9 100644 (file)
@@ -24,8 +24,6 @@ int rtw_set_802_11_add_wep23a(struct rtw_adapter * padapter,
 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_infrastructure_mode23a(struct rtw_adapter *padapter,
-                                         enum ndis_802_11_net_infra networktype);
 int rtw_set_802_11_ssid23a(struct rtw_adapter * padapter,
                           struct cfg80211_ssid * ssid);
 
index 92287ebe5b9be761bfee1da2c3becfbc8b878b71..0799d800c69921e4fb84161f51f714776310becb 100644 (file)
@@ -50,14 +50,6 @@ struct ndis_802_11_config {
        struct ndis_802_11_configuration_fh    FHConfig;
 };
 
-enum ndis_802_11_net_infra {
-       Ndis802_11IBSS,
-       Ndis802_11Infrastructure,
-       Ndis802_11AutoUnknown,
-       Ndis802_11InfrastructureMax,     /*  Not a real value, defined as upper bound */
-       Ndis802_11APMode
-};
-
 struct ndis_802_11_fixed_ies {
        u8  Timestamp[8];
        u16  BeaconInterval;
@@ -139,10 +131,6 @@ enum NDIS_802_11_STATUS_TYPE {
 /*  MIC check time, 60 seconds. */
 #define MIC_CHECK_TIME 60000000
 
-#ifndef Ndis802_11APMode
-#define Ndis802_11APMode (Ndis802_11InfrastructureMax+1)
-#endif
-
 struct wlan_phy_info {
        u8      SignalStrength;/* in percentage) */
        u8      SignalQuality;/* in percentage) */
@@ -172,7 +160,7 @@ struct wlan_bssid_ex {
        long  Rssi;/* in dBM, raw data , get from PHY) */
        enum ndis_802_11_net_type  NetworkTypeInUse;
        struct ndis_802_11_config  Configuration;
-       enum ndis_802_11_net_infra  InfrastructureMode;
+       enum nl80211_iftype ifmode;
        unsigned char SupportedRates[NDIS_802_11_LENGTH_RATES_EX];
        struct wlan_phy_info    PhyInfo;
        u32  IELength;
index 182f57c2d86bf5963c4edc35e799db6300e1c84b..aac1d418d9dd7ca862f9d0dfbfc1fde837899468 100644 (file)
@@ -1291,18 +1291,103 @@ exit:
        return ret;
 }
 
+int cfg80211_infrastructure_mode(struct rtw_adapter* padapter,
+                                enum nl80211_iftype ifmode)
+{
+       struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
+       struct wlan_network *cur_network = &pmlmepriv->cur_network;
+       enum nl80211_iftype old_mode;
+
+       old_mode = cur_network->network.ifmode;
+
+       RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_notice_,
+                ("+%s: old =%d new =%d fw_state = 0x%08x\n", __func__,
+                 old_mode, ifmode, get_fwstate(pmlmepriv)));
+
+       if (old_mode != ifmode) {
+               spin_lock_bh(&pmlmepriv->lock);
+
+               RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_,
+                        (" change mode!"));
+
+               if (old_mode == NL80211_IFTYPE_AP ||
+                   old_mode == NL80211_IFTYPE_P2P_GO) {
+                       /* change to other mode from Ndis802_11APMode */
+                       cur_network->join_res = -1;
+
+#ifdef CONFIG_8723AU_AP_MODE
+                       stop_ap_mode23a(padapter);
+#endif
+               }
+
+               if (check_fwstate(pmlmepriv, _FW_LINKED) ||
+                   old_mode == NL80211_IFTYPE_ADHOC)
+                       rtw_disassoc_cmd23a(padapter, 0, true);
+
+               if (check_fwstate(pmlmepriv, _FW_LINKED) ||
+                   check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE))
+                       rtw_free_assoc_resources23a(padapter, 1);
+
+               if (old_mode == NL80211_IFTYPE_STATION ||
+                   old_mode == NL80211_IFTYPE_P2P_CLIENT ||
+                   old_mode == NL80211_IFTYPE_ADHOC) {
+                       if (check_fwstate(pmlmepriv, _FW_LINKED)) {
+                               /* will clr Linked_state; before this function,
+                                  we must have chked whether issue
+                                  dis-assoc_cmd or not */
+                               rtw_indicate_disconnect23a(padapter);
+                       }
+              }
+
+               cur_network->network.ifmode = ifmode;
+
+               _clr_fwstate_(pmlmepriv, ~WIFI_NULL_STATE);
+
+               switch (ifmode) {
+               case NL80211_IFTYPE_ADHOC:
+                       set_fwstate(pmlmepriv, WIFI_ADHOC_STATE);
+                       break;
+
+               case NL80211_IFTYPE_P2P_CLIENT:
+               case NL80211_IFTYPE_STATION:
+                       set_fwstate(pmlmepriv, WIFI_STATION_STATE);
+                       break;
+
+               case NL80211_IFTYPE_P2P_GO:
+               case NL80211_IFTYPE_AP:
+                       set_fwstate(pmlmepriv, WIFI_AP_STATE);
+#ifdef CONFIG_8723AU_AP_MODE
+                       start_ap_mode23a(padapter);
+                       /* rtw_indicate_connect23a(padapter); */
+#endif
+                       break;
+
+               default:
+                       break;
+               }
+
+               /* SecClearAllKeys(adapter); */
+
+               /* RT_TRACE(COMP_OID_SET, DBG_LOUD,
+                  ("set_infrastructure: fw_state:%x after changing mode\n", */
+               /* get_fwstate(pmlmepriv))); */
+
+               spin_unlock_bh(&pmlmepriv->lock);
+       }
+
+       return _SUCCESS;
+}
+
 static int cfg80211_rtw_change_iface(struct wiphy *wiphy,
                                     struct net_device *ndev,
                                     enum nl80211_iftype type, u32 *flags,
                                     struct vif_params *params)
 {
        enum nl80211_iftype old_type;
-       enum ndis_802_11_net_infra networkType;
        struct rtw_adapter *padapter = wiphy_to_adapter(wiphy);
        struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
        struct wireless_dev *rtw_wdev = wiphy_to_wdev(wiphy);
        int ret = 0;
-       u8 change = false;
 
        DBG_8723A("%s(%s): call netdev_open23a\n", __func__, ndev->name);
        if (netdev_open23a(ndev) != 0) {
@@ -1320,22 +1405,17 @@ static int cfg80211_rtw_change_iface(struct wiphy *wiphy,
                  __func__, ndev->name, old_type, type);
 
        if (old_type != type) {
-               change = true;
                pmlmeext->action_public_rxseq = 0xffff;
                pmlmeext->action_public_dialog_token = 0xff;
        }
 
        switch (type) {
        case NL80211_IFTYPE_ADHOC:
-               networkType = Ndis802_11IBSS;
-               break;
        case NL80211_IFTYPE_P2P_CLIENT:
        case NL80211_IFTYPE_STATION:
-               networkType = Ndis802_11Infrastructure;
-               break;
        case NL80211_IFTYPE_P2P_GO:
        case NL80211_IFTYPE_AP:
-               networkType = Ndis802_11APMode;
+       case NL80211_IFTYPE_UNSPECIFIED:
                break;
        default:
                return -EOPNOTSUPP;
@@ -1343,14 +1423,13 @@ static int cfg80211_rtw_change_iface(struct wiphy *wiphy,
 
        rtw_wdev->iftype = type;
 
-       if (rtw_set_802_11_infrastructure_mode23a
-           (padapter, networkType) != _SUCCESS) {
+       if (cfg80211_infrastructure_mode(padapter, type) != _SUCCESS) {
                rtw_wdev->iftype = old_type;
                ret = -EPERM;
                goto exit;
        }
 
-       rtw_setopmode_cmd23a(padapter, networkType);
+       rtw_setopmode_cmd23a(padapter, type);
 
 exit:
        return ret;
@@ -1982,8 +2061,8 @@ static int cfg80211_rtw_connect(struct wiphy *wiphy, struct net_device *ndev,
                goto exit;
        }
 
-       if (rtw_set_802_11_infrastructure_mode23a
-           (padapter, pnetwork->network.InfrastructureMode) != _SUCCESS) {
+       if (cfg80211_infrastructure_mode(
+                   padapter, pnetwork->network.ifmode) != _SUCCESS) {
                ret = -EPERM;
                goto exit;
        }