Skip to content

Commit c6a5c74

Browse files
jsmart-ghmartinkpetersen
authored andcommitted
scsi: lpfc: Add MIB feature enablement support
MIB support is currently limited to detecting support in the adapter and ensuring FDMI support is enabled if present. For the new framework MIB support also requires active enablement of support via the SET_FEATURES command with the firmware. Rework the MIB detection and enablement for the following: - Move detection away from the get_sli4_parameters routine, and into the hba_setup path. get_sli4_parameters is only called once at attachment while hba_setup is called as part of any SLI port reset path. This ensures detection after firmware download. - Update SET_FEATURES mbx command for the MIB enablement feature and add support for the feature. - Create the cmf_setup routine to encapsulate the detection of MIB support and perform the enablement of the MIB support feature. 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 3b0009c commit c6a5c74

File tree

5 files changed

+123
-20
lines changed

5 files changed

+123
-20
lines changed

drivers/scsi/lpfc/lpfc_ct.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2332,24 +2332,29 @@ lpfc_cmpl_ct_disc_fdmi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
23322332
break;
23332333
case SLI_MGMT_RPA:
23342334
if (vport->port_type == LPFC_PHYSICAL_PORT &&
2335-
phba->cfg_enable_mi &&
2336-
phba->sli4_hba.pc_sli4_params.mi_ver > LPFC_MIB1_SUPPORT) {
2335+
phba->sli4_hba.pc_sli4_params.mi_ver) {
23372336
/* mi is only for the phyical port, no vports */
23382337
if (phba->link_flag & LS_CT_VEN_RPA) {
23392338
lpfc_printf_vlog(vport, KERN_INFO,
2340-
LOG_DISCOVERY | LOG_ELS,
2339+
LOG_DISCOVERY | LOG_ELS |
2340+
LOG_CGN_MGMT,
23412341
"6449 VEN RPA FDMI Success\n");
23422342
phba->link_flag &= ~LS_CT_VEN_RPA;
23432343
break;
23442344
}
23452345

2346+
lpfc_printf_log(phba, KERN_INFO, LOG_CGN_MGMT,
2347+
"6210 Issue Vendor MI FDMI %x\n",
2348+
phba->sli4_hba.pc_sli4_params.mi_ver);
2349+
2350+
/* CGN is only for the physical port, no vports */
23462351
if (lpfc_fdmi_cmd(vport, ndlp, cmd,
23472352
LPFC_FDMI_VENDOR_ATTR_mi) == 0)
23482353
phba->link_flag |= LS_CT_VEN_RPA;
23492354
lpfc_printf_log(phba, KERN_INFO,
23502355
LOG_DISCOVERY | LOG_ELS,
23512356
"6458 Send MI FDMI:%x Flag x%x\n",
2352-
phba->sli4_hba.pc_sli4_params.mi_value,
2357+
phba->sli4_hba.pc_sli4_params.mi_ver,
23532358
phba->link_flag);
23542359
} else {
23552360
lpfc_printf_log(phba, KERN_INFO,
@@ -3348,7 +3353,7 @@ lpfc_fdmi_vendor_attr_mi(struct lpfc_vport *vport,
33483353
ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
33493354
memset(ae, 0, 256);
33503355
sprintf(mibrevision, "ELXE2EM:%04d",
3351-
phba->sli4_hba.pc_sli4_params.mi_value);
3356+
phba->sli4_hba.pc_sli4_params.mi_ver);
33523357
strncpy(ae->un.AttrString, &mibrevision[0], sizeof(ae->un.AttrString));
33533358
len = strnlen(ae->un.AttrString, sizeof(ae->un.AttrString));
33543359
len += (len & 3) ? (4 - (len & 3)) : 4;

drivers/scsi/lpfc/lpfc_hw4.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3393,6 +3393,7 @@ struct lpfc_sli4_parameters {
33933393
#define LPFC_SET_UE_RECOVERY 0x10
33943394
#define LPFC_SET_MDS_DIAGS 0x12
33953395
#define LPFC_SET_DUAL_DUMP 0x1e
3396+
#define LPFC_SET_ENABLE_MI 0x21
33963397
struct lpfc_mbx_set_feature {
33973398
struct mbox_header header;
33983399
uint32_t feature;
@@ -3416,6 +3417,12 @@ struct lpfc_mbx_set_feature {
34163417
#define LPFC_DISABLE_DUAL_DUMP 0
34173418
#define LPFC_ENABLE_DUAL_DUMP 1
34183419
#define LPFC_QUERY_OP_DUAL_DUMP 2
3420+
#define lpfc_mbx_set_feature_mi_SHIFT 0
3421+
#define lpfc_mbx_set_feature_mi_MASK 0x0000ffff
3422+
#define lpfc_mbx_set_feature_mi_WORD word6
3423+
#define lpfc_mbx_set_feature_milunq_SHIFT 16
3424+
#define lpfc_mbx_set_feature_milunq_MASK 0x0000ffff
3425+
#define lpfc_mbx_set_feature_milunq_WORD word6
34193426
uint32_t word7;
34203427
#define lpfc_mbx_set_feature_UERP_SHIFT 0
34213428
#define lpfc_mbx_set_feature_UERP_MASK 0x0000ffff

drivers/scsi/lpfc/lpfc_init.c

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12350,21 +12350,6 @@ lpfc_get_sli4_parameters(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq)
1235012350
else
1235112351
phba->nsler = 0;
1235212352

12353-
/* Save PB info for use during HBA setup */
12354-
sli4_params->mi_ver = bf_get(cfg_mi_ver, mbx_sli4_parameters);
12355-
sli4_params->mib_bde_cnt = bf_get(cfg_mib_bde_cnt, mbx_sli4_parameters);
12356-
sli4_params->mib_size = mbx_sli4_parameters->mib_size;
12357-
sli4_params->mi_value = LPFC_DFLT_MIB_VAL;
12358-
12359-
/* Next we check for Vendor MIB support */
12360-
if (sli4_params->mi_ver && phba->cfg_enable_mi)
12361-
phba->cfg_fdmi_on = LPFC_FDMI_SUPPORT;
12362-
12363-
lpfc_printf_log(phba, KERN_INFO, LOG_INIT,
12364-
"6461 MIB attr %d enable %d FDMI %d buf %d:%d\n",
12365-
sli4_params->mi_ver, phba->cfg_enable_mi,
12366-
sli4_params->mi_value, sli4_params->mib_bde_cnt,
12367-
sli4_params->mib_size);
1236812353
return 0;
1236912354
}
1237012355

drivers/scsi/lpfc/lpfc_logmsg.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@
4444
#define LOG_NVME_DISC 0x00200000 /* NVME Discovery/Connect events. */
4545
#define LOG_NVME_ABTS 0x00400000 /* NVME ABTS events. */
4646
#define LOG_NVME_IOERR 0x00800000 /* NVME IO Error events. */
47+
#define LOG_RSVD1 0x01000000 /* Reserved */
48+
#define LOG_RSVD2 0x02000000 /* Reserved */
49+
#define LOG_CGN_MGMT 0x04000000 /* Congestion Mgmt events */
4750
#define LOG_TRACE_EVENT 0x80000000 /* Dmp the DBG log on this err */
4851
#define LOG_ALL_MSG 0x7fffffff /* LOG all messages */
4952

drivers/scsi/lpfc/lpfc_sli.c

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6447,6 +6447,14 @@ lpfc_set_features(struct lpfc_hba *phba, LPFC_MBOXQ_t *mbox,
64476447
mbox->u.mqe.un.set_feature.feature = LPFC_SET_DUAL_DUMP;
64486448
mbox->u.mqe.un.set_feature.param_len = 4;
64496449
break;
6450+
case LPFC_SET_ENABLE_MI:
6451+
mbox->u.mqe.un.set_feature.feature = LPFC_SET_ENABLE_MI;
6452+
mbox->u.mqe.un.set_feature.param_len = 4;
6453+
bf_set(lpfc_mbx_set_feature_milunq, &mbox->u.mqe.un.set_feature,
6454+
phba->pport->cfg_lun_queue_depth);
6455+
bf_set(lpfc_mbx_set_feature_mi, &mbox->u.mqe.un.set_feature,
6456+
phba->sli4_hba.pc_sli4_params.mi_ver);
6457+
break;
64506458
}
64516459

64526460
return;
@@ -7499,6 +7507,99 @@ static void lpfc_sli4_dip(struct lpfc_hba *phba)
74997507
}
75007508
}
75017509

7510+
/**
7511+
* lpfc_cmf_setup - Initialize idle_stat tracking
7512+
* @phba: Pointer to HBA context object.
7513+
*
7514+
* This is called from HBA setup during driver load or when the HBA
7515+
* comes online. this does all the initialization to support CMF and MI.
7516+
**/
7517+
static int
7518+
lpfc_cmf_setup(struct lpfc_hba *phba)
7519+
{
7520+
LPFC_MBOXQ_t *mboxq;
7521+
struct lpfc_mqe *mqe;
7522+
struct lpfc_pc_sli4_params *sli4_params;
7523+
struct lpfc_sli4_parameters *mbx_sli4_parameters;
7524+
int length;
7525+
int rc, mi_ver;
7526+
7527+
mboxq = (LPFC_MBOXQ_t *)mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
7528+
if (!mboxq)
7529+
return -ENOMEM;
7530+
mqe = &mboxq->u.mqe;
7531+
7532+
/* Read the port's SLI4 Config Parameters */
7533+
length = (sizeof(struct lpfc_mbx_get_sli4_parameters) -
7534+
sizeof(struct lpfc_sli4_cfg_mhdr));
7535+
lpfc_sli4_config(phba, mboxq, LPFC_MBOX_SUBSYSTEM_COMMON,
7536+
LPFC_MBOX_OPCODE_GET_SLI4_PARAMETERS,
7537+
length, LPFC_SLI4_MBX_EMBED);
7538+
7539+
rc = lpfc_sli_issue_mbox(phba, mboxq, MBX_POLL);
7540+
if (unlikely(rc)) {
7541+
mempool_free(mboxq, phba->mbox_mem_pool);
7542+
return rc;
7543+
}
7544+
7545+
/* Gather info on MI support */
7546+
sli4_params = &phba->sli4_hba.pc_sli4_params;
7547+
mbx_sli4_parameters = &mqe->un.get_sli4_parameters.sli4_parameters;
7548+
sli4_params->mi_ver = bf_get(cfg_mi_ver, mbx_sli4_parameters);
7549+
7550+
/* Are we forcing MI off via module parameter? */
7551+
if (!phba->cfg_enable_mi)
7552+
sli4_params->mi_ver = 0;
7553+
7554+
/* Always try to enable MI feature if we can */
7555+
if (sli4_params->mi_ver) {
7556+
lpfc_set_features(phba, mboxq, LPFC_SET_ENABLE_MI);
7557+
rc = lpfc_sli_issue_mbox(phba, mboxq, MBX_POLL);
7558+
mi_ver = bf_get(lpfc_mbx_set_feature_mi,
7559+
&mboxq->u.mqe.un.set_feature);
7560+
7561+
if (rc == MBX_SUCCESS) {
7562+
if (mi_ver) {
7563+
lpfc_printf_log(phba,
7564+
KERN_WARNING, LOG_CGN_MGMT,
7565+
"6215 MI is enabled\n");
7566+
sli4_params->mi_ver = mi_ver;
7567+
} else {
7568+
lpfc_printf_log(phba,
7569+
KERN_WARNING, LOG_CGN_MGMT,
7570+
"6338 MI is disabled\n");
7571+
sli4_params->mi_ver = 0;
7572+
}
7573+
} else {
7574+
/* mi_ver is already set from GET_SLI4_PARAMETERS */
7575+
lpfc_printf_log(phba, KERN_INFO,
7576+
LOG_CGN_MGMT | LOG_INIT,
7577+
"6245 Enable MI Mailbox x%x (x%x/x%x) "
7578+
"failed, rc:x%x mi:x%x\n",
7579+
bf_get(lpfc_mqe_command, &mboxq->u.mqe),
7580+
lpfc_sli_config_mbox_subsys_get
7581+
(phba, mboxq),
7582+
lpfc_sli_config_mbox_opcode_get
7583+
(phba, mboxq),
7584+
rc, sli4_params->mi_ver);
7585+
}
7586+
} else {
7587+
lpfc_printf_log(phba, KERN_WARNING, LOG_CGN_MGMT,
7588+
"6217 MI is disabled\n");
7589+
}
7590+
7591+
/* Ensure FDMI is enabled for MI if enable_mi is set */
7592+
if (sli4_params->mi_ver)
7593+
phba->cfg_fdmi_on = LPFC_FDMI_SUPPORT;
7594+
7595+
lpfc_printf_log(phba, KERN_INFO, LOG_INIT,
7596+
"6470 Setup MI version %d\n",
7597+
sli4_params->mi_ver);
7598+
7599+
mempool_free(mboxq, phba->mbox_mem_pool);
7600+
return 0;
7601+
}
7602+
75027603
static int
75037604
lpfc_set_host_tm(struct lpfc_hba *phba)
75047605
{
@@ -7637,6 +7738,8 @@ lpfc_sli4_hba_setup(struct lpfc_hba *phba)
76377738
lpfc_printf_log(phba, KERN_ERR, LOG_MBOX | LOG_INIT,
76387739
"6468 Set host date / time: Status x%x:\n", rc);
76397740

7741+
lpfc_cmf_setup(phba);
7742+
76407743
/*
76417744
* Continue initialization with default values even if driver failed
76427745
* to read FCoE param config regions, only read parameters if the

0 commit comments

Comments
 (0)