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()
1895 snic_dr_finish(struct snic *snic, struct scsi_cmnd *sc) in snic_dr_finish() argument
1903 io_lock = snic_io_lock_hash(snic, sc); in snic_dr_finish()
1905 rqi = (struct snic_req_info *) CMD_SP(sc); in snic_dr_finish()
1910 snic_cmd_tag(sc), sc, CMD_FLAGS(sc)); in snic_dr_finish()
1918 lr_res = CMD_LR_STATUS(sc); in snic_dr_finish()
1925 snic_cmd_tag(sc), CMD_FLAGS(sc)); in snic_dr_finish()
1927 CMD_FLAGS(sc) |= SNIC_DEV_RST_TIMEDOUT; in snic_dr_finish()
1935 snic_cmd_tag(sc)); in snic_dr_finish()
1942 snic_cmd_tag(sc), in snic_dr_finish()
1943 snic_io_status_to_str(lr_res), CMD_FLAGS(sc)); in snic_dr_finish()
1957 ret = snic_dr_clean_pending_req(snic, sc); in snic_dr_finish()
1962 snic_cmd_tag(sc)); in snic_dr_finish()
1963 rqi = (struct snic_req_info *) CMD_SP(sc); in snic_dr_finish()
1969 rqi = (struct snic_req_info *) CMD_SP(sc); in snic_dr_finish()
1979 CMD_SP(sc) = NULL; in snic_dr_finish()
1983 snic_release_req_buf(snic, rqi, sc); in snic_dr_finish()
1992 struct scsi_cmnd *sc) in snic_queue_dr_req() argument
1997 return snic_issue_tm_req(snic, rqi, sc, SNIC_ITMF_LUN_RESET); in snic_queue_dr_req()
2001 snic_send_dr_and_wait(struct snic *snic, struct scsi_cmnd *sc) in snic_send_dr_and_wait() argument
2008 int ret = FAILED, tag = snic_cmd_tag(sc); in snic_send_dr_and_wait()
2010 io_lock = snic_io_lock_hash(snic, sc); in snic_send_dr_and_wait()
2012 CMD_FLAGS(sc) |= SNIC_DEVICE_RESET; in snic_send_dr_and_wait()
2013 rqi = (struct snic_req_info *) CMD_SP(sc); in snic_send_dr_and_wait()
2017 tag, CMD_FLAGS(sc)); in snic_send_dr_and_wait()
2025 sv_state = CMD_STATE(sc); in snic_send_dr_and_wait()
2027 CMD_STATE(sc) = SNIC_IOREQ_LR_PENDING; in snic_send_dr_and_wait()
2028 CMD_LR_STATUS(sc) = SNIC_INVALID_CODE; in snic_send_dr_and_wait()
2043 ret = snic_queue_dr_req(snic, rqi, sc); in snic_send_dr_and_wait()
2047 tag, ret, CMD_FLAGS(sc)); in snic_send_dr_and_wait()
2051 CMD_STATE(sc) = sv_state; in snic_send_dr_and_wait()
2052 rqi = (struct snic_req_info *) CMD_SP(sc); in snic_send_dr_and_wait()
2063 CMD_FLAGS(sc) |= SNIC_DEV_RST_ISSUED; in snic_send_dr_and_wait()
2090 snic_unlink_and_release_req(struct snic *snic, struct scsi_cmnd *sc, int flag) in snic_unlink_and_release_req() argument
2097 io_lock = snic_io_lock_hash(snic, sc); in snic_unlink_and_release_req()
2099 rqi = (struct snic_req_info *) CMD_SP(sc); in snic_unlink_and_release_req()
2102 CMD_SP(sc) = NULL; in snic_unlink_and_release_req()
2105 CMD_FLAGS(sc) |= flag; in snic_unlink_and_release_req()
2109 snic_release_req_buf(snic, rqi, sc); in snic_unlink_and_release_req()
2111 SNIC_TRC(snic->shost->host_no, snic_cmd_tag(sc), (ulong) sc, in snic_unlink_and_release_req()
2113 SNIC_TRC_CMD(sc), SNIC_TRC_CMD_STATE_FLAGS(sc)); in snic_unlink_and_release_req()
2122 snic_device_reset(struct scsi_cmnd *sc) in snic_device_reset() argument
2124 struct Scsi_Host *shost = sc->device->host; in snic_device_reset()
2127 int tag = snic_cmd_tag(sc); in snic_device_reset()
2133 sc, sc->cmnd[0], scsi_cmd_to_rq(sc), in snic_device_reset()
2134 snic_cmd_tag(sc)); in snic_device_reset()
2135 dr_supp = snic_dev_reset_supported(sc->device); in snic_device_reset()
2139 snic_unlink_and_release_req(snic, sc, SNIC_DEV_RST_NOTSUP); in snic_device_reset()
2145 snic_unlink_and_release_req(snic, sc, 0); in snic_device_reset()
2160 memset(scsi_cmd_priv(sc), 0, in snic_device_reset()
2162 CMD_SP(sc) = (char *)rqi; in snic_device_reset()
2163 CMD_FLAGS(sc) = SNIC_NO_FLAGS; in snic_device_reset()
2167 rqi->sc = sc; in snic_device_reset()
2170 ret = snic_send_dr_and_wait(snic, sc); in snic_device_reset()
2176 snic_unlink_and_release_req(snic, sc, 0); in snic_device_reset()
2181 ret = snic_dr_finish(snic, sc); in snic_device_reset()
2184 SNIC_TRC(snic->shost->host_no, tag, (ulong) sc, in snic_device_reset()
2186 0, SNIC_TRC_CMD(sc), SNIC_TRC_CMD_STATE_FLAGS(sc)); in snic_device_reset()
2206 snic_issue_hba_reset(struct snic *snic, struct scsi_cmnd *sc) in snic_issue_hba_reset() argument
2222 if (snic_cmd_tag(sc) == SCSI_NO_TAG) { in snic_issue_hba_reset()
2223 memset(scsi_cmd_priv(sc), 0, in snic_issue_hba_reset()
2226 rqi->sc = sc; in snic_issue_hba_reset()
2231 io_lock = snic_io_lock_hash(snic, sc); in snic_issue_hba_reset()
2233 SNIC_BUG_ON(CMD_SP(sc) != NULL); in snic_issue_hba_reset()
2234 CMD_STATE(sc) = SNIC_IOREQ_PENDING; in snic_issue_hba_reset()
2235 CMD_SP(sc) = (char *) rqi; in snic_issue_hba_reset()
2236 CMD_FLAGS(sc) |= SNIC_IO_INITIALIZED; in snic_issue_hba_reset()
2241 snic_io_hdr_enc(&req->hdr, SNIC_REQ_HBA_RESET, 0, snic_cmd_tag(sc), in snic_issue_hba_reset()
2256 CMD_FLAGS(sc) |= SNIC_HOST_RESET_ISSUED; in snic_issue_hba_reset()
2273 rqi = (struct snic_req_info *) CMD_SP(sc); in snic_issue_hba_reset()
2274 CMD_SP(sc) = NULL; in snic_issue_hba_reset()
2287 rqi = (struct snic_req_info *) CMD_SP(sc); in snic_issue_hba_reset()
2288 CMD_SP(sc) = NULL; in snic_issue_hba_reset()
2303 snic_reset(struct Scsi_Host *shost, struct scsi_cmnd *sc) in snic_reset() argument
2332 ret = snic_issue_hba_reset(snic, sc); in snic_reset()
2360 snic_host_reset(struct scsi_cmnd *sc) in snic_host_reset() argument
2362 struct Scsi_Host *shost = sc->device->host; in snic_host_reset()
2368 sc, sc->cmnd[0], scsi_cmd_to_rq(sc), in snic_host_reset()
2369 snic_cmd_tag(sc), CMD_FLAGS(sc)); in snic_host_reset()
2371 ret = snic_reset(shost, sc); in snic_host_reset()
2373 SNIC_TRC(shost->host_no, snic_cmd_tag(sc), (ulong) sc, in snic_host_reset()
2375 0, SNIC_TRC_CMD(sc), SNIC_TRC_CMD_STATE_FLAGS(sc)); in snic_host_reset()
2384 snic_cmpl_pending_tmreq(struct snic *snic, struct scsi_cmnd *sc) in snic_cmpl_pending_tmreq() argument
2390 sc, snic_io_status_to_str(CMD_STATE(sc)), CMD_FLAGS(sc)); in snic_cmpl_pending_tmreq()
2397 CMD_ABTS_STATUS(sc) = SNIC_STAT_IO_SUCCESS; in snic_cmpl_pending_tmreq()
2399 rqi = (struct snic_req_info *) CMD_SP(sc); in snic_cmpl_pending_tmreq()
2416 struct scsi_cmnd *sc = NULL; in snic_scsi_cleanup() local
2431 sc = scsi_host_find_tag(snic->shost, tag); in snic_scsi_cleanup()
2432 if (!sc) { in snic_scsi_cleanup()
2438 if (unlikely(snic_tmreq_pending(sc))) { in snic_scsi_cleanup()
2443 snic_cmpl_pending_tmreq(snic, sc); in snic_scsi_cleanup()
2449 rqi = (struct snic_req_info *) CMD_SP(sc); in snic_scsi_cleanup()
2458 sc, rqi, tag, CMD_FLAGS(sc)); in snic_scsi_cleanup()
2460 CMD_SP(sc) = NULL; in snic_scsi_cleanup()
2461 CMD_FLAGS(sc) |= SNIC_SCSI_CLEANUP; in snic_scsi_cleanup()
2467 rqi, CMD_FLAGS(sc)); in snic_scsi_cleanup()
2469 snic_release_req_buf(snic, rqi, sc); in snic_scsi_cleanup()
2472 sc->result = DID_TRANSPORT_DISRUPTED << 16; in snic_scsi_cleanup()
2475 sc, scsi_cmd_to_rq(sc)->tag, CMD_FLAGS(sc), rqi, in snic_scsi_cleanup()
2481 SNIC_TRC(snic->shost->host_no, tag, (ulong) sc, in snic_scsi_cleanup()
2483 SNIC_TRC_CMD(sc), in snic_scsi_cleanup()
2484 SNIC_TRC_CMD_STATE_FLAGS(sc)); in snic_scsi_cleanup()
2486 scsi_done(sc); in snic_scsi_cleanup()
2503 snic_internal_abort_io(struct snic *snic, struct scsi_cmnd *sc, int tmf) in snic_internal_abort_io() argument
2511 io_lock = snic_io_lock_hash(snic, sc); in snic_internal_abort_io()
2513 rqi = (struct snic_req_info *) CMD_SP(sc); in snic_internal_abort_io()
2517 if (CMD_STATE(sc) == SNIC_IOREQ_ABTS_PENDING) in snic_internal_abort_io()
2520 if ((CMD_FLAGS(sc) & SNIC_DEVICE_RESET) && in snic_internal_abort_io()
2521 (!(CMD_FLAGS(sc) & SNIC_DEV_RST_ISSUED))) { in snic_internal_abort_io()
2525 sc); in snic_internal_abort_io()
2531 if (!(CMD_FLAGS(sc) & SNIC_IO_ISSUED)) { in snic_internal_abort_io()
2534 sc, snic_cmd_tag(sc), CMD_FLAGS(sc), CMD_STATE(sc)); in snic_internal_abort_io()
2539 sv_state = CMD_STATE(sc); in snic_internal_abort_io()
2540 CMD_STATE(sc) = SNIC_IOREQ_ABTS_PENDING; in snic_internal_abort_io()
2541 CMD_ABTS_STATUS(sc) = SNIC_INVALID_CODE; in snic_internal_abort_io()
2542 CMD_FLAGS(sc) |= SNIC_IO_INTERNAL_TERM_PENDING; in snic_internal_abort_io()
2544 if (CMD_FLAGS(sc) & SNIC_DEVICE_RESET) { in snic_internal_abort_io()
2547 SNIC_SCSI_DBG(snic->shost, "internal_abts:dev rst sc %p\n", sc); in snic_internal_abort_io()
2551 snic_cmd_tag(sc)); in snic_internal_abort_io()
2555 ret = snic_queue_abort_req(snic, rqi, sc, tmf); in snic_internal_abort_io()
2559 snic_cmd_tag(sc), ret); in snic_internal_abort_io()
2563 if (CMD_STATE(sc) == SNIC_IOREQ_ABTS_PENDING) in snic_internal_abort_io()
2564 CMD_STATE(sc) = sv_state; in snic_internal_abort_io()
2570 if (CMD_FLAGS(sc) & SNIC_DEVICE_RESET) in snic_internal_abort_io()
2571 CMD_FLAGS(sc) |= SNIC_DEV_RST_TERM_ISSUED; in snic_internal_abort_io()
2573 CMD_FLAGS(sc) |= SNIC_IO_INTERNAL_TERM_ISSUED; in snic_internal_abort_io()
2591 struct scsi_cmnd *sc = NULL; in snic_tgt_scsi_abort_io() local
2612 sc = scsi_host_find_tag(snic->shost, tag); in snic_tgt_scsi_abort_io()
2613 if (!sc) { in snic_tgt_scsi_abort_io()
2619 sc_tgt = starget_to_tgt(scsi_target(sc->device)); in snic_tgt_scsi_abort_io()
2627 ret = snic_internal_abort_io(snic, sc, tmf); in snic_tgt_scsi_abort_io()