TDLS: Enhance TDLS external control operations (gTDLSExternalControl=1)

This commit enhances the external control operations to

1.Allows gTDLSTxStatsPeriod to accept a minimal value of 10 msec.
2.Allows gTDLSIdlePacketThreshold to accept a minimal value of 0 packets.
3.Caters the requirement of establishing the TDLS link irrespective of
  the data traffic, the moment tdls_setup is issued by the framework.
4.Only teardown based on non-zero idle packet threshold, to address a use
    case where this threshold does not get consider for TEAR DOWN.

Change-Id: Idf5a6c5ecb72565586b21217a9c066c3ca2c83fc
CRs-fixed: 537537
diff --git a/CORE/HDD/src/wlan_hdd_cfg80211.c b/CORE/HDD/src/wlan_hdd_cfg80211.c
index 86a005c..fd64ef6 100644
--- a/CORE/HDD/src/wlan_hdd_cfg80211.c
+++ b/CORE/HDD/src/wlan_hdd_cfg80211.c
@@ -8590,6 +8590,7 @@
             }
         case NL80211_TDLS_SETUP:
             {
+                hddTdlsPeer_t *pTdlsPeer;
                 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
                           " %s : NL80211_TDLS_SETUP for " MAC_ADDRESS_STR,
                           __func__, MAC_ADDR_ARRAY(peer));
@@ -8603,7 +8604,24 @@
                     return -ENOTSUPP;
                 }
 
-                return wlan_hdd_tdls_add_force_peer(pAdapter, peer);
+                if ( 0 != wlan_hdd_tdls_add_force_peer(pAdapter, peer) ) {
+
+                    VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
+                          " %s TDLS Add Force Peer Failed",
+                          __func__);
+                    return -EINVAL;
+                }
+                /* To cater the requirement of establishing the TDLS link
+                 * irrespective of the data traffic , get an entry of TDLS peer.
+                 */
+                pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, peer);
+                if (pTdlsPeer == NULL) {
+                    VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
+                              "%s: peer " MAC_ADDRESS_STR " not existing",
+                              __func__, MAC_ADDR_ARRAY(peer));
+                    return -EINVAL;
+                }
+                break;
             }
         case NL80211_TDLS_DISCOVERY_REQ:
             /* We don't support in-driver setup/teardown/discovery */
diff --git a/CORE/HDD/src/wlan_hdd_tdls.c b/CORE/HDD/src/wlan_hdd_tdls.c
index 4abbf89..bc108c0 100644
--- a/CORE/HDD/src/wlan_hdd_tdls.c
+++ b/CORE/HDD/src/wlan_hdd_tdls.c
@@ -339,10 +339,15 @@
                         goto next_peer;
                     }
 
-                    if ((curr_peer->tx_pkt <
+                    /* Only teardown based on non zero idle packet threshold, to address a use
+                     * case where this threshold does not get consider for TEAR DOWN.
+                     */
+
+                    if (( 0 != pHddTdlsCtx->threshold_config.idle_packet_n ) &&
+                        ((curr_peer->tx_pkt <
                             pHddTdlsCtx->threshold_config.idle_packet_n) &&
                         (curr_peer->rx_pkt <
-                            pHddTdlsCtx->threshold_config.idle_packet_n)) {
+                            pHddTdlsCtx->threshold_config.idle_packet_n))) {
                         if (VOS_TIMER_STATE_RUNNING !=
                                 vos_timer_getCurrentState(&curr_peer->peerIdleTimer)) {
                             VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,