xref: /freebsd/share/examples/scsi_target/scsi_target.8 (revision fa9896e082a1046ff4fbc75fcba4d18d1f2efc19)
1c38b150aSNate Lawson.\" Copyright (c) 2002
2c38b150aSNate Lawson.\"	Nate Lawson.  All rights reserved.
3c38b150aSNate Lawson.\"
4c38b150aSNate Lawson.\" Redistribution and use in source and binary forms, with or without
5c38b150aSNate Lawson.\" modification, are permitted provided that the following conditions
6c38b150aSNate Lawson.\" are met:
7c38b150aSNate Lawson.\" 1. Redistributions of source code must retain the above copyright
8c38b150aSNate Lawson.\"    notice, this list of conditions and the following disclaimer.
9c38b150aSNate Lawson.\" 2. Redistributions in binary form must reproduce the above copyright
10c38b150aSNate Lawson.\"    notice, this list of conditions and the following disclaimer in the
11c38b150aSNate Lawson.\"    documentation and/or other materials provided with the distribution.
12c38b150aSNate Lawson.\" 3. Neither the name of the author nor the names of any co-contributors
13c38b150aSNate Lawson.\"    may be used to endorse or promote products derived from this software
14c38b150aSNate Lawson.\"    without specific prior written permission.
15c38b150aSNate Lawson.\"
16c38b150aSNate Lawson.\" THIS SOFTWARE IS PROVIDED BY Nate Lawson AND CONTRIBUTORS ``AS IS'' AND
17c38b150aSNate Lawson.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18c38b150aSNate Lawson.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19c38b150aSNate Lawson.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20c38b150aSNate Lawson.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21c38b150aSNate Lawson.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22c38b150aSNate Lawson.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23c38b150aSNate Lawson.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24c38b150aSNate Lawson.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25c38b150aSNate Lawson.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26c38b150aSNate Lawson.\" SUCH DAMAGE.
27c38b150aSNate Lawson.\"
28c38b150aSNate Lawson.Dd November 15, 2002
29c38b150aSNate Lawson.Dt SCSI_TARGET 8
30c38b150aSNate Lawson.Os
31c38b150aSNate Lawson.Sh NAME
32c38b150aSNate Lawson.Nm scsi_target
33c38b150aSNate Lawson.Nd usermode SCSI disk emulator
34c38b150aSNate Lawson.Sh SYNOPSIS
35c38b150aSNate Lawson.Nm
36c38b150aSNate Lawson.Op Fl AdST
37c38b150aSNate Lawson.Op Fl b Ar size
38c38b150aSNate Lawson.Op Fl c Ar size
39c38b150aSNate Lawson.Op Fl s Ar size
40c38b150aSNate Lawson.Op Fl W Ar num
41a7348c92SRuslan Ermilov.Ar bus : Ns Ar target : Ns Ar lun
42c38b150aSNate Lawson.Ar filename
43c38b150aSNate Lawson.Sh DESCRIPTION
44c38b150aSNate LawsonThe
45c38b150aSNate Lawson.Nm
46a7348c92SRuslan Ermilovutility emulates a SCSI target device using the
47c38b150aSNate Lawson.Xr targ 4
48a7348c92SRuslan Ermilovdevice driver.
49a7348c92SRuslan ErmilovIt supports the basic commands of a direct access device, like
50c38b150aSNate Lawson.Xr da 4 .
51c38b150aSNate LawsonIn typical operation, it opens a control device and
52a7348c92SRuslan Ermilovenables target mode for the specified LUN.
53a7348c92SRuslan ErmilovIt then communicates with
54c38b150aSNate Lawsonthe SIM using CCBs exchanged via
55c38b150aSNate Lawson.Xr read 2
56c38b150aSNate Lawsonand
57c38b150aSNate Lawson.Xr write 2 .
58c38b150aSNate LawsonREAD and WRITE CDBs are satisfied with the specified backing store file.
59c38b150aSNate Lawson.Pp
60c38b150aSNate LawsonFor performance, all backing store accesses use
61c38b150aSNate Lawson.Xr aio 4 .
62c38b150aSNate LawsonThus,
63c38b150aSNate Lawson.Nm
64a7348c92SRuslan Ermilovrequires a kernel compiled with
65a7348c92SRuslan Ermilov.Cd "options VFS_AIO" .
66c38b150aSNate Lawson.Pp
67c38b150aSNate LawsonOptions:
68a7348c92SRuslan Ermilov.Bl -tag -width indent
69c38b150aSNate Lawson.It Fl A
70a7348c92SRuslan ErmilovEnable 16 addresses if supported by the SIM.
71a7348c92SRuslan ErmilovDefault is 8.
72c38b150aSNate Lawson.It Fl S
73a7348c92SRuslan ErmilovEnable synchronous transfers if supported by the SIM.
74a7348c92SRuslan ErmilovDefault is disabled.
75c38b150aSNate Lawson.It Fl T
76a7348c92SRuslan ErmilovEnable tagged queuing if supported by the SIM.
77a7348c92SRuslan ErmilovDefault is no tagged queuing.
78a7348c92SRuslan Ermilov.It Fl W Cm 8 | 16 | 32
79a7348c92SRuslan ErmilovEnable 16 or 32 bit wide transfers if supported by the SIM.
80a7348c92SRuslan ErmilovDefault is 8.
81c38b150aSNate Lawson.It Fl b Ar bufsize
82a7348c92SRuslan ErmilovSet buffer size for transfers.
83a7348c92SRuslan ErmilovTransfers larger than this will be split into multiple transfers.
84c38b150aSNate Lawson.It Fl c Ar sectorsize
85a7348c92SRuslan ErmilovSet sector size for emulated volume.
86a7348c92SRuslan ErmilovDefault is 512.
87c38b150aSNate Lawson.It Fl d
88c38b150aSNate LawsonEnable debugging output in
89c38b150aSNate Lawson.Nm
90c38b150aSNate Lawsonand its associated control device.
91c38b150aSNate Lawson.It Fl s Ar volsize
92a7348c92SRuslan ErmilovUse a different size for the emulated volume.
93a7348c92SRuslan ErmilovMust be less than or equal to the size of
94c38b150aSNate Lawson.Ar filename .
95068d70baSHidetoshi ShimokawaIf the number ends with a
96068d70baSHidetoshi Shimokawa.Dq Li k ,
97068d70baSHidetoshi Shimokawa.Dq Li m ,
98068d70baSHidetoshi Shimokawa.Dq Li g ,
99068d70baSHidetoshi Shimokawa.Dq Li t ,
100068d70baSHidetoshi Shimokawa.Dq Li p ,
101068d70baSHidetoshi Shimokawaor
102068d70baSHidetoshi Shimokawa.Dq Li e ,
103068d70baSHidetoshi Shimokawathe number is multiplied by 2^10 (1K), 2^20 (1M), 2^30 (1G), 2^40 (1T),
104068d70baSHidetoshi Shimokawa2^50 (1P) and 2^60 (1E)
105068d70baSHidetoshi Shimokawarespectively.
106c38b150aSNate Lawson.El
107c38b150aSNate Lawson.Pp
108c38b150aSNate LawsonRequired arguments:
109a7348c92SRuslan Ermilov.Bl -tag -width indent
110a7348c92SRuslan Ermilov.It Ar bus : Ns Ar target : Ns Ar lun
111a7348c92SRuslan ErmilovAttach to specified bus ID, target ID, and LUN.
112c38b150aSNate Lawson.It Ar filename
113a7348c92SRuslan ErmilovFile to use as a backing store.
114c38b150aSNate Lawson.El
115c38b150aSNate Lawson.Pp
116c38b150aSNate LawsonAll options default to the minimal functionality of SCSI-1.
117c38b150aSNate LawsonTo be safe,
118c38b150aSNate Lawson.Nm
119c38b150aSNate Lawsonchecks the SIM for the requested capability before enabling target mode.
1209cbda590SRuslan Ermilov.Sh FILES
1219cbda590SRuslan Ermilov.Bl -tag -width ".Pa /usr/share/examples/scsi_target" -compact
1229cbda590SRuslan Ermilov.It Pa /dev/targ*
1239cbda590SRuslan ErmilovControl devices.
1249cbda590SRuslan Ermilov.It Pa /usr/share/examples/scsi_target
1259cbda590SRuslan ErmilovSource directory.
1269cbda590SRuslan Ermilov.El
127a7348c92SRuslan Ermilov.Sh EXAMPLES
128c38b150aSNate LawsonCreate a 5 megabyte backing store file.
129c38b150aSNate Lawson.Pp
130a7348c92SRuslan Ermilov.Dl "dd if=/dev/zero of=vol size=1m count=5"
131a7348c92SRuslan Ermilov.Pp
132a7348c92SRuslan ErmilovEnable target mode on bus 0, target ID 1, LUN 0, using
133a7348c92SRuslan Ermilov.Pa vol
134c38b150aSNate Lawsonas the backing store for READ6/10 and WRITE6/10 commands.
135c38b150aSNate LawsonOnly the first 1000 bytes of
136a7348c92SRuslan Ermilov.Pa vol
137a7348c92SRuslan Ermilovwill be used.
138a7348c92SRuslan ErmilovDebugging information will be output.
139c38b150aSNate Lawson16-bit wide transfers will be used if the SIM supports them.
140c38b150aSNate Lawson.Pp
14185aeaa60SPawel Jakub Dawidek.Dl "scsi_target -d -s 1000 -W 16 0:1:0 vol"
142c38b150aSNate Lawson.Sh SEE ALSO
143a7348c92SRuslan Ermilov.Xr scsi 4 ,
144a7348c92SRuslan Ermilov.Xr targ 4
145c38b150aSNate Lawson.Sh AUTHORS
146a7348c92SRuslan Ermilov.An -nosplit
147c38b150aSNate LawsonThe
148c38b150aSNate Lawson.Nm
149c38b150aSNate Lawsonexample first appeared in
150c38b150aSNate Lawson.Fx 3.0
151c38b150aSNate Lawsonand was written by
152c38b150aSNate Lawson.An Justin T. Gibbs .
153c38b150aSNate LawsonIt was rewritten for
154c38b150aSNate Lawson.Fx 5.0
155c38b150aSNate Lawsonby
156*bd0891ceSBaptiste Daroussin.An Nate Lawson Aq Mt nate@root.org .
157