prima: Enable/Disable TDLS only for p2p interfaces

Currently, Disable and Teardown functionality invoked for
TDLS during concurrency only if device mode is other than
WLAN_HDD_INFRA_STATION and during p2p disconnection since the
device mode will be either WLAN_HDD_P2P_CLIENT/WLAN_HDD_P2P_GO
which would invoke Disable and teardown functionality again and
thus disabling TDLS and connection attempt was not made.

To mitigate:
Include check for device mode and invoke Disable and
Teardown TDLS functionality only if device mode is
WLAN_HDD_P2P_DEVICE and interface type is
NL80211_IFTYPE_P2P_CLIENT/NL80211_IFTYPE_P2P_GO.

Change-Id: Ia2c272a2975c83aebff147ceb6b2fb57a90182b2
CRs-Fixed: 891225
diff --git a/CORE/HDD/src/wlan_hdd_tdls.c b/CORE/HDD/src/wlan_hdd_tdls.c
index 636cfaf..3ab746a 100644
--- a/CORE/HDD/src/wlan_hdd_tdls.c
+++ b/CORE/HDD/src/wlan_hdd_tdls.c
@@ -178,7 +178,6 @@
  */
 void hdd_tdls_notify_mode_change(hdd_adapter_t *adapter, hdd_context_t *hddctx)
 {
-    if (adapter->device_mode != WLAN_HDD_INFRA_STATION)
         wlan_hdd_tdls_disable_offchan_and_teardown_links(hddctx);
 }
 
@@ -3271,5 +3270,43 @@
             "mac : " MAC_ADDRESS_STR "rssi is %d",
             MAC_ADDR_ARRAY(mac), rssiAvg);
 }
-/*EXT TDLS*/
 
+/**
+ * wlan_hdd_tdls_reenable() - Re-Enable TDLS
+ * @hddctx: pointer to hdd context
+ *
+ * Function re-enable's TDLS which might be disabled during concurrency
+ *
+ * Return: None
+ */
+void wlan_hdd_tdls_reenable(hdd_context_t *pHddCtx)
+{
+
+    if ((TRUE != pHddCtx->cfg_ini->fEnableTDLSSupport) ||
+        (TRUE != sme_IsFeatureSupportedByFW(TDLS))) {
+        VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
+                  FL("tdls support not enabled"));
+        return;
+    }
+
+    /* if tdls is not enabled or BtCoex is on then don't revert tdls mode */
+    if ((eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) ||
+        (pHddCtx->is_tdls_btc_enabled == FALSE)) {
+        VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
+                  FL("btc disable tdls so no need to enable: Mode=%d, BTC enabled=%d"),
+                  pHddCtx->tdls_mode, pHddCtx->is_tdls_btc_enabled);
+            return;
+    }
+
+    if (eTDLS_SUPPORT_ENABLED == pHddCtx->tdls_mode_last ||
+         eTDLS_SUPPORT_EXPLICIT_TRIGGER_ONLY ==
+                               pHddCtx->tdls_mode_last) {
+            /* Enable TDLS support Once P2P session ends since
+             * upond detection of concurrency TDLS might be disabled
+             */
+             hddLog(LOG1, FL("TDLS mode set to %d"), pHddCtx->tdls_mode_last);
+             wlan_hdd_tdls_set_mode(pHddCtx, pHddCtx->tdls_mode_last,
+                                    FALSE);
+    }
+}
+/*EXT TDLS*/