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