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