xref: /freebsd/sbin/camcontrol/camcontrol.8 (revision d184218c18d067f8fd47203f54ab02a7b2ed9b11)
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 June 4, 2012
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 v
45.Nm
46.Ic periphlist
47.Op device id
48.Op Fl n Ar dev_name
49.Op Fl u Ar unit_number
50.Nm
51.Ic tur
52.Op device id
53.Op generic args
54.Nm
55.Ic inquiry
56.Op device id
57.Op generic args
58.Op Fl D
59.Op Fl S
60.Op Fl R
61.Nm
62.Ic identify
63.Op device id
64.Op generic args
65.Op Fl v
66.Nm
67.Ic reportluns
68.Op device id
69.Op generic args
70.Op Fl c
71.Op Fl l
72.Op Fl r Ar reporttype
73.Nm
74.Ic readcap
75.Op device id
76.Op generic args
77.Op Fl b
78.Op Fl h
79.Op Fl H
80.Op Fl N
81.Op Fl q
82.Op Fl s
83.Nm
84.Ic start
85.Op device id
86.Op generic args
87.Nm
88.Ic stop
89.Op device id
90.Op generic args
91.Nm
92.Ic load
93.Op device id
94.Op generic args
95.Nm
96.Ic eject
97.Op device id
98.Op generic args
99.Nm
100.Ic rescan
101.Aq all | bus Ns Op :target:lun
102.Nm
103.Ic reset
104.Aq all | bus Ns Op :target:lun
105.Nm
106.Ic defects
107.Op device id
108.Op generic args
109.Aq Fl f Ar format
110.Op Fl P
111.Op Fl G
112.Nm
113.Ic modepage
114.Op device id
115.Op generic args
116.Aq Fl m Ar page | Fl l
117.Op Fl P Ar pgctl
118.Op Fl b | Fl e
119.Op Fl d
120.Nm
121.Ic cmd
122.Op device id
123.Op generic args
124.Aq Fl a Ar cmd Op args
125.Aq Fl c Ar cmd Op args
126.Op Fl d
127.Op Fl f
128.Op Fl i Ar len Ar fmt
129.Bk -words
130.Op Fl o Ar len Ar fmt Op args
131.Op Fl r Ar fmt
132.Ek
133.Nm
134.Ic smpcmd
135.Op device id
136.Op generic args
137.Aq Fl r Ar len Ar fmt Op args
138.Aq Fl R Ar len Ar fmt Op args
139.Nm
140.Ic smprg
141.Op device id
142.Op generic args
143.Op Fl l
144.Nm
145.Ic smppc
146.Op device id
147.Op generic args
148.Aq Fl p Ar phy
149.Op Fl l
150.Op Fl o Ar operation
151.Op Fl d Ar name
152.Op Fl m Ar rate
153.Op Fl M Ar rate
154.Op Fl T Ar pp_timeout
155.Op Fl a Ar enable|disable
156.Op Fl A Ar enable|disable
157.Op Fl s Ar enable|disable
158.Op Fl S Ar enable|disable
159.Nm
160.Ic smpphylist
161.Op device id
162.Op generic args
163.Op Fl l
164.Op Fl q
165.Nm
166.Ic smpmaninfo
167.Op device id
168.Op generic args
169.Op Fl l
170.Nm
171.Ic debug
172.Op Fl I
173.Op Fl P
174.Op Fl T
175.Op Fl S
176.Op Fl X
177.Op Fl c
178.Op Fl p
179.Aq all|off|bus Ns Op :target Ns Op :lun
180.Nm
181.Ic tags
182.Op device id
183.Op generic args
184.Op Fl N Ar tags
185.Op Fl q
186.Op Fl v
187.Nm
188.Ic negotiate
189.Op device id
190.Op generic args
191.Op Fl c
192.Op Fl D Ar enable|disable
193.Op Fl M Ar mode
194.Op Fl O Ar offset
195.Op Fl q
196.Op Fl R Ar syncrate
197.Op Fl T Ar enable|disable
198.Op Fl U
199.Op Fl W Ar bus_width
200.Op Fl v
201.Nm
202.Ic format
203.Op device id
204.Op generic args
205.Op Fl q
206.Op Fl r
207.Op Fl w
208.Op Fl y
209.Nm
210.Ic idle
211.Op device id
212.Op generic args
213.Op Fl t Ar time
214.Nm
215.Ic standby
216.Op device id
217.Op generic args
218.Op Fl t Ar time
219.Nm
220.Ic sleep
221.Op device id
222.Op generic args
223.Nm
224.Ic fwdownload
225.Op device id
226.Op generic args
227.Aq Fl f Ar fw_image
228.Op Fl y
229.Op Fl s
230.Nm
231.Ic security
232.Op device id
233.Op generic args
234.Op Fl d Ar pwd
235.Op Fl e Ar pwd
236.Op Fl f
237.Op Fl h Ar pwd
238.Op Fl k Ar pwd
239.Op Fl l Ar high|maximum
240.Op Fl q
241.Op Fl s Ar pwd
242.Op Fl T Ar timeout
243.Op Fl U Ar user|master
244.Op Fl y
245.Nm
246.Ic help
247.Sh DESCRIPTION
248The
249.Nm
250utility is designed to provide a way for users to access and control the
251.Fx
252CAM subsystem.
253.Pp
254The
255.Nm
256utility
257can cause a loss of data and/or system crashes if used improperly.
258Even
259expert users are encouraged to exercise caution when using this command.
260Novice users should stay away from this utility.
261.Pp
262The
263.Nm
264utility has a number of primary functions, many of which support an optional
265device identifier.
266A device identifier can take one of three forms:
267.Bl -tag -width 14n
268.It deviceUNIT
269Specify a device name and unit number combination, like "da5" or "cd3".
270.It bus:target
271Specify a bus number and target id.
272The bus number can be determined from
273the output of
274.Dq camcontrol devlist .
275The lun defaults to 0.
276.It bus:target:lun
277Specify the bus, target and lun for a device.
278(e.g.\& 1:2:0)
279.El
280.Pp
281The device identifier, if it is specified,
282.Em must
283come immediately after the function name, and before any generic or
284function-specific arguments.
285Note that the
286.Fl n
287and
288.Fl u
289arguments described below will override any device name or unit number
290specified beforehand.
291The
292.Fl n
293and
294.Fl u
295arguments will
296.Em not
297override a specified bus:target or bus:target:lun, however.
298.Pp
299Most of the
300.Nm
301primary functions support these generic arguments:
302.Bl -tag -width 14n
303.It Fl C Ar count
304SCSI command retry count.
305In order for this to work, error recovery
306.Pq Fl E
307must be turned on.
308.It Fl E
309Instruct the kernel to perform generic SCSI error recovery for the given
310command.
311This is needed in order for the retry count
312.Pq Fl C
313to be honored.
314Other than retrying commands, the generic error recovery in
315the code will generally attempt to spin up drives that are not spinning.
316It may take some other actions, depending upon the sense code returned from
317the command.
318.It Fl n Ar dev_name
319Specify the device type to operate on, e.g.\& "da", "cd".
320.It Fl t Ar timeout
321SCSI command timeout in seconds.
322This overrides the default timeout for
323any given command.
324.It Fl u Ar unit_number
325Specify the device unit number, e.g.\& "1", "5".
326.It Fl v
327Be verbose, print out sense information for failed SCSI commands.
328.El
329.Pp
330Primary command functions:
331.Bl -tag -width periphlist
332.It Ic devlist
333List all physical devices (logical units) attached to the CAM subsystem.
334This also includes a list of peripheral drivers attached to each device.
335With the
336.Fl v
337argument, SCSI bus number, adapter name and unit numbers are printed as
338well.
339.It Ic periphlist
340List all peripheral drivers attached to a given physical device (logical
341unit).
342.It Ic tur
343Send the SCSI test unit ready (0x00) command to the given device.
344The
345.Nm
346utility will report whether the device is ready or not.
347.It Ic inquiry
348Send a SCSI inquiry command (0x12) to a device.
349By default,
350.Nm
351will print out the standard inquiry data, device serial number, and
352transfer rate information.
353The user can specify that only certain types of
354inquiry data be printed:
355.Bl -tag -width 4n
356.It Fl D
357Get the standard inquiry data.
358.It Fl S
359Print out the serial number.
360If this flag is the only one specified,
361.Nm
362will not print out "Serial Number" before the value returned by the drive.
363This is to aid in script writing.
364.It Fl R
365Print out transfer rate information.
366.El
367.It Ic identify
368Send a ATA identify command (0xec) to a device.
369.It Ic reportluns
370Send the SCSI REPORT LUNS (0xA0) command to the given device.
371By default,
372.Nm
373will print out the list of logical units (LUNs) supported by the target device.
374There are a couple of options to modify the output:
375.Bl -tag -width 14n
376.It Fl c
377Just print out a count of LUNs, not the actual LUN numbers.
378.It Fl l
379Just print out the LUNs, and do not print out the count.
380.It Fl r Ar reporttype
381Specify the type of report to request from the target:
382.Bl -tag -width 012345678
383.It default
384Return the default report.
385This is the
386.Nm
387default.
388Most targets will support this report if they support the REPORT LUNS
389command.
390.It wellknown
391Return only well known LUNs.
392.It all
393Return all available LUNs.
394.El
395.El
396.Pp
397.Nm
398will try to print out LUN numbers in a reasonable format.
399It can understand the peripheral, flat, LUN and extended LUN formats.
400.It Ic readcap
401Send the SCSI READ CAPACITY command to the given device and display
402the results.
403If the device is larger than 2TB, the SCSI READ CAPACITY (16) service
404action will be sent to obtain the full size of the device.
405By default,
406.Nm
407will print out the last logical block of the device, and the blocksize of
408the device in bytes.
409To modify the output format, use the following options:
410.Bl -tag -width 5n
411.It Fl b
412Just print out the blocksize, not the last block or device size.
413This cannot be used with
414.Fl N
415or
416.Fl s .
417.It Fl h
418Print out the device size in human readable (base 2, 1K == 1024) format.
419This implies
420.Fl N
421and cannot be used with
422.Fl q
423or
424.Fl b .
425.It Fl H
426Print out the device size in human readable (base 10, 1K == 1000) format.
427.It Fl N
428Print out the number of blocks in the device instead of the last logical
429block.
430.It Fl q
431Quiet, print out the numbers only (separated by a comma if
432.Fl b
433or
434.Fl s
435are not specified).
436.It Fl s
437Print out the last logical block or the size of the device only, and omit
438the blocksize.
439.El
440.It Ic start
441Send the SCSI Start/Stop Unit (0x1B) command to the given device with the
442start bit set.
443.It Ic stop
444Send the SCSI Start/Stop Unit (0x1B) command to the given device with the
445start bit cleared.
446.It Ic load
447Send the SCSI Start/Stop Unit (0x1B) command to the given device with the
448start bit set and the load/eject bit set.
449.It Ic eject
450Send the SCSI Start/Stop Unit (0x1B) command to the given device with the
451start bit cleared and the load/eject bit set.
452.It Ic rescan
453Tell the kernel to scan all busses in the system (with the
454.Ar all
455argument), the given bus (XPT_SCAN_BUS), or bus:target:lun
456(XPT_SCAN_LUN) for new devices or devices that have gone away.
457The user
458may specify a scan of all busses, a single bus, or a lun.
459Scanning all luns
460on a target is not supported.
461.It Ic reset
462Tell the kernel to reset all busses in the system (with the
463.Ar all
464argument) or the given bus (XPT_RESET_BUS) by issuing a SCSI bus
465reset for that bus, or to reset the given bus:target:lun
466(XPT_RESET_DEV), typically by issuing a BUS DEVICE RESET message after
467connecting to that device.
468Note that this can have a destructive impact
469on the system.
470.It Ic defects
471Send the SCSI READ DEFECT DATA (10) command (0x37) to the given device, and
472print out any combination of: the total number of defects, the primary
473defect list (PLIST), and the grown defect list (GLIST).
474.Bl -tag -width 11n
475.It Fl f Ar format
476The three format options are:
477.Em block ,
478to print out the list as logical blocks,
479.Em bfi ,
480to print out the list in bytes from index format, and
481.Em phys ,
482to print out the list in physical sector format.
483The format argument is
484required.
485Most drives support the physical sector format.
486Some drives
487support the logical block format.
488Many drives, if they do not support the
489requested format, return the data in an alternate format, along with sense
490information indicating that the requested data format is not supported.
491The
492.Nm
493utility
494attempts to detect this, and print out whatever format the drive returns.
495If the drive uses a non-standard sense code to report that it does not
496support the requested format,
497.Nm
498will probably see the error as a failure to complete the request.
499.It Fl G
500Print out the grown defect list.
501This is a list of bad blocks that have
502been remapped since the disk left the factory.
503.It Fl P
504Print out the primary defect list.
505.El
506.Pp
507If neither
508.Fl P
509nor
510.Fl G
511is specified,
512.Nm
513will print out the number of defects given in the READ DEFECT DATA header
514returned from the drive.
515Some drives will report 0 defects if neither the primary or grown defect
516lists are requested.
517.It Ic modepage
518Allows the user to display and optionally edit a SCSI mode page.
519The mode
520page formats are located in
521.Pa /usr/share/misc/scsi_modes .
522This can be overridden by specifying a different file in the
523.Ev SCSI_MODES
524environment variable.
525The
526.Ic modepage
527command takes several arguments:
528.Bl -tag -width 12n
529.It Fl d
530Disable block descriptors for mode sense.
531.It Fl b
532Displays mode page data in binary format.
533.It Fl e
534This flag allows the user to edit values in the mode page.
535The user may
536either edit mode page values with the text editor pointed to by his
537.Ev EDITOR
538environment variable, or supply mode page values via standard input, using
539the same format that
540.Nm
541uses to display mode page values.
542The editor will be invoked if
543.Nm
544detects that standard input is terminal.
545.It Fl l
546Lists all available mode pages.
547.It Fl m Ar mode_page
548This specifies the number of the mode page the user would like to view
549and/or edit.
550This argument is mandatory unless
551.Fl l
552is specified.
553.It Fl P Ar pgctl
554This allows the user to specify the page control field.
555Possible values are:
556.Bl -tag -width xxx -compact
557.It 0
558Current values
559.It 1
560Changeable values
561.It 2
562Default values
563.It 3
564Saved values
565.El
566.El
567.It Ic cmd
568Allows the user to send an arbitrary ATA or SCSI CDB to any device.
569The
570.Ic cmd
571function requires the
572.Fl c
573argument to specify SCSI CDB or the
574.Fl a
575argument to specify ATA Command Block registers values.
576Other arguments are optional, depending on
577the command type.
578The command and data specification syntax is documented
579in
580.Xr cam_cdbparse 3 .
581NOTE: If the CDB specified causes data to be transferred to or from the
582SCSI device in question, you MUST specify either
583.Fl i
584or
585.Fl o .
586.Bl -tag -width 17n
587.It Fl a Ar cmd Op args
588This specifies the content of 12 ATA Command Block registers (command,
589features, lba_low, lba_mid, lba_high, device, lba_low_exp, lba_mid_exp.
590lba_high_exp, features_exp, sector_count, sector_count_exp).
591.It Fl c Ar cmd Op args
592This specifies the SCSI CDB.
593SCSI CDBs may be 6, 10, 12 or 16 bytes.
594.It Fl d
595Specifies DMA protocol to be used for ATA command.
596.It Fl f
597Specifies FPDMA (NCQ) protocol to be used for ATA command.
598.It Fl i Ar len Ar fmt
599This specifies the amount of data to read, and how it should be displayed.
600If the format is
601.Sq - ,
602.Ar len
603bytes of data will be read from the device and written to standard output.
604.It Fl o Ar len Ar fmt Op args
605This specifies the amount of data to be written to a device, and the data
606that is to be written.
607If the format is
608.Sq - ,
609.Ar len
610bytes of data will be read from standard input and written to the device.
611.It Fl r Ar fmt
612This specifies that 11 result ATA Command Block registers should be displayed
613(status, error, lba_low, lba_mid, lba_high, device, lba_low_exp, lba_mid_exp,
614lba_high_exp, sector_count, sector_count_exp), and how.
615If the format is
616.Sq - ,
61711 result registers will be written to standard output in hex.
618.El
619.It Ic smpcmd
620Allows the user to send an arbitrary Serial
621Management Protocol (SMP) command to a device.
622The
623.Ic smpcmd
624function requires the
625.Fl r
626argument to specify the SMP request to be sent, and the
627.Fl R
628argument to specify the format of the SMP response.
629The syntax for the SMP request and response arguments is documented in
630.Xr cam_cdbparse 3 .
631.Pp
632Note that SAS adapters that support SMP passthrough (at least the currently
633known adapters) do not accept CRC bytes from the user in the request and do
634not pass CRC bytes back to the user in the response.
635Therefore users should not include the CRC bytes in the length of the
636request and not expect CRC bytes to be returned in the response.
637.Bl -tag -width 17n
638.It Fl r Ar len Ar fmt Op args
639This specifies the size of the SMP request, without the CRC bytes, and the
640SMP request format.  If the format is
641.Sq - ,
642.Ar len
643bytes of data will be read from standard input and written as the SMP
644request.
645.It Fl R Ar len Ar fmt Op args
646This specifies the size of the buffer allocated for the SMP response, and
647the SMP response format.
648If the format is
649.Sq - ,
650.Ar len
651bytes of data will be allocated for the response and the response will be
652written to standard output.
653.El
654.It Ic smprg
655Allows the user to send the Serial Management Protocol (SMP) Report General
656command to a device.
657.Nm
658will display the data returned by the Report General command.
659If the SMP target supports the long response format, the additional data
660will be requested and displayed automatically.
661.Bl -tag -width 8n
662.It Fl l
663Request the long response format only.
664Not all SMP targets support the long response format.
665This option causes
666.Nm
667to skip sending the initial report general request without the long bit set
668and only issue a report general request with the long bit set.
669.El
670.It Ic smppc
671Allows the user to issue the Serial Management Protocol (SMP) PHY Control
672command to a device.
673This function should be used with some caution, as it can render devices
674inaccessible, and could potentially cause data corruption as well.
675The
676.Fl p
677argument is required to specify the PHY to operate on.
678.Bl -tag -width 17n
679.It Fl p Ar phy
680Specify the PHY to operate on.
681This argument is required.
682.It Fl l
683Request the long request/response format.
684Not all SMP targets support the long response format.
685For the PHY Control command, this currently only affects whether the
686request length is set to a value other than 0.
687.It Fl o Ar operation
688Specify a PHY control operation.
689Only one
690.Fl o
691operation may be specified.
692The operation may be specified numerically (in decimal, hexadecimal, or octal)
693or one of the following operation names may be specified:
694.Bl -tag -width 16n
695.It nop
696No operation.
697It is not necessary to specify this argument.
698.It linkreset
699Send the LINK RESET command to the phy.
700.It hardreset
701Send the HARD RESET command to the phy.
702.It disable
703Send the DISABLE command to the phy.
704Note that the LINK RESET or HARD RESET commands should re-enable the phy.
705.It clearerrlog
706Send the CLEAR ERROR LOG command.
707This clears the error log counters for the specified phy.
708.It clearaffiliation
709Send the CLEAR AFFILIATION command.
710This clears the affiliation from the STP initiator port with the same SAS
711address as the SMP initiator that requests the clear operation.
712.It sataportsel
713Send the TRANSMIT SATA PORT SELECTION SIGNAL command to the phy.
714This will cause a SATA port selector to use the given phy as its active phy
715and make the other phy inactive.
716.It clearitnl
717Send the CLEAR STP I_T NEXUS LOSS command to the PHY.
718.It setdevname
719Send the SET ATTACHED DEVICE NAME command to the PHY.
720This requires the
721.Fl d
722argument to specify the device name.
723.El
724.It Fl d Ar name
725Specify the attached device name.
726This option is needed with the
727.Fl o Ar setdevname
728phy operation.
729The name is a 64-bit number, and can be specified in decimal, hexadecimal
730or octal format.
731.It Fl m Ar rate
732Set the minimum physical link rate for the phy.
733This is a numeric argument.
734Currently known link rates are:
735.Bl -tag -width 5n
736.It 0x0
737Do not change current value.
738.It 0x8
7391.5 Gbps
740.It 0x9
7413 Gbps
742.It 0xa
7436 Gbps
744.El
745.Pp
746Other values may be specified for newer physical link rates.
747.It Fl M Ar rate
748Set the maximum physical link rate for the phy.
749This is a numeric argument.
750See the
751.Fl m
752argument description for known link rate arguments.
753.It Fl T Ar pp_timeout
754Set the partial pathway timeout value, in microseconds.
755See the
756.Tn ANSI
757.Tn SAS
758Protocol Layer (SPL)
759specification for more information on this field.
760.It Fl a Ar enable|disable
761Enable or disable SATA slumber phy power conditions.
762.It Fl A Ar enable|disable
763Enable or disable SATA partial power conditions.
764.It Fl s Ar enable|disable
765Enable or disable SAS slumber phy power conditions.
766.It Fl S Ar enable|disable
767Enable or disable SAS partial phy power conditions.
768.El
769.It Ic smpphylist
770List phys attached to a SAS expander, the address of the end device
771attached to the phy, and the inquiry data for that device and peripheral
772devices attached to that device.
773The inquiry data and peripheral devices are displayed if available.
774.Bl -tag -width 5n
775.It Fl l
776Turn on the long response format for the underlying SMP commands used for
777this command.
778.It Fl q
779Only print out phys that are attached to a device in the CAM EDT (Existing
780Device Table).
781.El
782.It Ic smpmaninfo
783Send the SMP Report Manufacturer Information command to the device and
784display the response.
785.Bl -tag -width 5n
786.It Fl l
787Turn on the long response format for the underlying SMP commands used for
788this command.
789.El
790.It Ic debug
791Turn on CAM debugging printfs in the kernel.
792This requires options CAMDEBUG
793in your kernel config file.
794WARNING: enabling debugging printfs currently
795causes an EXTREME number of kernel printfs.
796You may have difficulty
797turning off the debugging printfs once they start, since the kernel will be
798busy printing messages and unable to service other requests quickly.
799The
800.Ic debug
801function takes a number of arguments:
802.Bl -tag -width 18n
803.It Fl I
804Enable CAM_DEBUG_INFO printfs.
805.It Fl P
806Enable CAM_DEBUG_PERIPH printfs.
807.It Fl T
808Enable CAM_DEBUG_TRACE printfs.
809.It Fl S
810Enable CAM_DEBUG_SUBTRACE printfs.
811.It Fl X
812Enable CAM_DEBUG_XPT printfs.
813.It Fl c
814Enable CAM_DEBUG_CDB printfs.
815This will cause the kernel to print out the
816SCSI CDBs sent to the specified device(s).
817.It Fl p
818Enable CAM_DEBUG_PROBE printfs.
819.It all
820Enable debugging for all devices.
821.It off
822Turn off debugging for all devices
823.It bus Ns Op :target Ns Op :lun
824Turn on debugging for the given bus, target or lun.
825If the lun or target
826and lun are not specified, they are wildcarded.
827(i.e., just specifying a
828bus turns on debugging printfs for all devices on that bus.)
829.El
830.It Ic tags
831Show or set the number of "tagged openings" or simultaneous transactions
832we attempt to queue to a particular device.
833By default, the
834.Ic tags
835command, with no command-specific arguments (i.e., only generic arguments)
836prints out the "soft" maximum number of transactions that can be queued to
837the device in question.
838For more detailed information, use the
839.Fl v
840argument described below.
841.Bl -tag -width 7n
842.It Fl N Ar tags
843Set the number of tags for the given device.
844This must be between the
845minimum and maximum number set in the kernel quirk table.
846The default for
847most devices that support tagged queueing is a minimum of 2 and a maximum
848of 255.
849The minimum and maximum values for a given device may be
850determined by using the
851.Fl v
852switch.
853The meaning of the
854.Fl v
855switch for this
856.Nm
857subcommand is described below.
858.It Fl q
859Be quiet, and do not report the number of tags.
860This is generally used when
861setting the number of tags.
862.It Fl v
863The verbose flag has special functionality for the
864.Em tags
865argument.
866It causes
867.Nm
868to print out the tagged queueing related fields of the XPT_GDEV_TYPE CCB:
869.Bl -tag -width 13n
870.It dev_openings
871This is the amount of capacity for transactions queued to a given device.
872.It dev_active
873This is the number of transactions currently queued to a device.
874.It devq_openings
875This is the kernel queue space for transactions.
876This count usually mirrors
877dev_openings except during error recovery operations when
878the device queue is frozen (device is not allowed to receive
879commands), the number of dev_openings is reduced, or transaction
880replay is occurring.
881.It devq_queued
882This is the number of transactions waiting in the kernel queue for capacity
883on the device.
884This number is usually zero unless error recovery is in
885progress.
886.It held
887The held count is the number of CCBs held by peripheral drivers that have
888either just been completed or are about to be released to the transport
889layer for service by a device.
890Held CCBs reserve capacity on a given
891device.
892.It mintags
893This is the current "hard" minimum number of transactions that can be
894queued to a device at once.
895The
896.Ar dev_openings
897value above cannot go below this number.
898The default value for
899.Ar mintags
900is 2, although it may be set higher or lower for various devices.
901.It maxtags
902This is the "hard" maximum number of transactions that can be queued to a
903device at one time.
904The
905.Ar dev_openings
906value cannot go above this number.
907The default value for
908.Ar maxtags
909is 255, although it may be set higher or lower for various devices.
910.El
911.El
912.It Ic negotiate
913Show or negotiate various communication parameters.
914Some controllers may
915not support setting or changing some of these values.
916For instance, the
917Adaptec 174x controllers do not support changing a device's sync rate or
918offset.
919The
920.Nm
921utility
922will not attempt to set the parameter if the controller indicates that it
923does not support setting the parameter.
924To find out what the controller
925supports, use the
926.Fl v
927flag.
928The meaning of the
929.Fl v
930flag for the
931.Ic negotiate
932command is described below.
933Also, some controller drivers do not support
934setting negotiation parameters, even if the underlying controller supports
935negotiation changes.
936Some controllers, such as the Advansys wide
937controllers, support enabling and disabling synchronous negotiation for
938a device, but do not support setting the synchronous negotiation rate.
939.Bl -tag -width 17n
940.It Fl a
941Attempt to make the negotiation settings take effect immediately by sending
942a Test Unit Ready command to the device.
943.It Fl c
944Show or set current negotiation settings.
945This is the default.
946.It Fl D Ar enable|disable
947Enable or disable disconnection.
948.It Fl M Ar mode
949Set ATA mode.
950.It Fl O Ar offset
951Set the command delay offset.
952.It Fl q
953Be quiet, do not print anything.
954This is generally useful when you want to
955set a parameter, but do not want any status information.
956.It Fl R Ar syncrate
957Change the synchronization rate for a device.
958The sync rate is a floating
959point value specified in MHz.
960So, for instance,
961.Sq 20.000
962is a legal value, as is
963.Sq 20 .
964.It Fl T Ar enable|disable
965Enable or disable tagged queueing for a device.
966.It Fl U
967Show or set user negotiation settings.
968The default is to show or set
969current negotiation settings.
970.It Fl v
971The verbose switch has special meaning for the
972.Ic negotiate
973subcommand.
974It causes
975.Nm
976to print out the contents of a Path Inquiry (XPT_PATH_INQ) CCB sent to the
977controller driver.
978.It Fl W Ar bus_width
979Specify the bus width to negotiate with a device.
980The bus width is
981specified in bits.
982The only useful values to specify are 8, 16, and 32
983bits.
984The controller must support the bus width in question in order for
985the setting to take effect.
986.El
987.Pp
988In general, sync rate and offset settings will not take effect for a
989device until a command has been sent to the device.
990The
991.Fl a
992switch above will automatically send a Test Unit Ready to the device so
993negotiation parameters will take effect.
994.It Ic format
995Issue the
996.Tn SCSI
997FORMAT UNIT command to the named device.
998.Pp
999.Em WARNING! WARNING! WARNING!
1000.Pp
1001Low level formatting a disk will destroy ALL data on the disk.
1002Use
1003extreme caution when issuing this command.
1004Many users low-level format
1005disks that do not really need to be low-level formatted.
1006There are
1007relatively few scenarios that call for low-level formatting a disk.
1008One reason for
1009low-level formatting a disk is to initialize the disk after changing
1010its physical sector size.
1011Another reason for low-level formatting a disk
1012is to revive the disk if you are getting "medium format corrupted" errors
1013from the disk in response to read and write requests.
1014.Pp
1015Some disks take longer than others to format.
1016Users should specify a
1017timeout long enough to allow the format to complete.
1018The default format
1019timeout is 3 hours, which should be long enough for most disks.
1020Some hard
1021disks will complete a format operation in a very short period of time
1022(on the order of 5 minutes or less).
1023This is often because the drive
1024does not really support the FORMAT UNIT command -- it just accepts the
1025command, waits a few minutes and then returns it.
1026.Pp
1027The
1028.Sq format
1029subcommand takes several arguments that modify its default behavior.
1030The
1031.Fl q
1032and
1033.Fl y
1034arguments can be useful for scripts.
1035.Bl -tag -width 6n
1036.It Fl q
1037Be quiet, do not print any status messages.
1038This option will not disable
1039the questions, however.
1040To disable questions, use the
1041.Fl y
1042argument, below.
1043.It Fl r
1044Run in
1045.Dq report only
1046mode.
1047This will report status on a format that is already running on the drive.
1048.It Fl w
1049Issue a non-immediate format command.
1050By default,
1051.Nm
1052issues the FORMAT UNIT command with the immediate bit set.
1053This tells the
1054device to immediately return the format command, before the format has
1055actually completed.
1056Then,
1057.Nm
1058gathers
1059.Tn SCSI
1060sense information from the device every second to determine how far along
1061in the format process it is.
1062If the
1063.Fl w
1064argument is specified,
1065.Nm
1066will issue a non-immediate format command, and will be unable to print any
1067information to let the user know what percentage of the disk has been
1068formatted.
1069.It Fl y
1070Do not ask any questions.
1071By default,
1072.Nm
1073will ask the user if he/she really wants to format the disk in question,
1074and also if the default format command timeout is acceptable.
1075The user
1076will not be asked about the timeout if a timeout is specified on the
1077command line.
1078.El
1079.It Ic idle
1080Put ATA device into IDLE state. Optional parameter
1081.Pq Fl t
1082specifies automatic standby timer value in seconds. Value 0 disables timer.
1083.It Ic standby
1084Put ATA device into STANDBY state. Optional parameter
1085.Pq Fl t
1086specifies automatic standby timer value in seconds. Value 0 disables timer.
1087.It Ic sleep
1088Put ATA device into SLEEP state. Note that the only way get device out of
1089this state may be reset.
1090.It Ic security
1091Update or report security settings, using an ATA identify command (0xec).
1092By default,
1093.Nm
1094will print out the security support and associated settings of the device.
1095The
1096.Ic security
1097command takes several arguments:
1098.Bl -tag -width 0n
1099.It Fl d Ar pwd
1100.Pp
1101Disable device security using the given password for the selected user according
1102to the devices configured security level.
1103.It Fl e Ar pwd
1104.Pp
1105Erase the device using the given password for the selected user.
1106.Pp
1107.Em WARNING! WARNING! WARNING!
1108.Pp
1109Issuing a secure erase will
1110.Em ERASE ALL
1111user data on the device and may take several hours to complete.
1112.Pp
1113When this command is used against an SSD drive all its cells will be marked as
1114empty, restoring it to factory default write performance. For SSD's this action
1115usually takes just a few seconds.
1116.It Fl f
1117.Pp
1118Freeze the security configuration of the specified device.
1119.Pp
1120After command completion any other commands that update the device lock mode
1121shall be command aborted.
1122Frozen mode is disabled by power-off or hardware reset.
1123.It Fl h Ar pwd
1124.Pp
1125Enhanced erase the device using the given password for the selected user.
1126.Pp
1127.Em WARNING! WARNING! WARNING!
1128.Pp
1129Issuing an enhanced secure erase will
1130.Em ERASE ALL
1131user data on the device and may take several hours to complete.
1132.Pp
1133An enhanced erase writes predetermined data patterns to all user data areas,
1134all previously written user data shall be overwritten, including sectors that
1135are no longer in use due to reallocation.
1136.It Fl k Ar pwd
1137.Pp
1138Unlock the device using the given password for the selected user according to
1139the devices configured security level.
1140.It Fl l Ar high|maximum
1141.Pp
1142Specifies which security level to set when issuing a
1143.Fl s Ar pwd
1144command. The security level determines device behavior when the master
1145password is used to unlock the device. When the security level is set to high
1146the device requires the unlock command and the master password to unlock.
1147When the security level is set to maximum the device requires a secure erase
1148with the master password to unlock.
1149.Pp
1150This option must be used in conjunction with one of the security action commands.
1151.Pp
1152Defaults to
1153.Em high
1154.It Fl q
1155.Pp
1156Be quiet, do not print any status messages.
1157This option will not disable the questions, however.
1158To disable questions, use the
1159.Fl y
1160argument, below.
1161.It Fl s Ar pwd
1162.Pp
1163Password the device (enable security) using the given password for the selected
1164user. This option can be combined with other options such as
1165.Fl e Em pwd
1166.Pp
1167A master password may be set in a addition to the user password. The purpose of
1168the master password is to allow an administrator to establish a password that
1169is kept secret from the user, and which may be used to unlock the device if the
1170user password is lost.
1171.Pp
1172.Em Note:
1173Setting the master password does not enable device security.
1174.Pp
1175If the master password is set and the drive supports a Master Revision Code
1176feature the Master Password Revision Code will be decremented.
1177.It Fl T Ar timeout
1178.Pp
1179Overrides the default timeout, specified in seconds, used for both
1180.Fl e
1181and
1182.Fl h
1183this is useful if your system has problems processing long timeouts correctly.
1184.Pp
1185Usually the timeout is calculated from the information stored on the drive if
1186present, otherwise it defaults to 2 hours.
1187.It Fl U Ar user|master
1188.Pp
1189Specifies which user to set / use for the running action command, valid values
1190are user or master and defaults to master if not set.
1191.Pp
1192This option must be used in conjunction with one of the security action commands.
1193.Pp
1194Defaults to
1195.Em master
1196.It Fl y
1197.Pp
1198Confirm yes to dangerous options such as
1199.Fl e
1200without prompting for confirmation.
1201.Pp
1202.El
1203If the password specified for any action commands doesn't match the configured
1204password for the specified user the command will fail.
1205.Pp
1206The password in all cases is limited to 32 characters, longer passwords will
1207fail.
1208.It Ic fwdownload
1209Program firmware of the named SCSI device using the image file provided.
1210.Pp
1211Current list of supported vendors:
1212.Bl -bullet -offset indent -compact
1213.It
1214HITACHI
1215.It
1216HP
1217.It
1218IBM
1219.It
1220PLEXTOR
1221.It
1222QUANTUM
1223.It
1224SEAGATE
1225.El
1226.Pp
1227.Em WARNING! WARNING! WARNING!
1228.Pp
1229Little testing has been done to make sure that different device models from
1230each vendor work correctly with the fwdownload command.
1231A vendor name appearing in the supported list means only that firmware of at
1232least one device type from that vendor has successfully been programmed with
1233the fwdownload command.
1234Extra caution should be taken when using this command since there is no
1235guarantee it will not break a device from the listed vendors.
1236Ensure that you have a recent backup of the data on the device before
1237performing a firmware update.
1238.Bl -tag -width 11n
1239.It Fl f Ar fw_image
1240Path to the firmware image file to be downloaded to the specified device.
1241.It Fl y
1242Do not ask for confirmation.
1243.It Fl s
1244Run in simulation mode.
1245Packet sizes that will be sent are shown, but no actual packet is sent to the
1246device.
1247No confirmation is asked in simulation mode.
1248.It Fl v
1249Besides showing sense information in case of a failure, the verbose option
1250causes
1251.Nm
1252to output a line for every firmware segment that is sent to the device by the
1253fwdownload command
1254-- the same as the ones shown in simulation mode.
1255.El
1256.It Ic help
1257Print out verbose usage information.
1258.El
1259.Sh ENVIRONMENT
1260The
1261.Ev SCSI_MODES
1262variable allows the user to specify an alternate mode page format file.
1263.Pp
1264The
1265.Ev EDITOR
1266variable determines which text editor
1267.Nm
1268starts when editing mode pages.
1269.Sh FILES
1270.Bl -tag -width /usr/share/misc/scsi_modes -compact
1271.It Pa /usr/share/misc/scsi_modes
1272is the SCSI mode format database.
1273.It Pa /dev/xpt0
1274is the transport layer device.
1275.It Pa /dev/pass*
1276are the CAM application passthrough devices.
1277.El
1278.Sh EXAMPLES
1279.Dl camcontrol eject -n cd -u 1 -v
1280.Pp
1281Eject the CD from cd1, and print SCSI sense information if the command
1282fails.
1283.Pp
1284.Dl camcontrol tur da0
1285.Pp
1286Send the SCSI test unit ready command to da0.
1287The
1288.Nm
1289utility will report whether the disk is ready, but will not display sense
1290information if the command fails since the
1291.Fl v
1292switch was not specified.
1293.Bd -literal -offset indent
1294camcontrol tur da1 -E -C 4 -t 50 -v
1295.Ed
1296.Pp
1297Send a test unit ready command to da1.
1298Enable kernel error recovery.
1299Specify a retry count of 4, and a timeout of 50 seconds.
1300Enable sense
1301printing (with the
1302.Fl v
1303flag) if the command fails.
1304Since error recovery is turned on, the
1305disk will be spun up if it is not currently spinning.
1306The
1307.Nm
1308utility will report whether the disk is ready.
1309.Bd -literal -offset indent
1310camcontrol cmd -n cd -u 1 -v -c "3C 00 00 00 00 00 00 00 0e 00" \e
1311	-i 0xe "s1 i3 i1 i1 i1 i1 i1 i1 i1 i1 i1 i1"
1312.Ed
1313.Pp
1314Issue a READ BUFFER command (0x3C) to cd1.
1315Display the buffer size of cd1,
1316and display the first 10 bytes from the cache on cd1.
1317Display SCSI sense
1318information if the command fails.
1319.Bd -literal -offset indent
1320camcontrol cmd -n cd -u 1 -v -c "3B 00 00 00 00 00 00 00 0e 00" \e
1321	-o 14 "00 00 00 00 1 2 3 4 5 6 v v v v" 7 8 9 8
1322.Ed
1323.Pp
1324Issue a WRITE BUFFER (0x3B) command to cd1.
1325Write out 10 bytes of data,
1326not including the (reserved) 4 byte header.
1327Print out sense information if
1328the command fails.
1329Be very careful with this command, improper use may
1330cause data corruption.
1331.Bd -literal -offset indent
1332camcontrol modepage da3 -m 1 -e -P 3
1333.Ed
1334.Pp
1335Edit mode page 1 (the Read-Write Error Recover page) for da3, and save the
1336settings on the drive.
1337Mode page 1 contains a disk drive's auto read and
1338write reallocation settings, among other things.
1339.Pp
1340.Dl camcontrol rescan all
1341.Pp
1342Rescan all SCSI busses in the system for devices that have been added,
1343removed or changed.
1344.Pp
1345.Dl camcontrol rescan 0
1346.Pp
1347Rescan SCSI bus 0 for devices that have been added, removed or changed.
1348.Pp
1349.Dl camcontrol rescan 0:1:0
1350.Pp
1351Rescan SCSI bus 0, target 1, lun 0 to see if it has been added, removed, or
1352changed.
1353.Pp
1354.Dl camcontrol tags da5 -N 24
1355.Pp
1356Set the number of concurrent transactions for da5 to 24.
1357.Bd -literal -offset indent
1358camcontrol negotiate -n da -u 4 -T disable
1359.Ed
1360.Pp
1361Disable tagged queueing for da4.
1362.Bd -literal -offset indent
1363camcontrol negotiate -n da -u 3 -R 20.000 -O 15 -a
1364.Ed
1365.Pp
1366Negotiate a sync rate of 20MHz and an offset of 15 with da3.
1367Then send a
1368Test Unit Ready command to make the settings take effect.
1369.Bd -literal -offset indent
1370camcontrol smpcmd ses0 -v -r 4 "40 0 00 0" -R 1020 "s9 i1"
1371.Ed
1372.Pp
1373Send the SMP REPORT GENERAL command to ses0, and display the number of PHYs
1374it contains.
1375Display SMP errors if the command fails.
1376.Bd -literal -offset indent
1377camcontrol security ada0
1378.Ed
1379.Pp
1380Report security support and settings for ada0
1381.Bd -literal -offset indent
1382camcontrol security ada0 -u user -s MyPass
1383.Ed
1384.Pp
1385Enable security on device ada0 with the password MyPass
1386.Bd -literal -offset indent
1387camcontrol security ada0 -u user -e MyPass
1388.Ed
1389.Pp
1390Secure erase ada0 which has had security enabled with user password MyPass
1391.Pp
1392.Em WARNING! WARNING! WARNING!
1393.Pp
1394This will
1395.Em ERASE ALL
1396data from the device, so backup your data before using!
1397.Pp
1398This command can be used used against an SSD drive to restoring it to
1399factory default write performance.
1400.Sh SEE ALSO
1401.Xr cam 3 ,
1402.Xr cam_cdbparse 3 ,
1403.Xr cam 4 ,
1404.Xr pass 4 ,
1405.Xr xpt 4
1406.Sh HISTORY
1407The
1408.Nm
1409utility first appeared in
1410.Fx 3.0 .
1411.Pp
1412The mode page editing code and arbitrary SCSI command code are based upon
1413code in the old
1414.Xr scsi 8
1415utility and
1416.Xr scsi 3
1417library, written by Julian Elischer and Peter Dufault.
1418The
1419.Xr scsi 8
1420program first appeared in
1421.Bx 386 0.1.2.4 ,
1422and first appeared in
1423.Fx
1424in
1425.Fx 2.0.5 .
1426.Sh AUTHORS
1427.An Kenneth Merry Aq ken@FreeBSD.org
1428.Sh BUGS
1429The code that parses the generic command line arguments does not know that
1430some of the subcommands take multiple arguments.
1431So if, for instance, you
1432tried something like this:
1433.Bd -literal -offset indent
1434camcontrol cmd -n da -u 1 -c "00 00 00 00 00 v" 0x00 -v
1435.Ed
1436.Pp
1437The sense information from the test unit ready command would not get
1438printed out, since the first
1439.Xr getopt 3
1440call in
1441.Nm
1442bails out when it sees the second argument to
1443.Fl c
1444(0x00),
1445above.
1446Fixing this behavior would take some gross code, or changes to the
1447.Xr getopt 3
1448interface.
1449The best way to circumvent this problem is to always make sure
1450to specify generic
1451.Nm
1452arguments before any command-specific arguments.
1453