Home | History | Annotate | Download | only in scsipi
History log of /src/sys/dev/scsipi/sdvar.h
RevisionDateAuthorComments
 1.42  27-Feb-2025  jakllsch sd(4): Translate discard to UNMAP (10) command
 1.41  27-Feb-2025  jakllsch Implement DIOCGSECTORALIGN for sd(4).

Use only READ CAPACITY 16 if peripheral claims conformance to SPC-3.
 1.40  28-Aug-2022  mlelstv Don't fetch data beyond end of inquiry buffer, which, here, is not
NUL-terminated.

Reduce target buffer to needed size (product name + NUL terminator).
 1.39  19-Mar-2019  mlelstv branches: 1.39.4;
Set disk product name as disk type. The information can be queried through
drvctl(4).
 1.38  10-Dec-2016  mlelstv branches: 1.38.16;
Refactored sd and cd to use common disk subroutines.
 1.37  24-Aug-2015  pooka branches: 1.37.2;
would you like some freshly ground _KERNEL_OPT with that?
yes? excellent choice, sir/madam.
 1.36  13-Apr-2015  riastradh Convert sys/dev to use <sys/rndsource.h>.
 1.35  05-Sep-2014  matt branches: 1.35.2;
Don't nest structure definitions.
 1.34  02-Feb-2012  tls branches: 1.34.6;
Entropy-pool implementation move and cleanup.

1) Move core entropy-pool code and source/sink/sample management code
to sys/kern from sys/dev.

2) Remove use of NRND as test for presence of entropy-pool code throughout
source tree.

3) Remove use of RND_ENABLED in device drivers as microoptimization to
avoid expensive operations on disabled entropy sources; make the
rnd_add calls do this directly so all callers benefit.

4) Fix bug in recent rnd_add_data()/rnd_add_uint32() changes that might
have lead to slight entropy overestimation for some sources.

5) Add new source types for environmental sensors, power sensors, VM
system events, and skew between clocks, with a sample implementation
for each.

ok releng to go in before the branch due to the difficulty of later
pullup (widespread #ifdef removal and moved files). Tested with release
builds on amd64 and evbarm and live testing on amd64.
 1.33  19-Nov-2011  tls branches: 1.33.2;
First step of random number subsystem rework described in
<20111022023242.BA26F14A158@mail.netbsd.org>. This change includes
the following:

An initial cleanup and minor reorganization of the entropy pool
code in sys/dev/rnd.c and sys/dev/rndpool.c. Several bugs are
fixed. Some effort is made to accumulate entropy more quickly at
boot time.

A generic interface, "rndsink", is added, for stream generators to
request that they be re-keyed with good quality entropy from the pool
as soon as it is available.

The arc4random()/arc4randbytes() implementation in libkern is
adjusted to use the rndsink interface for rekeying, which helps
address the problem of low-quality keys at boot time.

An implementation of the FIPS 140-2 statistical tests for random
number generator quality is provided (libkern/rngtest.c). This
is based on Greg Rose's implementation from Qualcomm.

A new random stream generator, nist_ctr_drbg, is provided. It is
based on an implementation of the NIST SP800-90 CTR_DRBG by
Henric Jungheim. This generator users AES in a modified counter
mode to generate a backtracking-resistant random stream.

An abstraction layer, "cprng", is provided for in-kernel consumers
of randomness. The arc4random/arc4randbytes API is deprecated for
in-kernel use. It is replaced by "cprng_strong". The current
cprng_fast implementation wraps the existing arc4random
implementation. The current cprng_strong implementation wraps the
new CTR_DRBG implementation. Both interfaces are rekeyed from
the entropy pool automatically at intervals justifiable from best
current cryptographic practice.

In some quick tests, cprng_fast() is about the same speed as
the old arc4randbytes(), and cprng_strong() is about 20% faster
than rnd_extract_data(). Performance is expected to improve.

The AES code in src/crypto/rijndael is no longer an optional
kernel component, as it is required by cprng_strong, which is
not an optional kernel component.

The entropy pool output is subjected to the rngtest tests at
startup time; if it fails, the system will reboot. There is
approximately a 3/10000 chance of a false positive from these
tests. Entropy pool _input_ from hardware random numbers is
subjected to the rngtest tests at attach time, as well as the
FIPS continuous-output test, to detect bad or stuck hardware
RNGs; if any are detected, they are detached, but the system
continues to run.

A problem with rndctl(8) is fixed -- datastructures with
pointers in arrays are no longer passed to userspace (this
was not a security problem, but rather a major issue for
compat32). A new kernel will require a new rndctl.

The sysctl kern.arandom() and kern.urandom() nodes are hooked
up to the new generators, but the /dev/*random pseudodevices
are not, yet.

Manual pages for the new kernel interfaces are forthcoming.
 1.32  10-Apr-2009  dyoung branches: 1.32.12;
Use a PMF shutdown hook instead of shutdownhook_establish(). This ought
to stop the crash during shutdown that yamt@ reports in kern/41182.
 1.31  16-Jul-2008  drochner branches: 1.31.2; 1.31.8;
split device/softc for sd (tested with a USB stick)
 1.30  28-Apr-2008  martin branches: 1.30.2; 1.30.4; 1.30.6;
Remove clause 3 and 4 from TNF licenses
 1.29  09-Jul-2007  ad branches: 1.29.28; 1.29.30; 1.29.32;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.28  11-Dec-2005  christos branches: 1.28.30; 1.28.32;
merge ktrace-lwp.
 1.27  15-Oct-2005  yamt - change the way to specify a bufq strategy. (by string rather than by number)
- rather than embedding bufq_state in driver softc,
have a pointer to the former.
- move bufq related functions from kern/subr_disk.c to kern/subr_bufq.c.
- rename method to strategy for consistency.
- move some definitions which don't need to be exposed to the rest of kernel
from sys/bufq.h to sys/bufq_impl.h.
(is it better to move it to kern/ or somewhere?)
- fix some obvious breakage in dev/qbus/ts.c. (not tested)
 1.26  01-Feb-2005  reinoud branches: 1.26.6;
Backing out changes to clean up scsipi. I was pointed out there were
problems i hadn't seen. To prevent lossage i'd decided to back off all
changes and let them be reviewed on tech-kern.
 1.25  31-Jan-2005  reinoud Part of the cleanup of sys/scsipi's use of types; rename all u_int* to
uint* and change the u_long's to uint32_t's where possible. Note that the
iocl definitions/hooks have to be ulong (or u_long) or they'll bomb out.
 1.24  01-Oct-2004  thorpej branches: 1.24.4;
Don't need the lock in the softc anymore.
 1.23  17-Sep-2004  mycroft Do not manipulate xs->bp in "generic" code -- do it only in the psw_done
routine. As part of this, pass down our pre-parsed error code -- though this
interface will probably change later to accomodate better error handling.
 1.22  27-Aug-2004  bouyer Improve handling of memory shortage, to fix problems like:
sd3(mpt0:0:1:0): unable to allocate scsipi_xfer
sd3: not queued, error 12
Havard Eidnes's analysis of this problem is that the scsipi_xfer pool is
competing for resources with other pools, including the the inode and vnode
pools which can grow quite large.

*_scsipi_cmd(): don't biodone the buffer if scsipi_make_xs() fails, let the
caller deal with the problem
start function of block devices drivers: dequeue the buffer after the
scsipi_command() call. If scsipi_command() fails with ENOMEM don't dequeue
the buffer, and schedule a callout to call the start function after
some delay.
scsipi_init(): prime the scsipi_xfer_pool with one page. This ensure that
there is always some scsipi_xfer to play with. If scsipi_command() fails
because of pool_get(), we're sure there will be resources available later,
when the pending commands have completed.

Reviewed by Jason Thorpe and Havard Eidnes.
Todo: remove the "unable to allocate scsipi_xfer" and "not queued, error %d"
printfs, but I choose to keep them for now, to help make sure the code does
what it should.
 1.21  24-Feb-2004  wiz branches: 1.21.2;
parameter with two es. From Peter Postma.
 1.20  18-Sep-2003  mycroft Merge the geometry and cache handling code for all direct access and optical
devices, as it's general to all SCSI MMC devices. In the process, remove
PQUIRK_NO_FLEX_PAGE.
 1.19  03-Apr-2003  fvdl branches: 1.19.2;
Check RAW_PART against the media size instead of the disklabel.
Add the media size in 512-byte sectors to the softc, to avoid
some 64 bit computations. Bump the capacity stored in softcs
for disks to 64 bits.
 1.18  06-Jan-2003  matt Add multiple inclusion protection.
 1.17  16-Jul-2002  hannken Implement a new device buffer queue interface.
One basic struct, a function to setup a queue with a specific strategy and
three macros to put buf's into the queue, get and remove the next buf or
get the next buf without removal.

The BUFQ_XXX interface will be removed in the future.
The B_ORDERED flag is not longer supported.

Approved by: Jason R. Thorpe <thorpej@wasabisystems.com>
 1.16  09-Jan-2002  thorpej branches: 1.16.8;
Add ioctls to get (DIOCGCACHE) and set (DIOCSCACHE) cache enables
on disks in a generic way. Implement these ioctls for SCSI disks.

This is not fully fleshed-out yet, but it allows people to experiment
with disk caches more easily.
 1.15  23-May-2001  chs branches: 1.15.2;
fix typo in previous revision so that the scsi code compiles again.
 1.14  22-May-2001  mjacob Make SDRETRIES an option you can dig out of opt_scsi.h.

Add SD_IO_TIMEOUT (an option in opt_scsi.h) also, which defaults to the
normal 60 * 1000 timeout for normal read/write commamds. This allows you
to shorten or lengthen the timeout as needed.
 1.13  25-Apr-2001  bouyer Pull up the thorpej_scsipi branch to main branch.
This is a completely rewritten scsipi_xfer execution engine, and the
associated changes to HBA drivers. Overview of changes & features:
- All xfers are queued in the mid-layer, rather than doing so in an
ad-hoc fashion in individual adapter drivers.
- Adapter/channel resource management in the mid-layer, avoids even trying
to start running an xfer if the adapter/channel doesn't have the resources.
- Better communication between the mid-layer and the adapters.
- Asynchronous event notification mechanism from adapter to mid-layer and
peripherals.
- Better peripheral queue management: freeze/thaw, sorted requeueing during
recovery, etc.
- Clean separation of peripherals, adapters, and adapter channels (no more
scsipi_link).
- Kernel thread for each scsipi_channel makes error recovery much easier
(no more dealing with interrupt context when recovering from an error).
- Mid-layer support for tagged queueing: commands can have the tag type
set explicitly, tag IDs are allocated in the mid-layer (thus eliminating
the need to use buggy tag ID allocation schemes in many adapter drivers).
- support for QUEUE FULL and CHECK CONDITION status in mid-layer; the command
will be requeued, or a REQUEST SENSE will be sent as appropriate.

Just before the merge syssrc has been tagged with thorpej_scsipi_beforemerge
 1.12  23-May-2000  bouyer branches: 1.12.6;
sd_interpret_sense() can be called from interrupt context; call scsipi_start()
with XS_CTL_ASYNC if the failed command was called with XS_CTL_ASYNC.
Add a SDF_RESTART flag to keep state, cleared in sddone().
A mounted disk can now spin down, it will propely spin up at the next access.
 1.11  22-Jan-2000  drochner include "rnd.h" explicitely since the size of sd_softc depends on it
(sd_scsi.c and sd_atapi.c missed it, leading to random memory corruption)
 1.10  21-Jan-2000  thorpej Update for sys/buf.h/disksort_*() changes.
 1.9  11-Sep-1999  thorpej branches: 1.9.2;
Implement detaching SCSI and ATAPI disks.
 1.8  26-Aug-1999  hannken Make `sc_ops->sdo_flush' synchronous. The flags `SDF_FLUSHING' and
`SDF_DIRTY' were never reset because `sddone' doesn't get called from
synchronous scsi commands.
 1.7  17-Aug-1998  mycroft branches: 1.7.6;
Assign my copyrights to TNF.
 1.6  15-Aug-1998  thorpej Keep track if the disk has had done i/o, making it dirty. On last close,
or at shutdown, flush the cache if the disk is still dirty and it support
cache flushing. Fixes PRs #5588 (Jim Bernard) and #5589 (Justin Gibbs).
 1.5  05-Aug-1998  drochner Improve generation of default disklabels:
-store printable product ID in cd's and sd's softc, use it as "typename"
-for this, add a "destination buffer length" argument to scsipi_strvis()
-return ATAPI device type for ATAPI devices
 1.4  10-Jun-1998  thorpej Add a shutdown hook for SCSI-2 and higher disks that issues a SYNCHRONIZE CACHE
operation with address 0 length 0, which, according to the SCSI-2 spec, should
be interpreted as "synchronize all remaining blocks beginning at address 0".
 1.3  13-Feb-1998  enami Backout previous change, and rather, remove all protection but the one
actually currently required. Suggested by Charles M. Hannum.
 1.2  13-Feb-1998  enami Fix or add protection for mutiple inclusion.
 1.1  15-Jan-1998  cgd add support for an ATAPI attachment for 'sd'.
fix 'cd' driver's NCD_SCSI bogosity (was using testing wrong macro!)
clean up in various ways:
* make common atapi_mode_{sense,select}() functions.
* put ATAPI data structures in more sensible headers, split up by
device type.
* include headers a bit more carefully.
* pass flags to attachment-specific cd functions, and use them.
* get rid of SCSI bits in scsipi_base.h's scsipi_make_xs(), move
them into the correct place in scsi_base.c.
* fix minor typo in struct name in scsipiconf.h (which was apparently
never used except in a #define later in the same file).
* use __attribute__ to force 4-byte alignment for xs command store,
so that architectures trying to bus_space_write_multi_N() (where
N > 1) that data to a controller won't lose.
* clean up a few comments in typos, and make a few #defines easier to
understand/maintain.
* rename cd_link.h to cdvar.h (via repository copy). This is exactly
what a 'var' file is supposed to be.
 1.7.6.1  23-Jan-2000  he Pull up revision 1.11 (requested by drochner):
Fix a size inconsistency of "struct sd_softc" if the "random"
pseudo-device is enabled, leading to data corruption.
 1.9.2.2  20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.

Main changes to the scsipi code itself:
- add a scsipi_channel->type to allow umass to attach to both atapibus and
scsibus. Will die when IDE is converted from ata_atapi_attach to
scsipi_channel/scsipi_adapter
- Add a chan_defquirks to scsipi_channel so that adapters can pass a default
set of quirks to be set for each device attached
- add adapt_getgeom and adapt_accesschk callbacks
 1.9.2.1  19-Oct-1999  thorpej Completely rewritten scsipi_xfer execution engine:
- All xfers are queued in the mid-layer, rather than doing so in an
ad-hoc fashion in individual adapter drivers.
- Adapter/channel resource management in the mid-layer, avoids even trying
to start running an xfer if the adapter/channel doesn't have the resources.
- Better communication between the mid-layer and the adapters.
- Asynchronous event notification mechanism from adapter to mid-layer and
peripherals.
- Better peripheral queue management: freeze/thaw, sorted requeueing during
recovery, etc.
- Clean separation of peripherals, adapters, and adapter channels (no more
scsipi_link).
- Kernel thread for each scsipi_channel makes error recovery much easier
(no more dealing with interrupt context when recovering from an error).
- Mid-layer support for tagged queueing: commands can have the tag type
set explicitly, tag IDs are allocated in the mid-layer (thus eliminating
the need to use buggy tag ID allocation schemes in many adapter drivers).

There is a lot more work to do, but this correctly functions for the most
part on several file servers I run.
 1.12.6.5  07-Jan-2003  thorpej Sync with HEAD.
 1.12.6.4  01-Aug-2002  nathanw Catch up to -current.
 1.12.6.3  28-Feb-2002  nathanw Catch up to -current.
 1.12.6.2  11-Jan-2002  nathanw More catchup.
 1.12.6.1  21-Jun-2001  nathanw Catch up to -current.
 1.15.2.2  06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.15.2.1  10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.16.8.1  20-Jul-2002  gehenna catch up with -current.
 1.19.2.6  10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.19.2.5  19-Oct-2004  skrll Sync with HEAD
 1.19.2.4  21-Sep-2004  skrll Fix the sync with head I botched.
 1.19.2.3  18-Sep-2004  skrll Sync with HEAD.
 1.19.2.2  03-Sep-2004  skrll Sync with HEAD
 1.19.2.1  03-Aug-2004  skrll Sync with HEAD
 1.21.2.1  11-Sep-2004  he Pull up revision 1.22 (via patch, requested by bouyer in ticket #837):
Improve handling of memory shortage, to fix problems like:
sd3(mpt0:0:1:0): unable to allocate scsipi_xfer
sd3: not queued, error 12
The theory is that other consumers of pool memory is causing
this memory shortage in certain somewhat hard to reproduce
situations.
This is done by giving scsipi_command an extra argument to
optionally pass a preallocated scsipi_xfer, and allocating a
scsipi_xfer before dequeueing a buffer in the various *start()
functions. If the allocation of a scsipi_xfer fails, schedule
a callout for delayed invocation of the start function. Also
reserve one page for scsipi_xfer structs, to ensure that we will
eventually have some available once pending commands complete.
Should fix PR#25670.
 1.24.4.1  29-Apr-2005  kent sync with -current
 1.26.6.2  03-Sep-2007  yamt sync with head.
 1.26.6.1  21-Jun-2006  yamt sync with head.
 1.28.32.1  11-Jul-2007  mjf Sync with head.
 1.28.30.1  01-Jul-2007  ad Adapt to callout API change.
 1.29.32.2  04-May-2009  yamt sync with head.
 1.29.32.1  16-May-2008  yamt sync with head.
 1.29.30.1  18-May-2008  yamt sync with head.
 1.29.28.2  28-Sep-2008  mjf Sync with HEAD.
 1.29.28.1  02-Jun-2008  mjf Sync with HEAD.
 1.30.6.1  19-Oct-2008  haad Sync with HEAD.
 1.30.4.1  18-Jul-2008  simonb Sync with head.
 1.30.2.1  18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.31.8.1  13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.31.2.1  28-Apr-2009  skrll Sync with HEAD.
 1.32.12.1  17-Apr-2012  yamt sync with head
 1.33.2.1  18-Feb-2012  mrg merge to -current.
 1.34.6.1  03-Dec-2017  jdolecek update from HEAD
 1.35.2.3  05-Feb-2017  skrll Sync with HEAD
 1.35.2.2  22-Sep-2015  skrll Sync with HEAD
 1.35.2.1  06-Jun-2015  skrll Sync with HEAD
 1.37.2.1  07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.38.16.1  10-Jun-2019  christos Sync with HEAD
 1.39.4.1  29-Aug-2022  martin Pull up following revision(s) (requested by mlelstv in ticket #1509):

sys/dev/scsipi/sdvar.h: revision 1.40
sys/dev/scsipi/sd.c: revision 1.335

Don't fetch data beyond end of inquiry buffer, which, here, is not
NUL-terminated.

Reduce target buffer to needed size (product name + NUL terminator).

RSS XML Feed