xref: /freebsd/share/examples/scsi_target/scsi_target.8 (revision fe75646a0234a261c0013bf1840fdac4acaf0cec)
1.\" Copyright (c) 2002
2.\"	Nate Lawson.  All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\" 3. Neither the name of the author nor the names of any co-contributors
13.\"    may be used to endorse or promote products derived from this software
14.\"    without specific prior written permission.
15.\"
16.\" THIS SOFTWARE IS PROVIDED BY Nate Lawson 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.Dd November 15, 2002
29.Dt SCSI_TARGET 8
30.Os
31.Sh NAME
32.Nm scsi_target
33.Nd usermode SCSI disk emulator
34.Sh SYNOPSIS
35.Nm
36.Op Fl AdST
37.Op Fl b Ar size
38.Op Fl c Ar size
39.Op Fl s Ar size
40.Op Fl W Ar num
41.Ar bus : Ns Ar target : Ns Ar lun
42.Ar filename
43.Sh DESCRIPTION
44The
45.Nm
46utility emulates a SCSI target device using the
47.Xr targ 4
48device driver.
49It supports the basic commands of a direct access device, like
50.Xr da 4 .
51In typical operation, it opens a control device and
52enables target mode for the specified LUN.
53It then communicates with
54the SIM using CCBs exchanged via
55.Xr read 2
56and
57.Xr write 2 .
58READ and WRITE CDBs are satisfied with the specified backing store file.
59.Pp
60For performance, all backing store accesses use
61.Xr aio 4 .
62Thus,
63.Nm
64requires a kernel compiled with
65.Cd "options VFS_AIO" .
66.Pp
67Options:
68.Bl -tag -width indent
69.It Fl A
70Enable 16 addresses if supported by the SIM.
71Default is 8.
72.It Fl S
73Enable synchronous transfers if supported by the SIM.
74Default is disabled.
75.It Fl T
76Enable tagged queuing if supported by the SIM.
77Default is no tagged queuing.
78.It Fl W Cm 8 | 16 | 32
79Enable 16 or 32 bit wide transfers if supported by the SIM.
80Default is 8.
81.It Fl b Ar bufsize
82Set buffer size for transfers.
83Transfers larger than this will be split into multiple transfers.
84.It Fl c Ar sectorsize
85Set sector size for emulated volume.
86Default is 512.
87.It Fl d
88Enable debugging output in
89.Nm
90and its associated control device.
91.It Fl s Ar volsize
92Use a different size for the emulated volume.
93Must be less than or equal to the size of
94.Ar filename .
95If the number ends with a
96.Dq Li k ,
97.Dq Li m ,
98.Dq Li g ,
99.Dq Li t ,
100.Dq Li p ,
101or
102.Dq Li e ,
103the number is multiplied by 2^10 (1K), 2^20 (1M), 2^30 (1G), 2^40 (1T),
1042^50 (1P) and 2^60 (1E)
105respectively.
106.El
107.Pp
108Required arguments:
109.Bl -tag -width indent
110.It Ar bus : Ns Ar target : Ns Ar lun
111Attach to specified bus ID, target ID, and LUN.
112.It Ar filename
113File to use as a backing store.
114.El
115.Pp
116All options default to the minimal functionality of SCSI-1.
117To be safe,
118.Nm
119checks the SIM for the requested capability before enabling target mode.
120.Sh FILES
121.Bl -tag -width ".Pa /usr/share/examples/scsi_target" -compact
122.It Pa /dev/targ*
123Control devices.
124.It Pa /usr/share/examples/scsi_target
125Source directory.
126.El
127.Sh EXAMPLES
128Create a 5 megabyte backing store file.
129.Pp
130.Dl "dd if=/dev/zero of=vol size=1m count=5"
131.Pp
132Enable target mode on bus 0, target ID 1, LUN 0, using
133.Pa vol
134as the backing store for READ6/10 and WRITE6/10 commands.
135Only the first 1000 bytes of
136.Pa vol
137will be used.
138Debugging information will be output.
13916-bit wide transfers will be used if the SIM supports them.
140.Pp
141.Dl "scsi_target -d -s 1000 -W 16 0:1:0 vol"
142.Sh SEE ALSO
143.Xr scsi 4 ,
144.Xr targ 4
145.Sh AUTHORS
146.An -nosplit
147The
148.Nm
149example first appeared in
150.Fx 3.0
151and was written by
152.An Justin T. Gibbs .
153It was rewritten for
154.Fx 5.0
155by
156.An Nate Lawson Aq Mt nate@root.org .
157