Lines Matching refs:sc

22 #define snic_cmd_tag(sc)	(scsi_cmd_to_rq(sc)->tag)  argument
98 snic_io_lock_hash(struct snic *snic, struct scsi_cmnd *sc) in snic_io_lock_hash() argument
100 u32 hash = snic_cmd_tag(sc) & (SNIC_IO_LOCKS - 1); in snic_io_lock_hash()
115 struct scsi_cmnd *sc) in snic_release_req_buf() argument
120 SNIC_BUG_ON(!((CMD_STATE(sc) == SNIC_IOREQ_COMPLETE) || in snic_release_req_buf()
121 (CMD_STATE(sc) == SNIC_IOREQ_ABTS_COMPLETE) || in snic_release_req_buf()
122 (CMD_FLAGS(sc) & SNIC_DEV_RST_NOTSUP) || in snic_release_req_buf()
123 (CMD_FLAGS(sc) & SNIC_IO_INTERNAL_TERM_ISSUED) || in snic_release_req_buf()
124 (CMD_FLAGS(sc) & SNIC_DEV_RST_TERM_ISSUED) || in snic_release_req_buf()
125 (CMD_FLAGS(sc) & SNIC_SCSI_CLEANUP) || in snic_release_req_buf()
126 (CMD_STATE(sc) == SNIC_IOREQ_LR_COMPLETE))); in snic_release_req_buf()
130 sc, snic_cmd_tag(sc), rqi, rqi->req, rqi->abort_req, in snic_release_req_buf()
131 rqi->dr_req, snic_ioreq_state_to_str(CMD_STATE(sc)), in snic_release_req_buf()
132 CMD_FLAGS(sc)); in snic_release_req_buf()
140 scsi_dma_unmap(sc); in snic_release_req_buf()
151 struct scsi_cmnd *sc, in snic_queue_icmnd_req() argument
166 for_each_sg(scsi_sglist(sc), sg, sg_cnt, i) { in snic_queue_icmnd_req()
175 sc->sense_buffer, in snic_queue_icmnd_req()
181 sc->sense_buffer, snic_cmd_tag(sc)); in snic_queue_icmnd_req()
187 int_to_scsilun(sc->device->lun, &lun); in snic_queue_icmnd_req()
188 if (sc->sc_data_direction == DMA_FROM_DEVICE) in snic_queue_icmnd_req()
190 if (sc->sc_data_direction == DMA_TO_DEVICE) in snic_queue_icmnd_req()
195 snic_cmd_tag(sc), in snic_queue_icmnd_req()
201 sc->cmnd, in snic_queue_icmnd_req()
202 sc->cmd_len, in snic_queue_icmnd_req()
203 scsi_bufflen(sc), in snic_queue_icmnd_req()
228 struct scsi_cmnd *sc) in snic_issue_scsi_req() argument
233 u32 tag = snic_cmd_tag(sc); in snic_issue_scsi_req()
238 CMD_STATE(sc) = SNIC_IOREQ_NOT_INITED; in snic_issue_scsi_req()
239 CMD_FLAGS(sc) = SNIC_NO_FLAGS; in snic_issue_scsi_req()
240 sg_cnt = scsi_dma_map(sc); in snic_issue_scsi_req()
242 SNIC_TRC((u16)snic->shost->host_no, tag, (ulong) sc, 0, in snic_issue_scsi_req()
243 sc->cmnd[0], sg_cnt, CMD_STATE(sc)); in snic_issue_scsi_req()
253 scsi_dma_unmap(sc); in snic_issue_scsi_req()
260 rqi->sc = sc; in snic_issue_scsi_req()
262 CMD_STATE(sc) = SNIC_IOREQ_PENDING; in snic_issue_scsi_req()
263 CMD_SP(sc) = (char *) rqi; in snic_issue_scsi_req()
264 cmd_trc = SNIC_TRC_CMD(sc); in snic_issue_scsi_req()
265 CMD_FLAGS(sc) |= (SNIC_IO_INITIALIZED | SNIC_IO_ISSUED); in snic_issue_scsi_req()
266 cmd_st_flags = SNIC_TRC_CMD_STATE_FLAGS(sc); in snic_issue_scsi_req()
267 io_lock = snic_io_lock_hash(snic, sc); in snic_issue_scsi_req()
270 ret = snic_queue_icmnd_req(snic, rqi, sc, sg_cnt); in snic_issue_scsi_req()
274 sc, ret); in snic_issue_scsi_req()
277 rqi = (struct snic_req_info *) CMD_SP(sc); in snic_issue_scsi_req()
278 CMD_SP(sc) = NULL; in snic_issue_scsi_req()
279 CMD_STATE(sc) = SNIC_IOREQ_COMPLETE; in snic_issue_scsi_req()
280 CMD_FLAGS(sc) &= ~SNIC_IO_ISSUED; /* turn off the flag */ in snic_issue_scsi_req()
284 snic_release_req_buf(snic, rqi, sc); in snic_issue_scsi_req()
286 SNIC_TRC(snic->shost->host_no, tag, (ulong) sc, 0, 0, 0, in snic_issue_scsi_req()
287 SNIC_TRC_CMD_STATE_FLAGS(sc)); in snic_issue_scsi_req()
289 u32 io_sz = scsi_bufflen(sc) >> 9; in snic_issue_scsi_req()
301 sc, tag); in snic_issue_scsi_req()
303 SNIC_TRC(snic->shost->host_no, tag, (ulong) sc, (ulong) rqi, in snic_issue_scsi_req()
319 snic_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *sc) in snic_queuecommand() argument
325 tgt = starget_to_tgt(scsi_target(sc->device)); in snic_queuecommand()
330 sc->result = ret; in snic_queuecommand()
331 scsi_done(sc); in snic_queuecommand()
345 sc, snic_cmd_tag(sc), sc->cmnd[0], sc->device->lun); in snic_queuecommand()
347 ret = snic_issue_scsi_req(snic, tgt, sc); in snic_queuecommand()
364 struct scsi_cmnd *sc, in snic_proc_tmreq_pending_state() argument
367 int state = CMD_STATE(sc); in snic_proc_tmreq_pending_state()
370 CMD_FLAGS(sc) |= SNIC_IO_ABTS_PENDING; in snic_proc_tmreq_pending_state()
372 CMD_FLAGS(sc) |= SNIC_DEV_RST_PENDING; in snic_proc_tmreq_pending_state()
378 CMD_FLAGS(sc) |= SNIC_IO_DONE; in snic_proc_tmreq_pending_state()
382 CMD_FLAGS(sc) |= SNIC_IO_ABORTED; in snic_proc_tmreq_pending_state()
397 struct scsi_cmnd *sc, in snic_process_io_failed_state() argument
415 scsi_set_resid(sc, le32_to_cpu(icmnd_cmpl->resid)); in snic_process_io_failed_state()
461 snic_io_status_to_str(cmpl_stat), CMD_FLAGS(sc)); in snic_process_io_failed_state()
464 sc->result = (res << 16) | icmnd_cmpl->scsi_status; in snic_process_io_failed_state()
471 snic_tmreq_pending(struct scsi_cmnd *sc) in snic_tmreq_pending() argument
473 int state = CMD_STATE(sc); in snic_tmreq_pending()
487 struct scsi_cmnd *sc) in snic_process_icmnd_cmpl_status() argument
493 CMD_STATE(sc) = SNIC_IOREQ_COMPLETE; in snic_process_icmnd_cmpl_status()
496 sc->result = (DID_OK << 16) | scsi_stat; in snic_process_icmnd_cmpl_status()
499 scsi_set_resid(sc, le32_to_cpu(icmnd_cmpl->resid)); in snic_process_icmnd_cmpl_status()
509 snic_process_io_failed_state(snic, icmnd_cmpl, sc, cmpl_stat); in snic_process_icmnd_cmpl_status()
513 snic_io_status_to_str(cmpl_stat), CMD_FLAGS(sc)); in snic_process_icmnd_cmpl_status()
531 struct scsi_cmnd *sc = NULL; in snic_icmnd_cmpl_handler() local
554 sc = scsi_host_find_tag(snic->shost, cmnd_id); in snic_icmnd_cmpl_handler()
555 WARN_ON_ONCE(!sc); in snic_icmnd_cmpl_handler()
557 if (!sc) { in snic_icmnd_cmpl_handler()
573 io_lock = snic_io_lock_hash(snic, sc); in snic_icmnd_cmpl_handler()
576 rqi = (struct snic_req_info *) CMD_SP(sc); in snic_icmnd_cmpl_handler()
579 sc->device->lun, sc, sc->cmnd[0], snic_cmd_tag(sc), in snic_icmnd_cmpl_handler()
580 CMD_FLAGS(sc), rqi); in snic_icmnd_cmpl_handler()
582 if (CMD_FLAGS(sc) & SNIC_HOST_RESET_CMD_TERM) { in snic_icmnd_cmpl_handler()
592 CMD_FLAGS(sc) |= SNIC_IO_REQ_NULL; in snic_icmnd_cmpl_handler()
598 cmnd_id, sc, CMD_FLAGS(sc)); in snic_icmnd_cmpl_handler()
612 if (unlikely(snic_tmreq_pending(sc))) { in snic_icmnd_cmpl_handler()
613 snic_proc_tmreq_pending_state(snic, sc, hdr_stat); in snic_icmnd_cmpl_handler()
624 snic_ioreq_state_to_str(CMD_STATE(sc)), in snic_icmnd_cmpl_handler()
626 sc, sc_stat, le32_to_cpu(icmnd_cmpl->resid), in snic_icmnd_cmpl_handler()
627 CMD_FLAGS(sc)); in snic_icmnd_cmpl_handler()
629 SNIC_TRC(snic->shost->host_no, cmnd_id, (ulong) sc, in snic_icmnd_cmpl_handler()
631 SNIC_TRC_CMD(sc), SNIC_TRC_CMD_STATE_FLAGS(sc)); in snic_icmnd_cmpl_handler()
636 if (snic_process_icmnd_cmpl_status(snic, icmnd_cmpl, hdr_stat, sc)) { in snic_icmnd_cmpl_handler()
637 scsi_print_command(sc); in snic_icmnd_cmpl_handler()
640 sc, sc->cmnd[0], cmnd_id, in snic_icmnd_cmpl_handler()
641 snic_io_status_to_str(hdr_stat), CMD_FLAGS(sc)); in snic_icmnd_cmpl_handler()
645 CMD_SP(sc) = NULL; in snic_icmnd_cmpl_handler()
646 CMD_FLAGS(sc) |= SNIC_IO_DONE; in snic_icmnd_cmpl_handler()
653 snic_release_req_buf(snic, rqi, sc); in snic_icmnd_cmpl_handler()
655 SNIC_TRC(snic->shost->host_no, cmnd_id, (ulong) sc, in snic_icmnd_cmpl_handler()
657 SNIC_TRC_CMD(sc), SNIC_TRC_CMD_STATE_FLAGS(sc)); in snic_icmnd_cmpl_handler()
660 scsi_done(sc); in snic_icmnd_cmpl_handler()
670 struct scsi_cmnd *sc) in snic_proc_dr_cmpl_locked() argument
672 struct snic_req_info *rqi = (struct snic_req_info *) CMD_SP(sc); in snic_proc_dr_cmpl_locked()
675 CMD_LR_STATUS(sc) = cmpl_stat; in snic_proc_dr_cmpl_locked()
678 snic_ioreq_state_to_str(CMD_STATE(sc))); in snic_proc_dr_cmpl_locked()
680 if (CMD_STATE(sc) == SNIC_IOREQ_ABTS_PENDING) { in snic_proc_dr_cmpl_locked()
681 CMD_FLAGS(sc) |= SNIC_DEV_RST_ABTS_PENDING; in snic_proc_dr_cmpl_locked()
683 SNIC_TRC(snic->shost->host_no, cmnd_id, (ulong) sc, in snic_proc_dr_cmpl_locked()
685 (ulong) fwreq, 0, SNIC_TRC_CMD_STATE_FLAGS(sc)); in snic_proc_dr_cmpl_locked()
691 CMD_FLAGS(sc)); in snic_proc_dr_cmpl_locked()
697 if (CMD_FLAGS(sc) & SNIC_DEV_RST_TIMEDOUT) { in snic_proc_dr_cmpl_locked()
698 SNIC_TRC(snic->shost->host_no, cmnd_id, (ulong) sc, in snic_proc_dr_cmpl_locked()
700 (ulong) fwreq, 0, SNIC_TRC_CMD_STATE_FLAGS(sc)); in snic_proc_dr_cmpl_locked()
706 CMD_FLAGS(sc)); in snic_proc_dr_cmpl_locked()
711 CMD_STATE(sc) = SNIC_IOREQ_LR_COMPLETE; in snic_proc_dr_cmpl_locked()
712 CMD_FLAGS(sc) |= SNIC_DEV_RST_DONE; in snic_proc_dr_cmpl_locked()
718 CMD_FLAGS(sc)); in snic_proc_dr_cmpl_locked()
757 struct scsi_cmnd *sc) in snic_process_itmf_cmpl() argument
766 io_lock = snic_io_lock_hash(snic, sc); in snic_process_itmf_cmpl()
768 if (CMD_FLAGS(sc) & SNIC_HOST_RESET_CMD_TERM) { in snic_process_itmf_cmpl()
773 rqi = (struct snic_req_info *) CMD_SP(sc); in snic_process_itmf_cmpl()
779 CMD_FLAGS(sc) |= SNIC_IO_ABTS_TERM_REQ_NULL; in snic_process_itmf_cmpl()
782 snic_io_status_to_str(cmpl_stat), cmnd_id, sc, in snic_process_itmf_cmpl()
783 CMD_FLAGS(sc)); in snic_process_itmf_cmpl()
799 if (CMD_STATE(sc) != SNIC_IOREQ_ABTS_PENDING) { in snic_process_itmf_cmpl()
806 CMD_STATE(sc) = SNIC_IOREQ_ABTS_COMPLETE; in snic_process_itmf_cmpl()
807 CMD_ABTS_STATUS(sc) = cmpl_stat; in snic_process_itmf_cmpl()
808 CMD_FLAGS(sc) |= SNIC_IO_ABTS_TERM_DONE; in snic_process_itmf_cmpl()
814 CMD_FLAGS(sc)); in snic_process_itmf_cmpl()
828 CMD_SP(sc) = NULL; in snic_process_itmf_cmpl()
829 sc->result = (DID_ERROR << 16); in snic_process_itmf_cmpl()
832 sc, CMD_FLAGS(sc)); in snic_process_itmf_cmpl()
836 snic_release_req_buf(snic, rqi, sc); in snic_process_itmf_cmpl()
838 SNIC_TRC(snic->shost->host_no, cmnd_id, (ulong) sc, in snic_process_itmf_cmpl()
840 (ulong) fwreq, SNIC_TRC_CMD(sc), in snic_process_itmf_cmpl()
841 SNIC_TRC_CMD_STATE_FLAGS(sc)); in snic_process_itmf_cmpl()
843 scsi_done(sc); in snic_process_itmf_cmpl()
849 snic_proc_dr_cmpl_locked(snic, fwreq, cmpl_stat, cmnd_id, sc); in snic_process_itmf_cmpl()
858 CMD_STATE(sc) = SNIC_IOREQ_ABTS_COMPLETE; in snic_process_itmf_cmpl()
859 CMD_ABTS_STATUS(sc) = cmpl_stat; in snic_process_itmf_cmpl()
860 CMD_FLAGS(sc) |= SNIC_DEV_RST_DONE; in snic_process_itmf_cmpl()
865 CMD_FLAGS(sc)); in snic_process_itmf_cmpl()
881 snic_ioreq_state_to_str(CMD_STATE(sc)), in snic_process_itmf_cmpl()
883 CMD_FLAGS(sc)); in snic_process_itmf_cmpl()
900 struct scsi_cmnd *sc = NULL; in snic_itmf_cmpl_handler() local
922 sc = rqi->sc; in snic_itmf_cmpl_handler()
936 sc = scsi_host_find_tag(snic->shost, cmnd_id & SNIC_TAG_MASK); in snic_itmf_cmpl_handler()
937 WARN_ON_ONCE(!sc); in snic_itmf_cmpl_handler()
940 if (!sc) { in snic_itmf_cmpl_handler()
949 snic_process_itmf_cmpl(snic, fwreq, cmnd_id, hdr_stat, sc); in snic_itmf_cmpl_handler()
955 snic_hba_reset_scsi_cleanup(struct snic *snic, struct scsi_cmnd *sc) in snic_hba_reset_scsi_cleanup() argument
961 snic_scsi_cleanup(snic, snic_cmd_tag(sc)); in snic_hba_reset_scsi_cleanup()
987 struct scsi_cmnd *sc = NULL; in snic_hba_reset_cmpl_handler() local
1008 sc = rqi->sc; in snic_hba_reset_cmpl_handler()
1022 sc = scsi_host_find_tag(snic->shost, cmnd_id); in snic_hba_reset_cmpl_handler()
1024 if (!sc) { in snic_hba_reset_cmpl_handler()
1036 sc, rqi, cmnd_id, CMD_FLAGS(sc)); in snic_hba_reset_cmpl_handler()
1038 io_lock = snic_io_lock_hash(snic, sc); in snic_hba_reset_cmpl_handler()
1050 rqi = (struct snic_req_info *) CMD_SP(sc); in snic_hba_reset_cmpl_handler()
1056 CMD_FLAGS(sc) |= SNIC_IO_ABTS_TERM_REQ_NULL; in snic_hba_reset_cmpl_handler()
1059 snic_io_status_to_str(hdr_stat), cmnd_id, sc, in snic_hba_reset_cmpl_handler()
1060 CMD_FLAGS(sc)); in snic_hba_reset_cmpl_handler()
1070 snic_hba_reset_scsi_cleanup(snic, sc); in snic_hba_reset_cmpl_handler()
1287 struct scsi_cmnd *sc, in snic_queue_itmf_req() argument
1293 int tm_tag = snic_cmd_tag(sc) | rqi->tm_tag; in snic_queue_itmf_req()
1300 int_to_scsilun(sc->device->lun, &lun); in snic_queue_itmf_req()
1324 tmf, sc, rqi, req_id, snic_cmd_tag(sc), ret); in snic_queue_itmf_req()
1328 tmf, sc, rqi, req_id, snic_cmd_tag(sc)); in snic_queue_itmf_req()
1336 struct scsi_cmnd *sc, in snic_issue_tm_req() argument
1340 int req_id = 0, tag = snic_cmd_tag(sc); in snic_issue_tm_req()
1367 ret = snic_queue_itmf_req(snic, tmreq, sc, tmf, req_id); in snic_issue_tm_req()
1373 tmf, sc, rqi, req_id, tag, ret); in snic_issue_tm_req()
1377 tmf, sc, rqi, req_id, tag); in snic_issue_tm_req()
1391 struct scsi_cmnd *sc, in snic_queue_abort_req() argument
1395 sc, rqi, snic_cmd_tag(sc), tmf); in snic_queue_abort_req()
1400 return snic_issue_tm_req(snic, rqi, sc, tmf); in snic_queue_abort_req()
1407 snic_abort_finish(struct snic *snic, struct scsi_cmnd *sc) in snic_abort_finish() argument
1412 int ret = 0, tag = snic_cmd_tag(sc); in snic_abort_finish()
1414 io_lock = snic_io_lock_hash(snic, sc); in snic_abort_finish()
1416 rqi = (struct snic_req_info *) CMD_SP(sc); in snic_abort_finish()
1419 CMD_FLAGS(sc) |= SNIC_IO_ABTS_TERM_REQ_NULL; in snic_abort_finish()
1423 tag, sc, CMD_FLAGS(sc)); in snic_abort_finish()
1434 switch (CMD_ABTS_STATUS(sc)) { in snic_abort_finish()
1437 CMD_FLAGS(sc) |= SNIC_IO_ABTS_TIMEDOUT; in snic_abort_finish()
1441 sc, snic_cmd_tag(sc), CMD_FLAGS(sc)); in snic_abort_finish()
1455 sc->result = (DID_ERROR << 16); in snic_abort_finish()
1456 scsi_done(sc); in snic_abort_finish()
1466 CMD_SP(sc) = NULL; in snic_abort_finish()
1469 tag, snic_io_status_to_str(CMD_ABTS_STATUS(sc)), in snic_abort_finish()
1470 CMD_FLAGS(sc)); in snic_abort_finish()
1475 snic_release_req_buf(snic, rqi, sc); in snic_abort_finish()
1484 snic_send_abort_and_wait(struct snic *snic, struct scsi_cmnd *sc) in snic_send_abort_and_wait() argument
1492 int ret = 0, tmf = 0, tag = snic_cmd_tag(sc); in snic_send_abort_and_wait()
1494 tgt = starget_to_tgt(scsi_target(sc->device)); in snic_send_abort_and_wait()
1502 io_lock = snic_io_lock_hash(snic, sc); in snic_send_abort_and_wait()
1517 rqi = (struct snic_req_info *) CMD_SP(sc); in snic_send_abort_and_wait()
1523 tag, CMD_FLAGS(sc)); in snic_send_abort_and_wait()
1531 if (CMD_STATE(sc) == SNIC_IOREQ_ABTS_PENDING) { in snic_send_abort_and_wait()
1540 sv_state = CMD_STATE(sc); in snic_send_abort_and_wait()
1548 CMD_STATE(sc) = SNIC_IOREQ_ABTS_PENDING; in snic_send_abort_and_wait()
1549 CMD_ABTS_STATUS(sc) = SNIC_INVALID_CODE; in snic_send_abort_and_wait()
1556 ret = snic_queue_abort_req(snic, rqi, sc, tmf); in snic_send_abort_and_wait()
1561 tag, ret, CMD_FLAGS(sc)); in snic_send_abort_and_wait()
1565 CMD_STATE(sc) = sv_state; in snic_send_abort_and_wait()
1566 rqi = (struct snic_req_info *) CMD_SP(sc); in snic_send_abort_and_wait()
1577 CMD_FLAGS(sc) |= SNIC_IO_ABTS_ISSUED; in snic_send_abort_and_wait()
1581 CMD_FLAGS(sc) |= SNIC_IO_TERM_ISSUED; in snic_send_abort_and_wait()
1587 sc, tag, CMD_FLAGS(sc)); in snic_send_abort_and_wait()
1610 snic_abort_cmd(struct scsi_cmnd *sc) in snic_abort_cmd() argument
1612 struct snic *snic = shost_priv(sc->device->host); in snic_abort_cmd()
1613 int ret = SUCCESS, tag = snic_cmd_tag(sc); in snic_abort_cmd()
1617 sc, sc->cmnd[0], scsi_cmd_to_rq(sc), tag); in snic_abort_cmd()
1629 ret = snic_send_abort_and_wait(snic, sc); in snic_abort_cmd()
1633 ret = snic_abort_finish(snic, sc); in snic_abort_cmd()
1636 SNIC_TRC(snic->shost->host_no, tag, (ulong) sc, in snic_abort_cmd()
1638 SNIC_TRC_CMD(sc), SNIC_TRC_CMD_STATE_FLAGS(sc)); in snic_abort_cmd()
1654 struct scsi_cmnd *sc = NULL; in snic_is_abts_pending() local
1668 sc = scsi_host_find_tag(snic->shost, tag); in snic_is_abts_pending()
1670 if (!sc || (lr_sc && (sc->device != lr_sdev || sc == lr_sc))) { in snic_is_abts_pending()
1676 rqi = (struct snic_req_info *) CMD_SP(sc); in snic_is_abts_pending()
1688 snic_ioreq_state_to_str(CMD_STATE(sc))); in snic_is_abts_pending()
1690 if (CMD_STATE(sc) == SNIC_IOREQ_ABTS_PENDING) { in snic_is_abts_pending()
1709 struct scsi_cmnd *sc = NULL; in snic_dr_clean_single_req() local
1718 sc = scsi_host_find_tag(snic->shost, tag); in snic_dr_clean_single_req()
1721 if (!sc || sc->device != lr_sdev) in snic_dr_clean_single_req()
1724 rqi = (struct snic_req_info *) CMD_SP(sc); in snic_dr_clean_single_req()
1730 if (CMD_STATE(sc) == SNIC_IOREQ_ABTS_PENDING) in snic_dr_clean_single_req()
1734 if ((CMD_FLAGS(sc) & SNIC_DEVICE_RESET) && in snic_dr_clean_single_req()
1735 (!(CMD_FLAGS(sc) & SNIC_DEV_RST_ISSUED))) { in snic_dr_clean_single_req()
1739 sc); in snic_dr_clean_single_req()
1746 snic_ioreq_state_to_str(CMD_STATE(sc))); in snic_dr_clean_single_req()
1749 sv_state = CMD_STATE(sc); in snic_dr_clean_single_req()
1759 CMD_STATE(sc) = SNIC_IOREQ_ABTS_PENDING; in snic_dr_clean_single_req()
1762 if (CMD_FLAGS(sc) & SNIC_DEVICE_RESET) { in snic_dr_clean_single_req()
1766 "clean_single_req:devrst sc 0x%p\n", sc); in snic_dr_clean_single_req()
1769 CMD_ABTS_STATUS(sc) = SNIC_INVALID_CODE; in snic_dr_clean_single_req()
1773 tgt = starget_to_tgt(scsi_target(sc->device)); in snic_dr_clean_single_req()
1780 ret = snic_queue_abort_req(snic, rqi, sc, tmf); in snic_dr_clean_single_req()
1784 sc, tag, rqi->tm_tag, CMD_FLAGS(sc)); in snic_dr_clean_single_req()
1787 rqi = (struct snic_req_info *) CMD_SP(sc); in snic_dr_clean_single_req()
1792 if (CMD_STATE(sc) == SNIC_IOREQ_ABTS_PENDING) in snic_dr_clean_single_req()
1793 CMD_STATE(sc) = sv_state; in snic_dr_clean_single_req()
1800 if (CMD_FLAGS(sc) & SNIC_DEVICE_RESET) in snic_dr_clean_single_req()
1801 CMD_FLAGS(sc) |= SNIC_DEV_RST_TERM_ISSUED; in snic_dr_clean_single_req()
1803 CMD_FLAGS(sc) |= SNIC_IO_INTERNAL_TERM_ISSUED; in snic_dr_clean_single_req()
1810 rqi = (struct snic_req_info *) CMD_SP(sc); in snic_dr_clean_single_req()
1812 CMD_FLAGS(sc) |= SNIC_IO_ABTS_TERM_REQ_NULL; in snic_dr_clean_single_req()
1818 if (CMD_ABTS_STATUS(sc) == SNIC_INVALID_CODE) { in snic_dr_clean_single_req()
1821 sc, tag, rqi->tm_tag, CMD_FLAGS(sc)); in snic_dr_clean_single_req()
1823 CMD_FLAGS(sc) |= SNIC_IO_ABTS_TERM_DONE; in snic_dr_clean_single_req()
1829 CMD_STATE(sc) = SNIC_IOREQ_ABTS_COMPLETE; in snic_dr_clean_single_req()
1830 CMD_SP(sc) = NULL; in snic_dr_clean_single_req()
1833 snic_release_req_buf(snic, rqi, sc); in snic_dr_clean_single_req()
1835 sc->result = (DID_ERROR << 16); in snic_dr_clean_single_req()
1836 scsi_done(sc); in snic_dr_clean_single_req()
1889 snic_dr_finish(struct snic *snic, struct scsi_cmnd *sc) in snic_dr_finish() argument
1897 io_lock = snic_io_lock_hash(snic, sc); in snic_dr_finish()
1899 rqi = (struct snic_req_info *) CMD_SP(sc); in snic_dr_finish()
1904 snic_cmd_tag(sc), sc, CMD_FLAGS(sc)); in snic_dr_finish()
1912 lr_res = CMD_LR_STATUS(sc); in snic_dr_finish()
1919 snic_cmd_tag(sc), CMD_FLAGS(sc)); in snic_dr_finish()
1921 CMD_FLAGS(sc) |= SNIC_DEV_RST_TIMEDOUT; in snic_dr_finish()
1929 snic_cmd_tag(sc)); in snic_dr_finish()
1936 snic_cmd_tag(sc), in snic_dr_finish()
1937 snic_io_status_to_str(lr_res), CMD_FLAGS(sc)); in snic_dr_finish()
1951 ret = snic_dr_clean_pending_req(snic, sc); in snic_dr_finish()
1956 snic_cmd_tag(sc)); in snic_dr_finish()
1957 rqi = (struct snic_req_info *) CMD_SP(sc); in snic_dr_finish()
1963 rqi = (struct snic_req_info *) CMD_SP(sc); in snic_dr_finish()
1973 CMD_SP(sc) = NULL; in snic_dr_finish()
1977 snic_release_req_buf(snic, rqi, sc); in snic_dr_finish()
1986 struct scsi_cmnd *sc) in snic_queue_dr_req() argument
1991 return snic_issue_tm_req(snic, rqi, sc, SNIC_ITMF_LUN_RESET); in snic_queue_dr_req()
1995 snic_send_dr_and_wait(struct snic *snic, struct scsi_cmnd *sc) in snic_send_dr_and_wait() argument
2002 int ret = FAILED, tag = snic_cmd_tag(sc); in snic_send_dr_and_wait()
2004 io_lock = snic_io_lock_hash(snic, sc); in snic_send_dr_and_wait()
2006 CMD_FLAGS(sc) |= SNIC_DEVICE_RESET; in snic_send_dr_and_wait()
2007 rqi = (struct snic_req_info *) CMD_SP(sc); in snic_send_dr_and_wait()
2011 tag, CMD_FLAGS(sc)); in snic_send_dr_and_wait()
2019 sv_state = CMD_STATE(sc); in snic_send_dr_and_wait()
2021 CMD_STATE(sc) = SNIC_IOREQ_LR_PENDING; in snic_send_dr_and_wait()
2022 CMD_LR_STATUS(sc) = SNIC_INVALID_CODE; in snic_send_dr_and_wait()
2037 ret = snic_queue_dr_req(snic, rqi, sc); in snic_send_dr_and_wait()
2041 tag, ret, CMD_FLAGS(sc)); in snic_send_dr_and_wait()
2045 CMD_STATE(sc) = sv_state; in snic_send_dr_and_wait()
2046 rqi = (struct snic_req_info *) CMD_SP(sc); in snic_send_dr_and_wait()
2057 CMD_FLAGS(sc) |= SNIC_DEV_RST_ISSUED; in snic_send_dr_and_wait()
2084 snic_unlink_and_release_req(struct snic *snic, struct scsi_cmnd *sc, int flag) in snic_unlink_and_release_req() argument
2091 io_lock = snic_io_lock_hash(snic, sc); in snic_unlink_and_release_req()
2093 rqi = (struct snic_req_info *) CMD_SP(sc); in snic_unlink_and_release_req()
2096 CMD_SP(sc) = NULL; in snic_unlink_and_release_req()
2099 CMD_FLAGS(sc) |= flag; in snic_unlink_and_release_req()
2103 snic_release_req_buf(snic, rqi, sc); in snic_unlink_and_release_req()
2105 SNIC_TRC(snic->shost->host_no, snic_cmd_tag(sc), (ulong) sc, in snic_unlink_and_release_req()
2107 SNIC_TRC_CMD(sc), SNIC_TRC_CMD_STATE_FLAGS(sc)); in snic_unlink_and_release_req()
2116 snic_device_reset(struct scsi_cmnd *sc) in snic_device_reset() argument
2118 struct Scsi_Host *shost = sc->device->host; in snic_device_reset()
2121 int tag = snic_cmd_tag(sc); in snic_device_reset()
2127 sc, sc->cmnd[0], scsi_cmd_to_rq(sc), in snic_device_reset()
2128 snic_cmd_tag(sc)); in snic_device_reset()
2129 dr_supp = snic_dev_reset_supported(sc->device); in snic_device_reset()
2133 snic_unlink_and_release_req(snic, sc, SNIC_DEV_RST_NOTSUP); in snic_device_reset()
2139 snic_unlink_and_release_req(snic, sc, 0); in snic_device_reset()
2154 memset(scsi_cmd_priv(sc), 0, in snic_device_reset()
2156 CMD_SP(sc) = (char *)rqi; in snic_device_reset()
2157 CMD_FLAGS(sc) = SNIC_NO_FLAGS; in snic_device_reset()
2161 rqi->sc = sc; in snic_device_reset()
2164 ret = snic_send_dr_and_wait(snic, sc); in snic_device_reset()
2170 snic_unlink_and_release_req(snic, sc, 0); in snic_device_reset()
2175 ret = snic_dr_finish(snic, sc); in snic_device_reset()
2178 SNIC_TRC(snic->shost->host_no, tag, (ulong) sc, in snic_device_reset()
2180 0, SNIC_TRC_CMD(sc), SNIC_TRC_CMD_STATE_FLAGS(sc)); in snic_device_reset()
2200 snic_issue_hba_reset(struct snic *snic, struct scsi_cmnd *sc) in snic_issue_hba_reset() argument
2216 if (snic_cmd_tag(sc) == SCSI_NO_TAG) { in snic_issue_hba_reset()
2217 memset(scsi_cmd_priv(sc), 0, in snic_issue_hba_reset()
2220 rqi->sc = sc; in snic_issue_hba_reset()
2225 io_lock = snic_io_lock_hash(snic, sc); in snic_issue_hba_reset()
2227 SNIC_BUG_ON(CMD_SP(sc) != NULL); in snic_issue_hba_reset()
2228 CMD_STATE(sc) = SNIC_IOREQ_PENDING; in snic_issue_hba_reset()
2229 CMD_SP(sc) = (char *) rqi; in snic_issue_hba_reset()
2230 CMD_FLAGS(sc) |= SNIC_IO_INITIALIZED; in snic_issue_hba_reset()
2235 snic_io_hdr_enc(&req->hdr, SNIC_REQ_HBA_RESET, 0, snic_cmd_tag(sc), in snic_issue_hba_reset()
2250 CMD_FLAGS(sc) |= SNIC_HOST_RESET_ISSUED; in snic_issue_hba_reset()
2267 rqi = (struct snic_req_info *) CMD_SP(sc); in snic_issue_hba_reset()
2268 CMD_SP(sc) = NULL; in snic_issue_hba_reset()
2281 rqi = (struct snic_req_info *) CMD_SP(sc); in snic_issue_hba_reset()
2282 CMD_SP(sc) = NULL; in snic_issue_hba_reset()
2297 snic_reset(struct Scsi_Host *shost, struct scsi_cmnd *sc) in snic_reset() argument
2326 ret = snic_issue_hba_reset(snic, sc); in snic_reset()
2354 snic_host_reset(struct scsi_cmnd *sc) in snic_host_reset() argument
2356 struct Scsi_Host *shost = sc->device->host; in snic_host_reset()
2362 sc, sc->cmnd[0], scsi_cmd_to_rq(sc), in snic_host_reset()
2363 snic_cmd_tag(sc), CMD_FLAGS(sc)); in snic_host_reset()
2365 ret = snic_reset(shost, sc); in snic_host_reset()
2367 SNIC_TRC(shost->host_no, snic_cmd_tag(sc), (ulong) sc, in snic_host_reset()
2369 0, SNIC_TRC_CMD(sc), SNIC_TRC_CMD_STATE_FLAGS(sc)); in snic_host_reset()
2378 snic_cmpl_pending_tmreq(struct snic *snic, struct scsi_cmnd *sc) in snic_cmpl_pending_tmreq() argument
2384 sc, snic_io_status_to_str(CMD_STATE(sc)), CMD_FLAGS(sc)); in snic_cmpl_pending_tmreq()
2391 CMD_ABTS_STATUS(sc) = SNIC_STAT_IO_SUCCESS; in snic_cmpl_pending_tmreq()
2393 rqi = (struct snic_req_info *) CMD_SP(sc); in snic_cmpl_pending_tmreq()
2410 struct scsi_cmnd *sc = NULL; in snic_scsi_cleanup() local
2425 sc = scsi_host_find_tag(snic->shost, tag); in snic_scsi_cleanup()
2426 if (!sc) { in snic_scsi_cleanup()
2432 if (unlikely(snic_tmreq_pending(sc))) { in snic_scsi_cleanup()
2437 snic_cmpl_pending_tmreq(snic, sc); in snic_scsi_cleanup()
2443 rqi = (struct snic_req_info *) CMD_SP(sc); in snic_scsi_cleanup()
2452 sc, rqi, tag, CMD_FLAGS(sc)); in snic_scsi_cleanup()
2454 CMD_SP(sc) = NULL; in snic_scsi_cleanup()
2455 CMD_FLAGS(sc) |= SNIC_SCSI_CLEANUP; in snic_scsi_cleanup()
2461 rqi, CMD_FLAGS(sc)); in snic_scsi_cleanup()
2463 snic_release_req_buf(snic, rqi, sc); in snic_scsi_cleanup()
2466 sc->result = DID_TRANSPORT_DISRUPTED << 16; in snic_scsi_cleanup()
2469 sc, scsi_cmd_to_rq(sc)->tag, CMD_FLAGS(sc), rqi, in snic_scsi_cleanup()
2475 SNIC_TRC(snic->shost->host_no, tag, (ulong) sc, in snic_scsi_cleanup()
2477 SNIC_TRC_CMD(sc), in snic_scsi_cleanup()
2478 SNIC_TRC_CMD_STATE_FLAGS(sc)); in snic_scsi_cleanup()
2480 scsi_done(sc); in snic_scsi_cleanup()
2497 snic_internal_abort_io(struct snic *snic, struct scsi_cmnd *sc, int tmf) in snic_internal_abort_io() argument
2505 io_lock = snic_io_lock_hash(snic, sc); in snic_internal_abort_io()
2507 rqi = (struct snic_req_info *) CMD_SP(sc); in snic_internal_abort_io()
2511 if (CMD_STATE(sc) == SNIC_IOREQ_ABTS_PENDING) in snic_internal_abort_io()
2514 if ((CMD_FLAGS(sc) & SNIC_DEVICE_RESET) && in snic_internal_abort_io()
2515 (!(CMD_FLAGS(sc) & SNIC_DEV_RST_ISSUED))) { in snic_internal_abort_io()
2519 sc); in snic_internal_abort_io()
2525 if (!(CMD_FLAGS(sc) & SNIC_IO_ISSUED)) { in snic_internal_abort_io()
2528 sc, snic_cmd_tag(sc), CMD_FLAGS(sc), CMD_STATE(sc)); in snic_internal_abort_io()
2533 sv_state = CMD_STATE(sc); in snic_internal_abort_io()
2534 CMD_STATE(sc) = SNIC_IOREQ_ABTS_PENDING; in snic_internal_abort_io()
2535 CMD_ABTS_STATUS(sc) = SNIC_INVALID_CODE; in snic_internal_abort_io()
2536 CMD_FLAGS(sc) |= SNIC_IO_INTERNAL_TERM_PENDING; in snic_internal_abort_io()
2538 if (CMD_FLAGS(sc) & SNIC_DEVICE_RESET) { in snic_internal_abort_io()
2541 SNIC_SCSI_DBG(snic->shost, "internal_abts:dev rst sc %p\n", sc); in snic_internal_abort_io()
2545 snic_cmd_tag(sc)); in snic_internal_abort_io()
2549 ret = snic_queue_abort_req(snic, rqi, sc, tmf); in snic_internal_abort_io()
2553 snic_cmd_tag(sc), ret); in snic_internal_abort_io()
2557 if (CMD_STATE(sc) == SNIC_IOREQ_ABTS_PENDING) in snic_internal_abort_io()
2558 CMD_STATE(sc) = sv_state; in snic_internal_abort_io()
2564 if (CMD_FLAGS(sc) & SNIC_DEVICE_RESET) in snic_internal_abort_io()
2565 CMD_FLAGS(sc) |= SNIC_DEV_RST_TERM_ISSUED; in snic_internal_abort_io()
2567 CMD_FLAGS(sc) |= SNIC_IO_INTERNAL_TERM_ISSUED; in snic_internal_abort_io()
2585 struct scsi_cmnd *sc = NULL; in snic_tgt_scsi_abort_io() local
2606 sc = scsi_host_find_tag(snic->shost, tag); in snic_tgt_scsi_abort_io()
2607 if (!sc) { in snic_tgt_scsi_abort_io()
2613 sc_tgt = starget_to_tgt(scsi_target(sc->device)); in snic_tgt_scsi_abort_io()
2621 ret = snic_internal_abort_io(snic, sc, tmf); in snic_tgt_scsi_abort_io()