wlan: (2)Decouple init scan and NOA insert in P2P GO case

Currently we have scan req coupled with NOA publishing for GO. This
blocks our MLME state to scan state for 3 beacon intervals which causes
1) Huge Throughput dip during scan since we suspend TL for 3 BIs
2) Sometimes connection problems since we are in scan state for longer
time though we are not doing scan (for 3 BIs) esp. since some frames get
delayed on both and client and GO sides during scan because of current
implementation.
So the change is decouple publishing of NOA from scan in a way that
while we wait for NOA publishing for 3 BIs we can do all other jobs at
lim module and below. Also, we will be suspending TL only when we are
actually doing scan
3) Changed the BIs for which NOA is published to 2 instead of 3

Change-Id: Id8f2db8019e132183f671aa4aa80d8dfdfe05f97
CR-Fixed: 426949
(cherry picked from commit d86bde28085c661638a4f46cb660ca00851d3497)
diff --git a/CORE/MAC/src/pe/lim/limProcessMessageQueue.c b/CORE/MAC/src/pe/lim/limProcessMessageQueue.c
index 614e4e7..d93eed5 100644
--- a/CORE/MAC/src/pe/lim/limProcessMessageQueue.c
+++ b/CORE/MAC/src/pe/lim/limProcessMessageQueue.c
@@ -81,6 +81,11 @@
 #include "vos_memory.h"
 #endif
 
+#ifdef WLAN_FEATURE_P2P
+/* In P2P GO case, we want to call scan on NOA start indication from limProcessMessages */
+extern void __limProcessSmeScanReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf);
+#endif
+
 void limLogSessionStates(tpAniSirGlobal pMac);
 
 /** -------------------------------------------------------------
@@ -1527,16 +1532,51 @@
             limMsg->bodyptr = NULL;
             break;
 
+        case SIR_HAL_P2P_NOA_START_IND:
+        {
+            tpPESession psessionEntry = &pMac->lim.gpSession[0];
+            tANI_U8  i;
+            
+            limLog(pMac, LOG1, "LIM received NOA start %x\n", limMsg->type);
+            for(i=0; i < pMac->lim.maxBssId; i++)
+            {
+                psessionEntry = &pMac->lim.gpSession[i];
+                if   ( (psessionEntry != NULL) && (psessionEntry->valid) &&
+                    (psessionEntry->pePersona == VOS_P2P_GO_MODE))
+                { //Save P2P NOA start attributes for P2P Go persona
+                    palCopyMemory(pMac->hHdd, &psessionEntry->p2pGoPsNoaStartInd, limMsg->bodyptr, sizeof(tSirP2PNoaStart));
+                    
+                    if ((pMac->lim.gpLimSmeScanReq != NULL) && (psessionEntry->p2pGoPsNoaStartInd.status == eHAL_STATUS_SUCCESS))
+                    {
+                        /* We received the NOA start indication. Now we can send down the scan request */
+                        __limProcessSmeScanReq(pMac, (tANI_U32 *)pMac->lim.gpLimSmeScanReq);
+                        /* Since insert NOA is done and NOA start msg received, we should deactivate the Insert NOA timer */
+                        limDeactivateAndChangeTimer(pMac, eLIM_INSERT_SINGLESHOT_NOA_TIMER);
+                        /* __limProcessSmeScanReq consumed the buffer. We can free it. */
+                        palFreeMemory( pMac->hHdd, (tANI_U8 *) pMac->lim.gpLimSmeScanReq);
+                        pMac->lim.gpLimSmeScanReq = NULL;
+                    }
+                    else
+                        limLog(pMac, LOGE, FL("GO NOA start failure reported by FW - don't do scan\n"));
+                    break;
+                }
+            }
+        }
+            palFreeMemory(pMac->hHdd, (tANI_U8 *)limMsg->bodyptr);
+            limMsg->bodyptr = NULL;
+            break;
+            
+
         case SIR_HAL_P2P_NOA_ATTR_IND:
             {
                 tpPESession psessionEntry = &pMac->lim.gpSession[0];  
                 tANI_U8  i;
                 
-                
                 limLog(pMac, LOGW, FL("Received message Noa_ATTR %x\n"), limMsg->type);
                 for(i=0; i < pMac->lim.maxBssId; i++)
                 {
-                    if   ( (psessionEntry != NULL) && (pMac->lim.gpSession[i].valid) && 
+                    psessionEntry = &pMac->lim.gpSession[i];
+                    if   ( (psessionEntry != NULL) && (psessionEntry->valid) && 
                         (psessionEntry->pePersona == VOS_P2P_GO_MODE))
                     { //Save P2P attributes for P2P Go persona
                     
@@ -1756,6 +1796,7 @@
 #endif
 #ifdef WLAN_FEATURE_P2P
         case SIR_LIM_REMAIN_CHN_TIMEOUT:
+        case SIR_LIM_INSERT_SINGLESHOT_NOA_TIMEOUT:
 #endif
         case SIR_LIM_DISASSOC_ACK_TIMEOUT:
         case SIR_LIM_DEAUTH_ACK_TIMEOUT: