[PATCH -v2] target: clean up get_fabric_proto_ident

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add a protocol identifier field to the target template instead of
the .get_fabric_proto_ident method.

Signed-off-by: Ming Lin <mlin@xxxxxxxxxx>
---
 drivers/infiniband/ulp/srpt/ib_srpt.c        |  7 +----
 drivers/scsi/qla2xxx/tcm_qla2xxx.c           | 21 ++-----------
 drivers/target/iscsi/iscsi_target_configfs.c |  2 +-
 drivers/target/loopback/tcm_loop.c           | 19 +++---------
 drivers/target/sbp/sbp_target.c              | 14 +--------
 drivers/target/target_core_configfs.c        |  4 ---
 drivers/target/target_core_fabric_lib.c      | 45 ++++++++--------------------
 drivers/target/target_core_pr.c              |  9 +++---
 drivers/target/target_core_spc.c             | 12 +++-----
 drivers/target/tcm_fc/tfc_conf.c             |  2 +-
 drivers/usb/gadget/legacy/tcm_usb_gadget.c   | 19 +-----------
 drivers/vhost/scsi.c                         | 18 ++---------
 drivers/xen/xen-scsiback.c                   | 18 ++---------
 include/target/target_core_fabric.h          |  7 ++---
 14 files changed, 40 insertions(+), 157 deletions(-)

v2:
- use scsi_protocol instead of fabric_proto_ident (Bart Van Assche)
- remove now unused {sas,fc,iscsi}_get_fabric_proto_ident
v1:
- based on hch's target-nacl-cleanup branch

diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c
index 6e9aba5..b99afd9 100644
--- a/drivers/infiniband/ulp/srpt/ib_srpt.c
+++ b/drivers/infiniband/ulp/srpt/ib_srpt.c
@@ -3400,11 +3400,6 @@ static char *srpt_get_fabric_name(void)
 	return "srpt";
 }
 
-static u8 srpt_get_fabric_proto_ident(struct se_portal_group *se_tpg)
-{
-	return SCSI_TRANSPORTID_PROTOCOLID_SRP;
-}
-
 static char *srpt_get_fabric_wwn(struct se_portal_group *tpg)
 {
 	struct srpt_port *sport = container_of(tpg, struct srpt_port, port_tpg_1);
@@ -3868,8 +3863,8 @@ static struct configfs_attribute *srpt_wwn_attrs[] = {
 
 static struct target_core_fabric_ops srpt_template = {
 	.node_acl_size			= sizeof(struct srpt_node_acl),
+	.scsi_protocol			= SCSI_TRANSPORTID_PROTOCOLID_SRP,
 	.get_fabric_name		= srpt_get_fabric_name,
-	.get_fabric_proto_ident		= srpt_get_fabric_proto_ident,
 	.tpg_get_wwn			= srpt_get_fabric_wwn,
 	.tpg_get_tag			= srpt_get_tag,
 	.tpg_get_pr_transport_id	= srpt_get_pr_transport_id,
diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
index f808ef1..b7c5b27 100644
--- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c
+++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
@@ -191,23 +191,6 @@ static char *tcm_qla2xxx_npiv_get_fabric_name(void)
 	return "qla2xxx_npiv";
 }
 
-static u8 tcm_qla2xxx_get_fabric_proto_ident(struct se_portal_group *se_tpg)
-{
-	struct tcm_qla2xxx_tpg *tpg = container_of(se_tpg,
-				struct tcm_qla2xxx_tpg, se_tpg);
-	struct tcm_qla2xxx_lport *lport = tpg->lport;
-	u8 proto_id;
-
-	switch (lport->lport_proto_id) {
-	case SCSI_PROTOCOL_FCP:
-	default:
-		proto_id = fc_get_fabric_proto_ident(se_tpg);
-		break;
-	}
-
-	return proto_id;
-}
-
 static char *tcm_qla2xxx_get_fabric_wwn(struct se_portal_group *se_tpg)
 {
 	struct tcm_qla2xxx_tpg *tpg = container_of(se_tpg,
@@ -1910,8 +1893,8 @@ static struct configfs_attribute *tcm_qla2xxx_wwn_attrs[] = {
 
 static struct target_core_fabric_ops tcm_qla2xxx_ops = {
 	.node_acl_size			= sizeof(struct tcm_qla2xxx_nacl),
+	.scsi_protocol			= SCSI_PROTOCOL_FCP,
 	.get_fabric_name		= tcm_qla2xxx_get_fabric_name,
-	.get_fabric_proto_ident		= tcm_qla2xxx_get_fabric_proto_ident,
 	.tpg_get_wwn			= tcm_qla2xxx_get_fabric_wwn,
 	.tpg_get_tag			= tcm_qla2xxx_get_tag,
 	.tpg_get_pr_transport_id	= tcm_qla2xxx_get_pr_transport_id,
@@ -1954,8 +1937,8 @@ static struct target_core_fabric_ops tcm_qla2xxx_ops = {
 
 static struct target_core_fabric_ops tcm_qla2xxx_npiv_ops = {
 	.node_acl_size			= sizeof(struct tcm_qla2xxx_nacl),
+	.scsi_protocol			= SCSI_PROTOCOL_FCP,
 	.get_fabric_name		= tcm_qla2xxx_npiv_get_fabric_name,
-	.get_fabric_proto_ident		= tcm_qla2xxx_get_fabric_proto_ident,
 	.tpg_get_wwn			= tcm_qla2xxx_get_fabric_wwn,
 	.tpg_get_tag			= tcm_qla2xxx_get_tag,
 	.tpg_get_pr_transport_id	= tcm_qla2xxx_get_pr_transport_id,
diff --git a/drivers/target/iscsi/iscsi_target_configfs.c b/drivers/target/iscsi/iscsi_target_configfs.c
index b90aea5..e5107a2 100644
--- a/drivers/target/iscsi/iscsi_target_configfs.c
+++ b/drivers/target/iscsi/iscsi_target_configfs.c
@@ -1951,8 +1951,8 @@ int iscsi_target_register_configfs(void)
 	 * Setup the fabric API of function pointers used by target_core_mod..
 	 */
 	fabric->tf_ops.node_acl_size = sizeof(struct iscsi_node_acl);
+	fabric->tf_ops.scsi_protocol = SCSI_PROTOCOL_ISCSI;
 	fabric->tf_ops.get_fabric_name = &iscsi_get_fabric_name;
-	fabric->tf_ops.get_fabric_proto_ident = &iscsi_get_fabric_proto_ident;
 	fabric->tf_ops.tpg_get_wwn = &lio_tpg_get_endpoint_wwn;
 	fabric->tf_ops.tpg_get_tag = &lio_tpg_get_tag;
 	fabric->tf_ops.tpg_get_default_depth = &lio_tpg_get_default_depth;
diff --git a/drivers/target/loopback/tcm_loop.c b/drivers/target/loopback/tcm_loop.c
index f052551..4a85723 100644
--- a/drivers/target/loopback/tcm_loop.c
+++ b/drivers/target/loopback/tcm_loop.c
@@ -532,20 +532,7 @@ static u8 tcm_loop_get_fabric_proto_ident(struct se_portal_group *se_tpg)
 	 * Based upon tl_proto_id, TCM_Loop emulates the requested fabric
 	 * ProtocolID using target_core_fabric_lib.c symbols.
 	 */
-	switch (tl_hba->tl_proto_id) {
-	case SCSI_PROTOCOL_SAS:
-		return sas_get_fabric_proto_ident(se_tpg);
-	case SCSI_PROTOCOL_FCP:
-		return fc_get_fabric_proto_ident(se_tpg);
-	case SCSI_PROTOCOL_ISCSI:
-		return iscsi_get_fabric_proto_ident(se_tpg);
-	default:
-		pr_err("Unknown tl_proto_id: 0x%02x, using"
-			" SAS emulation\n", tl_hba->tl_proto_id);
-		break;
-	}
-
-	return sas_get_fabric_proto_ident(se_tpg);
+	return target_get_fabric_proto_ident(tl_hba->tl_proto_id);
 }
 
 static char *tcm_loop_get_endpoint_wwn(struct se_portal_group *se_tpg)
@@ -1215,6 +1202,9 @@ static struct se_portal_group *tcm_loop_make_naa_tpg(
 	if (ret < 0)
 		return ERR_PTR(-ENOMEM);
 
+	tcm_loop_fabric_configfs->tf_ops.scsi_protocol =
+		tcm_loop_get_fabric_proto_ident(&tl_tpg->tl_se_tpg);
+
 	pr_debug("TCM_Loop_ConfigFS: Allocated Emulated %s"
 		" Target Port %s,t,0x%04lx\n", tcm_loop_dump_proto_id(tl_hba),
 		config_item_name(&wwn->wwn_group.cg_item), tpgt);
@@ -1378,7 +1368,6 @@ static int tcm_loop_register_configfs(void)
 	 * Setup the fabric API of function pointers used by target_core_mod
 	 */
 	fabric->tf_ops.get_fabric_name = &tcm_loop_get_fabric_name;
-	fabric->tf_ops.get_fabric_proto_ident = &tcm_loop_get_fabric_proto_ident;
 	fabric->tf_ops.tpg_get_wwn = &tcm_loop_get_endpoint_wwn;
 	fabric->tf_ops.tpg_get_tag = &tcm_loop_get_tag;
 	fabric->tf_ops.tpg_get_pr_transport_id = &tcm_loop_get_pr_transport_id;
diff --git a/drivers/target/sbp/sbp_target.c b/drivers/target/sbp/sbp_target.c
index c30bbc7..72c80c9 100644
--- a/drivers/target/sbp/sbp_target.c
+++ b/drivers/target/sbp/sbp_target.c
@@ -1833,18 +1833,6 @@ static int sbp_check_stop_free(struct se_cmd *se_cmd)
 	return 1;
 }
 
-/*
- * Handlers for Serial Bus Protocol 2/3 (SBP-2 / SBP-3)
- */
-static u8 sbp_get_fabric_proto_ident(struct se_portal_group *se_tpg)
-{
-	/*
-	 * Return a IEEE 1394 SCSI Protocol identifier for loopback operations
-	 * This is defined in section 7.5.1 Table 362 in spc4r17
-	 */
-	return SCSI_PROTOCOL_SBP;
-}
-
 static u32 sbp_get_pr_transport_id(
 	struct se_portal_group *se_tpg,
 	struct se_node_acl *se_nacl,
@@ -2433,8 +2421,8 @@ static struct configfs_attribute *sbp_tpg_attrib_attrs[] = {
 };
 
 static struct target_core_fabric_ops sbp_ops = {
+	.scsi_protocol			= SCSI_PROTOCOL_SBP,
 	.get_fabric_name		= sbp_get_fabric_name,
-	.get_fabric_proto_ident		= sbp_get_fabric_proto_ident,
 	.tpg_get_wwn			= sbp_get_fabric_wwn,
 	.tpg_get_tag			= sbp_get_tag,
 	.tpg_get_pr_transport_id	= sbp_get_pr_transport_id,
diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c
index 96ecb3d..30847ec 100644
--- a/drivers/target/target_core_configfs.c
+++ b/drivers/target/target_core_configfs.c
@@ -379,10 +379,6 @@ static int target_fabric_tf_ops_check(
 		pr_err("Missing tfo->get_fabric_name()\n");
 		return -EINVAL;
 	}
-	if (!tfo->get_fabric_proto_ident) {
-		pr_err("Missing tfo->get_fabric_proto_ident()\n");
-		return -EINVAL;
-	}
 	if (!tfo->tpg_get_wwn) {
 		pr_err("Missing tfo->tpg_get_wwn()\n");
 		return -EINVAL;
diff --git a/drivers/target/target_core_fabric_lib.c b/drivers/target/target_core_fabric_lib.c
index 35bfe77..7cf4e31 100644
--- a/drivers/target/target_core_fabric_lib.c
+++ b/drivers/target/target_core_fabric_lib.c
@@ -39,18 +39,20 @@
 #include "target_core_internal.h"
 #include "target_core_pr.h"
 
-/*
- * Handlers for Serial Attached SCSI (SAS)
- */
-u8 sas_get_fabric_proto_ident(struct se_portal_group *se_tpg)
+u8 target_get_fabric_proto_ident(u8 proto_id)
 {
-	/*
-	 * Return a SAS Serial SCSI Protocol identifier for loopback operations
-	 * This is defined in  section 7.5.1 Table 362 in spc4r17
-	 */
-	return 0x6;
+	switch (proto_id) {
+	case SCSI_PROTOCOL_SAS:
+	case SCSI_PROTOCOL_FCP:
+	case SCSI_PROTOCOL_ISCSI:
+		return proto_id;
+	default:
+		pr_err("Unknown proto_id: 0x%02x, using"
+			" SAS emulation\n", proto_id);
+	}
+	return SCSI_PROTOCOL_SAS;
 }
-EXPORT_SYMBOL(sas_get_fabric_proto_ident);
+EXPORT_SYMBOL(target_get_fabric_proto_ident);
 
 u32 sas_get_pr_transport_id(
 	struct se_portal_group *se_tpg,
@@ -125,15 +127,6 @@ char *sas_parse_pr_out_transport_id(
 }
 EXPORT_SYMBOL(sas_parse_pr_out_transport_id);
 
-/*
- * Handlers for Fibre Channel Protocol (FCP)
- */
-u8 fc_get_fabric_proto_ident(struct se_portal_group *se_tpg)
-{
-	return 0x0;	/* 0 = fcp-2 per SPC4 section 7.5.1 */
-}
-EXPORT_SYMBOL(fc_get_fabric_proto_ident);
-
 u32 fc_get_pr_transport_id_len(
 	struct se_portal_group *se_tpg,
 	struct se_node_acl *se_nacl,
@@ -205,20 +198,6 @@ char *fc_parse_pr_out_transport_id(
 }
 EXPORT_SYMBOL(fc_parse_pr_out_transport_id);
 
-/*
- * Handlers for Internet Small Computer Systems Interface (iSCSI)
- */
-
-u8 iscsi_get_fabric_proto_ident(struct se_portal_group *se_tpg)
-{
-	/*
-	 * This value is defined for "Internet SCSI (iSCSI)"
-	 * in spc4r17 section 7.5.1 Table 362
-	 */
-	return 0x5;
-}
-EXPORT_SYMBOL(iscsi_get_fabric_proto_ident);
-
 u32 iscsi_get_pr_transport_id(
 	struct se_portal_group *se_tpg,
 	struct se_node_acl *se_nacl,
diff --git a/drivers/target/target_core_pr.c b/drivers/target/target_core_pr.c
index 7436fda..a9e5fc7 100644
--- a/drivers/target/target_core_pr.c
+++ b/drivers/target/target_core_pr.c
@@ -1552,14 +1552,13 @@ core_scsi3_decode_spec_i_port(
 			tmp_tf_ops = tmp_tpg->se_tpg_tfo;
 			if (!tmp_tf_ops)
 				continue;
-			if (!tmp_tf_ops->get_fabric_proto_ident ||
-			    !tmp_tf_ops->tpg_parse_pr_out_transport_id)
+			if (!tmp_tf_ops->tpg_parse_pr_out_transport_id)
 				continue;
 			/*
 			 * Look for the matching proto_ident provided by
 			 * the received TransportID
 			 */
-			tmp_proto_ident = tmp_tf_ops->get_fabric_proto_ident(tmp_tpg);
+			tmp_proto_ident = tmp_tf_ops->scsi_protocol;
 			if (tmp_proto_ident != proto_ident)
 				continue;
 			dest_rtpi = tmp_port->sep_rtpi;
@@ -3246,11 +3245,11 @@ core_scsi3_emulate_pro_register_and_move(struct se_cmd *cmd, u64 res_key,
 	pr_debug("SPC-3 PR REGISTER_AND_MOVE: Extracted Protocol Identifier:"
 			" 0x%02x\n", proto_ident);
 
-	if (proto_ident != dest_tf_ops->get_fabric_proto_ident(dest_se_tpg)) {
+	if (proto_ident != dest_tf_ops->scsi_protocol) {
 		pr_err("SPC-3 PR REGISTER_AND_MOVE: Received"
 			" proto_ident: 0x%02x does not match ident: 0x%02x"
 			" from fabric: %s\n", proto_ident,
-			dest_tf_ops->get_fabric_proto_ident(dest_se_tpg),
+			dest_tf_ops->scsi_protocol,
 			dest_tf_ops->get_fabric_name());
 		ret = TCM_INVALID_PARAMETER_LIST;
 		goto out;
diff --git a/drivers/target/target_core_spc.c b/drivers/target/target_core_spc.c
index 9ec6459..9acb4c5 100644
--- a/drivers/target/target_core_spc.c
+++ b/drivers/target/target_core_spc.c
@@ -286,8 +286,7 @@ check_t10_vend_desc:
 		 * Get the PROTOCOL IDENTIFIER as defined by spc4r17
 		 * section 7.5.1 Table 362
 		 */
-		buf[off] =
-			(tpg->se_tpg_tfo->get_fabric_proto_ident(tpg) << 4);
+		buf[off] = tpg->se_tpg_tfo->scsi_protocol << 4;
 		buf[off++] |= 0x1; /* CODE SET == Binary */
 		buf[off] = 0x80; /* Set PIV=1 */
 		/* Set ASSOCIATION == target port: 01b */
@@ -322,8 +321,7 @@ check_t10_vend_desc:
 		tg_pt_gp_id = tg_pt_gp->tg_pt_gp_id;
 		spin_unlock(&tg_pt_gp_mem->tg_pt_gp_mem_lock);
 
-		buf[off] =
-			(tpg->se_tpg_tfo->get_fabric_proto_ident(tpg) << 4);
+		buf[off] = tpg->se_tpg_tfo->scsi_protocol << 4;
 		buf[off++] |= 0x1; /* CODE SET == Binary */
 		buf[off] = 0x80; /* Set PIV=1 */
 		/* Set ASSOCIATION == target port: 01b */
@@ -371,8 +369,7 @@ check_lu_gp:
 		 * section 7.5.1 Table 362
 		 */
 check_scsi_name:
-		buf[off] =
-			(tpg->se_tpg_tfo->get_fabric_proto_ident(tpg) << 4);
+		buf[off] = tpg->se_tpg_tfo->scsi_protocol << 4;
 		buf[off++] |= 0x3; /* CODE SET == UTF-8 */
 		buf[off] = 0x80; /* Set PIV=1 */
 		/* Set ASSOCIATION == target port: 01b */
@@ -412,8 +409,7 @@ check_scsi_name:
 		/*
 		 * Target device designator
 		 */
-		buf[off] =
-			(tpg->se_tpg_tfo->get_fabric_proto_ident(tpg) << 4);
+		buf[off] = tpg->se_tpg_tfo->scsi_protocol << 4;
 		buf[off++] |= 0x3; /* CODE SET == UTF-8 */
 		buf[off] = 0x80; /* Set PIV=1 */
 		/* Set ASSOCIATION == target device: 10b */
diff --git a/drivers/target/tcm_fc/tfc_conf.c b/drivers/target/tcm_fc/tfc_conf.c
index 070f09c..d42d73f 100644
--- a/drivers/target/tcm_fc/tfc_conf.c
+++ b/drivers/target/tcm_fc/tfc_conf.c
@@ -449,8 +449,8 @@ static u32 ft_tpg_get_inst_index(struct se_portal_group *se_tpg)
 
 static struct target_core_fabric_ops ft_fabric_ops = {
 	.node_acl_size =		sizeof(struct ft_node_acl),
+	.scsi_protocol =		SCSI_PROTOCOL_FCP,
 	.get_fabric_name =		ft_get_fabric_name,
-	.get_fabric_proto_ident =	fc_get_fabric_proto_ident,
 	.tpg_get_wwn =			ft_get_fabric_wwn,
 	.tpg_get_tag =			ft_get_tag,
 	.tpg_get_pr_transport_id =	fc_get_pr_transport_id,
diff --git a/drivers/usb/gadget/legacy/tcm_usb_gadget.c b/drivers/usb/gadget/legacy/tcm_usb_gadget.c
index b3289be..aad2de1 100644
--- a/drivers/usb/gadget/legacy/tcm_usb_gadget.c
+++ b/drivers/usb/gadget/legacy/tcm_usb_gadget.c
@@ -1274,23 +1274,6 @@ static char *usbg_get_fabric_name(void)
 	return "usb_gadget";
 }
 
-static u8 usbg_get_fabric_proto_ident(struct se_portal_group *se_tpg)
-{
-	struct usbg_tpg *tpg = container_of(se_tpg,
-				struct usbg_tpg, se_tpg);
-	struct usbg_tport *tport = tpg->tport;
-	u8 proto_id;
-
-	switch (tport->tport_proto_id) {
-	case SCSI_PROTOCOL_SAS:
-	default:
-		proto_id = sas_get_fabric_proto_ident(se_tpg);
-		break;
-	}
-
-	return proto_id;
-}
-
 static char *usbg_get_fabric_wwn(struct se_portal_group *se_tpg)
 {
 	struct usbg_tpg *tpg = container_of(se_tpg,
@@ -1795,8 +1778,8 @@ static int usbg_check_stop_free(struct se_cmd *se_cmd)
 }
 
 static struct target_core_fabric_ops usbg_ops = {
+	.scsi_protocol			= SCSI_PROTOCOL_SAS,
 	.get_fabric_name		= usbg_get_fabric_name,
-	.get_fabric_proto_ident		= usbg_get_fabric_proto_ident,
 	.tpg_get_wwn			= usbg_get_fabric_wwn,
 	.tpg_get_tag			= usbg_get_tag,
 	.tpg_get_pr_transport_id	= usbg_get_pr_transport_id,
diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c
index 43865a3..636c1e7 100644
--- a/drivers/vhost/scsi.c
+++ b/drivers/vhost/scsi.c
@@ -296,20 +296,7 @@ static u8 vhost_scsi_get_fabric_proto_ident(struct se_portal_group *se_tpg)
 				struct vhost_scsi_tpg, se_tpg);
 	struct vhost_scsi_tport *tport = tpg->tport;
 
-	switch (tport->tport_proto_id) {
-	case SCSI_PROTOCOL_SAS:
-		return sas_get_fabric_proto_ident(se_tpg);
-	case SCSI_PROTOCOL_FCP:
-		return fc_get_fabric_proto_ident(se_tpg);
-	case SCSI_PROTOCOL_ISCSI:
-		return iscsi_get_fabric_proto_ident(se_tpg);
-	default:
-		pr_err("Unknown tport_proto_id: 0x%02x, using"
-			" SAS emulation\n", tport->tport_proto_id);
-		break;
-	}
-
-	return sas_get_fabric_proto_ident(se_tpg);
+	return target_get_fabric_proto_ident(tport->tport_proto_id);
 }
 
 static char *vhost_scsi_get_fabric_wwn(struct se_portal_group *se_tpg)
@@ -2130,6 +2117,8 @@ vhost_scsi_make_tpg(struct se_wwn *wwn,
 		kfree(tpg);
 		return NULL;
 	}
+	vhost_scsi_fabric_configfs->tf_ops.scsi_protocol =
+		vhost_scsi_get_fabric_proto_ident(&tpg->se_tpg);
 	mutex_lock(&vhost_scsi_mutex);
 	list_add_tail(&tpg->tv_tpg_list, &vhost_scsi_list);
 	mutex_unlock(&vhost_scsi_mutex);
@@ -2247,7 +2236,6 @@ static struct configfs_attribute *vhost_scsi_wwn_attrs[] = {
 
 static struct target_core_fabric_ops vhost_scsi_ops = {
 	.get_fabric_name		= vhost_scsi_get_fabric_name,
-	.get_fabric_proto_ident		= vhost_scsi_get_fabric_proto_ident,
 	.tpg_get_wwn			= vhost_scsi_get_fabric_wwn,
 	.tpg_get_tag			= vhost_scsi_get_tpgt,
 	.tpg_get_pr_transport_id	= vhost_scsi_get_pr_transport_id,
diff --git a/drivers/xen/xen-scsiback.c b/drivers/xen/xen-scsiback.c
index 41fa771..d539945 100644
--- a/drivers/xen/xen-scsiback.c
+++ b/drivers/xen/xen-scsiback.c
@@ -1257,20 +1257,7 @@ static u8 scsiback_get_fabric_proto_ident(struct se_portal_group *se_tpg)
 				struct scsiback_tpg, se_tpg);
 	struct scsiback_tport *tport = tpg->tport;
 
-	switch (tport->tport_proto_id) {
-	case SCSI_PROTOCOL_SAS:
-		return sas_get_fabric_proto_ident(se_tpg);
-	case SCSI_PROTOCOL_FCP:
-		return fc_get_fabric_proto_ident(se_tpg);
-	case SCSI_PROTOCOL_ISCSI:
-		return iscsi_get_fabric_proto_ident(se_tpg);
-	default:
-		pr_err("Unknown tport_proto_id: 0x%02x, using SAS emulation\n",
-			tport->tport_proto_id);
-		break;
-	}
-
-	return sas_get_fabric_proto_ident(se_tpg);
+	return target_get_fabric_proto_ident(tport->tport_proto_id);
 }
 
 static char *scsiback_get_fabric_wwn(struct se_portal_group *se_tpg)
@@ -1889,6 +1876,8 @@ scsiback_make_tpg(struct se_wwn *wwn,
 		kfree(tpg);
 		return NULL;
 	}
+	scsiback_fabric_configfs->tf_ops.scsi_protocol =
+		scsiback_get_fabric_proto_ident(&tpg->se_tpg);
 	mutex_lock(&scsiback_mutex);
 	list_add_tail(&tpg->tv_tpg_list, &scsiback_list);
 	mutex_unlock(&scsiback_mutex);
@@ -1927,7 +1916,6 @@ static int scsiback_check_false(struct se_portal_group *se_tpg)
 
 static struct target_core_fabric_ops scsiback_ops = {
 	.get_fabric_name		= scsiback_get_fabric_name,
-	.get_fabric_proto_ident		= scsiback_get_fabric_proto_ident,
 	.tpg_get_wwn			= scsiback_get_fabric_wwn,
 	.tpg_get_tag			= scsiback_get_tag,
 	.tpg_get_pr_transport_id	= scsiback_get_pr_transport_id,
diff --git a/include/target/target_core_fabric.h b/include/target/target_core_fabric.h
index e0a8191..4e58d49 100644
--- a/include/target/target_core_fabric.h
+++ b/include/target/target_core_fabric.h
@@ -4,8 +4,8 @@
 struct target_core_fabric_ops {
 	struct configfs_subsystem *tf_subsys;
 	size_t node_acl_size;
+	u8 scsi_protocol;
 	char *(*get_fabric_name)(void);
-	u8 (*get_fabric_proto_ident)(struct se_portal_group *);
 	char *(*tpg_get_wwn)(struct se_portal_group *);
 	u16 (*tpg_get_tag)(struct se_portal_group *);
 	u32 (*tpg_get_default_depth)(struct se_portal_group *);
@@ -161,8 +161,9 @@ int	core_tpg_register(struct target_core_fabric_ops *, struct se_wwn *,
 		struct se_portal_group *, void *, int);
 int	core_tpg_deregister(struct se_portal_group *);
 
+u8	target_get_fabric_proto_ident(u8);
+
 /* SAS helpers */
-u8	sas_get_fabric_proto_ident(struct se_portal_group *);
 u32	sas_get_pr_transport_id(struct se_portal_group *, struct se_node_acl *,
 		struct t10_pr_registration *, int *, unsigned char *);
 u32	sas_get_pr_transport_id_len(struct se_portal_group *, struct se_node_acl *,
@@ -171,7 +172,6 @@ char	*sas_parse_pr_out_transport_id(struct se_portal_group *, const char *,
 		u32 *, char **);
 
 /* FC helpers */
-u8	fc_get_fabric_proto_ident(struct se_portal_group *);
 u32	fc_get_pr_transport_id(struct se_portal_group *, struct se_node_acl *,
 		struct t10_pr_registration *, int *, unsigned char *);
 u32	fc_get_pr_transport_id_len(struct se_portal_group *, struct se_node_acl *,
@@ -180,7 +180,6 @@ char	*fc_parse_pr_out_transport_id(struct se_portal_group *, const char *,
 		u32 *, char **);
 
 /* iSCSI helpers */
-u8	iscsi_get_fabric_proto_ident(struct se_portal_group *);
 u32	iscsi_get_pr_transport_id(struct se_portal_group *, struct se_node_acl *,
 		struct t10_pr_registration *, int *, unsigned char *);
 u32	iscsi_get_pr_transport_id_len(struct se_portal_group *, struct se_node_acl *,
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe target-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux SCSI]     [Kernel Newbies]     [Linux SCSI Target Infrastructure]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Device Mapper]

  Powered by Linux