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