Skip to content

Commit f6e8479

Browse files
jsmart-ghmartinkpetersen
authored andcommitted
scsi: lpfc: Fix default driver parameter collision for allowing NPIV support
The conversion to enable SCSI and NVME fc4 support ran into an issue with NPIV support. With NVME, NPIV is not currently supported, but with SCSI it was. The driver reverted to its lowest setting meaning NPIV with SCSI was not allowed. Convert the NPIV checks and implementation so that SCSI can continue to allow NPIV support. Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com> Signed-off-by: James Smart <jsmart2021@gmail.com> Reviewed-by: Hannes Reinecke <hare@suse.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent c201726 commit f6e8479

File tree

10 files changed

+46
-59
lines changed

10 files changed

+46
-59
lines changed

drivers/scsi/lpfc/lpfc.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,7 @@ struct lpfc_vport {
462462
uint32_t cfg_use_adisc;
463463
uint32_t cfg_discovery_threads;
464464
uint32_t cfg_log_verbose;
465+
uint32_t cfg_enable_fc4_type;
465466
uint32_t cfg_max_luns;
466467
uint32_t cfg_enable_da_id;
467468
uint32_t cfg_max_scsicmpl_time;
@@ -860,6 +861,7 @@ struct lpfc_hba {
860861
uint32_t cfg_prot_guard;
861862
uint32_t cfg_hostmem_hgp;
862863
uint32_t cfg_log_verbose;
864+
uint32_t cfg_enable_fc4_type;
863865
uint32_t cfg_aer_support;
864866
uint32_t cfg_sriov_nr_virtfn;
865867
uint32_t cfg_request_firmware_upgrade;
@@ -880,7 +882,6 @@ struct lpfc_hba {
880882
uint32_t cfg_ras_fwlog_level;
881883
uint32_t cfg_ras_fwlog_buffsize;
882884
uint32_t cfg_ras_fwlog_func;
883-
uint32_t cfg_enable_fc4_type;
884885
uint32_t cfg_enable_bbcr; /* Enable BB Credit Recovery */
885886
uint32_t cfg_enable_dpp; /* Enable Direct Packet Push */
886887
#define LPFC_ENABLE_FCP 1

drivers/scsi/lpfc/lpfc_attr.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ lpfc_nvme_info_show(struct device *dev, struct device_attribute *attr,
160160
int len = 0;
161161
char tmp[LPFC_MAX_NVME_INFO_TMP_LEN] = {0};
162162

163-
if (!(phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME)) {
163+
if (!(vport->cfg_enable_fc4_type & LPFC_ENABLE_NVME)) {
164164
len = scnprintf(buf, PAGE_SIZE, "NVME Disabled\n");
165165
return len;
166166
}
@@ -519,7 +519,7 @@ lpfc_scsi_stat_show(struct device *dev, struct device_attribute *attr,
519519
int i;
520520
char tmp[LPFC_MAX_SCSI_INFO_TMP_LEN] = {0};
521521

522-
if (!(phba->cfg_enable_fc4_type & LPFC_ENABLE_FCP) ||
522+
if (!(vport->cfg_enable_fc4_type & LPFC_ENABLE_FCP) ||
523523
(phba->sli_rev != LPFC_SLI_REV4))
524524
return 0;
525525

drivers/scsi/lpfc/lpfc_ct.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1656,16 +1656,16 @@ lpfc_ns_cmd(struct lpfc_vport *vport, int cmdcode,
16561656
CtReq->un.rft.PortId = cpu_to_be32(vport->fc_myDID);
16571657

16581658
/* Register FC4 FCP type if enabled. */
1659-
if ((phba->cfg_enable_fc4_type == LPFC_ENABLE_BOTH) ||
1660-
(phba->cfg_enable_fc4_type == LPFC_ENABLE_FCP))
1659+
if (vport->cfg_enable_fc4_type == LPFC_ENABLE_BOTH ||
1660+
vport->cfg_enable_fc4_type == LPFC_ENABLE_FCP)
16611661
CtReq->un.rft.fcpReg = 1;
16621662

16631663
/* Register NVME type if enabled. Defined LE and swapped.
16641664
* rsvd[0] is used as word1 because of the hard-coded
16651665
* word0 usage in the ct_request data structure.
16661666
*/
1667-
if ((phba->cfg_enable_fc4_type == LPFC_ENABLE_BOTH) ||
1668-
(phba->cfg_enable_fc4_type == LPFC_ENABLE_NVME))
1667+
if (vport->cfg_enable_fc4_type == LPFC_ENABLE_BOTH ||
1668+
vport->cfg_enable_fc4_type == LPFC_ENABLE_NVME)
16691669
CtReq->un.rft.rsvd[0] =
16701670
cpu_to_be32(LPFC_FC4_TYPE_BITMASK);
16711671

@@ -1732,8 +1732,8 @@ lpfc_ns_cmd(struct lpfc_vport *vport, int cmdcode,
17321732
* caller can specify NVME (type x28) as well. But only
17331733
* these that FC4 type is supported.
17341734
*/
1735-
if (((phba->cfg_enable_fc4_type == LPFC_ENABLE_BOTH) ||
1736-
(phba->cfg_enable_fc4_type == LPFC_ENABLE_NVME)) &&
1735+
if (((vport->cfg_enable_fc4_type == LPFC_ENABLE_BOTH) ||
1736+
(vport->cfg_enable_fc4_type == LPFC_ENABLE_NVME)) &&
17371737
(context == FC_TYPE_NVME)) {
17381738
if ((vport == phba->pport) && phba->nvmet_support) {
17391739
CtReq->un.rff.fbits = (FC4_FEATURE_TARGET |
@@ -1744,8 +1744,8 @@ lpfc_ns_cmd(struct lpfc_vport *vport, int cmdcode,
17441744
}
17451745
CtReq->un.rff.type_code = context;
17461746

1747-
} else if (((phba->cfg_enable_fc4_type == LPFC_ENABLE_BOTH) ||
1748-
(phba->cfg_enable_fc4_type == LPFC_ENABLE_FCP)) &&
1747+
} else if (((vport->cfg_enable_fc4_type == LPFC_ENABLE_BOTH) ||
1748+
(vport->cfg_enable_fc4_type == LPFC_ENABLE_FCP)) &&
17491749
(context == FC_TYPE_FCP))
17501750
CtReq->un.rff.type_code = context;
17511751

drivers/scsi/lpfc/lpfc_debugfs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,7 +1166,7 @@ lpfc_debugfs_nvmestat_data(struct lpfc_vport *vport, char *buf, int size)
11661166
phba->sli4_hba.nvmet_io_wait_total,
11671167
tot);
11681168
} else {
1169-
if (!(phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME))
1169+
if (!(vport->cfg_enable_fc4_type & LPFC_ENABLE_NVME))
11701170
return len;
11711171

11721172
localport = vport->localport;
@@ -1264,7 +1264,7 @@ lpfc_debugfs_scsistat_data(struct lpfc_vport *vport, char *buf, int size)
12641264
int i;
12651265
char tmp[LPFC_MAX_SCSI_INFO_TMP_LEN] = {0};
12661266

1267-
if (!(phba->cfg_enable_fc4_type & LPFC_ENABLE_FCP) ||
1267+
if (!(vport->cfg_enable_fc4_type & LPFC_ENABLE_FCP) ||
12681268
(phba->sli_rev != LPFC_SLI_REV4))
12691269
return 0;
12701270

drivers/scsi/lpfc/lpfc_els.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2827,8 +2827,8 @@ lpfc_cmpl_els_logo(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
28272827
!(vport->fc_flag & FC_PT2PT_PLOGI)) {
28282828
phba->pport->fc_myDID = 0;
28292829

2830-
if ((phba->cfg_enable_fc4_type == LPFC_ENABLE_BOTH) ||
2831-
(phba->cfg_enable_fc4_type == LPFC_ENABLE_NVME)) {
2830+
if ((vport->cfg_enable_fc4_type == LPFC_ENABLE_BOTH) ||
2831+
(vport->cfg_enable_fc4_type == LPFC_ENABLE_NVME)) {
28322832
if (phba->nvmet_support)
28332833
lpfc_nvmet_update_targetport(phba);
28342834
else

drivers/scsi/lpfc/lpfc_hbadisc.c

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -857,10 +857,9 @@ lpfc_port_link_failure(struct lpfc_vport *vport)
857857
void
858858
lpfc_linkdown_port(struct lpfc_vport *vport)
859859
{
860-
struct lpfc_hba *phba = vport->phba;
861860
struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
862861

863-
if (phba->cfg_enable_fc4_type != LPFC_ENABLE_NVME)
862+
if (vport->cfg_enable_fc4_type != LPFC_ENABLE_NVME)
864863
fc_host_post_event(shost, fc_get_event_number(),
865864
FCH_EVT_LINKDOWN, 0);
866865

@@ -923,8 +922,8 @@ lpfc_linkdown(struct lpfc_hba *phba)
923922

924923
vports[i]->fc_myDID = 0;
925924

926-
if ((phba->cfg_enable_fc4_type == LPFC_ENABLE_BOTH) ||
927-
(phba->cfg_enable_fc4_type == LPFC_ENABLE_NVME)) {
925+
if ((vport->cfg_enable_fc4_type == LPFC_ENABLE_BOTH) ||
926+
(vport->cfg_enable_fc4_type == LPFC_ENABLE_NVME)) {
928927
if (phba->nvmet_support)
929928
lpfc_nvmet_update_targetport(phba);
930929
else
@@ -1010,7 +1009,7 @@ lpfc_linkup_port(struct lpfc_vport *vport)
10101009
(vport != phba->pport))
10111010
return;
10121011

1013-
if (phba->cfg_enable_fc4_type != LPFC_ENABLE_NVME)
1012+
if (vport->cfg_enable_fc4_type != LPFC_ENABLE_NVME)
10141013
fc_host_post_event(shost, fc_get_event_number(),
10151014
FCH_EVT_LINKUP, 0);
10161015

@@ -3658,8 +3657,8 @@ lpfc_mbx_cmpl_reg_vpi(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
36583657
spin_unlock_irq(shost->host_lock);
36593658
vport->fc_myDID = 0;
36603659

3661-
if ((phba->cfg_enable_fc4_type == LPFC_ENABLE_BOTH) ||
3662-
(phba->cfg_enable_fc4_type == LPFC_ENABLE_NVME)) {
3660+
if ((vport->cfg_enable_fc4_type == LPFC_ENABLE_BOTH) ||
3661+
(vport->cfg_enable_fc4_type == LPFC_ENABLE_NVME)) {
36633662
if (phba->nvmet_support)
36643663
lpfc_nvmet_update_targetport(phba);
36653664
else
@@ -3921,11 +3920,9 @@ lpfc_mbx_cmpl_fabric_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
39213920
int
39223921
lpfc_issue_gidft(struct lpfc_vport *vport)
39233922
{
3924-
struct lpfc_hba *phba = vport->phba;
3925-
39263923
/* Good status, issue CT Request to NameServer */
3927-
if ((phba->cfg_enable_fc4_type == LPFC_ENABLE_BOTH) ||
3928-
(phba->cfg_enable_fc4_type == LPFC_ENABLE_FCP)) {
3924+
if ((vport->cfg_enable_fc4_type == LPFC_ENABLE_BOTH) ||
3925+
(vport->cfg_enable_fc4_type == LPFC_ENABLE_FCP)) {
39293926
if (lpfc_ns_cmd(vport, SLI_CTNS_GID_FT, 0, SLI_CTPT_FCP)) {
39303927
/* Cannot issue NameServer FCP Query, so finish up
39313928
* discovery
@@ -3940,8 +3937,8 @@ lpfc_issue_gidft(struct lpfc_vport *vport)
39403937
vport->gidft_inp++;
39413938
}
39423939

3943-
if ((phba->cfg_enable_fc4_type == LPFC_ENABLE_BOTH) ||
3944-
(phba->cfg_enable_fc4_type == LPFC_ENABLE_NVME)) {
3940+
if ((vport->cfg_enable_fc4_type == LPFC_ENABLE_BOTH) ||
3941+
(vport->cfg_enable_fc4_type == LPFC_ENABLE_NVME)) {
39453942
if (lpfc_ns_cmd(vport, SLI_CTNS_GID_FT, 0, SLI_CTPT_NVME)) {
39463943
/* Cannot issue NameServer NVME Query, so finish up
39473944
* discovery
@@ -4057,12 +4054,12 @@ lpfc_mbx_cmpl_ns_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
40574054
lpfc_ns_cmd(vport, SLI_CTNS_RSPN_ID, 0, 0);
40584055
lpfc_ns_cmd(vport, SLI_CTNS_RFT_ID, 0, 0);
40594056

4060-
if ((phba->cfg_enable_fc4_type == LPFC_ENABLE_BOTH) ||
4061-
(phba->cfg_enable_fc4_type == LPFC_ENABLE_FCP))
4057+
if ((vport->cfg_enable_fc4_type == LPFC_ENABLE_BOTH) ||
4058+
(vport->cfg_enable_fc4_type == LPFC_ENABLE_FCP))
40624059
lpfc_ns_cmd(vport, SLI_CTNS_RFF_ID, 0, FC_TYPE_FCP);
40634060

4064-
if ((phba->cfg_enable_fc4_type == LPFC_ENABLE_BOTH) ||
4065-
(phba->cfg_enable_fc4_type == LPFC_ENABLE_NVME))
4061+
if ((vport->cfg_enable_fc4_type == LPFC_ENABLE_BOTH) ||
4062+
(vport->cfg_enable_fc4_type == LPFC_ENABLE_NVME))
40664063
lpfc_ns_cmd(vport, SLI_CTNS_RFF_ID, 0,
40674064
FC_TYPE_NVME);
40684065

@@ -4098,7 +4095,7 @@ lpfc_register_remote_port(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp)
40984095
struct fc_rport_identifiers rport_ids;
40994096
struct lpfc_hba *phba = vport->phba;
41004097

4101-
if (phba->cfg_enable_fc4_type == LPFC_ENABLE_NVME)
4098+
if (vport->cfg_enable_fc4_type == LPFC_ENABLE_NVME)
41024099
return;
41034100

41044101
/* Remote port has reappeared. Re-register w/ FC transport */
@@ -4173,9 +4170,8 @@ lpfc_unregister_remote_port(struct lpfc_nodelist *ndlp)
41734170
{
41744171
struct fc_rport *rport = ndlp->rport;
41754172
struct lpfc_vport *vport = ndlp->vport;
4176-
struct lpfc_hba *phba = vport->phba;
41774173

4178-
if (phba->cfg_enable_fc4_type == LPFC_ENABLE_NVME)
4174+
if (vport->cfg_enable_fc4_type == LPFC_ENABLE_NVME)
41794175
return;
41804176

41814177
lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_RPORT,

drivers/scsi/lpfc/lpfc_init.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4290,6 +4290,9 @@ lpfc_create_port(struct lpfc_hba *phba, int instance, struct device *dev)
42904290
vport->fc_rscn_flush = 0;
42914291
lpfc_get_vport_cfgparam(vport);
42924292

4293+
/* Adjust value in vport */
4294+
vport->cfg_enable_fc4_type = phba->cfg_enable_fc4_type;
4295+
42934296
shost->unique_id = instance;
42944297
shost->max_id = LPFC_MAX_TARGET;
42954298
shost->max_lun = vport->cfg_max_luns;

drivers/scsi/lpfc/lpfc_nportdisc.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,7 @@ lpfc_rcv_prli(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
825825
"rport rolechg: role:x%x did:x%x flg:x%x",
826826
roles, ndlp->nlp_DID, ndlp->nlp_flag);
827827

828-
if (phba->cfg_enable_fc4_type != LPFC_ENABLE_NVME)
828+
if (vport->cfg_enable_fc4_type != LPFC_ENABLE_NVME)
829829
fc_remote_port_rolechg(rport, roles);
830830
}
831831
}
@@ -1789,8 +1789,8 @@ lpfc_cmpl_reglogin_reglogin_issue(struct lpfc_vport *vport,
17891789
* is configured try it.
17901790
*/
17911791
ndlp->nlp_fc4_type |= NLP_FC4_FCP;
1792-
if ((phba->cfg_enable_fc4_type == LPFC_ENABLE_BOTH) ||
1793-
(phba->cfg_enable_fc4_type == LPFC_ENABLE_NVME)) {
1792+
if ((vport->cfg_enable_fc4_type == LPFC_ENABLE_BOTH) ||
1793+
(vport->cfg_enable_fc4_type == LPFC_ENABLE_NVME)) {
17941794
ndlp->nlp_fc4_type |= NLP_FC4_NVME;
17951795
/* We need to update the localport also */
17961796
lpfc_nvme_update_localport(vport);
@@ -1804,7 +1804,7 @@ lpfc_cmpl_reglogin_reglogin_issue(struct lpfc_vport *vport,
18041804
* should just issue PRLI for FCP. Otherwise issue
18051805
* GFT_ID to determine if remote port supports NVME.
18061806
*/
1807-
if (phba->cfg_enable_fc4_type != LPFC_ENABLE_FCP) {
1807+
if (vport->cfg_enable_fc4_type != LPFC_ENABLE_FCP) {
18081808
rc = lpfc_ns_cmd(vport, SLI_CTNS_GFT_ID,
18091809
0, ndlp->nlp_DID);
18101810
return ndlp->nlp_state;

drivers/scsi/lpfc/lpfc_scsi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ lpfc_sli4_vport_delete_fcp_xri_aborted(struct lpfc_vport *vport)
530530
unsigned long iflag = 0;
531531
int idx;
532532

533-
if (!(phba->cfg_enable_fc4_type & LPFC_ENABLE_FCP))
533+
if (!(vport->cfg_enable_fc4_type & LPFC_ENABLE_FCP))
534534
return;
535535

536536
spin_lock_irqsave(&phba->hbalock, iflag);

drivers/scsi/lpfc/lpfc_vport.c

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -313,11 +313,11 @@ lpfc_vport_create(struct fc_vport *fc_vport, bool disable)
313313
goto error_out;
314314
}
315315

316-
/* NPIV is not supported if HBA has NVME enabled */
317-
if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) {
316+
/* NPIV is not supported if HBA has NVME Target enabled */
317+
if (phba->nvmet_support) {
318318
lpfc_printf_log(phba, KERN_ERR, LOG_VPORT,
319319
"3189 Create VPORT failed: "
320-
"NPIV is not supported on NVME\n");
320+
"NPIV is not supported on NVME Target\n");
321321
rc = VPORT_INVAL;
322322
goto error_out;
323323
}
@@ -403,6 +403,9 @@ lpfc_vport_create(struct fc_vport *fc_vport, bool disable)
403403
/* Set the DFT_LUN_Q_DEPTH accordingly */
404404
vport->cfg_lun_queue_depth = phba->pport->cfg_lun_queue_depth;
405405

406+
/* Only the physical port can support NVME for now */
407+
vport->cfg_enable_fc4_type = LPFC_ENABLE_FCP;
408+
406409
*(struct lpfc_vport **)fc_vport->dd_data = vport;
407410
vport->fc_vport = fc_vport;
408411

@@ -415,22 +418,6 @@ lpfc_vport_create(struct fc_vport *fc_vport, bool disable)
415418
vport->fdmi_port_mask = phba->pport->fdmi_port_mask;
416419
}
417420

418-
if ((phba->nvmet_support == 0) &&
419-
((phba->cfg_enable_fc4_type == LPFC_ENABLE_BOTH) ||
420-
(phba->cfg_enable_fc4_type == LPFC_ENABLE_NVME))) {
421-
/* Create NVME binding with nvme_fc_transport. This
422-
* ensures the vport is initialized.
423-
*/
424-
rc = lpfc_nvme_create_localport(vport);
425-
if (rc) {
426-
lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
427-
"6003 %s status x%x\n",
428-
"NVME registration failed, ",
429-
rc);
430-
goto error_out;
431-
}
432-
}
433-
434421
/*
435422
* In SLI4, the vpi must be activated before it can be used
436423
* by the port.

0 commit comments

Comments
 (0)