dhd_dbg.h 5.0 KB

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