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$
|
|
|
|
.\"
|
|
|
|
.Dd November 15, 2002
|
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
|
|
|
|
.Cd device targ
|
|
|
|
.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
|
|
|
|
driver supplies control devices,
|
2002-12-10 14:21:55 +00:00
|
|
|
.Pa /dev/targ0 ,
|
|
|
|
.Pa /dev/targ1 ,
|
2002-11-22 22:55:51 +00:00
|
|
|
etc.
|
2003-02-24 22:53:26 +00:00
|
|
|
If a device is already in use,
|
|
|
|
.Xr open 2
|
|
|
|
will fail and
|
2002-11-22 22:55:51 +00:00
|
|
|
.Va errno
|
|
|
|
will be set to
|
|
|
|
.Er EBUSY .
|
|
|
|
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
|
|
|
|
.Aq Pa 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
|
2002-11-22 22:55:51 +00:00
|
|
|
.It Aq Pa 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
|
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"
|
|
|
|
.%O http://www.root.org/~nate/freebsd/
|
|
|
|
.Re
|
|
|
|
.Sh BUGS
|
|
|
|
Currently, only the
|
|
|
|
.Xr ahc 4
|
|
|
|
and
|
2003-01-16 00:24:29 +00:00
|
|
|
.Xr isp 4
|
|
|
|
drivers fully support target mode.
|
2002-11-22 22:55:51 +00:00
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Xr ahc 4
|
|
|
|
driver does not support tagged queuing in target mode.
|
|
|
|
.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
|
|
|
|
.An Nate Lawson Aq nate@root.org .
|