Added iwpriv command to print out TDLS peer table.

Added iwpriv getTdlsPeers command to print out TDLS
peer table for AST testing.

CRs-Fixed: 444418
Change-Id: I5b57583d21d36e8aa36439607fcbfb430935890a
diff --git a/CORE/HDD/inc/wlan_hdd_tdls.h b/CORE/HDD/inc/wlan_hdd_tdls.h
index 828a5cb..0e9931c 100644
--- a/CORE/HDD/inc/wlan_hdd_tdls.h
+++ b/CORE/HDD/inc/wlan_hdd_tdls.h
@@ -108,4 +108,6 @@
 
 u8 wlan_hdd_tdlsConnectedPeers(void);
 
+int wlan_hdd_tdls_get_all_peers(char *buf, int buflen);
+
 #endif // __HDD_TDSL_H
diff --git a/CORE/HDD/src/wlan_hdd_tdls.c b/CORE/HDD/src/wlan_hdd_tdls.c
index 838fff3..04284e2 100755
--- a/CORE/HDD/src/wlan_hdd_tdls.c
+++ b/CORE/HDD/src/wlan_hdd_tdls.c
@@ -153,6 +153,9 @@
                                                    NL80211_TDLS_SETUP, FALSE,
                                                    GFP_KERNEL);
 #endif
+                        VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
+                                "Tput triggering TDLS");
+
                         goto next_peer;
                     }
 
@@ -160,8 +163,8 @@
                             (tANI_S32)(pHddTdlsCtx->threshold_config.rssi_hysteresis +
                                 pHddTdlsCtx->ap_rssi)) {
 
-                        VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
-                                "RSSI triggering");
+                        VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
+                                "RSSI triggering TDLS");
 
 #ifdef CONFIG_TDLS_IMPLICIT
                         cfg80211_tdls_oper_request(pHddTdlsCtx->dev,
@@ -178,7 +181,7 @@
                             curr_peer->rx_pkt == 0)) {
                         if (VOS_TIMER_STATE_RUNNING !=
                                 vos_timer_getCurrentState(&curr_peer->peerIdleTimer)) {
-                            VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Tx/Rx Idle!");
+                            VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Tx/Rx Idle timer start!");
                             vos_timer_start( &curr_peer->peerIdleTimer,
                                         pHddTdlsCtx->threshold_config.rx_timeout_t );
                         }
@@ -217,7 +220,7 @@
     hddTdlsPeer_t *curr_peer = (hddTdlsPeer_t *)userData;
 #endif
 
-    VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Tx/Rx Idle - teardown!");
+    VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, "Tx/Rx Idle - teardown now!");
 
 #ifdef CONFIG_TDLS_IMPLICIT
     cfg80211_tdls_oper_request(pHddTdlsCtx->dev,
@@ -735,3 +738,49 @@
     }
     return count;
 }
+
+int wlan_hdd_tdls_get_all_peers(char *buf, int buflen)
+{
+    int i;
+    int len, init_len;
+    hddTdlsPeer_t *curr_peer;
+
+    if (NULL == pHddTdlsCtx) {
+        len = snprintf(buf, buflen, "TDLS not enabled\n");
+        return len;
+    }
+
+    init_len = buflen;
+    len = snprintf(buf, buflen, "\n%-18s%-3s%-4s%-3s%-5s\n", "MAC", "Id", "cap", "up", "RSSI");
+    buf += len;
+    buflen -= len;
+    /*                           1234567890123456789012345678901234567 */
+    len = snprintf(buf, buflen, "---------------------------------\n");
+    buf += len;
+    buflen -= len;
+
+    for (i = 0; i < 256; i++) {
+
+        curr_peer = pHddTdlsCtx->peer_list[i];
+
+        if (NULL != curr_peer) {
+            do {
+                if(buflen < 32+1)
+                    break;
+                len = snprintf(buf, buflen,
+                    "%02x:%02x:%02x:%02x:%02x:%02x%3d%4s%3s%5d\n",
+                    curr_peer->peerMac[0], curr_peer->peerMac[1],
+                    curr_peer->peerMac[2], curr_peer->peerMac[3],
+                    curr_peer->peerMac[4], curr_peer->peerMac[5],
+                    curr_peer->staId,
+                    (curr_peer->tdls_support == eTDLS_CAP_SUPPORTED) ? "Y":"N",
+                    (curr_peer->link_status == eTDLS_LINK_CONNECTED) ? "Y":"N",
+                    curr_peer->rssi);
+                buf += len;
+                buflen -= len;
+                curr_peer = (hddTdlsPeer_t *)curr_peer->node.next;
+            } while (&curr_peer->node != curr_peer->node.next);
+        }
+    }
+    return init_len-buflen;
+}
diff --git a/CORE/HDD/src/wlan_hdd_wext.c b/CORE/HDD/src/wlan_hdd_wext.c
index a752455..ae70e11 100644
--- a/CORE/HDD/src/wlan_hdd_wext.c
+++ b/CORE/HDD/src/wlan_hdd_wext.c
@@ -211,6 +211,9 @@
 #ifdef WLAN_FEATURE_11AC
 #define WE_GET_RSSI          6
 #endif
+#ifdef FEATURE_WLAN_TDLS
+#define WE_GET_TDLS_PEERS    8
+#endif
 
 /* Private ioctls and their sub-ioctls */
 #define WLAN_PRIV_SET_NONE_GET_NONE   (SIOCIWFIRSTPRIV + 6)
@@ -4053,6 +4056,13 @@
 
             break;
         }
+#ifdef FEATURE_WLAN_TDLS
+        case WE_GET_TDLS_PEERS:
+        {
+            wrqu->data.length = wlan_hdd_tdls_get_all_peers(extra, WE_MAX_STR_LEN)+1;
+            break;
+        }
+#endif
         default:  
         {
             hddLog(LOGE, "Invalid IOCTL command %d  \n",  sub_cmd );
@@ -4302,15 +4312,6 @@
                 tdlsParams.rx_timeout_t      = apps_args[4];
                 tdlsParams.rssi_hysteresis   = apps_args[5];
 
-                  VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
-                            "iw set tdls params: %d %d %d %d %d %d",
-                            tdlsParams.tx_period_t,
-                            tdlsParams.tx_packet_n,
-                            tdlsParams.discovery_period_t,
-                            tdlsParams.discovery_tries_n,
-                            tdlsParams.rx_timeout_t,
-                            tdlsParams.rssi_hysteresis);
-
                 wlan_hdd_tdls_set_params(&tdlsParams);
             }
         break;
@@ -6262,7 +6263,13 @@
         0, 
         IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
         "getChannelList" },
-
+#ifdef FEATURE_WLAN_TDLS
+    {
+        WE_GET_TDLS_PEERS,
+        0,
+        IW_PRIV_TYPE_CHAR| WE_MAX_STR_LEN,
+        "getTdlsPeers" },
+#endif
     /* handlers for main ioctl */
     {   WLAN_PRIV_SET_NONE_GET_NONE,
         0,