17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*0205780bSrralphs  * Common Development and Distribution License (the "License").
6*0205780bSrralphs  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22*0205780bSrralphs  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23*0205780bSrralphs  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #ifndef	_SYS_SCSI_GENERIC_STATUS_H
277c478bd9Sstevel@tonic-gate #define	_SYS_SCSI_GENERIC_STATUS_H
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
307c478bd9Sstevel@tonic-gate extern "C" {
317c478bd9Sstevel@tonic-gate #endif
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate /*
347c478bd9Sstevel@tonic-gate  * SCSI status completion block
357c478bd9Sstevel@tonic-gate  *
367c478bd9Sstevel@tonic-gate  * The SCSI standard specifies one byte of status.
377c478bd9Sstevel@tonic-gate  */
387c478bd9Sstevel@tonic-gate 
397c478bd9Sstevel@tonic-gate /*
407c478bd9Sstevel@tonic-gate  * The definition of of the Status block as a bitfield
417c478bd9Sstevel@tonic-gate  */
427c478bd9Sstevel@tonic-gate 
437c478bd9Sstevel@tonic-gate struct scsi_status {
447c478bd9Sstevel@tonic-gate #if defined(_BIT_FIELDS_LTOH)
457c478bd9Sstevel@tonic-gate 	uchar_t	sts_vu0		: 1,	/* vendor unique 		*/
467c478bd9Sstevel@tonic-gate 		sts_chk		: 1,	/* check condition 		*/
477c478bd9Sstevel@tonic-gate 		sts_cm		: 1,	/* condition met 		*/
487c478bd9Sstevel@tonic-gate 		sts_busy	: 1,	/* device busy or reserved 	*/
497c478bd9Sstevel@tonic-gate 		sts_is		: 1,	/* intermediate status sent 	*/
507c478bd9Sstevel@tonic-gate 		sts_vu6		: 1,	/* vendor unique 		*/
517c478bd9Sstevel@tonic-gate 		sts_vu7		: 1,	/* vendor unique 		*/
527c478bd9Sstevel@tonic-gate 		sts_resvd	: 1;	/* reserved 			*/
537c478bd9Sstevel@tonic-gate #elif defined(_BIT_FIELDS_HTOL)
547c478bd9Sstevel@tonic-gate 	uchar_t	sts_resvd	: 1,	/* reserved */
557c478bd9Sstevel@tonic-gate 		sts_vu7		: 1,	/* vendor unique */
567c478bd9Sstevel@tonic-gate 		sts_vu6		: 1,	/* vendor unique */
577c478bd9Sstevel@tonic-gate 		sts_is		: 1,	/* intermediate status sent */
587c478bd9Sstevel@tonic-gate 		sts_busy	: 1,	/* device busy or reserved */
597c478bd9Sstevel@tonic-gate 		sts_cm		: 1,	/* condition met */
607c478bd9Sstevel@tonic-gate 		sts_chk		: 1,	/* check condition */
617c478bd9Sstevel@tonic-gate 		sts_vu0		: 1;	/* vendor unique */
627c478bd9Sstevel@tonic-gate #else
637c478bd9Sstevel@tonic-gate #error	One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined
647c478bd9Sstevel@tonic-gate #endif	/* _BIT_FIELDS_LTOH */
657c478bd9Sstevel@tonic-gate };
667c478bd9Sstevel@tonic-gate #define	sts_scsi2	sts_vu6		/* SCSI modifier bit */
677c478bd9Sstevel@tonic-gate 
687c478bd9Sstevel@tonic-gate /*
697c478bd9Sstevel@tonic-gate  * if auto request sense has been enabled, then use this structure
707c478bd9Sstevel@tonic-gate  */
717c478bd9Sstevel@tonic-gate struct scsi_arq_status {
727c478bd9Sstevel@tonic-gate 	struct scsi_status	sts_status;
737c478bd9Sstevel@tonic-gate 	struct scsi_status	sts_rqpkt_status;
747c478bd9Sstevel@tonic-gate 	uchar_t			sts_rqpkt_reason;	/* reason completion */
757c478bd9Sstevel@tonic-gate 	uchar_t			sts_rqpkt_resid;	/* residue */
767c478bd9Sstevel@tonic-gate 	uint_t			sts_rqpkt_state;	/* state of command */
777c478bd9Sstevel@tonic-gate 	uint_t			sts_rqpkt_statistics;	/* statistics */
787c478bd9Sstevel@tonic-gate 	struct scsi_extended_sense sts_sensedata;
797c478bd9Sstevel@tonic-gate };
807c478bd9Sstevel@tonic-gate 
817c478bd9Sstevel@tonic-gate #define	SECMDS_STATUS_SIZE  (sizeof (struct scsi_arq_status))
827c478bd9Sstevel@tonic-gate 
837c478bd9Sstevel@tonic-gate /*
847c478bd9Sstevel@tonic-gate  * Bit Mask definitions, for use accessing the status as a byte.
857c478bd9Sstevel@tonic-gate  */
867c478bd9Sstevel@tonic-gate 
877c478bd9Sstevel@tonic-gate #define	STATUS_MASK			0x3E
887c478bd9Sstevel@tonic-gate #define	STATUS_GOOD			0x00
897c478bd9Sstevel@tonic-gate #define	STATUS_CHECK			0x02
907c478bd9Sstevel@tonic-gate #define	STATUS_MET			0x04
917c478bd9Sstevel@tonic-gate #define	STATUS_BUSY			0x08
927c478bd9Sstevel@tonic-gate #define	STATUS_INTERMEDIATE		0x10
937c478bd9Sstevel@tonic-gate #define	STATUS_SCSI2			0x20
947c478bd9Sstevel@tonic-gate #define	STATUS_INTERMEDIATE_MET		0x14
957c478bd9Sstevel@tonic-gate #define	STATUS_RESERVATION_CONFLICT	0x18
967c478bd9Sstevel@tonic-gate #define	STATUS_TERMINATED		0x22
977c478bd9Sstevel@tonic-gate #define	STATUS_QFULL			0x28
987c478bd9Sstevel@tonic-gate #define	STATUS_ACA_ACTIVE		0x30
99*0205780bSrralphs #define	STATUS_TASK_ABORT		0x40
1007c478bd9Sstevel@tonic-gate 
1017c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
1027c478bd9Sstevel@tonic-gate }
1037c478bd9Sstevel@tonic-gate #endif
1047c478bd9Sstevel@tonic-gate 
1057c478bd9Sstevel@tonic-gate /*
1067c478bd9Sstevel@tonic-gate  * Some deviations from the one byte of Status are known. Each
1077c478bd9Sstevel@tonic-gate  * implementation will define them specifically
1087c478bd9Sstevel@tonic-gate  */
1097c478bd9Sstevel@tonic-gate 
1107c478bd9Sstevel@tonic-gate #include <sys/scsi/impl/status.h>
1117c478bd9Sstevel@tonic-gate 
1127c478bd9Sstevel@tonic-gate #endif	/* _SYS_SCSI_GENERIC_STATUS_H */
113