scsi_util.h revision 724365f7556fc4201fdb11766ebc6bd918523130
/*
* 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 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _SCSI_UTIL_H
#define _SCSI_UTIL_H
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Definitions for data structures used in the SCSI IE module
*/
#ifdef __cplusplus
extern "C" {
#endif
#include <sys/byteorder.h>
/*
* Log page structures
*/
#pragma pack(1)
struct log_header {
#if defined(_BIT_FIELDS_LTOH)
rsrvd : 2;
#elif defined(_BIT_FIELDS_HTOL)
code : 6;
#else
#endif /* _BIT_FIELDS_LTOH */
};
struct log_parameter_header {
#if defined(_BIT_FIELDS_LTOH)
lbin : 1,
tmc : 2,
etc : 1,
tsd : 1,
ds : 1,
du : 1;
#elif defined(_BIT_FIELDS_HTOL)
ds : 1,
tsd : 1,
etc : 1,
tmc : 2,
lbin : 1,
lp : 1;
#else
#endif /* _BIT_FIELDS_LTOH */
};
struct supported_log_pages {
struct log_header hdr;
};
/*
* Specific log page parameters:
*/
struct info_excpt_log_param {
struct log_parameter_header hdr;
/*
* The following fields may or may not exist -- depending on the
* length specified in the log parameter header.
*/
union {
struct ie_ibm_extensions {
} ibm_e;
} vnd;
};
/*
* The SCSI-3 SPC document states that IE log page (0x2F) parameter 0
* must have a length of at least 4 (including the length byte).
* Drives that provide 5 bytes use the 5th byte as the temperature
* threshold (reference) value.
*/
#define INVALID_TEMPERATURE 0xff
#define LOGPARAM_IE 0x0000
struct temperature_log_param_curtemp {
struct log_parameter_header hdr;
};
struct temperature_log_param_reftemp {
struct log_parameter_header hdr;
#define REFTEMP_INVALID 0xff
};
struct selftest_log_parameter {
struct log_parameter_header hdr;
#if defined(_BIT_FIELDS_LTOH)
rsrvd : 1,
testcode : 3;
#elif defined(_BIT_FIELDS_HTOL)
rsrvd : 1,
results : 4;
#endif /* _BIT_FIELDS_LTOH */
#if defined(_BIT_FIELDS_LTOH)
rsrvd1 : 4;
#elif defined(_BIT_FIELDS_HTOL)
sense_key : 4;
#endif /* _BIT_FIELDS_LTOH */
};
/* The results field of the self-test log parameter */
#define SELFTEST_FAILURE_INCOMPLETE 3
#define SELFTEST_FAILURE_SEG_UNKNOWN 4
#define SELFTEST_FAILURE_SEG_FIRST 5
#define SELFTEST_FAILURE_SEG_SECOND 6
#define SELFTEST_FAILURE_SEG_OTHER 7
#define LOGPARAM_TEMP_CURTEMP 0x0000
#define LOGPARAM_TEMP_REFTEMP 0x0001
#define LOGPARAM_TEMP_CURTEMP_LEN \
(sizeof (struct temperature_log_param_curtemp) - \
sizeof (struct log_parameter_header))
#define LOGPARAM_TEMP_REFTEMP_LEN \
(sizeof (struct temperature_log_param_reftemp) - \
sizeof (struct log_parameter_header))
/*
*/
struct scsi_ms_header {
struct mode_header mode_header;
struct block_descriptor block_descriptor;
};
struct scsi_ms_header_g1 {
struct mode_header_g1 mode_header;
struct block_descriptor block_descriptor;
};
struct info_except_page {
#if defined(_BIT_FIELDS_LTOH)
rsrvd1 : 1,
rsrvd2 : 1,
rsrvd3 : 4;
#elif defined(_BIT_FIELDS_HTOL)
rsrvd2 : 1,
rsrvd1 : 1,
#else
#endif /* _BIT_FIELDS_LTOH */
};
#pragma pack()
#define MODEPAGE_INFO_EXCPT_LEN (sizeof (struct info_except_page))
/*
* Values for the MSIE field of the informational exceptions control mode page
*/
#define IE_REPORT_NONE 0
#define IE_REPORT_ASYNCH 1
#define IE_REPORT_UNIT_ATTN 2
#define IE_REPORT_RECOV_ERR_COND 3
#define IE_REPORT_RECOV_ERR_ALWAYS 4
#define IE_REPORT_NO_SENSE 5
#define IE_REPORT_ON_REQUEST 6
/*
* Constants in support of the CONTROL MODE mode page (page 0xA)
*/
#define MODEPAGE_CTRL_MODE_LEN (sizeof (struct mode_control_scsi3))
#define LOGPAGE_SELFTEST_MIN_PARAM_CODE 0x0001
#define LOGPAGE_SELFTEST_MAX_PARAM_CODE 0x0014
#define LOGPAGE_SELFTEST_PARAM_LEN \
((sizeof (struct selftest_log_parameter)) - \
(sizeof (struct log_parameter_header)))
/*
* Macro to extract the length of a mode sense page
* as returned by a target.
*/
sizeof (struct mode_page))
/*
* Mode Select options
*/
#define MODE_SELECT_SP 0x01
#define MODE_SELECT_PF 0x10
/*
* Mode Sense Page Control
*/
#define PC_CURRENT (0 << 6)
/*
* Log Sense Page Control
*/
/*
* These flags are used to control disk command execution.
*/
/*
* LOG page codes
*/
#define LOGPAGE_SUPP_LIST 0x00
#define LOGPAGE_TEMP 0x0d
#define LOGPAGE_SELFTEST 0x10
#define LOGPAGE_IE 0x2f
/*
* "impossible" status value
*/
#define IMPOSSIBLE_SCSI_STATUS 0xff
/*
* Minimum length of Request Sense data that we can accept
*/
#define MIN_REQUEST_SENSE_LEN 18
/*
* Rounded parameter, as returned in Extended Sense information
*/
#define ROUNDED_PARAMETER 0x37
/* ASC constants */
#define ASC_INVALID_OPCODE 0x20
#define ASC_INVALID_CDB_FIELD 0x24
#define ASC_FAILURE_PREDICTION_THRESHOLD_EXCEEDED 0x5d
/* ASCQ constants */
#define ASCQ_INVALID_OPCODE 0
/* Error tests: */
#define SCSI_INVALID_OPCODE(s, a, aq) \
(((s) == KEY_ILLEGAL_REQUEST) && ((a) == ASC_INVALID_OPCODE) && \
((aq) == ASCQ_INVALID_OPCODE))
#define MODE_PAGE_UNSUPPORTED(s, a, aq) \
(((s) == KEY_ILLEGAL_REQUEST) && ((a) == ASC_INVALID_CDB_FIELD))
int *rqblen);
#ifdef __cplusplus
}
#endif
#endif /* _SCSI_UTIL_H */