aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwlegacy/debug.c
diff options
context:
space:
mode:
authorStanislaw Gruszka <sgruszka@redhat.com>2012-02-13 05:23:20 -0500
committerJohn W. Linville <linville@tuxdriver.com>2012-02-22 14:51:15 -0500
commit288f9954132cd64f60fbb8051e31d62d8c35875f (patch)
tree5defaae6d77d4babd0a8bf5b9e3eefe3f1d19ee6 /drivers/net/wireless/iwlegacy/debug.c
parentc936355172a7e4aeadbbdcaae48f10e31f604899 (diff)
iwlegacy: get rid of tx/rx traffic log
The same data can be gathered using monitor mode. Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/iwlegacy/debug.c')
-rw-r--r--drivers/net/wireless/iwlegacy/debug.c243
1 files changed, 135 insertions, 108 deletions
diff --git a/drivers/net/wireless/iwlegacy/debug.c b/drivers/net/wireless/iwlegacy/debug.c
index be6005da785d..236dc90b035b 100644
--- a/drivers/net/wireless/iwlegacy/debug.c
+++ b/drivers/net/wireless/iwlegacy/debug.c
@@ -31,6 +31,101 @@
31 31
32#include "common.h" 32#include "common.h"
33 33
34void
35il_clear_traffic_stats(struct il_priv *il)
36{
37 memset(&il->tx_stats, 0, sizeof(struct traffic_stats));
38 memset(&il->rx_stats, 0, sizeof(struct traffic_stats));
39}
40
41/*
42 * il_update_stats function record all the MGMT, CTRL and DATA pkt for
43 * both TX and Rx . Use debugfs to display the rx/rx_stats
44 */
45void
46il_update_stats(struct il_priv *il, bool is_tx, __le16 fc, u16 len)
47{
48 struct traffic_stats *stats;
49
50 if (is_tx)
51 stats = &il->tx_stats;
52 else
53 stats = &il->rx_stats;
54
55 if (ieee80211_is_mgmt(fc)) {
56 switch (fc & cpu_to_le16(IEEE80211_FCTL_STYPE)) {
57 case cpu_to_le16(IEEE80211_STYPE_ASSOC_REQ):
58 stats->mgmt[MANAGEMENT_ASSOC_REQ]++;
59 break;
60 case cpu_to_le16(IEEE80211_STYPE_ASSOC_RESP):
61 stats->mgmt[MANAGEMENT_ASSOC_RESP]++;
62 break;
63 case cpu_to_le16(IEEE80211_STYPE_REASSOC_REQ):
64 stats->mgmt[MANAGEMENT_REASSOC_REQ]++;
65 break;
66 case cpu_to_le16(IEEE80211_STYPE_REASSOC_RESP):
67 stats->mgmt[MANAGEMENT_REASSOC_RESP]++;
68 break;
69 case cpu_to_le16(IEEE80211_STYPE_PROBE_REQ):
70 stats->mgmt[MANAGEMENT_PROBE_REQ]++;
71 break;
72 case cpu_to_le16(IEEE80211_STYPE_PROBE_RESP):
73 stats->mgmt[MANAGEMENT_PROBE_RESP]++;
74 break;
75 case cpu_to_le16(IEEE80211_STYPE_BEACON):
76 stats->mgmt[MANAGEMENT_BEACON]++;
77 break;
78 case cpu_to_le16(IEEE80211_STYPE_ATIM):
79 stats->mgmt[MANAGEMENT_ATIM]++;
80 break;
81 case cpu_to_le16(IEEE80211_STYPE_DISASSOC):
82 stats->mgmt[MANAGEMENT_DISASSOC]++;
83 break;
84 case cpu_to_le16(IEEE80211_STYPE_AUTH):
85 stats->mgmt[MANAGEMENT_AUTH]++;
86 break;
87 case cpu_to_le16(IEEE80211_STYPE_DEAUTH):
88 stats->mgmt[MANAGEMENT_DEAUTH]++;
89 break;
90 case cpu_to_le16(IEEE80211_STYPE_ACTION):
91 stats->mgmt[MANAGEMENT_ACTION]++;
92 break;
93 }
94 } else if (ieee80211_is_ctl(fc)) {
95 switch (fc & cpu_to_le16(IEEE80211_FCTL_STYPE)) {
96 case cpu_to_le16(IEEE80211_STYPE_BACK_REQ):
97 stats->ctrl[CONTROL_BACK_REQ]++;
98 break;
99 case cpu_to_le16(IEEE80211_STYPE_BACK):
100 stats->ctrl[CONTROL_BACK]++;
101 break;
102 case cpu_to_le16(IEEE80211_STYPE_PSPOLL):
103 stats->ctrl[CONTROL_PSPOLL]++;
104 break;
105 case cpu_to_le16(IEEE80211_STYPE_RTS):
106 stats->ctrl[CONTROL_RTS]++;
107 break;
108 case cpu_to_le16(IEEE80211_STYPE_CTS):
109 stats->ctrl[CONTROL_CTS]++;
110 break;
111 case cpu_to_le16(IEEE80211_STYPE_ACK):
112 stats->ctrl[CONTROL_ACK]++;
113 break;
114 case cpu_to_le16(IEEE80211_STYPE_CFEND):
115 stats->ctrl[CONTROL_CFEND]++;
116 break;
117 case cpu_to_le16(IEEE80211_STYPE_CFENDACK):
118 stats->ctrl[CONTROL_CFENDACK]++;
119 break;
120 }
121 } else {
122 /* data */
123 stats->data_cnt++;
124 stats->data_bytes += len;
125 }
126}
127EXPORT_SYMBOL(il_update_stats);
128
34/* create and remove of files */ 129/* create and remove of files */
35#define DEBUGFS_ADD_FILE(name, parent, mode) do { \ 130#define DEBUGFS_ADD_FILE(name, parent, mode) do { \
36 if (!debugfs_create_file(#name, mode, parent, il, \ 131 if (!debugfs_create_file(#name, mode, parent, il, \
@@ -98,6 +193,46 @@ static const struct file_operations il_dbgfs_##name##_ops = { \
98 .llseek = generic_file_llseek, \ 193 .llseek = generic_file_llseek, \
99}; 194};
100 195
196static const char *
197il_get_mgmt_string(int cmd)
198{
199 switch (cmd) {
200 IL_CMD(MANAGEMENT_ASSOC_REQ);
201 IL_CMD(MANAGEMENT_ASSOC_RESP);
202 IL_CMD(MANAGEMENT_REASSOC_REQ);
203 IL_CMD(MANAGEMENT_REASSOC_RESP);
204 IL_CMD(MANAGEMENT_PROBE_REQ);
205 IL_CMD(MANAGEMENT_PROBE_RESP);
206 IL_CMD(MANAGEMENT_BEACON);
207 IL_CMD(MANAGEMENT_ATIM);
208 IL_CMD(MANAGEMENT_DISASSOC);
209 IL_CMD(MANAGEMENT_AUTH);
210 IL_CMD(MANAGEMENT_DEAUTH);
211 IL_CMD(MANAGEMENT_ACTION);
212 default:
213 return "UNKNOWN";
214
215 }
216}
217
218static const char *
219il_get_ctrl_string(int cmd)
220{
221 switch (cmd) {
222 IL_CMD(CONTROL_BACK_REQ);
223 IL_CMD(CONTROL_BACK);
224 IL_CMD(CONTROL_PSPOLL);
225 IL_CMD(CONTROL_RTS);
226 IL_CMD(CONTROL_CTS);
227 IL_CMD(CONTROL_ACK);
228 IL_CMD(CONTROL_CFEND);
229 IL_CMD(CONTROL_CFENDACK);
230 default:
231 return "UNKNOWN";
232
233 }
234}
235
101static ssize_t 236static ssize_t
102il_dbgfs_tx_stats_read(struct file *file, char __user *user_buf, size_t count, 237il_dbgfs_tx_stats_read(struct file *file, char __user *user_buf, size_t count,
103 loff_t *ppos) 238 loff_t *ppos)
@@ -715,112 +850,6 @@ DEBUGFS_READ_FILE_OPS(qos);
715DEBUGFS_READ_WRITE_FILE_OPS(disable_ht40); 850DEBUGFS_READ_WRITE_FILE_OPS(disable_ht40);
716 851
717static ssize_t 852static ssize_t
718il_dbgfs_traffic_log_read(struct file *file, char __user *user_buf,
719 size_t count, loff_t *ppos)
720{
721 struct il_priv *il = file->private_data;
722 int pos = 0, ofs = 0;
723 int cnt = 0, entry;
724 struct il_tx_queue *txq;
725 struct il_queue *q;
726 struct il_rx_queue *rxq = &il->rxq;
727 char *buf;
728 int bufsz =
729 ((IL_TRAFFIC_ENTRIES * IL_TRAFFIC_ENTRY_SIZE * 64) * 2) +
730 (il->cfg->num_of_queues * 32 * 8) + 400;
731 const u8 *ptr;
732 ssize_t ret;
733
734 if (!il->txq) {
735 IL_ERR("txq not ready\n");
736 return -EAGAIN;
737 }
738 buf = kzalloc(bufsz, GFP_KERNEL);
739 if (!buf) {
740 IL_ERR("Can not allocate buffer\n");
741 return -ENOMEM;
742 }
743 pos += scnprintf(buf + pos, bufsz - pos, "Tx Queue\n");
744 for (cnt = 0; cnt < il->hw_params.max_txq_num; cnt++) {
745 txq = &il->txq[cnt];
746 q = &txq->q;
747 pos +=
748 scnprintf(buf + pos, bufsz - pos,
749 "q[%d]: read_ptr: %u, write_ptr: %u\n", cnt,
750 q->read_ptr, q->write_ptr);
751 }
752 if (il->tx_traffic && (il_debug_level & IL_DL_TX)) {
753 ptr = il->tx_traffic;
754 pos +=
755 scnprintf(buf + pos, bufsz - pos, "Tx Traffic idx: %u\n",
756 il->tx_traffic_idx);
757 for (cnt = 0, ofs = 0; cnt < IL_TRAFFIC_ENTRIES; cnt++) {
758 for (entry = 0; entry < IL_TRAFFIC_ENTRY_SIZE / 16;
759 entry++, ofs += 16) {
760 pos +=
761 scnprintf(buf + pos, bufsz - pos, "0x%.4x ",
762 ofs);
763 hex_dump_to_buffer(ptr + ofs, 16, 16, 2,
764 buf + pos, bufsz - pos, 0);
765 pos += strlen(buf + pos);
766 if (bufsz - pos > 0)
767 buf[pos++] = '\n';
768 }
769 }
770 }
771
772 pos += scnprintf(buf + pos, bufsz - pos, "Rx Queue\n");
773 pos +=
774 scnprintf(buf + pos, bufsz - pos, "read: %u, write: %u\n",
775 rxq->read, rxq->write);
776
777 if (il->rx_traffic && (il_debug_level & IL_DL_RX)) {
778 ptr = il->rx_traffic;
779 pos +=
780 scnprintf(buf + pos, bufsz - pos, "Rx Traffic idx: %u\n",
781 il->rx_traffic_idx);
782 for (cnt = 0, ofs = 0; cnt < IL_TRAFFIC_ENTRIES; cnt++) {
783 for (entry = 0; entry < IL_TRAFFIC_ENTRY_SIZE / 16;
784 entry++, ofs += 16) {
785 pos +=
786 scnprintf(buf + pos, bufsz - pos, "0x%.4x ",
787 ofs);
788 hex_dump_to_buffer(ptr + ofs, 16, 16, 2,
789 buf + pos, bufsz - pos, 0);
790 pos += strlen(buf + pos);
791 if (bufsz - pos > 0)
792 buf[pos++] = '\n';
793 }
794 }
795 }
796
797 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
798 kfree(buf);
799 return ret;
800}
801
802static ssize_t
803il_dbgfs_traffic_log_write(struct file *file, const char __user *user_buf,
804 size_t count, loff_t *ppos)
805{
806 struct il_priv *il = file->private_data;
807 char buf[8];
808 int buf_size;
809 int traffic_log;
810
811 memset(buf, 0, sizeof(buf));
812 buf_size = min(count, sizeof(buf) - 1);
813 if (copy_from_user(buf, user_buf, buf_size))
814 return -EFAULT;
815 if (sscanf(buf, "%d", &traffic_log) != 1)
816 return -EFAULT;
817 if (traffic_log == 0)
818 il_reset_traffic_log(il);
819
820 return count;
821}
822
823static ssize_t
824il_dbgfs_tx_queue_read(struct file *file, char __user *user_buf, size_t count, 853il_dbgfs_tx_queue_read(struct file *file, char __user *user_buf, size_t count,
825 loff_t *ppos) 854 loff_t *ppos)
826{ 855{
@@ -1303,7 +1332,6 @@ il_dbgfs_wd_timeout_write(struct file *file, const char __user *user_buf,
1303 1332
1304DEBUGFS_READ_FILE_OPS(rx_stats); 1333DEBUGFS_READ_FILE_OPS(rx_stats);
1305DEBUGFS_READ_FILE_OPS(tx_stats); 1334DEBUGFS_READ_FILE_OPS(tx_stats);
1306DEBUGFS_READ_WRITE_FILE_OPS(traffic_log);
1307DEBUGFS_READ_FILE_OPS(rx_queue); 1335DEBUGFS_READ_FILE_OPS(rx_queue);
1308DEBUGFS_READ_FILE_OPS(tx_queue); 1336DEBUGFS_READ_FILE_OPS(tx_queue);
1309DEBUGFS_READ_FILE_OPS(ucode_rx_stats); 1337DEBUGFS_READ_FILE_OPS(ucode_rx_stats);
@@ -1357,7 +1385,6 @@ il_dbgfs_register(struct il_priv *il, const char *name)
1357 DEBUGFS_ADD_FILE(disable_ht40, dir_data, S_IWUSR | S_IRUSR); 1385 DEBUGFS_ADD_FILE(disable_ht40, dir_data, S_IWUSR | S_IRUSR);
1358 DEBUGFS_ADD_FILE(rx_stats, dir_debug, S_IRUSR); 1386 DEBUGFS_ADD_FILE(rx_stats, dir_debug, S_IRUSR);
1359 DEBUGFS_ADD_FILE(tx_stats, dir_debug, S_IRUSR); 1387 DEBUGFS_ADD_FILE(tx_stats, dir_debug, S_IRUSR);
1360 DEBUGFS_ADD_FILE(traffic_log, dir_debug, S_IWUSR | S_IRUSR);
1361 DEBUGFS_ADD_FILE(rx_queue, dir_debug, S_IRUSR); 1388 DEBUGFS_ADD_FILE(rx_queue, dir_debug, S_IRUSR);
1362 DEBUGFS_ADD_FILE(tx_queue, dir_debug, S_IRUSR); 1389 DEBUGFS_ADD_FILE(tx_queue, dir_debug, S_IRUSR);
1363 DEBUGFS_ADD_FILE(power_save_status, dir_debug, S_IRUSR); 1390 DEBUGFS_ADD_FILE(power_save_status, dir_debug, S_IRUSR);