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