1 #include <linux/config.h>
2 #include <linux/module.h>
3 #include <linux/kernel.h>
7 extern struct i2o_driver
**i2o_drivers
;
8 extern unsigned int i2o_max_drivers
;
9 static void i2o_report_util_cmd(u8 cmd
);
10 static void i2o_report_exec_cmd(u8 cmd
);
11 static void i2o_report_fail_status(u8 req_status
, u32
* msg
);
12 static void i2o_report_common_status(u8 req_status
);
13 static void i2o_report_common_dsc(u16 detailed_status
);
16 * Used for error reporting/debugging purposes.
17 * Report Cmd name, Request status, Detailed Status.
19 void i2o_report_status(const char *severity
, const char *str
,
20 struct i2o_message
*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)];
28 if (cmd
== I2O_CMD_UTIL_EVT_REGISTER
)
29 return; // No status in this reply
31 printk(KERN_DEBUG
"%s%s: ", severity
, str
);
33 if (cmd
< 0x1F) // Utility cmd
34 i2o_report_util_cmd(cmd
);
36 else if (cmd
>= 0xA0 && cmd
<= 0xEF) // Executive cmd
37 i2o_report_exec_cmd(cmd
);
39 printk(KERN_DEBUG
"Cmd = %0#2x, ", cmd
); // Other cmds
41 if (msg
[0] & MSG_FAIL
) {
42 i2o_report_fail_status(req_status
, msg
);
46 i2o_report_common_status(req_status
);
48 if (cmd
< 0x1F || (cmd
>= 0xA0 && cmd
<= 0xEF))
49 i2o_report_common_dsc(detailed_status
);
51 printk(KERN_DEBUG
" / DetailedStatus = %0#4x.\n",
55 /* Used to dump a message to syslog during debugging */
56 void i2o_dump_message(struct i2o_message
*m
)
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
]);
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.
73 static void i2o_report_fail_status(u8 req_status
, u32
* msg
)
75 static char *FAIL_STATUS
[] = {
76 "0x80", /* not used */
77 "SERVICE_SUSPENDED", /* 0x81 */
78 "SERVICE_TERMINATED", /* 0x82 */
90 "INVALID_INITIATOR_ID",
91 "INVALID_INITIATOR_CONTEX", /* 0x8F */
92 "UNKNOWN_FAILURE" /* 0xFF */
95 if (req_status
== I2O_FSC_TRANSPORT_UNKNOWN_FAILURE
)
96 printk(KERN_DEBUG
"TRANSPORT_UNKNOWN_FAILURE (%0#2x)\n.",
99 printk(KERN_DEBUG
"TRANSPORT_%s.\n",
100 FAIL_STATUS
[req_status
& 0x0F]);
102 /* Dump some details */
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);
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))
123 "(Congestion), resources temporarily not available;"
124 "do not retry immediately.\n");
128 * Used for error reporting/debugging purposes.
129 * Following reply status are common to all classes.
131 static void i2o_report_common_status(u8 req_status
)
133 static char *REPLY_STATUS
[] = {
136 "ABORT_NO_DATA_TRANSFER",
137 "ABORT_PARTIAL_TRANSFER",
139 "ERROR_NO_DATA_TRANSFER",
140 "ERROR_PARTIAL_TRANSFER",
141 "PROCESS_ABORT_DIRTY",
142 "PROCESS_ABORT_NO_DATA_TRANSFER",
143 "PROCESS_ABORT_PARTIAL_TRANSFER",
148 if (req_status
>= ARRAY_SIZE(REPLY_STATUS
))
149 printk(KERN_DEBUG
"RequestStatus = %0#2x", req_status
);
151 printk(KERN_DEBUG
"%s", REPLY_STATUS
[req_status
]);
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.
159 static void i2o_report_common_dsc(u16 detailed_status
)
161 static char *COMMON_DSC
[] = {
168 "INSUFFICIENT_RESOURCE_SOFT",
169 "INSUFFICIENT_RESOURCE_HARD",
171 "CHAIN_BUFFER_TOO_LARGE",
172 "UNSUPPORTED_FUNCTION",
175 "INAPPROPRIATE_FUNCTION",
176 "INVALID_INITIATOR_ADDRESS",
177 "INVALID_MESSAGE_FLAGS",
181 "INVALID_TARGET_ADDRESS",
188 "UNSUPPORTED_VERSION",
190 "DEVICE_NOT_AVAILABLE"
193 if (detailed_status
> I2O_DSC_DEVICE_NOT_AVAILABLE
)
194 printk(KERN_DEBUG
" / DetailedStatus = %0#4x.\n",
197 printk(KERN_DEBUG
" / %s.\n", COMMON_DSC
[detailed_status
]);
201 * Used for error reporting/debugging purposes
203 static void i2o_report_util_cmd(u8 cmd
)
206 case I2O_CMD_UTIL_NOP
:
207 printk(KERN_DEBUG
"UTIL_NOP, ");
209 case I2O_CMD_UTIL_ABORT
:
210 printk(KERN_DEBUG
"UTIL_ABORT, ");
212 case I2O_CMD_UTIL_CLAIM
:
213 printk(KERN_DEBUG
"UTIL_CLAIM, ");
215 case I2O_CMD_UTIL_RELEASE
:
216 printk(KERN_DEBUG
"UTIL_CLAIM_RELEASE, ");
218 case I2O_CMD_UTIL_CONFIG_DIALOG
:
219 printk(KERN_DEBUG
"UTIL_CONFIG_DIALOG, ");
221 case I2O_CMD_UTIL_DEVICE_RESERVE
:
222 printk(KERN_DEBUG
"UTIL_DEVICE_RESERVE, ");
224 case I2O_CMD_UTIL_DEVICE_RELEASE
:
225 printk(KERN_DEBUG
"UTIL_DEVICE_RELEASE, ");
227 case I2O_CMD_UTIL_EVT_ACK
:
228 printk(KERN_DEBUG
"UTIL_EVENT_ACKNOWLEDGE, ");
230 case I2O_CMD_UTIL_EVT_REGISTER
:
231 printk(KERN_DEBUG
"UTIL_EVENT_REGISTER, ");
233 case I2O_CMD_UTIL_LOCK
:
234 printk(KERN_DEBUG
"UTIL_LOCK, ");
236 case I2O_CMD_UTIL_LOCK_RELEASE
:
237 printk(KERN_DEBUG
"UTIL_LOCK_RELEASE, ");
239 case I2O_CMD_UTIL_PARAMS_GET
:
240 printk(KERN_DEBUG
"UTIL_PARAMS_GET, ");
242 case I2O_CMD_UTIL_PARAMS_SET
:
243 printk(KERN_DEBUG
"UTIL_PARAMS_SET, ");
245 case I2O_CMD_UTIL_REPLY_FAULT_NOTIFY
:
246 printk(KERN_DEBUG
"UTIL_REPLY_FAULT_NOTIFY, ");
249 printk(KERN_DEBUG
"Cmd = %0#2x, ", cmd
);
254 * Used for error reporting/debugging purposes
256 static void i2o_report_exec_cmd(u8 cmd
)
259 case I2O_CMD_ADAPTER_ASSIGN
:
260 printk(KERN_DEBUG
"EXEC_ADAPTER_ASSIGN, ");
262 case I2O_CMD_ADAPTER_READ
:
263 printk(KERN_DEBUG
"EXEC_ADAPTER_READ, ");
265 case I2O_CMD_ADAPTER_RELEASE
:
266 printk(KERN_DEBUG
"EXEC_ADAPTER_RELEASE, ");
268 case I2O_CMD_BIOS_INFO_SET
:
269 printk(KERN_DEBUG
"EXEC_BIOS_INFO_SET, ");
271 case I2O_CMD_BOOT_DEVICE_SET
:
272 printk(KERN_DEBUG
"EXEC_BOOT_DEVICE_SET, ");
274 case I2O_CMD_CONFIG_VALIDATE
:
275 printk(KERN_DEBUG
"EXEC_CONFIG_VALIDATE, ");
277 case I2O_CMD_CONN_SETUP
:
278 printk(KERN_DEBUG
"EXEC_CONN_SETUP, ");
280 case I2O_CMD_DDM_DESTROY
:
281 printk(KERN_DEBUG
"EXEC_DDM_DESTROY, ");
283 case I2O_CMD_DDM_ENABLE
:
284 printk(KERN_DEBUG
"EXEC_DDM_ENABLE, ");
286 case I2O_CMD_DDM_QUIESCE
:
287 printk(KERN_DEBUG
"EXEC_DDM_QUIESCE, ");
289 case I2O_CMD_DDM_RESET
:
290 printk(KERN_DEBUG
"EXEC_DDM_RESET, ");
292 case I2O_CMD_DDM_SUSPEND
:
293 printk(KERN_DEBUG
"EXEC_DDM_SUSPEND, ");
295 case I2O_CMD_DEVICE_ASSIGN
:
296 printk(KERN_DEBUG
"EXEC_DEVICE_ASSIGN, ");
298 case I2O_CMD_DEVICE_RELEASE
:
299 printk(KERN_DEBUG
"EXEC_DEVICE_RELEASE, ");
301 case I2O_CMD_HRT_GET
:
302 printk(KERN_DEBUG
"EXEC_HRT_GET, ");
304 case I2O_CMD_ADAPTER_CLEAR
:
305 printk(KERN_DEBUG
"EXEC_IOP_CLEAR, ");
307 case I2O_CMD_ADAPTER_CONNECT
:
308 printk(KERN_DEBUG
"EXEC_IOP_CONNECT, ");
310 case I2O_CMD_ADAPTER_RESET
:
311 printk(KERN_DEBUG
"EXEC_IOP_RESET, ");
313 case I2O_CMD_LCT_NOTIFY
:
314 printk(KERN_DEBUG
"EXEC_LCT_NOTIFY, ");
316 case I2O_CMD_OUTBOUND_INIT
:
317 printk(KERN_DEBUG
"EXEC_OUTBOUND_INIT, ");
319 case I2O_CMD_PATH_ENABLE
:
320 printk(KERN_DEBUG
"EXEC_PATH_ENABLE, ");
322 case I2O_CMD_PATH_QUIESCE
:
323 printk(KERN_DEBUG
"EXEC_PATH_QUIESCE, ");
325 case I2O_CMD_PATH_RESET
:
326 printk(KERN_DEBUG
"EXEC_PATH_RESET, ");
328 case I2O_CMD_STATIC_MF_CREATE
:
329 printk(KERN_DEBUG
"EXEC_STATIC_MF_CREATE, ");
331 case I2O_CMD_STATIC_MF_RELEASE
:
332 printk(KERN_DEBUG
"EXEC_STATIC_MF_RELEASE, ");
334 case I2O_CMD_STATUS_GET
:
335 printk(KERN_DEBUG
"EXEC_STATUS_GET, ");
337 case I2O_CMD_SW_DOWNLOAD
:
338 printk(KERN_DEBUG
"EXEC_SW_DOWNLOAD, ");
340 case I2O_CMD_SW_UPLOAD
:
341 printk(KERN_DEBUG
"EXEC_SW_UPLOAD, ");
343 case I2O_CMD_SW_REMOVE
:
344 printk(KERN_DEBUG
"EXEC_SW_REMOVE, ");
346 case I2O_CMD_SYS_ENABLE
:
347 printk(KERN_DEBUG
"EXEC_SYS_ENABLE, ");
349 case I2O_CMD_SYS_MODIFY
:
350 printk(KERN_DEBUG
"EXEC_SYS_MODIFY, ");
352 case I2O_CMD_SYS_QUIESCE
:
353 printk(KERN_DEBUG
"EXEC_SYS_QUIESCE, ");
355 case I2O_CMD_SYS_TAB_SET
:
356 printk(KERN_DEBUG
"EXEC_SYS_TAB_SET, ");
359 printk(KERN_DEBUG
"Cmd = %#02x, ", cmd
);
363 void i2o_debug_state(struct i2o_controller
*c
)
365 printk(KERN_INFO
"%s: State = ", c
->name
);
366 switch (((i2o_status_block
*) c
->status_block
.virt
)->iop_state
) {
368 printk(KERN_DEBUG
"INIT\n");
371 printk(KERN_DEBUG
"RESET\n");
374 printk(KERN_DEBUG
"HOLD\n");
377 printk(KERN_DEBUG
"READY\n");
380 printk(KERN_DEBUG
"OPERATIONAL\n");
383 printk(KERN_DEBUG
"FAILED\n");
386 printk(KERN_DEBUG
"FAULTED\n");
389 printk(KERN_DEBUG
"%x (unknown !!)\n",
390 ((i2o_status_block
*) c
->status_block
.virt
)->iop_state
);
394 void i2o_dump_hrt(struct i2o_controller
*c
)
396 u32
*rows
= (u32
*) c
->hrt
.virt
;
397 u8
*p
= (u8
*) c
->hrt
.virt
;
406 "%s: HRT table for controller is too new a version.\n",
411 count
= p
[0] | (p
[1] << 8);
414 printk(KERN_INFO
"%s: HRT has %d entries of %d bytes each.\n",
415 c
->name
, count
, length
<< 2);
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];
425 printk(KERN_DEBUG
"TID %04X:[", state
& 0xFFF);
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 */
435 printk(KERN_DEBUG
"*"); /* Hard */
437 printk(KERN_DEBUG
"]:");
439 switch (p
[3] & 0xFFFF) {
441 /* Adapter private bus - easy */
443 "Local bus %d: I/O at 0x%04X Mem 0x%08X", p
[2],
444 d
[1] << 8 | d
[0], *(u32
*) (d
+ 4));
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));
453 case 2: /* EISA bus */
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));
459 case 3: /* MCA bus */
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));
465 case 4: /* PCI bus */
467 "PCI %d: Bus %d Device %d Function %d", p
[2],
471 case 0x80: /* Other */
473 printk(KERN_DEBUG
"Unsupported bus type.");
476 printk(KERN_DEBUG
"\n");
481 EXPORT_SYMBOL(i2o_dump_message
);