Commit 81907422 authored by Justin Tee's avatar Justin Tee Committed by Martin K. Petersen

scsi: lpfc: Clean up SLI-4 sysfs resource reporting

Currently, we have dated logic to work around the differences between SLI-4
and SLI-3 resource reporting through sysfs.

Leave the SLI-3 path untouched, but for SLI4 path, retrieve resource values
from the phba->sli4_hba->max_cfg_param structure.  Max values are populated
during ACQE events right after READ_CONFIG mbox cmd is sent.  Instead of
the dated subtraction logic, used resource calculation is directly fed into
sysfs for display.
Signed-off-by: default avatarJustin Tee <justin.tee@broadcom.com>
Link: https://lore.kernel.org/r/20230712180522.112722-11-justintee8345@gmail.comSigned-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent d668b368
...@@ -2127,11 +2127,12 @@ lpfc_get_hba_info(struct lpfc_hba *phba, ...@@ -2127,11 +2127,12 @@ lpfc_get_hba_info(struct lpfc_hba *phba,
uint32_t *mrpi, uint32_t *arpi, uint32_t *mrpi, uint32_t *arpi,
uint32_t *mvpi, uint32_t *avpi) uint32_t *mvpi, uint32_t *avpi)
{ {
struct lpfc_mbx_read_config *rd_config;
LPFC_MBOXQ_t *pmboxq; LPFC_MBOXQ_t *pmboxq;
MAILBOX_t *pmb; MAILBOX_t *pmb;
int rc = 0; int rc = 0;
uint32_t max_vpi; struct lpfc_sli4_hba *sli4_hba;
struct lpfc_max_cfg_param *max_cfg_param;
u16 rsrc_ext_cnt, rsrc_ext_size, max_vpi;
/* /*
* prevent udev from issuing mailbox commands until the port is * prevent udev from issuing mailbox commands until the port is
...@@ -2167,31 +2168,65 @@ lpfc_get_hba_info(struct lpfc_hba *phba, ...@@ -2167,31 +2168,65 @@ lpfc_get_hba_info(struct lpfc_hba *phba,
} }
if (phba->sli_rev == LPFC_SLI_REV4) { if (phba->sli_rev == LPFC_SLI_REV4) {
rd_config = &pmboxq->u.mqe.un.rd_config; sli4_hba = &phba->sli4_hba;
if (mrpi) max_cfg_param = &sli4_hba->max_cfg_param;
*mrpi = bf_get(lpfc_mbx_rd_conf_rpi_count, rd_config);
if (arpi) /* Normally, extents are not used */
*arpi = bf_get(lpfc_mbx_rd_conf_rpi_count, rd_config) - if (!phba->sli4_hba.extents_in_use) {
phba->sli4_hba.max_cfg_param.rpi_used; if (mrpi)
if (mxri) *mrpi = max_cfg_param->max_rpi;
*mxri = bf_get(lpfc_mbx_rd_conf_xri_count, rd_config); if (mxri)
if (axri) *mxri = max_cfg_param->max_xri;
*axri = bf_get(lpfc_mbx_rd_conf_xri_count, rd_config) - if (mvpi) {
phba->sli4_hba.max_cfg_param.xri_used; max_vpi = max_cfg_param->max_vpi;
/* Limit the max we support */
if (max_vpi > LPFC_MAX_VPI)
max_vpi = LPFC_MAX_VPI;
*mvpi = max_vpi;
}
} else { /* Extents in use */
if (mrpi) {
if (lpfc_sli4_get_avail_extnt_rsrc(phba,
LPFC_RSC_TYPE_FCOE_RPI,
&rsrc_ext_cnt,
&rsrc_ext_size)) {
rc = 0;
goto free_pmboxq;
}
*mrpi = rsrc_ext_cnt * rsrc_ext_size;
}
/* Account for differences with SLI-3. Get vpi count from if (mxri) {
* mailbox data and subtract one for max vpi value. if (lpfc_sli4_get_avail_extnt_rsrc(phba,
*/ LPFC_RSC_TYPE_FCOE_XRI,
max_vpi = (bf_get(lpfc_mbx_rd_conf_vpi_count, rd_config) > 0) ? &rsrc_ext_cnt,
(bf_get(lpfc_mbx_rd_conf_vpi_count, rd_config) - 1) : 0; &rsrc_ext_size)) {
rc = 0;
goto free_pmboxq;
}
/* Limit the max we support */ *mxri = rsrc_ext_cnt * rsrc_ext_size;
if (max_vpi > LPFC_MAX_VPI) }
max_vpi = LPFC_MAX_VPI;
if (mvpi) if (mvpi) {
*mvpi = max_vpi; if (lpfc_sli4_get_avail_extnt_rsrc(phba,
if (avpi) LPFC_RSC_TYPE_FCOE_VPI,
*avpi = max_vpi - phba->sli4_hba.max_cfg_param.vpi_used; &rsrc_ext_cnt,
&rsrc_ext_size)) {
rc = 0;
goto free_pmboxq;
}
max_vpi = rsrc_ext_cnt * rsrc_ext_size;
/* Limit the max we support */
if (max_vpi > LPFC_MAX_VPI)
max_vpi = LPFC_MAX_VPI;
*mvpi = max_vpi;
}
}
} else { } else {
if (mrpi) if (mrpi)
*mrpi = pmb->un.varRdConfig.max_rpi; *mrpi = pmb->un.varRdConfig.max_rpi;
...@@ -2212,8 +2247,12 @@ lpfc_get_hba_info(struct lpfc_hba *phba, ...@@ -2212,8 +2247,12 @@ lpfc_get_hba_info(struct lpfc_hba *phba,
} }
} }
/* Success */
rc = 1;
free_pmboxq:
mempool_free(pmboxq, phba->mbox_mem_pool); mempool_free(pmboxq, phba->mbox_mem_pool);
return 1; return rc;
} }
/** /**
...@@ -2265,10 +2304,19 @@ lpfc_used_rpi_show(struct device *dev, struct device_attribute *attr, ...@@ -2265,10 +2304,19 @@ lpfc_used_rpi_show(struct device *dev, struct device_attribute *attr,
struct Scsi_Host *shost = class_to_shost(dev); struct Scsi_Host *shost = class_to_shost(dev);
struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
struct lpfc_hba *phba = vport->phba; struct lpfc_hba *phba = vport->phba;
uint32_t cnt, acnt; struct lpfc_sli4_hba *sli4_hba;
struct lpfc_max_cfg_param *max_cfg_param;
u32 cnt = 0, acnt = 0;
if (lpfc_get_hba_info(phba, NULL, NULL, &cnt, &acnt, NULL, NULL)) if (phba->sli_rev == LPFC_SLI_REV4) {
return scnprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt)); sli4_hba = &phba->sli4_hba;
max_cfg_param = &sli4_hba->max_cfg_param;
return scnprintf(buf, PAGE_SIZE, "%d\n",
max_cfg_param->rpi_used);
} else {
if (lpfc_get_hba_info(phba, NULL, NULL, &cnt, &acnt, NULL, NULL))
return scnprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt));
}
return scnprintf(buf, PAGE_SIZE, "Unknown\n"); return scnprintf(buf, PAGE_SIZE, "Unknown\n");
} }
...@@ -2321,10 +2369,19 @@ lpfc_used_xri_show(struct device *dev, struct device_attribute *attr, ...@@ -2321,10 +2369,19 @@ lpfc_used_xri_show(struct device *dev, struct device_attribute *attr,
struct Scsi_Host *shost = class_to_shost(dev); struct Scsi_Host *shost = class_to_shost(dev);
struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
struct lpfc_hba *phba = vport->phba; struct lpfc_hba *phba = vport->phba;
uint32_t cnt, acnt; struct lpfc_sli4_hba *sli4_hba;
struct lpfc_max_cfg_param *max_cfg_param;
u32 cnt = 0, acnt = 0;
if (lpfc_get_hba_info(phba, &cnt, &acnt, NULL, NULL, NULL, NULL)) if (phba->sli_rev == LPFC_SLI_REV4) {
return scnprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt)); sli4_hba = &phba->sli4_hba;
max_cfg_param = &sli4_hba->max_cfg_param;
return scnprintf(buf, PAGE_SIZE, "%d\n",
max_cfg_param->xri_used);
} else {
if (lpfc_get_hba_info(phba, &cnt, &acnt, NULL, NULL, NULL, NULL))
return scnprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt));
}
return scnprintf(buf, PAGE_SIZE, "Unknown\n"); return scnprintf(buf, PAGE_SIZE, "Unknown\n");
} }
...@@ -2377,10 +2434,19 @@ lpfc_used_vpi_show(struct device *dev, struct device_attribute *attr, ...@@ -2377,10 +2434,19 @@ lpfc_used_vpi_show(struct device *dev, struct device_attribute *attr,
struct Scsi_Host *shost = class_to_shost(dev); struct Scsi_Host *shost = class_to_shost(dev);
struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
struct lpfc_hba *phba = vport->phba; struct lpfc_hba *phba = vport->phba;
uint32_t cnt, acnt; struct lpfc_sli4_hba *sli4_hba;
struct lpfc_max_cfg_param *max_cfg_param;
u32 cnt = 0, acnt = 0;
if (lpfc_get_hba_info(phba, NULL, NULL, NULL, NULL, &cnt, &acnt)) if (phba->sli_rev == LPFC_SLI_REV4) {
return scnprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt)); sli4_hba = &phba->sli4_hba;
max_cfg_param = &sli4_hba->max_cfg_param;
return scnprintf(buf, PAGE_SIZE, "%d\n",
max_cfg_param->vpi_used);
} else {
if (lpfc_get_hba_info(phba, NULL, NULL, NULL, NULL, &cnt, &acnt))
return scnprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt));
}
return scnprintf(buf, PAGE_SIZE, "Unknown\n"); return scnprintf(buf, PAGE_SIZE, "Unknown\n");
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment