]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/scsi/lpfc/lpfc_attr.c
Merge git://git.kernel.org/pub/scm/linux/kernel/git/wim/linux-2.6-watchdog
[linux-2.6-omap-h63xx.git] / drivers / scsi / lpfc / lpfc_attr.c
index 860a52c090f408fb4bbdccad73675a72bc78a361..4bae4a2ed2f1e9218b627f279d513a847b5ce931 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-2007 Emulex.  All rights reserved.           *
+ * Copyright (C) 2004-2008 Emulex.  All rights reserved.           *
  * EMULEX and SLI are trademarks of Emulex.                        *
  * www.emulex.com                                                  *
  * Portions Copyright (C) 2004-2005 Christoph Hellwig              *
 #define LPFC_MIN_DEVLOSS_TMO 1
 #define LPFC_MAX_DEVLOSS_TMO 255
 
+#define LPFC_MAX_LINK_SPEED 8
+#define LPFC_LINK_SPEED_BITMAP 0x00000117
+#define LPFC_LINK_SPEED_STRING "0, 1, 2, 4, 8"
+
 static void
 lpfc_jedec_to_ascii(int incr, char hdw[])
 {
@@ -67,12 +71,6 @@ lpfc_drvr_version_show(struct class_device *cdev, char *buf)
        return snprintf(buf, PAGE_SIZE, LPFC_MODULE_DESC "\n");
 }
 
-static ssize_t
-management_version_show(struct class_device *cdev, char *buf)
-{
-       return snprintf(buf, PAGE_SIZE, DFC_API_VERSION "\n");
-}
-
 static ssize_t
 lpfc_info_show(struct class_device *cdev, char *buf)
 {
@@ -91,6 +89,15 @@ lpfc_serialnum_show(struct class_device *cdev, char *buf)
        return snprintf(buf, PAGE_SIZE, "%s\n",phba->SerialNumber);
 }
 
+static ssize_t
+lpfc_temp_sensor_show(struct class_device *cdev, char *buf)
+{
+       struct Scsi_Host *shost = class_to_shost(cdev);
+       struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
+       struct lpfc_hba   *phba = vport->phba;
+       return snprintf(buf, PAGE_SIZE, "%d\n",phba->temp_sensor_support);
+}
+
 static ssize_t
 lpfc_modeldesc_show(struct class_device *cdev, char *buf)
 {
@@ -184,12 +191,9 @@ lpfc_state_show(struct class_device *cdev, char *buf)
        case LPFC_LINK_UP:
        case LPFC_CLEAR_LA:
        case LPFC_HBA_READY:
-               len += snprintf(buf + len, PAGE_SIZE-len, "Link Up - \n");
+               len += snprintf(buf + len, PAGE_SIZE-len, "Link Up - ");
 
                switch (vport->port_state) {
-                       len += snprintf(buf + len, PAGE_SIZE-len,
-                                       "initializing\n");
-                       break;
                case LPFC_LOCAL_CFG_LINK:
                        len += snprintf(buf + len, PAGE_SIZE-len,
                                        "Configuring Link\n");
@@ -258,8 +262,7 @@ lpfc_issue_lip(struct Scsi_Host *shost)
        int mbxstatus = MBXERR_ERROR;
 
        if ((vport->fc_flag & FC_OFFLINE_MODE) ||
-           (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO) ||
-           (vport->port_state != LPFC_VPORT_READY))
+           (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO))
                return -EPERM;
 
        pmboxq = mempool_alloc(phba->mbox_mem_pool,GFP_KERNEL);
@@ -311,17 +314,18 @@ lpfc_do_offline(struct lpfc_hba *phba, uint32_t type)
 
        psli = &phba->sli;
 
+       /* Wait a little for things to settle down, but not
+        * long enough for dev loss timeout to expire.
+        */
        for (i = 0; i < psli->num_rings; i++) {
                pring = &psli->ring[i];
-               /* The linkdown event takes 30 seconds to timeout. */
                while (pring->txcmplq_cnt) {
                        msleep(10);
-                       if (cnt++ > 3000) {
+                       if (cnt++ > 500) {  /* 5 secs */
                                lpfc_printf_log(phba,
                                        KERN_WARNING, LOG_INIT,
-                                       "%d:0466 Outstanding IO when "
-                                       "bringing Adapter offline\n",
-                                       phba->brd_no);
+                                       "0466 Outstanding IO when "
+                                       "bringing Adapter offline\n");
                                break;
                        }
                }
@@ -343,6 +347,9 @@ lpfc_selective_reset(struct lpfc_hba *phba)
        struct completion online_compl;
        int status = 0;
 
+       if (!phba->cfg_enable_hba_reset)
+               return -EIO;
+
        status = lpfc_do_offline(phba, LPFC_EVT_OFFLINE);
 
        if (status != 0)
@@ -416,6 +423,8 @@ lpfc_board_mode_store(struct class_device *cdev, const char *buf, size_t count)
        struct completion online_compl;
        int status=0;
 
+       if (!phba->cfg_enable_hba_reset)
+               return -EACCES;
        init_completion(&online_compl);
 
        if(strncmp(buf, "online", sizeof("online") - 1) == 0) {
@@ -437,7 +446,7 @@ lpfc_board_mode_store(struct class_device *cdev, const char *buf, size_t count)
                return -EIO;
 }
 
-int
+static int
 lpfc_get_hba_info(struct lpfc_hba *phba,
                  uint32_t *mxri, uint32_t *axri,
                  uint32_t *mrpi, uint32_t *arpi,
@@ -694,9 +703,8 @@ lpfc_##attr##_init(struct lpfc_hba *phba, int val) \
                return 0;\
        }\
        lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \
-                       "%d:0449 lpfc_"#attr" attribute cannot be set to %d, "\
-                       "allowed range is ["#minval", "#maxval"]\n", \
-                       phba->brd_no, val); \
+                       "0449 lpfc_"#attr" attribute cannot be set to %d, "\
+                       "allowed range is ["#minval", "#maxval"]\n", val); \
        phba->cfg_##attr = default;\
        return -EINVAL;\
 }
@@ -710,9 +718,8 @@ lpfc_##attr##_set(struct lpfc_hba *phba, int val) \
                return 0;\
        }\
        lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \
-                       "%d:0450 lpfc_"#attr" attribute cannot be set to %d, "\
-                       "allowed range is ["#minval", "#maxval"]\n", \
-                       phba->brd_no, val); \
+                       "0450 lpfc_"#attr" attribute cannot be set to %d, "\
+                       "allowed range is ["#minval", "#maxval"]\n", val); \
        return -EINVAL;\
 }
 
@@ -734,6 +741,75 @@ lpfc_##attr##_store(struct class_device *cdev, const char *buf, size_t count) \
                return -EINVAL;\
 }
 
+#define lpfc_vport_param_show(attr)    \
+static ssize_t \
+lpfc_##attr##_show(struct class_device *cdev, char *buf) \
+{ \
+       struct Scsi_Host  *shost = class_to_shost(cdev);\
+       struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
+       int val = 0;\
+       val = vport->cfg_##attr;\
+       return snprintf(buf, PAGE_SIZE, "%d\n", vport->cfg_##attr);\
+}
+
+#define lpfc_vport_param_hex_show(attr)        \
+static ssize_t \
+lpfc_##attr##_show(struct class_device *cdev, char *buf) \
+{ \
+       struct Scsi_Host  *shost = class_to_shost(cdev);\
+       struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
+       int val = 0;\
+       val = vport->cfg_##attr;\
+       return snprintf(buf, PAGE_SIZE, "%#x\n", vport->cfg_##attr);\
+}
+
+#define lpfc_vport_param_init(attr, default, minval, maxval)   \
+static int \
+lpfc_##attr##_init(struct lpfc_vport *vport, int val) \
+{ \
+       if (val >= minval && val <= maxval) {\
+               vport->cfg_##attr = val;\
+               return 0;\
+       }\
+       lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \
+                        "0449 lpfc_"#attr" attribute cannot be set to %d, "\
+                        "allowed range is ["#minval", "#maxval"]\n", val); \
+       vport->cfg_##attr = default;\
+       return -EINVAL;\
+}
+
+#define lpfc_vport_param_set(attr, default, minval, maxval)    \
+static int \
+lpfc_##attr##_set(struct lpfc_vport *vport, int val) \
+{ \
+       if (val >= minval && val <= maxval) {\
+               vport->cfg_##attr = val;\
+               return 0;\
+       }\
+       lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \
+                        "0450 lpfc_"#attr" attribute cannot be set to %d, "\
+                        "allowed range is ["#minval", "#maxval"]\n", val); \
+       return -EINVAL;\
+}
+
+#define lpfc_vport_param_store(attr)   \
+static ssize_t \
+lpfc_##attr##_store(struct class_device *cdev, const char *buf, size_t count) \
+{ \
+       struct Scsi_Host  *shost = class_to_shost(cdev);\
+       struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
+       int val=0;\
+       if (!isdigit(buf[0]))\
+               return -EINVAL;\
+       if (sscanf(buf, "%i", &val) != 1)\
+               return -EINVAL;\
+       if (lpfc_##attr##_set(vport, val) == 0) \
+               return strlen(buf);\
+       else \
+               return -EINVAL;\
+}
+
+
 #define LPFC_ATTR(name, defval, minval, maxval, desc) \
 static int lpfc_##name = defval;\
 module_param(lpfc_##name, int, 0);\
@@ -778,6 +854,50 @@ lpfc_param_store(name)\
 static CLASS_DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\
                         lpfc_##name##_show, lpfc_##name##_store)
 
+#define LPFC_VPORT_ATTR(name, defval, minval, maxval, desc) \
+static int lpfc_##name = defval;\
+module_param(lpfc_##name, int, 0);\
+MODULE_PARM_DESC(lpfc_##name, desc);\
+lpfc_vport_param_init(name, defval, minval, maxval)
+
+#define LPFC_VPORT_ATTR_R(name, defval, minval, maxval, desc) \
+static int lpfc_##name = defval;\
+module_param(lpfc_##name, int, 0);\
+MODULE_PARM_DESC(lpfc_##name, desc);\
+lpfc_vport_param_show(name)\
+lpfc_vport_param_init(name, defval, minval, maxval)\
+static CLASS_DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL)
+
+#define LPFC_VPORT_ATTR_RW(name, defval, minval, maxval, desc) \
+static int lpfc_##name = defval;\
+module_param(lpfc_##name, int, 0);\
+MODULE_PARM_DESC(lpfc_##name, desc);\
+lpfc_vport_param_show(name)\
+lpfc_vport_param_init(name, defval, minval, maxval)\
+lpfc_vport_param_set(name, defval, minval, maxval)\
+lpfc_vport_param_store(name)\
+static CLASS_DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\
+                        lpfc_##name##_show, lpfc_##name##_store)
+
+#define LPFC_VPORT_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_vport_param_hex_show(name)\
+lpfc_vport_param_init(name, defval, minval, maxval)\
+static CLASS_DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL)
+
+#define LPFC_VPORT_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_vport_param_hex_show(name)\
+lpfc_vport_param_init(name, defval, minval, maxval)\
+lpfc_vport_param_set(name, defval, minval, maxval)\
+lpfc_vport_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);
@@ -794,8 +914,6 @@ static CLASS_DEVICE_ATTR(num_discovered_ports, S_IRUGO,
 static CLASS_DEVICE_ATTR(nport_evt_cnt, S_IRUGO, lpfc_nport_evt_cnt_show, NULL);
 static CLASS_DEVICE_ATTR(lpfc_drvr_version, S_IRUGO, lpfc_drvr_version_show,
                         NULL);
-static CLASS_DEVICE_ATTR(management_version, S_IRUGO, management_version_show,
-                        NULL);
 static CLASS_DEVICE_ATTR(board_mode, S_IRUGO | S_IWUSR,
                         lpfc_board_mode_show, lpfc_board_mode_store);
 static CLASS_DEVICE_ATTR(issue_reset, S_IWUSR, NULL, lpfc_issue_reset);
@@ -806,6 +924,8 @@ static CLASS_DEVICE_ATTR(used_rpi, S_IRUGO, lpfc_used_rpi_show, NULL);
 static CLASS_DEVICE_ATTR(max_xri, S_IRUGO, lpfc_max_xri_show, NULL);
 static CLASS_DEVICE_ATTR(used_xri, S_IRUGO, lpfc_used_xri_show, NULL);
 static CLASS_DEVICE_ATTR(npiv_info, S_IRUGO, lpfc_npiv_info_show, NULL);
+static CLASS_DEVICE_ATTR(lpfc_temp_sensor, S_IRUGO, lpfc_temp_sensor_show,
+                        NULL);
 
 
 static char *lpfc_soft_wwn_key = "C99G71SL8032A";
@@ -869,6 +989,14 @@ lpfc_soft_wwpn_store(struct class_device *cdev, const char *buf, size_t count)
        unsigned int i, j, cnt=count;
        u8 wwpn[8];
 
+       if (!phba->cfg_enable_hba_reset)
+               return -EACCES;
+       spin_lock_irq(&phba->hbalock);
+       if (phba->over_temp_state == HBA_OVER_TEMP) {
+               spin_unlock_irq(&phba->hbalock);
+               return -EACCES;
+       }
+       spin_unlock_irq(&phba->hbalock);
        /* count may include a LF at end of string */
        if (buf[cnt-1] == '\n')
                cnt--;
@@ -908,17 +1036,15 @@ lpfc_soft_wwpn_store(struct class_device *cdev, const char *buf, size_t count)
        stat1 = lpfc_do_offline(phba, LPFC_EVT_OFFLINE);
        if (stat1)
                lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
-                       "%d:0463 lpfc_soft_wwpn attribute set failed to reinit "
-                       "adapter - %d\n", phba->brd_no, stat1);
-
+                               "0463 lpfc_soft_wwpn attribute set failed to "
+                               "reinit adapter - %d\n", stat1);
        init_completion(&online_compl);
        lpfc_workq_post_event(phba, &stat2, &online_compl, LPFC_EVT_ONLINE);
        wait_for_completion(&online_compl);
        if (stat2)
                lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
-                       "%d:0464 lpfc_soft_wwpn attribute set failed to reinit "
-                       "adapter - %d\n", phba->brd_no, stat2);
-
+                               "0464 lpfc_soft_wwpn attribute set failed to "
+                               "reinit adapter - %d\n", stat2);
        return (stat1 || stat2) ? -EIO : count;
 }
 static CLASS_DEVICE_ATTR(lpfc_soft_wwpn, S_IRUGO | S_IWUSR,\
@@ -927,8 +1053,8 @@ static CLASS_DEVICE_ATTR(lpfc_soft_wwpn, S_IRUGO | S_IWUSR,\
 static ssize_t
 lpfc_soft_wwnn_show(struct class_device *cdev, char *buf)
 {
-       struct Scsi_Host *host = class_to_shost(cdev);
-       struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata;
+       struct Scsi_Host *shost = class_to_shost(cdev);
+       struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba;
        return snprintf(buf, PAGE_SIZE, "0x%llx\n",
                        (unsigned long long)phba->cfg_soft_wwnn);
 }
@@ -937,8 +1063,8 @@ lpfc_soft_wwnn_show(struct class_device *cdev, char *buf)
 static ssize_t
 lpfc_soft_wwnn_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 Scsi_Host *shost = class_to_shost(cdev);
+       struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba;
        unsigned int i, j, cnt=count;
        u8 wwnn[8];
 
@@ -1002,7 +1128,13 @@ MODULE_PARM_DESC(lpfc_sli_mode, "SLI mode selector:"
                 " 2 - select SLI-2 even on SLI-3 capable HBAs,"
                 " 3 - select SLI-3");
 
-LPFC_ATTR_R(npiv_enable, 0, 0, 1, "Enable NPIV functionality");
+int lpfc_enable_npiv = 0;
+module_param(lpfc_enable_npiv, int, 0);
+MODULE_PARM_DESC(lpfc_enable_npiv, "Enable NPIV functionality");
+lpfc_param_show(enable_npiv);
+lpfc_param_init(enable_npiv, 0, 0, 1);
+static CLASS_DEVICE_ATTR(lpfc_enable_npiv, S_IRUGO,
+                        lpfc_enable_npiv_show, NULL);
 
 /*
 # lpfc_nodev_tmo: If set, it will hold all I/O errors on devices that disappear
@@ -1019,90 +1151,75 @@ lpfc_nodev_tmo_show(struct class_device *cdev, char *buf)
 {
        struct Scsi_Host  *shost = class_to_shost(cdev);
        struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
-       struct lpfc_hba   *phba = vport->phba;
        int val = 0;
-       val = phba->cfg_devloss_tmo;
-       return snprintf(buf, PAGE_SIZE, "%d\n",
-                       phba->cfg_devloss_tmo);
+       val = vport->cfg_devloss_tmo;
+       return snprintf(buf, PAGE_SIZE, "%d\n", vport->cfg_devloss_tmo);
 }
 
 static int
-lpfc_nodev_tmo_init(struct lpfc_hba *phba, int val)
-{
-       static int warned;
-       if (phba->cfg_devloss_tmo !=  LPFC_DEF_DEVLOSS_TMO) {
-               phba->cfg_nodev_tmo = phba->cfg_devloss_tmo;
-               if (!warned && val != LPFC_DEF_DEVLOSS_TMO) {
-                       warned = 1;
-                       lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
-                                       "%d:0402 Ignoring nodev_tmo module "
-                                       "parameter because devloss_tmo is"
-                                       " set.\n",
-                                       phba->brd_no);
-               }
+lpfc_nodev_tmo_init(struct lpfc_vport *vport, int val)
+{
+       if (vport->cfg_devloss_tmo != LPFC_DEF_DEVLOSS_TMO) {
+               vport->cfg_nodev_tmo = vport->cfg_devloss_tmo;
+               if (val != LPFC_DEF_DEVLOSS_TMO)
+                       lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
+                                        "0402 Ignoring nodev_tmo module "
+                                        "parameter because devloss_tmo is "
+                                        "set.\n");
                return 0;
        }
 
        if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) {
-               phba->cfg_nodev_tmo = val;
-               phba->cfg_devloss_tmo = val;
+               vport->cfg_nodev_tmo = val;
+               vport->cfg_devloss_tmo = val;
                return 0;
        }
-       lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
-                       "%d:0400 lpfc_nodev_tmo attribute cannot be set to %d, "
-                       "allowed range is [%d, %d]\n",
-                       phba->brd_no, val,
-                       LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO);
-       phba->cfg_nodev_tmo = LPFC_DEF_DEVLOSS_TMO;
+       lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
+                        "0400 lpfc_nodev_tmo attribute cannot be set to"
+                        " %d, allowed range is [%d, %d]\n",
+                        val, LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO);
+       vport->cfg_nodev_tmo = LPFC_DEF_DEVLOSS_TMO;
        return -EINVAL;
 }
 
 static void
-lpfc_update_rport_devloss_tmo(struct lpfc_hba *phba)
+lpfc_update_rport_devloss_tmo(struct lpfc_vport *vport)
 {
-       struct lpfc_vport *vport;
        struct Scsi_Host  *shost;
        struct lpfc_nodelist  *ndlp;
 
-       list_for_each_entry(vport, &phba->port_list, listentry) {
-               shost = lpfc_shost_from_vport(vport);
-               spin_lock_irq(shost->host_lock);
-               list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp)
-                       if (ndlp->rport)
-                               ndlp->rport->dev_loss_tmo =
-                                       phba->cfg_devloss_tmo;
-               spin_unlock_irq(shost->host_lock);
-       }
+       shost = lpfc_shost_from_vport(vport);
+       spin_lock_irq(shost->host_lock);
+       list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp)
+               if (ndlp->rport)
+                       ndlp->rport->dev_loss_tmo = vport->cfg_devloss_tmo;
+       spin_unlock_irq(shost->host_lock);
 }
 
 static int
-lpfc_nodev_tmo_set(struct lpfc_hba *phba, int val)
+lpfc_nodev_tmo_set(struct lpfc_vport *vport, int val)
 {
-       if (phba->dev_loss_tmo_changed ||
-               (lpfc_devloss_tmo != LPFC_DEF_DEVLOSS_TMO)) {
-               lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
-                               "%d:0401 Ignoring change to nodev_tmo "
-                               "because devloss_tmo is set.\n",
-                               phba->brd_no);
+       if (vport->dev_loss_tmo_changed ||
+           (lpfc_devloss_tmo != LPFC_DEF_DEVLOSS_TMO)) {
+               lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
+                                "0401 Ignoring change to nodev_tmo "
+                                "because devloss_tmo is set.\n");
                return 0;
        }
-
        if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) {
-               phba->cfg_nodev_tmo = val;
-               phba->cfg_devloss_tmo = val;
-               lpfc_update_rport_devloss_tmo(phba);
+               vport->cfg_nodev_tmo = val;
+               vport->cfg_devloss_tmo = val;
+               lpfc_update_rport_devloss_tmo(vport);
                return 0;
        }
-
-       lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
-                       "%d:0403 lpfc_nodev_tmo attribute cannot be set to %d, "
-                       "allowed range is [%d, %d]\n",
-                       phba->brd_no, val, LPFC_MIN_DEVLOSS_TMO,
-                       LPFC_MAX_DEVLOSS_TMO);
+       lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
+                        "0403 lpfc_nodev_tmo attribute cannot be set to"
+                        "%d, allowed range is [%d, %d]\n",
+                        val, LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO);
        return -EINVAL;
 }
 
-lpfc_param_store(nodev_tmo)
+lpfc_vport_param_store(nodev_tmo)
 
 static CLASS_DEVICE_ATTR(lpfc_nodev_tmo, S_IRUGO | S_IWUSR,
                         lpfc_nodev_tmo_show, lpfc_nodev_tmo_store);
@@ -1116,29 +1233,28 @@ module_param(lpfc_devloss_tmo, int, 0);
 MODULE_PARM_DESC(lpfc_devloss_tmo,
                 "Seconds driver will hold I/O waiting "
                 "for a device to come back");
-lpfc_param_init(devloss_tmo, LPFC_DEF_DEVLOSS_TMO,
-               LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO)
-lpfc_param_show(devloss_tmo)
+lpfc_vport_param_init(devloss_tmo, LPFC_DEF_DEVLOSS_TMO,
+                     LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO)
+lpfc_vport_param_show(devloss_tmo)
 static int
-lpfc_devloss_tmo_set(struct lpfc_hba *phba, int val)
+lpfc_devloss_tmo_set(struct lpfc_vport *vport, int val)
 {
        if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) {
-               phba->cfg_nodev_tmo = val;
-               phba->cfg_devloss_tmo = val;
-               phba->dev_loss_tmo_changed = 1;
-               lpfc_update_rport_devloss_tmo(phba);
+               vport->cfg_nodev_tmo = val;
+               vport->cfg_devloss_tmo = val;
+               vport->dev_loss_tmo_changed = 1;
+               lpfc_update_rport_devloss_tmo(vport);
                return 0;
        }
 
-       lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
-                       "%d:0404 lpfc_devloss_tmo attribute cannot be set to"
-                       " %d, allowed range is [%d, %d]\n",
-                       phba->brd_no, val, LPFC_MIN_DEVLOSS_TMO,
-                       LPFC_MAX_DEVLOSS_TMO);
+       lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
+                        "0404 lpfc_devloss_tmo attribute cannot be set to"
+                        " %d, allowed range is [%d, %d]\n",
+                        val, LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO);
        return -EINVAL;
 }
 
-lpfc_param_store(devloss_tmo)
+lpfc_vport_param_store(devloss_tmo)
 static CLASS_DEVICE_ATTR(lpfc_devloss_tmo, S_IRUGO | S_IWUSR,
        lpfc_devloss_tmo_show, lpfc_devloss_tmo_store);
 
@@ -1160,14 +1276,22 @@ static CLASS_DEVICE_ATTR(lpfc_devloss_tmo, S_IRUGO | S_IWUSR,
 # LOG_LIBDFC                    0x2000     LIBDFC events
 # LOG_ALL_MSG                   0xffff     LOG all messages
 */
-LPFC_ATTR_HEX_RW(log_verbose, 0x0, 0x0, 0xffff, "Verbose logging bit-mask");
+LPFC_VPORT_ATTR_HEX_RW(log_verbose, 0x0, 0x0, 0xffff,
+                      "Verbose logging bit-mask");
+
+/*
+# lpfc_enable_da_id: This turns on the DA_ID CT command that deregisters
+# objects that have been registered with the nameserver after login.
+*/
+LPFC_VPORT_ATTR_R(enable_da_id, 0, 0, 1,
+                 "Deregister nameserver objects before LOGO");
 
 /*
 # lun_queue_depth:  This parameter is used to limit the number of outstanding
 # commands per FCP LUN. Value range is [1,128]. Default value is 30.
 */
-LPFC_ATTR_R(lun_queue_depth, 30, 1, 128,
-           "Max number of FCP commands we can queue to a specific LUN");
+LPFC_VPORT_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
@@ -1188,12 +1312,12 @@ LPFC_ATTR_R(hba_queue_depth, 8192, 32, 8192,
 # are allowed to login to each other.
 # Default value of this parameter is 0.
 */
-LPFC_ATTR_R(peer_port_login, 0, 0, 1,
-           "Allow peer ports on the same physical port to login to each "
-           "other.");
+LPFC_VPORT_ATTR_R(peer_port_login, 0, 0, 1,
+                 "Allow peer ports on the same physical port to login to each "
+                 "other.");
 
 /*
-# vport_restrict_login:  This parameter allows/prevents logins
+# restrict_login:  This parameter allows/prevents logins
 # between Virtual Ports and remote initiators.
 # When this parameter is not set (0) Virtual Ports will accept PLOGIs from
 # other initiators and will attempt to PLOGI all remote ports.
@@ -1203,8 +1327,55 @@ LPFC_ATTR_R(peer_port_login, 0, 0, 1,
 # This parameter does not restrict logins to Fabric resident remote ports.
 # Default value of this parameter is 1.
 */
-LPFC_ATTR_RW(vport_restrict_login, 1, 0, 1,
-           "Restrict virtual ports login to remote initiators.");
+static int lpfc_restrict_login = 1;
+module_param(lpfc_restrict_login, int, 0);
+MODULE_PARM_DESC(lpfc_restrict_login,
+                "Restrict virtual ports login to remote initiators.");
+lpfc_vport_param_show(restrict_login);
+
+static int
+lpfc_restrict_login_init(struct lpfc_vport *vport, int val)
+{
+       if (val < 0 || val > 1) {
+               lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
+                                "0449 lpfc_restrict_login attribute cannot "
+                                "be set to %d, allowed range is [0, 1]\n",
+                                val);
+               vport->cfg_restrict_login = 1;
+               return -EINVAL;
+       }
+       if (vport->port_type == LPFC_PHYSICAL_PORT) {
+               vport->cfg_restrict_login = 0;
+               return 0;
+       }
+       vport->cfg_restrict_login = val;
+       return 0;
+}
+
+static int
+lpfc_restrict_login_set(struct lpfc_vport *vport, int val)
+{
+       if (val < 0 || val > 1) {
+               lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
+                                "0450 lpfc_restrict_login attribute cannot "
+                                "be set to %d, allowed range is [0, 1]\n",
+                                val);
+               vport->cfg_restrict_login = 1;
+               return -EINVAL;
+       }
+       if (vport->port_type == LPFC_PHYSICAL_PORT && val != 0) {
+               lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
+                                "0468 lpfc_restrict_login must be 0 for "
+                                "Physical ports.\n");
+               vport->cfg_restrict_login = 0;
+               return 0;
+       }
+       vport->cfg_restrict_login = val;
+       return 0;
+}
+lpfc_vport_param_store(restrict_login);
+static CLASS_DEVICE_ATTR(lpfc_restrict_login, S_IRUGO | S_IWUSR,
+                        lpfc_restrict_login_show, lpfc_restrict_login_store);
 
 /*
 # Some disk devices have a "select ID" or "select Target" capability.
@@ -1223,8 +1394,8 @@ LPFC_ATTR_RW(vport_restrict_login, 1, 0, 1,
 # and will not work across a fabric. Also this parameter will take
 # effect only in the case when ALPA map is not available.)
 */
-LPFC_ATTR_R(scan_down, 1, 0, 1,
-            "Start scanning for devices from highest ALPA to lowest");
+LPFC_VPORT_ATTR_R(scan_down, 1, 0, 1,
+                 "Start scanning for devices from highest ALPA to lowest");
 
 /*
 # lpfc_topology:  link topology for init link
@@ -1237,7 +1408,33 @@ LPFC_ATTR_R(scan_down, 1, 0, 1,
 # Set loop mode if you want to run as an NL_Port. Value range is [0,0x6].
 # Default value is 0.
 */
-LPFC_ATTR_RW(topology, 0, 0, 6, "Select Fibre Channel topology");
+static int
+lpfc_topology_set(struct lpfc_hba *phba, int val)
+{
+       int err;
+       uint32_t prev_val;
+       if (val >= 0 && val <= 6) {
+               prev_val = phba->cfg_topology;
+               phba->cfg_topology = val;
+               err = lpfc_issue_lip(lpfc_shost_from_vport(phba->pport));
+               if (err)
+                       phba->cfg_topology = prev_val;
+               return err;
+       }
+       lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
+               "%d:0467 lpfc_topology attribute cannot be set to %d, "
+               "allowed range is [0, 6]\n",
+               phba->brd_no, val);
+       return -EINVAL;
+}
+static int lpfc_topology = 0;
+module_param(lpfc_topology, int, 0);
+MODULE_PARM_DESC(lpfc_topology, "Select Fibre Channel topology");
+lpfc_param_show(topology)
+lpfc_param_init(topology, 0, 0, 6)
+lpfc_param_store(topology)
+static CLASS_DEVICE_ATTR(lpfc_topology, S_IRUGO | S_IWUSR,
+               lpfc_topology_show, lpfc_topology_store);
 
 /*
 # lpfc_link_speed: Link speed selection for initializing the Fibre Channel
@@ -1249,21 +1446,73 @@ LPFC_ATTR_RW(topology, 0, 0, 6, "Select Fibre Channel topology");
 #       8  = 8 Gigabaud
 # Value range is [0,8]. Default value is 0.
 */
-LPFC_ATTR_R(link_speed, 0, 0, 8, "Select link speed");
+static int
+lpfc_link_speed_set(struct lpfc_hba *phba, int val)
+{
+       int err;
+       uint32_t prev_val;
+
+       if (((val == LINK_SPEED_1G) && !(phba->lmt & LMT_1Gb)) ||
+               ((val == LINK_SPEED_2G) && !(phba->lmt & LMT_2Gb)) ||
+               ((val == LINK_SPEED_4G) && !(phba->lmt & LMT_4Gb)) ||
+               ((val == LINK_SPEED_8G) && !(phba->lmt & LMT_8Gb)) ||
+               ((val == LINK_SPEED_10G) && !(phba->lmt & LMT_10Gb)))
+               return -EINVAL;
+
+       if ((val >= 0 && val <= LPFC_MAX_LINK_SPEED)
+               && (LPFC_LINK_SPEED_BITMAP & (1 << val))) {
+               prev_val = phba->cfg_link_speed;
+               phba->cfg_link_speed = val;
+               err = lpfc_issue_lip(lpfc_shost_from_vport(phba->pport));
+               if (err)
+                       phba->cfg_link_speed = prev_val;
+               return err;
+       }
+
+       lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
+               "%d:0469 lpfc_link_speed attribute cannot be set to %d, "
+               "allowed range is [0, 8]\n",
+               phba->brd_no, val);
+       return -EINVAL;
+}
+
+static int lpfc_link_speed = 0;
+module_param(lpfc_link_speed, int, 0);
+MODULE_PARM_DESC(lpfc_link_speed, "Select link speed");
+lpfc_param_show(link_speed)
+static int
+lpfc_link_speed_init(struct lpfc_hba *phba, int val)
+{
+       if ((val >= 0 && val <= LPFC_MAX_LINK_SPEED)
+               && (LPFC_LINK_SPEED_BITMAP & (1 << val))) {
+               phba->cfg_link_speed = val;
+               return 0;
+       }
+       lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
+                       "0454 lpfc_link_speed attribute cannot "
+                       "be set to %d, allowed values are "
+                       "["LPFC_LINK_SPEED_STRING"]\n", val);
+       phba->cfg_link_speed = 0;
+       return -EINVAL;
+}
+
+lpfc_param_store(link_speed)
+static CLASS_DEVICE_ATTR(lpfc_link_speed, S_IRUGO | S_IWUSR,
+               lpfc_link_speed_show, lpfc_link_speed_store);
 
 /*
 # lpfc_fcp_class:  Determines FC class to use for the FCP protocol.
 # Value range is [2,3]. Default value is 3.
 */
-LPFC_ATTR_R(fcp_class, 3, 2, 3,
-            "Select Fibre Channel class of service for FCP sequences");
+LPFC_VPORT_ATTR_R(fcp_class, 3, 2, 3,
+                 "Select Fibre Channel class of service for FCP sequences");
 
 /*
 # lpfc_use_adisc: Use ADISC for FCP rediscovery instead of PLOGI. Value range
 # is [0,1]. Default value is 0.
 */
-LPFC_ATTR_RW(use_adisc, 0, 0, 1,
-            "Use ADISC on rediscovery to authenticate FCP devices");
+LPFC_VPORT_ATTR_RW(use_adisc, 0, 0, 1,
+                  "Use ADISC on rediscovery to authenticate FCP devices");
 
 /*
 # lpfc_ack0: Use ACK0, instead of ACK1 for class 2 acknowledgement. Value
@@ -1315,13 +1564,13 @@ LPFC_ATTR_R(multi_ring_type, FC_LLC_SNAP, 1,
 #       2 = support FDMI with attribute of hostname
 # Value range [0,2]. Default value is 0.
 */
-LPFC_ATTR_RW(fdmi_on, 0, 0, 2, "Enable FDMI support");
+LPFC_VPORT_ATTR_RW(fdmi_on, 0, 0, 2, "Enable FDMI support");
 
 /*
 # Specifies the maximum number of ELS cmds we can have outstanding (for
 # discovery). Value range is [1,64]. Default value = 32.
 */
-LPFC_ATTR(discovery_threads, 32, 1, 64, "Maximum number of ELS commands "
+LPFC_VPORT_ATTR(discovery_threads, 32, 1, 64, "Maximum number of ELS commands "
                 "during discovery");
 
 /*
@@ -1329,8 +1578,7 @@ LPFC_ATTR(discovery_threads, 32, 1, 64, "Maximum number of ELS commands "
 # Value range is [0,65535]. Default value is 255.
 # NOTE: The SCSI layer might probe all allowed LUN on some old targets.
 */
-LPFC_ATTR_R(max_luns, 255, 0, 65535,
-            "Maximum allowed LUN");
+LPFC_VPORT_ATTR_R(max_luns, 255, 0, 65535, "Maximum allowed LUN");
 
 /*
 # lpfc_poll_tmo: .Milliseconds driver will wait between polling FCP ring.
@@ -1348,7 +1596,30 @@ LPFC_ATTR_RW(poll_tmo, 10, 1, 255,
 */
 LPFC_ATTR_R(use_msi, 0, 0, 1, "Use Message Signaled Interrupts, if possible");
 
+/*
+# lpfc_enable_hba_reset: Allow or prevent HBA resets to the hardware.
+#       0  = HBA resets disabled
+#       1  = HBA resets enabled (default)
+# Value range is [0,1]. Default value is 1.
+*/
+LPFC_ATTR_R(enable_hba_reset, 1, 0, 1, "Enable HBA resets from the driver.");
 
+/*
+# lpfc_enable_hba_heartbeat: Enable HBA heartbeat timer..
+#       0  = HBA Heartbeat disabled
+#       1  = HBA Heartbeat enabled (default)
+# Value range is [0,1]. Default value is 1.
+*/
+LPFC_ATTR_R(enable_hba_heartbeat, 1, 0, 1, "Enable HBA Heartbeat.");
+
+/*
+ * lpfc_sg_seg_cnt: Initial Maximum DMA Segment Count
+ * This value can be set to values between 64 and 256. The default value is
+ * 64, but may be increased to allow for larger Max I/O sizes. The scsi layer
+ * will be allowed to request I/Os of sizes up to (MAX_SEG_COUNT * SEG_SIZE).
+ */
+LPFC_ATTR_R(sg_seg_cnt, LPFC_DEFAULT_SG_SEG_CNT, LPFC_DEFAULT_SG_SEG_CNT,
+           LPFC_MAX_SG_SEG_CNT, "Max Scatter Gather Segment Count");
 
 struct class_device_attribute *lpfc_hba_attrs[] = {
        &class_device_attr_info,
@@ -1363,11 +1634,11 @@ struct class_device_attribute *lpfc_hba_attrs[] = {
        &class_device_attr_state,
        &class_device_attr_num_discovered_ports,
        &class_device_attr_lpfc_drvr_version,
+       &class_device_attr_lpfc_temp_sensor,
        &class_device_attr_lpfc_log_verbose,
        &class_device_attr_lpfc_lun_queue_depth,
        &class_device_attr_lpfc_hba_queue_depth,
        &class_device_attr_lpfc_peer_port_login,
-       &class_device_attr_lpfc_vport_restrict_login,
        &class_device_attr_lpfc_nodev_tmo,
        &class_device_attr_lpfc_devloss_tmo,
        &class_device_attr_lpfc_fcp_class,
@@ -1383,9 +1654,8 @@ struct class_device_attribute *lpfc_hba_attrs[] = {
        &class_device_attr_lpfc_multi_ring_type,
        &class_device_attr_lpfc_fdmi_on,
        &class_device_attr_lpfc_max_luns,
-       &class_device_attr_lpfc_npiv_enable,
+       &class_device_attr_lpfc_enable_npiv,
        &class_device_attr_nport_evt_cnt,
-       &class_device_attr_management_version,
        &class_device_attr_board_mode,
        &class_device_attr_max_vpi,
        &class_device_attr_used_vpi,
@@ -1401,6 +1671,32 @@ struct class_device_attribute *lpfc_hba_attrs[] = {
        &class_device_attr_lpfc_soft_wwnn,
        &class_device_attr_lpfc_soft_wwpn,
        &class_device_attr_lpfc_soft_wwn_enable,
+       &class_device_attr_lpfc_enable_hba_reset,
+       &class_device_attr_lpfc_enable_hba_heartbeat,
+       &class_device_attr_lpfc_sg_seg_cnt,
+       NULL,
+};
+
+struct class_device_attribute *lpfc_vport_attrs[] = {
+       &class_device_attr_info,
+       &class_device_attr_state,
+       &class_device_attr_num_discovered_ports,
+       &class_device_attr_lpfc_drvr_version,
+
+       &class_device_attr_lpfc_log_verbose,
+       &class_device_attr_lpfc_lun_queue_depth,
+       &class_device_attr_lpfc_nodev_tmo,
+       &class_device_attr_lpfc_devloss_tmo,
+       &class_device_attr_lpfc_hba_queue_depth,
+       &class_device_attr_lpfc_peer_port_login,
+       &class_device_attr_lpfc_restrict_login,
+       &class_device_attr_lpfc_fcp_class,
+       &class_device_attr_lpfc_use_adisc,
+       &class_device_attr_lpfc_fdmi_on,
+       &class_device_attr_lpfc_max_luns,
+       &class_device_attr_nport_evt_cnt,
+       &class_device_attr_npiv_info,
+       &class_device_attr_lpfc_enable_da_id,
        NULL,
 };
 
@@ -1576,13 +1872,18 @@ sysfs_mbox_read(struct kobject *kobj, struct bin_attribute *bin_attr,
 
        spin_lock_irq(&phba->hbalock);
 
+       if (phba->over_temp_state == HBA_OVER_TEMP) {
+               sysfs_mbox_idle(phba);
+               spin_unlock_irq(&phba->hbalock);
+               return  -EACCES;
+       }
+
        if (off == 0 &&
            phba->sysfs_mbox.state  == SMBOX_WRITING &&
            phba->sysfs_mbox.offset >= 2 * sizeof(uint32_t)) {
 
                switch (phba->sysfs_mbox.mbox->mb.mbxCommand) {
                        /* Offline only */
-               case MBX_WRITE_NV:
                case MBX_INIT_LINK:
                case MBX_DOWN_LINK:
                case MBX_CONFIG_LINK:
@@ -1593,9 +1894,7 @@ sysfs_mbox_read(struct kobject *kobj, struct bin_attribute *bin_attr,
                case MBX_DUMP_CONTEXT:
                case MBX_RUN_DIAGS:
                case MBX_RESTART:
-               case MBX_FLASH_WR_ULA:
                case MBX_SET_MASK:
-               case MBX_SET_SLIM:
                case MBX_SET_DEBUG:
                        if (!(vport->fc_flag & FC_OFFLINE_MODE)) {
                                printk(KERN_WARNING "mbox_read:Command 0x%x "
@@ -1605,6 +1904,8 @@ sysfs_mbox_read(struct kobject *kobj, struct bin_attribute *bin_attr,
                                spin_unlock_irq(&phba->hbalock);
                                return -EPERM;
                        }
+               case MBX_WRITE_NV:
+               case MBX_WRITE_VPARMS:
                case MBX_LOAD_SM:
                case MBX_READ_NV:
                case MBX_READ_CONFIG:
@@ -1621,6 +1922,8 @@ sysfs_mbox_read(struct kobject *kobj, struct bin_attribute *bin_attr,
                case MBX_LOAD_EXP_ROM:
                case MBX_BEACON:
                case MBX_DEL_LD_ENTRY:
+               case MBX_SET_VARIABLE:
+               case MBX_WRITE_WWN:
                        break;
                case MBX_READ_SPARM64:
                case MBX_READ_LA:
@@ -1642,6 +1945,17 @@ sysfs_mbox_read(struct kobject *kobj, struct bin_attribute *bin_attr,
                        return -EPERM;
                }
 
+               /* If HBA encountered an error attention, allow only DUMP
+                * mailbox command until the HBA is restarted.
+                */
+               if ((phba->pport->stopped) &&
+                       (phba->sysfs_mbox.mbox->mb.mbxCommand
+                               != MBX_DUMP_MEMORY)) {
+                       sysfs_mbox_idle(phba);
+                       spin_unlock_irq(&phba->hbalock);
+                       return -EPERM;
+               }
+
                phba->sysfs_mbox.mbox->vport = vport;
 
                if (phba->sli.sli_flag & LPFC_BLOCK_MGMT_IO) {
@@ -1842,7 +2156,8 @@ lpfc_get_host_speed(struct Scsi_Host *shost)
                                fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN;
                        break;
                }
-       }
+       } else
+               fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN;
 
        spin_unlock_irq(shost->host_lock);
 }
@@ -1862,7 +2177,7 @@ lpfc_get_host_fabric_name (struct Scsi_Host *shost)
                node_name = wwn_to_u64(phba->fc_fabparam.nodeName.u.wwn);
        else
                /* fabric is local port if there is no F/FL_Port */
-               node_name = wwn_to_u64(vport->fc_nodename.u.wwn);
+               node_name = 0;
 
        spin_unlock_irq(shost->host_lock);
 
@@ -2186,8 +2501,6 @@ struct fc_function_template lpfc_transport_functions = {
        .dev_loss_tmo_callbk = lpfc_dev_loss_tmo_callbk,
        .terminate_rport_io = lpfc_terminate_rport_io,
 
-       .vport_create = lpfc_vport_create,
-       .vport_delete = lpfc_vport_delete,
        .dd_fcvport_size = sizeof(struct lpfc_vport *),
 };
 
@@ -2243,7 +2556,6 @@ struct fc_function_template lpfc_vport_transport_functions = {
        .get_starget_port_name = lpfc_get_starget_port_name,
        .show_starget_port_name = 1,
 
-       .issue_fc_host_lip = lpfc_issue_lip,
        .dev_loss_tmo_callbk = lpfc_dev_loss_tmo_callbk,
        .terminate_rport_io = lpfc_terminate_rport_io,
 
@@ -2253,49 +2565,53 @@ struct fc_function_template lpfc_vport_transport_functions = {
 void
 lpfc_get_cfgparam(struct lpfc_hba *phba)
 {
-       lpfc_log_verbose_init(phba, lpfc_log_verbose);
        lpfc_cr_delay_init(phba, lpfc_cr_delay);
        lpfc_cr_count_init(phba, lpfc_cr_count);
        lpfc_multi_ring_support_init(phba, lpfc_multi_ring_support);
        lpfc_multi_ring_rctl_init(phba, lpfc_multi_ring_rctl);
        lpfc_multi_ring_type_init(phba, lpfc_multi_ring_type);
-       lpfc_lun_queue_depth_init(phba, lpfc_lun_queue_depth);
-       lpfc_fcp_class_init(phba, lpfc_fcp_class);
-       lpfc_use_adisc_init(phba, lpfc_use_adisc);
        lpfc_ack0_init(phba, lpfc_ack0);
        lpfc_topology_init(phba, lpfc_topology);
-       lpfc_scan_down_init(phba, lpfc_scan_down);
        lpfc_link_speed_init(phba, lpfc_link_speed);
-       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);
-       lpfc_peer_port_login_init(phba, lpfc_peer_port_login);
-       lpfc_npiv_enable_init(phba, lpfc_npiv_enable);
-       lpfc_vport_restrict_login_init(phba, lpfc_vport_restrict_login);
+       lpfc_enable_npiv_init(phba, lpfc_enable_npiv);
        lpfc_use_msi_init(phba, lpfc_use_msi);
-       lpfc_devloss_tmo_init(phba, lpfc_devloss_tmo);
-       lpfc_nodev_tmo_init(phba, lpfc_nodev_tmo);
+       lpfc_enable_hba_reset_init(phba, lpfc_enable_hba_reset);
+       lpfc_enable_hba_heartbeat_init(phba, lpfc_enable_hba_heartbeat);
        phba->cfg_poll = lpfc_poll;
        phba->cfg_soft_wwnn = 0L;
        phba->cfg_soft_wwpn = 0L;
-
-       /*
-        * The total number of segments is the configuration value plus 2
-        * since the IOCB need a command and response bde.
-        */
-       phba->cfg_sg_seg_cnt = LPFC_SG_SEG_CNT + 2;
-
+       lpfc_sg_seg_cnt_init(phba, lpfc_sg_seg_cnt);
+       /* Also reinitialize the host templates with new values. */
+       lpfc_vport_template.sg_tablesize = phba->cfg_sg_seg_cnt;
+       lpfc_template.sg_tablesize = phba->cfg_sg_seg_cnt;
        /*
         * Since the sg_tablesize is module parameter, the sg_dma_buf_size
-        * used to create the sg_dma_buf_pool must be dynamically calculated
+        * used to create the sg_dma_buf_pool must be dynamically calculated.
+        * 2 segments are added since the IOCB needs a command and response bde.
         */
        phba->cfg_sg_dma_buf_size = sizeof(struct fcp_cmnd) +
                        sizeof(struct fcp_rsp) +
-                       (phba->cfg_sg_seg_cnt * sizeof(struct ulp_bde64));
-
-
+                       ((phba->cfg_sg_seg_cnt + 2) * sizeof(struct ulp_bde64));
        lpfc_hba_queue_depth_init(phba, lpfc_hba_queue_depth);
+       return;
+}
 
+void
+lpfc_get_vport_cfgparam(struct lpfc_vport *vport)
+{
+       lpfc_log_verbose_init(vport, lpfc_log_verbose);
+       lpfc_lun_queue_depth_init(vport, lpfc_lun_queue_depth);
+       lpfc_devloss_tmo_init(vport, lpfc_devloss_tmo);
+       lpfc_nodev_tmo_init(vport, lpfc_nodev_tmo);
+       lpfc_peer_port_login_init(vport, lpfc_peer_port_login);
+       lpfc_restrict_login_init(vport, lpfc_restrict_login);
+       lpfc_fcp_class_init(vport, lpfc_fcp_class);
+       lpfc_use_adisc_init(vport, lpfc_use_adisc);
+       lpfc_fdmi_on_init(vport, lpfc_fdmi_on);
+       lpfc_discovery_threads_init(vport, lpfc_discovery_threads);
+       lpfc_max_luns_init(vport, lpfc_max_luns);
+       lpfc_scan_down_init(vport, lpfc_scan_down);
+       lpfc_enable_da_id_init(vport, lpfc_enable_da_id);
        return;
 }