blob: d9e93557d669d09b3ab08d1030aa47791184db00 [file] [log] [blame]
Nicholas Bellinger057cbf42012-07-18 14:31:32 -07001#define TCM_VHOST_VERSION "v0.1"
2#define TCM_VHOST_NAMELEN 256
3#define TCM_VHOST_MAX_CDB_SIZE 32
4
5struct tcm_vhost_cmd {
6 /* Descriptor from vhost_get_vq_desc() for virt_queue segment */
7 int tvc_vq_desc;
8 /* The Tag from include/linux/virtio_scsi.h:struct virtio_scsi_cmd_req */
9 u64 tvc_tag;
10 /* The number of scatterlists associated with this cmd */
11 u32 tvc_sgl_count;
12 /* Saved unpacked SCSI LUN for tcm_vhost_submission_work() */
13 u32 tvc_lun;
14 /* Pointer to the SGL formatted memory from virtio-scsi */
15 struct scatterlist *tvc_sgl;
16 /* Pointer to response */
17 struct virtio_scsi_cmd_resp __user *tvc_resp;
18 /* Pointer to vhost_scsi for our device */
19 struct vhost_scsi *tvc_vhost;
20 /* The TCM I/O descriptor that is accessed via container_of() */
21 struct se_cmd tvc_se_cmd;
22 /* work item used for cmwq dispatch to tcm_vhost_submission_work() */
23 struct work_struct work;
24 /* Copy of the incoming SCSI command descriptor block (CDB) */
25 unsigned char tvc_cdb[TCM_VHOST_MAX_CDB_SIZE];
26 /* Sense buffer that will be mapped into outgoing status */
27 unsigned char tvc_sense_buf[TRANSPORT_SENSE_BUFFER];
28 /* Completed commands list, serviced from vhost worker thread */
29 struct list_head tvc_completion_list;
30};
31
32struct tcm_vhost_nexus {
33 /* Pointer to TCM session for I_T Nexus */
34 struct se_session *tvn_se_sess;
35};
36
37struct tcm_vhost_nacl {
38 /* Binary World Wide unique Port Name for Vhost Initiator port */
39 u64 iport_wwpn;
40 /* ASCII formatted WWPN for Sas Initiator port */
41 char iport_name[TCM_VHOST_NAMELEN];
42 /* Returned by tcm_vhost_make_nodeacl() */
43 struct se_node_acl se_node_acl;
44};
45
46struct tcm_vhost_tpg {
47 /* Vhost port target portal group tag for TCM */
48 u16 tport_tpgt;
49 /* Used to track number of TPG Port/Lun Links wrt to explict I_T Nexus shutdown */
Nicholas Bellinger101998f2012-07-30 13:30:00 -070050 int tv_tpg_port_count;
51 /* Used for vhost_scsi device reference to tpg_nexus, protected by tv_tpg_mutex */
52 int tv_tpg_vhost_count;
Nicholas Bellinger057cbf42012-07-18 14:31:32 -070053 /* list for tcm_vhost_list */
54 struct list_head tv_tpg_list;
55 /* Used to protect access for tpg_nexus */
56 struct mutex tv_tpg_mutex;
57 /* Pointer to the TCM VHost I_T Nexus for this TPG endpoint */
58 struct tcm_vhost_nexus *tpg_nexus;
59 /* Pointer back to tcm_vhost_tport */
60 struct tcm_vhost_tport *tport;
61 /* Returned by tcm_vhost_make_tpg() */
62 struct se_portal_group se_tpg;
63};
64
65struct tcm_vhost_tport {
66 /* SCSI protocol the tport is providing */
67 u8 tport_proto_id;
68 /* Binary World Wide unique Port Name for Vhost Target port */
69 u64 tport_wwpn;
70 /* ASCII formatted WWPN for Vhost Target port */
71 char tport_name[TCM_VHOST_NAMELEN];
72 /* Returned by tcm_vhost_make_tport() */
73 struct se_wwn tport_wwn;
74};
75
76/*
77 * As per request from MST, keep TCM_VHOST related ioctl defines out of
78 * linux/vhost.h (user-space) for now..
79 */
80
81#include <linux/vhost.h>
82
83/*
84 * Used by QEMU userspace to ensure a consistent vhost-scsi ABI.
85 *
86 * ABI Rev 0: July 2012 version starting point for v3.6-rc merge candidate +
87 * RFC-v2 vhost-scsi userspace. Add GET_ABI_VERSION ioctl usage
88 */
89
90#define VHOST_SCSI_ABI_VERSION 0
91
92struct vhost_scsi_target {
93 int abi_version;
Nicholas Bellinger5b7517f2012-08-16 18:56:34 -070094 char vhost_wwpn[TRANSPORT_IQN_LEN];
Nicholas Bellinger057cbf42012-07-18 14:31:32 -070095 unsigned short vhost_tpgt;
Michael S. Tsirkin6de71452012-08-18 15:44:09 -070096 unsigned short reserved;
Nicholas Bellinger057cbf42012-07-18 14:31:32 -070097};
98
99/* VHOST_SCSI specific defines */
100#define VHOST_SCSI_SET_ENDPOINT _IOW(VHOST_VIRTIO, 0x40, struct vhost_scsi_target)
101#define VHOST_SCSI_CLEAR_ENDPOINT _IOW(VHOST_VIRTIO, 0x41, struct vhost_scsi_target)
Nicholas Bellinger101998f2012-07-30 13:30:00 -0700102/* Changing this breaks userspace. */
103#define VHOST_SCSI_GET_ABI_VERSION _IOW(VHOST_VIRTIO, 0x42, int)