This source file includes following definitions.
- print_opcode
- print_opcode
- print_command
- print_status
- print_sense
- print_msg
- print_Scsi_Cmnd
1
2
3
4
5
6 #ifdef MODULE
7
8
9
10
11 #define _SCSI_SYMS_VER_
12 #include <linux/autoconf.h>
13 #include <linux/module.h>
14 #include <linux/version.h>
15 #else
16 #define MOD_INC_USE_COUNT
17 #define MOD_DEC_USE_COUNT
18 #endif
19
20 #include <linux/config.h>
21 #include <linux/blk.h>
22 #include <linux/kernel.h>
23 #include "scsi.h"
24 #include "hosts.h"
25
26 #define CONST_COMMAND 0x01
27 #define CONST_STATUS 0x02
28 #define CONST_SENSE 0x04
29 #define CONST_XSENSE 0x08
30 #define CONST_CMND 0x10
31 #define CONST_MSG 0x20
32
33 static const char unknown[] = "UNKNOWN";
34
35 #ifdef CONFIG_SCSI_CONSTANTS
36 #ifdef CONSTANTS
37 #undef CONSTANTS
38 #endif
39 #define CONSTANTS (CONST_COMMAND | CONST_STATUS | CONST_SENSE | CONST_XSENSE | CONST_CMND | CONST_MSG)
40 #endif
41
42 #if (CONSTANTS & CONST_COMMAND)
43 static const char * group_0_commands[] = {
44 "Test Unit Ready", "Rezero Unit", unknown, "Request Sense",
45 "Format Unit", "Read Block Limits", unknown, "Reasssign Blocks",
46 "Read (6)", unknown, "Write (6)", "Seek (6)", unknown, unknown,
47 unknown, "Read Reverse", "Write Filemarks", "Space", "Inquiry",
48 unknown, "Recover Buffered Data", "Mode Select", "Reserve",
49 "Release", "Copy", "Erase", "Mode Sense", "Start/Stop Unit",
50 "Receive Diagnostic", "Send Diagnostic",
51 "Prevent/Allow Medium Removal", unknown,
52 };
53
54
55 static const char *group_1_commands[] = {
56 unknown, unknown, unknown,
57 unknown, unknown, "Read Capacity", unknown, unknown, "Read (10)",
58 unknown, "Write (10)", "Seek (10)", unknown, unknown,
59 "Write Verify","Verify", "Search High", "Search Equal",
60 "Search Low", "Set Limits", "Prefetch or Read Position",
61 "Synchronize Cache","Lock/Unlock Cache", "Read Defect Data",
62 "Medium Scan", "Compare","Copy Verify", "Write Buffer", "Read Buffer",
63 "Update Block", "Read Long", "Write Long",
64 };
65
66
67 static const char *group_2_commands[] = {
68 "Change Definition", "Write Same",
69 unknown, unknown, unknown, unknown, unknown, unknown, unknown,
70 unknown, unknown, unknown, "Log Select", "Log Sense", unknown, unknown,
71 unknown, unknown, unknown, unknown, unknown, "Mode Select (10)",
72 unknown, unknown, unknown, unknown, "Mode Sense (10)", unknown,
73 unknown, unknown, unknown,
74 };
75
76
77
78 #define group(opcode) (((opcode) >> 5) & 7)
79
80 #define RESERVED_GROUP 0
81 #define VENDOR_GROUP 1
82 #define NOTEXT_GROUP 2
83
84 static const char **commands[] = {
85 group_0_commands, group_1_commands, group_2_commands,
86 (const char **) RESERVED_GROUP, (const char **) RESERVED_GROUP,
87 (const char **) NOTEXT_GROUP, (const char **) VENDOR_GROUP,
88 (const char **) VENDOR_GROUP
89 };
90
91 static const char reserved[] = "RESERVED";
92 static const char vendor[] = "VENDOR SPECIFIC";
93
94 static void print_opcode(int opcode) {
95 const char **table = commands[ group(opcode) ];
96 switch ((unsigned long) table) {
97 case RESERVED_GROUP:
98 printk("%s(0x%02x) ", reserved, opcode);
99 break;
100 case NOTEXT_GROUP:
101 printk("%s(0x%02x) ", unknown, opcode);
102 break;
103 case VENDOR_GROUP:
104 printk("%s(0x%02x) ", vendor, opcode);
105 break;
106 default:
107 printk("%s ",table[opcode & 0x1f]);
108 }
109 }
110 #else
111 static void print_opcode(int opcode) {
112 printk("0x%02x ", opcode);
113 }
114 #endif
115
116 void print_command (unsigned char *command) {
117 int i,s;
118 print_opcode(command[0]);
119 for ( i = 1, s = COMMAND_SIZE(command[0]); i < s; ++i)
120 printk("%02x ", command[i]);
121 printk("\n");
122 }
123
124 #if (CONSTANTS & CONST_STATUS)
125 static const char * statuses[] = {
126 "Good", "Check Condition", "Condition Good", unknown, "Busy",
127 unknown, unknown, unknown, "Intermediate Good", unknown,
128 "Intermediate Good", unknown, "Reservation Conflict", unknown,
129 unknown, unknown,
130 };
131 #endif
132
133 void print_status (int status) {
134 status = (status >> 1) & 0xf;
135 #if (CONSTANTS & CONST_STATUS)
136 printk("%s ",statuses[status]);
137 #else
138 printk("0x%0x ", status);
139 #endif
140 }
141
142 #if (CONSTANTS & CONST_XSENSE)
143 #define D 0x001
144 #define T 0x002
145 #define L 0x004
146 #define P 0x008
147 #define W 0x010
148 #define R 0x020
149 #define S 0x040
150 #define O 0x080
151 #define M 0x100
152 #define C 0x200
153
154 struct error_info{
155 unsigned char code1, code2;
156 unsigned short int devices;
157 const char * text;
158 };
159
160 struct error_info2{
161 unsigned char code1, code2_min, code2_max;
162 unsigned short int devices;
163 const char * text;
164 };
165
166 static struct error_info2 additional2[] =
167 {
168 {0x40,0x00,0x7f,D,"Ram failure (%x)"},
169 {0x40,0x80,0xff,D|T|L|P|W|R|S|O|M|C,"Diagnostic failure on component (%x)"},
170 {0x41,0x00,0xff,D,"Data path failure (%x)"},
171 {0x42,0x00,0xff,D,"Power-on or self-test failure (%x)"},
172 {0, 0, 0, 0, NULL}
173 };
174
175 static struct error_info additional[] =
176 {
177 {0x00,0x01,T,"Filemark detected"},
178 {0x00,0x02,T|S,"End-of-partition/medium detected"},
179 {0x00,0x03,T,"Setmark detected"},
180 {0x00,0x04,T|S,"Beginning-of-partition/medium detected"},
181 {0x00,0x05,T|S,"End-of-data detected"},
182 {0x00,0x06,D|T|L|P|W|R|S|O|M|C,"I/O process terminated"},
183 {0x00,0x11,R,"Audio play operation in progress"},
184 {0x00,0x12,R,"Audio play operation paused"},
185 {0x00,0x13,R,"Audio play operation successfully completed"},
186 {0x00,0x14,R,"Audio play operation stopped due to error"},
187 {0x00,0x15,R,"No current audio status to return"},
188 {0x01,0x00,D|W|O,"No index/sector signal"},
189 {0x02,0x00,D|W|R|O|M,"No seek complete"},
190 {0x03,0x00,D|T|L|W|S|O,"Peripheral device write fault"},
191 {0x03,0x01,T,"No write current"},
192 {0x03,0x02,T,"Excessive write errors"},
193 {0x04,0x00,D|T|L|P|W|R|S|O|M|C,
194 "Logical unit not ready, cause not reportable"},
195 {0x04,0x01,D|T|L|P|W|R|S|O|M|C,
196 "Logical unit is in process of becoming ready"},
197 {0x04,0x02,D|T|L|P|W|R|S|O|M|C,
198 "Logical unit not ready, initializing command required"},
199 {0x04,0x03,D|T|L|P|W|R|S|O|M|C,
200 "Logical unit not ready, manual intervention required"},
201 {0x04,0x04,D|T|L|O,"Logical unit not ready, format in progress"},
202 {0x05,0x00,D|T|L|W|R|S|O|M|C,"Logical unit does not respond to selection"},
203 {0x06,0x00,D|W|R|O|M,"No reference position found"},
204 {0x07,0x00,D|T|L|W|R|S|O|M,"Multiple peripheral devices selected"},
205 {0x08,0x00,D|T|L|W|R|S|O|M|C,"Logical unit communication failure"},
206 {0x08,0x01,D|T|L|W|R|S|O|M|C,"Logical unit communication time-out"},
207 {0x08,0x02,D|T|L|W|R|S|O|M|C,"Logical unit communication parity error"},
208 {0x09,0x00,D|T|W|R|O,"Track following error"},
209 {0x09,0x01,W|R|O,"Tracking servo failure"},
210 {0x09,0x02,W|R|O,"Focus servo failure"},
211 {0x09,0x03,W|R|O,"Spindle servo failure"},
212 {0x0A,0x00,D|T|L|P|W|R|S|O|M|C,"Error log overflow"},
213 {0x0C,0x00,T|S,"Write error"},
214 {0x0C,0x01,D|W|O,"Write error recovered with auto reallocation"},
215 {0x0C,0x02,D|W|O,"Write error - auto reallocation failed"},
216 {0x10,0x00,D|W|O,"Id crc or ecc error"},
217 {0x11,0x00,D|T|W|R|S|O,"Unrecovered read error"},
218 {0x11,0x01,D|T|W|S|O,"Read retries exhausted"},
219 {0x11,0x02,D|T|W|S|O,"Error too long to correct"},
220 {0x11,0x03,D|T|W|S|O,"Multiple read errors"},
221 {0x11,0x04,D|W|O,"Unrecovered read error - auto reallocate failed"},
222 {0x11,0x05,W|R|O,"L-ec uncorrectable error"},
223 {0x11,0x06,W|R|O,"Circ unrecovered error"},
224 {0x11,0x07,W|O,"Data resynchronization error"},
225 {0x11,0x08,T,"Incomplete block read"},
226 {0x11,0x09,T,"No gap found"},
227 {0x11,0x0A,D|T|O,"Miscorrected error"},
228 {0x11,0x0B,D|W|O,"Unrecovered read error - recommend reassignment"},
229 {0x11,0x0C,D|W|O,"Unrecovered read error - recommend rewrite the data"},
230 {0x12,0x00,D|W|O,"Address mark not found for id field"},
231 {0x13,0x00,D|W|O,"Address mark not found for data field"},
232 {0x14,0x00,D|T|L|W|R|S|O,"Recorded entity not found"},
233 {0x14,0x01,D|T|W|R|O,"Record not found"},
234 {0x14,0x02,T,"Filemark or setmark not found"},
235 {0x14,0x03,T,"End-of-data not found"},
236 {0x14,0x04,T,"Block sequence error"},
237 {0x15,0x00,D|T|L|W|R|S|O|M,"Random positioning error"},
238 {0x15,0x01,D|T|L|W|R|S|O|M,"Mechanical positioning error"},
239 {0x15,0x02,D|T|W|R|O,"Positioning error detected by read of medium"},
240 {0x16,0x00,D|W|O,"Data synchronization mark error"},
241 {0x17,0x00,D|T|W|R|S|O,"Recovered data with no error correction applied"},
242 {0x17,0x01,D|T|W|R|S|O,"Recovered data with retries"},
243 {0x17,0x02,D|T|W|R|O,"Recovered data with positive head offset"},
244 {0x17,0x03,D|T|W|R|O,"Recovered data with negative head offset"},
245 {0x17,0x04,W|R|O,"Recovered data with retries and/or circ applied"},
246 {0x17,0x05,D|W|R|O,"Recovered data using previous sector id"},
247 {0x17,0x06,D|W|O,"Recovered data without ecc - data auto-reallocated"},
248 {0x17,0x07,D|W|O,"Recovered data without ecc - recommend reassignment"},
249 {0x18,0x00,D|T|W|R|O,"Recovered data with error correction applied"},
250 {0x18,0x01,D|W|R|O,"Recovered data with error correction and retries applied"},
251 {0x18,0x02,D|W|R|O,"Recovered data - data auto-reallocated"},
252 {0x18,0x03,R,"Recovered data with circ"},
253 {0x18,0x04,R,"Recovered data with lec"},
254 {0x18,0x05,D|W|R|O,"Recovered data - recommend reassignment"},
255 {0x19,0x00,D|O,"Defect list error"},
256 {0x19,0x01,D|O,"Defect list not available"},
257 {0x19,0x02,D|O,"Defect list error in primary list"},
258 {0x19,0x03,D|O,"Defect list error in grown list"},
259 {0x1A,0x00,D|T|L|P|W|R|S|O|M|C,"Parameter list length error"},
260 {0x1B,0x00,D|T|L|P|W|R|S|O|M|C,"Synchronous data transfer error"},
261 {0x1C,0x00,D|O,"Defect list not found"},
262 {0x1C,0x01,D|O,"Primary defect list not found"},
263 {0x1C,0x02,D|O,"Grown defect list not found"},
264 {0x1D,0x00,D|W|O,"Miscompare during verify operation"},
265 {0x1E,0x00,D|W|O,"Recovered id with ecc correction"},
266 {0x20,0x00,D|T|L|P|W|R|S|O|M|C,"Invalid command operation code"},
267 {0x21,0x00,D|T|W|R|O|M,"Logical block address out of range"},
268 {0x21,0x01,M,"Invalid element address"},
269 {0x22,0x00,D,"Illegal function (should use 20 00, 24 00, or 26 00)"},
270 {0x24,0x00,D|T|L|P|W|R|S|O|M|C,"Invalid field in cdb"},
271 {0x25,0x00,D|T|L|P|W|R|S|O|M|C,"Logical unit not supported"},
272 {0x26,0x00,D|T|L|P|W|R|S|O|M|C,"Invalid field in parameter list"},
273 {0x26,0x01,D|T|L|P|W|R|S|O|M|C,"Parameter not supported"},
274 {0x26,0x02,D|T|L|P|W|R|S|O|M|C,"Parameter value invalid"},
275 {0x26,0x03,D|T|L|P|W|R|S|O|M|C,"Threshold parameters not supported"},
276 {0x27,0x00,D|T|W|O,"Write protected"},
277 {0x28,0x00,D|T|L|P|W|R|S|O|M|C,"Not ready to ready transition (medium may have changed)"},
278 {0x28,0x01,M,"Import or export element accessed"},
279 {0x29,0x00,D|T|L|P|W|R|S|O|M|C,"Power on, reset, or bus device reset occurred"},
280 {0x2A,0x00,D|T|L|W|R|S|O|M|C,"Parameters changed"},
281 {0x2A,0x01,D|T|L|W|R|S|O|M|C,"Mode parameters changed"},
282 {0x2A,0x02,D|T|L|W|R|S|O|M|C,"Log parameters changed"},
283 {0x2B,0x00,D|T|L|P|W|R|S|O|C,"Copy cannot execute since host cannot disconnect"},
284 {0x2C,0x00,D|T|L|P|W|R|S|O|M|C,"Command sequence error"},
285 {0x2C,0x01,S,"Too many windows specified"},
286 {0x2C,0x02,S,"Invalid combination of windows specified"},
287 {0x2D,0x00,T,"Overwrite error on update in place"},
288 {0x2F,0x00,D|T|L|P|W|R|S|O|M|C,"Commands cleared by another initiator"},
289 {0x30,0x00,D|T|W|R|O|M,"Incompatible medium installed"},
290 {0x30,0x01,D|T|W|R|O,"Cannot read medium - unknown format"},
291 {0x30,0x02,D|T|W|R|O,"Cannot read medium - incompatible format"},
292 {0x30,0x03,D|T,"Cleaning cartridge installed"},
293 {0x31,0x00,D|T|W|O,"Medium format corrupted"},
294 {0x31,0x01,D|L|O,"Format command failed"},
295 {0x32,0x00,D|W|O,"No defect spare location available"},
296 {0x32,0x01,D|W|O,"Defect list update failure"},
297 {0x33,0x00,T,"Tape length error"},
298 {0x36,0x00,L,"Ribbon, ink, or toner failure"},
299 {0x37,0x00,D|T|L|W|R|S|O|M|C,"Rounded parameter"},
300 {0x39,0x00,D|T|L|W|R|S|O|M|C,"Saving parameters not supported"},
301 {0x3A,0x00,D|T|L|W|R|S|O|M,"Medium not present"},
302 {0x3B,0x00,T|L,"Sequential positioning error"},
303 {0x3B,0x01,T,"Tape position error at beginning-of-medium"},
304 {0x3B,0x02,T,"Tape position error at end-of-medium"},
305 {0x3B,0x03,L,"Tape or electronic vertical forms unit not ready"},
306 {0x3B,0x04,L,"Slew failure"},
307 {0x3B,0x05,L,"Paper jam"},
308 {0x3B,0x06,L,"Failed to sense top-of-form"},
309 {0x3B,0x07,L,"Failed to sense bottom-of-form"},
310 {0x3B,0x08,T,"Reposition error"},
311 {0x3B,0x09,S,"Read past end of medium"},
312 {0x3B,0x0A,S,"Read past beginning of medium"},
313 {0x3B,0x0B,S,"Position past end of medium"},
314 {0x3B,0x0C,S,"Position past beginning of medium"},
315 {0x3B,0x0D,M,"Medium destination element full"},
316 {0x3B,0x0E,M,"Medium source element empty"},
317 {0x3D,0x00,D|T|L|P|W|R|S|O|M|C,"Invalid bits in identify message"},
318 {0x3E,0x00,D|T|L|P|W|R|S|O|M|C,"Logical unit has not self-configured yet"},
319 {0x3F,0x00,D|T|L|P|W|R|S|O|M|C,"Target operating conditions have changed"},
320 {0x3F,0x01,D|T|L|P|W|R|S|O|M|C,"Microcode has been changed"},
321 {0x3F,0x02,D|T|L|P|W|R|S|O|M|C,"Changed operating definition"},
322 {0x3F,0x03,D|T|L|P|W|R|S|O|M|C,"Inquiry data has changed"},
323 {0x43,0x00,D|T|L|P|W|R|S|O|M|C,"Message error"},
324 {0x44,0x00,D|T|L|P|W|R|S|O|M|C,"Internal target failure"},
325 {0x45,0x00,D|T|L|P|W|R|S|O|M|C,"Select or reselect failure"},
326 {0x46,0x00,D|T|L|P|W|R|S|O|M|C,"Unsuccessful soft reset"},
327 {0x47,0x00,D|T|L|P|W|R|S|O|M|C,"Scsi parity error"},
328 {0x48,0x00,D|T|L|P|W|R|S|O|M|C,"Initiator detected error message received"},
329 {0x49,0x00,D|T|L|P|W|R|S|O|M|C,"Invalid message error"},
330 {0x4A,0x00,D|T|L|P|W|R|S|O|M|C,"Command phase error"},
331 {0x4B,0x00,D|T|L|P|W|R|S|O|M|C,"Data phase error"},
332 {0x4C,0x00,D|T|L|P|W|R|S|O|M|C,"Logical unit failed self-configuration"},
333 {0x4E,0x00,D|T|L|P|W|R|S|O|M|C,"Overlapped commands attempted"},
334 {0x50,0x00,T,"Write append error"},
335 {0x50,0x01,T,"Write append position error"},
336 {0x50,0x02,T,"Position error related to timing"},
337 {0x51,0x00,T|O,"Erase failure"},
338 {0x52,0x00,T,"Cartridge fault"},
339 {0x53,0x00,D|T|L|W|R|S|O|M,"Media load or eject failed"},
340 {0x53,0x01,T,"Unload tape failure"},
341 {0x53,0x02,D|T|W|R|O|M,"Medium removal prevented"},
342 {0x54,0x00,P,"Scsi to host system interface failure"},
343 {0x55,0x00,P,"System resource failure"},
344 {0x57,0x00,R,"Unable to recover table-of-contents"},
345 {0x58,0x00,O,"Generation does not exist"},
346 {0x59,0x00,O,"Updated block read"},
347 {0x5A,0x00,D|T|L|P|W|R|S|O|M,"Operator request or state change input (unspecified)"},
348 {0x5A,0x01,D|T|W|R|O|M,"Operator medium removal request"},
349 {0x5A,0x02,D|T|W|O,"Operator selected write protect"},
350 {0x5A,0x03,D|T|W|O,"Operator selected write permit"},
351 {0x5B,0x00,D|T|L|P|W|R|S|O|M,"Log exception"},
352 {0x5B,0x01,D|T|L|P|W|R|S|O|M,"Threshold condition met"},
353 {0x5B,0x02,D|T|L|P|W|R|S|O|M,"Log counter at maximum"},
354 {0x5B,0x03,D|T|L|P|W|R|S|O|M,"Log list codes exhausted"},
355 {0x5C,0x00,D|O,"Rpl status change"},
356 {0x5C,0x01,D|O,"Spindles synchronized"},
357 {0x5C,0x02,D|O,"Spindles not synchronized"},
358 {0x60,0x00,S,"Lamp failure"},
359 {0x61,0x00,S,"Video acquisition error"},
360 {0x61,0x01,S,"Unable to acquire video"},
361 {0x61,0x02,S,"Out of focus"},
362 {0x62,0x00,S,"Scan head positioning error"},
363 {0x63,0x00,R,"End of user area encountered on this track"},
364 {0x64,0x00,R,"Illegal mode for this track"},
365 {0, 0, 0, NULL}
366 };
367 #endif
368
369 #if (CONSTANTS & CONST_SENSE)
370 static const char *snstext[] = {
371 "None","Recovered Error","Not Ready","Medium Error","Hardware Error",
372 "Illegal Request","Unit Attention","Data Protect","Blank Check",
373 "Key=9","Copy Aborted","Aborted Command","End-Of-Medium",
374 "Volume Overflow", "Miscompare", "Key=15"};
375 #endif
376
377
378
379 void print_sense(const char * devclass, Scsi_Cmnd * SCpnt)
380 {
381 int i, s;
382 int sense_class, valid, code;
383 unsigned char * sense_buffer = SCpnt->sense_buffer;
384 const char * error = NULL;
385
386 sense_class = (sense_buffer[0] >> 4) & 0x07;
387 code = sense_buffer[0] & 0xf;
388 valid = sense_buffer[0] & 0x80;
389
390 if (sense_class == 7) {
391 s = sense_buffer[7] + 8;
392 if(s > sizeof(SCpnt->sense_buffer)) s = sizeof(SCpnt->sense_buffer);
393
394 if (!valid)
395 printk("extra data not valid ");
396
397 if (sense_buffer[2] & 0x80) printk( "FMK ");
398 if (sense_buffer[2] & 0x40) printk( "EOM ");
399 if (sense_buffer[2] & 0x20) printk( "ILI ");
400
401 switch (code) {
402 case 0x0:
403 error = "Current";
404 break;
405 case 0x1:
406 error = "Deferred";
407 break;
408 default:
409 error = "Invalid";
410 }
411
412 printk("%s error ", error);
413
414 #if (CONSTANTS & CONST_SENSE)
415 printk( "%s%s: sense key %s\n", devclass,
416 kdevname(SCpnt->request.rq_dev), snstext[sense_buffer[2] & 0x0f]);
417 #else
418 printk("%s%s: sns = %2x %2x\n", devclass,
419 kdevname(SCpnt->request.rq_dev), sense_buffer[0], sense_buffer[2]);
420 #endif
421
422
423 if(sense_buffer[7] + 7 < 13 ||
424 (sense_buffer[12] == 0 && sense_buffer[13] == 0)) goto done;
425
426 #if (CONSTANTS & CONST_XSENSE)
427 for(i=0; additional[i].text; i++)
428 if(additional[i].code1 == sense_buffer[12] &&
429 additional[i].code2 == sense_buffer[13])
430 printk("Additional sense indicates %s\n", additional[i].text);
431
432 for(i=0; additional2[i].text; i++)
433 if(additional2[i].code1 == sense_buffer[12] &&
434 additional2[i].code2_min >= sense_buffer[13] &&
435 additional2[i].code2_max <= sense_buffer[13]) {
436 printk("Additional sense indicates ");
437 printk(additional2[i].text, sense_buffer[13]);
438 printk("\n");
439 };
440 #else
441 printk("ASC=%2x ASCQ=%2x\n", sense_buffer[12], sense_buffer[13]);
442 #endif
443 } else {
444
445 #if (CONSTANTS & CONST_SENSE)
446 if (sense_buffer[0] < 15)
447 printk("%s%s: old sense key %s\n", devclass,
448 kdevname(SCpnt->request.rq_dev), snstext[sense_buffer[0] & 0x0f]);
449 else
450 #endif
451 printk("%s%s: sns = %2x %2x\n", devclass,
452 kdevname(SCpnt->request.rq_dev), sense_buffer[0], sense_buffer[2]);
453
454 printk("Non-extended sense class %d code 0x%0x ", sense_class, code);
455 s = 4;
456 }
457
458 done:
459 #if !(CONSTANTS & CONST_SENSE)
460 printk("Raw sense data:");
461 for (i = 0; i < s; ++i)
462 printk("0x%02x ", sense_buffer[i]);
463 printk("\n");
464 #endif
465 return;
466 }
467
468 #if (CONSTANTS & CONST_MSG)
469 static const char *one_byte_msgs[] = {
470 "Command Complete", NULL, "Save Pointers",
471 "Restore Pointers", "Disconnect", "Initiator Error",
472 "Abort", "Message Reject", "Nop", "Message Parity Error",
473 "Linked Command Complete", "Linked Command Complete w/flag",
474 "Bus device reset", "Abort Tag", "Clear Queue",
475 "Initiate Recovery", "Release Recovery"
476 };
477
478 #define NO_ONE_BYTE_MSGS (sizeof(one_byte_msgs) / sizeof (const char *))
479
480 static const char *two_byte_msgs[] = {
481 "Simple Queue Tag", "Head of Queue Tag", "Ordered Queue Tag"
482 "Ignore Wide Residue"
483 };
484
485 #define NO_TWO_BYTE_MSGS (sizeof(two_byte_msgs) / sizeof (const char *))
486
487 static const char *extended_msgs[] = {
488 "Modify Data Pointer", "Synchronous Data Transfer Request",
489 "SCSI-I Extended Identify", "Wide Data Transfer Request"
490 };
491
492 #define NO_EXTENDED_MSGS (sizeof(two_byte_msgs) / sizeof (const char *))
493 #endif
494
495 int print_msg (const unsigned char *msg) {
496 int len = 0, i;
497 if (msg[0] == EXTENDED_MESSAGE) {
498 len = 3 + msg[1];
499 #if (CONSTANTS & CONST_MSG)
500 if (msg[2] < NO_EXTENDED_MSGS)
501 printk ("%s ", extended_msgs[msg[2]]);
502 else
503 printk ("Extended Message, reserved code (0x%02x) ", (int) msg[2]);
504 switch (msg[2]) {
505 case EXTENDED_MODIFY_DATA_POINTER:
506 printk("pointer = %d", (int) (msg[3] << 24) | (msg[4] << 16) |
507 (msg[5] << 8) | msg[6]);
508 break;
509 case EXTENDED_SDTR:
510 printk("period = %d ns, offset = %d", (int) msg[3] * 4, (int)
511 msg[4]);
512 break;
513 case EXTENDED_WDTR:
514 printk("width = 2^%d bytes", msg[3]);
515 break;
516 default:
517 for (i = 2; i < len; ++i)
518 printk("%02x ", msg[i]);
519 }
520 #else
521 for (i = 0; i < len; ++i)
522 printk("%02x ", msg[i]);
523 #endif
524
525 } else if (msg[0] & 0x80) {
526 #if (CONSTANTS & CONST_MSG)
527 printk("Identify disconnect %sallowed %s %d ",
528 (msg[0] & 0x40) ? "" : "not ",
529 (msg[0] & 0x20) ? "target routine" : "lun",
530 msg[0] & 0x7);
531 #else
532 printk("%02x ", msg[0]);
533 #endif
534 len = 1;
535
536 } else if (msg[0] < 0x1f) {
537 #if (CONSTANTS & CONST_MSG)
538 if (msg[0] < NO_ONE_BYTE_MSGS)
539 printk(one_byte_msgs[msg[0]]);
540 else
541 printk("reserved (%02x) ", msg[0]);
542 #else
543 printk("%02x ", msg[0]);
544 #endif
545 len = 1;
546
547 } else if (msg[0] <= 0x2f) {
548 #if (CONSTANTS & CONST_MSG)
549 if ((msg[0] - 0x20) < NO_TWO_BYTE_MSGS)
550 printk("%s %02x ", two_byte_msgs[msg[0] - 0x20],
551 msg[1]);
552 else
553 printk("reserved two byte (%02x %02x) ",
554 msg[0], msg[1]);
555 #else
556 printk("%02x %02x", msg[0], msg[1]);
557 #endif
558 len = 2;
559 } else
560 #if (CONSTANTS & CONST_MSG)
561 printk(reserved);
562 #else
563 printk("%02x ", msg[0]);
564 #endif
565 return len;
566 }
567
568 void print_Scsi_Cmnd (Scsi_Cmnd *cmd) {
569 printk("scsi%d : destination target %d, lun %d\n",
570 cmd->host->host_no,
571 cmd->target,
572 cmd->lun);
573 printk(" command = ");
574 print_command (cmd->cmnd);
575 }
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594