Use \(xx style escape sequences for some special characters so that
[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.3 2006/02/17 19:37:09 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, open(2) will fail and
53 .Va errno
54 will be set to
55 .Er EBUSY .
56 After opening the device, the file descriptor must be bound to a
57 specific bus/target/LUN and enabled to process CCBs using the
58 .Dv TARGIOCENABLE
59 ioctl.
60 The process then uses
61 .Xr write 2
62 to send CCBs to the SIM and
63 .Xr poll 2
64 or
65 .Xr kqueue 2
66 to see if responses are ready.
67 Pointers to completed CCBs are returned via
68 .Xr read 2 .
69 Any data transfers requested by the user CCBs are done via zero-copy IO.
70 .Sh IOCTLS
71 The following
72 .Xr ioctl 2
73 calls are defined in the header file
74 .Aq Pa cam/scsi/scsi_targetio.h .
75 .Bl -tag -width ".Dv TARGIOCDISABLE"
76 .It Dv TARGIOCENABLE
77 .Pq Vt "struct ioc_enable_lun"
78 Enable target mode on the LUN specified by the following structure:
79 .Bd -literal -offset indent
80 struct ioc_enable_lun {
81         path_id_t       path_id;
82         target_id_t     target_id;
83         lun_id_t        lun_id;
84         int             grp6_len;
85         int             grp7_len;
86 };
87 .Ed
88 .Pp
89 The selected path (bus), target, and LUN must not already be in use or
90 .Er EADDRINUSE
91 is returned.
92 If
93 .Va grp6_len
94 or
95 .Va grp7_len
96 are non-zero, reception of vendor-specific commands
97 is enabled.
98 .It Dv TARGIOCDISABLE
99 Disable target mode and abort all pending CCBs.
100 The CCBs may optionally be read as they complete.
101 .Dv TARGIOCENABLE
102 can then be called to activate a different LUN.
103 Multiple disable calls have no effect.
104 The
105 .Xr close 2
106 system call automatically disables target mode if enabled.
107 .It Dv TARGIOCDEBUG
108 .Pq Vt int
109 Enables
110 .Dv CAM_PERIPH
111 debugging if the argument is non-zero, otherwise disables
112 it.
113 .El
114 .Sh FILES
115 .Bl -tag -width ".Pa /sys/cam/scsi/scsi_target.c" -compact
116 .It Aq Pa cam/scsi/scsi_targetio.h
117 describes the usermode interface.
118 .It Pa /sys/cam/scsi/scsi_target.c
119 is the driver source file.
120 .It Pa /dev/targ*
121 are the control devices.
122 .El
123 .Sh SEE ALSO
124 .Pa /usr/share/examples/scsi_target ,
125 .Xr ahc 4 ,
126 .Xr isp 4 ,
127 .Xr scsi 4
128 .Rs
129 .%T "FreeBSD Target Information"
130 .%O http://www.root.org/~nate/freebsd/
131 .Re
132 .Sh AUTHORS
133 .An -nosplit
134 The
135 .Nm
136 driver first appeared in
137 .Fx 3.0
138 and was written by
139 .An Justin T. Gibbs .
140 It was rewritten
141 for
142 .Fx 5.0
143 by
144 .An Nate Lawson Aq nate@root.org .
145 .Sh BUGS
146 Currently, only the
147 .Xr ahc 4
148 and
149 .Xr isp 4
150 drivers fully support target mode.
151 .Pp
152 The
153 .Xr ahc 4
154 driver does not support tagged queuing in target mode.