| Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 1 | /* | 
 | 2 |  * Logging Support for MPT (Message Passing Technology) based controllers | 
 | 3 |  * | 
 | 4 |  * This code is based on drivers/scsi/mpt2sas/mpt2_debug.c | 
| Kashyap, Desai | 31b7f2e | 2010-03-17 16:28:04 +0530 | [diff] [blame] | 5 |  * Copyright (C) 2007-2010  LSI Corporation | 
| Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 6 |  *  (mailto:DL-MPTFusionLinux@lsi.com) | 
 | 7 |  * | 
 | 8 |  * This program is free software; you can redistribute it and/or | 
 | 9 |  * modify it under the terms of the GNU General Public License | 
 | 10 |  * as published by the Free Software Foundation; either version 2 | 
 | 11 |  * of the License, or (at your option) any later version. | 
 | 12 |  * | 
 | 13 |  * This program is distributed in the hope that it will be useful, | 
 | 14 |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
 | 15 |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
 | 16 |  * GNU General Public License for more details. | 
 | 17 |  * | 
 | 18 |  * NO WARRANTY | 
 | 19 |  * THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR | 
 | 20 |  * CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT | 
 | 21 |  * LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, | 
 | 22 |  * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is | 
 | 23 |  * solely responsible for determining the appropriateness of using and | 
 | 24 |  * distributing the Program and assumes all risks associated with its | 
 | 25 |  * exercise of rights under this Agreement, including but not limited to | 
 | 26 |  * the risks and costs of program errors, damage to or loss of data, | 
 | 27 |  * programs or equipment, and unavailability or interruption of operations. | 
 | 28 |  | 
 | 29 |  * DISCLAIMER OF LIABILITY | 
 | 30 |  * NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY | 
 | 31 |  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 
 | 32 |  * DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND | 
 | 33 |  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR | 
 | 34 |  * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE | 
 | 35 |  * USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED | 
 | 36 |  * HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES | 
 | 37 |  | 
 | 38 |  * You should have received a copy of the GNU General Public License | 
 | 39 |  * along with this program; if not, write to the Free Software | 
 | 40 |  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, | 
 | 41 |  * USA. | 
 | 42 |  */ | 
 | 43 |  | 
 | 44 | #ifndef MPT2SAS_DEBUG_H_INCLUDED | 
 | 45 | #define MPT2SAS_DEBUG_H_INCLUDED | 
 | 46 |  | 
 | 47 | #define MPT_DEBUG			0x00000001 | 
 | 48 | #define MPT_DEBUG_MSG_FRAME		0x00000002 | 
 | 49 | #define MPT_DEBUG_SG			0x00000004 | 
 | 50 | #define MPT_DEBUG_EVENTS		0x00000008 | 
 | 51 | #define MPT_DEBUG_EVENT_WORK_TASK	0x00000010 | 
 | 52 | #define MPT_DEBUG_INIT			0x00000020 | 
 | 53 | #define MPT_DEBUG_EXIT			0x00000040 | 
 | 54 | #define MPT_DEBUG_FAIL			0x00000080 | 
 | 55 | #define MPT_DEBUG_TM			0x00000100 | 
 | 56 | #define MPT_DEBUG_REPLY			0x00000200 | 
 | 57 | #define MPT_DEBUG_HANDSHAKE		0x00000400 | 
 | 58 | #define MPT_DEBUG_CONFIG		0x00000800 | 
 | 59 | #define MPT_DEBUG_DL			0x00001000 | 
 | 60 | #define MPT_DEBUG_RESET			0x00002000 | 
 | 61 | #define MPT_DEBUG_SCSI			0x00004000 | 
 | 62 | #define MPT_DEBUG_IOCTL			0x00008000 | 
 | 63 | #define MPT_DEBUG_CSMISAS		0x00010000 | 
 | 64 | #define MPT_DEBUG_SAS			0x00020000 | 
 | 65 | #define MPT_DEBUG_TRANSPORT		0x00040000 | 
 | 66 | #define MPT_DEBUG_TASK_SET_FULL		0x00080000 | 
 | 67 |  | 
 | 68 | #define MPT_DEBUG_TARGET_MODE		0x00100000 | 
 | 69 |  | 
 | 70 |  | 
 | 71 | /* | 
 | 72 |  * CONFIG_SCSI_MPT2SAS_LOGGING - enabled in Kconfig | 
 | 73 |  */ | 
 | 74 |  | 
 | 75 | #ifdef CONFIG_SCSI_MPT2SAS_LOGGING | 
 | 76 | #define MPT_CHECK_LOGGING(IOC, CMD, BITS)			\ | 
 | 77 | {								\ | 
 | 78 | 	if (IOC->logging_level & BITS)				\ | 
 | 79 | 		CMD;						\ | 
 | 80 | } | 
 | 81 | #else | 
 | 82 | #define MPT_CHECK_LOGGING(IOC, CMD, BITS) | 
 | 83 | #endif /* CONFIG_SCSI_MPT2SAS_LOGGING */ | 
 | 84 |  | 
 | 85 |  | 
 | 86 | /* | 
 | 87 |  * debug macros | 
 | 88 |  */ | 
 | 89 |  | 
 | 90 | #define dprintk(IOC, CMD)			\ | 
 | 91 | 	MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG) | 
 | 92 |  | 
 | 93 | #define dsgprintk(IOC, CMD)			\ | 
 | 94 | 	MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_SG) | 
 | 95 |  | 
 | 96 | #define devtprintk(IOC, CMD)			\ | 
 | 97 | 	MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_EVENTS) | 
 | 98 |  | 
 | 99 | #define dewtprintk(IOC, CMD)		\ | 
 | 100 | 	MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_EVENT_WORK_TASK) | 
 | 101 |  | 
 | 102 | #define dinitprintk(IOC, CMD)			\ | 
 | 103 | 	MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_INIT) | 
 | 104 |  | 
 | 105 | #define dexitprintk(IOC, CMD)			\ | 
 | 106 | 	MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_EXIT) | 
 | 107 |  | 
 | 108 | #define dfailprintk(IOC, CMD)			\ | 
 | 109 | 	MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_FAIL) | 
 | 110 |  | 
 | 111 | #define dtmprintk(IOC, CMD)			\ | 
 | 112 | 	MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_TM) | 
 | 113 |  | 
 | 114 | #define dreplyprintk(IOC, CMD)			\ | 
 | 115 | 	MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_REPLY) | 
 | 116 |  | 
 | 117 | #define dhsprintk(IOC, CMD)			\ | 
 | 118 | 	MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_HANDSHAKE) | 
 | 119 |  | 
 | 120 | #define dcprintk(IOC, CMD)			\ | 
 | 121 | 	MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_CONFIG) | 
 | 122 |  | 
 | 123 | #define ddlprintk(IOC, CMD)			\ | 
 | 124 | 	MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_DL) | 
 | 125 |  | 
 | 126 | #define drsprintk(IOC, CMD)			\ | 
 | 127 | 	MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_RESET) | 
 | 128 |  | 
 | 129 | #define dsprintk(IOC, CMD)			\ | 
 | 130 | 	MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_SCSI) | 
 | 131 |  | 
 | 132 | #define dctlprintk(IOC, CMD)			\ | 
 | 133 | 	MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_IOCTL) | 
 | 134 |  | 
 | 135 | #define dcsmisasprintk(IOC, CMD)		\ | 
 | 136 | 	MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_CSMISAS) | 
 | 137 |  | 
 | 138 | #define dsasprintk(IOC, CMD)			\ | 
 | 139 | 	MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_SAS) | 
 | 140 |  | 
 | 141 | #define dsastransport(IOC, CMD)		\ | 
 | 142 | 	MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_SAS_WIDE) | 
 | 143 |  | 
 | 144 | #define dmfprintk(IOC, CMD)			\ | 
 | 145 | 	MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_MSG_FRAME) | 
 | 146 |  | 
 | 147 | #define dtsfprintk(IOC, CMD)			\ | 
 | 148 | 	MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_TASK_SET_FULL) | 
 | 149 |  | 
 | 150 | #define dtransportprintk(IOC, CMD)			\ | 
 | 151 | 	MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_TRANSPORT) | 
 | 152 |  | 
 | 153 | #define dTMprintk(IOC, CMD)			\ | 
 | 154 | 	MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_TARGET_MODE) | 
 | 155 |  | 
 | 156 | /* inline functions for dumping debug data*/ | 
 | 157 | #ifdef CONFIG_SCSI_MPT2SAS_LOGGING | 
 | 158 | /** | 
 | 159 |  * _debug_dump_mf - print message frame contents | 
 | 160 |  * @mpi_request: pointer to message frame | 
 | 161 |  * @sz: number of dwords | 
 | 162 |  */ | 
 | 163 | static inline void | 
 | 164 | _debug_dump_mf(void *mpi_request, int sz) | 
 | 165 | { | 
 | 166 | 	int i; | 
| Kashyap, Desai | c97951e | 2011-06-14 10:54:56 +0530 | [diff] [blame] | 167 | 	__le32 *mfp = (__le32 *)mpi_request; | 
| Eric Moore | 635374e | 2009-03-09 01:21:12 -0600 | [diff] [blame] | 168 |  | 
 | 169 | 	printk(KERN_INFO "mf:\n\t"); | 
 | 170 | 	for (i = 0; i < sz; i++) { | 
 | 171 | 		if (i && ((i % 8) == 0)) | 
 | 172 | 			printk("\n\t"); | 
 | 173 | 		printk("%08x ", le32_to_cpu(mfp[i])); | 
 | 174 | 	} | 
 | 175 | 	printk("\n"); | 
 | 176 | } | 
 | 177 | #else | 
 | 178 | #define _debug_dump_mf(mpi_request, sz) | 
 | 179 | #endif /* CONFIG_SCSI_MPT2SAS_LOGGING */ | 
 | 180 |  | 
 | 181 | #endif /* MPT2SAS_DEBUG_H_INCLUDED */ |