dhd_dbg.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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. #define BRCMF_SDIO_VAL 0x00020000
  36. /* set default print format */
  37. #undef pr_fmt
  38. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  39. /* Macro for error messages. net_ratelimit() is used when driver
  40. * debugging is not selected. When debugging the driver error
  41. * messages are as important as other tracing or even more so.
  42. */
  43. #ifndef CONFIG_BRCM_TRACING
  44. #ifdef CONFIG_BRCMDBG
  45. #define brcmf_err(fmt, ...) pr_err("%s: " fmt, __func__, ##__VA_ARGS__)
  46. #else
  47. #define brcmf_err(fmt, ...) \
  48. do { \
  49. if (net_ratelimit()) \
  50. pr_err("%s: " fmt, __func__, ##__VA_ARGS__); \
  51. } while (0)
  52. #endif
  53. #else
  54. __printf(2, 3)
  55. void __brcmf_err(const char *func, const char *fmt, ...);
  56. #define brcmf_err(fmt, ...) \
  57. __brcmf_err(__func__, fmt, ##__VA_ARGS__)
  58. #endif
  59. #if defined(DEBUG) || defined(CONFIG_BRCM_TRACING)
  60. __printf(3, 4)
  61. void __brcmf_dbg(u32 level, const char *func, const char *fmt, ...);
  62. #define brcmf_dbg(level, fmt, ...) \
  63. do { \
  64. __brcmf_dbg(BRCMF_##level##_VAL, __func__, \
  65. fmt, ##__VA_ARGS__); \
  66. } while (0)
  67. #define BRCMF_DATA_ON() (brcmf_msg_level & BRCMF_DATA_VAL)
  68. #define BRCMF_CTL_ON() (brcmf_msg_level & BRCMF_CTL_VAL)
  69. #define BRCMF_HDRS_ON() (brcmf_msg_level & BRCMF_HDRS_VAL)
  70. #define BRCMF_BYTES_ON() (brcmf_msg_level & BRCMF_BYTES_VAL)
  71. #define BRCMF_GLOM_ON() (brcmf_msg_level & BRCMF_GLOM_VAL)
  72. #define BRCMF_EVENT_ON() (brcmf_msg_level & BRCMF_EVENT_VAL)
  73. #define BRCMF_FIL_ON() (brcmf_msg_level & BRCMF_FIL_VAL)
  74. #else /* defined(DEBUG) || defined(CONFIG_BRCM_TRACING) */
  75. #define brcmf_dbg(level, fmt, ...) no_printk(fmt, ##__VA_ARGS__)
  76. #define BRCMF_DATA_ON() 0
  77. #define BRCMF_CTL_ON() 0
  78. #define BRCMF_HDRS_ON() 0
  79. #define BRCMF_BYTES_ON() 0
  80. #define BRCMF_GLOM_ON() 0
  81. #define BRCMF_EVENT_ON() 0
  82. #define BRCMF_FIL_ON() 0
  83. #endif /* defined(DEBUG) || defined(CONFIG_BRCM_TRACING) */
  84. #define brcmf_dbg_hex_dump(test, data, len, fmt, ...) \
  85. do { \
  86. if (test) \
  87. brcmu_dbg_hex_dump(data, len, fmt, ##__VA_ARGS__); \
  88. } while (0)
  89. extern int brcmf_msg_level;
  90. /*
  91. * hold counter variables used in brcmfmac sdio driver.
  92. */
  93. struct brcmf_sdio_count {
  94. uint intrcount; /* Count of device interrupt callbacks */
  95. uint lastintrs; /* Count as of last watchdog timer */
  96. uint pollcnt; /* Count of active polls */
  97. uint regfails; /* Count of R_REG failures */
  98. uint tx_sderrs; /* Count of tx attempts with sd errors */
  99. uint fcqueued; /* Tx packets that got queued */
  100. uint rxrtx; /* Count of rtx requests (NAK to dongle) */
  101. uint rx_toolong; /* Receive frames too long to receive */
  102. uint rxc_errors; /* SDIO errors when reading control frames */
  103. uint rx_hdrfail; /* SDIO errors on header reads */
  104. uint rx_badhdr; /* Bad received headers (roosync?) */
  105. uint rx_badseq; /* Mismatched rx sequence number */
  106. uint fc_rcvd; /* Number of flow-control events received */
  107. uint fc_xoff; /* Number which turned on flow-control */
  108. uint fc_xon; /* Number which turned off flow-control */
  109. uint rxglomfail; /* Failed deglom attempts */
  110. uint rxglomframes; /* Number of glom frames (superframes) */
  111. uint rxglompkts; /* Number of packets from glom frames */
  112. uint f2rxhdrs; /* Number of header reads */
  113. uint f2rxdata; /* Number of frame data reads */
  114. uint f2txdata; /* Number of f2 frame writes */
  115. uint f1regdata; /* Number of f1 register accesses */
  116. uint tickcnt; /* Number of watchdog been schedule */
  117. ulong tx_ctlerrs; /* Err of sending ctrl frames */
  118. ulong tx_ctlpkts; /* Ctrl frames sent to dongle */
  119. ulong rx_ctlerrs; /* Err of processing rx ctrl frames */
  120. ulong rx_ctlpkts; /* Ctrl frames processed from dongle */
  121. ulong rx_readahead_cnt; /* packets where header read-ahead was used */
  122. };
  123. struct brcmf_fws_stats {
  124. u32 tlv_parse_failed;
  125. u32 tlv_invalid_type;
  126. u32 header_only_pkt;
  127. u32 header_pulls;
  128. u32 pkt2bus;
  129. u32 send_pkts[5];
  130. u32 fifo_credits_sent[5];
  131. u32 fifo_credits_back[6];
  132. u32 generic_error;
  133. u32 mac_update_failed;
  134. u32 mac_ps_update_failed;
  135. u32 if_update_failed;
  136. u32 rollback_success;
  137. u32 rollback_failed;
  138. u32 delayq_full_error;
  139. u32 supprq_full_error;
  140. u32 txs_indicate;
  141. u32 txs_discard;
  142. u32 txs_supp_core;
  143. u32 txs_supp_ps;
  144. u32 txs_tossed;
  145. };
  146. struct brcmf_pub;
  147. #ifdef DEBUG
  148. void brcmf_debugfs_init(void);
  149. void brcmf_debugfs_exit(void);
  150. int brcmf_debugfs_attach(struct brcmf_pub *drvr);
  151. void brcmf_debugfs_detach(struct brcmf_pub *drvr);
  152. struct dentry *brcmf_debugfs_get_devdir(struct brcmf_pub *drvr);
  153. void brcmf_debugfs_create_sdio_count(struct brcmf_pub *drvr,
  154. struct brcmf_sdio_count *sdcnt);
  155. void brcmf_debugfs_create_fws_stats(struct brcmf_pub *drvr,
  156. struct brcmf_fws_stats *stats);
  157. #else
  158. static inline void brcmf_debugfs_init(void)
  159. {
  160. }
  161. static inline void brcmf_debugfs_exit(void)
  162. {
  163. }
  164. static inline int brcmf_debugfs_attach(struct brcmf_pub *drvr)
  165. {
  166. return 0;
  167. }
  168. static inline void brcmf_debugfs_detach(struct brcmf_pub *drvr)
  169. {
  170. }
  171. static inline void brcmf_debugfs_create_fws_stats(struct brcmf_pub *drvr,
  172. struct brcmf_fws_stats *stats)
  173. {
  174. }
  175. #endif
  176. #endif /* _BRCMF_DBG_H_ */