diff options
author | Nicholas Bellinger <nab@linux-iscsi.org> | 2014-02-19 19:52:15 -0500 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2014-02-20 16:01:17 -0500 |
commit | 394d62ba4580a74afc90bf0e007e10291bf447cc (patch) | |
tree | a3c3f103869b896f073bc27581393e2179f6b716 /drivers/scsi/qla2xxx/tcm_qla2xxx.c | |
parent | 3c231bdae1e7c8d366eeb133980b81dff2e1e809 (diff) |
tcm_qla2xxx: Add NPIV specific enable/disable attribute logic
This patch adds seperate logic for NPIV specific enable/disable
attribute logic, as NPIV vs. non-NPIV enable/disable ends up being
different enough to warrent seperate logic for setting configfs
tpg_group dependencies in the non-NPIV case.
Cc: Sawan Chandak <sawan.chandak@qlogic.com>
Cc: Quinn Tran <quinn.tran@qlogic.com>
Cc: Saurav Kashyap <saurav.kashyap@qlogic.com>
Cc: Giridhar Malavali <giridhar.malavali@qlogic.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers/scsi/qla2xxx/tcm_qla2xxx.c')
-rw-r--r-- | drivers/scsi/qla2xxx/tcm_qla2xxx.c | 59 |
1 files changed, 56 insertions, 3 deletions
diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c b/drivers/scsi/qla2xxx/tcm_qla2xxx.c index 75a141bbe74d..db43b2893525 100644 --- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c +++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c | |||
@@ -1053,11 +1053,64 @@ static void tcm_qla2xxx_drop_tpg(struct se_portal_group *se_tpg) | |||
1053 | /* | 1053 | /* |
1054 | * Clear local TPG=1 pointer for non NPIV mode. | 1054 | * Clear local TPG=1 pointer for non NPIV mode. |
1055 | */ | 1055 | */ |
1056 | lport->tpg_1 = NULL; | 1056 | lport->tpg_1 = NULL; |
1057 | |||
1058 | kfree(tpg); | 1057 | kfree(tpg); |
1059 | } | 1058 | } |
1060 | 1059 | ||
1060 | static ssize_t tcm_qla2xxx_npiv_tpg_show_enable( | ||
1061 | struct se_portal_group *se_tpg, | ||
1062 | char *page) | ||
1063 | { | ||
1064 | return tcm_qla2xxx_tpg_show_enable(se_tpg, page); | ||
1065 | } | ||
1066 | |||
1067 | static ssize_t tcm_qla2xxx_npiv_tpg_store_enable( | ||
1068 | struct se_portal_group *se_tpg, | ||
1069 | const char *page, | ||
1070 | size_t count) | ||
1071 | { | ||
1072 | struct se_wwn *se_wwn = se_tpg->se_tpg_wwn; | ||
1073 | struct tcm_qla2xxx_lport *lport = container_of(se_wwn, | ||
1074 | struct tcm_qla2xxx_lport, lport_wwn); | ||
1075 | struct scsi_qla_host *vha = lport->qla_vha; | ||
1076 | struct tcm_qla2xxx_tpg *tpg = container_of(se_tpg, | ||
1077 | struct tcm_qla2xxx_tpg, se_tpg); | ||
1078 | unsigned long op; | ||
1079 | int rc; | ||
1080 | |||
1081 | rc = kstrtoul(page, 0, &op); | ||
1082 | if (rc < 0) { | ||
1083 | pr_err("kstrtoul() returned %d\n", rc); | ||
1084 | return -EINVAL; | ||
1085 | } | ||
1086 | if ((op != 1) && (op != 0)) { | ||
1087 | pr_err("Illegal value for tpg_enable: %lu\n", op); | ||
1088 | return -EINVAL; | ||
1089 | } | ||
1090 | if (op) { | ||
1091 | if (atomic_read(&tpg->lport_tpg_enabled)) | ||
1092 | return -EEXIST; | ||
1093 | |||
1094 | atomic_set(&tpg->lport_tpg_enabled, 1); | ||
1095 | qlt_enable_vha(vha); | ||
1096 | } else { | ||
1097 | if (!atomic_read(&tpg->lport_tpg_enabled)) | ||
1098 | return count; | ||
1099 | |||
1100 | atomic_set(&tpg->lport_tpg_enabled, 0); | ||
1101 | qlt_stop_phase1(vha->vha_tgt.qla_tgt); | ||
1102 | } | ||
1103 | |||
1104 | return count; | ||
1105 | } | ||
1106 | |||
1107 | TF_TPG_BASE_ATTR(tcm_qla2xxx_npiv, enable, S_IRUGO | S_IWUSR); | ||
1108 | |||
1109 | static struct configfs_attribute *tcm_qla2xxx_npiv_tpg_attrs[] = { | ||
1110 | &tcm_qla2xxx_npiv_tpg_enable.attr, | ||
1111 | NULL, | ||
1112 | }; | ||
1113 | |||
1061 | static struct se_portal_group *tcm_qla2xxx_npiv_make_tpg( | 1114 | static struct se_portal_group *tcm_qla2xxx_npiv_make_tpg( |
1062 | struct se_wwn *wwn, | 1115 | struct se_wwn *wwn, |
1063 | struct config_group *group, | 1116 | struct config_group *group, |
@@ -1935,7 +1988,7 @@ static int tcm_qla2xxx_register_configfs(void) | |||
1935 | */ | 1988 | */ |
1936 | npiv_fabric->tf_cit_tmpl.tfc_wwn_cit.ct_attrs = tcm_qla2xxx_wwn_attrs; | 1989 | npiv_fabric->tf_cit_tmpl.tfc_wwn_cit.ct_attrs = tcm_qla2xxx_wwn_attrs; |
1937 | npiv_fabric->tf_cit_tmpl.tfc_tpg_base_cit.ct_attrs = | 1990 | npiv_fabric->tf_cit_tmpl.tfc_tpg_base_cit.ct_attrs = |
1938 | tcm_qla2xxx_tpg_attrs; | 1991 | tcm_qla2xxx_npiv_tpg_attrs; |
1939 | npiv_fabric->tf_cit_tmpl.tfc_tpg_attrib_cit.ct_attrs = NULL; | 1992 | npiv_fabric->tf_cit_tmpl.tfc_tpg_attrib_cit.ct_attrs = NULL; |
1940 | npiv_fabric->tf_cit_tmpl.tfc_tpg_param_cit.ct_attrs = NULL; | 1993 | npiv_fabric->tf_cit_tmpl.tfc_tpg_param_cit.ct_attrs = NULL; |
1941 | npiv_fabric->tf_cit_tmpl.tfc_tpg_np_base_cit.ct_attrs = NULL; | 1994 | npiv_fabric->tf_cit_tmpl.tfc_tpg_np_base_cit.ct_attrs = NULL; |