cifs_debug.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. *
  4. * Copyright (c) International Business Machines Corp., 2000,2002
  5. * Modified by Steve French (sfrench@us.ibm.com)
  6. */
  7. #ifndef _H_CIFS_DEBUG
  8. #define _H_CIFS_DEBUG
  9. #ifdef pr_fmt
  10. #undef pr_fmt
  11. #endif
  12. #define pr_fmt(fmt) "CIFS: " fmt
  13. void cifs_dump_mem(char *label, void *data, int length);
  14. void cifs_dump_detail(void *buf, struct TCP_Server_Info *ptcp_info);
  15. void cifs_dump_mids(struct TCP_Server_Info *);
  16. extern bool traceSMB; /* flag which enables the function below */
  17. void dump_smb(void *, int);
  18. #define CIFS_INFO 0x01
  19. #define CIFS_RC 0x02
  20. #define CIFS_TIMER 0x04
  21. #define VFS 1
  22. #define FYI 2
  23. extern int cifsFYI;
  24. #ifdef CONFIG_CIFS_DEBUG2
  25. #define NOISY 4
  26. #else
  27. #define NOISY 0
  28. #endif
  29. #define ONCE 8
  30. /*
  31. * debug ON
  32. * --------
  33. */
  34. #ifdef CONFIG_CIFS_DEBUG
  35. /*
  36. * When adding tracepoints and debug messages we have various choices.
  37. * Some considerations:
  38. *
  39. * Use cifs_dbg(VFS, ...) for things we always want logged, and the user to see
  40. * cifs_info(...) slightly less important, admin can filter via loglevel > 6
  41. * cifs_dbg(FYI, ...) minor debugging messages, off by default
  42. * trace_smb3_* ftrace functions are preferred for complex debug messages
  43. * intended for developers or experienced admins, off by default
  44. */
  45. /* Information level messages, minor events */
  46. #define cifs_info_func(ratefunc, fmt, ...) \
  47. pr_info_ ## ratefunc(fmt, ##__VA_ARGS__)
  48. #define cifs_info(fmt, ...) \
  49. cifs_info_func(ratelimited, fmt, ##__VA_ARGS__)
  50. /* information message: e.g., configuration, major event */
  51. #define cifs_dbg_func(ratefunc, type, fmt, ...) \
  52. do { \
  53. if ((type) & FYI && cifsFYI & CIFS_INFO) { \
  54. pr_debug_ ## ratefunc("%s: " fmt, \
  55. __FILE__, ##__VA_ARGS__); \
  56. } else if ((type) & VFS) { \
  57. pr_err_ ## ratefunc("VFS: " fmt, ##__VA_ARGS__); \
  58. } else if ((type) & NOISY && (NOISY != 0)) { \
  59. pr_debug_ ## ratefunc(fmt, ##__VA_ARGS__); \
  60. } \
  61. } while (0)
  62. #define cifs_dbg(type, fmt, ...) \
  63. do { \
  64. if ((type) & ONCE) \
  65. cifs_dbg_func(once, type, fmt, ##__VA_ARGS__); \
  66. else \
  67. cifs_dbg_func(ratelimited, type, fmt, ##__VA_ARGS__); \
  68. } while (0)
  69. #define cifs_server_dbg_func(ratefunc, type, fmt, ...) \
  70. do { \
  71. const char *sn = ""; \
  72. if (server && server->hostname) \
  73. sn = server->hostname; \
  74. if ((type) & FYI && cifsFYI & CIFS_INFO) { \
  75. pr_debug_ ## ratefunc("%s: \\\\%s " fmt, \
  76. __FILE__, sn, ##__VA_ARGS__); \
  77. } else if ((type) & VFS) { \
  78. pr_err_ ## ratefunc("VFS: \\\\%s " fmt, \
  79. sn, ##__VA_ARGS__); \
  80. } else if ((type) & NOISY && (NOISY != 0)) { \
  81. pr_debug_ ## ratefunc("\\\\%s " fmt, \
  82. sn, ##__VA_ARGS__); \
  83. } \
  84. } while (0)
  85. #define cifs_server_dbg(type, fmt, ...) \
  86. do { \
  87. if ((type) & ONCE) \
  88. cifs_server_dbg_func(once, type, fmt, ##__VA_ARGS__); \
  89. else \
  90. cifs_server_dbg_func(ratelimited, type, fmt, \
  91. ##__VA_ARGS__); \
  92. } while (0)
  93. #define cifs_tcon_dbg_func(ratefunc, type, fmt, ...) \
  94. do { \
  95. const char *tn = ""; \
  96. if (tcon && tcon->treeName) \
  97. tn = tcon->treeName; \
  98. if ((type) & FYI && cifsFYI & CIFS_INFO) { \
  99. pr_debug_ ## ratefunc("%s: %s " fmt, \
  100. __FILE__, tn, ##__VA_ARGS__); \
  101. } else if ((type) & VFS) { \
  102. pr_err_ ## ratefunc("VFS: %s " fmt, tn, ##__VA_ARGS__); \
  103. } else if ((type) & NOISY && (NOISY != 0)) { \
  104. pr_debug_ ## ratefunc("%s " fmt, tn, ##__VA_ARGS__); \
  105. } \
  106. } while (0)
  107. #define cifs_tcon_dbg(type, fmt, ...) \
  108. do { \
  109. if ((type) & ONCE) \
  110. cifs_tcon_dbg_func(once, type, fmt, ##__VA_ARGS__); \
  111. else \
  112. cifs_tcon_dbg_func(ratelimited, type, fmt, \
  113. ##__VA_ARGS__); \
  114. } while (0)
  115. /*
  116. * debug OFF
  117. * ---------
  118. */
  119. #else /* _CIFS_DEBUG */
  120. #define cifs_dbg(type, fmt, ...) \
  121. do { \
  122. if (0) \
  123. pr_debug(fmt, ##__VA_ARGS__); \
  124. } while (0)
  125. #define cifs_server_dbg(type, fmt, ...) \
  126. do { \
  127. if (0) \
  128. pr_debug("\\\\%s " fmt, \
  129. server->hostname, ##__VA_ARGS__); \
  130. } while (0)
  131. #define cifs_tcon_dbg(type, fmt, ...) \
  132. do { \
  133. if (0) \
  134. pr_debug("%s " fmt, tcon->treeName, ##__VA_ARGS__); \
  135. } while (0)
  136. #define cifs_info(fmt, ...) \
  137. pr_info(fmt, ##__VA_ARGS__)
  138. #endif
  139. #endif /* _H_CIFS_DEBUG */