Lines Matching refs:io_req
19 static int bnx2fc_split_bd(struct bnx2fc_cmd *io_req, u64 addr, int sg_len,
21 static int bnx2fc_map_sg(struct bnx2fc_cmd *io_req);
22 static int bnx2fc_build_bd_list_from_sg(struct bnx2fc_cmd *io_req);
23 static void bnx2fc_unmap_sg_list(struct bnx2fc_cmd *io_req);
24 static void bnx2fc_free_mp_resc(struct bnx2fc_cmd *io_req);
25 static void bnx2fc_parse_fcp_rsp(struct bnx2fc_cmd *io_req,
29 void bnx2fc_cmd_timer_set(struct bnx2fc_cmd *io_req,
32 struct bnx2fc_interface *interface = io_req->port->priv;
35 &io_req->timeout_work,
37 kref_get(&io_req->refcount);
42 struct bnx2fc_cmd *io_req = container_of(work, struct bnx2fc_cmd,
44 u8 cmd_type = io_req->cmd_type;
45 struct bnx2fc_rport *tgt = io_req->tgt;
48 BNX2FC_IO_DBG(io_req, "cmd_timeout, cmd_type = %d,"
49 "req_flags = %lx\n", cmd_type, io_req->req_flags);
52 if (test_and_clear_bit(BNX2FC_FLAG_ISSUE_RRQ, &io_req->req_flags)) {
53 clear_bit(BNX2FC_FLAG_RETIRE_OXID, &io_req->req_flags);
55 * ideally we should hold the io_req until RRQ complets,
56 * and release io_req from timeout hold.
59 bnx2fc_send_rrq(io_req);
62 if (test_and_clear_bit(BNX2FC_FLAG_RETIRE_OXID, &io_req->req_flags)) {
63 BNX2FC_IO_DBG(io_req, "IO ready for reuse now\n");
70 &io_req->req_flags)) {
72 BNX2FC_IO_DBG(io_req, "eh_abort timed out\n");
73 complete(&io_req->abts_done);
75 &io_req->req_flags)) {
77 BNX2FC_IO_DBG(io_req, "ABTS timed out refcnt = %d\n",
78 kref_read(&io_req->refcount));
80 &io_req->req_flags))) {
85 bnx2fc_initiate_cleanup(io_req);
86 kref_put(&io_req->refcount, bnx2fc_cmd_release);
93 BNX2FC_IO_DBG(io_req, "IO timed out. issue ABTS\n");
95 &io_req->req_flags)) {
96 BNX2FC_IO_DBG(io_req, "IO completed before "
102 &io_req->req_flags)) {
103 rc = bnx2fc_initiate_abts(io_req);
107 kref_put(&io_req->refcount, bnx2fc_cmd_release);
112 BNX2FC_IO_DBG(io_req, "IO already in "
119 if (test_bit(BNX2FC_FLAG_ISSUE_ABTS, &io_req->req_flags)) {
120 BNX2FC_IO_DBG(io_req, "ABTS for ELS timed out\n");
123 &io_req->req_flags)) {
124 kref_put(&io_req->refcount, bnx2fc_cmd_release);
136 BNX2FC_IO_DBG(io_req, "ELS timed out\n");
138 &io_req->req_flags))
142 set_bit(BNX2FC_FLAG_ELS_TIMEOUT, &io_req->req_flags);
144 if ((io_req->cb_func) && (io_req->cb_arg)) {
145 io_req->cb_func(io_req->cb_arg);
146 io_req->cb_arg = NULL;
158 kref_put(&io_req->refcount, bnx2fc_cmd_release);
162 static void bnx2fc_scsi_done(struct bnx2fc_cmd *io_req, int err_code)
165 struct scsi_cmnd *sc_cmd = io_req->sc_cmd;
172 if (io_req->cmd_type != BNX2FC_SCSI_CMD)
175 BNX2FC_IO_DBG(io_req, "scsi_done. err_code = 0x%x\n", err_code);
176 if (test_bit(BNX2FC_FLAG_CMD_LOST, &io_req->req_flags)) {
181 bnx2fc_unmap_sg_list(io_req);
182 io_req->sc_cmd = NULL;
188 io_req->xid);
192 pr_err(PFX "0x%x: sc_cmd->device is NULL.\n", io_req->xid);
197 io_req->xid);
203 BNX2FC_IO_DBG(io_req, "sc=%p, result=0x%x, retries=%d, allowed=%d\n",
215 struct bnx2fc_cmd *io_req;
275 io_req = kzalloc(sizeof(*io_req), GFP_KERNEL);
277 if (!io_req) {
278 printk(KERN_ERR PFX "failed to alloc io_req\n");
282 INIT_LIST_HEAD(&io_req->link);
283 INIT_DELAYED_WORK(&io_req->timeout_work, bnx2fc_cmd_timeout);
285 io_req->xid = xid++;
287 list_add_tail(&io_req->link,
288 &cmgr->free_list[io_req->xid %
291 list_add_tail(&io_req->link,
293 io_req++;
380 struct bnx2fc_cmd *tmp, *io_req;
382 list_for_each_entry_safe(io_req, tmp,
384 list_del(&io_req->link);
385 kfree(io_req);
399 struct bnx2fc_cmd *io_req;
440 io_req = (struct bnx2fc_cmd *) listp;
441 xid = io_req->xid;
442 cmd_mgr->cmds[xid] = io_req;
447 INIT_LIST_HEAD(&io_req->link);
449 io_req->port = port;
450 io_req->cmd_mgr = cmd_mgr;
451 io_req->req_flags = 0;
452 io_req->cmd_type = type;
454 /* Bind io_bdt for this io_req */
455 /* Have a static link between io_req and io_bdt_pool */
456 bd_tbl = io_req->bd_tbl = cmd_mgr->io_bdt_pool[xid];
457 bd_tbl->io_req = io_req;
459 /* Hold the io_req against deletion */
460 kref_init(&io_req->refcount);
461 return io_req;
469 struct bnx2fc_cmd *io_req;
495 io_req = (struct bnx2fc_cmd *) listp;
496 xid = io_req->xid;
497 cmd_mgr->cmds[xid] = io_req;
503 INIT_LIST_HEAD(&io_req->link);
505 io_req->port = port;
506 io_req->cmd_mgr = cmd_mgr;
507 io_req->req_flags = 0;
509 /* Bind io_bdt for this io_req */
510 /* Have a static link between io_req and io_bdt_pool */
511 bd_tbl = io_req->bd_tbl = cmd_mgr->io_bdt_pool[xid];
512 bd_tbl->io_req = io_req;
514 /* Hold the io_req against deletion */
515 kref_init(&io_req->refcount);
516 return io_req;
521 struct bnx2fc_cmd *io_req = container_of(ref,
523 struct bnx2fc_cmd_mgr *cmd_mgr = io_req->cmd_mgr;
526 if (io_req->cmd_type == BNX2FC_SCSI_CMD)
527 index = io_req->xid % num_possible_cpus();
533 if (io_req->cmd_type != BNX2FC_SCSI_CMD)
534 bnx2fc_free_mp_resc(io_req);
535 cmd_mgr->cmds[io_req->xid] = NULL;
537 list_del_init(&io_req->link);
539 list_add(&io_req->link,
541 atomic_dec(&io_req->tgt->num_active_ios);
546 static void bnx2fc_free_mp_resc(struct bnx2fc_cmd *io_req)
548 struct bnx2fc_mp_req *mp_req = &(io_req->mp_req);
549 struct bnx2fc_interface *interface = io_req->port->priv;
581 int bnx2fc_init_mp_req(struct bnx2fc_cmd *io_req)
586 struct bnx2fc_interface *interface = io_req->port->priv;
591 mp_req = (struct bnx2fc_mp_req *)&(io_req->mp_req);
594 if (io_req->cmd_type != BNX2FC_ELS) {
596 io_req->data_xfer_len = mp_req->req_len;
598 mp_req->req_len = io_req->data_xfer_len;
605 bnx2fc_free_mp_resc(io_req);
614 bnx2fc_free_mp_resc(io_req);
627 bnx2fc_free_mp_resc(io_req);
635 bnx2fc_free_mp_resc(io_req);
669 struct bnx2fc_cmd *io_req;
712 io_req = bnx2fc_elstm_alloc(tgt, BNX2FC_TASK_MGMT_CMD);
713 if (!io_req) {
722 /* Initialize rest of io_req fields */
723 io_req->sc_cmd = sc_cmd;
724 io_req->port = port;
725 io_req->tgt = tgt;
727 tm_req = (struct bnx2fc_mp_req *)&(io_req->mp_req);
729 rc = bnx2fc_init_mp_req(io_req);
733 kref_put(&io_req->refcount, bnx2fc_cmd_release);
739 io_req->io_req_flags = 0;
743 bnx2fc_build_fcp_cmnd(io_req, (struct fcp_cmnd *)tm_req->req_buf);
756 xid = io_req->xid;
766 bnx2fc_init_mp_task(io_req, task);
768 sc_cmd->SCp.ptr = (char *)io_req;
774 /* Enqueue the io_req to active_tm_queue */
775 io_req->on_tmf_queue = 1;
776 list_add_tail(&io_req->link, &tgt->active_tm_queue);
778 init_completion(&io_req->abts_done);
779 io_req->wait_for_abts_comp = 1;
785 rc = wait_for_completion_timeout(&io_req->abts_done,
789 io_req->wait_for_abts_comp = 0;
790 if (!(test_bit(BNX2FC_FLAG_TM_COMPL, &io_req->req_flags))) {
791 set_bit(BNX2FC_FLAG_TM_TIMEOUT, &io_req->req_flags);
792 if (io_req->on_tmf_queue) {
793 list_del_init(&io_req->link);
794 io_req->on_tmf_queue = 0;
796 io_req->wait_for_cleanup_comp = 1;
797 init_completion(&io_req->cleanup_done);
798 bnx2fc_initiate_cleanup(io_req);
800 rc = wait_for_completion_timeout(&io_req->cleanup_done,
803 io_req->wait_for_cleanup_comp = 0;
805 kref_put(&io_req->refcount, bnx2fc_cmd_release);
821 int bnx2fc_initiate_abts(struct bnx2fc_cmd *io_req)
824 struct bnx2fc_rport *tgt = io_req->tgt;
841 BNX2FC_IO_DBG(io_req, "Entered bnx2fc_initiate_abts\n");
843 port = io_req->port;
872 /* Initialize rest of io_req fields */
885 fc_hdr->fh_ox_id = htons(io_req->xid);
886 fc_hdr->fh_rx_id = htons(io_req->task->rxwr_txrd.var_ctx.rx_id);
896 BNX2FC_IO_DBG(abts_io_req, "ABTS io_req\n");
917 /* if (test_bit(BNX2FC_FLAG_ISSUE_ABTS, &io_req->req_flags))*/
918 bnx2fc_cmd_timer_set(io_req, 2 * r_a_tov);
965 /* Initialize rest of io_req fields */
981 cb_arg->io_req = seq_clnp_req;
998 int bnx2fc_initiate_cleanup(struct bnx2fc_cmd *io_req)
1000 struct bnx2fc_rport *tgt = io_req->tgt;
1011 BNX2FC_IO_DBG(io_req, "Entered bnx2fc_initiate_cleanup\n");
1013 port = io_req->port;
1023 /* Initialize rest of io_req fields */
1038 orig_xid = io_req->xid;
1040 BNX2FC_IO_DBG(io_req, "CLEANUP io_req xid = 0x%x\n", xid);
1048 set_bit(BNX2FC_FLAG_ISSUE_CLEANUP_REQ, &io_req->req_flags);
1083 static int bnx2fc_abts_cleanup(struct bnx2fc_cmd *io_req)
1086 struct bnx2fc_rport *tgt = io_req->tgt;
1089 init_completion(&io_req->cleanup_done);
1090 io_req->wait_for_cleanup_comp = 1;
1091 bnx2fc_initiate_cleanup(io_req);
1099 time_left = wait_for_completion_timeout(&io_req->cleanup_done,
1102 BNX2FC_IO_DBG(io_req, "%s(): Wait for cleanup timed out.\n",
1109 kref_put(&io_req->refcount, bnx2fc_cmd_release);
1113 io_req->wait_for_cleanup_comp = 0;
1129 struct bnx2fc_cmd *io_req;
1150 io_req = (struct bnx2fc_cmd *)sc_cmd->SCp.ptr;
1151 if (!io_req) {
1153 printk(KERN_ERR PFX "eh_abort: io_req is NULL\n");
1157 BNX2FC_IO_DBG(io_req, "eh_abort - refcnt = %d\n",
1158 kref_read(&io_req->refcount));
1161 kref_get(&io_req->refcount);
1163 BUG_ON(tgt != io_req->tgt);
1165 /* Remove the io_req from the active_q. */
1169 * io_req is no longer in the active_q.
1172 printk(KERN_ERR PFX "eh_abort: io_req (xid = 0x%x) "
1173 "flush in progress\n", io_req->xid);
1174 kref_put(&io_req->refcount, bnx2fc_cmd_release);
1179 if (io_req->on_active_queue == 0) {
1180 printk(KERN_ERR PFX "eh_abort: io_req (xid = 0x%x) "
1181 "not on active_q\n", io_req->xid);
1197 list_del_init(&io_req->link);
1198 io_req->on_active_queue = 0;
1200 list_add_tail(&io_req->link, &tgt->io_retire_queue);
1202 init_completion(&io_req->abts_done);
1203 init_completion(&io_req->cleanup_done);
1205 if (test_and_set_bit(BNX2FC_FLAG_ISSUE_ABTS, &io_req->req_flags)) {
1206 printk(KERN_ERR PFX "eh_abort: io_req (xid = 0x%x) "
1207 "already in abts processing\n", io_req->xid);
1208 if (cancel_delayed_work(&io_req->timeout_work))
1209 kref_put(&io_req->refcount,
1216 rc = bnx2fc_abts_cleanup(io_req);
1222 set_bit(BNX2FC_FLAG_IO_CLEANUP, &io_req->req_flags);
1227 /* Cancel the current timer running on this io_req */
1228 if (cancel_delayed_work(&io_req->timeout_work))
1229 kref_put(&io_req->refcount,
1231 set_bit(BNX2FC_FLAG_EH_ABORT, &io_req->req_flags);
1232 io_req->wait_for_abts_comp = 1;
1233 rc = bnx2fc_initiate_abts(io_req);
1235 io_req->wait_for_cleanup_comp = 1;
1236 bnx2fc_initiate_cleanup(io_req);
1238 wait_for_completion(&io_req->cleanup_done);
1240 io_req->wait_for_cleanup_comp = 0;
1246 time_left = wait_for_completion_timeout(&io_req->abts_done,
1249 BNX2FC_IO_DBG(io_req,
1253 io_req->wait_for_abts_comp = 0;
1254 if (test_bit(BNX2FC_FLAG_IO_COMPL, &io_req->req_flags)) {
1255 BNX2FC_IO_DBG(io_req, "IO completed in a different context\n");
1258 &io_req->req_flags))) {
1261 io_req->xid);
1266 rc = bnx2fc_abts_cleanup(io_req);
1274 BNX2FC_IO_DBG(io_req, "abort succeeded\n");
1276 bnx2fc_scsi_done(io_req, DID_ABORT);
1277 kref_put(&io_req->refcount, bnx2fc_cmd_release);
1281 kref_put(&io_req->refcount, bnx2fc_cmd_release);
1321 void bnx2fc_process_cleanup_compl(struct bnx2fc_cmd *io_req,
1325 BNX2FC_IO_DBG(io_req, "Entered process_cleanup_compl "
1327 kref_read(&io_req->refcount), io_req->cmd_type);
1333 &io_req->req_flags))
1340 if (test_bit(BNX2FC_FLAG_ISSUE_ABTS, &io_req->req_flags) &&
1341 !test_bit(BNX2FC_FLAG_ABTS_DONE, &io_req->req_flags)) {
1342 set_bit(BNX2FC_FLAG_ABTS_DONE, &io_req->req_flags);
1343 if (io_req->wait_for_abts_comp)
1344 complete(&io_req->abts_done);
1347 bnx2fc_scsi_done(io_req, DID_ERROR);
1348 kref_put(&io_req->refcount, bnx2fc_cmd_release);
1349 if (io_req->wait_for_cleanup_comp)
1350 complete(&io_req->cleanup_done);
1353 void bnx2fc_process_abts_compl(struct bnx2fc_cmd *io_req,
1360 struct bnx2fc_rport *tgt = io_req->tgt;
1362 BNX2FC_IO_DBG(io_req, "Entered process_abts_compl xid = 0x%x"
1364 io_req->xid,
1365 kref_read(&io_req->refcount), io_req->cmd_type);
1368 &io_req->req_flags)) {
1369 BNX2FC_IO_DBG(io_req, "Timer context finished processing"
1378 if (test_bit(BNX2FC_FLAG_ISSUE_CLEANUP_REQ, &io_req->req_flags)) {
1379 clear_bit(BNX2FC_FLAG_ISSUE_CLEANUP_REQ, &io_req->req_flags);
1380 if (io_req->wait_for_cleanup_comp)
1381 complete(&io_req->cleanup_done);
1386 &io_req->req_flags))
1395 if (test_bit(BNX2FC_FLAG_ISSUE_ABTS, &io_req->req_flags))
1396 if (cancel_delayed_work(&io_req->timeout_work))
1397 kref_put(&io_req->refcount,
1408 BNX2FC_IO_DBG(io_req, "ABTS response - ACC Send RRQ\n");
1413 BNX2FC_IO_DBG(io_req, "ABTS response - RJT\n");
1421 BNX2FC_IO_DBG(io_req, "Issue RRQ after R_A_TOV\n");
1422 set_bit(BNX2FC_FLAG_ISSUE_RRQ, &io_req->req_flags);
1424 set_bit(BNX2FC_FLAG_RETIRE_OXID, &io_req->req_flags);
1425 bnx2fc_cmd_timer_set(io_req, r_a_tov);
1428 if (io_req->wait_for_abts_comp) {
1430 &io_req->req_flags))
1431 complete(&io_req->abts_done);
1442 if (io_req->on_active_queue) {
1443 list_del_init(&io_req->link);
1444 io_req->on_active_queue = 0;
1446 list_add_tail(&io_req->link, &tgt->io_retire_queue);
1448 bnx2fc_scsi_done(io_req, DID_ERROR);
1449 kref_put(&io_req->refcount, bnx2fc_cmd_release);
1453 static void bnx2fc_lun_reset_cmpl(struct bnx2fc_cmd *io_req)
1455 struct scsi_cmnd *sc_cmd = io_req->sc_cmd;
1456 struct bnx2fc_rport *tgt = io_req->tgt;
1463 BNX2FC_IO_DBG(io_req, "Entered bnx2fc_lun_reset_cmpl\n");
1476 if (cancel_delayed_work(&io_req->timeout_work))
1477 kref_put(&io_req->refcount,
1491 static void bnx2fc_tgt_reset_cmpl(struct bnx2fc_cmd *io_req)
1493 struct bnx2fc_rport *tgt = io_req->tgt;
1498 BNX2FC_IO_DBG(io_req, "Entered bnx2fc_tgt_reset_cmpl\n");
1509 if (cancel_delayed_work(&io_req->timeout_work))
1510 kref_put(&io_req->refcount,
1522 void bnx2fc_process_tm_compl(struct bnx2fc_cmd *io_req,
1528 struct scsi_cmnd *sc_cmd = io_req->sc_cmd;
1534 BNX2FC_IO_DBG(io_req, "Entered process_tm_compl\n");
1536 if (!(test_bit(BNX2FC_FLAG_TM_TIMEOUT, &io_req->req_flags)))
1537 set_bit(BNX2FC_FLAG_TM_COMPL, &io_req->req_flags);
1546 tm_req = &(io_req->mp_req);
1561 bnx2fc_parse_fcp_rsp(io_req,
1564 if (io_req->fcp_rsp_code == 0) {
1567 bnx2fc_lun_reset_cmpl(io_req);
1569 bnx2fc_tgt_reset_cmpl(io_req);
1579 switch (io_req->fcp_status) {
1581 if (io_req->cdb_status == 0) {
1586 sc_cmd->result = (DID_OK << 16) | io_req->cdb_status;
1588 if (io_req->fcp_resid)
1589 scsi_set_resid(sc_cmd, io_req->fcp_resid);
1593 BNX2FC_IO_DBG(io_req, "process_tm_compl: fcp_status = %d\n",
1594 io_req->fcp_status);
1598 sc_cmd = io_req->sc_cmd;
1599 io_req->sc_cmd = NULL;
1601 /* check if the io_req exists in tgt's tmf_q */
1602 if (io_req->on_tmf_queue) {
1604 list_del_init(&io_req->link);
1605 io_req->on_tmf_queue = 0;
1615 kref_put(&io_req->refcount, bnx2fc_cmd_release);
1616 if (io_req->wait_for_abts_comp) {
1617 BNX2FC_IO_DBG(io_req, "tm_compl - wake up the waiter\n");
1618 complete(&io_req->abts_done);
1622 static int bnx2fc_split_bd(struct bnx2fc_cmd *io_req, u64 addr, int sg_len,
1625 struct fcoe_bd_ctx *bd = io_req->bd_tbl->bd_tbl;
1647 static int bnx2fc_map_sg(struct bnx2fc_cmd *io_req)
1649 struct bnx2fc_interface *interface = io_req->port->priv;
1651 struct scsi_cmnd *sc = io_req->sc_cmd;
1652 struct fcoe_bd_ctx *bd = io_req->bd_tbl->bd_tbl;
1673 sg_frags = bnx2fc_split_bd(io_req, addr, sg_len,
1689 io_req->xid);
1693 static int bnx2fc_build_bd_list_from_sg(struct bnx2fc_cmd *io_req)
1695 struct scsi_cmnd *sc = io_req->sc_cmd;
1696 struct fcoe_bd_ctx *bd = io_req->bd_tbl->bd_tbl;
1700 bd_count = bnx2fc_map_sg(io_req);
1708 io_req->bd_tbl->bd_valid = bd_count;
1716 bd_count, io_req->xid);
1723 static void bnx2fc_unmap_sg_list(struct bnx2fc_cmd *io_req)
1725 struct scsi_cmnd *sc = io_req->sc_cmd;
1726 struct bnx2fc_interface *interface = io_req->port->priv;
1733 if (io_req->bd_tbl->bd_valid && sc && scsi_sg_count(sc)) {
1736 io_req->bd_tbl->bd_valid = 0;
1740 void bnx2fc_build_fcp_cmnd(struct bnx2fc_cmd *io_req,
1743 struct scsi_cmnd *sc_cmd = io_req->sc_cmd;
1749 fcp_cmnd->fc_dl = htonl(io_req->data_xfer_len);
1754 fcp_cmnd->fc_tm_flags = io_req->mp_req.tm_flags;
1755 fcp_cmnd->fc_flags = io_req->io_req_flags;
1759 static void bnx2fc_parse_fcp_rsp(struct bnx2fc_cmd *io_req,
1763 struct scsi_cmnd *sc_cmd = io_req->sc_cmd;
1769 io_req->fcp_status = FC_GOOD;
1770 io_req->fcp_resid = 0;
1773 io_req->fcp_resid = fcp_rsp->fcp_resid;
1775 io_req->scsi_comp_flags = rsp_flags;
1776 CMD_SCSI_STATUS(sc_cmd) = io_req->cdb_status =
1800 io_req->fcp_rsp_len = fcp_rsp_len;
1801 io_req->fcp_sns_len = fcp_sns_len;
1814 io_req->fcp_rsp_code = rq_data[3];
1815 BNX2FC_IO_DBG(io_req, "fcp_rsp_code = %d\n",
1816 io_req->fcp_rsp_code);
1849 struct bnx2fc_cmd *io_req;
1888 io_req = bnx2fc_cmd_alloc(tgt);
1889 if (!io_req) {
1893 io_req->sc_cmd = sc_cmd;
1895 if (bnx2fc_post_io_req(tgt, io_req)) {
1896 printk(KERN_ERR PFX "Unable to post io_req\n");
1907 void bnx2fc_process_scsi_cmd_compl(struct bnx2fc_cmd *io_req,
1912 struct bnx2fc_rport *tgt = io_req->tgt;
1918 if (test_and_set_bit(BNX2FC_FLAG_IO_COMPL, &io_req->req_flags)) {
1920 BNX2FC_IO_DBG(io_req, "Timer context finished processing "
1923 &io_req->req_flags)) {
1924 BNX2FC_IO_DBG(io_req,
1926 bnx2fc_process_cleanup_compl(io_req, task, num_rq);
1932 if (cancel_delayed_work(&io_req->timeout_work))
1933 kref_put(&io_req->refcount,
1936 sc_cmd = io_req->sc_cmd;
1947 bnx2fc_parse_fcp_rsp(io_req, fcp_rsp, num_rq, rq_data);
1954 if (io_req->on_active_queue) {
1955 list_del_init(&io_req->link);
1956 io_req->on_active_queue = 0;
1958 list_add_tail(&io_req->link, &tgt->io_retire_queue);
1964 BNX2FC_IO_DBG(io_req, "xid not on active_cmd_queue\n");
1965 if (io_req->wait_for_abts_comp)
1967 &io_req->req_flags))
1968 complete(&io_req->abts_done);
1971 bnx2fc_unmap_sg_list(io_req);
1972 io_req->sc_cmd = NULL;
1974 switch (io_req->fcp_status) {
1976 if (io_req->cdb_status == 0) {
1981 BNX2FC_IO_DBG(io_req, "scsi_cmpl: cdb_status = %d"
1983 io_req->cdb_status, io_req->fcp_resid);
1984 sc_cmd->result = (DID_OK << 16) | io_req->cdb_status;
1986 if (io_req->cdb_status == SAM_STAT_TASK_SET_FULL ||
1987 io_req->cdb_status == SAM_STAT_BUSY) {
2013 if (io_req->fcp_resid)
2014 scsi_set_resid(sc_cmd, io_req->fcp_resid);
2018 io_req->fcp_status);
2023 kref_put(&io_req->refcount, bnx2fc_cmd_release);
2027 struct bnx2fc_cmd *io_req)
2031 struct scsi_cmnd *sc_cmd = io_req->sc_cmd;
2042 /* Initialize rest of io_req fields */
2043 io_req->cmd_type = BNX2FC_SCSI_CMD;
2044 io_req->port = port;
2045 io_req->tgt = tgt;
2046 io_req->data_xfer_len = scsi_bufflen(sc_cmd);
2047 sc_cmd->SCp.ptr = (char *)io_req;
2051 io_req->io_req_flags = BNX2FC_READ;
2053 stats->InputBytes += io_req->data_xfer_len;
2055 io_req->io_req_flags = BNX2FC_WRITE;
2057 stats->OutputBytes += io_req->data_xfer_len;
2059 io_req->io_req_flags = 0;
2064 xid = io_req->xid;
2067 if (bnx2fc_build_bd_list_from_sg(io_req)) {
2069 kref_put(&io_req->refcount, bnx2fc_cmd_release);
2079 bnx2fc_init_task(io_req, task);
2083 kref_put(&io_req->refcount, bnx2fc_cmd_release);
2089 kref_put(&io_req->refcount, bnx2fc_cmd_release);
2095 bnx2fc_cmd_timer_set(io_req, BNX2FC_IO_TIMEOUT);
2099 /* Enqueue the io_req to active_cmd_queue */
2101 io_req->on_active_queue = 1;
2102 /* move io_req from pending_queue to active_queue */
2103 list_add_tail(&io_req->link, &tgt->active_cmd_queue);