1 #include <linux/config.h>
2 #include <linux/module.h>
3 #include <linux/kernel.h>
7 static void i2o_report_util_cmd(u8 cmd);
8 static void i2o_report_exec_cmd(u8 cmd);
9 static void i2o_report_fail_status(u8 req_status, u32 * msg);
10 static void i2o_report_common_status(u8 req_status);
11 static void i2o_report_common_dsc(u16 detailed_status);
14 * Used for error reporting/debugging purposes.
15 * Report Cmd name, Request status, Detailed Status.
17 void i2o_report_status(const char *severity, const char *str,
18 struct i2o_message *m)
21 u8 cmd = (msg[1] >> 24) & 0xFF;
22 u8 req_status = (msg[4] >> 24) & 0xFF;
23 u16 detailed_status = msg[4] & 0xFFFF;
25 if (cmd == I2O_CMD_UTIL_EVT_REGISTER)
26 return; // No status in this reply
28 printk(KERN_DEBUG "%s%s: ", severity, str);
30 if (cmd < 0x1F) // Utility cmd
31 i2o_report_util_cmd(cmd);
33 else if (cmd >= 0xA0 && cmd <= 0xEF) // Executive cmd
34 i2o_report_exec_cmd(cmd);
36 printk(KERN_DEBUG "Cmd = %0#2x, ", cmd); // Other cmds
38 if (msg[0] & MSG_FAIL) {
39 i2o_report_fail_status(req_status, msg);
43 i2o_report_common_status(req_status);
45 if (cmd < 0x1F || (cmd >= 0xA0 && cmd <= 0xEF))
46 i2o_report_common_dsc(detailed_status);
48 printk(KERN_DEBUG " / DetailedStatus = %0#4x.\n",
52 /* Used to dump a message to syslog during debugging */
53 void i2o_dump_message(struct i2o_message *m)
58 printk(KERN_INFO "Dumping I2O message size %d @ %p\n",
59 msg[0] >> 16 & 0xffff, msg);
60 for (i = 0; i < ((msg[0] >> 16) & 0xffff); i++)
61 printk(KERN_INFO " msg[%d] = %0#10x\n", i, msg[i]);
66 * Used for error reporting/debugging purposes.
67 * Following fail status are common to all classes.
68 * The preserved message must be handled in the reply handler.
70 static void i2o_report_fail_status(u8 req_status, u32 * msg)
72 static char *FAIL_STATUS[] = {
73 "0x80", /* not used */
74 "SERVICE_SUSPENDED", /* 0x81 */
75 "SERVICE_TERMINATED", /* 0x82 */
87 "INVALID_INITIATOR_ID",
88 "INVALID_INITIATOR_CONTEX", /* 0x8F */
89 "UNKNOWN_FAILURE" /* 0xFF */
92 if (req_status == I2O_FSC_TRANSPORT_UNKNOWN_FAILURE)
93 printk(KERN_DEBUG "TRANSPORT_UNKNOWN_FAILURE (%0#2x).\n",
96 printk(KERN_DEBUG "TRANSPORT_%s.\n",
97 FAIL_STATUS[req_status & 0x0F]);
99 /* Dump some details */
101 printk(KERN_ERR " InitiatorId = %d, TargetId = %d\n",
102 (msg[1] >> 12) & 0xFFF, msg[1] & 0xFFF);
103 printk(KERN_ERR " LowestVersion = 0x%02X, HighestVersion = 0x%02X\n",
104 (msg[4] >> 8) & 0xFF, msg[4] & 0xFF);
105 printk(KERN_ERR " FailingHostUnit = 0x%04X, FailingIOP = 0x%03X\n",
106 msg[5] >> 16, msg[5] & 0xFFF);
108 printk(KERN_ERR " Severity: 0x%02X ", (msg[4] >> 16) & 0xFF);
109 if (msg[4] & (1 << 16))
110 printk(KERN_DEBUG "(FormatError), "
111 "this msg can never be delivered/processed.\n");
112 if (msg[4] & (1 << 17))
113 printk(KERN_DEBUG "(PathError), "
114 "this msg can no longer be delivered/processed.\n");
115 if (msg[4] & (1 << 18))
116 printk(KERN_DEBUG "(PathState), "
117 "the system state does not allow delivery.\n");
118 if (msg[4] & (1 << 19))
120 "(Congestion), resources temporarily not available;"
121 "do not retry immediately.\n");
125 * Used for error reporting/debugging purposes.
126 * Following reply status are common to all classes.
128 static void i2o_report_common_status(u8 req_status)
130 static char *REPLY_STATUS[] = {
133 "ABORT_NO_DATA_TRANSFER",
134 "ABORT_PARTIAL_TRANSFER",
136 "ERROR_NO_DATA_TRANSFER",
137 "ERROR_PARTIAL_TRANSFER",
138 "PROCESS_ABORT_DIRTY",
139 "PROCESS_ABORT_NO_DATA_TRANSFER",
140 "PROCESS_ABORT_PARTIAL_TRANSFER",
145 if (req_status >= ARRAY_SIZE(REPLY_STATUS))
146 printk(KERN_DEBUG "RequestStatus = %0#2x", req_status);
148 printk(KERN_DEBUG "%s", REPLY_STATUS[req_status]);
152 * Used for error reporting/debugging purposes.
153 * Following detailed status are valid for executive class,
154 * utility class, DDM class and for transaction error replies.
156 static void i2o_report_common_dsc(u16 detailed_status)
158 static char *COMMON_DSC[] = {
165 "INSUFFICIENT_RESOURCE_SOFT",
166 "INSUFFICIENT_RESOURCE_HARD",
168 "CHAIN_BUFFER_TOO_LARGE",
169 "UNSUPPORTED_FUNCTION",
172 "INAPPROPRIATE_FUNCTION",
173 "INVALID_INITIATOR_ADDRESS",
174 "INVALID_MESSAGE_FLAGS",
178 "INVALID_TARGET_ADDRESS",
185 "UNSUPPORTED_VERSION",
187 "DEVICE_NOT_AVAILABLE"
190 if (detailed_status > I2O_DSC_DEVICE_NOT_AVAILABLE)
191 printk(KERN_DEBUG " / DetailedStatus = %0#4x.\n",
194 printk(KERN_DEBUG " / %s.\n", COMMON_DSC[detailed_status]);
198 * Used for error reporting/debugging purposes
200 static void i2o_report_util_cmd(u8 cmd)
203 case I2O_CMD_UTIL_NOP:
204 printk(KERN_DEBUG "UTIL_NOP, ");
206 case I2O_CMD_UTIL_ABORT:
207 printk(KERN_DEBUG "UTIL_ABORT, ");
209 case I2O_CMD_UTIL_CLAIM:
210 printk(KERN_DEBUG "UTIL_CLAIM, ");
212 case I2O_CMD_UTIL_RELEASE:
213 printk(KERN_DEBUG "UTIL_CLAIM_RELEASE, ");
215 case I2O_CMD_UTIL_CONFIG_DIALOG:
216 printk(KERN_DEBUG "UTIL_CONFIG_DIALOG, ");
218 case I2O_CMD_UTIL_DEVICE_RESERVE:
219 printk(KERN_DEBUG "UTIL_DEVICE_RESERVE, ");
221 case I2O_CMD_UTIL_DEVICE_RELEASE:
222 printk(KERN_DEBUG "UTIL_DEVICE_RELEASE, ");
224 case I2O_CMD_UTIL_EVT_ACK:
225 printk(KERN_DEBUG "UTIL_EVENT_ACKNOWLEDGE, ");
227 case I2O_CMD_UTIL_EVT_REGISTER:
228 printk(KERN_DEBUG "UTIL_EVENT_REGISTER, ");
230 case I2O_CMD_UTIL_LOCK:
231 printk(KERN_DEBUG "UTIL_LOCK, ");
233 case I2O_CMD_UTIL_LOCK_RELEASE:
234 printk(KERN_DEBUG "UTIL_LOCK_RELEASE, ");
236 case I2O_CMD_UTIL_PARAMS_GET:
237 printk(KERN_DEBUG "UTIL_PARAMS_GET, ");
239 case I2O_CMD_UTIL_PARAMS_SET:
240 printk(KERN_DEBUG "UTIL_PARAMS_SET, ");
242 case I2O_CMD_UTIL_REPLY_FAULT_NOTIFY:
243 printk(KERN_DEBUG "UTIL_REPLY_FAULT_NOTIFY, ");
246 printk(KERN_DEBUG "Cmd = %0#2x, ", cmd);
251 * Used for error reporting/debugging purposes
253 static void i2o_report_exec_cmd(u8 cmd)
256 case I2O_CMD_ADAPTER_ASSIGN:
257 printk(KERN_DEBUG "EXEC_ADAPTER_ASSIGN, ");
259 case I2O_CMD_ADAPTER_READ:
260 printk(KERN_DEBUG "EXEC_ADAPTER_READ, ");
262 case I2O_CMD_ADAPTER_RELEASE:
263 printk(KERN_DEBUG "EXEC_ADAPTER_RELEASE, ");
265 case I2O_CMD_BIOS_INFO_SET:
266 printk(KERN_DEBUG "EXEC_BIOS_INFO_SET, ");
268 case I2O_CMD_BOOT_DEVICE_SET:
269 printk(KERN_DEBUG "EXEC_BOOT_DEVICE_SET, ");
271 case I2O_CMD_CONFIG_VALIDATE:
272 printk(KERN_DEBUG "EXEC_CONFIG_VALIDATE, ");
274 case I2O_CMD_CONN_SETUP:
275 printk(KERN_DEBUG "EXEC_CONN_SETUP, ");
277 case I2O_CMD_DDM_DESTROY:
278 printk(KERN_DEBUG "EXEC_DDM_DESTROY, ");
280 case I2O_CMD_DDM_ENABLE:
281 printk(KERN_DEBUG "EXEC_DDM_ENABLE, ");
283 case I2O_CMD_DDM_QUIESCE:
284 printk(KERN_DEBUG "EXEC_DDM_QUIESCE, ");
286 case I2O_CMD_DDM_RESET:
287 printk(KERN_DEBUG "EXEC_DDM_RESET, ");
289 case I2O_CMD_DDM_SUSPEND:
290 printk(KERN_DEBUG "EXEC_DDM_SUSPEND, ");
292 case I2O_CMD_DEVICE_ASSIGN:
293 printk(KERN_DEBUG "EXEC_DEVICE_ASSIGN, ");
295 case I2O_CMD_DEVICE_RELEASE:
296 printk(KERN_DEBUG "EXEC_DEVICE_RELEASE, ");
298 case I2O_CMD_HRT_GET:
299 printk(KERN_DEBUG "EXEC_HRT_GET, ");
301 case I2O_CMD_ADAPTER_CLEAR:
302 printk(KERN_DEBUG "EXEC_IOP_CLEAR, ");
304 case I2O_CMD_ADAPTER_CONNECT:
305 printk(KERN_DEBUG "EXEC_IOP_CONNECT, ");
307 case I2O_CMD_ADAPTER_RESET:
308 printk(KERN_DEBUG "EXEC_IOP_RESET, ");
310 case I2O_CMD_LCT_NOTIFY:
311 printk(KERN_DEBUG "EXEC_LCT_NOTIFY, ");
313 case I2O_CMD_OUTBOUND_INIT:
314 printk(KERN_DEBUG "EXEC_OUTBOUND_INIT, ");
316 case I2O_CMD_PATH_ENABLE:
317 printk(KERN_DEBUG "EXEC_PATH_ENABLE, ");
319 case I2O_CMD_PATH_QUIESCE:
320 printk(KERN_DEBUG "EXEC_PATH_QUIESCE, ");
322 case I2O_CMD_PATH_RESET:
323 printk(KERN_DEBUG "EXEC_PATH_RESET, ");
325 case I2O_CMD_STATIC_MF_CREATE:
326 printk(KERN_DEBUG "EXEC_STATIC_MF_CREATE, ");
328 case I2O_CMD_STATIC_MF_RELEASE:
329 printk(KERN_DEBUG "EXEC_STATIC_MF_RELEASE, ");
331 case I2O_CMD_STATUS_GET:
332 printk(KERN_DEBUG "EXEC_STATUS_GET, ");
334 case I2O_CMD_SW_DOWNLOAD:
335 printk(KERN_DEBUG "EXEC_SW_DOWNLOAD, ");
337 case I2O_CMD_SW_UPLOAD:
338 printk(KERN_DEBUG "EXEC_SW_UPLOAD, ");
340 case I2O_CMD_SW_REMOVE:
341 printk(KERN_DEBUG "EXEC_SW_REMOVE, ");
343 case I2O_CMD_SYS_ENABLE:
344 printk(KERN_DEBUG "EXEC_SYS_ENABLE, ");
346 case I2O_CMD_SYS_MODIFY:
347 printk(KERN_DEBUG "EXEC_SYS_MODIFY, ");
349 case I2O_CMD_SYS_QUIESCE:
350 printk(KERN_DEBUG "EXEC_SYS_QUIESCE, ");
352 case I2O_CMD_SYS_TAB_SET:
353 printk(KERN_DEBUG "EXEC_SYS_TAB_SET, ");
356 printk(KERN_DEBUG "Cmd = %#02x, ", cmd);
360 void i2o_debug_state(struct i2o_controller *c)
362 printk(KERN_INFO "%s: State = ", c->name);
363 switch (((i2o_status_block *) c->status_block.virt)->iop_state) {
365 printk(KERN_DEBUG "INIT\n");
368 printk(KERN_DEBUG "RESET\n");
371 printk(KERN_DEBUG "HOLD\n");
374 printk(KERN_DEBUG "READY\n");
377 printk(KERN_DEBUG "OPERATIONAL\n");
380 printk(KERN_DEBUG "FAILED\n");
383 printk(KERN_DEBUG "FAULTED\n");
386 printk(KERN_DEBUG "%x (unknown !!)\n",
387 ((i2o_status_block *) c->status_block.virt)->iop_state);
391 void i2o_dump_hrt(struct i2o_controller *c)
393 u32 *rows = (u32 *) c->hrt.virt;
394 u8 *p = (u8 *) c->hrt.virt;
403 "%s: HRT table for controller is too new a version.\n",
408 count = p[0] | (p[1] << 8);
411 printk(KERN_INFO "%s: HRT has %d entries of %d bytes each.\n",
412 c->name, count, length << 2);
416 for (i = 0; i < count; i++) {
417 printk(KERN_INFO "Adapter %08X: ", rows[0]);
418 p = (u8 *) (rows + 1);
419 d = (u8 *) (rows + 2);
420 state = p[1] << 8 | p[0];
422 printk(KERN_DEBUG "TID %04X:[", state & 0xFFF);
424 if (state & (1 << 0))
425 printk(KERN_DEBUG "H"); /* Hidden */
426 if (state & (1 << 2)) {
427 printk(KERN_DEBUG "P"); /* Present */
428 if (state & (1 << 1))
429 printk(KERN_DEBUG "C"); /* Controlled */
432 printk(KERN_DEBUG "*"); /* Hard */
434 printk(KERN_DEBUG "]:");
436 switch (p[3] & 0xFFFF) {
438 /* Adapter private bus - easy */
440 "Local bus %d: I/O at 0x%04X Mem 0x%08X", p[2],
441 d[1] << 8 | d[0], *(u32 *) (d + 4));
446 "ISA %d: CSN %d I/O at 0x%04X Mem 0x%08X", p[2],
447 d[2], d[1] << 8 | d[0], *(u32 *) (d + 4));
450 case 2: /* EISA bus */
452 "EISA %d: Slot %d I/O at 0x%04X Mem 0x%08X",
453 p[2], d[3], d[1] << 8 | d[0], *(u32 *) (d + 4));
456 case 3: /* MCA bus */
458 "MCA %d: Slot %d I/O at 0x%04X Mem 0x%08X", p[2],
459 d[3], d[1] << 8 | d[0], *(u32 *) (d + 4));
462 case 4: /* PCI bus */
464 "PCI %d: Bus %d Device %d Function %d", p[2],
468 case 0x80: /* Other */
470 printk(KERN_DEBUG "Unsupported bus type.");
473 printk(KERN_DEBUG "\n");
478 EXPORT_SYMBOL(i2o_dump_message);