Functional changes:

* Handle message retransmissions and partially sent messages correctly.
* Make sure we clear ATN after the last message is sent.
* Do the right thing if the target initiates negotiation for async mode
after having negotiated sync mode.
* Fix some cases where we set ATN with no message queued, or schedule a
message without setting ATN.
* Issue a REQUEST SENSE after an unexpected disconnect, per SCSI spec.
* Fix abort handling in a number of cases.
* Recognize selection timeouts better (to speed up probing).
This commit is contained in:
mycroft 1996-09-27 19:36:34 +00:00
parent 28068e33c0
commit 3075e1443b
2 changed files with 430 additions and 393 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
/* $NetBSD: espvar.h,v 1.5 1996/09/09 18:10:38 cgd Exp $ */
/* $NetBSD: espvar.h,v 1.6 1996/09/27 19:36:36 mycroft Exp $ */
/*
* Copyright (c) 1994 Peter Galbavy. All rights reserved.
@ -29,7 +29,9 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#define ESP_DEBUG 0
#define ESP_DEBUG 0
#define ESP_ABORT_TIMEOUT 2000 /* time to wait for abort */
#define FREQTOCCF(freq) (((freq + 4) / 5))
@ -47,23 +49,23 @@
* We'll generally update: xs->{flags,resid,error,sense,status} and
* occasionally xs->retries.
*/
struct ecb {
TAILQ_ENTRY(ecb) chain;
struct esp_ecb {
TAILQ_ENTRY(esp_ecb) chain;
struct scsi_xfer *xs; /* SCSI xfer ctrl block from above */
int flags; /* Status */
#define ECB_QNONE 0
#define ECB_QFREE 1
#define ECB_QREADY 2
#define ECB_QNEXUS 3
#define ECB_QBITS 0x07
#define ECB_CHKSENSE 0x08
#define ECB_ABORTED 0x10
#define ECB_SETQ(e, q) do (e)->flags = ((e)->flags&~ECB_QBITS)|(q); while(0)
int flags;
#define ECB_ALLOC 0x01
#define ECB_NEXUS 0x02
#define ECB_SENSE 0x04
#define ECB_ABORT 0x40
#define ECB_RESET 0x80
int timeout;
struct scsi_generic cmd; /* SCSI command block */
int clen;
char *daddr; /* Saved data pointer */
int dleft; /* Residue */
u_char stat; /* SCSI status byte */
#if ESP_DEBUG > 0
char trace[1000];
#endif
@ -172,12 +174,12 @@ struct esp_softc {
u_char sc_espfflags;
/* Lists of command blocks */
TAILQ_HEAD(ecb_list, ecb) free_list,
ready_list,
nexus_list;
TAILQ_HEAD(ecb_list, esp_ecb) free_list,
ready_list,
nexus_list;
struct ecb *sc_nexus; /* current command */
struct ecb sc_ecb[8]; /* one per target */
struct esp_ecb *sc_nexus; /* current command */
struct esp_ecb sc_ecb[8]; /* one per target */
struct esp_tinfo sc_tinfo[8];
/* Data about the current nexus (updated for every cmd switch) */
@ -195,6 +197,7 @@ struct esp_softc {
/* Message stuff */
u_char sc_msgpriq; /* One or more messages to send (encoded) */
u_char sc_msgout; /* What message is on its way out? */
u_char sc_msgoutq; /* What messages have been sent so far? */
u_char sc_omess[ESP_MAX_MSG_LEN];
caddr_t sc_omp; /* Message pointer (for multibyte messages) */
size_t sc_omlen;
@ -215,45 +218,35 @@ struct esp_softc {
};
/* values for sc_state */
#define ESP_IDLE 0x01 /* waiting for something to do */
#define ESP_TMP_UNAVAIL 0x02 /* Don't accept SCSI commands */
#define ESP_SELECTING 0x03 /* SCSI command is arbiting */
#define ESP_RESELECTED 0x04 /* Has been reselected */
#define ESP_HASNEXUS 0x05 /* Actively using the SCSI bus */
#define ESP_CLEANING 0x06
#define ESP_SBR 0x07 /* Expect a SCSI RST because we commanded it */
#define ESP_IDLE 1 /* waiting for something to do */
#define ESP_SELECTING 2 /* SCSI command is arbiting */
#define ESP_RESELECTED 3 /* Has been reselected */
#define ESP_CONNECTED 4 /* Actively using the SCSI bus */
#define ESP_DISCONNECT 5 /* MSG_DISCONNECT received */
#define ESP_CMDCOMPLETE 6 /* MSG_CMDCOMPLETE received */
#define ESP_CLEANING 7
#define ESP_SBR 8 /* Expect a SCSI RST because we commanded it */
/* values for sc_flags */
#define ESP_DROP_MSGI 0x01 /* Discard all msgs (parity err detected) */
#define ESP_DOINGDMA 0x02 /* The FIFO data path is active! */
#define ESP_BUSFREE_OK 0x04 /* Bus free phase is OK. */
#define ESP_ABORTING 0x02 /* Bailing out */
#define ESP_DOINGDMA 0x04 /* The FIFO data path is active! */
#define ESP_SYNCHNEGO 0x08 /* Synch negotiation in progress. */
/*#define ESP_BLOCKED 0x10 * Don't schedule new scsi bus operations */
#define ESP_DISCON 0x10 /* Target sent DISCONNECT msg */
#define ESP_ABORTING 0x20 /* Bailing out */
#define ESP_ICCS 0x40 /* Expect status phase results */
#define ESP_WAITI 0x80 /* Waiting for non-DMA data to arrive */
#define ESP_ICCS 0x10 /* Expect status phase results */
#define ESP_WAITI 0x20 /* Waiting for non-DMA data to arrive */
#define ESP_ATN 0x40 /* ATN asserted */
/* values for sc_msgout */
#define SEND_DEV_RESET 0x01
#define SEND_PARITY_ERROR 0x02
#define SEND_ABORT 0x04
#define SEND_INIT_DET_ERR 0x04
#define SEND_REJECT 0x08
#define SEND_INIT_DET_ERR 0x10
#define SEND_IDENTIFY 0x20
#define SEND_IDENTIFY 0x10
#define SEND_ABORT 0x20
#define SEND_SDTR 0x40
#define SEND_WDTR 0x80
/* SCSI Status codes */
#define ST_GOOD 0x00
#define ST_CHKCOND 0x02
#define ST_CONDMET 0x04
#define ST_BUSY 0x08
#define ST_INTERMED 0x10
#define ST_INTERMED_CONDMET 0x14
#define ST_RESERVATION_CONFLICT 0x18
#define ST_CMD_TERM 0x22
#define ST_QUEUE_FULL 0x28
#define ST_MASK 0x3e /* bit 0,6,7 is reserved */
/* phase bits */