aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/qla2xxx/qla_os.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/qla2xxx/qla_os.c')
-rw-r--r--drivers/scsi/qla2xxx/qla_os.c346
1 files changed, 321 insertions, 25 deletions
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index f31820691dc2..b1adeb71a8b0 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -29,6 +29,11 @@ char qla2x00_version_str[40];
29 */ 29 */
30static struct kmem_cache *srb_cachep; 30static struct kmem_cache *srb_cachep;
31 31
32/*
33 * CT6 CTX allocation cache
34 */
35static struct kmem_cache *ctx_cachep;
36
32int ql2xlogintimeout = 20; 37int ql2xlogintimeout = 20;
33module_param(ql2xlogintimeout, int, S_IRUGO|S_IRUSR); 38module_param(ql2xlogintimeout, int, S_IRUGO|S_IRUSR);
34MODULE_PARM_DESC(ql2xlogintimeout, 39MODULE_PARM_DESC(ql2xlogintimeout,
@@ -65,6 +70,12 @@ MODULE_PARM_DESC(ql2xextended_error_logging,
65 "Option to enable extended error logging, " 70 "Option to enable extended error logging, "
66 "Default is 0 - no logging. 1 - log errors."); 71 "Default is 0 - no logging. 1 - log errors.");
67 72
73int ql2xshiftctondsd = 6;
74module_param(ql2xshiftctondsd, int, S_IRUGO|S_IRUSR);
75MODULE_PARM_DESC(ql2xshiftctondsd,
76 "Set to control shifting of command type processing "
77 "based on total number of SG elements.");
78
68static void qla2x00_free_device(scsi_qla_host_t *); 79static void qla2x00_free_device(scsi_qla_host_t *);
69 80
70int ql2xfdmienable=1; 81int ql2xfdmienable=1;
@@ -114,6 +125,21 @@ MODULE_PARM_DESC(ql2xetsenable,
114 "Enables firmware ETS burst." 125 "Enables firmware ETS burst."
115 "Default is 0 - skip ETS enablement."); 126 "Default is 0 - skip ETS enablement.");
116 127
128int ql2xdbwr;
129module_param(ql2xdbwr, int, S_IRUGO|S_IRUSR);
130MODULE_PARM_DESC(ql2xdbwr,
131 "Option to specify scheme for request queue posting\n"
132 " 0 -- Regular doorbell.\n"
133 " 1 -- CAMRAM doorbell (faster).\n");
134
135int ql2xdontresethba;
136module_param(ql2xdontresethba, int, S_IRUGO|S_IRUSR);
137MODULE_PARM_DESC(ql2xdontresethba,
138 "Option to specify reset behaviour\n"
139 " 0 (Default) -- Reset on failure.\n"
140 " 1 -- Do not reset on failure.\n");
141
142
117/* 143/*
118 * SCSI host template entry points 144 * SCSI host template entry points
119 */ 145 */
@@ -183,6 +209,10 @@ qla2x00_start_timer(scsi_qla_host_t *vha, void *func, unsigned long interval)
183static inline void 209static inline void
184qla2x00_restart_timer(scsi_qla_host_t *vha, unsigned long interval) 210qla2x00_restart_timer(scsi_qla_host_t *vha, unsigned long interval)
185{ 211{
212 /* Currently used for 82XX only. */
213 if (vha->device_flags & DFLG_DEV_FAILED)
214 return;
215
186 mod_timer(&vha->timer, jiffies + interval * HZ); 216 mod_timer(&vha->timer, jiffies + interval * HZ);
187} 217}
188 218
@@ -739,7 +769,7 @@ qla2xxx_eh_abort(struct scsi_cmnd *cmd)
739 769
740 if (sp == NULL) 770 if (sp == NULL)
741 continue; 771 continue;
742 if (sp->ctx) 772 if ((sp->ctx) && !(sp->flags & SRB_FCP_CMND_DMA_VALID))
743 continue; 773 continue;
744 if (sp->cmd != cmd) 774 if (sp->cmd != cmd)
745 continue; 775 continue;
@@ -834,6 +864,24 @@ qla2x00_eh_wait_for_pending_commands(scsi_qla_host_t *vha, unsigned int t,
834 return status; 864 return status;
835} 865}
836 866
867void qla82xx_wait_for_pending_commands(scsi_qla_host_t *vha)
868{
869 int cnt;
870 srb_t *sp;
871 struct req_que *req = vha->req;
872
873 DEBUG2(qla_printk(KERN_INFO, vha->hw,
874 "Waiting for pending commands\n"));
875 for (cnt = 1; cnt < MAX_OUTSTANDING_COMMANDS; cnt++) {
876 sp = req->outstanding_cmds[cnt];
877 if (qla2x00_eh_wait_for_pending_commands(vha, 0, 0,
878 sp, WAIT_HOST) == QLA_SUCCESS) {
879 DEBUG2(qla_printk(KERN_INFO, vha->hw,
880 "Done wait for pending commands\n"));
881 }
882 }
883}
884
837static char *reset_errors[] = { 885static char *reset_errors[] = {
838 "HBA not online", 886 "HBA not online",
839 "HBA not ready", 887 "HBA not ready",
@@ -1020,11 +1068,19 @@ qla2xxx_eh_host_reset(struct scsi_cmnd *cmd)
1020 if (qla2x00_vp_abort_isp(vha)) 1068 if (qla2x00_vp_abort_isp(vha))
1021 goto eh_host_reset_lock; 1069 goto eh_host_reset_lock;
1022 } else { 1070 } else {
1071 if (IS_QLA82XX(vha->hw)) {
1072 if (!qla82xx_fcoe_ctx_reset(vha)) {
1073 /* Ctx reset success */
1074 ret = SUCCESS;
1075 goto eh_host_reset_lock;
1076 }
1077 /* fall thru if ctx reset failed */
1078 }
1023 if (ha->wq) 1079 if (ha->wq)
1024 flush_workqueue(ha->wq); 1080 flush_workqueue(ha->wq);
1025 1081
1026 set_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); 1082 set_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags);
1027 if (qla2x00_abort_isp(base_vha)) { 1083 if (ha->isp_ops->abort_isp(base_vha)) {
1028 clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); 1084 clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags);
1029 /* failed. schedule dpc to try */ 1085 /* failed. schedule dpc to try */
1030 set_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags); 1086 set_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags);
@@ -1078,7 +1134,7 @@ qla2x00_loop_reset(scsi_qla_host_t *vha)
1078 } 1134 }
1079 } 1135 }
1080 1136
1081 if (ha->flags.enable_lip_full_login && !IS_QLA81XX(ha)) { 1137 if (ha->flags.enable_lip_full_login && !IS_QLA8XXX_TYPE(ha)) {
1082 ret = qla2x00_full_login_lip(vha); 1138 ret = qla2x00_full_login_lip(vha);
1083 if (ret != QLA_SUCCESS) { 1139 if (ret != QLA_SUCCESS) {
1084 DEBUG2_3(printk("%s(%ld): failed: " 1140 DEBUG2_3(printk("%s(%ld): failed: "
@@ -1125,7 +1181,8 @@ qla2x00_abort_all_cmds(scsi_qla_host_t *vha, int res)
1125 sp = req->outstanding_cmds[cnt]; 1181 sp = req->outstanding_cmds[cnt];
1126 if (sp) { 1182 if (sp) {
1127 req->outstanding_cmds[cnt] = NULL; 1183 req->outstanding_cmds[cnt] = NULL;
1128 if (!sp->ctx) { 1184 if (!sp->ctx ||
1185 (sp->flags & SRB_FCP_CMND_DMA_VALID)) {
1129 sp->cmd->result = res; 1186 sp->cmd->result = res;
1130 qla2x00_sp_compl(ha, sp); 1187 qla2x00_sp_compl(ha, sp);
1131 } else { 1188 } else {
@@ -1387,6 +1444,7 @@ static struct isp_operations qla2100_isp_ops = {
1387 .write_optrom = qla2x00_write_optrom_data, 1444 .write_optrom = qla2x00_write_optrom_data,
1388 .get_flash_version = qla2x00_get_flash_version, 1445 .get_flash_version = qla2x00_get_flash_version,
1389 .start_scsi = qla2x00_start_scsi, 1446 .start_scsi = qla2x00_start_scsi,
1447 .abort_isp = qla2x00_abort_isp,
1390}; 1448};
1391 1449
1392static struct isp_operations qla2300_isp_ops = { 1450static struct isp_operations qla2300_isp_ops = {
@@ -1422,6 +1480,7 @@ static struct isp_operations qla2300_isp_ops = {
1422 .write_optrom = qla2x00_write_optrom_data, 1480 .write_optrom = qla2x00_write_optrom_data,
1423 .get_flash_version = qla2x00_get_flash_version, 1481 .get_flash_version = qla2x00_get_flash_version,
1424 .start_scsi = qla2x00_start_scsi, 1482 .start_scsi = qla2x00_start_scsi,
1483 .abort_isp = qla2x00_abort_isp,
1425}; 1484};
1426 1485
1427static struct isp_operations qla24xx_isp_ops = { 1486static struct isp_operations qla24xx_isp_ops = {
@@ -1457,6 +1516,7 @@ static struct isp_operations qla24xx_isp_ops = {
1457 .write_optrom = qla24xx_write_optrom_data, 1516 .write_optrom = qla24xx_write_optrom_data,
1458 .get_flash_version = qla24xx_get_flash_version, 1517 .get_flash_version = qla24xx_get_flash_version,
1459 .start_scsi = qla24xx_start_scsi, 1518 .start_scsi = qla24xx_start_scsi,
1519 .abort_isp = qla2x00_abort_isp,
1460}; 1520};
1461 1521
1462static struct isp_operations qla25xx_isp_ops = { 1522static struct isp_operations qla25xx_isp_ops = {
@@ -1492,6 +1552,7 @@ static struct isp_operations qla25xx_isp_ops = {
1492 .write_optrom = qla24xx_write_optrom_data, 1552 .write_optrom = qla24xx_write_optrom_data,
1493 .get_flash_version = qla24xx_get_flash_version, 1553 .get_flash_version = qla24xx_get_flash_version,
1494 .start_scsi = qla24xx_start_scsi, 1554 .start_scsi = qla24xx_start_scsi,
1555 .abort_isp = qla2x00_abort_isp,
1495}; 1556};
1496 1557
1497static struct isp_operations qla81xx_isp_ops = { 1558static struct isp_operations qla81xx_isp_ops = {
@@ -1527,6 +1588,43 @@ static struct isp_operations qla81xx_isp_ops = {
1527 .write_optrom = qla24xx_write_optrom_data, 1588 .write_optrom = qla24xx_write_optrom_data,
1528 .get_flash_version = qla24xx_get_flash_version, 1589 .get_flash_version = qla24xx_get_flash_version,
1529 .start_scsi = qla24xx_start_scsi, 1590 .start_scsi = qla24xx_start_scsi,
1591 .abort_isp = qla2x00_abort_isp,
1592};
1593
1594static struct isp_operations qla82xx_isp_ops = {
1595 .pci_config = qla82xx_pci_config,
1596 .reset_chip = qla82xx_reset_chip,
1597 .chip_diag = qla24xx_chip_diag,
1598 .config_rings = qla82xx_config_rings,
1599 .reset_adapter = qla24xx_reset_adapter,
1600 .nvram_config = qla81xx_nvram_config,
1601 .update_fw_options = qla24xx_update_fw_options,
1602 .load_risc = qla82xx_load_risc,
1603 .pci_info_str = qla82xx_pci_info_str,
1604 .fw_version_str = qla24xx_fw_version_str,
1605 .intr_handler = qla82xx_intr_handler,
1606 .enable_intrs = qla82xx_enable_intrs,
1607 .disable_intrs = qla82xx_disable_intrs,
1608 .abort_command = qla24xx_abort_command,
1609 .target_reset = qla24xx_abort_target,
1610 .lun_reset = qla24xx_lun_reset,
1611 .fabric_login = qla24xx_login_fabric,
1612 .fabric_logout = qla24xx_fabric_logout,
1613 .calc_req_entries = NULL,
1614 .build_iocbs = NULL,
1615 .prep_ms_iocb = qla24xx_prep_ms_iocb,
1616 .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb,
1617 .read_nvram = qla24xx_read_nvram_data,
1618 .write_nvram = qla24xx_write_nvram_data,
1619 .fw_dump = qla24xx_fw_dump,
1620 .beacon_on = qla24xx_beacon_on,
1621 .beacon_off = qla24xx_beacon_off,
1622 .beacon_blink = qla24xx_beacon_blink,
1623 .read_optrom = qla82xx_read_optrom_data,
1624 .write_optrom = qla82xx_write_optrom_data,
1625 .get_flash_version = qla24xx_get_flash_version,
1626 .start_scsi = qla82xx_start_scsi,
1627 .abort_isp = qla82xx_abort_isp,
1530}; 1628};
1531 1629
1532static inline void 1630static inline void
@@ -1615,10 +1713,22 @@ qla2x00_set_isp_flags(struct qla_hw_data *ha)
1615 ha->device_type |= DT_IIDMA; 1713 ha->device_type |= DT_IIDMA;
1616 ha->fw_srisc_address = RISC_START_ADDRESS_2400; 1714 ha->fw_srisc_address = RISC_START_ADDRESS_2400;
1617 break; 1715 break;
1716 case PCI_DEVICE_ID_QLOGIC_ISP8021:
1717 ha->device_type |= DT_ISP8021;
1718 ha->device_type |= DT_ZIO_SUPPORTED;
1719 ha->device_type |= DT_FWI2;
1720 ha->fw_srisc_address = RISC_START_ADDRESS_2400;
1721 /* Initialize 82XX ISP flags */
1722 qla82xx_init_flags(ha);
1723 break;
1618 } 1724 }
1619 1725
1620 /* Get adapter physical port no from interrupt pin register. */ 1726 if (IS_QLA82XX(ha))
1621 pci_read_config_byte(ha->pdev, PCI_INTERRUPT_PIN, &ha->port_no); 1727 ha->port_no = !(ha->portnum & 1);
1728 else
1729 /* Get adapter physical port no from interrupt pin register. */
1730 pci_read_config_byte(ha->pdev, PCI_INTERRUPT_PIN, &ha->port_no);
1731
1622 if (ha->port_no & 1) 1732 if (ha->port_no & 1)
1623 ha->flags.port0 = 1; 1733 ha->flags.port0 = 1;
1624 else 1734 else
@@ -1632,6 +1742,9 @@ qla2x00_iospace_config(struct qla_hw_data *ha)
1632 uint16_t msix; 1742 uint16_t msix;
1633 int cpus; 1743 int cpus;
1634 1744
1745 if (IS_QLA82XX(ha))
1746 return qla82xx_iospace_config(ha);
1747
1635 if (pci_request_selected_regions(ha->pdev, ha->bars, 1748 if (pci_request_selected_regions(ha->pdev, ha->bars,
1636 QLA2XXX_DRIVER_NAME)) { 1749 QLA2XXX_DRIVER_NAME)) {
1637 qla_printk(KERN_WARNING, ha, 1750 qla_printk(KERN_WARNING, ha,
@@ -1775,7 +1888,8 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
1775 pdev->device == PCI_DEVICE_ID_QLOGIC_ISP5422 || 1888 pdev->device == PCI_DEVICE_ID_QLOGIC_ISP5422 ||
1776 pdev->device == PCI_DEVICE_ID_QLOGIC_ISP5432 || 1889 pdev->device == PCI_DEVICE_ID_QLOGIC_ISP5432 ||
1777 pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2532 || 1890 pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2532 ||
1778 pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8001) { 1891 pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8001 ||
1892 pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8021) {
1779 bars = pci_select_bars(pdev, IORESOURCE_MEM); 1893 bars = pci_select_bars(pdev, IORESOURCE_MEM);
1780 mem_only = 1; 1894 mem_only = 1;
1781 } 1895 }
@@ -1905,6 +2019,19 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
1905 ha->flash_data_off = FARX_ACCESS_FLASH_DATA_81XX; 2019 ha->flash_data_off = FARX_ACCESS_FLASH_DATA_81XX;
1906 ha->nvram_conf_off = ~0; 2020 ha->nvram_conf_off = ~0;
1907 ha->nvram_data_off = ~0; 2021 ha->nvram_data_off = ~0;
2022 } else if (IS_QLA82XX(ha)) {
2023 ha->mbx_count = MAILBOX_REGISTER_COUNT;
2024 req_length = REQUEST_ENTRY_CNT_82XX;
2025 rsp_length = RESPONSE_ENTRY_CNT_82XX;
2026 ha->max_loop_id = SNS_LAST_LOOP_ID_2300;
2027 ha->init_cb_size = sizeof(struct mid_init_cb_81xx);
2028 ha->gid_list_info_size = 8;
2029 ha->optrom_size = OPTROM_SIZE_82XX;
2030 ha->isp_ops = &qla82xx_isp_ops;
2031 ha->flash_conf_off = FARX_ACCESS_FLASH_CONF;
2032 ha->flash_data_off = FARX_ACCESS_FLASH_DATA;
2033 ha->nvram_conf_off = FARX_ACCESS_NVRAM_CONF;
2034 ha->nvram_data_off = FARX_ACCESS_NVRAM_DATA;
1908 } 2035 }
1909 2036
1910 mutex_init(&ha->vport_lock); 2037 mutex_init(&ha->vport_lock);
@@ -1977,6 +2104,7 @@ que_init:
1977 " pointers\n"); 2104 " pointers\n");
1978 goto probe_init_failed; 2105 goto probe_init_failed;
1979 } 2106 }
2107
1980 ha->rsp_q_map[0] = rsp; 2108 ha->rsp_q_map[0] = rsp;
1981 ha->req_q_map[0] = req; 2109 ha->req_q_map[0] = req;
1982 rsp->req = req; 2110 rsp->req = req;
@@ -1995,6 +2123,12 @@ que_init:
1995 rsp->rsp_q_out = &ha->mqiobase->isp25mq.rsp_q_out; 2123 rsp->rsp_q_out = &ha->mqiobase->isp25mq.rsp_q_out;
1996 } 2124 }
1997 2125
2126 if (IS_QLA82XX(ha)) {
2127 req->req_q_out = &ha->iobase->isp82.req_q_out[0];
2128 rsp->rsp_q_in = &ha->iobase->isp82.rsp_q_in[0];
2129 rsp->rsp_q_out = &ha->iobase->isp82.rsp_q_out[0];
2130 }
2131
1998 if (qla2x00_initialize_adapter(base_vha)) { 2132 if (qla2x00_initialize_adapter(base_vha)) {
1999 qla_printk(KERN_WARNING, ha, 2133 qla_printk(KERN_WARNING, ha,
2000 "Failed to initialize adapter\n"); 2134 "Failed to initialize adapter\n");
@@ -2003,6 +2137,14 @@ que_init:
2003 "Adapter flags %x.\n", 2137 "Adapter flags %x.\n",
2004 base_vha->host_no, base_vha->device_flags)); 2138 base_vha->host_no, base_vha->device_flags));
2005 2139
2140 if (IS_QLA82XX(ha)) {
2141 qla82xx_idc_lock(ha);
2142 qla82xx_wr_32(ha, QLA82XX_CRB_DEV_STATE,
2143 QLA82XX_DEV_FAILED);
2144 qla82xx_idc_unlock(ha);
2145 qla_printk(KERN_INFO, ha, "HW State: FAILED\n");
2146 }
2147
2006 ret = -ENODEV; 2148 ret = -ENODEV;
2007 goto probe_failed; 2149 goto probe_failed;
2008 } 2150 }
@@ -2041,6 +2183,8 @@ skip_dpc:
2041 DEBUG2(printk("DEBUG: detect hba %ld at address = %p\n", 2183 DEBUG2(printk("DEBUG: detect hba %ld at address = %p\n",
2042 base_vha->host_no, ha)); 2184 base_vha->host_no, ha));
2043 2185
2186 ha->isp_ops->enable_intrs(ha);
2187
2044 ret = scsi_add_host(host, &pdev->dev); 2188 ret = scsi_add_host(host, &pdev->dev);
2045 if (ret) 2189 if (ret)
2046 goto probe_failed; 2190 goto probe_failed;
@@ -2048,8 +2192,6 @@ skip_dpc:
2048 base_vha->flags.init_done = 1; 2192 base_vha->flags.init_done = 1;
2049 base_vha->flags.online = 1; 2193 base_vha->flags.online = 1;
2050 2194
2051 ha->isp_ops->enable_intrs(ha);
2052
2053 scsi_scan_host(host); 2195 scsi_scan_host(host);
2054 2196
2055 qla2x00_alloc_sysfs_attr(base_vha); 2197 qla2x00_alloc_sysfs_attr(base_vha);
@@ -2091,9 +2233,17 @@ probe_failed:
2091 scsi_host_put(base_vha->host); 2233 scsi_host_put(base_vha->host);
2092 2234
2093probe_hw_failed: 2235probe_hw_failed:
2094 if (ha->iobase) 2236 if (IS_QLA82XX(ha)) {
2095 iounmap(ha->iobase); 2237 qla82xx_idc_lock(ha);
2096 2238 qla82xx_clear_drv_active(ha);
2239 qla82xx_idc_unlock(ha);
2240 iounmap((device_reg_t __iomem *)ha->nx_pcibase);
2241 if (!ql2xdbwr)
2242 iounmap((device_reg_t __iomem *)ha->nxdb_wr_ptr);
2243 } else {
2244 if (ha->iobase)
2245 iounmap(ha->iobase);
2246 }
2097 pci_release_selected_regions(ha->pdev, ha->bars); 2247 pci_release_selected_regions(ha->pdev, ha->bars);
2098 kfree(ha); 2248 kfree(ha);
2099 ha = NULL; 2249 ha = NULL;
@@ -2160,11 +2310,17 @@ qla2x00_remove_one(struct pci_dev *pdev)
2160 2310
2161 scsi_host_put(base_vha->host); 2311 scsi_host_put(base_vha->host);
2162 2312
2163 if (ha->iobase) 2313 if (IS_QLA82XX(ha)) {
2164 iounmap(ha->iobase); 2314 iounmap((device_reg_t __iomem *)ha->nx_pcibase);
2315 if (!ql2xdbwr)
2316 iounmap((device_reg_t __iomem *)ha->nxdb_wr_ptr);
2317 } else {
2318 if (ha->iobase)
2319 iounmap(ha->iobase);
2165 2320
2166 if (ha->mqiobase) 2321 if (ha->mqiobase)
2167 iounmap(ha->mqiobase); 2322 iounmap(ha->mqiobase);
2323 }
2168 2324
2169 pci_release_selected_regions(ha->pdev, ha->bars); 2325 pci_release_selected_regions(ha->pdev, ha->bars);
2170 kfree(ha); 2326 kfree(ha);
@@ -2213,8 +2369,10 @@ qla2x00_free_device(scsi_qla_host_t *vha)
2213 vha->flags.online = 0; 2369 vha->flags.online = 0;
2214 2370
2215 /* turn-off interrupts on the card */ 2371 /* turn-off interrupts on the card */
2216 if (ha->interrupts_on) 2372 if (ha->interrupts_on) {
2373 vha->flags.init_done = 0;
2217 ha->isp_ops->disable_intrs(ha); 2374 ha->isp_ops->disable_intrs(ha);
2375 }
2218 2376
2219 qla2x00_free_irqs(vha); 2377 qla2x00_free_irqs(vha);
2220 2378
@@ -2359,10 +2517,25 @@ qla2x00_mem_alloc(struct qla_hw_data *ha, uint16_t req_len, uint16_t rsp_len,
2359 if (!ha->srb_mempool) 2517 if (!ha->srb_mempool)
2360 goto fail_free_gid_list; 2518 goto fail_free_gid_list;
2361 2519
2520 if (IS_QLA82XX(ha)) {
2521 /* Allocate cache for CT6 Ctx. */
2522 if (!ctx_cachep) {
2523 ctx_cachep = kmem_cache_create("qla2xxx_ctx",
2524 sizeof(struct ct6_dsd), 0,
2525 SLAB_HWCACHE_ALIGN, NULL);
2526 if (!ctx_cachep)
2527 goto fail_free_gid_list;
2528 }
2529 ha->ctx_mempool = mempool_create_slab_pool(SRB_MIN_REQ,
2530 ctx_cachep);
2531 if (!ha->ctx_mempool)
2532 goto fail_free_srb_mempool;
2533 }
2534
2362 /* Get memory for cached NVRAM */ 2535 /* Get memory for cached NVRAM */
2363 ha->nvram = kzalloc(MAX_NVRAM_SIZE, GFP_KERNEL); 2536 ha->nvram = kzalloc(MAX_NVRAM_SIZE, GFP_KERNEL);
2364 if (!ha->nvram) 2537 if (!ha->nvram)
2365 goto fail_free_srb_mempool; 2538 goto fail_free_ctx_mempool;
2366 2539
2367 snprintf(name, sizeof(name), "%s_%d", QLA2XXX_DRIVER_NAME, 2540 snprintf(name, sizeof(name), "%s_%d", QLA2XXX_DRIVER_NAME,
2368 ha->pdev->device); 2541 ha->pdev->device);
@@ -2371,6 +2544,24 @@ qla2x00_mem_alloc(struct qla_hw_data *ha, uint16_t req_len, uint16_t rsp_len,
2371 if (!ha->s_dma_pool) 2544 if (!ha->s_dma_pool)
2372 goto fail_free_nvram; 2545 goto fail_free_nvram;
2373 2546
2547 if (IS_QLA82XX(ha)) {
2548 ha->dl_dma_pool = dma_pool_create(name, &ha->pdev->dev,
2549 DSD_LIST_DMA_POOL_SIZE, 8, 0);
2550 if (!ha->dl_dma_pool) {
2551 qla_printk(KERN_WARNING, ha,
2552 "Memory Allocation failed - dl_dma_pool\n");
2553 goto fail_s_dma_pool;
2554 }
2555
2556 ha->fcp_cmnd_dma_pool = dma_pool_create(name, &ha->pdev->dev,
2557 FCP_CMND_DMA_POOL_SIZE, 8, 0);
2558 if (!ha->fcp_cmnd_dma_pool) {
2559 qla_printk(KERN_WARNING, ha,
2560 "Memory Allocation failed - fcp_cmnd_dma_pool\n");
2561 goto fail_dl_dma_pool;
2562 }
2563 }
2564
2374 /* Allocate memory for SNS commands */ 2565 /* Allocate memory for SNS commands */
2375 if (IS_QLA2100(ha) || IS_QLA2200(ha)) { 2566 if (IS_QLA2100(ha) || IS_QLA2200(ha)) {
2376 /* Get consistent memory allocated for SNS commands */ 2567 /* Get consistent memory allocated for SNS commands */
@@ -2437,13 +2628,15 @@ qla2x00_mem_alloc(struct qla_hw_data *ha, uint16_t req_len, uint16_t rsp_len,
2437 ha->npiv_info = NULL; 2628 ha->npiv_info = NULL;
2438 2629
2439 /* Get consistent memory allocated for EX-INIT-CB. */ 2630 /* Get consistent memory allocated for EX-INIT-CB. */
2440 if (IS_QLA81XX(ha)) { 2631 if (IS_QLA8XXX_TYPE(ha)) {
2441 ha->ex_init_cb = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, 2632 ha->ex_init_cb = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL,
2442 &ha->ex_init_cb_dma); 2633 &ha->ex_init_cb_dma);
2443 if (!ha->ex_init_cb) 2634 if (!ha->ex_init_cb)
2444 goto fail_ex_init_cb; 2635 goto fail_ex_init_cb;
2445 } 2636 }
2446 2637
2638 INIT_LIST_HEAD(&ha->gbl_dsd_list);
2639
2447 INIT_LIST_HEAD(&ha->vp_list); 2640 INIT_LIST_HEAD(&ha->vp_list);
2448 return 1; 2641 return 1;
2449 2642
@@ -2473,11 +2666,24 @@ fail_free_ms_iocb:
2473 ha->ms_iocb = NULL; 2666 ha->ms_iocb = NULL;
2474 ha->ms_iocb_dma = 0; 2667 ha->ms_iocb_dma = 0;
2475fail_dma_pool: 2668fail_dma_pool:
2669 if (IS_QLA82XX(ha)) {
2670 dma_pool_destroy(ha->fcp_cmnd_dma_pool);
2671 ha->fcp_cmnd_dma_pool = NULL;
2672 }
2673fail_dl_dma_pool:
2674 if (IS_QLA82XX(ha)) {
2675 dma_pool_destroy(ha->dl_dma_pool);
2676 ha->dl_dma_pool = NULL;
2677 }
2678fail_s_dma_pool:
2476 dma_pool_destroy(ha->s_dma_pool); 2679 dma_pool_destroy(ha->s_dma_pool);
2477 ha->s_dma_pool = NULL; 2680 ha->s_dma_pool = NULL;
2478fail_free_nvram: 2681fail_free_nvram:
2479 kfree(ha->nvram); 2682 kfree(ha->nvram);
2480 ha->nvram = NULL; 2683 ha->nvram = NULL;
2684fail_free_ctx_mempool:
2685 mempool_destroy(ha->ctx_mempool);
2686 ha->ctx_mempool = NULL;
2481fail_free_srb_mempool: 2687fail_free_srb_mempool:
2482 mempool_destroy(ha->srb_mempool); 2688 mempool_destroy(ha->srb_mempool);
2483 ha->srb_mempool = NULL; 2689 ha->srb_mempool = NULL;
@@ -2546,7 +2752,8 @@ qla2x00_mem_free(struct qla_hw_data *ha)
2546 dma_pool_free(ha->s_dma_pool, ha->ms_iocb, ha->ms_iocb_dma); 2752 dma_pool_free(ha->s_dma_pool, ha->ms_iocb, ha->ms_iocb_dma);
2547 2753
2548 if (ha->ex_init_cb) 2754 if (ha->ex_init_cb)
2549 dma_pool_free(ha->s_dma_pool, ha->ex_init_cb, ha->ex_init_cb_dma); 2755 dma_pool_free(ha->s_dma_pool,
2756 ha->ex_init_cb, ha->ex_init_cb_dma);
2550 2757
2551 if (ha->s_dma_pool) 2758 if (ha->s_dma_pool)
2552 dma_pool_destroy(ha->s_dma_pool); 2759 dma_pool_destroy(ha->s_dma_pool);
@@ -2555,14 +2762,39 @@ qla2x00_mem_free(struct qla_hw_data *ha)
2555 dma_free_coherent(&ha->pdev->dev, GID_LIST_SIZE, ha->gid_list, 2762 dma_free_coherent(&ha->pdev->dev, GID_LIST_SIZE, ha->gid_list,
2556 ha->gid_list_dma); 2763 ha->gid_list_dma);
2557 2764
2765 if (IS_QLA82XX(ha)) {
2766 if (!list_empty(&ha->gbl_dsd_list)) {
2767 struct dsd_dma *dsd_ptr, *tdsd_ptr;
2768
2769 /* clean up allocated prev pool */
2770 list_for_each_entry_safe(dsd_ptr,
2771 tdsd_ptr, &ha->gbl_dsd_list, list) {
2772 dma_pool_free(ha->dl_dma_pool,
2773 dsd_ptr->dsd_addr, dsd_ptr->dsd_list_dma);
2774 list_del(&dsd_ptr->list);
2775 kfree(dsd_ptr);
2776 }
2777 }
2778 }
2779
2780 if (ha->dl_dma_pool)
2781 dma_pool_destroy(ha->dl_dma_pool);
2782
2783 if (ha->fcp_cmnd_dma_pool)
2784 dma_pool_destroy(ha->fcp_cmnd_dma_pool);
2785
2786 if (ha->ctx_mempool)
2787 mempool_destroy(ha->ctx_mempool);
2788
2558 if (ha->init_cb) 2789 if (ha->init_cb)
2559 dma_free_coherent(&ha->pdev->dev, ha->init_cb_size, 2790 dma_free_coherent(&ha->pdev->dev, ha->init_cb_size,
2560 ha->init_cb, ha->init_cb_dma); 2791 ha->init_cb, ha->init_cb_dma);
2561 vfree(ha->optrom_buffer); 2792 vfree(ha->optrom_buffer);
2562 kfree(ha->nvram); 2793 kfree(ha->nvram);
2563 kfree(ha->npiv_info); 2794 kfree(ha->npiv_info);
2564 2795
2565 ha->srb_mempool = NULL; 2796 ha->srb_mempool = NULL;
2797 ha->ctx_mempool = NULL;
2566 ha->eft = NULL; 2798 ha->eft = NULL;
2567 ha->eft_dma = 0; 2799 ha->eft_dma = 0;
2568 ha->sns_cmd = NULL; 2800 ha->sns_cmd = NULL;
@@ -2577,6 +2809,8 @@ qla2x00_mem_free(struct qla_hw_data *ha)
2577 ha->ex_init_cb_dma = 0; 2809 ha->ex_init_cb_dma = 0;
2578 2810
2579 ha->s_dma_pool = NULL; 2811 ha->s_dma_pool = NULL;
2812 ha->dl_dma_pool = NULL;
2813 ha->fcp_cmnd_dma_pool = NULL;
2580 2814
2581 ha->gid_list = NULL; 2815 ha->gid_list = NULL;
2582 ha->gid_list_dma = 0; 2816 ha->gid_list_dma = 0;
@@ -2904,6 +3138,45 @@ qla2x00_do_dpc(void *data)
2904 3138
2905 qla2x00_do_work(base_vha); 3139 qla2x00_do_work(base_vha);
2906 3140
3141 if (IS_QLA82XX(ha)) {
3142 if (test_and_clear_bit(ISP_UNRECOVERABLE,
3143 &base_vha->dpc_flags)) {
3144 qla82xx_idc_lock(ha);
3145 qla82xx_wr_32(ha, QLA82XX_CRB_DEV_STATE,
3146 QLA82XX_DEV_FAILED);
3147 qla82xx_idc_unlock(ha);
3148 qla_printk(KERN_INFO, ha,
3149 "HW State: FAILED\n");
3150 qla82xx_device_state_handler(base_vha);
3151 continue;
3152 }
3153
3154 if (test_and_clear_bit(FCOE_CTX_RESET_NEEDED,
3155 &base_vha->dpc_flags)) {
3156
3157 DEBUG(printk(KERN_INFO
3158 "scsi(%ld): dpc: sched "
3159 "qla82xx_fcoe_ctx_reset ha = %p\n",
3160 base_vha->host_no, ha));
3161 if (!(test_and_set_bit(ABORT_ISP_ACTIVE,
3162 &base_vha->dpc_flags))) {
3163 if (qla82xx_fcoe_ctx_reset(base_vha)) {
3164 /* FCoE-ctx reset failed.
3165 * Escalate to chip-reset
3166 */
3167 set_bit(ISP_ABORT_NEEDED,
3168 &base_vha->dpc_flags);
3169 }
3170 clear_bit(ABORT_ISP_ACTIVE,
3171 &base_vha->dpc_flags);
3172 }
3173
3174 DEBUG(printk("scsi(%ld): dpc:"
3175 " qla82xx_fcoe_ctx_reset end\n",
3176 base_vha->host_no));
3177 }
3178 }
3179
2907 if (test_and_clear_bit(ISP_ABORT_NEEDED, 3180 if (test_and_clear_bit(ISP_ABORT_NEEDED,
2908 &base_vha->dpc_flags)) { 3181 &base_vha->dpc_flags)) {
2909 3182
@@ -2913,7 +3186,7 @@ qla2x00_do_dpc(void *data)
2913 if (!(test_and_set_bit(ABORT_ISP_ACTIVE, 3186 if (!(test_and_set_bit(ABORT_ISP_ACTIVE,
2914 &base_vha->dpc_flags))) { 3187 &base_vha->dpc_flags))) {
2915 3188
2916 if (qla2x00_abort_isp(base_vha)) { 3189 if (ha->isp_ops->abort_isp(base_vha)) {
2917 /* failed. retry later */ 3190 /* failed. retry later */
2918 set_bit(ISP_ABORT_NEEDED, 3191 set_bit(ISP_ABORT_NEEDED,
2919 &base_vha->dpc_flags); 3192 &base_vha->dpc_flags);
@@ -3061,8 +3334,18 @@ qla2x00_sp_compl(struct qla_hw_data *ha, srb_t *sp)
3061 3334
3062 qla2x00_sp_free_dma(sp); 3335 qla2x00_sp_free_dma(sp);
3063 3336
3064 mempool_free(sp, ha->srb_mempool); 3337 if (sp->flags & SRB_FCP_CMND_DMA_VALID) {
3338 struct ct6_dsd *ctx = sp->ctx;
3339 dma_pool_free(ha->fcp_cmnd_dma_pool, ctx->fcp_cmnd,
3340 ctx->fcp_cmnd_dma);
3341 list_splice(&ctx->dsd_list, &ha->gbl_dsd_list);
3342 ha->gbl_dsd_inuse -= ctx->dsd_use_cnt;
3343 ha->gbl_dsd_avail += ctx->dsd_use_cnt;
3344 mempool_free(sp->ctx, ha->ctx_mempool);
3345 sp->ctx = NULL;
3346 }
3065 3347
3348 mempool_free(sp, ha->srb_mempool);
3066 cmd->scsi_done(cmd); 3349 cmd->scsi_done(cmd);
3067} 3350}
3068 3351
@@ -3087,6 +3370,9 @@ qla2x00_timer(scsi_qla_host_t *vha)
3087 struct qla_hw_data *ha = vha->hw; 3370 struct qla_hw_data *ha = vha->hw;
3088 struct req_que *req; 3371 struct req_que *req;
3089 3372
3373 if (IS_QLA82XX(ha))
3374 qla82xx_watchdog(vha);
3375
3090 /* Hardware read to raise pending EEH errors during mailbox waits. */ 3376 /* Hardware read to raise pending EEH errors during mailbox waits. */
3091 if (!pci_channel_offline(ha->pdev)) 3377 if (!pci_channel_offline(ha->pdev))
3092 pci_read_config_word(ha->pdev, PCI_VENDOR_ID, &w); 3378 pci_read_config_word(ha->pdev, PCI_VENDOR_ID, &w);
@@ -3201,6 +3487,8 @@ qla2x00_timer(scsi_qla_host_t *vha)
3201 start_dpc || 3487 start_dpc ||
3202 test_bit(RESET_MARKER_NEEDED, &vha->dpc_flags) || 3488 test_bit(RESET_MARKER_NEEDED, &vha->dpc_flags) ||
3203 test_bit(BEACON_BLINK_NEEDED, &vha->dpc_flags) || 3489 test_bit(BEACON_BLINK_NEEDED, &vha->dpc_flags) ||
3490 test_bit(ISP_UNRECOVERABLE, &vha->dpc_flags) ||
3491 test_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags) ||
3204 test_bit(VP_DPC_NEEDED, &vha->dpc_flags) || 3492 test_bit(VP_DPC_NEEDED, &vha->dpc_flags) ||
3205 test_bit(RELOGIN_NEEDED, &vha->dpc_flags))) 3493 test_bit(RELOGIN_NEEDED, &vha->dpc_flags)))
3206 qla2xxx_wake_dpc(vha); 3494 qla2xxx_wake_dpc(vha);
@@ -3210,7 +3498,7 @@ qla2x00_timer(scsi_qla_host_t *vha)
3210 3498
3211/* Firmware interface routines. */ 3499/* Firmware interface routines. */
3212 3500
3213#define FW_BLOBS 7 3501#define FW_BLOBS 8
3214#define FW_ISP21XX 0 3502#define FW_ISP21XX 0
3215#define FW_ISP22XX 1 3503#define FW_ISP22XX 1
3216#define FW_ISP2300 2 3504#define FW_ISP2300 2
@@ -3218,6 +3506,7 @@ qla2x00_timer(scsi_qla_host_t *vha)
3218#define FW_ISP24XX 4 3506#define FW_ISP24XX 4
3219#define FW_ISP25XX 5 3507#define FW_ISP25XX 5
3220#define FW_ISP81XX 6 3508#define FW_ISP81XX 6
3509#define FW_ISP82XX 7
3221 3510
3222#define FW_FILE_ISP21XX "ql2100_fw.bin" 3511#define FW_FILE_ISP21XX "ql2100_fw.bin"
3223#define FW_FILE_ISP22XX "ql2200_fw.bin" 3512#define FW_FILE_ISP22XX "ql2200_fw.bin"
@@ -3226,6 +3515,7 @@ qla2x00_timer(scsi_qla_host_t *vha)
3226#define FW_FILE_ISP24XX "ql2400_fw.bin" 3515#define FW_FILE_ISP24XX "ql2400_fw.bin"
3227#define FW_FILE_ISP25XX "ql2500_fw.bin" 3516#define FW_FILE_ISP25XX "ql2500_fw.bin"
3228#define FW_FILE_ISP81XX "ql8100_fw.bin" 3517#define FW_FILE_ISP81XX "ql8100_fw.bin"
3518#define FW_FILE_ISP82XX "ql8200_fw.bin"
3229 3519
3230static DEFINE_MUTEX(qla_fw_lock); 3520static DEFINE_MUTEX(qla_fw_lock);
3231 3521
@@ -3237,6 +3527,7 @@ static struct fw_blob qla_fw_blobs[FW_BLOBS] = {
3237 { .name = FW_FILE_ISP24XX, }, 3527 { .name = FW_FILE_ISP24XX, },
3238 { .name = FW_FILE_ISP25XX, }, 3528 { .name = FW_FILE_ISP25XX, },
3239 { .name = FW_FILE_ISP81XX, }, 3529 { .name = FW_FILE_ISP81XX, },
3530 { .name = FW_FILE_ISP82XX, },
3240}; 3531};
3241 3532
3242struct fw_blob * 3533struct fw_blob *
@@ -3260,6 +3551,8 @@ qla2x00_request_firmware(scsi_qla_host_t *vha)
3260 blob = &qla_fw_blobs[FW_ISP25XX]; 3551 blob = &qla_fw_blobs[FW_ISP25XX];
3261 } else if (IS_QLA81XX(ha)) { 3552 } else if (IS_QLA81XX(ha)) {
3262 blob = &qla_fw_blobs[FW_ISP81XX]; 3553 blob = &qla_fw_blobs[FW_ISP81XX];
3554 } else if (IS_QLA82XX(ha)) {
3555 blob = &qla_fw_blobs[FW_ISP82XX];
3263 } 3556 }
3264 3557
3265 mutex_lock(&qla_fw_lock); 3558 mutex_lock(&qla_fw_lock);
@@ -3400,7 +3693,7 @@ qla2xxx_pci_slot_reset(struct pci_dev *pdev)
3400 msleep(1000); 3693 msleep(1000);
3401 3694
3402 set_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); 3695 set_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags);
3403 if (qla2x00_abort_isp(base_vha) == QLA_SUCCESS) 3696 if (ha->isp_ops->abort_isp(base_vha) == QLA_SUCCESS)
3404 ret = PCI_ERS_RESULT_RECOVERED; 3697 ret = PCI_ERS_RESULT_RECOVERED;
3405 clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); 3698 clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags);
3406 3699
@@ -3453,6 +3746,7 @@ static struct pci_device_id qla2xxx_pci_tbl[] = {
3453 { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP5432) }, 3746 { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP5432) },
3454 { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2532) }, 3747 { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2532) },
3455 { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8001) }, 3748 { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8001) },
3749 { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8021) },
3456 { 0 }, 3750 { 0 },
3457}; 3751};
3458MODULE_DEVICE_TABLE(pci, qla2xxx_pci_tbl); 3752MODULE_DEVICE_TABLE(pci, qla2xxx_pci_tbl);
@@ -3524,6 +3818,8 @@ qla2x00_module_exit(void)
3524 pci_unregister_driver(&qla2xxx_pci_driver); 3818 pci_unregister_driver(&qla2xxx_pci_driver);
3525 qla2x00_release_firmware(); 3819 qla2x00_release_firmware();
3526 kmem_cache_destroy(srb_cachep); 3820 kmem_cache_destroy(srb_cachep);
3821 if (ctx_cachep)
3822 kmem_cache_destroy(ctx_cachep);
3527 fc_release_transport(qla2xxx_transport_template); 3823 fc_release_transport(qla2xxx_transport_template);
3528 fc_release_transport(qla2xxx_transport_vport_template); 3824 fc_release_transport(qla2xxx_transport_vport_template);
3529} 3825}