espvar.h revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* 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 (c) 1995-1998 by Sun Microsystems, Inc.
* All rights reserved.
*/
#ifndef _SYS_SCSI_ADAPTERS_ESPVAR_H
#define _SYS_SCSI_ADAPTERS_ESPVAR_H
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Emulex ESP (Enhanced Scsi Processor) Definitions,
* Software && Hardware.
*/
/*
* General SCSI includes
*/
/*
* Include hardware definitions for the ESP generation chips.
*/
#ifdef __cplusplus
extern "C" {
#endif
/*
* Compile options
*/
#if DEBUG
#define ESPDEBUG /* turn on debugging code */
#define ESPTEST
#ifdef ESPTEST
#define ESP_TEST_PARITY /* turn on parity test code */
#define ESP_TEST_ABORT /* turn on abort test code */
#define ESP_TEST_RESET /* turn on device reset code */
#define ESP_TEST_TIMEOUT /* turn on timeout test code */
#define ESP_TEST_BUS_RESET /* turn on bus reset code */
#define ESP_TEST_RQSENSE /* test rqsense with renegotiation */
#define ESP_NEW_HW_DEBUG /* turn on debug code for new h/w */
#define ESP_TEST_UNTAGGED /* turn on untagged/tagged mix test */
#endif /* ESPTEST */
#endif /* DEBUG */
/*
* Software Definitions
*/
#define ESP_INIT_SOFT_STATE 5
/*
* Data Structure for this Host Adapter.
*/
/*
* Tag lookup array structure
*/
struct t_slots {
short e_dups;
int e_timeout;
int e_timebase;
};
/*
* this structure collects all info about a callback thread; this
* thread may be shared between a number of esps
*/
struct callback_info {
struct callback_info *c_next;
};
/*
* HBA interface macros
*/
/*
* Configuration information for this host adapter
*/
struct esp {
/*
* Transport structure for this instance of the hba
*/
/*
* dev_info_t reference
*/
/*
* mutex
*/
/*
* Interrupt block cookie
*/
/*
* Next in a linked list of host adapters
*/
/*
* Type byte for this host adapter (53C90, 53C90A, ESP-236),
* part unique id code, and rev of the dma engine
*/
/*
* value for configuration register 1.
* Also contains Initiator Id.
*/
/*
* value for configuration register 2 (ESP100A)
*/
/*
*/
/*
* clock conversion register value for this host adapter.
* clock cycle value * 1000 for this host adapter,
* to retain 5 significant digits.
*/
/*
* selection timeout register value
*/
/*
* State of the host adapter
*/
/* zeroed for every selection attempt, */
/* every reconnection, and every disconnect */
/* interrupt. Each SYNCHRONOUS DATA TRANSFER */
/* message, both coming from the target, and */
/* sent to the target, causes this tag to be */
/* incremented. This allows the received */
/* message handling to determine whether */
/* a received SYNCHRONOUS DATA TRANSFER */
/* message is in response to one that we */
/* sent. */
/* went out */
/*
* Message handling: enough space is reserved for the expected length
* of all messages we could either send or receive.
*
* For sending, we expect to send only SYNCHRONOUS extended messages
* (5 bytes). We keep a history of the last message sent, and in order
* to control which message to send, an output message length is set
* to indicate whether and how much of the message area is to be used
* in sending a message. If a target shifts to message out phase
* unexpectedly, the default action will be to send a MSG_NOP message.
*
* After the successful transmission of a message, the initial message
* byte is moved to the e_last_msgout area for tracking what was the
* last message sent.
*/
#define OMSGSIZE 12
/*
* We expect, at, most, to receive a maximum of 7 bytes
* of an incoming extended message (MODIFY DATA POINTER),
* and thus reserve enough space for that.
*/
#define IMSGSIZE 8
/*
* These are used to index how far we've
* gone in receiving incoming messages.
*/
/*
* Saved last msgin.
*/
/*
* Target information
* Synchronous SCSI Information,
* Disconnect/reconnect capabilities
* Noise Susceptibility
*/
/* 0: no backoff 1: do backoff now */
/* 2: no backoff now but goto async */
/* on next failure */
/*
* This uchar_t is a bit map for targets
* whose SYNC capabilities are known.
*/
/*
* This uchar_t is a bit map for targets
* for disabling sync on request from
* target driver setcap
*/
/*
* This uchar_t is a bit map for targets who
* don't appear to be able to disconnect.
*/
/*
* This uchar_t is a bit map for targets
* who seem to be susceptible to noise.
*/
/*
* This byte is a bit map for targets who don't appear
* to be able to support tagged commands.
*/
/*
* scsi options, scsi_tag_age_limit per esp
*/
/*
* This ushort_t is a bit map for targets who need to have
* their properties update deferred.
*/
int e_scsi_options;
int e_scsi_tag_age_limit;
/*
* various chip and system idiosyncracies
*/
/*
* scsi reset delay per esp
*/
/*
* Scratch Buffer, allocated out of iopbmap for commands
* The same size as the ESP's fifo.
*/
/*
* shadow copy of dmaga_csr to avoid unnecessary I/O reads which are
* expensive
*/
/*
* Scratch Buffer DMA cookie
*/
/*
* dma attrs for esp
*/
/*
* Instrumentation
*/
short e_ncmds; /* number of commands stored here at present */
short e_ndisc; /* number of disconnected cmds at present */
/*
* Hardware pointers
*
* Pointer to mapped in ESP registers
*/
/*
* Pointer to mapped in DMA Gate Array registers
*/
/*
* last and current state, queues
*/
short e_last_slot; /* last active target/lun */
short e_cur_slot; /* current active target/lun */
short e_next_slot; /* round robin scheduling */
/*
* if throttle >= 0 then
* continue submitting cmds
* if throttle == 0 then hold cmds
* if throttle < 0 then drain
*/
short e_throttle[N_SLOTS];
/*
* if a device reset has been performed, a
* delay is required before accessing the target
* again; reset delays are in milli secs
* (assuming that reset watchdog runs every
* ESP_WATCH_RESET_DELAY_TICK milli secs;
* watchdog decrements the reset delay)
*/
int e_reset_delay[NTARGETS];
/*
* callback thread info for this esp; the thread may be shared
*/
struct callback_info *e_callback_info;
/*
* a queue for packets in case the esp mutex is locked
*/
struct kmem_cache *e_kmem_cache;
/*
* list of reset notification requests
*/
/*
* QFULL handling related timeouts and limits.
*/
/*
* data access handle for register mapping
*/
/*
* data access handle for cmdarea
*/
/*
* state flags
*/
int e_flags;
/*
* Interrupt kstat
*/
struct kstat *e_intr_kstat;
#ifdef ESP_KSTATS
/*
* stats per slot
*/
/*
* scsi bus statistics
*/
struct kstat *e_scsi_bus_stats;
#endif
#define NPHASE 16
#ifdef ESPDEBUG
/*
* SCSI analyzer function data structures.
*/
int e_xfer; /* size of current transfer */
short e_phase_index; /* next entry in table */
struct scsi_phases { /* SCSI analyzer structure */
short e_save_state;
short e_save_stat;
int e_reserved;
#endif /* ESPDEBUG */
};
/*
* e_req_ack_delay:
* of 0x20 for 101 was found to be preferable but this caused "illegal
* cmd interrupt" when a xfer > 64K was broken up (we were still using
* the 16 bit counter) in data phase; after restarting the xfer, the esp
* immediately returned "illegal cmd" because it is not legal to give a
* cmd while ACK is left asserted; it is not known yet why ACK is left
* asserted if this delay is 0x20; anyway, emulex now recommends 0x50
* The sunergy macio chip has more problems than the c2 with the value 0x20.
*/
/*
* define for e_options
*/
/* instead of 4 */
/*
* define for e_flags
*/
#ifdef ESPDEBUG
/*
* Log state and phase history of activity
*/
};
#else /* ESPDEBUG */
#endif /* ESPDEBUG */
/*
* Representations of Driver states (stored in tags e_state && e_laststate).
*/
/*
* Totally idle. There may or may not disconnected commands still
* running on targets.
*/
#define STATE_FREE 0x00
/*
* Selecting States. These states represent a selection attempt
* for a target.
*/
#define STATE_SELECT_NORMAL 0x0100
#define STATE_SELECT_N_STOP 0x0200
#define STATE_SELECT_N_SENDMSG 0x0400
#define STATE_SYNC_ASKING 0x0800
#define STATE_SELECT_N_TAG 0x1000
/*
* When the driver is neither idle nor selecting, it is in one of
* the information transfer phases. These states are not unique
* bit patterns- they are simple numbers used to mark transitions.
* They must start at 1 and proceed sequentially upwards and
* match the indexing of function vectors declared in the function
* esp_phasemanage().
*/
/*
* These states cover finishing sending a command out (if it wasn't
* sent as a side-effect of selecting), or the case of starting
* a command that was linked to the previous command (i.e., no
* selection phase for this particular command as the target
* remained connected when the previous command completed).
*/
#define ACTS_CMD_START 0x01
#define ACTS_CMD_DONE 0x02
/*
* These states are the begin and end of sending out a message.
* The message to be sent is stored in the field e_msgout (see above).
*/
#define ACTS_MSG_OUT 0x03
#define ACTS_MSG_OUT_DONE 0x04
/*
* These states are the beginning, middle, and end of incoming messages.
*
*/
#define ACTS_MSG_IN 0x05
#define ACTS_MSG_IN_MORE 0x06
#define ACTS_MSG_IN_DONE 0x07
/*
* This state is reached when the target may be getting
* ready to clear the bus (disconnect or command complete).
*/
#define ACTS_CLEARING 0x08
/*
* These states elide the begin and end of a DATA phase
*/
#define ACTS_DATA 0x09
#define ACTS_DATA_DONE 0x0A
/*
* This state indicates that we were in status phase. We handle status
* phase by issuing the ESP command 'CMD_COMP_SEQ' which causes the
* ESP to read the status byte, and then to read a message in (presumably
* one of COMMAND COMPLETE, LINKED COMMAND COMPLETE or LINKED COMMAND
* COMPLETE WITH FLAG).
*
* This state is what is expected to follow after the issuance of the
* ESP command 'CMD_COMP_SEQ'.
*/
#define ACTS_C_CMPLT 0x0B
/*
* This state is used by the driver to indicate that it
* is in the middle of processing a reselection attempt.
*/
#define ACTS_RESEL 0x0C
/*
* Hiwater mark of vectored states
*/
#define ACTS_ENDVEC 0x0C
/*
* This state is used by the driver to indicate that it doesn't know
* what the next state is, and that it should look at the ESP's status
* register to find out what SCSI bus phase we are in in order to select
* the next state to transition to.
*/
#define ACTS_UNKNOWN 0x1A
/*
* This state is used by the driver to indicate that a self-inititated
* Bus reset is in progress.
*/
#define ACTS_RESET 0x1C
/*
* This state is used by the driver to indicate to itself that it is
* in the middle of aborting things.
*/
#define ACTS_ABORTING 0x1D
/*
* This state is used by the driver to indicate to itself that it is
* in the middle of spanning a target driver completion call.
*/
#define ACTS_SPANNING 0x1E
/*
* This state is used by the driver to just hold the state of
* the softc structure while it is either aborting or resetting
* everything.
*/
#define ACTS_FROZEN 0x1F
/*
* These additional states are only used by the scsi bus analyzer.
*/
#define ACTS_PREEMPTED 0x21
#define ACTS_PROXY 0x22
#define ACTS_SYNCHOUT 0x23
#define ACTS_CMD_LOST 0x24
#define ACTS_DATAOUT 0x25
#define ACTS_DATAIN 0x26
#define ACTS_STATUS 0x27
#define ACTS_DISCONNECT 0x28
#define ACTS_NOP 0x29
#define ACTS_REJECT 0x2A
#define ACTS_RESTOREDP 0x2B
#define ACTS_SAVEDP 0x2C
#define ACTS_BAD_RESEL 0x2D
#define ACTS_LOG 0x0F
#define ACTS_TAG 0x2F
#define ACTS_CMD 0x30
#define ACTS_NEW_STATE 0x40
#define ACTS_ESP_CMD 0x41
/*
* Interrupt dispatch actions
*/
#define ACTION_FINSEL 0 /* finish selection */
/*
* Proxy command definitions.
*
* At certain times, we need to run a proxy command for a target
* (if only to select a target and send a message).
*
* We use the tail end of the cdb that is internal to the esp_cmd
* structure to store the proxy code, the proxy data (e.g., the
* message to send).
*
* We also store a boolean result code in this area so that the
* user of a proxy command knows whether it succeeded.
*/
/*
* Offsets into the cmd_db[] array for proxy data
*/
#define ESP_PROXY_TYPE CDB_GROUP0
/*
* Currently supported proxy types
*/
#define ESP_PROXY_SNDMSG 1
/*
* Reset actions
*/
#define ESP_RESET_SCSIBUS (ESP_RESET_BRESET)
#define ESP_RESET_MSG 0x20
/*
* Debugging macros and defines
*/
#ifdef ESPDEBUG
#define INFORMATIVE (espdebug)
#else /* ESPDEBUG */
#endif /* ESPDEBUG */
/*
* Shorthand macros and defines
*/
/*
* Short hand defines
*/
#define SAME_CMD 0
#define INT_CMD 1
#define NEW_CMD 2
#define CLEAR_THROTTLE 512
#define HOLD_THROTTLE 0
#define DRAIN_THROTTLE -1
#define QFULL_THROTTLE -2
#define PAD_LIMIT 1025
#ifdef ESP_KSTATS
#define ESP_KSTAT_SCSI_BUS(esp) \
if (esp_do_bus_kstats) { \
if (esp->e_scsi_bus_stats) { \
} \
if (esp->e_scsi_bus_stats) { \
} \
} \
}
#else
#endif
#define ESP_PREEMPT(esp) \
#define TRUE 1
#define FALSE 0
#define UNDEFINED -1
#define INVALID_MSG 0x7f
/*
* Some manifest miscellaneous constants
*/
#define ESP_FREQ_SLOP (25000)
/*
* DMA macros; we use a shadow copy of the dmaga_csr to save unnecessary
* reads
*/
} \
}
esp->e_dmaga_csr |= \
}
} else \
}
/*
* For DMA gate arrays, the PACKCNT field of the DMA
* CSR register indicates how many bytes are still
* latched up and need to be drained to memory.
*
* For the DMA+ CSR, the PACKCNT field will either
* D_CACHE. The DRAIN bit has no effect.
*
* DON'T flush the dma if there is a dma request pending; this could
* cause an abandonned rerun read which would hang the xbox
*/
#define ESP_FLUSH_DMA(esp) \
} \
esp->e_dmaga_csr &= \
#define ESP_DRAIN_DMA(esp) { \
int i = 0; \
if (DMAGA_NPACKED(dmap)) { \
} \
EPRINTF("draining dma\n"); \
for (i = 0; i < DMA_DRAIN_TIMEOUT; i++) { \
drv_usecwait(1); \
if (DMAGA_NPACKED(dmap) == 0) \
break; \
} \
} \
return (ACTION_RESET); \
} \
ESP_FLUSH_DMA(esp); \
}
{ \
SCSI_OPTIONS_PARITY)) { \
} \
} \
}
/*
* this macro is called without mutex held; there is a race but
* it is on the safe side
*/
#define ESP_WAKEUP_CALLBACK_THREAD(esp) \
{ \
register struct callback_info *cb_info = \
esp->e_callback_info; \
if (esp->e_callback_signal_needed) { \
esp->e_callback_signal_needed = 0; \
} \
}
#define ESP_CHECK_STARTQ_AND_ESP_MUTEX_EXIT(esp) \
esp_empty_startQ(esp); \
} \
mutex_exit(ESP_MUTEX); \
/*
* flags for _esp_start
*/
#define NO_TRAN_BUSY 0 /* _esp_start should not bounce these pkts */
/*
* reset delay tick
*/
/*
* 2 ms timeout on receiving tag on reconnect
*/
/*
* Default is to have 10 retries on receiving QFULL status and
* each retry to be after 100 ms.
*/
#define QFULL_RETRIES 10
#define QFULL_RETRY_INTERVAL 100
/*
* auto request sense
*/
/*
* packet completion
*/
} \
#define NEW_TIMEOUT 1
#ifdef __cplusplus
}
#endif
#endif /* _SYS_SCSI_ADAPTERS_ESPVAR_H */