Lines Matching +full:io +full:- +full:reset
36 #define snic_cmd_tag(sc) (((struct scsi_cmnd *) sc)->request->tag)
114 u32 hash = snic_cmd_tag(sc) & (SNIC_IO_LOCKS - 1); in snic_io_lock_hash()
116 return &snic->io_req_lock[hash]; in snic_io_lock_hash()
122 return &snic->io_req_lock[tag & (SNIC_IO_LOCKS - 1)]; in snic_io_lock_tag()
142 SNIC_SCSI_DBG(snic->shost, in snic_release_req_buf()
144 sc, snic_cmd_tag(sc), rqi, rqi->req, rqi->abort_req, in snic_release_req_buf()
145 rqi->dr_req, snic_ioreq_state_to_str(CMD_STATE(sc)), in snic_release_req_buf()
148 if (req->u.icmnd.sense_addr) in snic_release_req_buf()
149 dma_unmap_single(&snic->pdev->dev, in snic_release_req_buf()
150 le64_to_cpu(req->u.icmnd.sense_addr), in snic_release_req_buf()
178 sgd = (struct snic_sg_desc *) req_to_sgl(rqi->req); in snic_queue_icmnd_req()
181 sgd->addr = cpu_to_le64(sg_dma_address(sg)); in snic_queue_icmnd_req()
182 sgd->len = cpu_to_le32(sg_dma_len(sg)); in snic_queue_icmnd_req()
183 sgd->_resvd = 0; in snic_queue_icmnd_req()
188 pa = dma_map_single(&snic->pdev->dev, in snic_queue_icmnd_req()
189 sc->sense_buffer, in snic_queue_icmnd_req()
192 if (dma_mapping_error(&snic->pdev->dev, pa)) { in snic_queue_icmnd_req()
193 SNIC_HOST_ERR(snic->shost, in snic_queue_icmnd_req()
195 sc->sense_buffer, snic_cmd_tag(sc)); in snic_queue_icmnd_req()
196 ret = -ENOMEM; in snic_queue_icmnd_req()
201 int_to_scsilun(sc->device->lun, &lun); in snic_queue_icmnd_req()
202 if (sc->sc_data_direction == DMA_FROM_DEVICE) in snic_queue_icmnd_req()
204 if (sc->sc_data_direction == DMA_TO_DEVICE) in snic_queue_icmnd_req()
208 snic_icmnd_init(rqi->req, in snic_queue_icmnd_req()
210 snic->config.hid, /* hid */ in snic_queue_icmnd_req()
213 rqi->tgt_id, in snic_queue_icmnd_req()
215 sc->cmnd, in snic_queue_icmnd_req()
216 sc->cmd_len, in snic_queue_icmnd_req()
219 (ulong) req_to_sgl(rqi->req), in snic_queue_icmnd_req()
223 atomic64_inc(&snic->s_stats.io.active); in snic_queue_icmnd_req()
224 ret = snic_queue_wq_desc(snic, rqi->req, rqi->req_len); in snic_queue_icmnd_req()
226 atomic64_dec(&snic->s_stats.io.active); in snic_queue_icmnd_req()
227 SNIC_HOST_ERR(snic->shost, in snic_queue_icmnd_req()
231 snic_stats_update_active_ios(&snic->s_stats); in snic_queue_icmnd_req()
237 * snic_issue_scsi_req : Prepares IO request and Issues to FW.
256 SNIC_TRC((u16)snic->shost->host_no, tag, (ulong) sc, 0, in snic_issue_scsi_req()
257 sc->cmnd[0], sg_cnt, CMD_STATE(sc)); in snic_issue_scsi_req()
259 SNIC_HOST_ERR(snic->shost, "issue_sc:Failed to map SG List.\n"); in snic_issue_scsi_req()
260 ret = -ENOMEM; in snic_issue_scsi_req()
268 ret = -ENOMEM; in snic_issue_scsi_req()
273 rqi->tgt_id = tgt->id; in snic_issue_scsi_req()
274 rqi->sc = sc; in snic_issue_scsi_req()
286 SNIC_HOST_ERR(snic->shost, in snic_issue_scsi_req()
300 SNIC_TRC(snic->shost->host_no, tag, (ulong) sc, 0, 0, 0, in snic_issue_scsi_req()
304 u32 qtime = jiffies - rqi->start_time; in snic_issue_scsi_req()
305 struct snic_io_stats *iostats = &snic->s_stats.io; in snic_issue_scsi_req()
307 if (io_sz > atomic64_read(&iostats->max_io_sz)) in snic_issue_scsi_req()
308 atomic64_set(&iostats->max_io_sz, io_sz); in snic_issue_scsi_req()
310 if (qtime > atomic64_read(&iostats->max_qtime)) in snic_issue_scsi_req()
311 atomic64_set(&iostats->max_qtime, qtime); in snic_issue_scsi_req()
313 SNIC_SCSI_DBG(snic->shost, in snic_issue_scsi_req()
317 SNIC_TRC(snic->shost->host_no, tag, (ulong) sc, (ulong) rqi, in snic_issue_scsi_req()
339 tgt = starget_to_tgt(scsi_target(sc->device)); in snic_queuecommand()
342 SNIC_HOST_ERR(shost, "Tgt %p id %d Not Ready.\n", tgt, tgt->id); in snic_queuecommand()
343 atomic64_inc(&snic->s_stats.misc.tgt_not_rdy); in snic_queuecommand()
344 sc->result = ret; in snic_queuecommand()
345 sc->scsi_done(sc); in snic_queuecommand()
356 atomic_inc(&snic->ios_inflight); in snic_queuecommand()
359 sc, snic_cmd_tag(sc), sc->cmnd[0], sc->device->lun); in snic_queuecommand()
367 atomic_dec(&snic->ios_inflight); in snic_queuecommand()
374 * caller should hold IO lock
406 * Processes IO's error states
418 atomic64_inc(&snic->s_stats.misc.io_tmo); in snic_process_io_failed_state()
423 atomic64_inc(&snic->s_stats.misc.io_aborted); in snic_process_io_failed_state()
428 atomic64_inc(&snic->s_stats.misc.data_cnt_mismat); in snic_process_io_failed_state()
429 scsi_set_resid(sc, le32_to_cpu(icmnd_cmpl->resid)); in snic_process_io_failed_state()
434 atomic64_inc(&snic->s_stats.fw.out_of_res); in snic_process_io_failed_state()
439 atomic64_inc(&snic->s_stats.io.io_not_found); in snic_process_io_failed_state()
444 atomic64_inc(&snic->s_stats.misc.sgl_inval); in snic_process_io_failed_state()
449 atomic64_inc(&snic->s_stats.fw.io_errs); in snic_process_io_failed_state()
454 atomic64_inc(&snic->s_stats.fw.scsi_errs); in snic_process_io_failed_state()
468 SNIC_SCSI_DBG(snic->shost, in snic_process_io_failed_state()
474 SNIC_HOST_ERR(snic->shost, "fw returns failed status %s flags 0x%llx\n", in snic_process_io_failed_state()
477 /* Set sc->result */ in snic_process_io_failed_state()
478 sc->result = (res << 16) | icmnd_cmpl->scsi_status; in snic_process_io_failed_state()
503 u8 scsi_stat = icmnd_cmpl->scsi_status; in snic_process_icmnd_cmpl_status()
507 /* Mark the IO as complete */ in snic_process_icmnd_cmpl_status()
511 sc->result = (DID_OK << 16) | scsi_stat; in snic_process_icmnd_cmpl_status()
516 scsi_set_resid(sc, le32_to_cpu(icmnd_cmpl->resid)); in snic_process_icmnd_cmpl_status()
518 if (icmnd_cmpl->flags & SNIC_ICMND_CMPL_UNDR_RUN) { in snic_process_icmnd_cmpl_status()
519 xfer_len -= le32_to_cpu(icmnd_cmpl->resid); in snic_process_icmnd_cmpl_status()
520 atomic64_inc(&snic->s_stats.misc.io_under_run); in snic_process_icmnd_cmpl_status()
523 if (icmnd_cmpl->scsi_status == SAM_STAT_TASK_SET_FULL) in snic_process_icmnd_cmpl_status()
524 atomic64_inc(&snic->s_stats.misc.qfull); in snic_process_icmnd_cmpl_status()
529 atomic64_inc(&snic->s_stats.io.fail); in snic_process_icmnd_cmpl_status()
530 SNIC_HOST_ERR(snic->shost, in snic_process_icmnd_cmpl_status()
531 "icmnd_cmpl: IO Failed : Hdr Status %s flags 0x%llx\n", in snic_process_icmnd_cmpl_status()
558 snic_io_hdr_dec(&fwreq->hdr, &typ, &hdr_stat, &cmnd_id, &hid, &ctx); in snic_icmnd_cmpl_handler()
559 icmnd_cmpl = &fwreq->u.icmnd_cmpl; in snic_icmnd_cmpl_handler()
560 sc_stat = icmnd_cmpl->scsi_status; in snic_icmnd_cmpl_handler()
562 SNIC_SCSI_DBG(snic->shost, in snic_icmnd_cmpl_handler()
566 if (cmnd_id >= snic->max_tag_id) { in snic_icmnd_cmpl_handler()
567 SNIC_HOST_ERR(snic->shost, in snic_icmnd_cmpl_handler()
573 sc = scsi_host_find_tag(snic->shost, cmnd_id); in snic_icmnd_cmpl_handler()
577 atomic64_inc(&snic->s_stats.io.sc_null); in snic_icmnd_cmpl_handler()
578 SNIC_HOST_ERR(snic->shost, in snic_icmnd_cmpl_handler()
584 SNIC_TRC(snic->shost->host_no, cmnd_id, 0, in snic_icmnd_cmpl_handler()
586 (u64)sc_stat << 8 | (u64)icmnd_cmpl->flags), in snic_icmnd_cmpl_handler()
587 (ulong) fwreq, le32_to_cpu(icmnd_cmpl->resid), ctx); in snic_icmnd_cmpl_handler()
596 SNIC_SCSI_DBG(snic->shost, in snic_icmnd_cmpl_handler()
598 sc->device->lun, sc, sc->cmnd[0], snic_cmd_tag(sc), in snic_icmnd_cmpl_handler()
610 atomic64_inc(&snic->s_stats.io.req_null); in snic_icmnd_cmpl_handler()
614 SNIC_HOST_ERR(snic->shost, in snic_icmnd_cmpl_handler()
622 start_time = rqi->start_time; in snic_icmnd_cmpl_handler()
624 /* firmware completed the io */ in snic_icmnd_cmpl_handler()
625 rqi->io_cmpl = 1; in snic_icmnd_cmpl_handler()
628 * if SCSI-ML has already issued abort on this command, in snic_icmnd_cmpl_handler()
629 * ignore completion of the IO. The abts path will clean it up in snic_icmnd_cmpl_handler()
635 snic_stats_update_io_cmpl(&snic->s_stats); in snic_icmnd_cmpl_handler()
641 SNIC_SCSI_DBG(snic->shost, in snic_icmnd_cmpl_handler()
645 sc, sc_stat, le32_to_cpu(icmnd_cmpl->resid), in snic_icmnd_cmpl_handler()
648 SNIC_TRC(snic->shost->host_no, cmnd_id, (ulong) sc, in snic_icmnd_cmpl_handler()
649 jiffies_to_msecs(jiffies - start_time), (ulong) fwreq, in snic_icmnd_cmpl_handler()
657 SNIC_HOST_ERR(snic->shost, in snic_icmnd_cmpl_handler()
658 "icmnd_cmpl:IO Failed, sc 0x%p Tag %d Cmd %x Hdr Status %s flags 0x%llx\n", in snic_icmnd_cmpl_handler()
659 sc, sc->cmnd[0], cmnd_id, in snic_icmnd_cmpl_handler()
669 /* For now, consider only successful IO. */ in snic_icmnd_cmpl_handler()
674 SNIC_TRC(snic->shost->host_no, cmnd_id, (ulong) sc, in snic_icmnd_cmpl_handler()
675 jiffies_to_msecs(jiffies - start_time), (ulong) fwreq, in snic_icmnd_cmpl_handler()
679 if (sc->scsi_done) in snic_icmnd_cmpl_handler()
680 sc->scsi_done(sc); in snic_icmnd_cmpl_handler()
682 snic_stats_update_io_cmpl(&snic->s_stats); in snic_icmnd_cmpl_handler()
693 u32 start_time = rqi->start_time; in snic_proc_dr_cmpl_locked()
697 SNIC_SCSI_DBG(snic->shost, "itmf_cmpl: Cmd State = %s\n", in snic_proc_dr_cmpl_locked()
703 SNIC_TRC(snic->shost->host_no, cmnd_id, (ulong) sc, in snic_proc_dr_cmpl_locked()
704 jiffies_to_msecs(jiffies - start_time), in snic_proc_dr_cmpl_locked()
707 SNIC_SCSI_DBG(snic->shost, in snic_proc_dr_cmpl_locked()
708 "itmf_cmpl: Terminate Pending Dev Reset Cmpl Recvd.id %x, status %s flags 0x%llx\n", in snic_proc_dr_cmpl_locked()
718 SNIC_TRC(snic->shost->host_no, cmnd_id, (ulong) sc, in snic_proc_dr_cmpl_locked()
719 jiffies_to_msecs(jiffies - start_time), in snic_proc_dr_cmpl_locked()
722 SNIC_SCSI_DBG(snic->shost, in snic_proc_dr_cmpl_locked()
723 … "itmf_cmpl:Dev Reset Completion Received after timeout. id %d cmpl status %s flags 0x%llx\n", in snic_proc_dr_cmpl_locked()
734 SNIC_SCSI_DBG(snic->shost, in snic_proc_dr_cmpl_locked()
735 "itmf_cmpl:Dev Reset Cmpl Recvd id %d cmpl status %s flags 0x%llx\n", in snic_proc_dr_cmpl_locked()
740 if (rqi->dr_done) in snic_proc_dr_cmpl_locked()
741 complete(rqi->dr_done); in snic_proc_dr_cmpl_locked()
750 struct snic_abort_stats *abt_stats = &snic->s_stats.abts; in snic_update_abort_stats()
752 SNIC_SCSI_DBG(snic->shost, "Updating Abort stats.\n"); in snic_update_abort_stats()
759 atomic64_inc(&abt_stats->fw_tmo); in snic_update_abort_stats()
763 atomic64_inc(&abt_stats->io_not_found); in snic_update_abort_stats()
767 atomic64_inc(&abt_stats->fail); in snic_update_abort_stats()
797 atomic64_inc(&snic->s_stats.io.req_null); in snic_process_itmf_cmpl()
800 SNIC_HOST_ERR(snic->shost, in snic_process_itmf_cmpl()
811 start_time = rqi->start_time; in snic_process_itmf_cmpl()
821 ret = -1; in snic_process_itmf_cmpl()
830 SNIC_SCSI_DBG(snic->shost, in snic_process_itmf_cmpl()
838 * signal completion to it. IO will be cleaned in the thread, in snic_process_itmf_cmpl()
841 if (rqi->abts_done) { in snic_process_itmf_cmpl()
842 complete(rqi->abts_done); in snic_process_itmf_cmpl()
849 sc->result = (DID_ERROR << 16); in snic_process_itmf_cmpl()
850 SNIC_SCSI_DBG(snic->shost, in snic_process_itmf_cmpl()
851 "itmf_cmpl: Completing IO. sc %p flags 0x%llx\n", in snic_process_itmf_cmpl()
858 if (sc->scsi_done) { in snic_process_itmf_cmpl()
859 SNIC_TRC(snic->shost->host_no, cmnd_id, (ulong) sc, in snic_process_itmf_cmpl()
860 jiffies_to_msecs(jiffies - start_time), in snic_process_itmf_cmpl()
864 sc->scsi_done(sc); in snic_process_itmf_cmpl()
878 /* Abort and terminate completion of device reset req */ in snic_process_itmf_cmpl()
884 SNIC_SCSI_DBG(snic->shost, in snic_process_itmf_cmpl()
885 "itmf_cmpl:dev reset abts cmpl recvd. id %d status %s flags 0x%llx\n", in snic_process_itmf_cmpl()
889 if (rqi->abts_done) in snic_process_itmf_cmpl()
890 complete(rqi->abts_done); in snic_process_itmf_cmpl()
898 SNIC_HOST_ERR(snic->shost, in snic_process_itmf_cmpl()
901 SNIC_HOST_ERR(snic->shost, in snic_process_itmf_cmpl()
902 "itmf_cmpl:Unexpected itmf io stat %s Tag = 0x%x flags 0x%llx\n", in snic_process_itmf_cmpl()
906 ret = -1; in snic_process_itmf_cmpl()
931 snic_io_hdr_dec(&fwreq->hdr, &typ, &hdr_stat, &cmnd_id, &hid, &ctx); in snic_itmf_cmpl_handler()
932 SNIC_SCSI_DBG(snic->shost, in snic_itmf_cmpl_handler()
936 itmf_cmpl = &fwreq->u.itmf_cmpl; in snic_itmf_cmpl_handler()
937 SNIC_SCSI_DBG(snic->shost, in snic_itmf_cmpl_handler()
939 le32_to_cpu(itmf_cmpl->nterminated), itmf_cmpl->flags); in snic_itmf_cmpl_handler()
941 /* spl case, dev reset issued through ioctl */ in snic_itmf_cmpl_handler()
944 sc = rqi->sc; in snic_itmf_cmpl_handler()
949 if ((cmnd_id & SNIC_TAG_MASK) >= snic->max_tag_id) { in snic_itmf_cmpl_handler()
950 SNIC_HOST_ERR(snic->shost, in snic_itmf_cmpl_handler()
958 sc = scsi_host_find_tag(snic->shost, cmnd_id & SNIC_TAG_MASK); in snic_itmf_cmpl_handler()
963 atomic64_inc(&snic->s_stats.io.sc_null); in snic_itmf_cmpl_handler()
964 SNIC_HOST_ERR(snic->shost, in snic_itmf_cmpl_handler()
965 "Itmf_cmpl: sc is NULL - Hdr Stat %s Tag 0x%x\n", in snic_itmf_cmpl_handler()
979 struct snic_stats *st = &snic->s_stats; in snic_hba_reset_scsi_cleanup()
982 SNIC_SCSI_DBG(snic->shost, "HBA Reset scsi cleanup.\n"); in snic_hba_reset_scsi_cleanup()
986 act_ios = atomic64_read(&st->io.active); in snic_hba_reset_scsi_cleanup()
987 atomic64_add(act_ios, &st->io.compl); in snic_hba_reset_scsi_cleanup()
988 atomic64_sub(act_ios, &st->io.active); in snic_hba_reset_scsi_cleanup()
990 act_fwreqs = atomic64_read(&st->fw.actv_reqs); in snic_hba_reset_scsi_cleanup()
991 atomic64_sub(act_fwreqs, &st->fw.actv_reqs); in snic_hba_reset_scsi_cleanup()
1015 snic_io_hdr_dec(&fwreq->hdr, &typ, &hdr_stat, &cmnd_id, &hid, &ctx); in snic_hba_reset_cmpl_handler()
1016 SNIC_HOST_INFO(snic->shost, in snic_hba_reset_cmpl_handler()
1017 "reset_cmpl:Tag %d ctx %lx cmpl status %s HBA Reset Completion received.\n", in snic_hba_reset_cmpl_handler()
1020 SNIC_SCSI_DBG(snic->shost, in snic_hba_reset_cmpl_handler()
1024 /* spl case, host reset issued through ioctl */ in snic_hba_reset_cmpl_handler()
1027 SNIC_HOST_INFO(snic->shost, in snic_hba_reset_cmpl_handler()
1030 sc = rqi->sc; in snic_hba_reset_cmpl_handler()
1035 if (cmnd_id >= snic->max_tag_id) { in snic_hba_reset_cmpl_handler()
1036 SNIC_HOST_ERR(snic->shost, in snic_hba_reset_cmpl_handler()
1044 sc = scsi_host_find_tag(snic->shost, cmnd_id); in snic_hba_reset_cmpl_handler()
1047 atomic64_inc(&snic->s_stats.io.sc_null); in snic_hba_reset_cmpl_handler()
1048 SNIC_HOST_ERR(snic->shost, in snic_hba_reset_cmpl_handler()
1049 "reset_cmpl: sc is NULL - Hdr Stat %s Tag 0x%x\n", in snic_hba_reset_cmpl_handler()
1056 SNIC_HOST_INFO(snic->shost, in snic_hba_reset_cmpl_handler()
1063 if (!snic->remove_wait) { in snic_hba_reset_cmpl_handler()
1065 SNIC_HOST_ERR(snic->shost, in snic_hba_reset_cmpl_handler()
1066 "reset_cmpl:host reset completed after timeout\n"); in snic_hba_reset_cmpl_handler()
1076 atomic64_inc(&snic->s_stats.io.req_null); in snic_hba_reset_cmpl_handler()
1079 SNIC_HOST_ERR(snic->shost, in snic_hba_reset_cmpl_handler()
1097 /* Careful locking between snic_lock and io lock */ in snic_hba_reset_cmpl_handler()
1099 spin_lock_irqsave(&snic->snic_lock, gflags); in snic_hba_reset_cmpl_handler()
1102 spin_unlock_irqrestore(&snic->snic_lock, gflags); in snic_hba_reset_cmpl_handler()
1104 if (snic->remove_wait) in snic_hba_reset_cmpl_handler()
1105 complete(snic->remove_wait); in snic_hba_reset_cmpl_handler()
1108 atomic64_inc(&snic->s_stats.reset.hba_reset_cmpl); in snic_hba_reset_cmpl_handler()
1112 if (snic->config.xpt_type == SNIC_DAS) in snic_hba_reset_cmpl_handler()
1115 SNIC_SCSI_DBG(snic->shost, "reset_cmpl: Queuing discovery work.\n"); in snic_hba_reset_cmpl_handler()
1116 queue_work(snic_glob->event_q, &snic->disc_work); in snic_hba_reset_cmpl_handler()
1124 SNIC_HOST_INFO(snic->shost, "Message Ack Received.\n"); in snic_msg_ack_handler()
1135 struct snic_async_evnotify *aen = &fwreq->u.async_ev; in snic_aen_handler()
1138 snic_io_hdr_dec(&fwreq->hdr, &typ, &hdr_stat, &cmnd_id, &hid, &ctx); in snic_aen_handler()
1139 SNIC_SCSI_DBG(snic->shost, in snic_aen_handler()
1143 event_id = le32_to_cpu(aen->ev_id); in snic_aen_handler()
1147 SNIC_HOST_INFO(snic->shost, "aen:TGT_OFFLINE Event Recvd.\n"); in snic_aen_handler()
1151 SNIC_HOST_INFO(snic->shost, "aen:TGT_ONLINE Event Recvd.\n"); in snic_aen_handler()
1155 SNIC_HOST_INFO(snic->shost, "aen:LUN_OFFLINE Event Recvd.\n"); in snic_aen_handler()
1159 SNIC_HOST_INFO(snic->shost, "aen:LUN_ONLINE Event Recvd.\n"); in snic_aen_handler()
1163 SNIC_HOST_INFO(snic->shost, "aen:Config Change Event Recvd.\n"); in snic_aen_handler()
1167 SNIC_HOST_INFO(snic->shost, "aen:TGT_ADD Event Recvd.\n"); in snic_aen_handler()
1171 SNIC_HOST_INFO(snic->shost, "aen:TGT_DEL Event Recvd.\n"); in snic_aen_handler()
1175 SNIC_HOST_INFO(snic->shost, "aen:LUN_ADD Event Recvd.\n"); in snic_aen_handler()
1179 SNIC_HOST_INFO(snic->shost, "aen:LUN_DEL Event Recvd.\n"); in snic_aen_handler()
1183 SNIC_HOST_INFO(snic->shost, "aen:DISC_CMPL Event Recvd.\n"); in snic_aen_handler()
1187 SNIC_HOST_INFO(snic->shost, "aen:Unknown Event Recvd.\n"); in snic_aen_handler()
1197 * Routine to process CQ entries(IO Completions) posted by fw.
1210 if ((fwreq->hdr.type >= SNIC_RSP_REPORT_TGTS_CMPL) && in snic_io_cmpl_handler()
1211 (fwreq->hdr.type <= SNIC_RSP_BOOT_LUNS_CMPL)) in snic_io_cmpl_handler()
1212 atomic64_dec(&snic->s_stats.fw.actv_reqs); in snic_io_cmpl_handler()
1214 SNIC_BUG_ON((fwreq->hdr.type > SNIC_RSP_BOOT_LUNS_CMPL) && in snic_io_cmpl_handler()
1215 (fwreq->hdr.type < SNIC_MSG_ASYNC_EVNOTIFY)); in snic_io_cmpl_handler()
1218 switch (fwreq->hdr.status) { in snic_io_cmpl_handler()
1220 SNIC_HOST_ERR(snic->shost, in snic_io_cmpl_handler()
1225 SNIC_HOST_ERR(snic->shost, in snic_io_cmpl_handler()
1230 switch (fwreq->hdr.type) { in snic_io_cmpl_handler()
1261 SNIC_SCSI_DBG(snic->shost, in snic_io_cmpl_handler()
1263 fwreq->hdr.type); in snic_io_cmpl_handler()
1268 cmpl_time = jiffies - start; in snic_io_cmpl_handler()
1269 if (cmpl_time > atomic64_read(&snic->s_stats.io.max_cmpl_time)) in snic_io_cmpl_handler()
1270 atomic64_set(&snic->s_stats.io.max_cmpl_time, cmpl_time); in snic_io_cmpl_handler()
1286 struct snic_misc_stats *misc_stats = &snic->s_stats.misc; in snic_fwcq_cmpl_handler()
1288 for (cq_idx = snic->wq_count; cq_idx < snic->cq_count; cq_idx++) { in snic_fwcq_cmpl_handler()
1289 nent_per_cq = vnic_cq_fw_service(&snic->cq[cq_idx], in snic_fwcq_cmpl_handler()
1294 if (nent_per_cq > atomic64_read(&misc_stats->max_cq_ents)) in snic_fwcq_cmpl_handler()
1295 atomic64_set(&misc_stats->max_cq_ents, nent_per_cq); in snic_fwcq_cmpl_handler()
1303 * Use rqi->tm_tag for passing special tags.
1304 * @req_id : aborted request's tag, -1 for lun reset.
1315 int tm_tag = snic_cmd_tag(sc) | rqi->tm_tag; in snic_queue_itmf_req()
1319 SNIC_BUG_ON(!rqi->tm_tag); in snic_queue_itmf_req()
1322 int_to_scsilun(sc->device->lun, &lun); in snic_queue_itmf_req()
1327 snic->config.hid, in snic_queue_itmf_req()
1331 rqi->tgt_id, in snic_queue_itmf_req()
1339 * prior.SNIC_BUG_ON(completion_done(&rqi->done)); in snic_queue_itmf_req()
1344 SNIC_HOST_ERR(snic->shost, in snic_queue_itmf_req()
1348 SNIC_SCSI_DBG(snic->shost, in snic_queue_itmf_req()
1349 "qitmf:Queuing ITMF(%d) Req sc %p, rqi %p, req_id %d, tag %d (req_id)- Success.", in snic_queue_itmf_req()
1366 return -EBUSY; in snic_issue_tm_req()
1368 atomic_inc(&snic->ios_inflight); in snic_issue_tm_req()
1370 SNIC_SCSI_DBG(snic->shost, in snic_issue_tm_req()
1384 ret = -ENOMEM; in snic_issue_tm_req()
1393 SNIC_HOST_ERR(snic->shost, in snic_issue_tm_req()
1397 SNIC_SCSI_DBG(snic->shost, in snic_issue_tm_req()
1398 "issu_tmreq: Queueing ITMF(%d) Req, sc %p, rqi %p, req_id %d tag %x - Success.\n", in snic_issue_tm_req()
1402 atomic_dec(&snic->ios_inflight); in snic_issue_tm_req()
1416 SNIC_SCSI_DBG(snic->shost, "q_abtreq: sc %p, rqi %p, tag %x, tmf %d\n", in snic_queue_abort_req()
1420 rqi->tm_tag |= SNIC_TAG_ABORT; in snic_queue_abort_req()
1440 atomic64_inc(&snic->s_stats.io.req_null); in snic_abort_finish()
1443 SNIC_SCSI_DBG(snic->shost, in snic_abort_finish()
1451 rqi->abts_done = NULL; in snic_abort_finish()
1460 atomic64_inc(&snic->s_stats.abts.drv_tmo); in snic_abort_finish()
1461 SNIC_SCSI_DBG(snic->shost, in snic_abort_finish()
1474 * the # IO timeouts == 2, will cause the LUN offline. in snic_abort_finish()
1475 * Call scsi_done to complete the IO. in snic_abort_finish()
1477 sc->result = (DID_ERROR << 16); in snic_abort_finish()
1478 sc->scsi_done(sc); in snic_abort_finish()
1489 SNIC_HOST_INFO(snic->shost, in snic_abort_finish()
1516 tgt = starget_to_tgt(scsi_target(sc->device)); in snic_send_abort_and_wait()
1517 if ((snic_tgt_chkready(tgt) != 0) && (tgt->tdata.typ == SNIC_TGT_SAN)) in snic_send_abort_and_wait()
1543 SNIC_HOST_ERR(snic->shost, in snic_send_abort_and_wait()
1552 rqi->abts_done = &tm_done; in snic_send_abort_and_wait()
1559 SNIC_BUG_ON(!rqi->abts_done); in snic_send_abort_and_wait()
1567 * the completion won't be done till mid-layer, since abot in snic_send_abort_and_wait()
1573 SNIC_SCSI_DBG(snic->shost, "send_abt_cmd: TAG 0x%x\n", tag); in snic_send_abort_and_wait()
1580 atomic64_inc(&snic->s_stats.abts.q_fail); in snic_send_abort_and_wait()
1581 SNIC_HOST_ERR(snic->shost, in snic_send_abort_and_wait()
1582 "send_abt_cmd: IO w/ Tag 0x%x fail w/ err %d flags 0x%llx\n", in snic_send_abort_and_wait()
1590 rqi->abts_done = NULL; in snic_send_abort_and_wait()
1600 atomic64_inc(&snic->s_stats.abts.num); in snic_send_abort_and_wait()
1607 SNIC_SCSI_DBG(snic->shost, in snic_send_abort_and_wait()
1616 * Queued an abort IO, wait for its completion. in snic_send_abort_and_wait()
1628 * A SCSI IO is represent by snic_ioreq in the driver.
1629 * The snic_ioreq is linked to the SCSI Cmd, thus a link with the ULP'S IO
1634 struct snic *snic = shost_priv(sc->device->host); in snic_abort_cmd()
1638 SNIC_SCSI_DBG(snic->shost, "abt_cmd:sc %p :0x%x :req = %p :tag = %d\n", in snic_abort_cmd()
1639 sc, sc->cmnd[0], sc->request, tag); in snic_abort_cmd()
1642 SNIC_HOST_ERR(snic->shost, in snic_abort_cmd()
1658 SNIC_TRC(snic->shost->host_no, tag, (ulong) sc, in snic_abort_cmd()
1659 jiffies_to_msecs(jiffies - start_time), 0, in snic_abort_cmd()
1662 SNIC_SCSI_DBG(snic->shost, in snic_abort_cmd()
1683 lr_sdev = lr_sc->device; in snic_is_abts_pending()
1686 for (tag = 0; tag < snic->max_tag_id; tag++) { in snic_is_abts_pending()
1690 sc = scsi_host_find_tag(snic->shost, tag); in snic_is_abts_pending()
1692 if (!sc || (lr_sc && (sc->device != lr_sdev || sc == lr_sc))) { in snic_is_abts_pending()
1706 * Found IO that is still pending w/ firmware and belongs to in snic_is_abts_pending()
1707 * the LUN that is under reset, if lr_sc != NULL in snic_is_abts_pending()
1709 SNIC_SCSI_DBG(snic->shost, "Found IO in %s on LUN\n", in snic_is_abts_pending()
1740 sc = scsi_host_find_tag(snic->shost, tag); in snic_dr_clean_single_req()
1742 /* Ignore Cmd that don't belong to Lun Reset device */ in snic_dr_clean_single_req()
1743 if (!sc || sc->device != lr_sdev) in snic_dr_clean_single_req()
1759 SNIC_SCSI_DBG(snic->shost, in snic_dr_clean_single_req()
1766 SNIC_SCSI_DBG(snic->shost, in snic_dr_clean_single_req()
1767 "clean_single_req: Found IO in %s on lun\n", in snic_dr_clean_single_req()
1774 * Any pending IO issued prior to reset is expected to be in snic_dr_clean_single_req()
1776 * to indicate the IO is abort pending. in snic_dr_clean_single_req()
1777 * When IO is completed, the IO will be handed over and handled in snic_dr_clean_single_req()
1782 SNIC_BUG_ON(rqi->abts_done); in snic_dr_clean_single_req()
1785 rqi->tm_tag = SNIC_TAG_DEV_RST; in snic_dr_clean_single_req()
1787 SNIC_SCSI_DBG(snic->shost, in snic_dr_clean_single_req()
1792 rqi->abts_done = &tm_done; in snic_dr_clean_single_req()
1795 tgt = starget_to_tgt(scsi_target(sc->device)); in snic_dr_clean_single_req()
1796 if ((snic_tgt_chkready(tgt) != 0) && (tgt->tdata.typ == SNIC_TGT_SAN)) in snic_dr_clean_single_req()
1804 SNIC_HOST_ERR(snic->shost, in snic_dr_clean_single_req()
1806 sc, tag, rqi->tm_tag, CMD_FLAGS(sc)); in snic_dr_clean_single_req()
1811 rqi->abts_done = NULL; in snic_dr_clean_single_req()
1837 rqi->abts_done = NULL; in snic_dr_clean_single_req()
1841 SNIC_HOST_ERR(snic->shost, in snic_dr_clean_single_req()
1843 sc, tag, rqi->tm_tag, CMD_FLAGS(sc)); in snic_dr_clean_single_req()
1857 sc->result = (DID_ERROR << 16); in snic_dr_clean_single_req()
1858 sc->scsi_done(sc); in snic_dr_clean_single_req()
1873 struct scsi_device *lr_sdev = lr_sc->device; in snic_dr_clean_pending_req()
1877 for (tag = 0; tag < snic->max_tag_id; tag++) { in snic_dr_clean_pending_req()
1883 SNIC_HOST_ERR(snic->shost, "clean_err:tag = %d\n", tag); in snic_dr_clean_pending_req()
1899 SNIC_SCSI_DBG(snic->shost, "clean_pending_req: Success.\n"); in snic_dr_clean_pending_req()
1905 SNIC_HOST_ERR(snic->shost, in snic_dr_clean_pending_req()
1907 dev_name(&lr_sdev->sdev_gendev)); in snic_dr_clean_pending_req()
1930 SNIC_SCSI_DBG(snic->shost, in snic_dr_finish()
1938 rqi->dr_done = NULL; in snic_dr_finish()
1945 SNIC_SCSI_DBG(snic->shost, in snic_dr_finish()
1946 "dr_fini: Tag %x Dev Reset Timedout. flags 0x%llx\n", in snic_dr_finish()
1955 SNIC_SCSI_DBG(snic->shost, in snic_dr_finish()
1956 "dr_fini: Tag %x Dev Reset cmpl\n", in snic_dr_finish()
1962 SNIC_HOST_ERR(snic->shost, in snic_dr_finish()
1963 "dr_fini:Device Reset completed& failed.Tag = %x lr_status %s flags 0x%llx\n", in snic_dr_finish()
1973 * If any of these fail, then LUN Reset fails. in snic_dr_finish()
1975 * the lun reset command. If all cmds get cleaned, the LUN Reset in snic_dr_finish()
1982 SNIC_SCSI_DBG(snic->shost, in snic_dr_finish()
1983 "dr_fini: Device Reset Failed since could not abort all IOs. Tag = %x.\n", in snic_dr_finish()
1989 /* Cleanup LUN Reset Command */ in snic_dr_finish()
2016 /* Add special tag for device reset */ in snic_queue_dr_req()
2017 rqi->tm_tag |= SNIC_TAG_DEV_RST; in snic_queue_dr_req()
2037 SNIC_HOST_ERR(snic->shost, in snic_send_dr_and_wait()
2052 SNIC_SCSI_DBG(snic->shost, "dr: TAG = %x\n", tag); in snic_send_dr_and_wait()
2054 rqi->dr_done = &tm_done; in snic_send_dr_and_wait()
2055 SNIC_BUG_ON(!rqi->dr_done); in snic_send_dr_and_wait()
2062 * This logic still makes LUN Reset is inevitable. in snic_send_dr_and_wait()
2067 SNIC_HOST_ERR(snic->shost, in snic_send_dr_and_wait()
2068 "send_dr: IO w/ Tag 0x%x Failed err = %d. flags 0x%llx\n", in snic_send_dr_and_wait()
2076 rqi->dr_done = NULL; in snic_send_dr_and_wait()
2097 * auxillary funciton to check lun reset op is supported or not
2105 if (tgt->tdata.typ == SNIC_TGT_DAS) in snic_dev_reset_supported()
2123 start_time = rqi->start_time; in snic_unlink_and_release_req()
2133 SNIC_TRC(snic->shost->host_no, snic_cmd_tag(sc), (ulong) sc, in snic_unlink_and_release_req()
2134 jiffies_to_msecs(jiffies - start_time), (ulong) rqi, in snic_unlink_and_release_req()
2139 * SCSI Eh thread issues a LUN Reset when one or more commands on a LUN
2146 struct Scsi_Host *shost = sc->device->host; in snic_device_reset()
2155 sc, sc->cmnd[0], sc->request, in snic_device_reset()
2157 dr_supp = snic_dev_reset_supported(sc->device); in snic_device_reset()
2159 /* device reset op is not supported */ in snic_device_reset()
2160 SNIC_HOST_INFO(shost, "LUN Reset Op not supported.\n"); in snic_device_reset()
2173 /* There is no tag when lun reset is issue through ioctl. */ in snic_device_reset()
2175 SNIC_HOST_INFO(snic->shost, in snic_device_reset()
2176 "Devrst: LUN Reset Recvd thru IOCTL.\n"); in snic_device_reset()
2188 rqi->tm_tag = SNIC_TAG_IOCTL_DEV_RST; in snic_device_reset()
2189 rqi->sc = sc; in snic_device_reset()
2194 SNIC_HOST_ERR(snic->shost, in snic_device_reset()
2195 "Devrst: IO w/ Tag %x Failed w/ err = %d\n", in snic_device_reset()
2206 SNIC_TRC(snic->shost->host_no, tag, (ulong) sc, in snic_device_reset()
2207 jiffies_to_msecs(jiffies - start_time), in snic_device_reset()
2210 SNIC_SCSI_DBG(snic->shost, in snic_device_reset()
2211 "Devrst: Returning from Device Reset : %s\n", in snic_device_reset()
2221 * Host Reset is the highest level of error recovery. If this fails, then
2225 * snic_issue_hba_reset : Queues FW Reset Request.
2235 int ret = -ENOMEM; in snic_issue_hba_reset()
2239 ret = -ENOMEM; in snic_issue_hba_reset()
2247 SNIC_HOST_INFO(snic->shost, "issu_hr:Host reset thru ioctl.\n"); in snic_issue_hba_reset()
2248 rqi->sc = sc; in snic_issue_hba_reset()
2259 snic->remove_wait = &wait; in snic_issue_hba_reset()
2263 snic_io_hdr_enc(&req->hdr, SNIC_REQ_HBA_RESET, 0, snic_cmd_tag(sc), in snic_issue_hba_reset()
2264 snic->config.hid, 0, (ulong) rqi); in snic_issue_hba_reset()
2266 req->u.reset.flags = 0; in snic_issue_hba_reset()
2270 SNIC_HOST_ERR(snic->shost, in snic_issue_hba_reset()
2271 "issu_hr:Queuing HBA Reset Failed. w err %d\n", in snic_issue_hba_reset()
2280 atomic64_inc(&snic->s_stats.reset.hba_resets); in snic_issue_hba_reset()
2281 SNIC_HOST_INFO(snic->shost, "Queued HBA Reset Successfully.\n"); in snic_issue_hba_reset()
2283 wait_for_completion_timeout(snic->remove_wait, in snic_issue_hba_reset()
2287 SNIC_HOST_ERR(snic->shost, "reset_cmpl: Reset Timedout.\n"); in snic_issue_hba_reset()
2288 ret = -ETIMEDOUT; in snic_issue_hba_reset()
2294 snic->remove_wait = NULL; in snic_issue_hba_reset()
2308 snic->remove_wait = NULL; in snic_issue_hba_reset()
2317 SNIC_HOST_ERR(snic->shost, in snic_issue_hba_reset()
2318 "reset:HBA Reset Failed w/ err = %d.\n", in snic_issue_hba_reset()
2335 spin_lock_irqsave(&snic->snic_lock, flags); in snic_reset()
2337 spin_unlock_irqrestore(&snic->snic_lock, flags); in snic_reset()
2338 SNIC_HOST_INFO(shost, "reset:prev reset is in progres\n"); in snic_reset()
2347 spin_unlock_irqrestore(&snic->snic_lock, flags); in snic_reset()
2351 while (atomic_read(&snic->ios_inflight)) in snic_reset()
2357 "reset:Host Reset Failed w/ err %d.\n", in snic_reset()
2359 spin_lock_irqsave(&snic->snic_lock, flags); in snic_reset()
2361 spin_unlock_irqrestore(&snic->snic_lock, flags); in snic_reset()
2362 atomic64_inc(&snic->s_stats.reset.hba_reset_fail); in snic_reset()
2378 * Host Reset is the highest level of error recovery. If this fails, then
2384 struct Scsi_Host *shost = sc->device->host; in snic_host_reset()
2389 "host reset:sc %p sc_cmd 0x%x req %p tag %d flags 0x%llx\n", in snic_host_reset()
2390 sc, sc->cmnd[0], sc->request, in snic_host_reset()
2395 SNIC_TRC(shost->host_no, snic_cmd_tag(sc), (ulong) sc, in snic_host_reset()
2396 jiffies_to_msecs(jiffies - start_time), in snic_host_reset()
2410 SNIC_SCSI_DBG(snic->shost, in snic_cmpl_pending_tmreq()
2425 if (rqi->dr_done) in snic_cmpl_pending_tmreq()
2426 complete(rqi->dr_done); in snic_cmpl_pending_tmreq()
2427 else if (rqi->abts_done) in snic_cmpl_pending_tmreq()
2428 complete(rqi->abts_done); in snic_cmpl_pending_tmreq()
2444 SNIC_SCSI_DBG(snic->shost, "sc_clean: scsi cleanup.\n"); in snic_scsi_cleanup()
2446 for (tag = 0; tag < snic->max_tag_id; tag++) { in snic_scsi_cleanup()
2453 sc = scsi_host_find_tag(snic->shost, tag); in snic_scsi_cleanup()
2462 * When FW Completes reset w/o sending completions in snic_scsi_cleanup()
2478 SNIC_SCSI_DBG(snic->shost, in snic_scsi_cleanup()
2485 st_time = rqi->start_time; in snic_scsi_cleanup()
2487 SNIC_HOST_INFO(snic->shost, in snic_scsi_cleanup()
2494 sc->result = DID_TRANSPORT_DISRUPTED << 16; in snic_scsi_cleanup()
2495 SNIC_HOST_INFO(snic->shost, in snic_scsi_cleanup()
2497 sc, sc->request->tag, CMD_FLAGS(sc), rqi, in snic_scsi_cleanup()
2498 jiffies_to_msecs(jiffies - st_time)); in snic_scsi_cleanup()
2500 /* Update IO stats */ in snic_scsi_cleanup()
2501 snic_stats_update_io_cmpl(&snic->s_stats); in snic_scsi_cleanup()
2503 if (sc->scsi_done) { in snic_scsi_cleanup()
2504 SNIC_TRC(snic->shost->host_no, tag, (ulong) sc, in snic_scsi_cleanup()
2505 jiffies_to_msecs(jiffies - st_time), 0, in snic_scsi_cleanup()
2509 sc->scsi_done(sc); in snic_scsi_cleanup()
2517 SNIC_HOST_INFO(snic->shost, "Shutdown time SCSI Cleanup.\n"); in snic_shutdown_scsi_cleanup()
2547 SNIC_SCSI_DBG(snic->shost, in snic_internal_abort_io()
2556 SNIC_SCSI_DBG(snic->shost, in snic_internal_abort_io()
2557 "internal_abts: IO not yet issued sc 0x%p tag 0x%x flags 0x%llx state %d\n", in snic_internal_abort_io()
2570 rqi->tm_tag = SNIC_TAG_DEV_RST; in snic_internal_abort_io()
2571 SNIC_SCSI_DBG(snic->shost, "internal_abts:dev rst sc %p\n", sc); in snic_internal_abort_io()
2574 SNIC_SCSI_DBG(snic->shost, "internal_abts: Issuing abts tag %x\n", in snic_internal_abort_io()
2576 SNIC_BUG_ON(rqi->abts_done); in snic_internal_abort_io()
2581 SNIC_HOST_ERR(snic->shost, in snic_internal_abort_io()
2622 return -1; in snic_tgt_scsi_abort_io()
2625 SNIC_SCSI_DBG(snic->shost, "tgt_abt_io: Cleaning Pending IOs.\n"); in snic_tgt_scsi_abort_io()
2627 if (tgt->tdata.typ == SNIC_TGT_DAS) in snic_tgt_scsi_abort_io()
2632 for (tag = 0; tag < snic->max_tag_id; tag++) { in snic_tgt_scsi_abort_io()
2636 sc = scsi_host_find_tag(snic->shost, tag); in snic_tgt_scsi_abort_io()
2643 sc_tgt = starget_to_tgt(scsi_target(sc->device)); in snic_tgt_scsi_abort_io()
2653 SNIC_HOST_ERR(snic->shost, in snic_tgt_scsi_abort_io()
2664 SNIC_SCSI_DBG(snic->shost, "tgt_abt_io: abt_cnt = %d\n", abt_cnt); in snic_tgt_scsi_abort_io()