wlan: 11r CR fix integrated from Dev/11r: CL657576, CL 657577, CL658596

11r functional in Open mode

Change-Id: I53d4ec6f42a87a34b1a76887f6ea18daf0633c65
CR-Fixed: 414160, 412790, 414160, 418066
diff --git a/CORE/MAC/src/pe/lim/limSendManagementFrames.c b/CORE/MAC/src/pe/lim/limSendManagementFrames.c
index 42c9875..a291a03 100644
--- a/CORE/MAC/src/pe/lim/limSendManagementFrames.c
+++ b/CORE/MAC/src/pe/lim/limSendManagementFrames.c
@@ -2650,16 +2650,6 @@
         return;
     }
 
-#if defined WLAN_FEATURE_VOWIFI_11R
-    if (psessionEntry->is11Rconnection)
-    {
-        if (pMac->ft.ftSmeContext.reassoc_ft_ies_length == 0)
-        {
-            return;
-        }
-    }
-#endif
-
     /* check this early to avoid unncessary operation */
     if(NULL == psessionEntry->pLimReAssocReq)
     {
@@ -2852,6 +2842,13 @@
         PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
     }
 
+#if defined WLAN_FEATURE_VOWIFI_11R
+    if ( psessionEntry->pLimReAssocReq->bssDescription.mdiePresent && (0 == pMac->ft.ftSmeContext.reassoc_ft_ies_length) )
+    {
+        PopulateMDIE( pMac, &frm.MobilityDomain, psessionEntry->pLimReAssocReq->bssDescription.mdie);
+    }
+#endif
+
     nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
     if ( DOT11F_FAILED( nStatus ) )
     {
@@ -2976,8 +2973,8 @@
     }
 
 #ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
-    PELOGE(limLog(pMac, LOGE, FL("Re-assoc Req Frame is: "));
-            sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOGE,
+    PELOGE(limLog(pMac, LOG1, FL("Re-assoc Req Frame is: "));
+            sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG1,
                 (tANI_U8 *)pFrame,
                 (nBytes + ft_ies_length));)
 #endif
@@ -3003,6 +3000,7 @@
                            (ft_ies_length))) != eHAL_STATUS_SUCCESS )
     {
         PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
+        psessionEntry->assocReqLen = 0;
     }
     else
     {
@@ -3475,14 +3473,17 @@
 #if defined WLAN_FEATURE_VOWIFI_11R
                 if (pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH)
                 {
-                    if (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies) 
+                    if (0 != pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length) 
                     {
                         frameLen += pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length;
                         limLog(pMac, LOG3, FL("Auth frame, FTIES length added=%d\n"), 
                         pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length);
                     }
-                    else 
+                    else
+                    {
                         limLog(pMac, LOG3, FL("Auth frame, Does not contain FTIES!!!\n"));
+                    	frameLen += (2+SIR_MDIE_SIZE);
+                    }
                 }
 #endif
                 break;
@@ -3623,19 +3624,32 @@
 
             {
                 int i = 0;
-#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
                 if (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length) 
                 {
+#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
                     PELOGE(limLog(pMac, LOGE, FL("Auth1 Frame FTIE is: "));
                         sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOGE,
                             (tANI_U8 *)pBody,
                             (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length));)
-                }
 #endif
-                for (i=0; i<pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length; i++)
-                {
-                    *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies[i];
+                    for (i=0; i<pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length; i++)
+                    {
+                       *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies[i];
+                       pBody++;
+                    }
+                }
+                else
+                { 
+                    /* MDID attr is 54*/
+                    *pBody = 54;
                     pBody++;
+                    *pBody = SIR_MDIE_SIZE;
+                    pBody++;
+                    for(i=0;i<SIR_MDIE_SIZE;i++)
+                    {
+                      *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->pbssDescription->mdie[i];
+                       pBody++;
+                    }
                 }
             }
         }
diff --git a/CORE/SME/inc/csrSupport.h b/CORE/SME/inc/csrSupport.h
index 139e549..f54386f 100644
--- a/CORE/SME/inc/csrSupport.h
+++ b/CORE/SME/inc/csrSupport.h
@@ -813,7 +813,7 @@
 
 #ifdef WLAN_FEATURE_VOWIFI_11R
 tANI_BOOLEAN csrIsProfile11r( tCsrRoamProfile *pProfile );
-tANI_BOOLEAN csrIsAuthType11r( eCsrAuthType AuthType );
+tANI_BOOLEAN csrIsAuthType11r( eCsrAuthType AuthType, tANI_U8 mdiePresent);
 #endif
 
 #ifdef FEATURE_WLAN_CCX
diff --git a/CORE/SME/src/csr/csrApiRoam.c b/CORE/SME/src/csr/csrApiRoam.c
index fc06ea3..8069786 100644
--- a/CORE/SME/src/csr/csrApiRoam.c
+++ b/CORE/SME/src/csr/csrApiRoam.c
@@ -11412,6 +11412,7 @@
         palCopyMemory( pMac->hHdd, pBuf, &dwTmp, sizeof(tANI_U32) );
         pBuf += sizeof(tANI_U32);        
 #ifdef WLAN_FEATURE_VOWIFI_11R
+        pProfile->MDID.mdiePresent = pBssDescription->mdiePresent;
         if (csrIsProfile11r( pProfile ) )
         {
             // is11Rconnection;
@@ -14925,7 +14926,8 @@
     palCopyMemory(pMac->hHdd, (void *)&pftPreAuthReq->preAuthbssId, (void *)pBssDescription->bssId, sizeof(tSirMacAddr));  
 
 #ifdef WLAN_FEATURE_VOWIFI_11R
-    if (csrRoamIs11rAssoc(pMac))
+    if (csrRoamIs11rAssoc(pMac) && 
+          (pMac->roam.roamSession[sessionId].connectedProfile.AuthType != eCSR_AUTH_TYPE_OPEN_SYSTEM))
     {
         pftPreAuthReq->ft_ies_length = (tANI_U16)pMac->ft.ftSmeContext.auth_ft_ies_length;
         palCopyMemory(pMac->hHdd, pftPreAuthReq->ft_ies, pMac->ft.ftSmeContext.auth_ft_ies, 
diff --git a/CORE/SME/src/csr/csrNeighborRoam.c b/CORE/SME/src/csr/csrNeighborRoam.c
index 6a5a673..75d6f36 100644
--- a/CORE/SME/src/csr/csrNeighborRoam.c
+++ b/CORE/SME/src/csr/csrNeighborRoam.c
@@ -2960,7 +2960,8 @@
             
 #ifdef WLAN_FEATURE_VOWIFI_11R
             // Based on the auth scheme tell if we are 11r
-            if ( csrIsAuthType11r( pMac->roam.roamSession[sessionId].connectedProfile.AuthType ) )
+            if ( csrIsAuthType11r( pMac->roam.roamSession[sessionId].connectedProfile.AuthType, 
+                                   pMac->roam.roamSession[sessionId].connectedProfile.MDID.mdiePresent))
             {
                 if (pMac->roam.configParam.isFastTransitionEnabled)
                     init_ft_flag = TRUE;
@@ -3407,7 +3408,7 @@
     return eANI_BOOLEAN_FALSE;
 }
 
-#ifdef WLAN_FEATURE_VOWIFI_11R
+#if defined(WLAN_FEATURE_VOWIFI_11R) || defined(WLAN_FEATURE_NEIGHBOR_ROAMING)
 /* ---------------------------------------------------------------------------
 
     \fn csrNeighborRoamIs11rAssoc
diff --git a/CORE/SME/src/csr/csrUtil.c b/CORE/SME/src/csr/csrUtil.c
index 77e468f..5689d81 100644
--- a/CORE/SME/src/csr/csrUtil.c
+++ b/CORE/SME/src/csr/csrUtil.c
@@ -3028,10 +3028,14 @@
 
 #ifdef WLAN_FEATURE_VOWIFI_11R
 /* Function to return TRUE if the authtype is 11r */
-tANI_BOOLEAN csrIsAuthType11r( eCsrAuthType AuthType )
+tANI_BOOLEAN csrIsAuthType11r( eCsrAuthType AuthType, tANI_U8 mdiePresent)
 {
     switch ( AuthType )
     {
+        case eCSR_AUTH_TYPE_OPEN_SYSTEM:
+            if(mdiePresent)
+                return TRUE;
+            break; 
         case eCSR_AUTH_TYPE_FT_RSN_PSK:
         case eCSR_AUTH_TYPE_FT_RSN:
             return TRUE;
@@ -3045,7 +3049,7 @@
 /* Function to return TRUE if the profile is 11r */
 tANI_BOOLEAN csrIsProfile11r( tCsrRoamProfile *pProfile )
 {
-    return csrIsAuthType11r( pProfile->negotiatedAuthType );
+    return csrIsAuthType11r( pProfile->negotiatedAuthType, pProfile->MDID.mdiePresent );
 }
 
 #endif