debug.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /*
  2. * Intel Wireless Multicomm 3200 WiFi driver
  3. *
  4. * Copyright (C) 2009 Intel Corporation <ilw@linux.intel.com>
  5. * Samuel Ortiz <samuel.ortiz@intel.com>
  6. * Zhu Yi <yi.zhu@intel.com>
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License version
  10. * 2 as published by the Free Software Foundation.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  20. * 02110-1301, USA.
  21. *
  22. */
  23. #ifndef __IWM_DEBUG_H__
  24. #define __IWM_DEBUG_H__
  25. #define IWM_ERR(p, f, a...) dev_err(iwm_to_dev(p), f, ## a)
  26. #define IWM_WARN(p, f, a...) dev_warn(iwm_to_dev(p), f, ## a)
  27. #define IWM_INFO(p, f, a...) dev_info(iwm_to_dev(p), f, ## a)
  28. #define IWM_CRIT(p, f, a...) dev_crit(iwm_to_dev(p), f, ## a)
  29. #ifdef CONFIG_IWM_DEBUG
  30. #define IWM_DEBUG_MODULE(i, level, module, f, a...) \
  31. do { \
  32. if (unlikely(i->dbg.dbg_module[IWM_DM_##module] >= (IWM_DL_##level)))\
  33. dev_printk(KERN_INFO, (iwm_to_dev(i)), \
  34. "%s " f, __func__ , ## a); \
  35. } while (0)
  36. #define IWM_HEXDUMP(i, level, module, pref, buf, len) \
  37. do { \
  38. if (unlikely(i->dbg.dbg_module[IWM_DM_##module] >= (IWM_DL_##level)))\
  39. print_hex_dump(KERN_INFO, pref, DUMP_PREFIX_OFFSET, \
  40. 16, 1, buf, len, 1); \
  41. } while (0)
  42. #else
  43. #define IWM_DEBUG_MODULE(i, level, module, f, a...)
  44. #define IWM_HEXDUMP(i, level, module, pref, buf, len)
  45. #endif /* CONFIG_IWM_DEBUG */
  46. /* Debug modules */
  47. enum iwm_debug_module_id {
  48. IWM_DM_BOOT = 0,
  49. IWM_DM_FW,
  50. IWM_DM_SDIO,
  51. IWM_DM_NTF,
  52. IWM_DM_RX,
  53. IWM_DM_TX,
  54. IWM_DM_MLME,
  55. IWM_DM_CMD,
  56. IWM_DM_WEXT,
  57. __IWM_DM_NR,
  58. };
  59. #define IWM_DM_DEFAULT 0
  60. #define IWM_DBG_BOOT(i, l, f, a...) IWM_DEBUG_MODULE(i, l, BOOT, f, ## a)
  61. #define IWM_DBG_FW(i, l, f, a...) IWM_DEBUG_MODULE(i, l, FW, f, ## a)
  62. #define IWM_DBG_SDIO(i, l, f, a...) IWM_DEBUG_MODULE(i, l, SDIO, f, ## a)
  63. #define IWM_DBG_NTF(i, l, f, a...) IWM_DEBUG_MODULE(i, l, NTF, f, ## a)
  64. #define IWM_DBG_RX(i, l, f, a...) IWM_DEBUG_MODULE(i, l, RX, f, ## a)
  65. #define IWM_DBG_TX(i, l, f, a...) IWM_DEBUG_MODULE(i, l, TX, f, ## a)
  66. #define IWM_DBG_MLME(i, l, f, a...) IWM_DEBUG_MODULE(i, l, MLME, f, ## a)
  67. #define IWM_DBG_CMD(i, l, f, a...) IWM_DEBUG_MODULE(i, l, CMD, f, ## a)
  68. #define IWM_DBG_WEXT(i, l, f, a...) IWM_DEBUG_MODULE(i, l, WEXT, f, ## a)
  69. /* Debug levels */
  70. enum iwm_debug_level {
  71. IWM_DL_NONE = 0,
  72. IWM_DL_ERR,
  73. IWM_DL_WARN,
  74. IWM_DL_INFO,
  75. IWM_DL_DBG,
  76. };
  77. #define IWM_DL_DEFAULT IWM_DL_ERR
  78. struct iwm_debugfs {
  79. struct iwm_priv *iwm;
  80. struct dentry *rootdir;
  81. struct dentry *devdir;
  82. struct dentry *dbgdir;
  83. struct dentry *txdir;
  84. struct dentry *rxdir;
  85. struct dentry *busdir;
  86. u32 dbg_level;
  87. struct dentry *dbg_level_dentry;
  88. unsigned long dbg_modules;
  89. struct dentry *dbg_modules_dentry;
  90. u8 dbg_module[__IWM_DM_NR];
  91. struct dentry *dbg_module_dentries[__IWM_DM_NR];
  92. struct dentry *txq_dentry;
  93. struct dentry *tx_credit_dentry;
  94. struct dentry *rx_ticket_dentry;
  95. struct dentry *fw_err_dentry;
  96. };
  97. #ifdef CONFIG_IWM_DEBUG
  98. void iwm_debugfs_init(struct iwm_priv *iwm);
  99. void iwm_debugfs_exit(struct iwm_priv *iwm);
  100. #else
  101. static inline void iwm_debugfs_init(struct iwm_priv *iwm) {}
  102. static inline void iwm_debugfs_exit(struct iwm_priv *iwm) {}
  103. #endif
  104. #endif