debug.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /*
  2. * Copyright (c) 2010 Broadcom Corporation
  3. *
  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
  6. * copyright notice and this permission notice appear in all copies.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  9. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
  11. * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  13. * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  14. * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #ifndef BRCMFMAC_DEBUG_H
  17. #define BRCMFMAC_DEBUG_H
  18. /* message levels */
  19. #define BRCMF_TRACE_VAL 0x00000002
  20. #define BRCMF_INFO_VAL 0x00000004
  21. #define BRCMF_DATA_VAL 0x00000008
  22. #define BRCMF_CTL_VAL 0x00000010
  23. #define BRCMF_TIMER_VAL 0x00000020
  24. #define BRCMF_HDRS_VAL 0x00000040
  25. #define BRCMF_BYTES_VAL 0x00000080
  26. #define BRCMF_INTR_VAL 0x00000100
  27. #define BRCMF_GLOM_VAL 0x00000200
  28. #define BRCMF_EVENT_VAL 0x00000400
  29. #define BRCMF_BTA_VAL 0x00000800
  30. #define BRCMF_FIL_VAL 0x00001000
  31. #define BRCMF_USB_VAL 0x00002000
  32. #define BRCMF_SCAN_VAL 0x00004000
  33. #define BRCMF_CONN_VAL 0x00008000
  34. #define BRCMF_BCDC_VAL 0x00010000
  35. #define BRCMF_SDIO_VAL 0x00020000
  36. #define BRCMF_MSGBUF_VAL 0x00040000
  37. #define BRCMF_PCIE_VAL 0x00080000
  38. /* set default print format */
  39. #undef pr_fmt
  40. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  41. /* Macro for error messages. net_ratelimit() is used when driver
  42. * debugging is not selected. When debugging the driver error
  43. * messages are as important as other tracing or even more so.
  44. */
  45. #ifndef CONFIG_BRCM_TRACING
  46. #ifdef CONFIG_BRCMDBG
  47. #define brcmf_err(fmt, ...) pr_err("%s: " fmt, __func__, ##__VA_ARGS__)
  48. #else
  49. #define brcmf_err(fmt, ...) \
  50. do { \
  51. if (net_ratelimit()) \
  52. pr_err("%s: " fmt, __func__, ##__VA_ARGS__); \
  53. } while (0)
  54. #endif
  55. #else
  56. __printf(2, 3)
  57. void __brcmf_err(const char *func, const char *fmt, ...);
  58. #define brcmf_err(fmt, ...) \
  59. __brcmf_err(__func__, fmt, ##__VA_ARGS__)
  60. #endif
  61. #if defined(DEBUG) || defined(CONFIG_BRCM_TRACING)
  62. __printf(3, 4)
  63. void __brcmf_dbg(u32 level, const char *func, const char *fmt, ...);
  64. #define brcmf_dbg(level, fmt, ...) \
  65. do { \
  66. __brcmf_dbg(BRCMF_##level##_VAL, __func__, \
  67. fmt, ##__VA_ARGS__); \
  68. } while (0)
  69. #define BRCMF_DATA_ON() (brcmf_msg_level & BRCMF_DATA_VAL)
  70. #define BRCMF_CTL_ON() (brcmf_msg_level & BRCMF_CTL_VAL)
  71. #define BRCMF_HDRS_ON() (brcmf_msg_level & BRCMF_HDRS_VAL)
  72. #define BRCMF_BYTES_ON() (brcmf_msg_level & BRCMF_BYTES_VAL)
  73. #define BRCMF_GLOM_ON() (brcmf_msg_level & BRCMF_GLOM_VAL)
  74. #define BRCMF_EVENT_ON() (brcmf_msg_level & BRCMF_EVENT_VAL)
  75. #define BRCMF_FIL_ON() (brcmf_msg_level & BRCMF_FIL_VAL)
  76. #else /* defined(DEBUG) || defined(CONFIG_BRCM_TRACING) */
  77. #define brcmf_dbg(level, fmt, ...) no_printk(fmt, ##__VA_ARGS__)
  78. #define BRCMF_DATA_ON() 0
  79. #define BRCMF_CTL_ON() 0
  80. #define BRCMF_HDRS_ON() 0
  81. #define BRCMF_BYTES_ON() 0
  82. #define BRCMF_GLOM_ON() 0
  83. #define BRCMF_EVENT_ON() 0
  84. #define BRCMF_FIL_ON() 0
  85. #endif /* defined(DEBUG) || defined(CONFIG_BRCM_TRACING) */
  86. #define brcmf_dbg_hex_dump(test, data, len, fmt, ...) \
  87. do { \
  88. trace_brcmf_hexdump((void *)data, len); \
  89. if (test) \
  90. brcmu_dbg_hex_dump(data, len, fmt, ##__VA_ARGS__); \
  91. } while (0)
  92. extern int brcmf_msg_level;
  93. struct brcmf_pub;
  94. #ifdef DEBUG
  95. void brcmf_debugfs_init(void);
  96. void brcmf_debugfs_exit(void);
  97. int brcmf_debugfs_attach(struct brcmf_pub *drvr);
  98. void brcmf_debugfs_detach(struct brcmf_pub *drvr);
  99. struct dentry *brcmf_debugfs_get_devdir(struct brcmf_pub *drvr);
  100. int brcmf_debugfs_add_entry(struct brcmf_pub *drvr, const char *fn,
  101. int (*read_fn)(struct seq_file *seq, void *data));
  102. #else
  103. static inline void brcmf_debugfs_init(void)
  104. {
  105. }
  106. static inline void brcmf_debugfs_exit(void)
  107. {
  108. }
  109. static inline int brcmf_debugfs_attach(struct brcmf_pub *drvr)
  110. {
  111. return 0;
  112. }
  113. static inline void brcmf_debugfs_detach(struct brcmf_pub *drvr)
  114. {
  115. }
  116. static inline
  117. int brcmf_debugfs_add_entry(struct brcmf_pub *drvr, const char *fn,
  118. int (*read_fn)(struct seq_file *seq, void *data))
  119. {
  120. return 0;
  121. }
  122. #endif
  123. #endif /* BRCMFMAC_DEBUG_H */