[SCSI] qla2xxx: Use port number to compute nvram/vpd parameter offsets.
authorAnirban Chakraborty <anirban.chakraborty@qlogic.com>
Tue, 7 Apr 2009 05:33:50 +0000 (22:33 -0700)
committerJames Bottomley <James.Bottomley@HansenPartnership.com>
Wed, 20 May 2009 22:21:11 +0000 (17:21 -0500)
Read adapter's physical port number from interrupt pin register
and use it instead of pci function number to offset into the
nvram to obtain the port's configuration parameters.

Signed-off-by: Anirban Chakraborty <anirban.chakraborty@qlogic.com>
Signed-off-by: Andrew Vasquez <andrew.vasquez@qlogic.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
drivers/scsi/qla2xxx/qla_def.h
drivers/scsi/qla2xxx/qla_init.c
drivers/scsi/qla2xxx/qla_os.c
drivers/scsi/qla2xxx/qla_sup.c

index 6911b9b32febc71e2213da5056db557ef5443956..721bae94e4371004382cef90880b76602685a5c0 100644 (file)
@@ -2222,6 +2222,7 @@ struct qla_hw_data {
                uint32_t        fce_enabled             :1;
                uint32_t        fac_supported           :1;
                uint32_t        chip_reset_done         :1;
+               uint32_t        port0                   :1;
        } flags;
 
        /* This spinlock is used to protect "io transactions", you must
@@ -2256,6 +2257,9 @@ struct qla_hw_data {
 #define FLOGI_MID_SUPPORT       BIT_10
 #define FLOGI_VSAN_SUPPORT      BIT_12
 #define FLOGI_SP_SUPPORT        BIT_13
+
+       uint8_t         port_no;                /* Physical port of adapter */
+
        /* Timeout timers. */
        uint8_t         loop_down_abort_time;    /* port down timer */
        atomic_t        loop_down_timer;         /* loop down timer */
index 4952fc19aa20c37e51cb82af6e00bd0b0169a425..33e924810666ea86f5efb1a39460fc97c36abd4e 100644 (file)
@@ -3573,14 +3573,15 @@ qla24xx_nvram_config(scsi_qla_host_t *vha)
        nv = ha->nvram;
 
        /* Determine NVRAM starting address. */
-       ha->nvram_size = sizeof(struct nvram_24xx);
-       ha->nvram_base = FA_NVRAM_FUNC0_ADDR;
-       ha->vpd_size = FA_NVRAM_VPD_SIZE;
-       ha->vpd_base = FA_NVRAM_VPD0_ADDR;
-       if (PCI_FUNC(ha->pdev->devfn)) {
+       if (ha->flags.port0) {
+               ha->nvram_base = FA_NVRAM_FUNC0_ADDR;
+               ha->vpd_base = FA_NVRAM_VPD0_ADDR;
+       } else {
                ha->nvram_base = FA_NVRAM_FUNC1_ADDR;
                ha->vpd_base = FA_NVRAM_VPD1_ADDR;
        }
+       ha->nvram_size = sizeof(struct nvram_24xx);
+       ha->vpd_size = FA_NVRAM_VPD_SIZE;
 
        /* Get VPD data into cache */
        ha->vpd = ha->nvram + VPD_OFFSET;
@@ -3619,7 +3620,7 @@ qla24xx_nvram_config(scsi_qla_host_t *vha)
                nv->exchange_count = __constant_cpu_to_le16(0);
                nv->hard_address = __constant_cpu_to_le16(124);
                nv->port_name[0] = 0x21;
-               nv->port_name[1] = 0x00 + PCI_FUNC(ha->pdev->devfn);
+               nv->port_name[1] = 0x00 + ha->port_no;
                nv->port_name[2] = 0x00;
                nv->port_name[3] = 0xe0;
                nv->port_name[4] = 0x8b;
@@ -4348,7 +4349,7 @@ qla81xx_nvram_config(scsi_qla_host_t *vha)
                nv->execution_throttle = __constant_cpu_to_le16(0xFFFF);
                nv->exchange_count = __constant_cpu_to_le16(0);
                nv->port_name[0] = 0x21;
-               nv->port_name[1] = 0x00 + PCI_FUNC(ha->pdev->devfn);
+               nv->port_name[1] = 0x00 + ha->port_no;
                nv->port_name[2] = 0x00;
                nv->port_name[3] = 0xe0;
                nv->port_name[4] = 0x8b;
@@ -4382,7 +4383,7 @@ qla81xx_nvram_config(scsi_qla_host_t *vha)
                nv->enode_mac[2] = 0x03;
                nv->enode_mac[3] = 0x04;
                nv->enode_mac[4] = 0x05;
-               nv->enode_mac[5] = 0x06 + PCI_FUNC(ha->pdev->devfn);
+               nv->enode_mac[5] = 0x06 + ha->port_no;
 
                rval = 1;
        }
@@ -4415,7 +4416,7 @@ qla81xx_nvram_config(scsi_qla_host_t *vha)
                icb->enode_mac[2] = 0x03;
                icb->enode_mac[3] = 0x04;
                icb->enode_mac[4] = 0x05;
-               icb->enode_mac[5] = 0x06 + PCI_FUNC(ha->pdev->devfn);
+               icb->enode_mac[5] = 0x06 + ha->port_no;
        }
 
        /* Use extended-initialization control block. */
index 88a75d0a8d7e9c416c161b561332eb1b4fb9f85d..f4f5355369528a00499ab37b64fdbfa067388580 100644 (file)
@@ -1581,6 +1581,13 @@ qla2x00_set_isp_flags(struct qla_hw_data *ha)
                ha->fw_srisc_address = RISC_START_ADDRESS_2400;
                break;
        }
+
+       /* Get adapter physical port no from interrupt pin register. */
+       pci_read_config_byte(ha->pdev, PCI_INTERRUPT_PIN, &ha->port_no);
+       if (ha->port_no & 1)
+               ha->flags.port0 = 1;
+       else
+               ha->flags.port0 = 0;
 }
 
 static int
index 2a9b3f83ba678ac94af25003d29a05f389b9413a..22f97eb50cf9f01b54c2bd580ba9842db88743c3 100644 (file)
@@ -702,30 +702,30 @@ qla2xxx_get_flt_info(scsi_qla_host_t *vha, uint32_t flt_addr)
                        break;
                case FLT_REG_VPD_0:
                        ha->flt_region_vpd_nvram = start;
-                       if (!(PCI_FUNC(ha->pdev->devfn) & 1))
+                       if (ha->flags.port0)
                                ha->flt_region_vpd = start;
                        break;
                case FLT_REG_VPD_1:
-                       if (PCI_FUNC(ha->pdev->devfn) & 1)
+                       if (!ha->flags.port0)
                                ha->flt_region_vpd = start;
                        break;
                case FLT_REG_NVRAM_0:
-                       if (!(PCI_FUNC(ha->pdev->devfn) & 1))
+                       if (ha->flags.port0)
                                ha->flt_region_nvram = start;
                        break;
                case FLT_REG_NVRAM_1:
-                       if (PCI_FUNC(ha->pdev->devfn) & 1)
+                       if (!ha->flags.port0)
                                ha->flt_region_nvram = start;
                        break;
                case FLT_REG_FDT:
                        ha->flt_region_fdt = start;
                        break;
                case FLT_REG_NPIV_CONF_0:
-                       if (!(PCI_FUNC(ha->pdev->devfn) & 1))
+                       if (ha->flags.port0)
                                ha->flt_region_npiv_conf = start;
                        break;
                case FLT_REG_NPIV_CONF_1:
-                       if (PCI_FUNC(ha->pdev->devfn) & 1)
+                       if (!ha->flags.port0)
                                ha->flt_region_npiv_conf = start;
                        break;
                }
@@ -745,12 +745,12 @@ no_flash_data:
        ha->flt_region_fw = def_fw[def];
        ha->flt_region_boot = def_boot[def];
        ha->flt_region_vpd_nvram = def_vpd_nvram[def];
-       ha->flt_region_vpd = !(PCI_FUNC(ha->pdev->devfn) & 1) ?
+       ha->flt_region_vpd = ha->flags.port0 ?
            def_vpd0[def]: def_vpd1[def];
-       ha->flt_region_nvram = !(PCI_FUNC(ha->pdev->devfn) & 1) ?
+       ha->flt_region_nvram = ha->flags.port0 ?
            def_nvram0[def]: def_nvram1[def];
        ha->flt_region_fdt = def_fdt[def];
-       ha->flt_region_npiv_conf = !(PCI_FUNC(ha->pdev->devfn) & 1) ?
+       ha->flt_region_npiv_conf = ha->flags.port0 ?
            def_npiv_conf0[def]: def_npiv_conf1[def];
 done:
        DEBUG2(qla_printk(KERN_DEBUG, ha, "FLT[%s]: boot=0x%x fw=0x%x "