xref: /netbsd-src/sys/dev/scsipi/scsipi_verbose.c (revision 27578b9aac214cc7796ead81dcc5427e79d5f2a0)
1 /*	$NetBSD: scsipi_verbose.c,v 1.13 2001/08/20 07:41:14 ad Exp $	*/
2 
3 /*-
4  * Copyright (c) 1998 The NetBSD Foundation, Inc.
5  * All rights reserved.
6  *
7  * This code is derived from software contributed to The NetBSD Foundation
8  * by Charles M. Hannum.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  * 3. All advertising materials mentioning features or use of this software
19  *    must display the following acknowledgement:
20  *        This product includes software developed by the NetBSD
21  *        Foundation, Inc. and its contributors.
22  * 4. Neither the name of The NetBSD Foundation nor the names of its
23  *    contributors may be used to endorse or promote products derived
24  *    from this software without specific prior written permission.
25  *
26  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36  * POSSIBILITY OF SUCH DAMAGE.
37  */
38 
39 #include <sys/types.h>
40 #include <sys/param.h>
41 #include <sys/time.h>
42 #include <sys/proc.h>
43 #include <sys/device.h>
44 
45 #ifdef _KERNEL
46 #include <sys/systm.h>
47 
48 #include "opt_scsi.h"
49 #else
50 #include <stdio.h>
51 #endif
52 #include <dev/scsipi/scsipi_all.h>
53 #include <dev/scsipi/scsipiconf.h>
54 #include <dev/scsipi/scsiconf.h>
55 
56 static const char *sense_keys[16] = {
57 	"No Additional Sense",
58 	"Recovered Error",
59 	"Not Ready",
60 	"Media Error",
61 	"Hardware Error",
62 	"Illegal Request",
63 	"Unit Attention",
64 	"Write Protected",
65 	"Blank Check",
66 	"Vendor Unique",
67 	"Copy Aborted",
68 	"Aborted Command",
69 	"Equal Error",
70 	"Volume Overflow",
71 	"Miscompare Error",
72 	"Reserved"
73 };
74 
75 static const struct {
76 	unsigned char asc;
77 	unsigned char ascq;
78 	char *description;
79 } adesc[] = {
80 { 0x00, 0x00, "No Additional Sense Information" },
81 { 0x00, 0x01, "Filemark Detected" },
82 { 0x00, 0x02, "End-Of-Partition/Medium Detected" },
83 { 0x00, 0x03, "Setmark Detected" },
84 { 0x00, 0x04, "Beginning-Of-Partition/Medium Detected" },
85 { 0x00, 0x05, "End-Of-Data Detected" },
86 { 0x00, 0x06, "I/O Process Terminated" },
87 { 0x00, 0x11, "Audio Play Operation In Progress" },
88 { 0x00, 0x12, "Audio Play Operation Paused" },
89 { 0x00, 0x13, "Audio Play Operation Successfully Completed" },
90 { 0x00, 0x14, "Audio Play Operation Stopped Due to Error" },
91 { 0x00, 0x15, "No Current Audio Status To Return" },
92 { 0x01, 0x00, "No Index/Sector Signal" },
93 { 0x02, 0x00, "No Seek Complete" },
94 { 0x03, 0x00, "Peripheral Device Write Fault" },
95 { 0x03, 0x01, "No Write Current" },
96 { 0x03, 0x02, "Excessive Write Errors" },
97 { 0x04, 0x00, "Logical Unit Not Ready, Cause Not Reportable" },
98 { 0x04, 0x01, "Logical Unit Is in Process Of Becoming Ready" },
99 { 0x04, 0x02, "Logical Unit Not Ready, Initialization Command Required" },
100 { 0x04, 0x03, "Logical Unit Not Ready, Manual Intervention Required" },
101 { 0x04, 0x04, "Logical Unit Not Ready, Format In Progress" },
102 { 0x05, 0x00, "Logical Unit Does Not Respond To Selection" },
103 { 0x06, 0x00, "No Reference Position Found" },
104 { 0x07, 0x00, "Multiple Peripheral Devices Selected" },
105 { 0x08, 0x00, "Logical Unit Communication Failure" },
106 { 0x08, 0x01, "Logical Unit Communication Timeout" },
107 { 0x08, 0x02, "Logical Unit Communication Parity Error" },
108 { 0x09, 0x00, "Track Following Error" },
109 { 0x09, 0x01, "Tracking Servo Failure" },
110 { 0x09, 0x02, "Focus Servo Failure" },
111 { 0x09, 0x03, "Spindle Servo Failure" },
112 { 0x0A, 0x00, "Error Log Overflow" },
113 { 0x0C, 0x00, "Write Error" },
114 { 0x0C, 0x01, "Write Error Recovered with Auto Reallocation" },
115 { 0x0C, 0x02, "Write Error - Auto Reallocate Failed" },
116 { 0x10, 0x00, "ID CRC Or ECC Error" },
117 { 0x11, 0x00, "Unrecovered Read Error" },
118 { 0x11, 0x01, "Read Retried Exhausted" },
119 { 0x11, 0x02, "Error Too Long To Correct" },
120 { 0x11, 0x03, "Multiple Read Errors" },
121 { 0x11, 0x04, "Unrecovered Read Error - Auto Reallocate Failed" },
122 { 0x11, 0x05, "L-EC Uncorrectable Error" },
123 { 0x11, 0x06, "CIRC Unrecovered Error" },
124 { 0x11, 0x07, "Data Resynchronization Error" },
125 { 0x11, 0x08, "Incomplete Block Found" },
126 { 0x11, 0x09, "No Gap Found" },
127 { 0x11, 0x0A, "Miscorrected Error" },
128 { 0x11, 0x0B, "Uncorrected Read Error - Recommend Reassignment" },
129 { 0x11, 0x0C, "Uncorrected Read Error - Recommend Rewrite the Data" },
130 { 0x12, 0x00, "Address Mark Not Found for ID Field" },
131 { 0x13, 0x00, "Address Mark Not Found for Data Field" },
132 { 0x14, 0x00, "Recorded Entity Not Found" },
133 { 0x14, 0x01, "Record Not Found" },
134 { 0x14, 0x02, "Filemark or Setmark Not Found" },
135 { 0x14, 0x03, "End-Of-Data Not Found" },
136 { 0x14, 0x04, "Block Sequence Error" },
137 { 0x15, 0x00, "Random Positioning Error" },
138 { 0x15, 0x01, "Mechanical Positioning Error" },
139 { 0x15, 0x02, "Positioning Error Detected By Read of Medium" },
140 { 0x16, 0x00, "Data Synchronization Mark Error" },
141 { 0x17, 0x00, "Recovered Data With No Error Correction Applied" },
142 { 0x17, 0x01, "Recovered Data With Retries" },
143 { 0x17, 0x02, "Recovered Data With Positive Head Offset" },
144 { 0x17, 0x03, "Recovered Data With Negative Head Offset" },
145 { 0x17, 0x04, "Recovered Data With Retries and/or CIRC Applied" },
146 { 0x17, 0x05, "Recovered Data Using Previous Sector ID" },
147 { 0x17, 0x06, "Recovered Data Without ECC - Data Auto-Reallocated" },
148 { 0x17, 0x07, "Recovered Data Without ECC - Recommend Reassignment" },
149 { 0x17, 0x08, "Recovered Data Without ECC - Recommend Rewrite" },
150 { 0x18, 0x00, "Recovered Data With Error Correction Applied" },
151 { 0x18, 0x01, "Recovered Data With Error Correction & Retries Applied" },
152 { 0x18, 0x02, "Recovered Data - Data Auto-Reallocated" },
153 { 0x18, 0x03, "Recovered Data With CIRC" },
154 { 0x18, 0x04, "Recovered Data With LEC" },
155 { 0x18, 0x05, "Recovered Data - Recommend Reassignment" },
156 { 0x18, 0x06, "Recovered Data - Recommend Rewrite" },
157 { 0x19, 0x00, "Defect List Error" },
158 { 0x19, 0x01, "Defect List Not Available" },
159 { 0x19, 0x02, "Defect List Error in Primary List" },
160 { 0x19, 0x03, "Defect List Error in Grown List" },
161 { 0x1A, 0x00, "Parameter List Length Error" },
162 { 0x1B, 0x00, "Synchronous Data Transfer Error" },
163 { 0x1C, 0x00, "Defect List Not Found" },
164 { 0x1C, 0x01, "Primary Defect List Not Found" },
165 { 0x1C, 0x02, "Grown Defect List Not Found" },
166 { 0x1D, 0x00, "Miscompare During Verify Operation" },
167 { 0x1E, 0x00, "Recovered ID with ECC" },
168 { 0x20, 0x00, "Invalid Command Operation Code" },
169 { 0x21, 0x00, "Logical Block Address Out of Range" },
170 { 0x21, 0x01, "Invalid Element Address" },
171 { 0x22, 0x00, "Illegal Function (Should 20 00, 24 00, or 26 00)" },
172 { 0x24, 0x00, "Illegal Field in CDB" },
173 { 0x25, 0x00, "Logical Unit Not Supported" },
174 { 0x26, 0x00, "Invalid Field In Parameter List" },
175 { 0x26, 0x01, "Parameter Not Supported" },
176 { 0x26, 0x02, "Parameter Value Invalid" },
177 { 0x26, 0x03, "Threshold Parameters Not Supported" },
178 { 0x27, 0x00, "Write Protected" },
179 { 0x28, 0x00, "Not Ready To Ready Transition (Medium May Have Changed)" },
180 { 0x28, 0x01, "Import Or Export Element Accessed" },
181 { 0x29, 0x00, "Power On, Reset, or Bus Device Reset Occurred" },
182 { 0x2A, 0x00, "Parameters Changed" },
183 { 0x2A, 0x01, "Mode Parameters Changed" },
184 { 0x2A, 0x02, "Log Parameters Changed" },
185 { 0x2B, 0x00, "Copy Cannot Execute Since Host Cannot Disconnect" },
186 { 0x2C, 0x00, "Command Sequence Error" },
187 { 0x2C, 0x01, "Too Many Windows Specified" },
188 { 0x2C, 0x02, "Invalid Combination of Windows Specified" },
189 { 0x2D, 0x00, "Overwrite Error On Update In Place" },
190 { 0x2F, 0x00, "Commands Cleared By Another Initiator" },
191 { 0x30, 0x00, "Incompatible Medium Installed" },
192 { 0x30, 0x01, "Cannot Read Medium - Unknown Format" },
193 { 0x30, 0x02, "Cannot Read Medium - Incompatible Format" },
194 { 0x30, 0x03, "Cleaning Cartridge Installed" },
195 { 0x31, 0x00, "Medium Format Corrupted" },
196 { 0x31, 0x01, "Format Command Failed" },
197 { 0x32, 0x00, "No Defect Spare Location Available" },
198 { 0x32, 0x01, "Defect List Update Failure" },
199 { 0x33, 0x00, "Tape Length Error" },
200 { 0x36, 0x00, "Ribbon, Ink, or Toner Failure" },
201 { 0x37, 0x00, "Rounded Parameter" },
202 { 0x39, 0x00, "Saving Parameters Not Supported" },
203 { 0x3A, 0x00, "Medium Not Present" },
204 { 0x3A, 0x01, "Medium Not Present - Tray Closed" },
205 { 0x3A, 0x02, "Medium Not Present - Tray Open" },
206 { 0x3A, 0x03, "Medium Not Present - Loadable" },
207 { 0x3A, 0x04, "Medium Not Present - Medium Auxilliary Memory Accessible" },
208 { 0x3B, 0x00, "Positioning Error" },
209 { 0x3B, 0x01, "Tape Position Error At Beginning-of-Medium" },
210 { 0x3B, 0x02, "Tape Position Error At End-of-Medium" },
211 { 0x3B, 0x03, "Tape or Electronic Vertical Forms Unit Not Ready" },
212 { 0x3B, 0x04, "Slew Failure" },
213 { 0x3B, 0x05, "Paper Jam" },
214 { 0x3B, 0x06, "Failed To Sense Top-Of-Form" },
215 { 0x3B, 0x07, "Failed To Sense Bottom-Of-Form" },
216 { 0x3B, 0x08, "Reposition Error" },
217 { 0x3B, 0x09, "Read Past End Of Medium" },
218 { 0x3B, 0x0A, "Read Past Begining Of Medium" },
219 { 0x3B, 0x0B, "Position Past End Of Medium" },
220 { 0x3B, 0x0C, "Position Past Beginning Of Medium" },
221 { 0x3B, 0x0D, "Medium Destination Element Full" },
222 { 0x3B, 0x0E, "Medium Source Element Empty" },
223 { 0x3D, 0x00, "Invalid Bits In IDENTIFY Message" },
224 { 0x3E, 0x00, "Logical Unit Has Not Self-Configured Yet" },
225 { 0x3F, 0x00, "Target Operating Conditions Have Changed" },
226 { 0x3F, 0x01, "Microcode Has Changed" },
227 { 0x3F, 0x02, "Changed Operating Definition" },
228 { 0x3F, 0x03, "INQUIRY Data Has Changed" },
229 { 0x40, 0x00, "RAM FAILURE (Should Use 40 NN)" },
230 { 0x41, 0x00, "Data Path FAILURE (Should Use 40 NN)" },
231 { 0x42, 0x00, "Power-On or Self-Test FAILURE (Should Use 40 NN)" },
232 { 0x43, 0x00, "Message Error" },
233 { 0x44, 0x00, "Internal Target Failure" },
234 { 0x45, 0x00, "Select Or Reselect Failure" },
235 { 0x46, 0x00, "Unsuccessful Soft Reset" },
236 { 0x47, 0x00, "SCSI Parity Error" },
237 { 0x48, 0x00, "INITIATOR DETECTED ERROR Message Received" },
238 { 0x49, 0x00, "Invalid Message Error" },
239 { 0x4A, 0x00, "Command Phase Error" },
240 { 0x4B, 0x00, "Data Phase Error" },
241 { 0x4C, 0x00, "Logical Unit Failed Self-Configuration" },
242 { 0x4E, 0x00, "Overlapped Commands Attempted" },
243 { 0x50, 0x00, "Write Append Error" },
244 { 0x50, 0x01, "Write Append Position Error" },
245 { 0x50, 0x01, "Write Append Position Error" },
246 { 0x50, 0x02, "Position Error Related To Timing" },
247 { 0x51, 0x00, "Erase Failure" },
248 { 0x52, 0x00, "Cartridge Fault" },
249 { 0x53, 0x00, "Media Load or Eject Failed" },
250 { 0x53, 0x01, "Unload Tape Failure" },
251 { 0x53, 0x02, "Medium Removal Prevented" },
252 { 0x54, 0x00, "SCSI To Host System Interface Failure" },
253 { 0x55, 0x00, "System Resource Failure" },
254 { 0x57, 0x00, "Unable To Recover Table-Of-Contents" },
255 { 0x58, 0x00, "Generation Does Not Exist" },
256 { 0x59, 0x00, "Updated Block Read" },
257 { 0x5A, 0x00, "Operator Request or State Change Input (Unspecified)" },
258 { 0x5A, 0x01, "Operator Medium Removal Requested" },
259 { 0x5A, 0x02, "Operator Selected Write Protect" },
260 { 0x5A, 0x03, "Operator Selected Write Permit" },
261 { 0x5B, 0x00, "Log Exception" },
262 { 0x5B, 0x01, "Threshold Condition Met" },
263 { 0x5B, 0x02, "Log Counter At Maximum" },
264 { 0x5B, 0x03, "Log List Codes Exhausted" },
265 { 0x5C, 0x00, "RPL Status Change" },
266 { 0x5C, 0x01, "Spindles Synchronized" },
267 { 0x5C, 0x02, "Spindles Not Synchronized" },
268 { 0x60, 0x00, "Lamp Failure" },
269 { 0x61, 0x00, "Video Acquisition Error" },
270 { 0x61, 0x01, "Unable To Acquire Video" },
271 { 0x61, 0x02, "Out Of Focus" },
272 { 0x62, 0x00, "Scan Head Positioning Error" },
273 { 0x63, 0x00, "End Of User Area Encountered On This Track" },
274 { 0x64, 0x00, "Illegal Mode For This Track" },
275 { 0x00, 0x00, NULL }
276 };
277 
278 static __inline void asc2ascii __P((unsigned char, unsigned char, char *));
279 
280 static __inline void
281 asc2ascii(asc, ascq, result)
282 	unsigned char asc, ascq;
283 	char *result;
284 {
285 	int i = 0;
286 
287 	while (adesc[i].description != NULL) {
288 		if (adesc[i].asc == asc && adesc[i].ascq == ascq)
289 			break;
290 		i++;
291 	}
292 	if (adesc[i].description == NULL) {
293 		if (asc == 0x40 && ascq != 0)
294 			(void)sprintf(result,
295 			    "Diagnostic Failure on Component 0x%02x",
296 			    ascq & 0xff);
297 		else
298 			(void)sprintf(result, "ASC 0x%02x ASCQ 0x%02x",
299 			    asc & 0xff, ascq & 0xff);
300 	} else
301 		(void)strcpy(result, adesc[i].description);
302 }
303 
304 void
305 scsipi_print_sense_data(sense, verbosity)
306 	struct scsipi_sense_data *sense;
307 	int verbosity;
308 {
309 	int32_t info;
310 	int i, j, k;
311 	char *sbs, *s = (char *) sense;
312 
313 	/*
314 	 * Basics- print out SENSE KEY
315 	 */
316 	printf("    SENSE KEY:  %s", scsipi_decode_sense(s, 0));
317 
318 	/*
319 	 * Print out, unqualified but aligned, FMK, EOM and ILI status.
320 	 */
321 	if (s[2] & 0xe0) {
322 		char pad;
323 	        printf("\n              ");
324 		pad = ' ';
325 		if (s[2] & SSD_FILEMARK) {
326 			printf("%c Filemark Detected", pad);
327 			pad = ',';
328 		}
329 		if (s[2] & SSD_EOM) {
330 			printf("%c EOM Detected", pad);
331 			pad = ',';
332 		}
333 		if (s[2] & SSD_ILI)
334 			printf("%c Incorrect Length Indicator Set", pad);
335 	}
336 
337 	/*
338 	 * Now we should figure out, based upon device type, how
339 	 * to format the information field. Unfortunately, that's
340 	 * not convenient here, so we'll print it as a signed
341 	 * 32 bit integer.
342 	 */
343 	info = _4btol(&s[3]);
344 	if (info)
345 		printf("\n   INFO FIELD:  %d", info);
346 
347 	/*
348 	 * Now we check additional length to see whether there is
349 	 * more information to extract.
350 	 */
351 
352 	/* enough for command specific information? */
353 	if (((unsigned int) s[7]) < 4) {
354 		printf("\n");
355 		return;
356 	}
357 	info = _4btol(&s[8]);
358 	if (info)
359 		printf("\n COMMAND INFO:  %d (0x%x)", info, info);
360 
361 	/*
362 	 * Decode ASC && ASCQ info, plus FRU, plus the rest...
363 	 */
364 
365 	sbs = scsipi_decode_sense(s, 1);
366 	if (sbs)
367 		printf("\n     ASC/ASCQ:  %s", sbs);
368 	if (s[14] != 0)
369 		printf("\n     FRU CODE:  0x%x", s[14] & 0xff);
370 	sbs = scsipi_decode_sense(s, 3);
371 	if (sbs)
372 		printf("\n         SKSV:  %s", sbs);
373 	printf("\n");
374 	if (verbosity == 0) {
375 		printf("\n");
376 		return;
377 	}
378 
379 	/*
380 	 * Now figure whether we should print any additional informtion.
381 	 *
382 	 * Where should we start from? If we had SKSV data,
383 	 * start from offset 18, else from offset 15.
384 	 *
385 	 * From that point until the end of the buffer, check for any
386 	 * nonzero data. If we have some, go back and print the lot,
387 	 * otherwise we're done.
388 	 */
389 	if (sbs)
390 		i = 18;
391 	else
392 		i = 15;
393 	for (j = i; j < sizeof (*sense); j++)
394 		if (s[j])
395 			break;
396 	if (j == sizeof (*sense))
397 		return;
398 
399 	printf("\n Additional Sense Information (byte %d out...):\n", i);
400 	if (i == 15) {
401 		printf("\n\t%2d:", i);
402 		k = 7;
403 	} else {
404 		printf("\n\t%2d:", i);
405 		k = 2;
406 		j -= 2;
407 	}
408 	while (j > 0) {
409 		if (i >= sizeof (*sense))
410 			break;
411 		if (k == 8) {
412 			k = 0;
413 			printf("\n\t%2d:", i);
414 		}
415 		printf(" 0x%02x", s[i] & 0xff);
416 		k++;
417 		j--;
418 		i++;
419 	}
420 	printf("\n\n");
421 }
422 
423 char *
424 scsipi_decode_sense(sinfo, flag)
425 	void *sinfo;
426 	int flag;
427 {
428 	unsigned char *snsbuf;
429 	unsigned char skey;
430 	static char rqsbuf[132];
431 
432 	skey = 0;
433 
434 	snsbuf = (unsigned char *) sinfo;
435 	if (flag == 0 || flag == 2 || flag == 3)
436 		skey = snsbuf[2] & 0xf;
437 	if (flag == 0) {			/* Sense Key Only */
438 		(void) strcpy(rqsbuf, sense_keys[skey]);
439 		return (rqsbuf);
440 	} else if (flag == 1) {			/* ASC/ASCQ Only */
441 		asc2ascii(snsbuf[12], snsbuf[13], rqsbuf);
442 		return (rqsbuf);
443 	} else  if (flag == 2) {		/* Sense Key && ASC/ASCQ */
444 		auto char localbuf[64];
445 		asc2ascii(snsbuf[12], snsbuf[13], localbuf);
446 		(void) sprintf(rqsbuf, "%s, %s", sense_keys[skey], localbuf);
447 		return (rqsbuf);
448 	} else if (flag == 3 && snsbuf[7] >= 9 && (snsbuf[15] & 0x80)) {
449 		/*
450 		 * SKSV Data
451 		 */
452 		switch (skey) {
453 		case SKEY_ILLEGAL_REQUEST:
454 			if (snsbuf[15] & 0x8)
455 				(void)sprintf(rqsbuf,
456 				    "Error in %s, Offset %d, bit %d",
457 				    (snsbuf[15] & 0x40)? "CDB" : "Parameters",
458 				    (snsbuf[16] & 0xff) << 8 |
459 				    (snsbuf[17] & 0xff), snsbuf[15] & 0x7);
460 			else
461 				(void)sprintf(rqsbuf,
462 				    "Error in %s, Offset %d",
463 				    (snsbuf[15] & 0x40)? "CDB" : "Parameters",
464 				    (snsbuf[16] & 0xff) << 8 |
465 				    (snsbuf[17] & 0xff));
466 			return (rqsbuf);
467 		case SKEY_RECOVERED_ERROR:
468 		case SKEY_MEDIUM_ERROR:
469 		case SKEY_HARDWARE_ERROR:
470 			(void)sprintf(rqsbuf, "Actual Retry Count: %d",
471 			    (snsbuf[16] & 0xff) << 8 | (snsbuf[17] & 0xff));
472 			return (rqsbuf);
473 		case SKEY_NOT_READY:
474 			(void)sprintf(rqsbuf, "Progress Indicator: %d",
475 			    (snsbuf[16] & 0xff) << 8 | (snsbuf[17] & 0xff));
476 			return (rqsbuf);
477 		default:
478 			break;
479 		}
480 	}
481 	return (NULL);
482 }
483 
484 void
485 scsipi_print_sense(xs, verbosity)
486 	struct scsipi_xfer *xs;
487 	int verbosity;
488 {
489 	int i, j;
490 
491 	scsipi_printaddr(xs->xs_periph);
492  	printf(" Check Condition on CDB: 0x%02x", xs->cmd->opcode);
493 
494  	switch (CDB_GROUPID(xs->cmd->opcode)) {
495  	case CDB_GROUPID_0:
496  		j = CDB_GROUP0;
497  		break;
498  	case CDB_GROUPID_1:
499  		j = CDB_GROUP1;
500  		break;
501  	case CDB_GROUPID_2:
502  		j = CDB_GROUP2;
503  		break;
504  	case CDB_GROUPID_3:
505  		j = CDB_GROUP3;
506  		break;
507  	case CDB_GROUPID_4:
508  		j = CDB_GROUP4;
509  		break;
510  	case CDB_GROUPID_5:
511  		j = CDB_GROUP5;
512  		break;
513  	case CDB_GROUPID_6:
514  		j = CDB_GROUP6;
515  		break;
516  	case CDB_GROUPID_7:
517  		j = CDB_GROUP7;
518  		break;
519  	default:
520  		j = 0;
521  	}
522  	if (j == 0)
523  		j = sizeof (xs->cmd->bytes);
524  	for (i = 0; i < j-1; i++) /* already done the opcode */
525  		printf(" %02x", xs->cmd->bytes[i]);
526  	printf("\n");
527 	scsipi_print_sense_data(&xs->sense.scsi_sense, verbosity);
528 }
529