[SCSI] qla2xxx: Add CPU affinity support.
[safe/jmp/linux-2.6] / drivers / scsi / qla2xxx / qla_attr.c
index adf9732..f3536e5 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * QLogic Fibre Channel HBA Driver
- * Copyright (c)  2003-2005 QLogic Corporation
+ * Copyright (c)  2003-2008 QLogic Corporation
  *
  * See LICENSE.qla2xxx for copyright and licensing details.
  */
@@ -8,6 +8,7 @@
 
 #include <linux/kthread.h>
 #include <linux/vmalloc.h>
+#include <linux/delay.h>
 
 static int qla24xx_vport_disable(struct fc_vport *, bool);
 
@@ -18,20 +19,15 @@ qla2x00_sysfs_read_fw_dump(struct kobject *kobj,
                           struct bin_attribute *bin_attr,
                           char *buf, loff_t off, size_t count)
 {
-       struct scsi_qla_host *ha = shost_priv(dev_to_shost(container_of(kobj,
+       struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj,
            struct device, kobj)));
-       char *rbuf = (char *)ha->fw_dump;
+       struct qla_hw_data *ha = vha->hw;
 
        if (ha->fw_dump_reading == 0)
                return 0;
-       if (off > ha->fw_dump_len)
-                return 0;
-       if (off + count > ha->fw_dump_len)
-               count = ha->fw_dump_len - off;
 
-       memcpy(buf, &rbuf[off], count);
-
-       return (count);
+       return memory_read_from_buffer(buf, count, &off, ha->fw_dump,
+                                       ha->fw_dump_len);
 }
 
 static ssize_t
@@ -39,8 +35,9 @@ qla2x00_sysfs_write_fw_dump(struct kobject *kobj,
                            struct bin_attribute *bin_attr,
                            char *buf, loff_t off, size_t count)
 {
-       struct scsi_qla_host *ha = shost_priv(dev_to_shost(container_of(kobj,
+       struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj,
            struct device, kobj)));
+       struct qla_hw_data *ha = vha->hw;
        int reading;
 
        if (off != 0)
@@ -53,7 +50,7 @@ qla2x00_sysfs_write_fw_dump(struct kobject *kobj,
                        break;
 
                qla_printk(KERN_INFO, ha,
-                   "Firmware dump cleared on (%ld).\n", ha->host_no);
+                   "Firmware dump cleared on (%ld).\n", vha->host_no);
 
                ha->fw_dump_reading = 0;
                ha->fw_dumped = 0;
@@ -64,11 +61,14 @@ qla2x00_sysfs_write_fw_dump(struct kobject *kobj,
 
                        qla_printk(KERN_INFO, ha,
                            "Raw firmware dump ready for read on (%ld).\n",
-                           ha->host_no);
+                           vha->host_no);
                }
                break;
        case 2:
-               qla2x00_alloc_fw_dump(ha);
+               qla2x00_alloc_fw_dump(vha);
+               break;
+       case 3:
+               qla2x00_system_error(vha);
                break;
        }
        return (count);
@@ -89,22 +89,18 @@ qla2x00_sysfs_read_nvram(struct kobject *kobj,
                         struct bin_attribute *bin_attr,
                         char *buf, loff_t off, size_t count)
 {
-       struct scsi_qla_host *ha = shost_priv(dev_to_shost(container_of(kobj,
+       struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj,
            struct device, kobj)));
-       int             size = ha->nvram_size;
-       char            *nvram_cache = ha->nvram;
+       struct qla_hw_data *ha = vha->hw;
 
-       if (!capable(CAP_SYS_ADMIN) || off > size || count == 0)
+       if (!capable(CAP_SYS_ADMIN))
                return 0;
-       if (off + count > size) {
-               size -= off;
-               count = size;
-       }
-
-       /* Read NVRAM data from cache. */
-       memcpy(buf, &nvram_cache[off], count);
 
-       return count;
+       if (IS_NOCACHE_VPD_TYPE(ha))
+               ha->isp_ops->read_optrom(vha, ha->vpd, ha->flt_region_nvram << 2,
+                   ha->nvram_size);
+       return memory_read_from_buffer(buf, count, &off, ha->nvram,
+                                       ha->nvram_size);
 }
 
 static ssize_t
@@ -112,11 +108,13 @@ qla2x00_sysfs_write_nvram(struct kobject *kobj,
                          struct bin_attribute *bin_attr,
                          char *buf, loff_t off, size_t count)
 {
-       struct scsi_qla_host *ha = shost_priv(dev_to_shost(container_of(kobj,
+       struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj,
            struct device, kobj)));
+       struct qla_hw_data *ha = vha->hw;
        uint16_t        cnt;
 
-       if (!capable(CAP_SYS_ADMIN) || off != 0 || count != ha->nvram_size)
+       if (!capable(CAP_SYS_ADMIN) || off != 0 || count != ha->nvram_size ||
+           !ha->isp_ops->write_nvram)
                return 0;
 
        /* Checksum NVRAM. */
@@ -142,12 +140,21 @@ qla2x00_sysfs_write_nvram(struct kobject *kobj,
                *iter = chksum;
        }
 
+       if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) {
+               qla_printk(KERN_WARNING, ha,
+                   "HBA not online, failing NVRAM update.\n");
+               return -EAGAIN;
+       }
+
        /* Write NVRAM. */
-       ha->isp_ops->write_nvram(ha, (uint8_t *)buf, ha->nvram_base, count);
-       ha->isp_ops->read_nvram(ha, (uint8_t *)ha->nvram, ha->nvram_base,
+       ha->isp_ops->write_nvram(vha, (uint8_t *)buf, ha->nvram_base, count);
+       ha->isp_ops->read_nvram(vha, (uint8_t *)ha->nvram, ha->nvram_base,
            count);
 
-       set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags);
+       /* NVRAM settings take effect immediately. */
+       set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags);
+       qla2xxx_wake_dpc(vha);
+       qla2x00_wait_for_chip_reset(vha);
 
        return (count);
 }
@@ -167,19 +174,15 @@ qla2x00_sysfs_read_optrom(struct kobject *kobj,
                          struct bin_attribute *bin_attr,
                          char *buf, loff_t off, size_t count)
 {
-       struct scsi_qla_host *ha = shost_priv(dev_to_shost(container_of(kobj,
+       struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj,
            struct device, kobj)));
+       struct qla_hw_data *ha = vha->hw;
 
        if (ha->optrom_state != QLA_SREADING)
                return 0;
-       if (off > ha->optrom_region_size)
-               return 0;
-       if (off + count > ha->optrom_region_size)
-               count = ha->optrom_region_size - off;
-
-       memcpy(buf, &ha->optrom_buffer[off], count);
 
-       return count;
+       return memory_read_from_buffer(buf, count, &off, ha->optrom_buffer,
+                                       ha->optrom_region_size);
 }
 
 static ssize_t
@@ -187,8 +190,9 @@ qla2x00_sysfs_write_optrom(struct kobject *kobj,
                           struct bin_attribute *bin_attr,
                           char *buf, loff_t off, size_t count)
 {
-       struct scsi_qla_host *ha = shost_priv(dev_to_shost(container_of(kobj,
+       struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj,
            struct device, kobj)));
+       struct qla_hw_data *ha = vha->hw;
 
        if (ha->optrom_state != QLA_SWRITING)
                return -EINVAL;
@@ -217,8 +221,10 @@ qla2x00_sysfs_write_optrom_ctl(struct kobject *kobj,
                               struct bin_attribute *bin_attr,
                               char *buf, loff_t off, size_t count)
 {
-       struct scsi_qla_host *ha = shost_priv(dev_to_shost(container_of(kobj,
+       struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj,
            struct device, kobj)));
+       struct qla_hw_data *ha = vha->hw;
+
        uint32_t start = 0;
        uint32_t size = ha->optrom_size;
        int val, valid;
@@ -250,12 +256,6 @@ qla2x00_sysfs_write_optrom_ctl(struct kobject *kobj,
                if (ha->optrom_state != QLA_SWAITING)
                        break;
 
-               if (start & 0xfff) {
-                       qla_printk(KERN_WARNING, ha,
-                           "Invalid start region 0x%x/0x%x.\n", start, size);
-                       return -EINVAL;
-               }
-
                ha->optrom_region_start = start;
                ha->optrom_region_size = start + size > ha->optrom_size ?
                    ha->optrom_size - start : size;
@@ -276,7 +276,7 @@ qla2x00_sysfs_write_optrom_ctl(struct kobject *kobj,
                    ha->optrom_region_start, ha->optrom_region_size));
 
                memset(ha->optrom_buffer, 0, ha->optrom_region_size);
-               ha->isp_ops->read_optrom(ha, ha->optrom_buffer,
+               ha->isp_ops->read_optrom(vha, ha->optrom_buffer,
                    ha->optrom_region_start, ha->optrom_region_size);
                break;
        case 2:
@@ -306,10 +306,10 @@ qla2x00_sysfs_write_optrom_ctl(struct kobject *kobj,
                valid = 0;
                if (ha->optrom_size == OPTROM_SIZE_2300 && start == 0)
                        valid = 1;
-               else if (start == (FA_BOOT_CODE_ADDR*4) ||
-                   start == (FA_RISC_CODE_ADDR*4))
+               else if (start == (ha->flt_region_boot * 4) ||
+                   start == (ha->flt_region_fw * 4))
                        valid = 1;
-               else if (IS_QLA25XX(ha) && start == (FA_VPD_NVRAM_ADDR*4))
+               else if (IS_QLA25XX(ha) || IS_QLA81XX(ha))
                    valid = 1;
                if (!valid) {
                        qla_printk(KERN_WARNING, ha,
@@ -342,11 +342,17 @@ qla2x00_sysfs_write_optrom_ctl(struct kobject *kobj,
                if (ha->optrom_state != QLA_SWRITING)
                        break;
 
+               if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) {
+                       qla_printk(KERN_WARNING, ha,
+                           "HBA not online, failing flash update.\n");
+                       return -EAGAIN;
+               }
+
                DEBUG2(qla_printk(KERN_INFO, ha,
                    "Writing flash region -- 0x%x/0x%x.\n",
                    ha->optrom_region_start, ha->optrom_region_size));
 
-               ha->isp_ops->write_optrom(ha, ha->optrom_buffer,
+               ha->isp_ops->write_optrom(vha, ha->optrom_buffer,
                    ha->optrom_region_start, ha->optrom_region_size);
                break;
        default:
@@ -369,22 +375,17 @@ qla2x00_sysfs_read_vpd(struct kobject *kobj,
                       struct bin_attribute *bin_attr,
                       char *buf, loff_t off, size_t count)
 {
-       struct scsi_qla_host *ha = shost_priv(dev_to_shost(container_of(kobj,
+       struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj,
            struct device, kobj)));
-       int           size = ha->vpd_size;
-       char          *vpd_cache = ha->vpd;
+       struct qla_hw_data *ha = vha->hw;
 
-       if (!capable(CAP_SYS_ADMIN) || off > size || count == 0)
+       if (!capable(CAP_SYS_ADMIN))
                return 0;
-       if (off + count > size) {
-               size -= off;
-               count = size;
-       }
-
-       /* Read NVRAM data from cache. */
-       memcpy(buf, &vpd_cache[off], count);
 
-       return count;
+       if (IS_NOCACHE_VPD_TYPE(ha))
+               ha->isp_ops->read_optrom(vha, ha->vpd, ha->flt_region_vpd << 2,
+                   ha->vpd_size);
+       return memory_read_from_buffer(buf, count, &off, ha->vpd, ha->vpd_size);
 }
 
 static ssize_t
@@ -392,16 +393,38 @@ qla2x00_sysfs_write_vpd(struct kobject *kobj,
                        struct bin_attribute *bin_attr,
                        char *buf, loff_t off, size_t count)
 {
-       struct scsi_qla_host *ha = shost_priv(dev_to_shost(container_of(kobj,
+       struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj,
            struct device, kobj)));
+       struct qla_hw_data *ha = vha->hw;
+       uint8_t *tmp_data;
 
-       if (!capable(CAP_SYS_ADMIN) || off != 0 || count != ha->vpd_size)
+       if (!capable(CAP_SYS_ADMIN) || off != 0 || count != ha->vpd_size ||
+           !ha->isp_ops->write_nvram)
                return 0;
 
+       if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) {
+               qla_printk(KERN_WARNING, ha,
+                   "HBA not online, failing VPD update.\n");
+               return -EAGAIN;
+       }
+
        /* Write NVRAM. */
-       ha->isp_ops->write_nvram(ha, (uint8_t *)buf, ha->vpd_base, count);
-       ha->isp_ops->read_nvram(ha, (uint8_t *)ha->vpd, ha->vpd_base, count);
+       ha->isp_ops->write_nvram(vha, (uint8_t *)buf, ha->vpd_base, count);
+       ha->isp_ops->read_nvram(vha, (uint8_t *)ha->vpd, ha->vpd_base, count);
+
+       /* Update flash version information for 4Gb & above. */
+       if (!IS_FWI2_CAPABLE(ha))
+               goto done;
 
+       tmp_data = vmalloc(256);
+       if (!tmp_data) {
+               qla_printk(KERN_WARNING, ha,
+                   "Unable to allocate memory for VPD information update.\n");
+               goto done;
+       }
+       ha->isp_ops->get_flash_version(vha, tmp_data);
+       vfree(tmp_data);
+done:
        return count;
 }
 
@@ -420,14 +443,28 @@ qla2x00_sysfs_read_sfp(struct kobject *kobj,
                       struct bin_attribute *bin_attr,
                       char *buf, loff_t off, size_t count)
 {
-       struct scsi_qla_host *ha = shost_priv(dev_to_shost(container_of(kobj,
+       struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj,
            struct device, kobj)));
+       struct qla_hw_data *ha = vha->hw;
        uint16_t iter, addr, offset;
        int rval;
 
        if (!capable(CAP_SYS_ADMIN) || off != 0 || count != SFP_DEV_SIZE * 2)
                return 0;
 
+       if (ha->sfp_data)
+               goto do_read;
+
+       ha->sfp_data = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL,
+           &ha->sfp_data_dma);
+       if (!ha->sfp_data) {
+               qla_printk(KERN_WARNING, ha,
+                   "Unable to allocate memory for SFP read-data.\n");
+               return 0;
+       }
+
+do_read:
+       memset(ha->sfp_data, 0, SFP_BLOCK_SIZE);
        addr = 0xa0;
        for (iter = 0, offset = 0; iter < (SFP_DEV_SIZE * 2) / SFP_BLOCK_SIZE;
            iter++, offset += SFP_BLOCK_SIZE) {
@@ -437,7 +474,7 @@ qla2x00_sysfs_read_sfp(struct kobject *kobj,
                        offset = 0;
                }
 
-               rval = qla2x00_read_sfp(ha, ha->sfp_data_dma, addr, offset,
+               rval = qla2x00_read_sfp(vha, ha->sfp_data_dma, addr, offset,
                    SFP_BLOCK_SIZE);
                if (rval != QLA_SUCCESS) {
                        qla_printk(KERN_WARNING, ha,
@@ -462,6 +499,199 @@ static struct bin_attribute sysfs_sfp_attr = {
        .read = qla2x00_sysfs_read_sfp,
 };
 
+static ssize_t
+qla2x00_sysfs_write_reset(struct kobject *kobj,
+                       struct bin_attribute *bin_attr,
+                       char *buf, loff_t off, size_t count)
+{
+       struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj,
+           struct device, kobj)));
+       struct qla_hw_data *ha = vha->hw;
+       int type;
+
+       if (off != 0)
+               return 0;
+
+       type = simple_strtol(buf, NULL, 10);
+       switch (type) {
+       case 0x2025c:
+               qla_printk(KERN_INFO, ha,
+                   "Issuing ISP reset on (%ld).\n", vha->host_no);
+
+               scsi_block_requests(vha->host);
+               set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags);
+               qla2xxx_wake_dpc(vha);
+               qla2x00_wait_for_chip_reset(vha);
+               scsi_unblock_requests(vha->host);
+               break;
+       case 0x2025d:
+               if (!IS_QLA81XX(ha))
+                       break;
+
+               qla_printk(KERN_INFO, ha,
+                   "Issuing MPI reset on (%ld).\n", vha->host_no);
+
+               /* Make sure FC side is not in reset */
+               qla2x00_wait_for_hba_online(vha);
+
+               /* Issue MPI reset */
+               scsi_block_requests(vha->host);
+               if (qla81xx_restart_mpi_firmware(vha) != QLA_SUCCESS)
+                       qla_printk(KERN_WARNING, ha,
+                           "MPI reset failed on (%ld).\n", vha->host_no);
+               scsi_unblock_requests(vha->host);
+               break;
+       }
+       return count;
+}
+
+static struct bin_attribute sysfs_reset_attr = {
+       .attr = {
+               .name = "reset",
+               .mode = S_IWUSR,
+       },
+       .size = 0,
+       .write = qla2x00_sysfs_write_reset,
+};
+
+static ssize_t
+qla2x00_sysfs_write_edc(struct kobject *kobj,
+                       struct bin_attribute *bin_attr,
+                       char *buf, loff_t off, size_t count)
+{
+       struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj,
+           struct device, kobj)));
+       struct qla_hw_data *ha = vha->hw;
+       uint16_t dev, adr, opt, len;
+       int rval;
+
+       ha->edc_data_len = 0;
+
+       if (!capable(CAP_SYS_ADMIN) || off != 0 || count < 8)
+               return 0;
+
+       if (!ha->edc_data) {
+               ha->edc_data = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL,
+                   &ha->edc_data_dma);
+               if (!ha->edc_data) {
+                       DEBUG2(qla_printk(KERN_INFO, ha,
+                           "Unable to allocate memory for EDC write.\n"));
+                       return 0;
+               }
+       }
+
+       dev = le16_to_cpup((void *)&buf[0]);
+       adr = le16_to_cpup((void *)&buf[2]);
+       opt = le16_to_cpup((void *)&buf[4]);
+       len = le16_to_cpup((void *)&buf[6]);
+
+       if (!(opt & BIT_0))
+               if (len == 0 || len > DMA_POOL_SIZE || len > count - 8)
+                       return -EINVAL;
+
+       memcpy(ha->edc_data, &buf[8], len);
+
+       rval = qla2x00_write_edc(vha, dev, adr, ha->edc_data_dma,
+           ha->edc_data, len, opt);
+       if (rval != QLA_SUCCESS) {
+               DEBUG2(qla_printk(KERN_INFO, ha,
+                   "Unable to write EDC (%x) %02x:%02x:%04x:%02x:%02x.\n",
+                   rval, dev, adr, opt, len, *buf));
+               return 0;
+       }
+
+       return count;
+}
+
+static struct bin_attribute sysfs_edc_attr = {
+       .attr = {
+               .name = "edc",
+               .mode = S_IWUSR,
+       },
+       .size = 0,
+       .write = qla2x00_sysfs_write_edc,
+};
+
+static ssize_t
+qla2x00_sysfs_write_edc_status(struct kobject *kobj,
+                       struct bin_attribute *bin_attr,
+                       char *buf, loff_t off, size_t count)
+{
+       struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj,
+           struct device, kobj)));
+       struct qla_hw_data *ha = vha->hw;
+       uint16_t dev, adr, opt, len;
+       int rval;
+
+       ha->edc_data_len = 0;
+
+       if (!capable(CAP_SYS_ADMIN) || off != 0 || count < 8)
+               return 0;
+
+       if (!ha->edc_data) {
+               ha->edc_data = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL,
+                   &ha->edc_data_dma);
+               if (!ha->edc_data) {
+                       DEBUG2(qla_printk(KERN_INFO, ha,
+                           "Unable to allocate memory for EDC status.\n"));
+                       return 0;
+               }
+       }
+
+       dev = le16_to_cpup((void *)&buf[0]);
+       adr = le16_to_cpup((void *)&buf[2]);
+       opt = le16_to_cpup((void *)&buf[4]);
+       len = le16_to_cpup((void *)&buf[6]);
+
+       if (!(opt & BIT_0))
+               if (len == 0 || len > DMA_POOL_SIZE)
+                       return -EINVAL;
+
+       memset(ha->edc_data, 0, len);
+       rval = qla2x00_read_edc(vha, dev, adr, ha->edc_data_dma,
+           ha->edc_data, len, opt);
+       if (rval != QLA_SUCCESS) {
+               DEBUG2(qla_printk(KERN_INFO, ha,
+                   "Unable to write EDC status (%x) %02x:%02x:%04x:%02x.\n",
+                   rval, dev, adr, opt, len));
+               return 0;
+       }
+
+       ha->edc_data_len = len;
+
+       return count;
+}
+
+static ssize_t
+qla2x00_sysfs_read_edc_status(struct kobject *kobj,
+                          struct bin_attribute *bin_attr,
+                          char *buf, loff_t off, size_t count)
+{
+       struct scsi_qla_host *vha = shost_priv(dev_to_shost(container_of(kobj,
+           struct device, kobj)));
+       struct qla_hw_data *ha = vha->hw;
+
+       if (!capable(CAP_SYS_ADMIN) || off != 0 || count == 0)
+               return 0;
+
+       if (!ha->edc_data || ha->edc_data_len == 0 || ha->edc_data_len > count)
+               return -EINVAL;
+
+       memcpy(buf, ha->edc_data, ha->edc_data_len);
+
+       return ha->edc_data_len;
+}
+
+static struct bin_attribute sysfs_edc_status_attr = {
+       .attr = {
+               .name = "edc_status",
+               .mode = S_IRUSR | S_IWUSR,
+       },
+       .size = 0,
+       .write = qla2x00_sysfs_write_edc_status,
+       .read = qla2x00_sysfs_read_edc_status,
+};
+
 static struct sysfs_entry {
        char *name;
        struct bin_attribute *attr;
@@ -473,73 +703,88 @@ static struct sysfs_entry {
        { "optrom_ctl", &sysfs_optrom_ctl_attr, },
        { "vpd", &sysfs_vpd_attr, 1 },
        { "sfp", &sysfs_sfp_attr, 1 },
+       { "reset", &sysfs_reset_attr, },
+       { "edc", &sysfs_edc_attr, 2 },
+       { "edc_status", &sysfs_edc_status_attr, 2 },
        { NULL },
 };
 
 void
-qla2x00_alloc_sysfs_attr(scsi_qla_host_t *ha)
+qla2x00_alloc_sysfs_attr(scsi_qla_host_t *vha)
 {
-       struct Scsi_Host *host = ha->host;
+       struct Scsi_Host *host = vha->host;
        struct sysfs_entry *iter;
        int ret;
 
        for (iter = bin_file_entries; iter->name; iter++) {
-               if (iter->is4GBp_only && !IS_FWI2_CAPABLE(ha))
+               if (iter->is4GBp_only && !IS_FWI2_CAPABLE(vha->hw))
+                       continue;
+               if (iter->is4GBp_only == 2 && !IS_QLA25XX(vha->hw))
                        continue;
 
                ret = sysfs_create_bin_file(&host->shost_gendev.kobj,
                    iter->attr);
                if (ret)
-                       qla_printk(KERN_INFO, ha,
+                       qla_printk(KERN_INFO, vha->hw,
                            "Unable to create sysfs %s binary attribute "
                            "(%d).\n", iter->name, ret);
        }
 }
 
 void
-qla2x00_free_sysfs_attr(scsi_qla_host_t *ha)
+qla2x00_free_sysfs_attr(scsi_qla_host_t *vha)
 {
-       struct Scsi_Host *host = ha->host;
+       struct Scsi_Host *host = vha->host;
        struct sysfs_entry *iter;
+       struct qla_hw_data *ha = vha->hw;
 
        for (iter = bin_file_entries; iter->name; iter++) {
                if (iter->is4GBp_only && !IS_FWI2_CAPABLE(ha))
                        continue;
+               if (iter->is4GBp_only == 2 && !IS_QLA25XX(ha))
+                       continue;
 
                sysfs_remove_bin_file(&host->shost_gendev.kobj,
                    iter->attr);
        }
 
        if (ha->beacon_blink_led == 1)
-               ha->isp_ops->beacon_off(ha);
+               ha->isp_ops->beacon_off(vha);
 }
 
 /* Scsi_Host attributes. */
 
 static ssize_t
-qla2x00_drvr_version_show(struct class_device *cdev, char *buf)
+qla2x00_drvr_version_show(struct device *dev,
+                         struct device_attribute *attr, char *buf)
 {
        return snprintf(buf, PAGE_SIZE, "%s\n", qla2x00_version_str);
 }
 
 static ssize_t
-qla2x00_fw_version_show(struct class_device *cdev, char *buf)
+qla2x00_fw_version_show(struct device *dev,
+                       struct device_attribute *attr, char *buf)
 {
-       scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev));
-       char fw_str[30];
+       scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
+       struct qla_hw_data *ha = vha->hw;
+       char fw_str[128];
 
        return snprintf(buf, PAGE_SIZE, "%s\n",
-           ha->isp_ops->fw_version_str(ha, fw_str));
+           ha->isp_ops->fw_version_str(vha, fw_str));
 }
 
 static ssize_t
-qla2x00_serial_num_show(struct class_device *cdev, char *buf)
+qla2x00_serial_num_show(struct device *dev, struct device_attribute *attr,
+                       char *buf)
 {
-       scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev));
+       scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
+       struct qla_hw_data *ha = vha->hw;
        uint32_t sn;
 
-       if (IS_FWI2_CAPABLE(ha))
-               return snprintf(buf, PAGE_SIZE, "\n");
+       if (IS_FWI2_CAPABLE(ha)) {
+               qla2xxx_get_vpd_field(vha, "SN", buf, PAGE_SIZE);
+               return snprintf(buf, PAGE_SIZE, "%s\n", buf);
+       }
 
        sn = ((ha->serial0 & 0x1f) << 16) | (ha->serial2 << 8) | ha->serial1;
        return snprintf(buf, PAGE_SIZE, "%c%05d\n", 'A' + sn / 100000,
@@ -547,58 +792,66 @@ qla2x00_serial_num_show(struct class_device *cdev, char *buf)
 }
 
 static ssize_t
-qla2x00_isp_name_show(struct class_device *cdev, char *buf)
+qla2x00_isp_name_show(struct device *dev, struct device_attribute *attr,
+                     char *buf)
 {
-       scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev));
-       return snprintf(buf, PAGE_SIZE, "ISP%04X\n", ha->pdev->device);
+       scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
+       return snprintf(buf, PAGE_SIZE, "ISP%04X\n", vha->hw->pdev->device);
 }
 
 static ssize_t
-qla2x00_isp_id_show(struct class_device *cdev, char *buf)
+qla2x00_isp_id_show(struct device *dev, struct device_attribute *attr,
+                   char *buf)
 {
-       scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev));
+       scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
+       struct qla_hw_data *ha = vha->hw;
        return snprintf(buf, PAGE_SIZE, "%04x %04x %04x %04x\n",
            ha->product_id[0], ha->product_id[1], ha->product_id[2],
            ha->product_id[3]);
 }
 
 static ssize_t
-qla2x00_model_name_show(struct class_device *cdev, char *buf)
+qla2x00_model_name_show(struct device *dev, struct device_attribute *attr,
+                       char *buf)
 {
-       scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev));
-       return snprintf(buf, PAGE_SIZE, "%s\n", ha->model_number);
+       scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
+       return snprintf(buf, PAGE_SIZE, "%s\n", vha->hw->model_number);
 }
 
 static ssize_t
-qla2x00_model_desc_show(struct class_device *cdev, char *buf)
+qla2x00_model_desc_show(struct device *dev, struct device_attribute *attr,
+                       char *buf)
 {
-       scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev));
+       scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
        return snprintf(buf, PAGE_SIZE, "%s\n",
-           ha->model_desc ? ha->model_desc: "");
+           vha->hw->model_desc ? vha->hw->model_desc : "");
 }
 
 static ssize_t
-qla2x00_pci_info_show(struct class_device *cdev, char *buf)
+qla2x00_pci_info_show(struct device *dev, struct device_attribute *attr,
+                     char *buf)
 {
-       scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev));
+       scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
        char pci_info[30];
 
        return snprintf(buf, PAGE_SIZE, "%s\n",
-           ha->isp_ops->pci_info_str(ha, pci_info));
+           vha->hw->isp_ops->pci_info_str(vha, pci_info));
 }
 
 static ssize_t
-qla2x00_state_show(struct class_device *cdev, char *buf)
+qla2x00_link_state_show(struct device *dev, struct device_attribute *attr,
+                       char *buf)
 {
-       scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev));
+       scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
+       struct qla_hw_data *ha = vha->hw;
        int len = 0;
 
-       if (atomic_read(&ha->loop_state) == LOOP_DOWN ||
-           atomic_read(&ha->loop_state) == LOOP_DEAD)
+       if (atomic_read(&vha->loop_state) == LOOP_DOWN ||
+           atomic_read(&vha->loop_state) == LOOP_DEAD)
                len = snprintf(buf, PAGE_SIZE, "Link Down\n");
-       else if (atomic_read(&ha->loop_state) != LOOP_READY ||
-           test_bit(ABORT_ISP_ACTIVE, &ha->dpc_flags) ||
-           test_bit(ISP_ABORT_NEEDED, &ha->dpc_flags))
+       else if (atomic_read(&vha->loop_state) != LOOP_READY ||
+           test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags) ||
+           test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags))
                len = snprintf(buf, PAGE_SIZE, "Unknown Link State\n");
        else {
                len = snprintf(buf, PAGE_SIZE, "Link Up - ");
@@ -626,12 +879,13 @@ qla2x00_state_show(struct class_device *cdev, char *buf)
 }
 
 static ssize_t
-qla2x00_zio_show(struct class_device *cdev, char *buf)
+qla2x00_zio_show(struct device *dev, struct device_attribute *attr,
+                char *buf)
 {
-       scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev));
+       scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
        int len = 0;
 
-       switch (ha->zio_mode) {
+       switch (vha->hw->zio_mode) {
        case QLA_ZIO_MODE_6:
                len += snprintf(buf + len, PAGE_SIZE-len, "Mode 6\n");
                break;
@@ -643,9 +897,11 @@ qla2x00_zio_show(struct class_device *cdev, char *buf)
 }
 
 static ssize_t
-qla2x00_zio_store(struct class_device *cdev, const char *buf, size_t count)
+qla2x00_zio_store(struct device *dev, struct device_attribute *attr,
+                 const char *buf, size_t count)
 {
-       scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev));
+       scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
+       struct qla_hw_data *ha = vha->hw;
        int val = 0;
        uint16_t zio_mode;
 
@@ -663,24 +919,25 @@ qla2x00_zio_store(struct class_device *cdev, const char *buf, size_t count)
        /* Update per-hba values and queue a reset. */
        if (zio_mode != QLA_ZIO_DISABLED || ha->zio_mode != QLA_ZIO_DISABLED) {
                ha->zio_mode = zio_mode;
-               set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags);
+               set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags);
        }
        return strlen(buf);
 }
 
 static ssize_t
-qla2x00_zio_timer_show(struct class_device *cdev, char *buf)
+qla2x00_zio_timer_show(struct device *dev, struct device_attribute *attr,
+                      char *buf)
 {
-       scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev));
+       scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
 
-       return snprintf(buf, PAGE_SIZE, "%d us\n", ha->zio_timer * 100);
+       return snprintf(buf, PAGE_SIZE, "%d us\n", vha->hw->zio_timer * 100);
 }
 
 static ssize_t
-qla2x00_zio_timer_store(struct class_device *cdev, const char *buf,
-    size_t count)
+qla2x00_zio_timer_store(struct device *dev, struct device_attribute *attr,
+                       const char *buf, size_t count)
 {
-       scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev));
+       scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
        int val = 0;
        uint16_t zio_timer;
 
@@ -690,18 +947,19 @@ qla2x00_zio_timer_store(struct class_device *cdev, const char *buf,
                return -ERANGE;
 
        zio_timer = (uint16_t)(val / 100);
-       ha->zio_timer = zio_timer;
+       vha->hw->zio_timer = zio_timer;
 
        return strlen(buf);
 }
 
 static ssize_t
-qla2x00_beacon_show(struct class_device *cdev, char *buf)
+qla2x00_beacon_show(struct device *dev, struct device_attribute *attr,
+                   char *buf)
 {
-       scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev));
+       scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
        int len = 0;
 
-       if (ha->beacon_blink_led)
+       if (vha->hw->beacon_blink_led)
                len += snprintf(buf + len, PAGE_SIZE-len, "Enabled\n");
        else
                len += snprintf(buf + len, PAGE_SIZE-len, "Disabled\n");
@@ -709,17 +967,18 @@ qla2x00_beacon_show(struct class_device *cdev, char *buf)
 }
 
 static ssize_t
-qla2x00_beacon_store(struct class_device *cdev, const char *buf,
-    size_t count)
+qla2x00_beacon_store(struct device *dev, struct device_attribute *attr,
+                    const char *buf, size_t count)
 {
-       scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev));
+       scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
+       struct qla_hw_data *ha = vha->hw;
        int val = 0;
        int rval;
 
        if (IS_QLA2100(ha) || IS_QLA2200(ha))
                return -EPERM;
 
-       if (test_bit(ABORT_ISP_ACTIVE, &ha->dpc_flags)) {
+       if (test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags)) {
                qla_printk(KERN_WARNING, ha,
                    "Abort ISP active -- ignoring beacon request.\n");
                return -EBUSY;
@@ -729,9 +988,9 @@ qla2x00_beacon_store(struct class_device *cdev, const char *buf,
                return -EINVAL;
 
        if (val)
-               rval = ha->isp_ops->beacon_on(ha);
+               rval = ha->isp_ops->beacon_on(vha);
        else
-               rval = ha->isp_ops->beacon_off(ha);
+               rval = ha->isp_ops->beacon_off(vha);
 
        if (rval != QLA_SUCCESS)
                count = 0;
@@ -740,84 +999,177 @@ qla2x00_beacon_store(struct class_device *cdev, const char *buf,
 }
 
 static ssize_t
-qla2x00_optrom_bios_version_show(struct class_device *cdev, char *buf)
+qla2x00_optrom_bios_version_show(struct device *dev,
+                                struct device_attribute *attr, char *buf)
 {
-       scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev));
-
+       scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
+       struct qla_hw_data *ha = vha->hw;
        return snprintf(buf, PAGE_SIZE, "%d.%02d\n", ha->bios_revision[1],
            ha->bios_revision[0]);
 }
 
 static ssize_t
-qla2x00_optrom_efi_version_show(struct class_device *cdev, char *buf)
+qla2x00_optrom_efi_version_show(struct device *dev,
+                               struct device_attribute *attr, char *buf)
 {
-       scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev));
-
+       scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
+       struct qla_hw_data *ha = vha->hw;
        return snprintf(buf, PAGE_SIZE, "%d.%02d\n", ha->efi_revision[1],
            ha->efi_revision[0]);
 }
 
 static ssize_t
-qla2x00_optrom_fcode_version_show(struct class_device *cdev, char *buf)
+qla2x00_optrom_fcode_version_show(struct device *dev,
+                                 struct device_attribute *attr, char *buf)
 {
-       scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev));
-
+       scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
+       struct qla_hw_data *ha = vha->hw;
        return snprintf(buf, PAGE_SIZE, "%d.%02d\n", ha->fcode_revision[1],
            ha->fcode_revision[0]);
 }
 
 static ssize_t
-qla2x00_optrom_fw_version_show(struct class_device *cdev, char *buf)
+qla2x00_optrom_fw_version_show(struct device *dev,
+                              struct device_attribute *attr, char *buf)
 {
-       scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev));
-
+       scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
+       struct qla_hw_data *ha = vha->hw;
        return snprintf(buf, PAGE_SIZE, "%d.%02d.%02d %d\n",
            ha->fw_revision[0], ha->fw_revision[1], ha->fw_revision[2],
            ha->fw_revision[3]);
 }
 
-static CLASS_DEVICE_ATTR(driver_version, S_IRUGO, qla2x00_drvr_version_show,
-       NULL);
-static CLASS_DEVICE_ATTR(fw_version, S_IRUGO, qla2x00_fw_version_show, NULL);
-static CLASS_DEVICE_ATTR(serial_num, S_IRUGO, qla2x00_serial_num_show, NULL);
-static CLASS_DEVICE_ATTR(isp_name, S_IRUGO, qla2x00_isp_name_show, NULL);
-static CLASS_DEVICE_ATTR(isp_id, S_IRUGO, qla2x00_isp_id_show, NULL);
-static CLASS_DEVICE_ATTR(model_name, S_IRUGO, qla2x00_model_name_show, NULL);
-static CLASS_DEVICE_ATTR(model_desc, S_IRUGO, qla2x00_model_desc_show, NULL);
-static CLASS_DEVICE_ATTR(pci_info, S_IRUGO, qla2x00_pci_info_show, NULL);
-static CLASS_DEVICE_ATTR(state, S_IRUGO, qla2x00_state_show, NULL);
-static CLASS_DEVICE_ATTR(zio, S_IRUGO | S_IWUSR, qla2x00_zio_show,
-    qla2x00_zio_store);
-static CLASS_DEVICE_ATTR(zio_timer, S_IRUGO | S_IWUSR, qla2x00_zio_timer_show,
-    qla2x00_zio_timer_store);
-static CLASS_DEVICE_ATTR(beacon, S_IRUGO | S_IWUSR, qla2x00_beacon_show,
-    qla2x00_beacon_store);
-static CLASS_DEVICE_ATTR(optrom_bios_version, S_IRUGO,
-    qla2x00_optrom_bios_version_show, NULL);
-static CLASS_DEVICE_ATTR(optrom_efi_version, S_IRUGO,
-    qla2x00_optrom_efi_version_show, NULL);
-static CLASS_DEVICE_ATTR(optrom_fcode_version, S_IRUGO,
-    qla2x00_optrom_fcode_version_show, NULL);
-static CLASS_DEVICE_ATTR(optrom_fw_version, S_IRUGO,
-    qla2x00_optrom_fw_version_show, NULL);
-
-struct class_device_attribute *qla2x00_host_attrs[] = {
-       &class_device_attr_driver_version,
-       &class_device_attr_fw_version,
-       &class_device_attr_serial_num,
-       &class_device_attr_isp_name,
-       &class_device_attr_isp_id,
-       &class_device_attr_model_name,
-       &class_device_attr_model_desc,
-       &class_device_attr_pci_info,
-       &class_device_attr_state,
-       &class_device_attr_zio,
-       &class_device_attr_zio_timer,
-       &class_device_attr_beacon,
-       &class_device_attr_optrom_bios_version,
-       &class_device_attr_optrom_efi_version,
-       &class_device_attr_optrom_fcode_version,
-       &class_device_attr_optrom_fw_version,
+static ssize_t
+qla2x00_total_isp_aborts_show(struct device *dev,
+                             struct device_attribute *attr, char *buf)
+{
+       scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
+       struct qla_hw_data *ha = vha->hw;
+       return snprintf(buf, PAGE_SIZE, "%d\n",
+           ha->qla_stats.total_isp_aborts);
+}
+
+static ssize_t
+qla2x00_mpi_version_show(struct device *dev, struct device_attribute *attr,
+    char *buf)
+{
+       scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
+       struct qla_hw_data *ha = vha->hw;
+
+       if (!IS_QLA81XX(ha))
+               return snprintf(buf, PAGE_SIZE, "\n");
+
+       return snprintf(buf, PAGE_SIZE, "%d.%02d.%02d (%x)\n",
+           ha->mpi_version[0], ha->mpi_version[1], ha->mpi_version[2],
+           ha->mpi_capabilities);
+}
+
+static ssize_t
+qla2x00_phy_version_show(struct device *dev, struct device_attribute *attr,
+    char *buf)
+{
+       scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
+       struct qla_hw_data *ha = vha->hw;
+
+       if (!IS_QLA81XX(ha))
+               return snprintf(buf, PAGE_SIZE, "\n");
+
+       return snprintf(buf, PAGE_SIZE, "%d.%02d.%02d\n",
+           ha->phy_version[0], ha->phy_version[1], ha->phy_version[2]);
+}
+
+static ssize_t
+qla2x00_flash_block_size_show(struct device *dev,
+                             struct device_attribute *attr, char *buf)
+{
+       scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
+       struct qla_hw_data *ha = vha->hw;
+
+       return snprintf(buf, PAGE_SIZE, "0x%x\n", ha->fdt_block_size);
+}
+
+static ssize_t
+qla2x00_vlan_id_show(struct device *dev, struct device_attribute *attr,
+    char *buf)
+{
+       scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
+
+       if (!IS_QLA81XX(vha->hw))
+               return snprintf(buf, PAGE_SIZE, "\n");
+
+       return snprintf(buf, PAGE_SIZE, "%d\n", vha->fcoe_vlan_id);
+}
+
+static ssize_t
+qla2x00_vn_port_mac_address_show(struct device *dev,
+    struct device_attribute *attr, char *buf)
+{
+       scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
+
+       if (!IS_QLA81XX(vha->hw))
+               return snprintf(buf, PAGE_SIZE, "\n");
+
+       return snprintf(buf, PAGE_SIZE, "%02x:%02x:%02x:%02x:%02x:%02x\n",
+           vha->fcoe_vn_port_mac[5], vha->fcoe_vn_port_mac[4],
+           vha->fcoe_vn_port_mac[3], vha->fcoe_vn_port_mac[2],
+           vha->fcoe_vn_port_mac[1], vha->fcoe_vn_port_mac[0]);
+}
+
+static DEVICE_ATTR(driver_version, S_IRUGO, qla2x00_drvr_version_show, NULL);
+static DEVICE_ATTR(fw_version, S_IRUGO, qla2x00_fw_version_show, NULL);
+static DEVICE_ATTR(serial_num, S_IRUGO, qla2x00_serial_num_show, NULL);
+static DEVICE_ATTR(isp_name, S_IRUGO, qla2x00_isp_name_show, NULL);
+static DEVICE_ATTR(isp_id, S_IRUGO, qla2x00_isp_id_show, NULL);
+static DEVICE_ATTR(model_name, S_IRUGO, qla2x00_model_name_show, NULL);
+static DEVICE_ATTR(model_desc, S_IRUGO, qla2x00_model_desc_show, NULL);
+static DEVICE_ATTR(pci_info, S_IRUGO, qla2x00_pci_info_show, NULL);
+static DEVICE_ATTR(link_state, S_IRUGO, qla2x00_link_state_show, NULL);
+static DEVICE_ATTR(zio, S_IRUGO | S_IWUSR, qla2x00_zio_show, qla2x00_zio_store);
+static DEVICE_ATTR(zio_timer, S_IRUGO | S_IWUSR, qla2x00_zio_timer_show,
+                  qla2x00_zio_timer_store);
+static DEVICE_ATTR(beacon, S_IRUGO | S_IWUSR, qla2x00_beacon_show,
+                  qla2x00_beacon_store);
+static DEVICE_ATTR(optrom_bios_version, S_IRUGO,
+                  qla2x00_optrom_bios_version_show, NULL);
+static DEVICE_ATTR(optrom_efi_version, S_IRUGO,
+                  qla2x00_optrom_efi_version_show, NULL);
+static DEVICE_ATTR(optrom_fcode_version, S_IRUGO,
+                  qla2x00_optrom_fcode_version_show, NULL);
+static DEVICE_ATTR(optrom_fw_version, S_IRUGO, qla2x00_optrom_fw_version_show,
+                  NULL);
+static DEVICE_ATTR(total_isp_aborts, S_IRUGO, qla2x00_total_isp_aborts_show,
+                  NULL);
+static DEVICE_ATTR(mpi_version, S_IRUGO, qla2x00_mpi_version_show, NULL);
+static DEVICE_ATTR(phy_version, S_IRUGO, qla2x00_phy_version_show, NULL);
+static DEVICE_ATTR(flash_block_size, S_IRUGO, qla2x00_flash_block_size_show,
+                  NULL);
+static DEVICE_ATTR(vlan_id, S_IRUGO, qla2x00_vlan_id_show, NULL);
+static DEVICE_ATTR(vn_port_mac_address, S_IRUGO,
+                  qla2x00_vn_port_mac_address_show, NULL);
+
+struct device_attribute *qla2x00_host_attrs[] = {
+       &dev_attr_driver_version,
+       &dev_attr_fw_version,
+       &dev_attr_serial_num,
+       &dev_attr_isp_name,
+       &dev_attr_isp_id,
+       &dev_attr_model_name,
+       &dev_attr_model_desc,
+       &dev_attr_pci_info,
+       &dev_attr_link_state,
+       &dev_attr_zio,
+       &dev_attr_zio_timer,
+       &dev_attr_beacon,
+       &dev_attr_optrom_bios_version,
+       &dev_attr_optrom_efi_version,
+       &dev_attr_optrom_fcode_version,
+       &dev_attr_optrom_fw_version,
+       &dev_attr_total_isp_aborts,
+       &dev_attr_mpi_version,
+       &dev_attr_phy_version,
+       &dev_attr_flash_block_size,
+       &dev_attr_vlan_id,
+       &dev_attr_vn_port_mac_address,
        NULL,
 };
 
@@ -826,27 +1178,34 @@ struct class_device_attribute *qla2x00_host_attrs[] = {
 static void
 qla2x00_get_host_port_id(struct Scsi_Host *shost)
 {
-       scsi_qla_host_t *ha = shost_priv(shost);
+       scsi_qla_host_t *vha = shost_priv(shost);
 
-       fc_host_port_id(shost) = ha->d_id.b.domain << 16 |
-           ha->d_id.b.area << 8 | ha->d_id.b.al_pa;
+       fc_host_port_id(shost) = vha->d_id.b.domain << 16 |
+           vha->d_id.b.area << 8 | vha->d_id.b.al_pa;
 }
 
 static void
 qla2x00_get_host_speed(struct Scsi_Host *shost)
 {
-       scsi_qla_host_t *ha = shost_priv(shost);
-       uint32_t speed = 0;
+       struct qla_hw_data *ha = ((struct scsi_qla_host *)
+                                       (shost_priv(shost)))->hw;
+       u32 speed = FC_PORTSPEED_UNKNOWN;
 
        switch (ha->link_data_rate) {
        case PORT_SPEED_1GB:
-               speed = 1;
+               speed = FC_PORTSPEED_1GBIT;
                break;
        case PORT_SPEED_2GB:
-               speed = 2;
+               speed = FC_PORTSPEED_2GBIT;
                break;
        case PORT_SPEED_4GB:
-               speed = 4;
+               speed = FC_PORTSPEED_4GBIT;
+               break;
+       case PORT_SPEED_8GB:
+               speed = FC_PORTSPEED_8GBIT;
+               break;
+       case PORT_SPEED_10GB:
+               speed = FC_PORTSPEED_10GBIT;
                break;
        }
        fc_host_speed(shost) = speed;
@@ -855,10 +1214,14 @@ qla2x00_get_host_speed(struct Scsi_Host *shost)
 static void
 qla2x00_get_host_port_type(struct Scsi_Host *shost)
 {
-       scsi_qla_host_t *ha = shost_priv(shost);
+       scsi_qla_host_t *vha = shost_priv(shost);
        uint32_t port_type = FC_PORTTYPE_UNKNOWN;
 
-       switch (ha->current_topology) {
+       if (vha->vp_idx) {
+               fc_host_port_type(shost) = FC_PORTTYPE_NPIV;
+               return;
+       }
+       switch (vha->hw->current_topology) {
        case ISP_CFG_NL:
                port_type = FC_PORTTYPE_LPORT;
                break;
@@ -879,12 +1242,13 @@ static void
 qla2x00_get_starget_node_name(struct scsi_target *starget)
 {
        struct Scsi_Host *host = dev_to_shost(starget->dev.parent);
-       scsi_qla_host_t *ha = shost_priv(host);
+       scsi_qla_host_t *vha = shost_priv(host);
        fc_port_t *fcport;
        u64 node_name = 0;
 
-       list_for_each_entry(fcport, &ha->fcports, list) {
-               if (starget->id == fcport->os_target_id) {
+       list_for_each_entry(fcport, &vha->vp_fcports, list) {
+               if (fcport->rport &&
+                   starget->id == fcport->rport->scsi_target_id) {
                        node_name = wwn_to_u64(fcport->node_name);
                        break;
                }
@@ -897,12 +1261,13 @@ static void
 qla2x00_get_starget_port_name(struct scsi_target *starget)
 {
        struct Scsi_Host *host = dev_to_shost(starget->dev.parent);
-       scsi_qla_host_t *ha = shost_priv(host);
+       scsi_qla_host_t *vha = shost_priv(host);
        fc_port_t *fcport;
        u64 port_name = 0;
 
-       list_for_each_entry(fcport, &ha->fcports, list) {
-               if (starget->id == fcport->os_target_id) {
+       list_for_each_entry(fcport, &vha->vp_fcports, list) {
+               if (fcport->rport &&
+                   starget->id == fcport->rport->scsi_target_id) {
                        port_name = wwn_to_u64(fcport->port_name);
                        break;
                }
@@ -915,12 +1280,13 @@ static void
 qla2x00_get_starget_port_id(struct scsi_target *starget)
 {
        struct Scsi_Host *host = dev_to_shost(starget->dev.parent);
-       scsi_qla_host_t *ha = shost_priv(host);
+       scsi_qla_host_t *vha = shost_priv(host);
        fc_port_t *fcport;
        uint32_t port_id = ~0U;
 
-       list_for_each_entry(fcport, &ha->fcports, list) {
-               if (starget->id == fcport->os_target_id) {
+       list_for_each_entry(fcport, &vha->vp_fcports, list) {
+               if (fcport->rport &&
+                   starget->id == fcport->rport->scsi_target_id) {
                        port_id = fcport->d_id.b.domain << 16 |
                            fcport->d_id.b.area << 8 | fcport->d_id.b.al_pa;
                        break;
@@ -931,41 +1297,77 @@ qla2x00_get_starget_port_id(struct scsi_target *starget)
 }
 
 static void
-qla2x00_get_rport_loss_tmo(struct fc_rport *rport)
+qla2x00_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout)
 {
-       struct Scsi_Host *host = rport_to_shost(rport);
-       scsi_qla_host_t *ha = shost_priv(host);
-
-       rport->dev_loss_tmo = ha->port_down_retry_count + 5;
+       if (timeout)
+               rport->dev_loss_tmo = timeout;
+       else
+               rport->dev_loss_tmo = 1;
 }
 
 static void
-qla2x00_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout)
+qla2x00_dev_loss_tmo_callbk(struct fc_rport *rport)
 {
        struct Scsi_Host *host = rport_to_shost(rport);
-       scsi_qla_host_t *ha = shost_priv(host);
+       fc_port_t *fcport = *(fc_port_t **)rport->dd_data;
 
-       if (timeout)
-               ha->port_down_retry_count = timeout;
+       if (!fcport)
+               return;
+
+       if (unlikely(pci_channel_offline(fcport->vha->hw->pdev)))
+               qla2x00_abort_all_cmds(fcport->vha, DID_NO_CONNECT << 16);
        else
-               ha->port_down_retry_count = 1;
+               qla2x00_abort_fcport_cmds(fcport);
+
+       /*
+        * Transport has effectively 'deleted' the rport, clear
+        * all local references.
+        */
+       spin_lock_irq(host->host_lock);
+       fcport->rport = NULL;
+       *((fc_port_t **)rport->dd_data) = NULL;
+       spin_unlock_irq(host->host_lock);
+}
+
+static void
+qla2x00_terminate_rport_io(struct fc_rport *rport)
+{
+       fc_port_t *fcport = *(fc_port_t **)rport->dd_data;
 
-       rport->dev_loss_tmo = ha->port_down_retry_count + 5;
+       if (!fcport)
+               return;
+
+       if (unlikely(pci_channel_offline(fcport->vha->hw->pdev))) {
+               qla2x00_abort_all_cmds(fcport->vha, DID_NO_CONNECT << 16);
+               return;
+       }
+       /*
+        * At this point all fcport's software-states are cleared.  Perform any
+        * final cleanup of firmware resources (PCBs and XCBs).
+        */
+       if (fcport->loop_id != FC_NO_LOOP_ID)
+               fcport->vha->hw->isp_ops->fabric_logout(fcport->vha,
+                       fcport->loop_id, fcport->d_id.b.domain,
+                       fcport->d_id.b.area, fcport->d_id.b.al_pa);
+
+       qla2x00_abort_fcport_cmds(fcport);
 }
 
 static int
 qla2x00_issue_lip(struct Scsi_Host *shost)
 {
-       scsi_qla_host_t *ha = shost_priv(shost);
+       scsi_qla_host_t *vha = shost_priv(shost);
 
-       qla2x00_loop_reset(ha);
+       qla2x00_loop_reset(vha);
        return 0;
 }
 
 static struct fc_host_statistics *
 qla2x00_get_fc_host_stats(struct Scsi_Host *shost)
 {
-       scsi_qla_host_t *ha = shost_priv(shost);
+       scsi_qla_host_t *vha = shost_priv(shost);
+       struct qla_hw_data *ha = vha->hw;
+       struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev);
        int rval;
        struct link_statistics *stats;
        dma_addr_t stats_dma;
@@ -977,21 +1379,21 @@ qla2x00_get_fc_host_stats(struct Scsi_Host *shost)
        stats = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &stats_dma);
        if (stats == NULL) {
                DEBUG2_3_11(printk("%s(%ld): Failed to allocate memory.\n",
-                   __func__, ha->host_no));
+                   __func__, base_vha->host_no));
                goto done;
        }
        memset(stats, 0, DMA_POOL_SIZE);
 
        rval = QLA_FUNCTION_FAILED;
        if (IS_FWI2_CAPABLE(ha)) {
-               rval = qla24xx_get_isp_stats(ha, stats, stats_dma);
-       } else if (atomic_read(&ha->loop_state) == LOOP_READY &&
-                   !test_bit(ABORT_ISP_ACTIVE, &ha->dpc_flags) &&
-                   !test_bit(ISP_ABORT_NEEDED, &ha->dpc_flags) &&
+               rval = qla24xx_get_isp_stats(base_vha, stats, stats_dma);
+       } else if (atomic_read(&base_vha->loop_state) == LOOP_READY &&
+                   !test_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags) &&
+                   !test_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags) &&
                    !ha->dpc_active) {
                /* Must be in a 'READY' state for statistics retrieval. */
-               rval = qla2x00_get_link_status(ha, ha->loop_id, stats,
-                   stats_dma);
+               rval = qla2x00_get_link_status(base_vha, base_vha->loop_id,
+                                               stats, stats_dma);
        }
 
        if (rval != QLA_SUCCESS)
@@ -1004,11 +1406,14 @@ qla2x00_get_fc_host_stats(struct Scsi_Host *shost)
        pfc_host_stat->invalid_tx_word_count = stats->inval_xmit_word_cnt;
        pfc_host_stat->invalid_crc_count = stats->inval_crc_cnt;
        if (IS_FWI2_CAPABLE(ha)) {
+               pfc_host_stat->lip_count = stats->lip_cnt;
                pfc_host_stat->tx_frames = stats->tx_frames;
                pfc_host_stat->rx_frames = stats->rx_frames;
                pfc_host_stat->dumped_frames = stats->dumped_frames;
                pfc_host_stat->nos_count = stats->nos_rcvd;
        }
+       pfc_host_stat->fcp_input_megabytes = ha->qla_stats.input_bytes >> 20;
+       pfc_host_stat->fcp_output_megabytes = ha->qla_stats.output_bytes >> 20;
 
 done_free:
         dma_pool_free(ha->s_dma_pool, stats, stats_dma);
@@ -1019,29 +1424,29 @@ done:
 static void
 qla2x00_get_host_symbolic_name(struct Scsi_Host *shost)
 {
-       scsi_qla_host_t *ha = shost_priv(shost);
+       scsi_qla_host_t *vha = shost_priv(shost);
 
-       qla2x00_get_sym_node_name(ha, fc_host_symbolic_name(shost));
+       qla2x00_get_sym_node_name(vha, fc_host_symbolic_name(shost));
 }
 
 static void
 qla2x00_set_host_system_hostname(struct Scsi_Host *shost)
 {
-       scsi_qla_host_t *ha = shost_priv(shost);
+       scsi_qla_host_t *vha = shost_priv(shost);
 
-       set_bit(REGISTER_FDMI_NEEDED, &ha->dpc_flags);
+       set_bit(REGISTER_FDMI_NEEDED, &vha->dpc_flags);
 }
 
 static void
 qla2x00_get_host_fabric_name(struct Scsi_Host *shost)
 {
-       scsi_qla_host_t *ha = shost_priv(shost);
+       scsi_qla_host_t *vha = shost_priv(shost);
        u64 node_name;
 
-       if (ha->device_flags & SWITCH_FOUND)
-               node_name = wwn_to_u64(ha->fabric_node_name);
+       if (vha->device_flags & SWITCH_FOUND)
+               node_name = wwn_to_u64(vha->fabric_node_name);
        else
-               node_name = wwn_to_u64(ha->node_name);
+               node_name = wwn_to_u64(vha->node_name);
 
        fc_host_fabric_name(shost) = node_name;
 }
@@ -1049,11 +1454,12 @@ qla2x00_get_host_fabric_name(struct Scsi_Host *shost)
 static void
 qla2x00_get_host_port_state(struct Scsi_Host *shost)
 {
-       scsi_qla_host_t *ha = shost_priv(shost);
+       scsi_qla_host_t *vha = shost_priv(shost);
+       struct scsi_qla_host *base_vha = pci_get_drvdata(vha->hw->pdev);
 
-       if (!ha->flags.online)
+       if (!base_vha->flags.online)
                fc_host_port_state(shost) = FC_PORTSTATE_OFFLINE;
-       else if (atomic_read(&ha->loop_state) == LOOP_TIMEOUT)
+       else if (atomic_read(&base_vha->loop_state) == LOOP_TIMEOUT)
                fc_host_port_state(shost) = FC_PORTSTATE_UNKNOWN;
        else
                fc_host_port_state(shost) = FC_PORTSTATE_ONLINE;
@@ -1063,8 +1469,12 @@ static int
 qla24xx_vport_create(struct fc_vport *fc_vport, bool disable)
 {
        int     ret = 0;
-       scsi_qla_host_t *ha = shost_priv(fc_vport->shost);
-       scsi_qla_host_t *vha;
+       uint8_t qos = 0;
+       scsi_qla_host_t *base_vha = shost_priv(fc_vport->shost);
+       scsi_qla_host_t *vha = NULL;
+       struct qla_hw_data *ha = base_vha->hw;
+       uint16_t options = 0;
+       int     cnt;
 
        ret = qla24xx_vport_create_req_sanity_check(fc_vport);
        if (ret) {
@@ -1086,18 +1496,19 @@ qla24xx_vport_create(struct fc_vport *fc_vport, bool disable)
                atomic_set(&vha->vp_state, VP_FAILED);
 
        /* ready to create vport */
-       qla_printk(KERN_INFO, vha, "VP entry id %d assigned.\n", vha->vp_idx);
+       qla_printk(KERN_INFO, vha->hw, "VP entry id %d assigned.\n",
+                                                       vha->vp_idx);
 
        /* initialized vport states */
        atomic_set(&vha->loop_state, LOOP_DOWN);
        vha->vp_err_state=  VP_ERR_PORTDWN;
        vha->vp_prev_err_state=  VP_ERR_UNKWN;
        /* Check if physical ha port is Up */
-       if (atomic_read(&ha->loop_state) == LOOP_DOWN ||
-           atomic_read(&ha->loop_state) == LOOP_DEAD) {
+       if (atomic_read(&base_vha->loop_state) == LOOP_DOWN ||
+           atomic_read(&base_vha->loop_state) == LOOP_DEAD) {
                /* Don't retry or attempt login of this virtual port */
                DEBUG15(printk ("scsi(%ld): pport loop_state is not UP.\n",
-                   vha->host_no));
+                   base_vha->host_no));
                atomic_set(&vha->loop_state, LOOP_DEAD);
                if (!disable)
                        fc_vport_set_state(fc_vport, FC_VPORT_LINKDOWN);
@@ -1113,18 +1524,44 @@ qla24xx_vport_create(struct fc_vport *fc_vport, bool disable)
        fc_host_node_name(vha->host) = wwn_to_u64(vha->node_name);
        fc_host_port_name(vha->host) = wwn_to_u64(vha->port_name);
        fc_host_supported_classes(vha->host) =
-               fc_host_supported_classes(ha->host);
+               fc_host_supported_classes(base_vha->host);
        fc_host_supported_speeds(vha->host) =
-               fc_host_supported_speeds(ha->host);
+               fc_host_supported_speeds(base_vha->host);
 
        qla24xx_vport_disable(fc_vport, disable);
 
+       ret = 0;
+       if (ha->cur_vport_count <= ha->flex_port_count || ql2xmultique_tag
+               || ha->max_req_queues == 1 || !ha->npiv_info)
+               goto vport_queue;
+       /* Create a request queue in QoS mode for the vport */
+       for (cnt = ha->flex_port_count; cnt < ha->nvram_npiv_size; cnt++) {
+               if (ha->npiv_info[cnt].port_name == vha->port_name &&
+                       ha->npiv_info[cnt].node_name == vha->node_name) {
+                       qos = ha->npiv_info[cnt].q_qos;
+                       break;
+               }
+       }
+       if (qos) {
+               ret = qla25xx_create_req_que(ha, options, vha->vp_idx, 0, 0,
+                       qos);
+               if (!ret)
+                       qla_printk(KERN_WARNING, ha,
+                       "Can't create request queue for vp_idx:%d\n",
+                       vha->vp_idx);
+               else
+                       DEBUG2(qla_printk(KERN_INFO, ha,
+                       "Request Que:%d created for vp_idx:%d\n",
+                       ret, vha->vp_idx));
+       }
+
+vport_queue:
+       vha->req = ha->req_q_map[ret];
        return 0;
+
 vport_create_failed_2:
        qla24xx_disable_vp(vha);
        qla24xx_deallocate_vp_id(vha);
-       kfree(vha->port_name);
-       kfree(vha->node_name);
        scsi_host_put(vha->host);
        return FC_VPORT_FAILED;
 }
@@ -1132,19 +1569,28 @@ vport_create_failed_2:
 static int
 qla24xx_vport_delete(struct fc_vport *fc_vport)
 {
-       scsi_qla_host_t *ha = shost_priv(fc_vport->shost);
        scsi_qla_host_t *vha = fc_vport->dd_data;
+       fc_port_t *fcport, *tfcport;
+       struct qla_hw_data *ha = vha->hw;
+       uint16_t id = vha->vp_idx;
+
+       while (test_bit(LOOP_RESYNC_ACTIVE, &vha->dpc_flags) ||
+           test_bit(FCPORT_UPDATE_NEEDED, &vha->dpc_flags))
+               msleep(1000);
 
        qla24xx_disable_vp(vha);
-       qla24xx_deallocate_vp_id(vha);
 
-       down(&ha->vport_sem);
-       ha->cur_vport_count--;
-       clear_bit(vha->vp_idx, ha->vp_idx_map);
-       up(&ha->vport_sem);
+       fc_remove_host(vha->host);
 
-       kfree(vha->node_name);
-       kfree(vha->port_name);
+       scsi_remove_host(vha->host);
+
+       list_for_each_entry_safe(fcport, tfcport, &vha->vp_fcports, list) {
+               list_del(&fcport->list);
+               kfree(fcport);
+               fcport = NULL;
+       }
+
+       qla24xx_deallocate_vp_id(vha);
 
        if (vha->timer_active) {
                qla2x00_vp_stop_timer(vha);
@@ -1153,12 +1599,14 @@ qla24xx_vport_delete(struct fc_vport *fc_vport)
                    vha->host_no, vha->vp_idx, vha));
         }
 
-       fc_remove_host(vha->host);
-
-       scsi_remove_host(vha->host);
+       if (vha->req->id && !ql2xmultique_tag) {
+               if (qla25xx_delete_req_que(vha, vha->req) != QLA_SUCCESS)
+                       qla_printk(KERN_WARNING, ha,
+                               "Queue delete failed.\n");
+       }
 
        scsi_host_put(vha->host);
-
+       qla_printk(KERN_INFO, ha, "vport %d deleted\n", id);
        return 0;
 }
 
@@ -1180,6 +1628,7 @@ struct fc_function_template qla2xxx_transport_functions = {
        .show_host_node_name = 1,
        .show_host_port_name = 1,
        .show_host_supported_classes = 1,
+       .show_host_supported_speeds = 1,
 
        .get_host_port_id = qla2x00_get_host_port_id,
        .show_host_port_id = 1,
@@ -1206,11 +1655,12 @@ struct fc_function_template qla2xxx_transport_functions = {
        .get_starget_port_id  = qla2x00_get_starget_port_id,
        .show_starget_port_id = 1,
 
-       .get_rport_dev_loss_tmo = qla2x00_get_rport_loss_tmo,
        .set_rport_dev_loss_tmo = qla2x00_set_rport_loss_tmo,
        .show_rport_dev_loss_tmo = 1,
 
        .issue_fc_host_lip = qla2x00_issue_lip,
+       .dev_loss_tmo_callbk = qla2x00_dev_loss_tmo_callbk,
+       .terminate_rport_io = qla2x00_terminate_rport_io,
        .get_fc_host_stats = qla2x00_get_fc_host_stats,
 
        .vport_create = qla24xx_vport_create,
@@ -1249,20 +1699,38 @@ struct fc_function_template qla2xxx_transport_vport_functions = {
        .get_starget_port_id  = qla2x00_get_starget_port_id,
        .show_starget_port_id = 1,
 
-       .get_rport_dev_loss_tmo = qla2x00_get_rport_loss_tmo,
        .set_rport_dev_loss_tmo = qla2x00_set_rport_loss_tmo,
        .show_rport_dev_loss_tmo = 1,
 
        .issue_fc_host_lip = qla2x00_issue_lip,
+       .dev_loss_tmo_callbk = qla2x00_dev_loss_tmo_callbk,
+       .terminate_rport_io = qla2x00_terminate_rport_io,
        .get_fc_host_stats = qla2x00_get_fc_host_stats,
 };
 
 void
-qla2x00_init_host_attr(scsi_qla_host_t *ha)
+qla2x00_init_host_attr(scsi_qla_host_t *vha)
 {
-       fc_host_node_name(ha->host) = wwn_to_u64(ha->node_name);
-       fc_host_port_name(ha->host) = wwn_to_u64(ha->port_name);
-       fc_host_supported_classes(ha->host) = FC_COS_CLASS3;
-       fc_host_max_npiv_vports(ha->host) = ha->max_npiv_vports;;
-       fc_host_npiv_vports_inuse(ha->host) = ha->cur_vport_count;
+       struct qla_hw_data *ha = vha->hw;
+       u32 speed = FC_PORTSPEED_UNKNOWN;
+
+       fc_host_node_name(vha->host) = wwn_to_u64(vha->node_name);
+       fc_host_port_name(vha->host) = wwn_to_u64(vha->port_name);
+       fc_host_supported_classes(vha->host) = FC_COS_CLASS3;
+       fc_host_max_npiv_vports(vha->host) = ha->max_npiv_vports;
+       fc_host_npiv_vports_inuse(vha->host) = ha->cur_vport_count;
+
+       if (IS_QLA81XX(ha))
+               speed = FC_PORTSPEED_10GBIT;
+       else if (IS_QLA25XX(ha))
+               speed = FC_PORTSPEED_8GBIT | FC_PORTSPEED_4GBIT |
+                   FC_PORTSPEED_2GBIT | FC_PORTSPEED_1GBIT;
+       else if (IS_QLA24XX_TYPE(ha))
+               speed = FC_PORTSPEED_4GBIT | FC_PORTSPEED_2GBIT |
+                   FC_PORTSPEED_1GBIT;
+       else if (IS_QLA23XX(ha))
+               speed = FC_PORTSPEED_2GBIT | FC_PORTSPEED_1GBIT;
+       else
+               speed = FC_PORTSPEED_1GBIT;
+       fc_host_supported_speeds(vha->host) = speed;
 }