15 #include <linux/slab.h>
28 static int apidev_major;
47 "Specify if Class 2 operations are supported from the very "
48 "beginning. Default is 0 - class 2 not supported.");
53 "Login timeout value in seconds.");
58 "Maximum number of command retries to a port that returns "
59 "a PORT-DOWN status.");
64 "Option to enable PLOGI to devices that are not present after "
65 "a Fabric scan. This is needed for several broken switches. "
66 "Default is 0 - no PLOGI. 1 - perfom PLOGI.");
71 "Specify an alternate value for the NVRAM login retry count.");
76 "Option to enable allocation of memory for a firmware dump "
77 "during HBA initialization. Memory allocation requirements "
78 "vary by ISP type. Default is 1 - allocate memory.");
83 "Option to enable extended error logging,\n"
84 "\t\tDefault is 0 - no logging. 0x40000000 - Module Init & Probe.\n"
85 "\t\t0x20000000 - Mailbox Cmnds. 0x10000000 - Device Discovery.\n"
86 "\t\t0x08000000 - IO tracing. 0x04000000 - DPC Thread.\n"
87 "\t\t0x02000000 - Async events. 0x01000000 - Timer routines.\n"
88 "\t\t0x00800000 - User space. 0x00400000 - Task Management.\n"
89 "\t\t0x00200000 - AER/EEH. 0x00100000 - Multi Q.\n"
90 "\t\t0x00080000 - P3P Specific. 0x00040000 - Virtual Port.\n"
91 "\t\t0x00020000 - Buffer Dump. 0x00010000 - Misc.\n"
92 "\t\t0x7fffffff - For enabling all logs, can be too many logs.\n"
93 "\t\t0x1e400000 - Preferred value for capturing essential "
94 "debug information (equivalent to old "
95 "ql2xextended_error_logging=1).\n"
96 "\t\tDo LOGICAL OR of the value to enable more than one level");
101 "Set to control shifting of command type processing "
102 "based on total number of SG elements.");
109 "Enables FDMI registrations. "
110 "0 - no FDMI. Default is 1 - perform FDMI.");
112 #define MAX_Q_DEPTH 32
116 "Maximum queue depth to set for each LUN. "
122 " Enable T10-CRC-DIF "
123 " Default is 0 - No DIF Support. 1 - Enable it"
124 ", 2 - Enable DIF for all types, except Type 0.");
129 " Enable T10-CRC-DIF Error isolation by HBA:\n"
131 " 0 -- Error isolation disabled\n"
132 " 1 -- Error isolation enabled only for DIX Type 0\n"
133 " 2 -- Error isolation enabled for all Types\n");
138 "Enables iIDMA settings "
139 "Default is 1 - perform iIDMA. 0 - no iIDMA.");
144 "Enables MQ settings "
145 "Default is 1 for single queue. Set it to number "
146 "of queues in MQ mode.");
151 "Enables CPU affinity settings for the driver "
152 "Default is 0 for no affinity of request and response IO. "
153 "Set it to 1 to turn on the cpu affinity.");
158 "Option to specify location from which to load ISP firmware:.\n"
159 " 2 -- load firmware via the request_firmware() (hotplug).\n"
161 " 1 -- load firmware from flash.\n"
162 " 0 -- use default semantics.\n");
167 "Enables firmware ETS burst."
168 "Default is 0 - skip ETS enablement.");
173 "Option to specify scheme for request queue posting.\n"
174 " 0 -- Regular doorbell.\n"
175 " 1 -- CAMRAM doorbell (faster).\n");
180 "Enable target reset."
181 "Default is 1 - use hw defaults.");
186 "Enables GFF_ID checks of port type. "
187 "Default is 0 - Do not use GFF_ID information.");
192 "Enables issue of TM IOCBs asynchronously via IOCB mechanism"
193 "Default is 0 - Issue TM IOCBs via mailbox mechanism.");
198 "Option to specify reset behaviour.\n"
199 " 0 (Default) -- Reset on failure.\n"
200 " 1 -- Do not reset on failure.\n");
205 "Defines the maximum LU number to register with the SCSI "
206 "midlayer. Default is 65535.");
211 "Set the Minidump driver capture mask level. "
212 "Default is 0x1F - Can be set to 0x3, 0x7, 0xF, 0x1F, 0x7F.");
217 "Enable/disable MiniDump. "
218 "0 - MiniDump disabled. "
219 "1 (Default) - MiniDump enabled.");
225 static int qla2xxx_slave_alloc(
struct scsi_device *);
226 static int qla2xxx_scan_finished(
struct Scsi_Host *,
unsigned long time);
227 static void qla2xxx_scan_start(
struct Scsi_Host *);
228 static void qla2xxx_slave_destroy(
struct scsi_device *);
230 static int qla2xxx_eh_abort(
struct scsi_cmnd *);
231 static int qla2xxx_eh_device_reset(
struct scsi_cmnd *);
232 static int qla2xxx_eh_target_reset(
struct scsi_cmnd *);
233 static int qla2xxx_eh_bus_reset(
struct scsi_cmnd *);
234 static int qla2xxx_eh_host_reset(
struct scsi_cmnd *);
236 static int qla2x00_change_queue_depth(
struct scsi_device *,
int,
int);
237 static int qla2x00_change_queue_type(
struct scsi_device *,
int);
242 .queuecommand = qla2xxx_queuecommand,
244 .eh_abort_handler = qla2xxx_eh_abort,
245 .eh_device_reset_handler = qla2xxx_eh_device_reset,
246 .eh_target_reset_handler = qla2xxx_eh_target_reset,
247 .eh_bus_reset_handler = qla2xxx_eh_bus_reset,
248 .eh_host_reset_handler = qla2xxx_eh_host_reset,
250 .slave_configure = qla2xxx_slave_configure,
252 .slave_alloc = qla2xxx_slave_alloc,
253 .slave_destroy = qla2xxx_slave_destroy,
254 .scan_finished = qla2xxx_scan_finished,
255 .scan_start = qla2xxx_scan_start,
256 .change_queue_depth = qla2x00_change_queue_depth,
257 .change_queue_type = qla2x00_change_queue_type,
263 .max_sectors = 0xFFFF,
294 "Device in a failed state, returning.\n");
308 static int qla2x00_do_dpc(
void *
data);
314 static void qla2x00_free_fw_dump(
struct qla_hw_data *);
315 static void qla2x00_mem_free(
struct qla_hw_data *);
326 "Unable to allocate memory for request queue ptrs.\n");
334 "Unable to allocate memory for response queue ptrs.\n");
356 if (req && req->
ring)
367 if (rsp && rsp->
ring)
376 static void qla2x00_free_queues(
struct qla_hw_data *ha)
384 qla2x00_free_req_que(ha, req);
391 qla2x00_free_rsp_que(ha, rsp);
405 "Firmware is not multi-queue capable.\n");
415 "Failed to create request queue.\n");
425 "Failed to create response queue.\n");
429 ha->
flags.cpu_affinity_enabled = 1;
431 "CPU affinity mode enalbed, "
432 "no. of response queues:%d no. of request queues:%d.\n",
435 "CPU affinity mode enalbed, "
436 "no. of response queues:%d no. of request queues:%d.\n",
457 static char *pci_bus_modes[] = {
458 "33",
"66",
"100",
"133",
466 strcat(str, pci_bus_modes[pci_bus]);
470 strcat(str, pci_bus_modes[pci_bus]);
480 static char *pci_bus_modes[] = {
"33",
"66",
"100",
"133", };
485 pcie_reg = pci_pcie_cap(ha->
pdev);
488 uint16_t pcie_lstat, lspeed, lwidth;
491 pci_read_config_word(ha->
pdev, pcie_reg, &pcie_lstat);
493 lwidth = (pcie_lstat &
499 else if (lspeed == 2)
502 strcat(str,
"<unknown> ");
503 snprintf(lwstr,
sizeof(lwstr),
"x%d)", lwidth);
511 if (pci_bus == 0 || pci_bus == 8) {
513 strcat(str, pci_bus_modes[pci_bus >> 3]);
521 strcat(str, pci_bus_modes[pci_bus & ~BIT_2]);
598 qla2x00_clean_dsd_pool(ha, sp);
625 qla2x00_sp_compl(
void *
data,
void *
ptr,
int res)
635 "SP reference-count to ZERO -- sp=%p cmd=%p.\n",
659 if (ha->
flags.eeh_busy) {
660 if (ha->
flags.pci_channel_io_perm_failure) {
662 "PCI Channel IO permanent failure, exiting "
667 "EEH_Busy, Requeuing the cmd=%p.\n", cmd);
670 goto qc24_fail_command;
673 rval = fc_remote_port_chkready(
rport);
677 "fc_remote_port_chkready failed for cmd=%p, rval=0x%x.\n",
679 goto qc24_fail_command;
682 if (!vha->
flags.difdix_supported &&
685 "DIF Cap not reg, fail DIF capable cmd's:%p.\n",
688 goto qc24_fail_command;
693 goto qc24_fail_command;
700 "Returning DNC, fcport_state=%d loop_state=%d.\n",
704 goto qc24_fail_command;
706 goto qc24_target_busy;
709 sp = qla2x00_get_sp(base_vha, fcport,
GFP_ATOMIC);
718 sp->
done = qla2x00_sp_compl;
720 rval = ha->
isp_ops->start_scsi(sp);
723 "Start scsi failed rval=%d for cmd=%p.\n", rval, cmd);
724 goto qc24_host_busy_free_sp;
729 qc24_host_busy_free_sp:
757 qla2x00_eh_wait_on_command(
struct scsi_cmnd *cmd)
759 #define ABORT_POLLING_PERIOD 1000
760 #define ABORT_WAIT_ITER ((10 * 1000) / (ABORT_POLLING_PERIOD))
768 "Return:eh_wait.\n");
772 while (
CMD_SP(cmd) && wait_iter--) {
773 msleep(ABORT_POLLING_PERIOD);
802 unsigned long wait_online;
814 if (base_vha->
flags.online)
819 return (return_status);
844 unsigned long wait_online;
862 "%s return status=%d.\n", __func__, return_status);
864 return return_status;
871 unsigned long wait_reset;
884 ha->
flags.chip_reset_done)
887 if (ha->
flags.chip_reset_done)
892 return return_status;
896 sp_get(
struct srb *sp)
922 unsigned int id,
lun;
941 spin_unlock_irqrestore(&ha->hardware_lock, flags);
946 "Aborting from RISC nexus=%ld:%d:%d sp=%p cmd=%p\n",
947 vha->
host_no,
id, lun, sp, cmd);
952 spin_unlock_irqrestore(&ha->hardware_lock, flags);
953 if (ha->
isp_ops->abort_command(sp)) {
956 "Abort command mbx failed cmd=%p.\n", cmd);
959 "Abort command mbx success cmd=%p.\n", cmd);
965 spin_unlock_irqrestore(&ha->hardware_lock, flags);
973 if (qla2x00_eh_wait_on_command(cmd) !=
QLA_SUCCESS) {
975 "Abort handler timed out cmd=%p.\n", cmd);
981 "Abort command issued nexus=%ld:%d:%d -- %d %x.\n",
982 vha->
host_no,
id, lun, wait, ret);
1021 match = (cmd->
device->id == t &&
1028 spin_unlock_irqrestore(&ha->hardware_lock, flags);
1029 status = qla2x00_eh_wait_on_command(cmd);
1032 spin_unlock_irqrestore(&ha->hardware_lock, flags);
1037 static char *reset_errors[] = {
1040 "Task management failed",
1041 "Waiting for command completions",
1061 "%s RESET ISSUED nexus=%ld:%d:%d cmd=%p.\n", name, vha->
host_no,
1067 "Wait for hba online failed for cmd=%p.\n", cmd);
1068 goto eh_reset_failed;
1074 "do_reset failed for cmd=%p.\n", cmd);
1075 goto eh_reset_failed;
1081 "wait for pending cmds failed for cmd=%p.\n", cmd);
1082 goto eh_reset_failed;
1086 "%s RESET SUCCEEDED nexus:%ld:%d:%d cmd=%p.\n", name,
1093 "%s RESET FAILED: %s nexus=%ld:%d:%d cmd=%p.\n", name,
1100 qla2xxx_eh_device_reset(
struct scsi_cmnd *cmd)
1105 return __qla2xxx_eh_generic_reset(
"DEVICE",
WAIT_LUN, cmd,
1110 qla2xxx_eh_target_reset(
struct scsi_cmnd *cmd)
1115 return __qla2xxx_eh_generic_reset(
"TARGET",
WAIT_TARGET, cmd,
1135 qla2xxx_eh_bus_reset(
struct scsi_cmnd *cmd)
1140 unsigned int id, lun;
1155 "BUS RESET ISSUED nexus=%ld:%d:%d.\n", vha->
host_no,
id, lun);
1159 "Wait for hba online failed board disabled.\n");
1160 goto eh_bus_reset_done;
1167 goto eh_bus_reset_done;
1173 "Wait for pending commands failed.\n");
1179 "BUS RESET %s nexus=%ld:%d:%d.\n",
1180 (ret ==
FAILED) ?
"FAILED" :
"SUCCEEDED", vha->
host_no,
id, lun);
1201 qla2xxx_eh_host_reset(
struct scsi_cmnd *cmd)
1206 unsigned int id,
lun;
1213 "ADAPTER RESET ISSUED nexus=%ld:%d:%d.\n", vha->
host_no,
id, lun);
1215 if (qla2x00_wait_for_reset_ready(vha) !=
QLA_SUCCESS)
1216 goto eh_host_reset_lock;
1218 if (vha != base_vha) {
1220 goto eh_host_reset_lock;
1226 goto eh_host_reset_lock;
1234 if (ha->
isp_ops->abort_isp(base_vha)) {
1241 "wait for hba online failed.\n");
1242 goto eh_host_reset_lock;
1255 "ADAPTER RESET %s nexus=%ld:%d:%d.\n",
1256 (ret ==
FAILED) ?
"FAILED" :
"SUCCEEDED", vha->
host_no,
id, lun);
1283 ret = ha->
isp_ops->target_reset(fcport, 0, 0);
1286 "Bus Reset failed: Target Reset=%d "
1287 "d_id=%x.\n", ret, fcport->
d_id.
b24);
1296 "full_login_lip=%d.\n", ret);
1303 if (ha->
flags.enable_lip_reset) {
1307 "lip_reset failed (%d).\n", ret);
1320 unsigned long flags;
1334 sp->
done(vha, sp, res);
1338 spin_unlock_irqrestore(&ha->hardware_lock, flags);
1346 if (!rport || fc_remote_port_chkready(rport))
1376 static void qla2x00_handle_queue_full(
struct scsi_device *sdev,
int qdepth)
1384 "Queue depth adjusted-down to %d for nexus=%ld:%d:%d.\n",
1388 static void qla2x00_adjust_sdev_qdepth_up(
struct scsi_device *sdev,
int qdepth)
1407 "Queue depth adjusted-up to %d for nexus=%ld:%d:%d.\n",
1419 qla2x00_handle_queue_full(sdev, qdepth);
1422 qla2x00_adjust_sdev_qdepth_up(sdev, qdepth);
1435 scsi_set_tag_type(sdev, tag_type);
1454 qla2x00_config_dma_addressing(
struct qla_hw_data *ha)
1457 ha->
flags.enable_64bit_addressing = 0;
1464 ha->
flags.enable_64bit_addressing = 1;
1478 unsigned long flags = 0;
1486 spin_unlock_irqrestore(&ha->hardware_lock, flags);
1493 unsigned long flags = 0;
1501 spin_unlock_irqrestore(&ha->hardware_lock, flags);
1507 unsigned long flags = 0;
1514 spin_unlock_irqrestore(&ha->hardware_lock, flags);
1520 unsigned long flags = 0;
1529 spin_unlock_irqrestore(&ha->hardware_lock, flags);
1542 "Failed to reserve PIO/MMIO regions (%s), aborting.\n",
1543 pci_name(ha->
pdev));
1544 goto iospace_error_exit;
1546 if (!(ha->
bars & 1))
1554 "Invalid pci I/O region size (%s).\n",
1555 pci_name(ha->
pdev));
1560 "Region #0 no a PIO resource (%s).\n",
1561 pci_name(ha->
pdev));
1566 "PIO address=%llu.\n",
1573 "Region #1 not an MMIO resource (%s), aborting.\n",
1574 pci_name(ha->
pdev));
1575 goto iospace_error_exit;
1579 "Invalid PCI mem region size (%s), aborting.\n",
1580 pci_name(ha->
pdev));
1581 goto iospace_error_exit;
1587 "Cannot remap MMIO (%s), aborting.\n",
1588 pci_name(ha->
pdev));
1589 goto iospace_error_exit;
1618 "QoS mode set, max no of request queues:%d.\n",
1621 "QoS mode set, max no of request queues:%d.\n",
1625 "MSI-X vector count: %d.\n", msix);
1628 "BAR 3 not enabled.\n");
1650 "Failed to reserve PIO/MMIO regions (%s), aborting.\n",
1651 pci_name(ha->
pdev));
1653 goto iospace_error_exit;
1659 "Invalid pci I/O region size (%s).\n",
1660 pci_name(ha->
pdev));
1661 goto iospace_error_exit;
1665 "Invalid PCI mem region size (%s), aborting\n",
1666 pci_name(ha->
pdev));
1667 goto iospace_error_exit;
1673 "Cannot remap MMIO (%s), aborting.\n",
1674 pci_name(ha->
pdev));
1675 goto iospace_error_exit;
1687 "BAR2/region4 not enabled\n");
1695 pci_read_config_word(ha->
pdev,
1709 "QoS mode set, max no of request queues:%d.\n",
1712 "QoS mode set, max no of request queues:%d.\n",
1716 "MSI-X vector count: %d.\n", msix);
1719 "BAR 1 not enabled.\n");
1740 .pci_info_str = qla2x00_pci_info_str,
1741 .fw_version_str = qla2x00_fw_version_str,
1743 .enable_intrs = qla2x00_enable_intrs,
1744 .disable_intrs = qla2x00_disable_intrs,
1759 .beacon_blink =
NULL,
1765 .iospace_config = qla2x00_iospace_config,
1777 .pci_info_str = qla2x00_pci_info_str,
1778 .fw_version_str = qla2x00_fw_version_str,
1780 .enable_intrs = qla2x00_enable_intrs,
1781 .disable_intrs = qla2x00_disable_intrs,
1802 .iospace_config = qla2x00_iospace_config,
1814 .pci_info_str = qla24xx_pci_info_str,
1815 .fw_version_str = qla24xx_fw_version_str,
1817 .enable_intrs = qla24xx_enable_intrs,
1818 .disable_intrs = qla24xx_disable_intrs,
1824 .calc_req_entries =
NULL,
1825 .build_iocbs =
NULL,
1839 .iospace_config = qla2x00_iospace_config,
1851 .pci_info_str = qla24xx_pci_info_str,
1852 .fw_version_str = qla24xx_fw_version_str,
1854 .enable_intrs = qla24xx_enable_intrs,
1855 .disable_intrs = qla24xx_disable_intrs,
1861 .calc_req_entries =
NULL,
1862 .build_iocbs =
NULL,
1876 .iospace_config = qla2x00_iospace_config,
1888 .pci_info_str = qla24xx_pci_info_str,
1889 .fw_version_str = qla24xx_fw_version_str,
1891 .enable_intrs = qla24xx_enable_intrs,
1892 .disable_intrs = qla24xx_disable_intrs,
1898 .calc_req_entries =
NULL,
1899 .build_iocbs =
NULL,
1903 .write_nvram =
NULL,
1913 .iospace_config = qla2x00_iospace_config,
1925 .pci_info_str = qla24xx_pci_info_str,
1926 .fw_version_str = qla24xx_fw_version_str,
1935 .calc_req_entries =
NULL,
1936 .build_iocbs =
NULL,
1944 .beacon_blink =
NULL,
1962 .pci_info_str = qla24xx_pci_info_str,
1963 .fw_version_str = qla24xx_fw_version_str,
1965 .enable_intrs = qla24xx_enable_intrs,
1966 .disable_intrs = qla24xx_disable_intrs,
1972 .calc_req_entries =
NULL,
1973 .build_iocbs =
NULL,
1977 .write_nvram =
NULL,
1987 .iospace_config = qla83xx_iospace_config,
1994 switch (ha->
pdev->device) {
2018 if (ha->
pdev->subsystem_vendor == 0x1028 &&
2019 ha->
pdev->subsystem_device == 0x0170)
2109 ha->
flags.port0 = 1;
2111 ha->
flags.port0 = 0;
2113 "device_type=0x%x port=%d fw_srisc_address=0x%x.\n",
2122 if (vha->
hw->flags.running_gold_fw)
2132 qla2xxx_scan_finished(
struct Scsi_Host *shost,
unsigned long time)
2138 if (time > vha->
hw->loop_reset_delay *
HZ)
2155 char fw_str[30], wq_name[30];
2157 int bars, mem_only = 0;
2158 uint16_t req_length = 0, rsp_length = 0;
2177 "Mem only adapter.\n");
2180 "Bars=%d.\n", bars);
2196 "Unable to allocate memory for ha.\n");
2200 "Memory allocated for ha=%p.\n", ha);
2212 qla2x00_set_isp_flags(ha);
2236 ha->
isp_ops = &qla2100_isp_ops;
2248 ha->
isp_ops = &qla2100_isp_ops;
2262 ha->
isp_ops = &qla2300_isp_ops;
2274 ha->
isp_ops = &qla24xx_isp_ops;
2290 ha->
isp_ops = &qla25xx_isp_ops;
2305 ha->
isp_ops = &qla81xx_isp_ops;
2320 ha->
isp_ops = &qla82xx_isp_ops;
2336 ha->
isp_ops = &qla83xx_isp_ops;
2344 "mbx_count=%d, req_length=%d, "
2345 "rsp_length=%d, max_loop_id=%d, init_cb_size=%d, "
2346 "gid_list_info_size=%d, optrom_size=%d, nvram_npiv_size=%d, "
2347 "max_fibre_devices=%d.\n",
2352 "isp_ops=%p, flash_conf_off=%d, "
2353 "flash_data_off=%d, nvram_conf_off=%d, nvram_data_off=%d.\n",
2358 ret = ha->
isp_ops->iospace_config(ha);
2360 goto probe_hw_failed;
2363 "Found an ISP%04X irq %d iobase 0x%p.\n",
2373 qla2x00_config_dma_addressing(ha);
2375 "64 Bit addressing is %s.\n",
2376 ha->
flags.enable_64bit_addressing ?
"enable" :
2378 ret = qla2x00_mem_alloc(ha, req_length, rsp_length, &req, &rsp);
2381 "Failed to allocate memory for adapter, aborting.\n");
2383 goto probe_hw_failed;
2387 if (ql2xmaxqdepth != 0 && ql2xmaxqdepth <= 0xffffU)
2394 qla2x00_mem_free(ha);
2395 qla2x00_free_req_que(ha, req);
2396 qla2x00_free_rsp_que(ha, rsp);
2397 goto probe_hw_failed;
2400 pci_set_drvdata(pdev, base_vha);
2402 host = base_vha->
host;
2420 "can_queue=%d, req=%p, "
2421 "mgmt_svr_loop_id=%d, sg_tablesize=%d.\n",
2433 host->
transportt = qla2xxx_transport_template;
2437 "max_id=%d this_id=%d "
2438 "cmd_per_len=%d unique_id=%d max_cmd_len=%d max_channel=%d "
2439 "max_lun=%d transportt=%p, vendor_id=%llu.\n", host->
max_id,
2446 if (!qla2x00_alloc_queues(ha, req, rsp)) {
2448 "Failed to allocate memory for queue pointers..."
2450 goto probe_init_failed;
2458 goto probe_init_failed;
2485 "rsp_q_map=%p req_q_map=%p rsp->req=%p req->rsp=%p.\n",
2488 "req->req_q_in=%p req->req_q_out=%p "
2489 "rsp->rsp_q_in=%p rsp->rsp_q_out=%p.\n",
2493 "rsp_q_map=%p req_q_map=%p rsp->req=%p req->rsp=%p.\n",
2496 "req->req_q_in=%p req->req_q_out=%p rsp->rsp_q_in=%p rsp->rsp_q_out=%p.\n",
2501 "Failed to initialize adapter - Adapter flags %x.\n",
2510 "HW State: FAILED.\n");
2518 if (qla25xx_setup_mode(base_vha)) {
2520 "Failed to create queues, falling back to single queue mode.\n");
2525 if (ha->
flags.running_gold_fw)
2535 "Failed to start DPC thread.\n");
2540 "DPC thread started successfully.\n");
2566 base_vha->
host->irq = ha->
pdev->irq;
2571 "Started qla2x00_timer with "
2574 "Detected hba at address=%p.\n",
2579 int prot = 0, guard;
2580 base_vha->
flags.difdix_supported = 1;
2582 "Registering for DIF/DIX type 1 and 3 protection.\n");
2585 scsi_host_set_prot(host,
2599 scsi_host_set_guard(host, guard);
2601 base_vha->
flags.difdix_supported = 0;
2604 ha->
isp_ops->enable_intrs(ha);
2606 ret = scsi_add_host(host, &pdev->
dev);
2610 base_vha->
flags.init_done = 1;
2611 base_vha->
flags.online = 1;
2614 "Init done and hba is online.\n");
2616 if (qla_ini_mode_enabled(base_vha))
2620 "skipping scsi_scan_host() for non-initiator port\n");
2629 "QLogic %s - %s.\n",
2632 "ISP%04X: %s @ %s hdma%c host#=%ld fw=%s.\n",
2633 pdev->
device, ha->
isp_ops->pci_info_str(base_vha, pci_info),
2634 pci_name(pdev), ha->
flags.enable_64bit_addressing ?
'+' :
'-',
2636 ha->
isp_ops->fw_version_str(base_vha, fw_str));
2643 qla2x00_free_req_que(ha, req);
2646 qla2x00_free_rsp_que(ha, rsp);
2653 qla2x00_stop_timer(base_vha);
2654 base_vha->
flags.online = 0;
2662 qla2x00_free_device(base_vha);
2704 qla2x00_shutdown(
struct pci_dev *pdev)
2709 vha = pci_get_drvdata(pdev);
2713 if (ha->
flags.fce_enabled) {
2715 ha->
flags.fce_enabled = 0;
2726 vha->
flags.online = 0;
2730 vha->
flags.init_done = 0;
2731 ha->
isp_ops->disable_intrs(ha);
2736 qla2x00_free_fw_dump(ha);
2740 qla2x00_remove_one(
struct pci_dev *pdev)
2744 unsigned long flags;
2753 base_vha = pci_get_drvdata(pdev);
2756 ha->
flags.host_shutting_down = 1;
2781 "Clearing fcoe driver presence.\n");
2784 "Error while clearing DRV-Presence.\n");
2797 qla2x00_stop_timer(base_vha);
2799 base_vha->
flags.online = 0;
2842 qla2x00_free_device(base_vha);
2872 pci_set_drvdata(pdev,
NULL);
2884 qla2x00_stop_timer(vha);
2886 qla2x00_stop_dpc_thread(vha);
2889 if (ha->
flags.fce_enabled)
2898 vha->
flags.online = 0;
2902 vha->
flags.init_done = 0;
2903 ha->
isp_ops->disable_intrs(ha);
2910 qla2x00_mem_free(ha);
2914 qla2x00_free_queues(ha);
2923 qla2x00_clear_loop_id(fcport);
2935 unsigned long flags;
2940 rport = fcport->
rport;
2942 base_vha = pci_get_drvdata(vha->
hw->pdev);
2945 spin_unlock_irqrestore(vha->
host->host_lock, flags);
2964 int do_login,
int defer)
2969 qla2x00_schedule_rport_del(vha, fcport, defer);
2987 "%02x%02x%02x%02x%02x%02x%02x%02x, "
2988 "id = 0x%04x retry cnt=%d.\n",
3028 qla2x00_schedule_rport_del(vha, fcport, defer);
3029 else if (vha->
vp_idx == fcport->
vha->vp_idx)
3030 qla2x00_schedule_rport_del(vha, fcport, defer);
3055 goto fail_free_init_cb;
3060 goto fail_free_tgt_mem;
3064 goto fail_free_gid_list;
3073 goto fail_free_gid_list;
3078 goto fail_free_srb_mempool;
3080 "ctx_cachep=%p ctx_mempool=%p.\n",
3087 goto fail_free_ctx_mempool;
3094 goto fail_free_nvram;
3097 "init_cb=%p gid_list=%p, srb_mempool=%p s_dma_pool=%p.\n",
3105 "Failed to allocate memory for dl_dma_pool.\n");
3106 goto fail_s_dma_pool;
3113 "Failed to allocate memory for fcp_cmnd_dma_pool.\n");
3114 goto fail_dl_dma_pool;
3117 "dl_dma_pool=%p fcp_cmnd_dma_pool=%p.\n",
3129 "sns_cmd: %p.\n", ha->
sns_cmd);
3140 goto fail_free_ms_iocb;
3142 "ms_iocb=%p ct_sns=%p.\n",
3150 "Failed to allocate memory for req.\n");
3155 ((*req)->length + 1) *
sizeof(
request_t),
3157 if (!(*req)->ring) {
3159 "Failed to allocate memory for req_ring.\n");
3166 "Failed to allocate memory for rsp.\n");
3174 if (!(*rsp)->ring) {
3176 "Failed to allocate memory for rsp_ring.\n");
3182 "req=%p req->length=%d req->ring=%p rsp=%p "
3183 "rsp->length=%d rsp->ring=%p.\n",
3184 *req, (*req)->
length, (*req)->ring, *rsp, (*rsp)->
length,
3192 "Failed to allocate memory for npiv_info.\n");
3193 goto fail_npiv_info;
3203 goto fail_ex_init_cb;
3228 qla2x00_set_reserved_loop_ids(ha);
3241 sizeof(
response_t), (*rsp)->ring, (*rsp)->dma);
3242 (*rsp)->ring =
NULL;
3248 sizeof(
request_t), (*req)->ring, (*req)->dma);
3249 (*req)->ring =
NULL;
3278 fail_free_ctx_mempool:
3281 fail_free_srb_mempool:
3299 "Memory allocation failure.\n");
3342 qla2x00_free_fw_dump(ha);
3389 struct dsd_dma *dsd_ptr, *tdsd_ptr;
3445 ha->
tgt.atio_dma = 0;
3458 "Failed to allocate host from the scsi layer, aborting.\n");
3463 vha = shost_priv(host);
3472 INIT_LIST_HEAD(&vha->
list);
3478 "Allocated the host=%p hw=%p vha=%p dev_name=%s",
3480 dev_name(&(ha->
pdev->dev)));
3504 INIT_LIST_HEAD(&e->
list);
3513 unsigned long flags;
3517 spin_unlock_irqrestore(&vha->
work_lock, flags);
3535 return qla2x00_post_work(vha, e);
3548 return qla2x00_post_work(vha, e);
3551 #define qla2x00_post_async_work(name, type) \
3552 int qla2x00_post_async_##name##_work( \
3553 struct scsi_qla_host *vha, \
3554 fc_port_t *fcport, uint16_t *data) \
3556 struct qla_work_evt *e; \
3558 e = qla2x00_alloc_work(vha, type); \
3560 return QLA_FUNCTION_FAILED; \
3562 e->u.logio.fcport = fcport; \
3564 e->u.logio.data[0] = data[0]; \
3565 e->u.logio.data[1] = data[1]; \
3567 return qla2x00_post_work(vha, e); \
3587 return qla2x00_post_work(vha, e);
3593 char event_string[40];
3594 char *envp[] = { event_string,
NULL };
3598 snprintf(event_string,
sizeof(event_string),
"FW_DUMP=%ld",
3612 unsigned long flags;
3617 spin_unlock_irqrestore(&vha->
work_lock, flags);
3620 list_del_init(&e->
list);
3654 qla2x00_uevent_emit(vha, e->
u.
uevent.code);
3686 ha->
isp_ops->fabric_logout(vha,
3688 fcport->
d_id.
b.domain,
3689 fcport->
d_id.
b.area,
3690 fcport->
d_id.
b.al_pa);
3693 fcport->
loop_id = next_loopid =
3715 fcport, &next_loopid);
3740 "Port login OK: logged in ID 0x%x.\n",
3745 }
else if (status == 1) {
3749 "Retrying %d login again loop_id 0x%x.\n",
3756 qla2x00_clear_loop_id(fcport);
3769 switch (work_code) {
3776 if (!ha->
flags.nic_core_reset_hdlr_active) {
3781 "NIC Core reset is already active. Skip "
3782 "scheduling it again.\n");
3794 "Unknow work-code=0x%x.\n", work_code);
3812 if (ha->
flags.nic_core_reset_owner) {
3813 ha->
flags.nic_core_reset_owner = 0;
3843 unsigned long heart_beat_wait =
jiffies + (1 *
HZ);
3844 uint32_t heart_beat_counter1, heart_beat_counter2;
3849 "Nic Core f/w is not alive.\n");
3856 &heart_beat_counter1);
3861 &heart_beat_counter2);
3863 }
while (heart_beat_counter1 == heart_beat_counter2);
3880 "Failed to dump mctp\n");
3884 if (!ha->
flags.nic_core_reset_hdlr_active) {
3892 "Nic Core f/w is alive.\n");
3897 ha->
flags.nic_core_reset_hdlr_active = 1;
3901 "NIC Core reset failed.\n");
3903 ha->
flags.nic_core_reset_hdlr_active = 0;
3923 "Application requested NIC Core Reset.\n");
3928 "Other protocol driver requested NIC Core Reset.\n");
3938 qla83xx_wait_logic(
void)
3952 for (i = 0; i < 20; i++)
3962 uint32_t idc_lck_rcvry_stage_mask = 0x3;
3963 uint32_t idc_lck_rcvry_owner_mask = 0x3c;
3970 if ((data & idc_lck_rcvry_stage_mask) > 0) {
3986 if (((data & idc_lck_rcvry_owner_mask) >> 2) == ha->
portnum) {
3988 ~(idc_lck_rcvry_stage_mask));
4020 uint32_t o_drv_lockid, n_drv_lockid;
4021 unsigned long lock_recovery_timeout;
4041 if (o_drv_lockid == n_drv_lockid) {
4042 qla83xx_wait_logic();
4068 "Failed to acquire IDC lock. retrying...\n");
4073 qla83xx_wait_logic();
4077 "IDC Lock recovery FAILED.\n");
4088 "Failed to acquire IDC lock. retrying...\n");
4091 qla83xx_wait_logic();
4095 "IDC Lock recovery FAILED.\n");
4119 }
else if (
retry < 10) {
4123 qla83xx_wait_logic();
4126 "Failed to release IDC lock, retyring=%d\n",
retry);
4129 }
else if (
retry < 10) {
4131 qla83xx_wait_logic();
4134 "Failed to read drv-lockid, retyring=%d\n",
retry);
4146 qla83xx_wait_logic();
4149 "Failed to release IDC lock, retyring=%d\n",
retry);
4166 drv_presence |= (1 << ha->
portnum);
4195 drv_presence &= ~(1 << ha->
portnum);
4220 unsigned long ack_timeout;
4227 if (drv_ack == drv_presence)
4232 "RESET ACK TIMEOUT! drv_presence=0x%x "
4233 "drv_ack=0x%x\n", drv_presence, drv_ack);
4239 if (drv_ack != drv_presence)
4274 "Failed to restart NIC f/w.\n");
4279 "Success in restarting nic f/w.\n");
4293 unsigned long dev_init_timeout;
4303 "Initialization TIMEOUT!\n");
4310 "HW State: FAILED.\n");
4314 switch (dev_state) {
4316 if (ha->
flags.nic_core_reset_owner)
4319 ha->
flags.nic_core_reset_owner = 0;
4321 "Reset_owner reset by 0x%x.\n",
4325 if (ha->
flags.nic_core_reset_owner)
4361 if (ha->
flags.quiesce_owner)
4371 if (ha->
flags.nic_core_reset_owner)
4374 ha->
flags.nic_core_reset_owner = 0;
4388 "Unknow Device State: %x.\n", dev_state);
4415 qla2x00_do_dpc(
void *data)
4422 base_vha = pci_get_drvdata(ha->
pdev);
4429 "DPC handler sleeping.\n");
4434 if (!base_vha->
flags.init_done || ha->
flags.mbox_busy)
4437 if (ha->
flags.eeh_busy) {
4439 "eeh_busy=%d.\n", ha->
flags.eeh_busy);
4446 "DPC handler waking up, dpc_flags=0x%lx.\n",
4459 "HW State: FAILED.\n");
4468 "FCoE context reset scheduled.\n");
4483 "FCoE context reset end.\n");
4491 "ISP abort scheduled.\n");
4495 if (ha->
isp_ops->abort_isp(base_vha)) {
4505 "ISP abort end.\n");
4518 "Failed to enable receiving of RSCN "
4519 "requests: 0x%x.\n", ret);
4525 "Quiescence mode scheduled.\n");
4530 if (!ha->
flags.quiesce_owner) {
4543 "Quiescence mode end.\n");
4551 "Reset marker scheduled.\n");
4552 qla2x00_rst_aen(base_vha);
4555 "Reset marker end.\n");
4565 "Relogin scheduled.\n");
4575 "Loop resync scheduled.\n");
4587 "Loop resync end.\n");
4597 ha->
isp_ops->enable_intrs(ha);
4601 ha->
isp_ops->beacon_blink(base_vha);
4612 "DPC handler exiting.\n");
4645 if (vha->
flags.online && !vha->
flags.reset_active &&
4672 unsigned long cpu_flags = 0;
4680 if (ha->
flags.eeh_busy) {
4682 "EEH = %d, restarting timer.\n",
4683 ha->
flags.eeh_busy);
4689 if (!pci_channel_offline(ha->
pdev))
4703 && vha->
flags.online) {
4709 "Loop down - aborting the queues before time expires.\n");
4745 spin_unlock_irqrestore(&ha->hardware_lock,
4755 "Loop down - aborting ISP.\n");
4766 "Loop down - seconds remaining %d.\n",
4795 "isp_abort_needed=%d loop_resync_needed=%d "
4796 "fcport_update_needed=%d start_dpc=%d "
4797 "reset_marker_needed=%d",
4804 "beacon_blink_needed=%d isp_unrecoverable=%d "
4805 "fcoe_ctx_reset_needed=%d vp_dpc_needed=%d "
4806 "relogin_needed=%d.\n",
4821 #define FW_ISP21XX 0
4822 #define FW_ISP22XX 1
4823 #define FW_ISP2300 2
4824 #define FW_ISP2322 3
4825 #define FW_ISP24XX 4
4826 #define FW_ISP25XX 5
4827 #define FW_ISP81XX 6
4828 #define FW_ISP82XX 7
4829 #define FW_ISP2031 8
4830 #define FW_ISP8031 9
4832 #define FW_FILE_ISP21XX "ql2100_fw.bin"
4833 #define FW_FILE_ISP22XX "ql2200_fw.bin"
4834 #define FW_FILE_ISP2300 "ql2300_fw.bin"
4835 #define FW_FILE_ISP2322 "ql2322_fw.bin"
4836 #define FW_FILE_ISP24XX "ql2400_fw.bin"
4837 #define FW_FILE_ISP25XX "ql2500_fw.bin"
4838 #define FW_FILE_ISP81XX "ql8100_fw.bin"
4839 #define FW_FILE_ISP82XX "ql8200_fw.bin"
4840 #define FW_FILE_ISP2031 "ql2600_fw.bin"
4841 #define FW_FILE_ISP8031 "ql8300_fw.bin"
4894 "Failed to load firmware image (%s).\n", blob->
name);
4906 qla2x00_release_firmware(
void)
4911 for (idx = 0; idx <
FW_BLOBS; idx++)
4923 "PCI error detected, state %x.\n", state);
4927 ha->
flags.eeh_busy = 0;
4930 ha->
flags.eeh_busy = 1;
4933 ha->
flags.isp82xx_fw_hung = 1;
4943 ha->
flags.pci_channel_io_perm_failure = 1;
4951 qla2xxx_pci_mmio_enabled(
struct pci_dev *pdev)
4953 int risc_paused = 0;
4955 unsigned long flags;
4978 spin_unlock_irqrestore(&ha->hardware_lock, flags);
4982 "RISC paused -- mmio_enabled, Dumping firmware.\n");
4983 ha->
isp_ops->fw_dump(base_vha, 0);
4999 "Entered %s.\n", __func__);
5003 if (base_vha->
flags.online) {
5014 "Finding pci device at function = 0x%x.\n", fn);
5024 "Found PCI func available and enable at 0x%x.\n",
5035 "This devfn is reset owner = 0x%x.\n",
5047 "drv_active = 0x%x.\n", drv_active);
5061 "HW State: FAILED.\n");
5067 "HW State: READY.\n");
5071 ha->
flags.isp82xx_fw_hung = 0;
5081 "This devfn is not reset owner = 0x%x.\n",
5085 ha->
flags.isp82xx_fw_hung = 0;
5098 qla2xxx_pci_slot_reset(
struct pci_dev *pdev)
5129 "Can't re-enable PCI device after reset.\n");
5130 goto exit_slot_reset;
5135 goto exit_slot_reset;
5137 if (ha->
isp_ops->pci_config(base_vha))
5138 goto exit_slot_reset;
5143 goto exit_slot_reset;
5145 goto exit_slot_reset;
5148 while (ha->
flags.mbox_busy && retries--)
5159 "slot_reset return %x.\n", ret);
5165 qla2xxx_pci_resume(
struct pci_dev *pdev)
5177 "The device failed to resume I/O from slot/link_reset.\n");
5182 ha->
flags.eeh_busy = 0;
5186 .error_detected = qla2xxx_pci_error_detected,
5187 .mmio_enabled = qla2xxx_pci_mmio_enabled,
5188 .slot_reset = qla2xxx_pci_slot_reset,
5189 .resume = qla2xxx_pci_resume,
5214 static struct pci_driver qla2xxx_pci_driver = {
5219 .id_table = qla2xxx_pci_tbl,
5220 .probe = qla2x00_probe_one,
5221 .remove = qla2x00_remove_one,
5222 .shutdown = qla2x00_shutdown,
5223 .err_handler = &qla2xxx_err_handler,
5235 qla2x00_module_init(
void)
5242 if (srb_cachep ==
NULL) {
5244 "Unable to allocate SRB cache...Failing load!.\n");
5253 }
else if (ret > 0) {
5268 qla2xxx_transport_template =
5270 if (!qla2xxx_transport_template) {
5273 "fc_attach_transport failed...Failing load!.\n");
5279 if (apidev_major < 0) {
5284 qla2xxx_transport_vport_template =
5286 if (!qla2xxx_transport_vport_template) {
5291 "fc_attach_transport vport failed...Failing load!.\n");
5295 "QLogic Fibre Channel HBA Driver: %s.\n",
5297 ret = pci_register_driver(&qla2xxx_pci_driver);
5304 "pci_register_driver failed...ret=%d Failing load!.\n",
5314 qla2x00_module_exit(
void)
5318 qla2x00_release_firmware();