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