]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - drivers/scsi/mpt3sas/mpt3sas_debug.h
Merge remote-tracking branch 'asoc/topic/core' into for-tiwai
[mirror_ubuntu-bionic-kernel.git] / drivers / scsi / mpt3sas / mpt3sas_debug.h
CommitLineData
f92363d1
SR
1/*
2 * Logging Support for MPT (Message Passing Technology) based controllers
3 *
4 * This code is based on drivers/scsi/mpt3sas/mpt3sas_debug.c
48e3b985 5 * Copyright (C) 2012-2013 LSI Corporation
f92363d1
SR
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 MPT3SAS_DEBUG_H_INCLUDED
45#define MPT3SAS_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_SAS 0x00020000
64#define MPT_DEBUG_TRANSPORT 0x00040000
65#define MPT_DEBUG_TASK_SET_FULL 0x00080000
66
67#define MPT_DEBUG_TRIGGER_DIAG 0x00200000
68
69
70/*
71 * CONFIG_SCSI_MPT3SAS_LOGGING - enabled in Kconfig
72 */
73
74#ifdef CONFIG_SCSI_MPT3SAS_LOGGING
75#define MPT_CHECK_LOGGING(IOC, CMD, BITS) \
76{ \
77 if (IOC->logging_level & BITS) \
78 CMD; \
79}
80#else
81#define MPT_CHECK_LOGGING(IOC, CMD, BITS)
82#endif /* CONFIG_SCSI_MPT3SAS_LOGGING */
83
84
85/*
86 * debug macros
87 */
88
89#define dprintk(IOC, CMD) \
90 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG)
91
92#define dsgprintk(IOC, CMD) \
93 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_SG)
94
95#define devtprintk(IOC, CMD) \
96 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_EVENTS)
97
98#define dewtprintk(IOC, CMD) \
99 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_EVENT_WORK_TASK)
100
101#define dinitprintk(IOC, CMD) \
102 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_INIT)
103
104#define dexitprintk(IOC, CMD) \
105 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_EXIT)
106
107#define dfailprintk(IOC, CMD) \
108 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_FAIL)
109
110#define dtmprintk(IOC, CMD) \
111 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_TM)
112
113#define dreplyprintk(IOC, CMD) \
114 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_REPLY)
115
116#define dhsprintk(IOC, CMD) \
117 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_HANDSHAKE)
118
119#define dcprintk(IOC, CMD) \
120 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_CONFIG)
121
122#define ddlprintk(IOC, CMD) \
123 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_DL)
124
125#define drsprintk(IOC, CMD) \
126 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_RESET)
127
128#define dsprintk(IOC, CMD) \
129 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_SCSI)
130
131#define dctlprintk(IOC, CMD) \
132 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_IOCTL)
133
134#define dsasprintk(IOC, CMD) \
135 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_SAS)
136
137#define dsastransport(IOC, CMD) \
138 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_SAS_WIDE)
139
140#define dmfprintk(IOC, CMD) \
141 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_MSG_FRAME)
142
143#define dtsfprintk(IOC, CMD) \
144 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_TASK_SET_FULL)
145
146#define dtransportprintk(IOC, CMD) \
147 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_TRANSPORT)
148
149#define dTriggerDiagPrintk(IOC, CMD) \
150 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_TRIGGER_DIAG)
151
152
153
154/* inline functions for dumping debug data*/
155#ifdef CONFIG_SCSI_MPT3SAS_LOGGING
156/**
157 * _debug_dump_mf - print message frame contents
158 * @mpi_request: pointer to message frame
159 * @sz: number of dwords
160 */
161static inline void
162_debug_dump_mf(void *mpi_request, int sz)
163{
164 int i;
165 __le32 *mfp = (__le32 *)mpi_request;
166
167 pr_info("mf:\n\t");
168 for (i = 0; i < sz; i++) {
169 if (i && ((i % 8) == 0))
170 pr_info("\n\t");
171 pr_info("%08x ", le32_to_cpu(mfp[i]));
172 }
173 pr_info("\n");
174}
175/**
176 * _debug_dump_reply - print message frame contents
177 * @mpi_request: pointer to message frame
178 * @sz: number of dwords
179 */
180static inline void
181_debug_dump_reply(void *mpi_request, int sz)
182{
183 int i;
184 __le32 *mfp = (__le32 *)mpi_request;
185
186 pr_info("reply:\n\t");
187 for (i = 0; i < sz; i++) {
188 if (i && ((i % 8) == 0))
189 pr_info("\n\t");
190 pr_info("%08x ", le32_to_cpu(mfp[i]));
191 }
192 pr_info("\n");
193}
194/**
195 * _debug_dump_config - print config page contents
196 * @mpi_request: pointer to message frame
197 * @sz: number of dwords
198 */
199static inline void
200_debug_dump_config(void *mpi_request, int sz)
201{
202 int i;
203 __le32 *mfp = (__le32 *)mpi_request;
204
205 pr_info("config:\n\t");
206 for (i = 0; i < sz; i++) {
207 if (i && ((i % 8) == 0))
208 pr_info("\n\t");
209 pr_info("%08x ", le32_to_cpu(mfp[i]));
210 }
211 pr_info("\n");
212}
213#else
214#define _debug_dump_mf(mpi_request, sz)
215#define _debug_dump_reply(mpi_request, sz)
216#define _debug_dump_config(mpi_request, sz)
217#endif /* CONFIG_SCSI_MPT3SAS_LOGGING */
218
219#endif /* MPT3SAS_DEBUG_H_INCLUDED */