Wlan: Enable scan split feature in SME for multiple session scenario

Enable the scan logic to breakdown the scan request into multiple scan
commands and provide a gap between scans on individual channels. During
the gaps the device returns to the home channel and provides an
opportunity for traffic on the home channel.

Change-Id: I3cbdac7a6f6f9ca2e012c760a474c34b532055ae
CR-Fixed: NA
diff --git a/CORE/SME/inc/csrInternal.h b/CORE/SME/inc/csrInternal.h
index 504f9dc..0755361 100644
--- a/CORE/SME/inc/csrInternal.h
+++ b/CORE/SME/inc/csrInternal.h
@@ -1033,6 +1033,7 @@
 tANI_BOOLEAN csrIsConnStateDisconnectedWds( tpAniSirGlobal pMac, tANI_U32 sessionId );
 tANI_BOOLEAN csrIsAnySessionInConnectState( tpAniSirGlobal pMac );
 tANI_BOOLEAN csrIsAllSessionDisconnected( tpAniSirGlobal pMac );
+tANI_BOOLEAN csrIsAnySessionConnected( tpAniSirGlobal pMac );
 tANI_BOOLEAN csrIsInfraConnected( tpAniSirGlobal pMac );
 tANI_BOOLEAN csrIsConcurrentInfraConnected( tpAniSirGlobal pMac );
 tANI_BOOLEAN csrIsConcurrentSessionRunning( tpAniSirGlobal pMac );
diff --git a/CORE/SME/src/csr/csrApiScan.c b/CORE/SME/src/csr/csrApiScan.c
index 2e24579..6dd7671 100644
--- a/CORE/SME/src/csr/csrApiScan.c
+++ b/CORE/SME/src/csr/csrApiScan.c
@@ -336,7 +336,8 @@
     tSmeCmd *pQueueScanCmd=NULL;
     tSmeCmd *pSendScanCmd=NULL;
 
-    if (vos_get_concurrency_mode() == VOS_STA_SAP) //TODO:- Also make sure AP BSS has started
+    /* split scan if any session is connected */
+    if (eANI_BOOLEAN_TRUE == csrIsAnySessionConnected(pMac))
     {
 
         tCsrScanRequest scanReq;
@@ -5326,11 +5327,6 @@
 
     }
 
-    if (!csrLLIsListEmpty( &pMac->scan.scanCmdPendingList, LL_ACCESS_NOLOCK ))
-    {
-         palTimerStart(pMac->hHdd, pMac->scan.hTimerStaApConcTimer, 
-                 CSR_SCAN_STAAP_CONC_INTERVAL, eANI_BOOLEAN_FALSE);
-    }
     csrLLUnlock(&pMac->scan.scanCmdPendingList);
     
 }
diff --git a/CORE/SME/src/csr/csrUtil.c b/CORE/SME/src/csr/csrUtil.c
index 9148c1a..a2c1744 100644
--- a/CORE/SME/src/csr/csrUtil.c
+++ b/CORE/SME/src/csr/csrUtil.c
@@ -1490,6 +1490,26 @@
     return ( fRc );
 }
 
+tANI_BOOLEAN csrIsAnySessionConnected( tpAniSirGlobal pMac )
+{
+    tANI_U32 i, count;
+    tANI_BOOLEAN fRc = eANI_BOOLEAN_FALSE;
+
+    count = 0;
+    for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
+    {
+        if( CSR_IS_SESSION_VALID( pMac, i ) && !csrIsConnStateDisconnected( pMac, i ) )
+        {
+            count++;
+        }
+    }
+
+    if (count > 0)
+    {
+        fRc = eANI_BOOLEAN_TRUE;
+    }
+    return( fRc );
+}
 
 tANI_BOOLEAN csrIsInfraConnected( tpAniSirGlobal pMac )
 {