1 #include <linux/module.h>
2 #include <linux/kernel.h>
6 static void i2o_report_util_cmd(u8 cmd);
7 static void i2o_report_exec_cmd(u8 cmd);
8 static void i2o_report_fail_status(u8 req_status, u32 * msg);
9 static void i2o_report_common_status(u8 req_status);
10 static void i2o_report_common_dsc(u16 detailed_status);
13 * Used for error reporting/debugging purposes.
14 * Report Cmd name, Request status, Detailed Status.
16 void i2o_report_status(const char *severity, const char *str,
17 struct i2o_message *m)
20 u8 cmd = (msg[1] >> 24) & 0xFF;
21 u8 req_status = (msg[4] >> 24) & 0xFF;
22 u16 detailed_status = msg[4] & 0xFFFF;
24 if (cmd == I2O_CMD_UTIL_EVT_REGISTER)
25 return; // No status in this reply
27 printk(KERN_DEBUG "%s%s: ", severity, str);
29 if (cmd < 0x1F) // Utility cmd
30 i2o_report_util_cmd(cmd);
32 else if (cmd >= 0xA0 && cmd <= 0xEF) // Executive cmd
33 i2o_report_exec_cmd(cmd);
35 printk(KERN_DEBUG "Cmd = %0#2x, ", cmd); // Other cmds
37 if (msg[0] & MSG_FAIL) {
38 i2o_report_fail_status(req_status, msg);
42 i2o_report_common_status(req_status);
44 if (cmd < 0x1F || (cmd >= 0xA0 && cmd <= 0xEF))
45 i2o_report_common_dsc(detailed_status);
47 printk(KERN_DEBUG " / DetailedStatus = %0#4x.\n",
51 /* Used to dump a message to syslog during debugging */
52 void i2o_dump_message(struct i2o_message *m)
57 printk(KERN_INFO "Dumping I2O message size %d @ %p\n",
58 msg[0] >> 16 & 0xffff, msg);
59 for (i = 0; i < ((msg[0] >> 16) & 0xffff); i++)
60 printk(KERN_INFO " msg[%d] = %0#10x\n", i, msg[i]);
65 * Used for error reporting/debugging purposes.
66 * Following fail status are common to all classes.
67 * The preserved message must be handled in the reply handler.
69 static void i2o_report_fail_status(u8 req_status, u32 * msg)
71 static char *FAIL_STATUS[] = {
72 "0x80", /* not used */
73 "SERVICE_SUSPENDED", /* 0x81 */
74 "SERVICE_TERMINATED", /* 0x82 */
86 "INVALID_INITIATOR_ID",
87 "INVALID_INITIATOR_CONTEX", /* 0x8F */
88 "UNKNOWN_FAILURE" /* 0xFF */
91 if (req_status == I2O_FSC_TRANSPORT_UNKNOWN_FAILURE)
92 printk(KERN_DEBUG "TRANSPORT_UNKNOWN_FAILURE (%0#2x).\n",
95 printk(KERN_DEBUG "TRANSPORT_%s.\n",
96 FAIL_STATUS[req_status & 0x0F]);
98 /* Dump some details */
100 printk(KERN_ERR " InitiatorId = %d, TargetId = %d\n",
101 (msg[1] >> 12) & 0xFFF, msg[1] & 0xFFF);
102 printk(KERN_ERR " LowestVersion = 0x%02X, HighestVersion = 0x%02X\n",
103 (msg[4] >> 8) & 0xFF, msg[4] & 0xFF);
104 printk(KERN_ERR " FailingHostUnit = 0x%04X, FailingIOP = 0x%03X\n",
105 msg[5] >> 16, msg[5] & 0xFFF);
107 printk(KERN_ERR " Severity: 0x%02X ", (msg[4] >> 16) & 0xFF);
108 if (msg[4] & (1 << 16))
109 printk(KERN_DEBUG "(FormatError), "
110 "this msg can never be delivered/processed.\n");
111 if (msg[4] & (1 << 17))
112 printk(KERN_DEBUG "(PathError), "
113 "this msg can no longer be delivered/processed.\n");
114 if (msg[4] & (1 << 18))
115 printk(KERN_DEBUG "(PathState), "
116 "the system state does not allow delivery.\n");
117 if (msg[4] & (1 << 19))
119 "(Congestion), resources temporarily not available;"
120 "do not retry immediately.\n");
124 * Used for error reporting/debugging purposes.
125 * Following reply status are common to all classes.
127 static void i2o_report_common_status(u8 req_status)
129 static char *REPLY_STATUS[] = {
132 "ABORT_NO_DATA_TRANSFER",
133 "ABORT_PARTIAL_TRANSFER",
135 "ERROR_NO_DATA_TRANSFER",
136 "ERROR_PARTIAL_TRANSFER",
137 "PROCESS_ABORT_DIRTY",
138 "PROCESS_ABORT_NO_DATA_TRANSFER",
139 "PROCESS_ABORT_PARTIAL_TRANSFER",
144 if (req_status >= ARRAY_SIZE(REPLY_STATUS))
145 printk(KERN_DEBUG "RequestStatus = %0#2x", req_status);
147 printk(KERN_DEBUG "%s", REPLY_STATUS[req_status]);
151 * Used for error reporting/debugging purposes.
152 * Following detailed status are valid for executive class,
153 * utility class, DDM class and for transaction error replies.
155 static void i2o_report_common_dsc(u16 detailed_status)
157 static char *COMMON_DSC[] = {
164 "INSUFFICIENT_RESOURCE_SOFT",
165 "INSUFFICIENT_RESOURCE_HARD",
167 "CHAIN_BUFFER_TOO_LARGE",
168 "UNSUPPORTED_FUNCTION",
171 "INAPPROPRIATE_FUNCTION",
172 "INVALID_INITIATOR_ADDRESS",
173 "INVALID_MESSAGE_FLAGS",
177 "INVALID_TARGET_ADDRESS",
184 "UNSUPPORTED_VERSION",
186 "DEVICE_NOT_AVAILABLE"
189 if (detailed_status > I2O_DSC_DEVICE_NOT_AVAILABLE)
190 printk(KERN_DEBUG " / DetailedStatus = %0#4x.\n",
193 printk(KERN_DEBUG " / %s.\n", COMMON_DSC[detailed_status]);
197 * Used for error reporting/debugging purposes
199 static void i2o_report_util_cmd(u8 cmd)
202 case I2O_CMD_UTIL_NOP:
203 printk(KERN_DEBUG "UTIL_NOP, ");
205 case I2O_CMD_UTIL_ABORT:
206 printk(KERN_DEBUG "UTIL_ABORT, ");
208 case I2O_CMD_UTIL_CLAIM:
209 printk(KERN_DEBUG "UTIL_CLAIM, ");
211 case I2O_CMD_UTIL_RELEASE:
212 printk(KERN_DEBUG "UTIL_CLAIM_RELEASE, ");
214 case I2O_CMD_UTIL_CONFIG_DIALOG:
215 printk(KERN_DEBUG "UTIL_CONFIG_DIALOG, ");
217 case I2O_CMD_UTIL_DEVICE_RESERVE:
218 printk(KERN_DEBUG "UTIL_DEVICE_RESERVE, ");
220 case I2O_CMD_UTIL_DEVICE_RELEASE:
221 printk(KERN_DEBUG "UTIL_DEVICE_RELEASE, ");
223 case I2O_CMD_UTIL_EVT_ACK:
224 printk(KERN_DEBUG "UTIL_EVENT_ACKNOWLEDGE, ");
226 case I2O_CMD_UTIL_EVT_REGISTER:
227 printk(KERN_DEBUG "UTIL_EVENT_REGISTER, ");
229 case I2O_CMD_UTIL_LOCK:
230 printk(KERN_DEBUG "UTIL_LOCK, ");
232 case I2O_CMD_UTIL_LOCK_RELEASE:
233 printk(KERN_DEBUG "UTIL_LOCK_RELEASE, ");
235 case I2O_CMD_UTIL_PARAMS_GET:
236 printk(KERN_DEBUG "UTIL_PARAMS_GET, ");
238 case I2O_CMD_UTIL_PARAMS_SET:
239 printk(KERN_DEBUG "UTIL_PARAMS_SET, ");
241 case I2O_CMD_UTIL_REPLY_FAULT_NOTIFY:
242 printk(KERN_DEBUG "UTIL_REPLY_FAULT_NOTIFY, ");
245 printk(KERN_DEBUG "Cmd = %0#2x, ", cmd);
250 * Used for error reporting/debugging purposes
252 static void i2o_report_exec_cmd(u8 cmd)
255 case I2O_CMD_ADAPTER_ASSIGN:
256 printk(KERN_DEBUG "EXEC_ADAPTER_ASSIGN, ");
258 case I2O_CMD_ADAPTER_READ:
259 printk(KERN_DEBUG "EXEC_ADAPTER_READ, ");
261 case I2O_CMD_ADAPTER_RELEASE:
262 printk(KERN_DEBUG "EXEC_ADAPTER_RELEASE, ");
264 case I2O_CMD_BIOS_INFO_SET:
265 printk(KERN_DEBUG "EXEC_BIOS_INFO_SET, ");
267 case I2O_CMD_BOOT_DEVICE_SET:
268 printk(KERN_DEBUG "EXEC_BOOT_DEVICE_SET, ");
270 case I2O_CMD_CONFIG_VALIDATE:
271 printk(KERN_DEBUG "EXEC_CONFIG_VALIDATE, ");
273 case I2O_CMD_CONN_SETUP:
274 printk(KERN_DEBUG "EXEC_CONN_SETUP, ");
276 case I2O_CMD_DDM_DESTROY:
277 printk(KERN_DEBUG "EXEC_DDM_DESTROY, ");
279 case I2O_CMD_DDM_ENABLE:
280 printk(KERN_DEBUG "EXEC_DDM_ENABLE, ");
282 case I2O_CMD_DDM_QUIESCE:
283 printk(KERN_DEBUG "EXEC_DDM_QUIESCE, ");
285 case I2O_CMD_DDM_RESET:
286 printk(KERN_DEBUG "EXEC_DDM_RESET, ");
288 case I2O_CMD_DDM_SUSPEND:
289 printk(KERN_DEBUG "EXEC_DDM_SUSPEND, ");
291 case I2O_CMD_DEVICE_ASSIGN:
292 printk(KERN_DEBUG "EXEC_DEVICE_ASSIGN, ");
294 case I2O_CMD_DEVICE_RELEASE:
295 printk(KERN_DEBUG "EXEC_DEVICE_RELEASE, ");
297 case I2O_CMD_HRT_GET:
298 printk(KERN_DEBUG "EXEC_HRT_GET, ");
300 case I2O_CMD_ADAPTER_CLEAR:
301 printk(KERN_DEBUG "EXEC_IOP_CLEAR, ");
303 case I2O_CMD_ADAPTER_CONNECT:
304 printk(KERN_DEBUG "EXEC_IOP_CONNECT, ");
306 case I2O_CMD_ADAPTER_RESET:
307 printk(KERN_DEBUG "EXEC_IOP_RESET, ");
309 case I2O_CMD_LCT_NOTIFY:
310 printk(KERN_DEBUG "EXEC_LCT_NOTIFY, ");
312 case I2O_CMD_OUTBOUND_INIT:
313 printk(KERN_DEBUG "EXEC_OUTBOUND_INIT, ");
315 case I2O_CMD_PATH_ENABLE:
316 printk(KERN_DEBUG "EXEC_PATH_ENABLE, ");
318 case I2O_CMD_PATH_QUIESCE:
319 printk(KERN_DEBUG "EXEC_PATH_QUIESCE, ");
321 case I2O_CMD_PATH_RESET:
322 printk(KERN_DEBUG "EXEC_PATH_RESET, ");
324 case I2O_CMD_STATIC_MF_CREATE:
325 printk(KERN_DEBUG "EXEC_STATIC_MF_CREATE, ");
327 case I2O_CMD_STATIC_MF_RELEASE:
328 printk(KERN_DEBUG "EXEC_STATIC_MF_RELEASE, ");
330 case I2O_CMD_STATUS_GET:
331 printk(KERN_DEBUG "EXEC_STATUS_GET, ");
333 case I2O_CMD_SW_DOWNLOAD:
334 printk(KERN_DEBUG "EXEC_SW_DOWNLOAD, ");
336 case I2O_CMD_SW_UPLOAD:
337 printk(KERN_DEBUG "EXEC_SW_UPLOAD, ");
339 case I2O_CMD_SW_REMOVE:
340 printk(KERN_DEBUG "EXEC_SW_REMOVE, ");
342 case I2O_CMD_SYS_ENABLE:
343 printk(KERN_DEBUG "EXEC_SYS_ENABLE, ");
345 case I2O_CMD_SYS_MODIFY:
346 printk(KERN_DEBUG "EXEC_SYS_MODIFY, ");
348 case I2O_CMD_SYS_QUIESCE:
349 printk(KERN_DEBUG "EXEC_SYS_QUIESCE, ");
351 case I2O_CMD_SYS_TAB_SET:
352 printk(KERN_DEBUG "EXEC_SYS_TAB_SET, ");
355 printk(KERN_DEBUG "Cmd = %#02x, ", cmd);
359 void i2o_debug_state(struct i2o_controller *c)
361 printk(KERN_INFO "%s: State = ", c->name);
362 switch (((i2o_status_block *) c->status_block.virt)->iop_state) {
364 printk(KERN_DEBUG "INIT\n");
367 printk(KERN_DEBUG "RESET\n");
370 printk(KERN_DEBUG "HOLD\n");
373 printk(KERN_DEBUG "READY\n");
376 printk(KERN_DEBUG "OPERATIONAL\n");
379 printk(KERN_DEBUG "FAILED\n");
382 printk(KERN_DEBUG "FAULTED\n");
385 printk(KERN_DEBUG "%x (unknown !!)\n",
386 ((i2o_status_block *) c->status_block.virt)->iop_state);
390 void i2o_dump_hrt(struct i2o_controller *c)
392 u32 *rows = (u32 *) c->hrt.virt;
393 u8 *p = (u8 *) c->hrt.virt;
402 "%s: HRT table for controller is too new a version.\n",
407 count = p[0] | (p[1] << 8);
410 printk(KERN_INFO "%s: HRT has %d entries of %d bytes each.\n",
411 c->name, count, length << 2);
415 for (i = 0; i < count; i++) {
416 printk(KERN_INFO "Adapter %08X: ", rows[0]);
417 p = (u8 *) (rows + 1);
418 d = (u8 *) (rows + 2);
419 state = p[1] << 8 | p[0];
421 printk("TID %04X:[", state & 0xFFF);
423 if (state & (1 << 0))
424 printk("H"); /* Hidden */
425 if (state & (1 << 2)) {
426 printk("P"); /* Present */
427 if (state & (1 << 1))
428 printk("C"); /* Controlled */
431 printk("*"); /* Hard */
435 switch (p[3] & 0xFFFF) {
437 /* Adapter private bus - easy */
438 printk("Local bus %d: I/O at 0x%04X Mem 0x%08X", p[2],
439 d[1] << 8 | d[0], *(u32 *) (d + 4));
443 printk("ISA %d: CSN %d I/O at 0x%04X Mem 0x%08X", p[2],
444 d[2], d[1] << 8 | d[0], *(u32 *) (d + 4));
447 case 2: /* EISA bus */
448 printk("EISA %d: Slot %d I/O at 0x%04X Mem 0x%08X",
449 p[2], d[3], d[1] << 8 | d[0], *(u32 *) (d + 4));
452 case 3: /* MCA bus */
453 printk("MCA %d: Slot %d I/O at 0x%04X Mem 0x%08X", p[2],
454 d[3], d[1] << 8 | d[0], *(u32 *) (d + 4));
457 case 4: /* PCI bus */
458 printk("PCI %d: Bus %d Device %d Function %d", p[2],
462 case 0x80: /* Other */
464 printk("Unsupported bus type.");
472 EXPORT_SYMBOL(i2o_dump_message);