diff options
author | Arend van Spriel <arend@broadcom.com> | 2014-11-09 05:31:59 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-11-26 22:38:37 -0500 |
commit | 631bee257bd506ad6622aac16dfeedce09034ade (patch) | |
tree | f07e1e5d8ad24d9102134f089aefd8cb04b97e4a /drivers/net | |
parent | 98210b7f73f1db182bd9a558a031093cd166e907 (diff) |
ath: use seq_file api for ath9k debugfs files
The debugfs files that are defined in debug.c which are read-only
and using a simple_open as .open file operation have been modified
to use the single_open seq_file API. This simplifies the read
functions defining the file contents.
Signed-off-by: Arend van Spriel <arend@broadcom.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/wireless/ath/ath9k/debug.c | 455 | ||||
-rw-r--r-- | drivers/net/wireless/ath/ath9k/debug.h | 11 |
2 files changed, 192 insertions, 274 deletions
diff --git a/drivers/net/wireless/ath/ath9k/debug.c b/drivers/net/wireless/ath/ath9k/debug.c index 5c45e787814e..e7b709f03b29 100644 --- a/drivers/net/wireless/ath/ath9k/debug.c +++ b/drivers/net/wireless/ath/ath9k/debug.c | |||
@@ -401,22 +401,14 @@ static const struct file_operations fops_antenna_diversity = { | |||
401 | .llseek = default_llseek, | 401 | .llseek = default_llseek, |
402 | }; | 402 | }; |
403 | 403 | ||
404 | static ssize_t read_file_dma(struct file *file, char __user *user_buf, | 404 | static int read_file_dma(struct seq_file *file, void *data) |
405 | size_t count, loff_t *ppos) | ||
406 | { | 405 | { |
407 | struct ath_softc *sc = file->private_data; | 406 | struct ath_softc *sc = file->private; |
408 | struct ath_hw *ah = sc->sc_ah; | 407 | struct ath_hw *ah = sc->sc_ah; |
409 | char *buf; | ||
410 | int retval; | ||
411 | unsigned int len = 0; | ||
412 | u32 val[ATH9K_NUM_DMA_DEBUG_REGS]; | 408 | u32 val[ATH9K_NUM_DMA_DEBUG_REGS]; |
413 | int i, qcuOffset = 0, dcuOffset = 0; | 409 | int i, qcuOffset = 0, dcuOffset = 0; |
414 | u32 *qcuBase = &val[0], *dcuBase = &val[4]; | 410 | u32 *qcuBase = &val[0], *dcuBase = &val[4]; |
415 | 411 | ||
416 | buf = kmalloc(DMA_BUF_LEN, GFP_KERNEL); | ||
417 | if (!buf) | ||
418 | return -ENOMEM; | ||
419 | |||
420 | ath9k_ps_wakeup(sc); | 412 | ath9k_ps_wakeup(sc); |
421 | 413 | ||
422 | REG_WRITE_D(ah, AR_MACMISC, | 414 | REG_WRITE_D(ah, AR_MACMISC, |
@@ -424,21 +416,18 @@ static ssize_t read_file_dma(struct file *file, char __user *user_buf, | |||
424 | (AR_MACMISC_MISC_OBS_BUS_1 << | 416 | (AR_MACMISC_MISC_OBS_BUS_1 << |
425 | AR_MACMISC_MISC_OBS_BUS_MSB_S))); | 417 | AR_MACMISC_MISC_OBS_BUS_MSB_S))); |
426 | 418 | ||
427 | len += scnprintf(buf + len, DMA_BUF_LEN - len, | 419 | seq_puts(file, "Raw DMA Debug values:\n"); |
428 | "Raw DMA Debug values:\n"); | ||
429 | 420 | ||
430 | for (i = 0; i < ATH9K_NUM_DMA_DEBUG_REGS; i++) { | 421 | for (i = 0; i < ATH9K_NUM_DMA_DEBUG_REGS; i++) { |
431 | if (i % 4 == 0) | 422 | if (i % 4 == 0) |
432 | len += scnprintf(buf + len, DMA_BUF_LEN - len, "\n"); | 423 | seq_puts(file, "\n"); |
433 | 424 | ||
434 | val[i] = REG_READ_D(ah, AR_DMADBG_0 + (i * sizeof(u32))); | 425 | val[i] = REG_READ_D(ah, AR_DMADBG_0 + (i * sizeof(u32))); |
435 | len += scnprintf(buf + len, DMA_BUF_LEN - len, "%d: %08x ", | 426 | seq_printf(file, "%d: %08x ", i, val[i]); |
436 | i, val[i]); | ||
437 | } | 427 | } |
438 | 428 | ||
439 | len += scnprintf(buf + len, DMA_BUF_LEN - len, "\n\n"); | 429 | seq_puts(file, "\n\n"); |
440 | len += scnprintf(buf + len, DMA_BUF_LEN - len, | 430 | seq_puts(file, "Num QCU: chain_st fsp_ok fsp_st DCU: chain_st\n"); |
441 | "Num QCU: chain_st fsp_ok fsp_st DCU: chain_st\n"); | ||
442 | 431 | ||
443 | for (i = 0; i < ATH9K_NUM_QUEUES; i++, qcuOffset += 4, dcuOffset += 5) { | 432 | for (i = 0; i < ATH9K_NUM_QUEUES; i++, qcuOffset += 4, dcuOffset += 5) { |
444 | if (i == 8) { | 433 | if (i == 8) { |
@@ -451,55 +440,47 @@ static ssize_t read_file_dma(struct file *file, char __user *user_buf, | |||
451 | dcuBase++; | 440 | dcuBase++; |
452 | } | 441 | } |
453 | 442 | ||
454 | len += scnprintf(buf + len, DMA_BUF_LEN - len, | 443 | seq_printf(file, "%2d %2x %1x %2x %2x\n", |
455 | "%2d %2x %1x %2x %2x\n", | 444 | i, (*qcuBase & (0x7 << qcuOffset)) >> qcuOffset, |
456 | i, (*qcuBase & (0x7 << qcuOffset)) >> qcuOffset, | 445 | (*qcuBase & (0x8 << qcuOffset)) >> (qcuOffset + 3), |
457 | (*qcuBase & (0x8 << qcuOffset)) >> (qcuOffset + 3), | 446 | (val[2] & (0x7 << (i * 3))) >> (i * 3), |
458 | (val[2] & (0x7 << (i * 3))) >> (i * 3), | 447 | (*dcuBase & (0x1f << dcuOffset)) >> dcuOffset); |
459 | (*dcuBase & (0x1f << dcuOffset)) >> dcuOffset); | ||
460 | } | 448 | } |
461 | 449 | ||
462 | len += scnprintf(buf + len, DMA_BUF_LEN - len, "\n"); | 450 | seq_puts(file, "\n"); |
463 | 451 | ||
464 | len += scnprintf(buf + len, DMA_BUF_LEN - len, | 452 | seq_printf(file, "qcu_stitch state: %2x qcu_fetch state: %2x\n", |
465 | "qcu_stitch state: %2x qcu_fetch state: %2x\n", | 453 | (val[3] & 0x003c0000) >> 18, (val[3] & 0x03c00000) >> 22); |
466 | (val[3] & 0x003c0000) >> 18, (val[3] & 0x03c00000) >> 22); | 454 | seq_printf(file, "qcu_complete state: %2x dcu_complete state: %2x\n", |
467 | len += scnprintf(buf + len, DMA_BUF_LEN - len, | 455 | (val[3] & 0x1c000000) >> 26, (val[6] & 0x3)); |
468 | "qcu_complete state: %2x dcu_complete state: %2x\n", | 456 | seq_printf(file, "dcu_arb state: %2x dcu_fp state: %2x\n", |
469 | (val[3] & 0x1c000000) >> 26, (val[6] & 0x3)); | 457 | (val[5] & 0x06000000) >> 25, (val[5] & 0x38000000) >> 27); |
470 | len += scnprintf(buf + len, DMA_BUF_LEN - len, | 458 | seq_printf(file, "chan_idle_dur: %3d chan_idle_dur_valid: %1d\n", |
471 | "dcu_arb state: %2x dcu_fp state: %2x\n", | 459 | (val[6] & 0x000003fc) >> 2, (val[6] & 0x00000400) >> 10); |
472 | (val[5] & 0x06000000) >> 25, (val[5] & 0x38000000) >> 27); | 460 | seq_printf(file, "txfifo_valid_0: %1d txfifo_valid_1: %1d\n", |
473 | len += scnprintf(buf + len, DMA_BUF_LEN - len, | 461 | (val[6] & 0x00000800) >> 11, (val[6] & 0x00001000) >> 12); |
474 | "chan_idle_dur: %3d chan_idle_dur_valid: %1d\n", | 462 | seq_printf(file, "txfifo_dcu_num_0: %2d txfifo_dcu_num_1: %2d\n", |
475 | (val[6] & 0x000003fc) >> 2, (val[6] & 0x00000400) >> 10); | 463 | (val[6] & 0x0001e000) >> 13, (val[6] & 0x001e0000) >> 17); |
476 | len += scnprintf(buf + len, DMA_BUF_LEN - len, | 464 | |
477 | "txfifo_valid_0: %1d txfifo_valid_1: %1d\n", | 465 | seq_printf(file, "pcu observe: 0x%x\n", REG_READ_D(ah, AR_OBS_BUS_1)); |
478 | (val[6] & 0x00000800) >> 11, (val[6] & 0x00001000) >> 12); | 466 | seq_printf(file, "AR_CR: 0x%x\n", REG_READ_D(ah, AR_CR)); |
479 | len += scnprintf(buf + len, DMA_BUF_LEN - len, | ||
480 | "txfifo_dcu_num_0: %2d txfifo_dcu_num_1: %2d\n", | ||
481 | (val[6] & 0x0001e000) >> 13, (val[6] & 0x001e0000) >> 17); | ||
482 | |||
483 | len += scnprintf(buf + len, DMA_BUF_LEN - len, "pcu observe: 0x%x\n", | ||
484 | REG_READ_D(ah, AR_OBS_BUS_1)); | ||
485 | len += scnprintf(buf + len, DMA_BUF_LEN - len, | ||
486 | "AR_CR: 0x%x\n", REG_READ_D(ah, AR_CR)); | ||
487 | 467 | ||
488 | ath9k_ps_restore(sc); | 468 | ath9k_ps_restore(sc); |
489 | 469 | ||
490 | if (len > DMA_BUF_LEN) | 470 | return 0; |
491 | len = DMA_BUF_LEN; | 471 | } |
492 | 472 | ||
493 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); | 473 | static int open_file_dma(struct inode *inode, struct file *f) |
494 | kfree(buf); | 474 | { |
495 | return retval; | 475 | return single_open(f, read_file_dma, inode->i_private); |
496 | } | 476 | } |
497 | 477 | ||
498 | static const struct file_operations fops_dma = { | 478 | static const struct file_operations fops_dma = { |
499 | .read = read_file_dma, | 479 | .open = open_file_dma, |
500 | .open = simple_open, | 480 | .read = seq_read, |
501 | .owner = THIS_MODULE, | 481 | .owner = THIS_MODULE, |
502 | .llseek = default_llseek, | 482 | .llseek = seq_lseek, |
483 | .release = single_release, | ||
503 | }; | 484 | }; |
504 | 485 | ||
505 | 486 | ||
@@ -556,22 +537,14 @@ void ath_debug_stat_interrupt(struct ath_softc *sc, enum ath9k_int status) | |||
556 | sc->debug.stats.istats.gen_timer++; | 537 | sc->debug.stats.istats.gen_timer++; |
557 | } | 538 | } |
558 | 539 | ||
559 | static ssize_t read_file_interrupt(struct file *file, char __user *user_buf, | 540 | static int read_file_interrupt(struct seq_file *file, void *data) |
560 | size_t count, loff_t *ppos) | ||
561 | { | 541 | { |
562 | struct ath_softc *sc = file->private_data; | 542 | struct ath_softc *sc = file->private; |
563 | unsigned int len = 0; | ||
564 | int rv; | ||
565 | int mxlen = 4000; | ||
566 | char *buf = kmalloc(mxlen, GFP_KERNEL); | ||
567 | if (!buf) | ||
568 | return -ENOMEM; | ||
569 | 543 | ||
570 | #define PR_IS(a, s) \ | 544 | #define PR_IS(a, s) \ |
571 | do { \ | 545 | do { \ |
572 | len += scnprintf(buf + len, mxlen - len, \ | 546 | seq_printf(file, "%21s: %10u\n", a, \ |
573 | "%21s: %10u\n", a, \ | 547 | sc->debug.stats.istats.s); \ |
574 | sc->debug.stats.istats.s); \ | ||
575 | } while (0) | 548 | } while (0) |
576 | 549 | ||
577 | if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) { | 550 | if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) { |
@@ -602,8 +575,7 @@ static ssize_t read_file_interrupt(struct file *file, char __user *user_buf, | |||
602 | PR_IS("GENTIMER", gen_timer); | 575 | PR_IS("GENTIMER", gen_timer); |
603 | PR_IS("TOTAL", total); | 576 | PR_IS("TOTAL", total); |
604 | 577 | ||
605 | len += scnprintf(buf + len, mxlen - len, | 578 | seq_puts(file, "SYNC_CAUSE stats:\n"); |
606 | "SYNC_CAUSE stats:\n"); | ||
607 | 579 | ||
608 | PR_IS("Sync-All", sync_cause_all); | 580 | PR_IS("Sync-All", sync_cause_all); |
609 | PR_IS("RTC-IRQ", sync_rtc_irq); | 581 | PR_IS("RTC-IRQ", sync_rtc_irq); |
@@ -625,35 +597,27 @@ static ssize_t read_file_interrupt(struct file *file, char __user *user_buf, | |||
625 | PR_IS("MAC-Asleep", mac_asleep); | 597 | PR_IS("MAC-Asleep", mac_asleep); |
626 | PR_IS("MAC-Sleep-Access", mac_sleep_access); | 598 | PR_IS("MAC-Sleep-Access", mac_sleep_access); |
627 | 599 | ||
628 | if (len > mxlen) | 600 | return 0; |
629 | len = mxlen; | 601 | } |
630 | 602 | ||
631 | rv = simple_read_from_buffer(user_buf, count, ppos, buf, len); | 603 | static int open_file_interrupt(struct inode *inode, struct file *f) |
632 | kfree(buf); | 604 | { |
633 | return rv; | 605 | return single_open(f, read_file_interrupt, inode->i_private); |
634 | } | 606 | } |
635 | 607 | ||
636 | static const struct file_operations fops_interrupt = { | 608 | static const struct file_operations fops_interrupt = { |
637 | .read = read_file_interrupt, | 609 | .read = seq_read, |
638 | .open = simple_open, | 610 | .open = open_file_interrupt, |
639 | .owner = THIS_MODULE, | 611 | .owner = THIS_MODULE, |
640 | .llseek = default_llseek, | 612 | .llseek = seq_lseek, |
613 | .release = single_release, | ||
641 | }; | 614 | }; |
642 | 615 | ||
643 | static ssize_t read_file_xmit(struct file *file, char __user *user_buf, | 616 | static int read_file_xmit(struct seq_file *file, void *data) |
644 | size_t count, loff_t *ppos) | ||
645 | { | 617 | { |
646 | struct ath_softc *sc = file->private_data; | 618 | struct ath_softc *sc = file->private; |
647 | char *buf; | ||
648 | unsigned int len = 0, size = 2048; | ||
649 | ssize_t retval = 0; | ||
650 | |||
651 | buf = kzalloc(size, GFP_KERNEL); | ||
652 | if (buf == NULL) | ||
653 | return -ENOMEM; | ||
654 | 619 | ||
655 | len += sprintf(buf, "%30s %10s%10s%10s\n\n", | 620 | seq_printf(file, "%30s %10s%10s%10s\n\n", "BE", "BK", "VI", "VO"); |
656 | "BE", "BK", "VI", "VO"); | ||
657 | 621 | ||
658 | PR("MPDUs Queued: ", queued); | 622 | PR("MPDUs Queued: ", queued); |
659 | PR("MPDUs Completed: ", completed); | 623 | PR("MPDUs Completed: ", completed); |
@@ -678,153 +642,115 @@ static ssize_t read_file_xmit(struct file *file, char __user *user_buf, | |||
678 | PR("HW-tx-proc-desc: ", txprocdesc); | 642 | PR("HW-tx-proc-desc: ", txprocdesc); |
679 | PR("TX-Failed: ", txfailed); | 643 | PR("TX-Failed: ", txfailed); |
680 | 644 | ||
681 | if (len > size) | 645 | return 0; |
682 | len = size; | ||
683 | |||
684 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); | ||
685 | kfree(buf); | ||
686 | |||
687 | return retval; | ||
688 | } | 646 | } |
689 | 647 | ||
690 | static ssize_t print_queue(struct ath_softc *sc, struct ath_txq *txq, | 648 | static void print_queue(struct ath_softc *sc, struct ath_txq *txq, |
691 | char *buf, ssize_t size) | 649 | struct seq_file *file) |
692 | { | 650 | { |
693 | ssize_t len = 0; | ||
694 | |||
695 | ath_txq_lock(sc, txq); | 651 | ath_txq_lock(sc, txq); |
696 | 652 | ||
697 | len += scnprintf(buf + len, size - len, "%s: %d ", | 653 | seq_printf(file, "%s: %d ", "qnum", txq->axq_qnum); |
698 | "qnum", txq->axq_qnum); | 654 | seq_printf(file, "%s: %2d ", "qdepth", txq->axq_depth); |
699 | len += scnprintf(buf + len, size - len, "%s: %2d ", | 655 | seq_printf(file, "%s: %2d ", "ampdu-depth", txq->axq_ampdu_depth); |
700 | "qdepth", txq->axq_depth); | 656 | seq_printf(file, "%s: %3d ", "pending", txq->pending_frames); |
701 | len += scnprintf(buf + len, size - len, "%s: %2d ", | 657 | seq_printf(file, "%s: %d\n", "stopped", txq->stopped); |
702 | "ampdu-depth", txq->axq_ampdu_depth); | ||
703 | len += scnprintf(buf + len, size - len, "%s: %3d ", | ||
704 | "pending", txq->pending_frames); | ||
705 | len += scnprintf(buf + len, size - len, "%s: %d\n", | ||
706 | "stopped", txq->stopped); | ||
707 | 658 | ||
708 | ath_txq_unlock(sc, txq); | 659 | ath_txq_unlock(sc, txq); |
709 | return len; | ||
710 | } | 660 | } |
711 | 661 | ||
712 | static ssize_t read_file_queues(struct file *file, char __user *user_buf, | 662 | static int read_file_queues(struct seq_file *file, void *data) |
713 | size_t count, loff_t *ppos) | ||
714 | { | 663 | { |
715 | struct ath_softc *sc = file->private_data; | 664 | struct ath_softc *sc = file->private; |
716 | struct ath_txq *txq; | 665 | struct ath_txq *txq; |
717 | char *buf; | ||
718 | unsigned int len = 0; | ||
719 | const unsigned int size = 1024; | ||
720 | ssize_t retval = 0; | ||
721 | int i; | 666 | int i; |
722 | static const char *qname[4] = { | 667 | static const char *qname[4] = { |
723 | "VO", "VI", "BE", "BK" | 668 | "VO", "VI", "BE", "BK" |
724 | }; | 669 | }; |
725 | 670 | ||
726 | buf = kzalloc(size, GFP_KERNEL); | ||
727 | if (buf == NULL) | ||
728 | return -ENOMEM; | ||
729 | |||
730 | for (i = 0; i < IEEE80211_NUM_ACS; i++) { | 671 | for (i = 0; i < IEEE80211_NUM_ACS; i++) { |
731 | txq = sc->tx.txq_map[i]; | 672 | txq = sc->tx.txq_map[i]; |
732 | len += scnprintf(buf + len, size - len, "(%s): ", qname[i]); | 673 | seq_printf(file, "(%s): ", qname[i]); |
733 | len += print_queue(sc, txq, buf + len, size - len); | 674 | print_queue(sc, txq, file); |
734 | } | 675 | } |
735 | 676 | ||
736 | len += scnprintf(buf + len, size - len, "(CAB): "); | 677 | seq_puts(file, "(CAB): "); |
737 | len += print_queue(sc, sc->beacon.cabq, buf + len, size - len); | 678 | print_queue(sc, sc->beacon.cabq, file); |
738 | |||
739 | if (len > size) | ||
740 | len = size; | ||
741 | |||
742 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); | ||
743 | kfree(buf); | ||
744 | 679 | ||
745 | return retval; | 680 | return 0; |
746 | } | 681 | } |
747 | 682 | ||
748 | static ssize_t read_file_misc(struct file *file, char __user *user_buf, | 683 | static int read_file_misc(struct seq_file *file, void *data) |
749 | size_t count, loff_t *ppos) | ||
750 | { | 684 | { |
751 | struct ath_softc *sc = file->private_data; | 685 | struct ath_softc *sc = file->private; |
752 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); | 686 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
753 | struct ath9k_vif_iter_data iter_data; | 687 | struct ath9k_vif_iter_data iter_data; |
754 | struct ath_chanctx *ctx; | 688 | struct ath_chanctx *ctx; |
755 | char buf[512]; | ||
756 | unsigned int len = 0; | ||
757 | ssize_t retval = 0; | ||
758 | unsigned int reg; | 689 | unsigned int reg; |
759 | u32 rxfilter, i; | 690 | u32 rxfilter, i; |
760 | 691 | ||
761 | len += scnprintf(buf + len, sizeof(buf) - len, | 692 | seq_printf(file, "BSSID: %pM\n", common->curbssid); |
762 | "BSSID: %pM\n", common->curbssid); | 693 | seq_printf(file, "BSSID-MASK: %pM\n", common->bssidmask); |
763 | len += scnprintf(buf + len, sizeof(buf) - len, | 694 | seq_printf(file, "OPMODE: %s\n", |
764 | "BSSID-MASK: %pM\n", common->bssidmask); | 695 | ath_opmode_to_string(sc->sc_ah->opmode)); |
765 | len += scnprintf(buf + len, sizeof(buf) - len, | ||
766 | "OPMODE: %s\n", | ||
767 | ath_opmode_to_string(sc->sc_ah->opmode)); | ||
768 | 696 | ||
769 | ath9k_ps_wakeup(sc); | 697 | ath9k_ps_wakeup(sc); |
770 | rxfilter = ath9k_hw_getrxfilter(sc->sc_ah); | 698 | rxfilter = ath9k_hw_getrxfilter(sc->sc_ah); |
771 | ath9k_ps_restore(sc); | 699 | ath9k_ps_restore(sc); |
772 | 700 | ||
773 | len += scnprintf(buf + len, sizeof(buf) - len, | 701 | seq_printf(file, "RXFILTER: 0x%x", rxfilter); |
774 | "RXFILTER: 0x%x", rxfilter); | ||
775 | 702 | ||
776 | if (rxfilter & ATH9K_RX_FILTER_UCAST) | 703 | if (rxfilter & ATH9K_RX_FILTER_UCAST) |
777 | len += scnprintf(buf + len, sizeof(buf) - len, " UCAST"); | 704 | seq_puts(file, " UCAST"); |
778 | if (rxfilter & ATH9K_RX_FILTER_MCAST) | 705 | if (rxfilter & ATH9K_RX_FILTER_MCAST) |
779 | len += scnprintf(buf + len, sizeof(buf) - len, " MCAST"); | 706 | seq_puts(file, " MCAST"); |
780 | if (rxfilter & ATH9K_RX_FILTER_BCAST) | 707 | if (rxfilter & ATH9K_RX_FILTER_BCAST) |
781 | len += scnprintf(buf + len, sizeof(buf) - len, " BCAST"); | 708 | seq_puts(file, " BCAST"); |
782 | if (rxfilter & ATH9K_RX_FILTER_CONTROL) | 709 | if (rxfilter & ATH9K_RX_FILTER_CONTROL) |
783 | len += scnprintf(buf + len, sizeof(buf) - len, " CONTROL"); | 710 | seq_puts(file, " CONTROL"); |
784 | if (rxfilter & ATH9K_RX_FILTER_BEACON) | 711 | if (rxfilter & ATH9K_RX_FILTER_BEACON) |
785 | len += scnprintf(buf + len, sizeof(buf) - len, " BEACON"); | 712 | seq_puts(file, " BEACON"); |
786 | if (rxfilter & ATH9K_RX_FILTER_PROM) | 713 | if (rxfilter & ATH9K_RX_FILTER_PROM) |
787 | len += scnprintf(buf + len, sizeof(buf) - len, " PROM"); | 714 | seq_puts(file, " PROM"); |
788 | if (rxfilter & ATH9K_RX_FILTER_PROBEREQ) | 715 | if (rxfilter & ATH9K_RX_FILTER_PROBEREQ) |
789 | len += scnprintf(buf + len, sizeof(buf) - len, " PROBEREQ"); | 716 | seq_puts(file, " PROBEREQ"); |
790 | if (rxfilter & ATH9K_RX_FILTER_PHYERR) | 717 | if (rxfilter & ATH9K_RX_FILTER_PHYERR) |
791 | len += scnprintf(buf + len, sizeof(buf) - len, " PHYERR"); | 718 | seq_puts(file, " PHYERR"); |
792 | if (rxfilter & ATH9K_RX_FILTER_MYBEACON) | 719 | if (rxfilter & ATH9K_RX_FILTER_MYBEACON) |
793 | len += scnprintf(buf + len, sizeof(buf) - len, " MYBEACON"); | 720 | seq_puts(file, " MYBEACON"); |
794 | if (rxfilter & ATH9K_RX_FILTER_COMP_BAR) | 721 | if (rxfilter & ATH9K_RX_FILTER_COMP_BAR) |
795 | len += scnprintf(buf + len, sizeof(buf) - len, " COMP_BAR"); | 722 | seq_puts(file, " COMP_BAR"); |
796 | if (rxfilter & ATH9K_RX_FILTER_PSPOLL) | 723 | if (rxfilter & ATH9K_RX_FILTER_PSPOLL) |
797 | len += scnprintf(buf + len, sizeof(buf) - len, " PSPOLL"); | 724 | seq_puts(file, " PSPOLL"); |
798 | if (rxfilter & ATH9K_RX_FILTER_PHYRADAR) | 725 | if (rxfilter & ATH9K_RX_FILTER_PHYRADAR) |
799 | len += scnprintf(buf + len, sizeof(buf) - len, " PHYRADAR"); | 726 | seq_puts(file, " PHYRADAR"); |
800 | if (rxfilter & ATH9K_RX_FILTER_MCAST_BCAST_ALL) | 727 | if (rxfilter & ATH9K_RX_FILTER_MCAST_BCAST_ALL) |
801 | len += scnprintf(buf + len, sizeof(buf) - len, " MCAST_BCAST_ALL"); | 728 | seq_puts(file, " MCAST_BCAST_ALL"); |
802 | if (rxfilter & ATH9K_RX_FILTER_CONTROL_WRAPPER) | 729 | if (rxfilter & ATH9K_RX_FILTER_CONTROL_WRAPPER) |
803 | len += scnprintf(buf + len, sizeof(buf) - len, " CONTROL_WRAPPER"); | 730 | seq_puts(file, " CONTROL_WRAPPER"); |
804 | 731 | ||
805 | len += scnprintf(buf + len, sizeof(buf) - len, "\n"); | 732 | seq_puts(file, "\n"); |
806 | 733 | ||
807 | reg = sc->sc_ah->imask; | 734 | reg = sc->sc_ah->imask; |
808 | 735 | ||
809 | len += scnprintf(buf + len, sizeof(buf) - len, | 736 | seq_printf(file, "INTERRUPT-MASK: 0x%x", reg); |
810 | "INTERRUPT-MASK: 0x%x", reg); | ||
811 | 737 | ||
812 | if (reg & ATH9K_INT_SWBA) | 738 | if (reg & ATH9K_INT_SWBA) |
813 | len += scnprintf(buf + len, sizeof(buf) - len, " SWBA"); | 739 | seq_puts(file, " SWBA"); |
814 | if (reg & ATH9K_INT_BMISS) | 740 | if (reg & ATH9K_INT_BMISS) |
815 | len += scnprintf(buf + len, sizeof(buf) - len, " BMISS"); | 741 | seq_puts(file, " BMISS"); |
816 | if (reg & ATH9K_INT_CST) | 742 | if (reg & ATH9K_INT_CST) |
817 | len += scnprintf(buf + len, sizeof(buf) - len, " CST"); | 743 | seq_puts(file, " CST"); |
818 | if (reg & ATH9K_INT_RX) | 744 | if (reg & ATH9K_INT_RX) |
819 | len += scnprintf(buf + len, sizeof(buf) - len, " RX"); | 745 | seq_puts(file, " RX"); |
820 | if (reg & ATH9K_INT_RXHP) | 746 | if (reg & ATH9K_INT_RXHP) |
821 | len += scnprintf(buf + len, sizeof(buf) - len, " RXHP"); | 747 | seq_puts(file, " RXHP"); |
822 | if (reg & ATH9K_INT_RXLP) | 748 | if (reg & ATH9K_INT_RXLP) |
823 | len += scnprintf(buf + len, sizeof(buf) - len, " RXLP"); | 749 | seq_puts(file, " RXLP"); |
824 | if (reg & ATH9K_INT_BB_WATCHDOG) | 750 | if (reg & ATH9K_INT_BB_WATCHDOG) |
825 | len += scnprintf(buf + len, sizeof(buf) - len, " BB_WATCHDOG"); | 751 | seq_puts(file, " BB_WATCHDOG"); |
826 | 752 | ||
827 | len += scnprintf(buf + len, sizeof(buf) - len, "\n"); | 753 | seq_puts(file, "\n"); |
828 | 754 | ||
829 | i = 0; | 755 | i = 0; |
830 | ath_for_each_chanctx(sc, ctx) { | 756 | ath_for_each_chanctx(sc, ctx) { |
@@ -832,61 +758,42 @@ static ssize_t read_file_misc(struct file *file, char __user *user_buf, | |||
832 | continue; | 758 | continue; |
833 | ath9k_calculate_iter_data(sc, ctx, &iter_data); | 759 | ath9k_calculate_iter_data(sc, ctx, &iter_data); |
834 | 760 | ||
835 | len += scnprintf(buf + len, sizeof(buf) - len, | 761 | seq_printf(file, |
836 | "VIF-COUNTS: CTX %i AP: %i STA: %i MESH: %i WDS: %i", | 762 | "VIF-COUNTS: CTX %i AP: %i STA: %i MESH: %i WDS: %i", |
837 | i++, iter_data.naps, iter_data.nstations, | 763 | i++, iter_data.naps, iter_data.nstations, |
838 | iter_data.nmeshes, iter_data.nwds); | 764 | iter_data.nmeshes, iter_data.nwds); |
839 | len += scnprintf(buf + len, sizeof(buf) - len, | 765 | seq_printf(file, " ADHOC: %i TOTAL: %hi BEACON-VIF: %hi\n", |
840 | " ADHOC: %i TOTAL: %hi BEACON-VIF: %hi\n", | 766 | iter_data.nadhocs, sc->cur_chan->nvifs, |
841 | iter_data.nadhocs, sc->cur_chan->nvifs, sc->nbcnvifs); | 767 | sc->nbcnvifs); |
842 | } | 768 | } |
843 | 769 | ||
844 | if (len > sizeof(buf)) | 770 | return 0; |
845 | len = sizeof(buf); | ||
846 | |||
847 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); | ||
848 | return retval; | ||
849 | } | 771 | } |
850 | 772 | ||
851 | static ssize_t read_file_reset(struct file *file, char __user *user_buf, | 773 | static int read_file_reset(struct seq_file *file, void *data) |
852 | size_t count, loff_t *ppos) | ||
853 | { | 774 | { |
854 | struct ath_softc *sc = file->private_data; | 775 | struct ath_softc *sc = file->private; |
855 | char buf[512]; | 776 | |
856 | unsigned int len = 0; | 777 | seq_printf(file, "%17s: %2d\n", "Baseband Hang", |
857 | 778 | sc->debug.stats.reset[RESET_TYPE_BB_HANG]); | |
858 | len += scnprintf(buf + len, sizeof(buf) - len, | 779 | seq_printf(file, "%17s: %2d\n", "Baseband Watchdog", |
859 | "%17s: %2d\n", "Baseband Hang", | 780 | sc->debug.stats.reset[RESET_TYPE_BB_WATCHDOG]); |
860 | sc->debug.stats.reset[RESET_TYPE_BB_HANG]); | 781 | seq_printf(file, "%17s: %2d\n", "Fatal HW Error", |
861 | len += scnprintf(buf + len, sizeof(buf) - len, | 782 | sc->debug.stats.reset[RESET_TYPE_FATAL_INT]); |
862 | "%17s: %2d\n", "Baseband Watchdog", | 783 | seq_printf(file, "%17s: %2d\n", "TX HW error", |
863 | sc->debug.stats.reset[RESET_TYPE_BB_WATCHDOG]); | 784 | sc->debug.stats.reset[RESET_TYPE_TX_ERROR]); |
864 | len += scnprintf(buf + len, sizeof(buf) - len, | 785 | seq_printf(file, "%17s: %2d\n", "TX Path Hang", |
865 | "%17s: %2d\n", "Fatal HW Error", | 786 | sc->debug.stats.reset[RESET_TYPE_TX_HANG]); |
866 | sc->debug.stats.reset[RESET_TYPE_FATAL_INT]); | 787 | seq_printf(file, "%17s: %2d\n", "PLL RX Hang", |
867 | len += scnprintf(buf + len, sizeof(buf) - len, | 788 | sc->debug.stats.reset[RESET_TYPE_PLL_HANG]); |
868 | "%17s: %2d\n", "TX HW error", | 789 | seq_printf(file, "%17s: %2d\n", "MAC Hang", |
869 | sc->debug.stats.reset[RESET_TYPE_TX_ERROR]); | 790 | sc->debug.stats.reset[RESET_TYPE_MAC_HANG]); |
870 | len += scnprintf(buf + len, sizeof(buf) - len, | 791 | seq_printf(file, "%17s: %2d\n", "Stuck Beacon", |
871 | "%17s: %2d\n", "TX Path Hang", | 792 | sc->debug.stats.reset[RESET_TYPE_BEACON_STUCK]); |
872 | sc->debug.stats.reset[RESET_TYPE_TX_HANG]); | 793 | seq_printf(file, "%17s: %2d\n", "MCI Reset", |
873 | len += scnprintf(buf + len, sizeof(buf) - len, | 794 | sc->debug.stats.reset[RESET_TYPE_MCI]); |
874 | "%17s: %2d\n", "PLL RX Hang", | ||
875 | sc->debug.stats.reset[RESET_TYPE_PLL_HANG]); | ||
876 | len += scnprintf(buf + len, sizeof(buf) - len, | ||
877 | "%17s: %2d\n", "MAC Hang", | ||
878 | sc->debug.stats.reset[RESET_TYPE_MAC_HANG]); | ||
879 | len += scnprintf(buf + len, sizeof(buf) - len, | ||
880 | "%17s: %2d\n", "Stuck Beacon", | ||
881 | sc->debug.stats.reset[RESET_TYPE_BEACON_STUCK]); | ||
882 | len += scnprintf(buf + len, sizeof(buf) - len, | ||
883 | "%17s: %2d\n", "MCI Reset", | ||
884 | sc->debug.stats.reset[RESET_TYPE_MCI]); | ||
885 | |||
886 | if (len > sizeof(buf)) | ||
887 | len = sizeof(buf); | ||
888 | 795 | ||
889 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); | 796 | return 0; |
890 | } | 797 | } |
891 | 798 | ||
892 | void ath_debug_stat_tx(struct ath_softc *sc, struct ath_buf *bf, | 799 | void ath_debug_stat_tx(struct ath_softc *sc, struct ath_buf *bf, |
@@ -926,32 +833,56 @@ void ath_debug_stat_tx(struct ath_softc *sc, struct ath_buf *bf, | |||
926 | TX_STAT_INC(qnum, delim_underrun); | 833 | TX_STAT_INC(qnum, delim_underrun); |
927 | } | 834 | } |
928 | 835 | ||
836 | static int open_file_xmit(struct inode *inode, struct file *f) | ||
837 | { | ||
838 | return single_open(f, read_file_xmit, inode->i_private); | ||
839 | } | ||
840 | |||
929 | static const struct file_operations fops_xmit = { | 841 | static const struct file_operations fops_xmit = { |
930 | .read = read_file_xmit, | 842 | .read = seq_read, |
931 | .open = simple_open, | 843 | .open = open_file_xmit, |
932 | .owner = THIS_MODULE, | 844 | .owner = THIS_MODULE, |
933 | .llseek = default_llseek, | 845 | .llseek = seq_lseek, |
846 | .release = single_release, | ||
934 | }; | 847 | }; |
935 | 848 | ||
849 | static int open_file_queues(struct inode *inode, struct file *f) | ||
850 | { | ||
851 | return single_open(f, read_file_queues, inode->i_private); | ||
852 | } | ||
853 | |||
936 | static const struct file_operations fops_queues = { | 854 | static const struct file_operations fops_queues = { |
937 | .read = read_file_queues, | 855 | .read = seq_read, |
938 | .open = simple_open, | 856 | .open = open_file_queues, |
939 | .owner = THIS_MODULE, | 857 | .owner = THIS_MODULE, |
940 | .llseek = default_llseek, | 858 | .llseek = seq_lseek, |
859 | .release = single_release, | ||
941 | }; | 860 | }; |
942 | 861 | ||
862 | static int open_file_misc(struct inode *inode, struct file *f) | ||
863 | { | ||
864 | return single_open(f, read_file_misc, inode->i_private); | ||
865 | } | ||
866 | |||
943 | static const struct file_operations fops_misc = { | 867 | static const struct file_operations fops_misc = { |
944 | .read = read_file_misc, | 868 | .read = seq_read, |
945 | .open = simple_open, | 869 | .open = open_file_misc, |
946 | .owner = THIS_MODULE, | 870 | .owner = THIS_MODULE, |
947 | .llseek = default_llseek, | 871 | .llseek = seq_lseek, |
872 | .release = single_release, | ||
948 | }; | 873 | }; |
949 | 874 | ||
875 | static int open_file_reset(struct inode *inode, struct file *f) | ||
876 | { | ||
877 | return single_open(f, read_file_reset, inode->i_private); | ||
878 | } | ||
879 | |||
950 | static const struct file_operations fops_reset = { | 880 | static const struct file_operations fops_reset = { |
951 | .read = read_file_reset, | 881 | .read = seq_read, |
952 | .open = simple_open, | 882 | .open = open_file_reset, |
953 | .owner = THIS_MODULE, | 883 | .owner = THIS_MODULE, |
954 | .llseek = default_llseek, | 884 | .llseek = seq_lseek, |
885 | .release = single_release, | ||
955 | }; | 886 | }; |
956 | 887 | ||
957 | void ath_debug_stat_rx(struct ath_softc *sc, struct ath_rx_status *rs) | 888 | void ath_debug_stat_rx(struct ath_softc *sc, struct ath_rx_status *rs) |
@@ -960,7 +891,7 @@ void ath_debug_stat_rx(struct ath_softc *sc, struct ath_rx_status *rs) | |||
960 | } | 891 | } |
961 | 892 | ||
962 | static ssize_t read_file_regidx(struct file *file, char __user *user_buf, | 893 | static ssize_t read_file_regidx(struct file *file, char __user *user_buf, |
963 | size_t count, loff_t *ppos) | 894 | size_t count, loff_t *ppos) |
964 | { | 895 | { |
965 | struct ath_softc *sc = file->private_data; | 896 | struct ath_softc *sc = file->private_data; |
966 | char buf[32]; | 897 | char buf[32]; |
@@ -971,7 +902,7 @@ static ssize_t read_file_regidx(struct file *file, char __user *user_buf, | |||
971 | } | 902 | } |
972 | 903 | ||
973 | static ssize_t write_file_regidx(struct file *file, const char __user *user_buf, | 904 | static ssize_t write_file_regidx(struct file *file, const char __user *user_buf, |
974 | size_t count, loff_t *ppos) | 905 | size_t count, loff_t *ppos) |
975 | { | 906 | { |
976 | struct ath_softc *sc = file->private_data; | 907 | struct ath_softc *sc = file->private_data; |
977 | unsigned long regidx; | 908 | unsigned long regidx; |
@@ -999,7 +930,7 @@ static const struct file_operations fops_regidx = { | |||
999 | }; | 930 | }; |
1000 | 931 | ||
1001 | static ssize_t read_file_regval(struct file *file, char __user *user_buf, | 932 | static ssize_t read_file_regval(struct file *file, char __user *user_buf, |
1002 | size_t count, loff_t *ppos) | 933 | size_t count, loff_t *ppos) |
1003 | { | 934 | { |
1004 | struct ath_softc *sc = file->private_data; | 935 | struct ath_softc *sc = file->private_data; |
1005 | struct ath_hw *ah = sc->sc_ah; | 936 | struct ath_hw *ah = sc->sc_ah; |
@@ -1015,7 +946,7 @@ static ssize_t read_file_regval(struct file *file, char __user *user_buf, | |||
1015 | } | 946 | } |
1016 | 947 | ||
1017 | static ssize_t write_file_regval(struct file *file, const char __user *user_buf, | 948 | static ssize_t write_file_regval(struct file *file, const char __user *user_buf, |
1018 | size_t count, loff_t *ppos) | 949 | size_t count, loff_t *ppos) |
1019 | { | 950 | { |
1020 | struct ath_softc *sc = file->private_data; | 951 | struct ath_softc *sc = file->private_data; |
1021 | struct ath_hw *ah = sc->sc_ah; | 952 | struct ath_hw *ah = sc->sc_ah; |
@@ -1081,57 +1012,45 @@ static const struct file_operations fops_regdump = { | |||
1081 | .llseek = default_llseek,/* read accesses f_pos */ | 1012 | .llseek = default_llseek,/* read accesses f_pos */ |
1082 | }; | 1013 | }; |
1083 | 1014 | ||
1084 | static ssize_t read_file_dump_nfcal(struct file *file, char __user *user_buf, | 1015 | static int read_file_dump_nfcal(struct seq_file *file, void *data) |
1085 | size_t count, loff_t *ppos) | ||
1086 | { | 1016 | { |
1087 | struct ath_softc *sc = file->private_data; | 1017 | struct ath_softc *sc = file->private; |
1088 | struct ath_hw *ah = sc->sc_ah; | 1018 | struct ath_hw *ah = sc->sc_ah; |
1089 | struct ath9k_nfcal_hist *h = sc->cur_chan->caldata.nfCalHist; | 1019 | struct ath9k_nfcal_hist *h = sc->cur_chan->caldata.nfCalHist; |
1090 | struct ath_common *common = ath9k_hw_common(ah); | 1020 | struct ath_common *common = ath9k_hw_common(ah); |
1091 | struct ieee80211_conf *conf = &common->hw->conf; | 1021 | struct ieee80211_conf *conf = &common->hw->conf; |
1092 | u32 len = 0, size = 1500; | ||
1093 | u32 i, j; | 1022 | u32 i, j; |
1094 | ssize_t retval = 0; | ||
1095 | char *buf; | ||
1096 | u8 chainmask = (ah->rxchainmask << 3) | ah->rxchainmask; | 1023 | u8 chainmask = (ah->rxchainmask << 3) | ah->rxchainmask; |
1097 | u8 nread; | 1024 | u8 nread; |
1098 | 1025 | ||
1099 | buf = kzalloc(size, GFP_KERNEL); | 1026 | seq_printf(file, "Channel Noise Floor : %d\n", ah->noise); |
1100 | if (!buf) | 1027 | seq_puts(file, "Chain | privNF | # Readings | NF Readings\n"); |
1101 | return -ENOMEM; | ||
1102 | |||
1103 | len += scnprintf(buf + len, size - len, | ||
1104 | "Channel Noise Floor : %d\n", ah->noise); | ||
1105 | len += scnprintf(buf + len, size - len, | ||
1106 | "Chain | privNF | # Readings | NF Readings\n"); | ||
1107 | for (i = 0; i < NUM_NF_READINGS; i++) { | 1028 | for (i = 0; i < NUM_NF_READINGS; i++) { |
1108 | if (!(chainmask & (1 << i)) || | 1029 | if (!(chainmask & (1 << i)) || |
1109 | ((i >= AR5416_MAX_CHAINS) && !conf_is_ht40(conf))) | 1030 | ((i >= AR5416_MAX_CHAINS) && !conf_is_ht40(conf))) |
1110 | continue; | 1031 | continue; |
1111 | 1032 | ||
1112 | nread = AR_PHY_CCA_FILTERWINDOW_LENGTH - h[i].invalidNFcount; | 1033 | nread = AR_PHY_CCA_FILTERWINDOW_LENGTH - h[i].invalidNFcount; |
1113 | len += scnprintf(buf + len, size - len, " %d\t %d\t %d\t\t", | 1034 | seq_printf(file, " %d\t %d\t %d\t\t", i, h[i].privNF, nread); |
1114 | i, h[i].privNF, nread); | ||
1115 | for (j = 0; j < nread; j++) | 1035 | for (j = 0; j < nread; j++) |
1116 | len += scnprintf(buf + len, size - len, | 1036 | seq_printf(file, " %d", h[i].nfCalBuffer[j]); |
1117 | " %d", h[i].nfCalBuffer[j]); | 1037 | seq_puts(file, "\n"); |
1118 | len += scnprintf(buf + len, size - len, "\n"); | ||
1119 | } | 1038 | } |
1120 | 1039 | ||
1121 | if (len > size) | 1040 | return 0; |
1122 | len = size; | 1041 | } |
1123 | |||
1124 | retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); | ||
1125 | kfree(buf); | ||
1126 | 1042 | ||
1127 | return retval; | 1043 | static int open_file_dump_nfcal(struct inode *inode, struct file *f) |
1044 | { | ||
1045 | return single_open(f, read_file_dump_nfcal, inode->i_private); | ||
1128 | } | 1046 | } |
1129 | 1047 | ||
1130 | static const struct file_operations fops_dump_nfcal = { | 1048 | static const struct file_operations fops_dump_nfcal = { |
1131 | .read = read_file_dump_nfcal, | 1049 | .read = seq_read, |
1132 | .open = simple_open, | 1050 | .open = open_file_dump_nfcal, |
1133 | .owner = THIS_MODULE, | 1051 | .owner = THIS_MODULE, |
1134 | .llseek = default_llseek, | 1052 | .llseek = seq_lseek, |
1053 | .release = single_release, | ||
1135 | }; | 1054 | }; |
1136 | 1055 | ||
1137 | #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT | 1056 | #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT |
diff --git a/drivers/net/wireless/ath/ath9k/debug.h b/drivers/net/wireless/ath/ath9k/debug.h index 53ae15bd0c9d..15dba7d0becc 100644 --- a/drivers/net/wireless/ath/ath9k/debug.h +++ b/drivers/net/wireless/ath/ath9k/debug.h | |||
@@ -195,12 +195,11 @@ struct ath_tx_stats { | |||
195 | #define TXSTATS sc->debug.stats.txstats | 195 | #define TXSTATS sc->debug.stats.txstats |
196 | #define PR(str, elem) \ | 196 | #define PR(str, elem) \ |
197 | do { \ | 197 | do { \ |
198 | len += scnprintf(buf + len, size - len, \ | 198 | seq_printf(file, "%s%13u%11u%10u%10u\n", str, \ |
199 | "%s%13u%11u%10u%10u\n", str, \ | 199 | TXSTATS[PR_QNUM(IEEE80211_AC_BE)].elem,\ |
200 | TXSTATS[PR_QNUM(IEEE80211_AC_BE)].elem,\ | 200 | TXSTATS[PR_QNUM(IEEE80211_AC_BK)].elem,\ |
201 | TXSTATS[PR_QNUM(IEEE80211_AC_BK)].elem,\ | 201 | TXSTATS[PR_QNUM(IEEE80211_AC_VI)].elem,\ |
202 | TXSTATS[PR_QNUM(IEEE80211_AC_VI)].elem,\ | 202 | TXSTATS[PR_QNUM(IEEE80211_AC_VO)].elem); \ |
203 | TXSTATS[PR_QNUM(IEEE80211_AC_VO)].elem); \ | ||
204 | } while(0) | 203 | } while(0) |
205 | 204 | ||
206 | struct ath_rx_rate_stats { | 205 | struct ath_rx_rate_stats { |