Postpone scan request until TDLS torn down

Introduce delayed_work and reschedule the scan request until
all TDLS peers are torn down.
Define tdls_scan_callback() and tdls_scan_done_callback() to
be called from cfg80211_scan() and cfg80211_scan_done().
Reject the scan request when TDLS connection is in progress.
Check the number of reschedule scan and allow scan if exceed max
attempt.

CRs-Fixed: 453508
Change-Id: Ieab5b72cd214b64ff041d952923533454fc98e85
diff --git a/CORE/HDD/src/wlan_hdd_cfg80211.c b/CORE/HDD/src/wlan_hdd_cfg80211.c
index 50bc480..d71639d 100755
--- a/CORE/HDD/src/wlan_hdd_cfg80211.c
+++ b/CORE/HDD/src/wlan_hdd_cfg80211.c
@@ -4189,6 +4189,10 @@
      * to process the connect request to AP */
     hdd_allow_suspend_timeout(100);
 
+#ifdef FEATURE_WLAN_TDLS
+    wlan_hdd_tdls_scan_done_callback(pAdapter);
+#endif
+
     EXIT();
     return 0;
 }
@@ -4350,27 +4354,20 @@
         return -EBUSY;
     }
 #ifdef FEATURE_WLAN_TDLS
-    if (wlan_hdd_tdlsConnectedPeers(pAdapter))
-    {
-        tANI_U8 staIdx;
-
-        for (staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++)
-        {
-            if (pHddCtx->tdlsConnInfo[staIdx].staId)
-            {
-                VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
-                               ("scan: indicate TDLS teadown (staId %d)"), pHddCtx->tdlsConnInfo[staIdx].staId) ;
-
-#ifdef CONFIG_TDLS_IMPLICIT
-                cfg80211_tdls_oper_request(pAdapter->dev,
-                                           pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes,
-                                           NL80211_TDLS_TEARDOWN,
-                                           eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON,
-                                           GFP_KERNEL);
+    /* if tdls disagree scan right now, return immediately.
+       tdls will schedule the scan when scan is allowed. (return SUCCESS)
+       or will reject the scan if any TDLS is in progress. (return -EBUSY)
+    */
+    status = wlan_hdd_tdls_scan_callback (pAdapter,
+                                         wiphy,
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
+                                         dev,
 #endif
-            }
-        }
-        return -EBUSY;
+                                         request);
+    if(status <= 0)
+    {
+        hddLog(VOS_TRACE_LEVEL_INFO, "%s: TDLS Pending %d", __func__, status);
+        return status;
     }
 #endif