xref: /freebsd/share/man/man4/scsi.4 (revision e796cc77c586c2955b2f3940dbf4991b31e8d289)
1.\" Copyright (c) 1996
2.\"	Julian Elischer <julian@FreeBSD.org>.  All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\"
10.\" 2. Redistributions in binary form must reproduce the above copyright
11.\"    notice, this list of conditions and the following disclaimer in the
12.\"    documentation and/or other materials provided with the distribution.
13.\"
14.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24.\" SUCH DAMAGE.
25.\"
26.\" $FreeBSD$
27.Dd December 20, 2017
28.Dt CAM 4
29.Os
30.Sh NAME
31.Nm CAM
32.Nd Common Access Method Storage subsystem
33.Sh SYNOPSIS
34.Cd "device scbus"
35.Cd "device ada"
36.Cd "device cd"
37.Cd "device ch"
38.Cd "device da"
39.Cd "device pass"
40.Cd "device pt"
41.Cd "device sa"
42.Cd "options CAMDEBUG"
43.Cd "options CAM_DEBUG_BUS=-1"
44.Cd "options CAM_DEBUG_TARGET=-1"
45.Cd "options CAM_DEBUG_LUN=-1"
46.Cd "options CAM_DEBUG_COMPILE=CAM_DEBUG_INFO|CAM_DEBUG_CDB|CAM_DEBUG_PROBE"
47.Cd "options CAM_DEBUG_FLAGS=CAM_DEBUG_INFO|CAM_DEBUG_CDB"
48.Cd "options CAM_MAX_HIGHPOWER=4"
49.Cd "options SCSI_NO_SENSE_STRINGS"
50.Cd "options SCSI_NO_OP_STRINGS"
51.Cd "options SCSI_DELAY=8000"
52.Sh DESCRIPTION
53The
54.Nm
55subsystem provides a uniform and modular system for the implementation
56of drivers to control various
57.Tn SCSI ,
58.Tn ATA ,
59.Tn NMVe ,
60and
61.Tn MMC / SD
62devices, and to utilize different
63.Tn SCSI ,
64.Tn ATA ,
65.Tn NVMe ,
66and
67.Tn MMC / SD
68host adapters through host adapter drivers.
69When the system probes buses, it attaches any devices it finds to the
70appropriate drivers.
71The
72.Xr pass 4
73driver, if it is configured in the kernel, will attach to all devices.
74.Sh KERNEL CONFIGURATION
75There are a number of generic kernel configuration options for the
76.Nm
77subsystem:
78.Bl -tag -width SCSI_NO_SENSE_STRINGS
79.It Dv CAMDEBUG
80This option compiles in all the
81.Nm
82debugging printf code.
83This will not actually
84cause any debugging information to be printed out when included by itself.
85See below for details.
86.It Dv "CAM_MAX_HIGHPOWER=4"
87This sets the maximum allowable number of concurrent "high power" commands.
88A "high power" command is a command that takes more electrical power than
89most to complete.
90An example of this is the
91.Tn SCSI
92START UNIT command.
93Starting a disk often takes significantly more electrical power than normal
94operation.
95This option allows the
96user to specify how many concurrent high power commands may be outstanding
97without overloading the power supply on his computer.
98.It Dv SCSI_NO_SENSE_STRINGS
99This eliminates text descriptions of each
100.Tn SCSI
101Additional Sense Code and Additional Sense Code Qualifier pair.
102Since this
103is a fairly large text database, eliminating it reduces the size of the
104kernel somewhat.
105This is primarily necessary for boot floppies and other
106low disk space or low memory space environments.
107In most cases, though,
108this should be enabled, since it speeds the interpretation of
109.Tn SCSI
110error messages.
111Do not let the "kernel bloat" zealots get to you -- leave
112the sense descriptions in your kernel!
113.It Dv SCSI_NO_OP_STRINGS
114This disables text descriptions of each
115.Tn SCSI
116opcode.
117This option, like the sense string option above, is primarily
118useful for environments like a boot floppy where kernel size is critical.
119Enabling this option for normal use is not recommended, since it slows
120debugging of
121.Tn SCSI
122problems.
123.It Dv SCSI_DELAY=8000
124This is the
125.Tn SCSI
126"bus settle delay."
127In
128.Nm ,
129it is specified in
130.Em milliseconds ,
131not seconds like the old
132.Tn SCSI
133layer used to do.
134When the kernel boots, it sends a bus reset to each
135.Tn SCSI
136bus to tell each device to reset itself to a default set of transfer
137negotiations and other settings.
138Most
139.Tn SCSI
140devices need some amount of time to recover from a bus reset.
141Newer disks
142may need as little as 100ms, while old, slow devices may need much longer.
143If the
144.Dv SCSI_DELAY
145is not specified, it defaults to 2 seconds.
146The minimum allowable value for
147.Dv SCSI_DELAY
148is "100", or 100ms.
149One special case is that if the
150.Dv SCSI_DELAY
151is set to 0, that will be taken to mean the "lowest possible value."
152In that case, the
153.Dv SCSI_DELAY
154will be reset to 100ms.
155.El
156.Pp
157All devices and buses support dynamic allocation so that
158an upper number of devices and controllers does not need to be configured;
159.Cd "device da"
160will suffice for any number of disk drivers.
161.Pp
162The devices are either
163.Em wired
164so they appear as a particular device unit or
165.Em counted
166so that they appear as the next available unused unit.
167.Pp
168Units are wired down by setting kernel environment hints.
169This is usually done either interactively from the
170.Xr loader 8 ,
171or automatically via the
172.Pa /boot/device.hints
173file.
174The basic syntax is:
175.Bd -literal -offset indent
176hint.device.unit.property="value"
177.Ed
178.Pp
179Individual
180.Nm
181bus numbers can be wired down to specific controllers with
182a config line similar to the following:
183.Bd -literal -offset indent
184hint.scbus.0.at="ahd1"
185.Ed
186.Pp
187This assigns
188.Nm
189bus number 0 to the
190.Em ahd1
191driver instance.
192For controllers supporting more than one bus, a particular bus can be assigned
193as follows:
194.Bd -literal -offset indent
195hint.scbus.0.at="ahc1"
196hint.scbus.0.bus="1"
197.Ed
198.Pp
199This assigns
200.Nm
201bus 0 to the bus 1 instance on
202.Em ahc1 .
203Peripheral drivers can be wired to a specific bus, target, and lun as so:
204.Bd -literal -offset indent
205hint.da.0.at="scbus0"
206hint.da.0.target="0"
207hint.da.0.unit="0"
208.Ed
209.Pp
210This assigns
211.Em da0
212to target 0, unit (lun) 0 of scbus 0.
213Omitting the target or unit hints will instruct
214.Nm
215to treat them as wildcards
216and use the first respective counted instances.
217These examples can be combined together to allow a peripheral device to be
218wired to any particular controller, bus, target, and/or unit instance.
219.Pp
220This also works with
221.Xr nvme 4
222drives as well.
223.Bd -literal -offset indent
224hint.nvme.4.at="pci7:0:0"
225hint.scbus.10.at="nvme4"
226hint.nda.10.at="scbus10"
227hint.nda.10.target="1"
228hint.nda.10.unit="12"
229hint.nda.11.at="scbus10"
230hint.nda.11.target="1"
231hint.nda.11.unit="2"
232.Ed
233.Pp
234This assigns the NVMe card living at PCI bus 7 to scbus 10 (in PCIe,
235slot and function are rarely used and usually 0).
236The target for
237.Xr nda 4
238devices is always 1.
239The unit is the namespace identifier from the drive.
240The namespace id 1 is exported as
241.Tn nda10
242and namespace id 2 is exported as
243.Tn nda11 .
244.Pp
245When you have a mixture of wired down and counted devices then the
246counting begins with the first non-wired down unit for a particular
247type.
248That is, if you have a disk wired down as
249.Em "device da1" ,
250then the first non-wired disk shall come on line as
251.Em da2 .
252.Sh ADAPTERS
253The system allows common device drivers to work through many different
254types of adapters.
255The adapters take requests from the upper layers and do
256all IO between the
257.Tn SCSI ,
258.Tn ATA ,
259.Tn NVMe ,
260or
261.Tn MMC / SD
262bus and the system.
263The maximum size of a transfer is governed by the
264adapter.
265Most adapters can transfer 64KB in a single operation, however
266many can transfer larger amounts.
267.Sh TARGET MODE
268Some adapters support
269.Em target mode
270in which the system is capable of operating as a device, responding to
271operations initiated by another system.
272Target mode is supported for
273some adapters, but is not yet complete for this version of the
274.Nm
275.Tn SCSI
276subsystem.
277.Sh FILES
278see other
279.Nm
280device entries.
281.Sh DIAGNOSTICS
282An XPT_DEBUG CCB can be used to enable various amounts of tracing information
283on any specific bus/device from the list of options compiled into the kernel.
284There are currently seven debugging flags that may be compiled in and used:
285.Bl -tag -width CAM_DEBUG_SUBTRACE
286.It Dv CAM_DEBUG_INFO
287This flag enables general informational printfs for the device
288or devices in question.
289.It Dv CAM_DEBUG_TRACE
290This flag enables function-level command flow tracing i.e.,
291kernel printfs will happen at the entrance and exit of various functions.
292.It Dv CAM_DEBUG_SUBTRACE
293This flag enables debugging output internal to various functions.
294.It Dv CAM_DEBUG_CDB
295This flag will cause the kernel to print out all
296.Tn ATA
297and
298.Tn SCSI
299commands sent to a particular device or devices.
300.It Dv CAM_DEBUG_XPT
301This flag will enable command scheduler tracing.
302.It Dv CAM_DEBUG_PERIPH
303This flag will enable peripheral drivers messages.
304.It Dv CAM_DEBUG_PROBE
305This flag will enable devices probe process tracing.
306.El
307.Pp
308Some of these flags, most notably
309.Dv CAM_DEBUG_TRACE
310and
311.Dv CAM_DEBUG_SUBTRACE ,
312will produce kernel printfs in EXTREME numbers.
313.Pp
314Users can enable debugging from their kernel config file, by using
315the following kernel config options:
316.Bl -tag -width CAM_DEBUG_COMPILE
317.It Dv CAMDEBUG
318This builds into the kernel all possible
319.Nm
320debugging.
321.It Dv CAM_DEBUG_COMPILE
322This allows to specify support for which debugging flags described above
323should be built into the kernel.
324Flags may be ORed together if the user wishes to
325see printfs for multiple debugging levels.
326.It Dv CAM_DEBUG_FLAGS
327This allows to set the various debugging flags from a kernel config file.
328.It Dv CAM_DEBUG_BUS
329Specify a bus to debug.
330To debug all buses, set this to -1.
331.It Dv CAM_DEBUG_TARGET
332Specify a target to debug.
333To debug all targets, set this to -1.
334.It Dv CAM_DEBUG_LUN
335Specify a lun to debug.
336To debug all luns, set this to -1.
337.El
338.Pp
339Users may also enable debugging on the fly by using the
340.Xr camcontrol 8
341utility, if wanted options built into the kernel.
342See
343.Xr camcontrol 8
344for details.
345.Sh SEE ALSO
346.Xr ada 4 ,
347.Xr aha 4 ,
348.Xr ahc 4 ,
349.Xr ahci 4 ,
350.Xr ahd 4 ,
351.Xr ata 4 ,
352.Xr bt 4 ,
353.Xr cd 4 ,
354.Xr ch 4 ,
355.Xr da 4 ,
356.Xr nda 4 ,
357.Xr nvme 4 ,
358.Xr pass 4 ,
359.Xr pt 4 ,
360.Xr sa 4 ,
361.Xr xpt 4 ,
362.Xr camcontrol 8
363.Sh HISTORY
364The
365.Nm
366.Tn SCSI
367subsystem first appeared in
368.Fx 3.0 .
369The
370.Nm
371ATA support was added in
372.Fx 8.0 .
373.Sh AUTHORS
374.An -nosplit
375The
376.Nm
377.Tn SCSI
378subsystem was written by
379.An Justin Gibbs
380and
381.An Kenneth Merry .
382The
383.Nm
384.Tn ATA
385support was added by
386.An Alexander Motin Aq Mt mav@FreeBSD.org .
387The
388.Nm
389.Tn NVMe
390support was added by
391.An Warner Losh Aq Mt imp@FreeBSD.org .
392