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