Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  *  linux/drivers/message/fusion/mptdebug.h
0004  *      For use with LSI PCI chip/adapter(s)
0005  *      running LSI Fusion MPT (Message Passing Technology) firmware.
0006  *
0007  *  Copyright (c) 1999-2008 LSI Corporation
0008  *  (mailto:DL-MPTFusionLinux@lsi.com)
0009  *
0010  */
0011 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
0012 
0013 #ifndef MPTDEBUG_H_INCLUDED
0014 #define MPTDEBUG_H_INCLUDED
0015 
0016 /*
0017  * debug level can be programmed on the fly via SysFS (hex values)
0018  *
0019  * Example:  (programming for MPT_DEBUG_EVENTS on host 5)
0020  *
0021  * echo 8 > /sys/class/scsi_host/host5/debug_level
0022  *
0023  * --------------------------------------------------------
0024  * mpt_debug_level - command line parameter
0025  * this allow enabling debug at driver load time (for all iocs)
0026  *
0027  * Example  (programming for MPT_DEBUG_EVENTS)
0028  *
0029  * insmod mptbase.ko mpt_debug_level=8
0030  *
0031  * --------------------------------------------------------
0032  * CONFIG_FUSION_LOGGING - enables compiling debug into driver
0033  * this can be enabled in the driver Makefile
0034  *
0035  *
0036  * --------------------------------------------------------
0037  * Please note most debug prints are set to logging priority = debug
0038  * This is the lowest level, and most verbose.  Please refer to manual
0039  * pages for syslogd or syslogd-ng on how to configure this.
0040  */
0041 
0042 #define MPT_DEBUG           0x00000001
0043 #define MPT_DEBUG_MSG_FRAME     0x00000002
0044 #define MPT_DEBUG_SG            0x00000004
0045 #define MPT_DEBUG_EVENTS        0x00000008
0046 #define MPT_DEBUG_VERBOSE_EVENTS    0x00000010
0047 #define MPT_DEBUG_INIT          0x00000020
0048 #define MPT_DEBUG_EXIT          0x00000040
0049 #define MPT_DEBUG_FAIL          0x00000080
0050 #define MPT_DEBUG_TM            0x00000100
0051 #define MPT_DEBUG_DV            0x00000200
0052 #define MPT_DEBUG_REPLY         0x00000400
0053 #define MPT_DEBUG_HANDSHAKE     0x00000800
0054 #define MPT_DEBUG_CONFIG        0x00001000
0055 #define MPT_DEBUG_DL            0x00002000
0056 #define MPT_DEBUG_RESET         0x00008000
0057 #define MPT_DEBUG_SCSI          0x00010000
0058 #define MPT_DEBUG_IOCTL         0x00020000
0059 #define MPT_DEBUG_FC            0x00080000
0060 #define MPT_DEBUG_SAS           0x00100000
0061 #define MPT_DEBUG_SAS_WIDE      0x00200000
0062 #define MPT_DEBUG_36GB_MEM              0x00400000
0063 
0064 /*
0065  * CONFIG_FUSION_LOGGING - enabled in Kconfig
0066  */
0067 
0068 #ifdef CONFIG_FUSION_LOGGING
0069 #define MPT_CHECK_LOGGING(IOC, CMD, BITS)           \
0070 do {                                \
0071     if (IOC->debug_level & BITS)                \
0072         CMD;                        \
0073 } while (0)
0074 #else
0075 #define MPT_CHECK_LOGGING(IOC, CMD, BITS)           \
0076 do { } while (0)
0077 #endif
0078 
0079 
0080 /*
0081  * debug macros
0082  */
0083 
0084 #define dprintk(IOC, CMD)           \
0085     MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG)
0086 
0087 #define dsgprintk(IOC, CMD)         \
0088     MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_SG)
0089 
0090 #define devtprintk(IOC, CMD)            \
0091     MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_EVENTS)
0092 
0093 #define devtverboseprintk(IOC, CMD)     \
0094     MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_VERBOSE_EVENTS)
0095 
0096 #define dinitprintk(IOC, CMD)           \
0097     MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_INIT)
0098 
0099 #define dexitprintk(IOC, CMD)           \
0100     MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_EXIT)
0101 
0102 #define dfailprintk(IOC, CMD)           \
0103     MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_FAIL)
0104 
0105 #define dtmprintk(IOC, CMD)         \
0106     MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_TM)
0107 
0108 #define ddvprintk(IOC, CMD)         \
0109     MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_DV)
0110 
0111 #define dreplyprintk(IOC, CMD)          \
0112     MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_REPLY)
0113 
0114 #define dhsprintk(IOC, CMD)         \
0115     MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_HANDSHAKE)
0116 
0117 #define dcprintk(IOC, CMD)          \
0118     MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_CONFIG)
0119 
0120 #define ddlprintk(IOC, CMD)         \
0121     MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_DL)
0122 
0123 #define drsprintk(IOC, CMD)         \
0124     MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_RESET)
0125 
0126 #define dsprintk(IOC, CMD)          \
0127     MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_SCSI)
0128 
0129 #define dctlprintk(IOC, CMD)            \
0130     MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_IOCTL)
0131 
0132 #define dfcprintk(IOC, CMD)         \
0133     MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_FC)
0134 
0135 #define dsasprintk(IOC, CMD)            \
0136     MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_SAS)
0137 
0138 #define dsaswideprintk(IOC, CMD)        \
0139     MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_SAS_WIDE)
0140 
0141 #define d36memprintk(IOC, CMD)      \
0142     MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_36GB_MEM)
0143 
0144 
0145 /*
0146  * Verbose logging
0147  */
0148 #if defined(MPT_DEBUG_VERBOSE) && defined(CONFIG_FUSION_LOGGING)
0149 static inline void
0150 DBG_DUMP_FW_DOWNLOAD(MPT_ADAPTER *ioc, u32  *mfp, int numfrags)
0151 {
0152     int i;
0153 
0154     if (!(ioc->debug_level & MPT_DEBUG))
0155         return;
0156     printk(KERN_DEBUG "F/W download request:\n");
0157     for (i=0; i < 7+numfrags*2; i++)
0158         printk(" %08x", le32_to_cpu(mfp[i]));
0159     printk("\n");
0160 }
0161 
0162 static inline void
0163 DBG_DUMP_PUT_MSG_FRAME(MPT_ADAPTER *ioc, u32 *mfp)
0164 {
0165     int  ii, n;
0166 
0167     if (!(ioc->debug_level & MPT_DEBUG_MSG_FRAME))
0168         return;
0169     printk(KERN_DEBUG "%s: About to Put msg frame @ %p:\n",
0170         ioc->name, mfp);
0171     n = ioc->req_sz/4 - 1;
0172     while (mfp[n] == 0)
0173         n--;
0174     for (ii=0; ii<=n; ii++) {
0175         if (ii && ((ii%8)==0))
0176             printk("\n");
0177         printk(" %08x", le32_to_cpu(mfp[ii]));
0178     }
0179     printk("\n");
0180 }
0181 
0182 static inline void
0183 DBG_DUMP_FW_REQUEST_FRAME(MPT_ADAPTER *ioc, u32 *mfp)
0184 {
0185     int  i, n;
0186 
0187     if (!(ioc->debug_level & MPT_DEBUG_MSG_FRAME))
0188         return;
0189     n = 10;
0190     printk(KERN_INFO " ");
0191     for (i = 0; i < n; i++)
0192         printk(" %08x", le32_to_cpu(mfp[i]));
0193     printk("\n");
0194 }
0195 
0196 static inline void
0197 DBG_DUMP_REQUEST_FRAME(MPT_ADAPTER *ioc, u32 *mfp)
0198 {
0199     int  i, n;
0200 
0201     if (!(ioc->debug_level & MPT_DEBUG_MSG_FRAME))
0202         return;
0203     n = 24;
0204     for (i=0; i<n; i++) {
0205         if (i && ((i%8)==0))
0206             printk("\n");
0207         printk("%08x ", le32_to_cpu(mfp[i]));
0208     }
0209     printk("\n");
0210 }
0211 
0212 static inline void
0213 DBG_DUMP_REPLY_FRAME(MPT_ADAPTER *ioc, u32 *mfp)
0214 {
0215     int  i, n;
0216 
0217     if (!(ioc->debug_level & MPT_DEBUG_MSG_FRAME))
0218         return;
0219     n = (le32_to_cpu(mfp[0]) & 0x00FF0000) >> 16;
0220     printk(KERN_INFO " ");
0221     for (i=0; i<n; i++)
0222         printk(" %08x", le32_to_cpu(mfp[i]));
0223     printk("\n");
0224 }
0225 
0226 static inline void
0227 DBG_DUMP_REQUEST_FRAME_HDR(MPT_ADAPTER *ioc, u32 *mfp)
0228 {
0229     int  i, n;
0230 
0231     if (!(ioc->debug_level & MPT_DEBUG_MSG_FRAME))
0232         return;
0233     n = 3;
0234     printk(KERN_INFO " ");
0235     for (i=0; i<n; i++)
0236         printk(" %08x", le32_to_cpu(mfp[i]));
0237     printk("\n");
0238 }
0239 
0240 static inline void
0241 DBG_DUMP_TM_REQUEST_FRAME(MPT_ADAPTER *ioc, u32 *mfp)
0242 {
0243     int  i, n;
0244 
0245     if (!(ioc->debug_level & MPT_DEBUG_TM))
0246         return;
0247     n = 13;
0248     printk(KERN_DEBUG "TM_REQUEST:\n");
0249     for (i=0; i<n; i++) {
0250         if (i && ((i%8)==0))
0251             printk("\n");
0252         printk("%08x ", le32_to_cpu(mfp[i]));
0253     }
0254     printk("\n");
0255 }
0256 
0257 static inline void
0258 DBG_DUMP_TM_REPLY_FRAME(MPT_ADAPTER *ioc, u32 *mfp)
0259 {
0260     int  i, n;
0261 
0262     if (!(ioc->debug_level & MPT_DEBUG_TM))
0263         return;
0264     n = (le32_to_cpu(mfp[0]) & 0x00FF0000) >> 16;
0265     printk(KERN_DEBUG "TM_REPLY MessageLength=%d:\n", n);
0266     for (i=0; i<n; i++) {
0267         if (i && ((i%8)==0))
0268             printk("\n");
0269         printk(" %08x", le32_to_cpu(mfp[i]));
0270     }
0271     printk("\n");
0272 }
0273 
0274 #define dmfprintk(IOC, CMD)         \
0275     MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_MSG_FRAME)
0276 
0277 # else /* ifdef MPT_DEBUG_MF */
0278 
0279 #define DBG_DUMP_FW_DOWNLOAD(IOC, mfp, numfrags)
0280 #define DBG_DUMP_PUT_MSG_FRAME(IOC, mfp)
0281 #define DBG_DUMP_FW_REQUEST_FRAME(IOC, mfp)
0282 #define DBG_DUMP_REQUEST_FRAME(IOC, mfp)
0283 #define DBG_DUMP_REPLY_FRAME(IOC, mfp)
0284 #define DBG_DUMP_REQUEST_FRAME_HDR(IOC, mfp)
0285 #define DBG_DUMP_TM_REQUEST_FRAME(IOC, mfp)
0286 #define DBG_DUMP_TM_REPLY_FRAME(IOC, mfp)
0287 
0288 #define dmfprintk(IOC, CMD)         \
0289     MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_MSG_FRAME)
0290 
0291 #endif /* defined(MPT_DEBUG_VERBOSE) && defined(CONFIG_FUSION_LOGGING) */
0292 
0293 #endif /* ifndef MPTDEBUG_H_INCLUDED */