Skip to contentSkip to conversation

tcm_loop: Add multi-fabric Linux/SCSI LLD fabric module

RFC In review Nicholas A. Bellinger 1 participant 1 message Oct 18, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

RFC v3 21/21 tcm_loop: Add multi-fabric Linux/SCSI LLD fabric module

From: Nicholas Bellinger <[email protected]>

This patch adds the TCM_Loop Linux/SCSI LLD fabric module for accessing TCM device backstores as locally accessable SCSI LUNs in virtual SAS, FC, and iSCSI Target ports using the generic fabric TransportID and Target Port WWN naming handlers from TCM's target_core_fabric_lib.c The TCM_Loop module uses the generic fabric configfs infratructure provided by target_core_fabric_configfs.c and adds a module dependent attribute for the creation/release of the virtual I_T Nexus connected the TCM_Loop Target and Initiator Ports.

TCM_Loop can also be used with the scsi-generic driver so that STGT userspace fabric modules, QEMU-KVM and other hypervisor SCSI passthrough support can access TCM device backstore and control CDB emulation.

---
 drivers/target/Kbuild                          |    3 +
 drivers/target/Kconfig                         |    2 +
 drivers/target/tcm_loop/Kbuild                 |   11 +
 drivers/target/tcm_loop/Kconfig                |   13 +
 drivers/target/tcm_loop/tcm_loop_configfs.c    |  647 ++++++++++++++++++++++++
 drivers/target/tcm_loop/tcm_loop_configfs.h    |    2 +
 drivers/target/tcm_loop/tcm_loop_core.h        |   77 +++
 drivers/target/tcm_loop/tcm_loop_fabric.c      |  495 ++++++++++++++++++
 drivers/target/tcm_loop/tcm_loop_fabric.h      |   40 ++
 drivers/target/tcm_loop/tcm_loop_fabric_scsi.c |  618 ++++++++++++++++++++++
 drivers/target/tcm_loop/tcm_loop_fabric_scsi.h |   10 +
 11 files changed, 1918 insertions(+), 0 deletions(-)
 create mode 100644 drivers/target/tcm_loop/Kbuild
 create mode 100644 drivers/target/tcm_loop/Kconfig
 create mode 100644 drivers/target/tcm_loop/tcm_loop_configfs.c
 create mode 100644 drivers/target/tcm_loop/tcm_loop_configfs.h
 create mode 100644 drivers/target/tcm_loop/tcm_loop_core.h
 create mode 100644 drivers/target/tcm_loop/tcm_loop_fabric.c
 create mode 100644 drivers/target/tcm_loop/tcm_loop_fabric.h
 create mode 100644 drivers/target/tcm_loop/tcm_loop_fabric_scsi.c
 create mode 100644 drivers/target/tcm_loop/tcm_loop_fabric_scsi.h
drivers/target/Kbuild +3 -0
index a610f67..6d41a95 100644
@@ -25,3 +25,6 @@ obj-$(CONFIG_TARGET_CORE)	+= target_core_mod.o
 obj-$(CONFIG_TCM_IBLOCK)	+= target_core_iblock.o
 obj-$(CONFIG_TCM_FILEIO)	+= target_core_file.o
 obj-$(CONFIG_TCM_PSCSI)		+= target_core_pscsi.o
+
+# Fabric modules
+obj-$(CONFIG_TCM_LOOP_FABRIC)	+= tcm_loop/
drivers/target/Kconfig +2 -0
index 5c37653..55975fc 100644
@@ -32,3 +32,5 @@ config TCM_PSCSI
 	default y
 	---help---
 	Say Y here to enable the TCM/pSCSI subsystem plugin for non-buffered passthrough access to Linux/SCSI device
+
+source "drivers/target/tcm_loop/Kconfig"
drivers/target/tcm_loop/Kbuild new file +11 -0
new file mode 100644
index 0000000..f2c633a
@@ -0,0 +1,11 @@
+EXTRA_CFLAGS += -I$(srctree)/drivers/target/ -I$(srctree)/drivers/scsi/ -I$(srctree)/include/scsi/ -I$(srctree)/drivers/target/tcm_loop/
+
+tcm_loop-objs			:= tcm_loop_fabric.o \
+				   tcm_loop_fabric_scsi.o \
+				   tcm_loop_configfs.o \
+
+obj-$(CONFIG_TCM_LOOP_FABRIC)	+= tcm_loop.o
+
+ifdef CONFIG_TCM_LOOP_CDB_DEBUG
+EXTRA_CFLAGS			+= -DTCM_LOOP_CDB_DEBUG
+endif
drivers/target/tcm_loop/Kconfig new file +13 -0
new file mode 100644
index 0000000..7520a6d
@@ -0,0 +1,13 @@
+config TCM_LOOP_FABRIC
+        tristate "TCM Virtual SAS target and Linux/SCSI LDD fabric loopback module "
+        depends on TARGET_CORE && CONFIGFS_FS
+        default n
+        ---help---
+        Say Y here to enable the TCM Virtual SAS target and Linux/SCSI LDD fabric loopback module
+
+config TCM_LOOP_CDB_DEBUG
+	tristate "TCM loopback fabric module CDB debug code"
+	depends on TARGET_CORE && CONFIGFS_FS && TCM_LOOP_FABRIC
+	default n
+	---help---
+	Say Y here to enable the TCM loopback fabric module CDB debug code
drivers/target/tcm_loop/tcm_loop_configfs.c new file +647 -0

647 lines not on this page · raw message

drivers/target/tcm_loop/tcm_loop_configfs.h new file +2 -0
new file mode 100644
index 0000000..f46aa4b
@@ -0,0 +1,2 @@
+extern int tcm_loop_register_configfs(void);
+extern void tcm_loop_deregister_configfs(void);
drivers/target/tcm_loop/tcm_loop_core.h new file +77 -0

77 lines not on this page · raw message

drivers/target/tcm_loop/tcm_loop_fabric.c new file +495 -0

495 lines not on this page · raw message

drivers/target/tcm_loop/tcm_loop_fabric.h new file +40 -0
new file mode 100644
index 0000000..45af1f9
@@ -0,0 +1,40 @@
+extern char *tcm_loop_get_fabric_name(void);
+extern u8 tcm_loop_get_fabric_proto_ident(struct se_portal_group *);
+extern char *tcm_loop_get_endpoint_wwn(struct se_portal_group *);
+extern u16 tcm_loop_get_tag(struct se_portal_group *);
+extern u32 tcm_loop_get_default_depth(struct se_portal_group *);
+extern u32 tcm_loop_get_pr_transport_id(struct se_portal_group *, struct se_node_acl *,
+				struct t10_pr_registration *, int *,
+				unsigned char *);
+extern u32 tcm_loop_get_pr_transport_id_len(struct se_portal_group *,
+				struct se_node_acl *, struct t10_pr_registration *,
+				int *);
+extern char *tcm_loop_parse_pr_out_transport_id(struct se_portal_group *,
+				const char *, u32 *, char **);
+extern int tcm_loop_check_demo_mode(struct se_portal_group *);
+extern int tcm_loop_check_demo_mode_cache(struct se_portal_group *);
+extern int tcm_loop_check_demo_mode_write_protect(struct se_portal_group *);
+extern int tcm_loop_check_prod_mode_write_protect(struct se_portal_group *);
+extern struct se_node_acl *tcm_loop_tpg_alloc_fabric_acl(
+				struct se_portal_group *);
+void tcm_loop_tpg_release_fabric_acl(struct se_portal_group *, struct se_node_acl *);
+extern u32 tcm_loop_get_inst_index(struct se_portal_group *);
+extern void tcm_loop_new_cmd_failure(struct se_cmd *);
+extern int tcm_loop_is_state_remove(struct se_cmd *);
+extern int tcm_loop_sess_logged_in(struct se_session *);
+extern u32 tcm_loop_sess_get_index(struct se_session *);
+extern void tcm_loop_set_default_node_attributes(struct se_node_acl *);
+extern u32 tcm_loop_get_task_tag(struct se_cmd *);
+extern int tcm_loop_get_cmd_state(struct se_cmd *);
+extern int tcm_loop_shutdown_session(struct se_session *);
+extern void tcm_loop_close_session(struct se_session *);
+extern void tcm_loop_stop_session(struct se_session *, int, int);
+extern void tcm_loop_fall_back_to_erl0(struct se_session *);
+extern int tcm_loop_write_pending(struct se_cmd *);
+extern int tcm_loop_write_pending_status(struct se_cmd *);
+extern int tcm_loop_queue_data_in(struct se_cmd *);
+extern int tcm_loop_queue_status(struct se_cmd *);
+extern int tcm_loop_queue_tm_rsp(struct se_cmd *);
+extern u16 tcm_loop_set_fabric_sense_len(struct se_cmd *, u32);
+extern u16 tcm_loop_get_fabric_sense_len(void);
+extern u64 tcm_loop_pack_lun(unsigned int);
drivers/target/tcm_loop/tcm_loop_fabric_scsi.c new file +618 -0

618 lines not on this page · raw message

drivers/target/tcm_loop/tcm_loop_fabric_scsi.h new file +10 -0
new file mode 100644
index 0000000..bcba89b
@@ -0,0 +1,10 @@
+extern struct kmem_cache *tcm_loop_cmd_cache;
+
+extern int tcm_loop_new_cmd_map(struct se_cmd *);
+extern void tcm_loop_check_stop_free(struct se_cmd *);
+extern void tcm_loop_deallocate_core_cmd(struct se_cmd *);
+extern void tcm_loop_scsi_forget_host(struct Scsi_Host *);
+extern void tcm_loop_deallocate_core_cmd(struct se_cmd *);
+extern int tcm_loop_setup_hba_bus(struct tcm_loop_hba *, int);
+extern int tcm_loop_alloc_core_bus(void);
+extern void tcm_loop_release_core_bus(void);
Signature · 1 line
1.7.3.1