1c38b150aSNate Lawson.\" Copyright (c) 2002 2c38b150aSNate Lawson.\" Nate Lawson. All rights reserved. 3c38b150aSNate Lawson.\" 4c38b150aSNate Lawson.\" Redistribution and use in source and binary forms, with or without 5c38b150aSNate Lawson.\" modification, are permitted provided that the following conditions 6c38b150aSNate Lawson.\" are met: 7c38b150aSNate Lawson.\" 1. Redistributions of source code must retain the above copyright 8c38b150aSNate Lawson.\" notice, this list of conditions and the following disclaimer. 9c38b150aSNate Lawson.\" 2. Redistributions in binary form must reproduce the above copyright 10c38b150aSNate Lawson.\" notice, this list of conditions and the following disclaimer in the 11c38b150aSNate Lawson.\" documentation and/or other materials provided with the distribution. 12c38b150aSNate Lawson.\" 3. Neither the name of the author nor the names of any co-contributors 13c38b150aSNate Lawson.\" may be used to endorse or promote products derived from this software 14c38b150aSNate Lawson.\" without specific prior written permission. 15c38b150aSNate Lawson.\" 16c38b150aSNate Lawson.\" THIS SOFTWARE IS PROVIDED BY Nate Lawson AND CONTRIBUTORS ``AS IS'' AND 17c38b150aSNate Lawson.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18c38b150aSNate Lawson.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19c38b150aSNate Lawson.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20c38b150aSNate Lawson.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21c38b150aSNate Lawson.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22c38b150aSNate Lawson.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23c38b150aSNate Lawson.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24c38b150aSNate Lawson.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25c38b150aSNate Lawson.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26c38b150aSNate Lawson.\" SUCH DAMAGE. 27c38b150aSNate Lawson.\" 28c38b150aSNate Lawson.\" $FreeBSD$ 29c38b150aSNate Lawson.\" 30c38b150aSNate Lawson.Dd November 15, 2002 31c38b150aSNate Lawson.Dt SCSI_TARGET 8 32c38b150aSNate Lawson.Os 33c38b150aSNate Lawson.Sh NAME 34c38b150aSNate Lawson.Nm scsi_target 35c38b150aSNate Lawson.Nd usermode SCSI disk emulator 36c38b150aSNate Lawson.Sh SYNOPSIS 37c38b150aSNate Lawson.Nm 38c38b150aSNate Lawson.Op Fl AdST 39c38b150aSNate Lawson.Op Fl b Ar size 40c38b150aSNate Lawson.Op Fl c Ar size 41c38b150aSNate Lawson.Op Fl s Ar size 42c38b150aSNate Lawson.Op Fl W Ar num 43a7348c92SRuslan Ermilov.Ar bus : Ns Ar target : Ns Ar lun 44c38b150aSNate Lawson.Ar filename 45c38b150aSNate Lawson.Sh DESCRIPTION 46c38b150aSNate LawsonThe 47c38b150aSNate Lawson.Nm 48a7348c92SRuslan Ermilovutility emulates a SCSI target device using the 49c38b150aSNate Lawson.Xr targ 4 50a7348c92SRuslan Ermilovdevice driver. 51a7348c92SRuslan ErmilovIt supports the basic commands of a direct access device, like 52c38b150aSNate Lawson.Xr da 4 . 53c38b150aSNate LawsonIn typical operation, it opens a control device and 54a7348c92SRuslan Ermilovenables target mode for the specified LUN. 55a7348c92SRuslan ErmilovIt then communicates with 56c38b150aSNate Lawsonthe SIM using CCBs exchanged via 57c38b150aSNate Lawson.Xr read 2 58c38b150aSNate Lawsonand 59c38b150aSNate Lawson.Xr write 2 . 60c38b150aSNate LawsonREAD and WRITE CDBs are satisfied with the specified backing store file. 61c38b150aSNate Lawson.Pp 62c38b150aSNate LawsonFor performance, all backing store accesses use 63c38b150aSNate Lawson.Xr aio 4 . 64c38b150aSNate LawsonThus, 65c38b150aSNate Lawson.Nm 66a7348c92SRuslan Ermilovrequires a kernel compiled with 67a7348c92SRuslan Ermilov.Cd "options VFS_AIO" . 68c38b150aSNate Lawson.Pp 69c38b150aSNate LawsonOptions: 70a7348c92SRuslan Ermilov.Bl -tag -width indent 71c38b150aSNate Lawson.It Fl A 72a7348c92SRuslan ErmilovEnable 16 addresses if supported by the SIM. 73a7348c92SRuslan ErmilovDefault is 8. 74c38b150aSNate Lawson.It Fl S 75a7348c92SRuslan ErmilovEnable synchronous transfers if supported by the SIM. 76a7348c92SRuslan ErmilovDefault is disabled. 77c38b150aSNate Lawson.It Fl T 78a7348c92SRuslan ErmilovEnable tagged queuing if supported by the SIM. 79a7348c92SRuslan ErmilovDefault is no tagged queuing. 80a7348c92SRuslan Ermilov.It Fl W Cm 8 | 16 | 32 81a7348c92SRuslan ErmilovEnable 16 or 32 bit wide transfers if supported by the SIM. 82a7348c92SRuslan ErmilovDefault is 8. 83c38b150aSNate Lawson.It Fl b Ar bufsize 84a7348c92SRuslan ErmilovSet buffer size for transfers. 85a7348c92SRuslan ErmilovTransfers larger than this will be split into multiple transfers. 86c38b150aSNate Lawson.It Fl c Ar sectorsize 87a7348c92SRuslan ErmilovSet sector size for emulated volume. 88a7348c92SRuslan ErmilovDefault is 512. 89c38b150aSNate Lawson.It Fl d 90c38b150aSNate LawsonEnable debugging output in 91c38b150aSNate Lawson.Nm 92c38b150aSNate Lawsonand its associated control device. 93c38b150aSNate Lawson.It Fl s Ar volsize 94a7348c92SRuslan ErmilovUse a different size for the emulated volume. 95a7348c92SRuslan ErmilovMust be less than or equal to the size of 96c38b150aSNate Lawson.Ar filename . 97068d70baSHidetoshi ShimokawaIf the number ends with a 98068d70baSHidetoshi Shimokawa.Dq Li k , 99068d70baSHidetoshi Shimokawa.Dq Li m , 100068d70baSHidetoshi Shimokawa.Dq Li g , 101068d70baSHidetoshi Shimokawa.Dq Li t , 102068d70baSHidetoshi Shimokawa.Dq Li p , 103068d70baSHidetoshi Shimokawaor 104068d70baSHidetoshi Shimokawa.Dq Li e , 105068d70baSHidetoshi Shimokawathe number is multiplied by 2^10 (1K), 2^20 (1M), 2^30 (1G), 2^40 (1T), 106068d70baSHidetoshi Shimokawa2^50 (1P) and 2^60 (1E) 107068d70baSHidetoshi Shimokawarespectively. 108c38b150aSNate Lawson.El 109c38b150aSNate Lawson.Pp 110c38b150aSNate LawsonRequired arguments: 111a7348c92SRuslan Ermilov.Bl -tag -width indent 112a7348c92SRuslan Ermilov.It Ar bus : Ns Ar target : Ns Ar lun 113a7348c92SRuslan ErmilovAttach to specified bus ID, target ID, and LUN. 114c38b150aSNate Lawson.It Ar filename 115a7348c92SRuslan ErmilovFile to use as a backing store. 116c38b150aSNate Lawson.El 117c38b150aSNate Lawson.Pp 118c38b150aSNate LawsonAll options default to the minimal functionality of SCSI-1. 119c38b150aSNate LawsonTo be safe, 120c38b150aSNate Lawson.Nm 121c38b150aSNate Lawsonchecks the SIM for the requested capability before enabling target mode. 1229cbda590SRuslan Ermilov.Sh FILES 1239cbda590SRuslan Ermilov.Bl -tag -width ".Pa /usr/share/examples/scsi_target" -compact 1249cbda590SRuslan Ermilov.It Pa /dev/targ* 1259cbda590SRuslan ErmilovControl devices. 1269cbda590SRuslan Ermilov.It Pa /usr/share/examples/scsi_target 1279cbda590SRuslan ErmilovSource directory. 1289cbda590SRuslan Ermilov.El 129a7348c92SRuslan Ermilov.Sh EXAMPLES 130c38b150aSNate LawsonCreate a 5 megabyte backing store file. 131c38b150aSNate Lawson.Pp 132a7348c92SRuslan Ermilov.Dl "dd if=/dev/zero of=vol size=1m count=5" 133a7348c92SRuslan Ermilov.Pp 134a7348c92SRuslan ErmilovEnable target mode on bus 0, target ID 1, LUN 0, using 135a7348c92SRuslan Ermilov.Pa vol 136c38b150aSNate Lawsonas the backing store for READ6/10 and WRITE6/10 commands. 137c38b150aSNate LawsonOnly the first 1000 bytes of 138a7348c92SRuslan Ermilov.Pa vol 139a7348c92SRuslan Ermilovwill be used. 140a7348c92SRuslan ErmilovDebugging information will be output. 141c38b150aSNate Lawson16-bit wide transfers will be used if the SIM supports them. 142c38b150aSNate Lawson.Pp 14385aeaa60SPawel Jakub Dawidek.Dl "scsi_target -d -s 1000 -W 16 0:1:0 vol" 144c38b150aSNate Lawson.Sh SEE ALSO 145a7348c92SRuslan Ermilov.Xr scsi 4 , 146a7348c92SRuslan Ermilov.Xr targ 4 147c38b150aSNate Lawson.Sh AUTHORS 148a7348c92SRuslan Ermilov.An -nosplit 149c38b150aSNate LawsonThe 150c38b150aSNate Lawson.Nm 151c38b150aSNate Lawsonexample first appeared in 152c38b150aSNate Lawson.Fx 3.0 153c38b150aSNate Lawsonand was written by 154c38b150aSNate Lawson.An Justin T. Gibbs . 155c38b150aSNate LawsonIt was rewritten for 156c38b150aSNate Lawson.Fx 5.0 157c38b150aSNate Lawsonby 158c38b150aSNate Lawson.An Nate Lawson Aq nate@root.org . 159