xref: /dragonfly/sbin/camcontrol/camcontrol.8 (revision 82730a9c)
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: src/sbin/camcontrol/camcontrol.8,v 1.19.2.12 2003/01/08 17:55:02 njl Exp $
29.\"
30.Dd September 14, 1998
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 reportluns
63.Op device id
64.Op generic args
65.Op Fl c
66.Op Fl l
67.Op Fl r Ar reporttype
68.Nm
69.Ic readcap
70.Op device id
71.Op generic args
72.Op Fl b
73.Op Fl h
74.Op Fl H
75.Op Fl N
76.Op Fl q
77.Op Fl s
78.Nm
79.Ic start
80.Op device id
81.Op generic args
82.Nm
83.Ic stop
84.Op device id
85.Op generic args
86.Nm
87.Ic load
88.Op device id
89.Op generic args
90.Nm
91.Ic eject
92.Op device id
93.Op generic args
94.Nm
95.Ic rescan
96.Aq all | bus Ns Op :target:lun
97.Nm
98.Ic reset
99.Aq all | bus Ns Op :target:lun
100.Nm
101.Ic defects
102.Op device id
103.Op generic args
104.Aq Fl f Ar format
105.Op Fl P
106.Op Fl G
107.Nm
108.Ic modepage
109.Op device id
110.Op generic args
111.Aq Fl m Ar page
112.Op Fl P Ar pgctl
113.Op Fl e
114.Op Fl d
115.Nm
116.Ic cmd
117.Op device id
118.Op generic args
119.Aq Fl c Ar cmd Op args
120.Op Fl i Ar len Ar fmt
121.Bk -words
122.Op Fl o Ar len Ar fmt Op args
123.Ek
124.Nm
125.Ic debug
126.Op Fl I
127.Op Fl P
128.Op Fl T
129.Op Fl S
130.Op Fl X
131.Op Fl c
132.Aq all|off|bus Ns Op :target Ns Op :lun
133.Nm
134.Ic tags
135.Op device id
136.Op generic args
137.Op Fl N Ar tags
138.Op Fl q
139.Op Fl v
140.Nm
141.Ic negotiate
142.Op device id
143.Op generic args
144.Op Fl c
145.Op Fl D Ar enable|disable
146.Op Fl O Ar offset
147.Op Fl q
148.Op Fl R Ar syncrate
149.Op Fl T Ar enable|disable
150.Op Fl U
151.Op Fl W Ar bus_width
152.Op Fl v
153.Nm
154.Ic format
155.Op device id
156.Op generic args
157.Op Fl q
158.Op Fl r
159.Op Fl w
160.Op Fl y
161.Nm
162.Ic help
163.Sh DESCRIPTION
164The
165.Nm
166utility is designed to provide a way for users to access and control the
167.Dx
168CAM subsystem.
169.Pp
170The
171.Nm
172utility
173can cause a loss of data and/or system crashes if used improperly.  Even
174expert users are encouraged to exercise caution when using this command.
175Novice users should stay away from this utility.
176.Pp
177The
178.Nm
179utility has a number of primary functions, many of which support an optional
180device identifier.  A device identifier can take one of three forms:
181.Bl -tag -width 14n
182.It deviceUNIT
183Specify a device name and unit number combination, like "da5" or "cd3".
184Note that character device node names (e.g. /dev/da0) are
185.Em not
186allowed here.
187.It bus:target
188Specify a bus number and target id.  The bus number can be determined from
189the output of
190.Dq camcontrol devlist .
191The lun defaults to 0.
192.It bus:target:lun
193Specify the bus, target and lun for a device.  (e.g. 1:2:0)
194.El
195.Pp
196The device identifier, if it is specified,
197.Em must
198come immediately after the function name, and before any generic or
199function-specific arguments.  Note that the
200.Fl n
201and
202.Fl u
203arguments described below will override any device name or unit number
204specified beforehand.  The
205.Fl n
206and
207.Fl u
208arguments will
209.Em not
210override a specified bus:target or bus:target:lun, however.
211.Pp
212Most of the
213.Nm
214primary functions support these generic arguments:
215.Bl -tag -width 14n
216.It Fl C Ar count
217SCSI command retry count.  In order for this to work, error recovery
218.Pq Fl E
219must be turned on.
220.It Fl E
221Instruct the kernel to perform generic SCSI error recovery for the given
222command.  This is needed in order for the retry count
223.Pq Fl C
224to be honored.  Other than retrying commands, the generic error recovery in
225the code will generally attempt to spin up drives that are not spinning.
226It may take some other actions, depending upon the sense code returned from
227the command.
228.It Fl n Ar dev_name
229Specify the device type to operate on, e.g. "da", "cd".
230.It Fl t Ar timeout
231SCSI command timeout in seconds.  This overrides the default timeout for
232any given command.
233.It Fl u Ar unit_number
234Specify the device unit number, e.g. "1", "5".
235.It Fl v
236Be verbose, print out sense information for failed SCSI commands.
237.El
238.Pp
239Primary command functions:
240.Bl -tag -width periphlist
241.It Ic devlist
242List all physical devices (logical units) attached to the CAM subsystem.
243This also includes a list of peripheral drivers attached to each device.
244With the
245.Fl v
246argument, SCSI bus number, adapter name and unit numbers are printed as
247well.
248.It Ic periphlist
249List all peripheral drivers attached to a given physical device (logical
250unit).
251.It Ic tur
252Send the SCSI test unit ready (0x00) command to the given device.
253The
254.Nm
255utility will report whether the device is ready or not.
256.It Ic inquiry
257Send a SCSI inquiry command (0x12) to a device.  By default,
258.Nm
259will print out the standard inquiry data, device serial number, and
260transfer rate information.  The user can specify that only certain types of
261inquiry data be printed:
262.Bl -tag -width 4n
263.It Fl D
264Get the standard inquiry data.
265.It Fl S
266Print out the serial number.  If this flag is the only one specified,
267.Nm
268will not print out "Serial Number" before the value returned by the drive.
269This is to aid in script writing.
270.It Fl R
271Print out transfer rate information.
272.El
273.It Ic reportluns
274Send the SCSI REPORT LUNS (0xA0) command to the given device.
275By default,
276.Nm
277will print out the list of logical units (LUNs) supported by the target device.
278There are a couple of options to modify the output:
279.Bl -tag -width 01234567890123
280.It Fl c
281Just print out a count of LUNs, not the actual LUN numbers.
282.It Fl l
283Just print out the LUNs, and don't print out the count.
284.It Fl r Ar reporttype
285Specify the type of report to request from the target:
286.Bl -tag -width 012345678
287.It default
288Return the default report.
289This is the
290.Nm
291default.
292Most targets will support this report if they support the REPORT LUNS
293command.
294.It wellknown
295Return only well known LUNs.
296.It all
297Return all available LUNs.
298.El
299.El
300.Pp
301.Nm
302will try to print out LUN numbers in a reasonable format.
303It can understand the peripheral, flat, LUN and extended LUN formats.
304.It Ic readcap
305Send the SCSI READ CAPACITY command to the given device and display
306the results.
307If the device is larger than 2TB, the SCSI READ CAPACITY (16) service
308action will be sent to obtain the full size of the device.
309By default,
310.Nm
311will print out the last logical block of the device, and the blocksize of
312the device in bytes.
313To modify the output format, use the following options:
314.Bl -tag -width 5n
315.It Fl b
316Just print out the blocksize, not the last block or device size.
317This cannot be used with
318.Fl N
319or
320.Fl s .
321.It Fl h
322Print out the device size in human readable (base 2, 1K == 1024) format.
323This implies
324.Fl N
325and cannot be used with
326.Fl q
327or
328.Fl b .
329.It Fl H
330Print out the device size in human readable (base 10, 1K == 1000) format.
331.It Fl N
332Print out the number of blocks in the device instead of the last logical
333block.
334.It Fl q
335Quiet, print out the numbers only (separated by a comma if
336.Fl b
337or
338.Fl s
339are not specified).
340.It Fl s
341Print out the last logical block or the size of the device only, and omit
342the blocksize.
343.El
344.It Ic start
345Send the SCSI Start/Stop Unit (0x1B) command to the given device with the
346start bit set.
347.It Ic stop
348Send the SCSI Start/Stop Unit (0x1B) command to the given device with the
349start bit cleared.
350.It Ic load
351Send the SCSI Start/Stop Unit (0x1B) command to the given device with the
352start bit set and the load/eject bit set.
353.It Ic eject
354Send the SCSI Start/Stop Unit (0x1B) command to the given device with the
355start bit cleared and the load/eject bit set.
356.It Ic rescan
357Tell the kernel to scan all busses in the system (with the
358.Ar all
359argument), the given bus (XPT_SCAN_BUS), or bus:target:lun
360(XPT_SCAN_LUN) for new devices or devices that have gone away.  The user
361may specify a scan of all busses, a single bus, or a lun.  Scanning all luns
362on a target isn't supported.
363.It Ic reset
364Tell the kernel to reset all busses in the system (with the
365.Ar all
366argument) or the given bus (XPT_RESET_BUS) by issuing a SCSI bus
367reset for that bus, or to reset the given bus:target:lun
368(XPT_RESET_DEV), typically by issuing a BUS DEVICE RESET message after
369connecting to that device.
370Note that this can have a destructive impact
371on the system.
372.It Ic defects
373Send the SCSI READ DEFECT DATA (10) command (0x37) to the given device, and
374print out any combination of: the total number of defects, the primary
375defect list (PLIST), and the grown defect list (GLIST).
376.Bl -tag -width 11n
377.It Fl f Ar format
378The three format options are:
379.Em block ,
380to print out the list as logical blocks,
381.Em bfi ,
382to print out the list in bytes from index format, and
383.Em phys ,
384to print out the list in physical sector format.  The format argument is
385required.  Most drives support the physical sector format.  Some drives
386support the logical block format.  Many drives, if they don't support the
387requested format, return the data in an alternate format, along with sense
388information indicating that the requested data format isn't supported.
389The
390.Nm
391utility
392attempts to detect this, and print out whatever format the drive returns.
393If the drive uses a non-standard sense code to report that it doesn't
394support the requested format,
395.Nm
396will probably see the error as a failure to complete the request.
397.It Fl G
398Print out the grown defect list.  This is a list of bad blocks that have
399been remapped since the disk left the factory.
400.It Fl P
401Print out the primary defect list.
402.El
403.Pp
404If neither
405.Fl P
406nor
407.Fl G
408is specified,
409.Nm
410will print out the number of defects given in the READ DEFECT DATA header
411returned from the drive.
412.It Ic modepage
413Allows the user to display and optionally edit a SCSI mode page.  The mode
414page formats are located in
415.Pa /usr/share/misc/scsi_modes .
416This can be overridden by specifying a different file in the
417.Ev SCSI_MODES
418environment variable.
419The
420.Ic modepage
421command takes several arguments:
422.Bl -tag -width 12n
423.It Fl d
424Disable block descriptors for mode sense.
425.It Fl e
426This flag allows the user to edit values in the mode page.
427.It Fl m Ar mode_page
428This specifies the number of the mode page the user would like to view
429and/or edit.  This argument is mandatory.
430.It Fl P Ar pgctl
431This allows the user to specify the page control field.  Possible values are:
432.Bl -tag -width xxx -compact
433.It 0
434Current values
435.It 1
436Changeable values
437.It 2
438Default values
439.It 3
440Saved values
441.El
442.El
443.It Ic cmd
444Allows the user to send an arbitrary SCSI CDB to any device.
445The
446.Ic cmd
447function requires the
448.Fl c
449argument to specify the CDB.  Other arguments are optional, depending on
450the command type.  The command and data specification syntax is documented
451in
452.Xr cam_cdbparse 3 .
453NOTE:  If the CDB specified causes data to be transferred to or from the
454SCSI device in question, you MUST specify either
455.Fl i
456or
457.Fl o .
458.Bl -tag -width 17n
459.It Fl c Ar cmd Op args
460This specifies the SCSI CDB.  CDBs may be 6, 10, 12 or 16 bytes.
461.It Fl i Ar len Ar fmt
462This specifies the amount of data to read, and how it should be displayed.
463If the format is
464.Sq - ,
465.Ar len
466bytes of data will be read from the device and written to standard output.
467.It Fl o Ar len Ar fmt Op args
468This specifies the amount of data to be written to a device, and the data
469that is to be written.  If the format is
470.Sq - ,
471.Ar len
472bytes of data will be read from standard input and written to the device.
473.El
474.It Ic debug
475Turn on CAM debugging printfs in the kernel.  This requires
476.Cd options CAMDEBUG
477in your kernel config file.  WARNING:  enabling debugging printfs currently
478causes an EXTREME number of kernel printfs.  You may have difficulty
479turning off the debugging printfs once they start, since the kernel will be
480busy printing messages and unable to service other requests quickly.
481The
482.Ic debug
483function takes a number of arguments:
484.Bl -tag -width 18n
485.It Fl I
486Enable CAM_DEBUG_INFO printfs.
487.It Fl P
488Enable CAM_DEBUG_PERIPH printfs.
489.It Fl T
490Enable CAM_DEBUG_TRACE printfs.
491.It Fl S
492Enable CAM_DEBUG_SUBTRACE printfs.
493.It Fl X
494Enable CAM_DEBUG_XPT printfs.
495.It Fl c
496Enable CAM_DEBUG_CDB printfs.  This will cause the kernel to print out the
497SCSI CDBs sent to the specified device(s).
498.It all
499Enable debugging for all devices.
500.It off
501Turn off debugging for all devices
502.It bus Ns Op :target Ns Op :lun
503Turn on debugging for the given bus, target or lun.  If the lun or target
504and lun are not specified, they are wildcarded.  (i.e., just specifying a
505bus turns on debugging printfs for all devices on that bus.)
506.El
507.It Ic tags
508Show or set the number of "tagged openings" or simultaneous transactions
509we attempt to queue to a particular device.  By default, the
510.Ic tags
511command, with no command-specific arguments (i.e. only generic arguments)
512prints out the "soft" maximum number of transactions that can be queued to
513the device in question.  For more detailed information, use the
514.Fl v
515argument described below.
516.Bl -tag -width 7n
517.It Fl N Ar tags
518Set the number of tags for the given device.  This must be between the
519minimum and maximum number set in the kernel quirk table.  The default for
520most devices that support tagged queueing is a minimum of 2 and a maximum
521of 255.  The minimum and maximum values for a given device may be
522determined by using the
523.Fl v
524switch.  The meaning of the
525.Fl v
526switch for this
527.Nm
528subcommand is described below.
529.It Fl q
530Be quiet, and don't report the number of tags.  This is generally used when
531setting the number of tags.
532.It Fl v
533The verbose flag has special functionality for the
534.Em tags
535argument.  It causes
536.Nm
537to print out the tagged queueing related fields of the XPT_GDEV_TYPE CCB:
538.Bl -tag -width 13n
539.It dev_openings
540This is the amount of capacity for transactions queued to a given device.
541.It dev_active
542This is the number of transactions currently queued to a device.
543.It devq_openings
544This is the kernel queue space for transactions.  This count usually mirrors
545dev_openings except during error recovery operations when
546the device queue is frozen (device is not allowed to receive
547commands), the number of dev_openings is reduced, or transaction
548replay is occurring.
549.It devq_queued
550This is the number of transactions waiting in the kernel queue for capacity
551on the device.  This number is usually zero unless error recovery is in
552progress.
553.It held
554The held count is the number of CCBs held by peripheral drivers that have
555either just been completed or are about to be released to the transport
556layer for service by a device.  Held CCBs reserve capacity on a given
557device.
558.It mintags
559This is the current "hard" minimum number of transactions that can be
560queued to a device at once.  The
561.Ar dev_openings
562value above cannot go below this number.  The default value for
563.Ar mintags
564is 2, although it may be set higher or lower for various devices.
565.It maxtags
566This is the "hard" maximum number of transactions that can be queued to a
567device at one time.  The
568.Ar dev_openings
569value cannot go above this number.  The default value for
570.Ar maxtags
571is 255, although it may be set higher or lower for various devices.
572.El
573.El
574.It Ic negotiate
575Show or negotiate various communication parameters.  Some controllers may
576not support setting or changing some of these values.  For instance, the
577Adaptec 174x controllers do not support changing a device's sync rate or
578offset.
579The
580.Nm
581utility
582will not attempt to set the parameter if the controller indicates that it
583does not support setting the parameter.  To find out what the controller
584supports, use the
585.Fl v
586flag.  The meaning of the
587.Fl v
588flag for the
589.Ic negotiate
590command is described below.  Also, some controller drivers don't support
591setting negotiation parameters, even if the underlying controller supports
592negotiation changes.  Some controllers, such as the Advansys wide
593controllers, support enabling and disabling synchronous negotiation for
594a device, but do not support setting the synchronous negotiation rate.
595.Bl -tag -width 17n
596.It Fl a
597Attempt to make the negotiation settings take effect immediately by sending
598a Test Unit Ready command to the device.
599.It Fl c
600Show or set current negotiation settings.  This is the default.
601.It Fl D Ar enable|disable
602Enable or disable disconnection.
603.It Fl O Ar offset
604Set the command delay offset.
605.It Fl q
606Be quiet, don't print anything.  This is generally useful when you want to
607set a parameter, but don't want any status information.
608.It Fl R Ar syncrate
609Change the synchronization rate for a device.  The sync rate is a floating
610point value specified in MHz.  So, for instance,
611.Sq 20.000
612is a legal value, as is
613.Sq 20 .
614.It Fl T Ar enable|disable
615Enable or disable tagged queueing for a device.
616.It Fl U
617Show or set user negotiation settings.  The default is to show or set
618current negotiation settings.
619.It Fl v
620The verbose switch has special meaning for the
621.Ic negotiate
622subcommand.  It causes
623.Nm
624to print out the contents of a Path Inquiry (XPT_PATH_INQ) CCB sent to the
625controller driver.
626.It Fl W Ar bus_width
627Specify the bus width to negotiate with a device.  The bus width is
628specified in bits.  The only useful values to specify are 8, 16, and 32
629bits.  The controller must support the bus width in question in order for
630the setting to take effect.
631.El
632.Pp
633In general, sync rate and offset settings will not take effect for a
634device until a command has been sent to the device.  The
635.Fl a
636switch above will automatically send a Test Unit Ready to the device so
637negotiation parameters will take effect.
638.It Ic format
639Issue the
640.Tn SCSI
641FORMAT UNIT command to the named device.
642.Pp
643.Em WARNING! WARNING! WARNING!
644.Pp
645Low level formatting a disk will destroy ALL data on the disk.  Use
646extreme caution when issuing this command.  Many users low-level format
647disks that do not really need to be low-level formatted.  There are
648relatively few scenarios that call for low-level formatting a disk.
649One reason for
650low-level formatting a disk is to initialize the disk after changing
651its physical sector size.  Another reason for low-level formatting a disk
652is to revive the disk if you are getting "medium format corrupted" errors
653from the disk in response to read and write requests.
654.Pp
655Some disks take longer than others to format.  Users should specify a
656timeout long enough to allow the format to complete.  The default format
657timeout is 3 hours, which should be long enough for most disks.  Some hard
658disks will complete a format operation in a very short period of time
659(on the order of 5 minutes or less).  This is often because the drive
660doesn't really support the FORMAT UNIT command -- it just accepts the
661command, waits a few minutes and then returns it.
662.Pp
663The
664.Sq format
665subcommand takes several arguments that modify its default behavior.  The
666.Fl q
667and
668.Fl y
669arguments can be useful for scripts.
670.Bl -tag -width 6n
671.It Fl q
672Be quiet, don't print any status messages.  This option will not disable
673the questions, however.  To disable questions, use the
674.Fl y
675argument, below.
676.It Fl r
677Run in
678.Dq report only
679mode.
680This will report status on a format that is already running on the drive.
681.It Fl w
682Issue a non-immediate format command.  By default,
683.Nm
684issues the FORMAT UNIT command with the immediate bit set.  This tells the
685device to immediately return the format command, before the format has
686actually completed.  Then,
687.Nm
688gathers
689.Tn SCSI
690sense information from the device every second to determine how far along
691in the format process it is.  If the
692.Fl w
693argument is specified,
694.Nm
695will issue a non-immediate format command, and will be unable to print any
696information to let the user know what percentage of the disk has been
697formatted.
698.It Fl y
699Don't ask any questions.  By default,
700.Nm
701will ask the user if he/she really wants to format the disk in question,
702and also if the default format command timeout is acceptable.  The user
703will not be asked about the timeout if a timeout is specified on the
704command line.
705.El
706.It Ic help
707Print out verbose usage information.
708.El
709.Sh ENVIRONMENT
710The
711.Ev SCSI_MODES
712variable allows the user to specify an alternate mode page format file.
713.Pp
714The
715.Ev EDITOR
716variable determines which text editor
717.Nm
718starts when editing mode pages.
719.Sh FILES
720.Bl -tag -width /usr/share/misc/scsi_modes -compact
721.It Pa /usr/share/misc/scsi_modes
722is the SCSI mode format database.
723.It Pa /dev/xpt0
724is the transport layer device.
725.It Pa /dev/pass*
726are the CAM application passthrough devices.
727.El
728.Sh EXAMPLES
729.Dl camcontrol eject -n cd -u 1 -v
730.Pp
731Eject the CD from cd1, and print SCSI sense information if the command
732fails.
733.Pp
734.Dl camcontrol tur da0
735.Pp
736Send the SCSI test unit ready command to da0.
737The
738.Nm
739utility will report whether the disk is ready, but will not display sense
740information if the command fails since the
741.Fl v
742switch was not specified.
743.Bd -literal -offset indent
744camcontrol tur da1 -E -C 4 -t 50 -v
745.Ed
746.Pp
747Send a test unit ready command to da1.  Enable kernel error recovery.
748Specify a retry count of 4, and a timeout of 50 seconds.  Enable sense
749printing (with the
750.Fl v
751flag) if the command fails.  Since error recovery is turned on, the
752disk will be spun up if it is not currently spinning.
753The
754.Nm
755utility will report whether the disk is ready.
756.Bd -literal -offset indent
757camcontrol cmd -n cd -u 1 -v -c "3C 00 00 00 00 00 00 00 0e 00" \e
758	-i 0xe "s1 i3 i1 i1 i1 i1 i1 i1 i1 i1 i1 i1"
759.Ed
760.Pp
761Issue a READ BUFFER command (0x3C) to cd1.  Display the buffer size of cd1,
762and display the first 10 bytes from the cache on cd1.  Display SCSI sense
763information if the command fails.
764.Bd -literal -offset indent
765camcontrol cmd -n cd -u 1 -v -c "3B 00 00 00 00 00 00 00 0e 00" \e
766	-o 14 "00 00 00 00 1 2 3 4 5 6 v v v v" 7 8 9 8
767.Ed
768.Pp
769Issue a WRITE BUFFER (0x3B) command to cd1.  Write out 10 bytes of data,
770not including the (reserved) 4 byte header.  Print out sense information if
771the command fails.  Be very careful with this command, improper use may
772cause data corruption.
773.Bd -literal -offset indent
774camcontrol modepage da3 -m 1 -e -P 3
775.Ed
776.Pp
777Edit mode page 1 (the Read-Write Error Recover page) for da3, and save the
778settings on the drive.  Mode page 1 contains a disk drive's auto read and
779write reallocation settings, among other things.
780.Pp
781.Dl camcontrol rescan all
782.Pp
783Rescan all SCSI busses in the system for devices that have been added,
784removed or changed.
785.Pp
786.Dl camcontrol rescan 0
787.Pp
788Rescan SCSI bus 0 for devices that have been added, removed or changed.
789.Pp
790.Dl camcontrol rescan 0:1:0
791.Pp
792Rescan SCSI bus 0, target 1, lun 0 to see if it has been added, removed, or
793changed.
794.Pp
795.Dl camcontrol tags da5 -N 24
796.Pp
797Set the number of concurrent transactions for da5 to 24.
798.Bd -literal -offset indent
799camcontrol negotiate -n da -u 4 -T disable
800.Ed
801.Pp
802Disable tagged queueing for da4.
803.Bd -literal -offset indent
804camcontrol negotiate -n da -u 3 -R 20.000 -O 15 -a
805.Ed
806.Pp
807Negotiate a sync rate of 20MHz and an offset of 15 with da3.  Then send a
808Test Unit Ready command to make the settings take effect.
809.Sh SEE ALSO
810.Xr cam 3 ,
811.Xr cam_cdbparse 3 ,
812.Xr cam 4 ,
813.Xr pass 4 ,
814.Xr xpt 4
815.Sh HISTORY
816The
817.Nm
818utility first appeared in
819.Fx 3.0 .
820.Pp
821The mode page editing code and arbitrary SCSI command code are based upon
822code in the old
823.Xr scsi 8
824utility and
825.Xr scsi 3
826library, written by Julian Elischer and Peter Dufault.  The
827.Xr scsi 8
828program first appeared in
829.Bx 386 0.1.2.4 ,
830and first appeared in
831.Fx
832in
833.Fx 2.0.5 .
834.Sh AUTHORS
835.An Kenneth Merry Aq Mt ken@FreeBSD.org
836.Sh BUGS
837The code that parses the generic command line arguments doesn't know that
838some of the subcommands take multiple arguments.  So if, for instance, you
839tried something like this:
840.Bd -literal -offset indent
841camcontrol cmd -n da -u 1 -c "00 00 00 00 00 v" 0x00 -v
842.Ed
843.Pp
844The sense information from the test unit ready command would not get
845printed out, since the first
846.Xr getopt 3
847call in
848.Nm
849bails out when it sees the second argument to
850.Fl c
851(0x00),
852above.  Fixing this behavior would take some gross code, or changes to the
853.Xr getopt 3
854interface.  The best way to circumvent this problem is to always make sure
855to specify generic
856.Nm
857arguments before any command-specific arguments.
858