Loading...
1/*
2 * linux/drivers/message/fusion/mptdebug.h
3 * For use with LSI PCI chip/adapter(s)
4 * running LSI Fusion MPT (Message Passing Technology) firmware.
5 *
6 * Copyright (c) 1999-2008 LSI Corporation
7 * (mailto:DL-MPTFusionLinux@lsi.com)
8 *
9 */
10/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
11
12#ifndef MPTDEBUG_H_INCLUDED
13#define MPTDEBUG_H_INCLUDED
14
15/*
16 * debug level can be programmed on the fly via SysFS (hex values)
17 *
18 * Example: (programming for MPT_DEBUG_EVENTS on host 5)
19 *
20 * echo 8 > /sys/class/scsi_host/host5/debug_level
21 *
22 * --------------------------------------------------------
23 * mpt_debug_level - command line parameter
24 * this allow enabling debug at driver load time (for all iocs)
25 *
26 * Example (programming for MPT_DEBUG_EVENTS)
27 *
28 * insmod mptbase.ko mpt_debug_level=8
29 *
30 * --------------------------------------------------------
31 * CONFIG_FUSION_LOGGING - enables compiling debug into driver
32 * this can be enabled in the driver Makefile
33 *
34 *
35 * --------------------------------------------------------
36 * Please note most debug prints are set to logging priority = debug
37 * This is the lowest level, and most verbose. Please refer to manual
38 * pages for syslogd or syslogd-ng on how to configure this.
39 */
40
41#define MPT_DEBUG 0x00000001
42#define MPT_DEBUG_MSG_FRAME 0x00000002
43#define MPT_DEBUG_SG 0x00000004
44#define MPT_DEBUG_EVENTS 0x00000008
45#define MPT_DEBUG_VERBOSE_EVENTS 0x00000010
46#define MPT_DEBUG_INIT 0x00000020
47#define MPT_DEBUG_EXIT 0x00000040
48#define MPT_DEBUG_FAIL 0x00000080
49#define MPT_DEBUG_TM 0x00000100
50#define MPT_DEBUG_DV 0x00000200
51#define MPT_DEBUG_REPLY 0x00000400
52#define MPT_DEBUG_HANDSHAKE 0x00000800
53#define MPT_DEBUG_CONFIG 0x00001000
54#define MPT_DEBUG_DL 0x00002000
55#define MPT_DEBUG_RESET 0x00008000
56#define MPT_DEBUG_SCSI 0x00010000
57#define MPT_DEBUG_IOCTL 0x00020000
58#define MPT_DEBUG_FC 0x00080000
59#define MPT_DEBUG_SAS 0x00100000
60#define MPT_DEBUG_SAS_WIDE 0x00200000
61#define MPT_DEBUG_36GB_MEM 0x00400000
62
63/*
64 * CONFIG_FUSION_LOGGING - enabled in Kconfig
65 */
66
67#ifdef CONFIG_FUSION_LOGGING
68#define MPT_CHECK_LOGGING(IOC, CMD, BITS) \
69{ \
70 if (IOC->debug_level & BITS) \
71 CMD; \
72}
73#else
74#define MPT_CHECK_LOGGING(IOC, CMD, BITS)
75#endif
76
77
78/*
79 * debug macros
80 */
81
82#define dprintk(IOC, CMD) \
83 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG)
84
85#define dsgprintk(IOC, CMD) \
86 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_SG)
87
88#define devtprintk(IOC, CMD) \
89 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_EVENTS)
90
91#define devtverboseprintk(IOC, CMD) \
92 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_VERBOSE_EVENTS)
93
94#define dinitprintk(IOC, CMD) \
95 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_INIT)
96
97#define dexitprintk(IOC, CMD) \
98 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_EXIT)
99
100#define dfailprintk(IOC, CMD) \
101 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_FAIL)
102
103#define dtmprintk(IOC, CMD) \
104 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_TM)
105
106#define ddvprintk(IOC, CMD) \
107 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_DV)
108
109#define dreplyprintk(IOC, CMD) \
110 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_REPLY)
111
112#define dhsprintk(IOC, CMD) \
113 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_HANDSHAKE)
114
115#define dcprintk(IOC, CMD) \
116 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_CONFIG)
117
118#define ddlprintk(IOC, CMD) \
119 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_DL)
120
121#define drsprintk(IOC, CMD) \
122 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_RESET)
123
124#define dsprintk(IOC, CMD) \
125 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_SCSI)
126
127#define dctlprintk(IOC, CMD) \
128 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_IOCTL)
129
130#define dfcprintk(IOC, CMD) \
131 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_FC)
132
133#define dsasprintk(IOC, CMD) \
134 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_SAS)
135
136#define dsaswideprintk(IOC, CMD) \
137 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_SAS_WIDE)
138
139#define d36memprintk(IOC, CMD) \
140 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_36GB_MEM)
141
142
143/*
144 * Verbose logging
145 */
146#if defined(MPT_DEBUG_VERBOSE) && defined(CONFIG_FUSION_LOGGING)
147static inline void
148DBG_DUMP_FW_DOWNLOAD(MPT_ADAPTER *ioc, u32 *mfp, int numfrags)
149{
150 int i;
151
152 if (!(ioc->debug_level & MPT_DEBUG))
153 return;
154 printk(KERN_DEBUG "F/W download request:\n");
155 for (i=0; i < 7+numfrags*2; i++)
156 printk(" %08x", le32_to_cpu(mfp[i]));
157 printk("\n");
158}
159
160static inline void
161DBG_DUMP_PUT_MSG_FRAME(MPT_ADAPTER *ioc, u32 *mfp)
162{
163 int ii, n;
164
165 if (!(ioc->debug_level & MPT_DEBUG_MSG_FRAME))
166 return;
167 printk(KERN_DEBUG "%s: About to Put msg frame @ %p:\n",
168 ioc->name, mfp);
169 n = ioc->req_sz/4 - 1;
170 while (mfp[n] == 0)
171 n--;
172 for (ii=0; ii<=n; ii++) {
173 if (ii && ((ii%8)==0))
174 printk("\n");
175 printk(" %08x", le32_to_cpu(mfp[ii]));
176 }
177 printk("\n");
178}
179
180static inline void
181DBG_DUMP_FW_REQUEST_FRAME(MPT_ADAPTER *ioc, u32 *mfp)
182{
183 int i, n;
184
185 if (!(ioc->debug_level & MPT_DEBUG_MSG_FRAME))
186 return;
187 n = 10;
188 printk(KERN_INFO " ");
189 for (i = 0; i < n; i++)
190 printk(" %08x", le32_to_cpu(mfp[i]));
191 printk("\n");
192}
193
194static inline void
195DBG_DUMP_REQUEST_FRAME(MPT_ADAPTER *ioc, u32 *mfp)
196{
197 int i, n;
198
199 if (!(ioc->debug_level & MPT_DEBUG_MSG_FRAME))
200 return;
201 n = 24;
202 for (i=0; i<n; i++) {
203 if (i && ((i%8)==0))
204 printk("\n");
205 printk("%08x ", le32_to_cpu(mfp[i]));
206 }
207 printk("\n");
208}
209
210static inline void
211DBG_DUMP_REPLY_FRAME(MPT_ADAPTER *ioc, u32 *mfp)
212{
213 int i, n;
214
215 if (!(ioc->debug_level & MPT_DEBUG_MSG_FRAME))
216 return;
217 n = (le32_to_cpu(mfp[0]) & 0x00FF0000) >> 16;
218 printk(KERN_INFO " ");
219 for (i=0; i<n; i++)
220 printk(" %08x", le32_to_cpu(mfp[i]));
221 printk("\n");
222}
223
224static inline void
225DBG_DUMP_REQUEST_FRAME_HDR(MPT_ADAPTER *ioc, u32 *mfp)
226{
227 int i, n;
228
229 if (!(ioc->debug_level & MPT_DEBUG_MSG_FRAME))
230 return;
231 n = 3;
232 printk(KERN_INFO " ");
233 for (i=0; i<n; i++)
234 printk(" %08x", le32_to_cpu(mfp[i]));
235 printk("\n");
236}
237
238static inline void
239DBG_DUMP_TM_REQUEST_FRAME(MPT_ADAPTER *ioc, u32 *mfp)
240{
241 int i, n;
242
243 if (!(ioc->debug_level & MPT_DEBUG_TM))
244 return;
245 n = 13;
246 printk(KERN_DEBUG "TM_REQUEST:\n");
247 for (i=0; i<n; i++) {
248 if (i && ((i%8)==0))
249 printk("\n");
250 printk("%08x ", le32_to_cpu(mfp[i]));
251 }
252 printk("\n");
253}
254
255static inline void
256DBG_DUMP_TM_REPLY_FRAME(MPT_ADAPTER *ioc, u32 *mfp)
257{
258 int i, n;
259
260 if (!(ioc->debug_level & MPT_DEBUG_TM))
261 return;
262 n = (le32_to_cpu(mfp[0]) & 0x00FF0000) >> 16;
263 printk(KERN_DEBUG "TM_REPLY MessageLength=%d:\n", n);
264 for (i=0; i<n; i++) {
265 if (i && ((i%8)==0))
266 printk("\n");
267 printk(" %08x", le32_to_cpu(mfp[i]));
268 }
269 printk("\n");
270}
271
272#define dmfprintk(IOC, CMD) \
273 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_MSG_FRAME)
274
275# else /* ifdef MPT_DEBUG_MF */
276
277#define DBG_DUMP_FW_DOWNLOAD(IOC, mfp, numfrags)
278#define DBG_DUMP_PUT_MSG_FRAME(IOC, mfp)
279#define DBG_DUMP_FW_REQUEST_FRAME(IOC, mfp)
280#define DBG_DUMP_REQUEST_FRAME(IOC, mfp)
281#define DBG_DUMP_REPLY_FRAME(IOC, mfp)
282#define DBG_DUMP_REQUEST_FRAME_HDR(IOC, mfp)
283#define DBG_DUMP_TM_REQUEST_FRAME(IOC, mfp)
284#define DBG_DUMP_TM_REPLY_FRAME(IOC, mfp)
285
286#define dmfprintk(IOC, CMD) \
287 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_MSG_FRAME)
288
289#endif /* defined(MPT_DEBUG_VERBOSE) && defined(CONFIG_FUSION_LOGGING) */
290
291#endif /* ifndef MPTDEBUG_H_INCLUDED */
1/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * linux/drivers/message/fusion/mptdebug.h
4 * For use with LSI PCI chip/adapter(s)
5 * running LSI Fusion MPT (Message Passing Technology) firmware.
6 *
7 * Copyright (c) 1999-2008 LSI Corporation
8 * (mailto:DL-MPTFusionLinux@lsi.com)
9 *
10 */
11/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
12
13#ifndef MPTDEBUG_H_INCLUDED
14#define MPTDEBUG_H_INCLUDED
15
16/*
17 * debug level can be programmed on the fly via SysFS (hex values)
18 *
19 * Example: (programming for MPT_DEBUG_EVENTS on host 5)
20 *
21 * echo 8 > /sys/class/scsi_host/host5/debug_level
22 *
23 * --------------------------------------------------------
24 * mpt_debug_level - command line parameter
25 * this allow enabling debug at driver load time (for all iocs)
26 *
27 * Example (programming for MPT_DEBUG_EVENTS)
28 *
29 * insmod mptbase.ko mpt_debug_level=8
30 *
31 * --------------------------------------------------------
32 * CONFIG_FUSION_LOGGING - enables compiling debug into driver
33 * this can be enabled in the driver Makefile
34 *
35 *
36 * --------------------------------------------------------
37 * Please note most debug prints are set to logging priority = debug
38 * This is the lowest level, and most verbose. Please refer to manual
39 * pages for syslogd or syslogd-ng on how to configure this.
40 */
41
42#define MPT_DEBUG 0x00000001
43#define MPT_DEBUG_MSG_FRAME 0x00000002
44#define MPT_DEBUG_SG 0x00000004
45#define MPT_DEBUG_EVENTS 0x00000008
46#define MPT_DEBUG_VERBOSE_EVENTS 0x00000010
47#define MPT_DEBUG_INIT 0x00000020
48#define MPT_DEBUG_EXIT 0x00000040
49#define MPT_DEBUG_FAIL 0x00000080
50#define MPT_DEBUG_TM 0x00000100
51#define MPT_DEBUG_DV 0x00000200
52#define MPT_DEBUG_REPLY 0x00000400
53#define MPT_DEBUG_HANDSHAKE 0x00000800
54#define MPT_DEBUG_CONFIG 0x00001000
55#define MPT_DEBUG_DL 0x00002000
56#define MPT_DEBUG_RESET 0x00008000
57#define MPT_DEBUG_SCSI 0x00010000
58#define MPT_DEBUG_IOCTL 0x00020000
59#define MPT_DEBUG_FC 0x00080000
60#define MPT_DEBUG_SAS 0x00100000
61#define MPT_DEBUG_SAS_WIDE 0x00200000
62#define MPT_DEBUG_36GB_MEM 0x00400000
63
64/*
65 * CONFIG_FUSION_LOGGING - enabled in Kconfig
66 */
67
68#ifdef CONFIG_FUSION_LOGGING
69#define MPT_CHECK_LOGGING(IOC, CMD, BITS) \
70do { \
71 if (IOC->debug_level & BITS) \
72 CMD; \
73} while (0)
74#else
75#define MPT_CHECK_LOGGING(IOC, CMD, BITS) \
76do { } while (0)
77#endif
78
79
80/*
81 * debug macros
82 */
83
84#define dprintk(IOC, CMD) \
85 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG)
86
87#define dsgprintk(IOC, CMD) \
88 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_SG)
89
90#define devtprintk(IOC, CMD) \
91 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_EVENTS)
92
93#define devtverboseprintk(IOC, CMD) \
94 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_VERBOSE_EVENTS)
95
96#define dinitprintk(IOC, CMD) \
97 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_INIT)
98
99#define dexitprintk(IOC, CMD) \
100 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_EXIT)
101
102#define dfailprintk(IOC, CMD) \
103 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_FAIL)
104
105#define dtmprintk(IOC, CMD) \
106 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_TM)
107
108#define ddvprintk(IOC, CMD) \
109 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_DV)
110
111#define dreplyprintk(IOC, CMD) \
112 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_REPLY)
113
114#define dhsprintk(IOC, CMD) \
115 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_HANDSHAKE)
116
117#define dcprintk(IOC, CMD) \
118 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_CONFIG)
119
120#define ddlprintk(IOC, CMD) \
121 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_DL)
122
123#define drsprintk(IOC, CMD) \
124 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_RESET)
125
126#define dsprintk(IOC, CMD) \
127 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_SCSI)
128
129#define dctlprintk(IOC, CMD) \
130 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_IOCTL)
131
132#define dfcprintk(IOC, CMD) \
133 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_FC)
134
135#define dsasprintk(IOC, CMD) \
136 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_SAS)
137
138#define dsaswideprintk(IOC, CMD) \
139 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_SAS_WIDE)
140
141#define d36memprintk(IOC, CMD) \
142 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_36GB_MEM)
143
144
145/*
146 * Verbose logging
147 */
148#if defined(MPT_DEBUG_VERBOSE) && defined(CONFIG_FUSION_LOGGING)
149static inline void
150DBG_DUMP_FW_DOWNLOAD(MPT_ADAPTER *ioc, u32 *mfp, int numfrags)
151{
152 int i;
153
154 if (!(ioc->debug_level & MPT_DEBUG))
155 return;
156 printk(KERN_DEBUG "F/W download request:\n");
157 for (i=0; i < 7+numfrags*2; i++)
158 printk(" %08x", le32_to_cpu(mfp[i]));
159 printk("\n");
160}
161
162static inline void
163DBG_DUMP_PUT_MSG_FRAME(MPT_ADAPTER *ioc, u32 *mfp)
164{
165 int ii, n;
166
167 if (!(ioc->debug_level & MPT_DEBUG_MSG_FRAME))
168 return;
169 printk(KERN_DEBUG "%s: About to Put msg frame @ %p:\n",
170 ioc->name, mfp);
171 n = ioc->req_sz/4 - 1;
172 while (mfp[n] == 0)
173 n--;
174 for (ii=0; ii<=n; ii++) {
175 if (ii && ((ii%8)==0))
176 printk("\n");
177 printk(" %08x", le32_to_cpu(mfp[ii]));
178 }
179 printk("\n");
180}
181
182static inline void
183DBG_DUMP_FW_REQUEST_FRAME(MPT_ADAPTER *ioc, u32 *mfp)
184{
185 int i, n;
186
187 if (!(ioc->debug_level & MPT_DEBUG_MSG_FRAME))
188 return;
189 n = 10;
190 printk(KERN_INFO " ");
191 for (i = 0; i < n; i++)
192 printk(" %08x", le32_to_cpu(mfp[i]));
193 printk("\n");
194}
195
196static inline void
197DBG_DUMP_REQUEST_FRAME(MPT_ADAPTER *ioc, u32 *mfp)
198{
199 int i, n;
200
201 if (!(ioc->debug_level & MPT_DEBUG_MSG_FRAME))
202 return;
203 n = 24;
204 for (i=0; i<n; i++) {
205 if (i && ((i%8)==0))
206 printk("\n");
207 printk("%08x ", le32_to_cpu(mfp[i]));
208 }
209 printk("\n");
210}
211
212static inline void
213DBG_DUMP_REPLY_FRAME(MPT_ADAPTER *ioc, u32 *mfp)
214{
215 int i, n;
216
217 if (!(ioc->debug_level & MPT_DEBUG_MSG_FRAME))
218 return;
219 n = (le32_to_cpu(mfp[0]) & 0x00FF0000) >> 16;
220 printk(KERN_INFO " ");
221 for (i=0; i<n; i++)
222 printk(" %08x", le32_to_cpu(mfp[i]));
223 printk("\n");
224}
225
226static inline void
227DBG_DUMP_REQUEST_FRAME_HDR(MPT_ADAPTER *ioc, u32 *mfp)
228{
229 int i, n;
230
231 if (!(ioc->debug_level & MPT_DEBUG_MSG_FRAME))
232 return;
233 n = 3;
234 printk(KERN_INFO " ");
235 for (i=0; i<n; i++)
236 printk(" %08x", le32_to_cpu(mfp[i]));
237 printk("\n");
238}
239
240static inline void
241DBG_DUMP_TM_REQUEST_FRAME(MPT_ADAPTER *ioc, u32 *mfp)
242{
243 int i, n;
244
245 if (!(ioc->debug_level & MPT_DEBUG_TM))
246 return;
247 n = 13;
248 printk(KERN_DEBUG "TM_REQUEST:\n");
249 for (i=0; i<n; i++) {
250 if (i && ((i%8)==0))
251 printk("\n");
252 printk("%08x ", le32_to_cpu(mfp[i]));
253 }
254 printk("\n");
255}
256
257static inline void
258DBG_DUMP_TM_REPLY_FRAME(MPT_ADAPTER *ioc, u32 *mfp)
259{
260 int i, n;
261
262 if (!(ioc->debug_level & MPT_DEBUG_TM))
263 return;
264 n = (le32_to_cpu(mfp[0]) & 0x00FF0000) >> 16;
265 printk(KERN_DEBUG "TM_REPLY MessageLength=%d:\n", n);
266 for (i=0; i<n; i++) {
267 if (i && ((i%8)==0))
268 printk("\n");
269 printk(" %08x", le32_to_cpu(mfp[i]));
270 }
271 printk("\n");
272}
273
274#define dmfprintk(IOC, CMD) \
275 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_MSG_FRAME)
276
277# else /* ifdef MPT_DEBUG_MF */
278
279#define DBG_DUMP_FW_DOWNLOAD(IOC, mfp, numfrags)
280#define DBG_DUMP_PUT_MSG_FRAME(IOC, mfp)
281#define DBG_DUMP_FW_REQUEST_FRAME(IOC, mfp)
282#define DBG_DUMP_REQUEST_FRAME(IOC, mfp)
283#define DBG_DUMP_REPLY_FRAME(IOC, mfp)
284#define DBG_DUMP_REQUEST_FRAME_HDR(IOC, mfp)
285#define DBG_DUMP_TM_REQUEST_FRAME(IOC, mfp)
286#define DBG_DUMP_TM_REPLY_FRAME(IOC, mfp)
287
288#define dmfprintk(IOC, CMD) \
289 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_MSG_FRAME)
290
291#endif /* defined(MPT_DEBUG_VERBOSE) && defined(CONFIG_FUSION_LOGGING) */
292
293#endif /* ifndef MPTDEBUG_H_INCLUDED */