xref: /qemu/include/hw/virtio/vhost-scsi.h (revision 5e9be92d775208cf6cc9bf9a592853888046239e)
1*5e9be92dSNicholas Bellinger /*
2*5e9be92dSNicholas Bellinger  * vhost_scsi host device
3*5e9be92dSNicholas Bellinger  *
4*5e9be92dSNicholas Bellinger  * Copyright IBM, Corp. 2011
5*5e9be92dSNicholas Bellinger  *
6*5e9be92dSNicholas Bellinger  * Authors:
7*5e9be92dSNicholas Bellinger  *  Stefan Hajnoczi   <stefanha@linux.vnet.ibm.com>
8*5e9be92dSNicholas Bellinger  *
9*5e9be92dSNicholas Bellinger  * This work is licensed under the terms of the GNU LGPL, version 2 or later.
10*5e9be92dSNicholas Bellinger  * See the COPYING.LIB file in the top-level directory.
11*5e9be92dSNicholas Bellinger  *
12*5e9be92dSNicholas Bellinger  */
13*5e9be92dSNicholas Bellinger 
14*5e9be92dSNicholas Bellinger #ifndef VHOST_SCSI_H
15*5e9be92dSNicholas Bellinger #define VHOST_SCSI_H
16*5e9be92dSNicholas Bellinger 
17*5e9be92dSNicholas Bellinger #include "qemu-common.h"
18*5e9be92dSNicholas Bellinger #include "hw/qdev.h"
19*5e9be92dSNicholas Bellinger #include "hw/virtio/virtio-scsi.h"
20*5e9be92dSNicholas Bellinger #include "hw/virtio/vhost.h"
21*5e9be92dSNicholas Bellinger 
22*5e9be92dSNicholas Bellinger /*
23*5e9be92dSNicholas Bellinger  * Used by QEMU userspace to ensure a consistent vhost-scsi ABI.
24*5e9be92dSNicholas Bellinger  *
25*5e9be92dSNicholas Bellinger  * ABI Rev 0: July 2012 version starting point for v3.6-rc merge candidate +
26*5e9be92dSNicholas Bellinger  *            RFC-v2 vhost-scsi userspace.  Add GET_ABI_VERSION ioctl usage
27*5e9be92dSNicholas Bellinger  * ABI Rev 1: January 2013. Ignore vhost_tpgt filed in struct vhost_scsi_target.
28*5e9be92dSNicholas Bellinger  * 	      All the targets under vhost_wwpn can be seen and used by guest.
29*5e9be92dSNicholas Bellinger  */
30*5e9be92dSNicholas Bellinger 
31*5e9be92dSNicholas Bellinger #define VHOST_SCSI_ABI_VERSION 1
32*5e9be92dSNicholas Bellinger 
33*5e9be92dSNicholas Bellinger /* TODO #include <linux/vhost.h> properly */
34*5e9be92dSNicholas Bellinger /* For VHOST_SCSI_SET_ENDPOINT/VHOST_SCSI_CLEAR_ENDPOINT ioctl */
35*5e9be92dSNicholas Bellinger struct vhost_scsi_target {
36*5e9be92dSNicholas Bellinger     int abi_version;
37*5e9be92dSNicholas Bellinger     char vhost_wwpn[224];
38*5e9be92dSNicholas Bellinger     unsigned short vhost_tpgt;
39*5e9be92dSNicholas Bellinger     unsigned short reserved;
40*5e9be92dSNicholas Bellinger };
41*5e9be92dSNicholas Bellinger 
42*5e9be92dSNicholas Bellinger enum vhost_scsi_vq_list {
43*5e9be92dSNicholas Bellinger     VHOST_SCSI_VQ_CONTROL = 0,
44*5e9be92dSNicholas Bellinger     VHOST_SCSI_VQ_EVENT = 1,
45*5e9be92dSNicholas Bellinger     VHOST_SCSI_VQ_NUM_FIXED = 2,
46*5e9be92dSNicholas Bellinger };
47*5e9be92dSNicholas Bellinger 
48*5e9be92dSNicholas Bellinger #define VHOST_VIRTIO 0xAF
49*5e9be92dSNicholas Bellinger #define VHOST_SCSI_SET_ENDPOINT _IOW(VHOST_VIRTIO, 0x40, struct vhost_scsi_target)
50*5e9be92dSNicholas Bellinger #define VHOST_SCSI_CLEAR_ENDPOINT _IOW(VHOST_VIRTIO, 0x41, struct vhost_scsi_target)
51*5e9be92dSNicholas Bellinger #define VHOST_SCSI_GET_ABI_VERSION _IOW(VHOST_VIRTIO, 0x42, int)
52*5e9be92dSNicholas Bellinger 
53*5e9be92dSNicholas Bellinger #define TYPE_VHOST_SCSI "vhost-scsi"
54*5e9be92dSNicholas Bellinger #define VHOST_SCSI(obj) \
55*5e9be92dSNicholas Bellinger         OBJECT_CHECK(VHostSCSI, (obj), TYPE_VHOST_SCSI)
56*5e9be92dSNicholas Bellinger 
57*5e9be92dSNicholas Bellinger typedef struct VHostSCSI {
58*5e9be92dSNicholas Bellinger     VirtIOSCSICommon parent_obj;
59*5e9be92dSNicholas Bellinger 
60*5e9be92dSNicholas Bellinger     Error *migration_blocker;
61*5e9be92dSNicholas Bellinger 
62*5e9be92dSNicholas Bellinger     struct vhost_dev dev;
63*5e9be92dSNicholas Bellinger } VHostSCSI;
64*5e9be92dSNicholas Bellinger 
65*5e9be92dSNicholas Bellinger #define DEFINE_VHOST_SCSI_PROPERTIES(_state, _conf_field) \
66*5e9be92dSNicholas Bellinger     DEFINE_PROP_STRING("vhostfd", _state, _conf_field.vhostfd), \
67*5e9be92dSNicholas Bellinger     DEFINE_PROP_STRING("wwpn", _state, _conf_field.wwpn), \
68*5e9be92dSNicholas Bellinger     DEFINE_PROP_UINT32("num_queues", _state, _conf_field.num_queues, 1), \
69*5e9be92dSNicholas Bellinger     DEFINE_PROP_UINT32("max_sectors", _state, _conf_field.max_sectors, 0xFFFF), \
70*5e9be92dSNicholas Bellinger     DEFINE_PROP_UINT32("cmd_per_lun", _state, _conf_field.cmd_per_lun, 128)
71*5e9be92dSNicholas Bellinger 
72*5e9be92dSNicholas Bellinger 
73*5e9be92dSNicholas Bellinger #endif
74