blob: f42ed3b1733068bfe9e406ff8eddfb5909e78eda [file] [log] [blame]
Sujith88b126a2008-11-28 22:19:02 +05301/*
Sujith Manoharan5b681382011-05-17 13:36:18 +05302 * Copyright (c) 2008-2011 Atheros Communications Inc.
Sujith88b126a2008-11-28 22:19:02 +05303 *
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
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090017#include <linux/slab.h>
Vasanthakumar Thiagarajan582d0062011-03-01 05:30:55 -080018#include <linux/vmalloc.h>
Paul Gortmakeree40fa02011-05-27 16:14:23 -040019#include <linux/export.h>
Gabor Juhos52103112009-03-06 09:57:39 +010020#include <asm/unaligned.h>
21
Sujith394cf0a2009-02-09 13:26:54 +053022#include "ath9k.h"
Sujith88b126a2008-11-28 22:19:02 +053023
Luis R. Rodriguez475a6e42009-09-23 23:06:59 -040024#define REG_WRITE_D(_ah, _reg, _val) \
25 ath9k_hw_common(_ah)->ops->write((_ah), (_val), (_reg))
26#define REG_READ_D(_ah, _reg) \
27 ath9k_hw_common(_ah)->ops->read((_ah), (_reg))
28
Felix Fietkau6a4d05d2013-12-19 18:01:48 +010029void ath9k_debug_sync_cause(struct ath_softc *sc, u32 sync_cause)
30{
31 if (sync_cause)
32 sc->debug.stats.istats.sync_cause_all++;
33 if (sync_cause & AR_INTR_SYNC_RTC_IRQ)
34 sc->debug.stats.istats.sync_rtc_irq++;
35 if (sync_cause & AR_INTR_SYNC_MAC_IRQ)
36 sc->debug.stats.istats.sync_mac_irq++;
37 if (sync_cause & AR_INTR_SYNC_EEPROM_ILLEGAL_ACCESS)
38 sc->debug.stats.istats.eeprom_illegal_access++;
39 if (sync_cause & AR_INTR_SYNC_APB_TIMEOUT)
40 sc->debug.stats.istats.apb_timeout++;
41 if (sync_cause & AR_INTR_SYNC_PCI_MODE_CONFLICT)
42 sc->debug.stats.istats.pci_mode_conflict++;
43 if (sync_cause & AR_INTR_SYNC_HOST1_FATAL)
44 sc->debug.stats.istats.host1_fatal++;
45 if (sync_cause & AR_INTR_SYNC_HOST1_PERR)
46 sc->debug.stats.istats.host1_perr++;
47 if (sync_cause & AR_INTR_SYNC_TRCV_FIFO_PERR)
48 sc->debug.stats.istats.trcv_fifo_perr++;
49 if (sync_cause & AR_INTR_SYNC_RADM_CPL_EP)
50 sc->debug.stats.istats.radm_cpl_ep++;
51 if (sync_cause & AR_INTR_SYNC_RADM_CPL_DLLP_ABORT)
52 sc->debug.stats.istats.radm_cpl_dllp_abort++;
53 if (sync_cause & AR_INTR_SYNC_RADM_CPL_TLP_ABORT)
54 sc->debug.stats.istats.radm_cpl_tlp_abort++;
55 if (sync_cause & AR_INTR_SYNC_RADM_CPL_ECRC_ERR)
56 sc->debug.stats.istats.radm_cpl_ecrc_err++;
57 if (sync_cause & AR_INTR_SYNC_RADM_CPL_TIMEOUT)
58 sc->debug.stats.istats.radm_cpl_timeout++;
59 if (sync_cause & AR_INTR_SYNC_LOCAL_TIMEOUT)
60 sc->debug.stats.istats.local_timeout++;
61 if (sync_cause & AR_INTR_SYNC_PM_ACCESS)
62 sc->debug.stats.istats.pm_access++;
63 if (sync_cause & AR_INTR_SYNC_MAC_AWAKE)
64 sc->debug.stats.istats.mac_awake++;
65 if (sync_cause & AR_INTR_SYNC_MAC_ASLEEP)
66 sc->debug.stats.istats.mac_asleep++;
67 if (sync_cause & AR_INTR_SYNC_MAC_SLEEP_ACCESS)
68 sc->debug.stats.istats.mac_sleep_access++;
69}
Sujith2a163c62008-11-28 22:21:08 +053070
Vasanthakumar Thiagarajan582d0062011-03-01 05:30:55 -080071static ssize_t ath9k_debugfs_read_buf(struct file *file, char __user *user_buf,
72 size_t count, loff_t *ppos)
73{
74 u8 *buf = file->private_data;
75 return simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf));
76}
77
78static int ath9k_debugfs_release_buf(struct inode *inode, struct file *file)
79{
80 vfree(file->private_data);
81 return 0;
82}
83
Felix Fietkaua830df02009-11-23 22:33:27 +010084#ifdef CONFIG_ATH_DEBUG
85
Jeff Hansen24939282009-05-27 12:48:29 +000086static ssize_t read_file_debug(struct file *file, char __user *user_buf,
87 size_t count, loff_t *ppos)
88{
89 struct ath_softc *sc = file->private_data;
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -070090 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
Jeff Hansen24939282009-05-27 12:48:29 +000091 char buf[32];
Vasanthakumar Thiagarajan581f7252009-06-02 19:28:55 +053092 unsigned int len;
93
Dan Carpenter2b87f3a2010-05-14 15:24:37 +020094 len = sprintf(buf, "0x%08x\n", common->debug_mask);
Jeff Hansen24939282009-05-27 12:48:29 +000095 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
96}
97
98static ssize_t write_file_debug(struct file *file, const char __user *user_buf,
99 size_t count, loff_t *ppos)
100{
101 struct ath_softc *sc = file->private_data;
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -0700102 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
Jeff Hansen24939282009-05-27 12:48:29 +0000103 unsigned long mask;
104 char buf[32];
Vasanthakumar Thiagarajan581f7252009-06-02 19:28:55 +0530105 ssize_t len;
106
107 len = min(count, sizeof(buf) - 1);
108 if (copy_from_user(buf, user_buf, len))
Dan Carpenter04236062010-05-14 15:25:39 +0200109 return -EFAULT;
Vasanthakumar Thiagarajan581f7252009-06-02 19:28:55 +0530110
111 buf[len] = '\0';
Jingoo Han27d7f472013-05-31 21:24:06 +0000112 if (kstrtoul(buf, 0, &mask))
Vasanthakumar Thiagarajan581f7252009-06-02 19:28:55 +0530113 return -EINVAL;
114
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -0700115 common->debug_mask = mask;
Jeff Hansen24939282009-05-27 12:48:29 +0000116 return count;
117}
118
119static const struct file_operations fops_debug = {
120 .read = read_file_debug,
121 .write = write_file_debug,
Stephen Boyd234e3402012-04-05 14:25:11 -0700122 .open = simple_open,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200123 .owner = THIS_MODULE,
124 .llseek = default_llseek,
Jeff Hansen24939282009-05-27 12:48:29 +0000125};
126
Felix Fietkaua830df02009-11-23 22:33:27 +0100127#endif
128
Pavel Roskin991a0982010-01-29 17:22:26 -0500129#define DMA_BUF_LEN 1024
130
Felix Fietkau15340692010-05-11 17:23:01 +0200131
Sujith Manoharan6e4d2912013-06-03 09:19:28 +0530132static ssize_t read_file_ani(struct file *file, char __user *user_buf,
Mohammed Shafi Shajakhan05c0be22011-05-26 10:56:15 +0530133 size_t count, loff_t *ppos)
134{
135 struct ath_softc *sc = file->private_data;
136 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
Sujith Manoharan6e4d2912013-06-03 09:19:28 +0530137 struct ath_hw *ah = sc->sc_ah;
138 unsigned int len = 0, size = 1024;
139 ssize_t retval = 0;
140 char *buf;
Mohammed Shafi Shajakhan05c0be22011-05-26 10:56:15 +0530141
Sujith Manoharan6e4d2912013-06-03 09:19:28 +0530142 buf = kzalloc(size, GFP_KERNEL);
143 if (buf == NULL)
144 return -ENOMEM;
145
146 if (common->disable_ani) {
Zefir Kurtisi5e88ba62013-09-05 14:11:57 +0200147 len += scnprintf(buf + len, size - len, "%s: %s\n",
148 "ANI", "DISABLED");
Sujith Manoharan6e4d2912013-06-03 09:19:28 +0530149 goto exit;
150 }
151
Zefir Kurtisi5e88ba62013-09-05 14:11:57 +0200152 len += scnprintf(buf + len, size - len, "%15s: %s\n",
153 "ANI", "ENABLED");
154 len += scnprintf(buf + len, size - len, "%15s: %u\n",
155 "ANI RESET", ah->stats.ast_ani_reset);
156 len += scnprintf(buf + len, size - len, "%15s: %u\n",
157 "SPUR UP", ah->stats.ast_ani_spurup);
158 len += scnprintf(buf + len, size - len, "%15s: %u\n",
159 "SPUR DOWN", ah->stats.ast_ani_spurup);
160 len += scnprintf(buf + len, size - len, "%15s: %u\n",
161 "OFDM WS-DET ON", ah->stats.ast_ani_ofdmon);
162 len += scnprintf(buf + len, size - len, "%15s: %u\n",
163 "OFDM WS-DET OFF", ah->stats.ast_ani_ofdmoff);
164 len += scnprintf(buf + len, size - len, "%15s: %u\n",
165 "MRC-CCK ON", ah->stats.ast_ani_ccklow);
166 len += scnprintf(buf + len, size - len, "%15s: %u\n",
167 "MRC-CCK OFF", ah->stats.ast_ani_cckhigh);
168 len += scnprintf(buf + len, size - len, "%15s: %u\n",
169 "FIR-STEP UP", ah->stats.ast_ani_stepup);
170 len += scnprintf(buf + len, size - len, "%15s: %u\n",
171 "FIR-STEP DOWN", ah->stats.ast_ani_stepdown);
172 len += scnprintf(buf + len, size - len, "%15s: %u\n",
173 "INV LISTENTIME", ah->stats.ast_ani_lneg_or_lzero);
174 len += scnprintf(buf + len, size - len, "%15s: %u\n",
175 "OFDM ERRORS", ah->stats.ast_ani_ofdmerrs);
176 len += scnprintf(buf + len, size - len, "%15s: %u\n",
177 "CCK ERRORS", ah->stats.ast_ani_cckerrs);
Sujith Manoharan6e4d2912013-06-03 09:19:28 +0530178exit:
179 if (len > size)
180 len = size;
181
182 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
183 kfree(buf);
184
185 return retval;
Mohammed Shafi Shajakhan05c0be22011-05-26 10:56:15 +0530186}
187
Sujith Manoharan6e4d2912013-06-03 09:19:28 +0530188static ssize_t write_file_ani(struct file *file,
189 const char __user *user_buf,
190 size_t count, loff_t *ppos)
Mohammed Shafi Shajakhan05c0be22011-05-26 10:56:15 +0530191{
192 struct ath_softc *sc = file->private_data;
193 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
Sujith Manoharan6e4d2912013-06-03 09:19:28 +0530194 unsigned long ani;
Mohammed Shafi Shajakhan05c0be22011-05-26 10:56:15 +0530195 char buf[32];
196 ssize_t len;
197
198 len = min(count, sizeof(buf) - 1);
199 if (copy_from_user(buf, user_buf, len))
200 return -EFAULT;
201
202 buf[len] = '\0';
John W. Linville3899ba92013-06-11 14:48:32 -0400203 if (kstrtoul(buf, 0, &ani))
Mohammed Shafi Shajakhan05c0be22011-05-26 10:56:15 +0530204 return -EINVAL;
205
Sujith Manoharan6e4d2912013-06-03 09:19:28 +0530206 if (ani < 0 || ani > 1)
207 return -EINVAL;
Mohammed Shafi Shajakhan05c0be22011-05-26 10:56:15 +0530208
Sujith Manoharan6e4d2912013-06-03 09:19:28 +0530209 common->disable_ani = !ani;
210
211 if (common->disable_ani) {
Sujith Manoharan781b14a2012-06-04 20:23:55 +0530212 clear_bit(SC_OP_ANI_RUN, &sc->sc_flags);
Sujith Manoharanda0d45f2012-07-17 17:16:29 +0530213 ath_stop_ani(sc);
Mohammed Shafi Shajakhan05c0be22011-05-26 10:56:15 +0530214 } else {
Sujith Manoharanda0d45f2012-07-17 17:16:29 +0530215 ath_check_ani(sc);
Mohammed Shafi Shajakhan05c0be22011-05-26 10:56:15 +0530216 }
217
218 return count;
219}
220
Sujith Manoharan6e4d2912013-06-03 09:19:28 +0530221static const struct file_operations fops_ani = {
222 .read = read_file_ani,
223 .write = write_file_ani,
Stephen Boyd234e3402012-04-05 14:25:11 -0700224 .open = simple_open,
Mohammed Shafi Shajakhan05c0be22011-05-26 10:56:15 +0530225 .owner = THIS_MODULE,
226 .llseek = default_llseek,
227};
Felix Fietkau15340692010-05-11 17:23:01 +0200228
Sujith Manoharan36e88252013-08-06 12:44:15 +0530229#ifdef CONFIG_ATH9K_BTCOEX_SUPPORT
230
Sujith Manoharan63081302013-08-04 14:21:55 +0530231static ssize_t read_file_bt_ant_diversity(struct file *file,
232 char __user *user_buf,
233 size_t count, loff_t *ppos)
Sujith Manoharan302a3c32012-09-26 07:55:18 +0530234{
235 struct ath_softc *sc = file->private_data;
236 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
237 char buf[32];
238 unsigned int len;
239
Sujith Manoharan63081302013-08-04 14:21:55 +0530240 len = sprintf(buf, "%d\n", common->bt_ant_diversity);
Sujith Manoharan302a3c32012-09-26 07:55:18 +0530241 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
242}
243
Sujith Manoharan63081302013-08-04 14:21:55 +0530244static ssize_t write_file_bt_ant_diversity(struct file *file,
245 const char __user *user_buf,
246 size_t count, loff_t *ppos)
Sujith Manoharan302a3c32012-09-26 07:55:18 +0530247{
248 struct ath_softc *sc = file->private_data;
249 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
Sujith Manoharan3f2da952013-08-04 14:21:56 +0530250 struct ath9k_hw_capabilities *pCap = &sc->sc_ah->caps;
Sujith Manoharan63081302013-08-04 14:21:55 +0530251 unsigned long bt_ant_diversity;
Sujith Manoharan302a3c32012-09-26 07:55:18 +0530252 char buf[32];
253 ssize_t len;
254
255 len = min(count, sizeof(buf) - 1);
256 if (copy_from_user(buf, user_buf, len))
257 return -EFAULT;
258
Sujith Manoharan3f2da952013-08-04 14:21:56 +0530259 if (!(pCap->hw_caps & ATH9K_HW_CAP_BT_ANT_DIV))
260 goto exit;
261
Sujith Manoharan302a3c32012-09-26 07:55:18 +0530262 buf[len] = '\0';
Sujith Manoharan63081302013-08-04 14:21:55 +0530263 if (kstrtoul(buf, 0, &bt_ant_diversity))
Sujith Manoharan302a3c32012-09-26 07:55:18 +0530264 return -EINVAL;
265
Sujith Manoharan63081302013-08-04 14:21:55 +0530266 common->bt_ant_diversity = !!bt_ant_diversity;
Sujith Manoharan302a3c32012-09-26 07:55:18 +0530267 ath9k_ps_wakeup(sc);
Sujith Manoharan047dc3a2013-08-05 15:08:26 +0530268 ath9k_hw_set_bt_ant_diversity(sc->sc_ah, common->bt_ant_diversity);
Sujith Manoharan63081302013-08-04 14:21:55 +0530269 ath_dbg(common, CONFIG, "Enable WLAN/BT RX Antenna diversity: %d\n",
270 common->bt_ant_diversity);
Sujith Manoharan302a3c32012-09-26 07:55:18 +0530271 ath9k_ps_restore(sc);
Sujith Manoharan3f2da952013-08-04 14:21:56 +0530272exit:
Sujith Manoharan302a3c32012-09-26 07:55:18 +0530273 return count;
274}
275
Sujith Manoharan63081302013-08-04 14:21:55 +0530276static const struct file_operations fops_bt_ant_diversity = {
277 .read = read_file_bt_ant_diversity,
278 .write = write_file_bt_ant_diversity,
Sujith Manoharan302a3c32012-09-26 07:55:18 +0530279 .open = simple_open,
280 .owner = THIS_MODULE,
281 .llseek = default_llseek,
282};
283
Sujith Manoharan36e88252013-08-06 12:44:15 +0530284#endif
285
Sujith Manoharane3d52912013-08-01 20:57:06 +0530286void ath9k_debug_stat_ant(struct ath_softc *sc,
287 struct ath_hw_antcomb_conf *div_ant_conf,
288 int main_rssi_avg, int alt_rssi_avg)
289{
290 struct ath_antenna_stats *as_main = &sc->debug.stats.ant_stats[ANT_MAIN];
291 struct ath_antenna_stats *as_alt = &sc->debug.stats.ant_stats[ANT_ALT];
292
293 as_main->lna_attempt_cnt[div_ant_conf->main_lna_conf]++;
294 as_alt->lna_attempt_cnt[div_ant_conf->alt_lna_conf]++;
295
296 as_main->rssi_avg = main_rssi_avg;
297 as_alt->rssi_avg = alt_rssi_avg;
298}
299
Sujith Manoharan4eba10c2013-07-29 16:04:49 +0530300static ssize_t read_file_antenna_diversity(struct file *file,
301 char __user *user_buf,
302 size_t count, loff_t *ppos)
303{
304 struct ath_softc *sc = file->private_data;
305 struct ath_hw *ah = sc->sc_ah;
306 struct ath9k_hw_capabilities *pCap = &ah->caps;
307 struct ath_antenna_stats *as_main = &sc->debug.stats.ant_stats[ANT_MAIN];
308 struct ath_antenna_stats *as_alt = &sc->debug.stats.ant_stats[ANT_ALT];
Sujith Manoharane3d52912013-08-01 20:57:06 +0530309 struct ath_hw_antcomb_conf div_ant_conf;
Sujith Manoharan4eba10c2013-07-29 16:04:49 +0530310 unsigned int len = 0, size = 1024;
311 ssize_t retval = 0;
312 char *buf;
Sujith Manoharane3d52912013-08-01 20:57:06 +0530313 char *lna_conf_str[4] = {"LNA1_MINUS_LNA2",
314 "LNA2",
315 "LNA1",
316 "LNA1_PLUS_LNA2"};
Sujith Manoharan4eba10c2013-07-29 16:04:49 +0530317
318 buf = kzalloc(size, GFP_KERNEL);
319 if (buf == NULL)
320 return -ENOMEM;
321
322 if (!(pCap->hw_caps & ATH9K_HW_CAP_ANT_DIV_COMB)) {
Zefir Kurtisi5e88ba62013-09-05 14:11:57 +0200323 len += scnprintf(buf + len, size - len, "%s\n",
324 "Antenna Diversity Combining is disabled");
Sujith Manoharan4eba10c2013-07-29 16:04:49 +0530325 goto exit;
326 }
327
Sujith Manoharane3d52912013-08-01 20:57:06 +0530328 ath9k_ps_wakeup(sc);
329 ath9k_hw_antdiv_comb_conf_get(ah, &div_ant_conf);
Zefir Kurtisi5e88ba62013-09-05 14:11:57 +0200330 len += scnprintf(buf + len, size - len, "Current MAIN config : %s\n",
331 lna_conf_str[div_ant_conf.main_lna_conf]);
332 len += scnprintf(buf + len, size - len, "Current ALT config : %s\n",
333 lna_conf_str[div_ant_conf.alt_lna_conf]);
334 len += scnprintf(buf + len, size - len, "Average MAIN RSSI : %d\n",
335 as_main->rssi_avg);
336 len += scnprintf(buf + len, size - len, "Average ALT RSSI : %d\n\n",
337 as_alt->rssi_avg);
Sujith Manoharane3d52912013-08-01 20:57:06 +0530338 ath9k_ps_restore(sc);
339
Zefir Kurtisi5e88ba62013-09-05 14:11:57 +0200340 len += scnprintf(buf + len, size - len, "Packet Receive Cnt:\n");
341 len += scnprintf(buf + len, size - len, "-------------------\n");
Sujith Manoharane3d52912013-08-01 20:57:06 +0530342
Zefir Kurtisi5e88ba62013-09-05 14:11:57 +0200343 len += scnprintf(buf + len, size - len, "%30s%15s\n",
344 "MAIN", "ALT");
345 len += scnprintf(buf + len, size - len, "%-14s:%15d%15d\n",
346 "TOTAL COUNT",
347 as_main->recv_cnt,
348 as_alt->recv_cnt);
349 len += scnprintf(buf + len, size - len, "%-14s:%15d%15d\n",
350 "LNA1",
351 as_main->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1],
352 as_alt->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1]);
353 len += scnprintf(buf + len, size - len, "%-14s:%15d%15d\n",
354 "LNA2",
355 as_main->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA2],
356 as_alt->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA2]);
357 len += scnprintf(buf + len, size - len, "%-14s:%15d%15d\n",
358 "LNA1 + LNA2",
359 as_main->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2],
360 as_alt->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2]);
361 len += scnprintf(buf + len, size - len, "%-14s:%15d%15d\n",
362 "LNA1 - LNA2",
363 as_main->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2],
364 as_alt->lna_recv_cnt[ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2]);
Sujith Manoharane3d52912013-08-01 20:57:06 +0530365
Zefir Kurtisi5e88ba62013-09-05 14:11:57 +0200366 len += scnprintf(buf + len, size - len, "\nLNA Config Attempts:\n");
367 len += scnprintf(buf + len, size - len, "--------------------\n");
Sujith Manoharane3d52912013-08-01 20:57:06 +0530368
Zefir Kurtisi5e88ba62013-09-05 14:11:57 +0200369 len += scnprintf(buf + len, size - len, "%30s%15s\n",
370 "MAIN", "ALT");
371 len += scnprintf(buf + len, size - len, "%-14s:%15d%15d\n",
372 "LNA1",
373 as_main->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1],
374 as_alt->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1]);
375 len += scnprintf(buf + len, size - len, "%-14s:%15d%15d\n",
376 "LNA2",
377 as_main->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA2],
378 as_alt->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA2]);
379 len += scnprintf(buf + len, size - len, "%-14s:%15d%15d\n",
380 "LNA1 + LNA2",
381 as_main->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2],
382 as_alt->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2]);
383 len += scnprintf(buf + len, size - len, "%-14s:%15d%15d\n",
384 "LNA1 - LNA2",
385 as_main->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2],
386 as_alt->lna_attempt_cnt[ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2]);
Sujith Manoharane3d52912013-08-01 20:57:06 +0530387
Sujith Manoharan4eba10c2013-07-29 16:04:49 +0530388exit:
389 if (len > size)
390 len = size;
391
392 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
393 kfree(buf);
394
395 return retval;
396}
397
398static const struct file_operations fops_antenna_diversity = {
399 .read = read_file_antenna_diversity,
400 .open = simple_open,
401 .owner = THIS_MODULE,
402 .llseek = default_llseek,
403};
404
Sujith2a163c62008-11-28 22:21:08 +0530405static ssize_t read_file_dma(struct file *file, char __user *user_buf,
406 size_t count, loff_t *ppos)
407{
408 struct ath_softc *sc = file->private_data;
Sujithcbe61d82009-02-09 13:27:12 +0530409 struct ath_hw *ah = sc->sc_ah;
Pavel Roskin991a0982010-01-29 17:22:26 -0500410 char *buf;
411 int retval;
Sujith2a163c62008-11-28 22:21:08 +0530412 unsigned int len = 0;
413 u32 val[ATH9K_NUM_DMA_DEBUG_REGS];
414 int i, qcuOffset = 0, dcuOffset = 0;
415 u32 *qcuBase = &val[0], *dcuBase = &val[4];
416
Pavel Roskin991a0982010-01-29 17:22:26 -0500417 buf = kmalloc(DMA_BUF_LEN, GFP_KERNEL);
418 if (!buf)
Dan Carpenter04236062010-05-14 15:25:39 +0200419 return -ENOMEM;
Pavel Roskin991a0982010-01-29 17:22:26 -0500420
Sujith7cf4a2e2009-08-26 11:11:57 +0530421 ath9k_ps_wakeup(sc);
422
Luis R. Rodriguez475a6e42009-09-23 23:06:59 -0400423 REG_WRITE_D(ah, AR_MACMISC,
Sujith2a163c62008-11-28 22:21:08 +0530424 ((AR_MACMISC_DMA_OBS_LINE_8 << AR_MACMISC_DMA_OBS_S) |
425 (AR_MACMISC_MISC_OBS_BUS_1 <<
426 AR_MACMISC_MISC_OBS_BUS_MSB_S)));
427
Zefir Kurtisi5e88ba62013-09-05 14:11:57 +0200428 len += scnprintf(buf + len, DMA_BUF_LEN - len,
429 "Raw DMA Debug values:\n");
Sujith2a163c62008-11-28 22:21:08 +0530430
431 for (i = 0; i < ATH9K_NUM_DMA_DEBUG_REGS; i++) {
432 if (i % 4 == 0)
Zefir Kurtisi5e88ba62013-09-05 14:11:57 +0200433 len += scnprintf(buf + len, DMA_BUF_LEN - len, "\n");
Sujith2a163c62008-11-28 22:21:08 +0530434
Luis R. Rodriguez475a6e42009-09-23 23:06:59 -0400435 val[i] = REG_READ_D(ah, AR_DMADBG_0 + (i * sizeof(u32)));
Zefir Kurtisi5e88ba62013-09-05 14:11:57 +0200436 len += scnprintf(buf + len, DMA_BUF_LEN - len, "%d: %08x ",
437 i, val[i]);
Sujith2a163c62008-11-28 22:21:08 +0530438 }
439
Zefir Kurtisi5e88ba62013-09-05 14:11:57 +0200440 len += scnprintf(buf + len, DMA_BUF_LEN - len, "\n\n");
441 len += scnprintf(buf + len, DMA_BUF_LEN - len,
442 "Num QCU: chain_st fsp_ok fsp_st DCU: chain_st\n");
Sujith2a163c62008-11-28 22:21:08 +0530443
444 for (i = 0; i < ATH9K_NUM_QUEUES; i++, qcuOffset += 4, dcuOffset += 5) {
445 if (i == 8) {
446 qcuOffset = 0;
447 qcuBase++;
448 }
449
450 if (i == 6) {
451 dcuOffset = 0;
452 dcuBase++;
453 }
454
Zefir Kurtisi5e88ba62013-09-05 14:11:57 +0200455 len += scnprintf(buf + len, DMA_BUF_LEN - len,
456 "%2d %2x %1x %2x %2x\n",
457 i, (*qcuBase & (0x7 << qcuOffset)) >> qcuOffset,
458 (*qcuBase & (0x8 << qcuOffset)) >> (qcuOffset + 3),
459 val[2] & (0x7 << (i * 3)) >> (i * 3),
460 (*dcuBase & (0x1f << dcuOffset)) >> dcuOffset);
Sujith2a163c62008-11-28 22:21:08 +0530461 }
462
Zefir Kurtisi5e88ba62013-09-05 14:11:57 +0200463 len += scnprintf(buf + len, DMA_BUF_LEN - len, "\n");
Sujith2a163c62008-11-28 22:21:08 +0530464
Zefir Kurtisi5e88ba62013-09-05 14:11:57 +0200465 len += scnprintf(buf + len, DMA_BUF_LEN - len,
Sujith2a163c62008-11-28 22:21:08 +0530466 "qcu_stitch state: %2x qcu_fetch state: %2x\n",
467 (val[3] & 0x003c0000) >> 18, (val[3] & 0x03c00000) >> 22);
Zefir Kurtisi5e88ba62013-09-05 14:11:57 +0200468 len += scnprintf(buf + len, DMA_BUF_LEN - len,
Sujith2a163c62008-11-28 22:21:08 +0530469 "qcu_complete state: %2x dcu_complete state: %2x\n",
470 (val[3] & 0x1c000000) >> 26, (val[6] & 0x3));
Zefir Kurtisi5e88ba62013-09-05 14:11:57 +0200471 len += scnprintf(buf + len, DMA_BUF_LEN - len,
Sujith2a163c62008-11-28 22:21:08 +0530472 "dcu_arb state: %2x dcu_fp state: %2x\n",
473 (val[5] & 0x06000000) >> 25, (val[5] & 0x38000000) >> 27);
Zefir Kurtisi5e88ba62013-09-05 14:11:57 +0200474 len += scnprintf(buf + len, DMA_BUF_LEN - len,
Sujith2a163c62008-11-28 22:21:08 +0530475 "chan_idle_dur: %3d chan_idle_dur_valid: %1d\n",
476 (val[6] & 0x000003fc) >> 2, (val[6] & 0x00000400) >> 10);
Zefir Kurtisi5e88ba62013-09-05 14:11:57 +0200477 len += scnprintf(buf + len, DMA_BUF_LEN - len,
Sujith2a163c62008-11-28 22:21:08 +0530478 "txfifo_valid_0: %1d txfifo_valid_1: %1d\n",
479 (val[6] & 0x00000800) >> 11, (val[6] & 0x00001000) >> 12);
Zefir Kurtisi5e88ba62013-09-05 14:11:57 +0200480 len += scnprintf(buf + len, DMA_BUF_LEN - len,
Sujith2a163c62008-11-28 22:21:08 +0530481 "txfifo_dcu_num_0: %2d txfifo_dcu_num_1: %2d\n",
482 (val[6] & 0x0001e000) >> 13, (val[6] & 0x001e0000) >> 17);
483
Zefir Kurtisi5e88ba62013-09-05 14:11:57 +0200484 len += scnprintf(buf + len, DMA_BUF_LEN - len, "pcu observe: 0x%x\n",
485 REG_READ_D(ah, AR_OBS_BUS_1));
486 len += scnprintf(buf + len, DMA_BUF_LEN - len,
487 "AR_CR: 0x%x\n", REG_READ_D(ah, AR_CR));
Sujith2a163c62008-11-28 22:21:08 +0530488
Sujith7cf4a2e2009-08-26 11:11:57 +0530489 ath9k_ps_restore(sc);
490
Dan Carpenter2b87f3a2010-05-14 15:24:37 +0200491 if (len > DMA_BUF_LEN)
492 len = DMA_BUF_LEN;
493
Pavel Roskin991a0982010-01-29 17:22:26 -0500494 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
495 kfree(buf);
496 return retval;
Sujith2a163c62008-11-28 22:21:08 +0530497}
498
499static const struct file_operations fops_dma = {
500 .read = read_file_dma,
Stephen Boyd234e3402012-04-05 14:25:11 -0700501 .open = simple_open,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200502 .owner = THIS_MODULE,
503 .llseek = default_llseek,
Sujith2a163c62008-11-28 22:21:08 +0530504};
505
Sujith817e11d2008-12-07 21:42:44 +0530506
507void ath_debug_stat_interrupt(struct ath_softc *sc, enum ath9k_int status)
508{
509 if (status)
Sujith17d79042009-02-09 13:27:03 +0530510 sc->debug.stats.istats.total++;
Luis R. Rodrigueza9616f42010-04-15 17:39:30 -0400511 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) {
512 if (status & ATH9K_INT_RXLP)
513 sc->debug.stats.istats.rxlp++;
514 if (status & ATH9K_INT_RXHP)
515 sc->debug.stats.istats.rxhp++;
Luis R. Rodriguez08578b82010-05-13 13:33:44 -0400516 if (status & ATH9K_INT_BB_WATCHDOG)
517 sc->debug.stats.istats.bb_watchdog++;
Luis R. Rodrigueza9616f42010-04-15 17:39:30 -0400518 } else {
519 if (status & ATH9K_INT_RX)
520 sc->debug.stats.istats.rxok++;
521 }
Sujith817e11d2008-12-07 21:42:44 +0530522 if (status & ATH9K_INT_RXEOL)
Sujith17d79042009-02-09 13:27:03 +0530523 sc->debug.stats.istats.rxeol++;
Sujith817e11d2008-12-07 21:42:44 +0530524 if (status & ATH9K_INT_RXORN)
Sujith17d79042009-02-09 13:27:03 +0530525 sc->debug.stats.istats.rxorn++;
Sujith817e11d2008-12-07 21:42:44 +0530526 if (status & ATH9K_INT_TX)
Sujith17d79042009-02-09 13:27:03 +0530527 sc->debug.stats.istats.txok++;
Sujith817e11d2008-12-07 21:42:44 +0530528 if (status & ATH9K_INT_TXURN)
Sujith17d79042009-02-09 13:27:03 +0530529 sc->debug.stats.istats.txurn++;
Sujith817e11d2008-12-07 21:42:44 +0530530 if (status & ATH9K_INT_RXPHY)
Sujith17d79042009-02-09 13:27:03 +0530531 sc->debug.stats.istats.rxphyerr++;
Sujith817e11d2008-12-07 21:42:44 +0530532 if (status & ATH9K_INT_RXKCM)
Sujith17d79042009-02-09 13:27:03 +0530533 sc->debug.stats.istats.rx_keycache_miss++;
Sujith817e11d2008-12-07 21:42:44 +0530534 if (status & ATH9K_INT_SWBA)
Sujith17d79042009-02-09 13:27:03 +0530535 sc->debug.stats.istats.swba++;
Sujith817e11d2008-12-07 21:42:44 +0530536 if (status & ATH9K_INT_BMISS)
Sujith17d79042009-02-09 13:27:03 +0530537 sc->debug.stats.istats.bmiss++;
Sujith817e11d2008-12-07 21:42:44 +0530538 if (status & ATH9K_INT_BNR)
Sujith17d79042009-02-09 13:27:03 +0530539 sc->debug.stats.istats.bnr++;
Sujith817e11d2008-12-07 21:42:44 +0530540 if (status & ATH9K_INT_CST)
Sujith17d79042009-02-09 13:27:03 +0530541 sc->debug.stats.istats.cst++;
Sujith817e11d2008-12-07 21:42:44 +0530542 if (status & ATH9K_INT_GTT)
Sujith17d79042009-02-09 13:27:03 +0530543 sc->debug.stats.istats.gtt++;
Sujith817e11d2008-12-07 21:42:44 +0530544 if (status & ATH9K_INT_TIM)
Sujith17d79042009-02-09 13:27:03 +0530545 sc->debug.stats.istats.tim++;
Sujith817e11d2008-12-07 21:42:44 +0530546 if (status & ATH9K_INT_CABEND)
Sujith17d79042009-02-09 13:27:03 +0530547 sc->debug.stats.istats.cabend++;
Sujith817e11d2008-12-07 21:42:44 +0530548 if (status & ATH9K_INT_DTIMSYNC)
Sujith17d79042009-02-09 13:27:03 +0530549 sc->debug.stats.istats.dtimsync++;
Sujith817e11d2008-12-07 21:42:44 +0530550 if (status & ATH9K_INT_DTIM)
Sujith17d79042009-02-09 13:27:03 +0530551 sc->debug.stats.istats.dtim++;
Mohammed Shafi Shajakhan6dde1aa2011-04-22 17:27:01 +0530552 if (status & ATH9K_INT_TSFOOR)
553 sc->debug.stats.istats.tsfoor++;
Sujith Manoharan97ba5152012-06-04 16:27:41 +0530554 if (status & ATH9K_INT_MCI)
555 sc->debug.stats.istats.mci++;
Mohammed Shafi Shajakhanc9e6e982012-09-07 15:54:13 +0530556 if (status & ATH9K_INT_GENTIMER)
557 sc->debug.stats.istats.gen_timer++;
Sujith817e11d2008-12-07 21:42:44 +0530558}
559
560static ssize_t read_file_interrupt(struct file *file, char __user *user_buf,
561 size_t count, loff_t *ppos)
562{
563 struct ath_softc *sc = file->private_data;
Sujith817e11d2008-12-07 21:42:44 +0530564 unsigned int len = 0;
Ben Greear462e58f2012-04-12 10:04:00 -0700565 int rv;
566 int mxlen = 4000;
567 char *buf = kmalloc(mxlen, GFP_KERNEL);
568 if (!buf)
569 return -ENOMEM;
570
571#define PR_IS(a, s) \
572 do { \
Zefir Kurtisi5e88ba62013-09-05 14:11:57 +0200573 len += scnprintf(buf + len, mxlen - len, \
574 "%21s: %10u\n", a, \
575 sc->debug.stats.istats.s); \
Ben Greear462e58f2012-04-12 10:04:00 -0700576 } while (0)
Sujith817e11d2008-12-07 21:42:44 +0530577
Luis R. Rodrigueza9616f42010-04-15 17:39:30 -0400578 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) {
Ben Greear462e58f2012-04-12 10:04:00 -0700579 PR_IS("RXLP", rxlp);
580 PR_IS("RXHP", rxhp);
581 PR_IS("WATHDOG", bb_watchdog);
Luis R. Rodrigueza9616f42010-04-15 17:39:30 -0400582 } else {
Ben Greear462e58f2012-04-12 10:04:00 -0700583 PR_IS("RX", rxok);
Luis R. Rodrigueza9616f42010-04-15 17:39:30 -0400584 }
Ben Greear462e58f2012-04-12 10:04:00 -0700585 PR_IS("RXEOL", rxeol);
586 PR_IS("RXORN", rxorn);
587 PR_IS("TX", txok);
588 PR_IS("TXURN", txurn);
589 PR_IS("MIB", mib);
590 PR_IS("RXPHY", rxphyerr);
591 PR_IS("RXKCM", rx_keycache_miss);
592 PR_IS("SWBA", swba);
593 PR_IS("BMISS", bmiss);
594 PR_IS("BNR", bnr);
595 PR_IS("CST", cst);
596 PR_IS("GTT", gtt);
597 PR_IS("TIM", tim);
598 PR_IS("CABEND", cabend);
599 PR_IS("DTIMSYNC", dtimsync);
600 PR_IS("DTIM", dtim);
601 PR_IS("TSFOOR", tsfoor);
Sujith Manoharan97ba5152012-06-04 16:27:41 +0530602 PR_IS("MCI", mci);
Mohammed Shafi Shajakhanc9e6e982012-09-07 15:54:13 +0530603 PR_IS("GENTIMER", gen_timer);
Ben Greear462e58f2012-04-12 10:04:00 -0700604 PR_IS("TOTAL", total);
Sujith817e11d2008-12-07 21:42:44 +0530605
Zefir Kurtisi5e88ba62013-09-05 14:11:57 +0200606 len += scnprintf(buf + len, mxlen - len,
607 "SYNC_CAUSE stats:\n");
Mohammed Shafi Shajakhan6dde1aa2011-04-22 17:27:01 +0530608
Ben Greear462e58f2012-04-12 10:04:00 -0700609 PR_IS("Sync-All", sync_cause_all);
610 PR_IS("RTC-IRQ", sync_rtc_irq);
611 PR_IS("MAC-IRQ", sync_mac_irq);
612 PR_IS("EEPROM-Illegal-Access", eeprom_illegal_access);
613 PR_IS("APB-Timeout", apb_timeout);
614 PR_IS("PCI-Mode-Conflict", pci_mode_conflict);
615 PR_IS("HOST1-Fatal", host1_fatal);
616 PR_IS("HOST1-Perr", host1_perr);
617 PR_IS("TRCV-FIFO-Perr", trcv_fifo_perr);
618 PR_IS("RADM-CPL-EP", radm_cpl_ep);
619 PR_IS("RADM-CPL-DLLP-Abort", radm_cpl_dllp_abort);
620 PR_IS("RADM-CPL-TLP-Abort", radm_cpl_tlp_abort);
621 PR_IS("RADM-CPL-ECRC-Err", radm_cpl_ecrc_err);
622 PR_IS("RADM-CPL-Timeout", radm_cpl_timeout);
623 PR_IS("Local-Bus-Timeout", local_timeout);
624 PR_IS("PM-Access", pm_access);
625 PR_IS("MAC-Awake", mac_awake);
626 PR_IS("MAC-Asleep", mac_asleep);
627 PR_IS("MAC-Sleep-Access", mac_sleep_access);
Dan Carpenter2b87f3a2010-05-14 15:24:37 +0200628
Ben Greear462e58f2012-04-12 10:04:00 -0700629 if (len > mxlen)
630 len = mxlen;
631
632 rv = simple_read_from_buffer(user_buf, count, ppos, buf, len);
633 kfree(buf);
634 return rv;
Sujith817e11d2008-12-07 21:42:44 +0530635}
636
637static const struct file_operations fops_interrupt = {
638 .read = read_file_interrupt,
Stephen Boyd234e3402012-04-05 14:25:11 -0700639 .open = simple_open,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200640 .owner = THIS_MODULE,
641 .llseek = default_llseek,
Sujith817e11d2008-12-07 21:42:44 +0530642};
643
Sujithfec247c2009-07-27 12:08:16 +0530644static ssize_t read_file_xmit(struct file *file, char __user *user_buf,
645 size_t count, loff_t *ppos)
646{
647 struct ath_softc *sc = file->private_data;
648 char *buf;
Sujith Manoharan78ef7312012-11-21 18:13:11 +0530649 unsigned int len = 0, size = 2048;
Sujithfec247c2009-07-27 12:08:16 +0530650 ssize_t retval = 0;
651
652 buf = kzalloc(size, GFP_KERNEL);
653 if (buf == NULL)
Dan Carpenter04236062010-05-14 15:25:39 +0200654 return -ENOMEM;
Sujithfec247c2009-07-27 12:08:16 +0530655
Sujith Manoharan78ef7312012-11-21 18:13:11 +0530656 len += sprintf(buf, "%30s %10s%10s%10s\n\n",
Ben Greear7f010c92011-01-09 23:11:49 -0800657 "BE", "BK", "VI", "VO");
Sujithfec247c2009-07-27 12:08:16 +0530658
659 PR("MPDUs Queued: ", queued);
660 PR("MPDUs Completed: ", completed);
Felix Fietkau5a6f78a2011-05-31 21:21:41 +0200661 PR("MPDUs XRetried: ", xretries);
Sujithfec247c2009-07-27 12:08:16 +0530662 PR("Aggregates: ", a_aggr);
Ben Greearbda8add2011-01-09 23:11:48 -0800663 PR("AMPDUs Queued HW:", a_queued_hw);
664 PR("AMPDUs Queued SW:", a_queued_sw);
Sujithfec247c2009-07-27 12:08:16 +0530665 PR("AMPDUs Completed:", a_completed);
666 PR("AMPDUs Retried: ", a_retries);
667 PR("AMPDUs XRetried: ", a_xretries);
Ben Greear4d900382013-03-04 15:31:16 -0800668 PR("TXERR Filtered: ", txerr_filtered);
Sujithfec247c2009-07-27 12:08:16 +0530669 PR("FIFO Underrun: ", fifo_underrun);
670 PR("TXOP Exceeded: ", xtxop);
671 PR("TXTIMER Expiry: ", timer_exp);
672 PR("DESC CFG Error: ", desc_cfg_err);
673 PR("DATA Underrun: ", data_underrun);
674 PR("DELIM Underrun: ", delim_underrun);
Ben Greear99c15bf2010-10-01 12:26:30 -0700675 PR("TX-Pkts-All: ", tx_pkts_all);
676 PR("TX-Bytes-All: ", tx_bytes_all);
Sujith Manoharan78ef7312012-11-21 18:13:11 +0530677 PR("HW-put-tx-buf: ", puttxbuf);
678 PR("HW-tx-start: ", txstart);
679 PR("HW-tx-proc-desc: ", txprocdesc);
Ben Greeara5a0bca2012-04-03 09:16:55 -0700680 PR("TX-Failed: ", txfailed);
Sujithfec247c2009-07-27 12:08:16 +0530681
Ben Greear7f010c92011-01-09 23:11:49 -0800682 if (len > size)
683 len = size;
684
685 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
686 kfree(buf);
687
688 return retval;
689}
690
Felix Fietkau18fcf1c2013-08-06 14:18:05 +0200691static ssize_t print_queue(struct ath_softc *sc, struct ath_txq *txq,
692 char *buf, ssize_t size)
693{
694 ssize_t len = 0;
695
696 ath_txq_lock(sc, txq);
697
Zefir Kurtisi5e88ba62013-09-05 14:11:57 +0200698 len += scnprintf(buf + len, size - len, "%s: %d ",
699 "qnum", txq->axq_qnum);
700 len += scnprintf(buf + len, size - len, "%s: %2d ",
701 "qdepth", txq->axq_depth);
702 len += scnprintf(buf + len, size - len, "%s: %2d ",
703 "ampdu-depth", txq->axq_ampdu_depth);
704 len += scnprintf(buf + len, size - len, "%s: %3d ",
705 "pending", txq->pending_frames);
706 len += scnprintf(buf + len, size - len, "%s: %d\n",
707 "stopped", txq->stopped);
Felix Fietkau18fcf1c2013-08-06 14:18:05 +0200708
709 ath_txq_unlock(sc, txq);
710 return len;
711}
712
Sujith Manoharanc0b74872012-11-21 18:13:12 +0530713static ssize_t read_file_queues(struct file *file, char __user *user_buf,
714 size_t count, loff_t *ppos)
715{
716 struct ath_softc *sc = file->private_data;
717 struct ath_txq *txq;
718 char *buf;
719 unsigned int len = 0, size = 1024;
720 ssize_t retval = 0;
721 int i;
722 char *qname[4] = {"VO", "VI", "BE", "BK"};
723
724 buf = kzalloc(size, GFP_KERNEL);
725 if (buf == NULL)
726 return -ENOMEM;
727
728 for (i = 0; i < IEEE80211_NUM_ACS; i++) {
729 txq = sc->tx.txq_map[i];
Zefir Kurtisi5e88ba62013-09-05 14:11:57 +0200730 len += scnprintf(buf + len, size - len, "(%s): ", qname[i]);
Felix Fietkau18fcf1c2013-08-06 14:18:05 +0200731 len += print_queue(sc, txq, buf + len, size - len);
Sujith Manoharanc0b74872012-11-21 18:13:12 +0530732 }
733
Zefir Kurtisi5e88ba62013-09-05 14:11:57 +0200734 len += scnprintf(buf + len, size - len, "(CAB): ");
Felix Fietkau18fcf1c2013-08-06 14:18:05 +0200735 len += print_queue(sc, sc->beacon.cabq, buf + len, size - len);
736
Sujith Manoharanc0b74872012-11-21 18:13:12 +0530737 if (len > size)
738 len = size;
739
740 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
741 kfree(buf);
742
743 return retval;
744}
745
Ben Greear55f6d0f2011-01-17 11:54:50 -0800746static ssize_t read_file_misc(struct file *file, char __user *user_buf,
747 size_t count, loff_t *ppos)
748{
749 struct ath_softc *sc = file->private_data;
750 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
Ben Greear55f6d0f2011-01-17 11:54:50 -0800751 struct ieee80211_hw *hw = sc->hw;
Sujith Manoharan6bcf6f62012-02-16 11:51:02 +0530752 struct ath9k_vif_iter_data iter_data;
753 char buf[512];
754 unsigned int len = 0;
Ben Greear55f6d0f2011-01-17 11:54:50 -0800755 ssize_t retval = 0;
Ben Greear55f6d0f2011-01-17 11:54:50 -0800756 unsigned int reg;
Sujith Manoharan6bcf6f62012-02-16 11:51:02 +0530757 u32 rxfilter;
Ben Greear55f6d0f2011-01-17 11:54:50 -0800758
Zefir Kurtisi5e88ba62013-09-05 14:11:57 +0200759 len += scnprintf(buf + len, sizeof(buf) - len,
760 "BSSID: %pM\n", common->curbssid);
761 len += scnprintf(buf + len, sizeof(buf) - len,
762 "BSSID-MASK: %pM\n", common->bssidmask);
763 len += scnprintf(buf + len, sizeof(buf) - len,
764 "OPMODE: %s\n",
765 ath_opmode_to_string(sc->sc_ah->opmode));
Ben Greear55f6d0f2011-01-17 11:54:50 -0800766
Rajkumar Manoharan79d2b152011-05-16 18:23:23 +0530767 ath9k_ps_wakeup(sc);
Sujith Manoharan6bcf6f62012-02-16 11:51:02 +0530768 rxfilter = ath9k_hw_getrxfilter(sc->sc_ah);
Rajkumar Manoharan79d2b152011-05-16 18:23:23 +0530769 ath9k_ps_restore(sc);
Sujith Manoharan6bcf6f62012-02-16 11:51:02 +0530770
Zefir Kurtisi5e88ba62013-09-05 14:11:57 +0200771 len += scnprintf(buf + len, sizeof(buf) - len,
772 "RXFILTER: 0x%x", rxfilter);
Sujith Manoharan6bcf6f62012-02-16 11:51:02 +0530773
774 if (rxfilter & ATH9K_RX_FILTER_UCAST)
Zefir Kurtisi5e88ba62013-09-05 14:11:57 +0200775 len += scnprintf(buf + len, sizeof(buf) - len, " UCAST");
Sujith Manoharan6bcf6f62012-02-16 11:51:02 +0530776 if (rxfilter & ATH9K_RX_FILTER_MCAST)
Zefir Kurtisi5e88ba62013-09-05 14:11:57 +0200777 len += scnprintf(buf + len, sizeof(buf) - len, " MCAST");
Sujith Manoharan6bcf6f62012-02-16 11:51:02 +0530778 if (rxfilter & ATH9K_RX_FILTER_BCAST)
Zefir Kurtisi5e88ba62013-09-05 14:11:57 +0200779 len += scnprintf(buf + len, sizeof(buf) - len, " BCAST");
Sujith Manoharan6bcf6f62012-02-16 11:51:02 +0530780 if (rxfilter & ATH9K_RX_FILTER_CONTROL)
Zefir Kurtisi5e88ba62013-09-05 14:11:57 +0200781 len += scnprintf(buf + len, sizeof(buf) - len, " CONTROL");
Sujith Manoharan6bcf6f62012-02-16 11:51:02 +0530782 if (rxfilter & ATH9K_RX_FILTER_BEACON)
Zefir Kurtisi5e88ba62013-09-05 14:11:57 +0200783 len += scnprintf(buf + len, sizeof(buf) - len, " BEACON");
Sujith Manoharan6bcf6f62012-02-16 11:51:02 +0530784 if (rxfilter & ATH9K_RX_FILTER_PROM)
Zefir Kurtisi5e88ba62013-09-05 14:11:57 +0200785 len += scnprintf(buf + len, sizeof(buf) - len, " PROM");
Sujith Manoharan6bcf6f62012-02-16 11:51:02 +0530786 if (rxfilter & ATH9K_RX_FILTER_PROBEREQ)
Zefir Kurtisi5e88ba62013-09-05 14:11:57 +0200787 len += scnprintf(buf + len, sizeof(buf) - len, " PROBEREQ");
Sujith Manoharan6bcf6f62012-02-16 11:51:02 +0530788 if (rxfilter & ATH9K_RX_FILTER_PHYERR)
Zefir Kurtisi5e88ba62013-09-05 14:11:57 +0200789 len += scnprintf(buf + len, sizeof(buf) - len, " PHYERR");
Sujith Manoharan6bcf6f62012-02-16 11:51:02 +0530790 if (rxfilter & ATH9K_RX_FILTER_MYBEACON)
Zefir Kurtisi5e88ba62013-09-05 14:11:57 +0200791 len += scnprintf(buf + len, sizeof(buf) - len, " MYBEACON");
Sujith Manoharan6bcf6f62012-02-16 11:51:02 +0530792 if (rxfilter & ATH9K_RX_FILTER_COMP_BAR)
Zefir Kurtisi5e88ba62013-09-05 14:11:57 +0200793 len += scnprintf(buf + len, sizeof(buf) - len, " COMP_BAR");
Sujith Manoharan6bcf6f62012-02-16 11:51:02 +0530794 if (rxfilter & ATH9K_RX_FILTER_PSPOLL)
Zefir Kurtisi5e88ba62013-09-05 14:11:57 +0200795 len += scnprintf(buf + len, sizeof(buf) - len, " PSPOLL");
Sujith Manoharan6bcf6f62012-02-16 11:51:02 +0530796 if (rxfilter & ATH9K_RX_FILTER_PHYRADAR)
Zefir Kurtisi5e88ba62013-09-05 14:11:57 +0200797 len += scnprintf(buf + len, sizeof(buf) - len, " PHYRADAR");
Sujith Manoharan6bcf6f62012-02-16 11:51:02 +0530798 if (rxfilter & ATH9K_RX_FILTER_MCAST_BCAST_ALL)
Zefir Kurtisi5e88ba62013-09-05 14:11:57 +0200799 len += scnprintf(buf + len, sizeof(buf) - len, " MCAST_BCAST_ALL");
Sujith Manoharan6bcf6f62012-02-16 11:51:02 +0530800 if (rxfilter & ATH9K_RX_FILTER_CONTROL_WRAPPER)
Zefir Kurtisi5e88ba62013-09-05 14:11:57 +0200801 len += scnprintf(buf + len, sizeof(buf) - len, " CONTROL_WRAPPER");
Sujith Manoharan6bcf6f62012-02-16 11:51:02 +0530802
Zefir Kurtisi5e88ba62013-09-05 14:11:57 +0200803 len += scnprintf(buf + len, sizeof(buf) - len, "\n");
Ben Greear55f6d0f2011-01-17 11:54:50 -0800804
805 reg = sc->sc_ah->imask;
Ben Greear55f6d0f2011-01-17 11:54:50 -0800806
Zefir Kurtisi5e88ba62013-09-05 14:11:57 +0200807 len += scnprintf(buf + len, sizeof(buf) - len,
808 "INTERRUPT-MASK: 0x%x", reg);
Sujith Manoharan6bcf6f62012-02-16 11:51:02 +0530809
810 if (reg & ATH9K_INT_SWBA)
Zefir Kurtisi5e88ba62013-09-05 14:11:57 +0200811 len += scnprintf(buf + len, sizeof(buf) - len, " SWBA");
Sujith Manoharan6bcf6f62012-02-16 11:51:02 +0530812 if (reg & ATH9K_INT_BMISS)
Zefir Kurtisi5e88ba62013-09-05 14:11:57 +0200813 len += scnprintf(buf + len, sizeof(buf) - len, " BMISS");
Sujith Manoharan6bcf6f62012-02-16 11:51:02 +0530814 if (reg & ATH9K_INT_CST)
Zefir Kurtisi5e88ba62013-09-05 14:11:57 +0200815 len += scnprintf(buf + len, sizeof(buf) - len, " CST");
Sujith Manoharan6bcf6f62012-02-16 11:51:02 +0530816 if (reg & ATH9K_INT_RX)
Zefir Kurtisi5e88ba62013-09-05 14:11:57 +0200817 len += scnprintf(buf + len, sizeof(buf) - len, " RX");
Sujith Manoharan6bcf6f62012-02-16 11:51:02 +0530818 if (reg & ATH9K_INT_RXHP)
Zefir Kurtisi5e88ba62013-09-05 14:11:57 +0200819 len += scnprintf(buf + len, sizeof(buf) - len, " RXHP");
Sujith Manoharan6bcf6f62012-02-16 11:51:02 +0530820 if (reg & ATH9K_INT_RXLP)
Zefir Kurtisi5e88ba62013-09-05 14:11:57 +0200821 len += scnprintf(buf + len, sizeof(buf) - len, " RXLP");
Sujith Manoharan6bcf6f62012-02-16 11:51:02 +0530822 if (reg & ATH9K_INT_BB_WATCHDOG)
Zefir Kurtisi5e88ba62013-09-05 14:11:57 +0200823 len += scnprintf(buf + len, sizeof(buf) - len, " BB_WATCHDOG");
Sujith Manoharan6bcf6f62012-02-16 11:51:02 +0530824
Zefir Kurtisi5e88ba62013-09-05 14:11:57 +0200825 len += scnprintf(buf + len, sizeof(buf) - len, "\n");
Sujith Manoharan6bcf6f62012-02-16 11:51:02 +0530826
827 ath9k_calculate_iter_data(hw, NULL, &iter_data);
828
Zefir Kurtisi5e88ba62013-09-05 14:11:57 +0200829 len += scnprintf(buf + len, sizeof(buf) - len,
830 "VIF-COUNTS: AP: %i STA: %i MESH: %i WDS: %i"
831 " ADHOC: %i TOTAL: %hi BEACON-VIF: %hi\n",
832 iter_data.naps, iter_data.nstations, iter_data.nmeshes,
833 iter_data.nwds, iter_data.nadhocs,
834 sc->nvifs, sc->nbcnvifs);
Ben Greear55f6d0f2011-01-17 11:54:50 -0800835
Sujith Manoharan6bcf6f62012-02-16 11:51:02 +0530836 if (len > sizeof(buf))
837 len = sizeof(buf);
Ben Greear55f6d0f2011-01-17 11:54:50 -0800838
839 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
Ben Greear55f6d0f2011-01-17 11:54:50 -0800840 return retval;
841}
842
Sujith Manoharanf8b815d2012-02-16 11:51:11 +0530843static ssize_t read_file_reset(struct file *file, char __user *user_buf,
844 size_t count, loff_t *ppos)
845{
846 struct ath_softc *sc = file->private_data;
847 char buf[512];
848 unsigned int len = 0;
849
Zefir Kurtisi5e88ba62013-09-05 14:11:57 +0200850 len += scnprintf(buf + len, sizeof(buf) - len,
851 "%17s: %2d\n", "Baseband Hang",
852 sc->debug.stats.reset[RESET_TYPE_BB_HANG]);
853 len += scnprintf(buf + len, sizeof(buf) - len,
854 "%17s: %2d\n", "Baseband Watchdog",
855 sc->debug.stats.reset[RESET_TYPE_BB_WATCHDOG]);
856 len += scnprintf(buf + len, sizeof(buf) - len,
857 "%17s: %2d\n", "Fatal HW Error",
858 sc->debug.stats.reset[RESET_TYPE_FATAL_INT]);
859 len += scnprintf(buf + len, sizeof(buf) - len,
860 "%17s: %2d\n", "TX HW error",
861 sc->debug.stats.reset[RESET_TYPE_TX_ERROR]);
862 len += scnprintf(buf + len, sizeof(buf) - len,
863 "%17s: %2d\n", "TX Path Hang",
864 sc->debug.stats.reset[RESET_TYPE_TX_HANG]);
865 len += scnprintf(buf + len, sizeof(buf) - len,
866 "%17s: %2d\n", "PLL RX Hang",
867 sc->debug.stats.reset[RESET_TYPE_PLL_HANG]);
868 len += scnprintf(buf + len, sizeof(buf) - len,
Felix Fietkau443626e52014-02-21 11:45:36 +0100869 "%17s: %2d\n", "MAC Hang",
870 sc->debug.stats.reset[RESET_TYPE_MAC_HANG]);
871 len += scnprintf(buf + len, sizeof(buf) - len,
872 "%17s: %2d\n", "Stuck Beacon",
873 sc->debug.stats.reset[RESET_TYPE_BEACON_STUCK]);
874 len += scnprintf(buf + len, sizeof(buf) - len,
Zefir Kurtisi5e88ba62013-09-05 14:11:57 +0200875 "%17s: %2d\n", "MCI Reset",
876 sc->debug.stats.reset[RESET_TYPE_MCI]);
Sujith Manoharanf8b815d2012-02-16 11:51:11 +0530877
878 if (len > sizeof(buf))
879 len = sizeof(buf);
880
881 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
882}
883
Felix Fietkau066dae92010-11-07 14:59:39 +0100884void ath_debug_stat_tx(struct ath_softc *sc, struct ath_buf *bf,
Felix Fietkau55797b12011-09-14 21:24:16 +0200885 struct ath_tx_status *ts, struct ath_txq *txq,
886 unsigned int flags)
Sujithfec247c2009-07-27 12:08:16 +0530887{
Felix Fietkau5bec3e52011-01-24 21:29:25 +0100888 int qnum = txq->axq_qnum;
Felix Fietkau066dae92010-11-07 14:59:39 +0100889
890 TX_STAT_INC(qnum, tx_pkts_all);
891 sc->debug.stats.txstats[qnum].tx_bytes_all += bf->bf_mpdu->len;
Ben Greear99c15bf2010-10-01 12:26:30 -0700892
Sujithfec247c2009-07-27 12:08:16 +0530893 if (bf_isampdu(bf)) {
Felix Fietkau156369f2011-12-14 22:08:04 +0100894 if (flags & ATH_TX_ERROR)
Felix Fietkau066dae92010-11-07 14:59:39 +0100895 TX_STAT_INC(qnum, a_xretries);
Sujithfec247c2009-07-27 12:08:16 +0530896 else
Felix Fietkau066dae92010-11-07 14:59:39 +0100897 TX_STAT_INC(qnum, a_completed);
Sujithfec247c2009-07-27 12:08:16 +0530898 } else {
Felix Fietkau55797b12011-09-14 21:24:16 +0200899 if (ts->ts_status & ATH9K_TXERR_XRETRY)
Felix Fietkau5a6f78a2011-05-31 21:21:41 +0200900 TX_STAT_INC(qnum, xretries);
901 else
902 TX_STAT_INC(qnum, completed);
Sujithfec247c2009-07-27 12:08:16 +0530903 }
904
Ben Greear4d900382013-03-04 15:31:16 -0800905 if (ts->ts_status & ATH9K_TXERR_FILT)
906 TX_STAT_INC(qnum, txerr_filtered);
Felix Fietkaudb1a0522010-03-29 20:07:11 -0700907 if (ts->ts_status & ATH9K_TXERR_FIFO)
Felix Fietkau066dae92010-11-07 14:59:39 +0100908 TX_STAT_INC(qnum, fifo_underrun);
Felix Fietkaudb1a0522010-03-29 20:07:11 -0700909 if (ts->ts_status & ATH9K_TXERR_XTXOP)
Felix Fietkau066dae92010-11-07 14:59:39 +0100910 TX_STAT_INC(qnum, xtxop);
Felix Fietkaudb1a0522010-03-29 20:07:11 -0700911 if (ts->ts_status & ATH9K_TXERR_TIMER_EXPIRED)
Felix Fietkau066dae92010-11-07 14:59:39 +0100912 TX_STAT_INC(qnum, timer_exp);
Felix Fietkaudb1a0522010-03-29 20:07:11 -0700913 if (ts->ts_flags & ATH9K_TX_DESC_CFG_ERR)
Felix Fietkau066dae92010-11-07 14:59:39 +0100914 TX_STAT_INC(qnum, desc_cfg_err);
Felix Fietkaudb1a0522010-03-29 20:07:11 -0700915 if (ts->ts_flags & ATH9K_TX_DATA_UNDERRUN)
Felix Fietkau066dae92010-11-07 14:59:39 +0100916 TX_STAT_INC(qnum, data_underrun);
Felix Fietkaudb1a0522010-03-29 20:07:11 -0700917 if (ts->ts_flags & ATH9K_TX_DELIM_UNDERRUN)
Felix Fietkau066dae92010-11-07 14:59:39 +0100918 TX_STAT_INC(qnum, delim_underrun);
Sujithfec247c2009-07-27 12:08:16 +0530919}
920
921static const struct file_operations fops_xmit = {
922 .read = read_file_xmit,
Stephen Boyd234e3402012-04-05 14:25:11 -0700923 .open = simple_open,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200924 .owner = THIS_MODULE,
925 .llseek = default_llseek,
Sujithfec247c2009-07-27 12:08:16 +0530926};
Jouni Malinen39d89cd2009-03-03 19:23:40 +0200927
Sujith Manoharanc0b74872012-11-21 18:13:12 +0530928static const struct file_operations fops_queues = {
929 .read = read_file_queues,
930 .open = simple_open,
931 .owner = THIS_MODULE,
932 .llseek = default_llseek,
933};
934
Ben Greear55f6d0f2011-01-17 11:54:50 -0800935static const struct file_operations fops_misc = {
936 .read = read_file_misc,
Stephen Boyd234e3402012-04-05 14:25:11 -0700937 .open = simple_open,
Ben Greear55f6d0f2011-01-17 11:54:50 -0800938 .owner = THIS_MODULE,
939 .llseek = default_llseek,
940};
941
Sujith Manoharanf8b815d2012-02-16 11:51:11 +0530942static const struct file_operations fops_reset = {
943 .read = read_file_reset,
Stephen Boyd234e3402012-04-05 14:25:11 -0700944 .open = simple_open,
Sujith Manoharanf8b815d2012-02-16 11:51:11 +0530945 .owner = THIS_MODULE,
946 .llseek = default_llseek,
947};
948
Sujith1395d3f2010-01-08 10:36:11 +0530949static ssize_t read_file_recv(struct file *file, char __user *user_buf,
950 size_t count, loff_t *ppos)
951{
Ben Greear24a07312012-04-12 10:03:59 -0700952#define RXS_ERR(s, e) \
953 do { \
Zefir Kurtisi5e88ba62013-09-05 14:11:57 +0200954 len += scnprintf(buf + len, size - len, \
Sujith Manoharanc3b9f9e2014-01-13 07:29:29 +0530955 "%18s : %10u\n", s, \
Zefir Kurtisi5e88ba62013-09-05 14:11:57 +0200956 sc->debug.stats.rxstats.e);\
Ben Greear24a07312012-04-12 10:03:59 -0700957 } while (0)
958
Sujith1395d3f2010-01-08 10:36:11 +0530959 struct ath_softc *sc = file->private_data;
960 char *buf;
Sujith Manoharan42032142012-02-16 11:51:23 +0530961 unsigned int len = 0, size = 1600;
Sujith1395d3f2010-01-08 10:36:11 +0530962 ssize_t retval = 0;
963
964 buf = kzalloc(size, GFP_KERNEL);
965 if (buf == NULL)
Dan Carpenter04236062010-05-14 15:25:39 +0200966 return -ENOMEM;
Sujith1395d3f2010-01-08 10:36:11 +0530967
Sujith Manoharanc3b9f9e2014-01-13 07:29:29 +0530968 RXS_ERR("PKTS-ALL", rx_pkts_all);
969 RXS_ERR("BYTES-ALL", rx_bytes_all);
970 RXS_ERR("BEACONS", rx_beacons);
971 RXS_ERR("FRAGS", rx_frags);
972 RXS_ERR("SPECTRAL", rx_spectral);
973
Ben Greear24a07312012-04-12 10:03:59 -0700974 RXS_ERR("CRC ERR", crc_err);
975 RXS_ERR("DECRYPT CRC ERR", decrypt_crc_err);
976 RXS_ERR("PHY ERR", phy_err);
977 RXS_ERR("MIC ERR", mic_err);
978 RXS_ERR("PRE-DELIM CRC ERR", pre_delim_crc_err);
979 RXS_ERR("POST-DELIM CRC ERR", post_delim_crc_err);
980 RXS_ERR("DECRYPT BUSY ERR", decrypt_busy_err);
Sujith Manoharanc3b9f9e2014-01-13 07:29:29 +0530981 RXS_ERR("LENGTH-ERR", rx_len_err);
982 RXS_ERR("OOM-ERR", rx_oom_err);
983 RXS_ERR("RATE-ERR", rx_rate_err);
984 RXS_ERR("TOO-MANY-FRAGS", rx_too_many_frags_err);
Ben Greear99c15bf2010-10-01 12:26:30 -0700985
Dan Carpenter2b87f3a2010-05-14 15:24:37 +0200986 if (len > size)
987 len = size;
988
Sujith1395d3f2010-01-08 10:36:11 +0530989 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
990 kfree(buf);
991
992 return retval;
993
Ben Greear24a07312012-04-12 10:03:59 -0700994#undef RXS_ERR
Sujith1395d3f2010-01-08 10:36:11 +0530995}
996
Felix Fietkau8e6f5aa2010-03-29 20:09:27 -0700997void ath_debug_stat_rx(struct ath_softc *sc, struct ath_rx_status *rs)
Sujith1395d3f2010-01-08 10:36:11 +0530998{
Sujith1395d3f2010-01-08 10:36:11 +0530999#define RX_PHY_ERR_INC(c) sc->debug.stats.rxstats.phy_err_stats[c]++
1000
Ben Greear99c15bf2010-10-01 12:26:30 -07001001 RX_STAT_INC(rx_pkts_all);
1002 sc->debug.stats.rxstats.rx_bytes_all += rs->rs_datalen;
1003
Felix Fietkau8e6f5aa2010-03-29 20:09:27 -07001004 if (rs->rs_status & ATH9K_RXERR_CRC)
Sujith1395d3f2010-01-08 10:36:11 +05301005 RX_STAT_INC(crc_err);
Felix Fietkau8e6f5aa2010-03-29 20:09:27 -07001006 if (rs->rs_status & ATH9K_RXERR_DECRYPT)
Sujith1395d3f2010-01-08 10:36:11 +05301007 RX_STAT_INC(decrypt_crc_err);
Felix Fietkau8e6f5aa2010-03-29 20:09:27 -07001008 if (rs->rs_status & ATH9K_RXERR_MIC)
Sujith1395d3f2010-01-08 10:36:11 +05301009 RX_STAT_INC(mic_err);
Felix Fietkau8e6f5aa2010-03-29 20:09:27 -07001010 if (rs->rs_status & ATH9K_RX_DELIM_CRC_PRE)
Sujith1395d3f2010-01-08 10:36:11 +05301011 RX_STAT_INC(pre_delim_crc_err);
Felix Fietkau8e6f5aa2010-03-29 20:09:27 -07001012 if (rs->rs_status & ATH9K_RX_DELIM_CRC_POST)
Sujith1395d3f2010-01-08 10:36:11 +05301013 RX_STAT_INC(post_delim_crc_err);
Felix Fietkau8e6f5aa2010-03-29 20:09:27 -07001014 if (rs->rs_status & ATH9K_RX_DECRYPT_BUSY)
Sujith1395d3f2010-01-08 10:36:11 +05301015 RX_STAT_INC(decrypt_busy_err);
1016
Felix Fietkau8e6f5aa2010-03-29 20:09:27 -07001017 if (rs->rs_status & ATH9K_RXERR_PHY) {
Sujith1395d3f2010-01-08 10:36:11 +05301018 RX_STAT_INC(phy_err);
Sujith Manoharandbb07f02012-02-16 11:52:25 +05301019 if (rs->rs_phyerr < ATH9K_PHYERR_MAX)
1020 RX_PHY_ERR_INC(rs->rs_phyerr);
Sujith1395d3f2010-01-08 10:36:11 +05301021 }
1022
Sujith1395d3f2010-01-08 10:36:11 +05301023#undef RX_PHY_ERR_INC
1024}
1025
1026static const struct file_operations fops_recv = {
1027 .read = read_file_recv,
Stephen Boyd234e3402012-04-05 14:25:11 -07001028 .open = simple_open,
Arnd Bergmann6038f372010-08-15 18:52:59 +02001029 .owner = THIS_MODULE,
1030 .llseek = default_llseek,
Sujith1395d3f2010-01-08 10:36:11 +05301031};
1032
Sujith Manoharanc3b9f9e2014-01-13 07:29:29 +05301033static ssize_t read_file_phy_err(struct file *file, char __user *user_buf,
1034 size_t count, loff_t *ppos)
1035{
1036#define PHY_ERR(s, p) \
1037 len += scnprintf(buf + len, size - len, "%22s : %10u\n", s, \
1038 sc->debug.stats.rxstats.phy_err_stats[p]);
1039
1040 struct ath_softc *sc = file->private_data;
1041 char *buf;
1042 unsigned int len = 0, size = 1600;
1043 ssize_t retval = 0;
1044
1045 buf = kzalloc(size, GFP_KERNEL);
1046 if (buf == NULL)
1047 return -ENOMEM;
1048
1049 PHY_ERR("UNDERRUN ERR", ATH9K_PHYERR_UNDERRUN);
1050 PHY_ERR("TIMING ERR", ATH9K_PHYERR_TIMING);
1051 PHY_ERR("PARITY ERR", ATH9K_PHYERR_PARITY);
1052 PHY_ERR("RATE ERR", ATH9K_PHYERR_RATE);
1053 PHY_ERR("LENGTH ERR", ATH9K_PHYERR_LENGTH);
1054 PHY_ERR("RADAR ERR", ATH9K_PHYERR_RADAR);
1055 PHY_ERR("SERVICE ERR", ATH9K_PHYERR_SERVICE);
1056 PHY_ERR("TOR ERR", ATH9K_PHYERR_TOR);
1057 PHY_ERR("OFDM-TIMING ERR", ATH9K_PHYERR_OFDM_TIMING);
1058 PHY_ERR("OFDM-SIGNAL-PARITY ERR", ATH9K_PHYERR_OFDM_SIGNAL_PARITY);
1059 PHY_ERR("OFDM-RATE ERR", ATH9K_PHYERR_OFDM_RATE_ILLEGAL);
1060 PHY_ERR("OFDM-LENGTH ERR", ATH9K_PHYERR_OFDM_LENGTH_ILLEGAL);
1061 PHY_ERR("OFDM-POWER-DROP ERR", ATH9K_PHYERR_OFDM_POWER_DROP);
1062 PHY_ERR("OFDM-SERVICE ERR", ATH9K_PHYERR_OFDM_SERVICE);
1063 PHY_ERR("OFDM-RESTART ERR", ATH9K_PHYERR_OFDM_RESTART);
1064 PHY_ERR("FALSE-RADAR-EXT ERR", ATH9K_PHYERR_FALSE_RADAR_EXT);
1065 PHY_ERR("CCK-TIMING ERR", ATH9K_PHYERR_CCK_TIMING);
1066 PHY_ERR("CCK-HEADER-CRC ERR", ATH9K_PHYERR_CCK_HEADER_CRC);
1067 PHY_ERR("CCK-RATE ERR", ATH9K_PHYERR_CCK_RATE_ILLEGAL);
1068 PHY_ERR("CCK-SERVICE ERR", ATH9K_PHYERR_CCK_SERVICE);
1069 PHY_ERR("CCK-RESTART ERR", ATH9K_PHYERR_CCK_RESTART);
1070 PHY_ERR("CCK-LENGTH ERR", ATH9K_PHYERR_CCK_LENGTH_ILLEGAL);
1071 PHY_ERR("CCK-POWER-DROP ERR", ATH9K_PHYERR_CCK_POWER_DROP);
1072 PHY_ERR("HT-CRC ERR", ATH9K_PHYERR_HT_CRC_ERROR);
1073 PHY_ERR("HT-LENGTH ERR", ATH9K_PHYERR_HT_LENGTH_ILLEGAL);
1074 PHY_ERR("HT-RATE ERR", ATH9K_PHYERR_HT_RATE_ILLEGAL);
1075
1076 if (len > size)
1077 len = size;
1078
1079 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
1080 kfree(buf);
1081
1082 return retval;
1083
1084#undef PHY_ERR
1085}
1086
1087static const struct file_operations fops_phy_err = {
1088 .read = read_file_phy_err,
1089 .open = simple_open,
1090 .owner = THIS_MODULE,
1091 .llseek = default_llseek,
1092};
1093
Felix Fietkau9bff0bc2010-05-11 17:23:02 +02001094static ssize_t read_file_regidx(struct file *file, char __user *user_buf,
1095 size_t count, loff_t *ppos)
1096{
1097 struct ath_softc *sc = file->private_data;
1098 char buf[32];
1099 unsigned int len;
1100
Dan Carpenter2b87f3a2010-05-14 15:24:37 +02001101 len = sprintf(buf, "0x%08x\n", sc->debug.regidx);
Felix Fietkau9bff0bc2010-05-11 17:23:02 +02001102 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
1103}
1104
1105static ssize_t write_file_regidx(struct file *file, const char __user *user_buf,
1106 size_t count, loff_t *ppos)
1107{
1108 struct ath_softc *sc = file->private_data;
1109 unsigned long regidx;
1110 char buf[32];
1111 ssize_t len;
1112
1113 len = min(count, sizeof(buf) - 1);
1114 if (copy_from_user(buf, user_buf, len))
Dan Carpenter04236062010-05-14 15:25:39 +02001115 return -EFAULT;
Felix Fietkau9bff0bc2010-05-11 17:23:02 +02001116
1117 buf[len] = '\0';
Jingoo Han27d7f472013-05-31 21:24:06 +00001118 if (kstrtoul(buf, 0, &regidx))
Felix Fietkau9bff0bc2010-05-11 17:23:02 +02001119 return -EINVAL;
1120
1121 sc->debug.regidx = regidx;
1122 return count;
1123}
1124
1125static const struct file_operations fops_regidx = {
1126 .read = read_file_regidx,
1127 .write = write_file_regidx,
Stephen Boyd234e3402012-04-05 14:25:11 -07001128 .open = simple_open,
Arnd Bergmann6038f372010-08-15 18:52:59 +02001129 .owner = THIS_MODULE,
1130 .llseek = default_llseek,
Felix Fietkau9bff0bc2010-05-11 17:23:02 +02001131};
1132
1133static ssize_t read_file_regval(struct file *file, char __user *user_buf,
1134 size_t count, loff_t *ppos)
1135{
1136 struct ath_softc *sc = file->private_data;
1137 struct ath_hw *ah = sc->sc_ah;
1138 char buf[32];
1139 unsigned int len;
1140 u32 regval;
1141
Rajkumar Manoharan79d2b152011-05-16 18:23:23 +05301142 ath9k_ps_wakeup(sc);
Felix Fietkau9bff0bc2010-05-11 17:23:02 +02001143 regval = REG_READ_D(ah, sc->debug.regidx);
Rajkumar Manoharan79d2b152011-05-16 18:23:23 +05301144 ath9k_ps_restore(sc);
Dan Carpenter2b87f3a2010-05-14 15:24:37 +02001145 len = sprintf(buf, "0x%08x\n", regval);
Felix Fietkau9bff0bc2010-05-11 17:23:02 +02001146 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
1147}
1148
1149static ssize_t write_file_regval(struct file *file, const char __user *user_buf,
1150 size_t count, loff_t *ppos)
1151{
1152 struct ath_softc *sc = file->private_data;
1153 struct ath_hw *ah = sc->sc_ah;
1154 unsigned long regval;
1155 char buf[32];
1156 ssize_t len;
1157
1158 len = min(count, sizeof(buf) - 1);
1159 if (copy_from_user(buf, user_buf, len))
Dan Carpenter04236062010-05-14 15:25:39 +02001160 return -EFAULT;
Felix Fietkau9bff0bc2010-05-11 17:23:02 +02001161
1162 buf[len] = '\0';
Jingoo Han27d7f472013-05-31 21:24:06 +00001163 if (kstrtoul(buf, 0, &regval))
Felix Fietkau9bff0bc2010-05-11 17:23:02 +02001164 return -EINVAL;
1165
Rajkumar Manoharan79d2b152011-05-16 18:23:23 +05301166 ath9k_ps_wakeup(sc);
Felix Fietkau9bff0bc2010-05-11 17:23:02 +02001167 REG_WRITE_D(ah, sc->debug.regidx, regval);
Rajkumar Manoharan79d2b152011-05-16 18:23:23 +05301168 ath9k_ps_restore(sc);
Felix Fietkau9bff0bc2010-05-11 17:23:02 +02001169 return count;
1170}
1171
1172static const struct file_operations fops_regval = {
1173 .read = read_file_regval,
1174 .write = write_file_regval,
Stephen Boyd234e3402012-04-05 14:25:11 -07001175 .open = simple_open,
Arnd Bergmann6038f372010-08-15 18:52:59 +02001176 .owner = THIS_MODULE,
1177 .llseek = default_llseek,
Felix Fietkau9bff0bc2010-05-11 17:23:02 +02001178};
1179
Vasanthakumar Thiagarajan582d0062011-03-01 05:30:55 -08001180#define REGDUMP_LINE_SIZE 20
1181
1182static int open_file_regdump(struct inode *inode, struct file *file)
1183{
1184 struct ath_softc *sc = inode->i_private;
1185 unsigned int len = 0;
1186 u8 *buf;
1187 int i;
1188 unsigned long num_regs, regdump_len, max_reg_offset;
1189
1190 max_reg_offset = AR_SREV_9300_20_OR_LATER(sc->sc_ah) ? 0x16bd4 : 0xb500;
1191 num_regs = max_reg_offset / 4 + 1;
1192 regdump_len = num_regs * REGDUMP_LINE_SIZE + 1;
1193 buf = vmalloc(regdump_len);
1194 if (!buf)
1195 return -ENOMEM;
1196
1197 ath9k_ps_wakeup(sc);
1198 for (i = 0; i < num_regs; i++)
1199 len += scnprintf(buf + len, regdump_len - len,
1200 "0x%06x 0x%08x\n", i << 2, REG_READ(sc->sc_ah, i << 2));
1201 ath9k_ps_restore(sc);
1202
1203 file->private_data = buf;
1204
1205 return 0;
1206}
1207
1208static const struct file_operations fops_regdump = {
1209 .open = open_file_regdump,
1210 .read = ath9k_debugfs_read_buf,
1211 .release = ath9k_debugfs_release_buf,
1212 .owner = THIS_MODULE,
1213 .llseek = default_llseek,/* read accesses f_pos */
1214};
1215
Rajkumar Manoharand069a462011-08-13 10:28:18 +05301216static ssize_t read_file_dump_nfcal(struct file *file, char __user *user_buf,
1217 size_t count, loff_t *ppos)
1218{
1219 struct ath_softc *sc = file->private_data;
1220 struct ath_hw *ah = sc->sc_ah;
1221 struct ath9k_nfcal_hist *h = sc->caldata.nfCalHist;
1222 struct ath_common *common = ath9k_hw_common(ah);
1223 struct ieee80211_conf *conf = &common->hw->conf;
1224 u32 len = 0, size = 1500;
1225 u32 i, j;
1226 ssize_t retval = 0;
1227 char *buf;
1228 u8 chainmask = (ah->rxchainmask << 3) | ah->rxchainmask;
1229 u8 nread;
1230
1231 buf = kzalloc(size, GFP_KERNEL);
1232 if (!buf)
1233 return -ENOMEM;
1234
Zefir Kurtisi5e88ba62013-09-05 14:11:57 +02001235 len += scnprintf(buf + len, size - len,
1236 "Channel Noise Floor : %d\n", ah->noise);
1237 len += scnprintf(buf + len, size - len,
1238 "Chain | privNF | # Readings | NF Readings\n");
Rajkumar Manoharand069a462011-08-13 10:28:18 +05301239 for (i = 0; i < NUM_NF_READINGS; i++) {
1240 if (!(chainmask & (1 << i)) ||
1241 ((i >= AR5416_MAX_CHAINS) && !conf_is_ht40(conf)))
1242 continue;
1243
1244 nread = AR_PHY_CCA_FILTERWINDOW_LENGTH - h[i].invalidNFcount;
Zefir Kurtisi5e88ba62013-09-05 14:11:57 +02001245 len += scnprintf(buf + len, size - len, " %d\t %d\t %d\t\t",
1246 i, h[i].privNF, nread);
Rajkumar Manoharand069a462011-08-13 10:28:18 +05301247 for (j = 0; j < nread; j++)
Zefir Kurtisi5e88ba62013-09-05 14:11:57 +02001248 len += scnprintf(buf + len, size - len,
1249 " %d", h[i].nfCalBuffer[j]);
1250 len += scnprintf(buf + len, size - len, "\n");
Rajkumar Manoharand069a462011-08-13 10:28:18 +05301251 }
1252
1253 if (len > size)
1254 len = size;
1255
1256 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
1257 kfree(buf);
1258
1259 return retval;
1260}
1261
1262static const struct file_operations fops_dump_nfcal = {
1263 .read = read_file_dump_nfcal,
Stephen Boyd234e3402012-04-05 14:25:11 -07001264 .open = simple_open,
Rajkumar Manoharand069a462011-08-13 10:28:18 +05301265 .owner = THIS_MODULE,
1266 .llseek = default_llseek,
1267};
1268
Rajkumar Manoharan580f0102011-07-29 17:38:12 +05301269static ssize_t read_file_base_eeprom(struct file *file, char __user *user_buf,
1270 size_t count, loff_t *ppos)
1271{
1272 struct ath_softc *sc = file->private_data;
1273 struct ath_hw *ah = sc->sc_ah;
1274 u32 len = 0, size = 1500;
1275 ssize_t retval = 0;
1276 char *buf;
1277
1278 buf = kzalloc(size, GFP_KERNEL);
1279 if (!buf)
1280 return -ENOMEM;
1281
1282 len = ah->eep_ops->dump_eeprom(ah, true, buf, len, size);
1283
1284 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
1285 kfree(buf);
1286
1287 return retval;
1288}
1289
1290static const struct file_operations fops_base_eeprom = {
1291 .read = read_file_base_eeprom,
Stephen Boyd234e3402012-04-05 14:25:11 -07001292 .open = simple_open,
Rajkumar Manoharan580f0102011-07-29 17:38:12 +05301293 .owner = THIS_MODULE,
1294 .llseek = default_llseek,
1295};
1296
Rajkumar Manoharan3f4c4bd2011-07-29 17:38:13 +05301297static ssize_t read_file_modal_eeprom(struct file *file, char __user *user_buf,
1298 size_t count, loff_t *ppos)
1299{
1300 struct ath_softc *sc = file->private_data;
1301 struct ath_hw *ah = sc->sc_ah;
1302 u32 len = 0, size = 6000;
1303 char *buf;
1304 size_t retval;
1305
1306 buf = kzalloc(size, GFP_KERNEL);
1307 if (buf == NULL)
1308 return -ENOMEM;
1309
1310 len = ah->eep_ops->dump_eeprom(ah, false, buf, len, size);
1311
1312 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
1313 kfree(buf);
1314
1315 return retval;
1316}
1317
1318static const struct file_operations fops_modal_eeprom = {
1319 .read = read_file_modal_eeprom,
Stephen Boyd234e3402012-04-05 14:25:11 -07001320 .open = simple_open,
Rajkumar Manoharan3f4c4bd2011-07-29 17:38:13 +05301321 .owner = THIS_MODULE,
1322 .llseek = default_llseek,
1323};
1324
Rajkumar Manoharan4df50ca2012-10-25 17:16:54 +05301325#ifdef CONFIG_ATH9K_BTCOEX_SUPPORT
1326static ssize_t read_file_btcoex(struct file *file, char __user *user_buf,
1327 size_t count, loff_t *ppos)
1328{
1329 struct ath_softc *sc = file->private_data;
1330 u32 len = 0, size = 1500;
1331 char *buf;
1332 size_t retval;
1333
1334 buf = kzalloc(size, GFP_KERNEL);
1335 if (buf == NULL)
1336 return -ENOMEM;
1337
Sujith Manoharanac46ba42012-11-19 14:24:46 +05301338 if (!sc->sc_ah->common.btcoex_enabled) {
Zefir Kurtisi5e88ba62013-09-05 14:11:57 +02001339 len = scnprintf(buf, size, "%s\n",
1340 "BTCOEX is disabled");
Sujith Manoharanac46ba42012-11-19 14:24:46 +05301341 goto exit;
1342 }
Rajkumar Manoharan4df50ca2012-10-25 17:16:54 +05301343
Sujith Manoharanac46ba42012-11-19 14:24:46 +05301344 len = ath9k_dump_btcoex(sc, buf, size);
1345exit:
Rajkumar Manoharan4df50ca2012-10-25 17:16:54 +05301346 retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
1347 kfree(buf);
1348
1349 return retval;
1350}
1351
1352static const struct file_operations fops_btcoex = {
1353 .read = read_file_btcoex,
1354 .open = simple_open,
1355 .owner = THIS_MODULE,
1356 .llseek = default_llseek,
1357};
1358#endif
1359
Sujith Manoharanc175db82012-11-28 15:08:52 +05301360/* Ethtool support for get-stats */
1361
1362#define AMKSTR(nm) #nm "_BE", #nm "_BK", #nm "_VI", #nm "_VO"
1363static const char ath9k_gstrings_stats[][ETH_GSTRING_LEN] = {
1364 "tx_pkts_nic",
1365 "tx_bytes_nic",
1366 "rx_pkts_nic",
1367 "rx_bytes_nic",
1368 AMKSTR(d_tx_pkts),
1369 AMKSTR(d_tx_bytes),
1370 AMKSTR(d_tx_mpdus_queued),
1371 AMKSTR(d_tx_mpdus_completed),
1372 AMKSTR(d_tx_mpdu_xretries),
1373 AMKSTR(d_tx_aggregates),
1374 AMKSTR(d_tx_ampdus_queued_hw),
1375 AMKSTR(d_tx_ampdus_queued_sw),
1376 AMKSTR(d_tx_ampdus_completed),
1377 AMKSTR(d_tx_ampdu_retries),
1378 AMKSTR(d_tx_ampdu_xretries),
1379 AMKSTR(d_tx_fifo_underrun),
1380 AMKSTR(d_tx_op_exceeded),
1381 AMKSTR(d_tx_timer_expiry),
1382 AMKSTR(d_tx_desc_cfg_err),
1383 AMKSTR(d_tx_data_underrun),
1384 AMKSTR(d_tx_delim_underrun),
Ben Greear18c45b12013-03-04 15:31:17 -08001385 "d_rx_crc_err",
Sujith Manoharanc175db82012-11-28 15:08:52 +05301386 "d_rx_decrypt_crc_err",
1387 "d_rx_phy_err",
1388 "d_rx_mic_err",
1389 "d_rx_pre_delim_crc_err",
1390 "d_rx_post_delim_crc_err",
1391 "d_rx_decrypt_busy_err",
1392
1393 "d_rx_phyerr_radar",
1394 "d_rx_phyerr_ofdm_timing",
1395 "d_rx_phyerr_cck_timing",
1396
1397};
1398#define ATH9K_SSTATS_LEN ARRAY_SIZE(ath9k_gstrings_stats)
1399
1400void ath9k_get_et_strings(struct ieee80211_hw *hw,
1401 struct ieee80211_vif *vif,
1402 u32 sset, u8 *data)
1403{
1404 if (sset == ETH_SS_STATS)
1405 memcpy(data, *ath9k_gstrings_stats,
1406 sizeof(ath9k_gstrings_stats));
1407}
1408
1409int ath9k_get_et_sset_count(struct ieee80211_hw *hw,
1410 struct ieee80211_vif *vif, int sset)
1411{
1412 if (sset == ETH_SS_STATS)
1413 return ATH9K_SSTATS_LEN;
1414 return 0;
1415}
1416
1417#define AWDATA(elem) \
1418 do { \
1419 data[i++] = sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_BE)].elem; \
1420 data[i++] = sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_BK)].elem; \
1421 data[i++] = sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_VI)].elem; \
1422 data[i++] = sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_VO)].elem; \
1423 } while (0)
1424
1425#define AWDATA_RX(elem) \
1426 do { \
1427 data[i++] = sc->debug.stats.rxstats.elem; \
1428 } while (0)
1429
1430void ath9k_get_et_stats(struct ieee80211_hw *hw,
1431 struct ieee80211_vif *vif,
1432 struct ethtool_stats *stats, u64 *data)
1433{
1434 struct ath_softc *sc = hw->priv;
1435 int i = 0;
1436
1437 data[i++] = (sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_BE)].tx_pkts_all +
1438 sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_BK)].tx_pkts_all +
1439 sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_VI)].tx_pkts_all +
1440 sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_VO)].tx_pkts_all);
1441 data[i++] = (sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_BE)].tx_bytes_all +
1442 sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_BK)].tx_bytes_all +
1443 sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_VI)].tx_bytes_all +
1444 sc->debug.stats.txstats[PR_QNUM(IEEE80211_AC_VO)].tx_bytes_all);
1445 AWDATA_RX(rx_pkts_all);
1446 AWDATA_RX(rx_bytes_all);
1447
1448 AWDATA(tx_pkts_all);
1449 AWDATA(tx_bytes_all);
1450 AWDATA(queued);
1451 AWDATA(completed);
1452 AWDATA(xretries);
1453 AWDATA(a_aggr);
1454 AWDATA(a_queued_hw);
1455 AWDATA(a_queued_sw);
1456 AWDATA(a_completed);
1457 AWDATA(a_retries);
1458 AWDATA(a_xretries);
1459 AWDATA(fifo_underrun);
1460 AWDATA(xtxop);
1461 AWDATA(timer_exp);
1462 AWDATA(desc_cfg_err);
1463 AWDATA(data_underrun);
1464 AWDATA(delim_underrun);
1465
Ben Greear18c45b12013-03-04 15:31:17 -08001466 AWDATA_RX(crc_err);
Sujith Manoharanc175db82012-11-28 15:08:52 +05301467 AWDATA_RX(decrypt_crc_err);
1468 AWDATA_RX(phy_err);
1469 AWDATA_RX(mic_err);
1470 AWDATA_RX(pre_delim_crc_err);
1471 AWDATA_RX(post_delim_crc_err);
1472 AWDATA_RX(decrypt_busy_err);
1473
1474 AWDATA_RX(phy_err_stats[ATH9K_PHYERR_RADAR]);
1475 AWDATA_RX(phy_err_stats[ATH9K_PHYERR_OFDM_TIMING]);
1476 AWDATA_RX(phy_err_stats[ATH9K_PHYERR_CCK_TIMING]);
1477
1478 WARN_ON(i != ATH9K_SSTATS_LEN);
1479}
1480
Sujith Manoharanaf690092013-05-10 18:41:06 +05301481void ath9k_deinit_debug(struct ath_softc *sc)
1482{
Sujith Manoharanf65c0822013-12-18 09:53:18 +05301483 ath9k_spectral_deinit_debug(sc);
Sujith Manoharanaf690092013-05-10 18:41:06 +05301484}
1485
Luis R. Rodriguez4d6b2282009-09-07 04:52:26 -07001486int ath9k_init_debug(struct ath_hw *ah)
Sujith88b126a2008-11-28 22:19:02 +05301487{
Luis R. Rodriguezbc974f42009-09-28 02:54:40 -04001488 struct ath_common *common = ath9k_hw_common(ah);
1489 struct ath_softc *sc = (struct ath_softc *) common->priv;
Luis R. Rodriguez4d6b2282009-09-07 04:52:26 -07001490
Ben Greeareb272442010-11-29 14:13:22 -08001491 sc->debug.debugfs_phy = debugfs_create_dir("ath9k",
1492 sc->hw->wiphy->debugfsdir);
Sujith17d79042009-02-09 13:27:03 +05301493 if (!sc->debug.debugfs_phy)
Felix Fietkauc8a72c02010-05-11 17:23:00 +02001494 return -ENOMEM;
Sujith826d2682008-11-28 22:20:23 +05301495
Felix Fietkaua830df02009-11-23 22:33:27 +01001496#ifdef CONFIG_ATH_DEBUG
Felix Fietkauc70cab12011-03-19 13:55:37 +01001497 debugfs_create_file("debug", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
1498 sc, &fops_debug);
Felix Fietkaua830df02009-11-23 22:33:27 +01001499#endif
Zefir Kurtisi29942bc2011-12-14 20:16:34 -08001500
1501 ath9k_dfs_init_debug(sc);
Sujith Manoharanef6b19e2013-10-24 12:04:39 +05301502 ath9k_tx99_init_debug(sc);
Sujith Manoharanf65c0822013-12-18 09:53:18 +05301503 ath9k_spectral_init_debug(sc);
Zefir Kurtisi29942bc2011-12-14 20:16:34 -08001504
Felix Fietkauc70cab12011-03-19 13:55:37 +01001505 debugfs_create_file("dma", S_IRUSR, sc->debug.debugfs_phy, sc,
1506 &fops_dma);
1507 debugfs_create_file("interrupt", S_IRUSR, sc->debug.debugfs_phy, sc,
1508 &fops_interrupt);
Felix Fietkauc70cab12011-03-19 13:55:37 +01001509 debugfs_create_file("xmit", S_IRUSR, sc->debug.debugfs_phy, sc,
1510 &fops_xmit);
Sujith Manoharanc0b74872012-11-21 18:13:12 +05301511 debugfs_create_file("queues", S_IRUSR, sc->debug.debugfs_phy, sc,
1512 &fops_queues);
Felix Fietkau7702e782012-07-15 19:53:35 +02001513 debugfs_create_u32("qlen_bk", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
Sujith Manoharanbea843c2012-11-21 18:13:10 +05301514 &sc->tx.txq_max_pending[IEEE80211_AC_BK]);
Felix Fietkau7702e782012-07-15 19:53:35 +02001515 debugfs_create_u32("qlen_be", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
Sujith Manoharanbea843c2012-11-21 18:13:10 +05301516 &sc->tx.txq_max_pending[IEEE80211_AC_BE]);
Felix Fietkau7702e782012-07-15 19:53:35 +02001517 debugfs_create_u32("qlen_vi", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
Sujith Manoharanbea843c2012-11-21 18:13:10 +05301518 &sc->tx.txq_max_pending[IEEE80211_AC_VI]);
Felix Fietkau7702e782012-07-15 19:53:35 +02001519 debugfs_create_u32("qlen_vo", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
Sujith Manoharanbea843c2012-11-21 18:13:10 +05301520 &sc->tx.txq_max_pending[IEEE80211_AC_VO]);
Felix Fietkauc70cab12011-03-19 13:55:37 +01001521 debugfs_create_file("misc", S_IRUSR, sc->debug.debugfs_phy, sc,
1522 &fops_misc);
Sujith Manoharanf8b815d2012-02-16 11:51:11 +05301523 debugfs_create_file("reset", S_IRUSR, sc->debug.debugfs_phy, sc,
1524 &fops_reset);
Felix Fietkauc70cab12011-03-19 13:55:37 +01001525 debugfs_create_file("recv", S_IRUSR, sc->debug.debugfs_phy, sc,
1526 &fops_recv);
Sujith Manoharanc3b9f9e2014-01-13 07:29:29 +05301527 debugfs_create_file("phy_err", S_IRUSR, sc->debug.debugfs_phy, sc,
1528 &fops_phy_err);
Felix Fietkauca6d4a72013-08-13 12:33:27 +02001529 debugfs_create_u8("rx_chainmask", S_IRUSR, sc->debug.debugfs_phy,
1530 &ah->rxchainmask);
1531 debugfs_create_u8("tx_chainmask", S_IRUSR, sc->debug.debugfs_phy,
1532 &ah->txchainmask);
Sujith Manoharan6e4d2912013-06-03 09:19:28 +05301533 debugfs_create_file("ani", S_IRUSR | S_IWUSR,
1534 sc->debug.debugfs_phy, sc, &fops_ani);
Felix Fietkau74673db2012-09-08 15:24:17 +02001535 debugfs_create_bool("paprd", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
1536 &sc->sc_ah->config.enable_paprd);
Felix Fietkauc70cab12011-03-19 13:55:37 +01001537 debugfs_create_file("regidx", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
1538 sc, &fops_regidx);
1539 debugfs_create_file("regval", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
1540 sc, &fops_regval);
1541 debugfs_create_bool("ignore_extcca", S_IRUSR | S_IWUSR,
1542 sc->debug.debugfs_phy,
1543 &ah->config.cwm_ignore_extcca);
1544 debugfs_create_file("regdump", S_IRUSR, sc->debug.debugfs_phy, sc,
1545 &fops_regdump);
Rajkumar Manoharand069a462011-08-13 10:28:18 +05301546 debugfs_create_file("dump_nfcal", S_IRUSR, sc->debug.debugfs_phy, sc,
1547 &fops_dump_nfcal);
Rajkumar Manoharan580f0102011-07-29 17:38:12 +05301548 debugfs_create_file("base_eeprom", S_IRUSR, sc->debug.debugfs_phy, sc,
1549 &fops_base_eeprom);
Rajkumar Manoharan3f4c4bd2011-07-29 17:38:13 +05301550 debugfs_create_file("modal_eeprom", S_IRUSR, sc->debug.debugfs_phy, sc,
1551 &fops_modal_eeprom);
Felix Fietkau691680b2011-03-19 13:55:38 +01001552 debugfs_create_u32("gpio_mask", S_IRUSR | S_IWUSR,
1553 sc->debug.debugfs_phy, &sc->sc_ah->gpio_mask);
Felix Fietkau691680b2011-03-19 13:55:38 +01001554 debugfs_create_u32("gpio_val", S_IRUSR | S_IWUSR,
1555 sc->debug.debugfs_phy, &sc->sc_ah->gpio_val);
Sujith Manoharan4eba10c2013-07-29 16:04:49 +05301556 debugfs_create_file("antenna_diversity", S_IRUSR,
1557 sc->debug.debugfs_phy, sc, &fops_antenna_diversity);
Rajkumar Manoharan4df50ca2012-10-25 17:16:54 +05301558#ifdef CONFIG_ATH9K_BTCOEX_SUPPORT
Sujith Manoharan36e88252013-08-06 12:44:15 +05301559 debugfs_create_file("bt_ant_diversity", S_IRUSR | S_IWUSR,
1560 sc->debug.debugfs_phy, sc, &fops_bt_ant_diversity);
Rajkumar Manoharan4df50ca2012-10-25 17:16:54 +05301561 debugfs_create_file("btcoex", S_IRUSR, sc->debug.debugfs_phy, sc,
1562 &fops_btcoex);
1563#endif
Luis R. Rodriguez89f927a2013-10-14 17:42:11 -07001564
Sujith826d2682008-11-28 22:20:23 +05301565 return 0;
Sujith88b126a2008-11-28 22:19:02 +05301566}