2 * ASCII values for a number of symbolic constants, printing functions,
4 * Additions for SCSI 2 and Linux 2.2.x by D. Gilbert (990422)
5 * Additions for SCSI 3+ (SPC-3 T10/1416-D Rev 07 3 May 2002)
6 * by D. Gilbert and aeb (20020609)
9 #include <linux/module.h>
11 #include <linux/config.h>
12 #include <linux/blkdev.h>
13 #include <linux/kernel.h>
17 #define CONST_COMMAND 0x01
18 #define CONST_STATUS 0x02
19 #define CONST_SENSE 0x04
20 #define CONST_XSENSE 0x08
21 #define CONST_CMND 0x10
22 #define CONST_MSG 0x20
23 #define CONST_HOST 0x40
24 #define CONST_DRIVER 0x80
26 static const char unknown[] = "UNKNOWN";
28 #ifdef CONFIG_SCSI_CONSTANTS
32 #define CONSTANTS (CONST_COMMAND | CONST_STATUS | CONST_SENSE | CONST_XSENSE \
33 | CONST_CMND | CONST_MSG | CONST_HOST | CONST_DRIVER)
36 #if (CONSTANTS & CONST_COMMAND)
37 static const char * group_0_commands[] = {
38 /* 00-03 */ "Test Unit Ready", "Rezero Unit", unknown, "Request Sense",
39 /* 04-07 */ "Format Unit", "Read Block Limits", unknown, "Reasssign Blocks",
40 /* 08-0d */ "Read (6)", unknown, "Write (6)", "Seek (6)", unknown, unknown,
41 /* 0e-12 */ unknown, "Read Reverse", "Write Filemarks", "Space", "Inquiry",
42 /* 13-16 */ "Verify", "Recover Buffered Data", "Mode Select", "Reserve",
43 /* 17-1b */ "Release", "Copy", "Erase", "Mode Sense", "Start/Stop Unit",
44 /* 1c-1d */ "Receive Diagnostic", "Send Diagnostic",
45 /* 1e-1f */ "Prevent/Allow Medium Removal", unknown,
49 static const char *group_1_commands[] = {
50 /* 20-22 */ unknown, unknown, unknown,
51 /* 23-28 */ unknown, "Define window parameters", "Read Capacity",
52 unknown, unknown, "Read (10)",
53 /* 29-2d */ "Read Generation", "Write (10)", "Seek (10)", "Erase",
55 /* 2e-31 */ "Write Verify","Verify", "Search High", "Search Equal",
56 /* 32-34 */ "Search Low", "Set Limits", "Prefetch or Read Position",
57 /* 35-37 */ "Synchronize Cache","Lock/Unlock Cache", "Read Defect Data",
58 /* 38-3c */ "Medium Scan", "Compare", "Copy Verify", "Write Buffer",
60 /* 3d-3f */ "Update Block", "Read Long", "Write Long",
64 static const char *group_2_commands[] = {
65 /* 40-41 */ "Change Definition", "Write Same",
66 /* 42-48 */ "Read sub-channel", "Read TOC", "Read header",
67 "Play audio (10)", "Get configuration", "Play audio msf",
68 "Play audio track/index",
69 /* 49-4f */ "Play track relative (10)", "Get event status notification",
70 "Pause/resume", "Log Select", "Log Sense", "Stop play/scan",
72 /* 50-55 */ "Xdwrite", "Xpwrite, Read disk info", "Xdread, Read track info",
73 "Reserve track", "Send OPC onfo", "Mode Select (10)",
74 /* 56-5b */ "Reserve (10)", "Release (10)", "Repair track", "Read master cue",
75 "Mode Sense (10)", "Close track/session",
76 /* 5c-5f */ "Read buffer capacity", "Send cue sheet", "Persistent reserve in",
77 "Persistent reserve out",
81 /* The following are 16 byte commands in group 4 */
82 static const char *group_4_commands[] = {
83 /* 80-84 */ "Xdwrite (16)", "Rebuild (16)", "Regenerate (16)", "Extended copy",
84 "Receive copy results",
85 /* 85-89 */ "Memory Export In (16)", "Access control in", "Access control out",
86 "Read (16)", "Memory Export Out (16)",
87 /* 8a-8f */ "Write (16)", unknown, "Read attributes", "Write attributes",
88 "Write and verify (16)", "Verify (16)",
89 /* 90-94 */ "Pre-fetch (16)", "Synchronize cache (16)",
90 "Lock/unlock cache (16)", "Write same (16)", unknown,
91 /* 95-99 */ unknown, unknown, unknown, unknown, unknown,
92 /* 9a-9f */ unknown, unknown, unknown, unknown, "Service action in",
96 /* The following are 12 byte commands in group 5 */
97 static const char *group_5_commands[] = {
98 /* a0-a5 */ "Report luns", "Blank", "Send event", "Maintenance (in)",
99 "Maintenance (out)", "Move medium/play audio(12)",
100 /* a6-a9 */ "Exchange medium", "Move medium attached", "Read(12)",
101 "Play track relative(12)",
102 /* aa-ae */ "Write(12)", unknown, "Erase(12), Get Performance",
103 "Read DVD structure", "Write and verify(12)",
104 /* af-b1 */ "Verify(12)", "Search data high(12)", "Search data equal(12)",
105 /* b2-b4 */ "Search data low(12)", "Set limits(12)",
106 "Read element status attached",
107 /* b5-b6 */ "Request volume element address", "Send volume tag, set streaming",
108 /* b7-b9 */ "Read defect data(12)", "Read element status", "Read CD msf",
109 /* ba-bc */ "Redundancy group (in), Scan",
110 "Redundancy group (out), Set cd-rom speed", "Spare (in), Play cd",
111 /* bd-bf */ "Spare (out), Mechanism status", "Volume set (in), Read cd",
112 "Volume set (out), Send DVD structure",
117 #define group(opcode) (((opcode) >> 5) & 7)
119 #define RESERVED_GROUP 0
120 #define VENDOR_GROUP 1
122 static const char **commands[] = {
123 group_0_commands, group_1_commands, group_2_commands,
124 (const char **) RESERVED_GROUP, group_4_commands,
125 group_5_commands, (const char **) VENDOR_GROUP,
126 (const char **) VENDOR_GROUP
129 static const char reserved[] = "RESERVED";
130 static const char vendor[] = "VENDOR SPECIFIC";
132 static void print_opcode(int opcode) {
133 const char **table = commands[ group(opcode) ];
134 switch ((unsigned long) table) {
136 printk("%s(0x%02x) ", reserved, opcode);
139 printk("%s(0x%02x) ", vendor, opcode);
142 if (table[opcode & 0x1f] != unknown)
143 printk("%s ",table[opcode & 0x1f]);
145 printk("%s(0x%02x) ", unknown, opcode);
149 #else /* CONST & CONST_COMMAND */
150 static void print_opcode(int opcode) {
151 printk("0x%02x ", opcode);
155 void print_command (unsigned char *command) {
157 print_opcode(command[0]);
158 for ( i = 1, s = COMMAND_SIZE(command[0]); i < s; ++i)
159 printk("%02x ", command[i]);
165 * print_status - print scsi status description
166 * @scsi_status: scsi status value
168 * If the status is recognized, the description is printed.
169 * Otherwise "Unknown status" is output. No trailing space.
170 * If CONFIG_SCSI_CONSTANTS is not set, then print status in hex
171 * (e.g. "0x2" for Check Condition).
174 print_status(unsigned char scsi_status) {
175 #if (CONSTANTS & CONST_STATUS)
178 switch (scsi_status) {
179 case 0: ccp = "Good"; break;
180 case 0x2: ccp = "Check Condition"; break;
181 case 0x4: ccp = "Condition Met"; break;
182 case 0x8: ccp = "Busy"; break;
183 case 0x10: ccp = "Intermediate"; break;
184 case 0x14: ccp = "Intermediate-Condition Met"; break;
185 case 0x18: ccp = "Reservation Conflict"; break;
186 case 0x22: ccp = "Command Terminated"; break; /* obsolete */
187 case 0x28: ccp = "Task set Full"; break; /* was: Queue Full */
188 case 0x30: ccp = "ACA Active"; break;
189 case 0x40: ccp = "Task Aborted"; break;
190 default: ccp = "Unknown status";
194 printk("0x%0x", scsi_status);
198 #if (CONSTANTS & CONST_XSENSE)
201 unsigned short code12; /* 0x0302 looks better than 0x03,0x02 */
205 static struct error_info additional[] =
207 {0x0000, "No additional sense information"},
208 {0x0001, "Filemark detected"},
209 {0x0002, "End-of-partition/medium detected"},
210 {0x0003, "Setmark detected"},
211 {0x0004, "Beginning-of-partition/medium detected"},
212 {0x0005, "End-of-data detected"},
213 {0x0006, "I/O process terminated"},
214 {0x0011, "Audio play operation in progress"},
215 {0x0012, "Audio play operation paused"},
216 {0x0013, "Audio play operation successfully completed"},
217 {0x0014, "Audio play operation stopped due to error"},
218 {0x0015, "No current audio status to return"},
219 {0x0016, "Operation in progress"},
220 {0x0017, "Cleaning requested"},
221 {0x0018, "Erase operation in progress"},
222 {0x0019, "Locate operation in progress"},
223 {0x001A, "Rewind operation in progress"},
224 {0x001B, "Set capacity operation in progress"},
225 {0x001C, "Verify operation in progress"},
227 {0x0100, "No index/sector signal"},
229 {0x0200, "No seek complete"},
231 {0x0300, "Peripheral device write fault"},
232 {0x0301, "No write current"},
233 {0x0302, "Excessive write errors"},
235 {0x0400, "Logical unit not ready, cause not reportable"},
236 {0x0401, "Logical unit is in process of becoming ready"},
237 {0x0402, "Logical unit not ready, initializing cmd. required"},
238 {0x0403, "Logical unit not ready, manual intervention required"},
239 {0x0404, "Logical unit not ready, format in progress"},
240 {0x0405, "Logical unit not ready, rebuild in progress"},
241 {0x0406, "Logical unit not ready, recalculation in progress"},
242 {0x0407, "Logical unit not ready, operation in progress"},
243 {0x0408, "Logical unit not ready, long write in progress"},
244 {0x0409, "Logical unit not ready, self-test in progress"},
245 {0x040A, "Logical unit not accessible, asymmetric access state "
247 {0x040B, "Logical unit not accessible, target port in standby state"},
248 {0x040C, "Logical unit not accessible, target port in unavailable "
250 {0x0410, "Logical unit not ready, auxiliary memory not accessible"},
252 {0x0500, "Logical unit does not respond to selection"},
254 {0x0600, "No reference position found"},
256 {0x0700, "Multiple peripheral devices selected"},
258 {0x0800, "Logical unit communication failure"},
259 {0x0801, "Logical unit communication time-out"},
260 {0x0802, "Logical unit communication parity error"},
261 {0x0803, "Logical unit communication CRC error (Ultra-DMA/32)"},
262 {0x0804, "Unreachable copy target"},
264 {0x0900, "Track following error"},
265 {0x0901, "Tracking servo failure"},
266 {0x0902, "Focus servo failure"},
267 {0x0903, "Spindle servo failure"},
268 {0x0904, "Head select fault"},
270 {0x0A00, "Error log overflow"},
273 {0x0B01, "Warning - specified temperature exceeded"},
274 {0x0B02, "Warning - enclosure degraded"},
276 {0x0C00, "Write error"},
277 {0x0C01, "Write error - recovered with auto reallocation"},
278 {0x0C02, "Write error - auto reallocation failed"},
279 {0x0C03, "Write error - recommend reassignment"},
280 {0x0C04, "Compression check miscompare error"},
281 {0x0C05, "Data expansion occurred during compression"},
282 {0x0C06, "Block not compressible"},
283 {0x0C07, "Write error - recovery needed"},
284 {0x0C08, "Write error - recovery failed"},
285 {0x0C09, "Write error - loss of streaming"},
286 {0x0C0A, "Write error - padding blocks added"},
287 {0x0C0B, "Auxiliary memory write error"},
288 {0x0C0C, "Write error - unexpected unsolicited data"},
289 {0x0C0D, "Write error - not enough unsolicited data"},
291 {0x0D00, "Error detected by third party temporary initiator"},
292 {0x0D01, "Third party device failure"},
293 {0x0D02, "Copy target device not reachable"},
294 {0x0D03, "Incorrect copy target device type"},
295 {0x0D04, "Copy target device data underrun"},
296 {0x0D05, "Copy target device data overrun"},
298 {0x1000, "Id CRC or ECC error"},
300 {0x1100, "Unrecovered read error"},
301 {0x1101, "Read retries exhausted"},
302 {0x1102, "Error too long to correct"},
303 {0x1103, "Multiple read errors"},
304 {0x1104, "Unrecovered read error - auto reallocate failed"},
305 {0x1105, "L-EC uncorrectable error"},
306 {0x1106, "CIRC unrecovered error"},
307 {0x1107, "Data re-synchronization error"},
308 {0x1108, "Incomplete block read"},
309 {0x1109, "No gap found"},
310 {0x110A, "Miscorrected error"},
311 {0x110B, "Unrecovered read error - recommend reassignment"},
312 {0x110C, "Unrecovered read error - recommend rewrite the data"},
313 {0x110D, "De-compression CRC error"},
314 {0x110E, "Cannot decompress using declared algorithm"},
315 {0x110F, "Error reading UPC/EAN number"},
316 {0x1110, "Error reading ISRC number"},
317 {0x1111, "Read error - loss of streaming"},
318 {0x1112, "Auxiliary memory read error"},
319 {0x1113, "Read error - failed retransmission request"},
321 {0x1200, "Address mark not found for id field"},
323 {0x1300, "Address mark not found for data field"},
325 {0x1400, "Recorded entity not found"},
326 {0x1401, "Record not found"},
327 {0x1402, "Filemark or setmark not found"},
328 {0x1403, "End-of-data not found"},
329 {0x1404, "Block sequence error"},
330 {0x1405, "Record not found - recommend reassignment"},
331 {0x1406, "Record not found - data auto-reallocated"},
332 {0x1407, "Locate operation failure"},
334 {0x1500, "Random positioning error"},
335 {0x1501, "Mechanical positioning error"},
336 {0x1502, "Positioning error detected by read of medium"},
338 {0x1600, "Data synchronization mark error"},
339 {0x1601, "Data sync error - data rewritten"},
340 {0x1602, "Data sync error - recommend rewrite"},
341 {0x1603, "Data sync error - data auto-reallocated"},
342 {0x1604, "Data sync error - recommend reassignment"},
344 {0x1700, "Recovered data with no error correction applied"},
345 {0x1701, "Recovered data with retries"},
346 {0x1702, "Recovered data with positive head offset"},
347 {0x1703, "Recovered data with negative head offset"},
348 {0x1704, "Recovered data with retries and/or circ applied"},
349 {0x1705, "Recovered data using previous sector id"},
350 {0x1706, "Recovered data without ECC - data auto-reallocated"},
351 {0x1707, "Recovered data without ECC - recommend reassignment"},
352 {0x1708, "Recovered data without ECC - recommend rewrite"},
353 {0x1709, "Recovered data without ECC - data rewritten"},
355 {0x1800, "Recovered data with error correction applied"},
356 {0x1801, "Recovered data with error corr. & retries applied"},
357 {0x1802, "Recovered data - data auto-reallocated"},
358 {0x1803, "Recovered data with CIRC"},
359 {0x1804, "Recovered data with L-EC"},
360 {0x1805, "Recovered data - recommend reassignment"},
361 {0x1806, "Recovered data - recommend rewrite"},
362 {0x1807, "Recovered data with ECC - data rewritten"},
363 {0x1808, "Recovered data with linking"},
365 {0x1900, "Defect list error"},
366 {0x1901, "Defect list not available"},
367 {0x1902, "Defect list error in primary list"},
368 {0x1903, "Defect list error in grown list"},
370 {0x1A00, "Parameter list length error"},
372 {0x1B00, "Synchronous data transfer error"},
374 {0x1C00, "Defect list not found"},
375 {0x1C01, "Primary defect list not found"},
376 {0x1C02, "Grown defect list not found"},
378 {0x1D00, "Miscompare during verify operation"},
380 {0x1E00, "Recovered id with ECC correction"},
382 {0x1F00, "Partial defect list transfer"},
384 {0x2000, "Invalid command operation code"},
385 {0x2001, "Access denied - initiator pending-enrolled"},
386 {0x2002, "Access denied - no access rights"},
387 {0x2003, "Access denied - invalid mgmt id key"},
388 {0x2004, "Illegal command while in write capable state"},
389 {0x2005, "Obsolete"},
390 {0x2006, "Illegal command while in explicit address mode"},
391 {0x2007, "Illegal command while in implicit address mode"},
392 {0x2008, "Access denied - enrollment conflict"},
393 {0x2009, "Access denied - invalid LU identifier"},
394 {0x200A, "Access denied - invalid proxy token"},
395 {0x200B, "Access denied - ACL LUN conflict"},
397 {0x2100, "Logical block address out of range"},
398 {0x2101, "Invalid element address"},
399 {0x2102, "Invalid address for write"},
401 {0x2200, "Illegal function (use 20 00, 24 00, or 26 00)"},
403 {0x2400, "Invalid field in cdb"},
404 {0x2401, "CDB decryption error"},
405 {0x2402, "Obsolete"},
406 {0x2403, "Obsolete"},
408 {0x2500, "Logical unit not supported"},
410 {0x2600, "Invalid field in parameter list"},
411 {0x2601, "Parameter not supported"},
412 {0x2602, "Parameter value invalid"},
413 {0x2603, "Threshold parameters not supported"},
414 {0x2604, "Invalid release of persistent reservation"},
415 {0x2605, "Data decryption error"},
416 {0x2606, "Too many target descriptors"},
417 {0x2607, "Unsupported target descriptor type code"},
418 {0x2608, "Too many segment descriptors"},
419 {0x2609, "Unsupported segment descriptor type code"},
420 {0x260A, "Unexpected inexact segment"},
421 {0x260B, "Inline data length exceeded"},
422 {0x260C, "Invalid operation for copy source or destination"},
423 {0x260D, "Copy segment granularity violation"},
425 {0x2700, "Write protected"},
426 {0x2701, "Hardware write protected"},
427 {0x2702, "Logical unit software write protected"},
428 {0x2703, "Associated write protect"},
429 {0x2704, "Persistent write protect"},
430 {0x2705, "Permanent write protect"},
431 {0x2706, "Conditional write protect"},
433 {0x2800, "Not ready to ready change, medium may have changed"},
434 {0x2801, "Import or export element accessed"},
436 {0x2900, "Power on, reset, or bus device reset occurred"},
437 {0x2901, "Power on occurred"},
438 {0x2902, "Scsi bus reset occurred"},
439 {0x2903, "Bus device reset function occurred"},
440 {0x2904, "Device internal reset"},
441 {0x2905, "Transceiver mode changed to single-ended"},
442 {0x2906, "Transceiver mode changed to lvd"},
443 {0x2907, "I_T nexus loss occurred"},
445 {0x2A00, "Parameters changed"},
446 {0x2A01, "Mode parameters changed"},
447 {0x2A02, "Log parameters changed"},
448 {0x2A03, "Reservations preempted"},
449 {0x2A04, "Reservations released"},
450 {0x2A05, "Registrations preempted"},
451 {0x2A06, "Asymmetric access state changed"},
452 {0x2A07, "Implicit asymmetric access state transition failed"},
454 {0x2B00, "Copy cannot execute since host cannot disconnect"},
456 {0x2C00, "Command sequence error"},
457 {0x2C01, "Too many windows specified"},
458 {0x2C02, "Invalid combination of windows specified"},
459 {0x2C03, "Current program area is not empty"},
460 {0x2C04, "Current program area is empty"},
461 {0x2C05, "Illegal power condition request"},
462 {0x2C06, "Persistent prevent conflict"},
463 {0x2C07, "Previous busy status"},
464 {0x2C08, "Previous task set full status"},
465 {0x2C09, "Previous reservation conflict status"},
467 {0x2D00, "Overwrite error on update in place"},
469 {0x2E00, "Insufficient time for operation"},
471 {0x2F00, "Commands cleared by another initiator"},
473 {0x3000, "Incompatible medium installed"},
474 {0x3001, "Cannot read medium - unknown format"},
475 {0x3002, "Cannot read medium - incompatible format"},
476 {0x3003, "Cleaning cartridge installed"},
477 {0x3004, "Cannot write medium - unknown format"},
478 {0x3005, "Cannot write medium - incompatible format"},
479 {0x3006, "Cannot format medium - incompatible medium"},
480 {0x3007, "Cleaning failure"},
481 {0x3008, "Cannot write - application code mismatch"},
482 {0x3009, "Current session not fixated for append"},
483 {0x3010, "Medium not formatted"},
485 {0x3100, "Medium format corrupted"},
486 {0x3101, "Format command failed"},
487 {0x3102, "Zoned formatting failed due to spare linking"},
489 {0x3200, "No defect spare location available"},
490 {0x3201, "Defect list update failure"},
492 {0x3300, "Tape length error"},
494 {0x3400, "Enclosure failure"},
496 {0x3500, "Enclosure services failure"},
497 {0x3501, "Unsupported enclosure function"},
498 {0x3502, "Enclosure services unavailable"},
499 {0x3503, "Enclosure services transfer failure"},
500 {0x3504, "Enclosure services transfer refused"},
502 {0x3600, "Ribbon, ink, or toner failure"},
504 {0x3700, "Rounded parameter"},
506 {0x3800, "Event status notification"},
507 {0x3802, "Esn - power management class event"},
508 {0x3804, "Esn - media class event"},
509 {0x3806, "Esn - device busy class event"},
511 {0x3900, "Saving parameters not supported"},
513 {0x3A00, "Medium not present"},
514 {0x3A01, "Medium not present - tray closed"},
515 {0x3A02, "Medium not present - tray open"},
516 {0x3A03, "Medium not present - loadable"},
517 {0x3A04, "Medium not present - medium auxiliary memory accessible"},
519 {0x3B00, "Sequential positioning error"},
520 {0x3B01, "Tape position error at beginning-of-medium"},
521 {0x3B02, "Tape position error at end-of-medium"},
522 {0x3B03, "Tape or electronic vertical forms unit not ready"},
523 {0x3B04, "Slew failure"},
524 {0x3B05, "Paper jam"},
525 {0x3B06, "Failed to sense top-of-form"},
526 {0x3B07, "Failed to sense bottom-of-form"},
527 {0x3B08, "Reposition error"},
528 {0x3B09, "Read past end of medium"},
529 {0x3B0A, "Read past beginning of medium"},
530 {0x3B0B, "Position past end of medium"},
531 {0x3B0C, "Position past beginning of medium"},
532 {0x3B0D, "Medium destination element full"},
533 {0x3B0E, "Medium source element empty"},
534 {0x3B0F, "End of medium reached"},
535 {0x3B11, "Medium magazine not accessible"},
536 {0x3B12, "Medium magazine removed"},
537 {0x3B13, "Medium magazine inserted"},
538 {0x3B14, "Medium magazine locked"},
539 {0x3B15, "Medium magazine unlocked"},
540 {0x3B16, "Mechanical positioning or changer error"},
542 {0x3D00, "Invalid bits in identify message"},
544 {0x3E00, "Logical unit has not self-configured yet"},
545 {0x3E01, "Logical unit failure"},
546 {0x3E02, "Timeout on logical unit"},
547 {0x3E03, "Logical unit failed self-test"},
548 {0x3E04, "Logical unit unable to update self-test log"},
550 {0x3F00, "Target operating conditions have changed"},
551 {0x3F01, "Microcode has been changed"},
552 {0x3F02, "Changed operating definition"},
553 {0x3F03, "Inquiry data has changed"},
554 {0x3F04, "Component device attached"},
555 {0x3F05, "Device identifier changed"},
556 {0x3F06, "Redundancy group created or modified"},
557 {0x3F07, "Redundancy group deleted"},
558 {0x3F08, "Spare created or modified"},
559 {0x3F09, "Spare deleted"},
560 {0x3F0A, "Volume set created or modified"},
561 {0x3F0B, "Volume set deleted"},
562 {0x3F0C, "Volume set deassigned"},
563 {0x3F0D, "Volume set reassigned"},
564 {0x3F0E, "Reported luns data has changed"},
565 {0x3F0F, "Echo buffer overwritten"},
566 {0x3F10, "Medium loadable"},
567 {0x3F11, "Medium auxiliary memory accessible"},
570 {0x40NN, "Ram failure"},
571 {0x40NN, "Diagnostic failure on component nn"},
572 {0x41NN, "Data path failure"},
573 {0x42NN, "Power-on or self-test failure"},
576 {0x4300, "Message error"},
578 {0x4400, "Internal target failure"},
580 {0x4500, "Select or reselect failure"},
582 {0x4600, "Unsuccessful soft reset"},
584 {0x4700, "Scsi parity error"},
585 {0x4701, "Data phase CRC error detected"},
586 {0x4702, "Scsi parity error detected during st data phase"},
587 {0x4703, "Information unit CRC error detected"},
588 {0x4704, "Asynchronous information protection error detected"},
589 {0x4705, "Protocol service CRC error"},
591 {0x4800, "Initiator detected error message received"},
593 {0x4900, "Invalid message error"},
595 {0x4A00, "Command phase error"},
597 {0x4B00, "Data phase error"},
599 {0x4C00, "Logical unit failed self-configuration"},
602 {0x4DNN, "Tagged overlapped commands (nn = queue tag)"},
605 {0x4E00, "Overlapped commands attempted"},
607 {0x5000, "Write append error"},
608 {0x5001, "Write append position error"},
609 {0x5002, "Position error related to timing"},
611 {0x5100, "Erase failure"},
612 {0x5101, "Erase failure - incomplete erase operation detected"},
614 {0x5200, "Cartridge fault"},
616 {0x5300, "Media load or eject failed"},
617 {0x5301, "Unload tape failure"},
618 {0x5302, "Medium removal prevented"},
620 {0x5400, "Scsi to host system interface failure"},
622 {0x5500, "System resource failure"},
623 {0x5501, "System buffer full"},
624 {0x5502, "Insufficient reservation resources"},
625 {0x5503, "Insufficient resources"},
626 {0x5504, "Insufficient registration resources"},
627 {0x5505, "Insufficient access control resources"},
628 {0x5506, "Auxiliary memory out of space"},
630 {0x5700, "Unable to recover table-of-contents"},
632 {0x5800, "Generation does not exist"},
634 {0x5900, "Updated block read"},
636 {0x5A00, "Operator request or state change input"},
637 {0x5A01, "Operator medium removal request"},
638 {0x5A02, "Operator selected write protect"},
639 {0x5A03, "Operator selected write permit"},
641 {0x5B00, "Log exception"},
642 {0x5B01, "Threshold condition met"},
643 {0x5B02, "Log counter at maximum"},
644 {0x5B03, "Log list codes exhausted"},
646 {0x5C00, "Rpl status change"},
647 {0x5C01, "Spindles synchronized"},
648 {0x5C02, "Spindles not synchronized"},
650 {0x5D00, "Failure prediction threshold exceeded"},
651 {0x5D01, "Media failure prediction threshold exceeded"},
652 {0x5D02, "Logical unit failure prediction threshold exceeded"},
653 {0x5D03, "Spare area exhaustion prediction threshold exceeded"},
654 {0x5D10, "Hardware impending failure general hard drive failure"},
655 {0x5D11, "Hardware impending failure drive error rate too high"},
656 {0x5D12, "Hardware impending failure data error rate too high"},
657 {0x5D13, "Hardware impending failure seek error rate too high"},
658 {0x5D14, "Hardware impending failure too many block reassigns"},
659 {0x5D15, "Hardware impending failure access times too high"},
660 {0x5D16, "Hardware impending failure start unit times too high"},
661 {0x5D17, "Hardware impending failure channel parametrics"},
662 {0x5D18, "Hardware impending failure controller detected"},
663 {0x5D19, "Hardware impending failure throughput performance"},
664 {0x5D1A, "Hardware impending failure seek time performance"},
665 {0x5D1B, "Hardware impending failure spin-up retry count"},
666 {0x5D1C, "Hardware impending failure drive calibration retry count"},
667 {0x5D20, "Controller impending failure general hard drive failure"},
668 {0x5D21, "Controller impending failure drive error rate too high"},
669 {0x5D22, "Controller impending failure data error rate too high"},
670 {0x5D23, "Controller impending failure seek error rate too high"},
671 {0x5D24, "Controller impending failure too many block reassigns"},
672 {0x5D25, "Controller impending failure access times too high"},
673 {0x5D26, "Controller impending failure start unit times too high"},
674 {0x5D27, "Controller impending failure channel parametrics"},
675 {0x5D28, "Controller impending failure controller detected"},
676 {0x5D29, "Controller impending failure throughput performance"},
677 {0x5D2A, "Controller impending failure seek time performance"},
678 {0x5D2B, "Controller impending failure spin-up retry count"},
679 {0x5D2C, "Controller impending failure drive calibration retry count"},
680 {0x5D30, "Data channel impending failure general hard drive failure"},
681 {0x5D31, "Data channel impending failure drive error rate too high"},
682 {0x5D32, "Data channel impending failure data error rate too high"},
683 {0x5D33, "Data channel impending failure seek error rate too high"},
684 {0x5D34, "Data channel impending failure too many block reassigns"},
685 {0x5D35, "Data channel impending failure access times too high"},
686 {0x5D36, "Data channel impending failure start unit times too high"},
687 {0x5D37, "Data channel impending failure channel parametrics"},
688 {0x5D38, "Data channel impending failure controller detected"},
689 {0x5D39, "Data channel impending failure throughput performance"},
690 {0x5D3A, "Data channel impending failure seek time performance"},
691 {0x5D3B, "Data channel impending failure spin-up retry count"},
692 {0x5D3C, "Data channel impending failure drive calibration retry "
694 {0x5D40, "Servo impending failure general hard drive failure"},
695 {0x5D41, "Servo impending failure drive error rate too high"},
696 {0x5D42, "Servo impending failure data error rate too high"},
697 {0x5D43, "Servo impending failure seek error rate too high"},
698 {0x5D44, "Servo impending failure too many block reassigns"},
699 {0x5D45, "Servo impending failure access times too high"},
700 {0x5D46, "Servo impending failure start unit times too high"},
701 {0x5D47, "Servo impending failure channel parametrics"},
702 {0x5D48, "Servo impending failure controller detected"},
703 {0x5D49, "Servo impending failure throughput performance"},
704 {0x5D4A, "Servo impending failure seek time performance"},
705 {0x5D4B, "Servo impending failure spin-up retry count"},
706 {0x5D4C, "Servo impending failure drive calibration retry count"},
707 {0x5D50, "Spindle impending failure general hard drive failure"},
708 {0x5D51, "Spindle impending failure drive error rate too high"},
709 {0x5D52, "Spindle impending failure data error rate too high"},
710 {0x5D53, "Spindle impending failure seek error rate too high"},
711 {0x5D54, "Spindle impending failure too many block reassigns"},
712 {0x5D55, "Spindle impending failure access times too high"},
713 {0x5D56, "Spindle impending failure start unit times too high"},
714 {0x5D57, "Spindle impending failure channel parametrics"},
715 {0x5D58, "Spindle impending failure controller detected"},
716 {0x5D59, "Spindle impending failure throughput performance"},
717 {0x5D5A, "Spindle impending failure seek time performance"},
718 {0x5D5B, "Spindle impending failure spin-up retry count"},
719 {0x5D5C, "Spindle impending failure drive calibration retry count"},
720 {0x5D60, "Firmware impending failure general hard drive failure"},
721 {0x5D61, "Firmware impending failure drive error rate too high"},
722 {0x5D62, "Firmware impending failure data error rate too high"},
723 {0x5D63, "Firmware impending failure seek error rate too high"},
724 {0x5D64, "Firmware impending failure too many block reassigns"},
725 {0x5D65, "Firmware impending failure access times too high"},
726 {0x5D66, "Firmware impending failure start unit times too high"},
727 {0x5D67, "Firmware impending failure channel parametrics"},
728 {0x5D68, "Firmware impending failure controller detected"},
729 {0x5D69, "Firmware impending failure throughput performance"},
730 {0x5D6A, "Firmware impending failure seek time performance"},
731 {0x5D6B, "Firmware impending failure spin-up retry count"},
732 {0x5D6C, "Firmware impending failure drive calibration retry count"},
733 {0x5DFF, "Failure prediction threshold exceeded (false)"},
735 {0x5E00, "Low power condition on"},
736 {0x5E01, "Idle condition activated by timer"},
737 {0x5E02, "Standby condition activated by timer"},
738 {0x5E03, "Idle condition activated by command"},
739 {0x5E04, "Standby condition activated by command"},
740 {0x5E41, "Power state change to active"},
741 {0x5E42, "Power state change to idle"},
742 {0x5E43, "Power state change to standby"},
743 {0x5E45, "Power state change to sleep"},
744 {0x5E47, "Power state change to device control"},
746 {0x6000, "Lamp failure"},
748 {0x6100, "Video acquisition error"},
749 {0x6101, "Unable to acquire video"},
750 {0x6102, "Out of focus"},
752 {0x6200, "Scan head positioning error"},
754 {0x6300, "End of user area encountered on this track"},
755 {0x6301, "Packet does not fit in available space"},
757 {0x6400, "Illegal mode for this track"},
758 {0x6401, "Invalid packet size"},
760 {0x6500, "Voltage fault"},
762 {0x6600, "Automatic document feeder cover up"},
763 {0x6601, "Automatic document feeder lift up"},
764 {0x6602, "Document jam in automatic document feeder"},
765 {0x6603, "Document miss feed automatic in document feeder"},
767 {0x6700, "Configuration failure"},
768 {0x6701, "Configuration of incapable logical units failed"},
769 {0x6702, "Add logical unit failed"},
770 {0x6703, "Modification of logical unit failed"},
771 {0x6704, "Exchange of logical unit failed"},
772 {0x6705, "Remove of logical unit failed"},
773 {0x6706, "Attachment of logical unit failed"},
774 {0x6707, "Creation of logical unit failed"},
775 {0x6708, "Assign failure occurred"},
776 {0x6709, "Multiply assigned logical unit"},
777 {0x670A, "Set target port groups command failed"},
779 {0x6800, "Logical unit not configured"},
781 {0x6900, "Data loss on logical unit"},
782 {0x6901, "Multiple logical unit failures"},
783 {0x6902, "Parity/data mismatch"},
785 {0x6A00, "Informational, refer to log"},
787 {0x6B00, "State change has occurred"},
788 {0x6B01, "Redundancy level got better"},
789 {0x6B02, "Redundancy level got worse"},
791 {0x6C00, "Rebuild failure occurred"},
793 {0x6D00, "Recalculate failure occurred"},
795 {0x6E00, "Command to logical unit failed"},
797 {0x6F00, "Copy protection key exchange failure - authentication "
799 {0x6F01, "Copy protection key exchange failure - key not present"},
800 {0x6F02, "Copy protection key exchange failure - key not established"},
801 {0x6F03, "Read of scrambled sector without authentication"},
802 {0x6F04, "Media region code is mismatched to logical unit region"},
803 {0x6F05, "Drive region must be permanent/region reset count error"},
806 {0x70NN, "Decompression exception short algorithm id of nn"},
809 {0x7100, "Decompression exception long algorithm id"},
811 {0x7200, "Session fixation error"},
812 {0x7201, "Session fixation error writing lead-in"},
813 {0x7202, "Session fixation error writing lead-out"},
814 {0x7203, "Session fixation error - incomplete track in session"},
815 {0x7204, "Empty or partially written reserved track"},
816 {0x7205, "No more track reservations allowed"},
818 {0x7300, "Cd control error"},
819 {0x7301, "Power calibration area almost full"},
820 {0x7302, "Power calibration area is full"},
821 {0x7303, "Power calibration area error"},
822 {0x7304, "Program memory area update failure"},
823 {0x7305, "Program memory area is full"},
824 {0x7306, "RMA/PMA is almost full"},
829 unsigned char code1, code2_min, code2_max;
833 static struct error_info2 additional2[] =
835 {0x40,0x00,0x7f,"Ram failure (%x)"},
836 {0x40,0x80,0xff,"Diagnostic failure on component (%x)"},
837 {0x41,0x00,0xff,"Data path failure (%x)"},
838 {0x42,0x00,0xff,"Power-on or self-test failure (%x)"},
839 {0x4D,0x00,0xff,"Tagged overlapped commands (queue tag %x)"},
840 {0x70,0x00,0xff,"Decompression exception short algorithm id of %x"},
845 #if (CONSTANTS & CONST_SENSE)
846 /* description of the sense key values */
847 static const char *snstext[] = {
848 "No Sense", /* 0: There is no sense information */
849 "Recovered Error", /* 1: The last command completed successfully
850 but used error correction */
851 "Not Ready", /* 2: The addressed target is not ready */
852 "Medium Error", /* 3: Data error detected on the medium */
853 "Hardware Error", /* 4: Controller or device failure */
854 "Illegal Request", /* 5: Error in request */
855 "Unit Attention", /* 6: Removable medium was changed, or
856 the target has been reset */
857 "Data Protect", /* 7: Access to the data is blocked */
858 "Blank Check", /* 8: Reached unexpected written or unwritten
859 region of the medium */
860 "Vendor Specific", /* 9: Vendor specific */
861 "Copy Aborted", /* A: COPY or COMPARE was aborted */
862 "Aborted Command", /* B: The target aborted the command */
863 "Equal", /* C: A SEARCH DATA command found data equal */
864 "Volume Overflow", /* D: Medium full with still data to be written */
865 "Miscompare", /* E: Source data and data on the medium
870 /* Get sense key string or NULL if not available */
872 scsi_sense_key_string(unsigned char key) {
873 #if (CONSTANTS & CONST_SENSE)
881 * Get extended sense key string or NULL if not available.
882 * This string may contain a %x and must be printed with ascq as arg.
885 scsi_extd_sense_format(unsigned char asc, unsigned char ascq) {
886 #if (CONSTANTS & CONST_XSENSE)
888 unsigned short code = ((asc << 8) | ascq);
890 for (i=0; additional[i].text; i++)
891 if (additional[i].code12 == code)
892 return additional[i].text;
893 for (i=0; additional2[i].fmt; i++)
894 if (additional2[i].code1 == asc &&
895 additional2[i].code2_min >= ascq &&
896 additional2[i].code2_max <= ascq)
897 return additional2[i].fmt;
902 /* Print extended sense information */
904 scsi_show_extd_sense(unsigned char asc, unsigned char ascq) {
905 const char *extd_sense_fmt = scsi_extd_sense_format(asc, ascq);
907 if (extd_sense_fmt) {
908 printk("Additional sense: ");
909 printk(extd_sense_fmt, ascq);
912 printk("ASC=%2x ASCQ=%2x\n", asc, ascq);
916 /* Print sense information */
918 print_sense_internal(const char *devclass,
919 const unsigned char *sense_buffer,
922 int s, sense_class, valid, code, info;
923 const char *error = NULL;
924 unsigned char asc, ascq;
925 const char *sense_txt;
926 const char *name = req->rq_disk ? req->rq_disk->disk_name : devclass;
928 sense_class = (sense_buffer[0] >> 4) & 0x07;
929 code = sense_buffer[0] & 0xf;
930 valid = sense_buffer[0] & 0x80;
932 if (sense_class == 7) { /* extended sense data */
933 s = sense_buffer[7] + 8;
934 if (s > SCSI_SENSE_BUFFERSIZE)
935 s = SCSI_SENSE_BUFFERSIZE;
937 info = ((sense_buffer[3] << 24) | (sense_buffer[4] << 16) |
938 (sense_buffer[5] << 8) | sense_buffer[6]);
940 printk("Info fld=0x%x", info);
941 if (!valid) /* info data not according to standard */
945 if (sense_buffer[2] & 0x80)
946 printk( "FMK "); /* current command has read a filemark */
947 if (sense_buffer[2] & 0x40)
948 printk( "EOM "); /* end-of-medium condition exists */
949 if (sense_buffer[2] & 0x20)
950 printk( "ILI "); /* incorrect block length requested */
954 error = "Current"; /* error concerns current command */
957 error = "Deferred"; /* error concerns some earlier command */
958 /* e.g., an earlier write to disk cache succeeded, but
959 now the disk discovers that it cannot write the data */
965 printk("%s ", error);
967 sense_txt = scsi_sense_key_string(sense_buffer[2]);
969 printk("%s: sense key %s\n", name, sense_txt);
971 printk("%s: sense = %2x %2x\n", name,
972 sense_buffer[0], sense_buffer[2]);
975 if (sense_buffer[7] + 7 >= 13) {
976 asc = sense_buffer[12];
977 ascq = sense_buffer[13];
980 scsi_show_extd_sense(asc, ascq);
982 } else { /* non-extended sense data */
986 * sense_buffer[0] & 0200 : address valid
987 * sense_buffer[0] & 0177 : vendor-specific error code
988 * sense_buffer[1] & 0340 : vendor-specific
989 * sense_buffer[1..3] : 21-bit logical block address
992 sense_txt = scsi_sense_key_string(sense_buffer[0]);
994 printk("%s: old sense key %s\n", name, sense_txt);
996 printk("%s: sense = %2x %2x\n", name,
997 sense_buffer[0], sense_buffer[2]);
999 printk("Non-extended sense class %d code 0x%0x\n",
1004 #if !(CONSTANTS & CONST_SENSE)
1007 printk("Raw sense data:");
1008 for (i = 0; i < s; ++i)
1009 printk("0x%02x ", sense_buffer[i]);
1015 void print_sense(const char *devclass, struct scsi_cmnd *cmd)
1017 print_sense_internal(devclass, cmd->sense_buffer, cmd->request);
1020 void print_req_sense(const char *devclass, struct scsi_request *sreq)
1022 print_sense_internal(devclass, sreq->sr_sense_buffer, sreq->sr_request);
1025 #if (CONSTANTS & CONST_MSG)
1026 static const char *one_byte_msgs[] = {
1027 /* 0x00 */ "Command Complete", NULL, "Save Pointers",
1028 /* 0x03 */ "Restore Pointers", "Disconnect", "Initiator Error",
1029 /* 0x06 */ "Abort", "Message Reject", "Nop", "Message Parity Error",
1030 /* 0x0a */ "Linked Command Complete", "Linked Command Complete w/flag",
1031 /* 0x0c */ "Bus device reset", "Abort Tag", "Clear Queue",
1032 /* 0x0f */ "Initiate Recovery", "Release Recovery"
1035 #define NO_ONE_BYTE_MSGS (sizeof(one_byte_msgs) / sizeof (const char *))
1037 static const char *two_byte_msgs[] = {
1038 /* 0x20 */ "Simple Queue Tag", "Head of Queue Tag", "Ordered Queue Tag"
1039 /* 0x23 */ "Ignore Wide Residue"
1042 #define NO_TWO_BYTE_MSGS (sizeof(two_byte_msgs) / sizeof (const char *))
1044 static const char *extended_msgs[] = {
1045 /* 0x00 */ "Modify Data Pointer", "Synchronous Data Transfer Request",
1046 /* 0x02 */ "SCSI-I Extended Identify", "Wide Data Transfer Request"
1049 #define NO_EXTENDED_MSGS (sizeof(two_byte_msgs) / sizeof (const char *))
1050 #endif /* (CONSTANTS & CONST_MSG) */
1052 int print_msg (const unsigned char *msg) {
1054 if (msg[0] == EXTENDED_MESSAGE) {
1056 #if (CONSTANTS & CONST_MSG)
1057 if (msg[2] < NO_EXTENDED_MSGS)
1058 printk ("%s ", extended_msgs[msg[2]]);
1060 printk ("Extended Message, reserved code (0x%02x) ", (int) msg[2]);
1062 case EXTENDED_MODIFY_DATA_POINTER:
1063 printk("pointer = %d", (int) (msg[3] << 24) | (msg[4] << 16) |
1064 (msg[5] << 8) | msg[6]);
1067 printk("period = %d ns, offset = %d", (int) msg[3] * 4, (int)
1071 printk("width = 2^%d bytes", msg[3]);
1074 for (i = 2; i < len; ++i)
1075 printk("%02x ", msg[i]);
1078 for (i = 0; i < len; ++i)
1079 printk("%02x ", msg[i]);
1082 } else if (msg[0] & 0x80) {
1083 #if (CONSTANTS & CONST_MSG)
1084 printk("Identify disconnect %sallowed %s %d ",
1085 (msg[0] & 0x40) ? "" : "not ",
1086 (msg[0] & 0x20) ? "target routine" : "lun",
1089 printk("%02x ", msg[0]);
1092 /* Normal One byte */
1093 } else if (msg[0] < 0x1f) {
1094 #if (CONSTANTS & CONST_MSG)
1095 if (msg[0] < NO_ONE_BYTE_MSGS)
1096 printk(one_byte_msgs[msg[0]]);
1098 printk("reserved (%02x) ", msg[0]);
1100 printk("%02x ", msg[0]);
1104 } else if (msg[0] <= 0x2f) {
1105 #if (CONSTANTS & CONST_MSG)
1106 if ((msg[0] - 0x20) < NO_TWO_BYTE_MSGS)
1107 printk("%s %02x ", two_byte_msgs[msg[0] - 0x20],
1110 printk("reserved two byte (%02x %02x) ",
1113 printk("%02x %02x", msg[0], msg[1]);
1117 #if (CONSTANTS & CONST_MSG)
1120 printk("%02x ", msg[0]);
1125 void print_Scsi_Cmnd(struct scsi_cmnd *cmd) {
1126 printk("scsi%d : destination target %d, lun %d\n",
1127 cmd->device->host->host_no,
1130 printk(" command = ");
1131 print_command(cmd->cmnd);
1134 #if (CONSTANTS & CONST_HOST)
1135 static const char * hostbyte_table[]={
1136 "DID_OK", "DID_NO_CONNECT", "DID_BUS_BUSY", "DID_TIME_OUT", "DID_BAD_TARGET",
1137 "DID_ABORT", "DID_PARITY", "DID_ERROR", "DID_RESET", "DID_BAD_INTR",
1138 "DID_PASSTHROUGH", "DID_SOFT_ERROR", "DID_IMM_RETRY", NULL};
1140 void print_hostbyte(int scsiresult)
1141 { static int maxcode=0;
1145 for(i=0;hostbyte_table[i];i++) ;
1148 printk("Hostbyte=0x%02x",host_byte(scsiresult));
1149 if(host_byte(scsiresult)>maxcode) {
1150 printk("is invalid ");
1153 printk("(%s) ",hostbyte_table[host_byte(scsiresult)]);
1156 void print_hostbyte(int scsiresult)
1157 { printk("Hostbyte=0x%02x ",host_byte(scsiresult));
1161 #if (CONSTANTS & CONST_DRIVER)
1162 static const char * driverbyte_table[]={
1163 "DRIVER_OK", "DRIVER_BUSY", "DRIVER_SOFT", "DRIVER_MEDIA", "DRIVER_ERROR",
1164 "DRIVER_INVALID", "DRIVER_TIMEOUT", "DRIVER_HARD",NULL };
1166 static const char * driversuggest_table[]={"SUGGEST_OK",
1167 "SUGGEST_RETRY", "SUGGEST_ABORT", "SUGGEST_REMAP", "SUGGEST_DIE",
1168 unknown,unknown,unknown, "SUGGEST_SENSE",NULL};
1171 void print_driverbyte(int scsiresult)
1172 { static int driver_max=0,suggest_max=0;
1173 int i,dr=driver_byte(scsiresult)&DRIVER_MASK,
1174 su=(driver_byte(scsiresult)&SUGGEST_MASK)>>4;
1177 for(i=0;driverbyte_table[i];i++) ;
1179 for(i=0;driversuggest_table[i];i++) ;
1182 printk("Driverbyte=0x%02x",driver_byte(scsiresult));
1184 dr<driver_max ? driverbyte_table[dr]:"invalid",
1185 su<suggest_max ? driversuggest_table[su]:"invalid");
1188 void print_driverbyte(int scsiresult)
1189 { printk("Driverbyte=0x%02x ",driver_byte(scsiresult));