aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/qla2xxx/qla_init.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/qla2xxx/qla_init.c')
-rw-r--r--drivers/scsi/qla2xxx/qla_init.c136
1 files changed, 43 insertions, 93 deletions
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index 87f9abc71460..bd7dd84c0648 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -20,7 +20,6 @@
20* QLogic ISP2x00 Hardware Support Function Prototypes. 20* QLogic ISP2x00 Hardware Support Function Prototypes.
21*/ 21*/
22static int qla2x00_isp_firmware(scsi_qla_host_t *); 22static int qla2x00_isp_firmware(scsi_qla_host_t *);
23static void qla2x00_resize_request_q(scsi_qla_host_t *);
24static int qla2x00_setup_chip(scsi_qla_host_t *); 23static int qla2x00_setup_chip(scsi_qla_host_t *);
25static int qla2x00_init_rings(scsi_qla_host_t *); 24static int qla2x00_init_rings(scsi_qla_host_t *);
26static int qla2x00_fw_ready(scsi_qla_host_t *); 25static int qla2x00_fw_ready(scsi_qla_host_t *);
@@ -61,8 +60,10 @@ qla2x00_initialize_adapter(scsi_qla_host_t *vha)
61 int rval; 60 int rval;
62 struct qla_hw_data *ha = vha->hw; 61 struct qla_hw_data *ha = vha->hw;
63 struct req_que *req = ha->req_q_map[0]; 62 struct req_que *req = ha->req_q_map[0];
63
64 /* Clear adapter flags. */ 64 /* Clear adapter flags. */
65 vha->flags.online = 0; 65 vha->flags.online = 0;
66 ha->flags.chip_reset_done = 0;
66 vha->flags.reset_active = 0; 67 vha->flags.reset_active = 0;
67 atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME); 68 atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME);
68 atomic_set(&vha->loop_state, LOOP_DOWN); 69 atomic_set(&vha->loop_state, LOOP_DOWN);
@@ -70,7 +71,6 @@ qla2x00_initialize_adapter(scsi_qla_host_t *vha)
70 vha->dpc_flags = 0; 71 vha->dpc_flags = 0;
71 vha->flags.management_server_logged_in = 0; 72 vha->flags.management_server_logged_in = 0;
72 vha->marker_needed = 0; 73 vha->marker_needed = 0;
73 ha->mbx_flags = 0;
74 ha->isp_abort_cnt = 0; 74 ha->isp_abort_cnt = 0;
75 ha->beacon_blink_led = 0; 75 ha->beacon_blink_led = 0;
76 set_bit(REGISTER_FDMI_NEEDED, &vha->dpc_flags); 76 set_bit(REGISTER_FDMI_NEEDED, &vha->dpc_flags);
@@ -131,6 +131,7 @@ qla2x00_initialize_adapter(scsi_qla_host_t *vha)
131 } 131 }
132 } 132 }
133 rval = qla2x00_init_rings(vha); 133 rval = qla2x00_init_rings(vha);
134 ha->flags.chip_reset_done = 1;
134 135
135 return (rval); 136 return (rval);
136} 137}
@@ -512,7 +513,6 @@ qla2x00_reset_chip(scsi_qla_host_t *vha)
512static inline void 513static inline void
513qla24xx_reset_risc(scsi_qla_host_t *vha) 514qla24xx_reset_risc(scsi_qla_host_t *vha)
514{ 515{
515 int hw_evt = 0;
516 unsigned long flags = 0; 516 unsigned long flags = 0;
517 struct qla_hw_data *ha = vha->hw; 517 struct qla_hw_data *ha = vha->hw;
518 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; 518 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
@@ -542,8 +542,6 @@ qla24xx_reset_risc(scsi_qla_host_t *vha)
542 d2 = (uint32_t) RD_REG_WORD(&reg->mailbox0); 542 d2 = (uint32_t) RD_REG_WORD(&reg->mailbox0);
543 barrier(); 543 barrier();
544 } 544 }
545 if (cnt == 0)
546 hw_evt = 1;
547 545
548 /* Wait for soft-reset to complete. */ 546 /* Wait for soft-reset to complete. */
549 d2 = RD_REG_DWORD(&reg->ctrl_status); 547 d2 = RD_REG_DWORD(&reg->ctrl_status);
@@ -816,7 +814,7 @@ qla2x00_alloc_fw_dump(scsi_qla_host_t *vha)
816 qla_printk(KERN_INFO, ha, "Allocated (%d KB) for FCE...\n", 814 qla_printk(KERN_INFO, ha, "Allocated (%d KB) for FCE...\n",
817 FCE_SIZE / 1024); 815 FCE_SIZE / 1024);
818 816
819 fce_size = sizeof(struct qla2xxx_fce_chain) + EFT_SIZE; 817 fce_size = sizeof(struct qla2xxx_fce_chain) + FCE_SIZE;
820 ha->flags.fce_enabled = 1; 818 ha->flags.fce_enabled = 1;
821 ha->fce_dma = tc_dma; 819 ha->fce_dma = tc_dma;
822 ha->fce = tc; 820 ha->fce = tc;
@@ -894,62 +892,6 @@ cont_alloc:
894} 892}
895 893
896/** 894/**
897 * qla2x00_resize_request_q() - Resize request queue given available ISP memory.
898 * @ha: HA context
899 *
900 * Returns 0 on success.
901 */
902static void
903qla2x00_resize_request_q(scsi_qla_host_t *vha)
904{
905 int rval;
906 uint16_t fw_iocb_cnt = 0;
907 uint16_t request_q_length = REQUEST_ENTRY_CNT_2XXX_EXT_MEM;
908 dma_addr_t request_dma;
909 request_t *request_ring;
910 struct qla_hw_data *ha = vha->hw;
911 struct req_que *req = ha->req_q_map[0];
912
913 /* Valid only on recent ISPs. */
914 if (IS_QLA2100(ha) || IS_QLA2200(ha))
915 return;
916
917 /* Retrieve IOCB counts available to the firmware. */
918 rval = qla2x00_get_resource_cnts(vha, NULL, NULL, NULL, &fw_iocb_cnt,
919 &ha->max_npiv_vports);
920 if (rval)
921 return;
922 /* No point in continuing if current settings are sufficient. */
923 if (fw_iocb_cnt < 1024)
924 return;
925 if (req->length >= request_q_length)
926 return;
927
928 /* Attempt to claim larger area for request queue. */
929 request_ring = dma_alloc_coherent(&ha->pdev->dev,
930 (request_q_length + 1) * sizeof(request_t), &request_dma,
931 GFP_KERNEL);
932 if (request_ring == NULL)
933 return;
934
935 /* Resize successful, report extensions. */
936 qla_printk(KERN_INFO, ha, "Extended memory detected (%d KB)...\n",
937 (ha->fw_memory_size + 1) / 1024);
938 qla_printk(KERN_INFO, ha, "Resizing request queue depth "
939 "(%d -> %d)...\n", req->length, request_q_length);
940
941 /* Clear old allocations. */
942 dma_free_coherent(&ha->pdev->dev,
943 (req->length + 1) * sizeof(request_t), req->ring,
944 req->dma);
945
946 /* Begin using larger queue. */
947 req->length = request_q_length;
948 req->ring = request_ring;
949 req->dma = request_dma;
950}
951
952/**
953 * qla2x00_setup_chip() - Load and start RISC firmware. 895 * qla2x00_setup_chip() - Load and start RISC firmware.
954 * @ha: HA context 896 * @ha: HA context
955 * 897 *
@@ -963,6 +905,7 @@ qla2x00_setup_chip(scsi_qla_host_t *vha)
963 struct qla_hw_data *ha = vha->hw; 905 struct qla_hw_data *ha = vha->hw;
964 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; 906 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
965 unsigned long flags; 907 unsigned long flags;
908 uint16_t fw_major_version;
966 909
967 if (!IS_FWI2_CAPABLE(ha) && !IS_QLA2100(ha) && !IS_QLA2200(ha)) { 910 if (!IS_FWI2_CAPABLE(ha) && !IS_QLA2100(ha) && !IS_QLA2200(ha)) {
968 /* Disable SRAM, Instruction RAM and GP RAM parity. */ 911 /* Disable SRAM, Instruction RAM and GP RAM parity. */
@@ -986,13 +929,15 @@ qla2x00_setup_chip(scsi_qla_host_t *vha)
986 929
987 rval = qla2x00_execute_fw(vha, srisc_address); 930 rval = qla2x00_execute_fw(vha, srisc_address);
988 /* Retrieve firmware information. */ 931 /* Retrieve firmware information. */
989 if (rval == QLA_SUCCESS && ha->fw_major_version == 0) { 932 if (rval == QLA_SUCCESS) {
933 fw_major_version = ha->fw_major_version;
990 qla2x00_get_fw_version(vha, 934 qla2x00_get_fw_version(vha,
991 &ha->fw_major_version, 935 &ha->fw_major_version,
992 &ha->fw_minor_version, 936 &ha->fw_minor_version,
993 &ha->fw_subminor_version, 937 &ha->fw_subminor_version,
994 &ha->fw_attributes, &ha->fw_memory_size, 938 &ha->fw_attributes, &ha->fw_memory_size,
995 ha->mpi_version, &ha->mpi_capabilities); 939 ha->mpi_version, &ha->mpi_capabilities,
940 ha->phy_version);
996 ha->flags.npiv_supported = 0; 941 ha->flags.npiv_supported = 0;
997 if (IS_QLA2XXX_MIDTYPE(ha) && 942 if (IS_QLA2XXX_MIDTYPE(ha) &&
998 (ha->fw_attributes & BIT_2)) { 943 (ha->fw_attributes & BIT_2)) {
@@ -1003,9 +948,11 @@ qla2x00_setup_chip(scsi_qla_host_t *vha)
1003 ha->max_npiv_vports = 948 ha->max_npiv_vports =
1004 MIN_MULTI_ID_FABRIC - 1; 949 MIN_MULTI_ID_FABRIC - 1;
1005 } 950 }
1006 qla2x00_resize_request_q(vha); 951 qla2x00_get_resource_cnts(vha, NULL,
952 &ha->fw_xcb_count, NULL, NULL,
953 &ha->max_npiv_vports);
1007 954
1008 if (ql2xallocfwdump) 955 if (!fw_major_version && ql2xallocfwdump)
1009 qla2x00_alloc_fw_dump(vha); 956 qla2x00_alloc_fw_dump(vha);
1010 } 957 }
1011 } else { 958 } else {
@@ -1028,6 +975,21 @@ qla2x00_setup_chip(scsi_qla_host_t *vha)
1028 spin_unlock_irqrestore(&ha->hardware_lock, flags); 975 spin_unlock_irqrestore(&ha->hardware_lock, flags);
1029 } 976 }
1030 977
978 if (rval == QLA_SUCCESS && IS_FAC_REQUIRED(ha)) {
979 uint32_t size;
980
981 rval = qla81xx_fac_get_sector_size(vha, &size);
982 if (rval == QLA_SUCCESS) {
983 ha->flags.fac_supported = 1;
984 ha->fdt_block_size = size << 2;
985 } else {
986 qla_printk(KERN_ERR, ha,
987 "Unsupported FAC firmware (%d.%02d.%02d).\n",
988 ha->fw_major_version, ha->fw_minor_version,
989 ha->fw_subminor_version);
990 }
991 }
992
1031 if (rval) { 993 if (rval) {
1032 DEBUG2_3(printk("scsi(%ld): Setup chip **** FAILED ****.\n", 994 DEBUG2_3(printk("scsi(%ld): Setup chip **** FAILED ****.\n",
1033 vha->host_no)); 995 vha->host_no));
@@ -1314,8 +1276,11 @@ qla2x00_init_rings(scsi_qla_host_t *vha)
1314 mid_init_cb->count = cpu_to_le16(ha->max_npiv_vports); 1276 mid_init_cb->count = cpu_to_le16(ha->max_npiv_vports);
1315 } 1277 }
1316 1278
1317 1279 if (IS_FWI2_CAPABLE(ha)) {
1318 mid_init_cb->options = __constant_cpu_to_le16(BIT_1); 1280 mid_init_cb->options = __constant_cpu_to_le16(BIT_1);
1281 mid_init_cb->init_cb.execution_throttle =
1282 cpu_to_le16(ha->fw_xcb_count);
1283 }
1319 1284
1320 rval = qla2x00_init_firmware(vha, ha->init_cb_size); 1285 rval = qla2x00_init_firmware(vha, ha->init_cb_size);
1321 if (rval) { 1286 if (rval) {
@@ -1989,7 +1954,6 @@ qla2x00_alloc_fcport(scsi_qla_host_t *vha, gfp_t flags)
1989 fcport->port_type = FCT_UNKNOWN; 1954 fcport->port_type = FCT_UNKNOWN;
1990 fcport->loop_id = FC_NO_LOOP_ID; 1955 fcport->loop_id = FC_NO_LOOP_ID;
1991 atomic_set(&fcport->state, FCS_UNCONFIGURED); 1956 atomic_set(&fcport->state, FCS_UNCONFIGURED);
1992 fcport->flags = FCF_RLC_SUPPORT;
1993 fcport->supported_classes = FC_COS_UNSPECIFIED; 1957 fcport->supported_classes = FC_COS_UNSPECIFIED;
1994 1958
1995 return fcport; 1959 return fcport;
@@ -2171,7 +2135,6 @@ qla2x00_configure_local_loop(scsi_qla_host_t *vha)
2171 vha->host_no, fcport->loop_id)); 2135 vha->host_no, fcport->loop_id));
2172 2136
2173 atomic_set(&fcport->state, FCS_DEVICE_LOST); 2137 atomic_set(&fcport->state, FCS_DEVICE_LOST);
2174 fcport->flags &= ~FCF_FARP_DONE;
2175 } 2138 }
2176 } 2139 }
2177 2140
@@ -2228,8 +2191,7 @@ qla2x00_configure_local_loop(scsi_qla_host_t *vha)
2228 WWN_SIZE)) 2191 WWN_SIZE))
2229 continue; 2192 continue;
2230 2193
2231 fcport->flags &= ~(FCF_FABRIC_DEVICE | 2194 fcport->flags &= ~FCF_FABRIC_DEVICE;
2232 FCF_PERSISTENT_BOUND);
2233 fcport->loop_id = new_fcport->loop_id; 2195 fcport->loop_id = new_fcport->loop_id;
2234 fcport->port_type = new_fcport->port_type; 2196 fcport->port_type = new_fcport->port_type;
2235 fcport->d_id.b24 = new_fcport->d_id.b24; 2197 fcport->d_id.b24 = new_fcport->d_id.b24;
@@ -2242,7 +2204,6 @@ qla2x00_configure_local_loop(scsi_qla_host_t *vha)
2242 2204
2243 if (!found) { 2205 if (!found) {
2244 /* New device, add to fcports list. */ 2206 /* New device, add to fcports list. */
2245 new_fcport->flags &= ~FCF_PERSISTENT_BOUND;
2246 if (vha->vp_idx) { 2207 if (vha->vp_idx) {
2247 new_fcport->vha = vha; 2208 new_fcport->vha = vha;
2248 new_fcport->vp_idx = vha->vp_idx; 2209 new_fcport->vp_idx = vha->vp_idx;
@@ -2275,11 +2236,6 @@ cleanup_allocation:
2275 "rval=%x\n", vha->host_no, rval)); 2236 "rval=%x\n", vha->host_no, rval));
2276 } 2237 }
2277 2238
2278 if (found_devs) {
2279 vha->device_flags |= DFLG_LOCAL_DEVICES;
2280 vha->device_flags &= ~DFLG_RETRY_LOCAL_DEVICES;
2281 }
2282
2283 return (rval); 2239 return (rval);
2284} 2240}
2285 2241
@@ -2765,7 +2721,6 @@ qla2x00_find_all_fabric_devs(scsi_qla_host_t *vha,
2765 fcport->loop_id = FC_NO_LOOP_ID; 2721 fcport->loop_id = FC_NO_LOOP_ID;
2766 fcport->flags |= (FCF_FABRIC_DEVICE | 2722 fcport->flags |= (FCF_FABRIC_DEVICE |
2767 FCF_LOGIN_NEEDED); 2723 FCF_LOGIN_NEEDED);
2768 fcport->flags &= ~FCF_PERSISTENT_BOUND;
2769 break; 2724 break;
2770 } 2725 }
2771 2726
@@ -2808,9 +2763,6 @@ qla2x00_find_all_fabric_devs(scsi_qla_host_t *vha,
2808 kfree(swl); 2763 kfree(swl);
2809 kfree(new_fcport); 2764 kfree(new_fcport);
2810 2765
2811 if (!list_empty(new_fcports))
2812 vha->device_flags |= DFLG_FABRIC_DEVICES;
2813
2814 return (rval); 2766 return (rval);
2815} 2767}
2816 2768
@@ -2993,7 +2945,6 @@ qla2x00_device_resync(scsi_qla_host_t *vha)
2993 0, 0); 2945 0, 0);
2994 } 2946 }
2995 } 2947 }
2996 fcport->flags &= ~FCF_FARP_DONE;
2997 } 2948 }
2998 } 2949 }
2999 return (rval); 2950 return (rval);
@@ -3302,6 +3253,7 @@ qla2x00_abort_isp(scsi_qla_host_t *vha)
3302 3253
3303 if (vha->flags.online) { 3254 if (vha->flags.online) {
3304 vha->flags.online = 0; 3255 vha->flags.online = 0;
3256 ha->flags.chip_reset_done = 0;
3305 clear_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); 3257 clear_bit(ISP_ABORT_NEEDED, &vha->dpc_flags);
3306 ha->qla_stats.total_isp_aborts++; 3258 ha->qla_stats.total_isp_aborts++;
3307 3259
@@ -3451,6 +3403,7 @@ qla2x00_restart_isp(scsi_qla_host_t *vha)
3451 3403
3452 if (!status && !(status = qla2x00_init_rings(vha))) { 3404 if (!status && !(status = qla2x00_init_rings(vha))) {
3453 clear_bit(RESET_MARKER_NEEDED, &vha->dpc_flags); 3405 clear_bit(RESET_MARKER_NEEDED, &vha->dpc_flags);
3406 ha->flags.chip_reset_done = 1;
3454 /* Initialize the queues in use */ 3407 /* Initialize the queues in use */
3455 qla25xx_init_queues(ha); 3408 qla25xx_init_queues(ha);
3456 3409
@@ -4338,23 +4291,17 @@ qla81xx_nvram_config(scsi_qla_host_t *vha)
4338 4291
4339 /* Determine NVRAM starting address. */ 4292 /* Determine NVRAM starting address. */
4340 ha->nvram_size = sizeof(struct nvram_81xx); 4293 ha->nvram_size = sizeof(struct nvram_81xx);
4341 ha->nvram_base = FA_NVRAM_FUNC0_ADDR;
4342 ha->vpd_size = FA_NVRAM_VPD_SIZE; 4294 ha->vpd_size = FA_NVRAM_VPD_SIZE;
4343 ha->vpd_base = FA_NVRAM_VPD0_ADDR;
4344 if (PCI_FUNC(ha->pdev->devfn) & 1) {
4345 ha->nvram_base = FA_NVRAM_FUNC1_ADDR;
4346 ha->vpd_base = FA_NVRAM_VPD1_ADDR;
4347 }
4348 4295
4349 /* Get VPD data into cache */ 4296 /* Get VPD data into cache */
4350 ha->vpd = ha->nvram + VPD_OFFSET; 4297 ha->vpd = ha->nvram + VPD_OFFSET;
4351 ha->isp_ops->read_nvram(vha, (uint8_t *)ha->vpd, 4298 ha->isp_ops->read_optrom(vha, ha->vpd, ha->flt_region_vpd << 2,
4352 ha->nvram_base - FA_NVRAM_FUNC0_ADDR, FA_NVRAM_VPD_SIZE * 4); 4299 ha->vpd_size);
4353 4300
4354 /* Get NVRAM data into cache and calculate checksum. */ 4301 /* Get NVRAM data into cache and calculate checksum. */
4355 dptr = (uint32_t *)nv; 4302 ha->isp_ops->read_optrom(vha, ha->nvram, ha->flt_region_nvram << 2,
4356 ha->isp_ops->read_nvram(vha, (uint8_t *)dptr, ha->nvram_base,
4357 ha->nvram_size); 4303 ha->nvram_size);
4304 dptr = (uint32_t *)nv;
4358 for (cnt = 0, chksum = 0; cnt < ha->nvram_size >> 2; cnt++) 4305 for (cnt = 0, chksum = 0; cnt < ha->nvram_size >> 2; cnt++)
4359 chksum += le32_to_cpu(*dptr++); 4306 chksum += le32_to_cpu(*dptr++);
4360 4307
@@ -4452,6 +4399,9 @@ qla81xx_nvram_config(scsi_qla_host_t *vha)
4452 icb->enode_mac[5] = 0x06 + PCI_FUNC(ha->pdev->devfn); 4399 icb->enode_mac[5] = 0x06 + PCI_FUNC(ha->pdev->devfn);
4453 } 4400 }
4454 4401
4402 /* Use extended-initialization control block. */
4403 memcpy(ha->ex_init_cb, &nv->ex_version, sizeof(*ha->ex_init_cb));
4404
4455 /* 4405 /*
4456 * Setup driver NVRAM options. 4406 * Setup driver NVRAM options.
4457 */ 4407 */