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