TDLS Support for the P2P interface

Make the HDD TDLS Context separate for each interface and have the
TDLS connection information common for both interface in HDD global
context.

CRs-Fixed: 458139
Change-Id: I07f06f3caa446d6d57645ff1abcb0dd09f4b0ea4
diff --git a/CORE/HDD/src/wlan_hdd_main.c b/CORE/HDD/src/wlan_hdd_main.c
index 7f79fb3..ae56f40 100644
--- a/CORE/HDD/src/wlan_hdd_main.c
+++ b/CORE/HDD/src/wlan_hdd_main.c
@@ -1848,8 +1848,23 @@
 
    set_bit(WMM_INIT_DONE, &pAdapter->event_flags);
 
+#ifdef FEATURE_WLAN_TDLS
+   if(0 != wlan_hdd_tdls_init(pAdapter))
+   {
+       status = VOS_STATUS_E_FAILURE;
+       hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wlan_hdd_tdls_init failed",__func__);
+       goto error_tdls_init;
+   }
+   set_bit(TDLS_INIT_DONE, &pAdapter->event_flags);
+#endif
+
    return VOS_STATUS_SUCCESS;
 
+#ifdef FEATURE_WLAN_TDLS
+error_tdls_init:
+   clear_bit(WMM_INIT_DONE, &pAdapter->event_flags);
+   hdd_wmm_adapter_close(pAdapter);
+#endif
 error_wmm_init:
    clear_bit(INIT_TX_RX_SUCCESS, &pAdapter->event_flags);
    hdd_deinit_tx_rx(pAdapter);
@@ -1917,6 +1932,13 @@
          }
 
          hdd_cleanup_actionframe(pHddCtx, pAdapter);
+#ifdef FEATURE_WLAN_TDLS
+         if(test_bit(TDLS_INIT_DONE, &pAdapter->event_flags))
+         {
+            wlan_hdd_tdls_exit(pAdapter);
+            clear_bit(TDLS_INIT_DONE, &pAdapter->event_flags);
+         }
+#endif
 
          break;
       }
@@ -3283,10 +3305,6 @@
       hddLog(VOS_TRACE_LEVEL_FATAL,"%s: hddDevTmUnregisterNotifyCallback failed",__func__);
    }
 
-#ifdef FEATURE_WLAN_TDLS
-    wlan_hdd_tdls_exit();
-#endif
-
    // Cancel any outstanding scan requests.  We are about to close all
    // of our adapters, but an adapter structure is what SME passes back
    // to our callback function.  Hence if there are any outstanding scan
@@ -4227,14 +4245,6 @@
    // Initialize the restart logic
    wlan_hdd_restart_init(pHddCtx);
 
-#ifdef FEATURE_WLAN_TDLS
-   if(0 != wlan_hdd_tdls_init(pAdapter->dev))
-   {
-       hddLog(VOS_TRACE_LEVEL_FATAL,"%s: wlan_hdd_tdls_init failed",__func__);
-       goto err_nl_srv;
-   }
-#endif
-  
    goto success;
 
 err_nl_srv: