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