xref: /titanic_41/usr/src/uts/common/sys/scsi/generic/status.h (revision fcf3ce441efd61da9bb2884968af01cb7c1452cc)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_SYS_SCSI_GENERIC_STATUS_H
27 #define	_SYS_SCSI_GENERIC_STATUS_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #ifdef	__cplusplus
32 extern "C" {
33 #endif
34 
35 /*
36  * SCSI status completion block
37  *
38  * The SCSI standard specifies one byte of status.
39  */
40 
41 /*
42  * The definition of of the Status block as a bitfield
43  */
44 
45 struct scsi_status {
46 #if defined(_BIT_FIELDS_LTOH)
47 	uchar_t	sts_vu0		: 1,	/* vendor unique 		*/
48 		sts_chk		: 1,	/* check condition 		*/
49 		sts_cm		: 1,	/* condition met 		*/
50 		sts_busy	: 1,	/* device busy or reserved 	*/
51 		sts_is		: 1,	/* intermediate status sent 	*/
52 		sts_vu6		: 1,	/* vendor unique 		*/
53 		sts_vu7		: 1,	/* vendor unique 		*/
54 		sts_resvd	: 1;	/* reserved 			*/
55 #elif defined(_BIT_FIELDS_HTOL)
56 	uchar_t	sts_resvd	: 1,	/* reserved */
57 		sts_vu7		: 1,	/* vendor unique */
58 		sts_vu6		: 1,	/* vendor unique */
59 		sts_is		: 1,	/* intermediate status sent */
60 		sts_busy	: 1,	/* device busy or reserved */
61 		sts_cm		: 1,	/* condition met */
62 		sts_chk		: 1,	/* check condition */
63 		sts_vu0		: 1;	/* vendor unique */
64 #else
65 #error	One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined
66 #endif	/* _BIT_FIELDS_LTOH */
67 };
68 #define	sts_scsi2	sts_vu6		/* SCSI modifier bit */
69 
70 /*
71  * if auto request sense has been enabled, then use this structure
72  */
73 struct scsi_arq_status {
74 	struct scsi_status	sts_status;
75 	struct scsi_status	sts_rqpkt_status;
76 	uchar_t			sts_rqpkt_reason;	/* reason completion */
77 	uchar_t			sts_rqpkt_resid;	/* residue */
78 	uint_t			sts_rqpkt_state;	/* state of command */
79 	uint_t			sts_rqpkt_statistics;	/* statistics */
80 	struct scsi_extended_sense sts_sensedata;
81 };
82 
83 #define	SECMDS_STATUS_SIZE  (sizeof (struct scsi_arq_status))
84 
85 /*
86  * Bit Mask definitions, for use accessing the status as a byte.
87  */
88 
89 #define	STATUS_MASK			0x3E
90 #define	STATUS_GOOD			0x00
91 #define	STATUS_CHECK			0x02
92 #define	STATUS_MET			0x04
93 #define	STATUS_BUSY			0x08
94 #define	STATUS_INTERMEDIATE		0x10
95 #define	STATUS_SCSI2			0x20
96 #define	STATUS_INTERMEDIATE_MET		0x14
97 #define	STATUS_RESERVATION_CONFLICT	0x18
98 #define	STATUS_TERMINATED		0x22
99 #define	STATUS_QFULL			0x28
100 #define	STATUS_ACA_ACTIVE		0x30
101 #define	STATUS_TASK_ABORT		0x40
102 
103 #ifdef	__cplusplus
104 }
105 #endif
106 
107 /*
108  * Some deviations from the one byte of Status are known. Each
109  * implementation will define them specifically
110  */
111 
112 #include <sys/scsi/impl/status.h>
113 
114 #endif	/* _SYS_SCSI_GENERIC_STATUS_H */
115