sense.h revision 63aa537723d4883425b44d96b6316b7ad14053fc
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _SYS_SCSI_GENERIC_SENSE_H
#define _SYS_SCSI_GENERIC_SENSE_H
#ifdef __cplusplus
extern "C" {
#endif
/*
* Standard (Non-Extended) SCSI Sense.
*
* For Error Classe 0-6. This is all
* Vendor Unique sense information.
*
* Note: This is pre-SCSI-2.
*/
struct scsi_sense {
#if defined(_BIT_FIELDS_LTOH)
#elif defined(_BIT_FIELDS_HTOL)
#else
#endif /* _BIT_FIELDS_LTOH */
};
/*
* SCSI Extended Sense structure
*
* For Error Class 7, the Extended Sense Structure is applicable (now referred
* to in SPC-3 as "fixed format sense data"). The es_code field is used
* to determine whether the extended sense data is actually "fixed format" or
* the newer "descriptor format" introduced in SPC-3.
*/
struct scsi_extended_sense {
#if defined(_BIT_FIELDS_LTOH)
: 1, /* reserved */
#elif defined(_BIT_FIELDS_HTOL)
: 1, /* reserved */
#else
#endif /* _BIT_FIELDS_LTOH */
/*
* Additional bytes may be defined in each implementation.
* The actual amount of space allocated for Sense Information
* is also implementation dependent.
*
* Modulo that, the declaration of an array two bytes in size
* nicely rounds this entire structure to a size of 20 bytes.
*/
};
/*
* Sense code values for Extended Sense
*/
#define CODE_FMT_FIXED_CURRENT 0x0
#define CODE_FMT_FIXED_DEFERRED 0x1
#define CODE_FMT_DESCR_CURRENT 0x2
#define CODE_FMT_DESCR_DEFERRED 0x3
#define CODE_FMT_VENDOR_SPECIFIC 0xF
#define SCSI_IS_DESCR_SENSE(sns_ptr) \
CODE_FMT_DESCR_CURRENT) || \
/*
* Sense Key values for Extended Sense.
*/
#define KEY_NO_SENSE 0x00
#define KEY_RECOVERABLE_ERROR 0x01
#define KEY_NOT_READY 0x02
#define KEY_MEDIUM_ERROR 0x03
#define KEY_HARDWARE_ERROR 0x04
#define KEY_ILLEGAL_REQUEST 0x05
#define KEY_UNIT_ATTENTION 0x06
#define KEY_WRITE_PROTECT 0x07
#define KEY_DATA_PROTECT KEY_WRITE_PROTECT
#define KEY_BLANK_CHECK 0x08
#define KEY_VENDOR_UNIQUE 0x09
#define KEY_COPY_ABORTED 0x0A
#define KEY_ABORTED_COMMAND 0x0B
#define KEY_EQUAL 0x0C
#define KEY_VOLUME_OVERFLOW 0x0D
#define KEY_MISCOMPARE 0x0E
#define KEY_RESERVED 0x0F
/*
* Descriptor sense data header
*
* Descriptor format sense data is described in the SPC-3 standard. Unlike
* the fixed format sense data, descriptor format consists of a header
* followed by a variable length list of sense data descriptors.
*/
struct scsi_descr_sense_hdr {
#if defined(_BIT_FIELDS_LTOH)
#elif defined(_BIT_FIELDS_HTOL)
#else
#endif /* _BIT_FIELDS_LTOH */
};
/*
* SCSI sense descriptors
*/
struct scsi_information_sense_descr {
#if defined(_BIT_FIELDS_LTOH)
#elif defined(_BIT_FIELDS_HTOL)
#else
#endif /* _BIT_FIELDS_LTOH */
};
struct scsi_cmd_specific_sense_descr {
};
union scsi_sk_specific_data {
/*
* Field pointer (Sense key = Illegal Request)
*/
struct {
#if defined(_BIT_FIELDS_LTOH)
bpv : 1,
reserved : 2,
cd : 1,
sksv : 1;
#elif defined(_BIT_FIELDS_HTOL)
cd : 1,
reserved : 2,
bpv : 1,
bit_pointer : 3;
#else
#endif /* _BIT_FIELDS_LTOH */
} fp;
/*
* Actual Retry Count (Sense key = Hardware error,
* Medium Error or Recovered Error)
*/
struct {
} arc;
/*
* Progress Indication (Sense key = No Sense or Not Ready
*/
struct {
} pi;
/*
* Segment Pointer (Sense key = Copy Aborted)
*/
struct {
#if defined(_BIT_FIELDS_LTOH)
bpv : 1,
reserved : 1,
sd : 1,
reserved2 : 1,
sksv : 1;
#elif defined(_BIT_FIELDS_HTOL)
reserved2 : 1,
sd : 1,
reserved : 1,
bpv : 1,
bit_pointer : 3;
#else
#endif /* _BIT_FIELDS_LTOH */
} sp;
};
struct scsi_sk_specific_sense_descr {
union scsi_sk_specific_data sss_data;
};
struct scsi_fru_sense_descr {
};
struct scsi_stream_cmd_data {
#if defined(_BIT_FIELDS_LTOH)
scs_ili : 1,
scs_eom : 1,
scs_filemark : 1;
#elif defined(_BIT_FIELDS_HTOL)
scs_eom : 1,
scs_ili : 1,
scs_reserved2 : 5;
#else
#endif /* _BIT_FIELDS_LTOH */
};
struct scsi_stream_cmd_sense_descr {
struct scsi_stream_cmd_data scs_data;
};
struct scsi_block_cmd_sense_descr {
#if defined(_BIT_FIELDS_LTOH)
bcs_ili : 1,
bcs_reserved3 : 2;
#elif defined(_BIT_FIELDS_HTOL)
bcs_ili : 1,
bcs_reserved2 : 5;
#else
#endif /* _BIT_FIELDS_LTOH */
};
struct scsi_ata_status_ret_sense_descr {
#if defined(_BIT_FIELDS_LTOH)
#elif defined(_BIT_FIELDS_HTOL)
ars_extend : 1;
#else
#endif /* _BIT_FIELDS_LTOH */
};
struct scsi_vendor_specific_sense_descr {
/*
* Variable length vendor specific data
*/
};
/*
* SCSI Descriptor Types
*/
#define DESCR_INFORMATION 0x00
#define DESCR_COMMAND_SPECIFIC 0x01
#define DESCR_SENSE_KEY_SPECIFIC 0x02
#define DESCR_FRU 0x03
#define DESCR_STREAM_COMMANDS 0x04
#define DESCR_BLOCK_COMMANDS 0x05
#define DESCR_OSD_OID 0x06
#define DESCR_OSD_RESP_INTEGRITY 0x07
#define DESCR_OSD_ATTR_ID 0x08
#define DESCR_ATA_STATUS_RETURN 0x09
#ifdef __cplusplus
}
#endif
/*
* Each implementation will have specific mappings to what
* Sense Information means
*/
#endif /* _SYS_SCSI_GENERIC_SENSE_H */