aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/target/loopback/tcm_loop.c
diff options
context:
space:
mode:
authorNicholas Bellinger <nab@linux-iscsi.org>2015-02-08 15:31:39 -0500
committerNicholas Bellinger <nab@linux-iscsi.org>2015-04-08 02:27:45 -0400
commit436f4a0a99520623ef3fb994d70d2938fc9f00b6 (patch)
tree61f52444f6caf4b366fc48f25288f3e364ea9df6 /drivers/target/loopback/tcm_loop.c
parent1762742f3fd276570456eb669922e34e11bd98b7 (diff)
loopback: Add fabric_prot_type attribute support
This patch updates loopback to add a new fabric_prot_type TPG attribute, used for controlling LLD level protection into LIO when the backend device does not support T10-PI. Also, go ahead and set DIN_PASS + DOUT_PASS so target-core knows that it will be doing any WRITE_STRIP and READ_INSERT operations. Cc: Martin Petersen <martin.petersen@oracle.com> Cc: Sagi Grimberg <sagig@mellanox.com> Cc: Hannes Reinecke <hare@suse.de> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers/target/loopback/tcm_loop.c')
-rw-r--r--drivers/target/loopback/tcm_loop.c54
1 files changed, 52 insertions, 2 deletions
diff --git a/drivers/target/loopback/tcm_loop.c b/drivers/target/loopback/tcm_loop.c
index f4618e722187..797c7315f520 100644
--- a/drivers/target/loopback/tcm_loop.c
+++ b/drivers/target/loopback/tcm_loop.c
@@ -697,6 +697,13 @@ static int tcm_loop_check_prod_mode_write_protect(struct se_portal_group *se_tpg
697 return 0; 697 return 0;
698} 698}
699 699
700static int tcm_loop_check_prot_fabric_only(struct se_portal_group *se_tpg)
701{
702 struct tcm_loop_tpg *tl_tpg = container_of(se_tpg, struct tcm_loop_tpg,
703 tl_se_tpg);
704 return tl_tpg->tl_fabric_prot_type;
705}
706
700static struct se_node_acl *tcm_loop_tpg_alloc_fabric_acl( 707static struct se_node_acl *tcm_loop_tpg_alloc_fabric_acl(
701 struct se_portal_group *se_tpg) 708 struct se_portal_group *se_tpg)
702{ 709{
@@ -912,6 +919,46 @@ static void tcm_loop_port_unlink(
912 919
913/* End items for tcm_loop_port_cit */ 920/* End items for tcm_loop_port_cit */
914 921
922static ssize_t tcm_loop_tpg_attrib_show_fabric_prot_type(
923 struct se_portal_group *se_tpg,
924 char *page)
925{
926 struct tcm_loop_tpg *tl_tpg = container_of(se_tpg, struct tcm_loop_tpg,
927 tl_se_tpg);
928
929 return sprintf(page, "%d\n", tl_tpg->tl_fabric_prot_type);
930}
931
932static ssize_t tcm_loop_tpg_attrib_store_fabric_prot_type(
933 struct se_portal_group *se_tpg,
934 const char *page,
935 size_t count)
936{
937 struct tcm_loop_tpg *tl_tpg = container_of(se_tpg, struct tcm_loop_tpg,
938 tl_se_tpg);
939 unsigned long val;
940 int ret = kstrtoul(page, 0, &val);
941
942 if (ret) {
943 pr_err("kstrtoul() returned %d for fabric_prot_type\n", ret);
944 return ret;
945 }
946 if (val != 0 && val != 1 && val != 3) {
947 pr_err("Invalid qla2xxx fabric_prot_type: %lu\n", val);
948 return -EINVAL;
949 }
950 tl_tpg->tl_fabric_prot_type = val;
951
952 return count;
953}
954
955TF_TPG_ATTRIB_ATTR(tcm_loop, fabric_prot_type, S_IRUGO | S_IWUSR);
956
957static struct configfs_attribute *tcm_loop_tpg_attrib_attrs[] = {
958 &tcm_loop_tpg_attrib_fabric_prot_type.attr,
959 NULL,
960};
961
915/* Start items for tcm_loop_nexus_cit */ 962/* Start items for tcm_loop_nexus_cit */
916 963
917static int tcm_loop_make_nexus( 964static int tcm_loop_make_nexus(
@@ -937,7 +984,8 @@ static int tcm_loop_make_nexus(
937 /* 984 /*
938 * Initialize the struct se_session pointer 985 * Initialize the struct se_session pointer
939 */ 986 */
940 tl_nexus->se_sess = transport_init_session(TARGET_PROT_ALL); 987 tl_nexus->se_sess = transport_init_session(
988 TARGET_PROT_DIN_PASS | TARGET_PROT_DOUT_PASS);
941 if (IS_ERR(tl_nexus->se_sess)) { 989 if (IS_ERR(tl_nexus->se_sess)) {
942 ret = PTR_ERR(tl_nexus->se_sess); 990 ret = PTR_ERR(tl_nexus->se_sess);
943 goto out; 991 goto out;
@@ -1377,6 +1425,8 @@ static int tcm_loop_register_configfs(void)
1377 &tcm_loop_check_demo_mode_write_protect; 1425 &tcm_loop_check_demo_mode_write_protect;
1378 fabric->tf_ops.tpg_check_prod_mode_write_protect = 1426 fabric->tf_ops.tpg_check_prod_mode_write_protect =
1379 &tcm_loop_check_prod_mode_write_protect; 1427 &tcm_loop_check_prod_mode_write_protect;
1428 fabric->tf_ops.tpg_check_prot_fabric_only =
1429 &tcm_loop_check_prot_fabric_only;
1380 /* 1430 /*
1381 * The TCM loopback fabric module runs in demo-mode to a local 1431 * The TCM loopback fabric module runs in demo-mode to a local
1382 * virtual SCSI device, so fabric dependent initator ACLs are 1432 * virtual SCSI device, so fabric dependent initator ACLs are
@@ -1429,7 +1479,7 @@ static int tcm_loop_register_configfs(void)
1429 */ 1479 */
1430 fabric->tf_cit_tmpl.tfc_wwn_cit.ct_attrs = tcm_loop_wwn_attrs; 1480 fabric->tf_cit_tmpl.tfc_wwn_cit.ct_attrs = tcm_loop_wwn_attrs;
1431 fabric->tf_cit_tmpl.tfc_tpg_base_cit.ct_attrs = tcm_loop_tpg_attrs; 1481 fabric->tf_cit_tmpl.tfc_tpg_base_cit.ct_attrs = tcm_loop_tpg_attrs;
1432 fabric->tf_cit_tmpl.tfc_tpg_attrib_cit.ct_attrs = NULL; 1482 fabric->tf_cit_tmpl.tfc_tpg_attrib_cit.ct_attrs = tcm_loop_tpg_attrib_attrs;
1433 fabric->tf_cit_tmpl.tfc_tpg_param_cit.ct_attrs = NULL; 1483 fabric->tf_cit_tmpl.tfc_tpg_param_cit.ct_attrs = NULL;
1434 fabric->tf_cit_tmpl.tfc_tpg_np_base_cit.ct_attrs = NULL; 1484 fabric->tf_cit_tmpl.tfc_tpg_np_base_cit.ct_attrs = NULL;
1435 /* 1485 /*