Lines Matching refs:sc
36 #define snic_cmd_tag(sc) (((struct scsi_cmnd *) sc)->request->tag)
112 snic_io_lock_hash(struct snic *snic, struct scsi_cmnd *sc)
114 u32 hash = snic_cmd_tag(sc) & (SNIC_IO_LOCKS - 1);
129 struct scsi_cmnd *sc)
134 SNIC_BUG_ON(!((CMD_STATE(sc) == SNIC_IOREQ_COMPLETE) ||
135 (CMD_STATE(sc) == SNIC_IOREQ_ABTS_COMPLETE) ||
136 (CMD_FLAGS(sc) & SNIC_DEV_RST_NOTSUP) ||
137 (CMD_FLAGS(sc) & SNIC_IO_INTERNAL_TERM_ISSUED) ||
138 (CMD_FLAGS(sc) & SNIC_DEV_RST_TERM_ISSUED) ||
139 (CMD_FLAGS(sc) & SNIC_SCSI_CLEANUP) ||
140 (CMD_STATE(sc) == SNIC_IOREQ_LR_COMPLETE)));
143 "Rel_req:sc %p:tag %x:rqi %p:ioreq %p:abt %p:dr %p: state %s:flags 0x%llx\n",
144 sc, snic_cmd_tag(sc), rqi, rqi->req, rqi->abort_req,
145 rqi->dr_req, snic_ioreq_state_to_str(CMD_STATE(sc)),
146 CMD_FLAGS(sc));
154 scsi_dma_unmap(sc);
165 struct scsi_cmnd *sc,
180 for_each_sg(scsi_sglist(sc), sg, sg_cnt, i) {
189 sc->sense_buffer,
195 sc->sense_buffer, snic_cmd_tag(sc));
201 int_to_scsilun(sc->device->lun, &lun);
202 if (sc->sc_data_direction == DMA_FROM_DEVICE)
204 if (sc->sc_data_direction == DMA_TO_DEVICE)
209 snic_cmd_tag(sc),
215 sc->cmnd,
216 sc->cmd_len,
217 scsi_bufflen(sc),
242 struct scsi_cmnd *sc)
247 u32 tag = snic_cmd_tag(sc);
252 CMD_STATE(sc) = SNIC_IOREQ_NOT_INITED;
253 CMD_FLAGS(sc) = SNIC_NO_FLAGS;
254 sg_cnt = scsi_dma_map(sc);
256 SNIC_TRC((u16)snic->shost->host_no, tag, (ulong) sc, 0,
257 sc->cmnd[0], sg_cnt, CMD_STATE(sc));
267 scsi_dma_unmap(sc);
274 rqi->sc = sc;
276 CMD_STATE(sc) = SNIC_IOREQ_PENDING;
277 CMD_SP(sc) = (char *) rqi;
278 cmd_trc = SNIC_TRC_CMD(sc);
279 CMD_FLAGS(sc) |= (SNIC_IO_INITIALIZED | SNIC_IO_ISSUED);
280 cmd_st_flags = SNIC_TRC_CMD_STATE_FLAGS(sc);
281 io_lock = snic_io_lock_hash(snic, sc);
284 ret = snic_queue_icmnd_req(snic, rqi, sc, sg_cnt);
287 "issue_sc: icmnd qing Failed for sc %p, err %d\n",
288 sc, ret);
291 rqi = (struct snic_req_info *) CMD_SP(sc);
292 CMD_SP(sc) = NULL;
293 CMD_STATE(sc) = SNIC_IOREQ_COMPLETE;
294 CMD_FLAGS(sc) &= ~SNIC_IO_ISSUED; /* turn off the flag */
298 snic_release_req_buf(snic, rqi, sc);
300 SNIC_TRC(snic->shost->host_no, tag, (ulong) sc, 0, 0, 0,
301 SNIC_TRC_CMD_STATE_FLAGS(sc));
303 u32 io_sz = scsi_bufflen(sc) >> 9;
314 "issue_sc:sc %p, tag %d queued to WQ.\n",
315 sc, tag);
317 SNIC_TRC(snic->shost->host_no, tag, (ulong) sc, (ulong) rqi,
333 snic_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *sc)
339 tgt = starget_to_tgt(scsi_target(sc->device));
344 sc->result = ret;
345 sc->scsi_done(sc);
358 SNIC_SCSI_DBG(shost, "sc %p Tag %d (sc %0x) lun %lld in snic_qcmd\n",
359 sc, snic_cmd_tag(sc), sc->cmnd[0], sc->device->lun);
361 ret = snic_issue_scsi_req(snic, tgt, sc);
378 struct scsi_cmnd *sc,
381 int state = CMD_STATE(sc);
384 CMD_FLAGS(sc) |= SNIC_IO_ABTS_PENDING;
386 CMD_FLAGS(sc) |= SNIC_DEV_RST_PENDING;
392 CMD_FLAGS(sc) |= SNIC_IO_DONE;
396 CMD_FLAGS(sc) |= SNIC_IO_ABORTED;
411 struct scsi_cmnd *sc,
429 scsi_set_resid(sc, le32_to_cpu(icmnd_cmpl->resid));
475 snic_io_status_to_str(cmpl_stat), CMD_FLAGS(sc));
477 /* Set sc->result */
478 sc->result = (res << 16) | icmnd_cmpl->scsi_status;
485 snic_tmreq_pending(struct scsi_cmnd *sc)
487 int state = CMD_STATE(sc);
501 struct scsi_cmnd *sc)
508 CMD_STATE(sc) = SNIC_IOREQ_COMPLETE;
511 sc->result = (DID_OK << 16) | scsi_stat;
513 xfer_len = scsi_bufflen(sc);
516 scsi_set_resid(sc, le32_to_cpu(icmnd_cmpl->resid));
528 snic_process_io_failed_state(snic, icmnd_cmpl, sc, cmpl_stat);
532 snic_io_status_to_str(cmpl_stat), CMD_FLAGS(sc));
550 struct scsi_cmnd *sc = NULL;
573 sc = scsi_host_find_tag(snic->shost, cmnd_id);
574 WARN_ON_ONCE(!sc);
576 if (!sc) {
579 "Icmnd_cmpl: Scsi Cmnd Not found, sc = NULL Hdr Status = %s tag = 0x%x fwreq = 0x%p\n",
592 io_lock = snic_io_lock_hash(snic, sc);
595 rqi = (struct snic_req_info *) CMD_SP(sc);
597 "Icmnd_cmpl:lun %lld sc %p cmd %xtag %d flags 0x%llx rqi %p\n",
598 sc->device->lun, sc, sc->cmnd[0], snic_cmd_tag(sc),
599 CMD_FLAGS(sc), rqi);
601 if (CMD_FLAGS(sc) & SNIC_HOST_RESET_CMD_TERM) {
611 CMD_FLAGS(sc) |= SNIC_IO_REQ_NULL;
615 "Icmnd_cmpl:Host Req Not Found(null), Hdr Status %s, Tag 0x%x, sc 0x%p flags 0x%llx\n",
617 cmnd_id, sc, CMD_FLAGS(sc));
631 if (unlikely(snic_tmreq_pending(sc))) {
632 snic_proc_tmreq_pending_state(snic, sc, hdr_stat);
642 "icmnd_cmpl:TM Req Pending(%s), Hdr Status %s sc 0x%p scsi status %x resid %d flags 0x%llx\n",
643 snic_ioreq_state_to_str(CMD_STATE(sc)),
645 sc, sc_stat, le32_to_cpu(icmnd_cmpl->resid),
646 CMD_FLAGS(sc));
648 SNIC_TRC(snic->shost->host_no, cmnd_id, (ulong) sc,
650 SNIC_TRC_CMD(sc), SNIC_TRC_CMD_STATE_FLAGS(sc));
655 if (snic_process_icmnd_cmpl_status(snic, icmnd_cmpl, hdr_stat, sc)) {
656 scsi_print_command(sc);
658 "icmnd_cmpl:IO Failed, sc 0x%p Tag %d Cmd %x Hdr Status %s flags 0x%llx\n",
659 sc, sc->cmnd[0], cmnd_id,
660 snic_io_status_to_str(hdr_stat), CMD_FLAGS(sc));
664 CMD_SP(sc) = NULL;
665 CMD_FLAGS(sc) |= SNIC_IO_DONE;
672 snic_release_req_buf(snic, rqi, sc);
674 SNIC_TRC(snic->shost->host_no, cmnd_id, (ulong) sc,
676 SNIC_TRC_CMD(sc), SNIC_TRC_CMD_STATE_FLAGS(sc));
679 if (sc->scsi_done)
680 sc->scsi_done(sc);
690 struct scsi_cmnd *sc)
692 struct snic_req_info *rqi = (struct snic_req_info *) CMD_SP(sc);
695 CMD_LR_STATUS(sc) = cmpl_stat;
698 snic_ioreq_state_to_str(CMD_STATE(sc)));
700 if (CMD_STATE(sc) == SNIC_IOREQ_ABTS_PENDING) {
701 CMD_FLAGS(sc) |= SNIC_DEV_RST_ABTS_PENDING;
703 SNIC_TRC(snic->shost->host_no, cmnd_id, (ulong) sc,
705 (ulong) fwreq, 0, SNIC_TRC_CMD_STATE_FLAGS(sc));
711 CMD_FLAGS(sc));
717 if (CMD_FLAGS(sc) & SNIC_DEV_RST_TIMEDOUT) {
718 SNIC_TRC(snic->shost->host_no, cmnd_id, (ulong) sc,
720 (ulong) fwreq, 0, SNIC_TRC_CMD_STATE_FLAGS(sc));
726 CMD_FLAGS(sc));
731 CMD_STATE(sc) = SNIC_IOREQ_LR_COMPLETE;
732 CMD_FLAGS(sc) |= SNIC_DEV_RST_DONE;
738 CMD_FLAGS(sc));
777 struct scsi_cmnd *sc)
786 io_lock = snic_io_lock_hash(snic, sc);
788 if (CMD_FLAGS(sc) & SNIC_HOST_RESET_CMD_TERM) {
793 rqi = (struct snic_req_info *) CMD_SP(sc);
799 CMD_FLAGS(sc) |= SNIC_IO_ABTS_TERM_REQ_NULL;
801 "itmf_cmpl: rqi is null,Hdr stat = %s Tag = 0x%x sc = 0x%p flags 0x%llx\n",
802 snic_io_status_to_str(cmpl_stat), cmnd_id, sc,
803 CMD_FLAGS(sc));
819 if (CMD_STATE(sc) != SNIC_IOREQ_ABTS_PENDING) {
826 CMD_STATE(sc) = SNIC_IOREQ_ABTS_COMPLETE;
827 CMD_ABTS_STATUS(sc) = cmpl_stat;
828 CMD_FLAGS(sc) |= SNIC_IO_ABTS_TERM_DONE;
834 CMD_FLAGS(sc));
848 CMD_SP(sc) = NULL;
849 sc->result = (DID_ERROR << 16);
851 "itmf_cmpl: Completing IO. sc %p flags 0x%llx\n",
852 sc, CMD_FLAGS(sc));
856 snic_release_req_buf(snic, rqi, sc);
858 if (sc->scsi_done) {
859 SNIC_TRC(snic->shost->host_no, cmnd_id, (ulong) sc,
861 (ulong) fwreq, SNIC_TRC_CMD(sc),
862 SNIC_TRC_CMD_STATE_FLAGS(sc));
864 sc->scsi_done(sc);
871 snic_proc_dr_cmpl_locked(snic, fwreq, cmpl_stat, cmnd_id, sc);
880 CMD_STATE(sc) = SNIC_IOREQ_ABTS_COMPLETE;
881 CMD_ABTS_STATUS(sc) = cmpl_stat;
882 CMD_FLAGS(sc) |= SNIC_DEV_RST_DONE;
887 CMD_FLAGS(sc));
903 snic_ioreq_state_to_str(CMD_STATE(sc)),
905 CMD_FLAGS(sc));
922 struct scsi_cmnd *sc = NULL;
944 sc = rqi->sc;
958 sc = scsi_host_find_tag(snic->shost, cmnd_id & SNIC_TAG_MASK);
959 WARN_ON_ONCE(!sc);
962 if (!sc) {
965 "Itmf_cmpl: sc is NULL - Hdr Stat %s Tag 0x%x\n",
971 snic_process_itmf_cmpl(snic, fwreq, cmnd_id, hdr_stat, sc);
977 snic_hba_reset_scsi_cleanup(struct snic *snic, struct scsi_cmnd *sc)
983 snic_scsi_cleanup(snic, snic_cmd_tag(sc));
1009 struct scsi_cmnd *sc = NULL;
1030 sc = rqi->sc;
1044 sc = scsi_host_find_tag(snic->shost, cmnd_id);
1046 if (!sc) {
1049 "reset_cmpl: sc is NULL - Hdr Stat %s Tag 0x%x\n",
1057 "reset_cmpl: sc %p rqi %p Tag %d flags 0x%llx\n",
1058 sc, rqi, cmnd_id, CMD_FLAGS(sc));
1060 io_lock = snic_io_lock_hash(snic, sc);
1072 rqi = (struct snic_req_info *) CMD_SP(sc);
1078 CMD_FLAGS(sc) |= SNIC_IO_ABTS_TERM_REQ_NULL;
1080 "reset_cmpl: rqi is null,Hdr stat %s Tag 0x%x sc 0x%p flags 0x%llx\n",
1081 snic_io_status_to_str(hdr_stat), cmnd_id, sc,
1082 CMD_FLAGS(sc));
1092 snic_hba_reset_scsi_cleanup(snic, sc);
1309 struct scsi_cmnd *sc,
1315 int tm_tag = snic_cmd_tag(sc) | rqi->tm_tag;
1322 int_to_scsilun(sc->device->lun, &lun);
1345 "qitmf:Queuing ITMF(%d) Req sc %p, rqi %p, req_id %d tag %d Failed, ret = %d\n",
1346 tmf, sc, rqi, req_id, snic_cmd_tag(sc), ret);
1349 "qitmf:Queuing ITMF(%d) Req sc %p, rqi %p, req_id %d, tag %d (req_id)- Success.",
1350 tmf, sc, rqi, req_id, snic_cmd_tag(sc));
1358 struct scsi_cmnd *sc,
1362 int req_id = 0, tag = snic_cmd_tag(sc);
1389 ret = snic_queue_itmf_req(snic, tmreq, sc, tmf, req_id);
1394 "issu_tmreq: Queueing ITMF(%d) Req, sc %p rqi %p req_id %d tag %x fails err = %d\n",
1395 tmf, sc, rqi, req_id, tag, ret);
1398 "issu_tmreq: Queueing ITMF(%d) Req, sc %p, rqi %p, req_id %d tag %x - Success.\n",
1399 tmf, sc, rqi, req_id, tag);
1413 struct scsi_cmnd *sc,
1416 SNIC_SCSI_DBG(snic->shost, "q_abtreq: sc %p, rqi %p, tag %x, tmf %d\n",
1417 sc, rqi, snic_cmd_tag(sc), tmf);
1422 return snic_issue_tm_req(snic, rqi, sc, tmf);
1429 snic_abort_finish(struct snic *snic, struct scsi_cmnd *sc)
1434 int ret = 0, tag = snic_cmd_tag(sc);
1436 io_lock = snic_io_lock_hash(snic, sc);
1438 rqi = (struct snic_req_info *) CMD_SP(sc);
1441 CMD_FLAGS(sc) |= SNIC_IO_ABTS_TERM_REQ_NULL;
1444 "abt_fini:req info is null tag 0x%x, sc 0x%p flags 0x%llx\n",
1445 tag, sc, CMD_FLAGS(sc));
1456 switch (CMD_ABTS_STATUS(sc)) {
1459 CMD_FLAGS(sc) |= SNIC_IO_ABTS_TIMEDOUT;
1462 "abt_fini:sc %p Tag %x Driver Timeout.flags 0x%llx\n",
1463 sc, snic_cmd_tag(sc), CMD_FLAGS(sc));
1477 sc->result = (DID_ERROR << 16);
1478 sc->scsi_done(sc);
1488 CMD_SP(sc) = NULL;
1491 tag, snic_io_status_to_str(CMD_ABTS_STATUS(sc)),
1492 CMD_FLAGS(sc));
1497 snic_release_req_buf(snic, rqi, sc);
1506 snic_send_abort_and_wait(struct snic *snic, struct scsi_cmnd *sc)
1514 int ret = 0, tmf = 0, tag = snic_cmd_tag(sc);
1516 tgt = starget_to_tgt(scsi_target(sc->device));
1524 io_lock = snic_io_lock_hash(snic, sc);
1539 rqi = (struct snic_req_info *) CMD_SP(sc);
1545 tag, CMD_FLAGS(sc));
1553 if (CMD_STATE(sc) == SNIC_IOREQ_ABTS_PENDING) {
1562 sv_state = CMD_STATE(sc);
1570 CMD_STATE(sc) = SNIC_IOREQ_ABTS_PENDING;
1571 CMD_ABTS_STATUS(sc) = SNIC_INVALID_CODE;
1578 ret = snic_queue_abort_req(snic, rqi, sc, tmf);
1583 tag, ret, CMD_FLAGS(sc));
1587 CMD_STATE(sc) = sv_state;
1588 rqi = (struct snic_req_info *) CMD_SP(sc);
1599 CMD_FLAGS(sc) |= SNIC_IO_ABTS_ISSUED;
1603 CMD_FLAGS(sc) |= SNIC_IO_TERM_ISSUED;
1608 "send_abt_cmd: sc %p Tag %x flags 0x%llx\n",
1609 sc, tag, CMD_FLAGS(sc));
1632 snic_abort_cmd(struct scsi_cmnd *sc)
1634 struct snic *snic = shost_priv(sc->device->host);
1635 int ret = SUCCESS, tag = snic_cmd_tag(sc);
1638 SNIC_SCSI_DBG(snic->shost, "abt_cmd:sc %p :0x%x :req = %p :tag = %d\n",
1639 sc, sc->cmnd[0], sc->request, tag);
1651 ret = snic_send_abort_and_wait(snic, sc);
1655 ret = snic_abort_finish(snic, sc);
1658 SNIC_TRC(snic->shost->host_no, tag, (ulong) sc,
1660 SNIC_TRC_CMD(sc), SNIC_TRC_CMD_STATE_FLAGS(sc));
1676 struct scsi_cmnd *sc = NULL;
1690 sc = scsi_host_find_tag(snic->shost, tag);
1692 if (!sc || (lr_sc && (sc->device != lr_sdev || sc == lr_sc))) {
1698 rqi = (struct snic_req_info *) CMD_SP(sc);
1710 snic_ioreq_state_to_str(CMD_STATE(sc)));
1712 if (CMD_STATE(sc) == SNIC_IOREQ_ABTS_PENDING) {
1731 struct scsi_cmnd *sc = NULL;
1740 sc = scsi_host_find_tag(snic->shost, tag);
1743 if (!sc || sc->device != lr_sdev)
1746 rqi = (struct snic_req_info *) CMD_SP(sc);
1752 if (CMD_STATE(sc) == SNIC_IOREQ_ABTS_PENDING)
1756 if ((CMD_FLAGS(sc) & SNIC_DEVICE_RESET) &&
1757 (!(CMD_FLAGS(sc) & SNIC_DEV_RST_ISSUED))) {
1760 "clean_single_req: devrst is not pending sc 0x%p\n",
1761 sc);
1768 snic_ioreq_state_to_str(CMD_STATE(sc)));
1771 sv_state = CMD_STATE(sc);
1781 CMD_STATE(sc) = SNIC_IOREQ_ABTS_PENDING;
1784 if (CMD_FLAGS(sc) & SNIC_DEVICE_RESET) {
1788 "clean_single_req:devrst sc 0x%p\n", sc);
1791 CMD_ABTS_STATUS(sc) = SNIC_INVALID_CODE;
1795 tgt = starget_to_tgt(scsi_target(sc->device));
1802 ret = snic_queue_abort_req(snic, rqi, sc, tmf);
1805 "clean_single_req_err:sc %p, tag %d abt failed. tm_tag %d flags 0x%llx\n",
1806 sc, tag, rqi->tm_tag, CMD_FLAGS(sc));
1809 rqi = (struct snic_req_info *) CMD_SP(sc);
1814 if (CMD_STATE(sc) == SNIC_IOREQ_ABTS_PENDING)
1815 CMD_STATE(sc) = sv_state;
1822 if (CMD_FLAGS(sc) & SNIC_DEVICE_RESET)
1823 CMD_FLAGS(sc) |= SNIC_DEV_RST_TERM_ISSUED;
1825 CMD_FLAGS(sc) |= SNIC_IO_INTERNAL_TERM_ISSUED;
1832 rqi = (struct snic_req_info *) CMD_SP(sc);
1834 CMD_FLAGS(sc) |= SNIC_IO_ABTS_TERM_REQ_NULL;
1840 if (CMD_ABTS_STATUS(sc) == SNIC_INVALID_CODE) {
1842 "clean_single_req_err:sc %p tag %d abt still pending w/ fw, tm_tag %d flags 0x%llx\n",
1843 sc, tag, rqi->tm_tag, CMD_FLAGS(sc));
1845 CMD_FLAGS(sc) |= SNIC_IO_ABTS_TERM_DONE;
1851 CMD_STATE(sc) = SNIC_IOREQ_ABTS_COMPLETE;
1852 CMD_SP(sc) = NULL;
1855 snic_release_req_buf(snic, rqi, sc);
1857 sc->result = (DID_ERROR << 16);
1858 sc->scsi_done(sc);
1917 snic_dr_finish(struct snic *snic, struct scsi_cmnd *sc)
1925 io_lock = snic_io_lock_hash(snic, sc);
1927 rqi = (struct snic_req_info *) CMD_SP(sc);
1931 "dr_fini: rqi is null tag 0x%x sc 0x%p flags 0x%llx\n",
1932 snic_cmd_tag(sc), sc, CMD_FLAGS(sc));
1940 lr_res = CMD_LR_STATUS(sc);
1947 snic_cmd_tag(sc), CMD_FLAGS(sc));
1949 CMD_FLAGS(sc) |= SNIC_DEV_RST_TIMEDOUT;
1957 snic_cmd_tag(sc));
1964 snic_cmd_tag(sc),
1965 snic_io_status_to_str(lr_res), CMD_FLAGS(sc));
1979 ret = snic_dr_clean_pending_req(snic, sc);
1984 snic_cmd_tag(sc));
1985 rqi = (struct snic_req_info *) CMD_SP(sc);
1991 rqi = (struct snic_req_info *) CMD_SP(sc);
2001 CMD_SP(sc) = NULL;
2005 snic_release_req_buf(snic, rqi, sc);
2014 struct scsi_cmnd *sc)
2019 return snic_issue_tm_req(snic, rqi, sc, SNIC_ITMF_LUN_RESET);
2023 snic_send_dr_and_wait(struct snic *snic, struct scsi_cmnd *sc)
2030 int ret = FAILED, tag = snic_cmd_tag(sc);
2032 io_lock = snic_io_lock_hash(snic, sc);
2034 CMD_FLAGS(sc) |= SNIC_DEVICE_RESET;
2035 rqi = (struct snic_req_info *) CMD_SP(sc);
2039 tag, CMD_FLAGS(sc));
2047 sv_state = CMD_STATE(sc);
2049 CMD_STATE(sc) = SNIC_IOREQ_LR_PENDING;
2050 CMD_LR_STATUS(sc) = SNIC_INVALID_CODE;
2065 ret = snic_queue_dr_req(snic, rqi, sc);
2069 tag, ret, CMD_FLAGS(sc));
2073 CMD_STATE(sc) = sv_state;
2074 rqi = (struct snic_req_info *) CMD_SP(sc);
2085 CMD_FLAGS(sc) |= SNIC_DEV_RST_ISSUED;
2112 snic_unlink_and_release_req(struct snic *snic, struct scsi_cmnd *sc, int flag)
2119 io_lock = snic_io_lock_hash(snic, sc);
2121 rqi = (struct snic_req_info *) CMD_SP(sc);
2124 CMD_SP(sc) = NULL;
2127 CMD_FLAGS(sc) |= flag;
2131 snic_release_req_buf(snic, rqi, sc);
2133 SNIC_TRC(snic->shost->host_no, snic_cmd_tag(sc), (ulong) sc,
2135 SNIC_TRC_CMD(sc), SNIC_TRC_CMD_STATE_FLAGS(sc));
2144 snic_device_reset(struct scsi_cmnd *sc)
2146 struct Scsi_Host *shost = sc->device->host;
2149 int tag = snic_cmd_tag(sc);
2154 SNIC_SCSI_DBG(shost, "dev_reset:sc %p :0x%x :req = %p :tag = %d\n",
2155 sc, sc->cmnd[0], sc->request,
2156 snic_cmd_tag(sc));
2157 dr_supp = snic_dev_reset_supported(sc->device);
2161 snic_unlink_and_release_req(snic, sc, SNIC_DEV_RST_NOTSUP);
2167 snic_unlink_and_release_req(snic, sc, 0);
2182 memset(scsi_cmd_priv(sc), 0,
2184 CMD_SP(sc) = (char *)rqi;
2185 CMD_FLAGS(sc) = SNIC_NO_FLAGS;
2189 rqi->sc = sc;
2192 ret = snic_send_dr_and_wait(snic, sc);
2198 snic_unlink_and_release_req(snic, sc, 0);
2203 ret = snic_dr_finish(snic, sc);
2206 SNIC_TRC(snic->shost->host_no, tag, (ulong) sc,
2208 0, SNIC_TRC_CMD(sc), SNIC_TRC_CMD_STATE_FLAGS(sc));
2228 snic_issue_hba_reset(struct snic *snic, struct scsi_cmnd *sc)
2244 if (snic_cmd_tag(sc) == SCSI_NO_TAG) {
2245 memset(scsi_cmd_priv(sc), 0,
2248 rqi->sc = sc;
2253 io_lock = snic_io_lock_hash(snic, sc);
2255 SNIC_BUG_ON(CMD_SP(sc) != NULL);
2256 CMD_STATE(sc) = SNIC_IOREQ_PENDING;
2257 CMD_SP(sc) = (char *) rqi;
2258 CMD_FLAGS(sc) |= SNIC_IO_INITIALIZED;
2263 snic_io_hdr_enc(&req->hdr, SNIC_REQ_HBA_RESET, 0, snic_cmd_tag(sc),
2278 CMD_FLAGS(sc) |= SNIC_HOST_RESET_ISSUED;
2295 rqi = (struct snic_req_info *) CMD_SP(sc);
2296 CMD_SP(sc) = NULL;
2309 rqi = (struct snic_req_info *) CMD_SP(sc);
2310 CMD_SP(sc) = NULL;
2325 snic_reset(struct Scsi_Host *shost, struct scsi_cmnd *sc)
2354 ret = snic_issue_hba_reset(snic, sc);
2382 snic_host_reset(struct scsi_cmnd *sc)
2384 struct Scsi_Host *shost = sc->device->host;
2389 "host reset:sc %p sc_cmd 0x%x req %p tag %d flags 0x%llx\n",
2390 sc, sc->cmnd[0], sc->request,
2391 snic_cmd_tag(sc), CMD_FLAGS(sc));
2393 ret = snic_reset(shost, sc);
2395 SNIC_TRC(shost->host_no, snic_cmd_tag(sc), (ulong) sc,
2397 0, SNIC_TRC_CMD(sc), SNIC_TRC_CMD_STATE_FLAGS(sc));
2406 snic_cmpl_pending_tmreq(struct snic *snic, struct scsi_cmnd *sc)
2411 "Completing Pending TM Req sc %p, state %s flags 0x%llx\n",
2412 sc, snic_io_status_to_str(CMD_STATE(sc)), CMD_FLAGS(sc));
2419 CMD_ABTS_STATUS(sc) = SNIC_STAT_IO_SUCCESS;
2421 rqi = (struct snic_req_info *) CMD_SP(sc);
2438 struct scsi_cmnd *sc = NULL;
2453 sc = scsi_host_find_tag(snic->shost, tag);
2454 if (!sc) {
2460 if (unlikely(snic_tmreq_pending(sc))) {
2465 snic_cmpl_pending_tmreq(snic, sc);
2471 rqi = (struct snic_req_info *) CMD_SP(sc);
2479 "sc_clean: sc %p, rqi %p, tag %d flags 0x%llx\n",
2480 sc, rqi, tag, CMD_FLAGS(sc));
2482 CMD_SP(sc) = NULL;
2483 CMD_FLAGS(sc) |= SNIC_SCSI_CLEANUP;
2489 rqi, CMD_FLAGS(sc));
2491 snic_release_req_buf(snic, rqi, sc);
2494 sc->result = DID_TRANSPORT_DISRUPTED << 16;
2496 "sc_clean: DID_TRANSPORT_DISRUPTED for sc %p, Tag %d flags 0x%llx rqi %p duration %u msecs\n",
2497 sc, sc->request->tag, CMD_FLAGS(sc), rqi,
2503 if (sc->scsi_done) {
2504 SNIC_TRC(snic->shost->host_no, tag, (ulong) sc,
2506 SNIC_TRC_CMD(sc),
2507 SNIC_TRC_CMD_STATE_FLAGS(sc));
2509 sc->scsi_done(sc);
2527 snic_internal_abort_io(struct snic *snic, struct scsi_cmnd *sc, int tmf)
2535 io_lock = snic_io_lock_hash(snic, sc);
2537 rqi = (struct snic_req_info *) CMD_SP(sc);
2541 if (CMD_STATE(sc) == SNIC_IOREQ_ABTS_PENDING)
2544 if ((CMD_FLAGS(sc) & SNIC_DEVICE_RESET) &&
2545 (!(CMD_FLAGS(sc) & SNIC_DEV_RST_ISSUED))) {
2548 "internal_abts: dev rst not pending sc 0x%p\n",
2549 sc);
2555 if (!(CMD_FLAGS(sc) & SNIC_IO_ISSUED)) {
2557 "internal_abts: IO not yet issued sc 0x%p tag 0x%x flags 0x%llx state %d\n",
2558 sc, snic_cmd_tag(sc), CMD_FLAGS(sc), CMD_STATE(sc));
2563 sv_state = CMD_STATE(sc);
2564 CMD_STATE(sc) = SNIC_IOREQ_ABTS_PENDING;
2565 CMD_ABTS_STATUS(sc) = SNIC_INVALID_CODE;
2566 CMD_FLAGS(sc) |= SNIC_IO_INTERNAL_TERM_PENDING;
2568 if (CMD_FLAGS(sc) & SNIC_DEVICE_RESET) {
2571 SNIC_SCSI_DBG(snic->shost, "internal_abts:dev rst sc %p\n", sc);
2575 snic_cmd_tag(sc));
2579 ret = snic_queue_abort_req(snic, rqi, sc, tmf);
2583 snic_cmd_tag(sc), ret);
2587 if (CMD_STATE(sc) == SNIC_IOREQ_ABTS_PENDING)
2588 CMD_STATE(sc) = sv_state;
2594 if (CMD_FLAGS(sc) & SNIC_DEVICE_RESET)
2595 CMD_FLAGS(sc) |= SNIC_DEV_RST_TERM_ISSUED;
2597 CMD_FLAGS(sc) |= SNIC_IO_INTERNAL_TERM_ISSUED;
2615 struct scsi_cmnd *sc = NULL;
2636 sc = scsi_host_find_tag(snic->shost, tag);
2637 if (!sc) {
2643 sc_tgt = starget_to_tgt(scsi_target(sc->device));
2651 ret = snic_internal_abort_io(snic, sc, tmf);