xref: /openbmc/linux/drivers/net/wireless/ath/ath9k/debug.c (revision 05c0be2f7f10404e5b3bc4105f9206096e9b8767)
1203c4805SLuis R. Rodriguez /*
25b68138eSSujith Manoharan  * Copyright (c) 2008-2011 Atheros Communications Inc.
3203c4805SLuis R. Rodriguez  *
4203c4805SLuis R. Rodriguez  * Permission to use, copy, modify, and/or distribute this software for any
5203c4805SLuis R. Rodriguez  * purpose with or without fee is hereby granted, provided that the above
6203c4805SLuis R. Rodriguez  * copyright notice and this permission notice appear in all copies.
7203c4805SLuis R. Rodriguez  *
8203c4805SLuis R. Rodriguez  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9203c4805SLuis R. Rodriguez  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10203c4805SLuis R. Rodriguez  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11203c4805SLuis R. Rodriguez  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12203c4805SLuis R. Rodriguez  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13203c4805SLuis R. Rodriguez  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14203c4805SLuis R. Rodriguez  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15203c4805SLuis R. Rodriguez  */
16203c4805SLuis R. Rodriguez 
175a0e3ad6STejun Heo #include <linux/slab.h>
18582d0064SVasanthakumar Thiagarajan #include <linux/vmalloc.h>
19203c4805SLuis R. Rodriguez #include <asm/unaligned.h>
20203c4805SLuis R. Rodriguez 
21203c4805SLuis R. Rodriguez #include "ath9k.h"
22203c4805SLuis R. Rodriguez 
23475a6e4dSLuis R. Rodriguez #define REG_WRITE_D(_ah, _reg, _val) \
24475a6e4dSLuis R. Rodriguez 	ath9k_hw_common(_ah)->ops->write((_ah), (_val), (_reg))
25475a6e4dSLuis R. Rodriguez #define REG_READ_D(_ah, _reg) \
26475a6e4dSLuis R. Rodriguez 	ath9k_hw_common(_ah)->ops->read((_ah), (_reg))
27475a6e4dSLuis R. Rodriguez 
28203c4805SLuis R. Rodriguez static int ath9k_debugfs_open(struct inode *inode, struct file *file)
29203c4805SLuis R. Rodriguez {
30203c4805SLuis R. Rodriguez 	file->private_data = inode->i_private;
31203c4805SLuis R. Rodriguez 	return 0;
32203c4805SLuis R. Rodriguez }
33203c4805SLuis R. Rodriguez 
34582d0064SVasanthakumar Thiagarajan static ssize_t ath9k_debugfs_read_buf(struct file *file, char __user *user_buf,
35582d0064SVasanthakumar Thiagarajan 				      size_t count, loff_t *ppos)
36582d0064SVasanthakumar Thiagarajan {
37582d0064SVasanthakumar Thiagarajan 	u8 *buf = file->private_data;
38582d0064SVasanthakumar Thiagarajan 	return simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf));
39582d0064SVasanthakumar Thiagarajan }
40582d0064SVasanthakumar Thiagarajan 
41582d0064SVasanthakumar Thiagarajan static int ath9k_debugfs_release_buf(struct inode *inode, struct file *file)
42582d0064SVasanthakumar Thiagarajan {
43582d0064SVasanthakumar Thiagarajan 	vfree(file->private_data);
44582d0064SVasanthakumar Thiagarajan 	return 0;
45582d0064SVasanthakumar Thiagarajan }
46582d0064SVasanthakumar Thiagarajan 
47a830df07SFelix Fietkau #ifdef CONFIG_ATH_DEBUG
48a830df07SFelix Fietkau 
492493928eSJeff Hansen static ssize_t read_file_debug(struct file *file, char __user *user_buf,
502493928eSJeff Hansen 			     size_t count, loff_t *ppos)
512493928eSJeff Hansen {
522493928eSJeff Hansen 	struct ath_softc *sc = file->private_data;
53c46917bbSLuis R. Rodriguez 	struct ath_common *common = ath9k_hw_common(sc->sc_ah);
542493928eSJeff Hansen 	char buf[32];
55581f725cSVasanthakumar Thiagarajan 	unsigned int len;
56581f725cSVasanthakumar Thiagarajan 
572b87f3aaSDan Carpenter 	len = sprintf(buf, "0x%08x\n", common->debug_mask);
582493928eSJeff Hansen 	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
592493928eSJeff Hansen }
602493928eSJeff Hansen 
612493928eSJeff Hansen static ssize_t write_file_debug(struct file *file, const char __user *user_buf,
622493928eSJeff Hansen 			     size_t count, loff_t *ppos)
632493928eSJeff Hansen {
642493928eSJeff Hansen 	struct ath_softc *sc = file->private_data;
65c46917bbSLuis R. Rodriguez 	struct ath_common *common = ath9k_hw_common(sc->sc_ah);
662493928eSJeff Hansen 	unsigned long mask;
672493928eSJeff Hansen 	char buf[32];
68581f725cSVasanthakumar Thiagarajan 	ssize_t len;
69581f725cSVasanthakumar Thiagarajan 
70581f725cSVasanthakumar Thiagarajan 	len = min(count, sizeof(buf) - 1);
71581f725cSVasanthakumar Thiagarajan 	if (copy_from_user(buf, user_buf, len))
7204236066SDan Carpenter 		return -EFAULT;
73581f725cSVasanthakumar Thiagarajan 
74581f725cSVasanthakumar Thiagarajan 	buf[len] = '\0';
75581f725cSVasanthakumar Thiagarajan 	if (strict_strtoul(buf, 0, &mask))
76581f725cSVasanthakumar Thiagarajan 		return -EINVAL;
77581f725cSVasanthakumar Thiagarajan 
78c46917bbSLuis R. Rodriguez 	common->debug_mask = mask;
792493928eSJeff Hansen 	return count;
802493928eSJeff Hansen }
812493928eSJeff Hansen 
822493928eSJeff Hansen static const struct file_operations fops_debug = {
832493928eSJeff Hansen 	.read = read_file_debug,
842493928eSJeff Hansen 	.write = write_file_debug,
852493928eSJeff Hansen 	.open = ath9k_debugfs_open,
866038f373SArnd Bergmann 	.owner = THIS_MODULE,
876038f373SArnd Bergmann 	.llseek = default_llseek,
882493928eSJeff Hansen };
892493928eSJeff Hansen 
90a830df07SFelix Fietkau #endif
91a830df07SFelix Fietkau 
92991a0987SPavel Roskin #define DMA_BUF_LEN 1024
93991a0987SPavel Roskin 
9415340694SFelix Fietkau static ssize_t read_file_tx_chainmask(struct file *file, char __user *user_buf,
9515340694SFelix Fietkau 			     size_t count, loff_t *ppos)
9615340694SFelix Fietkau {
9715340694SFelix Fietkau 	struct ath_softc *sc = file->private_data;
9815340694SFelix Fietkau 	struct ath_common *common = ath9k_hw_common(sc->sc_ah);
9915340694SFelix Fietkau 	char buf[32];
10015340694SFelix Fietkau 	unsigned int len;
10115340694SFelix Fietkau 
1022b87f3aaSDan Carpenter 	len = sprintf(buf, "0x%08x\n", common->tx_chainmask);
10315340694SFelix Fietkau 	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
10415340694SFelix Fietkau }
10515340694SFelix Fietkau 
10615340694SFelix Fietkau static ssize_t write_file_tx_chainmask(struct file *file, const char __user *user_buf,
10715340694SFelix Fietkau 			     size_t count, loff_t *ppos)
10815340694SFelix Fietkau {
10915340694SFelix Fietkau 	struct ath_softc *sc = file->private_data;
11015340694SFelix Fietkau 	struct ath_common *common = ath9k_hw_common(sc->sc_ah);
11115340694SFelix Fietkau 	unsigned long mask;
11215340694SFelix Fietkau 	char buf[32];
11315340694SFelix Fietkau 	ssize_t len;
11415340694SFelix Fietkau 
11515340694SFelix Fietkau 	len = min(count, sizeof(buf) - 1);
11615340694SFelix Fietkau 	if (copy_from_user(buf, user_buf, len))
11704236066SDan Carpenter 		return -EFAULT;
11815340694SFelix Fietkau 
11915340694SFelix Fietkau 	buf[len] = '\0';
12015340694SFelix Fietkau 	if (strict_strtoul(buf, 0, &mask))
12115340694SFelix Fietkau 		return -EINVAL;
12215340694SFelix Fietkau 
12315340694SFelix Fietkau 	common->tx_chainmask = mask;
12415340694SFelix Fietkau 	sc->sc_ah->caps.tx_chainmask = mask;
12515340694SFelix Fietkau 	return count;
12615340694SFelix Fietkau }
12715340694SFelix Fietkau 
12815340694SFelix Fietkau static const struct file_operations fops_tx_chainmask = {
12915340694SFelix Fietkau 	.read = read_file_tx_chainmask,
13015340694SFelix Fietkau 	.write = write_file_tx_chainmask,
13115340694SFelix Fietkau 	.open = ath9k_debugfs_open,
1326038f373SArnd Bergmann 	.owner = THIS_MODULE,
1336038f373SArnd Bergmann 	.llseek = default_llseek,
13415340694SFelix Fietkau };
13515340694SFelix Fietkau 
13615340694SFelix Fietkau 
13715340694SFelix Fietkau static ssize_t read_file_rx_chainmask(struct file *file, char __user *user_buf,
13815340694SFelix Fietkau 			     size_t count, loff_t *ppos)
13915340694SFelix Fietkau {
14015340694SFelix Fietkau 	struct ath_softc *sc = file->private_data;
14115340694SFelix Fietkau 	struct ath_common *common = ath9k_hw_common(sc->sc_ah);
14215340694SFelix Fietkau 	char buf[32];
14315340694SFelix Fietkau 	unsigned int len;
14415340694SFelix Fietkau 
1452b87f3aaSDan Carpenter 	len = sprintf(buf, "0x%08x\n", common->rx_chainmask);
14615340694SFelix Fietkau 	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
14715340694SFelix Fietkau }
14815340694SFelix Fietkau 
14915340694SFelix Fietkau static ssize_t write_file_rx_chainmask(struct file *file, const char __user *user_buf,
15015340694SFelix Fietkau 			     size_t count, loff_t *ppos)
15115340694SFelix Fietkau {
15215340694SFelix Fietkau 	struct ath_softc *sc = file->private_data;
15315340694SFelix Fietkau 	struct ath_common *common = ath9k_hw_common(sc->sc_ah);
15415340694SFelix Fietkau 	unsigned long mask;
15515340694SFelix Fietkau 	char buf[32];
15615340694SFelix Fietkau 	ssize_t len;
15715340694SFelix Fietkau 
15815340694SFelix Fietkau 	len = min(count, sizeof(buf) - 1);
15915340694SFelix Fietkau 	if (copy_from_user(buf, user_buf, len))
16004236066SDan Carpenter 		return -EFAULT;
16115340694SFelix Fietkau 
16215340694SFelix Fietkau 	buf[len] = '\0';
16315340694SFelix Fietkau 	if (strict_strtoul(buf, 0, &mask))
16415340694SFelix Fietkau 		return -EINVAL;
16515340694SFelix Fietkau 
16615340694SFelix Fietkau 	common->rx_chainmask = mask;
16715340694SFelix Fietkau 	sc->sc_ah->caps.rx_chainmask = mask;
16815340694SFelix Fietkau 	return count;
16915340694SFelix Fietkau }
17015340694SFelix Fietkau 
17115340694SFelix Fietkau static const struct file_operations fops_rx_chainmask = {
17215340694SFelix Fietkau 	.read = read_file_rx_chainmask,
17315340694SFelix Fietkau 	.write = write_file_rx_chainmask,
17415340694SFelix Fietkau 	.open = ath9k_debugfs_open,
1756038f373SArnd Bergmann 	.owner = THIS_MODULE,
1766038f373SArnd Bergmann 	.llseek = default_llseek,
17715340694SFelix Fietkau };
17815340694SFelix Fietkau 
179*05c0be2fSMohammed Shafi Shajakhan static ssize_t read_file_disable_ani(struct file *file, char __user *user_buf,
180*05c0be2fSMohammed Shafi Shajakhan 			     size_t count, loff_t *ppos)
181*05c0be2fSMohammed Shafi Shajakhan {
182*05c0be2fSMohammed Shafi Shajakhan 	struct ath_softc *sc = file->private_data;
183*05c0be2fSMohammed Shafi Shajakhan 	struct ath_common *common = ath9k_hw_common(sc->sc_ah);
184*05c0be2fSMohammed Shafi Shajakhan 	char buf[32];
185*05c0be2fSMohammed Shafi Shajakhan 	unsigned int len;
186*05c0be2fSMohammed Shafi Shajakhan 
187*05c0be2fSMohammed Shafi Shajakhan 	len = sprintf(buf, "%d\n", common->disable_ani);
188*05c0be2fSMohammed Shafi Shajakhan 	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
189*05c0be2fSMohammed Shafi Shajakhan }
190*05c0be2fSMohammed Shafi Shajakhan 
191*05c0be2fSMohammed Shafi Shajakhan static ssize_t write_file_disable_ani(struct file *file,
192*05c0be2fSMohammed Shafi Shajakhan 				      const char __user *user_buf,
193*05c0be2fSMohammed Shafi Shajakhan 				      size_t count, loff_t *ppos)
194*05c0be2fSMohammed Shafi Shajakhan {
195*05c0be2fSMohammed Shafi Shajakhan 	struct ath_softc *sc = file->private_data;
196*05c0be2fSMohammed Shafi Shajakhan 	struct ath_common *common = ath9k_hw_common(sc->sc_ah);
197*05c0be2fSMohammed Shafi Shajakhan 	unsigned long disable_ani;
198*05c0be2fSMohammed Shafi Shajakhan 	char buf[32];
199*05c0be2fSMohammed Shafi Shajakhan 	ssize_t len;
200*05c0be2fSMohammed Shafi Shajakhan 
201*05c0be2fSMohammed Shafi Shajakhan 	len = min(count, sizeof(buf) - 1);
202*05c0be2fSMohammed Shafi Shajakhan 	if (copy_from_user(buf, user_buf, len))
203*05c0be2fSMohammed Shafi Shajakhan 		return -EFAULT;
204*05c0be2fSMohammed Shafi Shajakhan 
205*05c0be2fSMohammed Shafi Shajakhan 	buf[len] = '\0';
206*05c0be2fSMohammed Shafi Shajakhan 	if (strict_strtoul(buf, 0, &disable_ani))
207*05c0be2fSMohammed Shafi Shajakhan 		return -EINVAL;
208*05c0be2fSMohammed Shafi Shajakhan 
209*05c0be2fSMohammed Shafi Shajakhan 	common->disable_ani = !!disable_ani;
210*05c0be2fSMohammed Shafi Shajakhan 
211*05c0be2fSMohammed Shafi Shajakhan 	if (disable_ani) {
212*05c0be2fSMohammed Shafi Shajakhan 		sc->sc_flags &= ~SC_OP_ANI_RUN;
213*05c0be2fSMohammed Shafi Shajakhan 		del_timer_sync(&common->ani.timer);
214*05c0be2fSMohammed Shafi Shajakhan 	} else {
215*05c0be2fSMohammed Shafi Shajakhan 		sc->sc_flags |= SC_OP_ANI_RUN;
216*05c0be2fSMohammed Shafi Shajakhan 		ath_start_ani(common);
217*05c0be2fSMohammed Shafi Shajakhan 	}
218*05c0be2fSMohammed Shafi Shajakhan 
219*05c0be2fSMohammed Shafi Shajakhan 	return count;
220*05c0be2fSMohammed Shafi Shajakhan }
221*05c0be2fSMohammed Shafi Shajakhan 
222*05c0be2fSMohammed Shafi Shajakhan static const struct file_operations fops_disable_ani = {
223*05c0be2fSMohammed Shafi Shajakhan 	.read = read_file_disable_ani,
224*05c0be2fSMohammed Shafi Shajakhan 	.write = write_file_disable_ani,
225*05c0be2fSMohammed Shafi Shajakhan 	.open = ath9k_debugfs_open,
226*05c0be2fSMohammed Shafi Shajakhan 	.owner = THIS_MODULE,
227*05c0be2fSMohammed Shafi Shajakhan 	.llseek = default_llseek,
228*05c0be2fSMohammed Shafi Shajakhan };
22915340694SFelix Fietkau 
230203c4805SLuis R. Rodriguez static ssize_t read_file_dma(struct file *file, char __user *user_buf,
231203c4805SLuis R. Rodriguez 			     size_t count, loff_t *ppos)
232203c4805SLuis R. Rodriguez {
233203c4805SLuis R. Rodriguez 	struct ath_softc *sc = file->private_data;
234203c4805SLuis R. Rodriguez 	struct ath_hw *ah = sc->sc_ah;
235991a0987SPavel Roskin 	char *buf;
236991a0987SPavel Roskin 	int retval;
237203c4805SLuis R. Rodriguez 	unsigned int len = 0;
238203c4805SLuis R. Rodriguez 	u32 val[ATH9K_NUM_DMA_DEBUG_REGS];
239203c4805SLuis R. Rodriguez 	int i, qcuOffset = 0, dcuOffset = 0;
240203c4805SLuis R. Rodriguez 	u32 *qcuBase = &val[0], *dcuBase = &val[4];
241203c4805SLuis R. Rodriguez 
242991a0987SPavel Roskin 	buf = kmalloc(DMA_BUF_LEN, GFP_KERNEL);
243991a0987SPavel Roskin 	if (!buf)
24404236066SDan Carpenter 		return -ENOMEM;
245991a0987SPavel Roskin 
2467cf4a2e7SSujith 	ath9k_ps_wakeup(sc);
2477cf4a2e7SSujith 
248475a6e4dSLuis R. Rodriguez 	REG_WRITE_D(ah, AR_MACMISC,
249203c4805SLuis R. Rodriguez 		  ((AR_MACMISC_DMA_OBS_LINE_8 << AR_MACMISC_DMA_OBS_S) |
250203c4805SLuis R. Rodriguez 		   (AR_MACMISC_MISC_OBS_BUS_1 <<
251203c4805SLuis R. Rodriguez 		    AR_MACMISC_MISC_OBS_BUS_MSB_S)));
252203c4805SLuis R. Rodriguez 
253991a0987SPavel Roskin 	len += snprintf(buf + len, DMA_BUF_LEN - len,
254203c4805SLuis R. Rodriguez 			"Raw DMA Debug values:\n");
255203c4805SLuis R. Rodriguez 
256203c4805SLuis R. Rodriguez 	for (i = 0; i < ATH9K_NUM_DMA_DEBUG_REGS; i++) {
257203c4805SLuis R. Rodriguez 		if (i % 4 == 0)
258991a0987SPavel Roskin 			len += snprintf(buf + len, DMA_BUF_LEN - len, "\n");
259203c4805SLuis R. Rodriguez 
260475a6e4dSLuis R. Rodriguez 		val[i] = REG_READ_D(ah, AR_DMADBG_0 + (i * sizeof(u32)));
261991a0987SPavel Roskin 		len += snprintf(buf + len, DMA_BUF_LEN - len, "%d: %08x ",
262203c4805SLuis R. Rodriguez 				i, val[i]);
263203c4805SLuis R. Rodriguez 	}
264203c4805SLuis R. Rodriguez 
265991a0987SPavel Roskin 	len += snprintf(buf + len, DMA_BUF_LEN - len, "\n\n");
266991a0987SPavel Roskin 	len += snprintf(buf + len, DMA_BUF_LEN - len,
267203c4805SLuis R. Rodriguez 			"Num QCU: chain_st fsp_ok fsp_st DCU: chain_st\n");
268203c4805SLuis R. Rodriguez 
269203c4805SLuis R. Rodriguez 	for (i = 0; i < ATH9K_NUM_QUEUES; i++, qcuOffset += 4, dcuOffset += 5) {
270203c4805SLuis R. Rodriguez 		if (i == 8) {
271203c4805SLuis R. Rodriguez 			qcuOffset = 0;
272203c4805SLuis R. Rodriguez 			qcuBase++;
273203c4805SLuis R. Rodriguez 		}
274203c4805SLuis R. Rodriguez 
275203c4805SLuis R. Rodriguez 		if (i == 6) {
276203c4805SLuis R. Rodriguez 			dcuOffset = 0;
277203c4805SLuis R. Rodriguez 			dcuBase++;
278203c4805SLuis R. Rodriguez 		}
279203c4805SLuis R. Rodriguez 
280991a0987SPavel Roskin 		len += snprintf(buf + len, DMA_BUF_LEN - len,
281203c4805SLuis R. Rodriguez 			"%2d          %2x      %1x     %2x           %2x\n",
282203c4805SLuis R. Rodriguez 			i, (*qcuBase & (0x7 << qcuOffset)) >> qcuOffset,
283203c4805SLuis R. Rodriguez 			(*qcuBase & (0x8 << qcuOffset)) >> (qcuOffset + 3),
284203c4805SLuis R. Rodriguez 			val[2] & (0x7 << (i * 3)) >> (i * 3),
285203c4805SLuis R. Rodriguez 			(*dcuBase & (0x1f << dcuOffset)) >> dcuOffset);
286203c4805SLuis R. Rodriguez 	}
287203c4805SLuis R. Rodriguez 
288991a0987SPavel Roskin 	len += snprintf(buf + len, DMA_BUF_LEN - len, "\n");
289203c4805SLuis R. Rodriguez 
290991a0987SPavel Roskin 	len += snprintf(buf + len, DMA_BUF_LEN - len,
291203c4805SLuis R. Rodriguez 		"qcu_stitch state:   %2x    qcu_fetch state:        %2x\n",
292203c4805SLuis R. Rodriguez 		(val[3] & 0x003c0000) >> 18, (val[3] & 0x03c00000) >> 22);
293991a0987SPavel Roskin 	len += snprintf(buf + len, DMA_BUF_LEN - len,
294203c4805SLuis R. Rodriguez 		"qcu_complete state: %2x    dcu_complete state:     %2x\n",
295203c4805SLuis R. Rodriguez 		(val[3] & 0x1c000000) >> 26, (val[6] & 0x3));
296991a0987SPavel Roskin 	len += snprintf(buf + len, DMA_BUF_LEN - len,
297203c4805SLuis R. Rodriguez 		"dcu_arb state:      %2x    dcu_fp state:           %2x\n",
298203c4805SLuis R. Rodriguez 		(val[5] & 0x06000000) >> 25, (val[5] & 0x38000000) >> 27);
299991a0987SPavel Roskin 	len += snprintf(buf + len, DMA_BUF_LEN - len,
300203c4805SLuis R. Rodriguez 		"chan_idle_dur:     %3d    chan_idle_dur_valid:     %1d\n",
301203c4805SLuis R. Rodriguez 		(val[6] & 0x000003fc) >> 2, (val[6] & 0x00000400) >> 10);
302991a0987SPavel Roskin 	len += snprintf(buf + len, DMA_BUF_LEN - len,
303203c4805SLuis R. Rodriguez 		"txfifo_valid_0:      %1d    txfifo_valid_1:          %1d\n",
304203c4805SLuis R. Rodriguez 		(val[6] & 0x00000800) >> 11, (val[6] & 0x00001000) >> 12);
305991a0987SPavel Roskin 	len += snprintf(buf + len, DMA_BUF_LEN - len,
306203c4805SLuis R. Rodriguez 		"txfifo_dcu_num_0:   %2d    txfifo_dcu_num_1:       %2d\n",
307203c4805SLuis R. Rodriguez 		(val[6] & 0x0001e000) >> 13, (val[6] & 0x001e0000) >> 17);
308203c4805SLuis R. Rodriguez 
309991a0987SPavel Roskin 	len += snprintf(buf + len, DMA_BUF_LEN - len, "pcu observe: 0x%x\n",
310475a6e4dSLuis R. Rodriguez 			REG_READ_D(ah, AR_OBS_BUS_1));
311991a0987SPavel Roskin 	len += snprintf(buf + len, DMA_BUF_LEN - len,
312475a6e4dSLuis R. Rodriguez 			"AR_CR: 0x%x\n", REG_READ_D(ah, AR_CR));
313203c4805SLuis R. Rodriguez 
3147cf4a2e7SSujith 	ath9k_ps_restore(sc);
3157cf4a2e7SSujith 
3162b87f3aaSDan Carpenter 	if (len > DMA_BUF_LEN)
3172b87f3aaSDan Carpenter 		len = DMA_BUF_LEN;
3182b87f3aaSDan Carpenter 
319991a0987SPavel Roskin 	retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
320991a0987SPavel Roskin 	kfree(buf);
321991a0987SPavel Roskin 	return retval;
322203c4805SLuis R. Rodriguez }
323203c4805SLuis R. Rodriguez 
324203c4805SLuis R. Rodriguez static const struct file_operations fops_dma = {
325203c4805SLuis R. Rodriguez 	.read = read_file_dma,
326203c4805SLuis R. Rodriguez 	.open = ath9k_debugfs_open,
3276038f373SArnd Bergmann 	.owner = THIS_MODULE,
3286038f373SArnd Bergmann 	.llseek = default_llseek,
329203c4805SLuis R. Rodriguez };
330203c4805SLuis R. Rodriguez 
331203c4805SLuis R. Rodriguez 
332203c4805SLuis R. Rodriguez void ath_debug_stat_interrupt(struct ath_softc *sc, enum ath9k_int status)
333203c4805SLuis R. Rodriguez {
334203c4805SLuis R. Rodriguez 	if (status)
335203c4805SLuis R. Rodriguez 		sc->debug.stats.istats.total++;
336a9616f41SLuis R. Rodriguez 	if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) {
337a9616f41SLuis R. Rodriguez 		if (status & ATH9K_INT_RXLP)
338a9616f41SLuis R. Rodriguez 			sc->debug.stats.istats.rxlp++;
339a9616f41SLuis R. Rodriguez 		if (status & ATH9K_INT_RXHP)
340a9616f41SLuis R. Rodriguez 			sc->debug.stats.istats.rxhp++;
34108578b8fSLuis R. Rodriguez 		if (status & ATH9K_INT_BB_WATCHDOG)
34208578b8fSLuis R. Rodriguez 			sc->debug.stats.istats.bb_watchdog++;
343a9616f41SLuis R. Rodriguez 	} else {
344203c4805SLuis R. Rodriguez 		if (status & ATH9K_INT_RX)
345203c4805SLuis R. Rodriguez 			sc->debug.stats.istats.rxok++;
346a9616f41SLuis R. Rodriguez 	}
347203c4805SLuis R. Rodriguez 	if (status & ATH9K_INT_RXEOL)
348203c4805SLuis R. Rodriguez 		sc->debug.stats.istats.rxeol++;
349203c4805SLuis R. Rodriguez 	if (status & ATH9K_INT_RXORN)
350203c4805SLuis R. Rodriguez 		sc->debug.stats.istats.rxorn++;
351203c4805SLuis R. Rodriguez 	if (status & ATH9K_INT_TX)
352203c4805SLuis R. Rodriguez 		sc->debug.stats.istats.txok++;
353203c4805SLuis R. Rodriguez 	if (status & ATH9K_INT_TXURN)
354203c4805SLuis R. Rodriguez 		sc->debug.stats.istats.txurn++;
355203c4805SLuis R. Rodriguez 	if (status & ATH9K_INT_MIB)
356203c4805SLuis R. Rodriguez 		sc->debug.stats.istats.mib++;
357203c4805SLuis R. Rodriguez 	if (status & ATH9K_INT_RXPHY)
358203c4805SLuis R. Rodriguez 		sc->debug.stats.istats.rxphyerr++;
359203c4805SLuis R. Rodriguez 	if (status & ATH9K_INT_RXKCM)
360203c4805SLuis R. Rodriguez 		sc->debug.stats.istats.rx_keycache_miss++;
361203c4805SLuis R. Rodriguez 	if (status & ATH9K_INT_SWBA)
362203c4805SLuis R. Rodriguez 		sc->debug.stats.istats.swba++;
363203c4805SLuis R. Rodriguez 	if (status & ATH9K_INT_BMISS)
364203c4805SLuis R. Rodriguez 		sc->debug.stats.istats.bmiss++;
365203c4805SLuis R. Rodriguez 	if (status & ATH9K_INT_BNR)
366203c4805SLuis R. Rodriguez 		sc->debug.stats.istats.bnr++;
367203c4805SLuis R. Rodriguez 	if (status & ATH9K_INT_CST)
368203c4805SLuis R. Rodriguez 		sc->debug.stats.istats.cst++;
369203c4805SLuis R. Rodriguez 	if (status & ATH9K_INT_GTT)
370203c4805SLuis R. Rodriguez 		sc->debug.stats.istats.gtt++;
371203c4805SLuis R. Rodriguez 	if (status & ATH9K_INT_TIM)
372203c4805SLuis R. Rodriguez 		sc->debug.stats.istats.tim++;
373203c4805SLuis R. Rodriguez 	if (status & ATH9K_INT_CABEND)
374203c4805SLuis R. Rodriguez 		sc->debug.stats.istats.cabend++;
375203c4805SLuis R. Rodriguez 	if (status & ATH9K_INT_DTIMSYNC)
376203c4805SLuis R. Rodriguez 		sc->debug.stats.istats.dtimsync++;
377203c4805SLuis R. Rodriguez 	if (status & ATH9K_INT_DTIM)
378203c4805SLuis R. Rodriguez 		sc->debug.stats.istats.dtim++;
3796dde1aabSMohammed Shafi Shajakhan 	if (status & ATH9K_INT_TSFOOR)
3806dde1aabSMohammed Shafi Shajakhan 		sc->debug.stats.istats.tsfoor++;
381203c4805SLuis R. Rodriguez }
382203c4805SLuis R. Rodriguez 
383203c4805SLuis R. Rodriguez static ssize_t read_file_interrupt(struct file *file, char __user *user_buf,
384203c4805SLuis R. Rodriguez 				   size_t count, loff_t *ppos)
385203c4805SLuis R. Rodriguez {
386203c4805SLuis R. Rodriguez 	struct ath_softc *sc = file->private_data;
387203c4805SLuis R. Rodriguez 	char buf[512];
388203c4805SLuis R. Rodriguez 	unsigned int len = 0;
389203c4805SLuis R. Rodriguez 
390a9616f41SLuis R. Rodriguez 	if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) {
391a9616f41SLuis R. Rodriguez 		len += snprintf(buf + len, sizeof(buf) - len,
392a9616f41SLuis R. Rodriguez 			"%8s: %10u\n", "RXLP", sc->debug.stats.istats.rxlp);
393a9616f41SLuis R. Rodriguez 		len += snprintf(buf + len, sizeof(buf) - len,
394a9616f41SLuis R. Rodriguez 			"%8s: %10u\n", "RXHP", sc->debug.stats.istats.rxhp);
39508578b8fSLuis R. Rodriguez 		len += snprintf(buf + len, sizeof(buf) - len,
39608578b8fSLuis R. Rodriguez 			"%8s: %10u\n", "WATCHDOG",
39708578b8fSLuis R. Rodriguez 			sc->debug.stats.istats.bb_watchdog);
398a9616f41SLuis R. Rodriguez 	} else {
399203c4805SLuis R. Rodriguez 		len += snprintf(buf + len, sizeof(buf) - len,
400203c4805SLuis R. Rodriguez 			"%8s: %10u\n", "RX", sc->debug.stats.istats.rxok);
401a9616f41SLuis R. Rodriguez 	}
402203c4805SLuis R. Rodriguez 	len += snprintf(buf + len, sizeof(buf) - len,
403203c4805SLuis R. Rodriguez 		"%8s: %10u\n", "RXEOL", sc->debug.stats.istats.rxeol);
404203c4805SLuis R. Rodriguez 	len += snprintf(buf + len, sizeof(buf) - len,
405203c4805SLuis R. Rodriguez 		"%8s: %10u\n", "RXORN", sc->debug.stats.istats.rxorn);
406203c4805SLuis R. Rodriguez 	len += snprintf(buf + len, sizeof(buf) - len,
407203c4805SLuis R. Rodriguez 		"%8s: %10u\n", "TX", sc->debug.stats.istats.txok);
408203c4805SLuis R. Rodriguez 	len += snprintf(buf + len, sizeof(buf) - len,
409203c4805SLuis R. Rodriguez 		"%8s: %10u\n", "TXURN", sc->debug.stats.istats.txurn);
410203c4805SLuis R. Rodriguez 	len += snprintf(buf + len, sizeof(buf) - len,
411203c4805SLuis R. Rodriguez 		"%8s: %10u\n", "MIB", sc->debug.stats.istats.mib);
412203c4805SLuis R. Rodriguez 	len += snprintf(buf + len, sizeof(buf) - len,
413203c4805SLuis R. Rodriguez 		"%8s: %10u\n", "RXPHY", sc->debug.stats.istats.rxphyerr);
414203c4805SLuis R. Rodriguez 	len += snprintf(buf + len, sizeof(buf) - len,
415203c4805SLuis R. Rodriguez 		"%8s: %10u\n", "RXKCM", sc->debug.stats.istats.rx_keycache_miss);
416203c4805SLuis R. Rodriguez 	len += snprintf(buf + len, sizeof(buf) - len,
417203c4805SLuis R. Rodriguez 		"%8s: %10u\n", "SWBA", sc->debug.stats.istats.swba);
418203c4805SLuis R. Rodriguez 	len += snprintf(buf + len, sizeof(buf) - len,
419203c4805SLuis R. Rodriguez 		"%8s: %10u\n", "BMISS", sc->debug.stats.istats.bmiss);
420203c4805SLuis R. Rodriguez 	len += snprintf(buf + len, sizeof(buf) - len,
421203c4805SLuis R. Rodriguez 		"%8s: %10u\n", "BNR", sc->debug.stats.istats.bnr);
422203c4805SLuis R. Rodriguez 	len += snprintf(buf + len, sizeof(buf) - len,
423203c4805SLuis R. Rodriguez 		"%8s: %10u\n", "CST", sc->debug.stats.istats.cst);
424203c4805SLuis R. Rodriguez 	len += snprintf(buf + len, sizeof(buf) - len,
425203c4805SLuis R. Rodriguez 		"%8s: %10u\n", "GTT", sc->debug.stats.istats.gtt);
426203c4805SLuis R. Rodriguez 	len += snprintf(buf + len, sizeof(buf) - len,
427203c4805SLuis R. Rodriguez 		"%8s: %10u\n", "TIM", sc->debug.stats.istats.tim);
428203c4805SLuis R. Rodriguez 	len += snprintf(buf + len, sizeof(buf) - len,
429203c4805SLuis R. Rodriguez 		"%8s: %10u\n", "CABEND", sc->debug.stats.istats.cabend);
430203c4805SLuis R. Rodriguez 	len += snprintf(buf + len, sizeof(buf) - len,
431203c4805SLuis R. Rodriguez 		"%8s: %10u\n", "DTIMSYNC", sc->debug.stats.istats.dtimsync);
432203c4805SLuis R. Rodriguez 	len += snprintf(buf + len, sizeof(buf) - len,
433203c4805SLuis R. Rodriguez 		"%8s: %10u\n", "DTIM", sc->debug.stats.istats.dtim);
434203c4805SLuis R. Rodriguez 	len += snprintf(buf + len, sizeof(buf) - len,
4356dde1aabSMohammed Shafi Shajakhan 		"%8s: %10u\n", "TSFOOR", sc->debug.stats.istats.tsfoor);
4366dde1aabSMohammed Shafi Shajakhan 	len += snprintf(buf + len, sizeof(buf) - len,
437203c4805SLuis R. Rodriguez 		"%8s: %10u\n", "TOTAL", sc->debug.stats.istats.total);
438203c4805SLuis R. Rodriguez 
4396dde1aabSMohammed Shafi Shajakhan 
4402b87f3aaSDan Carpenter 	if (len > sizeof(buf))
4412b87f3aaSDan Carpenter 		len = sizeof(buf);
4422b87f3aaSDan Carpenter 
443203c4805SLuis R. Rodriguez 	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
444203c4805SLuis R. Rodriguez }
445203c4805SLuis R. Rodriguez 
446203c4805SLuis R. Rodriguez static const struct file_operations fops_interrupt = {
447203c4805SLuis R. Rodriguez 	.read = read_file_interrupt,
448203c4805SLuis R. Rodriguez 	.open = ath9k_debugfs_open,
4496038f373SArnd Bergmann 	.owner = THIS_MODULE,
4506038f373SArnd Bergmann 	.llseek = default_llseek,
451203c4805SLuis R. Rodriguez };
452203c4805SLuis R. Rodriguez 
4534e6975f7SBen Greear static const char *channel_type_str(enum nl80211_channel_type t)
4544e6975f7SBen Greear {
4554e6975f7SBen Greear 	switch (t) {
4564e6975f7SBen Greear 	case NL80211_CHAN_NO_HT:
4574e6975f7SBen Greear 		return "no ht";
4584e6975f7SBen Greear 	case NL80211_CHAN_HT20:
4594e6975f7SBen Greear 		return "ht20";
4604e6975f7SBen Greear 	case NL80211_CHAN_HT40MINUS:
4614e6975f7SBen Greear 		return "ht40-";
4624e6975f7SBen Greear 	case NL80211_CHAN_HT40PLUS:
4634e6975f7SBen Greear 		return "ht40+";
4644e6975f7SBen Greear 	default:
4654e6975f7SBen Greear 		return "???";
4664e6975f7SBen Greear 	}
4674e6975f7SBen Greear }
4684e6975f7SBen Greear 
469203c4805SLuis R. Rodriguez static ssize_t read_file_wiphy(struct file *file, char __user *user_buf,
470203c4805SLuis R. Rodriguez 			       size_t count, loff_t *ppos)
471203c4805SLuis R. Rodriguez {
472203c4805SLuis R. Rodriguez 	struct ath_softc *sc = file->private_data;
47334302397SFelix Fietkau 	struct ieee80211_channel *chan = sc->hw->conf.channel;
4744e6975f7SBen Greear 	struct ieee80211_conf *conf = &(sc->hw->conf);
475203c4805SLuis R. Rodriguez 	char buf[512];
476203c4805SLuis R. Rodriguez 	unsigned int len = 0;
477203c4805SLuis R. Rodriguez 	u8 addr[ETH_ALEN];
47839057512SBen Greear 	u32 tmp;
479203c4805SLuis R. Rodriguez 
480203c4805SLuis R. Rodriguez 	len += snprintf(buf + len, sizeof(buf) - len,
4814e6975f7SBen Greear 			"%s (chan=%d  center-freq: %d MHz  channel-type: %d (%s))\n",
48234302397SFelix Fietkau 			wiphy_name(sc->hw->wiphy),
4838e0167a4SMohammed Shafi Shajakhan 			ieee80211_frequency_to_channel(chan->center_freq),
4844e6975f7SBen Greear 			chan->center_freq,
4854e6975f7SBen Greear 			conf->channel_type,
4864e6975f7SBen Greear 			channel_type_str(conf->channel_type));
487203c4805SLuis R. Rodriguez 
488c6e38c06SMohammed Shafi Shajakhan 	ath9k_ps_wakeup(sc);
489475a6e4dSLuis R. Rodriguez 	put_unaligned_le32(REG_READ_D(sc->sc_ah, AR_STA_ID0), addr);
490475a6e4dSLuis R. Rodriguez 	put_unaligned_le16(REG_READ_D(sc->sc_ah, AR_STA_ID1) & 0xffff, addr + 4);
491203c4805SLuis R. Rodriguez 	len += snprintf(buf + len, sizeof(buf) - len,
492203c4805SLuis R. Rodriguez 			"addr: %pM\n", addr);
493475a6e4dSLuis R. Rodriguez 	put_unaligned_le32(REG_READ_D(sc->sc_ah, AR_BSSMSKL), addr);
494475a6e4dSLuis R. Rodriguez 	put_unaligned_le16(REG_READ_D(sc->sc_ah, AR_BSSMSKU) & 0xffff, addr + 4);
495203c4805SLuis R. Rodriguez 	len += snprintf(buf + len, sizeof(buf) - len,
496203c4805SLuis R. Rodriguez 			"addrmask: %pM\n", addr);
49739057512SBen Greear 	tmp = ath9k_hw_getrxfilter(sc->sc_ah);
49879d2b157SRajkumar Manoharan 	ath9k_ps_restore(sc);
49939057512SBen Greear 	len += snprintf(buf + len, sizeof(buf) - len,
50039057512SBen Greear 			"rfilt: 0x%x", tmp);
50139057512SBen Greear 	if (tmp & ATH9K_RX_FILTER_UCAST)
50239057512SBen Greear 		len += snprintf(buf + len, sizeof(buf) - len, " UCAST");
50339057512SBen Greear 	if (tmp & ATH9K_RX_FILTER_MCAST)
50439057512SBen Greear 		len += snprintf(buf + len, sizeof(buf) - len, " MCAST");
50539057512SBen Greear 	if (tmp & ATH9K_RX_FILTER_BCAST)
50639057512SBen Greear 		len += snprintf(buf + len, sizeof(buf) - len, " BCAST");
50739057512SBen Greear 	if (tmp & ATH9K_RX_FILTER_CONTROL)
50839057512SBen Greear 		len += snprintf(buf + len, sizeof(buf) - len, " CONTROL");
50939057512SBen Greear 	if (tmp & ATH9K_RX_FILTER_BEACON)
51039057512SBen Greear 		len += snprintf(buf + len, sizeof(buf) - len, " BEACON");
51139057512SBen Greear 	if (tmp & ATH9K_RX_FILTER_PROM)
51239057512SBen Greear 		len += snprintf(buf + len, sizeof(buf) - len, " PROM");
51339057512SBen Greear 	if (tmp & ATH9K_RX_FILTER_PROBEREQ)
51439057512SBen Greear 		len += snprintf(buf + len, sizeof(buf) - len, " PROBEREQ");
51539057512SBen Greear 	if (tmp & ATH9K_RX_FILTER_PHYERR)
51639057512SBen Greear 		len += snprintf(buf + len, sizeof(buf) - len, " PHYERR");
51739057512SBen Greear 	if (tmp & ATH9K_RX_FILTER_MYBEACON)
51839057512SBen Greear 		len += snprintf(buf + len, sizeof(buf) - len, " MYBEACON");
51939057512SBen Greear 	if (tmp & ATH9K_RX_FILTER_COMP_BAR)
52039057512SBen Greear 		len += snprintf(buf + len, sizeof(buf) - len, " COMP_BAR");
52139057512SBen Greear 	if (tmp & ATH9K_RX_FILTER_PSPOLL)
52239057512SBen Greear 		len += snprintf(buf + len, sizeof(buf) - len, " PSPOLL");
52339057512SBen Greear 	if (tmp & ATH9K_RX_FILTER_PHYRADAR)
52439057512SBen Greear 		len += snprintf(buf + len, sizeof(buf) - len, " PHYRADAR");
52539057512SBen Greear 	if (tmp & ATH9K_RX_FILTER_MCAST_BCAST_ALL)
52639057512SBen Greear 		len += snprintf(buf + len, sizeof(buf) - len, " MCAST_BCAST_ALL\n");
52739057512SBen Greear 	else
52839057512SBen Greear 		len += snprintf(buf + len, sizeof(buf) - len, "\n");
529203c4805SLuis R. Rodriguez 
5302b87f3aaSDan Carpenter 	if (len > sizeof(buf))
5312b87f3aaSDan Carpenter 		len = sizeof(buf);
5322b87f3aaSDan Carpenter 
533203c4805SLuis R. Rodriguez 	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
534203c4805SLuis R. Rodriguez }
535203c4805SLuis R. Rodriguez 
536203c4805SLuis R. Rodriguez static const struct file_operations fops_wiphy = {
537203c4805SLuis R. Rodriguez 	.read = read_file_wiphy,
538203c4805SLuis R. Rodriguez 	.open = ath9k_debugfs_open,
5396038f373SArnd Bergmann 	.owner = THIS_MODULE,
5406038f373SArnd Bergmann 	.llseek = default_llseek,
541203c4805SLuis R. Rodriguez };
542203c4805SLuis R. Rodriguez 
5435bec3e5aSFelix Fietkau #define PR_QNUM(_n) sc->tx.txq_map[_n]->axq_qnum
544fec247c0SSujith #define PR(str, elem)							\
545fec247c0SSujith 	do {								\
546fec247c0SSujith 		len += snprintf(buf + len, size - len,			\
547fec247c0SSujith 				"%s%13u%11u%10u%10u\n", str,		\
5485bec3e5aSFelix Fietkau 		sc->debug.stats.txstats[PR_QNUM(WME_AC_BE)].elem, \
5495bec3e5aSFelix Fietkau 		sc->debug.stats.txstats[PR_QNUM(WME_AC_BK)].elem, \
5505bec3e5aSFelix Fietkau 		sc->debug.stats.txstats[PR_QNUM(WME_AC_VI)].elem, \
5515bec3e5aSFelix Fietkau 		sc->debug.stats.txstats[PR_QNUM(WME_AC_VO)].elem); \
5527f010c93SBen Greear 		if (len >= size)			  \
5537f010c93SBen Greear 			goto done;			  \
554fec247c0SSujith } while(0)
555fec247c0SSujith 
5561f427dd9SBen Greear #define PRX(str, elem)							\
5571f427dd9SBen Greear do {									\
5581f427dd9SBen Greear 	len += snprintf(buf + len, size - len,				\
5591f427dd9SBen Greear 			"%s%13u%11u%10u%10u\n", str,			\
5605bec3e5aSFelix Fietkau 			(unsigned int)(sc->tx.txq_map[WME_AC_BE]->elem),	\
5615bec3e5aSFelix Fietkau 			(unsigned int)(sc->tx.txq_map[WME_AC_BK]->elem),	\
5625bec3e5aSFelix Fietkau 			(unsigned int)(sc->tx.txq_map[WME_AC_VI]->elem),	\
5635bec3e5aSFelix Fietkau 			(unsigned int)(sc->tx.txq_map[WME_AC_VO]->elem));	\
5647f010c93SBen Greear 	if (len >= size)						\
5657f010c93SBen Greear 		goto done;						\
5661f427dd9SBen Greear } while(0)
5671f427dd9SBen Greear 
5682dac4fb9SBen Greear #define PRQLE(str, elem)						\
5692dac4fb9SBen Greear do {									\
5702dac4fb9SBen Greear 	len += snprintf(buf + len, size - len,				\
5712dac4fb9SBen Greear 			"%s%13i%11i%10i%10i\n", str,			\
5725bec3e5aSFelix Fietkau 			list_empty(&sc->tx.txq_map[WME_AC_BE]->elem),	\
5735bec3e5aSFelix Fietkau 			list_empty(&sc->tx.txq_map[WME_AC_BK]->elem),	\
5745bec3e5aSFelix Fietkau 			list_empty(&sc->tx.txq_map[WME_AC_VI]->elem),	\
5755bec3e5aSFelix Fietkau 			list_empty(&sc->tx.txq_map[WME_AC_VO]->elem));	\
5767f010c93SBen Greear 	if (len >= size)						\
5777f010c93SBen Greear 		goto done;						\
5782dac4fb9SBen Greear } while (0)
5792dac4fb9SBen Greear 
580fec247c0SSujith static ssize_t read_file_xmit(struct file *file, char __user *user_buf,
581fec247c0SSujith 			      size_t count, loff_t *ppos)
582fec247c0SSujith {
583fec247c0SSujith 	struct ath_softc *sc = file->private_data;
584fec247c0SSujith 	char *buf;
5857f010c93SBen Greear 	unsigned int len = 0, size = 8000;
5862dac4fb9SBen Greear 	int i;
587fec247c0SSujith 	ssize_t retval = 0;
5882dac4fb9SBen Greear 	char tmp[32];
589fec247c0SSujith 
590fec247c0SSujith 	buf = kzalloc(size, GFP_KERNEL);
591fec247c0SSujith 	if (buf == NULL)
59204236066SDan Carpenter 		return -ENOMEM;
593fec247c0SSujith 
59460f2d1d5SBen Greear 	len += sprintf(buf, "Num-Tx-Queues: %i  tx-queues-setup: 0x%x"
59560f2d1d5SBen Greear 		       " poll-work-seen: %u\n"
5967f010c93SBen Greear 		       "%30s %10s%10s%10s\n\n",
5977f010c93SBen Greear 		       ATH9K_NUM_TX_QUEUES, sc->tx.txqsetup,
59860f2d1d5SBen Greear 		       sc->tx_complete_poll_work_seen,
5997f010c93SBen Greear 		       "BE", "BK", "VI", "VO");
600fec247c0SSujith 
601fec247c0SSujith 	PR("MPDUs Queued:    ", queued);
602fec247c0SSujith 	PR("MPDUs Completed: ", completed);
603fec247c0SSujith 	PR("Aggregates:      ", a_aggr);
604bda8addaSBen Greear 	PR("AMPDUs Queued HW:", a_queued_hw);
605bda8addaSBen Greear 	PR("AMPDUs Queued SW:", a_queued_sw);
606fec247c0SSujith 	PR("AMPDUs Completed:", a_completed);
607fec247c0SSujith 	PR("AMPDUs Retried:  ", a_retries);
608fec247c0SSujith 	PR("AMPDUs XRetried: ", a_xretries);
609fec247c0SSujith 	PR("FIFO Underrun:   ", fifo_underrun);
610fec247c0SSujith 	PR("TXOP Exceeded:   ", xtxop);
611fec247c0SSujith 	PR("TXTIMER Expiry:  ", timer_exp);
612fec247c0SSujith 	PR("DESC CFG Error:  ", desc_cfg_err);
613fec247c0SSujith 	PR("DATA Underrun:   ", data_underrun);
614fec247c0SSujith 	PR("DELIM Underrun:  ", delim_underrun);
61599c15bf5SBen Greear 	PR("TX-Pkts-All:     ", tx_pkts_all);
61699c15bf5SBen Greear 	PR("TX-Bytes-All:    ", tx_bytes_all);
6172dac4fb9SBen Greear 	PR("hw-put-tx-buf:   ", puttxbuf);
6182dac4fb9SBen Greear 	PR("hw-tx-start:     ", txstart);
6192dac4fb9SBen Greear 	PR("hw-tx-proc-desc: ", txprocdesc);
6207f010c93SBen Greear 	len += snprintf(buf + len, size - len,
6217f010c93SBen Greear 			"%s%11p%11p%10p%10p\n", "txq-memory-address:",
622db7889cdSBen Greear 			sc->tx.txq_map[WME_AC_BE],
623db7889cdSBen Greear 			sc->tx.txq_map[WME_AC_BK],
624db7889cdSBen Greear 			sc->tx.txq_map[WME_AC_VI],
625db7889cdSBen Greear 			sc->tx.txq_map[WME_AC_VO]);
6267f010c93SBen Greear 	if (len >= size)
6277f010c93SBen Greear 		goto done;
628fec247c0SSujith 
6291f427dd9SBen Greear 	PRX("axq-qnum:        ", axq_qnum);
6301f427dd9SBen Greear 	PRX("axq-depth:       ", axq_depth);
6312dac4fb9SBen Greear 	PRX("axq-ampdu_depth: ", axq_ampdu_depth);
6321f427dd9SBen Greear 	PRX("axq-stopped      ", stopped);
6331f427dd9SBen Greear 	PRX("tx-in-progress   ", axq_tx_inprogress);
6341f427dd9SBen Greear 	PRX("pending-frames   ", pending_frames);
6352dac4fb9SBen Greear 	PRX("txq_headidx:     ", txq_headidx);
6362dac4fb9SBen Greear 	PRX("txq_tailidx:     ", txq_headidx);
6371f427dd9SBen Greear 
6382dac4fb9SBen Greear 	PRQLE("axq_q empty:       ", axq_q);
6392dac4fb9SBen Greear 	PRQLE("axq_acq empty:     ", axq_acq);
6402dac4fb9SBen Greear 	for (i = 0; i < ATH_TXFIFO_DEPTH; i++) {
6412dac4fb9SBen Greear 		snprintf(tmp, sizeof(tmp) - 1, "txq_fifo[%i] empty: ", i);
6422dac4fb9SBen Greear 		PRQLE(tmp, txq_fifo[i]);
6432dac4fb9SBen Greear 	}
6447f010c93SBen Greear 
64571e025a5SBen Greear 	/* Print out more detailed queue-info */
64671e025a5SBen Greear 	for (i = 0; i <= WME_AC_BK; i++) {
64771e025a5SBen Greear 		struct ath_txq *txq = &(sc->tx.txq[i]);
64871e025a5SBen Greear 		struct ath_atx_ac *ac;
64971e025a5SBen Greear 		struct ath_atx_tid *tid;
65071e025a5SBen Greear 		if (len >= size)
65171e025a5SBen Greear 			goto done;
65271e025a5SBen Greear 		spin_lock_bh(&txq->axq_lock);
65371e025a5SBen Greear 		if (!list_empty(&txq->axq_acq)) {
65471e025a5SBen Greear 			ac = list_first_entry(&txq->axq_acq, struct ath_atx_ac,
65571e025a5SBen Greear 					      list);
65671e025a5SBen Greear 			len += snprintf(buf + len, size - len,
65771e025a5SBen Greear 					"txq[%i] first-ac: %p sched: %i\n",
65871e025a5SBen Greear 					i, ac, ac->sched);
65971e025a5SBen Greear 			if (list_empty(&ac->tid_q) || (len >= size))
66071e025a5SBen Greear 				goto done_for;
66171e025a5SBen Greear 			tid = list_first_entry(&ac->tid_q, struct ath_atx_tid,
66271e025a5SBen Greear 					       list);
66371e025a5SBen Greear 			len += snprintf(buf + len, size - len,
66471e025a5SBen Greear 					" first-tid: %p sched: %i paused: %i\n",
66571e025a5SBen Greear 					tid, tid->sched, tid->paused);
66671e025a5SBen Greear 		}
66771e025a5SBen Greear 	done_for:
66871e025a5SBen Greear 		spin_unlock_bh(&txq->axq_lock);
66971e025a5SBen Greear 	}
67071e025a5SBen Greear 
6717f010c93SBen Greear done:
6727f010c93SBen Greear 	if (len > size)
6737f010c93SBen Greear 		len = size;
6747f010c93SBen Greear 
6757f010c93SBen Greear 	retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
6767f010c93SBen Greear 	kfree(buf);
6777f010c93SBen Greear 
6787f010c93SBen Greear 	return retval;
6797f010c93SBen Greear }
6807f010c93SBen Greear 
6817f010c93SBen Greear static ssize_t read_file_stations(struct file *file, char __user *user_buf,
6827f010c93SBen Greear 				  size_t count, loff_t *ppos)
6837f010c93SBen Greear {
6847f010c93SBen Greear 	struct ath_softc *sc = file->private_data;
6857f010c93SBen Greear 	char *buf;
6867f010c93SBen Greear 	unsigned int len = 0, size = 64000;
6877f010c93SBen Greear 	struct ath_node *an = NULL;
6887f010c93SBen Greear 	ssize_t retval = 0;
6897f010c93SBen Greear 	int q;
6907f010c93SBen Greear 
6917f010c93SBen Greear 	buf = kzalloc(size, GFP_KERNEL);
6927f010c93SBen Greear 	if (buf == NULL)
6937f010c93SBen Greear 		return -ENOMEM;
6947f010c93SBen Greear 
6957f010c93SBen Greear 	len += snprintf(buf + len, size - len,
6967f010c93SBen Greear 			"Stations:\n"
6977f010c93SBen Greear 			" tid: addr sched paused buf_q-empty an ac\n"
6987f010c93SBen Greear 			" ac: addr sched tid_q-empty txq\n");
6997f010c93SBen Greear 
7007f010c93SBen Greear 	spin_lock(&sc->nodes_lock);
7017f010c93SBen Greear 	list_for_each_entry(an, &sc->nodes, list) {
7027f010c93SBen Greear 		len += snprintf(buf + len, size - len,
7037f010c93SBen Greear 				"%pM\n", an->sta->addr);
7047f010c93SBen Greear 		if (len >= size)
7057f010c93SBen Greear 			goto done;
7067f010c93SBen Greear 
7077f010c93SBen Greear 		for (q = 0; q < WME_NUM_TID; q++) {
7087f010c93SBen Greear 			struct ath_atx_tid *tid = &(an->tid[q]);
7097f010c93SBen Greear 			len += snprintf(buf + len, size - len,
7107f010c93SBen Greear 					" tid: %p %s %s %i %p %p\n",
7117f010c93SBen Greear 					tid, tid->sched ? "sched" : "idle",
7127f010c93SBen Greear 					tid->paused ? "paused" : "running",
7137f010c93SBen Greear 					list_empty(&tid->buf_q),
7147f010c93SBen Greear 					tid->an, tid->ac);
7157f010c93SBen Greear 			if (len >= size)
7167f010c93SBen Greear 				goto done;
7177f010c93SBen Greear 		}
7187f010c93SBen Greear 
7197f010c93SBen Greear 		for (q = 0; q < WME_NUM_AC; q++) {
7207f010c93SBen Greear 			struct ath_atx_ac *ac = &(an->ac[q]);
7217f010c93SBen Greear 			len += snprintf(buf + len, size - len,
7227f010c93SBen Greear 					" ac: %p %s %i %p\n",
7237f010c93SBen Greear 					ac, ac->sched ? "sched" : "idle",
7247f010c93SBen Greear 					list_empty(&ac->tid_q), ac->txq);
7257f010c93SBen Greear 			if (len >= size)
7267f010c93SBen Greear 				goto done;
7277f010c93SBen Greear 		}
7287f010c93SBen Greear 	}
7297f010c93SBen Greear 
7307f010c93SBen Greear done:
7317f010c93SBen Greear 	spin_unlock(&sc->nodes_lock);
7322b87f3aaSDan Carpenter 	if (len > size)
7332b87f3aaSDan Carpenter 		len = size;
7342b87f3aaSDan Carpenter 
735fec247c0SSujith 	retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
736fec247c0SSujith 	kfree(buf);
737fec247c0SSujith 
738fec247c0SSujith 	return retval;
739fec247c0SSujith }
740fec247c0SSujith 
74155f6d0ffSBen Greear static ssize_t read_file_misc(struct file *file, char __user *user_buf,
74255f6d0ffSBen Greear 			      size_t count, loff_t *ppos)
74355f6d0ffSBen Greear {
74455f6d0ffSBen Greear 	struct ath_softc *sc = file->private_data;
74555f6d0ffSBen Greear 	struct ath_common *common = ath9k_hw_common(sc->sc_ah);
74655f6d0ffSBen Greear 	struct ath_hw *ah = sc->sc_ah;
74755f6d0ffSBen Greear 	struct ieee80211_hw *hw = sc->hw;
74855f6d0ffSBen Greear 	char *buf;
74955f6d0ffSBen Greear 	unsigned int len = 0, size = 8000;
75055f6d0ffSBen Greear 	ssize_t retval = 0;
75155f6d0ffSBen Greear 	const char *tmp;
75255f6d0ffSBen Greear 	unsigned int reg;
75355f6d0ffSBen Greear 	struct ath9k_vif_iter_data iter_data;
75455f6d0ffSBen Greear 
75555f6d0ffSBen Greear 	ath9k_calculate_iter_data(hw, NULL, &iter_data);
75655f6d0ffSBen Greear 
75755f6d0ffSBen Greear 	buf = kzalloc(size, GFP_KERNEL);
75855f6d0ffSBen Greear 	if (buf == NULL)
75955f6d0ffSBen Greear 		return -ENOMEM;
76055f6d0ffSBen Greear 
76155f6d0ffSBen Greear 	switch (sc->sc_ah->opmode) {
76255f6d0ffSBen Greear 	case  NL80211_IFTYPE_ADHOC:
76355f6d0ffSBen Greear 		tmp = "ADHOC";
76455f6d0ffSBen Greear 		break;
76555f6d0ffSBen Greear 	case  NL80211_IFTYPE_MESH_POINT:
76655f6d0ffSBen Greear 		tmp = "MESH";
76755f6d0ffSBen Greear 		break;
76855f6d0ffSBen Greear 	case  NL80211_IFTYPE_AP:
76955f6d0ffSBen Greear 		tmp = "AP";
77055f6d0ffSBen Greear 		break;
77155f6d0ffSBen Greear 	case  NL80211_IFTYPE_STATION:
77255f6d0ffSBen Greear 		tmp = "STATION";
77355f6d0ffSBen Greear 		break;
77455f6d0ffSBen Greear 	default:
77555f6d0ffSBen Greear 		tmp = "???";
77655f6d0ffSBen Greear 		break;
77755f6d0ffSBen Greear 	}
77855f6d0ffSBen Greear 
77979d2b157SRajkumar Manoharan 	ath9k_ps_wakeup(sc);
78055f6d0ffSBen Greear 	len += snprintf(buf + len, size - len,
78155f6d0ffSBen Greear 			"curbssid: %pM\n"
78255f6d0ffSBen Greear 			"OP-Mode: %s(%i)\n"
78355f6d0ffSBen Greear 			"Beacon-Timer-Register: 0x%x\n",
78455f6d0ffSBen Greear 			common->curbssid,
78555f6d0ffSBen Greear 			tmp, (int)(sc->sc_ah->opmode),
78655f6d0ffSBen Greear 			REG_READ(ah, AR_BEACON_PERIOD));
78755f6d0ffSBen Greear 
78855f6d0ffSBen Greear 	reg = REG_READ(ah, AR_TIMER_MODE);
78979d2b157SRajkumar Manoharan 	ath9k_ps_restore(sc);
79055f6d0ffSBen Greear 	len += snprintf(buf + len, size - len, "Timer-Mode-Register: 0x%x (",
79155f6d0ffSBen Greear 			reg);
79255f6d0ffSBen Greear 	if (reg & AR_TBTT_TIMER_EN)
79355f6d0ffSBen Greear 		len += snprintf(buf + len, size - len, "TBTT ");
79455f6d0ffSBen Greear 	if (reg & AR_DBA_TIMER_EN)
79555f6d0ffSBen Greear 		len += snprintf(buf + len, size - len, "DBA ");
79655f6d0ffSBen Greear 	if (reg & AR_SWBA_TIMER_EN)
79755f6d0ffSBen Greear 		len += snprintf(buf + len, size - len, "SWBA ");
79855f6d0ffSBen Greear 	if (reg & AR_HCF_TIMER_EN)
79955f6d0ffSBen Greear 		len += snprintf(buf + len, size - len, "HCF ");
80055f6d0ffSBen Greear 	if (reg & AR_TIM_TIMER_EN)
80155f6d0ffSBen Greear 		len += snprintf(buf + len, size - len, "TIM ");
80255f6d0ffSBen Greear 	if (reg & AR_DTIM_TIMER_EN)
80355f6d0ffSBen Greear 		len += snprintf(buf + len, size - len, "DTIM ");
80455f6d0ffSBen Greear 	len += snprintf(buf + len, size - len, ")\n");
80555f6d0ffSBen Greear 
80655f6d0ffSBen Greear 	reg = sc->sc_ah->imask;
80755f6d0ffSBen Greear 	len += snprintf(buf + len, size - len, "imask: 0x%x (", reg);
80855f6d0ffSBen Greear 	if (reg & ATH9K_INT_SWBA)
80955f6d0ffSBen Greear 		len += snprintf(buf + len, size - len, "SWBA ");
81055f6d0ffSBen Greear 	if (reg & ATH9K_INT_BMISS)
81155f6d0ffSBen Greear 		len += snprintf(buf + len, size - len, "BMISS ");
81255f6d0ffSBen Greear 	if (reg & ATH9K_INT_CST)
81355f6d0ffSBen Greear 		len += snprintf(buf + len, size - len, "CST ");
81455f6d0ffSBen Greear 	if (reg & ATH9K_INT_RX)
81555f6d0ffSBen Greear 		len += snprintf(buf + len, size - len, "RX ");
81655f6d0ffSBen Greear 	if (reg & ATH9K_INT_RXHP)
81755f6d0ffSBen Greear 		len += snprintf(buf + len, size - len, "RXHP ");
81855f6d0ffSBen Greear 	if (reg & ATH9K_INT_RXLP)
81955f6d0ffSBen Greear 		len += snprintf(buf + len, size - len, "RXLP ");
82055f6d0ffSBen Greear 	if (reg & ATH9K_INT_BB_WATCHDOG)
82155f6d0ffSBen Greear 		len += snprintf(buf + len, size - len, "BB_WATCHDOG ");
82255f6d0ffSBen Greear 	/* there are other IRQs if one wanted to add them. */
82355f6d0ffSBen Greear 	len += snprintf(buf + len, size - len, ")\n");
82455f6d0ffSBen Greear 
82555f6d0ffSBen Greear 	len += snprintf(buf + len, size - len,
82655f6d0ffSBen Greear 			"VIF Counts: AP: %i STA: %i MESH: %i WDS: %i"
82755f6d0ffSBen Greear 			" ADHOC: %i OTHER: %i nvifs: %hi beacon-vifs: %hi\n",
82855f6d0ffSBen Greear 			iter_data.naps, iter_data.nstations, iter_data.nmeshes,
82955f6d0ffSBen Greear 			iter_data.nwds, iter_data.nadhocs, iter_data.nothers,
83055f6d0ffSBen Greear 			sc->nvifs, sc->nbcnvifs);
83155f6d0ffSBen Greear 
83255f6d0ffSBen Greear 	len += snprintf(buf + len, size - len,
83355f6d0ffSBen Greear 			"Calculated-BSSID-Mask: %pM\n",
83455f6d0ffSBen Greear 			iter_data.mask);
83555f6d0ffSBen Greear 
83655f6d0ffSBen Greear 	if (len > size)
83755f6d0ffSBen Greear 		len = size;
83855f6d0ffSBen Greear 
83955f6d0ffSBen Greear 	retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
84055f6d0ffSBen Greear 	kfree(buf);
84155f6d0ffSBen Greear 
84255f6d0ffSBen Greear 	return retval;
84355f6d0ffSBen Greear }
84455f6d0ffSBen Greear 
845066dae93SFelix Fietkau void ath_debug_stat_tx(struct ath_softc *sc, struct ath_buf *bf,
8465bec3e5aSFelix Fietkau 		       struct ath_tx_status *ts, struct ath_txq *txq)
847fec247c0SSujith {
8485bec3e5aSFelix Fietkau 	int qnum = txq->axq_qnum;
849066dae93SFelix Fietkau 
850066dae93SFelix Fietkau 	TX_STAT_INC(qnum, tx_pkts_all);
851066dae93SFelix Fietkau 	sc->debug.stats.txstats[qnum].tx_bytes_all += bf->bf_mpdu->len;
85299c15bf5SBen Greear 
853fec247c0SSujith 	if (bf_isampdu(bf)) {
854fec247c0SSujith 		if (bf_isxretried(bf))
855066dae93SFelix Fietkau 			TX_STAT_INC(qnum, a_xretries);
856fec247c0SSujith 		else
857066dae93SFelix Fietkau 			TX_STAT_INC(qnum, a_completed);
858fec247c0SSujith 	} else {
859066dae93SFelix Fietkau 		TX_STAT_INC(qnum, completed);
860fec247c0SSujith 	}
861fec247c0SSujith 
862db1a052bSFelix Fietkau 	if (ts->ts_status & ATH9K_TXERR_FIFO)
863066dae93SFelix Fietkau 		TX_STAT_INC(qnum, fifo_underrun);
864db1a052bSFelix Fietkau 	if (ts->ts_status & ATH9K_TXERR_XTXOP)
865066dae93SFelix Fietkau 		TX_STAT_INC(qnum, xtxop);
866db1a052bSFelix Fietkau 	if (ts->ts_status & ATH9K_TXERR_TIMER_EXPIRED)
867066dae93SFelix Fietkau 		TX_STAT_INC(qnum, timer_exp);
868db1a052bSFelix Fietkau 	if (ts->ts_flags & ATH9K_TX_DESC_CFG_ERR)
869066dae93SFelix Fietkau 		TX_STAT_INC(qnum, desc_cfg_err);
870db1a052bSFelix Fietkau 	if (ts->ts_flags & ATH9K_TX_DATA_UNDERRUN)
871066dae93SFelix Fietkau 		TX_STAT_INC(qnum, data_underrun);
872db1a052bSFelix Fietkau 	if (ts->ts_flags & ATH9K_TX_DELIM_UNDERRUN)
873066dae93SFelix Fietkau 		TX_STAT_INC(qnum, delim_underrun);
874fec247c0SSujith }
875fec247c0SSujith 
876fec247c0SSujith static const struct file_operations fops_xmit = {
877fec247c0SSujith 	.read = read_file_xmit,
878fec247c0SSujith 	.open = ath9k_debugfs_open,
8796038f373SArnd Bergmann 	.owner = THIS_MODULE,
8806038f373SArnd Bergmann 	.llseek = default_llseek,
881fec247c0SSujith };
882203c4805SLuis R. Rodriguez 
8837f010c93SBen Greear static const struct file_operations fops_stations = {
8847f010c93SBen Greear 	.read = read_file_stations,
8857f010c93SBen Greear 	.open = ath9k_debugfs_open,
8867f010c93SBen Greear 	.owner = THIS_MODULE,
8877f010c93SBen Greear 	.llseek = default_llseek,
8887f010c93SBen Greear };
8897f010c93SBen Greear 
89055f6d0ffSBen Greear static const struct file_operations fops_misc = {
89155f6d0ffSBen Greear 	.read = read_file_misc,
89255f6d0ffSBen Greear 	.open = ath9k_debugfs_open,
89355f6d0ffSBen Greear 	.owner = THIS_MODULE,
89455f6d0ffSBen Greear 	.llseek = default_llseek,
89555f6d0ffSBen Greear };
89655f6d0ffSBen Greear 
8971395d3f0SSujith static ssize_t read_file_recv(struct file *file, char __user *user_buf,
8981395d3f0SSujith 			      size_t count, loff_t *ppos)
8991395d3f0SSujith {
9001395d3f0SSujith #define PHY_ERR(s, p) \
9011395d3f0SSujith 	len += snprintf(buf + len, size - len, "%18s : %10u\n", s, \
9021395d3f0SSujith 			sc->debug.stats.rxstats.phy_err_stats[p]);
9031395d3f0SSujith 
9041395d3f0SSujith 	struct ath_softc *sc = file->private_data;
9051395d3f0SSujith 	char *buf;
9067d755414SSenthil Balasubramanian 	unsigned int len = 0, size = 1400;
9071395d3f0SSujith 	ssize_t retval = 0;
9081395d3f0SSujith 
9091395d3f0SSujith 	buf = kzalloc(size, GFP_KERNEL);
9101395d3f0SSujith 	if (buf == NULL)
91104236066SDan Carpenter 		return -ENOMEM;
9121395d3f0SSujith 
9131395d3f0SSujith 	len += snprintf(buf + len, size - len,
9141395d3f0SSujith 			"%18s : %10u\n", "CRC ERR",
9151395d3f0SSujith 			sc->debug.stats.rxstats.crc_err);
9161395d3f0SSujith 	len += snprintf(buf + len, size - len,
9171395d3f0SSujith 			"%18s : %10u\n", "DECRYPT CRC ERR",
9181395d3f0SSujith 			sc->debug.stats.rxstats.decrypt_crc_err);
9191395d3f0SSujith 	len += snprintf(buf + len, size - len,
9201395d3f0SSujith 			"%18s : %10u\n", "PHY ERR",
9211395d3f0SSujith 			sc->debug.stats.rxstats.phy_err);
9221395d3f0SSujith 	len += snprintf(buf + len, size - len,
9231395d3f0SSujith 			"%18s : %10u\n", "MIC ERR",
9241395d3f0SSujith 			sc->debug.stats.rxstats.mic_err);
9251395d3f0SSujith 	len += snprintf(buf + len, size - len,
9261395d3f0SSujith 			"%18s : %10u\n", "PRE-DELIM CRC ERR",
9271395d3f0SSujith 			sc->debug.stats.rxstats.pre_delim_crc_err);
9281395d3f0SSujith 	len += snprintf(buf + len, size - len,
9291395d3f0SSujith 			"%18s : %10u\n", "POST-DELIM CRC ERR",
9301395d3f0SSujith 			sc->debug.stats.rxstats.post_delim_crc_err);
9311395d3f0SSujith 	len += snprintf(buf + len, size - len,
9321395d3f0SSujith 			"%18s : %10u\n", "DECRYPT BUSY ERR",
9331395d3f0SSujith 			sc->debug.stats.rxstats.decrypt_busy_err);
9341395d3f0SSujith 
9357d755414SSenthil Balasubramanian 	len += snprintf(buf + len, size - len,
9367d755414SSenthil Balasubramanian 			"%18s : %10d\n", "RSSI-CTL0",
9377d755414SSenthil Balasubramanian 			sc->debug.stats.rxstats.rs_rssi_ctl0);
9387d755414SSenthil Balasubramanian 
9397d755414SSenthil Balasubramanian 	len += snprintf(buf + len, size - len,
9407d755414SSenthil Balasubramanian 			"%18s : %10d\n", "RSSI-CTL1",
9417d755414SSenthil Balasubramanian 			sc->debug.stats.rxstats.rs_rssi_ctl1);
9427d755414SSenthil Balasubramanian 
9437d755414SSenthil Balasubramanian 	len += snprintf(buf + len, size - len,
9447d755414SSenthil Balasubramanian 			"%18s : %10d\n", "RSSI-CTL2",
9457d755414SSenthil Balasubramanian 			sc->debug.stats.rxstats.rs_rssi_ctl2);
9467d755414SSenthil Balasubramanian 
9477d755414SSenthil Balasubramanian 	len += snprintf(buf + len, size - len,
9487d755414SSenthil Balasubramanian 			"%18s : %10d\n", "RSSI-EXT0",
9497d755414SSenthil Balasubramanian 			sc->debug.stats.rxstats.rs_rssi_ext0);
9507d755414SSenthil Balasubramanian 
9517d755414SSenthil Balasubramanian 	len += snprintf(buf + len, size - len,
9527d755414SSenthil Balasubramanian 			"%18s : %10d\n", "RSSI-EXT1",
9537d755414SSenthil Balasubramanian 			sc->debug.stats.rxstats.rs_rssi_ext1);
9547d755414SSenthil Balasubramanian 
9557d755414SSenthil Balasubramanian 	len += snprintf(buf + len, size - len,
9567d755414SSenthil Balasubramanian 			"%18s : %10d\n", "RSSI-EXT2",
9577d755414SSenthil Balasubramanian 			sc->debug.stats.rxstats.rs_rssi_ext2);
9587d755414SSenthil Balasubramanian 
9597d755414SSenthil Balasubramanian 	len += snprintf(buf + len, size - len,
9607d755414SSenthil Balasubramanian 			"%18s : %10d\n", "Rx Antenna",
9617d755414SSenthil Balasubramanian 			sc->debug.stats.rxstats.rs_antenna);
9627d755414SSenthil Balasubramanian 
9631395d3f0SSujith 	PHY_ERR("UNDERRUN", ATH9K_PHYERR_UNDERRUN);
9641395d3f0SSujith 	PHY_ERR("TIMING", ATH9K_PHYERR_TIMING);
9651395d3f0SSujith 	PHY_ERR("PARITY", ATH9K_PHYERR_PARITY);
9661395d3f0SSujith 	PHY_ERR("RATE", ATH9K_PHYERR_RATE);
9671395d3f0SSujith 	PHY_ERR("LENGTH", ATH9K_PHYERR_LENGTH);
9681395d3f0SSujith 	PHY_ERR("RADAR", ATH9K_PHYERR_RADAR);
9691395d3f0SSujith 	PHY_ERR("SERVICE", ATH9K_PHYERR_SERVICE);
9701395d3f0SSujith 	PHY_ERR("TOR", ATH9K_PHYERR_TOR);
9711395d3f0SSujith 	PHY_ERR("OFDM-TIMING", ATH9K_PHYERR_OFDM_TIMING);
9721395d3f0SSujith 	PHY_ERR("OFDM-SIGNAL-PARITY", ATH9K_PHYERR_OFDM_SIGNAL_PARITY);
9731395d3f0SSujith 	PHY_ERR("OFDM-RATE", ATH9K_PHYERR_OFDM_RATE_ILLEGAL);
9741395d3f0SSujith 	PHY_ERR("OFDM-LENGTH", ATH9K_PHYERR_OFDM_LENGTH_ILLEGAL);
9751395d3f0SSujith 	PHY_ERR("OFDM-POWER-DROP", ATH9K_PHYERR_OFDM_POWER_DROP);
9761395d3f0SSujith 	PHY_ERR("OFDM-SERVICE", ATH9K_PHYERR_OFDM_SERVICE);
9771395d3f0SSujith 	PHY_ERR("OFDM-RESTART", ATH9K_PHYERR_OFDM_RESTART);
9781395d3f0SSujith 	PHY_ERR("FALSE-RADAR-EXT", ATH9K_PHYERR_FALSE_RADAR_EXT);
9791395d3f0SSujith 	PHY_ERR("CCK-TIMING", ATH9K_PHYERR_CCK_TIMING);
9801395d3f0SSujith 	PHY_ERR("CCK-HEADER-CRC", ATH9K_PHYERR_CCK_HEADER_CRC);
9811395d3f0SSujith 	PHY_ERR("CCK-RATE", ATH9K_PHYERR_CCK_RATE_ILLEGAL);
9821395d3f0SSujith 	PHY_ERR("CCK-SERVICE", ATH9K_PHYERR_CCK_SERVICE);
9831395d3f0SSujith 	PHY_ERR("CCK-RESTART", ATH9K_PHYERR_CCK_RESTART);
9841395d3f0SSujith 	PHY_ERR("CCK-LENGTH", ATH9K_PHYERR_CCK_LENGTH_ILLEGAL);
9851395d3f0SSujith 	PHY_ERR("CCK-POWER-DROP", ATH9K_PHYERR_CCK_POWER_DROP);
9861395d3f0SSujith 	PHY_ERR("HT-CRC", ATH9K_PHYERR_HT_CRC_ERROR);
9871395d3f0SSujith 	PHY_ERR("HT-LENGTH", ATH9K_PHYERR_HT_LENGTH_ILLEGAL);
9881395d3f0SSujith 	PHY_ERR("HT-RATE", ATH9K_PHYERR_HT_RATE_ILLEGAL);
9891395d3f0SSujith 
99099c15bf5SBen Greear 	len += snprintf(buf + len, size - len,
99199c15bf5SBen Greear 			"%18s : %10u\n", "RX-Pkts-All",
99299c15bf5SBen Greear 			sc->debug.stats.rxstats.rx_pkts_all);
99399c15bf5SBen Greear 	len += snprintf(buf + len, size - len,
99499c15bf5SBen Greear 			"%18s : %10u\n", "RX-Bytes-All",
99599c15bf5SBen Greear 			sc->debug.stats.rxstats.rx_bytes_all);
99699c15bf5SBen Greear 
9972b87f3aaSDan Carpenter 	if (len > size)
9982b87f3aaSDan Carpenter 		len = size;
9992b87f3aaSDan Carpenter 
10001395d3f0SSujith 	retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
10011395d3f0SSujith 	kfree(buf);
10021395d3f0SSujith 
10031395d3f0SSujith 	return retval;
10041395d3f0SSujith 
10051395d3f0SSujith #undef PHY_ERR
10061395d3f0SSujith }
10071395d3f0SSujith 
10088e6f5aa2SFelix Fietkau void ath_debug_stat_rx(struct ath_softc *sc, struct ath_rx_status *rs)
10091395d3f0SSujith {
10101395d3f0SSujith #define RX_STAT_INC(c) sc->debug.stats.rxstats.c++
10111395d3f0SSujith #define RX_PHY_ERR_INC(c) sc->debug.stats.rxstats.phy_err_stats[c]++
10121395d3f0SSujith 
10131395d3f0SSujith 	u32 phyerr;
10141395d3f0SSujith 
101599c15bf5SBen Greear 	RX_STAT_INC(rx_pkts_all);
101699c15bf5SBen Greear 	sc->debug.stats.rxstats.rx_bytes_all += rs->rs_datalen;
101799c15bf5SBen Greear 
10188e6f5aa2SFelix Fietkau 	if (rs->rs_status & ATH9K_RXERR_CRC)
10191395d3f0SSujith 		RX_STAT_INC(crc_err);
10208e6f5aa2SFelix Fietkau 	if (rs->rs_status & ATH9K_RXERR_DECRYPT)
10211395d3f0SSujith 		RX_STAT_INC(decrypt_crc_err);
10228e6f5aa2SFelix Fietkau 	if (rs->rs_status & ATH9K_RXERR_MIC)
10231395d3f0SSujith 		RX_STAT_INC(mic_err);
10248e6f5aa2SFelix Fietkau 	if (rs->rs_status & ATH9K_RX_DELIM_CRC_PRE)
10251395d3f0SSujith 		RX_STAT_INC(pre_delim_crc_err);
10268e6f5aa2SFelix Fietkau 	if (rs->rs_status & ATH9K_RX_DELIM_CRC_POST)
10271395d3f0SSujith 		RX_STAT_INC(post_delim_crc_err);
10288e6f5aa2SFelix Fietkau 	if (rs->rs_status & ATH9K_RX_DECRYPT_BUSY)
10291395d3f0SSujith 		RX_STAT_INC(decrypt_busy_err);
10301395d3f0SSujith 
10318e6f5aa2SFelix Fietkau 	if (rs->rs_status & ATH9K_RXERR_PHY) {
10321395d3f0SSujith 		RX_STAT_INC(phy_err);
10338e6f5aa2SFelix Fietkau 		phyerr = rs->rs_phyerr & 0x24;
10341395d3f0SSujith 		RX_PHY_ERR_INC(phyerr);
10351395d3f0SSujith 	}
10361395d3f0SSujith 
10377d755414SSenthil Balasubramanian 	sc->debug.stats.rxstats.rs_rssi_ctl0 = rs->rs_rssi_ctl0;
10387d755414SSenthil Balasubramanian 	sc->debug.stats.rxstats.rs_rssi_ctl1 = rs->rs_rssi_ctl1;
10397d755414SSenthil Balasubramanian 	sc->debug.stats.rxstats.rs_rssi_ctl2 = rs->rs_rssi_ctl2;
10407d755414SSenthil Balasubramanian 
10417d755414SSenthil Balasubramanian 	sc->debug.stats.rxstats.rs_rssi_ext0 = rs->rs_rssi_ext0;
10427d755414SSenthil Balasubramanian 	sc->debug.stats.rxstats.rs_rssi_ext1 = rs->rs_rssi_ext1;
10437d755414SSenthil Balasubramanian 	sc->debug.stats.rxstats.rs_rssi_ext2 = rs->rs_rssi_ext2;
10447d755414SSenthil Balasubramanian 
10457d755414SSenthil Balasubramanian 	sc->debug.stats.rxstats.rs_antenna = rs->rs_antenna;
10467d755414SSenthil Balasubramanian 
10471395d3f0SSujith #undef RX_STAT_INC
10481395d3f0SSujith #undef RX_PHY_ERR_INC
10491395d3f0SSujith }
10501395d3f0SSujith 
10511395d3f0SSujith static const struct file_operations fops_recv = {
10521395d3f0SSujith 	.read = read_file_recv,
10531395d3f0SSujith 	.open = ath9k_debugfs_open,
10546038f373SArnd Bergmann 	.owner = THIS_MODULE,
10556038f373SArnd Bergmann 	.llseek = default_llseek,
10561395d3f0SSujith };
10571395d3f0SSujith 
10589bff0bc4SFelix Fietkau static ssize_t read_file_regidx(struct file *file, char __user *user_buf,
10599bff0bc4SFelix Fietkau                                 size_t count, loff_t *ppos)
10609bff0bc4SFelix Fietkau {
10619bff0bc4SFelix Fietkau 	struct ath_softc *sc = file->private_data;
10629bff0bc4SFelix Fietkau 	char buf[32];
10639bff0bc4SFelix Fietkau 	unsigned int len;
10649bff0bc4SFelix Fietkau 
10652b87f3aaSDan Carpenter 	len = sprintf(buf, "0x%08x\n", sc->debug.regidx);
10669bff0bc4SFelix Fietkau 	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
10679bff0bc4SFelix Fietkau }
10689bff0bc4SFelix Fietkau 
10699bff0bc4SFelix Fietkau static ssize_t write_file_regidx(struct file *file, const char __user *user_buf,
10709bff0bc4SFelix Fietkau 			     size_t count, loff_t *ppos)
10719bff0bc4SFelix Fietkau {
10729bff0bc4SFelix Fietkau 	struct ath_softc *sc = file->private_data;
10739bff0bc4SFelix Fietkau 	unsigned long regidx;
10749bff0bc4SFelix Fietkau 	char buf[32];
10759bff0bc4SFelix Fietkau 	ssize_t len;
10769bff0bc4SFelix Fietkau 
10779bff0bc4SFelix Fietkau 	len = min(count, sizeof(buf) - 1);
10789bff0bc4SFelix Fietkau 	if (copy_from_user(buf, user_buf, len))
107904236066SDan Carpenter 		return -EFAULT;
10809bff0bc4SFelix Fietkau 
10819bff0bc4SFelix Fietkau 	buf[len] = '\0';
10829bff0bc4SFelix Fietkau 	if (strict_strtoul(buf, 0, &regidx))
10839bff0bc4SFelix Fietkau 		return -EINVAL;
10849bff0bc4SFelix Fietkau 
10859bff0bc4SFelix Fietkau 	sc->debug.regidx = regidx;
10869bff0bc4SFelix Fietkau 	return count;
10879bff0bc4SFelix Fietkau }
10889bff0bc4SFelix Fietkau 
10899bff0bc4SFelix Fietkau static const struct file_operations fops_regidx = {
10909bff0bc4SFelix Fietkau 	.read = read_file_regidx,
10919bff0bc4SFelix Fietkau 	.write = write_file_regidx,
10929bff0bc4SFelix Fietkau 	.open = ath9k_debugfs_open,
10936038f373SArnd Bergmann 	.owner = THIS_MODULE,
10946038f373SArnd Bergmann 	.llseek = default_llseek,
10959bff0bc4SFelix Fietkau };
10969bff0bc4SFelix Fietkau 
10979bff0bc4SFelix Fietkau static ssize_t read_file_regval(struct file *file, char __user *user_buf,
10989bff0bc4SFelix Fietkau 			     size_t count, loff_t *ppos)
10999bff0bc4SFelix Fietkau {
11009bff0bc4SFelix Fietkau 	struct ath_softc *sc = file->private_data;
11019bff0bc4SFelix Fietkau 	struct ath_hw *ah = sc->sc_ah;
11029bff0bc4SFelix Fietkau 	char buf[32];
11039bff0bc4SFelix Fietkau 	unsigned int len;
11049bff0bc4SFelix Fietkau 	u32 regval;
11059bff0bc4SFelix Fietkau 
110679d2b157SRajkumar Manoharan 	ath9k_ps_wakeup(sc);
11079bff0bc4SFelix Fietkau 	regval = REG_READ_D(ah, sc->debug.regidx);
110879d2b157SRajkumar Manoharan 	ath9k_ps_restore(sc);
11092b87f3aaSDan Carpenter 	len = sprintf(buf, "0x%08x\n", regval);
11109bff0bc4SFelix Fietkau 	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
11119bff0bc4SFelix Fietkau }
11129bff0bc4SFelix Fietkau 
11139bff0bc4SFelix Fietkau static ssize_t write_file_regval(struct file *file, const char __user *user_buf,
11149bff0bc4SFelix Fietkau 			     size_t count, loff_t *ppos)
11159bff0bc4SFelix Fietkau {
11169bff0bc4SFelix Fietkau 	struct ath_softc *sc = file->private_data;
11179bff0bc4SFelix Fietkau 	struct ath_hw *ah = sc->sc_ah;
11189bff0bc4SFelix Fietkau 	unsigned long regval;
11199bff0bc4SFelix Fietkau 	char buf[32];
11209bff0bc4SFelix Fietkau 	ssize_t len;
11219bff0bc4SFelix Fietkau 
11229bff0bc4SFelix Fietkau 	len = min(count, sizeof(buf) - 1);
11239bff0bc4SFelix Fietkau 	if (copy_from_user(buf, user_buf, len))
112404236066SDan Carpenter 		return -EFAULT;
11259bff0bc4SFelix Fietkau 
11269bff0bc4SFelix Fietkau 	buf[len] = '\0';
11279bff0bc4SFelix Fietkau 	if (strict_strtoul(buf, 0, &regval))
11289bff0bc4SFelix Fietkau 		return -EINVAL;
11299bff0bc4SFelix Fietkau 
113079d2b157SRajkumar Manoharan 	ath9k_ps_wakeup(sc);
11319bff0bc4SFelix Fietkau 	REG_WRITE_D(ah, sc->debug.regidx, regval);
113279d2b157SRajkumar Manoharan 	ath9k_ps_restore(sc);
11339bff0bc4SFelix Fietkau 	return count;
11349bff0bc4SFelix Fietkau }
11359bff0bc4SFelix Fietkau 
11369bff0bc4SFelix Fietkau static const struct file_operations fops_regval = {
11379bff0bc4SFelix Fietkau 	.read = read_file_regval,
11389bff0bc4SFelix Fietkau 	.write = write_file_regval,
11399bff0bc4SFelix Fietkau 	.open = ath9k_debugfs_open,
11406038f373SArnd Bergmann 	.owner = THIS_MODULE,
11416038f373SArnd Bergmann 	.llseek = default_llseek,
11429bff0bc4SFelix Fietkau };
11439bff0bc4SFelix Fietkau 
1144582d0064SVasanthakumar Thiagarajan #define REGDUMP_LINE_SIZE	20
1145582d0064SVasanthakumar Thiagarajan 
1146582d0064SVasanthakumar Thiagarajan static int open_file_regdump(struct inode *inode, struct file *file)
1147582d0064SVasanthakumar Thiagarajan {
1148582d0064SVasanthakumar Thiagarajan 	struct ath_softc *sc = inode->i_private;
1149582d0064SVasanthakumar Thiagarajan 	unsigned int len = 0;
1150582d0064SVasanthakumar Thiagarajan 	u8 *buf;
1151582d0064SVasanthakumar Thiagarajan 	int i;
1152582d0064SVasanthakumar Thiagarajan 	unsigned long num_regs, regdump_len, max_reg_offset;
1153582d0064SVasanthakumar Thiagarajan 
1154582d0064SVasanthakumar Thiagarajan 	max_reg_offset = AR_SREV_9300_20_OR_LATER(sc->sc_ah) ? 0x16bd4 : 0xb500;
1155582d0064SVasanthakumar Thiagarajan 	num_regs = max_reg_offset / 4 + 1;
1156582d0064SVasanthakumar Thiagarajan 	regdump_len = num_regs * REGDUMP_LINE_SIZE + 1;
1157582d0064SVasanthakumar Thiagarajan 	buf = vmalloc(regdump_len);
1158582d0064SVasanthakumar Thiagarajan 	if (!buf)
1159582d0064SVasanthakumar Thiagarajan 		return -ENOMEM;
1160582d0064SVasanthakumar Thiagarajan 
1161582d0064SVasanthakumar Thiagarajan 	ath9k_ps_wakeup(sc);
1162582d0064SVasanthakumar Thiagarajan 	for (i = 0; i < num_regs; i++)
1163582d0064SVasanthakumar Thiagarajan 		len += scnprintf(buf + len, regdump_len - len,
1164582d0064SVasanthakumar Thiagarajan 			"0x%06x 0x%08x\n", i << 2, REG_READ(sc->sc_ah, i << 2));
1165582d0064SVasanthakumar Thiagarajan 	ath9k_ps_restore(sc);
1166582d0064SVasanthakumar Thiagarajan 
1167582d0064SVasanthakumar Thiagarajan 	file->private_data = buf;
1168582d0064SVasanthakumar Thiagarajan 
1169582d0064SVasanthakumar Thiagarajan 	return 0;
1170582d0064SVasanthakumar Thiagarajan }
1171582d0064SVasanthakumar Thiagarajan 
1172582d0064SVasanthakumar Thiagarajan static const struct file_operations fops_regdump = {
1173582d0064SVasanthakumar Thiagarajan 	.open = open_file_regdump,
1174582d0064SVasanthakumar Thiagarajan 	.read = ath9k_debugfs_read_buf,
1175582d0064SVasanthakumar Thiagarajan 	.release = ath9k_debugfs_release_buf,
1176582d0064SVasanthakumar Thiagarajan 	.owner = THIS_MODULE,
1177582d0064SVasanthakumar Thiagarajan 	.llseek = default_llseek,/* read accesses f_pos */
1178582d0064SVasanthakumar Thiagarajan };
1179582d0064SVasanthakumar Thiagarajan 
11804d6b228dSLuis R. Rodriguez int ath9k_init_debug(struct ath_hw *ah)
1181203c4805SLuis R. Rodriguez {
1182bc974f4aSLuis R. Rodriguez 	struct ath_common *common = ath9k_hw_common(ah);
1183bc974f4aSLuis R. Rodriguez 	struct ath_softc *sc = (struct ath_softc *) common->priv;
11844d6b228dSLuis R. Rodriguez 
1185eb272441SBen Greear 	sc->debug.debugfs_phy = debugfs_create_dir("ath9k",
1186eb272441SBen Greear 						   sc->hw->wiphy->debugfsdir);
1187203c4805SLuis R. Rodriguez 	if (!sc->debug.debugfs_phy)
1188c8a72c00SFelix Fietkau 		return -ENOMEM;
1189203c4805SLuis R. Rodriguez 
1190a830df07SFelix Fietkau #ifdef CONFIG_ATH_DEBUG
1191c70cab1aSFelix Fietkau 	debugfs_create_file("debug", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
1192c70cab1aSFelix Fietkau 			    sc, &fops_debug);
1193a830df07SFelix Fietkau #endif
1194c70cab1aSFelix Fietkau 	debugfs_create_file("dma", S_IRUSR, sc->debug.debugfs_phy, sc,
1195c70cab1aSFelix Fietkau 			    &fops_dma);
1196c70cab1aSFelix Fietkau 	debugfs_create_file("interrupt", S_IRUSR, sc->debug.debugfs_phy, sc,
1197c70cab1aSFelix Fietkau 			    &fops_interrupt);
1198c70cab1aSFelix Fietkau 	debugfs_create_file("wiphy", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
1199c70cab1aSFelix Fietkau 			    sc, &fops_wiphy);
1200c70cab1aSFelix Fietkau 	debugfs_create_file("xmit", S_IRUSR, sc->debug.debugfs_phy, sc,
1201c70cab1aSFelix Fietkau 			    &fops_xmit);
1202c70cab1aSFelix Fietkau 	debugfs_create_file("stations", S_IRUSR, sc->debug.debugfs_phy, sc,
1203c70cab1aSFelix Fietkau 			    &fops_stations);
1204c70cab1aSFelix Fietkau 	debugfs_create_file("misc", S_IRUSR, sc->debug.debugfs_phy, sc,
1205c70cab1aSFelix Fietkau 			    &fops_misc);
1206c70cab1aSFelix Fietkau 	debugfs_create_file("recv", S_IRUSR, sc->debug.debugfs_phy, sc,
1207c70cab1aSFelix Fietkau 			    &fops_recv);
1208c70cab1aSFelix Fietkau 	debugfs_create_file("rx_chainmask", S_IRUSR | S_IWUSR,
1209c70cab1aSFelix Fietkau 			    sc->debug.debugfs_phy, sc, &fops_rx_chainmask);
1210c70cab1aSFelix Fietkau 	debugfs_create_file("tx_chainmask", S_IRUSR | S_IWUSR,
1211c70cab1aSFelix Fietkau 			    sc->debug.debugfs_phy, sc, &fops_tx_chainmask);
1212*05c0be2fSMohammed Shafi Shajakhan 	debugfs_create_file("disable_ani", S_IRUSR | S_IWUSR,
1213*05c0be2fSMohammed Shafi Shajakhan 			    sc->debug.debugfs_phy, sc, &fops_disable_ani);
1214c70cab1aSFelix Fietkau 	debugfs_create_file("regidx", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
1215c70cab1aSFelix Fietkau 			    sc, &fops_regidx);
1216c70cab1aSFelix Fietkau 	debugfs_create_file("regval", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
1217c70cab1aSFelix Fietkau 			    sc, &fops_regval);
1218c70cab1aSFelix Fietkau 	debugfs_create_bool("ignore_extcca", S_IRUSR | S_IWUSR,
1219c70cab1aSFelix Fietkau 			    sc->debug.debugfs_phy,
1220c70cab1aSFelix Fietkau 			    &ah->config.cwm_ignore_extcca);
1221c70cab1aSFelix Fietkau 	debugfs_create_file("regdump", S_IRUSR, sc->debug.debugfs_phy, sc,
1222c70cab1aSFelix Fietkau 			    &fops_regdump);
1223582d0064SVasanthakumar Thiagarajan 
1224691680b8SFelix Fietkau 	debugfs_create_u32("gpio_mask", S_IRUSR | S_IWUSR,
1225691680b8SFelix Fietkau 			   sc->debug.debugfs_phy, &sc->sc_ah->gpio_mask);
1226691680b8SFelix Fietkau 
1227691680b8SFelix Fietkau 	debugfs_create_u32("gpio_val", S_IRUSR | S_IWUSR,
1228691680b8SFelix Fietkau 			   sc->debug.debugfs_phy, &sc->sc_ah->gpio_val);
1229691680b8SFelix Fietkau 
12309bff0bc4SFelix Fietkau 	sc->debug.regidx = 0;
1231203c4805SLuis R. Rodriguez 	return 0;
1232203c4805SLuis R. Rodriguez }
1233