debug.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2017-2021, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef _ICNSS_DEBUG_H
  6. #define _ICNSS_DEBUG_H
  7. #include <linux/ipc_logging.h>
  8. #include <linux/printk.h>
  9. #define NUM_LOG_PAGES 10
  10. #define NUM_LOG_LONG_PAGES 4
  11. extern void *icnss_ipc_log_context;
  12. extern void *icnss_ipc_log_long_context;
  13. extern void *icnss_ipc_log_smp2p_context;
  14. extern void *icnss_ipc_soc_wake_context;
  15. #if IS_ENABLED(CONFIG_IPC_LOGGING)
  16. #define icnss_ipc_log_string(_x...) \
  17. ipc_log_string(icnss_ipc_log_context, _x)
  18. #define icnss_ipc_log_long_string(_x...) \
  19. ipc_log_string(icnss_ipc_log_long_context, _x)
  20. #define icnss_ipc_log_smp2p_string(_x...) \
  21. ipc_log_string(icnss_ipc_log_smp2p_context, _x)
  22. #define icnss_ipc_soc_wake_string(_x...) \
  23. ipc_log_string(icnss_ipc_soc_wake_context, _x)
  24. #else
  25. #define icnss_ipc_log_string(_x...)
  26. #define icnss_ipc_log_long_string(_x...)
  27. #define icnss_ipc_log_smp2p_string(_x...)
  28. #define icnss_ipc_soc_wake_string(_x...)
  29. #endif
  30. #define icnss_pr_err(_fmt, ...) do { \
  31. printk("%s" pr_fmt(_fmt), KERN_ERR, ##__VA_ARGS__); \
  32. icnss_ipc_log_string("%s" pr_fmt(_fmt), "", \
  33. ##__VA_ARGS__); \
  34. } while (0)
  35. #define icnss_pr_warn(_fmt, ...) do { \
  36. printk("%s" pr_fmt(_fmt), KERN_WARNING, ##__VA_ARGS__); \
  37. icnss_ipc_log_string("%s" pr_fmt(_fmt), "", \
  38. ##__VA_ARGS__); \
  39. } while (0)
  40. #define icnss_pr_info(_fmt, ...) do { \
  41. printk("%s" pr_fmt(_fmt), KERN_INFO, ##__VA_ARGS__); \
  42. icnss_ipc_log_string("%s" pr_fmt(_fmt), "", \
  43. ##__VA_ARGS__); \
  44. } while (0)
  45. #define icnss_pr_dbg(_fmt, ...) do { \
  46. pr_debug(_fmt, ##__VA_ARGS__); \
  47. icnss_ipc_log_string(pr_fmt(_fmt), ##__VA_ARGS__); \
  48. } while (0)
  49. #define icnss_pr_vdbg(_fmt, ...) do { \
  50. pr_debug(_fmt, ##__VA_ARGS__); \
  51. icnss_ipc_log_long_string(pr_fmt(_fmt), ##__VA_ARGS__); \
  52. } while (0)
  53. #define icnss_pr_smp2p(_fmt, ...) do { \
  54. pr_debug(_fmt, ##__VA_ARGS__); \
  55. icnss_ipc_log_smp2p_string(pr_fmt(_fmt), ##__VA_ARGS__); \
  56. } while (0)
  57. #define icnss_pr_soc_wake(_fmt, ...) do { \
  58. pr_debug(_fmt, ##__VA_ARGS__); \
  59. icnss_ipc_soc_wake_string(pr_fmt(_fmt), ##__VA_ARGS__); \
  60. } while (0)
  61. #ifdef CONFIG_ICNSS2_DEBUG
  62. #define ICNSS_ASSERT(_condition) do { \
  63. if (!(_condition)) { \
  64. icnss_pr_err("ASSERT at line %d\n", __LINE__); \
  65. BUG(); \
  66. } \
  67. } while (0)
  68. #else
  69. #define ICNSS_ASSERT(_condition) do { } while (0)
  70. #endif
  71. #define icnss_fatal_err(_fmt, ...) \
  72. icnss_pr_err("fatal: "_fmt, ##__VA_ARGS__)
  73. enum icnss_debug_quirks {
  74. HW_ALWAYS_ON,
  75. HW_DEBUG_ENABLE,
  76. SKIP_QMI,
  77. RECOVERY_DISABLE,
  78. SSR_ONLY,
  79. PDR_ONLY,
  80. FW_REJUVENATE_ENABLE,
  81. };
  82. void icnss_debug_init(void);
  83. void icnss_debug_deinit(void);
  84. int icnss_debugfs_create(struct icnss_priv *priv);
  85. void icnss_debugfs_destroy(struct icnss_priv *priv);
  86. #endif /* _ICNSS_DEBUG_H */