Added configuration to handle different BI scenario.

New configuration added to support different BI for
GO and STA role. If P2P-GO comes first and then STA connects
next allow the STA connection to go through.
Update the P2P-GO BI during run time based on peer AP BI.

Change-Id: Id31c0e09f0e97b474a12b32ac092cdf2f1be9230
Crs-fixed: 462276
diff --git a/CORE/SME/inc/csrSupport.h b/CORE/SME/inc/csrSupport.h
index 45a0586..a456e2e 100644
--- a/CORE/SME/inc/csrSupport.h
+++ b/CORE/SME/inc/csrSupport.h
@@ -827,7 +827,7 @@
 eHalStatus csrUpdatep2pBeaconInterval(tpAniSirGlobal pMac);
 
 //BeaconInterval validation for MCC support
-eHalStatus csrValidateMCCBeaconInterval(tpAniSirGlobal pMac, tANI_U8 channelId, 
+eHalStatus csrValidateMCCBeaconInterval(tpAniSirGlobal pMac, tANI_U8 channelId,
                                      tANI_U16 *beaconInterval, tANI_U32 cursessionId,
                                      tVOS_CON_MODE currBssPersona);
 
diff --git a/CORE/SME/src/csr/csrApiRoam.c b/CORE/SME/src/csr/csrApiRoam.c
index e6bf2d4..4fbcfc4 100644
--- a/CORE/SME/src/csr/csrApiRoam.c
+++ b/CORE/SME/src/csr/csrApiRoam.c
@@ -12856,8 +12856,8 @@
         {
             wTmp = pal_cpu_to_be16( WNI_CFG_BEACON_INTERVAL_STADEF );
         }
-        if(csrIsconcurrentsessionValid (pMac, sessionId, 
-                                   pParam->bssPersona) 
+        if(csrIsconcurrentsessionValid (pMac, sessionId,
+                                   pParam->bssPersona)
                                    == eHAL_STATUS_SUCCESS )
         {    
            csrValidateMCCBeaconInterval(pMac, pParam->operationChn, &wTmp, sessionId,
diff --git a/CORE/SME/src/csr/csrUtil.c b/CORE/SME/src/csr/csrUtil.c
index 9480151..0554ee7 100644
--- a/CORE/SME/src/csr/csrUtil.c
+++ b/CORE/SME/src/csr/csrUtil.c
@@ -1731,72 +1731,27 @@
                                                   tSirBssDescription *pBssDesc)
 {
     tCsrRoamSession *pSession = NULL;
-    tANI_U8 Index = 0, ConnId = 0;
     eAniBoolean status = eANI_BOOLEAN_FALSE;
 
-    tVOS_CON_MODE Mode[CSR_ROAM_SESSION_MAX];
-
     //Check for MCC support
     if (!pMac->roam.configParam.fenableMCCMode)
     {
         return status;
     }
 
-    for( Index = 0; Index < CSR_ROAM_SESSION_MAX; Index++ )
-    {
-        Mode[Index] = VOS_MAX_NO_OF_MODE;
-        if( CSR_IS_SESSION_VALID( pMac, Index ) )
-        {
-            pSession = CSR_GET_SESSION( pMac, Index );
-
-            if (NULL != pSession->pCurRoamProfile)
-            {
-                Mode[ConnId] = pSession->pCurRoamProfile->csrPersona;
-                ConnId++;
-             }
-         }
-    }
-
-    Index  = 0;
-    if (Mode[Index] == VOS_STA_MODE && ConnId > Index)
-    {
-        switch (Mode[Index+1])
-        {
-            case VOS_P2P_CLIENT_MODE :
-                status = eANI_BOOLEAN_TRUE;
-                break;
-            case VOS_MAX_NO_OF_MODE :
-            default :
-                 break;
-        }
-    }
-    else if (Mode[Index] == VOS_P2P_CLIENT_MODE && ConnId > Index)
-    {
-        switch (Mode[Index +1])
-        {
-            case VOS_STA_MODE :
-                status = eANI_BOOLEAN_TRUE;
-                break;
-
-            case VOS_MAX_NO_OF_MODE :
-            default :
-                break;
-         }
-    }
-
     //Validate BeaconInterval
     if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
     {
         pSession = CSR_GET_SESSION( pMac, sessionId );
         if (NULL != pSession->pCurRoamProfile)
         {
-            if(csrIsconcurrentsessionValid (pMac, sessionId, 
-                                       pSession->pCurRoamProfile->csrPersona) 
+            if (csrIsconcurrentsessionValid (pMac, sessionId,
+                                       pSession->pCurRoamProfile->csrPersona)
                                        == eHAL_STATUS_SUCCESS )
             {
-                if(csrValidateMCCBeaconInterval( pMac, pBssDesc->channelId, 
-                               &pBssDesc->beaconInterval, sessionId, 
-                               pSession->pCurRoamProfile->csrPersona) 
+                if (csrValidateMCCBeaconInterval( pMac, pBssDesc->channelId,
+                               &pBssDesc->beaconInterval, sessionId,
+                               pSession->pCurRoamProfile->csrPersona)
                                != eHAL_STATUS_SUCCESS)
                 {
                     status = eANI_BOOLEAN_FALSE;
@@ -2805,7 +2760,7 @@
             {
                 case VOS_STA_MODE:
                     if(pMac->roam.roamSession[sessionId].pCurRoamProfile &&
-                      (pMac->roam.roamSession[sessionId].pCurRoamProfile->csrPersona 
+                      (pMac->roam.roamSession[sessionId].pCurRoamProfile->csrPersona
                                       == VOS_STA_MODE)) //check for P2P client mode
                     {
                         smsLog(pMac, LOGE, FL(" ****STA mode already exists ****"));
@@ -2833,7 +2788,7 @@
 
                 case VOS_P2P_CLIENT_MODE:
                     if(pMac->roam.roamSession[sessionId].pCurRoamProfile &&
-                      (pMac->roam.roamSession[sessionId].pCurRoamProfile->csrPersona 
+                      (pMac->roam.roamSession[sessionId].pCurRoamProfile->csrPersona
                                                   == VOS_P2P_CLIENT_MODE)) //check for P2P client mode
                     {
                         smsLog(pMac, LOGE, FL(" ****CLIENT mode already exists ****"));
@@ -2881,11 +2836,24 @@
     {
         /* If GO in MCC support different beacon interval, 
          * change the BI of the P2P-GO */
-        if((pMac->roam.roamSession[sessionId].bssParams.bssPersona
-                              == VOS_P2P_GO_MODE) &&
-           (pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval ))
+        if (pMac->roam.roamSession[sessionId].bssParams.bssPersona
+                              == VOS_P2P_GO_MODE)
         {
-            return csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_DISCONNECT_ALL_P2P_CLIENTS, eCSR_ROAM_RESULT_NONE);
+           /* Handle different BI scneario based on the configuration set.
+            * If Config is set to 0x02 then Disconnect all the P2P clients
+            * associated. If config is set to 0x04 then update the BI
+            * without disconnecting all the clients
+            */
+           if ((pMac->roam.configParam.fAllowMCCGODiffBI == 0x04) &&
+               (pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval))
+           {
+               return csrSendChngMCCBeaconInterval( pMac, sessionId);
+           }
+           //If the configuration of fAllowMCCGODiffBI is set to other than 0x04
+           else if ( pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval)
+           {
+               return csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_DISCONNECT_ALL_P2P_CLIENTS, eCSR_ROAM_RESULT_NONE);
+           }
         }
     }
     return eHAL_STATUS_FAILURE;
@@ -2916,14 +2884,14 @@
         is_multiple = !(go_cbi % sta_bi);
     }
     // if it is multiple, then accept GO's beacon interval range [100,199] as it  is
-    if(is_multiple)
+    if (is_multiple)
     {
         return go_cbi;
     }
     //else , if it is not multiple, then then check for number of beacons to be 
     //inserted based on sta BI
     num_beacons = sta_bi / 100;
-    if(num_beacons)
+    if (num_beacons)
     { 
         // GO's final beacon interval will be aligned to sta beacon interval, but 
         //in the range of [100, 199].
@@ -2939,7 +2907,7 @@
     return go_fbi;
 }
 
-eHalStatus csrValidateMCCBeaconInterval(tpAniSirGlobal pMac, tANI_U8 channelId, 
+eHalStatus csrValidateMCCBeaconInterval(tpAniSirGlobal pMac, tANI_U8 channelId,
                                      tANI_U16 *beaconInterval, tANI_U32 cursessionId,
                                      tVOS_CON_MODE currBssPersona)
 {
@@ -2963,8 +2931,8 @@
             switch (currBssPersona)
             {
                 case VOS_STA_MODE:
-                    if(pMac->roam.roamSession[sessionId].pCurRoamProfile &&
-                      (pMac->roam.roamSession[sessionId].pCurRoamProfile->csrPersona 
+                    if (pMac->roam.roamSession[sessionId].pCurRoamProfile &&
+                       (pMac->roam.roamSession[sessionId].pCurRoamProfile->csrPersona
                                       == VOS_P2P_CLIENT_MODE)) //check for P2P client mode
                     {
                         smsLog(pMac, LOG1, FL(" Beacon Interval Validation not required for STA/CLIENT"));
@@ -2981,7 +2949,7 @@
                             return eHAL_STATUS_FAILURE;
                         }
                     }
-                    else if(pMac->roam.roamSession[sessionId].bssParams.bssPersona
+                    else if (pMac->roam.roamSession[sessionId].bssParams.bssPersona
                                       == VOS_P2P_GO_MODE) //Check for P2P go scenario
                     {
                         /* if GO in MCC support different beacon interval, 
@@ -2997,26 +2965,30 @@
                                return eHAL_STATUS_SUCCESS;
                            }
                            // Send only Broadcast disassoc and update beaconInterval
-                           else if(pMac->roam.configParam.fAllowMCCGODiffBI == 0x02)
+                           //If configuration is set to 0x04 then dont
+                           // disconnect all the station
+                           else if ((pMac->roam.configParam.fAllowMCCGODiffBI == 0x02) ||
+                                   (pMac->roam.configParam.fAllowMCCGODiffBI == 0x04))
                            {
                                //Check to pass the right beacon Interval
                                new_beaconInterval = csrCalculateMCCBeaconInterval(pMac, *beaconInterval, 
                                                          pMac->roam.roamSession[sessionId].bssParams.beaconInterval);
                                smsLog(pMac, LOG1, FL(" Peer AP BI : %d, new Beacon Interval: %d"),*beaconInterval,new_beaconInterval );
                                //Update the becon Interval
-                               if( new_beaconInterval !=
-                                     pMac->roam.roamSession[sessionId].bssParams.beaconInterval )
+                               if (new_beaconInterval != pMac->roam.roamSession[sessionId].bssParams.beaconInterval)
                                {
                                    //Update the beaconInterval now
-                                   smsLog(pMac, LOG1, FL(" Beacon Interval got changed"));
+                                   smsLog(pMac, LOGE, FL(" Beacon Interval got changed config used: %d\n"),
+                                                 pMac->roam.configParam.fAllowMCCGODiffBI);
+
                                    pMac->roam.roamSession[sessionId].bssParams.beaconInterval = new_beaconInterval;
                                    pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval = eANI_BOOLEAN_TRUE;
-                                   csrUpdateMCCp2pBeaconInterval(pMac);
+                                    return csrUpdateMCCp2pBeaconInterval(pMac);
                                }
                                return eHAL_STATUS_SUCCESS;
                            }
                            //Disconnect the P2P session
-                           else if(pMac->roam.configParam.fAllowMCCGODiffBI == 0x03)
+                           else if (pMac->roam.configParam.fAllowMCCGODiffBI == 0x03)
                            {
                                pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval =  eANI_BOOLEAN_FALSE;
                                return csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_SEND_P2P_STOP_BSS, eCSR_ROAM_RESULT_NONE);
@@ -3031,8 +3003,8 @@
                     break;
 
                 case VOS_P2P_CLIENT_MODE:
-                    if(pMac->roam.roamSession[sessionId].pCurRoamProfile &&
-                      (pMac->roam.roamSession[sessionId].pCurRoamProfile->csrPersona 
+                    if (pMac->roam.roamSession[sessionId].pCurRoamProfile &&
+                      (pMac->roam.roamSession[sessionId].pCurRoamProfile->csrPersona
                                                                 == VOS_STA_MODE)) //check for P2P client mode
                     {
                         smsLog(pMac, LOG1, FL(" Ignore Beacon Interval Validation..."));
@@ -3049,7 +3021,7 @@
                             return eHAL_STATUS_FAILURE;
                         }
                     }
-                    else if(pMac->roam.roamSession[sessionId].bssParams.bssPersona
+                    else if (pMac->roam.roamSession[sessionId].bssParams.bssPersona
                                     == VOS_P2P_GO_MODE) //Check for P2P go scenario
                     {
                         if ((pMac->roam.roamSession[sessionId].bssParams.operationChn 
@@ -3065,13 +3037,13 @@
 
                 case VOS_P2P_GO_MODE :
                 {
-                    if(pMac->roam.roamSession[sessionId].pCurRoamProfile  && 
-                      ((pMac->roam.roamSession[sessionId].pCurRoamProfile->csrPersona 
+                    if (pMac->roam.roamSession[sessionId].pCurRoamProfile  &&
+                      ((pMac->roam.roamSession[sessionId].pCurRoamProfile->csrPersona
                             == VOS_P2P_CLIENT_MODE) ||
-                      (pMac->roam.roamSession[sessionId].pCurRoamProfile->csrPersona 
+                      (pMac->roam.roamSession[sessionId].pCurRoamProfile->csrPersona
                             == VOS_STA_MODE))) //check for P2P_client scenario
                     {
-                        if ((pMac->roam.roamSession[sessionId].connectedProfile.operationChannel 
+                        if ((pMac->roam.roamSession[sessionId].connectedProfile.operationChannel
                                == 0 )&&
                            (pMac->roam.roamSession[sessionId].connectedProfile.beaconInterval
                                == 0))
@@ -3081,9 +3053,9 @@
 
                             
                         if (csrIsConnStateConnectedInfra(pMac, sessionId) &&
-                           (pMac->roam.roamSession[sessionId].connectedProfile.operationChannel 
+                           (pMac->roam.roamSession[sessionId].connectedProfile.operationChannel
                                 != channelId ) &&
-                           (pMac->roam.roamSession[sessionId].connectedProfile.beaconInterval 
+                           (pMac->roam.roamSession[sessionId].connectedProfile.beaconInterval
                                 != *beaconInterval))
                         {
                             /*