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