wlan: Process deauth rsp in sme callback

Deauth rsp in SME queue is not getting processed
due to other messages getting processed in PE queue
which is high priority than SME queue.

Fix is to process deauth rsp in sme callback instead
of posting message to SME queue.

Change-Id: I5bfcaf927956b3cef09dfcda055cf860841d8980
CRs-Fixed: 2270465
diff --git a/CORE/MAC/src/pe/lim/limProcessMlmReqMessages.c b/CORE/MAC/src/pe/lim/limProcessMlmReqMessages.c
index bc6cb0a..9c09b31 100644
--- a/CORE/MAC/src/pe/lim/limProcessMlmReqMessages.c
+++ b/CORE/MAC/src/pe/lim/limProcessMlmReqMessages.c
@@ -2918,8 +2918,8 @@
     tpPESession              psessionEntry;
     extern tANI_BOOLEAN     sendDisassocFrame;
     tSirSmeDisassocRsp      *pSirSmeDisassocRsp;
-    tANI_U32                *pMsg;
     tANI_U8                 *pBuf;
+    vos_msg_t               msg = {0};
 
     if(eHAL_STATUS_SUCCESS != suspendStatus)
     {
@@ -3043,10 +3043,14 @@
          pBuf  = (tANI_U8 *) pSirSmeDisassocRsp->peerMacAddr;
          vos_mem_copy( pBuf, pMlmDisassocReq->peerMacAddr, sizeof(tSirMacAddr));
 
-         pMsg = (tANI_U32*) pSirSmeDisassocRsp;
+         msg.type = eWNI_SME_DISASSOC_RSP;
+         msg.bodyptr = pSirSmeDisassocRsp;
 
-         limSendSmeDisassocDeauthNtf( pMac, eHAL_STATUS_SUCCESS,
-                                                (tANI_U32*) pMsg );
+         if (pMac->lim.sme_msg_callback)
+             pMac->lim.sme_msg_callback(pMac, &msg);
+         else
+             limLog(pMac, LOGE, FL("Sme msg callback is NULL"));
+
          return;
 
     }
@@ -3250,8 +3254,7 @@
     tpPESession             psessionEntry;
     tSirSmeDeauthRsp        *pSirSmeDeauthRsp;
     tANI_U8                 *pBuf;
-    tANI_U32                *pMsg;
-
+    vos_msg_t               msg = {0};
 
     if(eHAL_STATUS_SUCCESS != suspendStatus)
     {
@@ -3457,10 +3460,13 @@
         pBuf  = (tANI_U8 *) pSirSmeDeauthRsp->peerMacAddr;
         vos_mem_copy( pBuf, pMlmDeauthReq->peerMacAddr, sizeof(tSirMacAddr));
 
-        pMsg = (tANI_U32*)pSirSmeDeauthRsp;
+        msg.type = eWNI_SME_DEAUTH_RSP;
+        msg.bodyptr = pSirSmeDeauthRsp;
 
-        limSendSmeDisassocDeauthNtf( pMac, eHAL_STATUS_SUCCESS,
-                                            (tANI_U32*) pMsg );
+        if (pMac->lim.sme_msg_callback)
+            pMac->lim.sme_msg_callback(pMac, &msg);
+        else
+            limLog(pMac, LOGE, FL("Sme msg callback is NULL"));
 
         return;
 
diff --git a/CORE/MAC/src/pe/lim/limProcessMlmRspMessages.c b/CORE/MAC/src/pe/lim/limProcessMlmRspMessages.c
index 189b8dc..4357a1e 100644
--- a/CORE/MAC/src/pe/lim/limProcessMlmRspMessages.c
+++ b/CORE/MAC/src/pe/lim/limProcessMlmRspMessages.c
@@ -1323,6 +1323,8 @@
 
     if (pMac->lim.sme_msg_callback)
         pMac->lim.sme_msg_callback(pMac, &msg);
+    else
+        limLog(pMac, LOGE, FL("Sme msg callback is NULL"));
 // Enable this Compile flag to test the BT-AMP -AP assoc sequence
 #ifdef TEST_BTAMP_AP
 //tANI_U32 *pMsgBuf;
diff --git a/CORE/MAC/src/pe/lim/limSendSmeRspMessages.c b/CORE/MAC/src/pe/lim/limSendSmeRspMessages.c
index 69d186e..2949e60 100644
--- a/CORE/MAC/src/pe/lim/limSendSmeRspMessages.c
+++ b/CORE/MAC/src/pe/lim/limSendSmeRspMessages.c
@@ -1255,21 +1255,6 @@
 #endif
 } /*** end limSendSmeAuthRsp() ***/
 
-
-void limSendSmeDisassocDeauthNtf( tpAniSirGlobal pMac,
-                                eHalStatus status, tANI_U32 *pCtx )
-{
-    tSirMsgQ                mmhMsg;
-    tSirMsgQ                *pMsg = (tSirMsgQ*) pCtx;
-
-    mmhMsg.type = pMsg->type;
-    mmhMsg.bodyptr = pMsg;
-    mmhMsg.bodyval = 0;
-
-    MTRACE(macTrace(pMac, TRACE_CODE_TX_SME_MSG, NO_SESSION, mmhMsg.type));
-
-    limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
-}
 /**
  * limSendSmeDisassocNtf()
  *
@@ -1313,14 +1298,13 @@
     tSirSmeDisassocRsp      *pSirSmeDisassocRsp;
     tSirSmeDisassocInd      *pSirSmeDisassocInd;
     tSirSmeDisConDoneInd    *pSirSmeDisConDoneInd;
-    tANI_U32 *pMsg;
     bool failure = FALSE;
+    vos_msg_t               msg = {0};
 
     limLog(pMac, LOG1, FL("Disassoc Ntf with trigger : %d"
             "reasonCode: %d"),
             disassocTrigger,
             reasonCode);
-    
     switch (disassocTrigger)
     {
         case eLIM_HOST_DISASSOC:
@@ -1370,7 +1354,8 @@
             limDiagEventReport(pMac, WLAN_PE_DIAG_DISASSOC_RSP_EVENT,
                                       psessionEntry, (tANI_U16)reasonCode, 0);
 #endif
-            pMsg = (tANI_U32*) pSirSmeDisassocRsp;
+            msg.type = eWNI_SME_DISASSOC_RSP;
+            msg.bodyptr = pSirSmeDisassocRsp;
             break;
 
         case eLIM_PEER_ENTITY_DISASSOC:
@@ -1399,7 +1384,8 @@
             else
                 pSirSmeDisConDoneInd->reasonCode = reasonCode;
 
-            pMsg = (tANI_U32 *)pSirSmeDisConDoneInd;
+            msg.type = eWNI_SME_DISCONNECT_DONE_IND;
+            msg.bodyptr = pSirSmeDisConDoneInd;
             break;
 
         default:
@@ -1444,7 +1430,8 @@
             limDiagEventReport(pMac, WLAN_PE_DIAG_DISASSOC_IND_EVENT,
                                               psessionEntry, (tANI_U16)reasonCode, 0);
 #endif
-            pMsg = (tANI_U32*) pSirSmeDisassocInd;
+            msg.type = eWNI_SME_DISASSOC_IND;
+            msg.bodyptr = pSirSmeDisassocInd;
 
             break;
     }
@@ -1456,9 +1443,10 @@
     {
         peDeleteSession(pMac,psessionEntry);
     }
-    if (failure == FALSE)
-        limSendSmeDisassocDeauthNtf( pMac, eHAL_STATUS_SUCCESS,
-                                             (tANI_U32*) pMsg );
+    if (failure == FALSE && pMac->lim.sme_msg_callback)
+        pMac->lim.sme_msg_callback(pMac, &msg);
+    else if (failure == FALSE)
+        limLog(pMac, LOGE, FL("Sme msg callback is NULL"));
 } /*** end limSendSmeDisassocNtf() ***/
 
 
@@ -1777,7 +1765,7 @@
     tSirSmeDisConDoneInd *pSirSmeDisConDoneInd;
     tpPESession         psessionEntry;
     tANI_U8             sessionId;
-    tANI_U32            *pMsg;
+    vos_msg_t           msg = {0};
 
     psessionEntry = peFindSessionByBssid(pMac,peerMacAddr,&sessionId);  
     switch (deauthTrigger)
@@ -1812,7 +1800,8 @@
             limDiagEventReport(pMac, WLAN_PE_DIAG_DEAUTH_RSP_EVENT,
                                       psessionEntry, 0, (tANI_U16)reasonCode);
 #endif
-            pMsg = (tANI_U32*)pSirSmeDeauthRsp;
+            msg.type = eWNI_SME_DEAUTH_RSP;
+            msg.bodyptr = pSirSmeDeauthRsp;
 
             break;
 
@@ -1843,7 +1832,8 @@
             else
                 pSirSmeDisConDoneInd->reasonCode = reasonCode;
 
-            pMsg = (tANI_U32 *)pSirSmeDisConDoneInd;
+            msg.type = eWNI_SME_DISCONNECT_DONE_IND;
+            msg.bodyptr = pSirSmeDisConDoneInd;
             break;
 
         default:
@@ -1892,7 +1882,8 @@
             limDiagEventReport(pMac, WLAN_PE_DIAG_DEAUTH_IND_EVENT,
                                         psessionEntry, 0, (tANI_U16)reasonCode);
 #endif //FEATURE_WLAN_DIAG_SUPPORT
-            pMsg = (tANI_U32*)pSirSmeDeauthInd;
+            msg.type = eWNI_SME_DEAUTH_IND;
+            msg.bodyptr = pSirSmeDeauthInd;
 
             break;
     }
@@ -1903,9 +1894,10 @@
         peDeleteSession(pMac,psessionEntry);
     }   
 
-    limSendSmeDisassocDeauthNtf( pMac, eHAL_STATUS_SUCCESS,
-                                              (tANI_U32*) pMsg );
-
+    if (pMac->lim.sme_msg_callback)
+        pMac->lim.sme_msg_callback(pMac, &msg);
+    else
+        limLog(pMac, LOGE, FL("Sme msg callback is NULL"));
 } /*** end limSendSmeDeauthNtf() ***/
 
 
diff --git a/CORE/MAC/src/pe/lim/limTypes.h b/CORE/MAC/src/pe/lim/limTypes.h
index adbc842..6d0ca49 100644
--- a/CORE/MAC/src/pe/lim/limTypes.h
+++ b/CORE/MAC/src/pe/lim/limTypes.h
@@ -711,10 +711,7 @@
 void limSendNullDataFrame(tpAniSirGlobal, tpDphHashNode);
 void limSendDisassocMgmtFrame(tpAniSirGlobal, tANI_U16, tSirMacAddr, tpPESession, tANI_BOOLEAN waitForAck);
 void limSendDeauthMgmtFrame(tpAniSirGlobal, tANI_U16, tSirMacAddr, tpPESession, tANI_BOOLEAN waitForAck);
-void limSendSmeDisassocDeauthNtf( tpAniSirGlobal pMac,
-                                eHalStatus status, tANI_U32 *pCtx );
 void limDoSendAuthMgmtFrame(tpAniSirGlobal, tpPESession);
-
 void limContinueChannelScan(tpAniSirGlobal);
 tSirResultCodes limMlmAddBss(tpAniSirGlobal, tLimMlmStartReq *,tpPESession psessionEntry);
 
diff --git a/CORE/MAC/src/pe/sch/schBeaconProcess.c b/CORE/MAC/src/pe/sch/schBeaconProcess.c
index 19a9ec0..ef899bd 100644
--- a/CORE/MAC/src/pe/sch/schBeaconProcess.c
+++ b/CORE/MAC/src/pe/sch/schBeaconProcess.c
@@ -281,7 +281,10 @@
     //If station(STA/BT-STA/BT-AP/IBSS) mode, Always save the beacon in the scan results, if atleast one session is active
     //schBeaconProcessNoSession will be called only when there is atleast one session active, so not checking 
     //it again here.
-    limCheckAndAddBssDescription(pMac, pBeacon, pRxPacketInfo, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
+    if (WDA_GET_OFFLOADSCANLEARN(pRxPacketInfo) || pMac->fScanOffload)
+        limCheckAndAddBssDescription(pMac, pBeacon, pRxPacketInfo,
+                                     eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
+
     return;  
 }