tcm_vhost.h 3.3 KB

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