scsi: lpfc: Fix default driver parameter collision for allowing NPIV support
authorJames Smart <jsmart2021@gmail.com>
Mon, 28 Jan 2019 19:14:38 +0000 (11:14 -0800)
committerMartin K. Petersen <martin.petersen@oracle.com>
Wed, 6 Feb 2019 03:29:50 +0000 (22:29 -0500)
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>
drivers/scsi/lpfc/lpfc.h
drivers/scsi/lpfc/lpfc_attr.c
drivers/scsi/lpfc/lpfc_ct.c
drivers/scsi/lpfc/lpfc_debugfs.c
drivers/scsi/lpfc/lpfc_els.c
drivers/scsi/lpfc/lpfc_hbadisc.c
drivers/scsi/lpfc/lpfc_init.c
drivers/scsi/lpfc/lpfc_nportdisc.c
drivers/scsi/lpfc/lpfc_scsi.c
drivers/scsi/lpfc/lpfc_vport.c

index 0bc498172add8a367f09117710b59560207370a7..b710994a352e79293d85c0bd6d755642d8ae9c02 100644 (file)
@@ -462,6 +462,7 @@ struct lpfc_vport {
        uint32_t cfg_use_adisc;
        uint32_t cfg_discovery_threads;
        uint32_t cfg_log_verbose;
+       uint32_t cfg_enable_fc4_type;
        uint32_t cfg_max_luns;
        uint32_t cfg_enable_da_id;
        uint32_t cfg_max_scsicmpl_time;
@@ -860,6 +861,7 @@ struct lpfc_hba {
        uint32_t cfg_prot_guard;
        uint32_t cfg_hostmem_hgp;
        uint32_t cfg_log_verbose;
+       uint32_t cfg_enable_fc4_type;
        uint32_t cfg_aer_support;
        uint32_t cfg_sriov_nr_virtfn;
        uint32_t cfg_request_firmware_upgrade;
@@ -880,7 +882,6 @@ struct lpfc_hba {
        uint32_t cfg_ras_fwlog_level;
        uint32_t cfg_ras_fwlog_buffsize;
        uint32_t cfg_ras_fwlog_func;
-       uint32_t cfg_enable_fc4_type;
        uint32_t cfg_enable_bbcr;       /* Enable BB Credit Recovery */
        uint32_t cfg_enable_dpp;        /* Enable Direct Packet Push */
 #define LPFC_ENABLE_FCP  1
index 4006cb425f16e401e7ce5f1cf9810996a4d27bda..212bfae1966a817180616c468bd41adfdca95a24 100644 (file)
@@ -160,7 +160,7 @@ lpfc_nvme_info_show(struct device *dev, struct device_attribute *attr,
        int len = 0;
        char tmp[LPFC_MAX_NVME_INFO_TMP_LEN] = {0};
 
-       if (!(phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME)) {
+       if (!(vport->cfg_enable_fc4_type & LPFC_ENABLE_NVME)) {
                len = scnprintf(buf, PAGE_SIZE, "NVME Disabled\n");
                return len;
        }
@@ -519,7 +519,7 @@ lpfc_scsi_stat_show(struct device *dev, struct device_attribute *attr,
        int i;
        char tmp[LPFC_MAX_SCSI_INFO_TMP_LEN] = {0};
 
-       if (!(phba->cfg_enable_fc4_type & LPFC_ENABLE_FCP) ||
+       if (!(vport->cfg_enable_fc4_type & LPFC_ENABLE_FCP) ||
            (phba->sli_rev != LPFC_SLI_REV4))
                return 0;
 
index 552da8bf43e41a0fef71815e815845a76b997da3..98faa3aae35ca9ea42cf2ea4ea53e734326286e9 100644 (file)
@@ -1656,16 +1656,16 @@ lpfc_ns_cmd(struct lpfc_vport *vport, int cmdcode,
                CtReq->un.rft.PortId = cpu_to_be32(vport->fc_myDID);
 
                /* Register FC4 FCP type if enabled.  */
-               if ((phba->cfg_enable_fc4_type == LPFC_ENABLE_BOTH) ||
-                   (phba->cfg_enable_fc4_type == LPFC_ENABLE_FCP))
+               if (vport->cfg_enable_fc4_type == LPFC_ENABLE_BOTH ||
+                   vport->cfg_enable_fc4_type == LPFC_ENABLE_FCP)
                        CtReq->un.rft.fcpReg = 1;
 
                /* Register NVME type if enabled.  Defined LE and swapped.
                 * rsvd[0] is used as word1 because of the hard-coded
                 * word0 usage in the ct_request data structure.
                 */
-               if ((phba->cfg_enable_fc4_type == LPFC_ENABLE_BOTH) ||
-                   (phba->cfg_enable_fc4_type == LPFC_ENABLE_NVME))
+               if (vport->cfg_enable_fc4_type == LPFC_ENABLE_BOTH ||
+                   vport->cfg_enable_fc4_type == LPFC_ENABLE_NVME)
                        CtReq->un.rft.rsvd[0] =
                                cpu_to_be32(LPFC_FC4_TYPE_BITMASK);
 
@@ -1732,8 +1732,8 @@ lpfc_ns_cmd(struct lpfc_vport *vport, int cmdcode,
                 * caller can specify NVME (type x28) as well.  But only
                 * these that FC4 type is supported.
                 */
-               if (((phba->cfg_enable_fc4_type == LPFC_ENABLE_BOTH) ||
-                    (phba->cfg_enable_fc4_type == LPFC_ENABLE_NVME)) &&
+               if (((vport->cfg_enable_fc4_type == LPFC_ENABLE_BOTH) ||
+                    (vport->cfg_enable_fc4_type == LPFC_ENABLE_NVME)) &&
                    (context == FC_TYPE_NVME)) {
                        if ((vport == phba->pport) && phba->nvmet_support) {
                                CtReq->un.rff.fbits = (FC4_FEATURE_TARGET |
@@ -1744,8 +1744,8 @@ lpfc_ns_cmd(struct lpfc_vport *vport, int cmdcode,
                        }
                        CtReq->un.rff.type_code = context;
 
-               } else if (((phba->cfg_enable_fc4_type == LPFC_ENABLE_BOTH) ||
-                           (phba->cfg_enable_fc4_type == LPFC_ENABLE_FCP)) &&
+               } else if (((vport->cfg_enable_fc4_type == LPFC_ENABLE_BOTH) ||
+                           (vport->cfg_enable_fc4_type == LPFC_ENABLE_FCP)) &&
                           (context == FC_TYPE_FCP))
                        CtReq->un.rff.type_code = context;
 
index 16b461778e597098dc7d248e63d85f5d3615037d..19d13a8789b99379a7003b3ffb1d60522e46bc3b 100644 (file)
@@ -1166,7 +1166,7 @@ lpfc_debugfs_nvmestat_data(struct lpfc_vport *vport, char *buf, int size)
                                phba->sli4_hba.nvmet_io_wait_total,
                                tot);
        } else {
-               if (!(phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME))
+               if (!(vport->cfg_enable_fc4_type & LPFC_ENABLE_NVME))
                        return len;
 
                localport = vport->localport;
@@ -1264,7 +1264,7 @@ lpfc_debugfs_scsistat_data(struct lpfc_vport *vport, char *buf, int size)
        int i;
        char tmp[LPFC_MAX_SCSI_INFO_TMP_LEN] = {0};
 
-       if (!(phba->cfg_enable_fc4_type & LPFC_ENABLE_FCP) ||
+       if (!(vport->cfg_enable_fc4_type & LPFC_ENABLE_FCP) ||
            (phba->sli_rev != LPFC_SLI_REV4))
                return 0;
 
index b3a4789468c3807572ce23e985946d930cdb38fd..3df2cfd02b41024ea95d61bcf3dcf1e92c80e148 100644 (file)
@@ -2827,8 +2827,8 @@ out:
                !(vport->fc_flag & FC_PT2PT_PLOGI)) {
                phba->pport->fc_myDID = 0;
 
-               if ((phba->cfg_enable_fc4_type == LPFC_ENABLE_BOTH) ||
-                   (phba->cfg_enable_fc4_type == LPFC_ENABLE_NVME)) {
+               if ((vport->cfg_enable_fc4_type == LPFC_ENABLE_BOTH) ||
+                   (vport->cfg_enable_fc4_type == LPFC_ENABLE_NVME)) {
                        if (phba->nvmet_support)
                                lpfc_nvmet_update_targetport(phba);
                        else
index 62689a06c18811e41b8f19d6eb5bebbed6909348..47608d4b8e8ca25cb256d1ab487c05b9a7e2b937 100644 (file)
@@ -857,10 +857,9 @@ lpfc_port_link_failure(struct lpfc_vport *vport)
 void
 lpfc_linkdown_port(struct lpfc_vport *vport)
 {
-       struct lpfc_hba  *phba = vport->phba;
        struct Scsi_Host  *shost = lpfc_shost_from_vport(vport);
 
-       if (phba->cfg_enable_fc4_type != LPFC_ENABLE_NVME)
+       if (vport->cfg_enable_fc4_type != LPFC_ENABLE_NVME)
                fc_host_post_event(shost, fc_get_event_number(),
                                   FCH_EVT_LINKDOWN, 0);
 
@@ -923,8 +922,8 @@ lpfc_linkdown(struct lpfc_hba *phba)
 
                        vports[i]->fc_myDID = 0;
 
-                       if ((phba->cfg_enable_fc4_type == LPFC_ENABLE_BOTH) ||
-                           (phba->cfg_enable_fc4_type == LPFC_ENABLE_NVME)) {
+                       if ((vport->cfg_enable_fc4_type == LPFC_ENABLE_BOTH) ||
+                           (vport->cfg_enable_fc4_type == LPFC_ENABLE_NVME)) {
                                if (phba->nvmet_support)
                                        lpfc_nvmet_update_targetport(phba);
                                else
@@ -1010,7 +1009,7 @@ lpfc_linkup_port(struct lpfc_vport *vport)
                (vport != phba->pport))
                return;
 
-       if (phba->cfg_enable_fc4_type != LPFC_ENABLE_NVME)
+       if (vport->cfg_enable_fc4_type != LPFC_ENABLE_NVME)
                fc_host_post_event(shost, fc_get_event_number(),
                                   FCH_EVT_LINKUP, 0);
 
@@ -3658,8 +3657,8 @@ lpfc_mbx_cmpl_reg_vpi(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
                spin_unlock_irq(shost->host_lock);
                vport->fc_myDID = 0;
 
-               if ((phba->cfg_enable_fc4_type == LPFC_ENABLE_BOTH) ||
-                   (phba->cfg_enable_fc4_type == LPFC_ENABLE_NVME)) {
+               if ((vport->cfg_enable_fc4_type == LPFC_ENABLE_BOTH) ||
+                   (vport->cfg_enable_fc4_type == LPFC_ENABLE_NVME)) {
                        if (phba->nvmet_support)
                                lpfc_nvmet_update_targetport(phba);
                        else
@@ -3921,11 +3920,9 @@ lpfc_mbx_cmpl_fabric_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
 int
 lpfc_issue_gidft(struct lpfc_vport *vport)
 {
-       struct lpfc_hba *phba = vport->phba;
-
        /* Good status, issue CT Request to NameServer */
-       if ((phba->cfg_enable_fc4_type == LPFC_ENABLE_BOTH) ||
-           (phba->cfg_enable_fc4_type == LPFC_ENABLE_FCP)) {
+       if ((vport->cfg_enable_fc4_type == LPFC_ENABLE_BOTH) ||
+           (vport->cfg_enable_fc4_type == LPFC_ENABLE_FCP)) {
                if (lpfc_ns_cmd(vport, SLI_CTNS_GID_FT, 0, SLI_CTPT_FCP)) {
                        /* Cannot issue NameServer FCP Query, so finish up
                         * discovery
@@ -3940,8 +3937,8 @@ lpfc_issue_gidft(struct lpfc_vport *vport)
                vport->gidft_inp++;
        }
 
-       if ((phba->cfg_enable_fc4_type == LPFC_ENABLE_BOTH) ||
-           (phba->cfg_enable_fc4_type == LPFC_ENABLE_NVME)) {
+       if ((vport->cfg_enable_fc4_type == LPFC_ENABLE_BOTH) ||
+           (vport->cfg_enable_fc4_type == LPFC_ENABLE_NVME)) {
                if (lpfc_ns_cmd(vport, SLI_CTNS_GID_FT, 0, SLI_CTPT_NVME)) {
                        /* Cannot issue NameServer NVME Query, so finish up
                         * discovery
@@ -4057,12 +4054,12 @@ out:
                lpfc_ns_cmd(vport, SLI_CTNS_RSPN_ID, 0, 0);
                lpfc_ns_cmd(vport, SLI_CTNS_RFT_ID, 0, 0);
 
-               if ((phba->cfg_enable_fc4_type == LPFC_ENABLE_BOTH) ||
-                   (phba->cfg_enable_fc4_type == LPFC_ENABLE_FCP))
+               if ((vport->cfg_enable_fc4_type == LPFC_ENABLE_BOTH) ||
+                   (vport->cfg_enable_fc4_type == LPFC_ENABLE_FCP))
                        lpfc_ns_cmd(vport, SLI_CTNS_RFF_ID, 0, FC_TYPE_FCP);
 
-               if ((phba->cfg_enable_fc4_type == LPFC_ENABLE_BOTH) ||
-                   (phba->cfg_enable_fc4_type == LPFC_ENABLE_NVME))
+               if ((vport->cfg_enable_fc4_type == LPFC_ENABLE_BOTH) ||
+                   (vport->cfg_enable_fc4_type == LPFC_ENABLE_NVME))
                        lpfc_ns_cmd(vport, SLI_CTNS_RFF_ID, 0,
                                    FC_TYPE_NVME);
 
@@ -4098,7 +4095,7 @@ lpfc_register_remote_port(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp)
        struct fc_rport_identifiers rport_ids;
        struct lpfc_hba  *phba = vport->phba;
 
-       if (phba->cfg_enable_fc4_type == LPFC_ENABLE_NVME)
+       if (vport->cfg_enable_fc4_type == LPFC_ENABLE_NVME)
                return;
 
        /* Remote port has reappeared. Re-register w/ FC transport */
@@ -4173,9 +4170,8 @@ lpfc_unregister_remote_port(struct lpfc_nodelist *ndlp)
 {
        struct fc_rport *rport = ndlp->rport;
        struct lpfc_vport *vport = ndlp->vport;
-       struct lpfc_hba  *phba = vport->phba;
 
-       if (phba->cfg_enable_fc4_type == LPFC_ENABLE_NVME)
+       if (vport->cfg_enable_fc4_type == LPFC_ENABLE_NVME)
                return;
 
        lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_RPORT,
index 1188354ecd993df202265e30db5617574efd473c..563b6009ffced629f051f717d39ad7aadffd54de 100644 (file)
@@ -4290,6 +4290,9 @@ lpfc_create_port(struct lpfc_hba *phba, int instance, struct device *dev)
        vport->fc_rscn_flush = 0;
        lpfc_get_vport_cfgparam(vport);
 
+       /* Adjust value in vport */
+       vport->cfg_enable_fc4_type = phba->cfg_enable_fc4_type;
+
        shost->unique_id = instance;
        shost->max_id = LPFC_MAX_TARGET;
        shost->max_lun = vport->cfg_max_luns;
index 96bc3789a1662e650f5b70491b61679ab88fc9ba..acfce67dacde55364f963b64de8445136e2f281a 100644 (file)
@@ -825,7 +825,7 @@ lpfc_rcv_prli(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
                        "rport rolechg:   role:x%x did:x%x flg:x%x",
                        roles, ndlp->nlp_DID, ndlp->nlp_flag);
 
-               if (phba->cfg_enable_fc4_type != LPFC_ENABLE_NVME)
+               if (vport->cfg_enable_fc4_type != LPFC_ENABLE_NVME)
                        fc_remote_port_rolechg(rport, roles);
        }
 }
@@ -1789,8 +1789,8 @@ lpfc_cmpl_reglogin_reglogin_issue(struct lpfc_vport *vport,
                         * is configured try it.
                         */
                        ndlp->nlp_fc4_type |= NLP_FC4_FCP;
-                       if ((phba->cfg_enable_fc4_type == LPFC_ENABLE_BOTH) ||
-                            (phba->cfg_enable_fc4_type == LPFC_ENABLE_NVME)) {
+                       if ((vport->cfg_enable_fc4_type == LPFC_ENABLE_BOTH) ||
+                           (vport->cfg_enable_fc4_type == LPFC_ENABLE_NVME)) {
                                ndlp->nlp_fc4_type |= NLP_FC4_NVME;
                                /* We need to update the localport also */
                                lpfc_nvme_update_localport(vport);
@@ -1804,7 +1804,7 @@ lpfc_cmpl_reglogin_reglogin_issue(struct lpfc_vport *vport,
                         * should just issue PRLI for FCP. Otherwise issue
                         * GFT_ID to determine if remote port supports NVME.
                         */
-                       if (phba->cfg_enable_fc4_type != LPFC_ENABLE_FCP) {
+                       if (vport->cfg_enable_fc4_type != LPFC_ENABLE_FCP) {
                                rc = lpfc_ns_cmd(vport, SLI_CTNS_GFT_ID,
                                                 0, ndlp->nlp_DID);
                                return ndlp->nlp_state;
index c0065452bc9aab10ea22fd78c71a9a446cc35768..af263b0e8bad17f66460652f14e3eefbe02ca335 100644 (file)
@@ -530,7 +530,7 @@ lpfc_sli4_vport_delete_fcp_xri_aborted(struct lpfc_vport *vport)
        unsigned long iflag = 0;
        int idx;
 
-       if (!(phba->cfg_enable_fc4_type & LPFC_ENABLE_FCP))
+       if (!(vport->cfg_enable_fc4_type & LPFC_ENABLE_FCP))
                return;
 
        spin_lock_irqsave(&phba->hbalock, iflag);
index 102a011ff6d4190c8b3e35308f783fa105ba1ad5..0d712eb04e2b537b21465169eb5eaf8d5957f7b2 100644 (file)
@@ -313,11 +313,11 @@ lpfc_vport_create(struct fc_vport *fc_vport, bool disable)
                goto error_out;
        }
 
-       /* NPIV is not supported if HBA has NVME enabled */
-       if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) {
+       /* NPIV is not supported if HBA has NVME Target enabled */
+       if (phba->nvmet_support) {
                lpfc_printf_log(phba, KERN_ERR, LOG_VPORT,
                                "3189 Create VPORT failed: "
-                               "NPIV is not supported on NVME\n");
+                               "NPIV is not supported on NVME Target\n");
                rc = VPORT_INVAL;
                goto error_out;
        }
@@ -403,6 +403,9 @@ lpfc_vport_create(struct fc_vport *fc_vport, bool disable)
        /* Set the DFT_LUN_Q_DEPTH accordingly */
        vport->cfg_lun_queue_depth  = phba->pport->cfg_lun_queue_depth;
 
+       /* Only the physical port can support NVME for now */
+       vport->cfg_enable_fc4_type = LPFC_ENABLE_FCP;
+
        *(struct lpfc_vport **)fc_vport->dd_data = vport;
        vport->fc_vport = fc_vport;
 
@@ -415,22 +418,6 @@ lpfc_vport_create(struct fc_vport *fc_vport, bool disable)
                vport->fdmi_port_mask = phba->pport->fdmi_port_mask;
        }
 
-       if ((phba->nvmet_support == 0) &&
-           ((phba->cfg_enable_fc4_type == LPFC_ENABLE_BOTH) ||
-            (phba->cfg_enable_fc4_type == LPFC_ENABLE_NVME))) {
-               /* Create NVME binding with nvme_fc_transport. This
-                * ensures the vport is initialized.
-                */
-               rc = lpfc_nvme_create_localport(vport);
-               if (rc) {
-                       lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
-                                       "6003 %s status x%x\n",
-                                       "NVME registration failed, ",
-                                       rc);
-                       goto error_out;
-               }
-       }
-
        /*
         * In SLI4, the vpi must be activated before it can be used
         * by the port.