diff options
author | Nicholas Bellinger <nab@linux-iscsi.org> | 2012-07-18 17:31:32 -0400 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2012-07-29 16:49:10 -0400 |
commit | 057cbf49a1f08297877e46c82f707b1bfea806a8 (patch) | |
tree | 44b0d6a8637f61532bf36a9cdee4c62f69faed27 /drivers/vhost/tcm_vhost.h | |
parent | bdc0077af574800d24318b6945cf2344e8dbb050 (diff) |
tcm_vhost: Initial merge for vhost level target fabric driver
This patch adds the initial code for tcm_vhost, a Vhost level TCM
fabric driver for virtio SCSI initiators into KVM guest.
This code is currently up and running on v3.5-rc2 host+guest
from target-pending/for-next-merge.
Using tcm_vhost requires Zhi's -> Stefan -> nab's qemu vhost-scsi tree here:
http://git.kernel.org/?p=virt/kvm/nab/qemu-kvm.git;a=shortlog;h=refs/heads/vhost-scsi
--
Changelog v4 -> v5:
Expose ABI version via VHOST_SCSI_GET_ABI_VERSION + use Rev 0 as
starting point for v3.6-rc code (Stefan + ALiguori + nab)
Convert vhost_scsi_handle_vq() to vq_err() (nab + MST)
Minor style fixes from checkpatch (nab)
Changelog v3 -> v4:
Rename vhost_vring_target -> vhost_scsi_target (mst + nab)
Use TRANSPORT_IQN_LEN in vhost_scsi_target->vhost_wwpn[] def (nab)
Move back to drivers/vhost/, and just use drivers/vhost/Kconfig.tcm (mst)
Move TCM_VHOST related ioctl defines from include/linux/vhost.h ->
drivers/vhost/tcm_vhost.h as requested by MST (nab)
Move Kbuild.tcm include from drivers/staging -> drivers/vhost/, and
just use 'if STAGING' around 'source drivers/vhost/Kbuild.tcm'
Changelog v2 -> v3:
Unlock on error in tcm_vhost_drop_nexus() (DanC)
Fix strlen() doesn't count the terminator (DanC)
Call kfree() on an error path (DanC)
Convert tcm_vhost_write_pending to use target_execute_cmd (hch + nab)
Fix another strlen() off by one in tcm_vhost_make_tport (DanC)
Add option under drivers/staging/Kconfig, and move to drivers/vhost/tcm/
as requested by MST (nab)
Changelog v1 -> v2:
Fix tv_cmd completion -> release SGL memory leak (nab)
Fix sparse warnings for static variable usage ((Fengguang Wu)
Fix sparse warnings for min() typing + printk format specs (Fengguang Wu)
Convert to cmwq submission for I/O dispatch (nab + hch)
Changelog v0 -> v1:
Merge into single source + header file, and move to drivers/vhost/
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Cc: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Cc: Anthony Liguori <aliguori@us.ibm.com>
Cc: Zhi Yong Wu <wuzhy@cn.ibm.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Hannes Reinecke <hare@suse.de>
Cc: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers/vhost/tcm_vhost.h')
-rw-r--r-- | drivers/vhost/tcm_vhost.h | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/drivers/vhost/tcm_vhost.h b/drivers/vhost/tcm_vhost.h new file mode 100644 index 000000000000..c983ed21e413 --- /dev/null +++ b/drivers/vhost/tcm_vhost.h | |||
@@ -0,0 +1,101 @@ | |||
1 | #define TCM_VHOST_VERSION "v0.1" | ||
2 | #define TCM_VHOST_NAMELEN 256 | ||
3 | #define TCM_VHOST_MAX_CDB_SIZE 32 | ||
4 | |||
5 | struct 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 | |||
32 | struct tcm_vhost_nexus { | ||
33 | /* Pointer to TCM session for I_T Nexus */ | ||
34 | struct se_session *tvn_se_sess; | ||
35 | }; | ||
36 | |||
37 | struct 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 | |||
46 | struct 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 */ | ||
50 | atomic_t tv_tpg_port_count; | ||
51 | /* Used for vhost_scsi device reference to tpg_nexus */ | ||
52 | atomic_t tv_tpg_vhost_count; | ||
53 | /* 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 | |||
65 | struct 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 | |||
92 | struct vhost_scsi_target { | ||
93 | int abi_version; | ||
94 | unsigned char vhost_wwpn[TRANSPORT_IQN_LEN]; | ||
95 | unsigned short vhost_tpgt; | ||
96 | }; | ||
97 | |||
98 | /* VHOST_SCSI specific defines */ | ||
99 | #define VHOST_SCSI_SET_ENDPOINT _IOW(VHOST_VIRTIO, 0x40, struct vhost_scsi_target) | ||
100 | #define VHOST_SCSI_CLEAR_ENDPOINT _IOW(VHOST_VIRTIO, 0x41, struct vhost_scsi_target) | ||
101 | #define VHOST_SCSI_GET_ABI_VERSION _IOW(VHOST_VIRTIO, 0x42, struct vhost_scsi_target) | ||