diff options
author | David Gwynne <dlg@cvs.openbsd.org> | 2009-09-14 00:03:29 +0000 |
---|---|---|
committer | David Gwynne <dlg@cvs.openbsd.org> | 2009-09-14 00:03:29 +0000 |
commit | 4248e34dda8652ddd46e2885282d566d8168375c (patch) | |
tree | 82bb5feb84ccef77da33aa27666949da6540aff0 /sys/scsi/scsiconf.h | |
parent | 4d196425328e9719c037d7a94b4758298d0b2ad6 (diff) |
rework the scsi midlayer to start addressing some problems i have
with it which became extremely annoying with what mpath wants to
do.
the major change is a new interface for submitting scsi commands.
previously the only way for drivers like sd, cd, st, etc to push
commands onto the hardware was via scsi_scsi_cmd(). the problem
with scsi_scsi_cmd is that it doesnt tell the caller if the command
failed, was queued, or completed unless you shoved a buf down with
it. this is important for mpath which wants to know what the physical
path to the device did so it can report it back to the midlayer
which called it.
this provides a new api which lets drivers like cd/sd/st/mpath etc
allocate an xs, fill it in, and provide a completion routine which
the midlayer will call with the state of the command when it is
finished with it. the caller is then responsible for freeing the
xs.
from the hba side of thing, the return code from the scsi_cmd
entrypoint is largely ignored now, and it is now always the
responsibility of the hba driver to call scsi_done when it has
completed the io, rather than returning COMPLETE and expecting the
midlayer to do it for you.
i have emulated scsi_scsi_cmd on top of this new api so existing
users of it will continue to work. sd(4) has been reworked to use
the new api directly to both demonstrate its use and test that the
new api actually does work.
this diff was mostly written in a day at f2k9. thanks to miod for poking
through hba drivers to help mitigate against fallout from the change to
the COMPLETE semantic. this has been reviewed by krw who didnt spot
anything wrong.
thanks to dave del debbio for testing.
ok deraadt@
Diffstat (limited to 'sys/scsi/scsiconf.h')
-rw-r--r-- | sys/scsi/scsiconf.h | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/sys/scsi/scsiconf.h b/sys/scsi/scsiconf.h index 0723bcb73a7..60e8294ef5f 100644 --- a/sys/scsi/scsiconf.h +++ b/sys/scsi/scsiconf.h @@ -1,4 +1,4 @@ -/* $OpenBSD: scsiconf.h,v 1.100 2009/08/13 19:49:31 dlg Exp $ */ +/* $OpenBSD: scsiconf.h,v 1.101 2009/09/14 00:03:28 dlg Exp $ */ /* $NetBSD: scsiconf.h,v 1.35 1997/04/02 02:29:38 mycroft Exp $ */ /* @@ -53,6 +53,7 @@ #include <sys/queue.h> #include <sys/timeout.h> #include <sys/workq.h> +#include <sys/mutex.h> #include <machine/cpu.h> #include <scsi/scsi_debug.h> @@ -369,6 +370,7 @@ struct scsi_link { struct scsibus_softc *bus; /* link to the scsibus we're on */ struct scsi_inquiry_data inqdata; /* copy of INQUIRY data from probe */ struct devid id; + struct mutex mtx; }; int scsiprint(void *, const char *); @@ -444,6 +446,8 @@ struct scsi_xfer { * timeout structure for hba's to use for a command */ struct timeout stimeout; + void *cookie; + void (*done)(struct scsi_xfer *); }; /* @@ -560,6 +564,10 @@ int scsi_req_detach(struct scsibus_softc *, int, int, int); extern const u_int8_t version_to_spc[]; #define SCSISPC(x)(version_to_spc[(x) & SID_ANSII]) +struct scsi_xfer * scsi_xs_get(struct scsi_link *, int); +void scsi_xs_exec(struct scsi_xfer *); +void scsi_xs_put(struct scsi_xfer *); + /* * Entrypoints for multipathing */ |