wlan: Fix to enable TDLS only if enabled in INI and supported by FW

Though TDLS Feature is disabled in ini, during wlan startup tdls
mode is set based on either implicit or explicit mode from ini
regardless of TDLS feature support in ini which will lead to send
TDLS frames depending on TDLS mode of configuration(implicit or explicit)
which is incorrect and in current scenario TDLS discovery request
is sent with disabling BMPS(if enabled) and host will neither process
TDLS discovery response nor enable BMPS since tdls context is NULL
and TDLS context is NULL because of TDLS feature is not enabled
in ini thus leading to issue.

Fix is to ensure that TDLS mode is set to either implicit or explicit
only if TDLS feature is enabled in ini and supported by FW.

Change-Id: I3b7bb9026839c15d495ac3dc3b190fc75d48cc7a
CRs-Fixed: 981745
diff --git a/CORE/HDD/src/wlan_hdd_tdls.c b/CORE/HDD/src/wlan_hdd_tdls.c
index 36810e8..b7ae28a 100644
--- a/CORE/HDD/src/wlan_hdd_tdls.c
+++ b/CORE/HDD/src/wlan_hdd_tdls.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012-2015 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2012-2016 The Linux Foundation. All rights reserved.
  *
  * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
  *
@@ -961,14 +961,24 @@
         hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to register BT Coex TDLS callback"));
     }
 
-    if (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger)
+    if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSSupport) &&
+        (TRUE == sme_IsFeatureSupportedByFW(TDLS)))
     {
-        pHddCtx->tdls_mode = eTDLS_SUPPORT_EXPLICIT_TRIGGER_ONLY;
-        hddLog(VOS_TRACE_LEVEL_INFO, "%s TDLS Implicit trigger not enabled!", __func__);
+        if (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger)
+        {
+            pHddCtx->tdls_mode = eTDLS_SUPPORT_EXPLICIT_TRIGGER_ONLY;
+            hddLog(LOGE, FL("TDLS Implicit trigger not enabled!"));
+            return;
+        }
+        pHddCtx->tdls_mode = eTDLS_SUPPORT_ENABLED;
     }
     else
     {
-        pHddCtx->tdls_mode = eTDLS_SUPPORT_ENABLED;
+        hddLog(LOGE,
+               FL("TDLS not enabled (%d) or FW doesn't support (%d)"),
+               pHddCtx->cfg_ini->fEnableTDLSSupport,
+               sme_IsFeatureSupportedByFW(TDLS));
+        pHddCtx->tdls_mode = eTDLS_SUPPORT_NOT_ENABLED;
     }
 }
 
@@ -1821,6 +1831,17 @@
     tdlsCtx_t *pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter);
     eTDLSSupportMode req_tdls_mode;
 
+    if ((TRUE != pHddCtx->cfg_ini->fEnableTDLSSupport) &&
+        (TRUE != sme_IsFeatureSupportedByFW(TDLS)))
+    {
+        hddLog(LOGE,
+               FL("TDLS not enabled (%d) or FW doesn't support (%d)"),
+               pHddCtx->cfg_ini->fEnableTDLSSupport,
+               sme_IsFeatureSupportedByFW(TDLS));
+        pHddCtx->tdls_mode = eTDLS_SUPPORT_NOT_ENABLED;
+        return -EINVAL;
+    }
+
     if (NULL == pHddTdlsCtx)
     {
         hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS not enabled!"));