2002-11-22 22:55:51 +00:00
|
|
|
.\" 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$
|
|
|
|
.\"
|
2011-12-13 21:26:33 +00:00
|
|
|
.Dd December 13, 2011
|
2002-12-10 14:21:55 +00:00
|
|
|
.Dt TARG 4
|
2002-11-22 22:55:51 +00:00
|
|
|
.Os
|
|
|
|
.Sh NAME
|
|
|
|
.Nm targ
|
|
|
|
.Nd SCSI target emulator driver
|
|
|
|
.Sh SYNOPSIS
|
2009-10-15 11:32:05 +00:00
|
|
|
To compile this driver into the kernel,
|
|
|
|
place the following line in your
|
|
|
|
kernel configuration file:
|
|
|
|
.Bd -ragged -offset indent
|
|
|
|
.Cd "device targ"
|
|
|
|
.Ed
|
2002-11-22 22:55:51 +00:00
|
|
|
.Sh DESCRIPTION
|
|
|
|
The
|
|
|
|
.Nm
|
|
|
|
driver provides an interface for usermode programs to emulate SCSI target
|
2002-12-10 14:21:55 +00:00
|
|
|
devices.
|
|
|
|
A sample program that emulates a disk drive (similar to
|
2002-11-22 22:55:51 +00:00
|
|
|
.Xr da 4 )
|
2002-12-10 14:21:55 +00:00
|
|
|
can be found in
|
|
|
|
.Pa /usr/share/examples/scsi_target .
|
2002-11-22 22:55:51 +00:00
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Nm
|
2011-12-13 21:26:33 +00:00
|
|
|
driver supplies the control device
|
|
|
|
.Pa /dev/targ .
|
2002-11-22 22:55:51 +00:00
|
|
|
After opening the device, the file descriptor must be bound to a
|
2002-12-10 14:21:55 +00:00
|
|
|
specific bus/target/LUN and enabled to process CCBs using the
|
|
|
|
.Dv TARGIOCENABLE
|
2002-11-22 22:55:51 +00:00
|
|
|
ioctl.
|
|
|
|
The process then uses
|
|
|
|
.Xr write 2
|
|
|
|
to send CCBs to the SIM and
|
|
|
|
.Xr poll 2
|
|
|
|
or
|
|
|
|
.Xr kqueue 2
|
2002-12-10 14:21:55 +00:00
|
|
|
to see if responses are ready.
|
|
|
|
Pointers to completed CCBs are returned via
|
2002-11-22 22:55:51 +00:00
|
|
|
.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
|
2003-09-08 19:57:22 +00:00
|
|
|
.In cam/scsi/scsi_targetio.h .
|
2002-12-10 14:21:55 +00:00
|
|
|
.Bl -tag -width ".Dv TARGIOCDISABLE"
|
2002-11-22 22:55:51 +00:00
|
|
|
.It Dv TARGIOCENABLE
|
2002-12-10 14:21:55 +00:00
|
|
|
.Pq Vt "struct ioc_enable_lun"
|
2002-11-22 22:55:51 +00:00
|
|
|
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
|
2002-12-10 14:21:55 +00:00
|
|
|
The selected path (bus), target, and LUN must not already be in use or
|
2002-11-22 22:55:51 +00:00
|
|
|
.Er EADDRINUSE
|
|
|
|
is returned.
|
2002-12-10 14:21:55 +00:00
|
|
|
If
|
|
|
|
.Va grp6_len
|
|
|
|
or
|
|
|
|
.Va grp7_len
|
|
|
|
are non-zero, reception of vendor-specific commands
|
2002-11-22 22:55:51 +00:00
|
|
|
is enabled.
|
|
|
|
.It Dv TARGIOCDISABLE
|
|
|
|
Disable target mode and abort all pending CCBs.
|
2002-12-10 14:21:55 +00:00
|
|
|
The CCBs may optionally be read as they complete.
|
|
|
|
.Dv TARGIOCENABLE
|
2002-11-22 22:55:51 +00:00
|
|
|
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
|
2002-12-10 14:21:55 +00:00
|
|
|
.Pq Vt int
|
|
|
|
Enables
|
|
|
|
.Dv CAM_PERIPH
|
|
|
|
debugging if the argument is non-zero, otherwise disables
|
2002-11-22 22:55:51 +00:00
|
|
|
it.
|
|
|
|
.El
|
|
|
|
.Sh FILES
|
2002-12-10 14:21:55 +00:00
|
|
|
.Bl -tag -width ".Pa /sys/cam/scsi/scsi_target.c" -compact
|
2003-09-08 19:57:22 +00:00
|
|
|
.It In cam/scsi/scsi_targetio.h
|
2002-11-22 22:55:51 +00:00
|
|
|
describes the usermode interface.
|
|
|
|
.It Pa /sys/cam/scsi/scsi_target.c
|
|
|
|
is the driver source file.
|
2011-12-13 21:26:33 +00:00
|
|
|
.It Pa /dev/targ
|
|
|
|
is the control device.
|
2002-11-22 22:55:51 +00:00
|
|
|
.El
|
|
|
|
.Sh SEE ALSO
|
2002-12-10 14:21:55 +00:00
|
|
|
.Pa /usr/share/examples/scsi_target ,
|
2003-01-16 00:24:29 +00:00
|
|
|
.Xr ahc 4 ,
|
|
|
|
.Xr isp 4 ,
|
2002-11-22 22:55:51 +00:00
|
|
|
.Xr scsi 4
|
|
|
|
.Rs
|
|
|
|
.%T "FreeBSD Target Information"
|
2010-01-15 16:01:22 +00:00
|
|
|
.%U http://www.root.org/~nate/freebsd/
|
2002-11-22 22:55:51 +00:00
|
|
|
.Re
|
|
|
|
.Sh AUTHORS
|
2002-12-10 14:21:55 +00:00
|
|
|
.An -nosplit
|
2002-11-22 22:55:51 +00:00
|
|
|
The
|
|
|
|
.Nm
|
|
|
|
driver first appeared in
|
2002-12-10 14:21:55 +00:00
|
|
|
.Fx 3.0
|
|
|
|
and was written by
|
2002-11-22 22:55:51 +00:00
|
|
|
.An Justin T. Gibbs .
|
|
|
|
It was rewritten
|
|
|
|
for
|
2002-12-10 14:21:55 +00:00
|
|
|
.Fx 5.0
|
2002-11-22 22:55:51 +00:00
|
|
|
by
|
2014-06-26 21:46:14 +00:00
|
|
|
.An Nate Lawson Aq Mt nate@root.org .
|
2005-01-21 08:36:40 +00:00
|
|
|
.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.
|