Add an ffs(5) manual page.
[dragonfly.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: src/share/man/man4/targ.4,v 1.3.2.1 2003/02/18 22:07:11 njl Exp $
26 .\" $DragonFly: src/share/man/man4/targ.4,v 1.5 2007/04/26 17:35:03 swildner Exp $
27 .\"
28 .Dd November 15, 2002
29 .Dt TARG 4
30 .Os
31 .Sh NAME
32 .Nm targ
33 .Nd SCSI target emulator driver
34 .Sh SYNOPSIS
35 .Cd device targ
36 .Sh DESCRIPTION
37 The
38 .Nm
39 driver provides an interface for usermode programs to emulate SCSI target
40 devices.
41 A sample program that emulates a disk drive (similar to
42 .Xr da 4 )
43 can be found in
44 .Pa /usr/share/examples/scsi_target .
45 .Pp
46 The
47 .Nm
48 driver supplies control devices,
49 .Pa /dev/targ0 ,
50 .Pa /dev/targ1 ,
51 etc.
52 If a device is already in use,
53 .Xr open 2
54 will fail and
55 .Va errno
56 will be set to
57 .Er EBUSY .
58 After opening the device, the file descriptor must be bound to a
59 specific bus/target/LUN and enabled to process CCBs using the
60 .Dv TARGIOCENABLE
61 ioctl.
62 The process then uses
63 .Xr write 2
64 to send CCBs to the SIM and
65 .Xr poll 2
66 or
67 .Xr kqueue 2
68 to see if responses are ready.
69 Pointers to completed CCBs are returned via
70 .Xr read 2 .
71 Any data transfers requested by the user CCBs are done via zero-copy IO.
72 .Sh IOCTLS
73 The following
74 .Xr ioctl 2
75 calls are defined in the header file
76 .In bus/cam/scsi/scsi_targetio.h .
77 .Bl -tag -width ".Dv TARGIOCDISABLE"
78 .It Dv TARGIOCENABLE
79 .Pq Vt "struct ioc_enable_lun"
80 Enable target mode on the LUN specified by the following structure:
81 .Bd -literal -offset indent
82 struct ioc_enable_lun {
83         path_id_t       path_id;
84         target_id_t     target_id;
85         lun_id_t        lun_id;
86         int             grp6_len;
87         int             grp7_len;
88 };
89 .Ed
90 .Pp
91 The selected path (bus), target, and LUN must not already be in use or
92 .Er EADDRINUSE
93 is returned.
94 If
95 .Va grp6_len
96 or
97 .Va grp7_len
98 are non-zero, reception of vendor-specific commands
99 is enabled.
100 .It Dv TARGIOCDISABLE
101 Disable target mode and abort all pending CCBs.
102 The CCBs may optionally be read as they complete.
103 .Dv TARGIOCENABLE
104 can then be called to activate a different LUN.
105 Multiple disable calls have no effect.
106 The
107 .Xr close 2
108 system call automatically disables target mode if enabled.
109 .It Dv TARGIOCDEBUG
110 .Pq Vt int
111 Enables
112 .Dv CAM_PERIPH
113 debugging if the argument is non-zero, otherwise disables
114 it.
115 .El
116 .Sh FILES
117 .Bl -tag -width ".Pa /sys/cam/scsi/scsi_target.c" -compact
118 .It In bus/cam/scsi/scsi_targetio.h
119 describes the usermode interface.
120 .It Pa /sys/cam/scsi/scsi_target.c
121 is the driver source file.
122 .It Pa /dev/targ*
123 are the control devices.
124 .El
125 .Sh SEE ALSO
126 .Pa /usr/share/examples/scsi_target ,
127 .Xr ahc 4 ,
128 .Xr isp 4 ,
129 .Xr scsi 4
130 .Rs
131 .%T "FreeBSD Target Information"
132 .%O http://www.root.org/~nate/freebsd/
133 .Re
134 .Sh AUTHORS
135 .An -nosplit
136 The
137 .Nm
138 driver first appeared in
139 .Fx 3.0
140 and was written by
141 .An Justin T. Gibbs .
142 It was rewritten
143 for
144 .Fx 5.0
145 by
146 .An Nate Lawson Aq nate@root.org .
147 .Sh BUGS
148 Currently, only the
149 .Xr ahc 4
150 and
151 .Xr isp 4
152 drivers fully support target mode.
153 .Pp
154 The
155 .Xr ahc 4
156 driver does not support tagged queuing in target mode.