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