dhd_dbg.h 4.7 KB

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