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