diff options
Diffstat (limited to 'drivers/net/wireless/ath/ath9k/debug.c')
-rw-r--r-- | drivers/net/wireless/ath/ath9k/debug.c | 830 |
1 files changed, 510 insertions, 320 deletions
diff --git a/drivers/net/wireless/ath/ath9k/debug.c b/drivers/net/wireless/ath/ath9k/debug.c index 54aae931424e..d55ffd7d4bd2 100644 --- a/drivers/net/wireless/ath/ath9k/debug.c +++ b/drivers/net/wireless/ath/ath9k/debug.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2008-2009 Atheros Communications Inc. | 2 | * Copyright (c) 2008-2011 Atheros Communications Inc. |
3 | * | 3 | * |
4 | * Permission to use, copy, modify, and/or distribute this software for any | 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 | 5 | * purpose with or without fee is hereby granted, provided that the above |
@@ -15,6 +15,7 @@ | |||
15 | */ | 15 | */ |
16 | 16 | ||
17 | #include <linux/slab.h> | 17 | #include <linux/slab.h> |
18 | #include <linux/vmalloc.h> | ||
18 | #include <asm/unaligned.h> | 19 | #include <asm/unaligned.h> |
19 | 20 | ||
20 | #include "ath9k.h" | 21 | #include "ath9k.h" |
@@ -24,14 +25,25 @@ | |||
24 | #define REG_READ_D(_ah, _reg) \ | 25 | #define REG_READ_D(_ah, _reg) \ |
25 | ath9k_hw_common(_ah)->ops->read((_ah), (_reg)) | 26 | ath9k_hw_common(_ah)->ops->read((_ah), (_reg)) |
26 | 27 | ||
27 | static struct dentry *ath9k_debugfs_root; | ||
28 | |||
29 | static int ath9k_debugfs_open(struct inode *inode, struct file *file) | 28 | static int ath9k_debugfs_open(struct inode *inode, struct file *file) |
30 | { | 29 | { |
31 | file->private_data = inode->i_private; | 30 | file->private_data = inode->i_private; |
32 | return 0; | 31 | return 0; |
33 | } | 32 | } |
34 | 33 | ||
34 | static ssize_t ath9k_debugfs_read_buf(struct file *file, char __user *user_buf, | ||
35 | size_t count, loff_t *ppos) | ||
36 | { | ||
37 | u8 *buf = file->private_data; | ||
38 | return simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf)); | ||
39 | } | ||
40 | |||
41 | static int ath9k_debugfs_release_buf(struct inode *inode, struct file *file) | ||
42 | { | ||
43 | vfree(file->private_data); | ||
44 | return 0; | ||
45 | } | ||
46 | |||
35 | #ifdef CONFIG_ATH_DEBUG | 47 | #ifdef CONFIG_ATH_DEBUG |
36 | 48 | ||
37 | static ssize_t read_file_debug(struct file *file, char __user *user_buf, | 49 | static ssize_t read_file_debug(struct file *file, char __user *user_buf, |
@@ -71,7 +83,8 @@ static const struct file_operations fops_debug = { | |||
71 | .read = read_file_debug, | 83 | .read = read_file_debug, |
72 | .write = write_file_debug, | 84 | .write = write_file_debug, |
73 | .open = ath9k_debugfs_open, | 85 | .open = ath9k_debugfs_open, |
74 | .owner = THIS_MODULE | 86 | .owner = THIS_MODULE, |
87 | .llseek = default_llseek, | ||
75 | }; | 88 | }; |
76 | 89 | ||
77 | #endif | 90 | #endif |
@@ -116,7 +129,8 @@ static const struct file_operations fops_tx_chainmask = { | |||
116 | .read = read_file_tx_chainmask, | 129 | .read = read_file_tx_chainmask, |
117 | .write = write_file_tx_chainmask, | 130 | .write = write_file_tx_chainmask, |
118 | .open = ath9k_debugfs_open, | 131 | .open = ath9k_debugfs_open, |
119 | .owner = THIS_MODULE | 132 | .owner = THIS_MODULE, |
133 | .llseek = default_llseek, | ||
120 | }; | 134 | }; |
121 | 135 | ||
122 | 136 | ||
@@ -158,7 +172,8 @@ static const struct file_operations fops_rx_chainmask = { | |||
158 | .read = read_file_rx_chainmask, | 172 | .read = read_file_rx_chainmask, |
159 | .write = write_file_rx_chainmask, | 173 | .write = write_file_rx_chainmask, |
160 | .open = ath9k_debugfs_open, | 174 | .open = ath9k_debugfs_open, |
161 | .owner = THIS_MODULE | 175 | .owner = THIS_MODULE, |
176 | .llseek = default_llseek, | ||
162 | }; | 177 | }; |
163 | 178 | ||
164 | 179 | ||
@@ -259,7 +274,8 @@ static ssize_t read_file_dma(struct file *file, char __user *user_buf, | |||
259 | static const struct file_operations fops_dma = { | 274 | static const struct file_operations fops_dma = { |
260 | .read = read_file_dma, | 275 | .read = read_file_dma, |
261 | .open = ath9k_debugfs_open, | 276 | .open = ath9k_debugfs_open, |
262 | .owner = THIS_MODULE | 277 | .owner = THIS_MODULE, |
278 | .llseek = default_llseek, | ||
263 | }; | 279 | }; |
264 | 280 | ||
265 | 281 | ||
@@ -310,6 +326,8 @@ void ath_debug_stat_interrupt(struct ath_softc *sc, enum ath9k_int status) | |||
310 | sc->debug.stats.istats.dtimsync++; | 326 | sc->debug.stats.istats.dtimsync++; |
311 | if (status & ATH9K_INT_DTIM) | 327 | if (status & ATH9K_INT_DTIM) |
312 | sc->debug.stats.istats.dtim++; | 328 | sc->debug.stats.istats.dtim++; |
329 | if (status & ATH9K_INT_TSFOOR) | ||
330 | sc->debug.stats.istats.tsfoor++; | ||
313 | } | 331 | } |
314 | 332 | ||
315 | static ssize_t read_file_interrupt(struct file *file, char __user *user_buf, | 333 | static ssize_t read_file_interrupt(struct file *file, char __user *user_buf, |
@@ -364,8 +382,11 @@ static ssize_t read_file_interrupt(struct file *file, char __user *user_buf, | |||
364 | len += snprintf(buf + len, sizeof(buf) - len, | 382 | len += snprintf(buf + len, sizeof(buf) - len, |
365 | "%8s: %10u\n", "DTIM", sc->debug.stats.istats.dtim); | 383 | "%8s: %10u\n", "DTIM", sc->debug.stats.istats.dtim); |
366 | len += snprintf(buf + len, sizeof(buf) - len, | 384 | len += snprintf(buf + len, sizeof(buf) - len, |
385 | "%8s: %10u\n", "TSFOOR", sc->debug.stats.istats.tsfoor); | ||
386 | len += snprintf(buf + len, sizeof(buf) - len, | ||
367 | "%8s: %10u\n", "TOTAL", sc->debug.stats.istats.total); | 387 | "%8s: %10u\n", "TOTAL", sc->debug.stats.istats.total); |
368 | 388 | ||
389 | |||
369 | if (len > sizeof(buf)) | 390 | if (len > sizeof(buf)) |
370 | len = sizeof(buf); | 391 | len = sizeof(buf); |
371 | 392 | ||
@@ -375,140 +396,46 @@ static ssize_t read_file_interrupt(struct file *file, char __user *user_buf, | |||
375 | static const struct file_operations fops_interrupt = { | 396 | static const struct file_operations fops_interrupt = { |
376 | .read = read_file_interrupt, | 397 | .read = read_file_interrupt, |
377 | .open = ath9k_debugfs_open, | 398 | .open = ath9k_debugfs_open, |
378 | .owner = THIS_MODULE | 399 | .owner = THIS_MODULE, |
400 | .llseek = default_llseek, | ||
379 | }; | 401 | }; |
380 | 402 | ||
381 | void ath_debug_stat_rc(struct ath_softc *sc, int final_rate) | 403 | static const char *channel_type_str(enum nl80211_channel_type t) |
382 | { | ||
383 | struct ath_rc_stats *stats; | ||
384 | |||
385 | stats = &sc->debug.stats.rcstats[final_rate]; | ||
386 | stats->success++; | ||
387 | } | ||
388 | |||
389 | void ath_debug_stat_retries(struct ath_softc *sc, int rix, | ||
390 | int xretries, int retries, u8 per) | ||
391 | { | 404 | { |
392 | struct ath_rc_stats *stats = &sc->debug.stats.rcstats[rix]; | 405 | switch (t) { |
393 | 406 | case NL80211_CHAN_NO_HT: | |
394 | stats->xretries += xretries; | 407 | return "no ht"; |
395 | stats->retries += retries; | 408 | case NL80211_CHAN_HT20: |
396 | stats->per = per; | 409 | return "ht20"; |
397 | } | 410 | case NL80211_CHAN_HT40MINUS: |
398 | 411 | return "ht40-"; | |
399 | static ssize_t read_file_rcstat(struct file *file, char __user *user_buf, | 412 | case NL80211_CHAN_HT40PLUS: |
400 | size_t count, loff_t *ppos) | 413 | return "ht40+"; |
401 | { | 414 | default: |
402 | struct ath_softc *sc = file->private_data; | 415 | return "???"; |
403 | char *buf; | ||
404 | unsigned int len = 0, max; | ||
405 | int i = 0; | ||
406 | ssize_t retval; | ||
407 | |||
408 | if (sc->cur_rate_table == NULL) | ||
409 | return 0; | ||
410 | |||
411 | max = 80 + sc->cur_rate_table->rate_cnt * 1024 + 1; | ||
412 | buf = kmalloc(max, GFP_KERNEL); | ||
413 | if (buf == NULL) | ||
414 | return -ENOMEM; | ||
415 | |||
416 | len += sprintf(buf, "%6s %6s %6s " | ||
417 | "%10s %10s %10s %10s\n", | ||
418 | "HT", "MCS", "Rate", | ||
419 | "Success", "Retries", "XRetries", "PER"); | ||
420 | |||
421 | for (i = 0; i < sc->cur_rate_table->rate_cnt; i++) { | ||
422 | u32 ratekbps = sc->cur_rate_table->info[i].ratekbps; | ||
423 | struct ath_rc_stats *stats = &sc->debug.stats.rcstats[i]; | ||
424 | char mcs[5]; | ||
425 | char htmode[5]; | ||
426 | int used_mcs = 0, used_htmode = 0; | ||
427 | |||
428 | if (WLAN_RC_PHY_HT(sc->cur_rate_table->info[i].phy)) { | ||
429 | used_mcs = snprintf(mcs, 5, "%d", | ||
430 | sc->cur_rate_table->info[i].ratecode); | ||
431 | |||
432 | if (WLAN_RC_PHY_40(sc->cur_rate_table->info[i].phy)) | ||
433 | used_htmode = snprintf(htmode, 5, "HT40"); | ||
434 | else if (WLAN_RC_PHY_20(sc->cur_rate_table->info[i].phy)) | ||
435 | used_htmode = snprintf(htmode, 5, "HT20"); | ||
436 | else | ||
437 | used_htmode = snprintf(htmode, 5, "????"); | ||
438 | } | ||
439 | |||
440 | mcs[used_mcs] = '\0'; | ||
441 | htmode[used_htmode] = '\0'; | ||
442 | |||
443 | len += snprintf(buf + len, max - len, | ||
444 | "%6s %6s %3u.%d: " | ||
445 | "%10u %10u %10u %10u\n", | ||
446 | htmode, | ||
447 | mcs, | ||
448 | ratekbps / 1000, | ||
449 | (ratekbps % 1000) / 100, | ||
450 | stats->success, | ||
451 | stats->retries, | ||
452 | stats->xretries, | ||
453 | stats->per); | ||
454 | } | 416 | } |
455 | |||
456 | if (len > max) | ||
457 | len = max; | ||
458 | |||
459 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); | ||
460 | kfree(buf); | ||
461 | return retval; | ||
462 | } | ||
463 | |||
464 | static const struct file_operations fops_rcstat = { | ||
465 | .read = read_file_rcstat, | ||
466 | .open = ath9k_debugfs_open, | ||
467 | .owner = THIS_MODULE | ||
468 | }; | ||
469 | |||
470 | static const char * ath_wiphy_state_str(enum ath_wiphy_state state) | ||
471 | { | ||
472 | switch (state) { | ||
473 | case ATH_WIPHY_INACTIVE: | ||
474 | return "INACTIVE"; | ||
475 | case ATH_WIPHY_ACTIVE: | ||
476 | return "ACTIVE"; | ||
477 | case ATH_WIPHY_PAUSING: | ||
478 | return "PAUSING"; | ||
479 | case ATH_WIPHY_PAUSED: | ||
480 | return "PAUSED"; | ||
481 | case ATH_WIPHY_SCAN: | ||
482 | return "SCAN"; | ||
483 | } | ||
484 | return "?"; | ||
485 | } | 417 | } |
486 | 418 | ||
487 | static ssize_t read_file_wiphy(struct file *file, char __user *user_buf, | 419 | static ssize_t read_file_wiphy(struct file *file, char __user *user_buf, |
488 | size_t count, loff_t *ppos) | 420 | size_t count, loff_t *ppos) |
489 | { | 421 | { |
490 | struct ath_softc *sc = file->private_data; | 422 | struct ath_softc *sc = file->private_data; |
423 | struct ieee80211_channel *chan = sc->hw->conf.channel; | ||
424 | struct ieee80211_conf *conf = &(sc->hw->conf); | ||
491 | char buf[512]; | 425 | char buf[512]; |
492 | unsigned int len = 0; | 426 | unsigned int len = 0; |
493 | int i; | ||
494 | u8 addr[ETH_ALEN]; | 427 | u8 addr[ETH_ALEN]; |
428 | u32 tmp; | ||
495 | 429 | ||
496 | len += snprintf(buf + len, sizeof(buf) - len, | 430 | len += snprintf(buf + len, sizeof(buf) - len, |
497 | "primary: %s (%s chan=%d ht=%d)\n", | 431 | "%s (chan=%d center-freq: %d MHz channel-type: %d (%s))\n", |
498 | wiphy_name(sc->pri_wiphy->hw->wiphy), | 432 | wiphy_name(sc->hw->wiphy), |
499 | ath_wiphy_state_str(sc->pri_wiphy->state), | 433 | ieee80211_frequency_to_channel(chan->center_freq), |
500 | sc->pri_wiphy->chan_idx, sc->pri_wiphy->chan_is_ht); | 434 | chan->center_freq, |
501 | for (i = 0; i < sc->num_sec_wiphy; i++) { | 435 | conf->channel_type, |
502 | struct ath_wiphy *aphy = sc->sec_wiphy[i]; | 436 | channel_type_str(conf->channel_type)); |
503 | if (aphy == NULL) | ||
504 | continue; | ||
505 | len += snprintf(buf + len, sizeof(buf) - len, | ||
506 | "secondary: %s (%s chan=%d ht=%d)\n", | ||
507 | wiphy_name(aphy->hw->wiphy), | ||
508 | ath_wiphy_state_str(aphy->state), | ||
509 | aphy->chan_idx, aphy->chan_is_ht); | ||
510 | } | ||
511 | 437 | ||
438 | ath9k_ps_wakeup(sc); | ||
512 | put_unaligned_le32(REG_READ_D(sc->sc_ah, AR_STA_ID0), addr); | 439 | put_unaligned_le32(REG_READ_D(sc->sc_ah, AR_STA_ID0), addr); |
513 | put_unaligned_le16(REG_READ_D(sc->sc_ah, AR_STA_ID1) & 0xffff, addr + 4); | 440 | put_unaligned_le16(REG_READ_D(sc->sc_ah, AR_STA_ID1) & 0xffff, addr + 4); |
514 | len += snprintf(buf + len, sizeof(buf) - len, | 441 | len += snprintf(buf + len, sizeof(buf) - len, |
@@ -517,6 +444,38 @@ static ssize_t read_file_wiphy(struct file *file, char __user *user_buf, | |||
517 | put_unaligned_le16(REG_READ_D(sc->sc_ah, AR_BSSMSKU) & 0xffff, addr + 4); | 444 | put_unaligned_le16(REG_READ_D(sc->sc_ah, AR_BSSMSKU) & 0xffff, addr + 4); |
518 | len += snprintf(buf + len, sizeof(buf) - len, | 445 | len += snprintf(buf + len, sizeof(buf) - len, |
519 | "addrmask: %pM\n", addr); | 446 | "addrmask: %pM\n", addr); |
447 | tmp = ath9k_hw_getrxfilter(sc->sc_ah); | ||
448 | ath9k_ps_restore(sc); | ||
449 | len += snprintf(buf + len, sizeof(buf) - len, | ||
450 | "rfilt: 0x%x", tmp); | ||
451 | if (tmp & ATH9K_RX_FILTER_UCAST) | ||
452 | len += snprintf(buf + len, sizeof(buf) - len, " UCAST"); | ||
453 | if (tmp & ATH9K_RX_FILTER_MCAST) | ||
454 | len += snprintf(buf + len, sizeof(buf) - len, " MCAST"); | ||
455 | if (tmp & ATH9K_RX_FILTER_BCAST) | ||
456 | len += snprintf(buf + len, sizeof(buf) - len, " BCAST"); | ||
457 | if (tmp & ATH9K_RX_FILTER_CONTROL) | ||
458 | len += snprintf(buf + len, sizeof(buf) - len, " CONTROL"); | ||
459 | if (tmp & ATH9K_RX_FILTER_BEACON) | ||
460 | len += snprintf(buf + len, sizeof(buf) - len, " BEACON"); | ||
461 | if (tmp & ATH9K_RX_FILTER_PROM) | ||
462 | len += snprintf(buf + len, sizeof(buf) - len, " PROM"); | ||
463 | if (tmp & ATH9K_RX_FILTER_PROBEREQ) | ||
464 | len += snprintf(buf + len, sizeof(buf) - len, " PROBEREQ"); | ||
465 | if (tmp & ATH9K_RX_FILTER_PHYERR) | ||
466 | len += snprintf(buf + len, sizeof(buf) - len, " PHYERR"); | ||
467 | if (tmp & ATH9K_RX_FILTER_MYBEACON) | ||
468 | len += snprintf(buf + len, sizeof(buf) - len, " MYBEACON"); | ||
469 | if (tmp & ATH9K_RX_FILTER_COMP_BAR) | ||
470 | len += snprintf(buf + len, sizeof(buf) - len, " COMP_BAR"); | ||
471 | if (tmp & ATH9K_RX_FILTER_PSPOLL) | ||
472 | len += snprintf(buf + len, sizeof(buf) - len, " PSPOLL"); | ||
473 | if (tmp & ATH9K_RX_FILTER_PHYRADAR) | ||
474 | len += snprintf(buf + len, sizeof(buf) - len, " PHYRADAR"); | ||
475 | if (tmp & ATH9K_RX_FILTER_MCAST_BCAST_ALL) | ||
476 | len += snprintf(buf + len, sizeof(buf) - len, " MCAST_BCAST_ALL\n"); | ||
477 | else | ||
478 | len += snprintf(buf + len, sizeof(buf) - len, "\n"); | ||
520 | 479 | ||
521 | if (len > sizeof(buf)) | 480 | if (len > sizeof(buf)) |
522 | len = sizeof(buf); | 481 | len = sizeof(buf); |
@@ -524,136 +483,76 @@ static ssize_t read_file_wiphy(struct file *file, char __user *user_buf, | |||
524 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); | 483 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
525 | } | 484 | } |
526 | 485 | ||
527 | static struct ath_wiphy * get_wiphy(struct ath_softc *sc, const char *name) | ||
528 | { | ||
529 | int i; | ||
530 | if (strcmp(name, wiphy_name(sc->pri_wiphy->hw->wiphy)) == 0) | ||
531 | return sc->pri_wiphy; | ||
532 | for (i = 0; i < sc->num_sec_wiphy; i++) { | ||
533 | struct ath_wiphy *aphy = sc->sec_wiphy[i]; | ||
534 | if (aphy && strcmp(name, wiphy_name(aphy->hw->wiphy)) == 0) | ||
535 | return aphy; | ||
536 | } | ||
537 | return NULL; | ||
538 | } | ||
539 | |||
540 | static int del_wiphy(struct ath_softc *sc, const char *name) | ||
541 | { | ||
542 | struct ath_wiphy *aphy = get_wiphy(sc, name); | ||
543 | if (!aphy) | ||
544 | return -ENOENT; | ||
545 | return ath9k_wiphy_del(aphy); | ||
546 | } | ||
547 | |||
548 | static int pause_wiphy(struct ath_softc *sc, const char *name) | ||
549 | { | ||
550 | struct ath_wiphy *aphy = get_wiphy(sc, name); | ||
551 | if (!aphy) | ||
552 | return -ENOENT; | ||
553 | return ath9k_wiphy_pause(aphy); | ||
554 | } | ||
555 | |||
556 | static int unpause_wiphy(struct ath_softc *sc, const char *name) | ||
557 | { | ||
558 | struct ath_wiphy *aphy = get_wiphy(sc, name); | ||
559 | if (!aphy) | ||
560 | return -ENOENT; | ||
561 | return ath9k_wiphy_unpause(aphy); | ||
562 | } | ||
563 | |||
564 | static int select_wiphy(struct ath_softc *sc, const char *name) | ||
565 | { | ||
566 | struct ath_wiphy *aphy = get_wiphy(sc, name); | ||
567 | if (!aphy) | ||
568 | return -ENOENT; | ||
569 | return ath9k_wiphy_select(aphy); | ||
570 | } | ||
571 | |||
572 | static int schedule_wiphy(struct ath_softc *sc, const char *msec) | ||
573 | { | ||
574 | ath9k_wiphy_set_scheduler(sc, simple_strtoul(msec, NULL, 0)); | ||
575 | return 0; | ||
576 | } | ||
577 | |||
578 | static ssize_t write_file_wiphy(struct file *file, const char __user *user_buf, | ||
579 | size_t count, loff_t *ppos) | ||
580 | { | ||
581 | struct ath_softc *sc = file->private_data; | ||
582 | char buf[50]; | ||
583 | size_t len; | ||
584 | |||
585 | len = min(count, sizeof(buf) - 1); | ||
586 | if (copy_from_user(buf, user_buf, len)) | ||
587 | return -EFAULT; | ||
588 | buf[len] = '\0'; | ||
589 | if (len > 0 && buf[len - 1] == '\n') | ||
590 | buf[len - 1] = '\0'; | ||
591 | |||
592 | if (strncmp(buf, "add", 3) == 0) { | ||
593 | int res = ath9k_wiphy_add(sc); | ||
594 | if (res < 0) | ||
595 | return res; | ||
596 | } else if (strncmp(buf, "del=", 4) == 0) { | ||
597 | int res = del_wiphy(sc, buf + 4); | ||
598 | if (res < 0) | ||
599 | return res; | ||
600 | } else if (strncmp(buf, "pause=", 6) == 0) { | ||
601 | int res = pause_wiphy(sc, buf + 6); | ||
602 | if (res < 0) | ||
603 | return res; | ||
604 | } else if (strncmp(buf, "unpause=", 8) == 0) { | ||
605 | int res = unpause_wiphy(sc, buf + 8); | ||
606 | if (res < 0) | ||
607 | return res; | ||
608 | } else if (strncmp(buf, "select=", 7) == 0) { | ||
609 | int res = select_wiphy(sc, buf + 7); | ||
610 | if (res < 0) | ||
611 | return res; | ||
612 | } else if (strncmp(buf, "schedule=", 9) == 0) { | ||
613 | int res = schedule_wiphy(sc, buf + 9); | ||
614 | if (res < 0) | ||
615 | return res; | ||
616 | } else | ||
617 | return -EOPNOTSUPP; | ||
618 | |||
619 | return count; | ||
620 | } | ||
621 | |||
622 | static const struct file_operations fops_wiphy = { | 486 | static const struct file_operations fops_wiphy = { |
623 | .read = read_file_wiphy, | 487 | .read = read_file_wiphy, |
624 | .write = write_file_wiphy, | ||
625 | .open = ath9k_debugfs_open, | 488 | .open = ath9k_debugfs_open, |
626 | .owner = THIS_MODULE | 489 | .owner = THIS_MODULE, |
490 | .llseek = default_llseek, | ||
627 | }; | 491 | }; |
628 | 492 | ||
493 | #define PR_QNUM(_n) sc->tx.txq_map[_n]->axq_qnum | ||
629 | #define PR(str, elem) \ | 494 | #define PR(str, elem) \ |
630 | do { \ | 495 | do { \ |
631 | len += snprintf(buf + len, size - len, \ | 496 | len += snprintf(buf + len, size - len, \ |
632 | "%s%13u%11u%10u%10u\n", str, \ | 497 | "%s%13u%11u%10u%10u\n", str, \ |
633 | sc->debug.stats.txstats[sc->tx.hwq_map[WME_AC_BE]].elem, \ | 498 | sc->debug.stats.txstats[PR_QNUM(WME_AC_BE)].elem, \ |
634 | sc->debug.stats.txstats[sc->tx.hwq_map[WME_AC_BK]].elem, \ | 499 | sc->debug.stats.txstats[PR_QNUM(WME_AC_BK)].elem, \ |
635 | sc->debug.stats.txstats[sc->tx.hwq_map[WME_AC_VI]].elem, \ | 500 | sc->debug.stats.txstats[PR_QNUM(WME_AC_VI)].elem, \ |
636 | sc->debug.stats.txstats[sc->tx.hwq_map[WME_AC_VO]].elem); \ | 501 | sc->debug.stats.txstats[PR_QNUM(WME_AC_VO)].elem); \ |
502 | if (len >= size) \ | ||
503 | goto done; \ | ||
637 | } while(0) | 504 | } while(0) |
638 | 505 | ||
506 | #define PRX(str, elem) \ | ||
507 | do { \ | ||
508 | len += snprintf(buf + len, size - len, \ | ||
509 | "%s%13u%11u%10u%10u\n", str, \ | ||
510 | (unsigned int)(sc->tx.txq_map[WME_AC_BE]->elem), \ | ||
511 | (unsigned int)(sc->tx.txq_map[WME_AC_BK]->elem), \ | ||
512 | (unsigned int)(sc->tx.txq_map[WME_AC_VI]->elem), \ | ||
513 | (unsigned int)(sc->tx.txq_map[WME_AC_VO]->elem)); \ | ||
514 | if (len >= size) \ | ||
515 | goto done; \ | ||
516 | } while(0) | ||
517 | |||
518 | #define PRQLE(str, elem) \ | ||
519 | do { \ | ||
520 | len += snprintf(buf + len, size - len, \ | ||
521 | "%s%13i%11i%10i%10i\n", str, \ | ||
522 | list_empty(&sc->tx.txq_map[WME_AC_BE]->elem), \ | ||
523 | list_empty(&sc->tx.txq_map[WME_AC_BK]->elem), \ | ||
524 | list_empty(&sc->tx.txq_map[WME_AC_VI]->elem), \ | ||
525 | list_empty(&sc->tx.txq_map[WME_AC_VO]->elem)); \ | ||
526 | if (len >= size) \ | ||
527 | goto done; \ | ||
528 | } while (0) | ||
529 | |||
639 | static ssize_t read_file_xmit(struct file *file, char __user *user_buf, | 530 | static ssize_t read_file_xmit(struct file *file, char __user *user_buf, |
640 | size_t count, loff_t *ppos) | 531 | size_t count, loff_t *ppos) |
641 | { | 532 | { |
642 | struct ath_softc *sc = file->private_data; | 533 | struct ath_softc *sc = file->private_data; |
643 | char *buf; | 534 | char *buf; |
644 | unsigned int len = 0, size = 2048; | 535 | unsigned int len = 0, size = 8000; |
536 | int i; | ||
645 | ssize_t retval = 0; | 537 | ssize_t retval = 0; |
538 | char tmp[32]; | ||
646 | 539 | ||
647 | buf = kzalloc(size, GFP_KERNEL); | 540 | buf = kzalloc(size, GFP_KERNEL); |
648 | if (buf == NULL) | 541 | if (buf == NULL) |
649 | return -ENOMEM; | 542 | return -ENOMEM; |
650 | 543 | ||
651 | len += sprintf(buf, "%30s %10s%10s%10s\n\n", "BE", "BK", "VI", "VO"); | 544 | len += sprintf(buf, "Num-Tx-Queues: %i tx-queues-setup: 0x%x" |
545 | " poll-work-seen: %u\n" | ||
546 | "%30s %10s%10s%10s\n\n", | ||
547 | ATH9K_NUM_TX_QUEUES, sc->tx.txqsetup, | ||
548 | sc->tx_complete_poll_work_seen, | ||
549 | "BE", "BK", "VI", "VO"); | ||
652 | 550 | ||
653 | PR("MPDUs Queued: ", queued); | 551 | PR("MPDUs Queued: ", queued); |
654 | PR("MPDUs Completed: ", completed); | 552 | PR("MPDUs Completed: ", completed); |
655 | PR("Aggregates: ", a_aggr); | 553 | PR("Aggregates: ", a_aggr); |
656 | PR("AMPDUs Queued: ", a_queued); | 554 | PR("AMPDUs Queued HW:", a_queued_hw); |
555 | PR("AMPDUs Queued SW:", a_queued_sw); | ||
657 | PR("AMPDUs Completed:", a_completed); | 556 | PR("AMPDUs Completed:", a_completed); |
658 | PR("AMPDUs Retried: ", a_retries); | 557 | PR("AMPDUs Retried: ", a_retries); |
659 | PR("AMPDUs XRetried: ", a_xretries); | 558 | PR("AMPDUs XRetried: ", a_xretries); |
@@ -663,7 +562,64 @@ static ssize_t read_file_xmit(struct file *file, char __user *user_buf, | |||
663 | PR("DESC CFG Error: ", desc_cfg_err); | 562 | PR("DESC CFG Error: ", desc_cfg_err); |
664 | PR("DATA Underrun: ", data_underrun); | 563 | PR("DATA Underrun: ", data_underrun); |
665 | PR("DELIM Underrun: ", delim_underrun); | 564 | PR("DELIM Underrun: ", delim_underrun); |
565 | PR("TX-Pkts-All: ", tx_pkts_all); | ||
566 | PR("TX-Bytes-All: ", tx_bytes_all); | ||
567 | PR("hw-put-tx-buf: ", puttxbuf); | ||
568 | PR("hw-tx-start: ", txstart); | ||
569 | PR("hw-tx-proc-desc: ", txprocdesc); | ||
570 | len += snprintf(buf + len, size - len, | ||
571 | "%s%11p%11p%10p%10p\n", "txq-memory-address:", | ||
572 | sc->tx.txq_map[WME_AC_BE], | ||
573 | sc->tx.txq_map[WME_AC_BK], | ||
574 | sc->tx.txq_map[WME_AC_VI], | ||
575 | sc->tx.txq_map[WME_AC_VO]); | ||
576 | if (len >= size) | ||
577 | goto done; | ||
578 | |||
579 | PRX("axq-qnum: ", axq_qnum); | ||
580 | PRX("axq-depth: ", axq_depth); | ||
581 | PRX("axq-ampdu_depth: ", axq_ampdu_depth); | ||
582 | PRX("axq-stopped ", stopped); | ||
583 | PRX("tx-in-progress ", axq_tx_inprogress); | ||
584 | PRX("pending-frames ", pending_frames); | ||
585 | PRX("txq_headidx: ", txq_headidx); | ||
586 | PRX("txq_tailidx: ", txq_headidx); | ||
587 | |||
588 | PRQLE("axq_q empty: ", axq_q); | ||
589 | PRQLE("axq_acq empty: ", axq_acq); | ||
590 | PRQLE("txq_fifo_pending: ", txq_fifo_pending); | ||
591 | for (i = 0; i < ATH_TXFIFO_DEPTH; i++) { | ||
592 | snprintf(tmp, sizeof(tmp) - 1, "txq_fifo[%i] empty: ", i); | ||
593 | PRQLE(tmp, txq_fifo[i]); | ||
594 | } | ||
666 | 595 | ||
596 | /* Print out more detailed queue-info */ | ||
597 | for (i = 0; i <= WME_AC_BK; i++) { | ||
598 | struct ath_txq *txq = &(sc->tx.txq[i]); | ||
599 | struct ath_atx_ac *ac; | ||
600 | struct ath_atx_tid *tid; | ||
601 | if (len >= size) | ||
602 | goto done; | ||
603 | spin_lock_bh(&txq->axq_lock); | ||
604 | if (!list_empty(&txq->axq_acq)) { | ||
605 | ac = list_first_entry(&txq->axq_acq, struct ath_atx_ac, | ||
606 | list); | ||
607 | len += snprintf(buf + len, size - len, | ||
608 | "txq[%i] first-ac: %p sched: %i\n", | ||
609 | i, ac, ac->sched); | ||
610 | if (list_empty(&ac->tid_q) || (len >= size)) | ||
611 | goto done_for; | ||
612 | tid = list_first_entry(&ac->tid_q, struct ath_atx_tid, | ||
613 | list); | ||
614 | len += snprintf(buf + len, size - len, | ||
615 | " first-tid: %p sched: %i paused: %i\n", | ||
616 | tid, tid->sched, tid->paused); | ||
617 | } | ||
618 | done_for: | ||
619 | spin_unlock_bh(&txq->axq_lock); | ||
620 | } | ||
621 | |||
622 | done: | ||
667 | if (len > size) | 623 | if (len > size) |
668 | len = size; | 624 | len = size; |
669 | 625 | ||
@@ -673,36 +629,220 @@ static ssize_t read_file_xmit(struct file *file, char __user *user_buf, | |||
673 | return retval; | 629 | return retval; |
674 | } | 630 | } |
675 | 631 | ||
676 | void ath_debug_stat_tx(struct ath_softc *sc, struct ath_txq *txq, | 632 | static ssize_t read_file_stations(struct file *file, char __user *user_buf, |
677 | struct ath_buf *bf, struct ath_tx_status *ts) | 633 | size_t count, loff_t *ppos) |
678 | { | 634 | { |
635 | struct ath_softc *sc = file->private_data; | ||
636 | char *buf; | ||
637 | unsigned int len = 0, size = 64000; | ||
638 | struct ath_node *an = NULL; | ||
639 | ssize_t retval = 0; | ||
640 | int q; | ||
641 | |||
642 | buf = kzalloc(size, GFP_KERNEL); | ||
643 | if (buf == NULL) | ||
644 | return -ENOMEM; | ||
645 | |||
646 | len += snprintf(buf + len, size - len, | ||
647 | "Stations:\n" | ||
648 | " tid: addr sched paused buf_q-empty an ac\n" | ||
649 | " ac: addr sched tid_q-empty txq\n"); | ||
650 | |||
651 | spin_lock(&sc->nodes_lock); | ||
652 | list_for_each_entry(an, &sc->nodes, list) { | ||
653 | len += snprintf(buf + len, size - len, | ||
654 | "%pM\n", an->sta->addr); | ||
655 | if (len >= size) | ||
656 | goto done; | ||
657 | |||
658 | for (q = 0; q < WME_NUM_TID; q++) { | ||
659 | struct ath_atx_tid *tid = &(an->tid[q]); | ||
660 | len += snprintf(buf + len, size - len, | ||
661 | " tid: %p %s %s %i %p %p\n", | ||
662 | tid, tid->sched ? "sched" : "idle", | ||
663 | tid->paused ? "paused" : "running", | ||
664 | list_empty(&tid->buf_q), | ||
665 | tid->an, tid->ac); | ||
666 | if (len >= size) | ||
667 | goto done; | ||
668 | } | ||
669 | |||
670 | for (q = 0; q < WME_NUM_AC; q++) { | ||
671 | struct ath_atx_ac *ac = &(an->ac[q]); | ||
672 | len += snprintf(buf + len, size - len, | ||
673 | " ac: %p %s %i %p\n", | ||
674 | ac, ac->sched ? "sched" : "idle", | ||
675 | list_empty(&ac->tid_q), ac->txq); | ||
676 | if (len >= size) | ||
677 | goto done; | ||
678 | } | ||
679 | } | ||
680 | |||
681 | done: | ||
682 | spin_unlock(&sc->nodes_lock); | ||
683 | if (len > size) | ||
684 | len = size; | ||
685 | |||
686 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); | ||
687 | kfree(buf); | ||
688 | |||
689 | return retval; | ||
690 | } | ||
691 | |||
692 | static ssize_t read_file_misc(struct file *file, char __user *user_buf, | ||
693 | size_t count, loff_t *ppos) | ||
694 | { | ||
695 | struct ath_softc *sc = file->private_data; | ||
696 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); | ||
697 | struct ath_hw *ah = sc->sc_ah; | ||
698 | struct ieee80211_hw *hw = sc->hw; | ||
699 | char *buf; | ||
700 | unsigned int len = 0, size = 8000; | ||
701 | ssize_t retval = 0; | ||
702 | const char *tmp; | ||
703 | unsigned int reg; | ||
704 | struct ath9k_vif_iter_data iter_data; | ||
705 | |||
706 | ath9k_calculate_iter_data(hw, NULL, &iter_data); | ||
707 | |||
708 | buf = kzalloc(size, GFP_KERNEL); | ||
709 | if (buf == NULL) | ||
710 | return -ENOMEM; | ||
711 | |||
712 | switch (sc->sc_ah->opmode) { | ||
713 | case NL80211_IFTYPE_ADHOC: | ||
714 | tmp = "ADHOC"; | ||
715 | break; | ||
716 | case NL80211_IFTYPE_MESH_POINT: | ||
717 | tmp = "MESH"; | ||
718 | break; | ||
719 | case NL80211_IFTYPE_AP: | ||
720 | tmp = "AP"; | ||
721 | break; | ||
722 | case NL80211_IFTYPE_STATION: | ||
723 | tmp = "STATION"; | ||
724 | break; | ||
725 | default: | ||
726 | tmp = "???"; | ||
727 | break; | ||
728 | } | ||
729 | |||
730 | ath9k_ps_wakeup(sc); | ||
731 | len += snprintf(buf + len, size - len, | ||
732 | "curbssid: %pM\n" | ||
733 | "OP-Mode: %s(%i)\n" | ||
734 | "Beacon-Timer-Register: 0x%x\n", | ||
735 | common->curbssid, | ||
736 | tmp, (int)(sc->sc_ah->opmode), | ||
737 | REG_READ(ah, AR_BEACON_PERIOD)); | ||
738 | |||
739 | reg = REG_READ(ah, AR_TIMER_MODE); | ||
740 | ath9k_ps_restore(sc); | ||
741 | len += snprintf(buf + len, size - len, "Timer-Mode-Register: 0x%x (", | ||
742 | reg); | ||
743 | if (reg & AR_TBTT_TIMER_EN) | ||
744 | len += snprintf(buf + len, size - len, "TBTT "); | ||
745 | if (reg & AR_DBA_TIMER_EN) | ||
746 | len += snprintf(buf + len, size - len, "DBA "); | ||
747 | if (reg & AR_SWBA_TIMER_EN) | ||
748 | len += snprintf(buf + len, size - len, "SWBA "); | ||
749 | if (reg & AR_HCF_TIMER_EN) | ||
750 | len += snprintf(buf + len, size - len, "HCF "); | ||
751 | if (reg & AR_TIM_TIMER_EN) | ||
752 | len += snprintf(buf + len, size - len, "TIM "); | ||
753 | if (reg & AR_DTIM_TIMER_EN) | ||
754 | len += snprintf(buf + len, size - len, "DTIM "); | ||
755 | len += snprintf(buf + len, size - len, ")\n"); | ||
756 | |||
757 | reg = sc->sc_ah->imask; | ||
758 | len += snprintf(buf + len, size - len, "imask: 0x%x (", reg); | ||
759 | if (reg & ATH9K_INT_SWBA) | ||
760 | len += snprintf(buf + len, size - len, "SWBA "); | ||
761 | if (reg & ATH9K_INT_BMISS) | ||
762 | len += snprintf(buf + len, size - len, "BMISS "); | ||
763 | if (reg & ATH9K_INT_CST) | ||
764 | len += snprintf(buf + len, size - len, "CST "); | ||
765 | if (reg & ATH9K_INT_RX) | ||
766 | len += snprintf(buf + len, size - len, "RX "); | ||
767 | if (reg & ATH9K_INT_RXHP) | ||
768 | len += snprintf(buf + len, size - len, "RXHP "); | ||
769 | if (reg & ATH9K_INT_RXLP) | ||
770 | len += snprintf(buf + len, size - len, "RXLP "); | ||
771 | if (reg & ATH9K_INT_BB_WATCHDOG) | ||
772 | len += snprintf(buf + len, size - len, "BB_WATCHDOG "); | ||
773 | /* there are other IRQs if one wanted to add them. */ | ||
774 | len += snprintf(buf + len, size - len, ")\n"); | ||
775 | |||
776 | len += snprintf(buf + len, size - len, | ||
777 | "VIF Counts: AP: %i STA: %i MESH: %i WDS: %i" | ||
778 | " ADHOC: %i OTHER: %i nvifs: %hi beacon-vifs: %hi\n", | ||
779 | iter_data.naps, iter_data.nstations, iter_data.nmeshes, | ||
780 | iter_data.nwds, iter_data.nadhocs, iter_data.nothers, | ||
781 | sc->nvifs, sc->nbcnvifs); | ||
782 | |||
783 | len += snprintf(buf + len, size - len, | ||
784 | "Calculated-BSSID-Mask: %pM\n", | ||
785 | iter_data.mask); | ||
786 | |||
787 | if (len > size) | ||
788 | len = size; | ||
789 | |||
790 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); | ||
791 | kfree(buf); | ||
792 | |||
793 | return retval; | ||
794 | } | ||
795 | |||
796 | void ath_debug_stat_tx(struct ath_softc *sc, struct ath_buf *bf, | ||
797 | struct ath_tx_status *ts, struct ath_txq *txq) | ||
798 | { | ||
799 | int qnum = txq->axq_qnum; | ||
800 | |||
801 | TX_STAT_INC(qnum, tx_pkts_all); | ||
802 | sc->debug.stats.txstats[qnum].tx_bytes_all += bf->bf_mpdu->len; | ||
803 | |||
679 | if (bf_isampdu(bf)) { | 804 | if (bf_isampdu(bf)) { |
680 | if (bf_isxretried(bf)) | 805 | if (bf_isxretried(bf)) |
681 | TX_STAT_INC(txq->axq_qnum, a_xretries); | 806 | TX_STAT_INC(qnum, a_xretries); |
682 | else | 807 | else |
683 | TX_STAT_INC(txq->axq_qnum, a_completed); | 808 | TX_STAT_INC(qnum, a_completed); |
684 | } else { | 809 | } else { |
685 | TX_STAT_INC(txq->axq_qnum, completed); | 810 | TX_STAT_INC(qnum, completed); |
686 | } | 811 | } |
687 | 812 | ||
688 | if (ts->ts_status & ATH9K_TXERR_FIFO) | 813 | if (ts->ts_status & ATH9K_TXERR_FIFO) |
689 | TX_STAT_INC(txq->axq_qnum, fifo_underrun); | 814 | TX_STAT_INC(qnum, fifo_underrun); |
690 | if (ts->ts_status & ATH9K_TXERR_XTXOP) | 815 | if (ts->ts_status & ATH9K_TXERR_XTXOP) |
691 | TX_STAT_INC(txq->axq_qnum, xtxop); | 816 | TX_STAT_INC(qnum, xtxop); |
692 | if (ts->ts_status & ATH9K_TXERR_TIMER_EXPIRED) | 817 | if (ts->ts_status & ATH9K_TXERR_TIMER_EXPIRED) |
693 | TX_STAT_INC(txq->axq_qnum, timer_exp); | 818 | TX_STAT_INC(qnum, timer_exp); |
694 | if (ts->ts_flags & ATH9K_TX_DESC_CFG_ERR) | 819 | if (ts->ts_flags & ATH9K_TX_DESC_CFG_ERR) |
695 | TX_STAT_INC(txq->axq_qnum, desc_cfg_err); | 820 | TX_STAT_INC(qnum, desc_cfg_err); |
696 | if (ts->ts_flags & ATH9K_TX_DATA_UNDERRUN) | 821 | if (ts->ts_flags & ATH9K_TX_DATA_UNDERRUN) |
697 | TX_STAT_INC(txq->axq_qnum, data_underrun); | 822 | TX_STAT_INC(qnum, data_underrun); |
698 | if (ts->ts_flags & ATH9K_TX_DELIM_UNDERRUN) | 823 | if (ts->ts_flags & ATH9K_TX_DELIM_UNDERRUN) |
699 | TX_STAT_INC(txq->axq_qnum, delim_underrun); | 824 | TX_STAT_INC(qnum, delim_underrun); |
700 | } | 825 | } |
701 | 826 | ||
702 | static const struct file_operations fops_xmit = { | 827 | static const struct file_operations fops_xmit = { |
703 | .read = read_file_xmit, | 828 | .read = read_file_xmit, |
704 | .open = ath9k_debugfs_open, | 829 | .open = ath9k_debugfs_open, |
705 | .owner = THIS_MODULE | 830 | .owner = THIS_MODULE, |
831 | .llseek = default_llseek, | ||
832 | }; | ||
833 | |||
834 | static const struct file_operations fops_stations = { | ||
835 | .read = read_file_stations, | ||
836 | .open = ath9k_debugfs_open, | ||
837 | .owner = THIS_MODULE, | ||
838 | .llseek = default_llseek, | ||
839 | }; | ||
840 | |||
841 | static const struct file_operations fops_misc = { | ||
842 | .read = read_file_misc, | ||
843 | .open = ath9k_debugfs_open, | ||
844 | .owner = THIS_MODULE, | ||
845 | .llseek = default_llseek, | ||
706 | }; | 846 | }; |
707 | 847 | ||
708 | static ssize_t read_file_recv(struct file *file, char __user *user_buf, | 848 | static ssize_t read_file_recv(struct file *file, char __user *user_buf, |
@@ -714,7 +854,7 @@ static ssize_t read_file_recv(struct file *file, char __user *user_buf, | |||
714 | 854 | ||
715 | struct ath_softc *sc = file->private_data; | 855 | struct ath_softc *sc = file->private_data; |
716 | char *buf; | 856 | char *buf; |
717 | unsigned int len = 0, size = 1152; | 857 | unsigned int len = 0, size = 1400; |
718 | ssize_t retval = 0; | 858 | ssize_t retval = 0; |
719 | 859 | ||
720 | buf = kzalloc(size, GFP_KERNEL); | 860 | buf = kzalloc(size, GFP_KERNEL); |
@@ -743,6 +883,34 @@ static ssize_t read_file_recv(struct file *file, char __user *user_buf, | |||
743 | "%18s : %10u\n", "DECRYPT BUSY ERR", | 883 | "%18s : %10u\n", "DECRYPT BUSY ERR", |
744 | sc->debug.stats.rxstats.decrypt_busy_err); | 884 | sc->debug.stats.rxstats.decrypt_busy_err); |
745 | 885 | ||
886 | len += snprintf(buf + len, size - len, | ||
887 | "%18s : %10d\n", "RSSI-CTL0", | ||
888 | sc->debug.stats.rxstats.rs_rssi_ctl0); | ||
889 | |||
890 | len += snprintf(buf + len, size - len, | ||
891 | "%18s : %10d\n", "RSSI-CTL1", | ||
892 | sc->debug.stats.rxstats.rs_rssi_ctl1); | ||
893 | |||
894 | len += snprintf(buf + len, size - len, | ||
895 | "%18s : %10d\n", "RSSI-CTL2", | ||
896 | sc->debug.stats.rxstats.rs_rssi_ctl2); | ||
897 | |||
898 | len += snprintf(buf + len, size - len, | ||
899 | "%18s : %10d\n", "RSSI-EXT0", | ||
900 | sc->debug.stats.rxstats.rs_rssi_ext0); | ||
901 | |||
902 | len += snprintf(buf + len, size - len, | ||
903 | "%18s : %10d\n", "RSSI-EXT1", | ||
904 | sc->debug.stats.rxstats.rs_rssi_ext1); | ||
905 | |||
906 | len += snprintf(buf + len, size - len, | ||
907 | "%18s : %10d\n", "RSSI-EXT2", | ||
908 | sc->debug.stats.rxstats.rs_rssi_ext2); | ||
909 | |||
910 | len += snprintf(buf + len, size - len, | ||
911 | "%18s : %10d\n", "Rx Antenna", | ||
912 | sc->debug.stats.rxstats.rs_antenna); | ||
913 | |||
746 | PHY_ERR("UNDERRUN", ATH9K_PHYERR_UNDERRUN); | 914 | PHY_ERR("UNDERRUN", ATH9K_PHYERR_UNDERRUN); |
747 | PHY_ERR("TIMING", ATH9K_PHYERR_TIMING); | 915 | PHY_ERR("TIMING", ATH9K_PHYERR_TIMING); |
748 | PHY_ERR("PARITY", ATH9K_PHYERR_PARITY); | 916 | PHY_ERR("PARITY", ATH9K_PHYERR_PARITY); |
@@ -770,6 +938,13 @@ static ssize_t read_file_recv(struct file *file, char __user *user_buf, | |||
770 | PHY_ERR("HT-LENGTH", ATH9K_PHYERR_HT_LENGTH_ILLEGAL); | 938 | PHY_ERR("HT-LENGTH", ATH9K_PHYERR_HT_LENGTH_ILLEGAL); |
771 | PHY_ERR("HT-RATE", ATH9K_PHYERR_HT_RATE_ILLEGAL); | 939 | PHY_ERR("HT-RATE", ATH9K_PHYERR_HT_RATE_ILLEGAL); |
772 | 940 | ||
941 | len += snprintf(buf + len, size - len, | ||
942 | "%18s : %10u\n", "RX-Pkts-All", | ||
943 | sc->debug.stats.rxstats.rx_pkts_all); | ||
944 | len += snprintf(buf + len, size - len, | ||
945 | "%18s : %10u\n", "RX-Bytes-All", | ||
946 | sc->debug.stats.rxstats.rx_bytes_all); | ||
947 | |||
773 | if (len > size) | 948 | if (len > size) |
774 | len = size; | 949 | len = size; |
775 | 950 | ||
@@ -788,6 +963,9 @@ void ath_debug_stat_rx(struct ath_softc *sc, struct ath_rx_status *rs) | |||
788 | 963 | ||
789 | u32 phyerr; | 964 | u32 phyerr; |
790 | 965 | ||
966 | RX_STAT_INC(rx_pkts_all); | ||
967 | sc->debug.stats.rxstats.rx_bytes_all += rs->rs_datalen; | ||
968 | |||
791 | if (rs->rs_status & ATH9K_RXERR_CRC) | 969 | if (rs->rs_status & ATH9K_RXERR_CRC) |
792 | RX_STAT_INC(crc_err); | 970 | RX_STAT_INC(crc_err); |
793 | if (rs->rs_status & ATH9K_RXERR_DECRYPT) | 971 | if (rs->rs_status & ATH9K_RXERR_DECRYPT) |
@@ -807,6 +985,16 @@ void ath_debug_stat_rx(struct ath_softc *sc, struct ath_rx_status *rs) | |||
807 | RX_PHY_ERR_INC(phyerr); | 985 | RX_PHY_ERR_INC(phyerr); |
808 | } | 986 | } |
809 | 987 | ||
988 | sc->debug.stats.rxstats.rs_rssi_ctl0 = rs->rs_rssi_ctl0; | ||
989 | sc->debug.stats.rxstats.rs_rssi_ctl1 = rs->rs_rssi_ctl1; | ||
990 | sc->debug.stats.rxstats.rs_rssi_ctl2 = rs->rs_rssi_ctl2; | ||
991 | |||
992 | sc->debug.stats.rxstats.rs_rssi_ext0 = rs->rs_rssi_ext0; | ||
993 | sc->debug.stats.rxstats.rs_rssi_ext1 = rs->rs_rssi_ext1; | ||
994 | sc->debug.stats.rxstats.rs_rssi_ext2 = rs->rs_rssi_ext2; | ||
995 | |||
996 | sc->debug.stats.rxstats.rs_antenna = rs->rs_antenna; | ||
997 | |||
810 | #undef RX_STAT_INC | 998 | #undef RX_STAT_INC |
811 | #undef RX_PHY_ERR_INC | 999 | #undef RX_PHY_ERR_INC |
812 | } | 1000 | } |
@@ -814,7 +1002,8 @@ void ath_debug_stat_rx(struct ath_softc *sc, struct ath_rx_status *rs) | |||
814 | static const struct file_operations fops_recv = { | 1002 | static const struct file_operations fops_recv = { |
815 | .read = read_file_recv, | 1003 | .read = read_file_recv, |
816 | .open = ath9k_debugfs_open, | 1004 | .open = ath9k_debugfs_open, |
817 | .owner = THIS_MODULE | 1005 | .owner = THIS_MODULE, |
1006 | .llseek = default_llseek, | ||
818 | }; | 1007 | }; |
819 | 1008 | ||
820 | static ssize_t read_file_regidx(struct file *file, char __user *user_buf, | 1009 | static ssize_t read_file_regidx(struct file *file, char __user *user_buf, |
@@ -852,7 +1041,8 @@ static const struct file_operations fops_regidx = { | |||
852 | .read = read_file_regidx, | 1041 | .read = read_file_regidx, |
853 | .write = write_file_regidx, | 1042 | .write = write_file_regidx, |
854 | .open = ath9k_debugfs_open, | 1043 | .open = ath9k_debugfs_open, |
855 | .owner = THIS_MODULE | 1044 | .owner = THIS_MODULE, |
1045 | .llseek = default_llseek, | ||
856 | }; | 1046 | }; |
857 | 1047 | ||
858 | static ssize_t read_file_regval(struct file *file, char __user *user_buf, | 1048 | static ssize_t read_file_regval(struct file *file, char __user *user_buf, |
@@ -864,7 +1054,9 @@ static ssize_t read_file_regval(struct file *file, char __user *user_buf, | |||
864 | unsigned int len; | 1054 | unsigned int len; |
865 | u32 regval; | 1055 | u32 regval; |
866 | 1056 | ||
1057 | ath9k_ps_wakeup(sc); | ||
867 | regval = REG_READ_D(ah, sc->debug.regidx); | 1058 | regval = REG_READ_D(ah, sc->debug.regidx); |
1059 | ath9k_ps_restore(sc); | ||
868 | len = sprintf(buf, "0x%08x\n", regval); | 1060 | len = sprintf(buf, "0x%08x\n", regval); |
869 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); | 1061 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); |
870 | } | 1062 | } |
@@ -886,7 +1078,9 @@ static ssize_t write_file_regval(struct file *file, const char __user *user_buf, | |||
886 | if (strict_strtoul(buf, 0, ®val)) | 1078 | if (strict_strtoul(buf, 0, ®val)) |
887 | return -EINVAL; | 1079 | return -EINVAL; |
888 | 1080 | ||
1081 | ath9k_ps_wakeup(sc); | ||
889 | REG_WRITE_D(ah, sc->debug.regidx, regval); | 1082 | REG_WRITE_D(ah, sc->debug.regidx, regval); |
1083 | ath9k_ps_restore(sc); | ||
890 | return count; | 1084 | return count; |
891 | } | 1085 | } |
892 | 1086 | ||
@@ -894,98 +1088,94 @@ static const struct file_operations fops_regval = { | |||
894 | .read = read_file_regval, | 1088 | .read = read_file_regval, |
895 | .write = write_file_regval, | 1089 | .write = write_file_regval, |
896 | .open = ath9k_debugfs_open, | 1090 | .open = ath9k_debugfs_open, |
897 | .owner = THIS_MODULE | 1091 | .owner = THIS_MODULE, |
1092 | .llseek = default_llseek, | ||
898 | }; | 1093 | }; |
899 | 1094 | ||
900 | int ath9k_init_debug(struct ath_hw *ah) | 1095 | #define REGDUMP_LINE_SIZE 20 |
901 | { | ||
902 | struct ath_common *common = ath9k_hw_common(ah); | ||
903 | struct ath_softc *sc = (struct ath_softc *) common->priv; | ||
904 | 1096 | ||
905 | if (!ath9k_debugfs_root) | 1097 | static int open_file_regdump(struct inode *inode, struct file *file) |
906 | return -ENOENT; | 1098 | { |
1099 | struct ath_softc *sc = inode->i_private; | ||
1100 | unsigned int len = 0; | ||
1101 | u8 *buf; | ||
1102 | int i; | ||
1103 | unsigned long num_regs, regdump_len, max_reg_offset; | ||
907 | 1104 | ||
908 | sc->debug.debugfs_phy = debugfs_create_dir(wiphy_name(sc->hw->wiphy), | 1105 | max_reg_offset = AR_SREV_9300_20_OR_LATER(sc->sc_ah) ? 0x16bd4 : 0xb500; |
909 | ath9k_debugfs_root); | 1106 | num_regs = max_reg_offset / 4 + 1; |
910 | if (!sc->debug.debugfs_phy) | 1107 | regdump_len = num_regs * REGDUMP_LINE_SIZE + 1; |
1108 | buf = vmalloc(regdump_len); | ||
1109 | if (!buf) | ||
911 | return -ENOMEM; | 1110 | return -ENOMEM; |
912 | 1111 | ||
913 | #ifdef CONFIG_ATH_DEBUG | 1112 | ath9k_ps_wakeup(sc); |
914 | if (!debugfs_create_file("debug", S_IRUSR | S_IWUSR, | 1113 | for (i = 0; i < num_regs; i++) |
915 | sc->debug.debugfs_phy, sc, &fops_debug)) | 1114 | len += scnprintf(buf + len, regdump_len - len, |
916 | goto err; | 1115 | "0x%06x 0x%08x\n", i << 2, REG_READ(sc->sc_ah, i << 2)); |
917 | #endif | 1116 | ath9k_ps_restore(sc); |
918 | |||
919 | if (!debugfs_create_file("dma", S_IRUSR, sc->debug.debugfs_phy, | ||
920 | sc, &fops_dma)) | ||
921 | goto err; | ||
922 | |||
923 | if (!debugfs_create_file("interrupt", S_IRUSR, sc->debug.debugfs_phy, | ||
924 | sc, &fops_interrupt)) | ||
925 | goto err; | ||
926 | |||
927 | if (!debugfs_create_file("rcstat", S_IRUSR, sc->debug.debugfs_phy, | ||
928 | sc, &fops_rcstat)) | ||
929 | goto err; | ||
930 | |||
931 | if (!debugfs_create_file("wiphy", S_IRUSR | S_IWUSR, | ||
932 | sc->debug.debugfs_phy, sc, &fops_wiphy)) | ||
933 | goto err; | ||
934 | |||
935 | if (!debugfs_create_file("xmit", S_IRUSR, sc->debug.debugfs_phy, | ||
936 | sc, &fops_xmit)) | ||
937 | goto err; | ||
938 | |||
939 | if (!debugfs_create_file("recv", S_IRUSR, sc->debug.debugfs_phy, | ||
940 | sc, &fops_recv)) | ||
941 | goto err; | ||
942 | |||
943 | if (!debugfs_create_file("rx_chainmask", S_IRUSR | S_IWUSR, | ||
944 | sc->debug.debugfs_phy, sc, &fops_rx_chainmask)) | ||
945 | goto err; | ||
946 | |||
947 | if (!debugfs_create_file("tx_chainmask", S_IRUSR | S_IWUSR, | ||
948 | sc->debug.debugfs_phy, sc, &fops_tx_chainmask)) | ||
949 | goto err; | ||
950 | |||
951 | if (!debugfs_create_file("regidx", S_IRUSR | S_IWUSR, | ||
952 | sc->debug.debugfs_phy, sc, &fops_regidx)) | ||
953 | goto err; | ||
954 | |||
955 | if (!debugfs_create_file("regval", S_IRUSR | S_IWUSR, | ||
956 | sc->debug.debugfs_phy, sc, &fops_regval)) | ||
957 | goto err; | ||
958 | 1117 | ||
959 | if (!debugfs_create_bool("ignore_extcca", S_IRUSR | S_IWUSR, | 1118 | file->private_data = buf; |
960 | sc->debug.debugfs_phy, &ah->config.cwm_ignore_extcca)) | ||
961 | goto err; | ||
962 | 1119 | ||
963 | sc->debug.regidx = 0; | ||
964 | return 0; | 1120 | return 0; |
965 | err: | ||
966 | ath9k_exit_debug(ah); | ||
967 | return -ENOMEM; | ||
968 | } | 1121 | } |
969 | 1122 | ||
970 | void ath9k_exit_debug(struct ath_hw *ah) | 1123 | static const struct file_operations fops_regdump = { |
1124 | .open = open_file_regdump, | ||
1125 | .read = ath9k_debugfs_read_buf, | ||
1126 | .release = ath9k_debugfs_release_buf, | ||
1127 | .owner = THIS_MODULE, | ||
1128 | .llseek = default_llseek,/* read accesses f_pos */ | ||
1129 | }; | ||
1130 | |||
1131 | int ath9k_init_debug(struct ath_hw *ah) | ||
971 | { | 1132 | { |
972 | struct ath_common *common = ath9k_hw_common(ah); | 1133 | struct ath_common *common = ath9k_hw_common(ah); |
973 | struct ath_softc *sc = (struct ath_softc *) common->priv; | 1134 | struct ath_softc *sc = (struct ath_softc *) common->priv; |
974 | 1135 | ||
975 | debugfs_remove_recursive(sc->debug.debugfs_phy); | 1136 | sc->debug.debugfs_phy = debugfs_create_dir("ath9k", |
976 | } | 1137 | sc->hw->wiphy->debugfsdir); |
1138 | if (!sc->debug.debugfs_phy) | ||
1139 | return -ENOMEM; | ||
977 | 1140 | ||
978 | int ath9k_debug_create_root(void) | 1141 | #ifdef CONFIG_ATH_DEBUG |
979 | { | 1142 | debugfs_create_file("debug", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, |
980 | ath9k_debugfs_root = debugfs_create_dir(KBUILD_MODNAME, NULL); | 1143 | sc, &fops_debug); |
981 | if (!ath9k_debugfs_root) | 1144 | #endif |
982 | return -ENOENT; | 1145 | debugfs_create_file("dma", S_IRUSR, sc->debug.debugfs_phy, sc, |
1146 | &fops_dma); | ||
1147 | debugfs_create_file("interrupt", S_IRUSR, sc->debug.debugfs_phy, sc, | ||
1148 | &fops_interrupt); | ||
1149 | debugfs_create_file("wiphy", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, | ||
1150 | sc, &fops_wiphy); | ||
1151 | debugfs_create_file("xmit", S_IRUSR, sc->debug.debugfs_phy, sc, | ||
1152 | &fops_xmit); | ||
1153 | debugfs_create_file("stations", S_IRUSR, sc->debug.debugfs_phy, sc, | ||
1154 | &fops_stations); | ||
1155 | debugfs_create_file("misc", S_IRUSR, sc->debug.debugfs_phy, sc, | ||
1156 | &fops_misc); | ||
1157 | debugfs_create_file("recv", S_IRUSR, sc->debug.debugfs_phy, sc, | ||
1158 | &fops_recv); | ||
1159 | debugfs_create_file("rx_chainmask", S_IRUSR | S_IWUSR, | ||
1160 | sc->debug.debugfs_phy, sc, &fops_rx_chainmask); | ||
1161 | debugfs_create_file("tx_chainmask", S_IRUSR | S_IWUSR, | ||
1162 | sc->debug.debugfs_phy, sc, &fops_tx_chainmask); | ||
1163 | debugfs_create_file("regidx", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, | ||
1164 | sc, &fops_regidx); | ||
1165 | debugfs_create_file("regval", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, | ||
1166 | sc, &fops_regval); | ||
1167 | debugfs_create_bool("ignore_extcca", S_IRUSR | S_IWUSR, | ||
1168 | sc->debug.debugfs_phy, | ||
1169 | &ah->config.cwm_ignore_extcca); | ||
1170 | debugfs_create_file("regdump", S_IRUSR, sc->debug.debugfs_phy, sc, | ||
1171 | &fops_regdump); | ||
1172 | |||
1173 | debugfs_create_u32("gpio_mask", S_IRUSR | S_IWUSR, | ||
1174 | sc->debug.debugfs_phy, &sc->sc_ah->gpio_mask); | ||
1175 | |||
1176 | debugfs_create_u32("gpio_val", S_IRUSR | S_IWUSR, | ||
1177 | sc->debug.debugfs_phy, &sc->sc_ah->gpio_val); | ||
983 | 1178 | ||
1179 | sc->debug.regidx = 0; | ||
984 | return 0; | 1180 | return 0; |
985 | } | 1181 | } |
986 | |||
987 | void ath9k_debug_remove_root(void) | ||
988 | { | ||
989 | debugfs_remove(ath9k_debugfs_root); | ||
990 | ath9k_debugfs_root = NULL; | ||
991 | } | ||