debug.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /*
  2. * Atheros CARL9170 driver
  3. *
  4. * debug header
  5. *
  6. * Copyright 2010, Christian Lamparter <chunkeey@googlemail.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; see the file COPYING. If not, see
  20. * http://www.gnu.org/licenses/.
  21. *
  22. * This file incorporates work covered by the following copyright and
  23. * permission notice:
  24. * Copyright (c) 2007-2008 Atheros Communications, Inc.
  25. *
  26. * Permission to use, copy, modify, and/or distribute this software for any
  27. * purpose with or without fee is hereby granted, provided that the above
  28. * copyright notice and this permission notice appear in all copies.
  29. *
  30. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  31. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  32. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  33. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  34. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  35. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  36. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  37. */
  38. #ifndef __DEBUG_H
  39. #define __DEBUG_H
  40. #include "eeprom.h"
  41. #include "wlan.h"
  42. #include "hw.h"
  43. #include "fwdesc.h"
  44. #include "fwcmd.h"
  45. #include "../regd.h"
  46. struct hw_stat_reg_entry {
  47. u32 reg;
  48. char nreg[32];
  49. };
  50. #define STAT_MAC_REG(reg) \
  51. { (AR9170_MAC_REG_##reg), #reg }
  52. #define STAT_PTA_REG(reg) \
  53. { (AR9170_PTA_REG_##reg), #reg }
  54. #define STAT_USB_REG(reg) \
  55. { (AR9170_USB_REG_##reg), #reg }
  56. static const struct hw_stat_reg_entry hw_rx_tally_regs[] = {
  57. STAT_MAC_REG(RX_CRC32), STAT_MAC_REG(RX_CRC16),
  58. STAT_MAC_REG(RX_TIMEOUT_COUNT), STAT_MAC_REG(RX_ERR_DECRYPTION_UNI),
  59. STAT_MAC_REG(RX_ERR_DECRYPTION_MUL), STAT_MAC_REG(RX_MPDU),
  60. STAT_MAC_REG(RX_DROPPED_MPDU), STAT_MAC_REG(RX_DEL_MPDU),
  61. };
  62. static const struct hw_stat_reg_entry hw_phy_errors_regs[] = {
  63. STAT_MAC_REG(RX_PHY_MISC_ERROR), STAT_MAC_REG(RX_PHY_XR_ERROR),
  64. STAT_MAC_REG(RX_PHY_OFDM_ERROR), STAT_MAC_REG(RX_PHY_CCK_ERROR),
  65. STAT_MAC_REG(RX_PHY_HT_ERROR), STAT_MAC_REG(RX_PHY_TOTAL),
  66. };
  67. static const struct hw_stat_reg_entry hw_tx_tally_regs[] = {
  68. STAT_MAC_REG(TX_TOTAL), STAT_MAC_REG(TX_UNDERRUN),
  69. STAT_MAC_REG(TX_RETRY),
  70. };
  71. static const struct hw_stat_reg_entry hw_wlan_queue_regs[] = {
  72. STAT_MAC_REG(DMA_STATUS), STAT_MAC_REG(DMA_TRIGGER),
  73. STAT_MAC_REG(DMA_TXQ0_ADDR), STAT_MAC_REG(DMA_TXQ0_CURR_ADDR),
  74. STAT_MAC_REG(DMA_TXQ1_ADDR), STAT_MAC_REG(DMA_TXQ1_CURR_ADDR),
  75. STAT_MAC_REG(DMA_TXQ2_ADDR), STAT_MAC_REG(DMA_TXQ2_CURR_ADDR),
  76. STAT_MAC_REG(DMA_TXQ3_ADDR), STAT_MAC_REG(DMA_TXQ3_CURR_ADDR),
  77. STAT_MAC_REG(DMA_RXQ_ADDR), STAT_MAC_REG(DMA_RXQ_CURR_ADDR),
  78. };
  79. static const struct hw_stat_reg_entry hw_ampdu_info_regs[] = {
  80. STAT_MAC_REG(AMPDU_DENSITY), STAT_MAC_REG(AMPDU_FACTOR),
  81. };
  82. static const struct hw_stat_reg_entry hw_pta_queue_regs[] = {
  83. STAT_PTA_REG(DN_CURR_ADDRH), STAT_PTA_REG(DN_CURR_ADDRL),
  84. STAT_PTA_REG(UP_CURR_ADDRH), STAT_PTA_REG(UP_CURR_ADDRL),
  85. STAT_PTA_REG(DMA_STATUS), STAT_PTA_REG(DMA_MODE_CTRL),
  86. };
  87. #define DEFINE_TALLY(name) \
  88. u32 name##_sum[ARRAY_SIZE(name##_regs)], \
  89. name##_counter[ARRAY_SIZE(name##_regs)] \
  90. #define DEFINE_STAT(name) \
  91. u32 name##_counter[ARRAY_SIZE(name##_regs)] \
  92. struct ath_stats {
  93. DEFINE_TALLY(hw_tx_tally);
  94. DEFINE_TALLY(hw_rx_tally);
  95. DEFINE_TALLY(hw_phy_errors);
  96. DEFINE_STAT(hw_wlan_queue);
  97. DEFINE_STAT(hw_pta_queue);
  98. DEFINE_STAT(hw_ampdu_info);
  99. };
  100. struct carl9170_debug_mem_rbe {
  101. u32 reg;
  102. u32 value;
  103. };
  104. #define CARL9170_DEBUG_RING_SIZE 64
  105. struct carl9170_debug {
  106. struct ath_stats stats;
  107. struct carl9170_debug_mem_rbe ring[CARL9170_DEBUG_RING_SIZE];
  108. struct mutex ring_lock;
  109. unsigned int ring_head, ring_tail;
  110. struct delayed_work update_tally;
  111. };
  112. struct ar9170;
  113. void carl9170_debugfs_register(struct ar9170 *ar);
  114. void carl9170_debugfs_unregister(struct ar9170 *ar);
  115. #endif /* __DEBUG_H */