wlan: Do not wait for supplicant to transit the STA to authorized.

wlan: fix for WEP with EAP-SIM/AKA method insists to wait
for the supplicant to set the STA to authorized state.
Relying on Supplicant to move the station to authorized results
in the delay in 11R/LFR roam times. This commit shall not
depend on supplicant to move the station/port to the authorized
mode.

CRs-fixed: 490485
Change-Id: I1cd27973d1ca8dc5a028f4455f57648f23a59798
diff --git a/CORE/HDD/src/wlan_hdd_assoc.c b/CORE/HDD/src/wlan_hdd_assoc.c
index d513061..2eb2152 100644
--- a/CORE/HDD/src/wlan_hdd_assoc.c
+++ b/CORE/HDD/src/wlan_hdd_assoc.c
@@ -1018,12 +1018,14 @@
       return vosStatus;
    }
 
-   // if ( WPA ), tell TL to go to 'connected' and after keys come to the driver,
-
+   // if (WPA), tell TL to go to 'connected' and after keys come to the driver,
+   // then go to 'authenticated'.  For all other authentication types
+   // (those that donot require upper layer authentication) we can put
+   // TL directly into 'authenticated' state.
    if (staDesc.wSTAType != WLAN_STA_IBSS)
       VOS_ASSERT( fConnected );
 
-   if ( !pRoamInfo->fAuthRequired && (WLAN_STA_IBSS == staDesc.wSTAType) )
+   if ( !pRoamInfo->fAuthRequired )
    {
       // Connections that do not need Upper layer auth, transition TL directly
       // to 'Authenticated' state.
@@ -1035,8 +1037,8 @@
    else
    {
       VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
-              "ULA auth StaId= %d.  Changing TL state to CONNECTED at Join time",
-              pHddStaCtx->conn_info.staId[0] );
+                 "ULA auth StaId= %d. Changing TL state to CONNECTED"
+                 "at Join time", pHddStaCtx->conn_info.staId[0] );
       vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, staDesc.ucSTAId,
                                       WLANTL_STA_CONNECTED );
       pHddStaCtx->conn_info.uIsAuthenticated = VOS_FALSE;
@@ -1361,12 +1363,23 @@
 
             hdd_SendReAssocEvent(dev, pAdapter, pRoamInfo, reqRsnIe, reqRsnLength);
             //Reassoc successfully
-            vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, pHddStaCtx->conn_info.staId[ 0 ],
-                     WLANTL_STA_CONNECTED );
-            VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
-                     "%s: staId: %d Changing TL state to CONNECTED",
-                     __func__, pHddStaCtx->conn_info.staId[0]);
-            pHddStaCtx->conn_info.uIsAuthenticated = VOS_FALSE;
+            if( pRoamInfo->fAuthRequired )
+            {
+                vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
+                                                   pHddStaCtx->conn_info.staId[ 0 ],
+                                                   WLANTL_STA_CONNECTED );
+                pHddStaCtx->conn_info.uIsAuthenticated = VOS_FALSE;
+            }
+            else
+            {
+                VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
+                          "%s: staId: %d Changing TL state to AUTHENTICATED",
+                          __func__, pHddStaCtx->conn_info.staId[ 0 ] );
+                vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
+                                                   pHddStaCtx->conn_info.staId[ 0 ],
+                                                   WLANTL_STA_AUTHENTICATED );
+                pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
+            }
         }
 
         if ( VOS_IS_STATUS_SUCCESS( vosStatus ) )
@@ -1757,13 +1770,40 @@
       }
       else
       {
-          // TODO: Considering getting a state machine in HDD later.
-          // This routuine is invoked twice. 1)set PTK 2)set GTK.
-          vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
-                                            pHddStaCtx->conn_info.staId[ 0 ]);
-          pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
+         // TODO: Considering getting a state machine in HDD later.
+         // This routine is invoked twice. 1)set PTK 2)set GTK.
+         // The folloing if statement will be TRUE when setting GTK.
+         // At this time we don't handle the state in detail.
+         // Related CR: 174048 - TL not in authenticated state
+         if ( ( eCSR_ROAM_RESULT_AUTHENTICATED == roamResult ) &&
+             (pRoamInfo != NULL) && !pRoamInfo->fAuthRequired )
+         {
+            VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED, "Key set "
+                       "for StaId= %d.  Changing TL state to AUTHENTICATED",
+                       pHddStaCtx->conn_info.staId[ 0 ] );
+
+            // Connections that do not need Upper layer authentication,
+            // transition TL to 'Authenticated' state after the keys are set.
+            vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
+                                               pHddStaCtx->conn_info.staId[ 0 ],
+                                               WLANTL_STA_AUTHENTICATED );
+
+            pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
+         }
+         else
+         {
+            vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
+                                                pHddStaCtx->conn_info.staId[ 0 ]);
+         }
+
+         pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
       }
    }
+   else
+   {
+      // possible disassoc after issuing set key and waiting set key complete
+      pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
+   }
 
    EXIT();
    return( eHAL_STATUS_SUCCESS );