debug.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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. #include <linux/net.h> /* net_ratelimit() */
  19. /* message levels */
  20. #define BRCMF_TRACE_VAL 0x00000002
  21. #define BRCMF_INFO_VAL 0x00000004
  22. #define BRCMF_DATA_VAL 0x00000008
  23. #define BRCMF_CTL_VAL 0x00000010
  24. #define BRCMF_TIMER_VAL 0x00000020
  25. #define BRCMF_HDRS_VAL 0x00000040
  26. #define BRCMF_BYTES_VAL 0x00000080
  27. #define BRCMF_INTR_VAL 0x00000100
  28. #define BRCMF_GLOM_VAL 0x00000200
  29. #define BRCMF_EVENT_VAL 0x00000400
  30. #define BRCMF_BTA_VAL 0x00000800
  31. #define BRCMF_FIL_VAL 0x00001000
  32. #define BRCMF_USB_VAL 0x00002000
  33. #define BRCMF_SCAN_VAL 0x00004000
  34. #define BRCMF_CONN_VAL 0x00008000
  35. #define BRCMF_BCDC_VAL 0x00010000
  36. #define BRCMF_SDIO_VAL 0x00020000
  37. #define BRCMF_MSGBUF_VAL 0x00040000
  38. #define BRCMF_PCIE_VAL 0x00080000
  39. #define BRCMF_FWCON_VAL 0x00100000
  40. /* set default print format */
  41. #undef pr_fmt
  42. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  43. __printf(2, 3)
  44. void __brcmf_err(const char *func, const char *fmt, ...);
  45. /* Macro for error messages. When debugging / tracing the driver all error
  46. * messages are important to us.
  47. */
  48. #define brcmf_err(fmt, ...) \
  49. do { \
  50. if (IS_ENABLED(CONFIG_BRCMDBG) || \
  51. IS_ENABLED(CONFIG_BRCM_TRACING) || \
  52. net_ratelimit()) \
  53. __brcmf_err(__func__, fmt, ##__VA_ARGS__); \
  54. } while (0)
  55. #if defined(DEBUG) || defined(CONFIG_BRCM_TRACING)
  56. /* For debug/tracing purposes treat info messages as errors */
  57. #define brcmf_info brcmf_err
  58. __printf(3, 4)
  59. void __brcmf_dbg(u32 level, const char *func, const char *fmt, ...);
  60. #define brcmf_dbg(level, fmt, ...) \
  61. do { \
  62. __brcmf_dbg(BRCMF_##level##_VAL, __func__, \
  63. fmt, ##__VA_ARGS__); \
  64. } while (0)
  65. #define BRCMF_DATA_ON() (brcmf_msg_level & BRCMF_DATA_VAL)
  66. #define BRCMF_CTL_ON() (brcmf_msg_level & BRCMF_CTL_VAL)
  67. #define BRCMF_HDRS_ON() (brcmf_msg_level & BRCMF_HDRS_VAL)
  68. #define BRCMF_BYTES_ON() (brcmf_msg_level & BRCMF_BYTES_VAL)
  69. #define BRCMF_GLOM_ON() (brcmf_msg_level & BRCMF_GLOM_VAL)
  70. #define BRCMF_EVENT_ON() (brcmf_msg_level & BRCMF_EVENT_VAL)
  71. #define BRCMF_FIL_ON() (brcmf_msg_level & BRCMF_FIL_VAL)
  72. #define BRCMF_FWCON_ON() (brcmf_msg_level & BRCMF_FWCON_VAL)
  73. #define BRCMF_SCAN_ON() (brcmf_msg_level & BRCMF_SCAN_VAL)
  74. #else /* defined(DEBUG) || defined(CONFIG_BRCM_TRACING) */
  75. #define brcmf_info(fmt, ...) \
  76. do { \
  77. pr_info("%s: " fmt, __func__, ##__VA_ARGS__); \
  78. } while (0)
  79. #define brcmf_dbg(level, fmt, ...) no_printk(fmt, ##__VA_ARGS__)
  80. #define BRCMF_DATA_ON() 0
  81. #define BRCMF_CTL_ON() 0
  82. #define BRCMF_HDRS_ON() 0
  83. #define BRCMF_BYTES_ON() 0
  84. #define BRCMF_GLOM_ON() 0
  85. #define BRCMF_EVENT_ON() 0
  86. #define BRCMF_FIL_ON() 0
  87. #define BRCMF_FWCON_ON() 0
  88. #define BRCMF_SCAN_ON() 0
  89. #endif /* defined(DEBUG) || defined(CONFIG_BRCM_TRACING) */
  90. #define brcmf_dbg_hex_dump(test, data, len, fmt, ...) \
  91. do { \
  92. trace_brcmf_hexdump((void *)data, len); \
  93. if (test) \
  94. brcmu_dbg_hex_dump(data, len, fmt, ##__VA_ARGS__); \
  95. } while (0)
  96. extern int brcmf_msg_level;
  97. struct brcmf_bus;
  98. struct brcmf_pub;
  99. #ifdef DEBUG
  100. struct dentry *brcmf_debugfs_get_devdir(struct brcmf_pub *drvr);
  101. int brcmf_debugfs_add_entry(struct brcmf_pub *drvr, const char *fn,
  102. int (*read_fn)(struct seq_file *seq, void *data));
  103. int brcmf_debug_create_memdump(struct brcmf_bus *bus, const void *data,
  104. size_t len);
  105. #else
  106. static inline
  107. int brcmf_debugfs_add_entry(struct brcmf_pub *drvr, const char *fn,
  108. int (*read_fn)(struct seq_file *seq, void *data))
  109. {
  110. return 0;
  111. }
  112. static inline
  113. int brcmf_debug_create_memdump(struct brcmf_bus *bus, const void *data,
  114. size_t len)
  115. {
  116. return 0;
  117. }
  118. #endif
  119. #endif /* BRCMFMAC_DEBUG_H */