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