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