dhd_dbg.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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 _BRCMF_DBG_H_
  17. #define _BRCMF_DBG_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_CDC_VAL 0x00010000
  35. /* set default print format */
  36. #undef pr_fmt
  37. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  38. /* Macro for error messages. net_ratelimit() is used when driver
  39. * debugging is not selected. When debugging the driver error
  40. * messages are as important as other tracing or even more so.
  41. */
  42. #ifdef CONFIG_BRCMDBG
  43. #define brcmf_err(fmt, ...) pr_err("%s: " fmt, __func__, ##__VA_ARGS__)
  44. #else
  45. #define brcmf_err(fmt, ...) \
  46. do { \
  47. if (net_ratelimit()) \
  48. pr_err("%s: " fmt, __func__, ##__VA_ARGS__); \
  49. } while (0)
  50. #endif
  51. #if defined(DEBUG)
  52. #define brcmf_dbg(level, fmt, ...) \
  53. do { \
  54. if (brcmf_msg_level & BRCMF_##level##_VAL) \
  55. pr_debug("%s: " fmt, __func__, ##__VA_ARGS__); \
  56. } while (0)
  57. #define BRCMF_DATA_ON() (brcmf_msg_level & BRCMF_DATA_VAL)
  58. #define BRCMF_CTL_ON() (brcmf_msg_level & BRCMF_CTL_VAL)
  59. #define BRCMF_HDRS_ON() (brcmf_msg_level & BRCMF_HDRS_VAL)
  60. #define BRCMF_BYTES_ON() (brcmf_msg_level & BRCMF_BYTES_VAL)
  61. #define BRCMF_GLOM_ON() (brcmf_msg_level & BRCMF_GLOM_VAL)
  62. #define BRCMF_EVENT_ON() (brcmf_msg_level & BRCMF_EVENT_VAL)
  63. #define BRCMF_FIL_ON() (brcmf_msg_level & BRCMF_FIL_VAL)
  64. #else /* (defined DEBUG) || (defined DEBUG) */
  65. #define brcmf_dbg(level, fmt, ...) no_printk(fmt, ##__VA_ARGS__)
  66. #define BRCMF_DATA_ON() 0
  67. #define BRCMF_CTL_ON() 0
  68. #define BRCMF_HDRS_ON() 0
  69. #define BRCMF_BYTES_ON() 0
  70. #define BRCMF_GLOM_ON() 0
  71. #define BRCMF_EVENT_ON() 0
  72. #define BRCMF_FIL_ON() 0
  73. #endif /* defined(DEBUG) */
  74. #define brcmf_dbg_hex_dump(test, data, len, fmt, ...) \
  75. do { \
  76. if (test) \
  77. brcmu_dbg_hex_dump(data, len, fmt, ##__VA_ARGS__); \
  78. } while (0)
  79. extern int brcmf_msg_level;
  80. /*
  81. * hold counter variables used in brcmfmac sdio driver.
  82. */
  83. struct brcmf_sdio_count {
  84. uint intrcount; /* Count of device interrupt callbacks */
  85. uint lastintrs; /* Count as of last watchdog timer */
  86. uint pollcnt; /* Count of active polls */
  87. uint regfails; /* Count of R_REG failures */
  88. uint tx_sderrs; /* Count of tx attempts with sd errors */
  89. uint fcqueued; /* Tx packets that got queued */
  90. uint rxrtx; /* Count of rtx requests (NAK to dongle) */
  91. uint rx_toolong; /* Receive frames too long to receive */
  92. uint rxc_errors; /* SDIO errors when reading control frames */
  93. uint rx_hdrfail; /* SDIO errors on header reads */
  94. uint rx_badhdr; /* Bad received headers (roosync?) */
  95. uint rx_badseq; /* Mismatched rx sequence number */
  96. uint fc_rcvd; /* Number of flow-control events received */
  97. uint fc_xoff; /* Number which turned on flow-control */
  98. uint fc_xon; /* Number which turned off flow-control */
  99. uint rxglomfail; /* Failed deglom attempts */
  100. uint rxglomframes; /* Number of glom frames (superframes) */
  101. uint rxglompkts; /* Number of packets from glom frames */
  102. uint f2rxhdrs; /* Number of header reads */
  103. uint f2rxdata; /* Number of frame data reads */
  104. uint f2txdata; /* Number of f2 frame writes */
  105. uint f1regdata; /* Number of f1 register accesses */
  106. uint tickcnt; /* Number of watchdog been schedule */
  107. ulong tx_ctlerrs; /* Err of sending ctrl frames */
  108. ulong tx_ctlpkts; /* Ctrl frames sent to dongle */
  109. ulong rx_ctlerrs; /* Err of processing rx ctrl frames */
  110. ulong rx_ctlpkts; /* Ctrl frames processed from dongle */
  111. ulong rx_readahead_cnt; /* packets where header read-ahead was used */
  112. };
  113. struct brcmf_pub;
  114. #ifdef DEBUG
  115. void brcmf_debugfs_init(void);
  116. void brcmf_debugfs_exit(void);
  117. int brcmf_debugfs_attach(struct brcmf_pub *drvr);
  118. void brcmf_debugfs_detach(struct brcmf_pub *drvr);
  119. struct dentry *brcmf_debugfs_get_devdir(struct brcmf_pub *drvr);
  120. void brcmf_debugfs_create_sdio_count(struct brcmf_pub *drvr,
  121. struct brcmf_sdio_count *sdcnt);
  122. #else
  123. static inline void brcmf_debugfs_init(void)
  124. {
  125. }
  126. static inline void brcmf_debugfs_exit(void)
  127. {
  128. }
  129. static inline int brcmf_debugfs_attach(struct brcmf_pub *drvr)
  130. {
  131. return 0;
  132. }
  133. static inline void brcmf_debugfs_detach(struct brcmf_pub *drvr)
  134. {
  135. }
  136. #endif
  137. #endif /* _BRCMF_DBG_H_ */