sense.h revision 3a27445b7bb9d714bc575b48634a50f1f599fdab
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The contents of this file are subject to the terms of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Common Development and Distribution License (the "License").
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You may not use this file except in compliance with the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * or http://www.opensolaris.org/os/licensing.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and limitations under the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * When distributing Covered Code, include this CDDL HEADER in each
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If applicable, add the following below this CDDL HEADER, with the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fields enclosed by brackets "[]" replaced with your own identifying
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * information: Portions Copyright [yyyy] [name of copyright owner]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER END
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifndef _SYS_SCSI_IMPL_SENSE_H
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define _SYS_SCSI_IMPL_SENSE_H
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#pragma ident "%Z%%M% %I% %E% SMI"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef __cplusplus
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern "C" {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Implementation Variant defines
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * for SCSI Sense Information
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * These are 'pseudo' sense keys for common Sun implementation driver
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * detected errors. Note that they start out as being higher than the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * legal key numbers for standard SCSI.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define SUN_KEY_FATAL 0x10 /* driver, scsi handshake failure */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define SUN_KEY_TIMEOUT 0x11 /* driver, command timeout */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define SUN_KEY_EOF 0x12 /* driver, eof hit */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define SUN_KEY_EOT 0x13 /* driver, eot hit */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define SUN_KEY_LENGTH 0x14 /* driver, length error */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define SUN_KEY_BOT 0x15 /* driver, bot hit */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define SUN_KEY_WRONGMEDIA 0x16 /* driver, wrong tape media */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define NUM_IMPL_SENSE_KEYS 7 /* seven extra keys */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Common sense length allocation sufficient for this implementation.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define SENSE_LENGTH \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (roundup(sizeof (struct scsi_extended_sense), sizeof (int)))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Minimum useful Sense Length value
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define SUN_MIN_SENSE_LENGTH 4
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Specific variants to the Extended Sense structure.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Defines for:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Emulex MD21 SCSI/ESDI Controller
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Emulex MT02 SCSI/QIC-36 Controller.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 1) The Emulex controllers put error class and error code into the byte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * right after the 'additional sense length' field in Extended Sense.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 2) Except that some people state that this isn't so for the MD21- only
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the MT02.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define emulex_ercl_ercd es_cmd_info[0]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 2) These are valid on Extended Sense for the MD21, FORMAT command only:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define emulex_cyl_msb es_info_1
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define emulex_cyl_lsb es_info_2
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define emulex_head_num es_info_3
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define emulex_sect_num es_info_4
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestruct scsi_descr_template {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uchar_t sdt_descr_type;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uchar_t sdt_addl_length;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Function prototypes for descriptor-format sense data functions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteuint8_t *scsi_find_sense_descr(uint8_t *sense_buffer, int sense_buf_len,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int descr_type);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Function prototypes for format-neutral sense data functions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteuint8_t scsi_sense_key(uint8_t *sense_buffer);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteuint8_t scsi_sense_asc(uint8_t *sense_buffer);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteuint8_t scsi_sense_ascq(uint8_t *sense_buffer);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteboolean_t scsi_sense_info_uint64(uint8_t *sense_buffer,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int sense_buf_len, uint64_t *information);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteboolean_t scsi_sense_cmdspecific_uint64(uint8_t *sense_buffer,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int sense_buf_len, uint64_t *cmd_spec_info);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid scsi_ext_sense_fields(uint8_t *sense_buffer, int sense_buf_len,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t **information, uint8_t **cmd_spec_info, uint8_t **fru_code,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t **sk_specific, uint8_t **stream_flags);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint scsi_validate_sense(uint8_t *sense_buffer, int sense_buf_len, int *flags);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Return codes for scsi_validate_sense
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define SENSE_UNUSABLE 0
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define SENSE_FIXED_FORMAT 1
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define SENSE_DESCR_FORMAT 2
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Flags from scsi_validate_sense
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define SNS_BUF_OVERFLOW 1 /* Sense buffer too small */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define SNS_BUF_DEFERRED 2 /* Sense data is for prior operation */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef __cplusplus
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* _SYS_SCSI_IMPL_SENSE_H */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte