Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Logging Support for MPT (Message Passing Technology) based controllers
0003  *
0004  * This code is based on drivers/scsi/mpt3sas/mpt3sas_debug.c
0005  * Copyright (C) 2012-2014  LSI Corporation
0006  * Copyright (C) 2013-2014 Avago Technologies
0007  *  (mailto: MPT-FusionLinux.pdl@avagotech.com)
0008  *
0009  * This program is free software; you can redistribute it and/or
0010  * modify it under the terms of the GNU General Public License
0011  * as published by the Free Software Foundation; either version 2
0012  * of the License, or (at your option) any later version.
0013  *
0014  * This program is distributed in the hope that it will be useful,
0015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0017  * GNU General Public License for more details.
0018  *
0019  * NO WARRANTY
0020  * THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
0021  * CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
0022  * LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
0023  * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
0024  * solely responsible for determining the appropriateness of using and
0025  * distributing the Program and assumes all risks associated with its
0026  * exercise of rights under this Agreement, including but not limited to
0027  * the risks and costs of program errors, damage to or loss of data,
0028  * programs or equipment, and unavailability or interruption of operations.
0029 
0030  * DISCLAIMER OF LIABILITY
0031  * NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
0032  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
0033  * DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
0034  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
0035  * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
0036  * USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
0037  * HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES
0038 
0039  * You should have received a copy of the GNU General Public License
0040  * along with this program; if not, write to the Free Software
0041  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
0042  * USA.
0043  */
0044 
0045 #ifndef MPT3SAS_DEBUG_H_INCLUDED
0046 #define MPT3SAS_DEBUG_H_INCLUDED
0047 
0048 #define MPT_DEBUG           0x00000001
0049 #define MPT_DEBUG_MSG_FRAME     0x00000002
0050 #define MPT_DEBUG_SG            0x00000004
0051 #define MPT_DEBUG_EVENTS        0x00000008
0052 #define MPT_DEBUG_EVENT_WORK_TASK   0x00000010
0053 #define MPT_DEBUG_INIT          0x00000020
0054 #define MPT_DEBUG_EXIT          0x00000040
0055 #define MPT_DEBUG_FAIL          0x00000080
0056 #define MPT_DEBUG_TM            0x00000100
0057 #define MPT_DEBUG_REPLY     0x00000200
0058 #define MPT_DEBUG_HANDSHAKE     0x00000400
0059 #define MPT_DEBUG_CONFIG        0x00000800
0060 #define MPT_DEBUG_DL            0x00001000
0061 #define MPT_DEBUG_RESET     0x00002000
0062 #define MPT_DEBUG_SCSI          0x00004000
0063 #define MPT_DEBUG_IOCTL     0x00008000
0064 #define MPT_DEBUG_SAS           0x00020000
0065 #define MPT_DEBUG_TRANSPORT     0x00040000
0066 #define MPT_DEBUG_TASK_SET_FULL 0x00080000
0067 
0068 #define MPT_DEBUG_TRIGGER_DIAG      0x00200000
0069 
0070 
0071 #define MPT_CHECK_LOGGING(IOC, CMD, BITS)           \
0072 {                               \
0073     if (IOC->logging_level & BITS)              \
0074         CMD;                        \
0075 }
0076 
0077 /*
0078  * debug macros
0079  */
0080 
0081 #define dprintk(IOC, CMD)           \
0082     MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG)
0083 
0084 #define dsgprintk(IOC, CMD)         \
0085     MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_SG)
0086 
0087 #define devtprintk(IOC, CMD)            \
0088     MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_EVENTS)
0089 
0090 #define dewtprintk(IOC, CMD)        \
0091     MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_EVENT_WORK_TASK)
0092 
0093 #define dinitprintk(IOC, CMD)           \
0094     MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_INIT)
0095 
0096 #define dexitprintk(IOC, CMD)           \
0097     MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_EXIT)
0098 
0099 #define dfailprintk(IOC, CMD)           \
0100     MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_FAIL)
0101 
0102 #define dtmprintk(IOC, CMD)         \
0103     MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_TM)
0104 
0105 #define dreplyprintk(IOC, CMD)          \
0106     MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_REPLY)
0107 
0108 #define dhsprintk(IOC, CMD)         \
0109     MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_HANDSHAKE)
0110 
0111 #define dcprintk(IOC, CMD)          \
0112     MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_CONFIG)
0113 
0114 #define ddlprintk(IOC, CMD)         \
0115     MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_DL)
0116 
0117 #define drsprintk(IOC, CMD)         \
0118     MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_RESET)
0119 
0120 #define dsprintk(IOC, CMD)          \
0121     MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_SCSI)
0122 
0123 #define dctlprintk(IOC, CMD)            \
0124     MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_IOCTL)
0125 
0126 #define dsasprintk(IOC, CMD)            \
0127     MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_SAS)
0128 
0129 #define dsastransport(IOC, CMD)     \
0130     MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_SAS_WIDE)
0131 
0132 #define dmfprintk(IOC, CMD)         \
0133     MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_MSG_FRAME)
0134 
0135 #define dtsfprintk(IOC, CMD)            \
0136     MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_TASK_SET_FULL)
0137 
0138 #define dtransportprintk(IOC, CMD)          \
0139     MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_TRANSPORT)
0140 
0141 #define dTriggerDiagPrintk(IOC, CMD)            \
0142     MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_TRIGGER_DIAG)
0143 
0144 
0145 
0146 /* inline functions for dumping debug data*/
0147 
0148 /**
0149  * _debug_dump_mf - print message frame contents
0150  * @mpi_request: pointer to message frame
0151  * @sz: number of dwords
0152  */
0153 static inline void
0154 _debug_dump_mf(void *mpi_request, int sz)
0155 {
0156     int i;
0157     __le32 *mfp = (__le32 *)mpi_request;
0158 
0159     pr_info("mf:\n\t");
0160     for (i = 0; i < sz; i++) {
0161         if (i && ((i % 8) == 0))
0162             pr_info("\n\t");
0163         pr_info("%08x ", le32_to_cpu(mfp[i]));
0164     }
0165     pr_info("\n");
0166 }
0167 /**
0168  * _debug_dump_reply - print message frame contents
0169  * @mpi_request: pointer to message frame
0170  * @sz: number of dwords
0171  */
0172 static inline void
0173 _debug_dump_reply(void *mpi_request, int sz)
0174 {
0175     int i;
0176     __le32 *mfp = (__le32 *)mpi_request;
0177 
0178     pr_info("reply:\n\t");
0179     for (i = 0; i < sz; i++) {
0180         if (i && ((i % 8) == 0))
0181             pr_info("\n\t");
0182         pr_info("%08x ", le32_to_cpu(mfp[i]));
0183     }
0184     pr_info("\n");
0185 }
0186 /**
0187  * _debug_dump_config - print config page contents
0188  * @mpi_request: pointer to message frame
0189  * @sz: number of dwords
0190  */
0191 static inline void
0192 _debug_dump_config(void *mpi_request, int sz)
0193 {
0194     int i;
0195     __le32 *mfp = (__le32 *)mpi_request;
0196 
0197     pr_info("config:\n\t");
0198     for (i = 0; i < sz; i++) {
0199         if (i && ((i % 8) == 0))
0200             pr_info("\n\t");
0201         pr_info("%08x ", le32_to_cpu(mfp[i]));
0202     }
0203     pr_info("\n");
0204 }
0205 
0206 #endif /* MPT3SAS_DEBUG_H_INCLUDED */