2 * Atheros CARL9170 driver
6 * Copyright 2008, Johannes Berg <johannes@sipsolutions.net>
7 * Copyright 2009, 2010, Christian Lamparter <chunkeey@googlemail.com>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; see the file COPYING. If not, see
21 * http://www.gnu.org/licenses/.
23 * This file incorporates work covered by the following copyright and
25 * Copyright (c) 2008-2009 Atheros Communications, Inc.
27 * Permission to use, copy, modify, and/or distribute this software for any
28 * purpose with or without fee is hereby granted, provided that the above
29 * copyright notice and this permission notice appear in all copies.
31 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
32 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
33 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
34 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
35 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
36 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
37 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
40 #include <linux/init.h>
41 #include <linux/slab.h>
42 #include <linux/module.h>
43 #include <linux/seq_file.h>
44 #include <linux/vmalloc.h>
48 #define ADD(buf, off, max, fmt, args...) \
49 off += snprintf(&buf[off], max - off, fmt, ##args);
51 static int carl9170_debugfs_open(struct inode *inode, struct file *file)
53 file->private_data = inode->i_private;
57 struct carl9170_debugfs_fops {
58 unsigned int read_bufsize;
60 char *(*read)(struct ar9170 *ar, char *buf, size_t bufsize,
62 ssize_t (*write)(struct ar9170 *aru, const char *buf, size_t size);
63 const struct file_operations fops;
65 enum carl9170_device_state req_dev_state;
68 static ssize_t carl9170_debugfs_read(struct file *file, char __user *userbuf,
69 size_t count, loff_t *ppos)
71 struct carl9170_debugfs_fops *dfops;
73 char *buf = NULL, *res_buf = NULL;
80 ar = file->private_data;
84 dfops = container_of(file->f_op, struct carl9170_debugfs_fops, fops);
89 if (dfops->read_bufsize) {
90 buf = vmalloc(dfops->read_bufsize);
95 mutex_lock(&ar->mutex);
96 if (!CHK_DEV_STATE(ar, dfops->req_dev_state)) {
102 res_buf = dfops->read(ar, buf, dfops->read_bufsize, &ret);
105 err = simple_read_from_buffer(userbuf, count, ppos,
110 WARN_ON_ONCE(dfops->read_bufsize && (res_buf != buf));
114 mutex_unlock(&ar->mutex);
118 static ssize_t carl9170_debugfs_write(struct file *file,
119 const char __user *userbuf, size_t count, loff_t *ppos)
121 struct carl9170_debugfs_fops *dfops;
129 if (count > PAGE_SIZE)
132 ar = file->private_data;
136 dfops = container_of(file->f_op, struct carl9170_debugfs_fops, fops);
141 buf = vmalloc(count);
145 if (copy_from_user(buf, userbuf, count)) {
150 if (mutex_trylock(&ar->mutex) == 0) {
155 if (!CHK_DEV_STATE(ar, dfops->req_dev_state)) {
160 err = dfops->write(ar, buf, count);
165 mutex_unlock(&ar->mutex);
172 #define __DEBUGFS_DECLARE_FILE(name, _read, _write, _read_bufsize, \
174 static const struct carl9170_debugfs_fops carl_debugfs_##name ##_ops = {\
175 .read_bufsize = _read_bufsize, \
179 .req_dev_state = _dstate, \
181 .open = carl9170_debugfs_open, \
182 .read = carl9170_debugfs_read, \
183 .write = carl9170_debugfs_write, \
184 .owner = THIS_MODULE \
188 #define DEBUGFS_DECLARE_FILE(name, _read, _write, _read_bufsize, _attr) \
189 __DEBUGFS_DECLARE_FILE(name, _read, _write, _read_bufsize, \
190 _attr, CARL9170_STARTED) \
192 #define DEBUGFS_DECLARE_RO_FILE(name, _read_bufsize) \
193 DEBUGFS_DECLARE_FILE(name, carl9170_debugfs_##name ##_read, \
194 NULL, _read_bufsize, S_IRUSR)
196 #define DEBUGFS_DECLARE_WO_FILE(name) \
197 DEBUGFS_DECLARE_FILE(name, NULL, carl9170_debugfs_##name ##_write,\
200 #define DEBUGFS_DECLARE_RW_FILE(name, _read_bufsize) \
201 DEBUGFS_DECLARE_FILE(name, carl9170_debugfs_##name ##_read, \
202 carl9170_debugfs_##name ##_write, \
203 _read_bufsize, S_IRUSR | S_IWUSR)
205 #define __DEBUGFS_DECLARE_RW_FILE(name, _read_bufsize, _dstate) \
206 __DEBUGFS_DECLARE_FILE(name, carl9170_debugfs_##name ##_read, \
207 carl9170_debugfs_##name ##_write, \
208 _read_bufsize, S_IRUSR | S_IWUSR, _dstate)
210 #define DEBUGFS_READONLY_FILE(name, _read_bufsize, fmt, value...) \
211 static char *carl9170_debugfs_ ##name ## _read(struct ar9170 *ar, \
212 char *buf, size_t buf_size,\
215 ADD(buf, *len, buf_size, fmt "\n", ##value); \
218 DEBUGFS_DECLARE_RO_FILE(name, _read_bufsize)
220 static char *carl9170_debugfs_mem_usage_read(struct ar9170 *ar, char *buf,
221 size_t bufsize, ssize_t *len)
223 ADD(buf, *len, bufsize, "jar: [");
225 spin_lock_bh(&ar->mem_lock);
227 *len += bitmap_scnprintf(&buf[*len], bufsize - *len,
228 ar->mem_bitmap, ar->fw.mem_blocks);
230 ADD(buf, *len, bufsize, "]\n");
232 ADD(buf, *len, bufsize, "cookies: used:%3d / total:%3d, allocs:%d\n",
233 bitmap_weight(ar->mem_bitmap, ar->fw.mem_blocks),
234 ar->fw.mem_blocks, atomic_read(&ar->mem_allocs));
236 ADD(buf, *len, bufsize, "memory: free:%3d (%3d KiB) / total:%3d KiB)\n",
237 atomic_read(&ar->mem_free_blocks),
238 (atomic_read(&ar->mem_free_blocks) * ar->fw.mem_block_size) / 1024,
239 (ar->fw.mem_blocks * ar->fw.mem_block_size) / 1024);
241 spin_unlock_bh(&ar->mem_lock);
245 DEBUGFS_DECLARE_RO_FILE(mem_usage, 512);
247 static char *carl9170_debugfs_qos_stat_read(struct ar9170 *ar, char *buf,
248 size_t bufsize, ssize_t *len)
250 ADD(buf, *len, bufsize, "%s QoS AC\n", modparam_noht ? "Hardware" :
253 ADD(buf, *len, bufsize, "[ VO VI "
256 spin_lock_bh(&ar->tx_stats_lock);
257 ADD(buf, *len, bufsize, "[length/limit length/limit "
258 "length/limit length/limit ]\n"
260 " %3d/%3d %3d/%3d ]\n\n",
261 ar->tx_stats[0].len, ar->tx_stats[0].limit,
262 ar->tx_stats[1].len, ar->tx_stats[1].limit,
263 ar->tx_stats[2].len, ar->tx_stats[2].limit,
264 ar->tx_stats[3].len, ar->tx_stats[3].limit);
266 ADD(buf, *len, bufsize, "[ total total "
268 "[%10d %10d %10d %10d ]\n\n",
269 ar->tx_stats[0].count, ar->tx_stats[1].count,
270 ar->tx_stats[2].count, ar->tx_stats[3].count);
272 spin_unlock_bh(&ar->tx_stats_lock);
274 ADD(buf, *len, bufsize, "[ pend/waittx pend/waittx "
275 " pend/waittx pend/waittx]\n"
277 " %3d/%3d %3d/%3d ]\n\n",
278 skb_queue_len(&ar->tx_pending[0]),
279 skb_queue_len(&ar->tx_status[0]),
280 skb_queue_len(&ar->tx_pending[1]),
281 skb_queue_len(&ar->tx_status[1]),
282 skb_queue_len(&ar->tx_pending[2]),
283 skb_queue_len(&ar->tx_status[2]),
284 skb_queue_len(&ar->tx_pending[3]),
285 skb_queue_len(&ar->tx_status[3]));
289 DEBUGFS_DECLARE_RO_FILE(qos_stat, 512);
291 static void carl9170_debugfs_format_frame(struct ar9170 *ar,
292 struct sk_buff *skb, const char *prefix, char *buf,
293 ssize_t *off, ssize_t bufsize)
295 struct _carl9170_tx_superframe *txc = (void *) skb->data;
296 struct ieee80211_tx_info *txinfo = IEEE80211_SKB_CB(skb);
297 struct carl9170_tx_info *arinfo = (void *) txinfo->rate_driver_data;
298 struct ieee80211_hdr *hdr = (void *) txc->frame_data;
300 ADD(buf, *off, bufsize, "%s %p, c:%2x, DA:%pM, sq:%4d, mc:%.4x, "
301 "pc:%.8x, to:%d ms\n", prefix, skb, txc->s.cookie,
302 ieee80211_get_DA(hdr), get_seq_h(hdr),
303 le16_to_cpu(txc->f.mac_control), le32_to_cpu(txc->f.phy_control),
304 jiffies_to_msecs(jiffies - arinfo->timeout));
308 static char *carl9170_debugfs_ampdu_state_read(struct ar9170 *ar, char *buf,
309 size_t bufsize, ssize_t *len)
311 struct carl9170_sta_tid *iter;
317 list_for_each_entry_rcu(iter, &ar->tx_ampdu_list, list) {
319 spin_lock_bh(&iter->lock);
320 ADD(buf, *len, bufsize, "Entry: #%2d TID:%1d, BSN:%4d, "
321 "SNX:%4d, HSN:%4d, BAW:%2d, state:%1d, toggles:%d\n",
322 cnt, iter->tid, iter->bsn, iter->snx, iter->hsn,
323 iter->max, iter->state, iter->counter);
325 ADD(buf, *len, bufsize, "\tWindow: [");
327 *len += bitmap_scnprintf(&buf[*len], bufsize - *len,
328 iter->bitmap, CARL9170_BAW_BITS);
330 #define BM_STR_OFF(offset) \
331 ((CARL9170_BAW_BITS - (offset) - 1) / 4 + \
332 (CARL9170_BAW_BITS - (offset) - 1) / 32 + 1)
334 ADD(buf, *len, bufsize, ",W]\n");
336 offset = BM_STR_OFF(0);
337 ADD(buf, *len, bufsize, "\tBase Seq: %*s\n", offset, "T");
339 offset = BM_STR_OFF(SEQ_DIFF(iter->snx, iter->bsn));
340 ADD(buf, *len, bufsize, "\tNext Seq: %*s\n", offset, "W");
342 offset = BM_STR_OFF(((int)iter->hsn - (int)iter->bsn) %
344 ADD(buf, *len, bufsize, "\tLast Seq: %*s\n", offset, "N");
346 ADD(buf, *len, bufsize, "\tPre-Aggregation reorder buffer: "
347 " currently queued:%d\n", skb_queue_len(&iter->queue));
350 skb_queue_walk(&iter->queue, skb) {
353 snprintf(prefix, sizeof(prefix), "\t\t%3d :", fc);
354 carl9170_debugfs_format_frame(ar, skb, prefix, buf,
359 spin_unlock_bh(&iter->lock);
366 DEBUGFS_DECLARE_RO_FILE(ampdu_state, 8000);
368 static void carl9170_debugfs_queue_dump(struct ar9170 *ar, char *buf,
369 ssize_t *len, size_t bufsize, struct sk_buff_head *queue)
375 spin_lock_bh(&queue->lock);
376 skb_queue_walk(queue, skb) {
377 snprintf(prefix, sizeof(prefix), "%3d :", fc);
378 carl9170_debugfs_format_frame(ar, skb, prefix, buf,
382 spin_unlock_bh(&queue->lock);
385 #define DEBUGFS_QUEUE_DUMP(q, qi) \
386 static char *carl9170_debugfs_##q ##_##qi ##_read(struct ar9170 *ar, \
387 char *buf, size_t bufsize, ssize_t *len) \
389 carl9170_debugfs_queue_dump(ar, buf, len, bufsize, &ar->q[qi]); \
392 DEBUGFS_DECLARE_RO_FILE(q##_##qi, 8000);
394 static char *carl9170_debugfs_sta_psm_read(struct ar9170 *ar, char *buf,
395 size_t bufsize, ssize_t *len)
397 ADD(buf, *len, bufsize, "psm state: %s\n", (ar->ps.off_override ?
398 "FORCE CAM" : (ar->ps.state ? "PSM" : "CAM")));
400 ADD(buf, *len, bufsize, "sleep duration: %d ms.\n", ar->ps.sleep_ms);
401 ADD(buf, *len, bufsize, "last power-state transition: %d ms ago.\n",
402 jiffies_to_msecs(jiffies - ar->ps.last_action));
403 ADD(buf, *len, bufsize, "last CAM->PSM transition: %d ms ago.\n",
404 jiffies_to_msecs(jiffies - ar->ps.last_slept));
408 DEBUGFS_DECLARE_RO_FILE(sta_psm, 160);
410 static char *carl9170_debugfs_tx_stuck_read(struct ar9170 *ar, char *buf,
411 size_t bufsize, ssize_t *len)
415 for (i = 0; i < ar->hw->queues; i++) {
416 ADD(buf, *len, bufsize, "TX queue [%d]: %10d max:%10d ms.\n",
417 i, ieee80211_queue_stopped(ar->hw, i) ?
418 jiffies_to_msecs(jiffies - ar->queue_stop_timeout[i]) : 0,
419 jiffies_to_msecs(ar->max_queue_stop_timeout[i]));
421 ar->max_queue_stop_timeout[i] = 0;
426 DEBUGFS_DECLARE_RO_FILE(tx_stuck, 180);
428 static char *carl9170_debugfs_phy_noise_read(struct ar9170 *ar, char *buf,
429 size_t bufsize, ssize_t *len)
433 err = carl9170_get_noisefloor(ar);
439 ADD(buf, *len, bufsize, "Chain 1: %10d dBm, ext. chan.:%10d dBm\n",
440 ar->noise[1], ar->noise[4]);
441 ADD(buf, *len, bufsize, "Chain 2: %10d dBm, ext. chan.:%10d dBm\n",
442 ar->noise[2], ar->noise[5]);
443 ADD(buf, *len, bufsize, "Combined %10d dBm, ext. chan.:%10d dBm\n",
444 ar->noise[0], ar->noise[3]);
448 DEBUGFS_DECLARE_RO_FILE(phy_noise, 180);
450 static char *carl9170_debugfs_vif_dump_read(struct ar9170 *ar, char *buf,
451 size_t bufsize, ssize_t *len)
453 struct carl9170_vif_info *iter;
456 ADD(buf, *len, bufsize, "registered VIFs:%d \\ %d\n",
457 ar->vifs, ar->fw.vif_num);
459 ADD(buf, *len, bufsize, "VIF bitmap: [");
461 *len += bitmap_scnprintf(&buf[*len], bufsize - *len,
462 &ar->vif_bitmap, ar->fw.vif_num);
464 ADD(buf, *len, bufsize, "]\n");
467 list_for_each_entry_rcu(iter, &ar->vif_list, list) {
468 struct ieee80211_vif *vif = carl9170_get_vif(iter);
469 ADD(buf, *len, bufsize, "\t%d = [%s VIF, id:%d, type:%x "
470 " mac:%pM %s]\n", i, (carl9170_get_main_vif(ar) == vif ?
471 "Master" : " Slave"), iter->id, vif->type, vif->addr,
472 iter->enable_beacon ? "beaconing " : "");
479 DEBUGFS_DECLARE_RO_FILE(vif_dump, 8000);
481 #define UPDATE_COUNTER(ar, name) ({ \
482 u32 __tmp[ARRAY_SIZE(name##_regs)]; \
483 unsigned int __i, __err = -ENODEV; \
485 for (__i = 0; __i < ARRAY_SIZE(name##_regs); __i++) { \
486 __tmp[__i] = name##_regs[__i].reg; \
487 ar->debug.stats.name##_counter[__i] = 0; \
490 if (IS_STARTED(ar)) \
491 __err = carl9170_read_mreg(ar, ARRAY_SIZE(name##_regs), \
492 __tmp, ar->debug.stats.name##_counter); \
495 #define TALLY_SUM_UP(ar, name) do { \
498 for (__i = 0; __i < ARRAY_SIZE(name##_regs); __i++) { \
499 ar->debug.stats.name##_sum[__i] += \
500 ar->debug.stats.name##_counter[__i]; \
504 #define DEBUGFS_HW_TALLY_FILE(name, f) \
505 static char *carl9170_debugfs_##name ## _read(struct ar9170 *ar, \
506 char *dum, size_t bufsize, ssize_t *ret) \
509 int i, max_len, err; \
511 max_len = ARRAY_SIZE(name##_regs) * 80; \
512 buf = vmalloc(max_len); \
516 err = UPDATE_COUNTER(ar, name); \
522 TALLY_SUM_UP(ar, name); \
524 for (i = 0; i < ARRAY_SIZE(name##_regs); i++) { \
525 ADD(buf, *ret, max_len, "%22s = %" f "[+%" f "]\n", \
526 name##_regs[i].nreg, ar->debug.stats.name ##_sum[i],\
527 ar->debug.stats.name ##_counter[i]); \
532 DEBUGFS_DECLARE_RO_FILE(name, 0);
534 #define DEBUGFS_HW_REG_FILE(name, f) \
535 static char *carl9170_debugfs_##name ## _read(struct ar9170 *ar, \
536 char *dum, size_t bufsize, ssize_t *ret) \
539 int i, max_len, err; \
541 max_len = ARRAY_SIZE(name##_regs) * 80; \
542 buf = vmalloc(max_len); \
546 err = UPDATE_COUNTER(ar, name); \
552 for (i = 0; i < ARRAY_SIZE(name##_regs); i++) { \
553 ADD(buf, *ret, max_len, "%22s = %" f "\n", \
554 name##_regs[i].nreg, \
555 ar->debug.stats.name##_counter[i]); \
560 DEBUGFS_DECLARE_RO_FILE(name, 0);
562 static ssize_t carl9170_debugfs_hw_ioread32_write(struct ar9170 *ar,
563 const char *buf, size_t count)
565 int err = 0, i, n = 0, max_len = 32, res;
566 unsigned int reg, tmp;
574 res = sscanf(buf, "0x%X %d", ®, &n);
588 if ((reg >= 0x280000) || ((reg + (n << 2)) >= 0x280000)) {
589 err = -EADDRNOTAVAIL;
598 for (i = 0; i < n; i++) {
599 err = carl9170_read_reg(ar, reg + (i << 2), &tmp);
603 ar->debug.ring[ar->debug.ring_tail].reg = reg + (i << 2);
604 ar->debug.ring[ar->debug.ring_tail].value = tmp;
605 ar->debug.ring_tail++;
606 ar->debug.ring_tail %= CARL9170_DEBUG_RING_SIZE;
610 return err ? err : count;
613 static char *carl9170_debugfs_hw_ioread32_read(struct ar9170 *ar, char *buf,
614 size_t bufsize, ssize_t *ret)
618 while (ar->debug.ring_head != ar->debug.ring_tail) {
619 ADD(buf, *ret, bufsize, "%.8x = %.8x\n",
620 ar->debug.ring[ar->debug.ring_head].reg,
621 ar->debug.ring[ar->debug.ring_head].value);
623 ar->debug.ring_head++;
624 ar->debug.ring_head %= CARL9170_DEBUG_RING_SIZE;
629 ar->debug.ring_head = ar->debug.ring_tail;
632 DEBUGFS_DECLARE_RW_FILE(hw_ioread32, CARL9170_DEBUG_RING_SIZE * 40);
634 static ssize_t carl9170_debugfs_bug_write(struct ar9170 *ar, const char *buf,
644 ar->needs_full_reset = true;
648 if (!IS_STARTED(ar)) {
653 ar->needs_full_reset = false;
657 err = carl9170_mac_reset(ar);
664 err = carl9170_set_channel(ar, ar->hw->conf.channel,
665 ar->hw->conf.channel_type, CARL9170_RFI_COLD);
675 carl9170_restart(ar, CARL9170_RR_USER_REQUEST);
681 static char *carl9170_debugfs_bug_read(struct ar9170 *ar, char *buf,
682 size_t bufsize, ssize_t *ret)
684 ADD(buf, *ret, bufsize, "[P]hy reinit, [R]estart, [F]ull usb reset, "
686 ADD(buf, *ret, bufsize, "firmware restarts:%d, last reason:%d\n",
687 ar->restart_counter, ar->last_reason);
688 ADD(buf, *ret, bufsize, "phy reinit errors:%d (%d)\n",
689 ar->total_chan_fail, ar->chan_fail);
690 ADD(buf, *ret, bufsize, "reported firmware errors:%d\n",
692 ADD(buf, *ret, bufsize, "reported firmware BUGs:%d\n",
694 ADD(buf, *ret, bufsize, "pending restart requests:%d\n",
695 atomic_read(&ar->pending_restarts));
698 __DEBUGFS_DECLARE_RW_FILE(bug, 400, CARL9170_STOPPED);
700 static const char *erp_modes[] = {
701 [CARL9170_ERP_INVALID] = "INVALID",
702 [CARL9170_ERP_AUTO] = "Automatic",
703 [CARL9170_ERP_MAC80211] = "Set by MAC80211",
704 [CARL9170_ERP_OFF] = "Force Off",
705 [CARL9170_ERP_RTS] = "Force RTS",
706 [CARL9170_ERP_CTS] = "Force CTS"
709 static char *carl9170_debugfs_erp_read(struct ar9170 *ar, char *buf,
710 size_t bufsize, ssize_t *ret)
712 ADD(buf, *ret, bufsize, "ERP Setting: (%d) -> %s\n", ar->erp_mode,
713 erp_modes[ar->erp_mode]);
717 static ssize_t carl9170_debugfs_erp_write(struct ar9170 *ar, const char *buf,
725 res = sscanf(buf, "%d", &val);
729 if (!((val > CARL9170_ERP_INVALID) &&
730 (val < __CARL9170_ERP_NUM)))
737 DEBUGFS_DECLARE_RW_FILE(erp, 80);
739 static ssize_t carl9170_debugfs_hw_iowrite32_write(struct ar9170 *ar,
740 const char *buf, size_t count)
742 int err = 0, max_len = 22, res;
751 res = sscanf(buf, "0x%X 0x%X", ®, &val);
757 if (reg <= 0x100000 || reg >= 0x280000) {
758 err = -EADDRNOTAVAIL;
767 err = carl9170_write_reg(ar, reg, val);
772 return err ? err : count;
774 DEBUGFS_DECLARE_WO_FILE(hw_iowrite32);
776 DEBUGFS_HW_TALLY_FILE(hw_tx_tally, "u");
777 DEBUGFS_HW_TALLY_FILE(hw_rx_tally, "u");
778 DEBUGFS_HW_TALLY_FILE(hw_phy_errors, "u");
779 DEBUGFS_HW_REG_FILE(hw_wlan_queue, ".8x");
780 DEBUGFS_HW_REG_FILE(hw_pta_queue, ".8x");
781 DEBUGFS_HW_REG_FILE(hw_ampdu_info, ".8x");
782 DEBUGFS_QUEUE_DUMP(tx_status, 0);
783 DEBUGFS_QUEUE_DUMP(tx_status, 1);
784 DEBUGFS_QUEUE_DUMP(tx_status, 2);
785 DEBUGFS_QUEUE_DUMP(tx_status, 3);
786 DEBUGFS_QUEUE_DUMP(tx_pending, 0);
787 DEBUGFS_QUEUE_DUMP(tx_pending, 1);
788 DEBUGFS_QUEUE_DUMP(tx_pending, 2);
789 DEBUGFS_QUEUE_DUMP(tx_pending, 3);
790 DEBUGFS_READONLY_FILE(usb_tx_anch_urbs, 20, "%d",
791 atomic_read(&ar->tx_anch_urbs));
792 DEBUGFS_READONLY_FILE(usb_rx_anch_urbs, 20, "%d",
793 atomic_read(&ar->rx_anch_urbs));
794 DEBUGFS_READONLY_FILE(usb_rx_work_urbs, 20, "%d",
795 atomic_read(&ar->rx_work_urbs));
796 DEBUGFS_READONLY_FILE(usb_rx_pool_urbs, 20, "%d",
797 atomic_read(&ar->rx_pool_urbs));
799 DEBUGFS_READONLY_FILE(tx_total_queued, 20, "%d",
800 atomic_read(&ar->tx_total_queued));
801 DEBUGFS_READONLY_FILE(tx_ampdu_scheduler, 20, "%d",
802 atomic_read(&ar->tx_ampdu_scheduler));
803 DEBUGFS_READONLY_FILE(tx_ampdu_timeout, 20, "%d",
804 ar->tx_ampdu_timeout);
806 DEBUGFS_READONLY_FILE(tx_total_pending, 20, "%d",
807 atomic_read(&ar->tx_total_pending));
809 DEBUGFS_READONLY_FILE(tx_ampdu_list_len, 20, "%d",
810 ar->tx_ampdu_list_len);
812 DEBUGFS_READONLY_FILE(tx_ampdu_upload, 20, "%d",
813 atomic_read(&ar->tx_ampdu_upload));
815 DEBUGFS_READONLY_FILE(tx_janitor_last_run, 64, "last run:%d ms ago",
816 jiffies_to_msecs(jiffies - ar->tx_janitor_last_run));
818 DEBUGFS_READONLY_FILE(tx_dropped, 20, "%d", ar->tx_dropped);
820 DEBUGFS_READONLY_FILE(rx_dropped, 20, "%d", ar->rx_dropped);
822 DEBUGFS_READONLY_FILE(sniffer_enabled, 20, "%d", ar->sniffer_enabled);
823 DEBUGFS_READONLY_FILE(rx_software_decryption, 20, "%d",
824 ar->rx_software_decryption);
825 DEBUGFS_READONLY_FILE(ampdu_factor, 20, "%d",
827 DEBUGFS_READONLY_FILE(ampdu_density, 20, "%d",
828 ar->current_density);
830 DEBUGFS_READONLY_FILE(beacon_int, 20, "%d TU", ar->global_beacon_int);
831 DEBUGFS_READONLY_FILE(pretbtt, 20, "%d TU", ar->global_pretbtt);
833 void carl9170_debugfs_register(struct ar9170 *ar)
835 ar->debug_dir = debugfs_create_dir(KBUILD_MODNAME,
836 ar->hw->wiphy->debugfsdir);
838 #define DEBUGFS_ADD(name) \
839 debugfs_create_file(#name, carl_debugfs_##name ##_ops.attr, \
841 &carl_debugfs_##name ## _ops.fops);
843 DEBUGFS_ADD(usb_tx_anch_urbs);
844 DEBUGFS_ADD(usb_rx_pool_urbs);
845 DEBUGFS_ADD(usb_rx_anch_urbs);
846 DEBUGFS_ADD(usb_rx_work_urbs);
848 DEBUGFS_ADD(tx_total_queued);
849 DEBUGFS_ADD(tx_total_pending);
850 DEBUGFS_ADD(tx_dropped);
851 DEBUGFS_ADD(tx_stuck);
852 DEBUGFS_ADD(tx_ampdu_upload);
853 DEBUGFS_ADD(tx_ampdu_scheduler);
854 DEBUGFS_ADD(tx_ampdu_list_len);
856 DEBUGFS_ADD(rx_dropped);
857 DEBUGFS_ADD(sniffer_enabled);
858 DEBUGFS_ADD(rx_software_decryption);
860 DEBUGFS_ADD(mem_usage);
861 DEBUGFS_ADD(qos_stat);
862 DEBUGFS_ADD(sta_psm);
863 DEBUGFS_ADD(ampdu_state);
865 DEBUGFS_ADD(hw_tx_tally);
866 DEBUGFS_ADD(hw_rx_tally);
867 DEBUGFS_ADD(hw_phy_errors);
868 DEBUGFS_ADD(phy_noise);
870 DEBUGFS_ADD(hw_wlan_queue);
871 DEBUGFS_ADD(hw_pta_queue);
872 DEBUGFS_ADD(hw_ampdu_info);
874 DEBUGFS_ADD(ampdu_density);
875 DEBUGFS_ADD(ampdu_factor);
877 DEBUGFS_ADD(tx_ampdu_timeout);
879 DEBUGFS_ADD(tx_janitor_last_run);
881 DEBUGFS_ADD(tx_status_0);
882 DEBUGFS_ADD(tx_status_1);
883 DEBUGFS_ADD(tx_status_2);
884 DEBUGFS_ADD(tx_status_3);
886 DEBUGFS_ADD(tx_pending_0);
887 DEBUGFS_ADD(tx_pending_1);
888 DEBUGFS_ADD(tx_pending_2);
889 DEBUGFS_ADD(tx_pending_3);
891 DEBUGFS_ADD(hw_ioread32);
892 DEBUGFS_ADD(hw_iowrite32);
897 DEBUGFS_ADD(vif_dump);
899 DEBUGFS_ADD(beacon_int);
900 DEBUGFS_ADD(pretbtt);
905 void carl9170_debugfs_unregister(struct ar9170 *ar)
907 debugfs_remove_recursive(ar->debug_dir);