• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-WNDR4500v2-V1.0.0.60_1.0.38/src/linux/linux-2.6/drivers/scsi/qla2xxx/

Lines Matching defs:ha

72 static void qla2x00_config_dma_addressing(scsi_qla_host_t *ha);
109 static int qla2x00_loop_reset(scsi_qla_host_t *ha);
189 qla2x00_start_timer(scsi_qla_host_t *ha, void *func, unsigned long interval)
191 init_timer(&ha->timer);
192 ha->timer.expires = jiffies + interval * HZ;
193 ha->timer.data = (unsigned long)ha;
194 ha->timer.function = (void (*)(unsigned long))func;
195 add_timer(&ha->timer);
196 ha->timer_active = 1;
200 qla2x00_restart_timer(scsi_qla_host_t *ha, unsigned long interval)
202 mod_timer(&ha->timer, jiffies + interval * HZ);
206 qla2x00_stop_timer(scsi_qla_host_t *ha)
208 del_timer_sync(&ha->timer);
209 ha->timer_active = 0;
217 static void qla2x00_mem_free(scsi_qla_host_t *ha);
218 static int qla2x00_allocate_sp_pool( scsi_qla_host_t *ha);
219 static void qla2x00_free_sp_pool(scsi_qla_host_t *ha);
221 void qla2x00_sp_compl(scsi_qla_host_t *ha, srb_t *);
226 qla2x00_pci_info_str(struct scsi_qla_host *ha, char *str)
234 pci_bus = (ha->pci_attr & (BIT_9 | BIT_10)) >> 9;
239 pci_bus = (ha->pci_attr & BIT_8) >> 8;
249 qla24xx_pci_info_str(struct scsi_qla_host *ha, char *str)
255 pcie_reg = pci_find_capability(ha->pdev, PCI_CAP_ID_EXP);
261 pci_read_config_word(ha->pdev, pcie_reg, &pcie_lstat);
278 pci_bus = (ha->pci_attr & CSRX_PCIX_BUS_MODE_MASK) >> 8;
297 qla2x00_fw_version_str(struct scsi_qla_host *ha, char *str)
301 sprintf(str, "%d.%02d.%02d ", ha->fw_major_version,
302 ha->fw_minor_version,
303 ha->fw_subminor_version);
305 if (ha->fw_attributes & BIT_9) {
310 switch (ha->fw_attributes & 0xFF) {
324 sprintf(un_str, "(%x)", ha->fw_attributes);
328 if (ha->fw_attributes & 0x100)
335 qla24xx_fw_version_str(struct scsi_qla_host *ha, char *str)
337 sprintf(str, "%d.%02d.%02d ", ha->fw_major_version,
338 ha->fw_minor_version,
339 ha->fw_subminor_version);
341 if (ha->fw_attributes & BIT_0)
343 if (ha->fw_attributes & BIT_1)
345 if (ha->fw_attributes & BIT_2)
347 if (ha->fw_attributes & BIT_13)
353 qla2x00_get_new_sp(scsi_qla_host_t *ha, fc_port_t *fcport,
358 sp = mempool_alloc(ha->srb_mempool, GFP_ATOMIC);
362 sp->ha = ha;
375 scsi_qla_host_t *ha = to_qla_host(cmd->device->host);
395 atomic_read(&ha->loop_state) == LOOP_DEAD) {
402 spin_unlock_irq(ha->host->host_lock);
404 sp = qla2x00_get_new_sp(ha, fcport, cmd, done);
412 spin_lock_irq(ha->host->host_lock);
417 qla2x00_sp_free_dma(ha, sp);
418 mempool_free(sp, ha->srb_mempool);
421 spin_lock_irq(ha->host->host_lock);
436 scsi_qla_host_t *ha = to_qla_host(cmd->device->host);
456 atomic_read(&ha->loop_state) == LOOP_DEAD) {
463 spin_unlock_irq(ha->host->host_lock);
465 sp = qla2x00_get_new_sp(ha, fcport, cmd, done);
473 spin_lock_irq(ha->host->host_lock);
478 qla2x00_sp_free_dma(ha, sp);
479 mempool_free(sp, ha->srb_mempool);
482 spin_lock_irq(ha->host->host_lock);
500 * ha = actual ha whose done queue will contain the command
510 qla2x00_eh_wait_on_command(scsi_qla_host_t *ha, struct scsi_cmnd *cmd)
536 * ha - pointer to host adapter structure
547 qla2x00_wait_for_hba_online(scsi_qla_host_t *ha)
553 while (((test_bit(ISP_ABORT_NEEDED, &ha->dpc_flags)) ||
554 test_bit(ABORT_ISP_ACTIVE, &ha->dpc_flags) ||
555 test_bit(ISP_ABORT_RETRY, &ha->dpc_flags) ||
556 ha->dpc_active) && time_before(jiffies, wait_online)) {
560 if (ha->flags.online)
575 * ha - pointer to host adapter structure
587 qla2x00_wait_for_loop_ready(scsi_qla_host_t *ha)
595 while ((!atomic_read(&ha->loop_down_timer) &&
596 atomic_read(&ha->loop_state) == LOOP_DOWN) ||
597 atomic_read(&ha->loop_state) != LOOP_READY) {
598 if (atomic_read(&ha->loop_state) == LOOP_DEAD) {
646 scsi_qla_host_t *ha = to_qla_host(cmd->device->host);
666 spin_lock_irqsave(&ha->hardware_lock, flags);
668 sp = ha->outstanding_cmds[i];
677 __func__, ha->host_no, sp, serial));
680 spin_unlock_irqrestore(&ha->hardware_lock, flags);
681 if (ha->isp_ops.abort_command(ha, sp)) {
683 "mbx failed.\n", __func__, ha->host_no));
686 "mbx success.\n", __func__, ha->host_no));
689 spin_lock_irqsave(&ha->hardware_lock, flags);
693 spin_unlock_irqrestore(&ha->hardware_lock, flags);
697 if (qla2x00_eh_wait_on_command(ha, cmd) != QLA_SUCCESS) {
698 qla_printk(KERN_ERR, ha,
700 "%x.\n", ha->host_no, id, lun, serial, ret);
705 qla_printk(KERN_INFO, ha,
707 ha->host_no, id, lun, wait, serial, ret);
719 * ha - pointer to scsi_qla_host structure.
727 qla2x00_eh_wait_for_pending_target_commands(scsi_qla_host_t *ha, unsigned int t)
742 spin_lock_irqsave(&ha->hardware_lock, flags);
743 sp = ha->outstanding_cmds[cnt];
746 spin_unlock_irqrestore(&ha->hardware_lock, flags);
748 if (!qla2x00_eh_wait_on_command(ha, cmd)) {
754 spin_unlock_irqrestore(&ha->hardware_lock, flags);
783 scsi_qla_host_t *ha = to_qla_host(cmd->device->host);
800 qla_printk(KERN_INFO, ha,
801 "scsi(%ld:%d:%d): DEVICE RESET ISSUED.\n", ha->host_no, id, lun);
803 if (qla2x00_wait_for_hba_online(ha) != QLA_SUCCESS)
806 if (qla2x00_wait_for_loop_ready(ha) == QLA_SUCCESS) {
807 if (qla2x00_device_reset(ha, fcport) == 0)
813 ha->isp_ops.fabric_logout(ha, fcport->loop_id);
814 qla2x00_mark_device_lost(ha, fcport, 0, 0);
825 __func__, ha->host_no));
826 qla_printk(KERN_INFO, ha, "%s: device reset failed\n",
833 if (qla2x00_eh_wait_for_pending_target_commands(ha, id))
837 __func__, ha->host_no));
838 qla_printk(KERN_INFO, ha,
841 qla_printk(KERN_INFO, ha,
842 "scsi(%ld:%d:%d): DEVICE RESET SUCCEEDED.\n", ha->host_no,
855 * ha - pointer to scsi_qla_host structure.
864 qla2x00_eh_wait_for_pending_commands(scsi_qla_host_t *ha)
879 spin_lock_irqsave(&ha->hardware_lock, flags);
880 sp = ha->outstanding_cmds[cnt];
883 spin_unlock_irqrestore(&ha->hardware_lock, flags);
884 status = qla2x00_eh_wait_on_command(ha, cmd);
889 spin_unlock_irqrestore(&ha->hardware_lock, flags);
914 scsi_qla_host_t *ha = to_qla_host(cmd->device->host);
931 qla_printk(KERN_INFO, ha,
932 "scsi(%ld:%d:%d): LOOP RESET ISSUED.\n", ha->host_no, id, lun);
934 if (qla2x00_wait_for_hba_online(ha) != QLA_SUCCESS) {
939 if (qla2x00_wait_for_loop_ready(ha) == QLA_SUCCESS) {
940 if (qla2x00_loop_reset(ha) == QLA_SUCCESS)
947 if (!qla2x00_eh_wait_for_pending_commands(ha))
951 qla_printk(KERN_INFO, ha, "%s: reset %s\n", __func__,
975 scsi_qla_host_t *ha = to_qla_host(cmd->device->host);
992 qla_printk(KERN_INFO, ha,
993 "scsi(%ld:%d:%d): ADAPTER RESET ISSUED.\n", ha->host_no, id, lun);
995 if (qla2x00_wait_for_hba_online(ha) != QLA_SUCCESS)
998 qla2x00_wait_for_loop_ready(ha);
999 set_bit(ABORT_ISP_ACTIVE, &ha->dpc_flags);
1000 if (qla2x00_abort_isp(ha)) {
1001 clear_bit(ABORT_ISP_ACTIVE, &ha->dpc_flags);
1003 set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags);
1005 if (qla2x00_wait_for_hba_online(ha) != QLA_SUCCESS)
1008 clear_bit(ABORT_ISP_ACTIVE, &ha->dpc_flags);
1011 if (qla2x00_eh_wait_for_pending_commands(ha))
1015 qla_printk(KERN_INFO, ha, "%s: reset %s\n", __func__,
1026 * ha = adapter block pointer.
1032 qla2x00_loop_reset(scsi_qla_host_t *ha)
1037 if (ha->flags.enable_lip_full_login) {
1038 ret = qla2x00_full_login_lip(ha);
1041 "full_login_lip=%d.\n", __func__, ha->host_no,
1044 atomic_set(&ha->loop_state, LOOP_DOWN);
1045 atomic_set(&ha->loop_down_timer, LOOP_DOWN_TIME);
1046 qla2x00_mark_all_devices_lost(ha, 0);
1047 qla2x00_wait_for_loop_ready(ha);
1050 if (ha->flags.enable_lip_reset) {
1051 ret = qla2x00_lip_reset(ha);
1054 "lip_reset=%d.\n", __func__, ha->host_no, ret));
1056 qla2x00_wait_for_loop_ready(ha);
1059 if (ha->flags.enable_target_reset) {
1060 list_for_each_entry(fcport, &ha->fcports, list) {
1064 ret = qla2x00_device_reset(ha, fcport);
1068 ha->host_no, ret, fcport->d_id.b24));
1074 ha->marker_needed = 1;
1084 * ha = adapter block pointer.
1093 qla2x00_device_reset(scsi_qla_host_t *ha, fc_port_t *reset_fcport)
1096 return ha->isp_ops.abort_target(reset_fcport);
1115 scsi_qla_host_t *ha = to_qla_host(sdev->host);
1119 scsi_activate_tcq(sdev, ha->max_q_depth);
1121 scsi_deactivate_tcq(sdev, ha->max_q_depth);
1123 rport->dev_loss_tmo = ha->port_down_retry_count + 5;
1158 * @ha: HA context
1160 * At exit, the @ha's flags.enable_64bit_addressing set to indicated
1164 qla2x00_config_dma_addressing(scsi_qla_host_t *ha)
1167 ha->flags.enable_64bit_addressing = 0;
1169 if (!dma_set_mask(&ha->pdev->dev, DMA_64BIT_MASK)) {
1171 if (MSD(dma_get_required_mask(&ha->pdev->dev)) &&
1172 !pci_set_consistent_dma_mask(ha->pdev, DMA_64BIT_MASK)) {
1174 ha->flags.enable_64bit_addressing = 1;
1175 ha->isp_ops.calc_req_entries = qla2x00_calc_iocbs_64;
1176 ha->isp_ops.build_iocbs = qla2x00_build_scsi_iocbs_64;
1181 dma_set_mask(&ha->pdev->dev, DMA_32BIT_MASK);
1182 pci_set_consistent_dma_mask(ha->pdev, DMA_32BIT_MASK);
1186 qla2x00_set_isp_flags(scsi_qla_host_t *ha)
1188 ha->device_type = DT_EXTENDED_IDS;
1189 switch (ha->pdev->device) {
1191 ha->device_type |= DT_ISP2100;
1192 ha->device_type &= ~DT_EXTENDED_IDS;
1193 ha->fw_srisc_address = RISC_START_ADDRESS_2100;
1196 ha->device_type |= DT_ISP2200;
1197 ha->device_type &= ~DT_EXTENDED_IDS;
1198 ha->fw_srisc_address = RISC_START_ADDRESS_2100;
1201 ha->device_type |= DT_ISP2300;
1202 ha->device_type |= DT_ZIO_SUPPORTED;
1203 ha->fw_srisc_address = RISC_START_ADDRESS_2300;
1206 ha->device_type |= DT_ISP2312;
1207 ha->device_type |= DT_ZIO_SUPPORTED;
1208 ha->fw_srisc_address = RISC_START_ADDRESS_2300;
1211 ha->device_type |= DT_ISP2322;
1212 ha->device_type |= DT_ZIO_SUPPORTED;
1213 if (ha->pdev->subsystem_vendor == 0x1028 &&
1214 ha->pdev->subsystem_device == 0x0170)
1215 ha->device_type |= DT_OEM_001;
1216 ha->fw_srisc_address = RISC_START_ADDRESS_2300;
1219 ha->device_type |= DT_ISP6312;
1220 ha->fw_srisc_address = RISC_START_ADDRESS_2300;
1223 ha->device_type |= DT_ISP6322;
1224 ha->fw_srisc_address = RISC_START_ADDRESS_2300;
1227 ha->device_type |= DT_ISP2422;
1228 ha->device_type |= DT_ZIO_SUPPORTED;
1229 ha->fw_srisc_address = RISC_START_ADDRESS_2400;
1232 ha->device_type |= DT_ISP2432;
1233 ha->device_type |= DT_ZIO_SUPPORTED;
1234 ha->fw_srisc_address = RISC_START_ADDRESS_2400;
1237 ha->device_type |= DT_ISP5422;
1238 ha->fw_srisc_address = RISC_START_ADDRESS_2400;
1241 ha->device_type |= DT_ISP5432;
1242 ha->fw_srisc_address = RISC_START_ADDRESS_2400;
1248 qla2x00_iospace_config(scsi_qla_host_t *ha)
1254 pio = pci_resource_start(ha->pdev, 0);
1255 pio_len = pci_resource_len(ha->pdev, 0);
1256 pio_flags = pci_resource_flags(ha->pdev, 0);
1259 qla_printk(KERN_WARNING, ha,
1261 pci_name(ha->pdev));
1265 qla_printk(KERN_WARNING, ha,
1267 pci_name(ha->pdev));
1272 mmio = pci_resource_start(ha->pdev, 1);
1273 mmio_len = pci_resource_len(ha->pdev, 1);
1274 mmio_flags = pci_resource_flags(ha->pdev, 1);
1277 qla_printk(KERN_ERR, ha,
1279 pci_name(ha->pdev));
1283 qla_printk(KERN_ERR, ha,
1285 pci_name(ha->pdev));
1289 if (pci_request_regions(ha->pdev, QLA2XXX_DRIVER_NAME)) {
1290 qla_printk(KERN_WARNING, ha,
1292 pci_name(ha->pdev));
1297 ha->pio_address = pio;
1298 ha->pio_length = pio_len;
1299 ha->iobase = ioremap(mmio, MIN_IOBASE_LEN);
1300 if (!ha->iobase) {
1301 qla_printk(KERN_ERR, ha,
1302 "cannot remap MMIO (%s), aborting\n", pci_name(ha->pdev));
1314 qla2x00_enable_intrs(scsi_qla_host_t *ha)
1317 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
1319 spin_lock_irqsave(&ha->hardware_lock, flags);
1320 ha->interrupts_on = 1;
1324 spin_unlock_irqrestore(&ha->hardware_lock, flags);
1329 qla2x00_disable_intrs(scsi_qla_host_t *ha)
1332 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
1334 spin_lock_irqsave(&ha->hardware_lock, flags);
1335 ha->interrupts_on = 0;
1339 spin_unlock_irqrestore(&ha->hardware_lock, flags);
1343 qla24xx_enable_intrs(scsi_qla_host_t *ha)
1346 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
1348 spin_lock_irqsave(&ha->hardware_lock, flags);
1349 ha->interrupts_on = 1;
1352 spin_unlock_irqrestore(&ha->hardware_lock, flags);
1356 qla24xx_disable_intrs(scsi_qla_host_t *ha)
1359 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
1361 spin_lock_irqsave(&ha->hardware_lock, flags);
1362 ha->interrupts_on = 0;
1365 spin_unlock_irqrestore(&ha->hardware_lock, flags);
1371 scsi_qla_host_t *ha = (scsi_qla_host_t *)shost->hostdata;
1373 set_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags);
1374 set_bit(LOCAL_LOOP_UPDATE, &ha->dpc_flags);
1375 set_bit(RSCN_UPDATE, &ha->dpc_flags);
1381 scsi_qla_host_t *ha = (scsi_qla_host_t *)shost->hostdata;
1383 if (!ha->host)
1385 if (time > ha->loop_reset_delay * HZ)
1388 return atomic_read(&ha->loop_state) == LOOP_READY;
1400 scsi_qla_host_t *ha;
1423 ha = (scsi_qla_host_t *)host->hostdata;
1424 memset(ha, 0, sizeof(scsi_qla_host_t));
1426 ha->pdev = pdev;
1427 ha->host = host;
1428 ha->host_no = host->host_no;
1429 sprintf(ha->host_str, "%s_%ld", QLA2XXX_DRIVER_NAME, ha->host_no);
1432 qla2x00_set_isp_flags(ha);
1435 ret = qla2x00_iospace_config(ha);
1439 qla_printk(KERN_INFO, ha,
1441 ha->iobase);
1443 spin_lock_init(&ha->hardware_lock);
1445 ha->prev_topology = 0;
1446 ha->init_cb_size = sizeof(init_cb_t);
1447 ha->mgmt_svr_loop_id = MANAGEMENT_SERVER;
1448 ha->link_data_rate = PORT_SPEED_UNKNOWN;
1449 ha->optrom_size = OPTROM_SIZE_2300;
1451 ha->max_q_depth = MAX_Q_DEPTH;
1453 ha->max_q_depth = ql2xmaxqdepth;
1456 ha->isp_ops.pci_config = qla2100_pci_config;
1457 ha->isp_ops.reset_chip = qla2x00_reset_chip;
1458 ha->isp_ops.chip_diag = qla2x00_chip_diag;
1459 ha->isp_ops.config_rings = qla2x00_config_rings;
1460 ha->isp_ops.reset_adapter = qla2x00_reset_adapter;
1461 ha->isp_ops.nvram_config = qla2x00_nvram_config;
1462 ha->isp_ops.update_fw_options = qla2x00_update_fw_options;
1463 ha->isp_ops.load_risc = qla2x00_load_risc;
1464 ha->isp_ops.pci_info_str = qla2x00_pci_info_str;
1465 ha->isp_ops.fw_version_str = qla2x00_fw_version_str;
1466 ha->isp_ops.intr_handler = qla2100_intr_handler;
1467 ha->isp_ops.enable_intrs = qla2x00_enable_intrs;
1468 ha->isp_ops.disable_intrs = qla2x00_disable_intrs;
1469 ha->isp_ops.abort_command = qla2x00_abort_command;
1470 ha->isp_ops.abort_target = qla2x00_abort_target;
1471 ha->isp_ops.fabric_login = qla2x00_login_fabric;
1472 ha->isp_ops.fabric_logout = qla2x00_fabric_logout;
1473 ha->isp_ops.calc_req_entries = qla2x00_calc_iocbs_32;
1474 ha->isp_ops.build_iocbs = qla2x00_build_scsi_iocbs_32;
1475 ha->isp_ops.prep_ms_iocb = qla2x00_prep_ms_iocb;
1476 ha->isp_ops.prep_ms_fdmi_iocb = qla2x00_prep_ms_fdmi_iocb;
1477 ha->isp_ops.read_nvram = qla2x00_read_nvram_data;
1478 ha->isp_ops.write_nvram = qla2x00_write_nvram_data;
1479 ha->isp_ops.fw_dump = qla2100_fw_dump;
1480 ha->isp_ops.read_optrom = qla2x00_read_optrom_data;
1481 ha->isp_ops.write_optrom = qla2x00_write_optrom_data;
1482 ha->isp_ops.get_flash_version = qla2x00_get_flash_version;
1483 if (IS_QLA2100(ha)) {
1485 ha->mbx_count = MAILBOX_REGISTER_COUNT_2100;
1486 ha->request_q_length = REQUEST_ENTRY_CNT_2100;
1487 ha->response_q_length = RESPONSE_ENTRY_CNT_2100;
1488 ha->last_loop_id = SNS_LAST_LOOP_ID_2100;
1490 ha->gid_list_info_size = 4;
1491 } else if (IS_QLA2200(ha)) {
1493 ha->mbx_count = MAILBOX_REGISTER_COUNT;
1494 ha->request_q_length = REQUEST_ENTRY_CNT_2200;
1495 ha->response_q_length = RESPONSE_ENTRY_CNT_2100;
1496 ha->last_loop_id = SNS_LAST_LOOP_ID_2100;
1497 ha->gid_list_info_size = 4;
1498 } else if (IS_QLA23XX(ha)) {
1500 ha->mbx_count = MAILBOX_REGISTER_COUNT;
1501 ha->request_q_length = REQUEST_ENTRY_CNT_2200;
1502 ha->response_q_length = RESPONSE_ENTRY_CNT_2300;
1503 ha->last_loop_id = SNS_LAST_LOOP_ID_2300;
1504 ha->isp_ops.pci_config = qla2300_pci_config;
1505 ha->isp_ops.intr_handler = qla2300_intr_handler;
1506 ha->isp_ops.fw_dump = qla2300_fw_dump;
1507 ha->isp_ops.beacon_on = qla2x00_beacon_on;
1508 ha->isp_ops.beacon_off = qla2x00_beacon_off;
1509 ha->isp_ops.beacon_blink = qla2x00_beacon_blink;
1510 ha->gid_list_info_size = 6;
1511 if (IS_QLA2322(ha) || IS_QLA6322(ha))
1512 ha->optrom_size = OPTROM_SIZE_2322;
1513 } else if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) {
1515 ha->mbx_count = MAILBOX_REGISTER_COUNT;
1516 ha->request_q_length = REQUEST_ENTRY_CNT_24XX;
1517 ha->response_q_length = RESPONSE_ENTRY_CNT_2300;
1518 ha->last_loop_id = SNS_LAST_LOOP_ID_2300;
1519 ha->init_cb_size = sizeof(struct init_cb_24xx);
1520 ha->mgmt_svr_loop_id = 10;
1521 ha->isp_ops.pci_config = qla24xx_pci_config;
1522 ha->isp_ops.reset_chip = qla24xx_reset_chip;
1523 ha->isp_ops.chip_diag = qla24xx_chip_diag;
1524 ha->isp_ops.config_rings = qla24xx_config_rings;
1525 ha->isp_ops.reset_adapter = qla24xx_reset_adapter;
1526 ha->isp_ops.nvram_config = qla24xx_nvram_config;
1527 ha->isp_ops.update_fw_options = qla24xx_update_fw_options;
1528 ha->isp_ops.load_risc = qla24xx_load_risc;
1529 ha->isp_ops.pci_info_str = qla24xx_pci_info_str;
1530 ha->isp_ops.fw_version_str = qla24xx_fw_version_str;
1531 ha->isp_ops.intr_handler = qla24xx_intr_handler;
1532 ha->isp_ops.enable_intrs = qla24xx_enable_intrs;
1533 ha->isp_ops.disable_intrs = qla24xx_disable_intrs;
1534 ha->isp_ops.abort_command = qla24xx_abort_command;
1535 ha->isp_ops.abort_target = qla24xx_abort_target;
1536 ha->isp_ops.fabric_login = qla24xx_login_fabric;
1537 ha->isp_ops.fabric_logout = qla24xx_fabric_logout;
1538 ha->isp_ops.prep_ms_iocb = qla24xx_prep_ms_iocb;
1539 ha->isp_ops.prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb;
1540 ha->isp_ops.read_nvram = qla24xx_read_nvram_data;
1541 ha->isp_ops.write_nvram = qla24xx_write_nvram_data;
1542 ha->isp_ops.fw_dump = qla24xx_fw_dump;
1543 ha->isp_ops.read_optrom = qla24xx_read_optrom_data;
1544 ha->isp_ops.write_optrom = qla24xx_write_optrom_data;
1545 ha->isp_ops.beacon_on = qla24xx_beacon_on;
1546 ha->isp_ops.beacon_off = qla24xx_beacon_off;
1547 ha->isp_ops.beacon_blink = qla24xx_beacon_blink;
1548 ha->isp_ops.get_flash_version = qla24xx_get_flash_version;
1549 ha->gid_list_info_size = 8;
1550 ha->optrom_size = OPTROM_SIZE_24XX;
1552 host->can_queue = ha->request_q_length + 128;
1555 ha->instance = num_hosts;
1557 init_MUTEX(&ha->mbx_cmd_sem);
1558 init_MUTEX_LOCKED(&ha->mbx_intr_sem);
1560 INIT_LIST_HEAD(&ha->list);
1561 INIT_LIST_HEAD(&ha->fcports);
1563 qla2x00_config_dma_addressing(ha);
1564 if (qla2x00_mem_alloc(ha)) {
1565 qla_printk(KERN_WARNING, ha,
1572 if (qla2x00_initialize_adapter(ha)) {
1573 qla_printk(KERN_WARNING, ha,
1578 ha->host_no, ha->device_flags));
1587 ha->dpc_thread = kthread_create(qla2x00_do_dpc, ha,
1588 "%s_dpc", ha->host_str);
1589 if (IS_ERR(ha->dpc_thread)) {
1590 qla_printk(KERN_WARNING, ha,
1592 ret = PTR_ERR(ha->dpc_thread);
1598 host->unique_id = ha->instance;
1604 ret = qla2x00_request_irqs(ha);
1609 qla2x00_start_timer(ha, qla2x00_timer, WATCH_INTERVAL);
1612 ha->host_no, ha));
1614 ha->isp_ops.disable_intrs(ha);
1616 spin_lock_irqsave(&ha->hardware_lock, flags);
1617 reg = ha->iobase;
1618 if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) {
1627 if (!IS_QLA2100(ha) && !IS_QLA2200(ha)) {
1628 if (IS_QLA2300(ha))
1638 spin_unlock_irqrestore(&ha->hardware_lock, flags);
1640 ha->isp_ops.enable_intrs(ha);
1642 pci_set_drvdata(pdev, ha);
1644 ha->flags.init_done = 1;
1645 ha->flags.online = 1;
1655 qla2x00_alloc_sysfs_attr(ha);
1657 qla2x00_init_host_attr(ha);
1659 qla_printk(KERN_INFO, ha, "\n"
1663 qla2x00_version_str, ha->model_number,
1664 ha->model_desc ? ha->model_desc: "", pdev->device,
1665 ha->isp_ops.pci_info_str(ha, pci_info), pci_name(pdev),
1666 ha->flags.enable_64bit_addressing ? '+': '-', ha->host_no,
1667 ha->isp_ops.fw_version_str(ha, fw_str));
1672 qla2x00_free_device(ha);
1686 scsi_qla_host_t *ha;
1688 ha = pci_get_drvdata(pdev);
1690 qla2x00_free_sysfs_attr(ha);
1692 fc_remove_host(ha->host);
1694 scsi_remove_host(ha->host);
1696 qla2x00_free_device(ha);
1698 scsi_host_put(ha->host);
1705 qla2x00_free_device(scsi_qla_host_t *ha)
1708 if (ha->timer_active)
1709 qla2x00_stop_timer(ha);
1712 if (ha->dpc_thread) {
1713 struct task_struct *t = ha->dpc_thread;
1719 ha->dpc_thread = NULL;
1723 if (ha->eft)
1724 qla2x00_trace_control(ha, TC_DISABLE, 0, 0);
1726 ha->flags.online = 0;
1729 qla2x00_try_to_stop_firmware(ha);
1732 if (ha->interrupts_on)
1733 ha->isp_ops.disable_intrs(ha);
1735 qla2x00_mem_free(ha);
1737 qla2x00_free_irqs(ha);
1740 if (ha->iobase)
1741 iounmap(ha->iobase);
1742 pci_release_regions(ha->pdev);
1746 qla2x00_schedule_rport_del(struct scsi_qla_host *ha, fc_port_t *fcport,
1762 set_bit(FCPORT_UPDATE_NEEDED, &ha->dpc_flags);
1775 * Input: ha = adapter block pointer. fcport = port structure pointer.
1781 void qla2x00_mark_device_lost(scsi_qla_host_t *ha, fc_port_t *fcport,
1785 qla2x00_schedule_rport_del(ha, fcport, defer);
1798 fcport->login_retry = ha->login_retry_count;
1799 set_bit(RELOGIN_NEEDED, &ha->dpc_flags);
1804 ha->host_no,
1823 * ha = adapter block pointer.
1832 qla2x00_mark_all_devices_lost(scsi_qla_host_t *ha, int defer)
1836 list_for_each_entry(fcport, &ha->fcports, list) {
1847 qla2x00_schedule_rport_del(ha, fcport, defer);
1852 qla2xxx_wake_dpc(ha);
1864 qla2x00_mem_alloc(scsi_qla_host_t *ha)
1877 ha->request_ring = dma_alloc_coherent(&ha->pdev->dev,
1878 (ha->request_q_length + 1) * sizeof(request_t),
1879 &ha->request_dma, GFP_KERNEL);
1880 if (ha->request_ring == NULL) {
1881 qla_printk(KERN_WARNING, ha,
1884 qla2x00_mem_free(ha);
1890 ha->response_ring = dma_alloc_coherent(&ha->pdev->dev,
1891 (ha->response_q_length + 1) * sizeof(response_t),
1892 &ha->response_dma, GFP_KERNEL);
1893 if (ha->response_ring == NULL) {
1894 qla_printk(KERN_WARNING, ha,
1897 qla2x00_mem_free(ha);
1903 ha->gid_list = dma_alloc_coherent(&ha->pdev->dev, GID_LIST_SIZE,
1904 &ha->gid_list_dma, GFP_KERNEL);
1905 if (ha->gid_list == NULL) {
1906 qla_printk(KERN_WARNING, ha,
1909 qla2x00_mem_free(ha);
1916 ha->host_no);
1917 ha->s_dma_pool = dma_pool_create(name, &ha->pdev->dev,
1919 if (ha->s_dma_pool == NULL) {
1920 qla_printk(KERN_WARNING, ha,
1923 qla2x00_mem_free(ha);
1930 ha->init_cb = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL,
1931 &ha->init_cb_dma);
1932 if (ha->init_cb == NULL) {
1933 qla_printk(KERN_WARNING, ha,
1936 qla2x00_mem_free(ha);
1941 memset(ha->init_cb, 0, ha->init_cb_size);
1943 if (qla2x00_allocate_sp_pool(ha)) {
1944 qla_printk(KERN_WARNING, ha,
1948 qla2x00_mem_free(ha);
1955 if (IS_QLA2100(ha) || IS_QLA2200(ha)) {
1957 ha->sns_cmd = dma_alloc_coherent(&ha->pdev->dev,
1958 sizeof(struct sns_cmd_pkt), &ha->sns_cmd_dma,
1960 if (ha->sns_cmd == NULL) {
1962 qla_printk(KERN_WARNING, ha,
1965 qla2x00_mem_free(ha);
1970 memset(ha->sns_cmd, 0, sizeof(struct sns_cmd_pkt));
1973 ha->ms_iocb = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL,
1974 &ha->ms_iocb_dma);
1975 if (ha->ms_iocb == NULL) {
1977 qla_printk(KERN_WARNING, ha,
1980 qla2x00_mem_free(ha);
1985 memset(ha->ms_iocb, 0, sizeof(ms_iocb_entry_t));
1991 ha->ct_sns = dma_alloc_coherent(&ha->pdev->dev,
1992 sizeof(struct ct_sns_pkt), &ha->ct_sns_dma,
1994 if (ha->ct_sns == NULL) {
1996 qla_printk(KERN_WARNING, ha,
1999 qla2x00_mem_free(ha);
2004 memset(ha->ct_sns, 0, sizeof(struct ct_sns_pkt));
2006 if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) {
2011 ha->sfp_data = dma_pool_alloc(ha->s_dma_pool,
2012 GFP_KERNEL, &ha->sfp_data_dma);
2013 if (ha->sfp_data == NULL) {
2014 qla_printk(KERN_WARNING, ha,
2018 qla2x00_mem_free(ha);
2023 memset(ha->sfp_data, 0, SFP_BLOCK_SIZE);
2045 * ha = adapter block pointer.
2048 qla2x00_mem_free(scsi_qla_host_t *ha)
2053 if (ha == NULL) {
2055 DEBUG2(printk("%s(): ERROR invalid ha pointer.\n", __func__));
2060 qla2x00_free_sp_pool(ha);
2062 if (ha->fw_dump) {
2063 if (ha->eft)
2064 dma_free_coherent(&ha->pdev->dev,
2065 ntohl(ha->fw_dump->eft_size), ha->eft, ha->eft_dma);
2066 vfree(ha->fw_dump);
2069 if (ha->sns_cmd)
2070 dma_free_coherent(&ha->pdev->dev, sizeof(struct sns_cmd_pkt),
2071 ha->sns_cmd, ha->sns_cmd_dma);
2073 if (ha->ct_sns)
2074 dma_free_coherent(&ha->pdev->dev, sizeof(struct ct_sns_pkt),
2075 ha->ct_sns, ha->ct_sns_dma);
2077 if (ha->sfp_data)
2078 dma_pool_free(ha->s_dma_pool, ha->sfp_data, ha->sfp_data_dma);
2080 if (ha->ms_iocb)
2081 dma_pool_free(ha->s_dma_pool, ha->ms_iocb, ha->ms_iocb_dma);
2083 if (ha->init_cb)
2084 dma_pool_free(ha->s_dma_pool, ha->init_cb, ha->init_cb_dma);
2086 if (ha->s_dma_pool)
2087 dma_pool_destroy(ha->s_dma_pool);
2089 if (ha->gid_list)
2090 dma_free_coherent(&ha->pdev->dev, GID_LIST_SIZE, ha->gid_list,
2091 ha->gid_list_dma);
2093 if (ha->response_ring)
2094 dma_free_coherent(&ha->pdev->dev,
2095 (ha->response_q_length + 1) * sizeof(response_t),
2096 ha->response_ring, ha->response_dma);
2098 if (ha->request_ring)
2099 dma_free_coherent(&ha->pdev->dev,
2100 (ha->request_q_length + 1) * sizeof(request_t),
2101 ha->request_ring, ha->request_dma);
2103 ha->eft = NULL;
2104 ha->eft_dma = 0;
2105 ha->sns_cmd = NULL;
2106 ha->sns_cmd_dma = 0;
2107 ha->ct_sns = NULL;
2108 ha->ct_sns_dma = 0;
2109 ha->ms_iocb = NULL;
2110 ha->ms_iocb_dma = 0;
2111 ha->init_cb = NULL;
2112 ha->init_cb_dma = 0;
2114 ha->s_dma_pool = NULL;
2116 ha->gid_list = NULL;
2117 ha->gid_list_dma = 0;
2119 ha->response_ring = NULL;
2120 ha->response_dma = 0;
2121 ha->request_ring = NULL;
2122 ha->request_dma = 0;
2124 list_for_each_safe(fcpl, fcptemp, &ha->fcports) {
2131 INIT_LIST_HEAD(&ha->fcports);
2133 ha->fw_dump = NULL;
2134 ha->fw_dumped = 0;
2135 ha->fw_dump_reading = 0;
2137 vfree(ha->optrom_buffer);
2146 * ha = adapter block pointer.
2152 qla2x00_allocate_sp_pool(scsi_qla_host_t *ha)
2157 ha->srb_mempool = mempool_create_slab_pool(SRB_MIN_REQ, srb_cachep);
2158 if (ha->srb_mempool == NULL) {
2159 qla_printk(KERN_INFO, ha, "Unable to allocate SRB mempool.\n");
2170 qla2x00_free_sp_pool( scsi_qla_host_t *ha)
2172 if (ha->srb_mempool) {
2173 mempool_destroy(ha->srb_mempool);
2174 ha->srb_mempool = NULL;
2194 scsi_qla_host_t *ha;
2199 ha = (scsi_qla_host_t *)data;
2213 if (!ha->flags.init_done)
2216 DEBUG3(printk("scsi(%ld): DPC handler\n", ha->host_no));
2218 ha->dpc_active = 1;
2220 if (ha->flags.mbox_busy) {
2221 ha->dpc_active = 0;
2225 if (test_and_clear_bit(ISP_ABORT_NEEDED, &ha->dpc_flags)) {
2228 "qla2x00_abort_isp ha = %p\n",
2229 ha->host_no, ha));
2231 &ha->dpc_flags))) {
2233 if (qla2x00_abort_isp(ha)) {
2236 &ha->dpc_flags);
2238 clear_bit(ABORT_ISP_ACTIVE, &ha->dpc_flags);
2241 ha->host_no));
2244 if (test_and_clear_bit(FCPORT_UPDATE_NEEDED, &ha->dpc_flags))
2245 qla2x00_update_fcports(ha);
2247 if (test_and_clear_bit(LOOP_RESET_NEEDED, &ha->dpc_flags)) {
2249 ha->host_no));
2250 qla2x00_loop_reset(ha);
2253 if (test_and_clear_bit(RESET_MARKER_NEEDED, &ha->dpc_flags) &&
2254 (!(test_and_set_bit(RESET_ACTIVE, &ha->dpc_flags)))) {
2257 ha->host_no));
2259 qla2x00_rst_aen(ha);
2260 clear_bit(RESET_ACTIVE, &ha->dpc_flags);
2264 if ((test_and_clear_bit(RELOGIN_NEEDED, &ha->dpc_flags)) &&
2265 !test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags) &&
2266 atomic_read(&ha->loop_state) != LOOP_DOWN) {
2269 ha->host_no));
2272 list_for_each_entry(fcport, &ha->fcports, list) {
2284 ha->isp_ops.fabric_logout(
2285 ha, fcport->loop_id,
2290 ha, fcport, &next_loopid);
2294 ha, fcport);
2300 ha->host_no, fcport->loop_id));
2302 qla2x00_update_fcport(ha,
2305 set_bit(RELOGIN_NEEDED, &ha->dpc_flags);
2308 ha->host_no,
2314 if (test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags))
2318 ha->host_no));
2321 if ((test_bit(LOGIN_RETRY_NEEDED, &ha->dpc_flags)) &&
2322 atomic_read(&ha->loop_state) != LOOP_DOWN) {
2324 clear_bit(LOGIN_RETRY_NEEDED, &ha->dpc_flags);
2326 ha->host_no));
2328 set_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags);
2331 ha->host_no));
2334 if (test_and_clear_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags)) {
2337 ha->host_no));
2340 &ha->dpc_flags))) {
2342 qla2x00_loop_resync(ha);
2344 clear_bit(LOOP_RESYNC_ACTIVE, &ha->dpc_flags);
2348 ha->host_no));
2351 if (test_and_clear_bit(FCPORT_RESCAN_NEEDED, &ha->dpc_flags)) {
2354 ha->host_no));
2356 qla2x00_rescan_fcports(ha);
2360 ha->host_no));
2363 if (!ha->interrupts_on)
2364 ha->isp_ops.enable_intrs(ha);
2366 if (test_and_clear_bit(BEACON_BLINK_NEEDED, &ha->dpc_flags))
2367 ha->isp_ops.beacon_blink(ha);
2369 ha->dpc_active = 0;
2372 DEBUG(printk("scsi(%ld): DPC handler exiting\n", ha->host_no));
2377 ha->dpc_active = 0;
2383 qla2xxx_wake_dpc(scsi_qla_host_t *ha)
2385 if (ha->dpc_thread)
2386 wake_up_process(ha->dpc_thread);
2394 * ha = adapter block pointer.
2397 qla2x00_rst_aen(scsi_qla_host_t *ha)
2399 if (ha->flags.online && !ha->flags.reset_active &&
2400 !atomic_read(&ha->loop_down_timer) &&
2401 !(test_bit(ABORT_ISP_ACTIVE, &ha->dpc_flags))) {
2403 clear_bit(RESET_MARKER_NEEDED, &ha->dpc_flags);
2409 ha->marker_needed = 1;
2410 } while (!atomic_read(&ha->loop_down_timer) &&
2411 (test_bit(RESET_MARKER_NEEDED, &ha->dpc_flags)));
2416 qla2x00_sp_free_dma(scsi_qla_host_t *ha, srb_t *sp)
2422 dma_unmap_sg(&ha->pdev->dev, cmd->request_buffer,
2425 dma_unmap_single(&ha->pdev->dev, sp->dma_handle,
2434 qla2x00_sp_compl(scsi_qla_host_t *ha, srb_t *sp)
2438 qla2x00_sp_free_dma(ha, sp);
2440 mempool_free(sp, ha->srb_mempool);
2454 qla2x00_timer(scsi_qla_host_t *ha)
2471 list_for_each_entry(fcport, &ha->fcports, list) {
2485 ha->host_no,
2493 if (atomic_read(&ha->loop_down_timer) > 0 &&
2494 !(test_bit(ABORT_ISP_ACTIVE, &ha->dpc_flags)) && ha->flags.online) {
2496 if (atomic_read(&ha->loop_down_timer) ==
2497 ha->loop_down_abort_time) {
2501 ha->host_no));
2503 if (!IS_QLA2100(ha) && ha->link_down_timeout)
2504 atomic_set(&ha->loop_state, LOOP_DEAD);
2507 spin_lock_irqsave(&ha->hardware_lock, cpu_flags);
2512 sp = ha->outstanding_cmds[index];
2519 set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags);
2522 spin_unlock_irqrestore(&ha->hardware_lock, cpu_flags);
2524 set_bit(ABORT_QUEUES_NEEDED, &ha->dpc_flags);
2529 if (atomic_dec_and_test(&ha->loop_down_timer) != 0) {
2532 ha->host_no));
2534 set_bit(RESTART_QUEUES_NEEDED, &ha->dpc_flags);
2537 if (!(ha->device_flags & DFLG_NO_CABLE)) {
2540 ha->host_no));
2541 qla_printk(KERN_WARNING, ha,
2544 set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags);
2548 ha->host_no,
2549 atomic_read(&ha->loop_down_timer)));
2553 if (ha->beacon_blink_led == 1) {
2554 set_bit(BEACON_BLINK_NEEDED, &ha->dpc_flags);
2559 if ((test_bit(ISP_ABORT_NEEDED, &ha->dpc_flags) ||
2560 test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags) ||
2561 test_bit(LOOP_RESET_NEEDED, &ha->dpc_flags) ||
2562 test_bit(FCPORT_UPDATE_NEEDED, &ha->dpc_flags) ||
2564 test_bit(LOGIN_RETRY_NEEDED, &ha->dpc_flags) ||
2565 test_bit(RESET_MARKER_NEEDED, &ha->dpc_flags) ||
2566 test_bit(BEACON_BLINK_NEEDED, &ha->dpc_flags) ||
2567 test_bit(RELOGIN_NEEDED, &ha->dpc_flags)))
2568 qla2xxx_wake_dpc(ha);
2570 qla2x00_restart_timer(ha, WATCH_INTERVAL);
2615 qla2x00_request_firmware(scsi_qla_host_t *ha)
2620 if (IS_QLA2100(ha)) {
2622 } else if (IS_QLA2200(ha)) {
2624 } else if (IS_QLA2300(ha) || IS_QLA2312(ha) || IS_QLA6312(ha)) {
2626 } else if (IS_QLA2322(ha) || IS_QLA6322(ha)) {
2628 } else if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) {
2636 if (request_firmware(&blob->fw, blob->name, &ha->pdev->dev)) {
2638 "(%s).\n", ha->host_no, blob->name));