dhd_dbg.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  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. trace_brcmf_hexdump((void *)data, len); \
  87. if (test) \
  88. brcmu_dbg_hex_dump(data, len, fmt, ##__VA_ARGS__); \
  89. } while (0)
  90. extern int brcmf_msg_level;
  91. /*
  92. * hold counter variables used in brcmfmac sdio driver.
  93. */
  94. struct brcmf_sdio_count {
  95. uint intrcount; /* Count of device interrupt callbacks */
  96. uint lastintrs; /* Count as of last watchdog timer */
  97. uint pollcnt; /* Count of active polls */
  98. uint regfails; /* Count of R_REG failures */
  99. uint tx_sderrs; /* Count of tx attempts with sd errors */
  100. uint fcqueued; /* Tx packets that got queued */
  101. uint rxrtx; /* Count of rtx requests (NAK to dongle) */
  102. uint rx_toolong; /* Receive frames too long to receive */
  103. uint rxc_errors; /* SDIO errors when reading control frames */
  104. uint rx_hdrfail; /* SDIO errors on header reads */
  105. uint rx_badhdr; /* Bad received headers (roosync?) */
  106. uint rx_badseq; /* Mismatched rx sequence number */
  107. uint fc_rcvd; /* Number of flow-control events received */
  108. uint fc_xoff; /* Number which turned on flow-control */
  109. uint fc_xon; /* Number which turned off flow-control */
  110. uint rxglomfail; /* Failed deglom attempts */
  111. uint rxglomframes; /* Number of glom frames (superframes) */
  112. uint rxglompkts; /* Number of packets from glom frames */
  113. uint f2rxhdrs; /* Number of header reads */
  114. uint f2rxdata; /* Number of frame data reads */
  115. uint f2txdata; /* Number of f2 frame writes */
  116. uint f1regdata; /* Number of f1 register accesses */
  117. uint tickcnt; /* Number of watchdog been schedule */
  118. ulong tx_ctlerrs; /* Err of sending ctrl frames */
  119. ulong tx_ctlpkts; /* Ctrl frames sent to dongle */
  120. ulong rx_ctlerrs; /* Err of processing rx ctrl frames */
  121. ulong rx_ctlpkts; /* Ctrl frames processed from dongle */
  122. ulong rx_readahead_cnt; /* packets where header read-ahead was used */
  123. };
  124. struct brcmf_fws_stats {
  125. u32 tlv_parse_failed;
  126. u32 tlv_invalid_type;
  127. u32 header_only_pkt;
  128. u32 header_pulls;
  129. u32 pkt2bus;
  130. u32 send_pkts[5];
  131. u32 requested_sent[5];
  132. u32 generic_error;
  133. u32 mac_update_failed;
  134. u32 mac_ps_update_failed;
  135. u32 if_update_failed;
  136. u32 packet_request_failed;
  137. u32 credit_request_failed;
  138. u32 rollback_success;
  139. u32 rollback_failed;
  140. u32 delayq_full_error;
  141. u32 supprq_full_error;
  142. u32 txs_indicate;
  143. u32 txs_discard;
  144. u32 txs_supp_core;
  145. u32 txs_supp_ps;
  146. u32 txs_tossed;
  147. u32 txs_host_tossed;
  148. u32 bus_flow_block;
  149. u32 fws_flow_block;
  150. };
  151. struct brcmf_pub;
  152. #ifdef DEBUG
  153. void brcmf_debugfs_init(void);
  154. void brcmf_debugfs_exit(void);
  155. int brcmf_debugfs_attach(struct brcmf_pub *drvr);
  156. void brcmf_debugfs_detach(struct brcmf_pub *drvr);
  157. struct dentry *brcmf_debugfs_get_devdir(struct brcmf_pub *drvr);
  158. void brcmf_debugfs_create_sdio_count(struct brcmf_pub *drvr,
  159. struct brcmf_sdio_count *sdcnt);
  160. void brcmf_debugfs_create_fws_stats(struct brcmf_pub *drvr,
  161. struct brcmf_fws_stats *stats);
  162. #else
  163. static inline void brcmf_debugfs_init(void)
  164. {
  165. }
  166. static inline void brcmf_debugfs_exit(void)
  167. {
  168. }
  169. static inline int brcmf_debugfs_attach(struct brcmf_pub *drvr)
  170. {
  171. return 0;
  172. }
  173. static inline void brcmf_debugfs_detach(struct brcmf_pub *drvr)
  174. {
  175. }
  176. static inline void brcmf_debugfs_create_fws_stats(struct brcmf_pub *drvr,
  177. struct brcmf_fws_stats *stats)
  178. {
  179. }
  180. #endif
  181. #endif /* _BRCMF_DBG_H_ */