From: James Smart <jsmart2021@gmail.com>
Date: Thu, 5 May 2022 20:55:15 -0700
Subject: scsi: lpfc: Change VMID registration to be based on fabric parameters
Patch-mainline: v5.19-rc1
Git-commit: 5099478e436f0acd8c76495590c105668f2d8afc
References: bsc#1200045
Currently, VMID registration is configured via module parameters. This
could lead to VMID compatibility issues if two ports are connected to
different brands of switches, as the two brands implement VMID differently.
Make logical changes so that VMID registration is based on common service
parameters from FLOGI_ACC with fabric rather than module parameters.
Link: https://lore.kernel.org/r/20220506035519.50908-9-jsmart2021@gmail.com
Co-developed-by: Justin Tee <justin.tee@broadcom.com>
Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Acked-by: Daniel Wagner <dwagner@suse.de>
---
drivers/scsi/lpfc/lpfc.h | 1 +
drivers/scsi/lpfc/lpfc_els.c | 3 ++-
drivers/scsi/lpfc/lpfc_scsi.c | 17 +++++++++--------
drivers/scsi/lpfc/lpfc_sli.c | 4 ++--
4 files changed, 14 insertions(+), 11 deletions(-)
--- a/drivers/scsi/lpfc/lpfc.h
+++ b/drivers/scsi/lpfc/lpfc.h
@@ -713,6 +713,7 @@ struct lpfc_vport {
#define LPFC_VMID_QFPA_CMPL 0x4
#define LPFC_VMID_QOS_ENABLED 0x8
#define LPFC_VMID_TIMER_ENBLD 0x10
+#define LPFC_VMID_TYPE_PRIO 0x20
struct fc_qfpa_res *qfpa_res;
struct fc_vport *fc_vport;
--- a/drivers/scsi/lpfc/lpfc_els.c
+++ b/drivers/scsi/lpfc/lpfc_els.c
@@ -1105,7 +1105,8 @@ lpfc_cmpl_els_flogi(struct lpfc_hba *phb
sp->cmn.priority_tagging, kref_read(&ndlp->kref));
if (sp->cmn.priority_tagging)
- vport->vmid_flag |= LPFC_VMID_ISSUE_QFPA;
+ vport->phba->pport->vmid_flag |= (LPFC_VMID_ISSUE_QFPA |
+ LPFC_VMID_TYPE_PRIO);
if (vport->port_state == LPFC_FLOGI) {
/*
--- a/drivers/scsi/lpfc/lpfc_scsi.c
+++ b/drivers/scsi/lpfc/lpfc_scsi.c
@@ -5344,9 +5344,9 @@ static void lpfc_vmid_update_entry(struc
{
u64 *lta;
- if (vport->vmid_priority_tagging)
+ if (vport->phba->pport->vmid_flag & LPFC_VMID_TYPE_PRIO)
tag->cs_ctl_vmid = vmp->un.cs_ctl_vmid;
- else
+ else if (vport->phba->cfg_vmid_app_header)
tag->app_id = vmp->un.app_id;
if (cmd->sc_data_direction == DMA_TO_DEVICE)
@@ -5391,11 +5391,12 @@ static int lpfc_vmid_get_appid(struct lp
scsi_cmnd * cmd, union lpfc_vmid_io_tag *tag)
{
struct lpfc_vmid *vmp = NULL;
- int hash, len, rc, i;
+ int hash, len, rc = -EPERM, i;
/* check if QFPA is complete */
- if (lpfc_vmid_is_type_priority_tag(vport) && !(vport->vmid_flag &
- LPFC_VMID_QFPA_CMPL)) {
+ if (lpfc_vmid_is_type_priority_tag(vport) &&
+ !(vport->vmid_flag & LPFC_VMID_QFPA_CMPL) &&
+ (vport->vmid_flag & LPFC_VMID_ISSUE_QFPA)) {
vport->work_port_events |= WORKER_CHECK_VMID_ISSUE_QFPA;
return -EAGAIN;
}
@@ -5469,7 +5470,7 @@ static int lpfc_vmid_get_appid(struct lp
vport->vmid_inactivity_timeout ? 1 : 0;
/* if type priority tag, get next available VMID */
- if (lpfc_vmid_is_type_priority_tag(vport))
+ if (vport->phba->pport->vmid_flag & LPFC_VMID_TYPE_PRIO)
lpfc_vmid_assign_cs_ctl(vport, vmp);
/* allocate the per cpu variable for holding */
@@ -5488,9 +5489,9 @@ static int lpfc_vmid_get_appid(struct lp
write_unlock(&vport->vmid_lock);
/* complete transaction with switch */
- if (lpfc_vmid_is_type_priority_tag(vport))
+ if (vport->phba->pport->vmid_flag & LPFC_VMID_TYPE_PRIO)
rc = lpfc_vmid_uvem(vport, vmp, true);
- else
+ else if (vport->phba->cfg_vmid_app_header)
rc = lpfc_vmid_cmd(vport, SLI_CTAS_RAPP_IDENT, vmp);
if (!rc) {
write_lock(&vport->vmid_lock);
--- a/drivers/scsi/lpfc/lpfc_sli.c
+++ b/drivers/scsi/lpfc/lpfc_sli.c
@@ -10366,11 +10366,11 @@ lpfc_prep_embed_io(struct lpfc_hba *phba
/* add the VMID tags as per switch response */
if (unlikely(piocb->cmd_flag & LPFC_IO_VMID)) {
- if (phba->pport->vmid_priority_tagging) {
+ if (phba->pport->vmid_flag & LPFC_VMID_TYPE_PRIO) {
bf_set(wqe_ccpe, &wqe->fcp_iwrite.wqe_com, 1);
bf_set(wqe_ccp, &wqe->fcp_iwrite.wqe_com,
(piocb->vmid_tag.cs_ctl_vmid));
- } else {
+ } else if (phba->cfg_vmid_app_header) {
bf_set(wqe_appid, &wqe->fcp_iwrite.wqe_com, 1);
bf_set(wqe_wqes, &wqe->fcp_iwrite.wqe_com, 1);
wqe->words[31] = piocb->vmid_tag.app_id;