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