xref: /illumos-gate/usr/src/uts/common/sys/scsi/generic/status.h (revision 9164a50bf932130cbb5097a16f6986873ce0e6e5)
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 #ifdef	__cplusplus
30 extern "C" {
31 #endif
32 
33 /*
34  * SCSI status completion block
35  *
36  * The SCSI standard specifies one byte of status.
37  */
38 
39 /*
40  * The definition of of the Status block as a bitfield
41  */
42 
43 struct scsi_status {
44 #if defined(_BIT_FIELDS_LTOH)
45 	uchar_t	sts_vu0		: 1,	/* vendor unique 		*/
46 		sts_chk		: 1,	/* check condition 		*/
47 		sts_cm		: 1,	/* condition met 		*/
48 		sts_busy	: 1,	/* device busy or reserved 	*/
49 		sts_is		: 1,	/* intermediate status sent 	*/
50 		sts_vu6		: 1,	/* vendor unique 		*/
51 		sts_vu7		: 1,	/* vendor unique 		*/
52 		sts_resvd	: 1;	/* reserved 			*/
53 #elif defined(_BIT_FIELDS_HTOL)
54 	uchar_t	sts_resvd	: 1,	/* reserved */
55 		sts_vu7		: 1,	/* vendor unique */
56 		sts_vu6		: 1,	/* vendor unique */
57 		sts_is		: 1,	/* intermediate status sent */
58 		sts_busy	: 1,	/* device busy or reserved */
59 		sts_cm		: 1,	/* condition met */
60 		sts_chk		: 1,	/* check condition */
61 		sts_vu0		: 1;	/* vendor unique */
62 #else
63 #error	One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined
64 #endif	/* _BIT_FIELDS_LTOH */
65 };
66 #define	sts_scsi2	sts_vu6		/* SCSI modifier bit */
67 
68 /*
69  * if auto request sense has been enabled, then use this structure
70  */
71 struct scsi_arq_status {
72 	struct scsi_status	sts_status;
73 	struct scsi_status	sts_rqpkt_status;
74 	uchar_t			sts_rqpkt_reason;	/* reason completion */
75 	uchar_t			sts_rqpkt_resid;	/* residue */
76 	uint_t			sts_rqpkt_state;	/* state of command */
77 	uint_t			sts_rqpkt_statistics;	/* statistics */
78 	struct scsi_extended_sense sts_sensedata;
79 };
80 
81 #define	SECMDS_STATUS_SIZE  (sizeof (struct scsi_arq_status))
82 
83 /*
84  * Bit Mask definitions, for use accessing the status as a byte.
85  */
86 
87 #define	STATUS_MASK			0x3E
88 #define	STATUS_GOOD			0x00
89 #define	STATUS_CHECK			0x02
90 #define	STATUS_MET			0x04
91 #define	STATUS_BUSY			0x08
92 #define	STATUS_INTERMEDIATE		0x10
93 #define	STATUS_SCSI2			0x20
94 #define	STATUS_INTERMEDIATE_MET		0x14
95 #define	STATUS_RESERVATION_CONFLICT	0x18
96 #define	STATUS_TERMINATED		0x22
97 #define	STATUS_QFULL			0x28
98 #define	STATUS_ACA_ACTIVE		0x30
99 #define	STATUS_TASK_ABORT		0x40
100 
101 #ifdef	__cplusplus
102 }
103 #endif
104 
105 /*
106  * Some deviations from the one byte of Status are known. Each
107  * implementation will define them specifically
108  */
109 
110 #include <sys/scsi/impl/status.h>
111 
112 #endif	/* _SYS_SCSI_GENERIC_STATUS_H */
113