dhd_dbg.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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. #else /* (defined DEBUG) || (defined DEBUG) */
  54. #define brcmf_dbg(level, fmt, ...) no_printk(fmt, ##__VA_ARGS__)
  55. #define BRCMF_DATA_ON() 0
  56. #define BRCMF_CTL_ON() 0
  57. #define BRCMF_HDRS_ON() 0
  58. #define BRCMF_BYTES_ON() 0
  59. #define BRCMF_GLOM_ON() 0
  60. #endif /* defined(DEBUG) */
  61. #define brcmf_dbg_hex_dump(test, data, len, fmt, ...) \
  62. do { \
  63. if (test) \
  64. brcmu_dbg_hex_dump(data, len, fmt, ##__VA_ARGS__); \
  65. } while (0)
  66. extern int brcmf_msg_level;
  67. /*
  68. * hold counter variables used in brcmfmac sdio driver.
  69. */
  70. struct brcmf_sdio_count {
  71. uint intrcount; /* Count of device interrupt callbacks */
  72. uint lastintrs; /* Count as of last watchdog timer */
  73. uint pollcnt; /* Count of active polls */
  74. uint regfails; /* Count of R_REG failures */
  75. uint tx_sderrs; /* Count of tx attempts with sd errors */
  76. uint fcqueued; /* Tx packets that got queued */
  77. uint rxrtx; /* Count of rtx requests (NAK to dongle) */
  78. uint rx_toolong; /* Receive frames too long to receive */
  79. uint rxc_errors; /* SDIO errors when reading control frames */
  80. uint rx_hdrfail; /* SDIO errors on header reads */
  81. uint rx_badhdr; /* Bad received headers (roosync?) */
  82. uint rx_badseq; /* Mismatched rx sequence number */
  83. uint fc_rcvd; /* Number of flow-control events received */
  84. uint fc_xoff; /* Number which turned on flow-control */
  85. uint fc_xon; /* Number which turned off flow-control */
  86. uint rxglomfail; /* Failed deglom attempts */
  87. uint rxglomframes; /* Number of glom frames (superframes) */
  88. uint rxglompkts; /* Number of packets from glom frames */
  89. uint f2rxhdrs; /* Number of header reads */
  90. uint f2rxdata; /* Number of frame data reads */
  91. uint f2txdata; /* Number of f2 frame writes */
  92. uint f1regdata; /* Number of f1 register accesses */
  93. uint tickcnt; /* Number of watchdog been schedule */
  94. ulong tx_ctlerrs; /* Err of sending ctrl frames */
  95. ulong tx_ctlpkts; /* Ctrl frames sent to dongle */
  96. ulong rx_ctlerrs; /* Err of processing rx ctrl frames */
  97. ulong rx_ctlpkts; /* Ctrl frames processed from dongle */
  98. ulong rx_readahead_cnt; /* packets where header read-ahead was used */
  99. };
  100. struct brcmf_pub;
  101. #ifdef DEBUG
  102. void brcmf_debugfs_init(void);
  103. void brcmf_debugfs_exit(void);
  104. int brcmf_debugfs_attach(struct brcmf_pub *drvr);
  105. void brcmf_debugfs_detach(struct brcmf_pub *drvr);
  106. struct dentry *brcmf_debugfs_get_devdir(struct brcmf_pub *drvr);
  107. void brcmf_debugfs_create_sdio_count(struct brcmf_pub *drvr,
  108. struct brcmf_sdio_count *sdcnt);
  109. #else
  110. static inline void brcmf_debugfs_init(void)
  111. {
  112. }
  113. static inline void brcmf_debugfs_exit(void)
  114. {
  115. }
  116. static inline int brcmf_debugfs_attach(struct brcmf_pub *drvr)
  117. {
  118. return 0;
  119. }
  120. static inline void brcmf_debugfs_detach(struct brcmf_pub *drvr)
  121. {
  122. }
  123. #endif
  124. #endif /* _BRCMF_DBG_H_ */