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