stdef.h revision f3531714ff8a7263ce18dd2161d4c64d580dd6d7
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _SYS_SCSI_TARGETS_STDEF_H
#define _SYS_SCSI_TARGETS_STDEF_H
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef __cplusplus
extern "C" {
#endif
/*
* Defines for SCSI tape drives.
*/
/*
* Maximum variable length record size for a single request
*/
#define ST_MAXRECSIZE_VARIABLE 65535
/*
* If the requested record size exceeds ST_MAXRECSIZE_VARIABLE,
* then the following define is used.
*/
#define ST_MAXRECSIZE_VARIABLE_LIMIT 65534
#define INF 1000000000
/*
* Supported tape device types plus default type for opening.
* Types 10 - 13, are special (ancient too) drives - *NOT SUPPORTED*
* Types 14 - 1f, are 1/4-inch cartridge drives.
* Types 20 - 28, are 1/2-inch cartridge or reel drives.
* Types 28+, are rdat (vcr) drives.
*/
#define ST_TYPE_INVALID 0x00
/* Internal flags */
/* alloc'ed from the st.conf entry, */
/* instead of being used from the */
/* st_drivetypes array. */
/*
* Defines for supported drive options
*
* WARNING : THESE OPTIONS SHOULD NEVER BE CHANGED, AS OLDER CONFIGURATIONS
* WILL DEPEND ON THE FLAG VALUES REMAINING THE SAME
*/
/* length record sizes */
/* file as in mt(1) bsf : */
/* backspace over EOF marks. */
/* Devices not supporting bsf */
/* will fail with ENOTTY upon */
/* use of bsf */
/* record as in mt(1) bsr : */
/* backspace over records. If */
/* the device does not support */
/* bsr, the st driver emulates */
/* the action by rewinding the */
/* tape and using forward space */
/* file (fsf) to the correct */
/* file and then uses forward */
/* space record (fsr) to the */
/* correct record */
/* than normal to erase */
/* Device can figure out the */
/* tape density automatically, */
/* without issuing a */
/* mode-select/mode-sense */
/* This disables the device's */
/* ability for buffered writes */
/* I.e. The device acknowledges */
/* write completion after the */
/* data is written to the */
/* device's buffer, but before */
/* all the data is actually */
/* written to tape */
/* parity while talking to it. */
/* of Data) has been reached. */
/* If the device knows EOD, st */
/* uses fast file skipping. */
/* If it does not know EOD, */
/* file skipping happens one */
/* file at a time. */
/* the st driver is unloaded & */
/* loaded again; e.g. will */
/* return the correct inquiry */
/* string */
/* close to report soft errors. */
/* Currently only Exabyte and */
/* DAT drives support this */
/* feature. */
/* timeouts for normal */
/* operation */
/* driver and pre-acked to the */
/* application */
/* devices only. If flag is */
/* set, then don't limit */
/* record size to 64k as in */
/* pre-Solaris 2.4 releases. */
/* The only limit on the */
/* record size will be the max */
/* record size the device can */
/* handle or the max DMA */
/* transfer size of the */
/* machine, which ever is */
/* smaller. Beware of */
/* incompatabilities with */
/* tapes of pre-Solaris 2.4 */
/* OS's written with large */
/* (>64k) block sizes, as */
/* their true block size is */
/* a max of approx 64k */
/* configuration page (0x10) to */
/* instead of density codes for */
/* the "c" and "u" devices */
/* command. If this is enabled */
/* not be used during open/ */
/* close for High Availability */
/* to variable block devices */
/* which support the SILI bit */
/* option. It indicates that */
/* the SILI bit will be ignored */
/* during reads */
/* EOF marks do not indicate an */
/* EOM. This option is only */
/* supported on 1/2" reel tapes */
/* EXABYTE 8mm tape drives */
/* which support short */
/* filemarks. When this flag */
/* is set, short filemarks */
/* will be used for writing */
/* filemarks. */
/* and the tape is trapped in */
/* the medium changer, the tape */
/* is automatically ejected */
#define ST_RETRY_ON_RECOVERED_DEFERRED_ERROR 0x400000
/* This option applies only to */
/* IBM MAGSTAR 3590. If this */
/* flag is set, the st driver */
/* will retry the last cmd if */
/* the last error cause a check */
/* condition with error code */
/* 0x71 and sense code 0x01 */
/* detected to select correct */
/* density code. */
/* the tape drive provides the */
/* clean bit information in */
/* byte 21, bitmask 0x08 of */
/* Request Sense data */
/* the tape drive provides the */
/* clean bit information in */
/* byte 70, bitmask 0xc0 of */
/* Request Sense data */
/* the tape drive provides the */
/* clean bit information in */
/* byte 18, bitmask 0x01 of */
/* Request Sense data */
#define NDENSITIES MT_NDENSITIES
#define NSPEEDS MT_NSPEEDS
/*
* defines for Log Sense Pages
*/
#define SUPPORTED_LOG_PAGES_PAGE 0x00
#define TAPE_SEQUENTIAL_PAGE 0x0c
#define TAPE_ALERT_PAGE 0x2e
/*
* Log Page Control definitions
*/
#define CURRENT_THRESHOLD_VALUES 0x00
#define CURRENT_CUMULATIVE_VALUES 0x40
#define DEFAULT_THRESHOLD_VALUES 0x80
#define DEFAULT_CUMULATIVE_VALUES 0xC0
/*
* Tape Alert Flag definitions
*/
#define CLEANING_MEDIA 11
#define CLEAN_NOW 20
#define CLEAN_PERIODIC 21
#define CLEAN_FOR_ERRORS 24
#define TAPE_ALERT_SUPPORT_UNKNOWN 0x00
#define TAPE_ALERT_NOT_SUPPORTED 0x01
#define TAPE_ALERT_SUPPORTED 0x02
#define TAPE_ALERT_STILL_DIRTY 0x04
#define TAPE_SEQUENTIAL_SUPPORTED 0x08
#define TAPE_PREVIOUSLY_DIRTY 0x10
#define TAPE_ALERT_MAX_PARA 64
#define SEQUENTIAL_NEED_CLN 0x0100
/*
* Parameters
*/
struct st_drivetype {
char length; /* Length of vendor id */
char type; /* Drive type for driver */
int bsize; /* Block size */
int options; /* Drive options */
int max_rretries; /* Max read retries */
int max_wretries; /* Max write retries */
};
struct comp_mode_page {
#if defined(_BIT_FIELDS_LTOH)
uchar_t : 6,
uchar_t : 5,
#elif defined(_BIT_FIELDS_HTOL)
: 6;
: 5;
#endif
};
struct dev_mode_page {
#if defined(_BIT_FIELDS_LTOH)
: 1;
uchar_t : 3,
eod_defined: 3;
#elif defined(_BIT_FIELDS_HTOL)
uchar_t : 1,
: 3;
#endif
};
typedef union {
struct comp_mode_page comp;
struct dev_mode_page dev;
}modepage;
/*
*
* Parameter list for the MODE_SELECT and MODE_SENSE commands.
* The parameter list contains a header, followed by zero or more
* block descriptors, followed by vendor unique parameters, if any.
*
*/
struct seq_mode {
#if defined(_BIT_FIELDS_LTOH)
: 1,
#elif defined(_BIT_FIELDS_HTOL)
: 1,
page_code: 6;
#else
#endif /* _BIT_FIELDS_LTOH */
};
/*
* Data returned from the READ BLOCK LIMITS command.
*/
#define RBLSIZE (sizeof (struct read_blklim))
struct read_blklim {
#if defined(_BIT_FIELDS_HTOL)
#elif defined(_BIT_FIELDS_LTOH)
#endif
};
#ifdef _KERNEL
/*
* alloc more than one contig_mem, so mutiple I/O can be
* on-going simultaneously
*/
#define ST_MAX_CONTIG_MEM_NUM 3
/*
* 60K is used due to the limitation(size) of the intermediate buffer
* in DMA bind code(rootnex.c), which is 64K. If the I/O buf is page
* aligned, HBA can do 64K DMA, but if not, HBA can only do
* buffer will keep the page offset.
*/
struct contig_mem {
struct contig_mem *cm_next;
int cm_use_sbuf;
};
#endif
#endif /* _KERNEL */
/*
* Private info for scsi tapes. Pointed to by the un_private pointer
* of one of the SCSI_DEVICE chains.
*/
struct scsi_tape {
char *un_srqbufp; /* sense buffer for special io */
int un_oflags; /* open flags */
int un_fileno; /* current file number on tape */
int un_err_fileno; /* file where error occurred */
short un_fmneeded; /* filemarks to be written - HP only */
int un_pwr_mgmt; /* power management state */
/* check condidtion or error */
int un_maxdma; /* max dma xfer allowed by HBA */
int un_maxbsize; /* max block size allowed by drive */
int un_errno; /* errno (b_error) */
int un_init_options; /* Init time drive options */
int un_save_fileno; /* Save here for recovery */
int un_suspend_fileno; /* Save fileno for SUSPEND */
short un_tids_at_suspend; /* timeouts set at suspend */
/* restore on close */
struct contig_mem *un_contig_mem;
#endif
};
/*
* device error kstats
*/
struct st_errstats {
struct kstat_named st_softerrs;
struct kstat_named st_harderrs;
struct kstat_named st_transerrs;
struct kstat_named st_vid;
struct kstat_named st_pid;
struct kstat_named st_revision;
struct kstat_named st_serial;
};
/*
* generic log page struct
*/
struct log_page {
#if defined(_BIT_FIELDS_LTOH)
:2; /* reserved */
#elif defined(_BIT_FIELDS_HTOL)
#endif /* _BIT_FIELDS_LTOH */
/*
* Log parameters follow right after this...
*/
};
/*
* generic log page parameter struct
*/
struct log_param {
#if defined(_BIT_FIELDS_LTOH)
: 1, /* reserved */
#elif defined(_BIT_FIELDS_HTOL)
: 1, /* reserved */
#endif /* _BIT_FIELDS_LTOH */
/*
* Parameter values follow right after this...
*/
};
/*
* TapeAlert structures
*/
struct st_tape_alert_parameter {
};
struct st_tape_alert {
};
#define TAPE_ALERT_PARAMETER_LENGTH \
(sizeof (struct st_tape_alert_parameter)) * TAPE_ALERT_MAX_PARA
struct log_sequential_page_parameter {
};
struct log_sequential_page {
};
#if !defined(__lint)
))
#endif
/*
* driver states..
*/
#define ST_STATE_CLOSED 0
#define ST_STATE_OFFLINE 1
#define ST_STATE_INITIALIZING 2
#define ST_STATE_OPENING 3
#define ST_STATE_OPEN_PENDING_IO 4
#define ST_STATE_APPEND_TESTING 5
#define ST_STATE_OPEN 6
#define ST_STATE_RESOURCE_WAIT 7
#define ST_STATE_CLOSING 8
#define ST_STATE_SENSING 9
#define ST_STATE_CLOSE_PENDING_OPEN 10
/*
* Power management state
*/
#define ST_PWR_NORMAL 0
#define ST_PWR_SUSPENDED 1
/*
* operation codes
*/
#define ST_OP_NIL 0
#define ST_OP_CTL 1
#define ST_OP_READ 2
#define ST_OP_WRITE 3
#define ST_OP_WEOF 4
/*
*/
#define ST_NO_EOF 0x00
/* un_rqs_state codes */
/*
* stintr codes
*/
#define COMMAND_DONE 0
#define COMMAND_DONE_ERROR 1
#define COMMAND_DONE_ERROR_RECOVERED 2
#define QUE_COMMAND 3
#define QUE_BUSY_COMMAND 4
#define QUE_SENSE 5
#define JUST_RETURN 6
#define COMMAND_DONE_EACCES 7
#define QUE_LAST_COMMAND 8
/*
* Reservation Status
*
* ST_INIT_RESERVE -Used to check if the reservation has been lost
* in between opens and also to indicate the reservation
* has not been done till now.
* ST_RELEASE -Tape Unit is Released.
* ST_RESERVE -Tape Unit is Reserved.
* ST_PRESERVE_RESERVE -Reservation is to be preserved across opens.
*
*/
#define ST_INIT_RESERVE 0x001
#define ST_RELEASE 0x002
#define ST_RESERVE 0x004
#define ST_PRESERVE_RESERVE 0x008
#define ST_RESERVATION_CONFLICT 0x010
#define ST_LOST_RESERVE 0x020
#define ST_RESERVE_SUPPORTED(un) \
#define ST_RESERVATION_DELAY 500000
/*
* Asynch I/O tunables
*/
#define ST_MAX_THROTTLE 4
/*
* 60 minutes seems a reasonable amount of time
* to wait for tape space operations to complete.
*
*/
/*
* 2 minutes seems a reasonable amount of time
* to wait for tape i/o operations to complete.
*
*/
/*
* 10 seconds is what we'll wait if we get a Busy Status back
*/
#define ST_INTERRUPT_CONTEXT 1
#define ST_START_CONTEXT 2
/*
* Number of times we'll retry a normal operation.
*
* XXX This includes retries due to transport failure as well as
* XXX busy timeouts- Need to distinguish between Target and Transport
* XXX failure.
*/
#define ST_RETRY_COUNT 20
/*
* Number of times to retry a failed selection
*/
#define ST_SEL_RETRY_COUNT 2
/*
* es_code value for deferred error
* should be moved to sense.h
*/
#define ST_DEFERRED_ERROR 0x01
/*
* Maximum number of units (determined by minor device byte)
*/
#define ST_MAXUNIT 128
/*
* Time to wait for completion of a command before cancelling it.
* For SUSPEND use only
*/
#ifndef SECSIZE
#define SECSIZE 512
#endif
#ifndef SECDIV
#define SECDIV 9
#endif
/*
* convenient defines
*/
#define ASYNC_CMD 0
#define SYNC_CMD 1
/*
* Flush tape wait queue as needed.
*/
/*
* Macros for internal coding of count for SPACE command:
*
* Isfmk is 1 when spacing filemarks; 0 when spacing records:
* bit 24 set indicates a space filemark command.
* Fmk sets the filemark bit (24) and changes a backspace
* count into a positive number with the sign bit set.
* Blk changes a backspace count into a positive number with
* the sign bit set.
* space_cnt converts backwards counts to negative numbers.
*/
#define GET_SOFT_STATE(dev) \
register int instance; \
\
return (ENXIO);
/*
* Debugging turned on via conditional compilation switch -DSTDEBUG
*/
#ifdef DEBUG
#define STDEBUG
#endif
#ifdef STDEBUG
#else
#define st_debug (0)
#define DEBUGGING (0)
#endif
/*
* Media access values
*/
/*
* SCSI tape mode sense page information
*/
/*
* SCSI tape data compression Page definition.
*/
/*
* maxbsize values
*/
/*
* generic soft error reporting
*
* What we are doing here is allowing a greater number of errors to occur on
* smaller transfers (i.e. usually at the beginning of the tape), than on
* the rest of the tape.
*
* A small transfer is defined as :
* Transfers <= SOFT_ERROR_WARNING_THRESHOLD allow about 1.5 times more errors
*
* A larget tranfer is defined as :
* Transfers > SOFT_ERROR_WARNING_THRESHOLD allow normal amount
*
*/
/*
* soft error reporting for exabyte
*/
#define SENSE_19_BITS \
"\20\10PF\07BPE\06FPE\05ME\04ECO\03TME\02TNP\01LBOT"
#define SENSE_20_BITS \
"\20\10RSVD\07RSVD\06WP\05FMKE\04URE\03WE1\02SSE\01FW"
#define SENSE_21_BITS \
"\20\10RSVD\07RSVD\06RRR\05CLND\04CLN\03PEOT\02WSEB\01WSE0"
/* these are defined in percentages */
#define EXABYTE_WRITE_ERROR_THRESHOLD 6
#define EXABYTE_READ_ERROR_THRESHOLD 3
/*
* minumum amount of data transfer(MB) for checking soft error rate.
*/
#define CLN 0x8
#define CLND 0x10
/*
* soft error reporting for Archive 4mm DAT
*/
#define LOG_SENSE_LENGTH 0xff
#define MIN_LOG_SENSE_LENGTH 0x2b
/*
* ST timeouts that need to be cancelled for suspend
*/
#define ST_HIB_TID 0x01
#define ST_DELAY_TID 0x02
#ifdef __cplusplus
}
#endif
#endif /* _SYS_SCSI_TARGETS_STDEF_H */