wlan: Support SAP Auth Offload feature

For SAP Auth offload, station assoc and disassoc will happen
in firmware.
As soon driver is in waked up state, firmware
will send Assoc or disassoc indication to host.
In case of ADD STA indication, driver will parse all caps
of connected client and will register this client to TL and HDD.
In case of DEL STA indication, driver will remove entry for
this station and will start cleanup.

Change-Id: I8ab0cc906be97be6f1f61de3e2ac9359cb7d17b0
CRs-Fixed: 753731
diff --git a/CORE/MAC/src/pe/lim/limProcessSmeReqMessages.c b/CORE/MAC/src/pe/lim/limProcessSmeReqMessages.c
index 72840ab..8c02628 100644
--- a/CORE/MAC/src/pe/lim/limProcessSmeReqMessages.c
+++ b/CORE/MAC/src/pe/lim/limProcessSmeReqMessages.c
@@ -4063,7 +4063,94 @@
 
 } /*** end __limProcessSmeAssocCnfNew() ***/
 
+#ifdef SAP_AUTH_OFFLOAD
+/**
+ * __lim_process_sme_assoc_offload_cnf() station connection confirmation
+ *                          message from SME.
+ * @pMac: SirGlobal handler
+ * @msgType: message type
+ * @pMsgBuf: message body
+ *
+ * This function handles the station connect confirm of
+ * Software AP authentication offload feature
+ *
+ * Return: None
+ */
+    static void
+__lim_process_sme_assoc_offload_cnf(tpAniSirGlobal pmac,
+        tANI_U32 msg_type,
+        tANI_U32 *pmsg_buf)
+{
+    tSirSmeAssocCnf assoc_cnf;
+    tpDphHashNode sta_ds = NULL;
+    tpPESession psession_entry= NULL;
+    tANI_U8 session_id;
+    tANI_U16 aid=0;
 
+    if (pmsg_buf == NULL)
+    {
+        limLog(pmac, LOGE, FL("pmsg_buf is NULL "));
+        return;
+    }
+
+    if ((limAssocCnfSerDes(pmac, &assoc_cnf, (tANI_U8 *) pmsg_buf) ==
+                eSIR_FAILURE) || !__limIsSmeAssocCnfValid(&assoc_cnf))
+    {
+        limLog(pmac, LOGE, FL("Received invalid SME_RE(ASSOC)_CNF message "));
+        return;
+    }
+
+    if((psession_entry =
+               peFindSessionByBssid(pmac, assoc_cnf.bssId, &session_id))== NULL)
+    {
+        limLog(pmac, LOGE, FL("session does not exist for given bssId"));
+        goto end;
+    }
+
+    if ((!LIM_IS_AP_ROLE(psession_entry)) ||
+           ((psession_entry->limSmeState != eLIM_SME_NORMAL_STATE) &&
+           (psession_entry->limSmeState != eLIM_SME_NORMAL_CHANNEL_SCAN_STATE)))
+    {
+        limLog(pmac, LOGE,
+                FL("Received unexpected message %X in state %X, in role %X"),
+                msg_type, psession_entry->limSmeState,
+                GET_LIM_SYSTEM_ROLE(psession_entry));
+        goto end;
+    }
+    sta_ds = dphGetHashEntry(pmac,
+            assoc_cnf.aid,
+            &psession_entry->dph.dphHashTable);
+    if (sta_ds != NULL)
+    {
+        aid = sta_ds->assocId;
+        /* Deactivate/delete CNF_WAIT timer since ASSOC_CNF
+         * has been received */
+        limDeactivateAndChangePerStaIdTimer(pmac,
+                eLIM_CNF_WAIT_TIMER,
+                aid);
+    }
+
+end:
+    if((psession_entry != NULL) && (sta_ds != NULL))
+    {
+        if ( psession_entry->parsedAssocReq[aid] != NULL )
+        {
+            if ( ((tpSirAssocReq)
+                        (psession_entry->parsedAssocReq[aid]))->assocReqFrame)
+            {
+                vos_mem_free(((tpSirAssocReq)
+                         (psession_entry->parsedAssocReq[aid]))->assocReqFrame);
+                ((tpSirAssocReq)
+                 (psession_entry->parsedAssocReq[aid]))->assocReqFrame =
+                    NULL;
+            }
+            vos_mem_free(psession_entry->parsedAssocReq[aid]);
+            psession_entry->parsedAssocReq[aid] = NULL;
+        }
+    }
+
+} /*** end __lim_process_sme_assoc_offload_cnf() ***/
+#endif /* SAP_AUTH_OFFLOAD */
 
 
 static void
@@ -5713,7 +5800,14 @@
                 limLog(pMac, LOG1, FL("Received ASSOC_CNF message"));
             else
                 limLog(pMac, LOG1, FL("Received REASSOC_CNF message"));
+#ifdef SAP_AUTH_OFFLOAD
+            if (pMac->sap_auth_offload)
+                __lim_process_sme_assoc_offload_cnf(pMac, pMsg->type, pMsgBuf);
+            else
+                __limProcessSmeAssocCnfNew(pMac, pMsg->type, pMsgBuf);
+#else
             __limProcessSmeAssocCnfNew(pMac, pMsg->type, pMsgBuf);
+#endif /* SAP_AUTH_OFFLOAD */
             break;
 
         case eWNI_SME_ADDTS_REQ: