Home | History | Annotate | Download | only in scsipi
History log of /src/sys/dev/scsipi/cdvar.h
RevisionDateAuthorComments
 1.33  10-Dec-2016  mlelstv Refactored sd and cd to use common disk subroutines.
 1.32  14-Apr-2015  riastradh branches: 1.32.2;
Include <sys/rndsource.h> where it is actually used.

I had removed <sys/rnd.h> from files that didn't mention anything of
the rnd(9) API. But they included other files which assumed
<sys/rnd.h> had already been included.
 1.31  02-Feb-2012  tls branches: 1.31.6; 1.31.24;
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.30  19-Nov-2011  tls branches: 1.30.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.29  19-Oct-2009  bouyer branches: 1.29.12;
Remove closes 3 & 4 from my licence. Lots of thanks to Soren Jacobsen
for the booring work !
 1.28  24-Mar-2008  cube branches: 1.28.4;
Split device_t for cd(4).
 1.27  21-Jul-2007  ad branches: 1.27.26; 1.27.28;
Replace some uses of lockmgr().
 1.26  11-Dec-2005  christos branches: 1.26.30; 1.26.40;
merge ktrace-lwp.
 1.25  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.24  01-Feb-2005  reinoud branches: 1.24.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.23  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.22  17-Sep-2004  mycroft branches: 1.22.4;
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.21  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.20  08-Sep-2003  mycroft branches: 1.20.2;
Eliminate the separate ATAPI and SCSI attachments for "cd".
 1.19  07-Sep-2003  mycroft Set PQUIRK_ONLYBIG in the wdc-atapi frontend, obviating the need to ever test
the "bus type" for this.

Merge all the code in the SCSI and ATAPI backends for "cd" devices. All of
the mode page handling and whatnot is general to SCSI MMC devices, and should
never have been separated to begin with. This fixes a variety of problems,
and adds load/unload support for SCSI-attached devices.
 1.18  10-Jul-2003  martin If a CD drive reports != 2048 byte block size, try to change it into
2048 byte mode. Fixes PR kern/22090.
Reviewed by Manuel Bouyer.
 1.17  10-May-2003  thorpej branches: 1.17.2;
Change bounds_check_with_label() to take a pointer to the disk structure,
rather than the label itself. This paves the way for some future changes.
 1.16  03-Apr-2003  fvdl 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.15  22-Jul-2002  hannken Convert to new device buffer queue interface.
 1.14  23-Apr-2002  bouyer branches: 1.14.2;
More copyright fixes, pointed out by Thomas. Thanks !
 1.13  25-Apr-2001  bouyer branches: 1.13.2;
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  21-Jan-2000  thorpej branches: 1.12.6;
Update for sys/buf.h/disksort_*() changes.
 1.11  23-Sep-1999  enami branches: 1.11.2;
Allow to detach wdc, atapibus, wd and cd.
 1.10  02-Feb-1999  bouyer Bump CDRETRIES to 4. Now if a DMA error occurs, the driver should downgrade
to PIO mode and the command be retried properly.
 1.9  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.8  13-Jul-1998  hpeyerl Add support for ATA CD changer devices like the NEC CDR-251.
Evidence of managerial coding removed by Victor T. Cleaner (thorpej)
 1.7  13-Feb-1998  enami Backout previous change, and rather, remove all protection but the one
actually currently required. Suggested by Charles M. Hannum.
 1.6  13-Feb-1998  enami Fix or add protection for mutiple inclusion.
 1.5  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.4  13-Oct-1997  explorer o Make usage of /dev/random dependant on
pseudo-device rnd # /dev/random and in-kernel generator
in config files.

o Add declaration to all architectures.

o Clean up copyright message in rnd.c, rnd.h, and rndpool.c to include
that this code is derived in part from Ted Tyso's linux code.
 1.3  10-Oct-1997  explorer Add hooks to insert timing info into the random system
 1.2  27-Aug-1997  bouyer branches: 1.2.2;
Merge scsipi branch in the mainline. This add support for ATAPI devices
(currently only CD-ROM drives on i386). The sys/dev/scsipi system provides 2
busses to which devices can attach (scsibus and atapibus). This needed to
change some include files and structure names in the low level scsi drivers.
 1.1  01-Jul-1997  bouyer branches: 1.1.2;
file cd_link.h was initially added on branch bouyer-scsipi.
 1.1.2.2  01-Jul-1997  thorpej Use an operations vector set up at attach time rather than checking
for device type each time, for setvol/getvol/setchan operations.

Also, some KNF.
 1.1.2.1  01-Jul-1997  bouyer New merged scsi/atapi code. Tested on i386 and sparc. Commiting to a branch
for now, so that it can be tested on other ports too.
The config sheme is as follow:
New merged scsi/atapi code. Tested on i386 and sparc. Commiting to a branch
for now, so that it can be tested on other ports too.
The config sheme is as follow:
scsibus at aha
sd at scsibus
cd at scsibus
atapibus at wdc
cd at atapibus
cd has bus-specific config and function front-end in scsicd.c and atapicd.c
The call to theses functions from cd.c is conditionned to
NSCSICD and NATAPICD (all defined in cd.h by config).
 1.2.2.2  14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.2.2.1  27-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.11.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.11.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.3  01-Aug-2002  nathanw Catch up to -current.
 1.12.6.2  20-Jun-2002  nathanw Catch up to -current.
 1.12.6.1  21-Jun-2001  nathanw Catch up to -current.
 1.13.2.2  06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.13.2.1  23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.14.2.1  29-Aug-2002  gehenna catch up with -current.
 1.17.2.5  10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.17.2.4  21-Sep-2004  skrll Fix the sync with head I botched.
 1.17.2.3  18-Sep-2004  skrll Sync with HEAD.
 1.17.2.2  03-Sep-2004  skrll Sync with HEAD
 1.17.2.1  03-Aug-2004  skrll Sync with HEAD
 1.20.2.1  11-Sep-2004  he Pull up revision 1.21 (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.22.4.1  29-Apr-2005  kent sync with -current
 1.24.6.2  03-Sep-2007  yamt sync with head.
 1.24.6.1  21-Jun-2006  yamt sync with head.
 1.26.40.1  15-Aug-2007  skrll Sync with HEAD.
 1.26.30.1  20-Aug-2007  ad Sync with HEAD.
 1.27.28.2  21-Jul-2007  ad Replace some uses of lockmgr().
 1.27.28.1  21-Jul-2007  ad file cdvar.h was added on branch matt-mips64 on 2007-07-21 19:51:49 +0000
 1.27.26.1  03-Apr-2008  mjf Sync with HEAD.
 1.28.4.1  11-Mar-2010  yamt sync with head
 1.29.12.1  17-Apr-2012  yamt sync with head
 1.30.2.1  18-Feb-2012  mrg merge to -current.
 1.31.24.2  05-Feb-2017  skrll Sync with HEAD
 1.31.24.1  06-Jun-2015  skrll Sync with HEAD
 1.31.6.1  03-Dec-2017  jdolecek update from HEAD
 1.32.2.1  07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)

RSS XML Feed