mptdebug.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * linux/drivers/message/fusion/mptdebug.h
  4. * For use with LSI PCI chip/adapter(s)
  5. * running LSI Fusion MPT (Message Passing Technology) firmware.
  6. *
  7. * Copyright (c) 1999-2008 LSI Corporation
  8. * (mailto:[email protected])
  9. *
  10. */
  11. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
  12. #ifndef MPTDEBUG_H_INCLUDED
  13. #define MPTDEBUG_H_INCLUDED
  14. /*
  15. * debug level can be programmed on the fly via SysFS (hex values)
  16. *
  17. * Example: (programming for MPT_DEBUG_EVENTS on host 5)
  18. *
  19. * echo 8 > /sys/class/scsi_host/host5/debug_level
  20. *
  21. * --------------------------------------------------------
  22. * mpt_debug_level - command line parameter
  23. * this allow enabling debug at driver load time (for all iocs)
  24. *
  25. * Example (programming for MPT_DEBUG_EVENTS)
  26. *
  27. * insmod mptbase.ko mpt_debug_level=8
  28. *
  29. * --------------------------------------------------------
  30. * CONFIG_FUSION_LOGGING - enables compiling debug into driver
  31. * this can be enabled in the driver Makefile
  32. *
  33. *
  34. * --------------------------------------------------------
  35. * Please note most debug prints are set to logging priority = debug
  36. * This is the lowest level, and most verbose. Please refer to manual
  37. * pages for syslogd or syslogd-ng on how to configure this.
  38. */
  39. #define MPT_DEBUG 0x00000001
  40. #define MPT_DEBUG_MSG_FRAME 0x00000002
  41. #define MPT_DEBUG_SG 0x00000004
  42. #define MPT_DEBUG_EVENTS 0x00000008
  43. #define MPT_DEBUG_VERBOSE_EVENTS 0x00000010
  44. #define MPT_DEBUG_INIT 0x00000020
  45. #define MPT_DEBUG_EXIT 0x00000040
  46. #define MPT_DEBUG_FAIL 0x00000080
  47. #define MPT_DEBUG_TM 0x00000100
  48. #define MPT_DEBUG_DV 0x00000200
  49. #define MPT_DEBUG_REPLY 0x00000400
  50. #define MPT_DEBUG_HANDSHAKE 0x00000800
  51. #define MPT_DEBUG_CONFIG 0x00001000
  52. #define MPT_DEBUG_DL 0x00002000
  53. #define MPT_DEBUG_RESET 0x00008000
  54. #define MPT_DEBUG_SCSI 0x00010000
  55. #define MPT_DEBUG_IOCTL 0x00020000
  56. #define MPT_DEBUG_FC 0x00080000
  57. #define MPT_DEBUG_SAS 0x00100000
  58. #define MPT_DEBUG_SAS_WIDE 0x00200000
  59. #define MPT_DEBUG_36GB_MEM 0x00400000
  60. /*
  61. * CONFIG_FUSION_LOGGING - enabled in Kconfig
  62. */
  63. #ifdef CONFIG_FUSION_LOGGING
  64. #define MPT_CHECK_LOGGING(IOC, CMD, BITS) \
  65. do { \
  66. if (IOC->debug_level & BITS) \
  67. CMD; \
  68. } while (0)
  69. #else
  70. #define MPT_CHECK_LOGGING(IOC, CMD, BITS) \
  71. do { } while (0)
  72. #endif
  73. /*
  74. * debug macros
  75. */
  76. #define dprintk(IOC, CMD) \
  77. MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG)
  78. #define dsgprintk(IOC, CMD) \
  79. MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_SG)
  80. #define devtprintk(IOC, CMD) \
  81. MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_EVENTS)
  82. #define devtverboseprintk(IOC, CMD) \
  83. MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_VERBOSE_EVENTS)
  84. #define dinitprintk(IOC, CMD) \
  85. MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_INIT)
  86. #define dexitprintk(IOC, CMD) \
  87. MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_EXIT)
  88. #define dfailprintk(IOC, CMD) \
  89. MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_FAIL)
  90. #define dtmprintk(IOC, CMD) \
  91. MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_TM)
  92. #define ddvprintk(IOC, CMD) \
  93. MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_DV)
  94. #define dreplyprintk(IOC, CMD) \
  95. MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_REPLY)
  96. #define dhsprintk(IOC, CMD) \
  97. MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_HANDSHAKE)
  98. #define dcprintk(IOC, CMD) \
  99. MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_CONFIG)
  100. #define ddlprintk(IOC, CMD) \
  101. MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_DL)
  102. #define drsprintk(IOC, CMD) \
  103. MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_RESET)
  104. #define dsprintk(IOC, CMD) \
  105. MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_SCSI)
  106. #define dctlprintk(IOC, CMD) \
  107. MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_IOCTL)
  108. #define dfcprintk(IOC, CMD) \
  109. MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_FC)
  110. #define dsasprintk(IOC, CMD) \
  111. MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_SAS)
  112. #define dsaswideprintk(IOC, CMD) \
  113. MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_SAS_WIDE)
  114. #define d36memprintk(IOC, CMD) \
  115. MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_36GB_MEM)
  116. /*
  117. * Verbose logging
  118. */
  119. #if defined(MPT_DEBUG_VERBOSE) && defined(CONFIG_FUSION_LOGGING)
  120. static inline void
  121. DBG_DUMP_FW_DOWNLOAD(MPT_ADAPTER *ioc, u32 *mfp, int numfrags)
  122. {
  123. int i;
  124. if (!(ioc->debug_level & MPT_DEBUG))
  125. return;
  126. printk(KERN_DEBUG "F/W download request:\n");
  127. for (i=0; i < 7+numfrags*2; i++)
  128. printk(" %08x", le32_to_cpu(mfp[i]));
  129. printk("\n");
  130. }
  131. static inline void
  132. DBG_DUMP_PUT_MSG_FRAME(MPT_ADAPTER *ioc, u32 *mfp)
  133. {
  134. int ii, n;
  135. if (!(ioc->debug_level & MPT_DEBUG_MSG_FRAME))
  136. return;
  137. printk(KERN_DEBUG "%s: About to Put msg frame @ %p:\n",
  138. ioc->name, mfp);
  139. n = ioc->req_sz/4 - 1;
  140. while (mfp[n] == 0)
  141. n--;
  142. for (ii=0; ii<=n; ii++) {
  143. if (ii && ((ii%8)==0))
  144. printk("\n");
  145. printk(" %08x", le32_to_cpu(mfp[ii]));
  146. }
  147. printk("\n");
  148. }
  149. static inline void
  150. DBG_DUMP_FW_REQUEST_FRAME(MPT_ADAPTER *ioc, u32 *mfp)
  151. {
  152. int i, n;
  153. if (!(ioc->debug_level & MPT_DEBUG_MSG_FRAME))
  154. return;
  155. n = 10;
  156. printk(KERN_INFO " ");
  157. for (i = 0; i < n; i++)
  158. printk(" %08x", le32_to_cpu(mfp[i]));
  159. printk("\n");
  160. }
  161. static inline void
  162. DBG_DUMP_REQUEST_FRAME(MPT_ADAPTER *ioc, u32 *mfp)
  163. {
  164. int i, n;
  165. if (!(ioc->debug_level & MPT_DEBUG_MSG_FRAME))
  166. return;
  167. n = 24;
  168. for (i=0; i<n; i++) {
  169. if (i && ((i%8)==0))
  170. printk("\n");
  171. printk("%08x ", le32_to_cpu(mfp[i]));
  172. }
  173. printk("\n");
  174. }
  175. static inline void
  176. DBG_DUMP_REPLY_FRAME(MPT_ADAPTER *ioc, u32 *mfp)
  177. {
  178. int i, n;
  179. if (!(ioc->debug_level & MPT_DEBUG_MSG_FRAME))
  180. return;
  181. n = (le32_to_cpu(mfp[0]) & 0x00FF0000) >> 16;
  182. printk(KERN_INFO " ");
  183. for (i=0; i<n; i++)
  184. printk(" %08x", le32_to_cpu(mfp[i]));
  185. printk("\n");
  186. }
  187. static inline void
  188. DBG_DUMP_REQUEST_FRAME_HDR(MPT_ADAPTER *ioc, u32 *mfp)
  189. {
  190. int i, n;
  191. if (!(ioc->debug_level & MPT_DEBUG_MSG_FRAME))
  192. return;
  193. n = 3;
  194. printk(KERN_INFO " ");
  195. for (i=0; i<n; i++)
  196. printk(" %08x", le32_to_cpu(mfp[i]));
  197. printk("\n");
  198. }
  199. static inline void
  200. DBG_DUMP_TM_REQUEST_FRAME(MPT_ADAPTER *ioc, u32 *mfp)
  201. {
  202. int i, n;
  203. if (!(ioc->debug_level & MPT_DEBUG_TM))
  204. return;
  205. n = 13;
  206. printk(KERN_DEBUG "TM_REQUEST:\n");
  207. for (i=0; i<n; i++) {
  208. if (i && ((i%8)==0))
  209. printk("\n");
  210. printk("%08x ", le32_to_cpu(mfp[i]));
  211. }
  212. printk("\n");
  213. }
  214. static inline void
  215. DBG_DUMP_TM_REPLY_FRAME(MPT_ADAPTER *ioc, u32 *mfp)
  216. {
  217. int i, n;
  218. if (!(ioc->debug_level & MPT_DEBUG_TM))
  219. return;
  220. n = (le32_to_cpu(mfp[0]) & 0x00FF0000) >> 16;
  221. printk(KERN_DEBUG "TM_REPLY MessageLength=%d:\n", n);
  222. for (i=0; i<n; i++) {
  223. if (i && ((i%8)==0))
  224. printk("\n");
  225. printk(" %08x", le32_to_cpu(mfp[i]));
  226. }
  227. printk("\n");
  228. }
  229. #define dmfprintk(IOC, CMD) \
  230. MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_MSG_FRAME)
  231. # else /* ifdef MPT_DEBUG_MF */
  232. #define DBG_DUMP_FW_DOWNLOAD(IOC, mfp, numfrags)
  233. #define DBG_DUMP_PUT_MSG_FRAME(IOC, mfp)
  234. #define DBG_DUMP_FW_REQUEST_FRAME(IOC, mfp)
  235. #define DBG_DUMP_REQUEST_FRAME(IOC, mfp)
  236. #define DBG_DUMP_REPLY_FRAME(IOC, mfp)
  237. #define DBG_DUMP_REQUEST_FRAME_HDR(IOC, mfp)
  238. #define DBG_DUMP_TM_REQUEST_FRAME(IOC, mfp)
  239. #define DBG_DUMP_TM_REPLY_FRAME(IOC, mfp)
  240. #define dmfprintk(IOC, CMD) \
  241. MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_MSG_FRAME)
  242. #endif /* defined(MPT_DEBUG_VERBOSE) && defined(CONFIG_FUSION_LOGGING) */
  243. #endif /* ifndef MPTDEBUG_H_INCLUDED */