1a77a7ee0SJulian Elischer.\" Copyright (c) 1996 2eddc45e7SJeroen Ruigrok van der Werven.\" Julian Elischer <julian@FreeBSD.org>. All rights reserved. 3a77a7ee0SJulian Elischer.\" 4a77a7ee0SJulian Elischer.\" Redistribution and use in source and binary forms, with or without 5a77a7ee0SJulian Elischer.\" modification, are permitted provided that the following conditions 6a77a7ee0SJulian Elischer.\" are met: 7a77a7ee0SJulian Elischer.\" 1. Redistributions of source code must retain the above copyright 8a77a7ee0SJulian Elischer.\" notice, this list of conditions and the following disclaimer. 9a77a7ee0SJulian Elischer.\" 10a77a7ee0SJulian Elischer.\" 2. Redistributions in binary form must reproduce the above copyright 11a77a7ee0SJulian Elischer.\" notice, this list of conditions and the following disclaimer in the 12a77a7ee0SJulian Elischer.\" documentation and/or other materials provided with the distribution. 13a77a7ee0SJulian Elischer.\" 14a77a7ee0SJulian Elischer.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15a77a7ee0SJulian Elischer.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16a77a7ee0SJulian Elischer.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17a77a7ee0SJulian Elischer.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18a77a7ee0SJulian Elischer.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19a77a7ee0SJulian Elischer.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20a77a7ee0SJulian Elischer.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21a77a7ee0SJulian Elischer.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22a77a7ee0SJulian Elischer.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23a77a7ee0SJulian Elischer.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24a77a7ee0SJulian Elischer.\" SUCH DAMAGE. 25a77a7ee0SJulian Elischer.\" 264e8867b9SAlexey Zelkin.\" $FreeBSD$ 27*db4fcadfSConrad Meyer.Dd January 15, 2017 286d6d0ae4SAlexander Motin.Dt CAM 4 293d45e180SRuslan Ermilov.Os 30db35f309SDavid Greenman.Sh NAME 3189045423SKenneth D. Merry.Nm CAM 326d6d0ae4SAlexander Motin.Nd Common Access Method SCSI/ATA subsystem 33db35f309SDavid Greenman.Sh SYNOPSIS 34b9781e20SJeroen Ruigrok van der Werven.Cd "device scbus" 356d6d0ae4SAlexander Motin.Cd "device ada" 36b9781e20SJeroen Ruigrok van der Werven.Cd "device cd" 37b9781e20SJeroen Ruigrok van der Werven.Cd "device ch" 38b9781e20SJeroen Ruigrok van der Werven.Cd "device da" 39b9781e20SJeroen Ruigrok van der Werven.Cd "device pass" 40b9781e20SJeroen Ruigrok van der Werven.Cd "device pt" 41b9781e20SJeroen Ruigrok van der Werven.Cd "device sa" 423136363fSRuslan Ermilov.Cd "options CAMDEBUG" 433136363fSRuslan Ermilov.Cd "options CAM_DEBUG_BUS=-1" 443136363fSRuslan Ermilov.Cd "options CAM_DEBUG_TARGET=-1" 453136363fSRuslan Ermilov.Cd "options CAM_DEBUG_LUN=-1" 46f0f25b9cSAlexander Motin.Cd "options CAM_DEBUG_COMPILE=CAM_DEBUG_INFO|CAM_DEBUG_CDB|CAM_DEBUG_PROBE" 473136363fSRuslan Ermilov.Cd "options CAM_DEBUG_FLAGS=CAM_DEBUG_INFO|CAM_DEBUG_CDB" 483136363fSRuslan Ermilov.Cd "options CAM_MAX_HIGHPOWER=4" 493136363fSRuslan Ermilov.Cd "options SCSI_NO_SENSE_STRINGS" 503136363fSRuslan Ermilov.Cd "options SCSI_NO_OP_STRINGS" 513136363fSRuslan Ermilov.Cd "options SCSI_DELAY=8000" 52db35f309SDavid Greenman.Sh DESCRIPTION 536d6d0ae4SAlexander MotinThe 546d6d0ae4SAlexander Motin.Nm 5589045423SKenneth D. Merrysubsystem provides a uniform and modular system for the implementation 5689045423SKenneth D. Merryof drivers to control various 5789045423SKenneth D. Merry.Tn SCSI 586d6d0ae4SAlexander Motinand 596d6d0ae4SAlexander Motin.Tn ATA 6089045423SKenneth D. Merrydevices, and to utilize different 6189045423SKenneth D. Merry.Tn SCSI 626d6d0ae4SAlexander Motinand 636d6d0ae4SAlexander Motin.Tn ATA 646d249eeeSSheldon Hearnhost adapters through host adapter drivers. 65*db4fcadfSConrad MeyerWhen the system probes buses, it attaches any devices it finds to the 666d6d0ae4SAlexander Motinappropriate drivers. 67b5e7e999SRuslan ErmilovThe 6889045423SKenneth D. Merry.Xr pass 4 696d6d0ae4SAlexander Motindriver, if it is configured in the kernel, will attach to all devices. 70db35f309SDavid Greenman.Sh KERNEL CONFIGURATION 7189045423SKenneth D. MerryThere are a number of generic kernel configuration options for the 726d6d0ae4SAlexander Motin.Nm 7389045423SKenneth D. Merrysubsystem: 7489045423SKenneth D. Merry.Bl -tag -width SCSI_NO_SENSE_STRINGS 7589045423SKenneth D. Merry.It Dv CAMDEBUG 76f0f25b9cSAlexander MotinThis option compiles in all the 776d6d0ae4SAlexander Motin.Nm 786d6d0ae4SAlexander Motindebugging printf code. 790227791bSRuslan ErmilovThis will not actually 8089045423SKenneth D. Merrycause any debugging information to be printed out when included by itself. 81b5e7e999SRuslan ErmilovSee below for details. 8289045423SKenneth D. Merry.It Dv "CAM_MAX_HIGHPOWER=4" 8389045423SKenneth D. MerryThis sets the maximum allowable number of concurrent "high power" commands. 8489045423SKenneth D. MerryA "high power" command is a command that takes more electrical power than 85b5e7e999SRuslan Ermilovmost to complete. 866d6d0ae4SAlexander MotinAn example of this is the 8789045423SKenneth D. Merry.Tn SCSI 88b5e7e999SRuslan ErmilovSTART UNIT command. 896d6d0ae4SAlexander MotinStarting a disk often takes significantly more electrical power than normal 906d6d0ae4SAlexander Motinoperation. 91b5e7e999SRuslan ErmilovThis option allows the 9289045423SKenneth D. Merryuser to specify how many concurrent high power commands may be outstanding 9389045423SKenneth D. Merrywithout overloading the power supply on his computer. 9489045423SKenneth D. Merry.It Dv SCSI_NO_SENSE_STRINGS 9589045423SKenneth D. MerryThis eliminates text descriptions of each 9689045423SKenneth D. Merry.Tn SCSI 97b5e7e999SRuslan ErmilovAdditional Sense Code and Additional Sense Code Qualifier pair. 98b5e7e999SRuslan ErmilovSince this 9989045423SKenneth D. Merryis a fairly large text database, eliminating it reduces the size of the 100b5e7e999SRuslan Ermilovkernel somewhat. 101b5e7e999SRuslan ErmilovThis is primarily necessary for boot floppies and other 102b5e7e999SRuslan Ermilovlow disk space or low memory space environments. 103b5e7e999SRuslan ErmilovIn most cases, though, 10489045423SKenneth D. Merrythis should be enabled, since it speeds the interpretation of 10589045423SKenneth D. Merry.Tn SCSI 1065203edcdSRuslan Ermiloverror messages. 1070227791bSRuslan ErmilovDo not let the "kernel bloat" zealots get to you -- leave 10889045423SKenneth D. Merrythe sense descriptions in your kernel! 10989045423SKenneth D. Merry.It Dv SCSI_NO_OP_STRINGS 11089045423SKenneth D. MerryThis disables text descriptions of each 11189045423SKenneth D. Merry.Tn SCSI 112b5e7e999SRuslan Ermilovopcode. 113b5e7e999SRuslan ErmilovThis option, like the sense string option above, is primarily 11489045423SKenneth D. Merryuseful for environments like a boot floppy where kernel size is critical. 1150227791bSRuslan ErmilovEnabling this option for normal use is not recommended, since it slows 11689045423SKenneth D. Merrydebugging of 11789045423SKenneth D. Merry.Tn SCSI 11889045423SKenneth D. Merryproblems. 11989045423SKenneth D. Merry.It Dv SCSI_DELAY=8000 12089045423SKenneth D. MerryThis is the 12189045423SKenneth D. Merry.Tn SCSI 122b5e7e999SRuslan Ermilov"bus settle delay." 1236d6d0ae4SAlexander MotinIn 1246d6d0ae4SAlexander Motin.Nm , 1256d6d0ae4SAlexander Motinit is specified in 12689045423SKenneth D. Merry.Em milliseconds , 12789045423SKenneth D. Merrynot seconds like the old 12889045423SKenneth D. Merry.Tn SCSI 129b5e7e999SRuslan Ermilovlayer used to do. 130b5e7e999SRuslan ErmilovWhen the kernel boots, it sends a bus reset to each 13189045423SKenneth D. Merry.Tn SCSI 13289045423SKenneth D. Merrybus to tell each device to reset itself to a default set of transfer 133b5e7e999SRuslan Ermilovnegotiations and other settings. 134b5e7e999SRuslan ErmilovMost 13589045423SKenneth D. Merry.Tn SCSI 136b5e7e999SRuslan Ermilovdevices need some amount of time to recover from a bus reset. 137b5e7e999SRuslan ErmilovNewer disks 13889045423SKenneth D. Merrymay need as little as 100ms, while old, slow devices may need much longer. 13989045423SKenneth D. MerryIf the 14089045423SKenneth D. Merry.Dv SCSI_DELAY 1410227791bSRuslan Ermilovis not specified, it defaults to 2 seconds. 142b5e7e999SRuslan ErmilovThe minimum allowable value for 14389045423SKenneth D. Merry.Dv SCSI_DELAY 144b5e7e999SRuslan Ermilovis "100", or 100ms. 145b5e7e999SRuslan ErmilovOne special case is that if the 14689045423SKenneth D. Merry.Dv SCSI_DELAY 147b5e7e999SRuslan Ermilovis set to 0, that will be taken to mean the "lowest possible value." 148b5e7e999SRuslan ErmilovIn that case, the 14989045423SKenneth D. Merry.Dv SCSI_DELAY 15089045423SKenneth D. Merrywill be reset to 100ms. 15189045423SKenneth D. Merry.El 1522460bdf0SPeter Dufault.Pp 153*db4fcadfSConrad MeyerAll devices and buses support dynamic allocation so that 1542460bdf0SPeter Dufaultan upper number of devices and controllers does not need to be configured; 155f5a8c129SJuli Mallett.Cd "device da" 1562460bdf0SPeter Dufaultwill suffice for any number of disk drivers. 1572460bdf0SPeter Dufault.Pp 1582460bdf0SPeter DufaultThe devices are either 1592460bdf0SPeter Dufault.Em wired 1602460bdf0SPeter Dufaultso they appear as a particular device unit or 1612460bdf0SPeter Dufault.Em counted 1622460bdf0SPeter Dufaultso that they appear as the next available unused unit. 1632460bdf0SPeter Dufault.Pp 1649ff00466SScott LongUnits are wired down by setting kernel environment hints. 1655203edcdSRuslan ErmilovThis is usually done either interactively from the 1665203edcdSRuslan Ermilov.Xr loader 8 , 1675203edcdSRuslan Ermilovor automatically via the 1689ff00466SScott Long.Pa /boot/device.hints 1695203edcdSRuslan Ermilovfile. 1705203edcdSRuslan ErmilovThe basic syntax is: 1719ff00466SScott Long.Bd -literal -offset indent 1729ff00466SScott Longhint.device.unit.property="value" 1739ff00466SScott Long.Ed 1742460bdf0SPeter Dufault.Pp 1755203edcdSRuslan ErmilovIndividual 1765203edcdSRuslan Ermilov.Nm 1775203edcdSRuslan Ermilovbus numbers can be wired down to specific controllers with 1789ff00466SScott Longa config line similar to the following: 1799ff00466SScott Long.Bd -literal -offset indent 1809ff00466SScott Longhint.scbus.0.at="ahd1" 1819ff00466SScott Long.Ed 1829ff00466SScott Long.Pp 1835203edcdSRuslan ErmilovThis assigns 1845203edcdSRuslan Ermilov.Nm 1855203edcdSRuslan Ermilovbus number 0 to the 1869ff00466SScott Long.Em ahd1 1879ff00466SScott Longdriver instance. 1889ff00466SScott LongFor controllers supporting more than one bus, a particular bus can be assigned 1899ff00466SScott Longas follows: 1909ff00466SScott Long.Bd -literal -offset indent 1919ff00466SScott Longhint.scbus.0.at="ahc1" 1929ff00466SScott Longhint.scbus.0.bus="1" 1939ff00466SScott Long.Ed 1949ff00466SScott Long.Pp 1955203edcdSRuslan ErmilovThis assigns 1965203edcdSRuslan Ermilov.Nm 1975203edcdSRuslan Ermilovbus 0 to the bus 1 instance on 1982ccd462bSAlexander Motin.Em ahc1 . 1999ff00466SScott LongPeripheral drivers can be wired to a specific bus, target, and lun as so: 2009ff00466SScott Long.Bd -literal -offset indent 2019ff00466SScott Longhint.da.0.at="scbus0" 2029ff00466SScott Longhint.da.0.target="0" 2039ff00466SScott Longhint.da.0.unit="0" 2049ff00466SScott Long.Ed 2059ff00466SScott Long.Pp 2069ff00466SScott LongThis assigns 2079ff00466SScott Long.Em da0 2089ff00466SScott Longto target 0, unit (lun) 0 of scbus 0. 2096d6d0ae4SAlexander MotinOmitting the target or unit hints will instruct 2106d6d0ae4SAlexander Motin.Nm 2116d6d0ae4SAlexander Motinto treat them as wildcards 2129ff00466SScott Longand use the first respective counted instances. 2139ff00466SScott LongThese examples can be combined together to allow a peripheral device to be 2149ff00466SScott Longwired to any particular controller, bus, target, and/or unit instance. 2152460bdf0SPeter Dufault.Pp 2162460bdf0SPeter DufaultWhen you have a mixture of wired down and counted devices then the 2172460bdf0SPeter Dufaultcounting begins with the first non-wired down unit for a particular 218b5e7e999SRuslan Ermilovtype. 219b5e7e999SRuslan ErmilovThat is, if you have a disk wired down as 22089045423SKenneth D. Merry.Em "device da1" , 2212460bdf0SPeter Dufaultthen the first non-wired disk shall come on line as 22289045423SKenneth D. Merry.Em da2 . 223db35f309SDavid Greenman.Sh ADAPTERS 224db35f309SDavid GreenmanThe system allows common device drivers to work through many different 2256d249eeeSSheldon Hearntypes of adapters. 2266d249eeeSSheldon HearnThe adapters take requests from the upper layers and do 227db35f309SDavid Greenmanall IO between the 2286d6d0ae4SAlexander Motin.Tn SCSI 2296d6d0ae4SAlexander Motinor 2306d6d0ae4SAlexander Motin.Tn ATA 2316d249eeeSSheldon Hearnbus and the system. 2326d249eeeSSheldon HearnThe maximum size of a transfer is governed by the 2336d249eeeSSheldon Hearnadapter. 2346d249eeeSSheldon HearnMost adapters can transfer 64KB in a single operation, however 235db35f309SDavid Greenmanmany can transfer larger amounts. 236db35f309SDavid Greenman.Sh TARGET MODE 237db35f309SDavid GreenmanSome adapters support 23889045423SKenneth D. Merry.Em target mode 239db35f309SDavid Greenmanin which the system is capable of operating as a device, responding to 2406d249eeeSSheldon Hearnoperations initiated by another system. 2416d249eeeSSheldon HearnTarget mode is supported for 2426d6d0ae4SAlexander Motinsome adapters, but is not yet complete for this version of the 2436d6d0ae4SAlexander Motin.Nm 24489045423SKenneth D. Merry.Tn SCSI 24589045423SKenneth D. Merrysubsystem. 246db35f309SDavid Greenman.Sh FILES 2475203edcdSRuslan Ermilovsee other 2485203edcdSRuslan Ermilov.Nm 2495203edcdSRuslan Ermilovdevice entries. 250db35f309SDavid Greenman.Sh DIAGNOSTICS 251f0f25b9cSAlexander MotinAn XPT_DEBUG CCB can be used to enable various amounts of tracing information 252f0f25b9cSAlexander Motinon any specific bus/device from the list of options compiled into the kernel. 253f0f25b9cSAlexander MotinThere are currently seven debugging flags that may be compiled in and used: 25489045423SKenneth D. Merry.Bl -tag -width CAM_DEBUG_SUBTRACE 25589045423SKenneth D. Merry.It Dv CAM_DEBUG_INFO 256f0f25b9cSAlexander MotinThis flag enables general informational printfs for the device 25789045423SKenneth D. Merryor devices in question. 25889045423SKenneth D. Merry.It Dv CAM_DEBUG_TRACE 259f0f25b9cSAlexander MotinThis flag enables function-level command flow tracing. 2605203edcdSRuslan Ermilovi.e.\& 26189045423SKenneth D. Merrykernel printfs will happen at the entrance and exit of various functions. 26289045423SKenneth D. Merry.It Dv CAM_DEBUG_SUBTRACE 263f0f25b9cSAlexander MotinThis flag enables debugging output internal to various functions. 26489045423SKenneth D. Merry.It Dv CAM_DEBUG_CDB 265f0f25b9cSAlexander MotinThis flag will cause the kernel to print out all 266f0f25b9cSAlexander Motin.Tn ATA 267f0f25b9cSAlexander Motinand 26889045423SKenneth D. Merry.Tn SCSI 26989045423SKenneth D. Merrycommands sent to a particular device or devices. 270f0f25b9cSAlexander Motin.It Dv CAM_DEBUG_XPT 271f0f25b9cSAlexander MotinThis flag will enable command scheduler tracing. 272f0f25b9cSAlexander Motin.It Dv CAM_DEBUG_PERIPH 273f0f25b9cSAlexander MotinThis flag will enable peripheral drivers messages. 274f0f25b9cSAlexander Motin.It Dv CAM_DEBUG_PROBE 275f0f25b9cSAlexander MotinThis flag will enable devices probe process tracing. 276db35f309SDavid Greenman.El 27789045423SKenneth D. Merry.Pp 27889045423SKenneth D. MerrySome of these flags, most notably 27989045423SKenneth D. Merry.Dv CAM_DEBUG_TRACE 28089045423SKenneth D. Merryand 281f0f25b9cSAlexander Motin.Dv CAM_DEBUG_SUBTRACE , 282f0f25b9cSAlexander Motinwill produce kernel printfs in EXTREME numbers. 283f0f25b9cSAlexander Motin.Pp 2845203edcdSRuslan ErmilovUsers can enable debugging from their kernel config file, by using 28589045423SKenneth D. Merrythe following kernel config options: 286f0f25b9cSAlexander Motin.Bl -tag -width CAM_DEBUG_COMPILE 28789045423SKenneth D. Merry.It Dv CAMDEBUG 288f0f25b9cSAlexander MotinThis builds into the kernel all possible 2896d6d0ae4SAlexander Motin.Nm 2906d6d0ae4SAlexander Motindebugging. 291f0f25b9cSAlexander Motin.It Dv CAM_DEBUG_COMPILE 292f0f25b9cSAlexander MotinThis allows to specify support for which debugging flags described above 293f0f25b9cSAlexander Motinshould be built into the kernel. 294b5e7e999SRuslan ErmilovFlags may be ORed together if the user wishes to 29589045423SKenneth D. Merrysee printfs for multiple debugging levels. 296f0f25b9cSAlexander Motin.It Dv CAM_DEBUG_FLAGS 297f0f25b9cSAlexander MotinThis allows to set the various debugging flags from a kernel config file. 29889045423SKenneth D. Merry.It Dv CAM_DEBUG_BUS 299b5e7e999SRuslan ErmilovSpecify a bus to debug. 300*db4fcadfSConrad MeyerTo debug all buses, set this to -1. 30189045423SKenneth D. Merry.It Dv CAM_DEBUG_TARGET 302b5e7e999SRuslan ErmilovSpecify a target to debug. 303b5e7e999SRuslan ErmilovTo debug all targets, set this to -1. 30489045423SKenneth D. Merry.It Dv CAM_DEBUG_LUN 305b5e7e999SRuslan ErmilovSpecify a lun to debug. 306b5e7e999SRuslan ErmilovTo debug all luns, set this to -1. 30789045423SKenneth D. Merry.El 30889045423SKenneth D. Merry.Pp 309f0f25b9cSAlexander MotinUsers may also enable debugging on the fly by using the 31089045423SKenneth D. Merry.Xr camcontrol 8 311f0f25b9cSAlexander Motinutility, if wanted options built into the kernel. 3125203edcdSRuslan ErmilovSee 31389045423SKenneth D. Merry.Xr camcontrol 8 31489045423SKenneth D. Merryfor details. 315db35f309SDavid Greenman.Sh SEE ALSO 3166d6d0ae4SAlexander Motin.Xr ada 4 , 317e0e5145cSWolfram Schneider.Xr aha 4 , 318e0e5145cSWolfram Schneider.Xr ahb 4 , 31989045423SKenneth D. Merry.Xr ahc 4 , 3206d6d0ae4SAlexander Motin.Xr ahci 4 , 3216d6d0ae4SAlexander Motin.Xr ata 4 , 322e0e5145cSWolfram Schneider.Xr bt 4 , 3230b992c1dSWolfram Schneider.Xr cd 4 , 3240b992c1dSWolfram Schneider.Xr ch 4 , 32589045423SKenneth D. Merry.Xr da 4 , 32689045423SKenneth D. Merry.Xr pass 4 , 32789045423SKenneth D. Merry.Xr pt 4 , 32889045423SKenneth D. Merry.Xr sa 4 , 32989045423SKenneth D. Merry.Xr xpt 4 , 33089045423SKenneth D. Merry.Xr camcontrol 8 331db35f309SDavid Greenman.Sh HISTORY 3326d6d0ae4SAlexander MotinThe 3336d6d0ae4SAlexander Motin.Nm 33489045423SKenneth D. Merry.Tn SCSI 33589045423SKenneth D. Merrysubsystem first appeared in 33689045423SKenneth D. Merry.Fx 3.0 . 3376d6d0ae4SAlexander MotinThe 3386d6d0ae4SAlexander Motin.Nm 3396d6d0ae4SAlexander MotinATA support was added in 3406d6d0ae4SAlexander Motin.Fx 8.0 . 34189045423SKenneth D. Merry.Sh AUTHORS 342f4d874a1SRuslan Ermilov.An -nosplit 3436d6d0ae4SAlexander MotinThe 3446d6d0ae4SAlexander Motin.Nm 34589045423SKenneth D. Merry.Tn SCSI 346def37e7cSMike Pritchardsubsystem was written by 347def37e7cSMike Pritchard.An Justin Gibbs 348def37e7cSMike Pritchardand 349def37e7cSMike Pritchard.An Kenneth Merry . 3506d6d0ae4SAlexander MotinThe 3516d6d0ae4SAlexander Motin.Nm 3526d6d0ae4SAlexander Motin.Tn ATA 3536d6d0ae4SAlexander Motinsupport was added by 3546c899950SBaptiste Daroussin.An Alexander Motin Aq Mt mav@FreeBSD.org . 355