The dsreq type structure can be found in the sys/dsreq.h directory. The macros associated with a dsreq type structure are described below. The dslib routines are described in "dslib Routines Description".
typedef struct dsreq { /* devscsi prefix */ ulong ds_flags; /* see flags defined below */ ulong ds_time; /* time-out in milliseconds */ ulong ds_private; /* for private use by caller */ /* scsi request */ caddr_t ds_cmdbuf; /* command buffer */ uchar_t ds_cmdlen; /* command buffer length */ caddr_t ds_databuf; /* data buffer start */ ulong ds_datalen; /* total data length */ caddr_t ds_sensebuf; /* sense buffer */ uchar_t ds_senselen; /* sense buffer length */ /* miscellaneous */ dsiovec_t *ds_iovbuf; /* scatter-gather dma control */ ushort ds_iovlen; /* length of scatter-gather */ struct dsreq *ds_link; /* for linked requests */ ushort ds_synch; /* synchronous xfer control*/ uchar_t ds_revcode; /* devscsi version code*/ /* return portion */ uchar_t ds_ret; /* devscsi return code*/ uchar_t ds_status; /* device status byte value*/ uchar_t ds_msg; /* device message byte value */ uchar_t ds_cmdsent; /* actual length command*/ ulong ds_datasent; /* actual length user data*/ uchar_t ds_sensesent; /* actual length sense data*/ } dsreq_t;where:
#define FLAGS (dp) ((dp)->ds_flags)
There are symbolic constants that you can use to set the bits of the ds_flags value. (Not all of these flags are currently honored. Your driver can test for which flags are honored by checking the returned value of an ioctl() call on devscsi. See the ds(7M) man page.) These constants are defined in sys/dsreq.h:
DSRQ_ASYNC - No/Yes sleep until request done. A SCSI device option. Not implemented.
DSRQ_SENSE - Yes/No automatically get sense on status when a check condition occurs. A SCSI device option. All requests return only on completion. Not implemented.
DSRQ_TARGET - Target/Initiator role. A SCSI device option. Not implemented.
DSRQ_SELATN - Select with/without ATN. A select option. Not implemented.
DSRQ_DISC - Identify disconnect not-allowed/allowed. A select option. Not implemented.
DSRQ_SYNXFR - Negotiate synchronous SCSI transfer. A select option.
DSRQ_SELMSG - Send supplied/generated message. A select option. Not implemented.
DSRQ_IOV - Scatter-gather not-specified/specified. A data transfer option.
DSRQ_READ - Input data from SCSI bus to the CPU. A data transfer direction.
DSRQ_WRITE - Output data to SCSI bus from the CPU. A data transfer direction.
DSRQ_BUF - Buffered/Direct data transfer. A data transfer option.
DSRQ_CALL - Notify progress upon completion. A progress/continuation callback option. Used with DSRQ_ASYNC. Not implemented.
DSRQ_ACKH - Hold/Don't-hold ACK asserted. A progress/continuation callback option. Not implemented.
DSRQ_ATNH - Hold/don't-hold ATN asserted. A progress/continuation callback option. Not implemented.
DSRQ_ABORT - Send an abort message. Useful only with SCSI commands that have the immediate bit set.
DSRQ_TRACE - Trace/don't-trace this request. A host option (and so not likely to be portable).
DSRQ_PRINT - Print/don't-print this request. A host option (and so not likely to be portable).
DSRQ_CTRL1 - Request with host control bit 1. A host option (and so not likely to be portable).
DSRQ_CTRL2 - Request with host control bit 2. A host option (and so not likely to be portable).
DSRQ_MIXRDWR - Request can both read and write.
The file dsreq.h defines this macro as:
#define TIME (dp) ((dp)->ds_time)
If you use dslib, you must not change this pointer or the data it references.
#define PRIVATE(dp) ((dp)->ds_private)
This is intended to be used only in the library support routines.
#define CMDBUF(dp) ((caddr_t) (dp)->ds_cmdbuf)
#define CMDLEN(dp) ((dp)->ds_cmdlen)
Typically, this value is 6, 10, or 12 for SCSI commands of class 0, 1, or 2, respectively.
#define DATABUF(dp) ((caddr_t) (dp)->ds_databuf)
#define DATALEN(dp) ((dp)->ds_datalen)
#define SENSEBUF(dp) ((caddr_t) (dp)->ds_sensebuf)
It is used only if DSRQ_SENSE is set in the flags.
#define SENSELEN(dp) ((dp)->ds_senselen)
To access the value of the *ds_iovbuf member, you can use the macro, IOVBUF. The file dsreq.h currently defines this macro as:
#define IOVBUF(dp) ((caddr_t) (dp)->ds_iovbuf)
#define IOVLEN(dp) ((dp)->ds_iovlen)
#define RET(dp) ((dp)->ds_ret)
The file dsreq.h defines the following symbolic constants for the value pointed to by this member:
DSRT_DEVSCSI - General failure from SCSI bus.
DSRT_HOST - General host failure, typically a SCSI-bus request.
DSRT_STAI - Protocol error during status phase.
DSRT_EBSY - Busy dropped unexpectedly; protocol error.
DSRT_UNIMPL - Protocol error. Not implemented.
DSRT_CMDO - Protocol error during command phase.
DSRT_REJECT - Message rejected; protocol error.
DSRT_PARITY - Parity error on SCSI bus; protocol error.
DSRT_PROTO - Miscellaneous protocol failure.
DSRT_MEMORY - Host memory error.
DSRT_MULT - Request rejected by SCSI bus.
DSRT_CANCEL - Lower request canceled by SCSI bus.
DSRT_REVCODE - Software obsolete, must recompile.
DSRT_AGAIN - Try again, recoverable SCSI-bus error.
DSRT_NOSEL - No unit responded to select.
DSRT_SHORT - Incomplete transfer (not an error).
DSRT_OK - Completed transfer without error status.
DSRT_SENSE - Command with status, sense data successfully retrieved from SCSI host.
DSRT_NOSENSE - Command with status, error occurred while trying to get sense data from SCSI host.
DSRT_TIMEOUT - Request idled longer than requested. Command could not complete within the limit of the time-out value.
DSRT_LONG - Target over ran data bounds.
The file dsreq.h currently defines STATUS:
#define STATUS(dsp) ((dp)->ds_status)
The file dsreq.h defines the following symbolic constants for this byte:
STA_GOOD - the target has successfully completed the SCSI command.
STA_CHECK - indicates an error, exception, or abnormal condition. If DSRQ_SENSE is set, request sense is automatically done. See ds_sensebuf.
STA_BUSY - the target is busy, so the command was not issued.
STA_IGOOD - SCSI command with link completed.
STA_RESERV - Command aborted because it tried to access a logical unit or an extent within a logical unit that reserves that type of access to another SCSI device.
#define CMDSENT(dsp) ((dp)->ds_cmdsent)
#define DATASENT(dsp) ((dp)->ds_datasent)
#define SENSESENT(dsp) ((dp)->ds_sensesent)