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