Merge "wlan: Set SAE auth type for PMKID cached connect request"
diff --git a/CORE/HDD/src/wlan_hdd_assoc.c b/CORE/HDD/src/wlan_hdd_assoc.c
index d08e1b3..bb6fa46 100644
--- a/CORE/HDD/src/wlan_hdd_assoc.c
+++ b/CORE/HDD/src/wlan_hdd_assoc.c
@@ -4996,6 +4996,12 @@
                                             eCSR_AUTH_TYPE_RSN_8021X_SHA256;
             } else
 #endif
+            if ((RSNAuthType == eCSR_AUTH_TYPE_SAE) &&
+                ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
+                 == IW_AUTH_KEY_MGMT_802_1X)) {
+                 /* SAE case */
+                 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_SAE;
+            } else
             if ((RSNAuthType == eCSR_AUTH_TYPE_OWE) &&
                 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
                  == IW_AUTH_KEY_MGMT_802_1X)) {
diff --git a/CORE/MAC/inc/sirApi.h b/CORE/MAC/inc/sirApi.h
index 34b8c17..768c989 100644
--- a/CORE/MAC/inc/sirApi.h
+++ b/CORE/MAC/inc/sirApi.h
@@ -1079,6 +1079,7 @@
     tSirBssType         bsstype;                // add new type for BT -AMP STA and AP Modules
     tANI_U8             dot11mode;              // to support BT-AMP     
     tVOS_CON_MODE       staPersona;             //Persona
+    bool                sae_pmk_cached;
     tANI_BOOLEAN        bOSENAssociation;       //HS2.0
     tANI_BOOLEAN        bWPSAssociation;       //WPS
     ePhyChanBondState   cbMode;                 // Pass CB mode value in Join.
@@ -1147,7 +1148,6 @@
     tSirSupChnl         supportedChannels;
     bool force_24ghz_in_ht20;
     bool force_rsne_override;
-    bool sae_pmk_cached;
     tSirBssDescription  bssDescription;
     /*
      * WARNING: Pls make bssDescription as last variable in struct
diff --git a/CORE/MAC/src/pe/lim/limProcessAuthFrame.c b/CORE/MAC/src/pe/lim/limProcessAuthFrame.c
index 7998f83..0abfed6 100644
--- a/CORE/MAC/src/pe/lim/limProcessAuthFrame.c
+++ b/CORE/MAC/src/pe/lim/limProcessAuthFrame.c
@@ -1226,8 +1226,8 @@
                            FL("received Auth frame2 for unexpected auth algo num %d "
                            MAC_ADDRESS_STR), pRxAuthFrameBody->authAlgoNumber,
                            MAC_ADDR_ARRAY(pHdr->sa));)
+                    break;
                 }
-                break;
             }
 
             if (pRxAuthFrameBody->authStatusCode ==
diff --git a/CORE/MAC/src/pe/lim/limSerDesUtils.c b/CORE/MAC/src/pe/lim/limSerDesUtils.c
index 6e14ba5..ea0ebf4 100644
--- a/CORE/MAC/src/pe/lim/limSerDesUtils.c
+++ b/CORE/MAC/src/pe/lim/limSerDesUtils.c
@@ -992,6 +992,13 @@
         limLog(pMac, LOGE, FL("remaining len %d is too short"), len);
         return eSIR_FAILURE;
     }
+    pJoinReq->sae_pmk_cached = *pBuf++;
+    len--;
+    if (limCheckRemainingLength(pMac, len) == eSIR_FAILURE)
+    {
+        limLog(pMac, LOGE, FL("remaining len %d is too short"), len);
+        return eSIR_FAILURE;
+    }
 
     pJoinReq->bOSENAssociation = *pBuf++;
     len--;
diff --git a/CORE/SME/src/csr/csrApiRoam.c b/CORE/SME/src/csr/csrApiRoam.c
index d0332a7..64500d7 100644
--- a/CORE/SME/src/csr/csrApiRoam.c
+++ b/CORE/SME/src/csr/csrApiRoam.c
@@ -12881,20 +12881,20 @@
     uint16_t cache_idx = pSession->CurCacheIndex;
 
     /* Add entry to the cache */
+    pSession->PmkidCacheInfo[cache_idx].ssid_len = 0;
     if (!pmksa->ssid_len) {
-        vos_copy_macaddr(
-                (v_MACADDR_t *)pSession->PmkidCacheInfo[cache_idx].BSSID,
-                (v_MACADDR_t *)pmksa->BSSID);
-        pSession->PmkidCacheInfo[cache_idx].ssid_len = 0;
-    } else {
         vos_mem_copy(pSession->PmkidCacheInfo[cache_idx].ssid,
                 pmksa->ssid, pmksa->ssid_len);
         pSession->PmkidCacheInfo[cache_idx].ssid_len =
             pmksa->ssid_len;
-        vos_mem_copy(pSession->PmkidCacheInfo[cache_idx].cache_id,
-                pmksa->cache_id, CACHE_ID_LEN);
-
     }
+
+    vos_copy_macaddr(
+            (v_MACADDR_t *)pSession->PmkidCacheInfo[cache_idx].BSSID,
+            (v_MACADDR_t *)pmksa->BSSID);
+    vos_mem_copy(pSession->PmkidCacheInfo[cache_idx].cache_id,
+            pmksa->cache_id, CACHE_ID_LEN);
+
     vos_mem_copy(
             pSession->PmkidCacheInfo[cache_idx].PMKID,
             pmksa->PMKID, CSR_RSN_PMKID_SIZE);
@@ -13437,27 +13437,30 @@
  *
  * Return: None
  */
-static void csr_update_sae_config(tSirSmeJoinReq *csr_join_req,
-                                  tpAniSirGlobal mac, tCsrRoamSession *session)
+static bool csr_update_sae_config(tSirMacAddr bssid, tpAniSirGlobal mac,
+                                  tCsrRoamSession *session)
 {
     tPmkidCacheInfo pmkid_cache;
     uint32_t index;
+    bool sae_pmk_cached;
 
-    vos_mem_copy(pmkid_cache.BSSID, csr_join_req->bssDescription.bssId,
-                 VOS_MAC_ADDR_SIZE);
+    vos_mem_copy(pmkid_cache.BSSID, bssid, VOS_MAC_ADDR_SIZE);
 
-    csr_join_req->sae_pmk_cached =
+    sae_pmk_cached =
               csr_lookup_pmkid_using_bssid(mac, session, &pmkid_cache, &index);
 
     VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
-              "pmk_cached %d for BSSID=" MAC_ADDRESS_STR,
-              csr_join_req->sae_pmk_cached,
-              MAC_ADDR_ARRAY(csr_join_req->bssDescription.bssId));
+              "pmk_cached %d for BSSID=" MAC_ADDRESS_STR, sae_pmk_cached,
+              MAC_ADDR_ARRAY(bssid));
+
+    return sae_pmk_cached;
 }
 #else
-static void csr_update_sae_config(tSirSmeJoinReq *csr_join_req,
-                                  tpAniSirGlobal mac, tCsrRoamSession *session)
-{ }
+static bool csr_update_sae_config(tSirMacAddr bssid, tpAniSirGlobal mac,
+                                  tCsrRoamSession *session)
+{
+    return false;
+}
 #endif
 
 ////////////////////Mail box
@@ -13659,6 +13662,8 @@
         //Persona
         *pBuf = (tANI_U8)pProfile->csrPersona;
         pBuf++;
+        *pBuf = csr_update_sae_config(pBssDescription->bssId, pMac, pSession);
+        pBuf++;
         *pBuf = (tANI_U8)pProfile->bOSENAssociation;
         pBuf++;
         *pBuf = (tANI_U8)pProfile->bWPSAssociation;
@@ -14198,8 +14203,6 @@
         csrPrepareJoinReassocReqBuffer( pMac, pBssDescription, pBuf,
                 (tANI_U8)pProfile->uapsd_mask);
 
-        csr_update_sae_config(pMsg, pMac, pSession);
-
         status = palSendMBMessage(pMac->hHdd, pMsg );
         /* Memory allocated to pMsg will get free'd in palSendMBMessage */
         pMsg = NULL;
@@ -15787,7 +15790,7 @@
         //Persona
         *pBuf = (tANI_U8)pParam->bssPersona;
         pBuf++;
-        
+
         //txLdpcIniFeatureEnabled
         *pBuf = (tANI_U8)(tANI_U8)pMac->roam.configParam.txLdpcEnable;
         pBuf++;