synx_debugfs.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2019, The Linux Foundation. All rights reserved.
  4. * Copyright (c) 2022-2023, Qualcomm Innovation Center, Inc. All rights reserved.
  5. */
  6. #ifndef __SYNX_DEBUGFS_H__
  7. #define __SYNX_DEBUGFS_H__
  8. #include <linux/debugfs.h>
  9. #include <linux/delay.h>
  10. #include "synx_private.h"
  11. //#define ENABLE_DEBUGFS
  12. #define STATE_NAME_SPACE (4)
  13. enum synx_debug_level {
  14. SYNX_ERR = 0x0001,
  15. SYNX_WARN = 0x0002,
  16. SYNX_INFO = 0x0004,
  17. SYNX_DBG = 0x0008,
  18. SYNX_VERB = 0x0010,
  19. SYNX_IPCL = 0x0020,
  20. SYNX_GSM = 0x0040,
  21. SYNX_MEM = 0x0080,
  22. SYNX_ALL = SYNX_ERR | SYNX_WARN | SYNX_INFO |
  23. SYNX_DBG | SYNX_IPCL | SYNX_GSM | SYNX_MEM,
  24. };
  25. enum synx_columns_level {
  26. NAME_COLUMN = 0x00000001,
  27. ID_COLUMN = 0x00000002,
  28. BOUND_COLUMN = 0x00000004,
  29. STATUS_COLUMN = 0x00000008,
  30. FENCE_COLUMN = 0x00000010,
  31. COREDATA_COLUMN = 0x00000020,
  32. GLOBAL_IDX_COLUMN = 0x00000040,
  33. REL_CNT_COLUMN = 0x00000080,
  34. MAP_CNT_COLUMN = 0x00000100,
  35. REF_CNT_COLUMN = 0x00000200,
  36. NUM_CHILD_COLUMN = 0x00000400,
  37. SUBSCRIBERS_COLUMN = 0x00000800,
  38. WAITERS_COLUMN = 0x00001000,
  39. PARENTS_COLUMN = 0x00002000,
  40. CLIENT_ID_COLUMN = 0x00004000,
  41. LOCAL_HASHTABLE = 0x00010000,
  42. GLOBAL_HASHTABLE = 0x00020000,
  43. CLIENT_HASHTABLE = 0x00040000,
  44. GLOBAL_SHARED_MEM = 0x00080000,
  45. DMA_FENCE_MAP = 0x00100000,
  46. CSL_FENCE_MAP = 0x00200000,
  47. ERROR_CODES = 0x00008000,
  48. };
  49. #ifndef SYNX_DBG_LABEL
  50. #define SYNX_DBG_LABEL "synx"
  51. #endif
  52. #define SYNX_DBG_TAG SYNX_DBG_LABEL ": %4s: "
  53. extern int synx_debug;
  54. extern u32 lower_handle_id, upper_handle_id;
  55. extern long synx_columns;
  56. static inline char *synx_debug_str(int level)
  57. {
  58. switch (level) {
  59. case SYNX_ERR:
  60. return "err";
  61. case SYNX_WARN:
  62. return "warn";
  63. case SYNX_INFO:
  64. return "info";
  65. case SYNX_DBG:
  66. return "dbg";
  67. case SYNX_VERB:
  68. return "verb";
  69. case SYNX_IPCL:
  70. return "ipcl";
  71. case SYNX_GSM:
  72. return "gmem";
  73. case SYNX_MEM:
  74. return "mem";
  75. default:
  76. return "???";
  77. }
  78. }
  79. #define dprintk(__level, __fmt, arg...) \
  80. do { \
  81. if (synx_debug & __level) { \
  82. pr_info(SYNX_DBG_TAG "%s: %d: " __fmt, \
  83. synx_debug_str(__level), __func__, \
  84. __LINE__, ## arg); \
  85. } \
  86. } while (0)
  87. #define SYNX_CONSOLE_LOG(__cur, __end, \
  88. __fmt_string, arg...) \
  89. do { \
  90. if ((__end - __cur) * (sizeof(char *)) \
  91. - strlen(__fmt_string) <= STATE_NAME_SPACE) \
  92. dprintk(SYNX_DBG, __fmt_string, ## arg); \
  93. else \
  94. __cur += scnprintf(__cur, __end - __cur, \
  95. __fmt_string, ## arg); \
  96. } while (0)
  97. #define SYNX_READ_CHAR(__buf, __num, \
  98. __base, __pos) \
  99. do { \
  100. if (__buf[__pos] >= '0' && \
  101. __buf[__pos] <= '9') \
  102. __num = __num * __base + \
  103. (__buf[__pos] - '0'); \
  104. else if (__buf[__pos] >= 'a' && \
  105. __buf[__pos] <= 'f') \
  106. __num = __num * __base + \
  107. (__buf[__pos] - 'a' + 10); \
  108. else if (__buf[__pos] >= 'A' && \
  109. __buf[__pos] <= 'F') \
  110. __num = __num * __base + \
  111. (__buf[__pos] - 'A' + 10); \
  112. else \
  113. invalid_val = true; \
  114. } while (0)
  115. /**
  116. * synx_init_debugfs_dir - Initializes debugfs
  117. *
  118. * @param dev : Pointer to synx device structure
  119. */
  120. struct dentry *synx_init_debugfs_dir(struct synx_device *dev);
  121. /**
  122. * synx_remove_debugfs_dir - Removes debugfs
  123. *
  124. * @param dev : Pointer to synx device structure
  125. */
  126. void synx_remove_debugfs_dir(struct synx_device *dev);
  127. #endif /* __SYNX_DEBUGFS_H__ */