aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwlwifi/iwl-trans-rx-pcie.c
diff options
context:
space:
mode:
authorEmmanuel Grumbach <emmanuel.grumbach@intel.com>2011-08-26 02:10:54 -0400
committerJohn W. Linville <linville@tuxdriver.com>2011-08-29 15:25:33 -0400
commit7ff94706a055f3e21710b08ffbe3979d7db615db (patch)
tree453cabac4b495e4ee8d7fe63a193435e90920883 /drivers/net/wireless/iwlwifi/iwl-trans-rx-pcie.c
parent0c325769a394559941acda83e888a1d9b1ef8b7f (diff)
iwlagn: move the NIC error flow to the transport layer
It is transport dependent, move to the PCIe transport layer. Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com> Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/iwlwifi/iwl-trans-rx-pcie.c')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-trans-rx-pcie.c396
1 files changed, 396 insertions, 0 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-rx-pcie.c b/drivers/net/wireless/iwlwifi/iwl-trans-rx-pcie.c
index 15e2645c2fb3..aa7ced4324b8 100644
--- a/drivers/net/wireless/iwlwifi/iwl-trans-rx-pcie.c
+++ b/drivers/net/wireless/iwlwifi/iwl-trans-rx-pcie.c
@@ -496,6 +496,402 @@ static void iwl_rx_handle(struct iwl_trans *trans)
496 iwlagn_rx_queue_restock(trans); 496 iwlagn_rx_queue_restock(trans);
497} 497}
498 498
499static const char * const desc_lookup_text[] = {
500 "OK",
501 "FAIL",
502 "BAD_PARAM",
503 "BAD_CHECKSUM",
504 "NMI_INTERRUPT_WDG",
505 "SYSASSERT",
506 "FATAL_ERROR",
507 "BAD_COMMAND",
508 "HW_ERROR_TUNE_LOCK",
509 "HW_ERROR_TEMPERATURE",
510 "ILLEGAL_CHAN_FREQ",
511 "VCC_NOT_STABLE",
512 "FH_ERROR",
513 "NMI_INTERRUPT_HOST",
514 "NMI_INTERRUPT_ACTION_PT",
515 "NMI_INTERRUPT_UNKNOWN",
516 "UCODE_VERSION_MISMATCH",
517 "HW_ERROR_ABS_LOCK",
518 "HW_ERROR_CAL_LOCK_FAIL",
519 "NMI_INTERRUPT_INST_ACTION_PT",
520 "NMI_INTERRUPT_DATA_ACTION_PT",
521 "NMI_TRM_HW_ER",
522 "NMI_INTERRUPT_TRM",
523 "NMI_INTERRUPT_BREAK_POINT",
524 "DEBUG_0",
525 "DEBUG_1",
526 "DEBUG_2",
527 "DEBUG_3",
528};
529
530static struct { char *name; u8 num; } advanced_lookup[] = {
531 { "NMI_INTERRUPT_WDG", 0x34 },
532 { "SYSASSERT", 0x35 },
533 { "UCODE_VERSION_MISMATCH", 0x37 },
534 { "BAD_COMMAND", 0x38 },
535 { "NMI_INTERRUPT_DATA_ACTION_PT", 0x3C },
536 { "FATAL_ERROR", 0x3D },
537 { "NMI_TRM_HW_ERR", 0x46 },
538 { "NMI_INTERRUPT_TRM", 0x4C },
539 { "NMI_INTERRUPT_BREAK_POINT", 0x54 },
540 { "NMI_INTERRUPT_WDG_RXF_FULL", 0x5C },
541 { "NMI_INTERRUPT_WDG_NO_RBD_RXF_FULL", 0x64 },
542 { "NMI_INTERRUPT_HOST", 0x66 },
543 { "NMI_INTERRUPT_ACTION_PT", 0x7C },
544 { "NMI_INTERRUPT_UNKNOWN", 0x84 },
545 { "NMI_INTERRUPT_INST_ACTION_PT", 0x86 },
546 { "ADVANCED_SYSASSERT", 0 },
547};
548
549static const char *desc_lookup(u32 num)
550{
551 int i;
552 int max = ARRAY_SIZE(desc_lookup_text);
553
554 if (num < max)
555 return desc_lookup_text[num];
556
557 max = ARRAY_SIZE(advanced_lookup) - 1;
558 for (i = 0; i < max; i++) {
559 if (advanced_lookup[i].num == num)
560 break;
561 }
562 return advanced_lookup[i].name;
563}
564
565#define ERROR_START_OFFSET (1 * sizeof(u32))
566#define ERROR_ELEM_SIZE (7 * sizeof(u32))
567
568static void iwl_dump_nic_error_log(struct iwl_priv *priv)
569{
570 u32 base;
571 struct iwl_error_event_table table;
572
573 base = priv->device_pointers.error_event_table;
574 if (priv->ucode_type == IWL_UCODE_INIT) {
575 if (!base)
576 base = priv->init_errlog_ptr;
577 } else {
578 if (!base)
579 base = priv->inst_errlog_ptr;
580 }
581
582 if (!iwlagn_hw_valid_rtc_data_addr(base)) {
583 IWL_ERR(priv,
584 "Not valid error log pointer 0x%08X for %s uCode\n",
585 base,
586 (priv->ucode_type == IWL_UCODE_INIT)
587 ? "Init" : "RT");
588 return;
589 }
590
591 iwl_read_targ_mem_words(priv, base, &table, sizeof(table));
592
593 if (ERROR_START_OFFSET <= table.valid * ERROR_ELEM_SIZE) {
594 IWL_ERR(priv, "Start IWL Error Log Dump:\n");
595 IWL_ERR(priv, "Status: 0x%08lX, count: %d\n",
596 priv->shrd->status, table.valid);
597 }
598
599 priv->isr_stats.err_code = table.error_id;
600
601 trace_iwlwifi_dev_ucode_error(priv, table.error_id, table.tsf_low,
602 table.data1, table.data2, table.line,
603 table.blink1, table.blink2, table.ilink1,
604 table.ilink2, table.bcon_time, table.gp1,
605 table.gp2, table.gp3, table.ucode_ver,
606 table.hw_ver, table.brd_ver);
607 IWL_ERR(priv, "0x%08X | %-28s\n", table.error_id,
608 desc_lookup(table.error_id));
609 IWL_ERR(priv, "0x%08X | uPc\n", table.pc);
610 IWL_ERR(priv, "0x%08X | branchlink1\n", table.blink1);
611 IWL_ERR(priv, "0x%08X | branchlink2\n", table.blink2);
612 IWL_ERR(priv, "0x%08X | interruptlink1\n", table.ilink1);
613 IWL_ERR(priv, "0x%08X | interruptlink2\n", table.ilink2);
614 IWL_ERR(priv, "0x%08X | data1\n", table.data1);
615 IWL_ERR(priv, "0x%08X | data2\n", table.data2);
616 IWL_ERR(priv, "0x%08X | line\n", table.line);
617 IWL_ERR(priv, "0x%08X | beacon time\n", table.bcon_time);
618 IWL_ERR(priv, "0x%08X | tsf low\n", table.tsf_low);
619 IWL_ERR(priv, "0x%08X | tsf hi\n", table.tsf_hi);
620 IWL_ERR(priv, "0x%08X | time gp1\n", table.gp1);
621 IWL_ERR(priv, "0x%08X | time gp2\n", table.gp2);
622 IWL_ERR(priv, "0x%08X | time gp3\n", table.gp3);
623 IWL_ERR(priv, "0x%08X | uCode version\n", table.ucode_ver);
624 IWL_ERR(priv, "0x%08X | hw version\n", table.hw_ver);
625 IWL_ERR(priv, "0x%08X | board version\n", table.brd_ver);
626 IWL_ERR(priv, "0x%08X | hcmd\n", table.hcmd);
627}
628
629/**
630 * iwl_irq_handle_error - called for HW or SW error interrupt from card
631 */
632static void iwl_irq_handle_error(struct iwl_priv *priv)
633{
634 /* W/A for WiFi/WiMAX coex and WiMAX own the RF */
635 if (priv->cfg->internal_wimax_coex &&
636 (!(iwl_read_prph(priv, APMG_CLK_CTRL_REG) &
637 APMS_CLK_VAL_MRB_FUNC_MODE) ||
638 (iwl_read_prph(priv, APMG_PS_CTRL_REG) &
639 APMG_PS_CTRL_VAL_RESET_REQ))) {
640 /*
641 * Keep the restart process from trying to send host
642 * commands by clearing the ready bit.
643 */
644 clear_bit(STATUS_READY, &priv->shrd->status);
645 clear_bit(STATUS_HCMD_ACTIVE, &priv->shrd->status);
646 wake_up_interruptible(&priv->wait_command_queue);
647 IWL_ERR(priv, "RF is used by WiMAX\n");
648 return;
649 }
650
651 IWL_ERR(priv, "Loaded firmware version: %s\n",
652 priv->hw->wiphy->fw_version);
653
654 iwl_dump_nic_error_log(priv);
655 iwl_dump_csr(priv);
656 iwl_dump_fh(priv, NULL, false);
657 iwl_dump_nic_event_log(priv, false, NULL, false);
658#ifdef CONFIG_IWLWIFI_DEBUG
659 if (iwl_get_debug_level(priv->shrd) & IWL_DL_FW_ERRORS)
660 iwl_print_rx_config_cmd(priv,
661 &priv->contexts[IWL_RXON_CTX_BSS]);
662#endif
663
664 iwlagn_fw_error(priv, false);
665}
666
667#define EVENT_START_OFFSET (4 * sizeof(u32))
668
669/**
670 * iwl_print_event_log - Dump error event log to syslog
671 *
672 */
673static int iwl_print_event_log(struct iwl_priv *priv, u32 start_idx,
674 u32 num_events, u32 mode,
675 int pos, char **buf, size_t bufsz)
676{
677 u32 i;
678 u32 base; /* SRAM byte address of event log header */
679 u32 event_size; /* 2 u32s, or 3 u32s if timestamp recorded */
680 u32 ptr; /* SRAM byte address of log data */
681 u32 ev, time, data; /* event log data */
682 unsigned long reg_flags;
683
684 if (num_events == 0)
685 return pos;
686
687 base = priv->device_pointers.log_event_table;
688 if (priv->ucode_type == IWL_UCODE_INIT) {
689 if (!base)
690 base = priv->init_evtlog_ptr;
691 } else {
692 if (!base)
693 base = priv->inst_evtlog_ptr;
694 }
695
696 if (mode == 0)
697 event_size = 2 * sizeof(u32);
698 else
699 event_size = 3 * sizeof(u32);
700
701 ptr = base + EVENT_START_OFFSET + (start_idx * event_size);
702
703 /* Make sure device is powered up for SRAM reads */
704 spin_lock_irqsave(&priv->reg_lock, reg_flags);
705 iwl_grab_nic_access(priv);
706
707 /* Set starting address; reads will auto-increment */
708 iwl_write32(priv, HBUS_TARG_MEM_RADDR, ptr);
709 rmb();
710
711 /* "time" is actually "data" for mode 0 (no timestamp).
712 * place event id # at far right for easier visual parsing. */
713 for (i = 0; i < num_events; i++) {
714 ev = iwl_read32(priv, HBUS_TARG_MEM_RDAT);
715 time = iwl_read32(priv, HBUS_TARG_MEM_RDAT);
716 if (mode == 0) {
717 /* data, ev */
718 if (bufsz) {
719 pos += scnprintf(*buf + pos, bufsz - pos,
720 "EVT_LOG:0x%08x:%04u\n",
721 time, ev);
722 } else {
723 trace_iwlwifi_dev_ucode_event(priv, 0,
724 time, ev);
725 IWL_ERR(priv, "EVT_LOG:0x%08x:%04u\n",
726 time, ev);
727 }
728 } else {
729 data = iwl_read32(priv, HBUS_TARG_MEM_RDAT);
730 if (bufsz) {
731 pos += scnprintf(*buf + pos, bufsz - pos,
732 "EVT_LOGT:%010u:0x%08x:%04u\n",
733 time, data, ev);
734 } else {
735 IWL_ERR(priv, "EVT_LOGT:%010u:0x%08x:%04u\n",
736 time, data, ev);
737 trace_iwlwifi_dev_ucode_event(priv, time,
738 data, ev);
739 }
740 }
741 }
742
743 /* Allow device to power down */
744 iwl_release_nic_access(priv);
745 spin_unlock_irqrestore(&priv->reg_lock, reg_flags);
746 return pos;
747}
748
749/**
750 * iwl_print_last_event_logs - Dump the newest # of event log to syslog
751 */
752static int iwl_print_last_event_logs(struct iwl_priv *priv, u32 capacity,
753 u32 num_wraps, u32 next_entry,
754 u32 size, u32 mode,
755 int pos, char **buf, size_t bufsz)
756{
757 /*
758 * display the newest DEFAULT_LOG_ENTRIES entries
759 * i.e the entries just before the next ont that uCode would fill.
760 */
761 if (num_wraps) {
762 if (next_entry < size) {
763 pos = iwl_print_event_log(priv,
764 capacity - (size - next_entry),
765 size - next_entry, mode,
766 pos, buf, bufsz);
767 pos = iwl_print_event_log(priv, 0,
768 next_entry, mode,
769 pos, buf, bufsz);
770 } else
771 pos = iwl_print_event_log(priv, next_entry - size,
772 size, mode, pos, buf, bufsz);
773 } else {
774 if (next_entry < size) {
775 pos = iwl_print_event_log(priv, 0, next_entry,
776 mode, pos, buf, bufsz);
777 } else {
778 pos = iwl_print_event_log(priv, next_entry - size,
779 size, mode, pos, buf, bufsz);
780 }
781 }
782 return pos;
783}
784
785#define DEFAULT_DUMP_EVENT_LOG_ENTRIES (20)
786
787int iwl_dump_nic_event_log(struct iwl_priv *priv, bool full_log,
788 char **buf, bool display)
789{
790 u32 base; /* SRAM byte address of event log header */
791 u32 capacity; /* event log capacity in # entries */
792 u32 mode; /* 0 - no timestamp, 1 - timestamp recorded */
793 u32 num_wraps; /* # times uCode wrapped to top of log */
794 u32 next_entry; /* index of next entry to be written by uCode */
795 u32 size; /* # entries that we'll print */
796 u32 logsize;
797 int pos = 0;
798 size_t bufsz = 0;
799
800 base = priv->device_pointers.log_event_table;
801 if (priv->ucode_type == IWL_UCODE_INIT) {
802 logsize = priv->init_evtlog_size;
803 if (!base)
804 base = priv->init_evtlog_ptr;
805 } else {
806 logsize = priv->inst_evtlog_size;
807 if (!base)
808 base = priv->inst_evtlog_ptr;
809 }
810
811 if (!iwlagn_hw_valid_rtc_data_addr(base)) {
812 IWL_ERR(priv,
813 "Invalid event log pointer 0x%08X for %s uCode\n",
814 base,
815 (priv->ucode_type == IWL_UCODE_INIT)
816 ? "Init" : "RT");
817 return -EINVAL;
818 }
819
820 /* event log header */
821 capacity = iwl_read_targ_mem(priv, base);
822 mode = iwl_read_targ_mem(priv, base + (1 * sizeof(u32)));
823 num_wraps = iwl_read_targ_mem(priv, base + (2 * sizeof(u32)));
824 next_entry = iwl_read_targ_mem(priv, base + (3 * sizeof(u32)));
825
826 if (capacity > logsize) {
827 IWL_ERR(priv, "Log capacity %d is bogus, limit to %d entries\n",
828 capacity, logsize);
829 capacity = logsize;
830 }
831
832 if (next_entry > logsize) {
833 IWL_ERR(priv, "Log write index %d is bogus, limit to %d\n",
834 next_entry, logsize);
835 next_entry = logsize;
836 }
837
838 size = num_wraps ? capacity : next_entry;
839
840 /* bail out if nothing in log */
841 if (size == 0) {
842 IWL_ERR(priv, "Start IWL Event Log Dump: nothing in log\n");
843 return pos;
844 }
845
846 /* enable/disable bt channel inhibition */
847 priv->bt_ch_announce = iwlagn_mod_params.bt_ch_announce;
848
849#ifdef CONFIG_IWLWIFI_DEBUG
850 if (!(iwl_get_debug_level(priv->shrd) & IWL_DL_FW_ERRORS) && !full_log)
851 size = (size > DEFAULT_DUMP_EVENT_LOG_ENTRIES)
852 ? DEFAULT_DUMP_EVENT_LOG_ENTRIES : size;
853#else
854 size = (size > DEFAULT_DUMP_EVENT_LOG_ENTRIES)
855 ? DEFAULT_DUMP_EVENT_LOG_ENTRIES : size;
856#endif
857 IWL_ERR(priv, "Start IWL Event Log Dump: display last %u entries\n",
858 size);
859
860#ifdef CONFIG_IWLWIFI_DEBUG
861 if (display) {
862 if (full_log)
863 bufsz = capacity * 48;
864 else
865 bufsz = size * 48;
866 *buf = kmalloc(bufsz, GFP_KERNEL);
867 if (!*buf)
868 return -ENOMEM;
869 }
870 if ((iwl_get_debug_level(priv->shrd) & IWL_DL_FW_ERRORS) || full_log) {
871 /*
872 * if uCode has wrapped back to top of log,
873 * start at the oldest entry,
874 * i.e the next one that uCode would fill.
875 */
876 if (num_wraps)
877 pos = iwl_print_event_log(priv, next_entry,
878 capacity - next_entry, mode,
879 pos, buf, bufsz);
880 /* (then/else) start at top of log */
881 pos = iwl_print_event_log(priv, 0,
882 next_entry, mode, pos, buf, bufsz);
883 } else
884 pos = iwl_print_last_event_logs(priv, capacity, num_wraps,
885 next_entry, size, mode,
886 pos, buf, bufsz);
887#else
888 pos = iwl_print_last_event_logs(priv, capacity, num_wraps,
889 next_entry, size, mode,
890 pos, buf, bufsz);
891#endif
892 return pos;
893}
894
499/* tasklet for iwlagn interrupt */ 895/* tasklet for iwlagn interrupt */
500void iwl_irq_tasklet(struct iwl_trans *trans) 896void iwl_irq_tasklet(struct iwl_trans *trans)
501{ 897{