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
494 CMD_STATE(sc) = SNIC_IOREQ_COMPLETE; in snic_process_icmnd_cmpl_status()
497 sc->result = (DID_OK << 16) | scsi_stat; in snic_process_icmnd_cmpl_status()
499 xfer_len = scsi_bufflen(sc); in snic_process_icmnd_cmpl_status()
502 scsi_set_resid(sc, le32_to_cpu(icmnd_cmpl->resid)); in snic_process_icmnd_cmpl_status()
514 snic_process_io_failed_state(snic, icmnd_cmpl, sc, cmpl_stat); in snic_process_icmnd_cmpl_status()
518 snic_io_status_to_str(cmpl_stat), CMD_FLAGS(sc)); in snic_process_icmnd_cmpl_status()
536 struct scsi_cmnd *sc = NULL; in snic_icmnd_cmpl_handler() local
559 sc = scsi_host_find_tag(snic->shost, cmnd_id); in snic_icmnd_cmpl_handler()
560 WARN_ON_ONCE(!sc); in snic_icmnd_cmpl_handler()
562 if (!sc) { in snic_icmnd_cmpl_handler()
578 io_lock = snic_io_lock_hash(snic, sc); in snic_icmnd_cmpl_handler()
581 rqi = (struct snic_req_info *) CMD_SP(sc); in snic_icmnd_cmpl_handler()
584 sc->device->lun, sc, sc->cmnd[0], snic_cmd_tag(sc), in snic_icmnd_cmpl_handler()
585 CMD_FLAGS(sc), rqi); in snic_icmnd_cmpl_handler()
587 if (CMD_FLAGS(sc) & SNIC_HOST_RESET_CMD_TERM) { in snic_icmnd_cmpl_handler()
597 CMD_FLAGS(sc) |= SNIC_IO_REQ_NULL; in snic_icmnd_cmpl_handler()
603 cmnd_id, sc, CMD_FLAGS(sc)); in snic_icmnd_cmpl_handler()
617 if (unlikely(snic_tmreq_pending(sc))) { in snic_icmnd_cmpl_handler()
618 snic_proc_tmreq_pending_state(snic, sc, hdr_stat); in snic_icmnd_cmpl_handler()
629 snic_ioreq_state_to_str(CMD_STATE(sc)), in snic_icmnd_cmpl_handler()
631 sc, sc_stat, le32_to_cpu(icmnd_cmpl->resid), in snic_icmnd_cmpl_handler()
632 CMD_FLAGS(sc)); in snic_icmnd_cmpl_handler()
634 SNIC_TRC(snic->shost->host_no, cmnd_id, (ulong) sc, in snic_icmnd_cmpl_handler()
636 SNIC_TRC_CMD(sc), SNIC_TRC_CMD_STATE_FLAGS(sc)); in snic_icmnd_cmpl_handler()
641 if (snic_process_icmnd_cmpl_status(snic, icmnd_cmpl, hdr_stat, sc)) { in snic_icmnd_cmpl_handler()
642 scsi_print_command(sc); in snic_icmnd_cmpl_handler()
645 sc, sc->cmnd[0], cmnd_id, in snic_icmnd_cmpl_handler()
646 snic_io_status_to_str(hdr_stat), CMD_FLAGS(sc)); in snic_icmnd_cmpl_handler()
650 CMD_SP(sc) = NULL; in snic_icmnd_cmpl_handler()
651 CMD_FLAGS(sc) |= SNIC_IO_DONE; in snic_icmnd_cmpl_handler()
658 snic_release_req_buf(snic, rqi, sc); in snic_icmnd_cmpl_handler()
660 SNIC_TRC(snic->shost->host_no, cmnd_id, (ulong) sc, in snic_icmnd_cmpl_handler()
662 SNIC_TRC_CMD(sc), SNIC_TRC_CMD_STATE_FLAGS(sc)); in snic_icmnd_cmpl_handler()
665 scsi_done(sc); in snic_icmnd_cmpl_handler()
675 struct scsi_cmnd *sc) in snic_proc_dr_cmpl_locked() argument
677 struct snic_req_info *rqi = (struct snic_req_info *) CMD_SP(sc); in snic_proc_dr_cmpl_locked()
680 CMD_LR_STATUS(sc) = cmpl_stat; in snic_proc_dr_cmpl_locked()
683 snic_ioreq_state_to_str(CMD_STATE(sc))); in snic_proc_dr_cmpl_locked()
685 if (CMD_STATE(sc) == SNIC_IOREQ_ABTS_PENDING) { in snic_proc_dr_cmpl_locked()
686 CMD_FLAGS(sc) |= SNIC_DEV_RST_ABTS_PENDING; in snic_proc_dr_cmpl_locked()
688 SNIC_TRC(snic->shost->host_no, cmnd_id, (ulong) sc, in snic_proc_dr_cmpl_locked()
690 (ulong) fwreq, 0, SNIC_TRC_CMD_STATE_FLAGS(sc)); in snic_proc_dr_cmpl_locked()
696 CMD_FLAGS(sc)); in snic_proc_dr_cmpl_locked()
702 if (CMD_FLAGS(sc) & SNIC_DEV_RST_TIMEDOUT) { in snic_proc_dr_cmpl_locked()
703 SNIC_TRC(snic->shost->host_no, cmnd_id, (ulong) sc, in snic_proc_dr_cmpl_locked()
705 (ulong) fwreq, 0, SNIC_TRC_CMD_STATE_FLAGS(sc)); in snic_proc_dr_cmpl_locked()
711 CMD_FLAGS(sc)); in snic_proc_dr_cmpl_locked()
716 CMD_STATE(sc) = SNIC_IOREQ_LR_COMPLETE; in snic_proc_dr_cmpl_locked()
717 CMD_FLAGS(sc) |= SNIC_DEV_RST_DONE; in snic_proc_dr_cmpl_locked()
723 CMD_FLAGS(sc)); in snic_proc_dr_cmpl_locked()
762 struct scsi_cmnd *sc) in snic_process_itmf_cmpl() argument
771 io_lock = snic_io_lock_hash(snic, sc); in snic_process_itmf_cmpl()
773 if (CMD_FLAGS(sc) & SNIC_HOST_RESET_CMD_TERM) { in snic_process_itmf_cmpl()
778 rqi = (struct snic_req_info *) CMD_SP(sc); in snic_process_itmf_cmpl()
784 CMD_FLAGS(sc) |= SNIC_IO_ABTS_TERM_REQ_NULL; in snic_process_itmf_cmpl()
787 snic_io_status_to_str(cmpl_stat), cmnd_id, sc, in snic_process_itmf_cmpl()
788 CMD_FLAGS(sc)); in snic_process_itmf_cmpl()
804 if (CMD_STATE(sc) != SNIC_IOREQ_ABTS_PENDING) { in snic_process_itmf_cmpl()
811 CMD_STATE(sc) = SNIC_IOREQ_ABTS_COMPLETE; in snic_process_itmf_cmpl()
812 CMD_ABTS_STATUS(sc) = cmpl_stat; in snic_process_itmf_cmpl()
813 CMD_FLAGS(sc) |= SNIC_IO_ABTS_TERM_DONE; in snic_process_itmf_cmpl()
819 CMD_FLAGS(sc)); in snic_process_itmf_cmpl()
833 CMD_SP(sc) = NULL; in snic_process_itmf_cmpl()
834 sc->result = (DID_ERROR << 16); in snic_process_itmf_cmpl()
837 sc, CMD_FLAGS(sc)); in snic_process_itmf_cmpl()
841 snic_release_req_buf(snic, rqi, sc); in snic_process_itmf_cmpl()
843 SNIC_TRC(snic->shost->host_no, cmnd_id, (ulong) sc, in snic_process_itmf_cmpl()
845 (ulong) fwreq, SNIC_TRC_CMD(sc), in snic_process_itmf_cmpl()
846 SNIC_TRC_CMD_STATE_FLAGS(sc)); in snic_process_itmf_cmpl()
848 scsi_done(sc); in snic_process_itmf_cmpl()
854 snic_proc_dr_cmpl_locked(snic, fwreq, cmpl_stat, cmnd_id, sc); in snic_process_itmf_cmpl()
863 CMD_STATE(sc) = SNIC_IOREQ_ABTS_COMPLETE; in snic_process_itmf_cmpl()
864 CMD_ABTS_STATUS(sc) = cmpl_stat; in snic_process_itmf_cmpl()
865 CMD_FLAGS(sc) |= SNIC_DEV_RST_DONE; in snic_process_itmf_cmpl()
870 CMD_FLAGS(sc)); in snic_process_itmf_cmpl()
886 snic_ioreq_state_to_str(CMD_STATE(sc)), in snic_process_itmf_cmpl()
888 CMD_FLAGS(sc)); in snic_process_itmf_cmpl()
905 struct scsi_cmnd *sc = NULL; in snic_itmf_cmpl_handler() local
927 sc = rqi->sc; in snic_itmf_cmpl_handler()
941 sc = scsi_host_find_tag(snic->shost, cmnd_id & SNIC_TAG_MASK); in snic_itmf_cmpl_handler()
942 WARN_ON_ONCE(!sc); in snic_itmf_cmpl_handler()
945 if (!sc) { in snic_itmf_cmpl_handler()
954 snic_process_itmf_cmpl(snic, fwreq, cmnd_id, hdr_stat, sc); in snic_itmf_cmpl_handler()
960 snic_hba_reset_scsi_cleanup(struct snic *snic, struct scsi_cmnd *sc) in snic_hba_reset_scsi_cleanup() argument
966 snic_scsi_cleanup(snic, snic_cmd_tag(sc)); in snic_hba_reset_scsi_cleanup()
992 struct scsi_cmnd *sc = NULL; in snic_hba_reset_cmpl_handler() local
1013 sc = rqi->sc; in snic_hba_reset_cmpl_handler()
1027 sc = scsi_host_find_tag(snic->shost, cmnd_id); in snic_hba_reset_cmpl_handler()
1029 if (!sc) { in snic_hba_reset_cmpl_handler()
1041 sc, rqi, cmnd_id, CMD_FLAGS(sc)); in snic_hba_reset_cmpl_handler()
1043 io_lock = snic_io_lock_hash(snic, sc); in snic_hba_reset_cmpl_handler()
1055 rqi = (struct snic_req_info *) CMD_SP(sc); in snic_hba_reset_cmpl_handler()
1061 CMD_FLAGS(sc) |= SNIC_IO_ABTS_TERM_REQ_NULL; in snic_hba_reset_cmpl_handler()
1064 snic_io_status_to_str(hdr_stat), cmnd_id, sc, in snic_hba_reset_cmpl_handler()
1065 CMD_FLAGS(sc)); in snic_hba_reset_cmpl_handler()
1075 snic_hba_reset_scsi_cleanup(snic, sc); in snic_hba_reset_cmpl_handler()
1292 struct scsi_cmnd *sc, in snic_queue_itmf_req() argument
1298 int tm_tag = snic_cmd_tag(sc) | rqi->tm_tag; in snic_queue_itmf_req()
1305 int_to_scsilun(sc->device->lun, &lun); in snic_queue_itmf_req()
1329 tmf, sc, rqi, req_id, snic_cmd_tag(sc), ret); in snic_queue_itmf_req()
1333 tmf, sc, rqi, req_id, snic_cmd_tag(sc)); in snic_queue_itmf_req()
1341 struct scsi_cmnd *sc, in snic_issue_tm_req() argument
1345 int req_id = 0, tag = snic_cmd_tag(sc); in snic_issue_tm_req()
1372 ret = snic_queue_itmf_req(snic, tmreq, sc, tmf, req_id); in snic_issue_tm_req()
1378 tmf, sc, rqi, req_id, tag, ret); in snic_issue_tm_req()
1382 tmf, sc, rqi, req_id, tag); in snic_issue_tm_req()
1396 struct scsi_cmnd *sc, in snic_queue_abort_req() argument
1400 sc, rqi, snic_cmd_tag(sc), tmf); in snic_queue_abort_req()
1405 return snic_issue_tm_req(snic, rqi, sc, tmf); in snic_queue_abort_req()
1412 snic_abort_finish(struct snic *snic, struct scsi_cmnd *sc) in snic_abort_finish() argument
1417 int ret = 0, tag = snic_cmd_tag(sc); in snic_abort_finish()
1419 io_lock = snic_io_lock_hash(snic, sc); in snic_abort_finish()
1421 rqi = (struct snic_req_info *) CMD_SP(sc); in snic_abort_finish()
1424 CMD_FLAGS(sc) |= SNIC_IO_ABTS_TERM_REQ_NULL; in snic_abort_finish()
1428 tag, sc, CMD_FLAGS(sc)); in snic_abort_finish()
1439 switch (CMD_ABTS_STATUS(sc)) { in snic_abort_finish()
1442 CMD_FLAGS(sc) |= SNIC_IO_ABTS_TIMEDOUT; in snic_abort_finish()
1446 sc, snic_cmd_tag(sc), CMD_FLAGS(sc)); in snic_abort_finish()
1460 sc->result = (DID_ERROR << 16); in snic_abort_finish()
1461 scsi_done(sc); in snic_abort_finish()
1471 CMD_SP(sc) = NULL; in snic_abort_finish()
1474 tag, snic_io_status_to_str(CMD_ABTS_STATUS(sc)), in snic_abort_finish()
1475 CMD_FLAGS(sc)); in snic_abort_finish()
1480 snic_release_req_buf(snic, rqi, sc); in snic_abort_finish()
1489 snic_send_abort_and_wait(struct snic *snic, struct scsi_cmnd *sc) in snic_send_abort_and_wait() argument
1497 int ret = 0, tmf = 0, tag = snic_cmd_tag(sc); in snic_send_abort_and_wait()
1499 tgt = starget_to_tgt(scsi_target(sc->device)); in snic_send_abort_and_wait()
1507 io_lock = snic_io_lock_hash(snic, sc); in snic_send_abort_and_wait()
1522 rqi = (struct snic_req_info *) CMD_SP(sc); in snic_send_abort_and_wait()
1528 tag, CMD_FLAGS(sc)); in snic_send_abort_and_wait()
1536 if (CMD_STATE(sc) == SNIC_IOREQ_ABTS_PENDING) { in snic_send_abort_and_wait()
1545 sv_state = CMD_STATE(sc); in snic_send_abort_and_wait()
1553 CMD_STATE(sc) = SNIC_IOREQ_ABTS_PENDING; in snic_send_abort_and_wait()
1554 CMD_ABTS_STATUS(sc) = SNIC_INVALID_CODE; in snic_send_abort_and_wait()
1561 ret = snic_queue_abort_req(snic, rqi, sc, tmf); in snic_send_abort_and_wait()
1566 tag, ret, CMD_FLAGS(sc)); in snic_send_abort_and_wait()
1570 CMD_STATE(sc) = sv_state; in snic_send_abort_and_wait()
1571 rqi = (struct snic_req_info *) CMD_SP(sc); in snic_send_abort_and_wait()
1582 CMD_FLAGS(sc) |= SNIC_IO_ABTS_ISSUED; in snic_send_abort_and_wait()
1586 CMD_FLAGS(sc) |= SNIC_IO_TERM_ISSUED; in snic_send_abort_and_wait()
1592 sc, tag, CMD_FLAGS(sc)); in snic_send_abort_and_wait()
1615 snic_abort_cmd(struct scsi_cmnd *sc) in snic_abort_cmd() argument
1617 struct snic *snic = shost_priv(sc->device->host); in snic_abort_cmd()
1618 int ret = SUCCESS, tag = snic_cmd_tag(sc); in snic_abort_cmd()
1622 sc, sc->cmnd[0], scsi_cmd_to_rq(sc), tag); in snic_abort_cmd()
1634 ret = snic_send_abort_and_wait(snic, sc); in snic_abort_cmd()
1638 ret = snic_abort_finish(snic, sc); in snic_abort_cmd()
1641 SNIC_TRC(snic->shost->host_no, tag, (ulong) sc, in snic_abort_cmd()
1643 SNIC_TRC_CMD(sc), SNIC_TRC_CMD_STATE_FLAGS(sc)); in snic_abort_cmd()
1659 struct scsi_cmnd *sc = NULL; in snic_is_abts_pending() local
1673 sc = scsi_host_find_tag(snic->shost, tag); in snic_is_abts_pending()
1675 if (!sc || (lr_sc && (sc->device != lr_sdev || sc == lr_sc))) { in snic_is_abts_pending()
1681 rqi = (struct snic_req_info *) CMD_SP(sc); in snic_is_abts_pending()
1693 snic_ioreq_state_to_str(CMD_STATE(sc))); in snic_is_abts_pending()
1695 if (CMD_STATE(sc) == SNIC_IOREQ_ABTS_PENDING) { in snic_is_abts_pending()
1714 struct scsi_cmnd *sc = NULL; in snic_dr_clean_single_req() local
1723 sc = scsi_host_find_tag(snic->shost, tag); in snic_dr_clean_single_req()
1726 if (!sc || sc->device != lr_sdev) in snic_dr_clean_single_req()
1729 rqi = (struct snic_req_info *) CMD_SP(sc); in snic_dr_clean_single_req()
1735 if (CMD_STATE(sc) == SNIC_IOREQ_ABTS_PENDING) in snic_dr_clean_single_req()
1739 if ((CMD_FLAGS(sc) & SNIC_DEVICE_RESET) && in snic_dr_clean_single_req()
1740 (!(CMD_FLAGS(sc) & SNIC_DEV_RST_ISSUED))) { in snic_dr_clean_single_req()
1744 sc); in snic_dr_clean_single_req()
1751 snic_ioreq_state_to_str(CMD_STATE(sc))); in snic_dr_clean_single_req()
1754 sv_state = CMD_STATE(sc); in snic_dr_clean_single_req()
1764 CMD_STATE(sc) = SNIC_IOREQ_ABTS_PENDING; in snic_dr_clean_single_req()
1767 if (CMD_FLAGS(sc) & SNIC_DEVICE_RESET) { in snic_dr_clean_single_req()
1771 "clean_single_req:devrst sc 0x%p\n", sc); in snic_dr_clean_single_req()
1774 CMD_ABTS_STATUS(sc) = SNIC_INVALID_CODE; in snic_dr_clean_single_req()
1778 tgt = starget_to_tgt(scsi_target(sc->device)); in snic_dr_clean_single_req()
1785 ret = snic_queue_abort_req(snic, rqi, sc, tmf); in snic_dr_clean_single_req()
1789 sc, tag, rqi->tm_tag, CMD_FLAGS(sc)); in snic_dr_clean_single_req()
1792 rqi = (struct snic_req_info *) CMD_SP(sc); in snic_dr_clean_single_req()
1797 if (CMD_STATE(sc) == SNIC_IOREQ_ABTS_PENDING) in snic_dr_clean_single_req()
1798 CMD_STATE(sc) = sv_state; in snic_dr_clean_single_req()
1805 if (CMD_FLAGS(sc) & SNIC_DEVICE_RESET) in snic_dr_clean_single_req()
1806 CMD_FLAGS(sc) |= SNIC_DEV_RST_TERM_ISSUED; in snic_dr_clean_single_req()
1808 CMD_FLAGS(sc) |= SNIC_IO_INTERNAL_TERM_ISSUED; in snic_dr_clean_single_req()
1815 rqi = (struct snic_req_info *) CMD_SP(sc); in snic_dr_clean_single_req()
1817 CMD_FLAGS(sc) |= SNIC_IO_ABTS_TERM_REQ_NULL; in snic_dr_clean_single_req()
1823 if (CMD_ABTS_STATUS(sc) == SNIC_INVALID_CODE) { in snic_dr_clean_single_req()
1826 sc, tag, rqi->tm_tag, CMD_FLAGS(sc)); in snic_dr_clean_single_req()
1828 CMD_FLAGS(sc) |= SNIC_IO_ABTS_TERM_DONE; in snic_dr_clean_single_req()
1834 CMD_STATE(sc) = SNIC_IOREQ_ABTS_COMPLETE; in snic_dr_clean_single_req()
1835 CMD_SP(sc) = NULL; in snic_dr_clean_single_req()
1838 snic_release_req_buf(snic, rqi, sc); in snic_dr_clean_single_req()
1840 sc->result = (DID_ERROR << 16); in snic_dr_clean_single_req()
1841 scsi_done(sc); in snic_dr_clean_single_req()
1900 snic_dr_finish(struct snic *snic, struct scsi_cmnd *sc) in snic_dr_finish() argument
1908 io_lock = snic_io_lock_hash(snic, sc); in snic_dr_finish()
1910 rqi = (struct snic_req_info *) CMD_SP(sc); in snic_dr_finish()
1915 snic_cmd_tag(sc), sc, CMD_FLAGS(sc)); in snic_dr_finish()
1923 lr_res = CMD_LR_STATUS(sc); in snic_dr_finish()
1930 snic_cmd_tag(sc), CMD_FLAGS(sc)); in snic_dr_finish()
1932 CMD_FLAGS(sc) |= SNIC_DEV_RST_TIMEDOUT; in snic_dr_finish()
1940 snic_cmd_tag(sc)); in snic_dr_finish()
1947 snic_cmd_tag(sc), in snic_dr_finish()
1948 snic_io_status_to_str(lr_res), CMD_FLAGS(sc)); in snic_dr_finish()
1962 ret = snic_dr_clean_pending_req(snic, sc); in snic_dr_finish()
1967 snic_cmd_tag(sc)); in snic_dr_finish()
1968 rqi = (struct snic_req_info *) CMD_SP(sc); in snic_dr_finish()
1974 rqi = (struct snic_req_info *) CMD_SP(sc); in snic_dr_finish()
1984 CMD_SP(sc) = NULL; in snic_dr_finish()
1988 snic_release_req_buf(snic, rqi, sc); in snic_dr_finish()
1997 struct scsi_cmnd *sc) in snic_queue_dr_req() argument
2002 return snic_issue_tm_req(snic, rqi, sc, SNIC_ITMF_LUN_RESET); in snic_queue_dr_req()
2006 snic_send_dr_and_wait(struct snic *snic, struct scsi_cmnd *sc) in snic_send_dr_and_wait() argument
2013 int ret = FAILED, tag = snic_cmd_tag(sc); in snic_send_dr_and_wait()
2015 io_lock = snic_io_lock_hash(snic, sc); in snic_send_dr_and_wait()
2017 CMD_FLAGS(sc) |= SNIC_DEVICE_RESET; in snic_send_dr_and_wait()
2018 rqi = (struct snic_req_info *) CMD_SP(sc); in snic_send_dr_and_wait()
2022 tag, CMD_FLAGS(sc)); in snic_send_dr_and_wait()
2030 sv_state = CMD_STATE(sc); in snic_send_dr_and_wait()
2032 CMD_STATE(sc) = SNIC_IOREQ_LR_PENDING; in snic_send_dr_and_wait()
2033 CMD_LR_STATUS(sc) = SNIC_INVALID_CODE; in snic_send_dr_and_wait()
2048 ret = snic_queue_dr_req(snic, rqi, sc); in snic_send_dr_and_wait()
2052 tag, ret, CMD_FLAGS(sc)); in snic_send_dr_and_wait()
2056 CMD_STATE(sc) = sv_state; in snic_send_dr_and_wait()
2057 rqi = (struct snic_req_info *) CMD_SP(sc); in snic_send_dr_and_wait()
2068 CMD_FLAGS(sc) |= SNIC_DEV_RST_ISSUED; in snic_send_dr_and_wait()
2095 snic_unlink_and_release_req(struct snic *snic, struct scsi_cmnd *sc, int flag) in snic_unlink_and_release_req() argument
2102 io_lock = snic_io_lock_hash(snic, sc); in snic_unlink_and_release_req()
2104 rqi = (struct snic_req_info *) CMD_SP(sc); in snic_unlink_and_release_req()
2107 CMD_SP(sc) = NULL; in snic_unlink_and_release_req()
2110 CMD_FLAGS(sc) |= flag; in snic_unlink_and_release_req()
2114 snic_release_req_buf(snic, rqi, sc); in snic_unlink_and_release_req()
2116 SNIC_TRC(snic->shost->host_no, snic_cmd_tag(sc), (ulong) sc, in snic_unlink_and_release_req()
2118 SNIC_TRC_CMD(sc), SNIC_TRC_CMD_STATE_FLAGS(sc)); in snic_unlink_and_release_req()
2127 snic_device_reset(struct scsi_cmnd *sc) in snic_device_reset() argument
2129 struct Scsi_Host *shost = sc->device->host; in snic_device_reset()
2132 int tag = snic_cmd_tag(sc); in snic_device_reset()
2138 sc, sc->cmnd[0], scsi_cmd_to_rq(sc), in snic_device_reset()
2139 snic_cmd_tag(sc)); in snic_device_reset()
2140 dr_supp = snic_dev_reset_supported(sc->device); in snic_device_reset()
2144 snic_unlink_and_release_req(snic, sc, SNIC_DEV_RST_NOTSUP); in snic_device_reset()
2150 snic_unlink_and_release_req(snic, sc, 0); in snic_device_reset()
2165 memset(scsi_cmd_priv(sc), 0, in snic_device_reset()
2167 CMD_SP(sc) = (char *)rqi; in snic_device_reset()
2168 CMD_FLAGS(sc) = SNIC_NO_FLAGS; in snic_device_reset()
2172 rqi->sc = sc; in snic_device_reset()
2175 ret = snic_send_dr_and_wait(snic, sc); in snic_device_reset()
2181 snic_unlink_and_release_req(snic, sc, 0); in snic_device_reset()
2186 ret = snic_dr_finish(snic, sc); in snic_device_reset()
2189 SNIC_TRC(snic->shost->host_no, tag, (ulong) sc, in snic_device_reset()
2191 0, SNIC_TRC_CMD(sc), SNIC_TRC_CMD_STATE_FLAGS(sc)); in snic_device_reset()
2211 snic_issue_hba_reset(struct snic *snic, struct scsi_cmnd *sc) in snic_issue_hba_reset() argument
2227 if (snic_cmd_tag(sc) == SCSI_NO_TAG) { in snic_issue_hba_reset()
2228 memset(scsi_cmd_priv(sc), 0, in snic_issue_hba_reset()
2231 rqi->sc = sc; in snic_issue_hba_reset()
2236 io_lock = snic_io_lock_hash(snic, sc); in snic_issue_hba_reset()
2238 SNIC_BUG_ON(CMD_SP(sc) != NULL); in snic_issue_hba_reset()
2239 CMD_STATE(sc) = SNIC_IOREQ_PENDING; in snic_issue_hba_reset()
2240 CMD_SP(sc) = (char *) rqi; in snic_issue_hba_reset()
2241 CMD_FLAGS(sc) |= SNIC_IO_INITIALIZED; in snic_issue_hba_reset()
2246 snic_io_hdr_enc(&req->hdr, SNIC_REQ_HBA_RESET, 0, snic_cmd_tag(sc), in snic_issue_hba_reset()
2261 CMD_FLAGS(sc) |= SNIC_HOST_RESET_ISSUED; in snic_issue_hba_reset()
2278 rqi = (struct snic_req_info *) CMD_SP(sc); in snic_issue_hba_reset()
2279 CMD_SP(sc) = NULL; in snic_issue_hba_reset()
2292 rqi = (struct snic_req_info *) CMD_SP(sc); in snic_issue_hba_reset()
2293 CMD_SP(sc) = NULL; in snic_issue_hba_reset()
2308 snic_reset(struct Scsi_Host *shost, struct scsi_cmnd *sc) in snic_reset() argument
2337 ret = snic_issue_hba_reset(snic, sc); in snic_reset()
2365 snic_host_reset(struct scsi_cmnd *sc) in snic_host_reset() argument
2367 struct Scsi_Host *shost = sc->device->host; in snic_host_reset()
2373 sc, sc->cmnd[0], scsi_cmd_to_rq(sc), in snic_host_reset()
2374 snic_cmd_tag(sc), CMD_FLAGS(sc)); in snic_host_reset()
2376 ret = snic_reset(shost, sc); in snic_host_reset()
2378 SNIC_TRC(shost->host_no, snic_cmd_tag(sc), (ulong) sc, in snic_host_reset()
2380 0, SNIC_TRC_CMD(sc), SNIC_TRC_CMD_STATE_FLAGS(sc)); in snic_host_reset()
2389 snic_cmpl_pending_tmreq(struct snic *snic, struct scsi_cmnd *sc) in snic_cmpl_pending_tmreq() argument
2395 sc, snic_io_status_to_str(CMD_STATE(sc)), CMD_FLAGS(sc)); in snic_cmpl_pending_tmreq()
2402 CMD_ABTS_STATUS(sc) = SNIC_STAT_IO_SUCCESS; in snic_cmpl_pending_tmreq()
2404 rqi = (struct snic_req_info *) CMD_SP(sc); in snic_cmpl_pending_tmreq()
2421 struct scsi_cmnd *sc = NULL; in snic_scsi_cleanup() local
2436 sc = scsi_host_find_tag(snic->shost, tag); in snic_scsi_cleanup()
2437 if (!sc) { in snic_scsi_cleanup()
2443 if (unlikely(snic_tmreq_pending(sc))) { in snic_scsi_cleanup()
2448 snic_cmpl_pending_tmreq(snic, sc); in snic_scsi_cleanup()
2454 rqi = (struct snic_req_info *) CMD_SP(sc); in snic_scsi_cleanup()
2463 sc, rqi, tag, CMD_FLAGS(sc)); in snic_scsi_cleanup()
2465 CMD_SP(sc) = NULL; in snic_scsi_cleanup()
2466 CMD_FLAGS(sc) |= SNIC_SCSI_CLEANUP; in snic_scsi_cleanup()
2472 rqi, CMD_FLAGS(sc)); in snic_scsi_cleanup()
2474 snic_release_req_buf(snic, rqi, sc); in snic_scsi_cleanup()
2477 sc->result = DID_TRANSPORT_DISRUPTED << 16; in snic_scsi_cleanup()
2480 sc, scsi_cmd_to_rq(sc)->tag, CMD_FLAGS(sc), rqi, in snic_scsi_cleanup()
2486 SNIC_TRC(snic->shost->host_no, tag, (ulong) sc, in snic_scsi_cleanup()
2488 SNIC_TRC_CMD(sc), in snic_scsi_cleanup()
2489 SNIC_TRC_CMD_STATE_FLAGS(sc)); in snic_scsi_cleanup()
2491 scsi_done(sc); in snic_scsi_cleanup()
2508 snic_internal_abort_io(struct snic *snic, struct scsi_cmnd *sc, int tmf) in snic_internal_abort_io() argument
2516 io_lock = snic_io_lock_hash(snic, sc); in snic_internal_abort_io()
2518 rqi = (struct snic_req_info *) CMD_SP(sc); in snic_internal_abort_io()
2522 if (CMD_STATE(sc) == SNIC_IOREQ_ABTS_PENDING) in snic_internal_abort_io()
2525 if ((CMD_FLAGS(sc) & SNIC_DEVICE_RESET) && in snic_internal_abort_io()
2526 (!(CMD_FLAGS(sc) & SNIC_DEV_RST_ISSUED))) { in snic_internal_abort_io()
2530 sc); in snic_internal_abort_io()
2536 if (!(CMD_FLAGS(sc) & SNIC_IO_ISSUED)) { in snic_internal_abort_io()
2539 sc, snic_cmd_tag(sc), CMD_FLAGS(sc), CMD_STATE(sc)); in snic_internal_abort_io()
2544 sv_state = CMD_STATE(sc); in snic_internal_abort_io()
2545 CMD_STATE(sc) = SNIC_IOREQ_ABTS_PENDING; in snic_internal_abort_io()
2546 CMD_ABTS_STATUS(sc) = SNIC_INVALID_CODE; in snic_internal_abort_io()
2547 CMD_FLAGS(sc) |= SNIC_IO_INTERNAL_TERM_PENDING; in snic_internal_abort_io()
2549 if (CMD_FLAGS(sc) & SNIC_DEVICE_RESET) { in snic_internal_abort_io()
2552 SNIC_SCSI_DBG(snic->shost, "internal_abts:dev rst sc %p\n", sc); in snic_internal_abort_io()
2556 snic_cmd_tag(sc)); in snic_internal_abort_io()
2560 ret = snic_queue_abort_req(snic, rqi, sc, tmf); in snic_internal_abort_io()
2564 snic_cmd_tag(sc), ret); in snic_internal_abort_io()
2568 if (CMD_STATE(sc) == SNIC_IOREQ_ABTS_PENDING) in snic_internal_abort_io()
2569 CMD_STATE(sc) = sv_state; in snic_internal_abort_io()
2575 if (CMD_FLAGS(sc) & SNIC_DEVICE_RESET) in snic_internal_abort_io()
2576 CMD_FLAGS(sc) |= SNIC_DEV_RST_TERM_ISSUED; in snic_internal_abort_io()
2578 CMD_FLAGS(sc) |= SNIC_IO_INTERNAL_TERM_ISSUED; in snic_internal_abort_io()
2596 struct scsi_cmnd *sc = NULL; in snic_tgt_scsi_abort_io() local
2617 sc = scsi_host_find_tag(snic->shost, tag); in snic_tgt_scsi_abort_io()
2618 if (!sc) { in snic_tgt_scsi_abort_io()
2624 sc_tgt = starget_to_tgt(scsi_target(sc->device)); in snic_tgt_scsi_abort_io()
2632 ret = snic_internal_abort_io(snic, sc, tmf); in snic_tgt_scsi_abort_io()