aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/message/i2o/debug.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/message/i2o/debug.c')
-rw-r--r--drivers/message/i2o/debug.c481
1 files changed, 481 insertions, 0 deletions
diff --git a/drivers/message/i2o/debug.c b/drivers/message/i2o/debug.c
new file mode 100644
index 000000000000..2a5d478fc60e
--- /dev/null
+++ b/drivers/message/i2o/debug.c
@@ -0,0 +1,481 @@
1#include <linux/config.h>
2#include <linux/module.h>
3#include <linux/kernel.h>
4#include <linux/pci.h>
5#include <linux/i2o.h>
6
7extern struct i2o_driver **i2o_drivers;
8extern unsigned int i2o_max_drivers;
9static void i2o_report_util_cmd(u8 cmd);
10static void i2o_report_exec_cmd(u8 cmd);
11static void i2o_report_fail_status(u8 req_status, u32 * msg);
12static void i2o_report_common_status(u8 req_status);
13static void i2o_report_common_dsc(u16 detailed_status);
14
15/*
16 * Used for error reporting/debugging purposes.
17 * Report Cmd name, Request status, Detailed Status.
18 */
19void i2o_report_status(const char *severity, const char *str,
20 struct i2o_message *m)
21{
22 u32 *msg = (u32 *) m;
23 u8 cmd = (msg[1] >> 24) & 0xFF;
24 u8 req_status = (msg[4] >> 24) & 0xFF;
25 u16 detailed_status = msg[4] & 0xFFFF;
26 //struct i2o_driver *h = i2o_drivers[msg[2] & (i2o_max_drivers-1)];
27
28 if (cmd == I2O_CMD_UTIL_EVT_REGISTER)
29 return; // No status in this reply
30
31 printk(KERN_DEBUG "%s%s: ", severity, str);
32
33 if (cmd < 0x1F) // Utility cmd
34 i2o_report_util_cmd(cmd);
35
36 else if (cmd >= 0xA0 && cmd <= 0xEF) // Executive cmd
37 i2o_report_exec_cmd(cmd);
38 else
39 printk(KERN_DEBUG "Cmd = %0#2x, ", cmd); // Other cmds
40
41 if (msg[0] & MSG_FAIL) {
42 i2o_report_fail_status(req_status, msg);
43 return;
44 }
45
46 i2o_report_common_status(req_status);
47
48 if (cmd < 0x1F || (cmd >= 0xA0 && cmd <= 0xEF))
49 i2o_report_common_dsc(detailed_status);
50 else
51 printk(KERN_DEBUG " / DetailedStatus = %0#4x.\n",
52 detailed_status);
53}
54
55/* Used to dump a message to syslog during debugging */
56void i2o_dump_message(struct i2o_message *m)
57{
58#ifdef DEBUG
59 u32 *msg = (u32 *) m;
60 int i;
61 printk(KERN_INFO "Dumping I2O message size %d @ %p\n",
62 msg[0] >> 16 & 0xffff, msg);
63 for (i = 0; i < ((msg[0] >> 16) & 0xffff); i++)
64 printk(KERN_INFO " msg[%d] = %0#10x\n", i, msg[i]);
65#endif
66}
67
68/*
69 * Used for error reporting/debugging purposes.
70 * Following fail status are common to all classes.
71 * The preserved message must be handled in the reply handler.
72 */
73static void i2o_report_fail_status(u8 req_status, u32 * msg)
74{
75 static char *FAIL_STATUS[] = {
76 "0x80", /* not used */
77 "SERVICE_SUSPENDED", /* 0x81 */
78 "SERVICE_TERMINATED", /* 0x82 */
79 "CONGESTION",
80 "FAILURE",
81 "STATE_ERROR",
82 "TIME_OUT",
83 "ROUTING_FAILURE",
84 "INVALID_VERSION",
85 "INVALID_OFFSET",
86 "INVALID_MSG_FLAGS",
87 "FRAME_TOO_SMALL",
88 "FRAME_TOO_LARGE",
89 "INVALID_TARGET_ID",
90 "INVALID_INITIATOR_ID",
91 "INVALID_INITIATOR_CONTEX", /* 0x8F */
92 "UNKNOWN_FAILURE" /* 0xFF */
93 };
94
95 if (req_status == I2O_FSC_TRANSPORT_UNKNOWN_FAILURE)
96 printk(KERN_DEBUG "TRANSPORT_UNKNOWN_FAILURE (%0#2x)\n.",
97 req_status);
98 else
99 printk(KERN_DEBUG "TRANSPORT_%s.\n",
100 FAIL_STATUS[req_status & 0x0F]);
101
102 /* Dump some details */
103
104 printk(KERN_ERR " InitiatorId = %d, TargetId = %d\n",
105 (msg[1] >> 12) & 0xFFF, msg[1] & 0xFFF);
106 printk(KERN_ERR " LowestVersion = 0x%02X, HighestVersion = 0x%02X\n",
107 (msg[4] >> 8) & 0xFF, msg[4] & 0xFF);
108 printk(KERN_ERR " FailingHostUnit = 0x%04X, FailingIOP = 0x%03X\n",
109 msg[5] >> 16, msg[5] & 0xFFF);
110
111 printk(KERN_ERR " Severity: 0x%02X ", (msg[4] >> 16) & 0xFF);
112 if (msg[4] & (1 << 16))
113 printk(KERN_DEBUG "(FormatError), "
114 "this msg can never be delivered/processed.\n");
115 if (msg[4] & (1 << 17))
116 printk(KERN_DEBUG "(PathError), "
117 "this msg can no longer be delivered/processed.\n");
118 if (msg[4] & (1 << 18))
119 printk(KERN_DEBUG "(PathState), "
120 "the system state does not allow delivery.\n");
121 if (msg[4] & (1 << 19))
122 printk(KERN_DEBUG
123 "(Congestion), resources temporarily not available;"
124 "do not retry immediately.\n");
125}
126
127/*
128 * Used for error reporting/debugging purposes.
129 * Following reply status are common to all classes.
130 */
131static void i2o_report_common_status(u8 req_status)
132{
133 static char *REPLY_STATUS[] = {
134 "SUCCESS",
135 "ABORT_DIRTY",
136 "ABORT_NO_DATA_TRANSFER",
137 "ABORT_PARTIAL_TRANSFER",
138 "ERROR_DIRTY",
139 "ERROR_NO_DATA_TRANSFER",
140 "ERROR_PARTIAL_TRANSFER",
141 "PROCESS_ABORT_DIRTY",
142 "PROCESS_ABORT_NO_DATA_TRANSFER",
143 "PROCESS_ABORT_PARTIAL_TRANSFER",
144 "TRANSACTION_ERROR",
145 "PROGRESS_REPORT"
146 };
147
148 if (req_status >= ARRAY_SIZE(REPLY_STATUS))
149 printk(KERN_DEBUG "RequestStatus = %0#2x", req_status);
150 else
151 printk(KERN_DEBUG "%s", REPLY_STATUS[req_status]);
152}
153
154/*
155 * Used for error reporting/debugging purposes.
156 * Following detailed status are valid for executive class,
157 * utility class, DDM class and for transaction error replies.
158 */
159static void i2o_report_common_dsc(u16 detailed_status)
160{
161 static char *COMMON_DSC[] = {
162 "SUCCESS",
163 "0x01", // not used
164 "BAD_KEY",
165 "TCL_ERROR",
166 "REPLY_BUFFER_FULL",
167 "NO_SUCH_PAGE",
168 "INSUFFICIENT_RESOURCE_SOFT",
169 "INSUFFICIENT_RESOURCE_HARD",
170 "0x08", // not used
171 "CHAIN_BUFFER_TOO_LARGE",
172 "UNSUPPORTED_FUNCTION",
173 "DEVICE_LOCKED",
174 "DEVICE_RESET",
175 "INAPPROPRIATE_FUNCTION",
176 "INVALID_INITIATOR_ADDRESS",
177 "INVALID_MESSAGE_FLAGS",
178 "INVALID_OFFSET",
179 "INVALID_PARAMETER",
180 "INVALID_REQUEST",
181 "INVALID_TARGET_ADDRESS",
182 "MESSAGE_TOO_LARGE",
183 "MESSAGE_TOO_SMALL",
184 "MISSING_PARAMETER",
185 "TIMEOUT",
186 "UNKNOWN_ERROR",
187 "UNKNOWN_FUNCTION",
188 "UNSUPPORTED_VERSION",
189 "DEVICE_BUSY",
190 "DEVICE_NOT_AVAILABLE"
191 };
192
193 if (detailed_status > I2O_DSC_DEVICE_NOT_AVAILABLE)
194 printk(KERN_DEBUG " / DetailedStatus = %0#4x.\n",
195 detailed_status);
196 else
197 printk(KERN_DEBUG " / %s.\n", COMMON_DSC[detailed_status]);
198}
199
200/*
201 * Used for error reporting/debugging purposes
202 */
203static void i2o_report_util_cmd(u8 cmd)
204{
205 switch (cmd) {
206 case I2O_CMD_UTIL_NOP:
207 printk(KERN_DEBUG "UTIL_NOP, ");
208 break;
209 case I2O_CMD_UTIL_ABORT:
210 printk(KERN_DEBUG "UTIL_ABORT, ");
211 break;
212 case I2O_CMD_UTIL_CLAIM:
213 printk(KERN_DEBUG "UTIL_CLAIM, ");
214 break;
215 case I2O_CMD_UTIL_RELEASE:
216 printk(KERN_DEBUG "UTIL_CLAIM_RELEASE, ");
217 break;
218 case I2O_CMD_UTIL_CONFIG_DIALOG:
219 printk(KERN_DEBUG "UTIL_CONFIG_DIALOG, ");
220 break;
221 case I2O_CMD_UTIL_DEVICE_RESERVE:
222 printk(KERN_DEBUG "UTIL_DEVICE_RESERVE, ");
223 break;
224 case I2O_CMD_UTIL_DEVICE_RELEASE:
225 printk(KERN_DEBUG "UTIL_DEVICE_RELEASE, ");
226 break;
227 case I2O_CMD_UTIL_EVT_ACK:
228 printk(KERN_DEBUG "UTIL_EVENT_ACKNOWLEDGE, ");
229 break;
230 case I2O_CMD_UTIL_EVT_REGISTER:
231 printk(KERN_DEBUG "UTIL_EVENT_REGISTER, ");
232 break;
233 case I2O_CMD_UTIL_LOCK:
234 printk(KERN_DEBUG "UTIL_LOCK, ");
235 break;
236 case I2O_CMD_UTIL_LOCK_RELEASE:
237 printk(KERN_DEBUG "UTIL_LOCK_RELEASE, ");
238 break;
239 case I2O_CMD_UTIL_PARAMS_GET:
240 printk(KERN_DEBUG "UTIL_PARAMS_GET, ");
241 break;
242 case I2O_CMD_UTIL_PARAMS_SET:
243 printk(KERN_DEBUG "UTIL_PARAMS_SET, ");
244 break;
245 case I2O_CMD_UTIL_REPLY_FAULT_NOTIFY:
246 printk(KERN_DEBUG "UTIL_REPLY_FAULT_NOTIFY, ");
247 break;
248 default:
249 printk(KERN_DEBUG "Cmd = %0#2x, ", cmd);
250 }
251}
252
253/*
254 * Used for error reporting/debugging purposes
255 */
256static void i2o_report_exec_cmd(u8 cmd)
257{
258 switch (cmd) {
259 case I2O_CMD_ADAPTER_ASSIGN:
260 printk(KERN_DEBUG "EXEC_ADAPTER_ASSIGN, ");
261 break;
262 case I2O_CMD_ADAPTER_READ:
263 printk(KERN_DEBUG "EXEC_ADAPTER_READ, ");
264 break;
265 case I2O_CMD_ADAPTER_RELEASE:
266 printk(KERN_DEBUG "EXEC_ADAPTER_RELEASE, ");
267 break;
268 case I2O_CMD_BIOS_INFO_SET:
269 printk(KERN_DEBUG "EXEC_BIOS_INFO_SET, ");
270 break;
271 case I2O_CMD_BOOT_DEVICE_SET:
272 printk(KERN_DEBUG "EXEC_BOOT_DEVICE_SET, ");
273 break;
274 case I2O_CMD_CONFIG_VALIDATE:
275 printk(KERN_DEBUG "EXEC_CONFIG_VALIDATE, ");
276 break;
277 case I2O_CMD_CONN_SETUP:
278 printk(KERN_DEBUG "EXEC_CONN_SETUP, ");
279 break;
280 case I2O_CMD_DDM_DESTROY:
281 printk(KERN_DEBUG "EXEC_DDM_DESTROY, ");
282 break;
283 case I2O_CMD_DDM_ENABLE:
284 printk(KERN_DEBUG "EXEC_DDM_ENABLE, ");
285 break;
286 case I2O_CMD_DDM_QUIESCE:
287 printk(KERN_DEBUG "EXEC_DDM_QUIESCE, ");
288 break;
289 case I2O_CMD_DDM_RESET:
290 printk(KERN_DEBUG "EXEC_DDM_RESET, ");
291 break;
292 case I2O_CMD_DDM_SUSPEND:
293 printk(KERN_DEBUG "EXEC_DDM_SUSPEND, ");
294 break;
295 case I2O_CMD_DEVICE_ASSIGN:
296 printk(KERN_DEBUG "EXEC_DEVICE_ASSIGN, ");
297 break;
298 case I2O_CMD_DEVICE_RELEASE:
299 printk(KERN_DEBUG "EXEC_DEVICE_RELEASE, ");
300 break;
301 case I2O_CMD_HRT_GET:
302 printk(KERN_DEBUG "EXEC_HRT_GET, ");
303 break;
304 case I2O_CMD_ADAPTER_CLEAR:
305 printk(KERN_DEBUG "EXEC_IOP_CLEAR, ");
306 break;
307 case I2O_CMD_ADAPTER_CONNECT:
308 printk(KERN_DEBUG "EXEC_IOP_CONNECT, ");
309 break;
310 case I2O_CMD_ADAPTER_RESET:
311 printk(KERN_DEBUG "EXEC_IOP_RESET, ");
312 break;
313 case I2O_CMD_LCT_NOTIFY:
314 printk(KERN_DEBUG "EXEC_LCT_NOTIFY, ");
315 break;
316 case I2O_CMD_OUTBOUND_INIT:
317 printk(KERN_DEBUG "EXEC_OUTBOUND_INIT, ");
318 break;
319 case I2O_CMD_PATH_ENABLE:
320 printk(KERN_DEBUG "EXEC_PATH_ENABLE, ");
321 break;
322 case I2O_CMD_PATH_QUIESCE:
323 printk(KERN_DEBUG "EXEC_PATH_QUIESCE, ");
324 break;
325 case I2O_CMD_PATH_RESET:
326 printk(KERN_DEBUG "EXEC_PATH_RESET, ");
327 break;
328 case I2O_CMD_STATIC_MF_CREATE:
329 printk(KERN_DEBUG "EXEC_STATIC_MF_CREATE, ");
330 break;
331 case I2O_CMD_STATIC_MF_RELEASE:
332 printk(KERN_DEBUG "EXEC_STATIC_MF_RELEASE, ");
333 break;
334 case I2O_CMD_STATUS_GET:
335 printk(KERN_DEBUG "EXEC_STATUS_GET, ");
336 break;
337 case I2O_CMD_SW_DOWNLOAD:
338 printk(KERN_DEBUG "EXEC_SW_DOWNLOAD, ");
339 break;
340 case I2O_CMD_SW_UPLOAD:
341 printk(KERN_DEBUG "EXEC_SW_UPLOAD, ");
342 break;
343 case I2O_CMD_SW_REMOVE:
344 printk(KERN_DEBUG "EXEC_SW_REMOVE, ");
345 break;
346 case I2O_CMD_SYS_ENABLE:
347 printk(KERN_DEBUG "EXEC_SYS_ENABLE, ");
348 break;
349 case I2O_CMD_SYS_MODIFY:
350 printk(KERN_DEBUG "EXEC_SYS_MODIFY, ");
351 break;
352 case I2O_CMD_SYS_QUIESCE:
353 printk(KERN_DEBUG "EXEC_SYS_QUIESCE, ");
354 break;
355 case I2O_CMD_SYS_TAB_SET:
356 printk(KERN_DEBUG "EXEC_SYS_TAB_SET, ");
357 break;
358 default:
359 printk(KERN_DEBUG "Cmd = %#02x, ", cmd);
360 }
361}
362
363void i2o_debug_state(struct i2o_controller *c)
364{
365 printk(KERN_INFO "%s: State = ", c->name);
366 switch (((i2o_status_block *) c->status_block.virt)->iop_state) {
367 case 0x01:
368 printk(KERN_DEBUG "INIT\n");
369 break;
370 case 0x02:
371 printk(KERN_DEBUG "RESET\n");
372 break;
373 case 0x04:
374 printk(KERN_DEBUG "HOLD\n");
375 break;
376 case 0x05:
377 printk(KERN_DEBUG "READY\n");
378 break;
379 case 0x08:
380 printk(KERN_DEBUG "OPERATIONAL\n");
381 break;
382 case 0x10:
383 printk(KERN_DEBUG "FAILED\n");
384 break;
385 case 0x11:
386 printk(KERN_DEBUG "FAULTED\n");
387 break;
388 default:
389 printk(KERN_DEBUG "%x (unknown !!)\n",
390 ((i2o_status_block *) c->status_block.virt)->iop_state);
391 }
392};
393
394void i2o_dump_hrt(struct i2o_controller *c)
395{
396 u32 *rows = (u32 *) c->hrt.virt;
397 u8 *p = (u8 *) c->hrt.virt;
398 u8 *d;
399 int count;
400 int length;
401 int i;
402 int state;
403
404 if (p[3] != 0) {
405 printk(KERN_ERR
406 "%s: HRT table for controller is too new a version.\n",
407 c->name);
408 return;
409 }
410
411 count = p[0] | (p[1] << 8);
412 length = p[2];
413
414 printk(KERN_INFO "%s: HRT has %d entries of %d bytes each.\n",
415 c->name, count, length << 2);
416
417 rows += 2;
418
419 for (i = 0; i < count; i++) {
420 printk(KERN_INFO "Adapter %08X: ", rows[0]);
421 p = (u8 *) (rows + 1);
422 d = (u8 *) (rows + 2);
423 state = p[1] << 8 | p[0];
424
425 printk(KERN_DEBUG "TID %04X:[", state & 0xFFF);
426 state >>= 12;
427 if (state & (1 << 0))
428 printk(KERN_DEBUG "H"); /* Hidden */
429 if (state & (1 << 2)) {
430 printk(KERN_DEBUG "P"); /* Present */
431 if (state & (1 << 1))
432 printk(KERN_DEBUG "C"); /* Controlled */
433 }
434 if (state > 9)
435 printk(KERN_DEBUG "*"); /* Hard */
436
437 printk(KERN_DEBUG "]:");
438
439 switch (p[3] & 0xFFFF) {
440 case 0:
441 /* Adapter private bus - easy */
442 printk(KERN_DEBUG
443 "Local bus %d: I/O at 0x%04X Mem 0x%08X", p[2],
444 d[1] << 8 | d[0], *(u32 *) (d + 4));
445 break;
446 case 1:
447 /* ISA bus */
448 printk(KERN_DEBUG
449 "ISA %d: CSN %d I/O at 0x%04X Mem 0x%08X", p[2],
450 d[2], d[1] << 8 | d[0], *(u32 *) (d + 4));
451 break;
452
453 case 2: /* EISA bus */
454 printk(KERN_DEBUG
455 "EISA %d: Slot %d I/O at 0x%04X Mem 0x%08X",
456 p[2], d[3], d[1] << 8 | d[0], *(u32 *) (d + 4));
457 break;
458
459 case 3: /* MCA bus */
460 printk(KERN_DEBUG
461 "MCA %d: Slot %d I/O at 0x%04X Mem 0x%08X", p[2],
462 d[3], d[1] << 8 | d[0], *(u32 *) (d + 4));
463 break;
464
465 case 4: /* PCI bus */
466 printk(KERN_DEBUG
467 "PCI %d: Bus %d Device %d Function %d", p[2],
468 d[2], d[1], d[0]);
469 break;
470
471 case 0x80: /* Other */
472 default:
473 printk(KERN_DEBUG "Unsupported bus type.");
474 break;
475 }
476 printk(KERN_DEBUG "\n");
477 rows += length;
478 }
479}
480
481EXPORT_SYMBOL(i2o_dump_message);