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
|
<table class="head">
<tr>
<td class="head-ltitle">TARG(4)</td>
<td class="head-vol">Device Drivers Manual</td>
<td class="head-rtitle">TARG(4)</td>
</tr>
</table>
<div class="manual-text">
<section class="Sh">
<h1 class="Sh" id="NAME"><a class="permalink" href="#NAME">NAME</a></h1>
<p class="Pp"><code class="Nm">targ</code> — <span class="Nd">SCSI target
emulator driver</span></p>
</section>
<section class="Sh">
<h1 class="Sh" id="SYNOPSIS"><a class="permalink" href="#SYNOPSIS">SYNOPSIS</a></h1>
<p class="Pp">To compile this driver into the kernel, place the following line
in your kernel configuration file:</p>
<div class="Bd Pp Bd-indent"><code class="Cd">device targ</code></div>
</section>
<section class="Sh">
<h1 class="Sh" id="DESCRIPTION"><a class="permalink" href="#DESCRIPTION">DESCRIPTION</a></h1>
<p class="Pp">The <code class="Nm">targ</code> driver provides an interface for
usermode programs to emulate SCSI target devices. A sample program that
emulates a disk drive (similar to <a class="Xr">da(4)</a>) can be found in
<span class="Pa">/usr/share/examples/scsi_target</span>.</p>
<p class="Pp">The <code class="Nm">targ</code> driver supplies the control
device <span class="Pa">/dev/targ</span>. After opening the device, the file
descriptor must be bound to a specific bus/target/LUN and enabled to process
CCBs using the <code class="Dv">TARGIOCENABLE</code> ioctl. The process then
uses <a class="Xr">write(2)</a> to send CCBs to the SIM and
<a class="Xr">poll(2)</a> or <a class="Xr">kqueue(2)</a> to see if responses
are ready. Pointers to completed CCBs are returned via
<a class="Xr">read(2)</a>. Any data transfers requested by the user CCBs are
done via zero-copy IO.</p>
</section>
<section class="Sh">
<h1 class="Sh" id="IOCTLS"><a class="permalink" href="#IOCTLS">IOCTLS</a></h1>
<p class="Pp">The following <a class="Xr">ioctl(2)</a> calls are defined in the
header file
<code class="In"><<a class="In">cam/scsi/scsi_targetio.h</a>></code>.</p>
<dl class="Bl-tag">
<dt id="TARGIOCENABLE"><a class="permalink" href="#TARGIOCENABLE"><code class="Dv">TARGIOCENABLE</code></a></dt>
<dd>(<var class="Vt">struct ioc_enable_lun</var>) Enable target mode on the
LUN specified by the following structure:
<div class="Bd Pp Bd-indent Li">
<pre>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;
};</pre>
</div>
<p class="Pp">The selected path (bus), target, and LUN must not already be
in use or <code class="Er">EADDRINUSE</code> is returned. If
<var class="Va">grp6_len</var> or <var class="Va">grp7_len</var> are
non-zero, reception of vendor-specific commands is enabled.</p>
</dd>
<dt id="TARGIOCDISABLE"><a class="permalink" href="#TARGIOCDISABLE"><code class="Dv">TARGIOCDISABLE</code></a></dt>
<dd>Disable target mode and abort all pending CCBs. The CCBs may optionally be
read as they complete. <code class="Dv">TARGIOCENABLE</code> can then be
called to activate a different LUN. Multiple disable calls have no effect.
The <a class="Xr">close(2)</a> system call automatically disables target
mode if enabled.</dd>
<dt id="TARGIOCDEBUG"><a class="permalink" href="#TARGIOCDEBUG"><code class="Dv">TARGIOCDEBUG</code></a></dt>
<dd>(<var class="Vt">int</var>) Enables <code class="Dv">CAM_PERIPH</code>
debugging if the argument is non-zero, otherwise disables it.</dd>
</dl>
</section>
<section class="Sh">
<h1 class="Sh" id="FILES"><a class="permalink" href="#FILES">FILES</a></h1>
<dl class="Bl-tag Bl-compact">
<dt><code class="In"><<a class="In">cam/scsi/scsi_targetio.h</a>></code></dt>
<dd>describes the usermode interface.</dd>
<dt><span class="Pa">/sys/cam/scsi/scsi_target.c</span></dt>
<dd>is the driver source file.</dd>
<dt><span class="Pa">/dev/targ</span></dt>
<dd>is the control device.</dd>
</dl>
</section>
<section class="Sh">
<h1 class="Sh" id="SEE_ALSO"><a class="permalink" href="#SEE_ALSO">SEE
ALSO</a></h1>
<p class="Pp"><span class="Pa">/usr/share/examples/scsi_target</span>,
<a class="Xr">ahc(4)</a>, <a class="Xr">isp(4)</a>,
<a class="Xr">scsi(4)</a></p>
<p class="Pp"><cite class="Rs"><span class="RsT">FreeBSD Target
Information</span>,
<a class="RsU" href="http://www.root.org/~nate/freebsd/">http://www.root.org/~nate/freebsd/</a>.</cite></p>
</section>
<section class="Sh">
<h1 class="Sh" id="AUTHORS"><a class="permalink" href="#AUTHORS">AUTHORS</a></h1>
<p class="Pp">The <code class="Nm">targ</code> driver first appeared in
<span class="Ux">FreeBSD 3.0</span> and was written by
<span class="An">Justin T. Gibbs</span>. It was rewritten for
<span class="Ux">FreeBSD 5.0</span> by <span class="An">Nate Lawson</span>
<<a class="Mt" href="mailto:nate@root.org">nate@root.org</a>>.</p>
</section>
<section class="Sh">
<h1 class="Sh" id="BUGS"><a class="permalink" href="#BUGS">BUGS</a></h1>
<p class="Pp">Currently, only the <a class="Xr">ahc(4)</a> and
<a class="Xr">isp(4)</a> drivers fully support target mode.</p>
<p class="Pp">The <a class="Xr">ahc(4)</a> driver does not support tagged
queuing in target mode.</p>
</section>
</div>
<table class="foot">
<tr>
<td class="foot-date">December 13, 2011</td>
<td class="foot-os">FreeBSD 15.0</td>
</tr>
</table>
|