debug.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /* SPDX-License-Identifier: BSD-3-Clause-Clear */
  2. /*
  3. * Copyright (c) 2018-2019 The Linux Foundation. All rights reserved.
  4. * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
  5. */
  6. #ifndef _ATH11K_DEBUG_H_
  7. #define _ATH11K_DEBUG_H_
  8. #include "trace.h"
  9. #include "debugfs.h"
  10. enum ath11k_debug_mask {
  11. ATH11K_DBG_AHB = 0x00000001,
  12. ATH11K_DBG_WMI = 0x00000002,
  13. ATH11K_DBG_HTC = 0x00000004,
  14. ATH11K_DBG_DP_HTT = 0x00000008,
  15. ATH11K_DBG_MAC = 0x00000010,
  16. ATH11K_DBG_BOOT = 0x00000020,
  17. ATH11K_DBG_QMI = 0x00000040,
  18. ATH11K_DBG_DATA = 0x00000080,
  19. ATH11K_DBG_MGMT = 0x00000100,
  20. ATH11K_DBG_REG = 0x00000200,
  21. ATH11K_DBG_TESTMODE = 0x00000400,
  22. ATH11K_DBG_HAL = 0x00000800,
  23. ATH11K_DBG_PCI = 0x00001000,
  24. ATH11K_DBG_DP_TX = 0x00002000,
  25. ATH11K_DBG_DP_RX = 0x00004000,
  26. ATH11K_DBG_CE = 0x00008000,
  27. };
  28. static inline const char *ath11k_dbg_str(enum ath11k_debug_mask mask)
  29. {
  30. switch (mask) {
  31. case ATH11K_DBG_AHB:
  32. return "ahb";
  33. case ATH11K_DBG_WMI:
  34. return "wmi";
  35. case ATH11K_DBG_HTC:
  36. return "htc";
  37. case ATH11K_DBG_DP_HTT:
  38. return "dp_htt";
  39. case ATH11K_DBG_MAC:
  40. return "mac";
  41. case ATH11K_DBG_BOOT:
  42. return "boot";
  43. case ATH11K_DBG_QMI:
  44. return "qmi";
  45. case ATH11K_DBG_DATA:
  46. return "data";
  47. case ATH11K_DBG_MGMT:
  48. return "mgmt";
  49. case ATH11K_DBG_REG:
  50. return "reg";
  51. case ATH11K_DBG_TESTMODE:
  52. return "testmode";
  53. case ATH11K_DBG_HAL:
  54. return "hal";
  55. case ATH11K_DBG_PCI:
  56. return "pci";
  57. case ATH11K_DBG_DP_TX:
  58. return "dp_tx";
  59. case ATH11K_DBG_DP_RX:
  60. return "dp_rx";
  61. case ATH11K_DBG_CE:
  62. return "ce";
  63. /* no default handler to allow compiler to check that the
  64. * enum is fully handled
  65. */
  66. }
  67. return "<?>";
  68. }
  69. __printf(2, 3) void ath11k_info(struct ath11k_base *ab, const char *fmt, ...);
  70. __printf(2, 3) void ath11k_err(struct ath11k_base *ab, const char *fmt, ...);
  71. __printf(2, 3) void ath11k_warn(struct ath11k_base *ab, const char *fmt, ...);
  72. extern unsigned int ath11k_debug_mask;
  73. #ifdef CONFIG_ATH11K_DEBUG
  74. __printf(3, 4) void __ath11k_dbg(struct ath11k_base *ab,
  75. enum ath11k_debug_mask mask,
  76. const char *fmt, ...);
  77. void ath11k_dbg_dump(struct ath11k_base *ab,
  78. enum ath11k_debug_mask mask,
  79. const char *msg, const char *prefix,
  80. const void *buf, size_t len);
  81. #else /* CONFIG_ATH11K_DEBUG */
  82. static inline int __ath11k_dbg(struct ath11k_base *ab,
  83. enum ath11k_debug_mask dbg_mask,
  84. const char *fmt, ...)
  85. {
  86. return 0;
  87. }
  88. static inline void ath11k_dbg_dump(struct ath11k_base *ab,
  89. enum ath11k_debug_mask mask,
  90. const char *msg, const char *prefix,
  91. const void *buf, size_t len)
  92. {
  93. }
  94. #endif /* CONFIG_ATH11K_DEBUG */
  95. #define ath11k_dbg(ar, dbg_mask, fmt, ...) \
  96. do { \
  97. if ((ath11k_debug_mask & dbg_mask) || \
  98. trace_ath11k_log_dbg_enabled()) \
  99. __ath11k_dbg(ar, dbg_mask, fmt, ##__VA_ARGS__); \
  100. } while (0)
  101. #endif /* _ATH11K_DEBUG_H_ */