Lines Matching refs:vha

381 qla2x00_start_timer(scsi_qla_host_t *vha, unsigned long interval)
383 timer_setup(&vha->timer, qla2x00_timer, 0);
384 vha->timer.expires = jiffies + interval * HZ;
385 add_timer(&vha->timer);
386 vha->timer_active = 1;
390 qla2x00_restart_timer(scsi_qla_host_t *vha, unsigned long interval)
393 if (vha->device_flags & DFLG_DEV_FAILED) {
394 ql_dbg(ql_dbg_timer, vha, 0x600d,
399 mod_timer(&vha->timer, jiffies + interval * HZ);
403 qla2x00_stop_timer(scsi_qla_host_t *vha)
405 del_timer_sync(&vha->timer);
406 vha->timer_active = 0;
421 static void qla_init_base_qpair(struct scsi_qla_host *vha, struct req_que *req,
424 struct qla_hw_data *ha = vha->hw;
431 ha->base_qpair->vha = vha;
450 scsi_qla_host_t *vha = pci_get_drvdata(ha->pdev);
455 ql_log(ql_log_fatal, vha, 0x003b,
463 ql_log(ql_log_fatal, vha, 0x003c,
470 ql_log(ql_log_warn, vha, 0x00e0,
475 qla_init_base_qpair(vha, req, rsp);
481 ql_log(ql_log_fatal, vha, 0x0180,
603 qla2x00_pci_info_str(struct scsi_qla_host *vha, char *str, size_t str_len)
605 struct qla_hw_data *ha = vha->hw;
624 qla24xx_pci_info_str(struct scsi_qla_host *vha, char *str, size_t str_len)
629 struct qla_hw_data *ha = vha->hw;
675 qla2x00_fw_version_str(struct scsi_qla_host *vha, char *str, size_t size)
678 struct qla_hw_data *ha = vha->hw;
713 qla24xx_fw_version_str(struct scsi_qla_host *vha, char *str, size_t size)
715 struct qla_hw_data *ha = vha->hw;
724 struct qla_hw_data *ha = sp->vha->hw;
782 struct qla_hw_data *ha = sp->fcport->vha->hw;
824 ql_dbg(ql_dbg_tgt+ql_dbg_verbose, sp->vha, 0xe022,
830 ql_dbg(ql_dbg_tgt+ql_dbg_verbose, sp->vha, 0xe022,
876 scsi_qla_host_t *vha = shost_priv(host);
879 struct qla_hw_data *ha = vha->hw;
905 ql_dbg(ql_dbg_aer, vha, 0x9010,
910 ql_dbg(ql_dbg_aer, vha, 0x9011,
920 ql_dbg(ql_dbg_io + ql_dbg_verbose, vha, 0x3003,
926 if (!vha->flags.difdix_supported &&
928 ql_dbg(ql_dbg_io, vha, 0x3004,
943 ql_dbg(ql_dbg_io, vha, 0x3005,
966 qla2xxx_init_sp(sp, vha, vha->hw->base_qpair, fcport);
975 ql_dbg(ql_dbg_io + ql_dbg_verbose, vha, 0x3013,
1000 scsi_qla_host_t *vha = shost_priv(host);
1003 struct qla_hw_data *ha = vha->hw;
1011 ql_dbg(ql_dbg_io + ql_dbg_verbose, vha, 0x3076,
1018 ql_dbg(ql_dbg_io, vha, 0x3077,
1032 ql_dbg(ql_dbg_io, vha, 0x3077,
1055 qla2xxx_init_sp(sp, vha, qpair, fcport);
1064 ql_dbg(ql_dbg_io + ql_dbg_verbose, vha, 0x3078,
1102 qla2x00_wait_for_hba_online(scsi_qla_host_t *vha)
1106 struct qla_hw_data *ha = vha->hw;
1125 static inline int test_fcport_count(scsi_qla_host_t *vha)
1127 struct qla_hw_data *ha = vha->hw;
1133 ql_dbg(ql_dbg_init, vha, 0x00ec,
1135 vha, vha->fcport_count);
1136 res = (vha->fcport_count == 0);
1140 list_for_each_entry(fcport, &vha->vp_fcports, list) {
1162 qla2x00_wait_for_sess_deletion(scsi_qla_host_t *vha)
1166 qla2x00_mark_all_devices_lost(vha);
1169 if (wait_event_timeout(vha->fcport_waitQ,
1170 test_fcport_count(vha), HZ) > 0)
1174 flush_workqueue(vha->hw->wq);
1190 qla2x00_wait_for_hba_ready(scsi_qla_host_t *vha)
1192 struct qla_hw_data *ha = vha->hw;
1195 while ((qla2x00_reset_active(vha) || ha->dpc_active ||
1197 test_bit(FX00_RESET_RECOVERY, &vha->dpc_flags) ||
1198 test_bit(FX00_TARGET_SCAN, &vha->dpc_flags)) {
1206 qla2x00_wait_for_chip_reset(scsi_qla_host_t *vha)
1210 struct qla_hw_data *ha = vha->hw;
1251 scsi_qla_host_t *vha = shost_priv(cmd->device->host);
1258 struct qla_hw_data *ha = vha->hw;
1265 ql_log(ql_log_info, vha, 0x8042,
1267 qla_pci_set_eeh_busy(vha);
1279 vha->cmd_timeout_cnt++;
1292 ql_dbg(ql_dbg_taskm, vha, 0x8002,
1294 vha->host_no, id, lun, sp, cmd, sp->handle);
1303 ql_dbg(ql_dbg_taskm, vha, 0x8003,
1312 ql_dbg(ql_dbg_taskm, vha, 0xffff,
1327 ql_log(ql_log_info, vha, 0x801c,
1329 vha->host_no, id, lun, ret);
1346 scsi_qla_host_t *vha = qpair->vha;
1352 struct qla_hw_data *ha = vha->hw;
1366 if (vha->vp_idx != sp->vha->vp_idx)
1395 ql_dbg(ql_dbg_taskm, vha, 0x8005,
1422 qla2x00_eh_wait_for_pending_commands(scsi_qla_host_t *vha, unsigned int t,
1426 struct qla_hw_data *ha = vha->hw;
1452 scsi_qla_host_t *vha = shost_priv(sdev->host);
1455 struct qla_hw_data *ha = vha->hw;
1459 ql_log(ql_log_info, vha, 0x803e,
1461 qla_pci_set_eeh_busy(vha);
1476 ql_log(ql_log_info, vha, 0x8009,
1477 "DEVICE RESET ISSUED nexus=%ld:%d:%llu cmd=%p.\n", vha->host_no,
1481 if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) {
1482 ql_log(ql_log_warn, vha, 0x800a,
1489 ql_log(ql_log_warn, vha, 0x800c,
1494 if (qla2x00_eh_wait_for_pending_commands(vha, fcport->d_id.b24,
1497 ql_log(ql_log_warn, vha, 0x800d,
1502 ql_log(ql_log_info, vha, 0x800e,
1504 vha->host_no, sdev->id, sdev->lun, cmd);
1509 ql_log(ql_log_info, vha, 0x800f,
1511 reset_errors[err], vha->host_no, sdev->id, sdev->lun,
1513 vha->reset_cmd_err_cnt++;
1522 scsi_qla_host_t *vha = shost_priv(rport_to_shost(rport));
1523 struct qla_hw_data *ha = vha->hw;
1528 ql_log(ql_log_info, vha, 0x803f,
1530 qla_pci_set_eeh_busy(vha);
1545 ql_log(ql_log_info, vha, 0x8009,
1546 "TARGET RESET ISSUED nexus=%ld:%d cmd=%p.\n", vha->host_no,
1550 if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) {
1551 ql_log(ql_log_warn, vha, 0x800a,
1557 ql_log(ql_log_warn, vha, 0x800c,
1562 if (qla2x00_eh_wait_for_pending_commands(vha, fcport->d_id.b24, 0,
1564 ql_log(ql_log_warn, vha, 0x800d,
1569 ql_log(ql_log_info, vha, 0x800e,
1571 vha->host_no, sdev->id, cmd);
1576 ql_log(ql_log_info, vha, 0x800f,
1578 reset_errors[err], vha->host_no, cmd->device->id, cmd->device->lun,
1580 vha->reset_cmd_err_cnt++;
1602 scsi_qla_host_t *vha = shost_priv(cmd->device->host);
1606 struct qla_hw_data *ha = vha->hw;
1609 ql_log(ql_log_info, vha, 0x8040,
1611 qla_pci_set_eeh_busy(vha);
1618 if (qla2x00_chip_is_down(vha))
1621 ql_log(ql_log_info, vha, 0x8012,
1622 "BUS RESET ISSUED nexus=%ld:%d:%llu.\n", vha->host_no, id, lun);
1624 if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) {
1625 ql_log(ql_log_fatal, vha, 0x8013,
1630 if (qla2x00_loop_reset(vha) == QLA_SUCCESS)
1637 if (qla2x00_eh_wait_for_pending_commands(vha, 0, 0, WAIT_HOST) !=
1639 ql_log(ql_log_warn, vha, 0x8014,
1645 ql_log(ql_log_warn, vha, 0x802b,
1647 (ret == FAILED) ? "FAILED" : "SUCCEEDED", vha->host_no, id, lun);
1670 scsi_qla_host_t *vha = shost_priv(cmd->device->host);
1671 struct qla_hw_data *ha = vha->hw;
1678 ql_log(ql_log_info, vha, 0x8041,
1680 qla_pci_set_eeh_busy(vha);
1687 ql_log(ql_log_info, vha, 0x8018,
1688 "ADAPTER RESET ISSUED nexus=%ld:%d:%llu.\n", vha->host_no, id, lun);
1694 if (qla2x00_reset_active(vha) || ha->optrom_state != QLA_SWAITING)
1697 if (vha != base_vha) {
1698 if (qla2x00_vp_abort_isp(vha))
1701 if (IS_P3P_TYPE(vha->hw)) {
1702 if (!qla82xx_fcoe_ctx_reset(vha)) {
1718 if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) {
1719 ql_log(ql_log_warn, vha, 0x802a,
1728 if (qla2x00_eh_wait_for_pending_commands(vha, 0, 0, WAIT_HOST) ==
1733 ql_log(ql_log_info, vha, 0x8017,
1735 (ret == FAILED) ? "FAILED" : "SUCCEEDED", vha->host_no, id, lun);
1751 qla2x00_loop_reset(scsi_qla_host_t *vha)
1754 struct qla_hw_data *ha = vha->hw;
1760 atomic_set(&vha->loop_state, LOOP_DOWN);
1761 atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME);
1762 qla2x00_mark_all_devices_lost(vha);
1763 ret = qla2x00_full_login_lip(vha);
1765 ql_dbg(ql_dbg_taskm, vha, 0x802d,
1771 ret = qla2x00_lip_reset(vha);
1773 ql_dbg(ql_dbg_taskm, vha, 0x802e,
1778 vha->marker_needed = 1;
1793 scsi_qla_host_t *vha = qp->vha;
1794 struct qla_hw_data *ha = vha->hw;
1802 if (qla2x00_chip_is_down(vha)) {
1809 !test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags) &&
1827 ql_dbg(ql_dbg_taskm, vha, 0xffff,
1865 scsi_qla_host_t *vha = qp->vha;
1866 struct qla_hw_data *ha = vha->hw;
1868 struct qla_tgt *tgt = vha->vha_tgt.qla_tgt;
1881 if (qla2x00_chip_is_down(vha)) {
1894 if (!vha->hw->tgt.tgt_ops || !tgt ||
1895 qla_ini_mode_enabled(vha)) {
1896 ql_dbg(ql_dbg_tgt_mgt, vha, 0xf003,
1898 vha->dpc_flags);
1921 qla2x00_abort_all_cmds(scsi_qla_host_t *vha, int res)
1924 struct qla_hw_data *ha = vha->hw;
1957 scsi_qla_host_t *vha = shost_priv(sdev->host);
1958 struct req_que *req = vha->req;
2828 scsi_qla_host_t *vha = shost_priv(shost);
2830 if (vha->hw->flags.running_gold_fw)
2833 set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags);
2834 set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags);
2835 set_bit(RSCN_UPDATE, &vha->dpc_flags);
2836 set_bit(NPIV_CONFIG_NEEDED, &vha->dpc_flags);
2842 scsi_qla_host_t *vha = shost_priv(shost);
2844 if (test_bit(UNLOADING, &vha->dpc_flags))
2846 if (!vha->host)
2848 if (time > vha->hw->loop_reset_delay * HZ)
2851 return atomic_read(&vha->loop_state) == LOOP_READY;
2866 struct scsi_qla_host *vha = container_of(work,
2868 struct qla_hw_data *ha = vha->hw;
2876 while (!list_empty(&vha->work_list) && i > 0) {
2877 qla2x00_do_work(vha);
2881 spin_lock_irqsave(&vha->work_lock, flags);
2882 clear_bit(IOCB_WORK_ACTIVE, &vha->dpc_flags);
2883 spin_unlock_irqrestore(&vha->work_lock, flags);
3276 ha->mr.fcport.vha = base_vha;
3713 scsi_qla_host_t *vha;
3716 vha = pci_get_drvdata(pdev);
3717 ha = vha->hw;
3719 ql_log(ql_log_info, vha, 0xfffa,
3726 __qla_set_remove_flag(vha);
3734 qlafx00_driver_shutdown(vha, 20);
3738 qla2x00_disable_fce_trace(vha, NULL, NULL);
3744 qla2x00_disable_eft_trace(vha);
3749 qla2x00_abort_isp_cleanup(vha);
3752 qla2x00_try_to_stop_firmware(vha);
3756 if (vha->timer_active)
3757 qla2x00_stop_timer(vha);
3760 vha->flags.online = 0;
3764 vha->flags.init_done = 0;
3768 qla2x00_free_irqs(vha);
3773 ql_log(ql_log_info, vha, 0xfffe,
3781 scsi_qla_host_t *vha;
3789 /* This assumes first entry in ha->vp_list is always base vha */
3790 vha = list_first_entry(&base_vha->list, scsi_qla_host_t, list);
3791 scsi_host_get(vha->host);
3796 qla_nvme_delete(vha);
3798 fc_vport_terminate(vha->fc_vport);
3799 scsi_host_put(vha->host);
3996 if (item == &item->vha->default_item)
4004 qla2x00_free_device(scsi_qla_host_t *vha)
4006 struct qla_hw_data *ha = vha->hw;
4008 qla2x00_abort_all_cmds(vha, DID_NO_CONNECT << 16);
4011 if (vha->timer_active)
4012 qla2x00_stop_timer(vha);
4014 qla25xx_delete_queues(vha);
4015 vha->flags.online = 0;
4019 vha->flags.init_done = 0;
4023 qla2x00_free_fcports(vha);
4025 qla2x00_free_irqs(vha);
4034 qla24xx_free_purex_list(&vha->purex_list);
4038 qla82xx_md_free(vha);
4046 void qla2x00_free_fcports(struct scsi_qla_host *vha)
4050 list_for_each_entry_safe(fcport, tfcport, &vha->vp_fcports, list)
4055 qla2x00_schedule_rport_del(struct scsi_qla_host *vha, fc_port_t *fcport)
4063 ql_dbg(ql_dbg_disc, fcport->vha, 0x2109,
4069 qlt_do_generation_tick(vha, &now);
4081 void qla2x00_mark_device_lost(scsi_qla_host_t *vha, fc_port_t *fcport,
4084 if (IS_QLAFX00(vha->hw)) {
4086 qla2x00_schedule_rport_del(vha, fcport);
4091 vha->vp_idx == fcport->vha->vp_idx) {
4093 qla2x00_schedule_rport_del(vha, fcport);
4106 set_bit(RELOGIN_NEEDED, &vha->dpc_flags);
4110 qla2x00_mark_all_devices_lost(scsi_qla_host_t *vha)
4114 ql_dbg(ql_dbg_disc, vha, 0x20f1,
4117 list_for_each_entry(fcport, &vha->vp_fcports, list) {
4122 !qla2x00_reset_active(vha)) {
4123 ql_dbg(ql_dbg_disc, vha, 0x211a,
4613 qla2x00_set_exlogins_buffer(scsi_qla_host_t *vha)
4618 struct qla_hw_data *ha = vha->hw;
4627 ql_log(ql_log_info, vha, 0xd021, "EXLOGIN count: %d.\n", ql2xexlogins);
4629 rval = qla_get_exlogin_status(vha, &size, &max_cnt);
4643 ql_log(ql_log_info, vha, 0xd024,
4647 ql_log(ql_log_info, vha, 0xd025,
4661 rval = qla_set_exlogin_mem_cfg(vha, ha->exlogin_buf_dma);
4663 ql_log(ql_log_fatal, vha, 0xd033,
4689 qla2x00_number_of_exch(scsi_qla_host_t *vha, u32 *ret_cnt, u16 max_cnt)
4692 struct init_cb_81xx *icb = (struct init_cb_81xx *)&vha->hw->init_cb;
4695 if (max_cnt > vha->hw->max_exchg)
4696 max_cnt = vha->hw->max_exchg;
4698 if (qla_ini_mode_enabled(vha)) {
4699 if (vha->ql2xiniexchg > max_cnt)
4700 vha->ql2xiniexchg = max_cnt;
4702 if (vha->ql2xiniexchg > FW_DEF_EXCHANGES_CNT)
4703 *ret_cnt = vha->ql2xiniexchg;
4705 } else if (qla_tgt_mode_enabled(vha)) {
4706 if (vha->ql2xexchoffld > max_cnt) {
4707 vha->ql2xexchoffld = max_cnt;
4708 icb->exchange_count = cpu_to_le16(vha->ql2xexchoffld);
4711 if (vha->ql2xexchoffld > FW_DEF_EXCHANGES_CNT)
4712 *ret_cnt = vha->ql2xexchoffld;
4713 } else if (qla_dual_mode_enabled(vha)) {
4714 temp = vha->ql2xiniexchg + vha->ql2xexchoffld;
4716 vha->ql2xiniexchg -= (temp - max_cnt)/2;
4717 vha->ql2xexchoffld -= (((temp - max_cnt)/2) + 1);
4719 icb->exchange_count = cpu_to_le16(vha->ql2xexchoffld);
4728 qla2x00_set_exchoffld_buffer(scsi_qla_host_t *vha)
4733 struct qla_hw_data *ha = vha->hw;
4742 rval = qla_get_exchoffld_status(vha, &size, &max_cnt);
4749 qla2x00_number_of_exch(vha, &actual_cnt, max_cnt);
4750 ql_log(ql_log_info, vha, 0xd014,
4765 ql_log(ql_log_info, vha, 0xd016,
4769 ql_log(ql_log_info, vha, 0xd017,
4800 ql_log(ql_log_info, vha, 0xd016,
4807 rval = qla_set_exchoffld_mem_cfg(vha);
4809 ql_log(ql_log_fatal, vha, 0xd02e,
4816 if (qla_ini_mode_enabled(vha))
4819 icb->exchange_count = cpu_to_le16(vha->ql2xexchoffld);
5060 struct scsi_qla_host *vha = NULL;
5070 vha = shost_priv(host);
5071 memset(vha, 0, sizeof(scsi_qla_host_t));
5073 vha->host = host;
5074 vha->host_no = host->host_no;
5075 vha->hw = ha;
5077 vha->qlini_mode = ql2x_ini_mode;
5078 vha->ql2xexchoffld = ql2xexchoffld;
5079 vha->ql2xiniexchg = ql2xiniexchg;
5081 INIT_LIST_HEAD(&vha->vp_fcports);
5082 INIT_LIST_HEAD(&vha->work_list);
5083 INIT_LIST_HEAD(&vha->list);
5084 INIT_LIST_HEAD(&vha->qla_cmd_list);
5085 INIT_LIST_HEAD(&vha->logo_list);
5086 INIT_LIST_HEAD(&vha->plogi_ack_list);
5087 INIT_LIST_HEAD(&vha->qp_list);
5088 INIT_LIST_HEAD(&vha->gnl.fcports);
5089 INIT_WORK(&vha->iocb_work, qla2x00_iocb_work_fn);
5091 INIT_LIST_HEAD(&vha->purex_list.head);
5092 spin_lock_init(&vha->purex_list.lock);
5094 spin_lock_init(&vha->work_lock);
5095 spin_lock_init(&vha->cmd_list_lock);
5096 init_waitqueue_head(&vha->fcport_waitQ);
5097 init_waitqueue_head(&vha->vref_waitq);
5098 qla_enode_init(vha);
5099 qla_edb_init(vha);
5102 vha->gnl.size = sizeof(struct get_name_list_extended) *
5104 vha->gnl.l = dma_alloc_coherent(&ha->pdev->dev,
5105 vha->gnl.size, &vha->gnl.ldma, GFP_KERNEL);
5106 if (!vha->gnl.l) {
5107 ql_log(ql_log_fatal, vha, 0xd04a,
5109 scsi_host_put(vha->host);
5114 vha->scan.size = ha->max_fibre_devices * sizeof(struct fab_scan_rp);
5115 vha->scan.l = vmalloc(vha->scan.size);
5116 if (!vha->scan.l) {
5117 ql_log(ql_log_fatal, vha, 0xd04a,
5119 dma_free_coherent(&ha->pdev->dev, vha->gnl.size,
5120 vha->gnl.l, vha->gnl.ldma);
5121 vha->gnl.l = NULL;
5122 scsi_host_put(vha->host);
5125 INIT_DELAYED_WORK(&vha->scan.scan_work, qla_scan_work_fn);
5127 snprintf(vha->host_str, sizeof(vha->host_str), "%s_%lu",
5128 QLA2XXX_DRIVER_NAME, vha->host_no);
5129 ql_dbg(ql_dbg_init, vha, 0x0041,
5130 "Allocated the host=%p hw=%p vha=%p dev_name=%s",
5131 vha->host, vha->hw, vha,
5134 return vha;
5138 qla2x00_alloc_work(struct scsi_qla_host *vha, enum qla_work_type type)
5142 if (test_bit(UNLOADING, &vha->dpc_flags))
5145 if (qla_vha_mark_busy(vha))
5150 QLA_VHA_MARK_NOT_BUSY(vha);
5161 qla2x00_post_work(struct scsi_qla_host *vha, struct qla_work_evt *e)
5166 spin_lock_irqsave(&vha->work_lock, flags);
5167 list_add_tail(&e->list, &vha->work_list);
5169 if (!test_and_set_bit(IOCB_WORK_ACTIVE, &vha->dpc_flags))
5172 spin_unlock_irqrestore(&vha->work_lock, flags);
5175 queue_work(vha->hw->wq, &vha->iocb_work);
5181 qla2x00_post_aen_work(struct scsi_qla_host *vha, enum fc_host_event_code code,
5186 e = qla2x00_alloc_work(vha, QLA_EVT_AEN);
5192 return qla2x00_post_work(vha, e);
5196 qla2x00_post_idc_ack_work(struct scsi_qla_host *vha, uint16_t *mb)
5200 e = qla2x00_alloc_work(vha, QLA_EVT_IDC_ACK);
5205 return qla2x00_post_work(vha, e);
5210 struct scsi_qla_host *vha, \
5215 e = qla2x00_alloc_work(vha, type); \
5225 return qla2x00_post_work(vha, e); \
5235 qla2x00_post_uevent_work(struct scsi_qla_host *vha, u32 code)
5239 e = qla2x00_alloc_work(vha, QLA_EVT_UEVENT);
5244 return qla2x00_post_work(vha, e);
5248 qla2x00_uevent_emit(struct scsi_qla_host *vha, u32 code)
5256 vha->host_no);
5262 kobject_uevent_env(&vha->hw->pdev->dev.kobj, KOBJ_CHANGE, envp);
5266 qlafx00_post_aenfx_work(struct scsi_qla_host *vha, uint32_t evtcode,
5271 e = qla2x00_alloc_work(vha, QLA_EVT_AENFX);
5278 return qla2x00_post_work(vha, e);
5288 spin_lock_irqsave(&fcport->vha->work_lock, flags);
5290 spin_unlock_irqrestore(&fcport->vha->work_lock, flags);
5297 spin_unlock_irqrestore(&fcport->vha->work_lock, flags);
5303 void qla24xx_create_new_sess(struct scsi_qla_host *vha, struct qla_work_evt *e)
5311 ql_dbg(ql_dbg_disc, vha, 0xffff,
5315 spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags);
5316 fcport = qla2x00_find_fcport_by_wwpn(vha, e->u.new_sess.port_name, 1);
5324 qlt_plogi_ack_link(vha, pla, fcport, QLT_PLOGI_LINK_SAME_WWN);
5331 spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags);
5332 fcport = qla2x00_alloc_fcport(vha, GFP_KERNEL);
5343 if (NVME_PRIORITY(vha->hw, fcport))
5353 if (vha->flags.nvme_enabled)
5358 ql_dbg(ql_dbg_disc, vha, 0xffff,
5369 spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags);
5371 tfcp = qla2x00_find_fcport_by_wwpn(vha,
5375 ql_dbg(ql_dbg_disc, vha, 0xffff,
5382 list_add_tail(&fcport->list, &vha->vp_fcports);
5386 qlt_plogi_ack_link(vha, pla, fcport,
5391 spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags);
5396 fcport->chip_reset = vha->hw->base_qpair->chip_reset;
5421 qlt_plogi_ack_unref(vha, pla);
5425 spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags);
5426 tfcp = qla2x00_find_fcport_by_nportid(vha,
5432 ql_dbg(ql_dbg_disc, vha, 0xffff,
5451 spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags);
5455 if (N2N_TOPO(vha->hw)) {
5458 if (vha->flags.nvme_enabled) {
5465 schedule_delayed_work(&vha->scan.scan_work, 5);
5467 qla24xx_fcport_handle_login(vha, fcport);
5481 static void qla_sp_retry(struct scsi_qla_host *vha, struct qla_work_evt *e)
5488 ql_dbg(ql_dbg_disc, vha, 0x2043,
5491 qla24xx_sp_unmap(vha, sp);
5496 qla2x00_do_work(struct scsi_qla_host *vha)
5503 spin_lock_irqsave(&vha->work_lock, flags);
5504 list_splice_init(&vha->work_list, &work);
5505 spin_unlock_irqrestore(&vha->work_lock, flags);
5511 fc_host_post_event(vha->host, fc_get_event_number(),
5515 qla81xx_idc_ack(vha, e->u.idc_ack.mb);
5518 qla2x00_async_login(vha, e->u.logio.fcport,
5522 rc = qla2x00_async_logout(vha, e->u.logio.fcport);
5525 qla2x00_async_adisc(vha, e->u.logio.fcport,
5529 qla2x00_uevent_emit(vha, e->u.uevent.code);
5532 qlafx00_process_aen(vha, e);
5535 qla24xx_sp_unmap(vha, e->u.iosb.sp);
5538 qla2x00_relogin(vha);
5541 qla24xx_create_new_sess(vha, e);
5544 qla24xx_async_gpdb(vha, e->u.fcport.fcport,
5548 qla24xx_async_prli(vha, e->u.fcport.fcport);
5551 qla24xx_async_gpsc(vha, e->u.fcport.fcport);
5554 qla24xx_async_gnl(vha, e->u.fcport.fcport);
5557 qla24xx_do_nack_work(vha, e);
5560 rc = qla2x00_async_prlo(vha, e->u.logio.fcport);
5563 qla2x00_async_prlo_done(vha, e->u.logio.fcport,
5567 qla24xx_async_gpnft(vha, e->u.gpnft.fc4_type,
5571 qla24xx_async_gpnft_done(vha, e->u.iosb.sp);
5574 qla24xx_async_gnnft_done(vha, e->u.iosb.sp);
5577 qla24xx_async_gfpnid(vha, e->u.fcport.fcport);
5580 qla_sp_retry(vha, e);
5583 qla_do_iidma_work(vha, e->u.fcport.fcport);
5586 qla24xx_els_dcmd2_iocb(vha, ELS_DCMD_PLOGI,
5590 rc = qla24xx_issue_sa_replace_iocb(vha, e);
5595 /* put 'work' at head of 'vha->work_list' */
5596 spin_lock_irqsave(&vha->work_lock, flags);
5597 list_splice(&work, &vha->work_list);
5598 spin_unlock_irqrestore(&vha->work_lock, flags);
5605 /* For each work completed decrement vha ref count */
5606 QLA_VHA_MARK_NOT_BUSY(vha);
5610 int qla24xx_post_relogin_work(struct scsi_qla_host *vha)
5614 e = qla2x00_alloc_work(vha, QLA_EVT_RELOGIN);
5617 set_bit(RELOGIN_NEEDED, &vha->dpc_flags);
5621 return qla2x00_post_work(vha, e);
5627 void qla2x00_relogin(struct scsi_qla_host *vha)
5633 list_for_each_entry(fcport, &vha->vp_fcports, list) {
5649 if (vha->hw->current_topology != ISP_CFG_NL) {
5652 qla24xx_handle_relogin_event(vha, &ea);
5653 } else if (vha->hw->current_topology ==
5655 IS_QLA2XXX_MIDTYPE(vha->hw)) {
5656 (void)qla24xx_fcport_handle_login(vha,
5658 } else if (vha->hw->current_topology ==
5662 qla2x00_local_device_login(vha,
5667 ql_dbg(ql_dbg_disc, vha, 0x2003,
5671 (vha, fcport);
5674 &vha->dpc_flags);
5676 ql_dbg(ql_dbg_disc, vha, 0x2007,
5690 if (test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags))
5695 set_bit(RELOGIN_NEEDED, &vha->dpc_flags);
5697 ql_dbg(ql_dbg_disc, vha, 0x400e,
6020 qla25xx_rdp_rsp_reduce_size(struct scsi_qla_host *vha,
6032 ql_dbg(ql_dbg_init, vha, 0x0181, "%s: s_id=%#x\n", __func__, sid);
6036 ql_dbg(ql_dbg_init, vha, 0x0181,
6038 } else if (qla24xx_get_port_database(vha,
6040 ql_dbg(ql_dbg_init, vha, 0x0181,
6044 ql_dbg(ql_dbg_init, vha, 0x0181,
6053 vha->hw->isp_ops->fw_version_str(vha, fwstr, sizeof(fwstr));
6059 ql_dbg(ql_dbg_init, vha, 0x0181, "%s: fw=%s\n", __func__, fwstr);
6072 * vha: SCSI qla host
6075 void qla24xx_process_purex_rdp(struct scsi_qla_host *vha,
6078 struct qla_hw_data *ha = vha->hw;
6093 ql_dbg(ql_dbg_init + ql_dbg_verbose, vha, 0x0180,
6096 ql_dbg(ql_dbg_init + ql_dbg_verbose, vha, 0x0181,
6098 ql_dump_buffer(ql_dbg_init + ql_dbg_verbose, vha, 0x0182,
6101 if (qla25xx_rdp_rsp_reduce_size(vha, purex)) {
6104 ql_dbg(ql_dbg_init, vha, 0x0181,
6112 ql_log(ql_log_warn, vha, 0x0183,
6120 ql_log(ql_log_warn, vha, 0x0184,
6186 rval = qla2x00_read_sfp(vha, sfp_dma, sfp, 0xa0, 0x7, 2, 0);
6199 rval = qla2x00_read_sfp(vha, sfp_dma, sfp, 0xa0, 0x0, 1, 0);
6210 rval = qla2x00_read_sfp(vha, sfp_dma, sfp, 0xa2, 0x60, 10, 0);
6236 rval = qla24xx_get_isp_stats(vha, stat, stat_dma, 0);
6259 vha->node_name,
6262 vha->port_name,
6270 vha->fabric_node_name,
6273 vha->fabric_port_name,
6316 rval = qla2x00_read_sfp(vha, sfp_dma, sfp, 0xa2, 0, 64, 0);
6362 rval = qla2x00_read_sfp(vha, sfp_dma, sfp, 0xa2, 112, 64, 0);
6413 rval = qla2x00_read_sfp(vha, sfp_dma, sfp, 0xa0, 20, 64, 0);
6430 rval = qla2x00_read_sfp(vha, sfp_dma, sfp, 0xa0, 84, 8, 0);
6439 ql_dbg(ql_dbg_init, vha, 0x0183,
6441 ql_dbg(ql_dbg_init + ql_dbg_verbose, vha, 0x0184,
6443 ql_dump_buffer(ql_dbg_init + ql_dbg_verbose, vha, 0x0185,
6445 ql_dbg(ql_dbg_init + ql_dbg_verbose, vha, 0x0186,
6447 ql_dump_buffer(ql_dbg_init + ql_dbg_verbose, vha, 0x0187,
6450 rval = qla2x00_issue_iocb(vha, rsp_els, rsp_els_dma, 0);
6453 ql_log(ql_log_warn, vha, 0x0188,
6456 ql_log(ql_log_warn, vha, 0x0189,
6461 ql_dbg(ql_dbg_init, vha, 0x018a, "%s: done.\n", __func__);
6482 if (item == &item->vha->default_item)
6483 memset(&item->vha->default_item, 0, sizeof(struct purex_item));
6500 item->process_item(item->vha, item);
6572 __qla83xx_set_drv_presence(scsi_qla_host_t *vha)
6575 struct qla_hw_data *ha = vha->hw;
6578 rval = qla83xx_rd_reg(vha, QLA83XX_IDC_DRV_PRESENCE, &drv_presence);
6581 rval = qla83xx_wr_reg(vha, QLA83XX_IDC_DRV_PRESENCE,
6589 qla83xx_set_drv_presence(scsi_qla_host_t *vha)
6593 qla83xx_idc_lock(vha, 0);
6594 rval = __qla83xx_set_drv_presence(vha);
6595 qla83xx_idc_unlock(vha, 0);
6601 __qla83xx_clear_drv_presence(scsi_qla_host_t *vha)
6604 struct qla_hw_data *ha = vha->hw;
6607 rval = qla83xx_rd_reg(vha, QLA83XX_IDC_DRV_PRESENCE, &drv_presence);
6610 rval = qla83xx_wr_reg(vha, QLA83XX_IDC_DRV_PRESENCE,
6618 qla83xx_clear_drv_presence(scsi_qla_host_t *vha)
6622 qla83xx_idc_lock(vha, 0);
6623 rval = __qla83xx_clear_drv_presence(vha);
6624 qla83xx_idc_unlock(vha, 0);
6630 qla83xx_need_reset_handler(scsi_qla_host_t *vha)
6632 struct qla_hw_data *ha = vha->hw;
6639 qla83xx_rd_reg(vha, QLA83XX_IDC_DRIVER_ACK, &drv_ack);
6640 qla83xx_rd_reg(vha, QLA83XX_IDC_DRV_PRESENCE, &drv_presence);
6645 ql_log(ql_log_warn, vha, 0xb067,
6654 qla83xx_wr_reg(vha, QLA83XX_IDC_DRV_PRESENCE,
6659 qla83xx_idc_unlock(vha, 0);
6661 qla83xx_idc_lock(vha, 0);
6664 qla83xx_wr_reg(vha, QLA83XX_IDC_DEV_STATE, QLA8XXX_DEV_COLD);
6665 ql_log(ql_log_info, vha, 0xb068, "HW State: COLD/RE-INIT.\n");
6669 qla83xx_device_bootstrap(scsi_qla_host_t *vha)
6674 qla83xx_wr_reg(vha, QLA83XX_IDC_DEV_STATE, QLA8XXX_DEV_INITIALIZING);
6675 ql_log(ql_log_info, vha, 0xb069, "HW State: INITIALIZING.\n");
6678 __qla83xx_get_idc_control(vha, &idc_control);
6680 __qla83xx_set_idc_control(vha, 0);
6682 qla83xx_idc_unlock(vha, 0);
6683 rval = qla83xx_restart_nic_firmware(vha);
6684 qla83xx_idc_lock(vha, 0);
6687 ql_log(ql_log_fatal, vha, 0xb06a,
6689 qla83xx_wr_reg(vha, QLA83XX_IDC_DEV_STATE, QLA8XXX_DEV_FAILED);
6690 ql_log(ql_log_info, vha, 0xb06b, "HW State: FAILED.\n");
6692 ql_dbg(ql_dbg_p3p, vha, 0xb06c,
6694 qla83xx_wr_reg(vha, QLA83XX_IDC_DEV_STATE, QLA8XXX_DEV_READY);
6695 ql_log(ql_log_info, vha, 0xb06d, "HW State: READY.\n");
7258 qla2xxx_wake_dpc(struct scsi_qla_host *vha)
7260 struct qla_hw_data *ha = vha->hw;
7263 if (!test_bit(UNLOADING, &vha->dpc_flags) && t)
7275 qla2x00_rst_aen(scsi_qla_host_t *vha)
7277 if (vha->flags.online && !vha->flags.reset_active &&
7278 !atomic_read(&vha->loop_down_timer) &&
7279 !(test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags))) {
7281 clear_bit(RESET_MARKER_NEEDED, &vha->dpc_flags);
7287 vha->marker_needed = 1;
7288 } while (!atomic_read(&vha->loop_down_timer) &&
7289 (test_bit(RESET_MARKER_NEEDED, &vha->dpc_flags)));
7293 static bool qla_do_heartbeat(struct scsi_qla_host *vha)
7295 struct qla_hw_data *ha = vha->hw;
7328 static void qla_heart_beat(struct scsi_qla_host *vha, u16 dpc_started)
7330 struct qla_hw_data *ha = vha->hw;
7332 if (vha->vp_idx)
7335 if (vha->hw->flags.eeh_busy || qla2x00_chip_is_down(vha))
7347 if (qla_do_heartbeat(vha)) {
7353 static void qla_wind_down_chip(scsi_qla_host_t *vha)
7355 struct qla_hw_data *ha = vha->hw;
7369 ql_log(ql_log_info, vha, 0x9009,
7372 ha->isp_ops->reset_chip(vha);
7383 qla2x00_abort_isp_cleanup(vha);
7386 ql_log(ql_log_info, vha, 0x900a,
7402 scsi_qla_host_t *vha = from_timer(vha, t, timer);
7408 struct qla_hw_data *ha = vha->hw;
7414 qla_wind_down_chip(vha);
7416 ql_dbg(ql_dbg_timer, vha, 0x6000,
7419 qla2x00_restart_timer(vha, WATCH_INTERVAL);
7429 qla2x00_check_reg16_for_disconnect(vha, w);
7433 if (!vha->vp_idx && IS_P3P_TYPE(ha)) {
7434 if (test_bit(ISP_QUIESCE_NEEDED, &vha->dpc_flags))
7437 qla82xx_watchdog(vha);
7439 qla8044_watchdog(vha);
7442 if (!vha->vp_idx && IS_QLAFX00(ha))
7443 qlafx00_timer_routine(vha);
7445 if (vha->link_down_time < QLA2XX_MAX_LINK_DOWN_TIME)
7446 vha->link_down_time++;
7448 spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags);
7449 list_for_each_entry(fcport, &vha->vp_fcports, list) {
7453 spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags);
7456 if (atomic_read(&vha->loop_down_timer) > 0 &&
7457 !(test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags)) &&
7458 !(test_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags))
7459 && vha->flags.online) {
7461 if (atomic_read(&vha->loop_down_timer) ==
7462 vha->loop_down_abort_time) {
7464 ql_log(ql_log_info, vha, 0x6008,
7467 if (!IS_QLA2100(ha) && vha->link_down_timeout)
7468 atomic_set(&vha->loop_state, LOOP_DEAD);
7475 if (!vha->vp_idx) {
7497 &vha->dpc_flags);
7500 &vha->dpc_flags);
7510 if (atomic_dec_and_test(&vha->loop_down_timer) != 0) {
7511 if (!(vha->device_flags & DFLG_NO_CABLE) && !vha->vp_idx) {
7512 ql_log(ql_log_warn, vha, 0x6009,
7517 &vha->dpc_flags);
7520 &vha->dpc_flags);
7523 ql_dbg(ql_dbg_timer, vha, 0x600a,
7525 atomic_read(&vha->loop_down_timer));
7528 if (!vha->vp_idx && (ha->beacon_blink_led == 1)) {
7531 set_bit(BEACON_BLINK_NEEDED, &vha->dpc_flags);
7537 if (vha->hw->flags.edif_enabled)
7538 qla_edif_timer(vha);
7541 if (!list_empty(&vha->work_list)) {
7545 spin_lock_irqsave(&vha->work_lock, flags);
7546 if (!test_and_set_bit(IOCB_WORK_ACTIVE, &vha->dpc_flags))
7548 spin_unlock_irqrestore(&vha->work_lock, flags);
7550 queue_work(vha->hw->wq, &vha->iocb_work);
7558 if (!vha->vp_idx &&
7563 ql_log(ql_log_info, vha, 0x3002,
7566 set_bit(SET_ZIO_THRESHOLD_NEEDED, &vha->dpc_flags);
7570 if (!vha->vp_idx &&
7573 ql_log(ql_log_info, vha, 0x3002,
7577 set_bit(SET_ZIO_THRESHOLD_NEEDED, &vha->dpc_flags);
7580 qla_adjust_buf(vha);
7585 if ((test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags) ||
7586 test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags) ||
7588 test_bit(RESET_MARKER_NEEDED, &vha->dpc_flags) ||
7589 test_bit(BEACON_BLINK_NEEDED, &vha->dpc_flags) ||
7590 test_bit(ISP_UNRECOVERABLE, &vha->dpc_flags) ||
7591 test_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags) ||
7592 test_bit(VP_DPC_NEEDED, &vha->dpc_flags) ||
7593 test_bit(RELOGIN_NEEDED, &vha->dpc_flags) ||
7594 test_bit(PROCESS_PUREX_IOCB, &vha->dpc_flags))) {
7595 ql_dbg(ql_dbg_timer, vha, 0x600b,
7598 test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags),
7599 test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags),
7600 start_dpc, test_bit(RESET_MARKER_NEEDED, &vha->dpc_flags));
7601 ql_dbg(ql_dbg_timer, vha, 0x600c,
7605 test_bit(BEACON_BLINK_NEEDED, &vha->dpc_flags),
7606 test_bit(ISP_UNRECOVERABLE, &vha->dpc_flags),
7607 test_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags),
7608 test_bit(VP_DPC_NEEDED, &vha->dpc_flags),
7609 test_bit(RELOGIN_NEEDED, &vha->dpc_flags),
7610 test_bit(PROCESS_PUREX_IOCB, &vha->dpc_flags));
7611 qla2xxx_wake_dpc(vha);
7615 qla_heart_beat(vha, w);
7617 qla2x00_restart_timer(vha, WATCH_INTERVAL);
7668 qla2x00_request_firmware(scsi_qla_host_t *vha)
7670 struct qla_hw_data *ha = vha->hw;
7709 ql_log(ql_log_warn, vha, 0x0063,
7731 static void qla_pci_error_cleanup(scsi_qla_host_t *vha)
7733 struct qla_hw_data *ha = vha->hw;
7741 ql_dbg(ql_dbg_aer, vha, 0x9000,
7764 qla2x00_mark_all_devices_lost(vha);
7777 list_for_each_entry(fcport, &vha->vp_fcports, list)
7796 scsi_qla_host_t *vha = pci_get_drvdata(pdev);
7797 struct qla_hw_data *ha = vha->hw;
7800 ql_log(ql_log_warn, vha, 0x9000,
7805 ql_log(ql_log_info, vha, 0xffff,
7813 qla_pci_set_eeh_busy(vha);
7815 set_bit(QPAIR_ONLINE_CHECK_NEEDED, &vha->dpc_flags);
7816 qla2xxx_wake_dpc(vha);
7821 qla_pci_set_eeh_busy(vha);
7826 qla2x00_abort_all_cmds(vha, DID_NO_CONNECT << 16);
7828 set_bit(QPAIR_ONLINE_CHECK_NEEDED, &vha->dpc_flags);
7829 qla2xxx_wake_dpc(vha);
7834 ql_dbg(ql_dbg_aer, vha, 0x600d,
7981 void qla_pci_set_eeh_busy(struct scsi_qla_host *vha)
7983 struct qla_hw_data *ha = vha->hw;
8009 void qla_schedule_eeh_work(struct scsi_qla_host *vha)
8011 struct qla_hw_data *ha = vha->hw;
8074 scsi_qla_host_t *vha = (scsi_qla_host_t *)shost->hostdata;
8077 if (USER_CTRL_IRQ(vha->hw) || !vha->hw->mqiobase)
8080 blk_mq_pci_map_queues(qmap, vha->hw->pdev, vha->irq_offset);