Lines Matching refs:sc

22 #define snic_cmd_tag(sc)	(scsi_cmd_to_rq(sc)->tag)
98 snic_io_lock_hash(struct snic *snic, struct scsi_cmnd *sc)
100 u32 hash = snic_cmd_tag(sc) & (SNIC_IO_LOCKS - 1);
115 struct scsi_cmnd *sc)
120 SNIC_BUG_ON(!((CMD_STATE(sc) == SNIC_IOREQ_COMPLETE) ||
121 (CMD_STATE(sc) == SNIC_IOREQ_ABTS_COMPLETE) ||
122 (CMD_FLAGS(sc) & SNIC_DEV_RST_NOTSUP) ||
123 (CMD_FLAGS(sc) & SNIC_IO_INTERNAL_TERM_ISSUED) ||
124 (CMD_FLAGS(sc) & SNIC_DEV_RST_TERM_ISSUED) ||
125 (CMD_FLAGS(sc) & SNIC_SCSI_CLEANUP) ||
126 (CMD_STATE(sc) == SNIC_IOREQ_LR_COMPLETE)));
129 "Rel_req:sc %p:tag %x:rqi %p:ioreq %p:abt %p:dr %p: state %s:flags 0x%llx\n",
130 sc, snic_cmd_tag(sc), rqi, rqi->req, rqi->abort_req,
131 rqi->dr_req, snic_ioreq_state_to_str(CMD_STATE(sc)),
132 CMD_FLAGS(sc));
140 scsi_dma_unmap(sc);
151 struct scsi_cmnd *sc,
166 for_each_sg(scsi_sglist(sc), sg, sg_cnt, i) {
175 sc->sense_buffer,
181 sc->sense_buffer, snic_cmd_tag(sc));
187 int_to_scsilun(sc->device->lun, &lun);
188 if (sc->sc_data_direction == DMA_FROM_DEVICE)
190 if (sc->sc_data_direction == DMA_TO_DEVICE)
195 snic_cmd_tag(sc),
201 sc->cmnd,
202 sc->cmd_len,
203 scsi_bufflen(sc),
228 struct scsi_cmnd *sc)
233 u32 tag = snic_cmd_tag(sc);
238 CMD_STATE(sc) = SNIC_IOREQ_NOT_INITED;
239 CMD_FLAGS(sc) = SNIC_NO_FLAGS;
240 sg_cnt = scsi_dma_map(sc);
242 SNIC_TRC((u16)snic->shost->host_no, tag, (ulong) sc, 0,
243 sc->cmnd[0], sg_cnt, CMD_STATE(sc));
253 scsi_dma_unmap(sc);
260 rqi->sc = sc;
262 CMD_STATE(sc) = SNIC_IOREQ_PENDING;
263 CMD_SP(sc) = (char *) rqi;
264 cmd_trc = SNIC_TRC_CMD(sc);
265 CMD_FLAGS(sc) |= (SNIC_IO_INITIALIZED | SNIC_IO_ISSUED);
266 cmd_st_flags = SNIC_TRC_CMD_STATE_FLAGS(sc);
267 io_lock = snic_io_lock_hash(snic, sc);
270 ret = snic_queue_icmnd_req(snic, rqi, sc, sg_cnt);
273 "issue_sc: icmnd qing Failed for sc %p, err %d\n",
274 sc, ret);
277 rqi = (struct snic_req_info *) CMD_SP(sc);
278 CMD_SP(sc) = NULL;
279 CMD_STATE(sc) = SNIC_IOREQ_COMPLETE;
280 CMD_FLAGS(sc) &= ~SNIC_IO_ISSUED; /* turn off the flag */
284 snic_release_req_buf(snic, rqi, sc);
286 SNIC_TRC(snic->shost->host_no, tag, (ulong) sc, 0, 0, 0,
287 SNIC_TRC_CMD_STATE_FLAGS(sc));
289 u32 io_sz = scsi_bufflen(sc) >> 9;
300 "issue_sc:sc %p, tag %d queued to WQ.\n",
301 sc, tag);
303 SNIC_TRC(snic->shost->host_no, tag, (ulong) sc, (ulong) rqi,
319 snic_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *sc)
325 tgt = starget_to_tgt(scsi_target(sc->device));
330 sc->result = ret;
331 scsi_done(sc);
344 SNIC_SCSI_DBG(shost, "sc %p Tag %d (sc %0x) lun %lld in snic_qcmd\n",
345 sc, snic_cmd_tag(sc), sc->cmnd[0], sc->device->lun);
347 ret = snic_issue_scsi_req(snic, tgt, sc);
364 struct scsi_cmnd *sc,
367 int state = CMD_STATE(sc);
370 CMD_FLAGS(sc) |= SNIC_IO_ABTS_PENDING;
372 CMD_FLAGS(sc) |= SNIC_DEV_RST_PENDING;
378 CMD_FLAGS(sc) |= SNIC_IO_DONE;
382 CMD_FLAGS(sc) |= SNIC_IO_ABORTED;
397 struct scsi_cmnd *sc,
415 scsi_set_resid(sc, le32_to_cpu(icmnd_cmpl->resid));
461 snic_io_status_to_str(cmpl_stat), CMD_FLAGS(sc));
463 /* Set sc->result */
464 sc->result = (res << 16) | icmnd_cmpl->scsi_status;
471 snic_tmreq_pending(struct scsi_cmnd *sc)
473 int state = CMD_STATE(sc);
487 struct scsi_cmnd *sc)
493 CMD_STATE(sc) = SNIC_IOREQ_COMPLETE;
496 sc->result = (DID_OK << 16) | scsi_stat;
499 scsi_set_resid(sc, le32_to_cpu(icmnd_cmpl->resid));
509 snic_process_io_failed_state(snic, icmnd_cmpl, sc, cmpl_stat);
513 snic_io_status_to_str(cmpl_stat), CMD_FLAGS(sc));
531 struct scsi_cmnd *sc = NULL;
554 sc = scsi_host_find_tag(snic->shost, cmnd_id);
555 WARN_ON_ONCE(!sc);
557 if (!sc) {
560 "Icmnd_cmpl: Scsi Cmnd Not found, sc = NULL Hdr Status = %s tag = 0x%x fwreq = 0x%p\n",
573 io_lock = snic_io_lock_hash(snic, sc);
576 rqi = (struct snic_req_info *) CMD_SP(sc);
578 "Icmnd_cmpl:lun %lld sc %p cmd %xtag %d flags 0x%llx rqi %p\n",
579 sc->device->lun, sc, sc->cmnd[0], snic_cmd_tag(sc),
580 CMD_FLAGS(sc), rqi);
582 if (CMD_FLAGS(sc) & SNIC_HOST_RESET_CMD_TERM) {
592 CMD_FLAGS(sc) |= SNIC_IO_REQ_NULL;
596 "Icmnd_cmpl:Host Req Not Found(null), Hdr Status %s, Tag 0x%x, sc 0x%p flags 0x%llx\n",
598 cmnd_id, sc, CMD_FLAGS(sc));
612 if (unlikely(snic_tmreq_pending(sc))) {
613 snic_proc_tmreq_pending_state(snic, sc, hdr_stat);
623 "icmnd_cmpl:TM Req Pending(%s), Hdr Status %s sc 0x%p scsi status %x resid %d flags 0x%llx\n",
624 snic_ioreq_state_to_str(CMD_STATE(sc)),
626 sc, sc_stat, le32_to_cpu(icmnd_cmpl->resid),
627 CMD_FLAGS(sc));
629 SNIC_TRC(snic->shost->host_no, cmnd_id, (ulong) sc,
631 SNIC_TRC_CMD(sc), SNIC_TRC_CMD_STATE_FLAGS(sc));
636 if (snic_process_icmnd_cmpl_status(snic, icmnd_cmpl, hdr_stat, sc)) {
637 scsi_print_command(sc);
639 "icmnd_cmpl:IO Failed, sc 0x%p Tag %d Cmd %x Hdr Status %s flags 0x%llx\n",
640 sc, sc->cmnd[0], cmnd_id,
641 snic_io_status_to_str(hdr_stat), CMD_FLAGS(sc));
645 CMD_SP(sc) = NULL;
646 CMD_FLAGS(sc) |= SNIC_IO_DONE;
653 snic_release_req_buf(snic, rqi, sc);
655 SNIC_TRC(snic->shost->host_no, cmnd_id, (ulong) sc,
657 SNIC_TRC_CMD(sc), SNIC_TRC_CMD_STATE_FLAGS(sc));
660 scsi_done(sc);
670 struct scsi_cmnd *sc)
672 struct snic_req_info *rqi = (struct snic_req_info *) CMD_SP(sc);
675 CMD_LR_STATUS(sc) = cmpl_stat;
678 snic_ioreq_state_to_str(CMD_STATE(sc)));
680 if (CMD_STATE(sc) == SNIC_IOREQ_ABTS_PENDING) {
681 CMD_FLAGS(sc) |= SNIC_DEV_RST_ABTS_PENDING;
683 SNIC_TRC(snic->shost->host_no, cmnd_id, (ulong) sc,
685 (ulong) fwreq, 0, SNIC_TRC_CMD_STATE_FLAGS(sc));
691 CMD_FLAGS(sc));
697 if (CMD_FLAGS(sc) & SNIC_DEV_RST_TIMEDOUT) {
698 SNIC_TRC(snic->shost->host_no, cmnd_id, (ulong) sc,
700 (ulong) fwreq, 0, SNIC_TRC_CMD_STATE_FLAGS(sc));
706 CMD_FLAGS(sc));
711 CMD_STATE(sc) = SNIC_IOREQ_LR_COMPLETE;
712 CMD_FLAGS(sc) |= SNIC_DEV_RST_DONE;
718 CMD_FLAGS(sc));
757 struct scsi_cmnd *sc)
766 io_lock = snic_io_lock_hash(snic, sc);
768 if (CMD_FLAGS(sc) & SNIC_HOST_RESET_CMD_TERM) {
773 rqi = (struct snic_req_info *) CMD_SP(sc);
779 CMD_FLAGS(sc) |= SNIC_IO_ABTS_TERM_REQ_NULL;
781 "itmf_cmpl: rqi is null,Hdr stat = %s Tag = 0x%x sc = 0x%p flags 0x%llx\n",
782 snic_io_status_to_str(cmpl_stat), cmnd_id, sc,
783 CMD_FLAGS(sc));
799 if (CMD_STATE(sc) != SNIC_IOREQ_ABTS_PENDING) {
806 CMD_STATE(sc) = SNIC_IOREQ_ABTS_COMPLETE;
807 CMD_ABTS_STATUS(sc) = cmpl_stat;
808 CMD_FLAGS(sc) |= SNIC_IO_ABTS_TERM_DONE;
814 CMD_FLAGS(sc));
828 CMD_SP(sc) = NULL;
829 sc->result = (DID_ERROR << 16);
831 "itmf_cmpl: Completing IO. sc %p flags 0x%llx\n",
832 sc, CMD_FLAGS(sc));
836 snic_release_req_buf(snic, rqi, sc);
838 SNIC_TRC(snic->shost->host_no, cmnd_id, (ulong) sc,
840 (ulong) fwreq, SNIC_TRC_CMD(sc),
841 SNIC_TRC_CMD_STATE_FLAGS(sc));
843 scsi_done(sc);
849 snic_proc_dr_cmpl_locked(snic, fwreq, cmpl_stat, cmnd_id, sc);
858 CMD_STATE(sc) = SNIC_IOREQ_ABTS_COMPLETE;
859 CMD_ABTS_STATUS(sc) = cmpl_stat;
860 CMD_FLAGS(sc) |= SNIC_DEV_RST_DONE;
865 CMD_FLAGS(sc));
881 snic_ioreq_state_to_str(CMD_STATE(sc)),
883 CMD_FLAGS(sc));
900 struct scsi_cmnd *sc = NULL;
922 sc = rqi->sc;
936 sc = scsi_host_find_tag(snic->shost, cmnd_id & SNIC_TAG_MASK);
937 WARN_ON_ONCE(!sc);
940 if (!sc) {
943 "Itmf_cmpl: sc is NULL - Hdr Stat %s Tag 0x%x\n",
949 snic_process_itmf_cmpl(snic, fwreq, cmnd_id, hdr_stat, sc);
955 snic_hba_reset_scsi_cleanup(struct snic *snic, struct scsi_cmnd *sc)
961 snic_scsi_cleanup(snic, snic_cmd_tag(sc));
987 struct scsi_cmnd *sc = NULL;
1008 sc = rqi->sc;
1022 sc = scsi_host_find_tag(snic->shost, cmnd_id);
1024 if (!sc) {
1027 "reset_cmpl: sc is NULL - Hdr Stat %s Tag 0x%x\n",
1035 "reset_cmpl: sc %p rqi %p Tag %d flags 0x%llx\n",
1036 sc, rqi, cmnd_id, CMD_FLAGS(sc));
1038 io_lock = snic_io_lock_hash(snic, sc);
1050 rqi = (struct snic_req_info *) CMD_SP(sc);
1056 CMD_FLAGS(sc) |= SNIC_IO_ABTS_TERM_REQ_NULL;
1058 "reset_cmpl: rqi is null,Hdr stat %s Tag 0x%x sc 0x%p flags 0x%llx\n",
1059 snic_io_status_to_str(hdr_stat), cmnd_id, sc,
1060 CMD_FLAGS(sc));
1070 snic_hba_reset_scsi_cleanup(snic, sc);
1287 struct scsi_cmnd *sc,
1293 int tm_tag = snic_cmd_tag(sc) | rqi->tm_tag;
1300 int_to_scsilun(sc->device->lun, &lun);
1323 "qitmf:Queuing ITMF(%d) Req sc %p, rqi %p, req_id %d tag %d Failed, ret = %d\n",
1324 tmf, sc, rqi, req_id, snic_cmd_tag(sc), ret);
1327 "qitmf:Queuing ITMF(%d) Req sc %p, rqi %p, req_id %d, tag %d (req_id)- Success.",
1328 tmf, sc, rqi, req_id, snic_cmd_tag(sc));
1336 struct scsi_cmnd *sc,
1340 int req_id = 0, tag = snic_cmd_tag(sc);
1367 ret = snic_queue_itmf_req(snic, tmreq, sc, tmf, req_id);
1372 "issu_tmreq: Queueing ITMF(%d) Req, sc %p rqi %p req_id %d tag %x fails err = %d\n",
1373 tmf, sc, rqi, req_id, tag, ret);
1376 "issu_tmreq: Queueing ITMF(%d) Req, sc %p, rqi %p, req_id %d tag %x - Success.\n",
1377 tmf, sc, rqi, req_id, tag);
1391 struct scsi_cmnd *sc,
1394 SNIC_SCSI_DBG(snic->shost, "q_abtreq: sc %p, rqi %p, tag %x, tmf %d\n",
1395 sc, rqi, snic_cmd_tag(sc), tmf);
1400 return snic_issue_tm_req(snic, rqi, sc, tmf);
1407 snic_abort_finish(struct snic *snic, struct scsi_cmnd *sc)
1412 int ret = 0, tag = snic_cmd_tag(sc);
1414 io_lock = snic_io_lock_hash(snic, sc);
1416 rqi = (struct snic_req_info *) CMD_SP(sc);
1419 CMD_FLAGS(sc) |= SNIC_IO_ABTS_TERM_REQ_NULL;
1422 "abt_fini:req info is null tag 0x%x, sc 0x%p flags 0x%llx\n",
1423 tag, sc, CMD_FLAGS(sc));
1434 switch (CMD_ABTS_STATUS(sc)) {
1437 CMD_FLAGS(sc) |= SNIC_IO_ABTS_TIMEDOUT;
1440 "abt_fini:sc %p Tag %x Driver Timeout.flags 0x%llx\n",
1441 sc, snic_cmd_tag(sc), CMD_FLAGS(sc));
1455 sc->result = (DID_ERROR << 16);
1456 scsi_done(sc);
1466 CMD_SP(sc) = NULL;
1469 tag, snic_io_status_to_str(CMD_ABTS_STATUS(sc)),
1470 CMD_FLAGS(sc));
1475 snic_release_req_buf(snic, rqi, sc);
1484 snic_send_abort_and_wait(struct snic *snic, struct scsi_cmnd *sc)
1492 int ret = 0, tmf = 0, tag = snic_cmd_tag(sc);
1494 tgt = starget_to_tgt(scsi_target(sc->device));
1502 io_lock = snic_io_lock_hash(snic, sc);
1517 rqi = (struct snic_req_info *) CMD_SP(sc);
1523 tag, CMD_FLAGS(sc));
1531 if (CMD_STATE(sc) == SNIC_IOREQ_ABTS_PENDING) {
1540 sv_state = CMD_STATE(sc);
1548 CMD_STATE(sc) = SNIC_IOREQ_ABTS_PENDING;
1549 CMD_ABTS_STATUS(sc) = SNIC_INVALID_CODE;
1556 ret = snic_queue_abort_req(snic, rqi, sc, tmf);
1561 tag, ret, CMD_FLAGS(sc));
1565 CMD_STATE(sc) = sv_state;
1566 rqi = (struct snic_req_info *) CMD_SP(sc);
1577 CMD_FLAGS(sc) |= SNIC_IO_ABTS_ISSUED;
1581 CMD_FLAGS(sc) |= SNIC_IO_TERM_ISSUED;
1586 "send_abt_cmd: sc %p Tag %x flags 0x%llx\n",
1587 sc, tag, CMD_FLAGS(sc));
1610 snic_abort_cmd(struct scsi_cmnd *sc)
1612 struct snic *snic = shost_priv(sc->device->host);
1613 int ret = SUCCESS, tag = snic_cmd_tag(sc);
1616 SNIC_SCSI_DBG(snic->shost, "abt_cmd:sc %p :0x%x :req = %p :tag = %d\n",
1617 sc, sc->cmnd[0], scsi_cmd_to_rq(sc), tag);
1629 ret = snic_send_abort_and_wait(snic, sc);
1633 ret = snic_abort_finish(snic, sc);
1636 SNIC_TRC(snic->shost->host_no, tag, (ulong) sc,
1638 SNIC_TRC_CMD(sc), SNIC_TRC_CMD_STATE_FLAGS(sc));
1654 struct scsi_cmnd *sc = NULL;
1668 sc = scsi_host_find_tag(snic->shost, tag);
1670 if (!sc || (lr_sc && (sc->device != lr_sdev || sc == lr_sc))) {
1676 rqi = (struct snic_req_info *) CMD_SP(sc);
1688 snic_ioreq_state_to_str(CMD_STATE(sc)));
1690 if (CMD_STATE(sc) == SNIC_IOREQ_ABTS_PENDING) {
1709 struct scsi_cmnd *sc = NULL;
1718 sc = scsi_host_find_tag(snic->shost, tag);
1721 if (!sc || sc->device != lr_sdev)
1724 rqi = (struct snic_req_info *) CMD_SP(sc);
1730 if (CMD_STATE(sc) == SNIC_IOREQ_ABTS_PENDING)
1734 if ((CMD_FLAGS(sc) & SNIC_DEVICE_RESET) &&
1735 (!(CMD_FLAGS(sc) & SNIC_DEV_RST_ISSUED))) {
1738 "clean_single_req: devrst is not pending sc 0x%p\n",
1739 sc);
1746 snic_ioreq_state_to_str(CMD_STATE(sc)));
1749 sv_state = CMD_STATE(sc);
1759 CMD_STATE(sc) = SNIC_IOREQ_ABTS_PENDING;
1762 if (CMD_FLAGS(sc) & SNIC_DEVICE_RESET) {
1766 "clean_single_req:devrst sc 0x%p\n", sc);
1769 CMD_ABTS_STATUS(sc) = SNIC_INVALID_CODE;
1773 tgt = starget_to_tgt(scsi_target(sc->device));
1780 ret = snic_queue_abort_req(snic, rqi, sc, tmf);
1783 "clean_single_req_err:sc %p, tag %d abt failed. tm_tag %d flags 0x%llx\n",
1784 sc, tag, rqi->tm_tag, CMD_FLAGS(sc));
1787 rqi = (struct snic_req_info *) CMD_SP(sc);
1792 if (CMD_STATE(sc) == SNIC_IOREQ_ABTS_PENDING)
1793 CMD_STATE(sc) = sv_state;
1800 if (CMD_FLAGS(sc) & SNIC_DEVICE_RESET)
1801 CMD_FLAGS(sc) |= SNIC_DEV_RST_TERM_ISSUED;
1803 CMD_FLAGS(sc) |= SNIC_IO_INTERNAL_TERM_ISSUED;
1810 rqi = (struct snic_req_info *) CMD_SP(sc);
1812 CMD_FLAGS(sc) |= SNIC_IO_ABTS_TERM_REQ_NULL;
1818 if (CMD_ABTS_STATUS(sc) == SNIC_INVALID_CODE) {
1820 "clean_single_req_err:sc %p tag %d abt still pending w/ fw, tm_tag %d flags 0x%llx\n",
1821 sc, tag, rqi->tm_tag, CMD_FLAGS(sc));
1823 CMD_FLAGS(sc) |= SNIC_IO_ABTS_TERM_DONE;
1829 CMD_STATE(sc) = SNIC_IOREQ_ABTS_COMPLETE;
1830 CMD_SP(sc) = NULL;
1833 snic_release_req_buf(snic, rqi, sc);
1835 sc->result = (DID_ERROR << 16);
1836 scsi_done(sc);
1895 snic_dr_finish(struct snic *snic, struct scsi_cmnd *sc)
1903 io_lock = snic_io_lock_hash(snic, sc);
1905 rqi = (struct snic_req_info *) CMD_SP(sc);
1909 "dr_fini: rqi is null tag 0x%x sc 0x%p flags 0x%llx\n",
1910 snic_cmd_tag(sc), sc, CMD_FLAGS(sc));
1918 lr_res = CMD_LR_STATUS(sc);
1925 snic_cmd_tag(sc), CMD_FLAGS(sc));
1927 CMD_FLAGS(sc) |= SNIC_DEV_RST_TIMEDOUT;
1935 snic_cmd_tag(sc));
1942 snic_cmd_tag(sc),
1943 snic_io_status_to_str(lr_res), CMD_FLAGS(sc));
1957 ret = snic_dr_clean_pending_req(snic, sc);
1962 snic_cmd_tag(sc));
1963 rqi = (struct snic_req_info *) CMD_SP(sc);
1969 rqi = (struct snic_req_info *) CMD_SP(sc);
1979 CMD_SP(sc) = NULL;
1983 snic_release_req_buf(snic, rqi, sc);
1992 struct scsi_cmnd *sc)
1997 return snic_issue_tm_req(snic, rqi, sc, SNIC_ITMF_LUN_RESET);
2001 snic_send_dr_and_wait(struct snic *snic, struct scsi_cmnd *sc)
2008 int ret = FAILED, tag = snic_cmd_tag(sc);
2010 io_lock = snic_io_lock_hash(snic, sc);
2012 CMD_FLAGS(sc) |= SNIC_DEVICE_RESET;
2013 rqi = (struct snic_req_info *) CMD_SP(sc);
2017 tag, CMD_FLAGS(sc));
2025 sv_state = CMD_STATE(sc);
2027 CMD_STATE(sc) = SNIC_IOREQ_LR_PENDING;
2028 CMD_LR_STATUS(sc) = SNIC_INVALID_CODE;
2043 ret = snic_queue_dr_req(snic, rqi, sc);
2047 tag, ret, CMD_FLAGS(sc));
2051 CMD_STATE(sc) = sv_state;
2052 rqi = (struct snic_req_info *) CMD_SP(sc);
2063 CMD_FLAGS(sc) |= SNIC_DEV_RST_ISSUED;
2090 snic_unlink_and_release_req(struct snic *snic, struct scsi_cmnd *sc, int flag)
2097 io_lock = snic_io_lock_hash(snic, sc);
2099 rqi = (struct snic_req_info *) CMD_SP(sc);
2102 CMD_SP(sc) = NULL;
2105 CMD_FLAGS(sc) |= flag;
2109 snic_release_req_buf(snic, rqi, sc);
2111 SNIC_TRC(snic->shost->host_no, snic_cmd_tag(sc), (ulong) sc,
2113 SNIC_TRC_CMD(sc), SNIC_TRC_CMD_STATE_FLAGS(sc));
2122 snic_device_reset(struct scsi_cmnd *sc)
2124 struct Scsi_Host *shost = sc->device->host;
2127 int tag = snic_cmd_tag(sc);
2132 SNIC_SCSI_DBG(shost, "dev_reset:sc %p :0x%x :req = %p :tag = %d\n",
2133 sc, sc->cmnd[0], scsi_cmd_to_rq(sc),
2134 snic_cmd_tag(sc));
2135 dr_supp = snic_dev_reset_supported(sc->device);
2139 snic_unlink_and_release_req(snic, sc, SNIC_DEV_RST_NOTSUP);
2145 snic_unlink_and_release_req(snic, sc, 0);
2160 memset(scsi_cmd_priv(sc), 0,
2162 CMD_SP(sc) = (char *)rqi;
2163 CMD_FLAGS(sc) = SNIC_NO_FLAGS;
2167 rqi->sc = sc;
2170 ret = snic_send_dr_and_wait(snic, sc);
2176 snic_unlink_and_release_req(snic, sc, 0);
2181 ret = snic_dr_finish(snic, sc);
2184 SNIC_TRC(snic->shost->host_no, tag, (ulong) sc,
2186 0, SNIC_TRC_CMD(sc), SNIC_TRC_CMD_STATE_FLAGS(sc));
2206 snic_issue_hba_reset(struct snic *snic, struct scsi_cmnd *sc)
2222 if (snic_cmd_tag(sc) == SCSI_NO_TAG) {
2223 memset(scsi_cmd_priv(sc), 0,
2226 rqi->sc = sc;
2231 io_lock = snic_io_lock_hash(snic, sc);
2233 SNIC_BUG_ON(CMD_SP(sc) != NULL);
2234 CMD_STATE(sc) = SNIC_IOREQ_PENDING;
2235 CMD_SP(sc) = (char *) rqi;
2236 CMD_FLAGS(sc) |= SNIC_IO_INITIALIZED;
2241 snic_io_hdr_enc(&req->hdr, SNIC_REQ_HBA_RESET, 0, snic_cmd_tag(sc),
2256 CMD_FLAGS(sc) |= SNIC_HOST_RESET_ISSUED;
2273 rqi = (struct snic_req_info *) CMD_SP(sc);
2274 CMD_SP(sc) = NULL;
2287 rqi = (struct snic_req_info *) CMD_SP(sc);
2288 CMD_SP(sc) = NULL;
2303 snic_reset(struct Scsi_Host *shost, struct scsi_cmnd *sc)
2332 ret = snic_issue_hba_reset(snic, sc);
2360 snic_host_reset(struct scsi_cmnd *sc)
2362 struct Scsi_Host *shost = sc->device->host;
2367 "host reset:sc %p sc_cmd 0x%x req %p tag %d flags 0x%llx\n",
2368 sc, sc->cmnd[0], scsi_cmd_to_rq(sc),
2369 snic_cmd_tag(sc), CMD_FLAGS(sc));
2371 ret = snic_reset(shost, sc);
2373 SNIC_TRC(shost->host_no, snic_cmd_tag(sc), (ulong) sc,
2375 0, SNIC_TRC_CMD(sc), SNIC_TRC_CMD_STATE_FLAGS(sc));
2384 snic_cmpl_pending_tmreq(struct snic *snic, struct scsi_cmnd *sc)
2389 "Completing Pending TM Req sc %p, state %s flags 0x%llx\n",
2390 sc, snic_io_status_to_str(CMD_STATE(sc)), CMD_FLAGS(sc));
2397 CMD_ABTS_STATUS(sc) = SNIC_STAT_IO_SUCCESS;
2399 rqi = (struct snic_req_info *) CMD_SP(sc);
2416 struct scsi_cmnd *sc = NULL;
2431 sc = scsi_host_find_tag(snic->shost, tag);
2432 if (!sc) {
2438 if (unlikely(snic_tmreq_pending(sc))) {
2443 snic_cmpl_pending_tmreq(snic, sc);
2449 rqi = (struct snic_req_info *) CMD_SP(sc);
2457 "sc_clean: sc %p, rqi %p, tag %d flags 0x%llx\n",
2458 sc, rqi, tag, CMD_FLAGS(sc));
2460 CMD_SP(sc) = NULL;
2461 CMD_FLAGS(sc) |= SNIC_SCSI_CLEANUP;
2467 rqi, CMD_FLAGS(sc));
2469 snic_release_req_buf(snic, rqi, sc);
2472 sc->result = DID_TRANSPORT_DISRUPTED << 16;
2474 "sc_clean: DID_TRANSPORT_DISRUPTED for sc %p, Tag %d flags 0x%llx rqi %p duration %u msecs\n",
2475 sc, scsi_cmd_to_rq(sc)->tag, CMD_FLAGS(sc), rqi,
2481 SNIC_TRC(snic->shost->host_no, tag, (ulong) sc,
2483 SNIC_TRC_CMD(sc),
2484 SNIC_TRC_CMD_STATE_FLAGS(sc));
2486 scsi_done(sc);
2503 snic_internal_abort_io(struct snic *snic, struct scsi_cmnd *sc, int tmf)
2511 io_lock = snic_io_lock_hash(snic, sc);
2513 rqi = (struct snic_req_info *) CMD_SP(sc);
2517 if (CMD_STATE(sc) == SNIC_IOREQ_ABTS_PENDING)
2520 if ((CMD_FLAGS(sc) & SNIC_DEVICE_RESET) &&
2521 (!(CMD_FLAGS(sc) & SNIC_DEV_RST_ISSUED))) {
2524 "internal_abts: dev rst not pending sc 0x%p\n",
2525 sc);
2531 if (!(CMD_FLAGS(sc) & SNIC_IO_ISSUED)) {
2533 "internal_abts: IO not yet issued sc 0x%p tag 0x%x flags 0x%llx state %d\n",
2534 sc, snic_cmd_tag(sc), CMD_FLAGS(sc), CMD_STATE(sc));
2539 sv_state = CMD_STATE(sc);
2540 CMD_STATE(sc) = SNIC_IOREQ_ABTS_PENDING;
2541 CMD_ABTS_STATUS(sc) = SNIC_INVALID_CODE;
2542 CMD_FLAGS(sc) |= SNIC_IO_INTERNAL_TERM_PENDING;
2544 if (CMD_FLAGS(sc) & SNIC_DEVICE_RESET) {
2547 SNIC_SCSI_DBG(snic->shost, "internal_abts:dev rst sc %p\n", sc);
2551 snic_cmd_tag(sc));
2555 ret = snic_queue_abort_req(snic, rqi, sc, tmf);
2559 snic_cmd_tag(sc), ret);
2563 if (CMD_STATE(sc) == SNIC_IOREQ_ABTS_PENDING)
2564 CMD_STATE(sc) = sv_state;
2570 if (CMD_FLAGS(sc) & SNIC_DEVICE_RESET)
2571 CMD_FLAGS(sc) |= SNIC_DEV_RST_TERM_ISSUED;
2573 CMD_FLAGS(sc) |= SNIC_IO_INTERNAL_TERM_ISSUED;
2591 struct scsi_cmnd *sc = NULL;
2612 sc = scsi_host_find_tag(snic->shost, tag);
2613 if (!sc) {
2619 sc_tgt = starget_to_tgt(scsi_target(sc->device));
2627 ret = snic_internal_abort_io(snic, sc, tmf);