1.\" $OpenBSD: vscsi.4,v 1.14 2017/09/12 15:06:20 schwarze Exp $ 2.\" 3.\" Copyright (c) 2008 David Gwynne <dlg@openbsd.org> 4.\" 5.\" Permission to use, copy, modify, and distribute this software for any 6.\" purpose with or without fee is hereby granted, provided that the above 7.\" copyright notice and this permission notice appear in all copies. 8.\" 9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16.\" 17.Dd $Mdocdate: September 12 2017 $ 18.Dt VSCSI 4 19.Os 20.Sh NAME 21.Nm vscsi 22.Nd virtual SCSI controller 23.Sh SYNOPSIS 24.Cd "vscsi0 at root" 25.Pp 26.In sys/types.h 27.In sys/ioctl.h 28.In scsi/scsi_all.h 29.In dev/vscsivar.h 30.Sh DESCRIPTION 31The 32.Nm 33device takes commands from the kernel SCSI midlayer and makes them available 34to userland for handling. 35Using this interface it is possible to implement virtual SCSI devices that are 36usable by the kernel. 37.Pp 38The following 39.Xr ioctl 2 40commands are provided to allow userland to dequeue SCSI commands and reply to 41them: 42.Pp 43.Bl -tag -width Ds -compact 44.It Dv VSCSI_I2T Fa "struct vscsi_ioc_i2t *" 45Dequeue a SCSI command. 46If no SCSI commands are available to dequeue, 47.Xr ioctl 2 48will fail and set 49.Va errno 50to 51.Dv EAGAIN . 52.Pp 53When one or more SCSI commands are available to dequeue, 54.Xr select 2 55will indicate the descriptor as ready to read. 56.Bd -literal -offset indent 57struct vscsi_ioc_i2t { 58 int tag; 59 60 u_int target; 61 u_int lun; 62 63 struct scsi_generic cmd; 64 size_t cmdlen; 65 66 size_t datalen; 67 int direction; 68#define VSCSI_DIR_NONE 0 69#define VSCSI_DIR_READ 1 70#define VSCSI_DIR_WRITE 2 71}; 72.Ed 73.Pp 74.It Dv VSCSI_DATA_READ Fa "struct vscsi_ioc_data *" 75.It Dv VSCSI_DATA_WRITE Fa "struct vscsi_ioc_data *" 76Read or write data in response to a SCSI command identified by tag. 77.Bd -literal -offset indent 78struct vscsi_ioc_data { 79 int tag; 80 81 void * data; 82 size_t datalen; 83}; 84.Ed 85.Pp 86.It Dv VSCSI_T2I Fa "struct vscsi_ioc_t2i *" 87Signal completion of a SCSI command identified by tag. 88.Bd -literal -offset indent 89struct vscsi_ioc_t2i { 90 int tag; 91 92 int status; 93#define VSCSI_STAT_DONE 0 94#define VSCSI_STAT_SENSE 1 95#define VSCSI_STAT_RESET 2 96#define VSCSI_STAT_ERR 3 97 struct scsi_sense_data sense; 98}; 99.Ed 100.Pp 101.It Dv VSCSI_REQPROBE Fa "struct vscsi_ioc_devevent *" 102.It Dv VSCSI_REQDETACH Fa "struct vscsi_ioc_devevent *" 103Request a probe or a detach of the device at the addresses specified by the 104target and lun fields. 105.Bd -literal -offset indent 106struct vscsi_ioc_devevent { 107 u_int target; 108 u_int lun; 109}; 110.Ed 111.El 112.Sh FILES 113.Bl -tag -width /dev/vscsi0 114.It /dev/vscsi0 115.El 116.Sh SEE ALSO 117.Xr ioctl 2 , 118.Xr intro 4 , 119.Xr scsi 4 120.Sh HISTORY 121The 122.Nm 123driver first appeared in 124.Ox 4.5 . 125.Sh AUTHORS 126.An David Gwynne Aq Mt dlg@openbsd.org . 127