scsi: lpfc: Add MIB feature enablement support
authorJames Smart <jsmart2021@gmail.com>
Mon, 16 Aug 2021 16:28:48 +0000 (09:28 -0700)
committerMartin K. Petersen <martin.petersen@oracle.com>
Wed, 25 Aug 2021 02:56:33 +0000 (22:56 -0400)
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/20210816162901.121235-4-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>
drivers/scsi/lpfc/lpfc_ct.c
drivers/scsi/lpfc/lpfc_hw4.h
drivers/scsi/lpfc/lpfc_init.c
drivers/scsi/lpfc/lpfc_logmsg.h
drivers/scsi/lpfc/lpfc_sli.c

index a1c85fa135a90053ffa1733d82a9059181422af3..435349f893adfc6ef0d8277ea3d3fc974455a4c4 100644 (file)
@@ -2332,24 +2332,29 @@ lpfc_cmpl_ct_disc_fdmi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
                break;
        case SLI_MGMT_RPA:
                if (vport->port_type == LPFC_PHYSICAL_PORT &&
-                   phba->cfg_enable_mi &&
-                   phba->sli4_hba.pc_sli4_params.mi_ver > LPFC_MIB1_SUPPORT) {
+                   phba->sli4_hba.pc_sli4_params.mi_ver) {
                        /* mi is only for the phyical port, no vports */
                        if (phba->link_flag & LS_CT_VEN_RPA) {
                                lpfc_printf_vlog(vport, KERN_INFO,
-                                                LOG_DISCOVERY | LOG_ELS,
+                                                LOG_DISCOVERY | LOG_ELS |
+                                                LOG_CGN_MGMT,
                                                 "6449 VEN RPA FDMI Success\n");
                                phba->link_flag &= ~LS_CT_VEN_RPA;
                                break;
                        }
 
+                       lpfc_printf_log(phba, KERN_INFO, LOG_CGN_MGMT,
+                                       "6210 Issue Vendor MI FDMI %x\n",
+                                       phba->sli4_hba.pc_sli4_params.mi_ver);
+
+                       /* CGN is only for the physical port, no vports */
                        if (lpfc_fdmi_cmd(vport, ndlp, cmd,
                                          LPFC_FDMI_VENDOR_ATTR_mi) == 0)
                                phba->link_flag |= LS_CT_VEN_RPA;
                        lpfc_printf_log(phba, KERN_INFO,
                                        LOG_DISCOVERY | LOG_ELS,
                                        "6458 Send MI FDMI:%x Flag x%x\n",
-                                       phba->sli4_hba.pc_sli4_params.mi_value,
+                                       phba->sli4_hba.pc_sli4_params.mi_ver,
                                        phba->link_flag);
                } else {
                        lpfc_printf_log(phba, KERN_INFO,
@@ -3348,7 +3353,7 @@ lpfc_fdmi_vendor_attr_mi(struct lpfc_vport *vport,
        ae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;
        memset(ae, 0, 256);
        sprintf(mibrevision, "ELXE2EM:%04d",
-               phba->sli4_hba.pc_sli4_params.mi_value);
+               phba->sli4_hba.pc_sli4_params.mi_ver);
        strncpy(ae->un.AttrString, &mibrevision[0], sizeof(ae->un.AttrString));
        len = strnlen(ae->un.AttrString, sizeof(ae->un.AttrString));
        len += (len & 3) ? (4 - (len & 3)) : 4;
index 658b9c55823794aa02c26e09e6a1dc8a3aa1760f..fdc22e5d5fac430e072a32e5cb251db6f77f31ab 100644 (file)
@@ -3393,6 +3393,7 @@ struct lpfc_sli4_parameters {
 #define LPFC_SET_UE_RECOVERY           0x10
 #define LPFC_SET_MDS_DIAGS             0x12
 #define LPFC_SET_DUAL_DUMP             0x1e
+#define LPFC_SET_ENABLE_MI             0x21
 struct lpfc_mbx_set_feature {
        struct mbox_header header;
        uint32_t feature;
@@ -3416,6 +3417,12 @@ struct lpfc_mbx_set_feature {
 #define LPFC_DISABLE_DUAL_DUMP         0
 #define LPFC_ENABLE_DUAL_DUMP          1
 #define LPFC_QUERY_OP_DUAL_DUMP                2
+#define lpfc_mbx_set_feature_mi_SHIFT          0
+#define lpfc_mbx_set_feature_mi_MASK           0x0000ffff
+#define lpfc_mbx_set_feature_mi_WORD           word6
+#define lpfc_mbx_set_feature_milunq_SHIFT      16
+#define lpfc_mbx_set_feature_milunq_MASK       0x0000ffff
+#define lpfc_mbx_set_feature_milunq_WORD       word6
        uint32_t word7;
 #define lpfc_mbx_set_feature_UERP_SHIFT 0
 #define lpfc_mbx_set_feature_UERP_MASK  0x0000ffff
index 2c0aaa0a301d3d40d828513fa5c89c642ff865ef..6e75471525eb764d49ff34f5c58e120d9e83a796 100644 (file)
@@ -12350,21 +12350,6 @@ fcponly:
        else
                phba->nsler = 0;
 
-       /* Save PB info for use during HBA setup */
-       sli4_params->mi_ver = bf_get(cfg_mi_ver, mbx_sli4_parameters);
-       sli4_params->mib_bde_cnt = bf_get(cfg_mib_bde_cnt, mbx_sli4_parameters);
-       sli4_params->mib_size = mbx_sli4_parameters->mib_size;
-       sli4_params->mi_value = LPFC_DFLT_MIB_VAL;
-
-       /* Next we check for Vendor MIB support */
-       if (sli4_params->mi_ver && phba->cfg_enable_mi)
-               phba->cfg_fdmi_on = LPFC_FDMI_SUPPORT;
-
-       lpfc_printf_log(phba, KERN_INFO, LOG_INIT,
-                       "6461 MIB attr %d  enable %d  FDMI %d buf %d:%d\n",
-                       sli4_params->mi_ver, phba->cfg_enable_mi,
-                       sli4_params->mi_value, sli4_params->mib_bde_cnt,
-                       sli4_params->mib_size);
        return 0;
 }
 
index 5660a872946258ad696ccc335e51f6408f7ffc72..d719a16c0f96588919e2d83bbb571797e68d1cbb 100644 (file)
@@ -44,6 +44,9 @@
 #define LOG_NVME_DISC   0x00200000      /* NVME Discovery/Connect events. */
 #define LOG_NVME_ABTS   0x00400000      /* NVME ABTS events. */
 #define LOG_NVME_IOERR  0x00800000      /* NVME IO Error events. */
+#define LOG_RSVD1      0x01000000      /* Reserved */
+#define LOG_RSVD2      0x02000000      /* Reserved */
+#define LOG_CGN_MGMT    0x04000000     /* Congestion Mgmt events */
 #define LOG_TRACE_EVENT 0x80000000     /* Dmp the DBG log on this err */
 #define LOG_ALL_MSG    0x7fffffff      /* LOG all messages */
 
index 9ff4abb966af791e1ff31ed622c87477a977140b..5489cc7d06d5f5923376fde19ac4eee9f9e63fa3 100644 (file)
@@ -6447,6 +6447,14 @@ lpfc_set_features(struct lpfc_hba *phba, LPFC_MBOXQ_t *mbox,
                mbox->u.mqe.un.set_feature.feature = LPFC_SET_DUAL_DUMP;
                mbox->u.mqe.un.set_feature.param_len = 4;
                break;
+       case LPFC_SET_ENABLE_MI:
+               mbox->u.mqe.un.set_feature.feature = LPFC_SET_ENABLE_MI;
+               mbox->u.mqe.un.set_feature.param_len = 4;
+               bf_set(lpfc_mbx_set_feature_milunq, &mbox->u.mqe.un.set_feature,
+                      phba->pport->cfg_lun_queue_depth);
+               bf_set(lpfc_mbx_set_feature_mi, &mbox->u.mqe.un.set_feature,
+                      phba->sli4_hba.pc_sli4_params.mi_ver);
+               break;
        }
 
        return;
@@ -7499,6 +7507,99 @@ static void lpfc_sli4_dip(struct lpfc_hba *phba)
        }
 }
 
+/**
+ * lpfc_cmf_setup - Initialize idle_stat tracking
+ * @phba: Pointer to HBA context object.
+ *
+ * This is called from HBA setup during driver load or when the HBA
+ * comes online. this does all the initialization to support CMF and MI.
+ **/
+static int
+lpfc_cmf_setup(struct lpfc_hba *phba)
+{
+       LPFC_MBOXQ_t *mboxq;
+       struct lpfc_mqe *mqe;
+       struct lpfc_pc_sli4_params *sli4_params;
+       struct lpfc_sli4_parameters *mbx_sli4_parameters;
+       int length;
+       int rc, mi_ver;
+
+       mboxq = (LPFC_MBOXQ_t *)mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
+       if (!mboxq)
+               return -ENOMEM;
+       mqe = &mboxq->u.mqe;
+
+       /* Read the port's SLI4 Config Parameters */
+       length = (sizeof(struct lpfc_mbx_get_sli4_parameters) -
+                 sizeof(struct lpfc_sli4_cfg_mhdr));
+       lpfc_sli4_config(phba, mboxq, LPFC_MBOX_SUBSYSTEM_COMMON,
+                        LPFC_MBOX_OPCODE_GET_SLI4_PARAMETERS,
+                        length, LPFC_SLI4_MBX_EMBED);
+
+       rc = lpfc_sli_issue_mbox(phba, mboxq, MBX_POLL);
+       if (unlikely(rc)) {
+               mempool_free(mboxq, phba->mbox_mem_pool);
+               return rc;
+       }
+
+       /* Gather info on MI support */
+       sli4_params = &phba->sli4_hba.pc_sli4_params;
+       mbx_sli4_parameters = &mqe->un.get_sli4_parameters.sli4_parameters;
+       sli4_params->mi_ver = bf_get(cfg_mi_ver, mbx_sli4_parameters);
+
+       /* Are we forcing MI off via module parameter? */
+       if (!phba->cfg_enable_mi)
+               sli4_params->mi_ver = 0;
+
+       /* Always try to enable MI feature if we can */
+       if (sli4_params->mi_ver) {
+               lpfc_set_features(phba, mboxq, LPFC_SET_ENABLE_MI);
+               rc = lpfc_sli_issue_mbox(phba, mboxq, MBX_POLL);
+               mi_ver = bf_get(lpfc_mbx_set_feature_mi,
+                                &mboxq->u.mqe.un.set_feature);
+
+               if (rc == MBX_SUCCESS) {
+                       if (mi_ver) {
+                               lpfc_printf_log(phba,
+                                               KERN_WARNING, LOG_CGN_MGMT,
+                                               "6215 MI is enabled\n");
+                               sli4_params->mi_ver = mi_ver;
+                       } else {
+                               lpfc_printf_log(phba,
+                                               KERN_WARNING, LOG_CGN_MGMT,
+                                               "6338 MI is disabled\n");
+                               sli4_params->mi_ver = 0;
+                       }
+               } else {
+                       /* mi_ver is already set from GET_SLI4_PARAMETERS */
+                       lpfc_printf_log(phba, KERN_INFO,
+                                       LOG_CGN_MGMT | LOG_INIT,
+                                       "6245 Enable MI Mailbox x%x (x%x/x%x) "
+                                       "failed, rc:x%x mi:x%x\n",
+                                       bf_get(lpfc_mqe_command, &mboxq->u.mqe),
+                                       lpfc_sli_config_mbox_subsys_get
+                                               (phba, mboxq),
+                                       lpfc_sli_config_mbox_opcode_get
+                                               (phba, mboxq),
+                                       rc, sli4_params->mi_ver);
+               }
+       } else {
+               lpfc_printf_log(phba, KERN_WARNING, LOG_CGN_MGMT,
+                               "6217 MI is disabled\n");
+       }
+
+       /* Ensure FDMI is enabled for MI if enable_mi is set */
+       if (sli4_params->mi_ver)
+               phba->cfg_fdmi_on = LPFC_FDMI_SUPPORT;
+
+       lpfc_printf_log(phba, KERN_INFO, LOG_INIT,
+                       "6470 Setup MI version %d\n",
+                       sli4_params->mi_ver);
+
+       mempool_free(mboxq, phba->mbox_mem_pool);
+       return 0;
+}
+
 static int
 lpfc_set_host_tm(struct lpfc_hba *phba)
 {
@@ -7637,6 +7738,8 @@ lpfc_sli4_hba_setup(struct lpfc_hba *phba)
        lpfc_printf_log(phba, KERN_ERR, LOG_MBOX | LOG_INIT,
                        "6468 Set host date / time: Status x%x:\n", rc);
 
+       lpfc_cmf_setup(phba);
+
        /*
         * Continue initialization with default values even if driver failed
         * to read FCoE param config regions, only read parameters if the