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