1 #define TCM_VHOST_VERSION "v0.1"
2 #define TCM_VHOST_NAMELEN 256
3 #define TCM_VHOST_MAX_CDB_SIZE 32
6 /* Descriptor from vhost_get_vq_desc() for virt_queue segment */
8 /* virtio-scsi initiator task attribute */
10 /* virtio-scsi initiator data direction */
11 enum dma_data_direction tvc_data_direction;
12 /* Expected data transfer length from virtio-scsi header */
14 /* The Tag from include/linux/virtio_scsi.h:struct virtio_scsi_cmd_req */
16 /* The number of scatterlists associated with this cmd */
18 /* Saved unpacked SCSI LUN for tcm_vhost_submission_work() */
20 /* Pointer to the SGL formatted memory from virtio-scsi */
21 struct scatterlist *tvc_sgl;
22 /* Pointer to response */
23 struct virtio_scsi_cmd_resp __user *tvc_resp;
24 /* Pointer to vhost_scsi for our device */
25 struct vhost_scsi *tvc_vhost;
26 /* Pointer to vhost_virtqueue for the cmd */
27 struct vhost_virtqueue *tvc_vq;
28 /* Pointer to vhost nexus memory */
29 struct tcm_vhost_nexus *tvc_nexus;
30 /* The TCM I/O descriptor that is accessed via container_of() */
31 struct se_cmd tvc_se_cmd;
32 /* work item used for cmwq dispatch to tcm_vhost_submission_work() */
33 struct work_struct work;
34 /* Copy of the incoming SCSI command descriptor block (CDB) */
35 unsigned char tvc_cdb[TCM_VHOST_MAX_CDB_SIZE];
36 /* Sense buffer that will be mapped into outgoing status */
37 unsigned char tvc_sense_buf[TRANSPORT_SENSE_BUFFER];
38 /* Completed commands list, serviced from vhost worker thread */
39 struct llist_node tvc_completion_list;
42 struct tcm_vhost_nexus {
43 /* Pointer to TCM session for I_T Nexus */
44 struct se_session *tvn_se_sess;
47 struct tcm_vhost_nacl {
48 /* Binary World Wide unique Port Name for Vhost Initiator port */
50 /* ASCII formatted WWPN for Sas Initiator port */
51 char iport_name[TCM_VHOST_NAMELEN];
52 /* Returned by tcm_vhost_make_nodeacl() */
53 struct se_node_acl se_node_acl;
57 struct tcm_vhost_tpg {
58 /* Vhost port target portal group tag for TCM */
60 /* Used to track number of TPG Port/Lun Links wrt to explict I_T Nexus shutdown */
61 int tv_tpg_port_count;
62 /* Used for vhost_scsi device reference to tpg_nexus, protected by tv_tpg_mutex */
63 int tv_tpg_vhost_count;
64 /* list for tcm_vhost_list */
65 struct list_head tv_tpg_list;
66 /* Used to protect access for tpg_nexus */
67 struct mutex tv_tpg_mutex;
68 /* Pointer to the TCM VHost I_T Nexus for this TPG endpoint */
69 struct tcm_vhost_nexus *tpg_nexus;
70 /* Pointer back to tcm_vhost_tport */
71 struct tcm_vhost_tport *tport;
72 /* Returned by tcm_vhost_make_tpg() */
73 struct se_portal_group se_tpg;
74 /* Pointer back to vhost_scsi, protected by tv_tpg_mutex */
75 struct vhost_scsi *vhost_scsi;
78 struct tcm_vhost_tport {
79 /* SCSI protocol the tport is providing */
81 /* Binary World Wide unique Port Name for Vhost Target port */
83 /* ASCII formatted WWPN for Vhost Target port */
84 char tport_name[TCM_VHOST_NAMELEN];
85 /* Returned by tcm_vhost_make_tport() */
86 struct se_wwn tport_wwn;
89 struct tcm_vhost_evt {
90 /* event to be sent to guest */
91 struct virtio_scsi_event event;
92 /* event list, serviced from vhost worker thread */
93 struct llist_node list;
97 * As per request from MST, keep TCM_VHOST related ioctl defines out of
98 * linux/vhost.h (user-space) for now..
101 #include <linux/vhost.h>
104 * Used by QEMU userspace to ensure a consistent vhost-scsi ABI.
106 * ABI Rev 0: July 2012 version starting point for v3.6-rc merge candidate +
107 * RFC-v2 vhost-scsi userspace. Add GET_ABI_VERSION ioctl usage
108 * ABI Rev 1: January 2013. Ignore vhost_tpgt filed in struct vhost_scsi_target.
109 * All the targets under vhost_wwpn can be seen and used by guset.
112 #define VHOST_SCSI_ABI_VERSION 1
114 struct vhost_scsi_target {
116 char vhost_wwpn[TRANSPORT_IQN_LEN];
117 unsigned short vhost_tpgt;
118 unsigned short reserved;
121 /* VHOST_SCSI specific defines */
122 #define VHOST_SCSI_SET_ENDPOINT _IOW(VHOST_VIRTIO, 0x40, struct vhost_scsi_target)
123 #define VHOST_SCSI_CLEAR_ENDPOINT _IOW(VHOST_VIRTIO, 0x41, struct vhost_scsi_target)
124 /* Changing this breaks userspace. */
125 #define VHOST_SCSI_GET_ABI_VERSION _IOW(VHOST_VIRTIO, 0x42, int)
126 /* Set and get the events missed flag */
127 #define VHOST_SCSI_SET_EVENTS_MISSED _IOW(VHOST_VIRTIO, 0x43, __u32)
128 #define VHOST_SCSI_GET_EVENTS_MISSED _IOW(VHOST_VIRTIO, 0x44, __u32)