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