scsi: lpfc: Add support for the CM framework
[linux-2.6-block.git] / drivers / scsi / lpfc / lpfc_attr.c
index eb88aaaf36eb328031ddb1c81a78c544d52a8a84..b41891aefa647df3ad406e50762c6c3e8fbdbe5d 100644 (file)
@@ -2248,11 +2248,6 @@ lpfc_sriov_hw_max_virtfn_show(struct device *dev,
        return scnprintf(buf, PAGE_SIZE, "%d\n", max_nr_virtfn);
 }
 
-static inline bool lpfc_rangecheck(uint val, uint min, uint max)
-{
-       return val >= min && val <= max;
-}
-
 /**
  * lpfc_enable_bbcr_set: Sets an attribute value.
  * @phba: pointer the the adapter structure.
@@ -4038,6 +4033,7 @@ lpfc_topology_store(struct device *dev, struct device_attribute *attr,
        const char *val_buf = buf;
        int err;
        uint32_t prev_val;
+       u8 sli_family, if_type;
 
        if (!strncmp(buf, "nolip ", strlen("nolip "))) {
                nolip = 1;
@@ -4061,13 +4057,16 @@ lpfc_topology_store(struct device *dev, struct device_attribute *attr,
                /*
                 * The 'topology' is not a configurable parameter if :
                 *   - persistent topology enabled
-                *   - G7/G6 with no private loop support
+                *   - ASIC_GEN_NUM >= 0xC, with no private loop support
                 */
-
+               sli_family = bf_get(lpfc_sli_intf_sli_family,
+                                   &phba->sli4_hba.sli_intf);
+               if_type = bf_get(lpfc_sli_intf_if_type,
+                                &phba->sli4_hba.sli_intf);
                if ((phba->hba_flag & HBA_PERSISTENT_TOPO ||
-                    (!phba->sli4_hba.pc_sli4_params.pls &&
-                    (phba->pcidev->device == PCI_DEVICE_ID_LANCER_G6_FC ||
-                    phba->pcidev->device == PCI_DEVICE_ID_LANCER_G7_FC))) &&
+                   (!phba->sli4_hba.pc_sli4_params.pls &&
+                    (sli_family == LPFC_SLI_INTF_FAMILY_G6 ||
+                     if_type == LPFC_SLI_INTF_IF_TYPE_6))) &&
                    val == 4) {
                        lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
                                "3114 Loop mode not supported\n");
@@ -5412,9 +5411,9 @@ LPFC_VPORT_ATTR_R(fcp_class, 3, 2, 3,
 
 /*
 # lpfc_use_adisc: Use ADISC for FCP rediscovery instead of PLOGI. Value range
-# is [0,1]. Default value is 0.
+# is [0,1]. Default value is 1.
 */
-LPFC_VPORT_ATTR_RW(use_adisc, 0, 0, 1,
+LPFC_VPORT_ATTR_RW(use_adisc, 1, 0, 1,
                   "Use ADISC on rediscovery to authenticate FCP devices");
 
 /*
@@ -6146,6 +6145,19 @@ LPFC_ATTR_RW(ras_fwlog_func, 0, 0, 7, "Firmware Logging Enabled on Function");
  */
 LPFC_BBCR_ATTR_RW(enable_bbcr, 1, 0, 1, "Enable BBC Recovery");
 
+/* Signaling module parameters */
+int lpfc_fabric_cgn_frequency = 100; /* 100 ms default */
+module_param(lpfc_fabric_cgn_frequency, int, 0444);
+MODULE_PARM_DESC(lpfc_fabric_cgn_frequency, "Congestion signaling fabric freq");
+
+int lpfc_acqe_cgn_frequency = 10; /* 10 sec default */
+module_param(lpfc_acqe_cgn_frequency, int, 0444);
+MODULE_PARM_DESC(lpfc_acqe_cgn_frequency, "Congestion signaling ACQE freq");
+
+int lpfc_use_cgn_signal = 1; /* 0 - only use FPINs, 1 - Use signals if avail  */
+module_param(lpfc_use_cgn_signal, int, 0444);
+MODULE_PARM_DESC(lpfc_use_cgn_signal, "Use Congestion signaling if available");
+
 /*
  * lpfc_enable_dpp: Enable DPP on G7
  *       0  = DPP on G7 disabled
@@ -6741,6 +6753,9 @@ lpfc_get_host_speed(struct Scsi_Host *shost)
                case LPFC_LINK_SPEED_128GHZ:
                        fc_host_speed(shost) = FC_PORTSPEED_128GBIT;
                        break;
+               case LPFC_LINK_SPEED_256GHZ:
+                       fc_host_speed(shost) = FC_PORTSPEED_256GBIT;
+                       break;
                default:
                        fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN;
                        break;
@@ -6908,6 +6923,9 @@ lpfc_get_stats(struct Scsi_Host *shost)
        hs->invalid_crc_count = pmb->un.varRdLnk.crcCnt;
        hs->error_frames = pmb->un.varRdLnk.crcCnt;
 
+       hs->cn_sig_warn = atomic64_read(&phba->cgn_acqe_stat.warn);
+       hs->cn_sig_alarm = atomic64_read(&phba->cgn_acqe_stat.alarm);
+
        hs->link_failure_count -= lso->link_failure_count;
        hs->loss_of_sync_count -= lso->loss_of_sync_count;
        hs->loss_of_signal_count -= lso->loss_of_signal_count;
@@ -7019,6 +7037,12 @@ lpfc_reset_stats(struct Scsi_Host *shost)
        else
                lso->link_events = (phba->fc_eventTag >> 1);
 
+       atomic64_set(&phba->cgn_acqe_stat.warn, 0);
+       atomic64_set(&phba->cgn_acqe_stat.alarm, 0);
+
+       memset(&shost_to_fc_host(shost)->fpin_stats, 0,
+              sizeof(shost_to_fc_host(shost)->fpin_stats));
+
        psli->stats_start = ktime_get_seconds();
 
        mempool_free(pmboxq, phba->mbox_mem_pool);
@@ -7452,6 +7476,12 @@ lpfc_get_cfgparam(struct lpfc_hba *phba)
        lpfc_enable_dpp_init(phba, lpfc_enable_dpp);
        lpfc_enable_mi_init(phba, lpfc_enable_mi);
 
+       phba->cgn_p.cgn_param_mode = LPFC_CFG_OFF;
+       phba->cmf_active_mode = LPFC_CFG_OFF;
+       if (lpfc_fabric_cgn_frequency > EDC_CG_SIGFREQ_CNT_MAX ||
+          lpfc_fabric_cgn_frequency < EDC_CG_SIGFREQ_CNT_MIN)
+               lpfc_fabric_cgn_frequency = 100; /* 100 ms default */
+
        if (phba->sli_rev != LPFC_SLI_REV4) {
                /* NVME only supported on SLI4 */
                phba->nvmet_support = 0;