mwifiex: report tdls peers in debugfs
[cascardo/linux.git] / drivers / net / wireless / mwifiex / tdls.c
index 22884b4..efa81d8 100644 (file)
@@ -1123,6 +1123,36 @@ int mwifiex_get_tdls_link_status(struct mwifiex_private *priv, const u8 *mac)
        return TDLS_NOT_SETUP;
 }
 
+int mwifiex_get_tdls_list(struct mwifiex_private *priv,
+                         struct tdls_peer_info *buf)
+{
+       struct mwifiex_sta_node *sta_ptr;
+       struct tdls_peer_info *peer = buf;
+       int count = 0;
+       unsigned long flags;
+
+       if (!ISSUPP_TDLS_ENABLED(priv->adapter->fw_cap_info))
+               return 0;
+
+       /* make sure we are in station mode and connected */
+       if (!(priv->bss_type == MWIFIEX_BSS_TYPE_STA && priv->media_connected))
+               return 0;
+
+       spin_lock_irqsave(&priv->sta_list_spinlock, flags);
+       list_for_each_entry(sta_ptr, &priv->sta_list, list) {
+               if (sta_ptr->tdls_status == TDLS_SETUP_COMPLETE) {
+                       ether_addr_copy(peer->peer_addr, sta_ptr->mac_addr);
+                       peer++;
+                       count++;
+                       if (count >= MWIFIEX_MAX_TDLS_PEER_SUPPORTED)
+                               break;
+               }
+       }
+       spin_unlock_irqrestore(&priv->sta_list_spinlock, flags);
+
+       return count;
+}
+
 void mwifiex_disable_all_tdls_links(struct mwifiex_private *priv)
 {
        struct mwifiex_sta_node *sta_ptr;