aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSujith Manoharan <Sujith.Manoharan@atheros.com>2011-04-13 01:54:00 -0400
committerJohn W. Linville <linville@tuxdriver.com>2011-04-13 15:22:37 -0400
commit8e42e4ba98f986be64016df79eacbb671dbd3d18 (patch)
tree05191ee5162eaf0959e78756d7a1f954cb28597e
parentf4c88991f51e097b6541f998fd23d477999e5886 (diff)
ath9k_htc: Move debug code to a separate file
Signed-off-by: Sujith Manoharan <Sujith.Manoharan@atheros.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r--drivers/net/wireless/ath/ath9k/Makefile2
-rw-r--r--drivers/net/wireless/ath/ath9k/htc_drv_debug.c219
-rw-r--r--drivers/net/wireless/ath/ath9k/htc_drv_main.c212
3 files changed, 221 insertions, 212 deletions
diff --git a/drivers/net/wireless/ath/ath9k/Makefile b/drivers/net/wireless/ath/ath9k/Makefile
index ca4c436e0f65..05a6fade7b1c 100644
--- a/drivers/net/wireless/ath/ath9k/Makefile
+++ b/drivers/net/wireless/ath/ath9k/Makefile
@@ -48,4 +48,6 @@ ath9k_htc-y += htc_hst.o \
48 htc_drv_init.o \ 48 htc_drv_init.o \
49 htc_drv_gpio.o 49 htc_drv_gpio.o
50 50
51ath9k_htc-$(CONFIG_ATH9K_HTC_DEBUGFS) += htc_drv_debug.o
52
51obj-$(CONFIG_ATH9K_HTC) += ath9k_htc.o 53obj-$(CONFIG_ATH9K_HTC) += ath9k_htc.o
diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_debug.c b/drivers/net/wireless/ath/ath9k/htc_drv_debug.c
new file mode 100644
index 000000000000..8b679aab338a
--- /dev/null
+++ b/drivers/net/wireless/ath/ath9k/htc_drv_debug.c
@@ -0,0 +1,219 @@
1/*
2 * Copyright (c) 2010-2011 Atheros Communications Inc.
3 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17#include "htc.h"
18
19static struct dentry *ath9k_debugfs_root;
20
21static int ath9k_debugfs_open(struct inode *inode, struct file *file)
22{
23 file->private_data = inode->i_private;
24 return 0;
25}
26
27static ssize_t read_file_tgt_stats(struct file *file, char __user *user_buf,
28 size_t count, loff_t *ppos)
29{
30 struct ath9k_htc_priv *priv = file->private_data;
31 struct ath9k_htc_target_stats cmd_rsp;
32 char buf[512];
33 unsigned int len = 0;
34 int ret = 0;
35
36 memset(&cmd_rsp, 0, sizeof(cmd_rsp));
37
38 WMI_CMD(WMI_TGT_STATS_CMDID);
39 if (ret)
40 return -EINVAL;
41
42
43 len += snprintf(buf + len, sizeof(buf) - len,
44 "%19s : %10u\n", "TX Short Retries",
45 be32_to_cpu(cmd_rsp.tx_shortretry));
46 len += snprintf(buf + len, sizeof(buf) - len,
47 "%19s : %10u\n", "TX Long Retries",
48 be32_to_cpu(cmd_rsp.tx_longretry));
49 len += snprintf(buf + len, sizeof(buf) - len,
50 "%19s : %10u\n", "TX Xretries",
51 be32_to_cpu(cmd_rsp.tx_xretries));
52 len += snprintf(buf + len, sizeof(buf) - len,
53 "%19s : %10u\n", "TX Unaggr. Xretries",
54 be32_to_cpu(cmd_rsp.ht_txunaggr_xretry));
55 len += snprintf(buf + len, sizeof(buf) - len,
56 "%19s : %10u\n", "TX Xretries (HT)",
57 be32_to_cpu(cmd_rsp.ht_tx_xretries));
58 len += snprintf(buf + len, sizeof(buf) - len,
59 "%19s : %10u\n", "TX Rate", priv->debug.txrate);
60
61 if (len > sizeof(buf))
62 len = sizeof(buf);
63
64 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
65}
66
67static const struct file_operations fops_tgt_stats = {
68 .read = read_file_tgt_stats,
69 .open = ath9k_debugfs_open,
70 .owner = THIS_MODULE,
71 .llseek = default_llseek,
72};
73
74static ssize_t read_file_xmit(struct file *file, char __user *user_buf,
75 size_t count, loff_t *ppos)
76{
77 struct ath9k_htc_priv *priv = file->private_data;
78 char buf[512];
79 unsigned int len = 0;
80
81 len += snprintf(buf + len, sizeof(buf) - len,
82 "%20s : %10u\n", "Buffers queued",
83 priv->debug.tx_stats.buf_queued);
84 len += snprintf(buf + len, sizeof(buf) - len,
85 "%20s : %10u\n", "Buffers completed",
86 priv->debug.tx_stats.buf_completed);
87 len += snprintf(buf + len, sizeof(buf) - len,
88 "%20s : %10u\n", "SKBs queued",
89 priv->debug.tx_stats.skb_queued);
90 len += snprintf(buf + len, sizeof(buf) - len,
91 "%20s : %10u\n", "SKBs completed",
92 priv->debug.tx_stats.skb_completed);
93 len += snprintf(buf + len, sizeof(buf) - len,
94 "%20s : %10u\n", "SKBs dropped",
95 priv->debug.tx_stats.skb_dropped);
96 len += snprintf(buf + len, sizeof(buf) - len,
97 "%20s : %10u\n", "CAB queued",
98 priv->debug.tx_stats.cab_queued);
99
100 len += snprintf(buf + len, sizeof(buf) - len,
101 "%20s : %10u\n", "BE queued",
102 priv->debug.tx_stats.queue_stats[WME_AC_BE]);
103 len += snprintf(buf + len, sizeof(buf) - len,
104 "%20s : %10u\n", "BK queued",
105 priv->debug.tx_stats.queue_stats[WME_AC_BK]);
106 len += snprintf(buf + len, sizeof(buf) - len,
107 "%20s : %10u\n", "VI queued",
108 priv->debug.tx_stats.queue_stats[WME_AC_VI]);
109 len += snprintf(buf + len, sizeof(buf) - len,
110 "%20s : %10u\n", "VO queued",
111 priv->debug.tx_stats.queue_stats[WME_AC_VO]);
112
113 if (len > sizeof(buf))
114 len = sizeof(buf);
115
116 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
117}
118
119static const struct file_operations fops_xmit = {
120 .read = read_file_xmit,
121 .open = ath9k_debugfs_open,
122 .owner = THIS_MODULE,
123 .llseek = default_llseek,
124};
125
126static ssize_t read_file_recv(struct file *file, char __user *user_buf,
127 size_t count, loff_t *ppos)
128{
129 struct ath9k_htc_priv *priv = file->private_data;
130 char buf[512];
131 unsigned int len = 0;
132
133 len += snprintf(buf + len, sizeof(buf) - len,
134 "%20s : %10u\n", "SKBs allocated",
135 priv->debug.rx_stats.skb_allocated);
136 len += snprintf(buf + len, sizeof(buf) - len,
137 "%20s : %10u\n", "SKBs completed",
138 priv->debug.rx_stats.skb_completed);
139 len += snprintf(buf + len, sizeof(buf) - len,
140 "%20s : %10u\n", "SKBs Dropped",
141 priv->debug.rx_stats.skb_dropped);
142
143 if (len > sizeof(buf))
144 len = sizeof(buf);
145
146 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
147}
148
149static const struct file_operations fops_recv = {
150 .read = read_file_recv,
151 .open = ath9k_debugfs_open,
152 .owner = THIS_MODULE,
153 .llseek = default_llseek,
154};
155
156int ath9k_htc_init_debug(struct ath_hw *ah)
157{
158 struct ath_common *common = ath9k_hw_common(ah);
159 struct ath9k_htc_priv *priv = (struct ath9k_htc_priv *) common->priv;
160
161 if (!ath9k_debugfs_root)
162 return -ENOENT;
163
164 priv->debug.debugfs_phy = debugfs_create_dir(wiphy_name(priv->hw->wiphy),
165 ath9k_debugfs_root);
166 if (!priv->debug.debugfs_phy)
167 goto err;
168
169 priv->debug.debugfs_tgt_stats = debugfs_create_file("tgt_stats", S_IRUSR,
170 priv->debug.debugfs_phy,
171 priv, &fops_tgt_stats);
172 if (!priv->debug.debugfs_tgt_stats)
173 goto err;
174
175
176 priv->debug.debugfs_xmit = debugfs_create_file("xmit", S_IRUSR,
177 priv->debug.debugfs_phy,
178 priv, &fops_xmit);
179 if (!priv->debug.debugfs_xmit)
180 goto err;
181
182 priv->debug.debugfs_recv = debugfs_create_file("recv", S_IRUSR,
183 priv->debug.debugfs_phy,
184 priv, &fops_recv);
185 if (!priv->debug.debugfs_recv)
186 goto err;
187
188 return 0;
189
190err:
191 ath9k_htc_exit_debug(ah);
192 return -ENOMEM;
193}
194
195void ath9k_htc_exit_debug(struct ath_hw *ah)
196{
197 struct ath_common *common = ath9k_hw_common(ah);
198 struct ath9k_htc_priv *priv = (struct ath9k_htc_priv *) common->priv;
199
200 debugfs_remove(priv->debug.debugfs_recv);
201 debugfs_remove(priv->debug.debugfs_xmit);
202 debugfs_remove(priv->debug.debugfs_tgt_stats);
203 debugfs_remove(priv->debug.debugfs_phy);
204}
205
206int ath9k_htc_debug_create_root(void)
207{
208 ath9k_debugfs_root = debugfs_create_dir(KBUILD_MODNAME, NULL);
209 if (!ath9k_debugfs_root)
210 return -ENOENT;
211
212 return 0;
213}
214
215void ath9k_htc_debug_remove_root(void)
216{
217 debugfs_remove(ath9k_debugfs_root);
218 ath9k_debugfs_root = NULL;
219}
diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_main.c b/drivers/net/wireless/ath/ath9k/htc_drv_main.c
index 81dfe0782f74..59710e75f051 100644
--- a/drivers/net/wireless/ath/ath9k/htc_drv_main.c
+++ b/drivers/net/wireless/ath/ath9k/htc_drv_main.c
@@ -16,10 +16,6 @@
16 16
17#include "htc.h" 17#include "htc.h"
18 18
19#ifdef CONFIG_ATH9K_HTC_DEBUGFS
20static struct dentry *ath9k_debugfs_root;
21#endif
22
23/*************/ 19/*************/
24/* Utilities */ 20/* Utilities */
25/*************/ 21/*************/
@@ -720,214 +716,6 @@ static int ath9k_htc_tx_aggr_oper(struct ath9k_htc_priv *priv,
720 return ret; 716 return ret;
721} 717}
722 718
723/*********/
724/* DEBUG */
725/*********/
726
727#ifdef CONFIG_ATH9K_HTC_DEBUGFS
728
729static int ath9k_debugfs_open(struct inode *inode, struct file *file)
730{
731 file->private_data = inode->i_private;
732 return 0;
733}
734
735static ssize_t read_file_tgt_stats(struct file *file, char __user *user_buf,
736 size_t count, loff_t *ppos)
737{
738 struct ath9k_htc_priv *priv = file->private_data;
739 struct ath9k_htc_target_stats cmd_rsp;
740 char buf[512];
741 unsigned int len = 0;
742 int ret = 0;
743
744 memset(&cmd_rsp, 0, sizeof(cmd_rsp));
745
746 WMI_CMD(WMI_TGT_STATS_CMDID);
747 if (ret)
748 return -EINVAL;
749
750
751 len += snprintf(buf + len, sizeof(buf) - len,
752 "%19s : %10u\n", "TX Short Retries",
753 be32_to_cpu(cmd_rsp.tx_shortretry));
754 len += snprintf(buf + len, sizeof(buf) - len,
755 "%19s : %10u\n", "TX Long Retries",
756 be32_to_cpu(cmd_rsp.tx_longretry));
757 len += snprintf(buf + len, sizeof(buf) - len,
758 "%19s : %10u\n", "TX Xretries",
759 be32_to_cpu(cmd_rsp.tx_xretries));
760 len += snprintf(buf + len, sizeof(buf) - len,
761 "%19s : %10u\n", "TX Unaggr. Xretries",
762 be32_to_cpu(cmd_rsp.ht_txunaggr_xretry));
763 len += snprintf(buf + len, sizeof(buf) - len,
764 "%19s : %10u\n", "TX Xretries (HT)",
765 be32_to_cpu(cmd_rsp.ht_tx_xretries));
766 len += snprintf(buf + len, sizeof(buf) - len,
767 "%19s : %10u\n", "TX Rate", priv->debug.txrate);
768
769 if (len > sizeof(buf))
770 len = sizeof(buf);
771
772 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
773}
774
775static const struct file_operations fops_tgt_stats = {
776 .read = read_file_tgt_stats,
777 .open = ath9k_debugfs_open,
778 .owner = THIS_MODULE,
779 .llseek = default_llseek,
780};
781
782static ssize_t read_file_xmit(struct file *file, char __user *user_buf,
783 size_t count, loff_t *ppos)
784{
785 struct ath9k_htc_priv *priv = file->private_data;
786 char buf[512];
787 unsigned int len = 0;
788
789 len += snprintf(buf + len, sizeof(buf) - len,
790 "%20s : %10u\n", "Buffers queued",
791 priv->debug.tx_stats.buf_queued);
792 len += snprintf(buf + len, sizeof(buf) - len,
793 "%20s : %10u\n", "Buffers completed",
794 priv->debug.tx_stats.buf_completed);
795 len += snprintf(buf + len, sizeof(buf) - len,
796 "%20s : %10u\n", "SKBs queued",
797 priv->debug.tx_stats.skb_queued);
798 len += snprintf(buf + len, sizeof(buf) - len,
799 "%20s : %10u\n", "SKBs completed",
800 priv->debug.tx_stats.skb_completed);
801 len += snprintf(buf + len, sizeof(buf) - len,
802 "%20s : %10u\n", "SKBs dropped",
803 priv->debug.tx_stats.skb_dropped);
804 len += snprintf(buf + len, sizeof(buf) - len,
805 "%20s : %10u\n", "CAB queued",
806 priv->debug.tx_stats.cab_queued);
807
808 len += snprintf(buf + len, sizeof(buf) - len,
809 "%20s : %10u\n", "BE queued",
810 priv->debug.tx_stats.queue_stats[WME_AC_BE]);
811 len += snprintf(buf + len, sizeof(buf) - len,
812 "%20s : %10u\n", "BK queued",
813 priv->debug.tx_stats.queue_stats[WME_AC_BK]);
814 len += snprintf(buf + len, sizeof(buf) - len,
815 "%20s : %10u\n", "VI queued",
816 priv->debug.tx_stats.queue_stats[WME_AC_VI]);
817 len += snprintf(buf + len, sizeof(buf) - len,
818 "%20s : %10u\n", "VO queued",
819 priv->debug.tx_stats.queue_stats[WME_AC_VO]);
820
821 if (len > sizeof(buf))
822 len = sizeof(buf);
823
824 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
825}
826
827static const struct file_operations fops_xmit = {
828 .read = read_file_xmit,
829 .open = ath9k_debugfs_open,
830 .owner = THIS_MODULE,
831 .llseek = default_llseek,
832};
833
834static ssize_t read_file_recv(struct file *file, char __user *user_buf,
835 size_t count, loff_t *ppos)
836{
837 struct ath9k_htc_priv *priv = file->private_data;
838 char buf[512];
839 unsigned int len = 0;
840
841 len += snprintf(buf + len, sizeof(buf) - len,
842 "%20s : %10u\n", "SKBs allocated",
843 priv->debug.rx_stats.skb_allocated);
844 len += snprintf(buf + len, sizeof(buf) - len,
845 "%20s : %10u\n", "SKBs completed",
846 priv->debug.rx_stats.skb_completed);
847 len += snprintf(buf + len, sizeof(buf) - len,
848 "%20s : %10u\n", "SKBs Dropped",
849 priv->debug.rx_stats.skb_dropped);
850
851 if (len > sizeof(buf))
852 len = sizeof(buf);
853
854 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
855}
856
857static const struct file_operations fops_recv = {
858 .read = read_file_recv,
859 .open = ath9k_debugfs_open,
860 .owner = THIS_MODULE,
861 .llseek = default_llseek,
862};
863
864int ath9k_htc_init_debug(struct ath_hw *ah)
865{
866 struct ath_common *common = ath9k_hw_common(ah);
867 struct ath9k_htc_priv *priv = (struct ath9k_htc_priv *) common->priv;
868
869 if (!ath9k_debugfs_root)
870 return -ENOENT;
871
872 priv->debug.debugfs_phy = debugfs_create_dir(wiphy_name(priv->hw->wiphy),
873 ath9k_debugfs_root);
874 if (!priv->debug.debugfs_phy)
875 goto err;
876
877 priv->debug.debugfs_tgt_stats = debugfs_create_file("tgt_stats", S_IRUSR,
878 priv->debug.debugfs_phy,
879 priv, &fops_tgt_stats);
880 if (!priv->debug.debugfs_tgt_stats)
881 goto err;
882
883
884 priv->debug.debugfs_xmit = debugfs_create_file("xmit", S_IRUSR,
885 priv->debug.debugfs_phy,
886 priv, &fops_xmit);
887 if (!priv->debug.debugfs_xmit)
888 goto err;
889
890 priv->debug.debugfs_recv = debugfs_create_file("recv", S_IRUSR,
891 priv->debug.debugfs_phy,
892 priv, &fops_recv);
893 if (!priv->debug.debugfs_recv)
894 goto err;
895
896 return 0;
897
898err:
899 ath9k_htc_exit_debug(ah);
900 return -ENOMEM;
901}
902
903void ath9k_htc_exit_debug(struct ath_hw *ah)
904{
905 struct ath_common *common = ath9k_hw_common(ah);
906 struct ath9k_htc_priv *priv = (struct ath9k_htc_priv *) common->priv;
907
908 debugfs_remove(priv->debug.debugfs_recv);
909 debugfs_remove(priv->debug.debugfs_xmit);
910 debugfs_remove(priv->debug.debugfs_tgt_stats);
911 debugfs_remove(priv->debug.debugfs_phy);
912}
913
914int ath9k_htc_debug_create_root(void)
915{
916 ath9k_debugfs_root = debugfs_create_dir(KBUILD_MODNAME, NULL);
917 if (!ath9k_debugfs_root)
918 return -ENOENT;
919
920 return 0;
921}
922
923void ath9k_htc_debug_remove_root(void)
924{
925 debugfs_remove(ath9k_debugfs_root);
926 ath9k_debugfs_root = NULL;
927}
928
929#endif /* CONFIG_ATH9K_HTC_DEBUGFS */
930
931/*******/ 719/*******/
932/* ANI */ 720/* ANI */
933/*******/ 721/*******/