mpi3mr_debug.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * Driver for Broadcom MPI3 Storage Controllers
  4. *
  5. * Copyright (C) 2017-2022 Broadcom Inc.
  6. * (mailto: [email protected])
  7. *
  8. */
  9. #ifndef MPI3SAS_DEBUG_H_INCLUDED
  10. #define MPI3SAS_DEBUG_H_INCLUDED
  11. /*
  12. * debug levels
  13. */
  14. #define MPI3_DEBUG_EVENT 0x00000001
  15. #define MPI3_DEBUG_EVENT_WORK_TASK 0x00000002
  16. #define MPI3_DEBUG_INIT 0x00000004
  17. #define MPI3_DEBUG_EXIT 0x00000008
  18. #define MPI3_DEBUG_TM 0x00000010
  19. #define MPI3_DEBUG_RESET 0x00000020
  20. #define MPI3_DEBUG_SCSI_ERROR 0x00000040
  21. #define MPI3_DEBUG_REPLY 0x00000080
  22. #define MPI3_DEBUG_CFG_ERROR 0x00000100
  23. #define MPI3_DEBUG_TRANSPORT_ERROR 0x00000200
  24. #define MPI3_DEBUG_BSG_ERROR 0x00008000
  25. #define MPI3_DEBUG_BSG_INFO 0x00010000
  26. #define MPI3_DEBUG_SCSI_INFO 0x00020000
  27. #define MPI3_DEBUG_CFG_INFO 0x00040000
  28. #define MPI3_DEBUG_TRANSPORT_INFO 0x00080000
  29. #define MPI3_DEBUG 0x01000000
  30. #define MPI3_DEBUG_SG 0x02000000
  31. /*
  32. * debug macros
  33. */
  34. #define ioc_err(ioc, fmt, ...) \
  35. pr_err("%s: " fmt, (ioc)->name, ##__VA_ARGS__)
  36. #define ioc_notice(ioc, fmt, ...) \
  37. pr_notice("%s: " fmt, (ioc)->name, ##__VA_ARGS__)
  38. #define ioc_warn(ioc, fmt, ...) \
  39. pr_warn("%s: " fmt, (ioc)->name, ##__VA_ARGS__)
  40. #define ioc_info(ioc, fmt, ...) \
  41. pr_info("%s: " fmt, (ioc)->name, ##__VA_ARGS__)
  42. #define dprint(ioc, fmt, ...) \
  43. do { \
  44. if (ioc->logging_level & MPI3_DEBUG) \
  45. pr_info("%s: " fmt, (ioc)->name, ##__VA_ARGS__); \
  46. } while (0)
  47. #define dprint_event_th(ioc, fmt, ...) \
  48. do { \
  49. if (ioc->logging_level & MPI3_DEBUG_EVENT) \
  50. pr_info("%s: " fmt, (ioc)->name, ##__VA_ARGS__); \
  51. } while (0)
  52. #define dprint_event_bh(ioc, fmt, ...) \
  53. do { \
  54. if (ioc->logging_level & MPI3_DEBUG_EVENT_WORK_TASK) \
  55. pr_info("%s: " fmt, (ioc)->name, ##__VA_ARGS__); \
  56. } while (0)
  57. #define dprint_init(ioc, fmt, ...) \
  58. do { \
  59. if (ioc->logging_level & MPI3_DEBUG_INIT) \
  60. pr_info("%s: " fmt, (ioc)->name, ##__VA_ARGS__); \
  61. } while (0)
  62. #define dprint_exit(ioc, fmt, ...) \
  63. do { \
  64. if (ioc->logging_level & MPI3_DEBUG_EXIT) \
  65. pr_info("%s: " fmt, (ioc)->name, ##__VA_ARGS__); \
  66. } while (0)
  67. #define dprint_tm(ioc, fmt, ...) \
  68. do { \
  69. if (ioc->logging_level & MPI3_DEBUG_TM) \
  70. pr_info("%s: " fmt, (ioc)->name, ##__VA_ARGS__); \
  71. } while (0)
  72. #define dprint_reply(ioc, fmt, ...) \
  73. do { \
  74. if (ioc->logging_level & MPI3_DEBUG_REPLY) \
  75. pr_info("%s: " fmt, (ioc)->name, ##__VA_ARGS__); \
  76. } while (0)
  77. #define dprint_reset(ioc, fmt, ...) \
  78. do { \
  79. if (ioc->logging_level & MPI3_DEBUG_RESET) \
  80. pr_info("%s: " fmt, (ioc)->name, ##__VA_ARGS__); \
  81. } while (0)
  82. #define dprint_scsi_info(ioc, fmt, ...) \
  83. do { \
  84. if (ioc->logging_level & MPI3_DEBUG_SCSI_INFO) \
  85. pr_info("%s: " fmt, (ioc)->name, ##__VA_ARGS__); \
  86. } while (0)
  87. #define dprint_scsi_err(ioc, fmt, ...) \
  88. do { \
  89. if (ioc->logging_level & MPI3_DEBUG_SCSI_ERROR) \
  90. pr_info("%s: " fmt, (ioc)->name, ##__VA_ARGS__); \
  91. } while (0)
  92. #define dprint_scsi_command(ioc, SCMD, LOG_LEVEL) \
  93. do { \
  94. if (ioc->logging_level & LOG_LEVEL) \
  95. scsi_print_command(SCMD); \
  96. } while (0)
  97. #define dprint_bsg_info(ioc, fmt, ...) \
  98. do { \
  99. if (ioc->logging_level & MPI3_DEBUG_BSG_INFO) \
  100. pr_info("%s: " fmt, (ioc)->name, ##__VA_ARGS__); \
  101. } while (0)
  102. #define dprint_bsg_err(ioc, fmt, ...) \
  103. do { \
  104. if (ioc->logging_level & MPI3_DEBUG_BSG_ERROR) \
  105. pr_info("%s: " fmt, (ioc)->name, ##__VA_ARGS__); \
  106. } while (0)
  107. #define dprint_cfg_info(ioc, fmt, ...) \
  108. do { \
  109. if (ioc->logging_level & MPI3_DEBUG_CFG_INFO) \
  110. pr_info("%s: " fmt, (ioc)->name, ##__VA_ARGS__); \
  111. } while (0)
  112. #define dprint_cfg_err(ioc, fmt, ...) \
  113. do { \
  114. if (ioc->logging_level & MPI3_DEBUG_CFG_ERROR) \
  115. pr_info("%s: " fmt, (ioc)->name, ##__VA_ARGS__); \
  116. } while (0)
  117. #define dprint_transport_info(ioc, fmt, ...) \
  118. do { \
  119. if (ioc->logging_level & MPI3_DEBUG_TRANSPORT_INFO) \
  120. pr_info("%s: " fmt, (ioc)->name, ##__VA_ARGS__); \
  121. } while (0)
  122. #define dprint_transport_err(ioc, fmt, ...) \
  123. do { \
  124. if (ioc->logging_level & MPI3_DEBUG_TRANSPORT_ERROR) \
  125. pr_info("%s: " fmt, (ioc)->name, ##__VA_ARGS__); \
  126. } while (0)
  127. #endif /* MPT3SAS_DEBUG_H_INCLUDED */
  128. /**
  129. * dprint_dump - print contents of a memory buffer
  130. * @req: Pointer to a memory buffer
  131. * @sz: Memory buffer size
  132. * @namestr: Name String to identify the buffer type
  133. */
  134. static inline void
  135. dprint_dump(void *req, int sz, const char *name_string)
  136. {
  137. int i;
  138. __le32 *mfp = (__le32 *)req;
  139. sz = sz/4;
  140. if (name_string)
  141. pr_info("%s:\n\t", name_string);
  142. else
  143. pr_info("request:\n\t");
  144. for (i = 0; i < sz; i++) {
  145. if (i && ((i % 8) == 0))
  146. pr_info("\n\t");
  147. pr_info("%08x ", le32_to_cpu(mfp[i]));
  148. }
  149. pr_info("\n");
  150. }
  151. /**
  152. * dprint_dump_req - print message frame contents
  153. * @req: pointer to message frame
  154. * @sz: number of dwords
  155. */
  156. static inline void
  157. dprint_dump_req(void *req, int sz)
  158. {
  159. int i;
  160. __le32 *mfp = (__le32 *)req;
  161. pr_info("request:\n\t");
  162. for (i = 0; i < sz; i++) {
  163. if (i && ((i % 8) == 0))
  164. pr_info("\n\t");
  165. pr_info("%08x ", le32_to_cpu(mfp[i]));
  166. }
  167. pr_info("\n");
  168. }