Linux 4.18.10
[linux/fpc-iii.git] / drivers / scsi / mpt3sas / mpt3sas_debug.h
blobcceeb2c16e64c6e13d1cd8ae5c163b51af972086
1 /*
2 * Logging Support for MPT (Message Passing Technology) based controllers
4 * This code is based on drivers/scsi/mpt3sas/mpt3sas_debug.c
5 * Copyright (C) 2012-2014 LSI Corporation
6 * Copyright (C) 2013-2014 Avago Technologies
7 * (mailto: MPT-FusionLinux.pdl@avagotech.com)
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.
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.
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.
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
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.
45 #ifndef MPT3SAS_DEBUG_H_INCLUDED
46 #define MPT3SAS_DEBUG_H_INCLUDED
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_SAS 0x00020000
65 #define MPT_DEBUG_TRANSPORT 0x00040000
66 #define MPT_DEBUG_TASK_SET_FULL 0x00080000
68 #define MPT_DEBUG_TRIGGER_DIAG 0x00200000
71 #define MPT_CHECK_LOGGING(IOC, CMD, BITS) \
72 { \
73 if (IOC->logging_level & BITS) \
74 CMD; \
78 * debug macros
81 #define dprintk(IOC, CMD) \
82 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG)
84 #define dsgprintk(IOC, CMD) \
85 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_SG)
87 #define devtprintk(IOC, CMD) \
88 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_EVENTS)
90 #define dewtprintk(IOC, CMD) \
91 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_EVENT_WORK_TASK)
93 #define dinitprintk(IOC, CMD) \
94 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_INIT)
96 #define dexitprintk(IOC, CMD) \
97 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_EXIT)
99 #define dfailprintk(IOC, CMD) \
100 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_FAIL)
102 #define dtmprintk(IOC, CMD) \
103 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_TM)
105 #define dreplyprintk(IOC, CMD) \
106 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_REPLY)
108 #define dhsprintk(IOC, CMD) \
109 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_HANDSHAKE)
111 #define dcprintk(IOC, CMD) \
112 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_CONFIG)
114 #define ddlprintk(IOC, CMD) \
115 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_DL)
117 #define drsprintk(IOC, CMD) \
118 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_RESET)
120 #define dsprintk(IOC, CMD) \
121 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_SCSI)
123 #define dctlprintk(IOC, CMD) \
124 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_IOCTL)
126 #define dsasprintk(IOC, CMD) \
127 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_SAS)
129 #define dsastransport(IOC, CMD) \
130 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_SAS_WIDE)
132 #define dmfprintk(IOC, CMD) \
133 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_MSG_FRAME)
135 #define dtsfprintk(IOC, CMD) \
136 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_TASK_SET_FULL)
138 #define dtransportprintk(IOC, CMD) \
139 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_TRANSPORT)
141 #define dTriggerDiagPrintk(IOC, CMD) \
142 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_TRIGGER_DIAG)
146 /* inline functions for dumping debug data*/
149 * _debug_dump_mf - print message frame contents
150 * @mpi_request: pointer to message frame
151 * @sz: number of dwords
153 static inline void
154 _debug_dump_mf(void *mpi_request, int sz)
156 int i;
157 __le32 *mfp = (__le32 *)mpi_request;
159 pr_info("mf:\n\t");
160 for (i = 0; i < sz; i++) {
161 if (i && ((i % 8) == 0))
162 pr_info("\n\t");
163 pr_info("%08x ", le32_to_cpu(mfp[i]));
165 pr_info("\n");
168 * _debug_dump_reply - print message frame contents
169 * @mpi_request: pointer to message frame
170 * @sz: number of dwords
172 static inline void
173 _debug_dump_reply(void *mpi_request, int sz)
175 int i;
176 __le32 *mfp = (__le32 *)mpi_request;
178 pr_info("reply:\n\t");
179 for (i = 0; i < sz; i++) {
180 if (i && ((i % 8) == 0))
181 pr_info("\n\t");
182 pr_info("%08x ", le32_to_cpu(mfp[i]));
184 pr_info("\n");
187 * _debug_dump_config - print config page contents
188 * @mpi_request: pointer to message frame
189 * @sz: number of dwords
191 static inline void
192 _debug_dump_config(void *mpi_request, int sz)
194 int i;
195 __le32 *mfp = (__le32 *)mpi_request;
197 pr_info("config:\n\t");
198 for (i = 0; i < sz; i++) {
199 if (i && ((i % 8) == 0))
200 pr_info("\n\t");
201 pr_info("%08x ", le32_to_cpu(mfp[i]));
203 pr_info("\n");
206 #endif /* MPT3SAS_DEBUG_H_INCLUDED */