Home | History | Annotate | Download | only in Connection_Managment
      1 /*
      2  * connInfra.c
      3  *
      4  * Copyright(c) 1998 - 2010 Texas Instruments. All rights reserved.
      5  * All rights reserved.
      6  *
      7  * Redistribution and use in source and binary forms, with or without
      8  * modification, are permitted provided that the following conditions
      9  * are met:
     10  *
     11  *  * Redistributions of source code must retain the above copyright
     12  *    notice, this list of conditions and the following disclaimer.
     13  *  * Redistributions in binary form must reproduce the above copyright
     14  *    notice, this list of conditions and the following disclaimer in
     15  *    the documentation and/or other materials provided with the
     16  *    distribution.
     17  *  * Neither the name Texas Instruments nor the names of its
     18  *    contributors may be used to endorse or promote products derived
     19  *    from this software without specific prior written permission.
     20  *
     21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     24  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     25  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     26  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
     27  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     28  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     29  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     30  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     31  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     32  */
     33 
     34 /** \file connInfra.c
     35  *  \brief Infra connection implementation
     36  *
     37  *  \see connInfra.h
     38  */
     39 
     40 /***************************************************************************/
     41 /*                                                                         */
     42 /*      MODULE: connInfra.c                                                */
     43 /*    PURPOSE:  Infra connection implementation                            */
     44 /*                                                                         */
     45 /***************************************************************************/
     46 
     47 #define __FILE_ID__  FILE_ID_27
     48 #include "tidef.h"
     49 #include "report.h"
     50 #include "osApi.h"
     51 #include "conn.h"
     52 #include "connInfra.h"
     53 #include "timer.h"
     54 #include "fsm.h"
     55 #include "siteMgrApi.h"
     56 #include "sme.h"
     57 #include "rsnApi.h"
     58 #include "DataCtrl_Api.h"
     59 #include "paramOut.h"
     60 #include "siteHash.h"
     61 #include "smeSm.h"
     62 #include "PowerMgr_API.h"
     63 #include "measurementMgrApi.h"
     64 #include "TrafficMonitorAPI.h"
     65 #include "qosMngr_API.h"
     66 #include "EvHandler.h"
     67 #include "SwitchChannelApi.h"
     68 #include "ScanCncn.h"
     69 #include "currBss.h"
     70 #include "healthMonitor.h"
     71 #include "regulatoryDomainApi.h"
     72 #include "txCtrl.h"
     73 #include "TWDriver.h"
     74 #include "SoftGeminiApi.h"
     75 #include "RxQueue_api.h"
     76 
     77 #ifdef XCC_MODULE_INCLUDED
     78 #include "XCCMngr.h"
     79 #include "XCCTSMngr.h"
     80 #endif
     81 
     82 #define DISCONNECT_TIMEOUT_MSEC      800
     83 
     84 /* Local functions prototypes */
     85 
     86 static TI_STATUS actionUnexpected(void *pData);
     87 
     88 static TI_STATUS actionNop(void *pData);
     89 
     90 static TI_STATUS connInfra_ScrWait(void *pData);
     91 
     92 static TI_STATUS Idle_to_Idle(void *pData);
     93 
     94 static TI_STATUS ScrWait_to_idle(void *pData);
     95 
     96 static TI_STATUS ScrWait_to_JoinWait(void *pData);
     97 
     98 static TI_STATUS JoinWait_to_mlmeWait(void *pData);
     99 
    100 static TI_STATUS JoinWait_to_WaitDisconnect(void *pData);
    101 
    102 static TI_STATUS mlmeWait_to_WaitDisconnect(void *pData);
    103 
    104 static TI_STATUS mlmeWait_to_rsnWait(void *pData);
    105 
    106 static TI_STATUS rsnWait_to_disconnect(void *pData);
    107 
    108 static TI_STATUS rsnWait_to_configHW(void *pData);
    109 
    110 static TI_STATUS configHW_to_connected(void *pData);
    111 
    112 static TI_STATUS configHW_to_disconnect(void *pData);
    113 
    114 static TI_STATUS connInfra_ScrWaitDisconn_to_disconnect(void *pData);
    115 
    116 static TI_STATUS connect_to_ScrWait(void *pData);
    117 
    118 static TI_STATUS prepare_send_disconnect(void *pData);
    119 
    120 static TI_STATUS connInfra_WaitDisconnectToIdle (void *pData);
    121 
    122 
    123 static TI_STATUS stopModules( conn_t *pConn, TI_BOOL bDisconnect );
    124 
    125 void InfraConnSM_ScrCB( TI_HANDLE hConn, EScrClientRequestStatus requestStatus,
    126                         EScrResourceId eResource, EScePendReason pendReason );
    127 
    128 int conn_ConfigHwFinishCb(TI_HANDLE pData);
    129 
    130 /********************************************/
    131 /*      Functions Implementations           */
    132 /********************************************/
    133 
    134 
    135 /***********************************************************************
    136  *                        conn_infraConfig
    137  ***********************************************************************
    138 DESCRIPTION: Infra Connection configuration function, called by the conection set param function
    139                 in the selection phase. Configures the connection state machine to Infra connection mode
    140 
    141 INPUT:      hConn   -   Connection handle.
    142 
    143 OUTPUT:
    144 
    145 RETURN:     TI_OK on success, TI_NOK otherwise
    146 
    147 ************************************************************************/
    148 TI_STATUS conn_infraConfig(conn_t *pConn)
    149 {
    150     static fsm_actionCell_t    smMatrix[CONN_INFRA_NUM_STATES][CONN_INFRA_NUM_EVENTS] =
    151     {
    152         /* next state and actions for IDLE state */
    153         {   {STATE_CONN_INFRA_SCR_WAIT_CONN, connInfra_ScrWait},        /* "EVENT_CONNECT"  */
    154             {STATE_CONN_INFRA_IDLE, actionNop       },                  /* "EVENT_SCR_SUCC"*/
    155             {STATE_CONN_INFRA_IDLE, actionNop       },                  /* "EVENT_JOIN_CMD_CMPLT */
    156             {STATE_CONN_INFRA_IDLE, Idle_to_Idle    },                  /* "EVENT_DISCONNECT"       */
    157             {STATE_CONN_INFRA_IDLE, actionUnexpected},                  /* "EVENT_MLME_SUCC"*/
    158             {STATE_CONN_INFRA_IDLE, actionUnexpected},                  /* "EVENT_RSN_SUCC" */
    159             {STATE_CONN_INFRA_IDLE, actionNop},                         /* "EVENT_CONFIG_HW" */
    160             {STATE_CONN_INFRA_IDLE, actionUnexpected}                   /* "EVENT_DISCONN_COMPLETE" */
    161         },
    162 
    163         /* next state and actions for SCR_WAIT_CONN state */
    164         {   {STATE_CONN_INFRA_SCR_WAIT_CONN     , actionUnexpected},    /* "EVENT_CONNECT"  */
    165             {STATE_CONN_INFRA_WAIT_JOIN_CMPLT, ScrWait_to_JoinWait},    /* "EVENT_SCR_SUCC"*/
    166             {STATE_CONN_INFRA_SCR_WAIT_CONN     , actionUnexpected},    /* "EVENT_JOIN_CMD_CMPLT */
    167             {STATE_CONN_INFRA_IDLE,     ScrWait_to_idle},               /* "EVENT_DISCONNECT"       */
    168             {STATE_CONN_INFRA_SCR_WAIT_CONN     , actionUnexpected},    /* "EVENT_MLME_SUCC"*/
    169             {STATE_CONN_INFRA_SCR_WAIT_CONN     , actionUnexpected},    /* "EVENT_RSN_SUCC" */
    170             {STATE_CONN_INFRA_SCR_WAIT_CONN     , actionNop},           /* "EVENT_CONFIG_HW "*/
    171             {STATE_CONN_INFRA_SCR_WAIT_CONN     , actionNop}            /* "EVENT_DISCONN_COMPLETE" */
    172         },
    173 
    174         /* next state and actions for WAIT_JOIN_CMPLT */
    175         {   {STATE_CONN_INFRA_WAIT_JOIN_CMPLT, actionUnexpected},       /* "EVENT_CONNECT"    */
    176             {STATE_CONN_INFRA_WAIT_JOIN_CMPLT, actionUnexpected},       /* "EVENT_SCR_SUCC"*/
    177             {STATE_CONN_INFRA_MLME_WAIT,       JoinWait_to_mlmeWait},   /* "EVENT_JOIN_CMD_CMPLT"   */
    178             {STATE_CONN_INFRA_WAIT_DISCONNECT, JoinWait_to_WaitDisconnect},/* "EVENT_DISCONNECT"       */
    179             {STATE_CONN_INFRA_WAIT_JOIN_CMPLT, actionUnexpected},       /* "EVENT_MLME_SUCC"*/
    180             {STATE_CONN_INFRA_WAIT_JOIN_CMPLT, actionUnexpected},       /* "EVENT_RSN_SUCC" */
    181             {STATE_CONN_INFRA_WAIT_JOIN_CMPLT, actionNop},              /* "EVENT_CONFIG_HW"        */
    182             {STATE_CONN_INFRA_WAIT_JOIN_CMPLT, actionUnexpected}        /* "EVENT_DISCONN_COMPLETE" */
    183 
    184         },
    185 
    186         /* next state and actions for MLME_WAIT state */
    187         {   {STATE_CONN_INFRA_MLME_WAIT, actionUnexpected},             /* "EVENT_CONNECT"  */
    188             {STATE_CONN_INFRA_MLME_WAIT, actionUnexpected},             /* "EVENT_SCR_SUCC" */
    189             {STATE_CONN_INFRA_MLME_WAIT, actionUnexpected},             /* "EVENT_JOIN_CMD_CMPLT"*/
    190             {STATE_CONN_INFRA_WAIT_DISCONNECT, mlmeWait_to_WaitDisconnect}, /* "EVENT_DISCONNECT"       */
    191             {STATE_CONN_INFRA_RSN_WAIT,  mlmeWait_to_rsnWait},          /* "EVENT_MLME_SUCC"*/
    192             {STATE_CONN_INFRA_MLME_WAIT, actionUnexpected},             /* "EVENT_RSN_SUCC" */
    193             {STATE_CONN_INFRA_MLME_WAIT, actionUnexpected},             /* "EVENT_CONFIG_HW" */
    194             {STATE_CONN_INFRA_MLME_WAIT, actionUnexpected}              /* "EVENT_DISCONN_COMPLETE" */
    195         },
    196 
    197         /* next state and actions for RSN_WAIT state */
    198         {   {STATE_CONN_INFRA_RSN_WAIT,     actionUnexpected},          /* "EVENT_CONNECT"  */
    199             {STATE_CONN_INFRA_RSN_WAIT,     actionUnexpected},          /* "EVENT_SCR_SUCC" */
    200             {STATE_CONN_INFRA_RSN_WAIT,     actionUnexpected},          /* "EVENT_JOIN_CMD_CMPLT"*/
    201             {STATE_CONN_INFRA_WAIT_DISCONNECT,    rsnWait_to_disconnect},   /* "EVENT_DISCONNECT" */
    202             {STATE_CONN_INFRA_RSN_WAIT,     actionUnexpected},          /* "EVENT_MLME_SUCC"*/
    203             {STATE_CONN_INFRA_CONFIG_HW,    rsnWait_to_configHW},       /* "EVENT_RSN_SUCC" */
    204             {STATE_CONN_INFRA_RSN_WAIT,     actionUnexpected},          /* "EVENT_CONFIG_HW"        */
    205             {STATE_CONN_INFRA_RSN_WAIT,     actionUnexpected}           /* "EVENT_DISCONN_COMPLETE" */
    206         },
    207 
    208         /* next state and actions for CONFIG_HW state */
    209         {   {STATE_CONN_INFRA_CONFIG_HW, actionUnexpected},             /* "EVENT_CONNECT"  */
    210             {STATE_CONN_INFRA_CONFIG_HW, actionUnexpected},             /* "EVENT_SCR_SUCC" */
    211             {STATE_CONN_INFRA_CONFIG_HW, actionUnexpected},             /* "EVENT_JOIN_CMD_CMPLT"*/
    212             {STATE_CONN_INFRA_WAIT_DISCONNECT, configHW_to_disconnect},     /* "EVENT_DISCONNECT"       */
    213             {STATE_CONN_INFRA_CONFIG_HW, actionUnexpected},             /* "EVENT_MLME_SUCC"*/
    214             {STATE_CONN_INFRA_CONFIG_HW, actionUnexpected},             /* "EVENT_RSN_SUCC" */
    215             {STATE_CONN_INFRA_CONNECTED, configHW_to_connected},        /* "EVENT_CONFIG_HW"        */
    216             {STATE_CONN_INFRA_CONFIG_HW, actionUnexpected}              /* "EVENT_DISCONN_COMPLETE" */
    217         },
    218 
    219         /* next state and actions for CONNECTED state */
    220         {   {STATE_CONN_INFRA_SCR_WAIT_CONN, connect_to_ScrWait},   /* "EVENT_CONNECT"  */
    221             {STATE_CONN_INFRA_CONNECTED, actionUnexpected},         /* "EVENT_SCR_SUCC"*/
    222             {STATE_CONN_INFRA_CONNECTED, actionUnexpected},         /* "EVENT_JOIN_CMD_CMPLT" */
    223             {STATE_CONN_INFRA_SCR_WAIT_DISCONN, connInfra_ScrWait}, /* "EVENT_DISCONNECT"       */
    224             {STATE_CONN_INFRA_CONNECTED, actionUnexpected},         /* "EVENT_MLME_SUCC"*/
    225             {STATE_CONN_INFRA_CONNECTED, actionUnexpected},         /* "EVENT_RSN_SUCC" */
    226             {STATE_CONN_INFRA_CONNECTED, actionUnexpected},         /* "STATE_CONN_INFRA_CONFIG_HW" */
    227             {STATE_CONN_INFRA_CONNECTED, actionUnexpected}          /* "EVENT_DISCONN_COMPLETE" */
    228         },
    229 
    230         /* next state and actions for SCR_WAIT_DISCONN state */
    231         {   {STATE_CONN_INFRA_SCR_WAIT_DISCONN, actionUnexpected},     /* "EVENT_CONNECT"  */
    232             {STATE_CONN_INFRA_WAIT_DISCONNECT       , connInfra_ScrWaitDisconn_to_disconnect},  /* "EVENT_SCR_SUCC"*/
    233             {STATE_CONN_INFRA_SCR_WAIT_DISCONN, actionUnexpected},     /* "EVENT_JOIN_CMD_CMPLT */
    234             {STATE_CONN_INFRA_SCR_WAIT_DISCONN, ScrWait_to_idle},      /* "EVENT_DISCONNECT"       */
    235             {STATE_CONN_INFRA_SCR_WAIT_DISCONN, actionUnexpected},     /* "EVENT_MLME_SUCC"*/
    236             {STATE_CONN_INFRA_SCR_WAIT_DISCONN, actionUnexpected},     /* "EVENT_RSN_SUCC" */
    237             {STATE_CONN_INFRA_SCR_WAIT_DISCONN, actionNop},            /* "EVENT_CONFIG_HW "*/
    238             {STATE_CONN_INFRA_SCR_WAIT_DISCONN, actionNop}             /* "EVENT_DISCONN_COMPLETE" */
    239         },
    240 
    241         /* next state and actions for STATE_CONN_INFRA_WAIT_DISCONNECT state */
    242         {   {STATE_CONN_INFRA_WAIT_DISCONNECT, actionUnexpected},               /* "EVENT_CONNECT"  */
    243             {STATE_CONN_INFRA_WAIT_DISCONNECT, actionUnexpected},               /* "STATE_CONN_INFRA_SCR_WAIT_CONN"*/
    244             {STATE_CONN_INFRA_WAIT_DISCONNECT, actionUnexpected},               /* "EVENT_JOIN_CMD_CMPLT" */
    245             {STATE_CONN_INFRA_WAIT_DISCONNECT, actionUnexpected},               /* "EVENT_DISCONNECT" */
    246             {STATE_CONN_INFRA_WAIT_DISCONNECT, actionUnexpected},               /* "EVENT_MLME_SUCC"*/
    247             {STATE_CONN_INFRA_WAIT_DISCONNECT, actionUnexpected},               /* "EVENT_RSN_SUCC" */
    248             {STATE_CONN_INFRA_WAIT_DISCONNECT, actionUnexpected},               /* "STATE_CONN_INFRA_CONFIG_HW"  */
    249             {STATE_CONN_INFRA_IDLE           , connInfra_WaitDisconnectToIdle}  /* "EVENT_DISCONN_COMPLETE" */
    250         }
    251 
    252     };
    253 
    254     scr_registerClientCB( pConn->hScr, SCR_CID_CONNECT, InfraConnSM_ScrCB, pConn );
    255 
    256     return fsm_Config(pConn->infra_pFsm, (fsm_Matrix_t)smMatrix, CONN_INFRA_NUM_STATES, CONN_INFRA_NUM_EVENTS, conn_infraSMEvent, pConn->hOs);
    257 }
    258 
    259 /***********************************************************************
    260  *                        conn_infraSMEvent
    261  ***********************************************************************
    262 DESCRIPTION: Infra Connection SM event processing function, called by the connection API
    263                 Perform the following:
    264                 -   Print the state movement as a result from the event
    265                 -   Calls the generic state machine event processing function which preform the following:
    266                     -   Calls the correspoding callback function
    267                     -   Move to next state
    268 
    269 INPUT:      currentState    -   Pointer to the connection current state.
    270             event   -   Received event
    271             pConn   -   Connection handle
    272 
    273 OUTPUT:
    274 
    275 RETURN:     TI_OK on success, TI_NOK otherwise
    276 
    277 ************************************************************************/
    278 TI_STATUS conn_infraSMEvent(TI_UINT8 *currentState, TI_UINT8 event, TI_HANDLE hConn)
    279 {
    280    conn_t *pConn = (conn_t *)hConn;
    281     TI_STATUS       status;
    282     TI_UINT8       nextState;
    283 
    284     status = fsm_GetNextState(pConn->infra_pFsm, *currentState, event, &nextState);
    285     if (status != TI_OK)
    286     {
    287         TRACE0(pConn->hReport, REPORT_SEVERITY_SM, "State machine error, failed getting next state\n");
    288         return(TI_NOK);
    289     }
    290 
    291 	TRACE3( pConn->hReport, REPORT_SEVERITY_INFORMATION, "conn_infraSMEvent: <currentState = %d, event = %d> --> nextState = %d\n", *currentState, event, nextState);
    292 
    293     status = fsm_Event(pConn->infra_pFsm, currentState, event, (void *)pConn);
    294 
    295     return status;
    296 }
    297 
    298 /************************************************************************************************************/
    299 /*      In the following section are listed the callback function used by the Infra connection state machine    */
    300 /************************************************************************************************************/
    301 
    302 /* JOIN, SET_DATA_PORT_NOTIFY, START_MLME */
    303 static TI_STATUS ScrWait_to_JoinWait(void *pData)
    304 {
    305     TI_STATUS status;
    306     conn_t *pConn = (conn_t *)pData;
    307 
    308     status = siteMgr_join(((conn_t *)pData)->hSiteMgr );
    309     /* If the Join command was failed we report the SME that connection failure so it could exit connecting state */
    310     if (status != TI_OK)
    311     {
    312        TRACE0(pConn->hReport, REPORT_SEVERITY_ERROR, "Join command has failed!\n");
    313     }
    314     return status;
    315 }
    316 
    317 
    318 static TI_STATUS JoinWait_to_mlmeWait(void *pData)
    319 {
    320     TI_STATUS status;
    321     paramInfo_t *pParam;
    322     conn_t *pConn = (conn_t *)pData;
    323 
    324     pParam = (paramInfo_t *)os_memoryAlloc(pConn->hOs, sizeof(paramInfo_t));
    325     if (!pParam)
    326     {
    327         return TI_NOK;
    328     }
    329 
    330     /* Set the BA session policies to the FW */
    331     qosMngr_SetBaPolicies(pConn->hQosMngr);
    332 
    333     pParam->paramType = SITE_MGR_CURRENT_CHANNEL_PARAM;
    334     siteMgr_getParam(pConn->hSiteMgr, pParam);
    335 
    336     pParam->paramType = REGULATORY_DOMAIN_TX_POWER_AFTER_SELECTION_PARAM;
    337     pParam->content.channel = pParam->content.siteMgrCurrentChannel;
    338     regulatoryDomain_setParam(pConn->hRegulatoryDomain, pParam);
    339 
    340     pParam->paramType = RX_DATA_PORT_STATUS_PARAM;
    341     pParam->content.rxDataPortStatus = OPEN_NOTIFY;
    342     status = rxData_setParam(pConn->hRxData, pParam);
    343     if (status != TI_OK)
    344     {
    345         TRACE1( pConn->hReport, REPORT_SEVERITY_FATAL_ERROR, "JoinWait_to_mlmeWait: rxData_setParam return 0x%x.\n", status);
    346         os_memoryFree(pConn->hOs, pParam, sizeof(paramInfo_t));
    347         return status;
    348     }
    349 
    350     /* Update TxMgmtQueue SM to open Tx path only for Mgmt packets. */
    351     txMgmtQ_SetConnState (((conn_t *)pData)->hTxMgmtQ, TX_CONN_STATE_MGMT);
    352 
    353     /*
    354      * Set the reassociation flag in the association logic.
    355      */
    356     pParam->paramType = MLME_RE_ASSOC_PARAM;
    357 
    358     if( pConn->connType == CONN_TYPE_ROAM )
    359         pParam->content.mlmeReAssoc = TI_TRUE;
    360     else
    361         pParam->content.mlmeReAssoc = TI_FALSE;
    362 
    363     status = mlme_setParam(pConn->hMlmeSm, pParam);
    364 
    365     if (status != TI_OK)
    366     {
    367         TRACE1( pConn->hReport, REPORT_SEVERITY_FATAL_ERROR, "JoinWait_to_mlmeWait: mlme_setParam return 0x%x.\n", status);
    368     }
    369     os_memoryFree(pConn->hOs, pParam, sizeof(paramInfo_t));
    370     return mlme_start(pConn->hMlmeSm);
    371 }
    372 
    373 
    374 /* STOP_MLME, SET_DATA_PORT_CLOSE, DIS_JOIN */
    375 static TI_STATUS mlmeWait_to_WaitDisconnect(void *pData)
    376 {
    377     TI_STATUS   status;
    378     paramInfo_t *pParam;
    379     conn_t      *pConn = (conn_t *)pData;
    380 
    381     status = mlme_stop( pConn->hMlmeSm, DISCONNECT_IMMEDIATE, pConn->disConnReasonToAP );
    382     if (status != TI_OK)
    383         return status;
    384 
    385     pParam = (paramInfo_t *)os_memoryAlloc(pConn->hOs, sizeof(paramInfo_t));
    386     if (!pParam)
    387     {
    388         return TI_NOK;
    389     }
    390 
    391     pParam->paramType = RX_DATA_PORT_STATUS_PARAM;
    392     pParam->content.rxDataPortStatus = CLOSE;
    393     rxData_setParam(pConn->hRxData, pParam);
    394 
    395     /* Update TxMgmtQueue SM to close Tx path. */
    396     txMgmtQ_SetConnState (pConn->hTxMgmtQ, TX_CONN_STATE_CLOSE);
    397 
    398     /* Start the disconnect complete time out timer.
    399        Disconect Complete event, which stops the timer. */
    400     tmr_StartTimer (pConn->hConnTimer, conn_timeout, (TI_HANDLE)pConn, DISCONNECT_TIMEOUT_MSEC, TI_FALSE);
    401 
    402     /* FW will send the disconn frame according to disConnType */
    403     TWD_CmdFwDisconnect (pConn->hTWD, pConn->disConnType, pConn->disConnReasonToAP);
    404 
    405 #ifdef XCC_MODULE_INCLUDED
    406     XCCMngr_updateIappInformation(pConn->hXCCMngr, XCC_DISASSOC);
    407 #endif
    408     os_memoryFree(pConn->hOs, pParam, sizeof(paramInfo_t));
    409     return TI_OK;
    410 }
    411 
    412 /* This function is called from the WAIT_FOR_JOIN_CB_CMPLT state (before mlme_start)
    413   - all we need to do is call siteMgr_disJoin */
    414 static TI_STATUS JoinWait_to_WaitDisconnect(void *pData)
    415 {
    416     conn_t *pConn = (conn_t *)pData;
    417 
    418     /* Start the disconnect complete time out timer.
    419        Disconect Complete event, which stops the timer. */
    420     tmr_StartTimer (pConn->hConnTimer, conn_timeout, (TI_HANDLE)pConn, DISCONNECT_TIMEOUT_MSEC, TI_FALSE);
    421 
    422     /* FW will send the disconn frame according to disConnType */
    423     TWD_CmdFwDisconnect (pConn->hTWD, pConn->disConnType, pConn->disConnReasonToAP);
    424 
    425    return TI_OK;
    426 }
    427 
    428 /* SET_DATA_PORT_EAPOL, START_RSN */
    429 static TI_STATUS mlmeWait_to_rsnWait(void *pData)
    430 {
    431     TI_STATUS status;
    432     paramInfo_t *pParam;
    433     conn_t *pConn = (conn_t *)pData;
    434 
    435     pParam = (paramInfo_t *)os_memoryAlloc(pConn->hOs, sizeof(paramInfo_t));
    436     if (!pParam)
    437     {
    438         return TI_NOK;
    439     }
    440 
    441     pParam->paramType = RX_DATA_PORT_STATUS_PARAM;
    442     pParam->content.rxDataPortStatus = OPEN_EAPOL;
    443     status = rxData_setParam(pConn->hRxData, pParam);
    444     os_memoryFree(pConn->hOs, pParam, sizeof(paramInfo_t));
    445     if (status != TI_OK)
    446         return status;
    447     /* Update TxMgmtQueue SM to enable EAPOL packets. */
    448     txMgmtQ_SetConnState (((conn_t *)pData)->hTxMgmtQ, TX_CONN_STATE_EAPOL);
    449 
    450     /*
    451      *  Notify that the driver is associated to the supplicant\IP stack.
    452      */
    453     EvHandlerSendEvent(pConn->hEvHandler, IPC_EVENT_ASSOCIATED, NULL,0);
    454     status = rsn_start(pConn->hRsn);
    455     return status;
    456 }
    457 
    458 
    459 
    460 /* STOP_RSN, SET_DATA_PORT_CLOSE, STOP_MLME, DIS_JOIN */
    461 static TI_STATUS rsnWait_to_disconnect(void *pData)
    462 {
    463     TI_STATUS status;
    464     paramInfo_t *pParam;
    465     conn_t *pConn = (conn_t *)pData;
    466 
    467     status = rsn_stop(pConn->hRsn, pConn->disConEraseKeys);
    468     if (status != TI_OK)
    469         return status;
    470 
    471     pParam = (paramInfo_t *)os_memoryAlloc(pConn->hOs, sizeof(paramInfo_t));
    472     if (!pParam)
    473     {
    474         return TI_NOK;
    475     }
    476 
    477     pParam->paramType = RX_DATA_PORT_STATUS_PARAM;
    478     pParam->content.rxDataPortStatus = CLOSE;
    479     status = rxData_setParam(pConn->hRxData, pParam);
    480     os_memoryFree(pConn->hOs, pParam, sizeof(paramInfo_t));
    481     if (status != TI_OK)
    482         return status;
    483 
    484     /* Update TxMgmtQueue SM to close Tx path for all except Mgmt packets. */
    485     txMgmtQ_SetConnState (pConn->hTxMgmtQ, TX_CONN_STATE_MGMT);
    486 
    487     status = mlme_stop( pConn->hMlmeSm, DISCONNECT_IMMEDIATE, pConn->disConnReasonToAP );
    488 
    489     if (status != TI_OK)
    490         return status;
    491 
    492     /* send disconnect command to firmware */
    493     prepare_send_disconnect(pData);
    494 
    495     return TI_OK;
    496 }
    497 
    498 
    499 /* STOP_RSN, SET_DATA_PORT_CLOSE, STOP_MLME, DIS_JOIN */
    500 static TI_STATUS configHW_to_disconnect(void *pData)
    501 {
    502     TI_STATUS status;
    503     paramInfo_t *pParam;
    504     conn_t *pConn = (conn_t *)pData;
    505 
    506     status = rsn_stop(pConn->hRsn, pConn->disConEraseKeys );
    507     if (status != TI_OK)
    508         return status;
    509 
    510     pParam = (paramInfo_t *)os_memoryAlloc(pConn->hOs, sizeof(paramInfo_t));
    511     if (!pParam)
    512     {
    513         return TI_NOK;
    514     }
    515 
    516     pParam->paramType = RX_DATA_PORT_STATUS_PARAM;
    517     pParam->content.rxDataPortStatus = CLOSE;
    518     status = rxData_setParam(pConn->hRxData, pParam);
    519     if (status == TI_OK)
    520     {
    521         /* Update TxMgmtQueue SM to close Tx path for all except Mgmt packets. */
    522         txMgmtQ_SetConnState (pConn->hTxMgmtQ, TX_CONN_STATE_MGMT);
    523 
    524         status = mlme_stop( pConn->hMlmeSm, DISCONNECT_IMMEDIATE, pConn->disConnReasonToAP );
    525         if (status == TI_OK)
    526         {
    527             pParam->paramType = REGULATORY_DOMAIN_DISCONNECT_PARAM;
    528             regulatoryDomain_setParam(pConn->hRegulatoryDomain, pParam);
    529 
    530             /* Must be called AFTER mlme_stop. since De-Auth packet should be sent with the
    531                 supported rates, and stopModules clears all rates. */
    532             stopModules(pConn, TI_TRUE);
    533 
    534             /* send disconnect command to firmware */
    535             prepare_send_disconnect(pData);
    536         }
    537     }
    538     os_memoryFree(pConn->hOs, pParam, sizeof(paramInfo_t));
    539     return status;
    540 }
    541 
    542 static TI_STATUS connInfra_ScrWaitDisconn_to_disconnect(void *pData)
    543 {
    544     TI_STATUS status;
    545     paramInfo_t *pParam;
    546     conn_t *pConn = (conn_t *)pData;
    547 
    548     status = rsn_stop(pConn->hRsn, pConn->disConEraseKeys);
    549     if (status != TI_OK)
    550         return status;
    551 
    552     pParam = (paramInfo_t *)os_memoryAlloc(pConn->hOs, sizeof(paramInfo_t));
    553     if (!pParam)
    554     {
    555         return TI_NOK;
    556     }
    557 
    558     pParam->paramType = RX_DATA_PORT_STATUS_PARAM;
    559     pParam->content.rxDataPortStatus = CLOSE;
    560     status = rxData_setParam(pConn->hRxData, pParam);
    561     if (status == TI_OK)
    562     {
    563         /* Update TxMgmtQueue SM to close Tx path for all except Mgmt packets. */
    564         txMgmtQ_SetConnState(pConn->hTxMgmtQ, TX_CONN_STATE_MGMT);
    565 
    566         pParam->paramType = REGULATORY_DOMAIN_DISCONNECT_PARAM;
    567         regulatoryDomain_setParam(pConn->hRegulatoryDomain, pParam);
    568 
    569         status = mlme_stop(pConn->hMlmeSm, DISCONNECT_IMMEDIATE, pConn->disConnReasonToAP);
    570         if (status == TI_OK)
    571         {
    572             /* Must be called AFTER mlme_stop. since De-Auth packet should be sent with the
    573                 supported rates, and stopModules clears all rates. */
    574             stopModules(pConn, TI_TRUE);
    575 
    576             /* send disconnect command to firmware */
    577             prepare_send_disconnect(pData);
    578         }
    579     }
    580     os_memoryFree(pConn->hOs, pParam, sizeof(paramInfo_t));
    581     return status;
    582 
    583 }
    584 
    585 
    586 static TI_STATUS rsnWait_to_configHW(void *pData)
    587 {
    588     conn_t *pConn=(conn_t *)pData;
    589     TI_STATUS status;
    590     paramInfo_t *pParam;
    591 
    592     pParam = (paramInfo_t *)os_memoryAlloc(pConn->hOs, sizeof(paramInfo_t));
    593     if (!pParam)
    594     {
    595         return TI_NOK;
    596     }
    597 
    598     /* Open the RX to DATA */
    599     pParam->paramType = RX_DATA_PORT_STATUS_PARAM;
    600     pParam->content.rxDataPortStatus = OPEN;
    601     status = rxData_setParam(pConn->hRxData, pParam);
    602     os_memoryFree(pConn->hOs, pParam, sizeof(paramInfo_t));
    603     if (status != TI_OK)
    604          return status;
    605 
    606     status = qosMngr_connect(pConn->hQosMngr);
    607     if (status != TI_OK)
    608     {
    609          TRACE2(pConn->hReport, REPORT_SEVERITY_ERROR, "Infra Conn status=%d, have to return (%d)\n",status,__LINE__);
    610          return status;
    611     }
    612 
    613     status = measurementMgr_connected(pConn->hMeasurementMgr);
    614     if (status != TI_OK)
    615     {
    616          TRACE2(pConn->hReport, REPORT_SEVERITY_ERROR, "Infra Conn status=%d, have to return (%d)\n",status,__LINE__);
    617          return status;
    618     }
    619 
    620     status = TrafficMonitor_Start(pConn->hTrafficMonitor);
    621     if (status != TI_OK)
    622     {
    623          TRACE2(pConn->hReport, REPORT_SEVERITY_ERROR, "Infra Conn status=%d, have to return (%d)\n",status,__LINE__);
    624          return status;
    625     }
    626 
    627     healthMonitor_setState(pConn->hHealthMonitor, HEALTH_MONITOR_STATE_CONNECTED);
    628 
    629     switchChannel_start(pConn->hSwitchChannel);
    630 
    631     scanCncn_SwitchToConnected (pConn->hScanCncn);
    632 
    633     PowerMgr_startPS(pConn->hPwrMngr);
    634 
    635     TRACE1(pConn->hReport, REPORT_SEVERITY_INFORMATION, "rsnWait_to_configHW: setStaStatus %d\n",STA_STATE_CONNECTED);
    636     TWD_CmdSetStaState(pConn->hTWD, STA_STATE_CONNECTED, (void *)conn_ConfigHwFinishCb, pData);
    637 
    638     return TI_OK;
    639 }
    640 
    641 /* last command of rsnWait_to_configHW callback */
    642 int conn_ConfigHwFinishCb(TI_HANDLE pData)
    643 {
    644     conn_t *pConn = (conn_t *)pData;
    645 
    646     TRACE0(pConn->hReport, REPORT_SEVERITY_INFORMATION, "conn_MboxFlushFinishCb: called \n");
    647     return conn_infraSMEvent(&pConn->state, CONN_INFRA_HW_CONFIGURED, pConn);
    648 }
    649 
    650 static TI_STATUS configHW_to_connected(void *pData)
    651 {
    652     conn_t          *pConn=(conn_t *)pData;
    653     EScrResourceId  uResourceIndex;
    654 
    655     /* Update TxMgmtQueue SM to open Tx path to all packets. */
    656     txMgmtQ_SetConnState (((conn_t *)pData)->hTxMgmtQ, TX_CONN_STATE_OPEN);
    657 
    658 #ifdef XCC_MODULE_INCLUDED
    659     XCCMngr_updateIappInformation(pConn->hXCCMngr, XCC_ASSOC_OK);
    660 #endif
    661 
    662     /* Start keep alive process */
    663     siteMgr_start(pConn->hSiteMgr);
    664 
    665     /* free both SCR resources */
    666     for (uResourceIndex = SCR_RESOURCE_SERVING_CHANNEL;
    667          uResourceIndex < SCR_RESOURCE_NUM_OF_RESOURCES;
    668          uResourceIndex++)
    669     {
    670         scr_clientComplete(pConn->hScr, SCR_CID_CONNECT, uResourceIndex );
    671         pConn->scrRequested[ uResourceIndex ] = TI_FALSE;
    672     }
    673 
    674     /* Update current BSS connection type and mode */
    675     currBSS_updateConnectedState(pConn->hCurrBss, TI_TRUE, BSS_INFRASTRUCTURE);
    676 
    677     pConn->pConnStatusCB( pConn->connStatCbObj, STATUS_SUCCESSFUL, 0);
    678 
    679     SoftGemini_SetPSmode(pConn->hSoftGemini);
    680 #ifdef REPORT_LOG
    681     TRACE0(pConn->hReport, REPORT_SEVERITY_CONSOLE, "************ NEW CONNECTION ************\n");
    682     WLAN_OS_REPORT(("************ NEW CONNECTION ************\n"));
    683     siteMgr_printPrimarySiteDesc(pConn->hSiteMgr);
    684     TRACE0(pConn->hReport, REPORT_SEVERITY_CONSOLE, "****************************************\n");
    685     WLAN_OS_REPORT(("****************************************\n"));
    686 #else
    687     os_printf("%s: *** NEW CONNECTION ***\n", __func__);
    688 #endif
    689 
    690     return TI_OK;
    691 }
    692 
    693 
    694 static TI_STATUS actionUnexpected(void *pData)
    695 {
    696 #ifdef TI_DBG
    697     conn_t *pConn = (conn_t *)pData;
    698 
    699     TRACE0(pConn->hReport, REPORT_SEVERITY_SM, "State machine error, unexpected Event\n\n");
    700 #endif /*TI_DBG*/
    701 
    702     return TI_OK;
    703 }
    704 
    705 static TI_STATUS actionNop(void *pData)
    706 {
    707     return TI_OK;
    708 }
    709 
    710 
    711 static TI_STATUS connInfra_ScrWait(void *pData)
    712 {
    713     conn_t *pConn = (conn_t *)pData;
    714     EScrClientRequestStatus scrReplyStatus[ SCR_RESOURCE_NUM_OF_RESOURCES ];
    715     EScePendReason          scrPendReason[ SCR_RESOURCE_NUM_OF_RESOURCES ];
    716     EScrResourceId          uResourceIndex;
    717 
    718     TRACE0( pConn->hReport, REPORT_SEVERITY_INFORMATION, "Infra Connnect SM: Requesting SCR.\n");
    719 
    720     /* request the SCR for both resources, and act according to return status */
    721     for (uResourceIndex = SCR_RESOURCE_SERVING_CHANNEL;
    722          uResourceIndex < SCR_RESOURCE_NUM_OF_RESOURCES;
    723          uResourceIndex++)
    724     {
    725         scrReplyStatus[ uResourceIndex ] = scr_clientRequest( pConn->hScr, SCR_CID_CONNECT,
    726                                                               uResourceIndex,
    727                                                               &(scrPendReason[ uResourceIndex ]));
    728         pConn->scrRequested[ uResourceIndex ] = TI_TRUE;
    729 
    730         /* sanity check */
    731         if ((scrReplyStatus[ uResourceIndex ] > SCR_CRS_PEND) ||
    732             (scrReplyStatus[ uResourceIndex ] < SCR_CRS_RUN))
    733         {
    734             TRACE2(pConn->hReport, REPORT_SEVERITY_ERROR , "Idle_to_ScrWait: SCR for resource %d returned status %d\n", uResourceIndex, scrReplyStatus[ uResourceIndex ]);
    735             return TI_NOK;
    736         }
    737     }
    738 
    739     /* analyze SCR results: */
    740     /* both returned run - continue to next stage */
    741     if ((SCR_CRS_RUN == scrReplyStatus[ SCR_RESOURCE_SERVING_CHANNEL ]) &&
    742         (SCR_CRS_RUN == scrReplyStatus[ SCR_RESOURCE_PERIODIC_SCAN ]))
    743     {
    744         /* send an SCR SUCCESS event to the SM */
    745         TRACE0( pConn->hReport, REPORT_SEVERITY_INFORMATION, "Infra Conn: SCR acquired.\n");
    746         conn_infraSMEvent(&pConn->state, CONN_INFRA_SCR_SUCC, (TI_HANDLE) pConn);
    747     }
    748     else
    749     {
    750         /* mark which resource is pending (or both) */
    751         for (uResourceIndex = SCR_RESOURCE_PERIODIC_SCAN;
    752              uResourceIndex < SCR_RESOURCE_NUM_OF_RESOURCES;
    753              uResourceIndex++)
    754         {
    755             if (SCR_CRS_PEND == scrReplyStatus[ uResourceIndex ])
    756             {
    757                 TRACE2( pConn->hReport, REPORT_SEVERITY_INFORMATION, "Infra Conn: SCR pending for resource %d with pend reason: %d, stay in wait SCR state.\n", uResourceIndex, scrPendReason);
    758                 pConn->bScrAcquired[ uResourceIndex ] = TI_FALSE;
    759             }
    760             else
    761             {
    762                 pConn->bScrAcquired[ uResourceIndex ] = TI_TRUE;
    763             }
    764         }
    765     }
    766     return TI_OK;
    767 }
    768 
    769 
    770 
    771 void InfraConnSM_ScrCB( TI_HANDLE hConn, EScrClientRequestStatus requestStatus,
    772                         EScrResourceId eResource, EScePendReason pendReason )
    773 {
    774     conn_t *pConn = (conn_t *)hConn;
    775 
    776     TRACE2( pConn->hReport, REPORT_SEVERITY_INFORMATION, "InfraConnSM_ScrCB called by SCR for resource %d. Status is: %d.\n", eResource, requestStatus);
    777 
    778     /* act according to the request staus */
    779     switch ( requestStatus )
    780     {
    781     case SCR_CRS_RUN:
    782         TRACE0( pConn->hReport, REPORT_SEVERITY_INFORMATION, "Infra Conn: SCR acquired.\n");
    783         /* mark that the SCR was acquired for this resource */
    784         pConn->bScrAcquired[ eResource ] = TI_TRUE;
    785 
    786         /* if both resources had now been acquired */
    787         if ((TI_TRUE == pConn->bScrAcquired[ SCR_RESOURCE_SERVING_CHANNEL ]) &&
    788             (TI_TRUE == pConn->bScrAcquired[ SCR_RESOURCE_PERIODIC_SCAN ]))
    789         {
    790             /* send an SCR SUCCESS event to the SM */
    791             conn_infraSMEvent(&pConn->state, CONN_INFRA_SCR_SUCC, (TI_HANDLE) pConn);
    792         }
    793         break;
    794 
    795     case SCR_CRS_FW_RESET:
    796         /* Ignore FW reset, the MLME SM will handle re-try of the conn */
    797         TRACE0( pConn->hReport, REPORT_SEVERITY_INFORMATION, "Infra Conn: Recovery occured.\n");
    798         break;
    799 
    800     default:
    801         TRACE3( pConn->hReport, REPORT_SEVERITY_ERROR, "Illegal SCR request status:%d, pend reason:%d, resource: %d.\n", requestStatus, pendReason, eResource);
    802         break;
    803     }
    804 }
    805 
    806 
    807 
    808 static TI_STATUS ScrWait_to_idle(void *pData)
    809 {
    810     conn_t          *pConn = (conn_t *)pData;
    811     EScrResourceId  uResourceIndex;
    812 
    813     TRACE0( pConn->hReport, REPORT_SEVERITY_INFORMATION, "Infra Connnect SM: Stop event while in SCR wait, moving to IDLE.\n");
    814 
    815     /* free both SCR resources */
    816     for (uResourceIndex = SCR_RESOURCE_SERVING_CHANNEL;
    817          uResourceIndex < SCR_RESOURCE_NUM_OF_RESOURCES;
    818          uResourceIndex++)
    819     {
    820         scr_clientComplete(pConn->hScr, SCR_CID_CONNECT, uResourceIndex );
    821         pConn->scrRequested[ uResourceIndex ] = TI_FALSE;
    822     }
    823 
    824     /*
    825      * Call the connection lost callback set by the SME or AP_CONN.
    826      */
    827     pConn->pConnStatusCB( pConn->connStatCbObj, pConn->smContext.disAssocEventReason, pConn->smContext.disAssocEventStatusCode);
    828 
    829     return TI_OK;
    830 }
    831 
    832 
    833 static TI_STATUS stopModules( conn_t *pConn, TI_BOOL bDisconnect )
    834 {
    835 
    836     measurementMgr_disconnected(pConn->hMeasurementMgr);
    837 
    838     rxData_stop(pConn->hRxData);
    839 
    840     ctrlData_stop(pConn->hCtrlData);
    841 
    842     TrafficMonitor_Stop(pConn->hTrafficMonitor);
    843 
    844     switchChannel_stop(pConn->hSwitchChannel);
    845 
    846     healthMonitor_setState(pConn->hHealthMonitor, HEALTH_MONITOR_STATE_DISCONNECTED);
    847 
    848     siteMgr_stop(pConn->hSiteMgr);
    849 
    850     /* stopping power save */
    851     PowerMgr_stopPS(pConn->hPwrMngr, bDisconnect);
    852 
    853     scanCncn_SwitchToNotConnected (pConn->hScanCncn);
    854 
    855     /* Set Current BSS Module to stop triggerring roaming events */
    856     currBSS_updateConnectedState(pConn->hCurrBss, TI_FALSE, BSS_INFRASTRUCTURE);
    857 
    858     SoftGemini_unSetPSmode(pConn->hSoftGemini);
    859 
    860     return TI_OK;
    861 }
    862 
    863 
    864 static TI_STATUS prepare_send_disconnect(void *pData)
    865 {
    866     conn_t          *pConn = (conn_t *)pData;
    867 
    868     txCtrlParams_setEapolEncryptionStatus(pConn->hTxCtrl, DEF_EAPOL_ENCRYPTION_STATUS);
    869     qosMngr_disconnect (pConn->hQosMngr, TI_TRUE);
    870 
    871 #ifdef XCC_MODULE_INCLUDED
    872     measurementMgr_disableTsMetrics(pConn->hMeasurementMgr, MAX_NUM_OF_AC);
    873 #endif
    874 
    875     /* Start the disconnect complete time out timer.
    876        Disconect Complete event, which stops the timer. */
    877     tmr_StartTimer (pConn->hConnTimer, conn_timeout, (TI_HANDLE)pConn, DISCONNECT_TIMEOUT_MSEC, TI_FALSE);
    878 
    879     /* FW will send the disconn frame according to disConnType */
    880     TWD_CmdFwDisconnect (pConn->hTWD, pConn->disConnType, pConn->disConnReasonToAP);
    881 
    882 #ifdef XCC_MODULE_INCLUDED
    883     XCCMngr_updateIappInformation(pConn->hXCCMngr, XCC_DISASSOC);
    884 #endif
    885 
    886     return TI_OK;
    887 }
    888 
    889 static TI_STATUS connInfra_WaitDisconnectToIdle(void *pData)
    890 {
    891     conn_t          *pConn = (conn_t *)pData;
    892     EScrResourceId  uResourceIndex;
    893 
    894     /* close all BA sessions */
    895     TWD_CloseAllBaSessions(pConn->hTWD);
    896 
    897     /* Stop the disconnect timeout timer. */
    898     tmr_StopTimer (pConn->hConnTimer);
    899 
    900     /*
    901      * In case of connection failuer we might get here without freeing the SCR.
    902      */
    903     for (uResourceIndex = SCR_RESOURCE_SERVING_CHANNEL;
    904          uResourceIndex < SCR_RESOURCE_NUM_OF_RESOURCES;
    905          uResourceIndex++)
    906     {
    907         if (pConn->scrRequested[ uResourceIndex ] == TI_TRUE)
    908         {
    909             scr_clientComplete(pConn->hScr, SCR_CID_CONNECT, uResourceIndex );
    910             pConn->scrRequested[ uResourceIndex ] = TI_FALSE;
    911         }
    912     }
    913 
    914     /*
    915      * Call the connection lost callback set by the SME or AP_CONN.
    916      */
    917     pConn->pConnStatusCB( pConn->connStatCbObj, pConn->smContext.disAssocEventReason, pConn->smContext.disAssocEventStatusCode);
    918 
    919     return TI_OK;
    920 }
    921 
    922 static TI_STATUS connect_to_ScrWait(void *pData)
    923 {
    924     TI_STATUS   status;
    925     paramInfo_t *pParam;
    926     conn_t      *pConn = (conn_t *)pData;
    927 
    928     /*
    929      * This function performs roaming by two steps:
    930      * First - close the current connection without notify the SME.
    931      * Second - start new connection in reassociation mode.
    932      */
    933 
    934     /* close all BA sessions */
    935     TWD_CloseAllBaSessions(pConn->hTWD);
    936 
    937     status = rsn_stop(pConn->hRsn, pConn->disConEraseKeys);
    938     if (status != TI_OK)
    939         return status;
    940 
    941     pParam = (paramInfo_t *)os_memoryAlloc(pConn->hOs, sizeof(paramInfo_t));
    942     if (!pParam)
    943     {
    944         return TI_NOK;
    945     }
    946 
    947     pParam->paramType = RX_DATA_PORT_STATUS_PARAM;
    948     pParam->content.rxDataPortStatus = CLOSE;
    949     status = rxData_setParam(pConn->hRxData, pParam);
    950     if (status == TI_OK)
    951     {
    952         /* Update TxMgmtQueue SM to close Tx path. */
    953         txMgmtQ_SetConnState (((conn_t *)pData)->hTxMgmtQ, TX_CONN_STATE_CLOSE);
    954 
    955         status = mlme_stop(pConn->hMlmeSm, DISCONNECT_IMMEDIATE, pConn->disConnReasonToAP);
    956         if (status == TI_OK)
    957         {
    958             pParam->paramType = REGULATORY_DOMAIN_DISCONNECT_PARAM;
    959             regulatoryDomain_setParam(pConn->hRegulatoryDomain, pParam);
    960 
    961 #ifdef XCC_MODULE_INCLUDED
    962             XCCMngr_updateIappInformation(pConn->hXCCMngr, XCC_DISASSOC);
    963 #endif
    964         /* Must be called AFTER mlme_stop. since De-Auth packet should be sent with the
    965             supported rates, and stopModules clears all rates. */
    966             stopModules(pConn, TI_FALSE);
    967 
    968             txCtrlParams_setEapolEncryptionStatus(pConn->hTxCtrl, DEF_EAPOL_ENCRYPTION_STATUS);
    969             qosMngr_disconnect (pConn->hQosMngr, TI_FALSE);
    970 
    971         /*
    972          * Start new connection.
    973          */
    974             connInfra_ScrWait(pConn);
    975         }
    976     }
    977 
    978     os_memoryFree(pConn->hOs, pParam, sizeof(paramInfo_t));
    979     return status;
    980 }
    981 
    982 static TI_STATUS Idle_to_Idle(void *pData)
    983 {
    984     conn_t *pConn = (conn_t *)pData;
    985 
    986     /*
    987      * In case we are in IDLE and getting DISCONNECT event, we need to inform
    988      * the SME\AP_connection that we are disconnected.
    989      * Call the connection lost callback set by the SME or AP_CONN.
    990      */
    991     pConn->pConnStatusCB( pConn->connStatCbObj, pConn->smContext.disAssocEventReason, pConn->smContext.disAssocEventStatusCode);
    992 
    993     return TI_OK;
    994 }
    995 
    996 /***********************************************************************
    997                 connInfra_JoinCmpltNotification
    998  ***********************************************************************
    999 DESCRIPTION: Call back upon receving Join Event Complete.
   1000 
   1001 INPUT:      hSiteMgr    -   site mgr handle.
   1002 
   1003 OUTPUT:
   1004 
   1005 RETURN:
   1006 ************************************************************************/
   1007 TI_STATUS connInfra_JoinCmpltNotification(TI_HANDLE hconn)
   1008 {
   1009     conn_t *pConn = (conn_t *)hconn;
   1010 
   1011     TRACE0(pConn->hReport, REPORT_SEVERITY_INFORMATION, "connInfra_JoinCmpltNotification: has been called\n");
   1012 
   1013    if (pConn->currentConnType == CONNECTION_INFRA ) {
   1014        conn_infraSMEvent(&pConn->state, CONN_INFRA_JOIN_CMD_CMPLT, pConn);
   1015    }
   1016 
   1017    return TI_OK;
   1018 }
   1019 
   1020 void connInfra_DisconnectComplete (conn_t *pConn, TI_UINT8  *data, TI_UINT8   dataLength)
   1021 {
   1022     /* send an DISCONNECT COMPLETE event to the SM */
   1023     conn_infraSMEvent(&pConn->state, CONN_INFRA_DISCONN_COMPLETE, (TI_HANDLE) pConn);
   1024 }
   1025