]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - share/man/man4/targ.4
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / share / man / man4 / targ.4
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. Neither the name of the author nor the names of any co-contributors
10 .\"    may be used to endorse or promote products derived from this software
11 .\"    without specific prior written permission.
12 .\"
13 .\" THIS SOFTWARE IS PROVIDED BY Nate Lawson AND CONTRIBUTORS ``AS IS'' AND
14 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23 .\" SUCH DAMAGE.
24 .\"
25 .\" $FreeBSD$
26 .\"
27 .Dd November 15, 2002
28 .Dt TARG 4
29 .Os
30 .Sh NAME
31 .Nm targ
32 .Nd SCSI target emulator driver
33 .Sh SYNOPSIS
34 To compile this driver into the kernel,
35 place the following line in your
36 kernel configuration file:
37 .Bd -ragged -offset indent
38 .Cd "device targ"
39 .Ed
40 .Sh DESCRIPTION
41 The
42 .Nm
43 driver provides an interface for usermode programs to emulate SCSI target
44 devices.
45 A sample program that emulates a disk drive (similar to
46 .Xr da 4 )
47 can be found in
48 .Pa /usr/share/examples/scsi_target .
49 .Pp
50 The
51 .Nm
52 driver supplies control devices,
53 .Pa /dev/targ0 ,
54 .Pa /dev/targ1 ,
55 etc.
56 If a device is already in use,
57 .Xr open 2
58 will fail and
59 .Va errno
60 will be set to
61 .Er EBUSY .
62 After opening the device, the file descriptor must be bound to a
63 specific bus/target/LUN and enabled to process CCBs using the
64 .Dv TARGIOCENABLE
65 ioctl.
66 The process then uses
67 .Xr write 2
68 to send CCBs to the SIM and
69 .Xr poll 2
70 or
71 .Xr kqueue 2
72 to see if responses are ready.
73 Pointers to completed CCBs are returned via
74 .Xr read 2 .
75 Any data transfers requested by the user CCBs are done via zero-copy IO.
76 .Sh IOCTLS
77 The following
78 .Xr ioctl 2
79 calls are defined in the header file
80 .In cam/scsi/scsi_targetio.h .
81 .Bl -tag -width ".Dv TARGIOCDISABLE"
82 .It Dv TARGIOCENABLE
83 .Pq Vt "struct ioc_enable_lun"
84 Enable target mode on the LUN specified by the following structure:
85 .Bd -literal -offset indent
86 struct ioc_enable_lun {
87         path_id_t       path_id;
88         target_id_t     target_id;
89         lun_id_t        lun_id;
90         int             grp6_len;
91         int             grp7_len;
92 };
93 .Ed
94 .Pp
95 The selected path (bus), target, and LUN must not already be in use or
96 .Er EADDRINUSE
97 is returned.
98 If
99 .Va grp6_len
100 or
101 .Va grp7_len
102 are non-zero, reception of vendor-specific commands
103 is enabled.
104 .It Dv TARGIOCDISABLE
105 Disable target mode and abort all pending CCBs.
106 The CCBs may optionally be read as they complete.
107 .Dv TARGIOCENABLE
108 can then be called to activate a different LUN.
109 Multiple disable calls have no effect.
110 The
111 .Xr close 2
112 system call automatically disables target mode if enabled.
113 .It Dv TARGIOCDEBUG
114 .Pq Vt int
115 Enables
116 .Dv CAM_PERIPH
117 debugging if the argument is non-zero, otherwise disables
118 it.
119 .El
120 .Sh FILES
121 .Bl -tag -width ".Pa /sys/cam/scsi/scsi_target.c" -compact
122 .It In cam/scsi/scsi_targetio.h
123 describes the usermode interface.
124 .It Pa /sys/cam/scsi/scsi_target.c
125 is the driver source file.
126 .It Pa /dev/targ*
127 are the control devices.
128 .El
129 .Sh SEE ALSO
130 .Pa /usr/share/examples/scsi_target ,
131 .Xr ahc 4 ,
132 .Xr isp 4 ,
133 .Xr scsi 4
134 .Rs
135 .%T "FreeBSD Target Information"
136 .%U http://www.root.org/~nate/freebsd/
137 .Re
138 .Sh AUTHORS
139 .An -nosplit
140 The
141 .Nm
142 driver first appeared in
143 .Fx 3.0
144 and was written by
145 .An Justin T. Gibbs .
146 It was rewritten
147 for
148 .Fx 5.0
149 by
150 .An Nate Lawson Aq nate@root.org .
151 .Sh BUGS
152 Currently, only the
153 .Xr ahc 4
154 and
155 .Xr isp 4
156 drivers fully support target mode.
157 .Pp
158 The
159 .Xr ahc 4
160 driver does not support tagged queuing in target mode.