[SCSI] lpfc 8.1.2: Add ERROR and WARM_START modes for diagnostic purposes.
[safe/jmp/linux-2.6] / drivers / scsi / lpfc / lpfc_attr.c
index 9832681..e7aca3c 100644 (file)
@@ -1,7 +1,7 @@
 /*******************************************************************
  * This file is part of the Emulex Linux Device Driver for         *
  * Fibre Channel Host Bus Adapters.                                *
- * Copyright (C) 2004-2005 Emulex.  All rights reserved.           *
+ * Copyright (C) 2004-2006 Emulex.  All rights reserved.           *
  * EMULEX and SLI are trademarks of Emulex.                        *
  * www.emulex.com                                                  *
  * Portions Copyright (C) 2004-2005 Christoph Hellwig              *
@@ -79,7 +79,7 @@ static ssize_t
 lpfc_serialnum_show(struct class_device *cdev, char *buf)
 {
        struct Scsi_Host *host = class_to_shost(cdev);
-       struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata[0];
+       struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata;
        return snprintf(buf, PAGE_SIZE, "%s\n",phba->SerialNumber);
 }
 
@@ -87,7 +87,7 @@ static ssize_t
 lpfc_modeldesc_show(struct class_device *cdev, char *buf)
 {
        struct Scsi_Host *host = class_to_shost(cdev);
-       struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata[0];
+       struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata;
        return snprintf(buf, PAGE_SIZE, "%s\n",phba->ModelDesc);
 }
 
@@ -95,7 +95,7 @@ static ssize_t
 lpfc_modelname_show(struct class_device *cdev, char *buf)
 {
        struct Scsi_Host *host = class_to_shost(cdev);
-       struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata[0];
+       struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata;
        return snprintf(buf, PAGE_SIZE, "%s\n",phba->ModelName);
 }
 
@@ -103,7 +103,7 @@ static ssize_t
 lpfc_programtype_show(struct class_device *cdev, char *buf)
 {
        struct Scsi_Host *host = class_to_shost(cdev);
-       struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata[0];
+       struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata;
        return snprintf(buf, PAGE_SIZE, "%s\n",phba->ProgramType);
 }
 
@@ -111,7 +111,7 @@ static ssize_t
 lpfc_portnum_show(struct class_device *cdev, char *buf)
 {
        struct Scsi_Host *host = class_to_shost(cdev);
-       struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata[0];
+       struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata;
        return snprintf(buf, PAGE_SIZE, "%s\n",phba->Port);
 }
 
@@ -119,7 +119,7 @@ static ssize_t
 lpfc_fwrev_show(struct class_device *cdev, char *buf)
 {
        struct Scsi_Host *host = class_to_shost(cdev);
-       struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata[0];
+       struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata;
        char fwrev[32];
        lpfc_decode_firmware_rev(phba, fwrev, 1);
        return snprintf(buf, PAGE_SIZE, "%s\n",fwrev);
@@ -130,7 +130,7 @@ lpfc_hdw_show(struct class_device *cdev, char *buf)
 {
        char hdw[9];
        struct Scsi_Host *host = class_to_shost(cdev);
-       struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata[0];
+       struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata;
        lpfc_vpd_t *vp = &phba->vpd;
        lpfc_jedec_to_ascii(vp->rev.biuRev, hdw);
        return snprintf(buf, PAGE_SIZE, "%s\n", hdw);
@@ -139,16 +139,18 @@ static ssize_t
 lpfc_option_rom_version_show(struct class_device *cdev, char *buf)
 {
        struct Scsi_Host *host = class_to_shost(cdev);
-       struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata[0];
+       struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata;
        return snprintf(buf, PAGE_SIZE, "%s\n", phba->OptionROMVersion);
 }
 static ssize_t
 lpfc_state_show(struct class_device *cdev, char *buf)
 {
        struct Scsi_Host *host = class_to_shost(cdev);
-       struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata[0];
+       struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata;
        int len = 0;
        switch (phba->hba_state) {
+       case LPFC_STATE_UNKNOWN:
+       case LPFC_WARM_START:
        case LPFC_INIT_START:
        case LPFC_INIT_MBX_CMDS:
        case LPFC_LINK_DOWN:
@@ -194,7 +196,7 @@ static ssize_t
 lpfc_num_discovered_ports_show(struct class_device *cdev, char *buf)
 {
        struct Scsi_Host *host = class_to_shost(cdev);
-       struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata[0];
+       struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata;
        return snprintf(buf, PAGE_SIZE, "%d\n", phba->fc_map_cnt +
                                                        phba->fc_unmap_cnt);
 }
@@ -203,7 +205,7 @@ lpfc_num_discovered_ports_show(struct class_device *cdev, char *buf)
 static int
 lpfc_issue_lip(struct Scsi_Host *host)
 {
-       struct lpfc_hba *phba = (struct lpfc_hba *) host->hostdata[0];
+       struct lpfc_hba *phba = (struct lpfc_hba *) host->hostdata;
        LPFC_MBOXQ_t *pmboxq;
        int mbxstatus = MBXERR_ERROR;
 
@@ -235,7 +237,7 @@ static ssize_t
 lpfc_nport_evt_cnt_show(struct class_device *cdev, char *buf)
 {
        struct Scsi_Host *host = class_to_shost(cdev);
-       struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata[0];
+       struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata;
        return snprintf(buf, PAGE_SIZE, "%d\n", phba->nport_event_cnt);
 }
 
@@ -243,7 +245,7 @@ static ssize_t
 lpfc_board_online_show(struct class_device *cdev, char *buf)
 {
        struct Scsi_Host *host = class_to_shost(cdev);
-       struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata[0];
+       struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata;
 
        if (phba->fc_flag & FC_OFFLINE_MODE)
                return snprintf(buf, PAGE_SIZE, "0\n");
@@ -256,7 +258,7 @@ lpfc_board_online_store(struct class_device *cdev, const char *buf,
                                                                size_t count)
 {
        struct Scsi_Host *host = class_to_shost(cdev);
-       struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata[0];
+       struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata;
        struct completion online_compl;
        int val=0, status=0;
 
@@ -278,19 +280,148 @@ lpfc_board_online_store(struct class_device *cdev, const char *buf,
                return -EIO;
 }
 
+static ssize_t
+lpfc_board_mode_show(struct class_device *cdev, char *buf)
+{
+       struct Scsi_Host *host = class_to_shost(cdev);
+       struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata;
+       char  * state;
+
+       if (phba->hba_state == LPFC_HBA_ERROR)
+               state = "error";
+       else if (phba->hba_state == LPFC_WARM_START)
+               state = "warm start";
+       else if (phba->hba_state == LPFC_INIT_START)
+               state = "offline";
+       else
+               state = "online";
+
+       return snprintf(buf, PAGE_SIZE, "%s\n", state);
+}
+
+static ssize_t
+lpfc_board_mode_store(struct class_device *cdev, const char *buf, size_t count)
+{
+       struct Scsi_Host *host = class_to_shost(cdev);
+       struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata;
+       struct completion online_compl;
+       int status=0;
+
+       init_completion(&online_compl);
+
+       if(strncmp(buf, "online", sizeof("online") - 1) == 0)
+               lpfc_workq_post_event(phba, &status, &online_compl,
+                                     LPFC_EVT_ONLINE);
+       else if (strncmp(buf, "offline", sizeof("offline") - 1) == 0)
+               lpfc_workq_post_event(phba, &status, &online_compl,
+                                     LPFC_EVT_OFFLINE);
+       else if (strncmp(buf, "warm", sizeof("warm") - 1) == 0)
+               lpfc_workq_post_event(phba, &status, &online_compl,
+                                     LPFC_EVT_WARM_START);
+       else if (strncmp(buf, "error", sizeof("error") - 1) == 0)
+               lpfc_workq_post_event(phba, &status, &online_compl,
+                                     LPFC_EVT_KILL);
+       else
+               return -EINVAL;
+
+       wait_for_completion(&online_compl);
+
+       if (!status)
+               return strlen(buf);
+       else
+               return -EIO;
+}
+
+static ssize_t
+lpfc_poll_show(struct class_device *cdev, char *buf)
+{
+       struct Scsi_Host *host = class_to_shost(cdev);
+       struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata;
+
+       return snprintf(buf, PAGE_SIZE, "%#x\n", phba->cfg_poll);
+}
+
+static ssize_t
+lpfc_poll_store(struct class_device *cdev, const char *buf,
+               size_t count)
+{
+       struct Scsi_Host *host = class_to_shost(cdev);
+       struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata;
+       uint32_t creg_val;
+       uint32_t old_val;
+       int val=0;
+
+       if (!isdigit(buf[0]))
+               return -EINVAL;
+
+       if (sscanf(buf, "%i", &val) != 1)
+               return -EINVAL;
+
+       if ((val & 0x3) != val)
+               return -EINVAL;
+
+       spin_lock_irq(phba->host->host_lock);
+
+       old_val = phba->cfg_poll;
+
+       if (val & ENABLE_FCP_RING_POLLING) {
+               if ((val & DISABLE_FCP_RING_INT) &&
+                   !(old_val & DISABLE_FCP_RING_INT)) {
+                       creg_val = readl(phba->HCregaddr);
+                       creg_val &= ~(HC_R0INT_ENA << LPFC_FCP_RING);
+                       writel(creg_val, phba->HCregaddr);
+                       readl(phba->HCregaddr); /* flush */
+
+                       lpfc_poll_start_timer(phba);
+               }
+       } else if (val != 0x0) {
+               spin_unlock_irq(phba->host->host_lock);
+               return -EINVAL;
+       }
+
+       if (!(val & DISABLE_FCP_RING_INT) &&
+           (old_val & DISABLE_FCP_RING_INT))
+       {
+               spin_unlock_irq(phba->host->host_lock);
+               del_timer(&phba->fcp_poll_timer);
+               spin_lock_irq(phba->host->host_lock);
+               creg_val = readl(phba->HCregaddr);
+               creg_val |= (HC_R0INT_ENA << LPFC_FCP_RING);
+               writel(creg_val, phba->HCregaddr);
+               readl(phba->HCregaddr); /* flush */
+       }
+
+       phba->cfg_poll = val;
+
+       spin_unlock_irq(phba->host->host_lock);
+
+       return strlen(buf);
+}
 
 #define lpfc_param_show(attr)  \
 static ssize_t \
 lpfc_##attr##_show(struct class_device *cdev, char *buf) \
 { \
        struct Scsi_Host *host = class_to_shost(cdev);\
-       struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata[0];\
+       struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata;\
        int val = 0;\
        val = phba->cfg_##attr;\
        return snprintf(buf, PAGE_SIZE, "%d\n",\
                        phba->cfg_##attr);\
 }
 
+#define lpfc_param_hex_show(attr)      \
+static ssize_t \
+lpfc_##attr##_show(struct class_device *cdev, char *buf) \
+{ \
+       struct Scsi_Host *host = class_to_shost(cdev);\
+       struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata;\
+       int val = 0;\
+       val = phba->cfg_##attr;\
+       return snprintf(buf, PAGE_SIZE, "%#x\n",\
+                       phba->cfg_##attr);\
+}
+
 #define lpfc_param_init(attr, default, minval, maxval) \
 static int \
 lpfc_##attr##_init(struct lpfc_hba *phba, int val) \
@@ -327,10 +458,12 @@ static ssize_t \
 lpfc_##attr##_store(struct class_device *cdev, const char *buf, size_t count) \
 { \
        struct Scsi_Host *host = class_to_shost(cdev);\
-       struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata[0];\
+       struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata;\
        int val=0;\
-       if (sscanf(buf, "%d", &val) != 1)\
-       return -EPERM;\
+       if (!isdigit(buf[0]))\
+               return -EINVAL;\
+       if (sscanf(buf, "%i", &val) != 1)\
+               return -EINVAL;\
        if (lpfc_##attr##_set(phba, val) == 0) \
                return strlen(buf);\
        else \
@@ -362,6 +495,25 @@ lpfc_param_store(name)\
 static CLASS_DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\
                         lpfc_##name##_show, lpfc_##name##_store)
 
+#define LPFC_ATTR_HEX_R(name, defval, minval, maxval, desc) \
+static int lpfc_##name = defval;\
+module_param(lpfc_##name, int, 0);\
+MODULE_PARM_DESC(lpfc_##name, desc);\
+lpfc_param_hex_show(name)\
+lpfc_param_init(name, defval, minval, maxval)\
+static CLASS_DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL)
+
+#define LPFC_ATTR_HEX_RW(name, defval, minval, maxval, desc) \
+static int lpfc_##name = defval;\
+module_param(lpfc_##name, int, 0);\
+MODULE_PARM_DESC(lpfc_##name, desc);\
+lpfc_param_hex_show(name)\
+lpfc_param_init(name, defval, minval, maxval)\
+lpfc_param_set(name, defval, minval, maxval)\
+lpfc_param_store(name)\
+static CLASS_DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\
+                        lpfc_##name##_show, lpfc_##name##_store)
+
 static CLASS_DEVICE_ATTR(info, S_IRUGO, lpfc_info_show, NULL);
 static CLASS_DEVICE_ATTR(serialnum, S_IRUGO, lpfc_serialnum_show, NULL);
 static CLASS_DEVICE_ATTR(modeldesc, S_IRUGO, lpfc_modeldesc_show, NULL);
@@ -382,7 +534,18 @@ static CLASS_DEVICE_ATTR(management_version, S_IRUGO, management_version_show,
                         NULL);
 static CLASS_DEVICE_ATTR(board_online, S_IRUGO | S_IWUSR,
                         lpfc_board_online_show, lpfc_board_online_store);
+static CLASS_DEVICE_ATTR(board_mode, S_IRUGO | S_IWUSR,
+                        lpfc_board_mode_show, lpfc_board_mode_store);
+
+static int lpfc_poll = 0;
+module_param(lpfc_poll, int, 0);
+MODULE_PARM_DESC(lpfc_poll, "FCP ring polling mode control:"
+                " 0 - none,"
+                " 1 - poll with interrupts enabled"
+                " 3 - poll and disable FCP ring interrupts");
 
+static CLASS_DEVICE_ATTR(lpfc_poll, S_IRUGO | S_IWUSR,
+                        lpfc_poll_show, lpfc_poll_store);
 
 /*
 # lpfc_log_verbose: Only turn this flag on if you are willing to risk being
@@ -403,7 +566,7 @@ static CLASS_DEVICE_ATTR(board_online, S_IRUGO | S_IWUSR,
 # LOG_LIBDFC                    0x2000     LIBDFC events
 # LOG_ALL_MSG                   0xffff     LOG all messages
 */
-LPFC_ATTR_RW(log_verbose, 0x0, 0x0, 0xffff, "Verbose logging bit-mask");
+LPFC_ATTR_HEX_RW(log_verbose, 0x0, 0x0, 0xffff, "Verbose logging bit-mask");
 
 /*
 # lun_queue_depth:  This parameter is used to limit the number of outstanding
@@ -413,6 +576,16 @@ LPFC_ATTR_R(lun_queue_depth, 30, 1, 128,
            "Max number of FCP commands we can queue to a specific LUN");
 
 /*
+# hba_queue_depth:  This parameter is used to limit the number of outstanding
+# commands per lpfc HBA. Value range is [32,8192]. If this parameter
+# value is greater than the maximum number of exchanges supported by the HBA,
+# then maximum number of exchanges supported by the HBA is used to determine
+# the hba_queue_depth.
+*/
+LPFC_ATTR_R(hba_queue_depth, 8192, 32, 8192,
+           "Max number of FCP commands we can queue to a lpfc HBA");
+
+/*
 # Some disk devices have a "select ID" or "select Target" capability.
 # From a protocol standpoint "select ID" usually means select the
 # Fibre channel "ALPA".  In the FC-AL Profile there is an "informative
@@ -490,10 +663,10 @@ LPFC_ATTR_R(ack0, 0, 0, 1, "Enable ACK0 support");
 # is 0. Default value of cr_count is 1. The cr_count feature is disabled if
 # cr_delay is set to 0.
 */
-LPFC_ATTR(cr_delay, 0, 0, 63, "A count of milliseconds after which an"
+LPFC_ATTR_RW(cr_delay, 0, 0, 63, "A count of milliseconds after which an"
                "interrupt response is generated");
 
-LPFC_ATTR(cr_count, 1, 1, 255, "A count of I/O completions after which an"
+LPFC_ATTR_RW(cr_count, 1, 1, 255, "A count of I/O completions after which an"
                "interrupt response is generated");
 
 /*
@@ -520,6 +693,13 @@ LPFC_ATTR(discovery_threads, 32, 1, 64, "Maximum number of ELS commands"
 LPFC_ATTR_R(max_luns, 256, 1, 32768,
             "Maximum number of LUNs per target driver will support");
 
+/*
+# lpfc_poll_tmo: .Milliseconds driver will wait between polling FCP ring.
+# Value range is [1,255], default value is 10.
+*/
+LPFC_ATTR_RW(poll_tmo, 10, 1, 255,
+            "Milliseconds driver will wait between polling FCP ring");
+
 struct class_device_attribute *lpfc_host_attrs[] = {
        &class_device_attr_info,
        &class_device_attr_serialnum,
@@ -535,6 +715,7 @@ struct class_device_attribute *lpfc_host_attrs[] = {
        &class_device_attr_lpfc_drvr_version,
        &class_device_attr_lpfc_log_verbose,
        &class_device_attr_lpfc_lun_queue_depth,
+       &class_device_attr_lpfc_hba_queue_depth,
        &class_device_attr_lpfc_nodev_tmo,
        &class_device_attr_lpfc_fcp_class,
        &class_device_attr_lpfc_use_adisc,
@@ -542,11 +723,16 @@ struct class_device_attribute *lpfc_host_attrs[] = {
        &class_device_attr_lpfc_topology,
        &class_device_attr_lpfc_scan_down,
        &class_device_attr_lpfc_link_speed,
+       &class_device_attr_lpfc_cr_delay,
+       &class_device_attr_lpfc_cr_count,
        &class_device_attr_lpfc_fdmi_on,
        &class_device_attr_lpfc_max_luns,
        &class_device_attr_nport_evt_cnt,
        &class_device_attr_management_version,
        &class_device_attr_board_online,
+       &class_device_attr_board_mode,
+       &class_device_attr_lpfc_poll,
+       &class_device_attr_lpfc_poll_tmo,
        NULL,
 };
 
@@ -556,7 +742,7 @@ sysfs_ctlreg_write(struct kobject *kobj, char *buf, loff_t off, size_t count)
        size_t buf_off;
        struct Scsi_Host *host = class_to_shost(container_of(kobj,
                                             struct class_device, kobj));
-       struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata[0];
+       struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata;
 
        if ((off + count) > FF_REG_AREA_SIZE)
                return -ERANGE;
@@ -589,7 +775,7 @@ sysfs_ctlreg_read(struct kobject *kobj, char *buf, loff_t off, size_t count)
        uint32_t * tmp_ptr;
        struct Scsi_Host *host = class_to_shost(container_of(kobj,
                                             struct class_device, kobj));
-       struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata[0];
+       struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata;
 
        if (off > FF_REG_AREA_SIZE)
                return -ERANGE;
@@ -644,7 +830,7 @@ sysfs_mbox_write(struct kobject *kobj, char *buf, loff_t off, size_t count)
 {
        struct Scsi_Host * host =
                class_to_shost(container_of(kobj, struct class_device, kobj));
-       struct lpfc_hba * phba = (struct lpfc_hba*)host->hostdata[0];
+       struct lpfc_hba * phba = (struct lpfc_hba*)host->hostdata;
        struct lpfcMboxq * mbox = NULL;
 
        if ((count + off) > MAILBOX_CMD_SIZE)
@@ -697,7 +883,7 @@ sysfs_mbox_read(struct kobject *kobj, char *buf, loff_t off, size_t count)
        struct Scsi_Host *host =
                class_to_shost(container_of(kobj, struct class_device,
                                            kobj));
-       struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata[0];
+       struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata;
        int rc;
 
        if (off > sizeof(MAILBOX_t))
@@ -754,8 +940,11 @@ sysfs_mbox_read(struct kobject *kobj, char *buf, loff_t off, size_t count)
                case MBX_DUMP_MEMORY:
                case MBX_DOWN_LOAD:
                case MBX_UPDATE_CFG:
+               case MBX_KILL_BOARD:
                case MBX_LOAD_AREA:
                case MBX_LOAD_EXP_ROM:
+               case MBX_BEACON:
+               case MBX_DEL_LD_ENTRY:
                        break;
                case MBX_READ_SPARM64:
                case MBX_READ_LA:
@@ -872,7 +1061,7 @@ lpfc_free_sysfs_attr(struct lpfc_hba *phba)
 static void
 lpfc_get_host_port_id(struct Scsi_Host *shost)
 {
-       struct lpfc_hba *phba = (struct lpfc_hba*)shost->hostdata[0];
+       struct lpfc_hba *phba = (struct lpfc_hba*)shost->hostdata;
        /* note: fc_myDID already in cpu endianness */
        fc_host_port_id(shost) = phba->fc_myDID;
 }
@@ -880,7 +1069,7 @@ lpfc_get_host_port_id(struct Scsi_Host *shost)
 static void
 lpfc_get_host_port_type(struct Scsi_Host *shost)
 {
-       struct lpfc_hba *phba = (struct lpfc_hba*)shost->hostdata[0];
+       struct lpfc_hba *phba = (struct lpfc_hba*)shost->hostdata;
 
        spin_lock_irq(shost->host_lock);
 
@@ -905,7 +1094,7 @@ lpfc_get_host_port_type(struct Scsi_Host *shost)
 static void
 lpfc_get_host_port_state(struct Scsi_Host *shost)
 {
-       struct lpfc_hba *phba = (struct lpfc_hba*)shost->hostdata[0];
+       struct lpfc_hba *phba = (struct lpfc_hba*)shost->hostdata;
 
        spin_lock_irq(shost->host_lock);
 
@@ -913,6 +1102,8 @@ lpfc_get_host_port_state(struct Scsi_Host *shost)
                fc_host_port_state(shost) = FC_PORTSTATE_OFFLINE;
        else {
                switch (phba->hba_state) {
+               case LPFC_STATE_UNKNOWN:
+               case LPFC_WARM_START:
                case LPFC_INIT_START:
                case LPFC_INIT_MBX_CMDS:
                case LPFC_LINK_DOWN:
@@ -946,7 +1137,7 @@ lpfc_get_host_port_state(struct Scsi_Host *shost)
 static void
 lpfc_get_host_speed(struct Scsi_Host *shost)
 {
-       struct lpfc_hba *phba = (struct lpfc_hba*)shost->hostdata[0];
+       struct lpfc_hba *phba = (struct lpfc_hba*)shost->hostdata;
 
        spin_lock_irq(shost->host_lock);
 
@@ -973,7 +1164,7 @@ lpfc_get_host_speed(struct Scsi_Host *shost)
 static void
 lpfc_get_host_fabric_name (struct Scsi_Host *shost)
 {
-       struct lpfc_hba *phba = (struct lpfc_hba*)shost->hostdata[0];
+       struct lpfc_hba *phba = (struct lpfc_hba*)shost->hostdata;
        u64 node_name;
 
        spin_lock_irq(shost->host_lock);
@@ -995,7 +1186,7 @@ lpfc_get_host_fabric_name (struct Scsi_Host *shost)
 static struct fc_host_statistics *
 lpfc_get_stats(struct Scsi_Host *shost)
 {
-       struct lpfc_hba *phba = (struct lpfc_hba *)shost->hostdata[0];
+       struct lpfc_hba *phba = (struct lpfc_hba *)shost->hostdata;
        struct lpfc_sli *psli = &phba->sli;
        struct fc_host_statistics *hs = &phba->link_stats;
        LPFC_MBOXQ_t *pmboxq;
@@ -1085,7 +1276,7 @@ static void
 lpfc_get_starget_port_id(struct scsi_target *starget)
 {
        struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
-       struct lpfc_hba *phba = (struct lpfc_hba *) shost->hostdata[0];
+       struct lpfc_hba *phba = (struct lpfc_hba *) shost->hostdata;
        uint32_t did = -1;
        struct lpfc_nodelist *ndlp = NULL;
 
@@ -1106,7 +1297,7 @@ static void
 lpfc_get_starget_node_name(struct scsi_target *starget)
 {
        struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
-       struct lpfc_hba *phba = (struct lpfc_hba *) shost->hostdata[0];
+       struct lpfc_hba *phba = (struct lpfc_hba *) shost->hostdata;
        u64 node_name = 0;
        struct lpfc_nodelist *ndlp = NULL;
 
@@ -1127,7 +1318,7 @@ static void
 lpfc_get_starget_port_name(struct scsi_target *starget)
 {
        struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
-       struct lpfc_hba *phba = (struct lpfc_hba *) shost->hostdata[0];
+       struct lpfc_hba *phba = (struct lpfc_hba *) shost->hostdata;
        u64 port_name = 0;
        struct lpfc_nodelist *ndlp = NULL;
 
@@ -1259,6 +1450,9 @@ lpfc_get_cfgparam(struct lpfc_hba *phba)
        lpfc_fdmi_on_init(phba, lpfc_fdmi_on);
        lpfc_discovery_threads_init(phba, lpfc_discovery_threads);
        lpfc_max_luns_init(phba, lpfc_max_luns);
+       lpfc_poll_tmo_init(phba, lpfc_poll_tmo);
+
+       phba->cfg_poll = lpfc_poll;
 
        /*
         * The total number of segments is the configuration value plus 2
@@ -1290,5 +1484,9 @@ lpfc_get_cfgparam(struct lpfc_hba *phba)
        default:
                phba->cfg_hba_queue_depth = LPFC_DFT_HBA_Q_DEPTH;
        }
+
+       if (phba->cfg_hba_queue_depth > lpfc_hba_queue_depth)
+               lpfc_hba_queue_depth_init(phba, lpfc_hba_queue_depth);
+
        return;
 }