]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - share/man/man4/scsi.4
disk(9): Fix a few mandoc related errors
[FreeBSD/FreeBSD.git] / share / man / man4 / scsi.4
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 June 18, 2020
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
53 The
54 .Nm
55 subsystem provides a uniform and modular system for the implementation
56 of drivers to control various
57 .Tn SCSI ,
58 .Tn ATA ,
59 .Tn NMVe ,
60 and
61 .Tn MMC / SD
62 devices, and to utilize different
63 .Tn SCSI ,
64 .Tn ATA ,
65 .Tn NVMe ,
66 and
67 .Tn MMC / SD
68 host adapters through host adapter drivers.
69 When the system probes buses, it attaches any devices it finds to the
70 appropriate drivers.
71 The
72 .Xr pass 4
73 driver, if it is configured in the kernel, will attach to all devices.
74 .Sh KERNEL CONFIGURATION
75 There are a number of generic kernel configuration options for the
76 .Nm
77 subsystem:
78 .Bl -tag -width SCSI_NO_SENSE_STRINGS
79 .It Dv CAM_BOOT_DELAY
80 Additional time to wait after the static parts of the kernel have run to allow
81 for discovery of additional devices which may take time to connect,
82 such as USB attached storage.
83 .It Dv CAM_IOSCHED_DYNAMIC
84 Enable dynamic decisions in the I/O scheduler based on hints and the current
85 performance of the storage devices.
86 .It Dv CAM_IO_STATS
87 Enable collection of statistics for periph devices.
88 .It Dv CAM_TEST_FAILURE
89 Enable ability to simulate I/O failures.
90 .It Dv CAMDEBUG
91 This option compiles in all the
92 .Nm
93 debugging printf code.
94 This will not actually
95 cause any debugging information to be printed out when included by itself.
96 See below for details.
97 .It Dv "CAM_MAX_HIGHPOWER=4"
98 This sets the maximum allowable number of concurrent "high power" commands.
99 A "high power" command is a command that takes more electrical power than
100 most to complete.
101 An example of this is the
102 .Tn SCSI
103 START UNIT command.
104 Starting a disk often takes significantly more electrical power than normal
105 operation.
106 This option allows the
107 user to specify how many concurrent high power commands may be outstanding
108 without overloading the power supply on his computer.
109 .It Dv SCSI_NO_SENSE_STRINGS
110 This eliminates text descriptions of each
111 .Tn SCSI
112 Additional Sense Code and Additional Sense Code Qualifier pair.
113 Since this
114 is a fairly large text database, eliminating it reduces the size of the
115 kernel somewhat.
116 This is primarily necessary for boot floppies and other
117 low disk space or low memory space environments.
118 In most cases, though,
119 this should be enabled, since it speeds the interpretation of
120 .Tn SCSI
121 error messages.
122 Do not let the "kernel bloat" zealots get to you -- leave
123 the sense descriptions in your kernel!
124 .It Dv SCSI_NO_OP_STRINGS
125 This disables text descriptions of each
126 .Tn SCSI
127 opcode.
128 This option, like the sense string option above, is primarily
129 useful for environments like a boot floppy where kernel size is critical.
130 Enabling this option for normal use is not recommended, since it slows
131 debugging of
132 .Tn SCSI
133 problems.
134 .It Dv SCSI_DELAY=8000
135 This is the
136 .Tn SCSI
137 "bus settle delay."
138 In
139 .Nm ,
140 it is specified in
141 .Em milliseconds ,
142 not seconds like the old
143 .Tn SCSI
144 layer used to do.
145 When the kernel boots, it sends a bus reset to each
146 .Tn SCSI
147 bus to tell each device to reset itself to a default set of transfer
148 negotiations and other settings.
149 Most
150 .Tn SCSI
151 devices need some amount of time to recover from a bus reset.
152 Newer disks
153 may need as little as 100ms, while old, slow devices may need much longer.
154 If the
155 .Dv SCSI_DELAY
156 is not specified, it defaults to 2 seconds.
157 The minimum allowable value for
158 .Dv SCSI_DELAY
159 is "100", or 100ms.
160 One special case is that if the
161 .Dv SCSI_DELAY
162 is set to 0, that will be taken to mean the "lowest possible value."
163 In that case, the
164 .Dv SCSI_DELAY
165 will be reset to 100ms.
166 .El
167 .Pp
168 All devices and buses support dynamic allocation so that
169 an upper number of devices and controllers does not need to be configured;
170 .Cd "device da"
171 will suffice for any number of disk drivers.
172 .Pp
173 The devices are either
174 .Em wired
175 so they appear as a particular device unit or
176 .Em counted
177 so that they appear as the next available unused unit.
178 .Pp
179 Units are wired down by setting kernel environment hints.
180 This is usually done either interactively from the
181 .Xr loader 8 ,
182 or automatically via the
183 .Pa /boot/device.hints
184 file.
185 The basic syntax is:
186 .Bd -literal -offset indent
187 hint.device.unit.property="value"
188 .Ed
189 .Pp
190 Individual
191 .Nm
192 bus numbers can be wired down to specific controllers with
193 a config line similar to the following:
194 .Bd -literal -offset indent
195 hint.scbus.0.at="ahd1"
196 .Ed
197 .Pp
198 This assigns
199 .Nm
200 bus number 0 to the
201 .Em ahd1
202 driver instance.
203 For controllers supporting more than one bus, a particular bus can be assigned
204 as follows:
205 .Bd -literal -offset indent
206 hint.scbus.0.at="ahc1"
207 hint.scbus.0.bus="1"
208 .Ed
209 .Pp
210 This assigns
211 .Nm
212 bus 0 to the bus 1 instance on
213 .Em ahc1 .
214 Peripheral drivers can be wired to a specific bus, target, and lun as so:
215 .Bd -literal -offset indent
216 hint.da.0.at="scbus0"
217 hint.da.0.target="0"
218 hint.da.0.unit="0"
219 .Ed
220 .Pp
221 This assigns
222 .Em da0
223 to target 0, unit (lun) 0 of scbus 0.
224 Omitting the target or unit hints will instruct
225 .Nm
226 to treat them as wildcards
227 and use the first respective counted instances.
228 These examples can be combined together to allow a peripheral device to be
229 wired to any particular controller, bus, target, and/or unit instance.
230 .Pp
231 This also works with
232 .Xr nvme 4
233 drives as well.
234 .Bd -literal -offset indent
235 hint.nvme.4.at="pci7:0:0"
236 hint.scbus.10.at="nvme4"
237 hint.nda.10.at="scbus10"
238 hint.nda.10.target="1"
239 hint.nda.10.unit="12"
240 hint.nda.11.at="scbus10"
241 hint.nda.11.target="1"
242 hint.nda.11.unit="2"
243 .Ed
244 .Pp
245 This assigns the NVMe card living at PCI bus 7 to scbus 10 (in PCIe,
246 slot and function are rarely used and usually 0).
247 The target for
248 .Xr nda 4
249 devices is always 1.
250 The unit is the namespace identifier from the drive.
251 The namespace id 1 is exported as
252 .Tn nda10
253 and namespace id 2 is exported as
254 .Tn nda11 .
255 .Pp
256 When you have a mixture of wired down and counted devices then the
257 counting begins with the first non-wired down unit for a particular
258 type.
259 That is, if you have a disk wired down as
260 .Em "device da1" ,
261 then the first non-wired disk shall come on line as
262 .Em da2 .
263 .Sh ADAPTERS
264 The system allows common device drivers to work through many different
265 types of adapters.
266 The adapters take requests from the upper layers and do
267 all IO between the
268 .Tn SCSI ,
269 .Tn ATA ,
270 .Tn NVMe ,
271 or
272 .Tn MMC / SD
273 bus and the system.
274 The maximum size of a transfer is governed by the
275 adapter.
276 Most adapters can transfer 64KB in a single operation, however
277 many can transfer larger amounts.
278 .Sh TARGET MODE
279 Some adapters support
280 .Em target mode
281 in which the system is capable of operating as a device, responding to
282 operations initiated by another system.
283 Target mode is supported for
284 some adapters, but is not yet complete for this version of the
285 .Nm
286 .Tn SCSI
287 subsystem.
288 .Sh ARCHITECTURE
289 The
290 .Nm
291 subsystem glues together the upper layers of the system to the storage devices.
292 PERIPH devices accept storage requests from GEOM and other upper layers of the
293 system and translates them into protocol requests.
294 XPT (transport) dispatches these protocol requests to a SIM driver.
295 A SIM driver takes protocol requests and translates them into hardware commands
296 the host adapter understands to transfer the protocol requests, and data (if
297 any) to the storage device.
298 The CCB transports these requests around as messages.
299 .Ss CAM
300 The Common Access Method was a standard defined in the 1990s to talk to disk
301 drives.
302 .Fx
303 is one of the few operating systems to fully implement this model.
304 The interface between different parts of CAM is the CCB (or CAM Control Block).
305 Each CCB has a standard header, which contains the type of request and dispatch
306 information, and a command specific portion.
307 A CAM Periph generates requests.
308 The XPT layer dispatches these requests to the appropriate SIM.
309 Some CCBs are sent directly to the SIM for immediate processing, while others
310 are queued and complete when the I/O has finished.
311 A SIM takes CCBs and translates them into hardware specific commands to push the
312 SCSI CDB or other protocol control block to the peripheral, along with setting
313 up the DMA for the associated data.
314 .Ss Periph Devices
315 A periph driver knows how to translate standard requests into protocol messages
316 that a SIM can deliver to hardware.
317 These requests can come from any upper layer source, but primarily come in via
318 GEOM as a bio request.
319 They can also come in directly from character device requests for tapes and pass
320 through commands.
321 .Pp
322 Disk devices, or direct access (da) in CAM, are one type of peripheral.
323 These devices present themselves to the kernel a device ending in
324 .Dq da .
325 Each protocol has a unique device name:
326 .Bl -tag -width 4
327 .It Xr da 4
328 SCSI or SAS device, or devices that accept SCSI CDBs for I/O.
329 .It Xr ada 4
330 ATA or SATA device
331 .It Xr nda 4
332 NVME device
333 .It Xr sdda 4
334 An SD or MMC block storage device.
335 .El
336 .Pp
337 Tape devices are called serial access
338 .Po
339 .Xr sa 4
340 .Pc
341 in CAM.
342 They interface to the system via a character device and provide
343 .Xr ioctl 2
344 control for tape drives.
345 .Pp
346 The
347 .Xr pass 4
348 device will pass through CCB requests from userland to the SIM directly.
349 The device is used to send commands other than read, write, trim or flush to a
350 device.
351 The
352 .Xr camcontrol 8
353 command uses this device.
354 .Ss XPT drivers
355 The transport driver connects the periph to the SIM.
356 It is not configured separately.
357 It is also responsible for device discovery for those SIM drivers that do not
358 enumerate themselves.
359 .Ss SIM driver
360 SIM used to stand for SCSI Interface Module.
361 Now it is just SIM because it understands protocols other than SCSI.
362 There are two types of SIM drivers: virtual and physical.
363 Physical SIMs are typically called host bus adapters (HBA), but not universally.
364 Virtual SIM drivers are for communicating with virtual machine hosts.
365 .Sh FILES
366 see other
367 .Nm
368 device entries.
369 .Sh DIAGNOSTICS
370 An XPT_DEBUG CCB can be used to enable various amounts of tracing information
371 on any specific bus/device from the list of options compiled into the kernel.
372 There are currently seven debugging flags that may be compiled in and used:
373 .Bl -tag -width CAM_DEBUG_SUBTRACE
374 .It Dv CAM_DEBUG_INFO
375 This flag enables general informational printfs for the device
376 or devices in question.
377 .It Dv CAM_DEBUG_TRACE
378 This flag enables function-level command flow tracing i.e.,
379 kernel printfs will happen at the entrance and exit of various functions.
380 .It Dv CAM_DEBUG_SUBTRACE
381 This flag enables debugging output internal to various functions.
382 .It Dv CAM_DEBUG_CDB
383 This flag will cause the kernel to print out all
384 .Tn ATA
385 and
386 .Tn SCSI
387 commands sent to a particular device or devices.
388 .It Dv CAM_DEBUG_XPT
389 This flag will enable command scheduler tracing.
390 .It Dv CAM_DEBUG_PERIPH
391 This flag will enable peripheral drivers messages.
392 .It Dv CAM_DEBUG_PROBE
393 This flag will enable devices probe process tracing.
394 .El
395 .Pp
396 Some of these flags, most notably
397 .Dv CAM_DEBUG_TRACE
398 and
399 .Dv CAM_DEBUG_SUBTRACE ,
400 will produce kernel printfs in EXTREME numbers.
401 .Pp
402 Users can enable debugging from their kernel config file, by using
403 the following kernel config options:
404 .Bl -tag -width CAM_DEBUG_COMPILE
405 .It Dv CAMDEBUG
406 This builds into the kernel all possible
407 .Nm
408 debugging.
409 .It Dv CAM_DEBUG_COMPILE
410 This specifies support for which debugging flags described above
411 should be built into the kernel.
412 Flags may be ORed together if the user wishes to
413 see printfs for multiple debugging levels.
414 .It Dv CAM_DEBUG_FLAGS
415 This sets the various debugging flags from a kernel config file.
416 .It Dv CAM_DEBUG_BUS
417 Specify a bus to debug.
418 To debug all buses, set this to -1.
419 .It Dv CAM_DEBUG_TARGET
420 Specify a target to debug.
421 To debug all targets, set this to -1.
422 .It Dv CAM_DEBUG_LUN
423 Specify a lun to debug.
424 To debug all luns, set this to -1.
425 .El
426 .Pp
427 Users may also enable debugging on the fly by using the
428 .Xr camcontrol 8
429 utility, if wanted options built into the kernel.
430 See
431 .Xr camcontrol 8
432 for details.
433 .Sh SEE ALSO
434 .Bl -tag -width 20
435 .It Sy Commands:
436 .Xr camcontrol 8 ,
437 .Xr camdd 8
438 .It Sy Libraries:
439 .Xr cam 3
440 .It Sy Periph Drivers:
441 .Xr ada 4 ,
442 .Xr da 4 ,
443 .Xr nda 4 ,
444 .\" .Xr sdda 4 ,
445 .Xr pass 4 ,
446 .Xr sa 4
447 .Pp
448 .It Sy SIM Devices:
449 .Xr aac 4 ,
450 .Xr aacraid 4 ,
451 .Xr ahc 4 ,
452 .Xr ahci 4 ,
453 .Xr ata 4 ,
454 .Xr aw_mmc 4 ,
455 .Xr ciss 4 ,
456 .Xr hv_storvsc 4 ,
457 .Xr isci 4 ,
458 .Xr iscsi 4 ,
459 .Xr isp 4 ,
460 .\" .Xr mmcnull 4 ,
461 .Xr mpr 4 ,
462 .Xr mps 4 ,
463 .Xr mpt 4 ,
464 .Xr mrsas 4 ,
465 .Xr mvs 4 ,
466 .Xr nvme 4 ,
467 .Xr pms 4 ,
468 .Xr pvscsi 4 ,
469 .Xr sdhci 4 ,
470 .Xr smartpqi 4 ,
471 .Xr sym 4 ,
472 .Xr tws 4 ,
473 .Xr umass 4 ,
474 .Xr virtio_scsi 4
475 .It Sy Deprecated or Poorly Supported SIM Devices:
476 .Xr ahd 4 ,
477 .Xr amr 4 ,
478 .Xr arcmsr 4 ,
479 .Xr esp 4 ,
480 .\" .Xr fslsata 4 ,
481 .Xr hpt27xx 4 ,
482 .Xr hptiop 4 ,
483 .Xr hptmv 4 ,
484 .Xr hptnr 4 ,
485 .\" .Xr htprr 4 ,
486 .Xr iir 4
487 .Xr mfi 4 ,
488 .\" .Xr osc 4 ,
489 .\" .Xr ps3cdrom 4 ,
490 .Xr sbp 4 ,
491 .Xr twa 4
492 .El
493 .Sh HISTORY
494 The
495 .Nm
496 .Tn SCSI
497 subsystem first appeared in
498 .Fx 3.0 .
499 The
500 .Nm
501 ATA support was added in
502 .Fx 8.0 .
503 .Sh AUTHORS
504 .An -nosplit
505 The
506 .Nm
507 .Tn SCSI
508 subsystem was written by
509 .An Justin Gibbs
510 and
511 .An Kenneth Merry .
512 The
513 .Nm
514 .Tn ATA
515 support was added by
516 .An Alexander Motin Aq Mt mav@FreeBSD.org .
517 The
518 .Nm
519 .Tn NVMe
520 support was added by
521 .An Warner Losh Aq Mt imp@FreeBSD.org .