Skip to content

Commit 394d62b

Browse files
author
Nicholas Bellinger
committed
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>
1 parent 3c231bd commit 394d62b

File tree

1 file changed

+56
-3
lines changed

1 file changed

+56
-3
lines changed

drivers/scsi/qla2xxx/tcm_qla2xxx.c

Lines changed: 56 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,11 +1053,64 @@ static void tcm_qla2xxx_drop_tpg(struct se_portal_group *se_tpg)
10531053
/*
10541054
* Clear local TPG=1 pointer for non NPIV mode.
10551055
*/
1056-
lport->tpg_1 = NULL;
1057-
1056+
lport->tpg_1 = NULL;
10581057
kfree(tpg);
10591058
}
10601059

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+
10611114
static struct se_portal_group *tcm_qla2xxx_npiv_make_tpg(
10621115
struct se_wwn *wwn,
10631116
struct config_group *group,
@@ -1935,7 +1988,7 @@ static int tcm_qla2xxx_register_configfs(void)
19351988
*/
19361989
npiv_fabric->tf_cit_tmpl.tfc_wwn_cit.ct_attrs = tcm_qla2xxx_wwn_attrs;
19371990
npiv_fabric->tf_cit_tmpl.tfc_tpg_base_cit.ct_attrs =
1938-
tcm_qla2xxx_tpg_attrs;
1991+
tcm_qla2xxx_npiv_tpg_attrs;
19391992
npiv_fabric->tf_cit_tmpl.tfc_tpg_attrib_cit.ct_attrs = NULL;
19401993
npiv_fabric->tf_cit_tmpl.tfc_tpg_param_cit.ct_attrs = NULL;
19411994
npiv_fabric->tf_cit_tmpl.tfc_tpg_np_base_cit.ct_attrs = NULL;

0 commit comments

Comments
 (0)