]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/blob - sbin/camcontrol/camcontrol.8
MFC r368207,368607:
[FreeBSD/stable/10.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$
29 .\"
30 .Dd February 17, 2017
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 b
45 .Op Fl v
46 .Nm
47 .Ic periphlist
48 .Op device id
49 .Op Fl n Ar dev_name
50 .Op Fl u Ar unit_number
51 .Nm
52 .Ic tur
53 .Op device id
54 .Op generic args
55 .Nm
56 .Ic inquiry
57 .Op device id
58 .Op generic args
59 .Op Fl D
60 .Op Fl S
61 .Op Fl R
62 .Nm
63 .Ic identify
64 .Op device id
65 .Op generic args
66 .Op Fl v
67 .Nm
68 .Ic reportluns
69 .Op device id
70 .Op generic args
71 .Op Fl c
72 .Op Fl l
73 .Op Fl r Ar reporttype
74 .Nm
75 .Ic readcap
76 .Op device id
77 .Op generic args
78 .Op Fl b
79 .Op Fl h
80 .Op Fl H
81 .Op Fl N
82 .Op Fl q
83 .Op Fl s
84 .Nm
85 .Ic start
86 .Op device id
87 .Op generic args
88 .Nm
89 .Ic stop
90 .Op device id
91 .Op generic args
92 .Nm
93 .Ic load
94 .Op device id
95 .Op generic args
96 .Nm
97 .Ic eject
98 .Op device id
99 .Op generic args
100 .Nm
101 .Ic reprobe
102 .Op device id
103 .Nm
104 .Ic rescan
105 .Aq all | device id | bus Ns Op :target:lun
106 .Nm
107 .Ic reset
108 .Aq all | device id | bus Ns Op :target:lun
109 .Nm
110 .Ic defects
111 .Op device id
112 .Op generic args
113 .Aq Fl f Ar format
114 .Op Fl P
115 .Op Fl G
116 .Op Fl q
117 .Op Fl s
118 .Op Fl S Ar offset
119 .Op Fl X
120 .Nm
121 .Ic modepage
122 .Op device id
123 .Op generic args
124 .Aq Fl m Ar page[,subpage] | Fl l
125 .Op Fl P Ar pgctl
126 .Op Fl b | Fl e
127 .Op Fl d
128 .Nm
129 .Ic cmd
130 .Op device id
131 .Op generic args
132 .Aq Fl a Ar cmd Op args
133 .Aq Fl c Ar cmd Op args
134 .Op Fl d
135 .Op Fl f
136 .Op Fl i Ar len Ar fmt
137 .Bk -words
138 .Op Fl o Ar len Ar fmt Op args
139 .Op Fl r Ar fmt
140 .Ek
141 .Nm
142 .Ic smpcmd
143 .Op device id
144 .Op generic args
145 .Aq Fl r Ar len Ar fmt Op args
146 .Aq Fl R Ar len Ar fmt Op args
147 .Nm
148 .Ic smprg
149 .Op device id
150 .Op generic args
151 .Op Fl l
152 .Nm
153 .Ic smppc
154 .Op device id
155 .Op generic args
156 .Aq Fl p Ar phy
157 .Op Fl l
158 .Op Fl o Ar operation
159 .Op Fl d Ar name
160 .Op Fl m Ar rate
161 .Op Fl M Ar rate
162 .Op Fl T Ar pp_timeout
163 .Op Fl a Ar enable|disable
164 .Op Fl A Ar enable|disable
165 .Op Fl s Ar enable|disable
166 .Op Fl S Ar enable|disable
167 .Nm
168 .Ic smpphylist
169 .Op device id
170 .Op generic args
171 .Op Fl l
172 .Op Fl q
173 .Nm
174 .Ic smpmaninfo
175 .Op device id
176 .Op generic args
177 .Op Fl l
178 .Nm
179 .Ic debug
180 .Op Fl I
181 .Op Fl P
182 .Op Fl T
183 .Op Fl S
184 .Op Fl X
185 .Op Fl c
186 .Op Fl p
187 .Aq all|off|bus Ns Op :target Ns Op :lun
188 .Nm
189 .Ic tags
190 .Op device id
191 .Op generic args
192 .Op Fl N Ar tags
193 .Op Fl q
194 .Op Fl v
195 .Nm
196 .Ic negotiate
197 .Op device id
198 .Op generic args
199 .Op Fl c
200 .Op Fl D Ar enable|disable
201 .Op Fl M Ar mode
202 .Op Fl O Ar offset
203 .Op Fl q
204 .Op Fl R Ar syncrate
205 .Op Fl T Ar enable|disable
206 .Op Fl U
207 .Op Fl W Ar bus_width
208 .Op Fl v
209 .Nm
210 .Ic format
211 .Op device id
212 .Op generic args
213 .Op Fl q
214 .Op Fl r
215 .Op Fl w
216 .Op Fl y
217 .Nm
218 .Ic sanitize
219 .Op device id
220 .Op generic args
221 .Aq Fl a Ar overwrite | block | crypto | exitfailure
222 .Op Fl c Ar passes
223 .Op Fl I
224 .Op Fl P Ar pattern
225 .Op Fl q
226 .Op Fl U
227 .Op Fl r
228 .Op Fl w
229 .Op Fl y
230 .Nm
231 .Ic idle
232 .Op device id
233 .Op generic args
234 .Op Fl t Ar time
235 .Nm
236 .Ic standby
237 .Op device id
238 .Op generic args
239 .Op Fl t Ar time
240 .Nm
241 .Ic sleep
242 .Op device id
243 .Op generic args
244 .Nm
245 .Ic apm
246 .Op device id
247 .Op generic args
248 .Op Fl l Ar level
249 .Nm
250 .Ic aam
251 .Op device id
252 .Op generic args
253 .Op Fl l Ar level
254 .Nm
255 .Ic fwdownload
256 .Op device id
257 .Op generic args
258 .Aq Fl f Ar fw_image
259 .Op Fl q
260 .Op Fl s
261 .Op Fl y
262 .Nm
263 .Ic security
264 .Op device id
265 .Op generic args
266 .Op Fl d Ar pwd
267 .Op Fl e Ar pwd
268 .Op Fl f
269 .Op Fl h Ar pwd
270 .Op Fl k Ar pwd
271 .Op Fl l Ar high|maximum
272 .Op Fl q
273 .Op Fl s Ar pwd
274 .Op Fl T Ar timeout
275 .Op Fl U Ar user|master
276 .Op Fl y
277 .Nm
278 .Ic hpa
279 .Op device id
280 .Op generic args
281 .Op Fl f
282 .Op Fl l
283 .Op Fl P
284 .Op Fl p Ar pwd
285 .Op Fl q
286 .Op Fl s Ar max_sectors
287 .Op Fl U Ar pwd
288 .Op Fl y
289 .Nm
290 .Ic persist
291 .Op device id
292 .Op generic args
293 .Aq Fl i Ar action | Fl o Ar action
294 .Op Fl a
295 .Op Fl I Ar trans_id
296 .Op Fl k Ar key
297 .Op Fl K Ar sa_key
298 .Op Fl p
299 .Op Fl R Ar rel_tgt_port
300 .Op Fl s Ar scope
301 .Op Fl S
302 .Op Fl T Ar res_type
303 .Op Fl U
304 .Nm
305 .Ic attrib
306 .Op device id
307 .Op generic args
308 .Aq Fl r Ar action | Fl w Ar attrib
309 .Op Fl a Ar attr_num
310 .Op Fl c
311 .Op Fl e Ar elem_addr
312 .Op Fl F Ar form1,form2
313 .Op Fl p Ar part
314 .Op Fl s Ar start_addr
315 .Op Fl T Ar elem_type
316 .Op Fl V Ar lv_num
317 .Nm
318 .Ic opcodes
319 .Op device id
320 .Op generic args
321 .Op Fl o Ar opcode
322 .Op Fl s Ar service_action
323 .Op Fl N
324 .Op Fl T
325 .Nm
326 .Ic help
327 .Sh DESCRIPTION
328 The
329 .Nm
330 utility is designed to provide a way for users to access and control the
331 .Fx
332 CAM subsystem.
333 .Pp
334 The
335 .Nm
336 utility
337 can cause a loss of data and/or system crashes if used improperly.
338 Even
339 expert users are encouraged to exercise caution when using this command.
340 Novice users should stay away from this utility.
341 .Pp
342 The
343 .Nm
344 utility has a number of primary functions, many of which support an optional
345 device identifier.
346 A device identifier can take one of three forms:
347 .Bl -tag -width 14n
348 .It deviceUNIT
349 Specify a device name and unit number combination, like "da5" or "cd3".
350 .It bus:target
351 Specify a bus number and target id.
352 The bus number can be determined from
353 the output of
354 .Dq camcontrol devlist .
355 The lun defaults to 0.
356 .It bus:target:lun
357 Specify the bus, target and lun for a device.
358 (e.g.\& 1:2:0)
359 .El
360 .Pp
361 The device identifier, if it is specified,
362 .Em must
363 come immediately after the function name, and before any generic or
364 function-specific arguments.
365 Note that the
366 .Fl n
367 and
368 .Fl u
369 arguments described below will override any device name or unit number
370 specified beforehand.
371 The
372 .Fl n
373 and
374 .Fl u
375 arguments will
376 .Em not
377 override a specified bus:target or bus:target:lun, however.
378 .Pp
379 Most of the
380 .Nm
381 primary functions support these generic arguments:
382 .Bl -tag -width 14n
383 .It Fl C Ar count
384 SCSI command retry count.
385 In order for this to work, error recovery
386 .Pq Fl E
387 must be turned on.
388 .It Fl E
389 Instruct the kernel to perform generic SCSI error recovery for the given
390 command.
391 This is needed in order for the retry count
392 .Pq Fl C
393 to be honored.
394 Other than retrying commands, the generic error recovery in
395 the code will generally attempt to spin up drives that are not spinning.
396 It may take some other actions, depending upon the sense code returned from
397 the command.
398 .It Fl n Ar dev_name
399 Specify the device type to operate on, e.g.\& "da", "cd".
400 .It Fl Q Ar task_attr
401 .Tn SCSI
402 task attribute for the command, if it is a
403 .Tn SCSI
404 command.
405 This may be ordered, simple, head, or aca.
406 In most cases this is not needed.
407 The default is simple, which works with all
408 .Tn SCSI
409 devices.
410 The task attribute may also be specified numerically.
411 .It Fl t Ar timeout
412 SCSI command timeout in seconds.
413 This overrides the default timeout for
414 any given command.
415 .It Fl u Ar unit_number
416 Specify the device unit number, e.g.\& "1", "5".
417 .It Fl v
418 Be verbose, print out sense information for failed SCSI commands.
419 .El
420 .Pp
421 Primary command functions:
422 .Bl -tag -width periphlist
423 .It Ic devlist
424 List all physical devices (logical units) attached to the CAM subsystem.
425 This also includes a list of peripheral drivers attached to each device.
426 With the
427 .Fl v
428 argument, SCSI bus number, adapter name and unit numbers are printed as
429 well.
430 On the other hand, with the
431 .Fl b
432 argument, only the bus adapter, and unit information will be printed, and
433 device information will be omitted.
434 .It Ic periphlist
435 List all peripheral drivers attached to a given physical device (logical
436 unit).
437 .It Ic tur
438 Send the SCSI test unit ready (0x00) command to the given device.
439 The
440 .Nm
441 utility will report whether the device is ready or not.
442 .It Ic inquiry
443 Send a SCSI inquiry command (0x12) to a device.
444 By default,
445 .Nm
446 will print out the standard inquiry data, device serial number, and
447 transfer rate information.
448 The user can specify that only certain types of
449 inquiry data be printed:
450 .Bl -tag -width 4n
451 .It Fl D
452 Get the standard inquiry data.
453 .It Fl S
454 Print out the serial number.
455 If this flag is the only one specified,
456 .Nm
457 will not print out "Serial Number" before the value returned by the drive.
458 This is to aid in script writing.
459 .It Fl R
460 Print out transfer rate information.
461 .El
462 .It Ic identify
463 Send a ATA identify command (0xec) to a device.
464 .It Ic reportluns
465 Send the SCSI REPORT LUNS (0xA0) command to the given device.
466 By default,
467 .Nm
468 will print out the list of logical units (LUNs) supported by the target device.
469 There are a couple of options to modify the output:
470 .Bl -tag -width 14n
471 .It Fl c
472 Just print out a count of LUNs, not the actual LUN numbers.
473 .It Fl l
474 Just print out the LUNs, and do not print out the count.
475 .It Fl r Ar reporttype
476 Specify the type of report to request from the target:
477 .Bl -tag -width 012345678
478 .It default
479 Return the default report.
480 This is the
481 .Nm
482 default.
483 Most targets will support this report if they support the REPORT LUNS
484 command.
485 .It wellknown
486 Return only well known LUNs.
487 .It all
488 Return all available LUNs.
489 .El
490 .El
491 .Pp
492 .Nm
493 will try to print out LUN numbers in a reasonable format.
494 It can understand the peripheral, flat, LUN and extended LUN formats.
495 .It Ic readcap
496 Send the SCSI READ CAPACITY command to the given device and display
497 the results.
498 If the device is larger than 2TB, the SCSI READ CAPACITY (16) service
499 action will be sent to obtain the full size of the device.
500 By default,
501 .Nm
502 will print out the last logical block of the device, and the blocksize of
503 the device in bytes.
504 To modify the output format, use the following options:
505 .Bl -tag -width 5n
506 .It Fl b
507 Just print out the blocksize, not the last block or device size.
508 This cannot be used with
509 .Fl N
510 or
511 .Fl s .
512 .It Fl h
513 Print out the device size in human readable (base 2, 1K == 1024) format.
514 This implies
515 .Fl N
516 and cannot be used with
517 .Fl q
518 or
519 .Fl b .
520 .It Fl H
521 Print out the device size in human readable (base 10, 1K == 1000) format.
522 .It Fl N
523 Print out the number of blocks in the device instead of the last logical
524 block.
525 .It Fl q
526 Quiet, print out the numbers only (separated by a comma if
527 .Fl b
528 or
529 .Fl s
530 are not specified).
531 .It Fl s
532 Print out the last logical block or the size of the device only, and omit
533 the blocksize.
534 .El
535 .Pp
536 Note that this command only displays the information, it does not update
537 the kernel data structures.
538 Use the
539 .Nm 
540 reprobe subcommand to do that.
541 .It Ic start
542 Send the SCSI Start/Stop Unit (0x1B) command to the given device with the
543 start bit set.
544 .It Ic stop
545 Send the SCSI Start/Stop Unit (0x1B) command to the given device with the
546 start bit cleared.
547 .It Ic load
548 Send the SCSI Start/Stop Unit (0x1B) command to the given device with the
549 start bit set and the load/eject bit set.
550 .It Ic eject
551 Send the SCSI Start/Stop Unit (0x1B) command to the given device with the
552 start bit cleared and the load/eject bit set.
553 .It Ic rescan
554 Tell the kernel to scan all busses in the system (with the
555 .Ar all
556 argument), the given bus (XPT_SCAN_BUS), bus:target:lun or device
557 (XPT_SCAN_LUN) for new devices or devices that have gone away.
558 The user
559 may specify a scan of all busses, a single bus, or a lun.
560 Scanning all luns
561 on a target is not supported.
562 .Pp
563 If a device is specified by peripheral name and unit number, for instance
564 da4, it may only be rescanned if that device currently exists in the CAM EDT
565 (Existing Device Table).
566 If the device is no longer there (see
567 .Nm
568 devlist ),
569 you must use the bus:target:lun form to rescan it.
570 .It Ic reprobe
571 Tell the kernel to refresh the information about the device and
572 notify the upper layer,
573 .Xr GEOM 4 .
574 This includes sending the SCSI READ CAPACITY command and updating
575 the disk size visible to the rest of the system.
576 .It Ic reset
577 Tell the kernel to reset all busses in the system (with the
578 .Ar all
579 argument), the given bus (XPT_RESET_BUS) by issuing a SCSI bus
580 reset for that bus, or to reset the given bus:target:lun or device
581 (XPT_RESET_DEV), typically by issuing a BUS DEVICE RESET message after
582 connecting to that device.
583 Note that this can have a destructive impact
584 on the system.
585 .It Ic defects
586 Send the
587 .Tn SCSI
588 READ DEFECT DATA (10) command (0x37) or the 
589 .Tn SCSI
590 READ DEFECT DATA (12) command (0xB7) to the given device, and
591 print out any combination of: the total number of defects, the primary
592 defect list (PLIST), and the grown defect list (GLIST).
593 .Bl -tag -width 11n
594 .It Fl f Ar format
595 Specify the requested format of the defect list.
596 The format argument is
597 required.
598 Most drives support the physical sector format.
599 Some drives
600 support the logical block format.
601 Many drives, if they do not support the
602 requested format, return the data in an alternate format, along with sense
603 information indicating that the requested data format is not supported.
604 The
605 .Nm
606 utility
607 attempts to detect this, and print out whatever format the drive returns.
608 If the drive uses a non-standard sense code to report that it does not
609 support the requested format,
610 .Nm
611 will probably see the error as a failure to complete the request.
612 .Pp
613 The format options are:
614 .Bl -tag -width 9n
615 .It block
616 Print out the list as logical blocks.
617 This is limited to 32-bit block sizes, and isn't supported by many modern
618 drives.
619 .It longblock
620 Print out the list as logical blocks.
621 This option uses a 64-bit block size.
622 .It bfi 
623 Print out the list in bytes from index format.
624 .It extbfi
625 Print out the list in extended bytes from index format.
626 The extended format allows for ranges of blocks to be printed.
627 .It phys 
628 Print out the list in physical sector format.
629 Most drives support this format.
630 .It extphys
631 Print out the list in extended physical sector format.
632 The extended format allows for ranges of blocks to be printed.
633 .El
634 .Pp
635 .It Fl G
636 Print out the grown defect list.
637 This is a list of bad blocks that have
638 been remapped since the disk left the factory.
639 .It Fl P
640 Print out the primary defect list.
641 This is the list of defects that were present in the factory.
642 .It Fl q
643 When printing status information with
644 .Fl s ,
645 only print the number of defects.
646 .It Fl s
647 Just print the number of defects, not the list of defects.
648 .It Fl S Ar offset
649 Specify the starting offset into the defect list.
650 This implies using the
651 .Tn SCSI
652 READ DEFECT DATA (12) command, as the 10 byte version of the command
653 doesn't support the address descriptor index field.
654 Not all drives support the 12 byte command, and some drives that support
655 the 12 byte command don't support the address descriptor index field.
656 .It Fl X
657 Print out defects in hexadecimal (base 16) form instead of base 10 form.
658 .El
659 .Pp
660 If neither
661 .Fl P
662 nor
663 .Fl G
664 is specified,
665 .Nm
666 will print out the number of defects given in the READ DEFECT DATA header
667 returned from the drive.
668 Some drives will report 0 defects if neither the primary or grown defect
669 lists are requested.
670 .It Ic modepage
671 Allows the user to display and optionally edit a SCSI mode page.
672 The mode
673 page formats are located in
674 .Pa /usr/share/misc/scsi_modes .
675 This can be overridden by specifying a different file in the
676 .Ev SCSI_MODES
677 environment variable.
678 The
679 .Ic modepage
680 command takes several arguments:
681 .Bl -tag -width 12n
682 .It Fl d
683 Disable block descriptors for mode sense.
684 .It Fl b
685 Displays mode page data in binary format.
686 .It Fl e
687 This flag allows the user to edit values in the mode page.
688 The user may
689 either edit mode page values with the text editor pointed to by his
690 .Ev EDITOR
691 environment variable, or supply mode page values via standard input, using
692 the same format that
693 .Nm
694 uses to display mode page values.
695 The editor will be invoked if
696 .Nm
697 detects that standard input is terminal.
698 .It Fl l
699 Lists all available mode pages.
700 If specified more then once, also lists subpages.
701 .It Fl m Ar page[,subpage]
702 This specifies the number of the mode page and optionally subpage the user
703 would like to view and/or edit.
704 This argument is mandatory unless
705 .Fl l
706 is specified.
707 .It Fl P Ar pgctl
708 This allows the user to specify the page control field.
709 Possible values are:
710 .Bl -tag -width xxx -compact
711 .It 0
712 Current values
713 .It 1
714 Changeable values
715 .It 2
716 Default values
717 .It 3
718 Saved values
719 .El
720 .El
721 .It Ic cmd
722 Allows the user to send an arbitrary ATA or SCSI CDB to any device.
723 The
724 .Ic cmd
725 function requires the
726 .Fl c
727 argument to specify SCSI CDB or the
728 .Fl a
729 argument to specify ATA Command Block registers values.
730 Other arguments are optional, depending on
731 the command type.
732 The command and data specification syntax is documented
733 in
734 .Xr cam_cdbparse 3 .
735 NOTE: If the CDB specified causes data to be transferred to or from the
736 SCSI device in question, you MUST specify either
737 .Fl i
738 or
739 .Fl o .
740 .Bl -tag -width 17n
741 .It Fl a Ar cmd Op args
742 This specifies the content of 12 ATA Command Block registers (command,
743 features, lba_low, lba_mid, lba_high, device, lba_low_exp, lba_mid_exp.
744 lba_high_exp, features_exp, sector_count, sector_count_exp).
745 .It Fl c Ar cmd Op args
746 This specifies the SCSI CDB.
747 SCSI CDBs may be 6, 10, 12 or 16 bytes.
748 .It Fl d
749 Specifies DMA protocol to be used for ATA command.
750 .It Fl f
751 Specifies FPDMA (NCQ) protocol to be used for ATA command.
752 .It Fl i Ar len Ar fmt
753 This specifies the amount of data to read, and how it should be displayed.
754 If the format is
755 .Sq - ,
756 .Ar len
757 bytes of data will be read from the device and written to standard output.
758 .It Fl o Ar len Ar fmt Op args
759 This specifies the amount of data to be written to a device, and the data
760 that is to be written.
761 If the format is
762 .Sq - ,
763 .Ar len
764 bytes of data will be read from standard input and written to the device.
765 .It Fl r Ar fmt
766 This specifies that 11 result ATA Command Block registers should be displayed
767 (status, error, lba_low, lba_mid, lba_high, device, lba_low_exp, lba_mid_exp,
768 lba_high_exp, sector_count, sector_count_exp), and how.
769 If the format is
770 .Sq - ,
771 11 result registers will be written to standard output in hex.
772 .El
773 .It Ic smpcmd
774 Allows the user to send an arbitrary Serial
775 Management Protocol (SMP) command to a device.
776 The
777 .Ic smpcmd
778 function requires the
779 .Fl r
780 argument to specify the SMP request to be sent, and the
781 .Fl R
782 argument to specify the format of the SMP response.
783 The syntax for the SMP request and response arguments is documented in
784 .Xr cam_cdbparse 3 .
785 .Pp
786 Note that SAS adapters that support SMP passthrough (at least the currently
787 known adapters) do not accept CRC bytes from the user in the request and do
788 not pass CRC bytes back to the user in the response.
789 Therefore users should not include the CRC bytes in the length of the
790 request and not expect CRC bytes to be returned in the response.
791 .Bl -tag -width 17n
792 .It Fl r Ar len Ar fmt Op args
793 This specifies the size of the SMP request, without the CRC bytes, and the
794 SMP request format.
795 If the format is
796 .Sq - ,
797 .Ar len
798 bytes of data will be read from standard input and written as the SMP
799 request.
800 .It Fl R Ar len Ar fmt Op args
801 This specifies the size of the buffer allocated for the SMP response, and
802 the SMP response format.
803 If the format is
804 .Sq - ,
805 .Ar len
806 bytes of data will be allocated for the response and the response will be
807 written to standard output.
808 .El
809 .It Ic smprg
810 Allows the user to send the Serial Management Protocol (SMP) Report General
811 command to a device.
812 .Nm
813 will display the data returned by the Report General command.
814 If the SMP target supports the long response format, the additional data
815 will be requested and displayed automatically.
816 .Bl -tag -width 8n
817 .It Fl l
818 Request the long response format only.
819 Not all SMP targets support the long response format.
820 This option causes
821 .Nm
822 to skip sending the initial report general request without the long bit set
823 and only issue a report general request with the long bit set.
824 .El
825 .It Ic smppc
826 Allows the user to issue the Serial Management Protocol (SMP) PHY Control
827 command to a device.
828 This function should be used with some caution, as it can render devices
829 inaccessible, and could potentially cause data corruption as well.
830 The
831 .Fl p
832 argument is required to specify the PHY to operate on.
833 .Bl -tag -width 17n
834 .It Fl p Ar phy
835 Specify the PHY to operate on.
836 This argument is required.
837 .It Fl l
838 Request the long request/response format.
839 Not all SMP targets support the long response format.
840 For the PHY Control command, this currently only affects whether the
841 request length is set to a value other than 0.
842 .It Fl o Ar operation
843 Specify a PHY control operation.
844 Only one
845 .Fl o
846 operation may be specified.
847 The operation may be specified numerically (in decimal, hexadecimal, or octal)
848 or one of the following operation names may be specified:
849 .Bl -tag -width 16n
850 .It nop
851 No operation.
852 It is not necessary to specify this argument.
853 .It linkreset
854 Send the LINK RESET command to the phy.
855 .It hardreset
856 Send the HARD RESET command to the phy.
857 .It disable
858 Send the DISABLE command to the phy.
859 Note that the LINK RESET or HARD RESET commands should re-enable the phy.
860 .It clearerrlog
861 Send the CLEAR ERROR LOG command.
862 This clears the error log counters for the specified phy.
863 .It clearaffiliation
864 Send the CLEAR AFFILIATION command.
865 This clears the affiliation from the STP initiator port with the same SAS
866 address as the SMP initiator that requests the clear operation.
867 .It sataportsel
868 Send the TRANSMIT SATA PORT SELECTION SIGNAL command to the phy.
869 This will cause a SATA port selector to use the given phy as its active phy
870 and make the other phy inactive.
871 .It clearitnl
872 Send the CLEAR STP I_T NEXUS LOSS command to the PHY.
873 .It setdevname
874 Send the SET ATTACHED DEVICE NAME command to the PHY.
875 This requires the
876 .Fl d
877 argument to specify the device name.
878 .El
879 .It Fl d Ar name
880 Specify the attached device name.
881 This option is needed with the
882 .Fl o Ar setdevname
883 phy operation.
884 The name is a 64-bit number, and can be specified in decimal, hexadecimal
885 or octal format.
886 .It Fl m Ar rate
887 Set the minimum physical link rate for the phy.
888 This is a numeric argument.
889 Currently known link rates are:
890 .Bl -tag -width 5n
891 .It 0x0
892 Do not change current value.
893 .It 0x8
894 1.5 Gbps
895 .It 0x9
896 3 Gbps
897 .It 0xa
898 6 Gbps
899 .El
900 .Pp
901 Other values may be specified for newer physical link rates.
902 .It Fl M Ar rate
903 Set the maximum physical link rate for the phy.
904 This is a numeric argument.
905 See the
906 .Fl m
907 argument description for known link rate arguments.
908 .It Fl T Ar pp_timeout
909 Set the partial pathway timeout value, in microseconds.
910 See the
911 .Tn ANSI
912 .Tn SAS
913 Protocol Layer (SPL)
914 specification for more information on this field.
915 .It Fl a Ar enable|disable
916 Enable or disable SATA slumber phy power conditions.
917 .It Fl A Ar enable|disable
918 Enable or disable SATA partial power conditions.
919 .It Fl s Ar enable|disable
920 Enable or disable SAS slumber phy power conditions.
921 .It Fl S Ar enable|disable
922 Enable or disable SAS partial phy power conditions.
923 .El
924 .It Ic smpphylist
925 List phys attached to a SAS expander, the address of the end device
926 attached to the phy, and the inquiry data for that device and peripheral
927 devices attached to that device.
928 The inquiry data and peripheral devices are displayed if available.
929 .Bl -tag -width 5n
930 .It Fl l
931 Turn on the long response format for the underlying SMP commands used for
932 this command.
933 .It Fl q
934 Only print out phys that are attached to a device in the CAM EDT (Existing
935 Device Table).
936 .El
937 .It Ic smpmaninfo
938 Send the SMP Report Manufacturer Information command to the device and
939 display the response.
940 .Bl -tag -width 5n
941 .It Fl l
942 Turn on the long response format for the underlying SMP commands used for
943 this command.
944 .El
945 .It Ic debug
946 Turn on CAM debugging printfs in the kernel.
947 This requires options CAMDEBUG
948 in your kernel config file.
949 WARNING: enabling debugging printfs currently
950 causes an EXTREME number of kernel printfs.
951 You may have difficulty
952 turning off the debugging printfs once they start, since the kernel will be
953 busy printing messages and unable to service other requests quickly.
954 The
955 .Ic debug
956 function takes a number of arguments:
957 .Bl -tag -width 18n
958 .It Fl I
959 Enable CAM_DEBUG_INFO printfs.
960 .It Fl P
961 Enable CAM_DEBUG_PERIPH printfs.
962 .It Fl T
963 Enable CAM_DEBUG_TRACE printfs.
964 .It Fl S
965 Enable CAM_DEBUG_SUBTRACE printfs.
966 .It Fl X
967 Enable CAM_DEBUG_XPT printfs.
968 .It Fl c
969 Enable CAM_DEBUG_CDB printfs.
970 This will cause the kernel to print out the
971 SCSI CDBs sent to the specified device(s).
972 .It Fl p
973 Enable CAM_DEBUG_PROBE printfs.
974 .It all
975 Enable debugging for all devices.
976 .It off
977 Turn off debugging for all devices
978 .It bus Ns Op :target Ns Op :lun
979 Turn on debugging for the given bus, target or lun.
980 If the lun or target
981 and lun are not specified, they are wildcarded.
982 (i.e., just specifying a
983 bus turns on debugging printfs for all devices on that bus.)
984 .El
985 .It Ic tags
986 Show or set the number of "tagged openings" or simultaneous transactions
987 we attempt to queue to a particular device.
988 By default, the
989 .Ic tags
990 command, with no command-specific arguments (i.e., only generic arguments)
991 prints out the "soft" maximum number of transactions that can be queued to
992 the device in question.
993 For more detailed information, use the
994 .Fl v
995 argument described below.
996 .Bl -tag -width 7n
997 .It Fl N Ar tags
998 Set the number of tags for the given device.
999 This must be between the
1000 minimum and maximum number set in the kernel quirk table.
1001 The default for
1002 most devices that support tagged queueing is a minimum of 2 and a maximum
1003 of 255.
1004 The minimum and maximum values for a given device may be
1005 determined by using the
1006 .Fl v
1007 switch.
1008 The meaning of the
1009 .Fl v
1010 switch for this
1011 .Nm
1012 subcommand is described below.
1013 .It Fl q
1014 Be quiet, and do not report the number of tags.
1015 This is generally used when
1016 setting the number of tags.
1017 .It Fl v
1018 The verbose flag has special functionality for the
1019 .Em tags
1020 argument.
1021 It causes
1022 .Nm
1023 to print out the tagged queueing related fields of the XPT_GDEV_TYPE CCB:
1024 .Bl -tag -width 13n
1025 .It dev_openings
1026 This is the amount of capacity for transactions queued to a given device.
1027 .It dev_active
1028 This is the number of transactions currently queued to a device.
1029 .It devq_openings
1030 This is the kernel queue space for transactions.
1031 This count usually mirrors
1032 dev_openings except during error recovery operations when
1033 the device queue is frozen (device is not allowed to receive
1034 commands), the number of dev_openings is reduced, or transaction
1035 replay is occurring.
1036 .It devq_queued
1037 This is the number of transactions waiting in the kernel queue for capacity
1038 on the device.
1039 This number is usually zero unless error recovery is in
1040 progress.
1041 .It held
1042 The held count is the number of CCBs held by peripheral drivers that have
1043 either just been completed or are about to be released to the transport
1044 layer for service by a device.
1045 Held CCBs reserve capacity on a given
1046 device.
1047 .It mintags
1048 This is the current "hard" minimum number of transactions that can be
1049 queued to a device at once.
1050 The
1051 .Ar dev_openings
1052 value above cannot go below this number.
1053 The default value for
1054 .Ar mintags
1055 is 2, although it may be set higher or lower for various devices.
1056 .It maxtags
1057 This is the "hard" maximum number of transactions that can be queued to a
1058 device at one time.
1059 The
1060 .Ar dev_openings
1061 value cannot go above this number.
1062 The default value for
1063 .Ar maxtags
1064 is 255, although it may be set higher or lower for various devices.
1065 .El
1066 .El
1067 .It Ic negotiate
1068 Show or negotiate various communication parameters.
1069 Some controllers may
1070 not support setting or changing some of these values.
1071 For instance, the
1072 Adaptec 174x controllers do not support changing a device's sync rate or
1073 offset.
1074 The
1075 .Nm
1076 utility
1077 will not attempt to set the parameter if the controller indicates that it
1078 does not support setting the parameter.
1079 To find out what the controller
1080 supports, use the
1081 .Fl v
1082 flag.
1083 The meaning of the
1084 .Fl v
1085 flag for the
1086 .Ic negotiate
1087 command is described below.
1088 Also, some controller drivers do not support
1089 setting negotiation parameters, even if the underlying controller supports
1090 negotiation changes.
1091 Some controllers, such as the Advansys wide
1092 controllers, support enabling and disabling synchronous negotiation for
1093 a device, but do not support setting the synchronous negotiation rate.
1094 .Bl -tag -width 17n
1095 .It Fl a
1096 Attempt to make the negotiation settings take effect immediately by sending
1097 a Test Unit Ready command to the device.
1098 .It Fl c
1099 Show or set current negotiation settings.
1100 This is the default.
1101 .It Fl D Ar enable|disable
1102 Enable or disable disconnection.
1103 .It Fl M Ar mode
1104 Set ATA mode.
1105 .It Fl O Ar offset
1106 Set the command delay offset.
1107 .It Fl q
1108 Be quiet, do not print anything.
1109 This is generally useful when you want to
1110 set a parameter, but do not want any status information.
1111 .It Fl R Ar syncrate
1112 Change the synchronization rate for a device.
1113 The sync rate is a floating
1114 point value specified in MHz.
1115 So, for instance,
1116 .Sq 20.000
1117 is a legal value, as is
1118 .Sq 20 .
1119 .It Fl T Ar enable|disable
1120 Enable or disable tagged queueing for a device.
1121 .It Fl U
1122 Show or set user negotiation settings.
1123 The default is to show or set
1124 current negotiation settings.
1125 .It Fl v
1126 The verbose switch has special meaning for the
1127 .Ic negotiate
1128 subcommand.
1129 It causes
1130 .Nm
1131 to print out the contents of a Path Inquiry (XPT_PATH_INQ) CCB sent to the
1132 controller driver.
1133 .It Fl W Ar bus_width
1134 Specify the bus width to negotiate with a device.
1135 The bus width is
1136 specified in bits.
1137 The only useful values to specify are 8, 16, and 32
1138 bits.
1139 The controller must support the bus width in question in order for
1140 the setting to take effect.
1141 .El
1142 .Pp
1143 In general, sync rate and offset settings will not take effect for a
1144 device until a command has been sent to the device.
1145 The
1146 .Fl a
1147 switch above will automatically send a Test Unit Ready to the device so
1148 negotiation parameters will take effect.
1149 .It Ic format
1150 Issue the
1151 .Tn SCSI
1152 FORMAT UNIT command to the named device.
1153 .Pp
1154 .Em WARNING! WARNING! WARNING!
1155 .Pp
1156 Low level formatting a disk will destroy ALL data on the disk.
1157 Use
1158 extreme caution when issuing this command.
1159 Many users low-level format
1160 disks that do not really need to be low-level formatted.
1161 There are
1162 relatively few scenarios that call for low-level formatting a disk.
1163 One reason for
1164 low-level formatting a disk is to initialize the disk after changing
1165 its physical sector size.
1166 Another reason for low-level formatting a disk
1167 is to revive the disk if you are getting "medium format corrupted" errors
1168 from the disk in response to read and write requests.
1169 .Pp
1170 Some disks take longer than others to format.
1171 Users should specify a
1172 timeout long enough to allow the format to complete.
1173 The default format
1174 timeout is 3 hours, which should be long enough for most disks.
1175 Some hard
1176 disks will complete a format operation in a very short period of time
1177 (on the order of 5 minutes or less).
1178 This is often because the drive
1179 does not really support the FORMAT UNIT command -- it just accepts the
1180 command, waits a few minutes and then returns it.
1181 .Pp
1182 The
1183 .Sq format
1184 subcommand takes several arguments that modify its default behavior.
1185 The
1186 .Fl q
1187 and
1188 .Fl y
1189 arguments can be useful for scripts.
1190 .Bl -tag -width 6n
1191 .It Fl q
1192 Be quiet, do not print any status messages.
1193 This option will not disable
1194 the questions, however.
1195 To disable questions, use the
1196 .Fl y
1197 argument, below.
1198 .It Fl r
1199 Run in
1200 .Dq report only
1201 mode.
1202 This will report status on a format that is already running on the drive.
1203 .It Fl w
1204 Issue a non-immediate format command.
1205 By default,
1206 .Nm
1207 issues the FORMAT UNIT command with the immediate bit set.
1208 This tells the
1209 device to immediately return the format command, before the format has
1210 actually completed.
1211 Then,
1212 .Nm
1213 gathers
1214 .Tn SCSI
1215 sense information from the device every second to determine how far along
1216 in the format process it is.
1217 If the
1218 .Fl w
1219 argument is specified,
1220 .Nm
1221 will issue a non-immediate format command, and will be unable to print any
1222 information to let the user know what percentage of the disk has been
1223 formatted.
1224 .It Fl y
1225 Do not ask any questions.
1226 By default,
1227 .Nm
1228 will ask the user if he/she really wants to format the disk in question,
1229 and also if the default format command timeout is acceptable.
1230 The user
1231 will not be asked about the timeout if a timeout is specified on the
1232 command line.
1233 .El
1234 .It Ic sanitize
1235 Issue the
1236 .Tn SCSI
1237 SANITIZE command to the named device.
1238 .Pp
1239 .Em WARNING! WARNING! WARNING!
1240 .Pp
1241 ALL data in the cache and on the disk will be destroyed or made inaccessible.
1242 Recovery of the data is not possible.
1243 Use extreme caution when issuing this command.
1244 .Pp
1245 The
1246 .Sq sanitize
1247 subcommand takes several arguments that modify its default behavior.
1248 The
1249 .Fl q
1250 and
1251 .Fl y
1252 arguments can be useful for scripts.
1253 .Bl -tag -width 6n
1254 .It Fl a Ar operation
1255 Specify the sanitize operation to perform.
1256 .Bl -tag -width 16n
1257 .It overwrite
1258 Perform an overwrite operation by writing a user supplied
1259 data pattern to the device one or more times.
1260 The pattern is given by the
1261 .Fl P
1262 argument.
1263 The number of times is given by the
1264 .Fl c
1265 argument.
1266 .It block
1267 Perform a block erase operation.
1268 All the device's blocks are set to a vendor defined
1269 value, typically zero.
1270 .It crypto
1271 Perform a cryptographic erase operation.
1272 The encryption keys are changed to prevent the decryption
1273 of the data.
1274 .It exitfailure
1275 Exits a previously failed sanitize operation.
1276 A failed sanitize operation can only be exited if it was
1277 run in the unrestricted completion mode, as provided by the
1278 .Fl U
1279 argument.
1280 .El
1281 .It Fl c Ar passes
1282 The number of passes when performing an
1283 .Sq overwrite
1284 operation.
1285 Valid values are between 1 and 31.
1286 The default is 1.
1287 .It Fl I
1288 When performing an
1289 .Sq overwrite
1290 operation, the pattern is inverted between consecutive passes.
1291 .It Fl P Ar pattern
1292 Path to the file containing the pattern to use when
1293 performing an
1294 .Sq overwrite
1295 operation.
1296 The pattern is repeated as needed to fill each block.
1297 .It Fl q
1298 Be quiet, do not print any status messages.
1299 This option will not disable
1300 the questions, however.
1301 To disable questions, use the
1302 .Fl y
1303 argument, below.
1304 .It Fl U
1305 Perform the sanitize in the unrestricted completion mode.
1306 If the operation fails, it can later be exited with the
1307 .Sq exitfailure
1308 operation.
1309 .It Fl r
1310 Run in
1311 .Dq report only
1312 mode.
1313 This will report status on a sanitize that is already running on the drive.
1314 .It Fl w
1315 Issue a non-immediate sanitize command.
1316 By default,
1317 .Nm
1318 issues the SANITIZE command with the immediate bit set.
1319 This tells the
1320 device to immediately return the sanitize command, before
1321 the sanitize has actually completed.
1322 Then,
1323 .Nm
1324 gathers
1325 .Tn SCSI
1326 sense information from the device every second to determine how far along
1327 in the sanitize process it is.
1328 If the
1329 .Fl w
1330 argument is specified,
1331 .Nm
1332 will issue a non-immediate sanitize command, and will be unable to print any
1333 information to let the user know what percentage of the disk has been
1334 sanitized.
1335 .It Fl y
1336 Do not ask any questions.
1337 By default,
1338 .Nm
1339 will ask the user if he/she really wants to sanitize the disk in question,
1340 and also if the default sanitize command timeout is acceptable.
1341 The user
1342 will not be asked about the timeout if a timeout is specified on the
1343 command line.
1344 .El
1345 .It Ic idle
1346 Put ATA device into IDLE state.
1347 Optional parameter
1348 .Pq Fl t
1349 specifies automatic standby timer value in seconds.
1350 Value 0 disables timer.
1351 .It Ic standby
1352 Put ATA device into STANDBY state.
1353 Optional parameter
1354 .Pq Fl t
1355 specifies automatic standby timer value in seconds.
1356 Value 0 disables timer.
1357 .It Ic sleep
1358 Put ATA device into SLEEP state.
1359 Note that the only way get device out of
1360 this state may be reset.
1361 .It Ic apm
1362 It optional parameter
1363 .Pq Fl l
1364 specified, enables and sets advanced power management level, where
1365 1 -- minimum power, 127 -- maximum performance with standby,
1366 128 -- minimum power without standby, 254 -- maximum performance.
1367 If not specified -- APM is disabled.
1368 .It Ic aam
1369 It optional parameter
1370 .Pq Fl l
1371 specified, enables and sets automatic acoustic management level, where
1372 1 -- minimum noise, 254 -- maximum performance.
1373 If not specified -- AAM is disabled.
1374 .It Ic security
1375 Update or report security settings, using an ATA identify command (0xec).
1376 By default,
1377 .Nm
1378 will print out the security support and associated settings of the device.
1379 The
1380 .Ic security
1381 command takes several arguments:
1382 .Bl -tag -width 0n
1383 .It Fl d Ar pwd
1384 .Pp
1385 Disable device security using the given password for the selected user according
1386 to the devices configured security level.
1387 .It Fl e Ar pwd
1388 .Pp
1389 Erase the device using the given password for the selected user.
1390 .Pp
1391 .Em WARNING! WARNING! WARNING!
1392 .Pp
1393 Issuing a secure erase will
1394 .Em ERASE ALL
1395 user data on the device and may take several hours to complete.
1396 .Pp
1397 When this command is used against an SSD drive all its cells will be marked as
1398 empty, restoring it to factory default write performance.
1399 For SSD's this action
1400 usually takes just a few seconds.
1401 .It Fl f
1402 .Pp
1403 Freeze the security configuration of the specified device.
1404 .Pp
1405 After command completion any other commands that update the device lock mode
1406 shall be command aborted.
1407 Frozen mode is disabled by power-off or hardware reset.
1408 .It Fl h Ar pwd
1409 .Pp
1410 Enhanced erase the device using the given password for the selected user.
1411 .Pp
1412 .Em WARNING! WARNING! WARNING!
1413 .Pp
1414 Issuing an enhanced secure erase will
1415 .Em ERASE ALL
1416 user data on the device and may take several hours to complete.
1417 .Pp
1418 An enhanced erase writes predetermined data patterns to all user data areas,
1419 all previously written user data shall be overwritten, including sectors that
1420 are no longer in use due to reallocation.
1421 .It Fl k Ar pwd
1422 .Pp
1423 Unlock the device using the given password for the selected user according to
1424 the devices configured security level.
1425 .It Fl l Ar high|maximum
1426 .Pp
1427 Specifies which security level to set when issuing a
1428 .Fl s Ar pwd
1429 command.
1430 The security level determines device behavior when the master
1431 password is used to unlock the device.
1432 When the security level is set to high
1433 the device requires the unlock command and the master password to unlock.
1434 When the security level is set to maximum the device requires a secure erase
1435 with the master password to unlock.
1436 .Pp
1437 This option must be used in conjunction with one of the security action commands.
1438 .Pp
1439 Defaults to
1440 .Em high
1441 .It Fl q
1442 .Pp
1443 Be quiet, do not print any status messages.
1444 This option will not disable the questions, however.
1445 To disable questions, use the
1446 .Fl y
1447 argument, below.
1448 .It Fl s Ar pwd
1449 .Pp
1450 Password the device (enable security) using the given password for the selected
1451 user.
1452 This option can be combined with other options such as
1453 .Fl e Em pwd
1454 .Pp
1455 A master password may be set in a addition to the user password. The purpose of
1456 the master password is to allow an administrator to establish a password that
1457 is kept secret from the user, and which may be used to unlock the device if the
1458 user password is lost.
1459 .Pp
1460 .Em Note:
1461 Setting the master password does not enable device security.
1462 .Pp
1463 If the master password is set and the drive supports a Master Revision Code
1464 feature the Master Password Revision Code will be decremented.
1465 .It Fl T Ar timeout
1466 .Pp
1467 Overrides the default timeout, specified in seconds, used for both
1468 .Fl e
1469 and
1470 .Fl h
1471 this is useful if your system has problems processing long timeouts correctly.
1472 .Pp
1473 Usually the timeout is calculated from the information stored on the drive if
1474 present, otherwise it defaults to 2 hours.
1475 .It Fl U Ar user|master
1476 .Pp
1477 Specifies which user to set / use for the running action command, valid values
1478 are user or master and defaults to master if not set.
1479 .Pp
1480 This option must be used in conjunction with one of the security action commands.
1481 .Pp
1482 Defaults to
1483 .Em master
1484 .It Fl y
1485 .Pp
1486 Confirm yes to dangerous options such as
1487 .Fl e
1488 without prompting for confirmation.
1489 .Pp
1490 .El
1491 If the password specified for any action commands does not match the configured
1492 password for the specified user the command will fail.
1493 .Pp
1494 The password in all cases is limited to 32 characters, longer passwords will
1495 fail.
1496 .It Ic hpa
1497 Update or report Host Protected Area details.
1498 By default
1499 .Nm
1500 will print out the HPA support and associated settings of the device.
1501 The
1502 .Ic hpa
1503 command takes several optional arguments:
1504 .Bl -tag -width 0n
1505 .It Fl f
1506 .Pp
1507 Freeze the HPA configuration of the specified device.
1508 .Pp
1509 After command completion any other commands that update the HPA configuration
1510 shall be command aborted.
1511 Frozen mode is disabled by power-off or hardware reset.
1512 .It Fl l
1513 .Pp
1514 Lock the HPA configuration of the device until a successful call to unlock or
1515 the next power-on reset occurs.
1516 .It Fl P
1517 .Pp
1518 Make the HPA max sectors persist across power-on reset or a hardware reset.
1519 This must be used in combination with
1520 .Fl s Ar max_sectors
1521 .
1522 .It Fl p Ar pwd
1523 .Pp
1524 Set the HPA configuration password required for unlock calls.
1525 .It Fl q
1526 .Pp
1527 Be quiet, do not print any status messages.
1528 This option will not disable the questions.
1529 To disable questions, use the
1530 .Fl y
1531 argument, below.
1532 .It Fl s Ar max_sectors
1533 .Pp
1534 Configures the maximum user accessible sectors of the device.
1535 This will change the number of sectors the device reports.
1536 .Pp
1537 .Em WARNING! WARNING! WARNING!
1538 .Pp
1539 Changing the max sectors of a device using this option will make the data on
1540 the device beyond the specified value inaccessible.
1541 .Pp
1542 Only one successful
1543 .Fl s Ar max_sectors
1544 call can be made without a power-on reset or a hardware reset of the device.
1545 .It Fl U Ar pwd
1546 .Pp
1547 Unlock the HPA configuration of the specified device using the given password.
1548 If the password specified does not match the password configured via
1549 .Fl p Ar pwd
1550 the command will fail.
1551 .Pp
1552 After 5 failed unlock calls, due to password miss-match, the device will refuse
1553 additional unlock calls until after a power-on reset.
1554 .It Fl y
1555 .Pp
1556 Confirm yes to dangerous options such as
1557 .Fl e
1558 without prompting for confirmation
1559 .Pp
1560 .El
1561 The password for all HPA commands is limited to 32 characters, longer passwords
1562 will fail.
1563 .It Ic fwdownload
1564 Program firmware of the named
1565 .Tn SCSI
1566 or ATA device using the image file provided.
1567 .Pp
1568 If the device is a
1569 .Tn SCSI
1570 device and it provides a recommended timeout for the WRITE BUFFER command
1571 (see the
1572 .Nm 
1573 opcodes subcommand), that timeout will be used for the firmware download.
1574 The drive-recommended timeout value may be overridden on the command line
1575 with the
1576 .Fl t
1577 option.
1578 .Pp
1579 Current list of supported vendors for SCSI/SAS drives:
1580 .Bl -tag -width 10n
1581 .It HGST
1582 Tested with 4TB SAS drives, model number HUS724040ALS640.
1583 .It HITACHI
1584 .It HP
1585 .It IBM
1586 Tested with LTO-5 (ULTRIUM-HH5) and LTO-6 (ULTRIUM-HH6) tape drives.
1587 There is a separate table entry for hard drives, because the update method
1588 for hard drives is different than the method for tape drives.
1589 .It PLEXTOR
1590 .It QUALSTAR
1591 .It QUANTUM
1592 .It SAMSUNG
1593 Tested with SM1625 SSDs.
1594 .It SEAGATE
1595 Tested with Constellation ES (ST32000444SS), ES.2 (ST33000651SS) and
1596 ES.3 (ST1000NM0023) drives.
1597 .It SmrtStor
1598 Tested with 400GB Optimus SSDs (TXA2D20400GA6001).
1599 .El
1600 .Pp
1601 .Em WARNING! WARNING! WARNING!
1602 .Pp
1603 Little testing has been done to make sure that different device models from
1604 each vendor work correctly with the fwdownload command.
1605 A vendor name appearing in the supported list means only that firmware of at
1606 least one device type from that vendor has successfully been programmed with
1607 the fwdownload command.
1608 Extra caution should be taken when using this command since there is no
1609 guarantee it will not break a device from the listed vendors.
1610 Ensure that you have a recent backup of the data on the device before
1611 performing a firmware update.
1612 .Pp
1613 Note that unknown
1614 .Tn SCSI
1615 protocol devices will not be programmed, since there is little chance of
1616 the firmware download succeeding.
1617 .Pp
1618 .Nm
1619 will currently attempt a firmware download to any
1620 .Tn ATA
1621 or
1622 .Tn SATA
1623 device, since the standard 
1624 .Tn ATA
1625 DOWNLOAD MICROCODE command may work.
1626 Firmware downloads to
1627 .Tn ATA
1628 and 
1629 .Tn SATA
1630 devices are supported for devices connected
1631 to standard
1632 .Tn ATA
1633 and
1634 .Tn SATA
1635 controllers, and devices connected to SAS controllers
1636 with
1637 .Tn SCSI 
1638 to
1639 .Tn ATA
1640 translation capability.
1641 In the latter case,
1642 .Nm
1643 uses the
1644 .Tn SCSI
1645 .Tn ATA
1646 PASS-THROUGH command to send the 
1647 .Tn ATA
1648 DOWNLOAD MICROCODE command to the drive.
1649 Some
1650 .Tn SCSI
1651 to
1652 .Tn ATA
1653 translation implementations don't work fully when translating
1654 .Tn SCSI
1655 WRITE BUFFER commands to
1656 .Tn ATA
1657 DOWNLOAD MICROCODE commands, but do support
1658 .Tn ATA
1659 passthrough well enough to do a firmware download.
1660 .Bl -tag -width 11n
1661 .It Fl f Ar fw_image
1662 Path to the firmware image file to be downloaded to the specified device.
1663 .It Fl q
1664 Do not print informational messages, only print errors.
1665 This option should be used with the
1666 .Fl y
1667 option to suppress all output.
1668 .It Fl s
1669 Run in simulation mode.
1670 Device checks are run and the confirmation dialog is shown, but no firmware
1671 download will occur.
1672 .It Fl v
1673 Show
1674 .Tn SCSI
1675 or
1676 .Tn ATA
1677 errors in the event of a failure.
1678 .Pp
1679 In simulation mode, print out the
1680 .Tn SCSI
1681 CDB
1682 or
1683 .Tn ATA
1684 register values that would be used for the firmware download command.
1685 .It Fl y
1686 Do not ask for confirmation.
1687 .El
1688 .It Ic persist
1689 Persistent reservation support.
1690 Persistent reservations are a way to reserve a particular
1691 .Tn SCSI
1692 LUN for use by one or more
1693 .Tn SCSI
1694 initiators.
1695 If the
1696 .Fl i
1697 option is specified,
1698 .Nm
1699 will issue the
1700 .Tn SCSI
1701 PERSISTENT RESERVE IN
1702 command using the requested service action.
1703 If the
1704 .Fl o
1705 option is specified,
1706 .Nm
1707 will issue the
1708 .Tn SCSI
1709 PERSISTENT RESERVE OUT
1710 command using the requested service action.
1711 One of those two options is required.
1712 .Pp
1713 Persistent reservations are complex, and fully explaining them is outside
1714 the scope of this manual.
1715 Please visit
1716 http://www.t10.org
1717 and download the latest SPC spec for a full explanation of persistent
1718 reservations.
1719 .Bl -tag -width 8n
1720 .It Fl i Ar mode
1721 Specify the service action for the PERSISTENT RESERVE IN command.
1722 Supported service actions:
1723 .Bl -tag -width 19n
1724 .It read_keys
1725 Report the current persistent reservation generation (PRgeneration) and any
1726 registered keys.
1727 .It read_reservation
1728 Report the persistent reservation, if any.
1729 .It report_capabilities
1730 Report the persistent reservation capabilities of the LUN.
1731 .It read_full_status
1732 Report the full status of persistent reservations on the LUN.
1733 .El
1734 .It Fl o Ar mode
1735 Specify the service action for the PERSISTENT RESERVE OUT command.
1736 For service actions like register that are components of other service
1737 action names, the entire name must be specified.
1738 Otherwise, enough of the service action name must be specified to
1739 distinguish it from other possible service actions.
1740 Supported service actions:
1741 .Bl -tag -width 15n
1742 .It register
1743 Register a reservation key with the LUN or unregister a reservation key.
1744 To register a key, specify the requested key as the Service Action
1745 Reservation Key.
1746 To unregister a key, specify the previously registered key as the
1747 Reservation Key.
1748 To change a key, specify the old key as the Reservation Key and the new
1749 key as the Service Action Reservation Key.
1750 .It register_ignore
1751 This is similar to the register subcommand, except that the Reservation Key
1752 is ignored.
1753 The Service Action Reservation Key will overwrite any previous key
1754 registered for the initiator.
1755 .It reserve
1756 Create a reservation.
1757 A key must be registered with the LUN before the LUN can be reserved, and
1758 it must be specified as the Reservation Key.
1759 The type of reservation must also be specified.
1760 The scope defaults to LUN scope (LU_SCOPE), but may be changed.
1761 .It release
1762 Release a reservation.
1763 The Reservation Key must be specified.
1764 .It clear
1765 Release a reservation and remove all keys from the device.
1766 The Reservation Key must be specified.
1767 .It preempt
1768 Remove a reservation belonging to another initiator.
1769 The Reservation Key must be specified.
1770 The Service Action Reservation Key may be specified, depending on the
1771 operation being performed.
1772 .It preempt_abort
1773 Remove a reservation belonging to another initiator and abort all
1774 outstanding commands from that initiator.
1775 The Reservation Key must be specified.
1776 The Service Action Reservation Key may be specified, depending on the
1777 operation being performed.
1778 .It register_move
1779 Register another initiator with the LUN, and establish a reservation on the
1780 LUN for that initiator.
1781 The Reservation Key and Service Action Reservation Key must be specified.
1782 .It replace_lost
1783 Replace Lost Reservation information.
1784 .El
1785 .It Fl a
1786 Set the All Target Ports (ALL_TG_PT) bit.
1787 This requests that the key registration be applied to all target ports and
1788 not just the particular target port that receives the command.
1789 This only applies to the register and register_ignore actions.
1790 .It Fl I Ar tid
1791 Specify a Transport ID.
1792 This only applies to the Register and Register and Move service actions for
1793 Persistent Reserve Out.
1794 Multiple Transport IDs may be specified with multiple
1795 .Fl I
1796 arguments.
1797 With the Register service action, specifying one or more Transport IDs
1798 implicitly enables the
1799 .Fl S
1800 option which turns on the SPEC_I_PT bit.
1801 Transport IDs generally have the format protocol,id.
1802 .Bl -tag -width 5n
1803 .It SAS
1804 A SAS Transport ID consists of
1805 .Dq sas,
1806 followed by a 64-bit SAS address.
1807 For example:
1808 .Pp
1809 .Dl sas,0x1234567812345678
1810 .It FC
1811 A Fibre Channel Transport ID consists of
1812 .Dq fcp,
1813 followed by a 64-bit Fibre Channel World Wide Name. 
1814 For example:
1815 .Pp
1816 .Dl fcp,0x1234567812345678
1817 .It SPI
1818 A Parallel SCSI address consists of
1819 .Dq spi,
1820 followed by a SCSI target ID and a relative target port identifier.
1821 For example:
1822 .Pp
1823 .Dl spi,4,1
1824 .It 1394
1825 An IEEE 1394 (Firewire) Transport ID consists of
1826 .Dq sbp,
1827 followed by a 64-bit EUI-64 IEEE 1394 node unique identifier.
1828 For example:
1829 .Pp
1830 .Dl sbp,0x1234567812345678
1831 .It RDMA
1832 A SCSI over RDMA Transport ID consists of
1833 .Dq srp,
1834 followed by a 128-bit RDMA initiator port identifier.
1835 The port identifier must be exactly 32 or 34 (if the leading 0x is
1836 included) hexadecimal digits.
1837 Only hexadecimal (base 16) numbers are supported.
1838 For example:
1839 .Pp
1840 .Dl srp,0x12345678123456781234567812345678
1841 .It iSCSI
1842 An iSCSI Transport ID consists an iSCSI name and optionally a separator and
1843 iSCSI session ID.
1844 For example, if only the iSCSI name is specified:
1845 .Pp
1846 .Dl iqn.2012-06.com.example:target0
1847 .Pp
1848 If the iSCSI separator and initiator session ID are specified:
1849 .Pp
1850 .Dl iqn.2012-06.com.example:target0,i,0x123
1851 .It PCIe
1852 A SCSI over PCIe Transport ID consists of
1853 .Dq sop,
1854 followed by a PCIe Routing ID.
1855 The Routing ID consists of a bus, device and function or in the alternate
1856 form, a bus and function.
1857 The bus must be in the range of 0 to 255 inclusive and the device must be
1858 in the range of 0 to 31 inclusive.
1859 The function must be in the range of 0 to 7 inclusive if the standard form
1860 is used, and in the range of 0 to 255 inclusive if the alternate form is
1861 used.
1862 For example, if a bus, device and function are specified for the standard
1863 Routing ID form:
1864 .Pp
1865 .Dl sop,4,5,1
1866 .Pp
1867 If the alternate Routing ID form is used:
1868 .Pp
1869 .Dl sop,4,1
1870 .El
1871 .It Fl k Ar key
1872 Specify the Reservation Key.
1873 This may be in decimal, octal or hexadecimal format.
1874 The value is zero by default if not otherwise specified.
1875 The value must be between 0 and 2^64 - 1, inclusive.
1876 .It Fl K Ar key
1877 Specify the Service Action Reservation Key.
1878 This may be in decimal, octal or hexadecimal format.
1879 The value is zero by default if not otherwise specified.
1880 The value must be between 0 and 2^64 - 1, inclusive.
1881 .It Fl p
1882 Enable the Activate Persist Through Power Loss bit.
1883 This is only used for the register and register_ignore actions.
1884 This requests that the reservation persist across power loss events.
1885 .It Fl s Ar scope
1886 Specify the scope of the reservation.
1887 The scope may be specified by name or by number.
1888 The scope is ignored for register, register_ignore and clear.
1889 If the desired scope isn't available by name, you may specify the number.
1890 .Bl -tag -width 7n
1891 .It lun
1892 LUN scope (0x00).
1893 This encompasses the entire LUN.
1894 .It extent
1895 Extent scope (0x01).
1896 .It element
1897 Element scope (0x02).
1898 .El
1899 .It Fl R Ar rtp
1900 Specify the Relative Target Port.
1901 This only applies to the Register and Move service action of the Persistent
1902 Reserve Out command.
1903 .It Fl S
1904 Enable the SPEC_I_PT bit.
1905 This only applies to the Register service action of Persistent Reserve Out.
1906 You must also specify at least one Transport ID with
1907 .Fl I
1908 if this option is set.
1909 If you specify a Transport ID, this option is automatically set.
1910 It is an error to specify this option for any service action other than
1911 Register.
1912 .It Fl T Ar type
1913 Specify the reservation type.
1914 The reservation type may be specified by name or by number.
1915 If the desired reservation type isn't available by name, you may specify
1916 the number.
1917 Supported reservation type names:
1918 .Bl -tag -width 11n
1919 .It read_shared
1920 Read Shared mode.
1921 .It wr_ex
1922 Write Exclusive mode.
1923 May also be specified as
1924 .Dq write_exclusive .
1925 .It rd_ex
1926 Read Exclusive mode.
1927 May also be specified as
1928 .Dq read_exclusive .
1929 .It ex_ac
1930 Exclusive access mode.
1931 May also be specified as
1932 .Dq exclusive_access .
1933 .It wr_ex_ro
1934 Write Exclusive Registrants Only mode.
1935 May also be specified as 
1936 .Dq write_exclusive_reg_only .
1937 .It ex_ac_ro
1938 Exclusive Access Registrants Only mode.
1939 May also be specified as 
1940 .Dq exclusive_access_reg_only .
1941 .It wr_ex_ar
1942 Write Exclusive All Registrants mode.
1943 May also be specified as
1944 .Dq write_exclusive_all_regs .
1945 .It ex_ac_ar
1946 Exclusive Access All Registrants mode.
1947 May also be specified as 
1948 .Dq exclusive_access_all_regs .
1949 .El
1950 .It Fl U
1951 Specify that the target should unregister the initiator that sent
1952 the Register and Move request.
1953 By default, the target will not unregister the initiator that sends the
1954 Register and Move request.
1955 This option only applies to the Register and Move service action of the
1956 Persistent Reserve Out command.
1957 .El
1958 .It Ic attrib
1959 Issue the
1960 .Tn SCSI
1961 READ or WRITE ATTRIBUTE commands.
1962 These commands are used to read and write attributes in Medium Auxiliary
1963 Memory (MAM).
1964 The most common place Medium Auxiliary Memory is found is small flash chips
1965 included tape cartriges.
1966 For instance,
1967 .Tn LTO
1968 tapes have MAM.
1969 Either the
1970 .Fl r 
1971 option or the
1972 .Fl w 
1973 option must be specified.
1974 .Bl -tag -width 14n
1975 .It Fl r Ar action
1976 Specify the READ ATTRIBUTE service action.
1977 .Bl -tag -width 11n
1978 .It attr_values
1979 Issue the ATTRIBUTE VALUES service action.
1980 Read and decode the available attributes and their values.
1981 .It attr_list
1982 Issue the ATTRIBUTE LIST service action.
1983 List the attributes that are available to read and write.
1984 .It lv_list
1985 Issue the LOGICAL VOLUME LIST service action.
1986 List the available logical volumes in the MAM.
1987 .It part_list
1988 Issue the PARTITION LIST service action.
1989 List the available partitions in the MAM.
1990 .It supp_attr
1991 Issue the SUPPORTED ATTRIBUTES service action.
1992 List attributes that are supported for reading or writing.
1993 These attributes may or may not be currently present in the MAM.
1994 .El
1995 .It Fl w Ar attr
1996 Specify an attribute to write to the MAM.
1997 This option is not yet implemented.
1998 .It Fl a Ar num
1999 Specify the attribute number to display.
2000 This option only works with the attr_values, attr_list and supp_attr
2001 arguments to 
2002 .Fl r .
2003 .It Fl c
2004 Display cached attributes.
2005 If the device supports this flag, it allows displaying attributes for the
2006 last piece of media loaded in the drive.
2007 .It Fl e Ar num
2008 Specify the element address.
2009 This is used for specifying which element number in a medium changer to
2010 access when reading attributes.
2011 The element number could be for a picker, portal, slot or drive.
2012 .It Fl F Ar form1,form2
2013 Specify the output format for the attribute values (attr_val) display as a
2014 comma separated list of options.
2015 The default output is currently set to field_all,nonascii_trim,text_raw.
2016 Once this code is ported to FreeBSD 10, any text fields will be converted
2017 from their codeset to the user's native codeset with 
2018 .Xr iconv 3 .
2019 .Pp
2020 The text options are mutually exclusive; if you specify more than one, you
2021 will get unpredictable results.
2022 The nonascii options are also mutually exclusive.
2023 Most of the field options may be logically ORed together.
2024 .Bl -tag -width 12n
2025 .It text_esc
2026 Print text fields with non-ASCII characters escaped.
2027 .It text_raw
2028 Print text fields natively, with no codeset conversion.
2029 .It nonascii_esc
2030 If any non-ASCII characters occur in fields that are supposed to be ASCII,
2031 escape the non-ASCII characters.
2032 .It nonascii_trim
2033 If any non-ASCII characters occur in fields that are supposed to be ASCII,
2034 omit the non-ASCII characters.
2035 .It nonascii_raw
2036 If any non-ASCII characters occur in fields that are supposed to be ASCII,
2037 print them as they are.
2038 .It field_all
2039 Print all of the prefix fields: description, attribute number, attribute
2040 size, and the attribute's readonly status.
2041 If field_all is specified, specifying any other field options will not have
2042 an effect.
2043 .It field_none
2044 Print none of the prefix fields, and only print out the attribute value.
2045 If field_none is specified, specifying any other field options will result
2046 in those fields being printed.
2047 .It field_desc
2048 Print out the attribute description.
2049 .It field_num
2050 Print out the attribute number.
2051 .It field_size
2052 Print out the attribute size.
2053 .It field_rw
2054 Print out the attribute's readonly status.
2055 .El
2056 .It Fl p Ar part
2057 Specify the partition.
2058 When the media has multiple partitions, specifying different partition
2059 numbers allows seeing the values for each individual partition.
2060 .It Fl s Ar start_num
2061 Specify the starting attribute number.
2062 This requests that the target device return attribute information starting
2063 at the given number.
2064 .It Fl T Ar elem_type
2065 Specify the element type.
2066 For medium changer devices, this allows specifying the type the element
2067 referenced in the element address (
2068 .Fl e ) .
2069 Valid types are:
2070 .Dq all ,
2071 .Dq picker ,
2072 .Dq slot ,
2073 .Dq portal ,
2074 and
2075 .Dq drive .
2076 .El
2077 .It Fl V Ar vol_num
2078 Specify the number of the logical volume to operate on.
2079 If the media has multiple logical volumes, this will allow displaying
2080 or writing attributes on the given logical volume.
2081 .It Ic opcodes
2082 Issue the REPORT SUPPORTED OPCODES service action of the
2083 .Tn SCSI
2084 MAINTENANCE IN
2085 command.
2086 Without arguments, this command will return a list of all
2087 .Tn SCSI
2088 commands supported by the device, including service actions of commands
2089 that support service actions.
2090 It will also include the
2091 .Tn SCSI
2092 CDB (Command Data Block) length for each command, and the description of
2093 each command if it is known.
2094 .Bl -tag -width 18n
2095 .It Fl o Ar opcode
2096 Request information on a specific opcode instead of the list of supported
2097 commands.
2098 If supported, the target will return a CDB-like structure that indicates
2099 the opcode, service action (if any), and a mask of bits that are supported
2100 in that CDB.
2101 .It Fl s Ar service_action
2102 For commands that support a service action, specify the service action to
2103 query.
2104 .It Fl N
2105 If a service action is specified for a given opcode, and the device does
2106 not support the given service action, the device should not return a
2107 .Tn SCSI
2108 error, but rather indicate in the returned parameter data that the command
2109 is not supported.
2110 By default, if a service action is specified for an opcode, and service
2111 actions are not supported for the opcode in question, the device will
2112 return an error.
2113 .It Fl T
2114 Include timeout values.
2115 This option works with the default display, which includes all commands
2116 supported by the device, and with the
2117 .Fl o
2118 and
2119 .Fl s
2120 options, which request information on a specific command and service
2121 action.
2122 This requests that the device report Nominal and Recommended timeout values
2123 for the given command or commands.
2124 The timeout values are in seconds.
2125 The timeout descriptor also includes a command-specific 
2126 .El
2127 .It Ic help
2128 Print out verbose usage information.
2129 .El
2130 .Sh ENVIRONMENT
2131 The
2132 .Ev SCSI_MODES
2133 variable allows the user to specify an alternate mode page format file.
2134 .Pp
2135 The
2136 .Ev EDITOR
2137 variable determines which text editor
2138 .Nm
2139 starts when editing mode pages.
2140 .Sh FILES
2141 .Bl -tag -width /usr/share/misc/scsi_modes -compact
2142 .It Pa /usr/share/misc/scsi_modes
2143 is the SCSI mode format database.
2144 .It Pa /dev/xpt0
2145 is the transport layer device.
2146 .It Pa /dev/pass*
2147 are the CAM application passthrough devices.
2148 .El
2149 .Sh EXAMPLES
2150 .Dl camcontrol eject -n cd -u 1 -v
2151 .Pp
2152 Eject the CD from cd1, and print SCSI sense information if the command
2153 fails.
2154 .Pp
2155 .Dl camcontrol tur da0
2156 .Pp
2157 Send the SCSI test unit ready command to da0.
2158 The
2159 .Nm
2160 utility will report whether the disk is ready, but will not display sense
2161 information if the command fails since the
2162 .Fl v
2163 switch was not specified.
2164 .Bd -literal -offset indent
2165 camcontrol tur da1 -E -C 4 -t 50 -Q head -v
2166 .Ed
2167 .Pp
2168 Send a test unit ready command to da1.
2169 Enable kernel error recovery.
2170 Specify a retry count of 4, and a timeout of 50 seconds.
2171 Enable sense
2172 printing (with the
2173 .Fl v
2174 flag) if the command fails.
2175 Since error recovery is turned on, the
2176 disk will be spun up if it is not currently spinning.
2177 The
2178 .Tn SCSI
2179 task attribute for the command will be set to Head of Queue.
2180 The
2181 .Nm
2182 utility will report whether the disk is ready.
2183 .Bd -literal -offset indent
2184 camcontrol cmd -n cd -u 1 -v -c "3C 00 00 00 00 00 00 00 0e 00" \e
2185         -i 0xe "s1 i3 i1 i1 i1 i1 i1 i1 i1 i1 i1 i1"
2186 .Ed
2187 .Pp
2188 Issue a READ BUFFER command (0x3C) to cd1.
2189 Display the buffer size of cd1,
2190 and display the first 10 bytes from the cache on cd1.
2191 Display SCSI sense
2192 information if the command fails.
2193 .Bd -literal -offset indent
2194 camcontrol cmd -n cd -u 1 -v -c "3B 00 00 00 00 00 00 00 0e 00" \e
2195         -o 14 "00 00 00 00 1 2 3 4 5 6 v v v v" 7 8 9 8
2196 .Ed
2197 .Pp
2198 Issue a WRITE BUFFER (0x3B) command to cd1.
2199 Write out 10 bytes of data,
2200 not including the (reserved) 4 byte header.
2201 Print out sense information if
2202 the command fails.
2203 Be very careful with this command, improper use may
2204 cause data corruption.
2205 .Bd -literal -offset indent
2206 camcontrol modepage da3 -m 1 -e -P 3
2207 .Ed
2208 .Pp
2209 Edit mode page 1 (the Read-Write Error Recover page) for da3, and save the
2210 settings on the drive.
2211 Mode page 1 contains a disk drive's auto read and
2212 write reallocation settings, among other things.
2213 .Pp
2214 .Dl camcontrol rescan all
2215 .Pp
2216 Rescan all SCSI busses in the system for devices that have been added,
2217 removed or changed.
2218 .Pp
2219 .Dl camcontrol rescan 0
2220 .Pp
2221 Rescan SCSI bus 0 for devices that have been added, removed or changed.
2222 .Pp
2223 .Dl camcontrol rescan 0:1:0
2224 .Pp
2225 Rescan SCSI bus 0, target 1, lun 0 to see if it has been added, removed, or
2226 changed.
2227 .Pp
2228 .Dl camcontrol tags da5 -N 24
2229 .Pp
2230 Set the number of concurrent transactions for da5 to 24.
2231 .Bd -literal -offset indent
2232 camcontrol negotiate -n da -u 4 -T disable
2233 .Ed
2234 .Pp
2235 Disable tagged queueing for da4.
2236 .Bd -literal -offset indent
2237 camcontrol negotiate -n da -u 3 -R 20.000 -O 15 -a
2238 .Ed
2239 .Pp
2240 Negotiate a sync rate of 20MHz and an offset of 15 with da3.
2241 Then send a
2242 Test Unit Ready command to make the settings take effect.
2243 .Bd -literal -offset indent
2244 camcontrol smpcmd ses0 -v -r 4 "40 0 00 0" -R 1020 "s9 i1"
2245 .Ed
2246 .Pp
2247 Send the SMP REPORT GENERAL command to ses0, and display the number of PHYs
2248 it contains.
2249 Display SMP errors if the command fails.
2250 .Bd -literal -offset indent
2251 camcontrol security ada0
2252 .Ed
2253 .Pp
2254 Report security support and settings for ada0
2255 .Bd -literal -offset indent
2256 camcontrol security ada0 -U user -s MyPass
2257 .Ed
2258 .Pp
2259 Enable security on device ada0 with the password MyPass
2260 .Bd -literal -offset indent
2261 camcontrol security ada0 -U user -e MyPass
2262 .Ed
2263 .Pp
2264 Secure erase ada0 which has had security enabled with user password MyPass
2265 .Pp
2266 .Em WARNING! WARNING! WARNING!
2267 .Pp
2268 This will
2269 .Em ERASE ALL
2270 data from the device, so backup your data before using!
2271 .Pp
2272 This command can be used against an SSD drive to restoring it to
2273 factory default write performance.
2274 .Bd -literal -offset indent
2275 camcontrol hpa ada0
2276 .Ed
2277 .Pp
2278 Report HPA support and settings for ada0 (also reported via
2279 identify).
2280 .Bd -literal -offset indent
2281 camcontrol hpa ada0 -s 10240
2282 .Ed
2283 .Pp
2284 Enables HPA on ada0 setting the maximum reported sectors to 10240.
2285 .Pp
2286 .Em WARNING! WARNING! WARNING!
2287 .Pp
2288 This will
2289 .Em PREVENT ACCESS
2290 to all data on the device beyond this limit until HPA is disabled by setting
2291 HPA to native max sectors of the device, which can only be done after a
2292 power-on or hardware reset!
2293 .Pp
2294 .Em DO NOT
2295 use this on a device which has an active filesystem!
2296 .Pp
2297 .Bd -literal -offset indent
2298 camcontrol persist da0 -v -i read_keys
2299 .Ed
2300 .Pp
2301 This will read any persistent reservation keys registered with da0, and
2302 display any errors encountered when sending the PERSISTENT RESERVE IN
2303 .Tn SCSI 
2304 command.
2305 .Bd -literal -offset indent
2306 camcontrol persist da0 -v -o register -a -K 0x12345678
2307 .Ed
2308 .Pp
2309 This will register the persistent reservation key 0x12345678 with da0,
2310 apply that registration to all ports on da0, and display any errors that
2311 occur when sending the PERSISTENT RESERVE OUT command.
2312 .Bd -literal -offset indent
2313 camcontrol persist da0 -v -o reserve -s lun -k 0x12345678 -T ex_ac
2314 .Ed
2315 .Pp
2316 This will reserve da0 for the exlusive use of the initiator issuing the
2317 command.
2318 The scope of the reservation is the entire LUN.
2319 Any errors sending the PERSISTENT RESERVE OUT command will be displayed.
2320 .Bd -literal -offset indent
2321 camcontrol persist da0 -v -i read_full
2322 .Ed
2323 .Pp
2324 This will display the full status of all reservations on da0 and print out
2325 status if there are any errors.
2326 .Bd -literal -offset indent
2327 camcontrol persist da0 -v -o release -k 0x12345678 -T ex_ac
2328 .Ed
2329 .Pp
2330 This will release a reservation on da0 of the type ex_ac
2331 (Exclusive Access).
2332 The Reservation Key for this registration is 0x12345678.
2333 Any errors that occur will be displayed.
2334 .Bd -literal -offset indent
2335 camcontrol persist da0 -v -o register -K 0x12345678 -S \e
2336         -I sas,0x1234567812345678 -I sas,0x8765432187654321
2337 .Ed
2338 .Pp
2339 This will register the key 0x12345678 with da0, specifying that it applies
2340 to the SAS initiators with SAS addresses 0x1234567812345678 and
2341 0x8765432187654321.
2342 .Bd -literal -offset indent
2343 camcontrol persist da0 -v -o register_move -k 0x87654321 \e
2344         -K 0x12345678 -U -p -R 2 -I fcp,0x1234567812345678
2345 .Ed
2346 .Pp
2347 This will move the registration from the current initiator, whose
2348 Registration Key is 0x87654321, to the Fibre Channel initiator with the 
2349 Fiber Channel World Wide Node Name 0x1234567812345678.
2350 A new registration key, 0x12345678, will be registered for the initiator 
2351 with the Fibre Channel World Wide Node Name 0x1234567812345678, and the
2352 current initiator will be unregistered from the target.
2353 The reservation will be moved to relative target port 2 on the target
2354 device.
2355 The registration will persist across power losses.
2356 .Pp
2357 .Bd -literal -offset indent
2358 camcontrol attrib sa0 -v -i attr_values -p 1
2359 .Ed
2360 .Pp
2361 This will read and decode the attribute values from partition 1 on the tape
2362 in tape drive sa0, and will display any
2363 .Tn SCSI
2364 errors that result.
2365 .Sh SEE ALSO
2366 .Xr cam 3 ,
2367 .Xr cam_cdbparse 3 ,
2368 .Xr cam 4 ,
2369 .Xr pass 4 ,
2370 .Xr xpt 4
2371 .Sh HISTORY
2372 The
2373 .Nm
2374 utility first appeared in
2375 .Fx 3.0 .
2376 .Pp
2377 The mode page editing code and arbitrary SCSI command code are based upon
2378 code in the old
2379 .Xr scsi 8
2380 utility and
2381 .Xr scsi 3
2382 library, written by Julian Elischer and Peter Dufault.
2383 The
2384 .Xr scsi 8
2385 program first appeared in
2386 .Bx 386 0.1.2.4 ,
2387 and first appeared in
2388 .Fx
2389 in
2390 .Fx 2.0.5 .
2391 .Sh AUTHORS
2392 .An Kenneth Merry Aq Mt ken@FreeBSD.org
2393 .Sh BUGS
2394 The code that parses the generic command line arguments does not know that
2395 some of the subcommands take multiple arguments.
2396 So if, for instance, you
2397 tried something like this:
2398 .Bd -literal -offset indent
2399 camcontrol cmd -n da -u 1 -c "00 00 00 00 00 v" 0x00 -v
2400 .Ed
2401 .Pp
2402 The sense information from the test unit ready command would not get
2403 printed out, since the first
2404 .Xr getopt 3
2405 call in
2406 .Nm
2407 bails out when it sees the second argument to
2408 .Fl c
2409 (0x00),
2410 above.
2411 Fixing this behavior would take some gross code, or changes to the
2412 .Xr getopt 3
2413 interface.
2414 The best way to circumvent this problem is to always make sure
2415 to specify generic
2416 .Nm
2417 arguments before any command-specific arguments.