Lines Matching defs: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",
207 bnx2fc_priv(sc_cmd)->io_req = NULL;
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;
494 io_req = (struct bnx2fc_cmd *) listp;
495 xid = io_req->xid;
496 cmd_mgr->cmds[xid] = io_req;
501 INIT_LIST_HEAD(&io_req->link);
503 io_req->port = port;
504 io_req->cmd_mgr = cmd_mgr;
505 io_req->req_flags = 0;
507 /* Bind io_bdt for this io_req */
508 /* Have a static link between io_req and io_bdt_pool */
509 bd_tbl = io_req->bd_tbl = cmd_mgr->io_bdt_pool[xid];
510 bd_tbl->io_req = io_req;
512 /* Hold the io_req against deletion */
513 kref_init(&io_req->refcount);
514 return io_req;
519 struct bnx2fc_cmd *io_req = container_of(ref,
521 struct bnx2fc_cmd_mgr *cmd_mgr = io_req->cmd_mgr;
524 if (io_req->cmd_type == BNX2FC_SCSI_CMD)
525 index = io_req->xid % num_possible_cpus();
531 if (io_req->cmd_type != BNX2FC_SCSI_CMD)
532 bnx2fc_free_mp_resc(io_req);
533 cmd_mgr->cmds[io_req->xid] = NULL;
535 list_del_init(&io_req->link);
537 list_add(&io_req->link,
539 atomic_dec(&io_req->tgt->num_active_ios);
544 static void bnx2fc_free_mp_resc(struct bnx2fc_cmd *io_req)
546 struct bnx2fc_mp_req *mp_req = &(io_req->mp_req);
547 struct bnx2fc_interface *interface = io_req->port->priv;
579 int bnx2fc_init_mp_req(struct bnx2fc_cmd *io_req)
584 struct bnx2fc_interface *interface = io_req->port->priv;
589 mp_req = (struct bnx2fc_mp_req *)&(io_req->mp_req);
592 if (io_req->cmd_type != BNX2FC_ELS) {
594 io_req->data_xfer_len = mp_req->req_len;
596 mp_req->req_len = io_req->data_xfer_len;
603 bnx2fc_free_mp_resc(io_req);
612 bnx2fc_free_mp_resc(io_req);
625 bnx2fc_free_mp_resc(io_req);
633 bnx2fc_free_mp_resc(io_req);
666 struct bnx2fc_cmd *io_req;
706 io_req = bnx2fc_elstm_alloc(tgt, BNX2FC_TASK_MGMT_CMD);
707 if (!io_req) {
716 /* Initialize rest of io_req fields */
717 io_req->sc_cmd = NULL;
718 io_req->port = port;
719 io_req->tgt = tgt;
721 tm_req = (struct bnx2fc_mp_req *)&(io_req->mp_req);
723 rc = bnx2fc_init_mp_req(io_req);
727 kref_put(&io_req->refcount, bnx2fc_cmd_release);
733 io_req->io_req_flags = 0;
738 bnx2fc_build_fcp_cmnd(io_req, (struct fcp_cmnd *)tm_req->req_buf);
752 xid = io_req->xid;
762 bnx2fc_init_mp_task(io_req, task);
768 /* Enqueue the io_req to active_tm_queue */
769 io_req->on_tmf_queue = 1;
770 list_add_tail(&io_req->link, &tgt->active_tm_queue);
772 init_completion(&io_req->abts_done);
773 io_req->wait_for_abts_comp = 1;
779 rc = wait_for_completion_timeout(&io_req->abts_done,
783 io_req->wait_for_abts_comp = 0;
784 if (!(test_bit(BNX2FC_FLAG_TM_COMPL, &io_req->req_flags))) {
785 set_bit(BNX2FC_FLAG_TM_TIMEOUT, &io_req->req_flags);
786 if (io_req->on_tmf_queue) {
787 list_del_init(&io_req->link);
788 io_req->on_tmf_queue = 0;
790 io_req->wait_for_cleanup_comp = 1;
791 init_completion(&io_req->cleanup_done);
792 bnx2fc_initiate_cleanup(io_req);
794 rc = wait_for_completion_timeout(&io_req->cleanup_done,
797 io_req->wait_for_cleanup_comp = 0;
799 kref_put(&io_req->refcount, bnx2fc_cmd_release);
815 int bnx2fc_initiate_abts(struct bnx2fc_cmd *io_req)
818 struct bnx2fc_rport *tgt = io_req->tgt;
835 BNX2FC_IO_DBG(io_req, "Entered bnx2fc_initiate_abts\n");
837 port = io_req->port;
866 /* Initialize rest of io_req fields */
879 fc_hdr->fh_ox_id = htons(io_req->xid);
880 fc_hdr->fh_rx_id = htons(io_req->task->rxwr_txrd.var_ctx.rx_id);
890 BNX2FC_IO_DBG(abts_io_req, "ABTS io_req\n");
911 /* if (test_bit(BNX2FC_FLAG_ISSUE_ABTS, &io_req->req_flags))*/
912 bnx2fc_cmd_timer_set(io_req, 2 * r_a_tov);
959 /* Initialize rest of io_req fields */
975 cb_arg->io_req = seq_clnp_req;
992 int bnx2fc_initiate_cleanup(struct bnx2fc_cmd *io_req)
994 struct bnx2fc_rport *tgt = io_req->tgt;
1005 BNX2FC_IO_DBG(io_req, "Entered bnx2fc_initiate_cleanup\n");
1007 port = io_req->port;
1017 /* Initialize rest of io_req fields */
1032 orig_xid = io_req->xid;
1034 BNX2FC_IO_DBG(io_req, "CLEANUP io_req xid = 0x%x\n", xid);
1042 set_bit(BNX2FC_FLAG_ISSUE_CLEANUP_REQ, &io_req->req_flags);
1084 static int bnx2fc_abts_cleanup(struct bnx2fc_cmd *io_req)
1087 struct bnx2fc_rport *tgt = io_req->tgt;
1090 init_completion(&io_req->cleanup_done);
1091 io_req->wait_for_cleanup_comp = 1;
1092 bnx2fc_initiate_cleanup(io_req);
1100 time_left = wait_for_completion_timeout(&io_req->cleanup_done,
1103 BNX2FC_IO_DBG(io_req, "%s(): Wait for cleanup timed out.\n",
1110 kref_put(&io_req->refcount, bnx2fc_cmd_release);
1114 io_req->wait_for_cleanup_comp = 0;
1130 struct bnx2fc_cmd *io_req;
1151 io_req = bnx2fc_priv(sc_cmd)->io_req;
1152 if (!io_req) {
1154 printk(KERN_ERR PFX "eh_abort: io_req is NULL\n");
1158 BNX2FC_IO_DBG(io_req, "eh_abort - refcnt = %d\n",
1159 kref_read(&io_req->refcount));
1162 kref_get(&io_req->refcount);
1164 BUG_ON(tgt != io_req->tgt);
1166 /* Remove the io_req from the active_q. */
1170 * io_req is no longer in the active_q.
1173 printk(KERN_ERR PFX "eh_abort: io_req (xid = 0x%x) "
1174 "flush in progress\n", io_req->xid);
1175 kref_put(&io_req->refcount, bnx2fc_cmd_release);
1180 if (io_req->on_active_queue == 0) {
1181 printk(KERN_ERR PFX "eh_abort: io_req (xid = 0x%x) "
1182 "not on active_q\n", io_req->xid);
1198 list_del_init(&io_req->link);
1199 io_req->on_active_queue = 0;
1201 list_add_tail(&io_req->link, &tgt->io_retire_queue);
1203 init_completion(&io_req->abts_done);
1204 init_completion(&io_req->cleanup_done);
1206 if (test_and_set_bit(BNX2FC_FLAG_ISSUE_ABTS, &io_req->req_flags)) {
1207 printk(KERN_ERR PFX "eh_abort: io_req (xid = 0x%x) "
1208 "already in abts processing\n", io_req->xid);
1209 if (cancel_delayed_work(&io_req->timeout_work))
1210 kref_put(&io_req->refcount,
1217 bnx2fc_abts_cleanup(io_req);
1223 set_bit(BNX2FC_FLAG_IO_CLEANUP, &io_req->req_flags);
1228 /* Cancel the current timer running on this io_req */
1229 if (cancel_delayed_work(&io_req->timeout_work))
1230 kref_put(&io_req->refcount,
1232 set_bit(BNX2FC_FLAG_EH_ABORT, &io_req->req_flags);
1233 io_req->wait_for_abts_comp = 1;
1234 rc = bnx2fc_initiate_abts(io_req);
1236 io_req->wait_for_cleanup_comp = 1;
1237 bnx2fc_initiate_cleanup(io_req);
1239 wait_for_completion(&io_req->cleanup_done);
1241 io_req->wait_for_cleanup_comp = 0;
1247 time_left = wait_for_completion_timeout(&io_req->abts_done,
1250 BNX2FC_IO_DBG(io_req,
1254 io_req->wait_for_abts_comp = 0;
1255 if (test_bit(BNX2FC_FLAG_IO_COMPL, &io_req->req_flags)) {
1256 BNX2FC_IO_DBG(io_req, "IO completed in a different context\n");
1259 &io_req->req_flags))) {
1262 io_req->xid);
1267 rc = bnx2fc_abts_cleanup(io_req);
1275 BNX2FC_IO_DBG(io_req, "abort succeeded\n");
1277 bnx2fc_scsi_done(io_req, DID_ABORT);
1278 kref_put(&io_req->refcount, bnx2fc_cmd_release);
1282 kref_put(&io_req->refcount, bnx2fc_cmd_release);
1322 void bnx2fc_process_cleanup_compl(struct bnx2fc_cmd *io_req,
1326 BNX2FC_IO_DBG(io_req, "Entered process_cleanup_compl "
1328 kref_read(&io_req->refcount), io_req->cmd_type);
1334 &io_req->req_flags))
1341 if (test_bit(BNX2FC_FLAG_ISSUE_ABTS, &io_req->req_flags) &&
1342 !test_bit(BNX2FC_FLAG_ABTS_DONE, &io_req->req_flags)) {
1343 set_bit(BNX2FC_FLAG_ABTS_DONE, &io_req->req_flags);
1344 if (io_req->wait_for_abts_comp)
1345 complete(&io_req->abts_done);
1348 bnx2fc_scsi_done(io_req, DID_ERROR);
1349 kref_put(&io_req->refcount, bnx2fc_cmd_release);
1350 if (io_req->wait_for_cleanup_comp)
1351 complete(&io_req->cleanup_done);
1354 void bnx2fc_process_abts_compl(struct bnx2fc_cmd *io_req,
1361 struct bnx2fc_rport *tgt = io_req->tgt;
1363 BNX2FC_IO_DBG(io_req, "Entered process_abts_compl xid = 0x%x"
1365 io_req->xid,
1366 kref_read(&io_req->refcount), io_req->cmd_type);
1369 &io_req->req_flags)) {
1370 BNX2FC_IO_DBG(io_req, "Timer context finished processing"
1379 if (test_bit(BNX2FC_FLAG_ISSUE_CLEANUP_REQ, &io_req->req_flags)) {
1380 clear_bit(BNX2FC_FLAG_ISSUE_CLEANUP_REQ, &io_req->req_flags);
1381 if (io_req->wait_for_cleanup_comp)
1382 complete(&io_req->cleanup_done);
1387 &io_req->req_flags))
1396 if (test_bit(BNX2FC_FLAG_ISSUE_ABTS, &io_req->req_flags))
1397 if (cancel_delayed_work(&io_req->timeout_work))
1398 kref_put(&io_req->refcount,
1409 BNX2FC_IO_DBG(io_req, "ABTS response - ACC Send RRQ\n");
1414 BNX2FC_IO_DBG(io_req, "ABTS response - RJT\n");
1422 BNX2FC_IO_DBG(io_req, "Issue RRQ after R_A_TOV\n");
1423 set_bit(BNX2FC_FLAG_ISSUE_RRQ, &io_req->req_flags);
1425 set_bit(BNX2FC_FLAG_RETIRE_OXID, &io_req->req_flags);
1426 bnx2fc_cmd_timer_set(io_req, r_a_tov);
1429 if (io_req->wait_for_abts_comp) {
1431 &io_req->req_flags))
1432 complete(&io_req->abts_done);
1443 if (io_req->on_active_queue) {
1444 list_del_init(&io_req->link);
1445 io_req->on_active_queue = 0;
1447 list_add_tail(&io_req->link, &tgt->io_retire_queue);
1449 bnx2fc_scsi_done(io_req, DID_ERROR);
1450 kref_put(&io_req->refcount, bnx2fc_cmd_release);
1454 static void bnx2fc_lun_reset_cmpl(struct bnx2fc_cmd *io_req)
1456 struct bnx2fc_rport *tgt = io_req->tgt;
1458 struct bnx2fc_mp_req *tm_req = &io_req->mp_req;
1463 BNX2FC_IO_DBG(io_req, "Entered bnx2fc_lun_reset_cmpl\n");
1478 if (cancel_delayed_work(&io_req->timeout_work))
1479 kref_put(&io_req->refcount,
1493 static void bnx2fc_tgt_reset_cmpl(struct bnx2fc_cmd *io_req)
1495 struct bnx2fc_rport *tgt = io_req->tgt;
1500 BNX2FC_IO_DBG(io_req, "Entered bnx2fc_tgt_reset_cmpl\n");
1511 if (cancel_delayed_work(&io_req->timeout_work))
1512 kref_put(&io_req->refcount,
1524 void bnx2fc_process_tm_compl(struct bnx2fc_cmd *io_req,
1530 struct scsi_cmnd *sc_cmd = io_req->sc_cmd;
1536 BNX2FC_IO_DBG(io_req, "Entered process_tm_compl\n");
1538 if (!(test_bit(BNX2FC_FLAG_TM_TIMEOUT, &io_req->req_flags)))
1539 set_bit(BNX2FC_FLAG_TM_COMPL, &io_req->req_flags);
1548 tm_req = &(io_req->mp_req);
1563 bnx2fc_parse_fcp_rsp(io_req,
1566 if (io_req->fcp_rsp_code == 0) {
1569 bnx2fc_lun_reset_cmpl(io_req);
1571 bnx2fc_tgt_reset_cmpl(io_req);
1578 if (!bnx2fc_priv(sc_cmd)->io_req) {
1579 printk(KERN_ERR PFX "tm_compl: io_req is NULL\n");
1582 switch (io_req->fcp_status) {
1584 if (io_req->cdb_status == 0) {
1589 sc_cmd->result = (DID_OK << 16) | io_req->cdb_status;
1591 if (io_req->fcp_resid)
1592 scsi_set_resid(sc_cmd, io_req->fcp_resid);
1596 BNX2FC_IO_DBG(io_req, "process_tm_compl: fcp_status = %d\n",
1597 io_req->fcp_status);
1601 sc_cmd = io_req->sc_cmd;
1602 io_req->sc_cmd = NULL;
1604 bnx2fc_priv(sc_cmd)->io_req = NULL;
1608 /* check if the io_req exists in tgt's tmf_q */
1609 if (io_req->on_tmf_queue) {
1611 list_del_init(&io_req->link);
1612 io_req->on_tmf_queue = 0;
1619 kref_put(&io_req->refcount, bnx2fc_cmd_release);
1620 if (io_req->wait_for_abts_comp) {
1621 BNX2FC_IO_DBG(io_req, "tm_compl - wake up the waiter\n");
1622 complete(&io_req->abts_done);
1626 static int bnx2fc_split_bd(struct bnx2fc_cmd *io_req, u64 addr, int sg_len,
1629 struct fcoe_bd_ctx *bd = io_req->bd_tbl->bd_tbl;
1651 static int bnx2fc_map_sg(struct bnx2fc_cmd *io_req)
1653 struct bnx2fc_interface *interface = io_req->port->priv;
1655 struct scsi_cmnd *sc = io_req->sc_cmd;
1656 struct fcoe_bd_ctx *bd = io_req->bd_tbl->bd_tbl;
1677 sg_frags = bnx2fc_split_bd(io_req, addr, sg_len,
1693 io_req->xid);
1697 static int bnx2fc_build_bd_list_from_sg(struct bnx2fc_cmd *io_req)
1699 struct scsi_cmnd *sc = io_req->sc_cmd;
1700 struct fcoe_bd_ctx *bd = io_req->bd_tbl->bd_tbl;
1704 bd_count = bnx2fc_map_sg(io_req);
1712 io_req->bd_tbl->bd_valid = bd_count;
1720 bd_count, io_req->xid);
1727 static void bnx2fc_unmap_sg_list(struct bnx2fc_cmd *io_req)
1729 struct scsi_cmnd *sc = io_req->sc_cmd;
1730 struct bnx2fc_interface *interface = io_req->port->priv;
1737 if (io_req->bd_tbl->bd_valid && sc && scsi_sg_count(sc)) {
1740 io_req->bd_tbl->bd_valid = 0;
1744 void bnx2fc_build_fcp_cmnd(struct bnx2fc_cmd *io_req,
1749 fcp_cmnd->fc_dl = htonl(io_req->data_xfer_len);
1752 fcp_cmnd->fc_tm_flags = io_req->mp_req.tm_flags;
1753 fcp_cmnd->fc_flags = io_req->io_req_flags;
1757 static void bnx2fc_parse_fcp_rsp(struct bnx2fc_cmd *io_req,
1761 struct scsi_cmnd *sc_cmd = io_req->sc_cmd;
1767 io_req->fcp_status = FC_GOOD;
1768 io_req->fcp_resid = 0;
1771 io_req->fcp_resid = fcp_rsp->fcp_resid;
1773 io_req->scsi_comp_flags = rsp_flags;
1774 io_req->cdb_status = fcp_rsp->scsi_status_code;
1797 io_req->fcp_rsp_len = fcp_rsp_len;
1798 io_req->fcp_sns_len = fcp_sns_len;
1811 io_req->fcp_rsp_code = rq_data[3];
1812 BNX2FC_IO_DBG(io_req, "fcp_rsp_code = %d\n",
1813 io_req->fcp_rsp_code);
1846 struct bnx2fc_cmd *io_req;
1885 io_req = bnx2fc_cmd_alloc(tgt);
1886 if (!io_req) {
1890 io_req->sc_cmd = sc_cmd;
1892 if (bnx2fc_post_io_req(tgt, io_req)) {
1893 printk(KERN_ERR PFX "Unable to post io_req\n");
1904 void bnx2fc_process_scsi_cmd_compl(struct bnx2fc_cmd *io_req,
1909 struct bnx2fc_rport *tgt = io_req->tgt;
1915 if (test_and_set_bit(BNX2FC_FLAG_IO_COMPL, &io_req->req_flags)) {
1917 BNX2FC_IO_DBG(io_req, "Timer context finished processing "
1920 &io_req->req_flags)) {
1921 BNX2FC_IO_DBG(io_req,
1923 bnx2fc_process_cleanup_compl(io_req, task, num_rq);
1929 if (cancel_delayed_work(&io_req->timeout_work))
1930 kref_put(&io_req->refcount,
1933 sc_cmd = io_req->sc_cmd;
1944 bnx2fc_parse_fcp_rsp(io_req, fcp_rsp, num_rq, rq_data);
1946 if (!bnx2fc_priv(sc_cmd)->io_req) {
1947 printk(KERN_ERR PFX "io_req is NULL\n");
1951 if (io_req->on_active_queue) {
1952 list_del_init(&io_req->link);
1953 io_req->on_active_queue = 0;
1955 list_add_tail(&io_req->link, &tgt->io_retire_queue);
1961 BNX2FC_IO_DBG(io_req, "xid not on active_cmd_queue\n");
1962 if (io_req->wait_for_abts_comp)
1964 &io_req->req_flags))
1965 complete(&io_req->abts_done);
1968 bnx2fc_unmap_sg_list(io_req);
1969 io_req->sc_cmd = NULL;
1971 switch (io_req->fcp_status) {
1973 if (io_req->cdb_status == 0) {
1978 BNX2FC_IO_DBG(io_req, "scsi_cmpl: cdb_status = %d"
1980 io_req->cdb_status, io_req->fcp_resid);
1981 sc_cmd->result = (DID_OK << 16) | io_req->cdb_status;
1983 if (io_req->cdb_status == SAM_STAT_TASK_SET_FULL ||
1984 io_req->cdb_status == SAM_STAT_BUSY) {
2010 if (io_req->fcp_resid)
2011 scsi_set_resid(sc_cmd, io_req->fcp_resid);
2015 io_req->fcp_status);
2018 bnx2fc_priv(sc_cmd)->io_req = NULL;
2020 kref_put(&io_req->refcount, bnx2fc_cmd_release);
2024 struct bnx2fc_cmd *io_req)
2028 struct scsi_cmnd *sc_cmd = io_req->sc_cmd;
2038 /* Initialize rest of io_req fields */
2039 io_req->cmd_type = BNX2FC_SCSI_CMD;
2040 io_req->port = port;
2041 io_req->tgt = tgt;
2042 io_req->data_xfer_len = scsi_bufflen(sc_cmd);
2043 bnx2fc_priv(sc_cmd)->io_req = io_req;
2046 io_req->io_req_flags = BNX2FC_READ;
2048 this_cpu_add(lport->stats->InputBytes, io_req->data_xfer_len);
2050 io_req->io_req_flags = BNX2FC_WRITE;
2052 this_cpu_add(lport->stats->OutputBytes, io_req->data_xfer_len);
2054 io_req->io_req_flags = 0;
2058 xid = io_req->xid;
2061 if (bnx2fc_build_bd_list_from_sg(io_req)) {
2063 kref_put(&io_req->refcount, bnx2fc_cmd_release);
2073 bnx2fc_init_task(io_req, task);
2077 kref_put(&io_req->refcount, bnx2fc_cmd_release);
2083 kref_put(&io_req->refcount, bnx2fc_cmd_release);
2089 bnx2fc_cmd_timer_set(io_req, BNX2FC_IO_TIMEOUT);
2093 /* Enqueue the io_req to active_cmd_queue */
2095 io_req->on_active_queue = 1;
2096 /* move io_req from pending_queue to active_queue */
2097 list_add_tail(&io_req->link, &tgt->active_cmd_queue);