Merge branch 'vendor/XZ'
[dragonfly.git] / sbin / camcontrol / camcontrol.8
1 .\"
2 .\" Copyright (c) 1998, 1999, 2000, 2002, 2005, 2006, 2007 Kenneth D. Merry.
3 .\" All rights reserved.
4 .\"
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
7 .\" are met:
8 .\" 1. Redistributions of source code must retain the above copyright
9 .\"    notice, this list of conditions and the following disclaimer.
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 .\" 3. The name of the author may not be used to endorse or promote products
14 .\"    derived from this software without specific prior written permission.
15 .\"
16 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 .\" SUCH DAMAGE.
27 .\"
28 .\" $FreeBSD: src/sbin/camcontrol/camcontrol.8,v 1.19.2.12 2003/01/08 17:55:02 njl Exp $
29 .\"
30 .Dd September 14, 1998
31 .Dt CAMCONTROL 8
32 .Os
33 .Sh NAME
34 .Nm camcontrol
35 .Nd CAM control program
36 .Sh SYNOPSIS
37 .Nm
38 .Aq Ar command
39 .Op device id
40 .Op generic args
41 .Op command args
42 .Nm
43 .Ic devlist
44 .Op Fl v
45 .Nm
46 .Ic periphlist
47 .Op device id
48 .Op Fl n Ar dev_name
49 .Op Fl u Ar unit_number
50 .Nm
51 .Ic tur
52 .Op device id
53 .Op generic args
54 .Nm
55 .Ic inquiry
56 .Op device id
57 .Op generic args
58 .Op Fl D
59 .Op Fl S
60 .Op Fl R
61 .Nm
62 .Ic reportluns
63 .Op device id
64 .Op generic args
65 .Op Fl c
66 .Op Fl l
67 .Op Fl r Ar reporttype
68 .Nm
69 .Ic readcap
70 .Op device id
71 .Op generic args
72 .Op Fl b
73 .Op Fl h
74 .Op Fl H
75 .Op Fl N
76 .Op Fl q
77 .Op Fl s
78 .Nm
79 .Ic start
80 .Op device id
81 .Op generic args
82 .Nm
83 .Ic stop
84 .Op device id
85 .Op generic args
86 .Nm
87 .Ic load
88 .Op device id
89 .Op generic args
90 .Nm
91 .Ic eject
92 .Op device id
93 .Op generic args
94 .Nm
95 .Ic rescan
96 .Aq all | bus Ns Op :target:lun
97 .Nm
98 .Ic reset
99 .Aq all | bus Ns Op :target:lun
100 .Nm
101 .Ic defects
102 .Op device id
103 .Op generic args
104 .Aq Fl f Ar format
105 .Op Fl P
106 .Op Fl G
107 .Nm
108 .Ic modepage
109 .Op device id
110 .Op generic args
111 .Aq Fl m Ar page
112 .Op Fl P Ar pgctl
113 .Op Fl e
114 .Op Fl d
115 .Nm
116 .Ic cmd
117 .Op device id
118 .Op generic args
119 .Aq Fl c Ar cmd Op args
120 .Op Fl i Ar len Ar fmt
121 .Bk -words
122 .Op Fl o Ar len Ar fmt Op args
123 .Ek
124 .Nm
125 .Ic debug
126 .Op Fl I
127 .Op Fl P
128 .Op Fl T
129 .Op Fl S
130 .Op Fl X
131 .Op Fl c
132 .Aq all|off|bus Ns Op :target Ns Op :lun
133 .Nm
134 .Ic tags
135 .Op device id
136 .Op generic args
137 .Op Fl N Ar tags
138 .Op Fl q
139 .Op Fl v
140 .Nm
141 .Ic negotiate
142 .Op device id
143 .Op generic args
144 .Op Fl c
145 .Op Fl D Ar enable|disable
146 .Op Fl O Ar offset
147 .Op Fl q
148 .Op Fl R Ar syncrate
149 .Op Fl T Ar enable|disable
150 .Op Fl U
151 .Op Fl W Ar bus_width
152 .Op Fl v
153 .Nm
154 .Ic format
155 .Op device id
156 .Op generic args
157 .Op Fl q
158 .Op Fl r
159 .Op Fl w
160 .Op Fl y
161 .Nm
162 .Ic help
163 .Sh DESCRIPTION
164 The
165 .Nm
166 utility is designed to provide a way for users to access and control the
167 .Dx
168 CAM subsystem.
169 .Pp
170 The
171 .Nm
172 utility
173 can cause a loss of data and/or system crashes if used improperly.  Even
174 expert users are encouraged to exercise caution when using this command.
175 Novice users should stay away from this utility.
176 .Pp
177 The
178 .Nm
179 utility has a number of primary functions, many of which support an optional
180 device identifier.  A device identifier can take one of three forms:
181 .Bl -tag -width 14n
182 .It deviceUNIT
183 Specify a device name and unit number combination, like "da5" or "cd3".
184 Note that character device node names (e.g. /dev/da0) are
185 .Em not
186 allowed here.
187 .It bus:target
188 Specify a bus number and target id.  The bus number can be determined from
189 the output of
190 .Dq camcontrol devlist .
191 The lun defaults to 0.
192 .It bus:target:lun
193 Specify the bus, target and lun for a device.  (e.g. 1:2:0)
194 .El
195 .Pp
196 The device identifier, if it is specified,
197 .Em must
198 come immediately after the function name, and before any generic or
199 function-specific arguments.  Note that the
200 .Fl n
201 and
202 .Fl u
203 arguments described below will override any device name or unit number
204 specified beforehand.  The
205 .Fl n
206 and
207 .Fl u
208 arguments will
209 .Em not
210 override a specified bus:target or bus:target:lun, however.
211 .Pp
212 Most of the
213 .Nm
214 primary functions support these generic arguments:
215 .Bl -tag -width 14n
216 .It Fl C Ar count
217 SCSI command retry count.  In order for this to work, error recovery
218 .Pq Fl E
219 must be turned on.
220 .It Fl E
221 Instruct the kernel to perform generic SCSI error recovery for the given
222 command.  This is needed in order for the retry count
223 .Pq Fl C
224 to be honored.  Other than retrying commands, the generic error recovery in
225 the code will generally attempt to spin up drives that are not spinning.
226 It may take some other actions, depending upon the sense code returned from
227 the command.
228 .It Fl n Ar dev_name
229 Specify the device type to operate on, e.g. "da", "cd".
230 .It Fl t Ar timeout
231 SCSI command timeout in seconds.  This overrides the default timeout for
232 any given command.
233 .It Fl u Ar unit_number
234 Specify the device unit number, e.g. "1", "5".
235 .It Fl v
236 Be verbose, print out sense information for failed SCSI commands.
237 .El
238 .Pp
239 Primary command functions:
240 .Bl -tag -width periphlist
241 .It Ic devlist
242 List all physical devices (logical units) attached to the CAM subsystem.
243 This also includes a list of peripheral drivers attached to each device.
244 With the
245 .Fl v
246 argument, SCSI bus number, adapter name and unit numbers are printed as
247 well.
248 .It Ic periphlist
249 List all peripheral drivers attached to a given physical device (logical
250 unit).
251 .It Ic tur
252 Send the SCSI test unit ready (0x00) command to the given device.
253 The
254 .Nm
255 utility will report whether the device is ready or not.
256 .It Ic inquiry
257 Send a SCSI inquiry command (0x12) to a device.  By default,
258 .Nm
259 will print out the standard inquiry data, device serial number, and
260 transfer rate information.  The user can specify that only certain types of
261 inquiry data be printed:
262 .Bl -tag -width 4n
263 .It Fl D
264 Get the standard inquiry data.
265 .It Fl S
266 Print out the serial number.  If this flag is the only one specified,
267 .Nm
268 will not print out "Serial Number" before the value returned by the drive.
269 This is to aid in script writing.
270 .It Fl R
271 Print out transfer rate information.
272 .El
273 .It Ic reportluns
274 Send the SCSI REPORT LUNS (0xA0) command to the given device.
275 By default,
276 .Nm
277 will print out the list of logical units (LUNs) supported by the target device.
278 There are a couple of options to modify the output:
279 .Bl -tag -width 01234567890123
280 .It Fl c
281 Just print out a count of LUNs, not the actual LUN numbers.
282 .It Fl l
283 Just print out the LUNs, and don't print out the count.
284 .It Fl r Ar reporttype
285 Specify the type of report to request from the target:
286 .Bl -tag -width 012345678
287 .It default
288 Return the default report.
289 This is the
290 .Nm
291 default.
292 Most targets will support this report if they support the REPORT LUNS
293 command.
294 .It wellknown
295 Return only well known LUNs.
296 .It all
297 Return all available LUNs.
298 .El
299 .El
300 .Pp
301 .Nm
302 will try to print out LUN numbers in a reasonable format.
303 It can understand the peripheral, flat, LUN and extended LUN formats.
304 .It Ic readcap
305 Send the SCSI READ CAPACITY command to the given device and display
306 the results.
307 If the device is larger than 2TB, the SCSI READ CAPACITY (16) service
308 action will be sent to obtain the full size of the device.
309 By default,
310 .Nm
311 will print out the last logical block of the device, and the blocksize of
312 the device in bytes.
313 To modify the output format, use the following options:
314 .Bl -tag -width 5n
315 .It Fl b
316 Just print out the blocksize, not the last block or device size.
317 This cannot be used with
318 .Fl N
319 or
320 .Fl s .
321 .It Fl h
322 Print out the device size in human readable (base 2, 1K == 1024) format.
323 This implies
324 .Fl N
325 and cannot be used with
326 .Fl q
327 or
328 .Fl b .
329 .It Fl H
330 Print out the device size in human readable (base 10, 1K == 1000) format.
331 .It Fl N
332 Print out the number of blocks in the device instead of the last logical
333 block.
334 .It Fl q
335 Quiet, print out the numbers only (separated by a comma if
336 .Fl b
337 or
338 .Fl s
339 are not specified).
340 .It Fl s
341 Print out the last logical block or the size of the device only, and omit
342 the blocksize.
343 .El
344 .It Ic start
345 Send the SCSI Start/Stop Unit (0x1B) command to the given device with the
346 start bit set.
347 .It Ic stop
348 Send the SCSI Start/Stop Unit (0x1B) command to the given device with the
349 start bit cleared.
350 .It Ic load
351 Send the SCSI Start/Stop Unit (0x1B) command to the given device with the
352 start bit set and the load/eject bit set.
353 .It Ic eject
354 Send the SCSI Start/Stop Unit (0x1B) command to the given device with the
355 start bit cleared and the load/eject bit set.
356 .It Ic rescan
357 Tell the kernel to scan all busses in the system (with the
358 .Ar all
359 argument), the given bus (XPT_SCAN_BUS), or bus:target:lun
360 (XPT_SCAN_LUN) for new devices or devices that have gone away.  The user
361 may specify a scan of all busses, a single bus, or a lun.  Scanning all luns
362 on a target isn't supported.
363 .It Ic reset
364 Tell the kernel to reset all busses in the system (with the
365 .Ar all
366 argument) or the given bus (XPT_RESET_BUS) by issuing a SCSI bus
367 reset for that bus, or to reset the given bus:target:lun
368 (XPT_RESET_DEV), typically by issuing a BUS DEVICE RESET message after
369 connecting to that device.
370 Note that this can have a destructive impact
371 on the system.
372 .It Ic defects
373 Send the SCSI READ DEFECT DATA (10) command (0x37) to the given device, and
374 print out any combination of: the total number of defects, the primary
375 defect list (PLIST), and the grown defect list (GLIST).
376 .Bl -tag -width 11n
377 .It Fl f Ar format
378 The three format options are:
379 .Em block ,
380 to print out the list as logical blocks,
381 .Em bfi ,
382 to print out the list in bytes from index format, and
383 .Em phys ,
384 to print out the list in physical sector format.  The format argument is
385 required.  Most drives support the physical sector format.  Some drives
386 support the logical block format.  Many drives, if they don't support the
387 requested format, return the data in an alternate format, along with sense
388 information indicating that the requested data format isn't supported.
389 The
390 .Nm
391 utility
392 attempts to detect this, and print out whatever format the drive returns.
393 If the drive uses a non-standard sense code to report that it doesn't
394 support the requested format,
395 .Nm
396 will probably see the error as a failure to complete the request.
397 .It Fl G
398 Print out the grown defect list.  This is a list of bad blocks that have
399 been remapped since the disk left the factory.
400 .It Fl P
401 Print out the primary defect list.
402 .El
403 .Pp
404 If neither
405 .Fl P
406 nor
407 .Fl G
408 is specified,
409 .Nm
410 will print out the number of defects given in the READ DEFECT DATA header
411 returned from the drive.
412 .It Ic modepage
413 Allows the user to display and optionally edit a SCSI mode page.  The mode
414 page formats are located in
415 .Pa /usr/share/misc/scsi_modes .
416 This can be overridden by specifying a different file in the
417 .Ev SCSI_MODES
418 environment variable.
419 The
420 .Ic modepage
421 command takes several arguments:
422 .Bl -tag -width 12n
423 .It Fl d
424 Disable block descriptors for mode sense.
425 .It Fl e
426 This flag allows the user to edit values in the mode page.
427 .It Fl m Ar mode_page
428 This specifies the number of the mode page the user would like to view
429 and/or edit.  This argument is mandatory.
430 .It Fl P Ar pgctl
431 This allows the user to specify the page control field.  Possible values are:
432 .Bl -tag -width xxx -compact
433 .It 0
434 Current values
435 .It 1
436 Changeable values
437 .It 2
438 Default values
439 .It 3
440 Saved values
441 .El
442 .El
443 .It Ic cmd
444 Allows the user to send an arbitrary SCSI CDB to any device.
445 The
446 .Ic cmd
447 function requires the
448 .Fl c
449 argument to specify the CDB.  Other arguments are optional, depending on
450 the command type.  The command and data specification syntax is documented
451 in
452 .Xr cam_cdbparse 3 .
453 NOTE:  If the CDB specified causes data to be transferred to or from the
454 SCSI device in question, you MUST specify either
455 .Fl i
456 or
457 .Fl o .
458 .Bl -tag -width 17n
459 .It Fl c Ar cmd Op args
460 This specifies the SCSI CDB.  CDBs may be 6, 10, 12 or 16 bytes.
461 .It Fl i Ar len Ar fmt
462 This specifies the amount of data to read, and how it should be displayed.
463 If the format is
464 .Sq - ,
465 .Ar len
466 bytes of data will be read from the device and written to standard output.
467 .It Fl o Ar len Ar fmt Op args
468 This specifies the amount of data to be written to a device, and the data
469 that is to be written.  If the format is
470 .Sq - ,
471 .Ar len
472 bytes of data will be read from standard input and written to the device.
473 .El
474 .It Ic debug
475 Turn on CAM debugging printfs in the kernel.  This requires
476 .Cd options CAMDEBUG
477 in your kernel config file.  WARNING:  enabling debugging printfs currently
478 causes an EXTREME number of kernel printfs.  You may have difficulty
479 turning off the debugging printfs once they start, since the kernel will be
480 busy printing messages and unable to service other requests quickly.
481 The
482 .Ic debug
483 function takes a number of arguments:
484 .Bl -tag -width 18n
485 .It Fl I
486 Enable CAM_DEBUG_INFO printfs.
487 .It Fl P
488 Enable CAM_DEBUG_PERIPH printfs.
489 .It Fl T
490 Enable CAM_DEBUG_TRACE printfs.
491 .It Fl S
492 Enable CAM_DEBUG_SUBTRACE printfs.
493 .It Fl X
494 Enable CAM_DEBUG_XPT printfs.
495 .It Fl c
496 Enable CAM_DEBUG_CDB printfs.  This will cause the kernel to print out the
497 SCSI CDBs sent to the specified device(s).
498 .It all
499 Enable debugging for all devices.
500 .It off
501 Turn off debugging for all devices
502 .It bus Ns Op :target Ns Op :lun
503 Turn on debugging for the given bus, target or lun.  If the lun or target
504 and lun are not specified, they are wildcarded.  (i.e., just specifying a
505 bus turns on debugging printfs for all devices on that bus.)
506 .El
507 .It Ic tags
508 Show or set the number of "tagged openings" or simultaneous transactions
509 we attempt to queue to a particular device.  By default, the
510 .Ic tags
511 command, with no command-specific arguments (i.e. only generic arguments)
512 prints out the "soft" maximum number of transactions that can be queued to
513 the device in question.  For more detailed information, use the
514 .Fl v
515 argument described below.
516 .Bl -tag -width 7n
517 .It Fl N Ar tags
518 Set the number of tags for the given device.  This must be between the
519 minimum and maximum number set in the kernel quirk table.  The default for
520 most devices that support tagged queueing is a minimum of 2 and a maximum
521 of 255.  The minimum and maximum values for a given device may be
522 determined by using the
523 .Fl v
524 switch.  The meaning of the
525 .Fl v
526 switch for this
527 .Nm
528 subcommand is described below.
529 .It Fl q
530 Be quiet, and don't report the number of tags.  This is generally used when
531 setting the number of tags.
532 .It Fl v
533 The verbose flag has special functionality for the
534 .Em tags
535 argument.  It causes
536 .Nm
537 to print out the tagged queueing related fields of the XPT_GDEV_TYPE CCB:
538 .Bl -tag -width 13n
539 .It dev_openings
540 This is the amount of capacity for transactions queued to a given device.
541 .It dev_active
542 This is the number of transactions currently queued to a device.
543 .It devq_openings
544 This is the kernel queue space for transactions.  This count usually mirrors
545 dev_openings except during error recovery operations when
546 the device queue is frozen (device is not allowed to receive
547 commands), the number of dev_openings is reduced, or transaction
548 replay is occurring.
549 .It devq_queued
550 This is the number of transactions waiting in the kernel queue for capacity
551 on the device.  This number is usually zero unless error recovery is in
552 progress.
553 .It held
554 The held count is the number of CCBs held by peripheral drivers that have
555 either just been completed or are about to be released to the transport
556 layer for service by a device.  Held CCBs reserve capacity on a given
557 device.
558 .It mintags
559 This is the current "hard" minimum number of transactions that can be
560 queued to a device at once.  The
561 .Ar dev_openings
562 value above cannot go below this number.  The default value for
563 .Ar mintags
564 is 2, although it may be set higher or lower for various devices.
565 .It maxtags
566 This is the "hard" maximum number of transactions that can be queued to a
567 device at one time.  The
568 .Ar dev_openings
569 value cannot go above this number.  The default value for
570 .Ar maxtags
571 is 255, although it may be set higher or lower for various devices.
572 .El
573 .El
574 .It Ic negotiate
575 Show or negotiate various communication parameters.  Some controllers may
576 not support setting or changing some of these values.  For instance, the
577 Adaptec 174x controllers do not support changing a device's sync rate or
578 offset.
579 The
580 .Nm
581 utility
582 will not attempt to set the parameter if the controller indicates that it
583 does not support setting the parameter.  To find out what the controller
584 supports, use the
585 .Fl v
586 flag.  The meaning of the
587 .Fl v
588 flag for the
589 .Ic negotiate
590 command is described below.  Also, some controller drivers don't support
591 setting negotiation parameters, even if the underlying controller supports
592 negotiation changes.  Some controllers, such as the Advansys wide
593 controllers, support enabling and disabling synchronous negotiation for
594 a device, but do not support setting the synchronous negotiation rate.
595 .Bl -tag -width 17n
596 .It Fl a
597 Attempt to make the negotiation settings take effect immediately by sending
598 a Test Unit Ready command to the device.
599 .It Fl c
600 Show or set current negotiation settings.  This is the default.
601 .It Fl D Ar enable|disable
602 Enable or disable disconnection.
603 .It Fl O Ar offset
604 Set the command delay offset.
605 .It Fl q
606 Be quiet, don't print anything.  This is generally useful when you want to
607 set a parameter, but don't want any status information.
608 .It Fl R Ar syncrate
609 Change the synchronization rate for a device.  The sync rate is a floating
610 point value specified in MHz.  So, for instance,
611 .Sq 20.000
612 is a legal value, as is
613 .Sq 20 .
614 .It Fl T Ar enable|disable
615 Enable or disable tagged queueing for a device.
616 .It Fl U
617 Show or set user negotiation settings.  The default is to show or set
618 current negotiation settings.
619 .It Fl v
620 The verbose switch has special meaning for the
621 .Ic negotiate
622 subcommand.  It causes
623 .Nm
624 to print out the contents of a Path Inquiry (XPT_PATH_INQ) CCB sent to the
625 controller driver.
626 .It Fl W Ar bus_width
627 Specify the bus width to negotiate with a device.  The bus width is
628 specified in bits.  The only useful values to specify are 8, 16, and 32
629 bits.  The controller must support the bus width in question in order for
630 the setting to take effect.
631 .El
632 .Pp
633 In general, sync rate and offset settings will not take effect for a
634 device until a command has been sent to the device.  The
635 .Fl a
636 switch above will automatically send a Test Unit Ready to the device so
637 negotiation parameters will take effect.
638 .It Ic format
639 Issue the
640 .Tn SCSI
641 FORMAT UNIT command to the named device.
642 .Pp
643 .Em WARNING! WARNING! WARNING!
644 .Pp
645 Low level formatting a disk will destroy ALL data on the disk.  Use
646 extreme caution when issuing this command.  Many users low-level format
647 disks that do not really need to be low-level formatted.  There are
648 relatively few scenarios that call for low-level formatting a disk.
649 One reason for
650 low-level formatting a disk is to initialize the disk after changing
651 its physical sector size.  Another reason for low-level formatting a disk
652 is to revive the disk if you are getting "medium format corrupted" errors
653 from the disk in response to read and write requests.
654 .Pp
655 Some disks take longer than others to format.  Users should specify a
656 timeout long enough to allow the format to complete.  The default format
657 timeout is 3 hours, which should be long enough for most disks.  Some hard
658 disks will complete a format operation in a very short period of time
659 (on the order of 5 minutes or less).  This is often because the drive
660 doesn't really support the FORMAT UNIT command -- it just accepts the
661 command, waits a few minutes and then returns it.
662 .Pp
663 The
664 .Sq format
665 subcommand takes several arguments that modify its default behavior.  The
666 .Fl q
667 and
668 .Fl y
669 arguments can be useful for scripts.
670 .Bl -tag -width 6n
671 .It Fl q
672 Be quiet, don't print any status messages.  This option will not disable
673 the questions, however.  To disable questions, use the
674 .Fl y
675 argument, below.
676 .It Fl r
677 Run in
678 .Dq report only
679 mode.
680 This will report status on a format that is already running on the drive.
681 .It Fl w
682 Issue a non-immediate format command.  By default,
683 .Nm
684 issues the FORMAT UNIT command with the immediate bit set.  This tells the
685 device to immediately return the format command, before the format has
686 actually completed.  Then,
687 .Nm
688 gathers
689 .Tn SCSI
690 sense information from the device every second to determine how far along
691 in the format process it is.  If the
692 .Fl w
693 argument is specified,
694 .Nm
695 will issue a non-immediate format command, and will be unable to print any
696 information to let the user know what percentage of the disk has been
697 formatted.
698 .It Fl y
699 Don't ask any questions.  By default,
700 .Nm
701 will ask the user if he/she really wants to format the disk in question,
702 and also if the default format command timeout is acceptable.  The user
703 will not be asked about the timeout if a timeout is specified on the
704 command line.
705 .El
706 .It Ic help
707 Print out verbose usage information.
708 .El
709 .Sh ENVIRONMENT
710 The
711 .Ev SCSI_MODES
712 variable allows the user to specify an alternate mode page format file.
713 .Pp
714 The
715 .Ev EDITOR
716 variable determines which text editor
717 .Nm
718 starts when editing mode pages.
719 .Sh FILES
720 .Bl -tag -width /usr/share/misc/scsi_modes -compact
721 .It Pa /usr/share/misc/scsi_modes
722 is the SCSI mode format database.
723 .It Pa /dev/xpt0
724 is the transport layer device.
725 .It Pa /dev/pass*
726 are the CAM application passthrough devices.
727 .El
728 .Sh EXAMPLES
729 .Dl camcontrol eject -n cd -u 1 -v
730 .Pp
731 Eject the CD from cd1, and print SCSI sense information if the command
732 fails.
733 .Pp
734 .Dl camcontrol tur da0
735 .Pp
736 Send the SCSI test unit ready command to da0.
737 The
738 .Nm
739 utility will report whether the disk is ready, but will not display sense
740 information if the command fails since the
741 .Fl v
742 switch was not specified.
743 .Bd -literal -offset indent
744 camcontrol tur da1 -E -C 4 -t 50 -v
745 .Ed
746 .Pp
747 Send a test unit ready command to da1.  Enable kernel error recovery.
748 Specify a retry count of 4, and a timeout of 50 seconds.  Enable sense
749 printing (with the
750 .Fl v
751 flag) if the command fails.  Since error recovery is turned on, the
752 disk will be spun up if it is not currently spinning.
753 The
754 .Nm
755 utility will report whether the disk is ready.
756 .Bd -literal -offset indent
757 camcontrol cmd -n cd -u 1 -v -c "3C 00 00 00 00 00 00 00 0e 00" \e
758         -i 0xe "s1 i3 i1 i1 i1 i1 i1 i1 i1 i1 i1 i1"
759 .Ed
760 .Pp
761 Issue a READ BUFFER command (0x3C) to cd1.  Display the buffer size of cd1,
762 and display the first 10 bytes from the cache on cd1.  Display SCSI sense
763 information if the command fails.
764 .Bd -literal -offset indent
765 camcontrol cmd -n cd -u 1 -v -c "3B 00 00 00 00 00 00 00 0e 00" \e
766         -o 14 "00 00 00 00 1 2 3 4 5 6 v v v v" 7 8 9 8
767 .Ed
768 .Pp
769 Issue a WRITE BUFFER (0x3B) command to cd1.  Write out 10 bytes of data,
770 not including the (reserved) 4 byte header.  Print out sense information if
771 the command fails.  Be very careful with this command, improper use may
772 cause data corruption.
773 .Bd -literal -offset indent
774 camcontrol modepage da3 -m 1 -e -P 3
775 .Ed
776 .Pp
777 Edit mode page 1 (the Read-Write Error Recover page) for da3, and save the
778 settings on the drive.  Mode page 1 contains a disk drive's auto read and
779 write reallocation settings, among other things.
780 .Pp
781 .Dl camcontrol rescan all
782 .Pp
783 Rescan all SCSI busses in the system for devices that have been added,
784 removed or changed.
785 .Pp
786 .Dl camcontrol rescan 0
787 .Pp
788 Rescan SCSI bus 0 for devices that have been added, removed or changed.
789 .Pp
790 .Dl camcontrol rescan 0:1:0
791 .Pp
792 Rescan SCSI bus 0, target 1, lun 0 to see if it has been added, removed, or
793 changed.
794 .Pp
795 .Dl camcontrol tags da5 -N 24
796 .Pp
797 Set the number of concurrent transactions for da5 to 24.
798 .Bd -literal -offset indent
799 camcontrol negotiate -n da -u 4 -T disable
800 .Ed
801 .Pp
802 Disable tagged queueing for da4.
803 .Bd -literal -offset indent
804 camcontrol negotiate -n da -u 3 -R 20.000 -O 15 -a
805 .Ed
806 .Pp
807 Negotiate a sync rate of 20MHz and an offset of 15 with da3.  Then send a
808 Test Unit Ready command to make the settings take effect.
809 .Sh SEE ALSO
810 .Xr cam 3 ,
811 .Xr cam_cdbparse 3 ,
812 .Xr cam 4 ,
813 .Xr pass 4 ,
814 .Xr xpt 4
815 .Sh HISTORY
816 The
817 .Nm
818 utility first appeared in
819 .Fx 3.0 .
820 .Pp
821 The mode page editing code and arbitrary SCSI command code are based upon
822 code in the old
823 .Xr scsi 8
824 utility and
825 .Xr scsi 3
826 library, written by Julian Elischer and Peter Dufault.  The
827 .Xr scsi 8
828 program first appeared in
829 .Bx 386 0.1.2.4 ,
830 and first appeared in
831 .Fx
832 in
833 .Fx 2.0.5 .
834 .Sh AUTHORS
835 .An Kenneth Merry Aq Mt ken@FreeBSD.org
836 .Sh BUGS
837 The code that parses the generic command line arguments doesn't know that
838 some of the subcommands take multiple arguments.  So if, for instance, you
839 tried something like this:
840 .Bd -literal -offset indent
841 camcontrol cmd -n da -u 1 -c "00 00 00 00 00 v" 0x00 -v
842 .Ed
843 .Pp
844 The sense information from the test unit ready command would not get
845 printed out, since the first
846 .Xr getopt 3
847 call in
848 .Nm
849 bails out when it sees the second argument to
850 .Fl c
851 (0x00),
852 above.  Fixing this behavior would take some gross code, or changes to the
853 .Xr getopt 3
854 interface.  The best way to circumvent this problem is to always make sure
855 to specify generic
856 .Nm
857 arguments before any command-specific arguments.