mwifiex: report tdls peers in debugfs
authorXinming Hu <huxm@marvell.com>
Tue, 23 Dec 2014 13:44:05 +0000 (19:14 +0530)
committerKalle Valo <kvalo@codeaurora.org>
Tue, 6 Jan 2015 18:53:23 +0000 (20:53 +0200)
This patch add provision to show TDLS peer table in debugfs file.

Signed-off-by: Xinming Hu <huxm@marvell.com>
Signed-off-by: Cathy Luo <cluo@marvell.com>
Signed-off-by: Avinash Patil <patila@marvell.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/mwifiex/debugfs.c
drivers/net/wireless/mwifiex/decl.h
drivers/net/wireless/mwifiex/ioctl.h
drivers/net/wireless/mwifiex/main.h
drivers/net/wireless/mwifiex/tdls.c
drivers/net/wireless/mwifiex/util.c

index 2713f7acd35e6d45081482c36b983a8a92af89a3..b50603276ecb6c8c8913a95c16079fc74f77f52e 100644 (file)
@@ -493,6 +493,15 @@ mwifiex_debug_read(struct file *file, char __user *ubuf,
                }
        }
 
+       if (info.tdls_peer_num) {
+               p += sprintf(p, "TDLS peer table:\n");
+               for (i = 0; i < info.tdls_peer_num; i++) {
+                       p += sprintf(p, "peer = %pM",
+                                    info.tdls_list[i].peer_addr);
+                       p += sprintf(p, "\n");
+               }
+       }
+
        ret = simple_read_from_buffer(ubuf, count, ppos, (char *) page,
                                      (unsigned long) p - page);
 
index 2269acf41ad8e6c63498a1728d00d771e162e59b..21b5130c264ed5af6e0332919bafc12b4fd33e61 100644 (file)
@@ -41,6 +41,7 @@
 
 #define MWIFIEX_MAX_TX_BASTREAM_SUPPORTED      2
 #define MWIFIEX_MAX_RX_BASTREAM_SUPPORTED      16
+#define MWIFIEX_MAX_TDLS_PEER_SUPPORTED 8
 
 #define MWIFIEX_STA_AMPDU_DEF_TXWINSIZE        64
 #define MWIFIEX_STA_AMPDU_DEF_RXWINSIZE        64
index 0847f3e07ab7888e2f79eada0e07fd263620edcb..dcf4bdbd750519ae02271368c5a5439a5962e318 100644 (file)
@@ -180,7 +180,11 @@ struct mwifiex_ds_tx_ba_stream_tbl {
        u8 amsdu;
 };
 
-#define DBG_CMD_NUM    5
+#define DBG_CMD_NUM    5
+
+struct tdls_peer_info {
+       u8 peer_addr[ETH_ALEN];
+};
 
 struct mwifiex_debug_info {
        u32 int_counter;
@@ -193,6 +197,9 @@ struct mwifiex_debug_info {
        u32 rx_tbl_num;
        struct mwifiex_ds_rx_reorder_tbl rx_tbl
                [MWIFIEX_MAX_RX_BASTREAM_SUPPORTED];
+       u32 tdls_peer_num;
+       struct tdls_peer_info tdls_list
+               [MWIFIEX_MAX_TDLS_PEER_SUPPORTED];
        u16 ps_mode;
        u32 ps_state;
        u8 is_deep_sleep;
index e66993cb5daf185f32c9053ce30577678cd861a6..b3e23f625e1afa1f451e8086476d9d5ce16304a4 100644 (file)
@@ -1324,6 +1324,8 @@ void mwifiex_process_tdls_action_frame(struct mwifiex_private *priv,
                                       u8 *buf, int len);
 int mwifiex_tdls_oper(struct mwifiex_private *priv, const u8 *peer, u8 action);
 int mwifiex_get_tdls_link_status(struct mwifiex_private *priv, const u8 *mac);
+int mwifiex_get_tdls_list(struct mwifiex_private *priv,
+                         struct tdls_peer_info *buf);
 void mwifiex_disable_all_tdls_links(struct mwifiex_private *priv);
 bool mwifiex_is_bss_in_11ac_mode(struct mwifiex_private *priv);
 u8 mwifiex_get_center_freq_index(struct mwifiex_private *priv, u8 band,
index 22884b429be787cadefb8f588e99890f44dd5988..efa81d8f2597f042aa73084c339d597ca9c92294 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;
index b1768fbf98f2235a9c762b8af4a2fcc2fdf245a9..3bd917975e5bcc13c7ebb80f466e0dc30c2529f9 100644 (file)
@@ -97,6 +97,8 @@ int mwifiex_get_debug_info(struct mwifiex_private *priv,
                                                              info->rx_tbl);
                info->tx_tbl_num = mwifiex_get_tx_ba_stream_tbl(priv,
                                                                info->tx_tbl);
+               info->tdls_peer_num = mwifiex_get_tdls_list(priv,
+                                                           info->tdls_list);
                info->ps_mode = adapter->ps_mode;
                info->ps_state = adapter->ps_state;
                info->is_deep_sleep = adapter->is_deep_sleep;