mptdebug.h 6.8 KB

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