ses.h revision 0a2f1c3af09621047a6af13cfbe146b155c0277f
/*
* 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
*/
/*
* Enclosure Services Device target driver
*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _SYS_SCSI_TARGETS_SES_H
#define _SYS_SCSI_TARGETS_SES_H
#ifdef __cplusplus
extern "C" {
#endif
/*
* Useful defines and typedefs
*/
#define EOK 0
#define INVOP 0x10
#define Scsidevp struct scsi_device *
#define UNUSED_PARAMETER(x) x = x
/*
* SAF-TE specific defines- Mandatory ones only...
*/
/*
* READ BUFFER ('get' commands) IDs- placed in offset 2 of cdb
*/
/*
* WRITE BUFFER ('set' commands) IDs- placed in offset 0 of databuf
*/
/*
* Includes
*/
/*
* Private info (Device Info. Private)
*
* Pointed to by the un_private pointer
* of one of the SCSI_DEVICE structures.
*/
typedef struct ses_softc ses_softc_t;
typedef struct {
int (*softc_init)(ses_softc_t *, int);
int (*init_enc)(ses_softc_t *);
int (*get_encstat)(ses_softc_t *, int);
} encvec;
typedef struct {
} encobj;
#ifndef __lint /* no warlock for X86 */
#ifdef _KERNEL
#endif /* _KERNEL */
#endif /* __lint */
/*
* Overall Status is bits 0..3- status validity reserved at bit 7
*/
#define ENCI_SVALID 0x80
struct ses_softc {
void * ses_private; /* private data */
int ses_retries; /* retry count */
/*
* Associated storage for the special buf.
* Since we're single threaded on sbuf anyway,
* we might as well save ourselves a pile of
* grief and allocate local uscsicmd and
* ancillary storage here.
*/
};
#ifndef __lint /* no warlock for X86 */
#ifdef _KERNEL
#endif /* _KERNEL */
#endif /* __lint */
/*
* Compile options to turn on debugging code
*/
#ifdef DEBUG
#define SES_DEBUG
#endif /* DEBUG */
#ifndef SES_DEBUG
#define ses_debug 0
#endif /* SES_DEBUG */
/*
* Various I/O timeouts.
*
* These are hard-coded and not adjustable. The restart macro
* time input is in milliseconds with 1 msec. the minimum setting.
*
*/
drv_usectohz(1000)); \
}
/*
* Number of times we'll retry a normal operation.
*
* Note, retries have differnt weights to max retries.
* Unit Attention and request sense have the most retries.
* Command retries have the least.
*
* For no auto-request sense operation, the SES_RETRY_MULTIPLIER
* must be greater than the command RETRY_COUNT. Then the request
* sense commands won't impact the command retries.
*/
#define SES_RETRY_COUNT 4
#define SES_RETRY_MULTIPLIER 8
#define SES_CMD_RETRY SES_RETRY_MULTIPLIER
#define SES_NO_RETRY 0
#define SES_SENSE_RETRY 1
#define SES_BUSY_RETRY 4
/* Retry weight is 1 */
#define SES_CMD_RETRY1(retry) \
/* Retry weight is 2 */
#define SES_CMD_RETRY2(retry) \
/* Retry weight is 4 */
#define SES_CMD_RETRY4(retry) \
/*
* ses_present definitions
*/
#define SES_CLOSED 0
#define SES_OPENING 1
#define SES_OPEN 2
/*
* ses_callback action codes
*/
#define COMMAND_DONE 0
#define COMMAND_DONE_ERROR 1
#define QUE_COMMAND_NOW 3
#define QUE_COMMAND 4
#define QUE_SENSE 5
/*
* PF bit for RECEIVE DIAG command;
* needed for RSM first release hw.
*/
#define SCSI_ESI_PF 0x10
#define SEN_ID "UNISYS SUN_SEN"
#define SEN_ID_LEN 24
/*
* Common Driver Functions
*/
#if defined(_KERNEL)
extern void ses_log(ses_softc_t *, int, const char *, ...);
extern int ses_io_time;
#ifdef DEBUG
extern int ses_debug;
#endif /* DEBUG */
#endif /* defined(_KERNEL) */
#endif /* defined(_KERNEL) || defined(_KMEMUSER) */
#ifdef __cplusplus
}
#endif
#endif /* _SYS_SCSI_TARGETS_SES_H */