Skip to content

Commit 7a1dda9

Browse files
jsmart-ghmartinkpetersen
authored andcommitted
scsi: lpfc: Correct sysfs reporting of loop support after SFP status change
Applications determine loop support in part by querying the 'pls' sysfs node. Reporting of 'pls' (Private Loop Support) is derived from the descriptor returned by the COMMON_GET_SLI4_PARAMETERS mailbox command, which is issued during initialization or after a reset. The value of this field may change if there is a dynamic SFP change. The driver currently will not pick up the change as there was no reset scenario. Rework to commonize the sending of the COMMON_GET_SLI4_PARAMETERS command. Add the calling of the routine after receipt of an async event indicating an SFP change. Link: https://lore.kernel.org/r/[email protected] Co-developed-by: Justin Tee <[email protected]> Signed-off-by: Justin Tee <[email protected]> Signed-off-by: James Smart <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent d305c25 commit 7a1dda9

File tree

3 files changed

+55
-21
lines changed

3 files changed

+55
-21
lines changed

drivers/scsi/lpfc/lpfc_crtn.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ void lpfc_delayed_disc_timeout_handler(struct lpfc_vport *);
205205
int lpfc_config_port_prep(struct lpfc_hba *);
206206
void lpfc_update_vport_wwn(struct lpfc_vport *vport);
207207
int lpfc_config_port_post(struct lpfc_hba *);
208+
int lpfc_sli4_refresh_params(struct lpfc_hba *phba);
208209
int lpfc_hba_down_prep(struct lpfc_hba *);
209210
int lpfc_hba_down_post(struct lpfc_hba *);
210211
void lpfc_hba_init(struct lpfc_hba *, uint32_t *);

drivers/scsi/lpfc/lpfc_init.c

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,50 @@ lpfc_config_port_post(struct lpfc_hba *phba)
662662
return 0;
663663
}
664664

665+
/**
666+
* lpfc_sli4_refresh_params - update driver copy of params.
667+
* @phba: Pointer to HBA context object.
668+
*
669+
* This is called to refresh driver copy of dynamic fields from the
670+
* common_get_sli4_parameters descriptor.
671+
**/
672+
int
673+
lpfc_sli4_refresh_params(struct lpfc_hba *phba)
674+
{
675+
LPFC_MBOXQ_t *mboxq;
676+
struct lpfc_mqe *mqe;
677+
struct lpfc_sli4_parameters *mbx_sli4_parameters;
678+
int length, rc;
679+
680+
mboxq = (LPFC_MBOXQ_t *)mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
681+
if (!mboxq)
682+
return -ENOMEM;
683+
684+
mqe = &mboxq->u.mqe;
685+
/* Read the port's SLI4 Config Parameters */
686+
length = (sizeof(struct lpfc_mbx_get_sli4_parameters) -
687+
sizeof(struct lpfc_sli4_cfg_mhdr));
688+
lpfc_sli4_config(phba, mboxq, LPFC_MBOX_SUBSYSTEM_COMMON,
689+
LPFC_MBOX_OPCODE_GET_SLI4_PARAMETERS,
690+
length, LPFC_SLI4_MBX_EMBED);
691+
692+
rc = lpfc_sli_issue_mbox(phba, mboxq, MBX_POLL);
693+
if (unlikely(rc)) {
694+
mempool_free(mboxq, phba->mbox_mem_pool);
695+
return rc;
696+
}
697+
mbx_sli4_parameters = &mqe->un.get_sli4_parameters.sli4_parameters;
698+
phba->sli4_hba.pc_sli4_params.mi_ver =
699+
bf_get(cfg_mi_ver, mbx_sli4_parameters);
700+
phba->sli4_hba.pc_sli4_params.cmf =
701+
bf_get(cfg_cmf, mbx_sli4_parameters);
702+
phba->sli4_hba.pc_sli4_params.pls =
703+
bf_get(cfg_pvl, mbx_sli4_parameters);
704+
705+
mempool_free(mboxq, phba->mbox_mem_pool);
706+
return rc;
707+
}
708+
665709
/**
666710
* lpfc_hba_init_link - Initialize the FC link
667711
* @phba: pointer to lpfc hba data structure.
@@ -6455,6 +6499,12 @@ lpfc_sli4_async_sli_evt(struct lpfc_hba *phba, struct lpfc_acqe_sli *acqe_sli)
64556499
"3194 Unable to retrieve supported "
64566500
"speeds, rc = 0x%x\n", rc);
64576501
}
6502+
rc = lpfc_sli4_refresh_params(phba);
6503+
if (rc) {
6504+
lpfc_printf_log(phba, KERN_ERR, LOG_SLI,
6505+
"3174 Unable to update pls support, "
6506+
"rc x%x\n", rc);
6507+
}
64586508
vports = lpfc_create_vport_work_array(phba);
64596509
if (vports != NULL) {
64606510
for (i = 0; i <= phba->max_vports && vports[i] != NULL;

drivers/scsi/lpfc/lpfc_sli.c

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7891,36 +7891,19 @@ static int
78917891
lpfc_cmf_setup(struct lpfc_hba *phba)
78927892
{
78937893
LPFC_MBOXQ_t *mboxq;
7894-
struct lpfc_mqe *mqe;
78957894
struct lpfc_dmabuf *mp;
78967895
struct lpfc_pc_sli4_params *sli4_params;
7897-
struct lpfc_sli4_parameters *mbx_sli4_parameters;
7898-
int length;
78997896
int rc, cmf, mi_ver;
79007897

7898+
rc = lpfc_sli4_refresh_params(phba);
7899+
if (unlikely(rc))
7900+
return rc;
7901+
79017902
mboxq = (LPFC_MBOXQ_t *)mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
79027903
if (!mboxq)
79037904
return -ENOMEM;
7904-
mqe = &mboxq->u.mqe;
7905-
7906-
/* Read the port's SLI4 Config Parameters */
7907-
length = (sizeof(struct lpfc_mbx_get_sli4_parameters) -
7908-
sizeof(struct lpfc_sli4_cfg_mhdr));
7909-
lpfc_sli4_config(phba, mboxq, LPFC_MBOX_SUBSYSTEM_COMMON,
7910-
LPFC_MBOX_OPCODE_GET_SLI4_PARAMETERS,
7911-
length, LPFC_SLI4_MBX_EMBED);
7912-
7913-
rc = lpfc_sli_issue_mbox(phba, mboxq, MBX_POLL);
7914-
if (unlikely(rc)) {
7915-
mempool_free(mboxq, phba->mbox_mem_pool);
7916-
return rc;
7917-
}
79187905

7919-
/* Gather info on CMF and MI support */
79207906
sli4_params = &phba->sli4_hba.pc_sli4_params;
7921-
mbx_sli4_parameters = &mqe->un.get_sli4_parameters.sli4_parameters;
7922-
sli4_params->mi_ver = bf_get(cfg_mi_ver, mbx_sli4_parameters);
7923-
sli4_params->cmf = bf_get(cfg_cmf, mbx_sli4_parameters);
79247907

79257908
/* Are we forcing MI off via module parameter? */
79267909
if (!phba->cfg_enable_mi)

0 commit comments

Comments
 (0)