Lines Matching refs:io_req
18 static int bnx2fc_split_bd(struct bnx2fc_cmd *io_req, u64 addr, int sg_len,
20 static int bnx2fc_map_sg(struct bnx2fc_cmd *io_req);
21 static int bnx2fc_build_bd_list_from_sg(struct bnx2fc_cmd *io_req);
22 static void bnx2fc_unmap_sg_list(struct bnx2fc_cmd *io_req);
23 static void bnx2fc_free_mp_resc(struct bnx2fc_cmd *io_req);
24 static void bnx2fc_parse_fcp_rsp(struct bnx2fc_cmd *io_req,
28 void bnx2fc_cmd_timer_set(struct bnx2fc_cmd *io_req, in bnx2fc_cmd_timer_set() argument
31 struct bnx2fc_interface *interface = io_req->port->priv; in bnx2fc_cmd_timer_set()
34 &io_req->timeout_work, in bnx2fc_cmd_timer_set()
36 kref_get(&io_req->refcount); in bnx2fc_cmd_timer_set()
41 struct bnx2fc_cmd *io_req = container_of(work, struct bnx2fc_cmd, in bnx2fc_cmd_timeout() local
45 u8 cmd_type = io_req->cmd_type; in bnx2fc_cmd_timeout()
46 struct bnx2fc_rport *tgt = io_req->tgt; in bnx2fc_cmd_timeout()
50 BNX2FC_IO_DBG(io_req, "cmd_timeout, cmd_type = %d," in bnx2fc_cmd_timeout()
51 "req_flags = %lx\n", cmd_type, io_req->req_flags); in bnx2fc_cmd_timeout()
54 if (test_and_clear_bit(BNX2FC_FLAG_ISSUE_RRQ, &io_req->req_flags)) { in bnx2fc_cmd_timeout()
55 clear_bit(BNX2FC_FLAG_RETIRE_OXID, &io_req->req_flags); in bnx2fc_cmd_timeout()
61 bnx2fc_send_rrq(io_req); in bnx2fc_cmd_timeout()
64 if (test_and_clear_bit(BNX2FC_FLAG_RETIRE_OXID, &io_req->req_flags)) { in bnx2fc_cmd_timeout()
65 BNX2FC_IO_DBG(io_req, "IO ready for reuse now\n"); in bnx2fc_cmd_timeout()
72 &io_req->req_flags)) { in bnx2fc_cmd_timeout()
74 BNX2FC_IO_DBG(io_req, "eh_abort timed out\n"); in bnx2fc_cmd_timeout()
75 complete(&io_req->tm_done); in bnx2fc_cmd_timeout()
77 &io_req->req_flags)) { in bnx2fc_cmd_timeout()
79 BNX2FC_IO_DBG(io_req, "ABTS timed out refcnt = %d\n", in bnx2fc_cmd_timeout()
80 io_req->refcount.refcount.counter); in bnx2fc_cmd_timeout()
82 &io_req->req_flags))) { in bnx2fc_cmd_timeout()
84 lport = io_req->port->lport; in bnx2fc_cmd_timeout()
85 rdata = io_req->tgt->rdata; in bnx2fc_cmd_timeout()
89 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_cmd_timeout()
94 BNX2FC_IO_DBG(io_req, "Explicit " in bnx2fc_cmd_timeout()
106 BNX2FC_IO_DBG(io_req, "IO timed out. issue ABTS\n"); in bnx2fc_cmd_timeout()
108 &io_req->req_flags)) { in bnx2fc_cmd_timeout()
109 BNX2FC_IO_DBG(io_req, "IO completed before " in bnx2fc_cmd_timeout()
115 &io_req->req_flags)) { in bnx2fc_cmd_timeout()
116 rc = bnx2fc_initiate_abts(io_req); in bnx2fc_cmd_timeout()
123 lport = io_req->port->lport; in bnx2fc_cmd_timeout()
124 rdata = io_req->tgt->rdata; in bnx2fc_cmd_timeout()
128 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_cmd_timeout()
132 BNX2FC_IO_DBG(io_req, "Explicit " in bnx2fc_cmd_timeout()
143 BNX2FC_IO_DBG(io_req, "IO already in " in bnx2fc_cmd_timeout()
150 if (test_bit(BNX2FC_FLAG_ISSUE_ABTS, &io_req->req_flags)) { in bnx2fc_cmd_timeout()
151 BNX2FC_IO_DBG(io_req, "ABTS for ELS timed out\n"); in bnx2fc_cmd_timeout()
154 &io_req->req_flags)) { in bnx2fc_cmd_timeout()
155 lport = io_req->port->lport; in bnx2fc_cmd_timeout()
156 rdata = io_req->tgt->rdata; in bnx2fc_cmd_timeout()
160 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_cmd_timeout()
165 BNX2FC_IO_DBG(io_req, "Explicitly logo" in bnx2fc_cmd_timeout()
180 BNX2FC_IO_DBG(io_req, "ELS timed out\n"); in bnx2fc_cmd_timeout()
182 &io_req->req_flags)) in bnx2fc_cmd_timeout()
186 set_bit(BNX2FC_FLAG_ELS_TIMEOUT, &io_req->req_flags); in bnx2fc_cmd_timeout()
188 if ((io_req->cb_func) && (io_req->cb_arg)) { in bnx2fc_cmd_timeout()
189 io_req->cb_func(io_req->cb_arg); in bnx2fc_cmd_timeout()
190 io_req->cb_arg = NULL; in bnx2fc_cmd_timeout()
202 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_cmd_timeout()
206 static void bnx2fc_scsi_done(struct bnx2fc_cmd *io_req, int err_code) in bnx2fc_scsi_done() argument
209 struct scsi_cmnd *sc_cmd = io_req->sc_cmd; in bnx2fc_scsi_done()
216 if (io_req->cmd_type != BNX2FC_SCSI_CMD) in bnx2fc_scsi_done()
219 BNX2FC_IO_DBG(io_req, "scsi_done. err_code = 0x%x\n", err_code); in bnx2fc_scsi_done()
220 if (test_bit(BNX2FC_FLAG_CMD_LOST, &io_req->req_flags)) { in bnx2fc_scsi_done()
225 bnx2fc_unmap_sg_list(io_req); in bnx2fc_scsi_done()
226 io_req->sc_cmd = NULL; in bnx2fc_scsi_done()
230 io_req->xid); in bnx2fc_scsi_done()
235 BNX2FC_IO_DBG(io_req, "sc=%p, result=0x%x, retries=%d, allowed=%d\n", in bnx2fc_scsi_done()
247 struct bnx2fc_cmd *io_req; in bnx2fc_cmd_mgr_alloc() local
307 io_req = kzalloc(sizeof(*io_req), GFP_KERNEL); in bnx2fc_cmd_mgr_alloc()
309 if (!io_req) { in bnx2fc_cmd_mgr_alloc()
314 INIT_LIST_HEAD(&io_req->link); in bnx2fc_cmd_mgr_alloc()
315 INIT_DELAYED_WORK(&io_req->timeout_work, bnx2fc_cmd_timeout); in bnx2fc_cmd_mgr_alloc()
317 io_req->xid = xid++; in bnx2fc_cmd_mgr_alloc()
319 list_add_tail(&io_req->link, in bnx2fc_cmd_mgr_alloc()
320 &cmgr->free_list[io_req->xid % in bnx2fc_cmd_mgr_alloc()
323 list_add_tail(&io_req->link, in bnx2fc_cmd_mgr_alloc()
325 io_req++; in bnx2fc_cmd_mgr_alloc()
412 struct bnx2fc_cmd *tmp, *io_req; in bnx2fc_cmd_mgr_free() local
414 list_for_each_entry_safe(io_req, tmp, in bnx2fc_cmd_mgr_free()
416 list_del(&io_req->link); in bnx2fc_cmd_mgr_free()
417 kfree(io_req); in bnx2fc_cmd_mgr_free()
431 struct bnx2fc_cmd *io_req; in bnx2fc_elstm_alloc() local
472 io_req = (struct bnx2fc_cmd *) listp; in bnx2fc_elstm_alloc()
473 xid = io_req->xid; in bnx2fc_elstm_alloc()
474 cmd_mgr->cmds[xid] = io_req; in bnx2fc_elstm_alloc()
479 INIT_LIST_HEAD(&io_req->link); in bnx2fc_elstm_alloc()
481 io_req->port = port; in bnx2fc_elstm_alloc()
482 io_req->cmd_mgr = cmd_mgr; in bnx2fc_elstm_alloc()
483 io_req->req_flags = 0; in bnx2fc_elstm_alloc()
484 io_req->cmd_type = type; in bnx2fc_elstm_alloc()
488 bd_tbl = io_req->bd_tbl = cmd_mgr->io_bdt_pool[xid]; in bnx2fc_elstm_alloc()
489 bd_tbl->io_req = io_req; in bnx2fc_elstm_alloc()
492 kref_init(&io_req->refcount); in bnx2fc_elstm_alloc()
493 return io_req; in bnx2fc_elstm_alloc()
501 struct bnx2fc_cmd *io_req; in bnx2fc_cmd_alloc() local
527 io_req = (struct bnx2fc_cmd *) listp; in bnx2fc_cmd_alloc()
528 xid = io_req->xid; in bnx2fc_cmd_alloc()
529 cmd_mgr->cmds[xid] = io_req; in bnx2fc_cmd_alloc()
535 INIT_LIST_HEAD(&io_req->link); in bnx2fc_cmd_alloc()
537 io_req->port = port; in bnx2fc_cmd_alloc()
538 io_req->cmd_mgr = cmd_mgr; in bnx2fc_cmd_alloc()
539 io_req->req_flags = 0; in bnx2fc_cmd_alloc()
543 bd_tbl = io_req->bd_tbl = cmd_mgr->io_bdt_pool[xid]; in bnx2fc_cmd_alloc()
544 bd_tbl->io_req = io_req; in bnx2fc_cmd_alloc()
547 kref_init(&io_req->refcount); in bnx2fc_cmd_alloc()
548 return io_req; in bnx2fc_cmd_alloc()
553 struct bnx2fc_cmd *io_req = container_of(ref, in bnx2fc_cmd_release() local
555 struct bnx2fc_cmd_mgr *cmd_mgr = io_req->cmd_mgr; in bnx2fc_cmd_release()
558 if (io_req->cmd_type == BNX2FC_SCSI_CMD) in bnx2fc_cmd_release()
559 index = io_req->xid % num_possible_cpus(); in bnx2fc_cmd_release()
565 if (io_req->cmd_type != BNX2FC_SCSI_CMD) in bnx2fc_cmd_release()
566 bnx2fc_free_mp_resc(io_req); in bnx2fc_cmd_release()
567 cmd_mgr->cmds[io_req->xid] = NULL; in bnx2fc_cmd_release()
569 list_del_init(&io_req->link); in bnx2fc_cmd_release()
571 list_add(&io_req->link, in bnx2fc_cmd_release()
573 atomic_dec(&io_req->tgt->num_active_ios); in bnx2fc_cmd_release()
578 static void bnx2fc_free_mp_resc(struct bnx2fc_cmd *io_req) in bnx2fc_free_mp_resc() argument
580 struct bnx2fc_mp_req *mp_req = &(io_req->mp_req); in bnx2fc_free_mp_resc()
581 struct bnx2fc_interface *interface = io_req->port->priv; in bnx2fc_free_mp_resc()
613 int bnx2fc_init_mp_req(struct bnx2fc_cmd *io_req) in bnx2fc_init_mp_req() argument
618 struct bnx2fc_interface *interface = io_req->port->priv; in bnx2fc_init_mp_req()
623 mp_req = (struct bnx2fc_mp_req *)&(io_req->mp_req); in bnx2fc_init_mp_req()
627 io_req->data_xfer_len = mp_req->req_len; in bnx2fc_init_mp_req()
633 bnx2fc_free_mp_resc(io_req); in bnx2fc_init_mp_req()
642 bnx2fc_free_mp_resc(io_req); in bnx2fc_init_mp_req()
655 bnx2fc_free_mp_resc(io_req); in bnx2fc_init_mp_req()
663 bnx2fc_free_mp_resc(io_req); in bnx2fc_init_mp_req()
697 struct bnx2fc_cmd *io_req; in bnx2fc_initiate_tmf() local
740 io_req = bnx2fc_elstm_alloc(tgt, BNX2FC_TASK_MGMT_CMD); in bnx2fc_initiate_tmf()
741 if (!io_req) { in bnx2fc_initiate_tmf()
751 io_req->sc_cmd = sc_cmd; in bnx2fc_initiate_tmf()
752 io_req->port = port; in bnx2fc_initiate_tmf()
753 io_req->tgt = tgt; in bnx2fc_initiate_tmf()
755 tm_req = (struct bnx2fc_mp_req *)&(io_req->mp_req); in bnx2fc_initiate_tmf()
757 rc = bnx2fc_init_mp_req(io_req); in bnx2fc_initiate_tmf()
761 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_initiate_tmf()
767 io_req->io_req_flags = 0; in bnx2fc_initiate_tmf()
771 bnx2fc_build_fcp_cmnd(io_req, (struct fcp_cmnd *)tm_req->req_buf); in bnx2fc_initiate_tmf()
784 xid = io_req->xid; in bnx2fc_initiate_tmf()
794 bnx2fc_init_mp_task(io_req, task); in bnx2fc_initiate_tmf()
796 sc_cmd->SCp.ptr = (char *)io_req; in bnx2fc_initiate_tmf()
803 io_req->on_tmf_queue = 1; in bnx2fc_initiate_tmf()
804 list_add_tail(&io_req->link, &tgt->active_tm_queue); in bnx2fc_initiate_tmf()
806 init_completion(&io_req->tm_done); in bnx2fc_initiate_tmf()
807 io_req->wait_for_comp = 1; in bnx2fc_initiate_tmf()
813 rc = wait_for_completion_timeout(&io_req->tm_done, in bnx2fc_initiate_tmf()
817 io_req->wait_for_comp = 0; in bnx2fc_initiate_tmf()
818 if (!(test_bit(BNX2FC_FLAG_TM_COMPL, &io_req->req_flags))) { in bnx2fc_initiate_tmf()
819 set_bit(BNX2FC_FLAG_TM_TIMEOUT, &io_req->req_flags); in bnx2fc_initiate_tmf()
820 if (io_req->on_tmf_queue) { in bnx2fc_initiate_tmf()
821 list_del_init(&io_req->link); in bnx2fc_initiate_tmf()
822 io_req->on_tmf_queue = 0; in bnx2fc_initiate_tmf()
824 io_req->wait_for_comp = 1; in bnx2fc_initiate_tmf()
825 bnx2fc_initiate_cleanup(io_req); in bnx2fc_initiate_tmf()
827 rc = wait_for_completion_timeout(&io_req->tm_done, in bnx2fc_initiate_tmf()
830 io_req->wait_for_comp = 0; in bnx2fc_initiate_tmf()
832 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_initiate_tmf()
848 int bnx2fc_initiate_abts(struct bnx2fc_cmd *io_req) in bnx2fc_initiate_abts() argument
851 struct bnx2fc_rport *tgt = io_req->tgt; in bnx2fc_initiate_abts()
868 BNX2FC_IO_DBG(io_req, "Entered bnx2fc_initiate_abts\n"); in bnx2fc_initiate_abts()
870 port = io_req->port; in bnx2fc_initiate_abts()
912 fc_hdr->fh_ox_id = htons(io_req->xid); in bnx2fc_initiate_abts()
913 fc_hdr->fh_rx_id = htons(io_req->task->rxwr_txrd.var_ctx.rx_id); in bnx2fc_initiate_abts()
945 bnx2fc_cmd_timer_set(io_req, 2 * r_a_tov); in bnx2fc_initiate_abts()
1010 cb_arg->io_req = seq_clnp_req; in bnx2fc_initiate_seq_cleanup()
1027 int bnx2fc_initiate_cleanup(struct bnx2fc_cmd *io_req) in bnx2fc_initiate_cleanup() argument
1030 struct bnx2fc_rport *tgt = io_req->tgt; in bnx2fc_initiate_cleanup()
1041 BNX2FC_IO_DBG(io_req, "Entered bnx2fc_initiate_cleanup\n"); in bnx2fc_initiate_cleanup()
1043 port = io_req->port; in bnx2fc_initiate_cleanup()
1069 orig_xid = io_req->xid; in bnx2fc_initiate_cleanup()
1071 BNX2FC_IO_DBG(io_req, "CLEANUP io_req xid = 0x%x\n", xid); in bnx2fc_initiate_cleanup()
1111 int bnx2fc_expl_logo(struct fc_lport *lport, struct bnx2fc_cmd *io_req) in bnx2fc_expl_logo() argument
1113 struct bnx2fc_rport *tgt = io_req->tgt; in bnx2fc_expl_logo()
1119 BNX2FC_IO_DBG(io_req, "Expl logo - tgt flags = 0x%lx\n", in bnx2fc_expl_logo()
1123 io_req->wait_for_comp = 1; in bnx2fc_expl_logo()
1124 bnx2fc_initiate_cleanup(io_req); in bnx2fc_expl_logo()
1128 wait_for_completion(&io_req->tm_done); in bnx2fc_expl_logo()
1130 io_req->wait_for_comp = 0; in bnx2fc_expl_logo()
1135 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_expl_logo()
1165 struct bnx2fc_cmd *io_req; in bnx2fc_eh_abort() local
1186 io_req = (struct bnx2fc_cmd *)sc_cmd->SCp.ptr; in bnx2fc_eh_abort()
1187 if (!io_req) { in bnx2fc_eh_abort()
1193 BNX2FC_IO_DBG(io_req, "eh_abort - refcnt = %d\n", in bnx2fc_eh_abort()
1194 io_req->refcount.refcount.counter); in bnx2fc_eh_abort()
1197 kref_get(&io_req->refcount); in bnx2fc_eh_abort()
1199 BUG_ON(tgt != io_req->tgt); in bnx2fc_eh_abort()
1209 "flush in progress\n", io_req->xid); in bnx2fc_eh_abort()
1210 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_eh_abort()
1215 if (io_req->on_active_queue == 0) { in bnx2fc_eh_abort()
1217 "not on active_q\n", io_req->xid); in bnx2fc_eh_abort()
1224 bnx2fc_scsi_done(io_req, DID_ABORT); in bnx2fc_eh_abort()
1226 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_eh_abort()
1238 list_del_init(&io_req->link); in bnx2fc_eh_abort()
1239 io_req->on_active_queue = 0; in bnx2fc_eh_abort()
1241 list_add_tail(&io_req->link, &tgt->io_retire_queue); in bnx2fc_eh_abort()
1243 init_completion(&io_req->tm_done); in bnx2fc_eh_abort()
1245 if (test_and_set_bit(BNX2FC_FLAG_ISSUE_ABTS, &io_req->req_flags)) { in bnx2fc_eh_abort()
1247 "already in abts processing\n", io_req->xid); in bnx2fc_eh_abort()
1248 if (cancel_delayed_work(&io_req->timeout_work)) in bnx2fc_eh_abort()
1249 kref_put(&io_req->refcount, in bnx2fc_eh_abort()
1251 rc = bnx2fc_expl_logo(lport, io_req); in bnx2fc_eh_abort()
1257 set_bit(BNX2FC_FLAG_IO_CLEANUP, &io_req->req_flags); in bnx2fc_eh_abort()
1262 if (cancel_delayed_work(&io_req->timeout_work)) in bnx2fc_eh_abort()
1263 kref_put(&io_req->refcount, in bnx2fc_eh_abort()
1265 set_bit(BNX2FC_FLAG_EH_ABORT, &io_req->req_flags); in bnx2fc_eh_abort()
1266 io_req->wait_for_comp = 1; in bnx2fc_eh_abort()
1267 rc = bnx2fc_initiate_abts(io_req); in bnx2fc_eh_abort()
1269 bnx2fc_initiate_cleanup(io_req); in bnx2fc_eh_abort()
1271 wait_for_completion(&io_req->tm_done); in bnx2fc_eh_abort()
1273 io_req->wait_for_comp = 0; in bnx2fc_eh_abort()
1278 wait_for_completion(&io_req->tm_done); in bnx2fc_eh_abort()
1281 io_req->wait_for_comp = 0; in bnx2fc_eh_abort()
1282 if (test_bit(BNX2FC_FLAG_IO_COMPL, &io_req->req_flags)) { in bnx2fc_eh_abort()
1283 BNX2FC_IO_DBG(io_req, "IO completed in a different context\n"); in bnx2fc_eh_abort()
1286 &io_req->req_flags))) { in bnx2fc_eh_abort()
1289 io_req->xid); in bnx2fc_eh_abort()
1290 rc = bnx2fc_expl_logo(lport, io_req); in bnx2fc_eh_abort()
1298 BNX2FC_IO_DBG(io_req, "abort succeeded\n"); in bnx2fc_eh_abort()
1300 bnx2fc_scsi_done(io_req, DID_ABORT); in bnx2fc_eh_abort()
1301 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_eh_abort()
1305 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_eh_abort()
1346 void bnx2fc_process_cleanup_compl(struct bnx2fc_cmd *io_req, in bnx2fc_process_cleanup_compl() argument
1350 BNX2FC_IO_DBG(io_req, "Entered process_cleanup_compl " in bnx2fc_process_cleanup_compl()
1352 io_req->refcount.refcount.counter, io_req->cmd_type); in bnx2fc_process_cleanup_compl()
1353 bnx2fc_scsi_done(io_req, DID_ERROR); in bnx2fc_process_cleanup_compl()
1354 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_process_cleanup_compl()
1355 if (io_req->wait_for_comp) in bnx2fc_process_cleanup_compl()
1356 complete(&io_req->tm_done); in bnx2fc_process_cleanup_compl()
1359 void bnx2fc_process_abts_compl(struct bnx2fc_cmd *io_req, in bnx2fc_process_abts_compl() argument
1366 struct bnx2fc_rport *tgt = io_req->tgt; in bnx2fc_process_abts_compl()
1368 BNX2FC_IO_DBG(io_req, "Entered process_abts_compl xid = 0x%x" in bnx2fc_process_abts_compl()
1370 io_req->xid, in bnx2fc_process_abts_compl()
1371 io_req->refcount.refcount.counter, io_req->cmd_type); in bnx2fc_process_abts_compl()
1374 &io_req->req_flags)) { in bnx2fc_process_abts_compl()
1375 BNX2FC_IO_DBG(io_req, "Timer context finished processing" in bnx2fc_process_abts_compl()
1382 &io_req->req_flags)) in bnx2fc_process_abts_compl()
1391 if (test_bit(BNX2FC_FLAG_ISSUE_ABTS, &io_req->req_flags)) in bnx2fc_process_abts_compl()
1392 if (cancel_delayed_work(&io_req->timeout_work)) in bnx2fc_process_abts_compl()
1393 kref_put(&io_req->refcount, in bnx2fc_process_abts_compl()
1404 BNX2FC_IO_DBG(io_req, "ABTS response - ACC Send RRQ\n"); in bnx2fc_process_abts_compl()
1409 BNX2FC_IO_DBG(io_req, "ABTS response - RJT\n"); in bnx2fc_process_abts_compl()
1417 BNX2FC_IO_DBG(io_req, "Issue RRQ after R_A_TOV\n"); in bnx2fc_process_abts_compl()
1418 set_bit(BNX2FC_FLAG_ISSUE_RRQ, &io_req->req_flags); in bnx2fc_process_abts_compl()
1420 set_bit(BNX2FC_FLAG_RETIRE_OXID, &io_req->req_flags); in bnx2fc_process_abts_compl()
1421 bnx2fc_cmd_timer_set(io_req, r_a_tov); in bnx2fc_process_abts_compl()
1424 if (io_req->wait_for_comp) { in bnx2fc_process_abts_compl()
1426 &io_req->req_flags)) in bnx2fc_process_abts_compl()
1427 complete(&io_req->tm_done); in bnx2fc_process_abts_compl()
1438 if (io_req->on_active_queue) { in bnx2fc_process_abts_compl()
1439 list_del_init(&io_req->link); in bnx2fc_process_abts_compl()
1440 io_req->on_active_queue = 0; in bnx2fc_process_abts_compl()
1442 list_add_tail(&io_req->link, &tgt->io_retire_queue); in bnx2fc_process_abts_compl()
1444 bnx2fc_scsi_done(io_req, DID_ERROR); in bnx2fc_process_abts_compl()
1445 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_process_abts_compl()
1449 static void bnx2fc_lun_reset_cmpl(struct bnx2fc_cmd *io_req) in bnx2fc_lun_reset_cmpl() argument
1451 struct scsi_cmnd *sc_cmd = io_req->sc_cmd; in bnx2fc_lun_reset_cmpl()
1452 struct bnx2fc_rport *tgt = io_req->tgt; in bnx2fc_lun_reset_cmpl()
1459 BNX2FC_IO_DBG(io_req, "Entered bnx2fc_lun_reset_cmpl\n"); in bnx2fc_lun_reset_cmpl()
1472 if (cancel_delayed_work(&io_req->timeout_work)) in bnx2fc_lun_reset_cmpl()
1473 kref_put(&io_req->refcount, in bnx2fc_lun_reset_cmpl()
1487 static void bnx2fc_tgt_reset_cmpl(struct bnx2fc_cmd *io_req) in bnx2fc_tgt_reset_cmpl() argument
1489 struct bnx2fc_rport *tgt = io_req->tgt; in bnx2fc_tgt_reset_cmpl()
1494 BNX2FC_IO_DBG(io_req, "Entered bnx2fc_tgt_reset_cmpl\n"); in bnx2fc_tgt_reset_cmpl()
1505 if (cancel_delayed_work(&io_req->timeout_work)) in bnx2fc_tgt_reset_cmpl()
1506 kref_put(&io_req->refcount, in bnx2fc_tgt_reset_cmpl()
1518 void bnx2fc_process_tm_compl(struct bnx2fc_cmd *io_req, in bnx2fc_process_tm_compl() argument
1523 struct scsi_cmnd *sc_cmd = io_req->sc_cmd; in bnx2fc_process_tm_compl()
1529 BNX2FC_IO_DBG(io_req, "Entered process_tm_compl\n"); in bnx2fc_process_tm_compl()
1531 if (!(test_bit(BNX2FC_FLAG_TM_TIMEOUT, &io_req->req_flags))) in bnx2fc_process_tm_compl()
1532 set_bit(BNX2FC_FLAG_TM_COMPL, &io_req->req_flags); in bnx2fc_process_tm_compl()
1541 tm_req = &(io_req->mp_req); in bnx2fc_process_tm_compl()
1556 bnx2fc_parse_fcp_rsp(io_req, in bnx2fc_process_tm_compl()
1559 if (io_req->fcp_rsp_code == 0) { in bnx2fc_process_tm_compl()
1562 bnx2fc_lun_reset_cmpl(io_req); in bnx2fc_process_tm_compl()
1564 bnx2fc_tgt_reset_cmpl(io_req); in bnx2fc_process_tm_compl()
1574 switch (io_req->fcp_status) { in bnx2fc_process_tm_compl()
1576 if (io_req->cdb_status == 0) { in bnx2fc_process_tm_compl()
1581 sc_cmd->result = (DID_OK << 16) | io_req->cdb_status; in bnx2fc_process_tm_compl()
1583 if (io_req->fcp_resid) in bnx2fc_process_tm_compl()
1584 scsi_set_resid(sc_cmd, io_req->fcp_resid); in bnx2fc_process_tm_compl()
1588 BNX2FC_IO_DBG(io_req, "process_tm_compl: fcp_status = %d\n", in bnx2fc_process_tm_compl()
1589 io_req->fcp_status); in bnx2fc_process_tm_compl()
1593 sc_cmd = io_req->sc_cmd; in bnx2fc_process_tm_compl()
1594 io_req->sc_cmd = NULL; in bnx2fc_process_tm_compl()
1597 if (io_req->on_tmf_queue) { in bnx2fc_process_tm_compl()
1599 list_del_init(&io_req->link); in bnx2fc_process_tm_compl()
1600 io_req->on_tmf_queue = 0; in bnx2fc_process_tm_compl()
1610 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_process_tm_compl()
1611 if (io_req->wait_for_comp) { in bnx2fc_process_tm_compl()
1612 BNX2FC_IO_DBG(io_req, "tm_compl - wake up the waiter\n"); in bnx2fc_process_tm_compl()
1613 complete(&io_req->tm_done); in bnx2fc_process_tm_compl()
1617 static int bnx2fc_split_bd(struct bnx2fc_cmd *io_req, u64 addr, int sg_len, in bnx2fc_split_bd() argument
1620 struct fcoe_bd_ctx *bd = io_req->bd_tbl->bd_tbl; in bnx2fc_split_bd()
1642 static int bnx2fc_map_sg(struct bnx2fc_cmd *io_req) in bnx2fc_map_sg() argument
1644 struct bnx2fc_interface *interface = io_req->port->priv; in bnx2fc_map_sg()
1646 struct scsi_cmnd *sc = io_req->sc_cmd; in bnx2fc_map_sg()
1647 struct fcoe_bd_ctx *bd = io_req->bd_tbl->bd_tbl; in bnx2fc_map_sg()
1667 sg_frags = bnx2fc_split_bd(io_req, addr, sg_len, in bnx2fc_map_sg()
1683 io_req->xid); in bnx2fc_map_sg()
1687 static int bnx2fc_build_bd_list_from_sg(struct bnx2fc_cmd *io_req) in bnx2fc_build_bd_list_from_sg() argument
1689 struct scsi_cmnd *sc = io_req->sc_cmd; in bnx2fc_build_bd_list_from_sg()
1690 struct fcoe_bd_ctx *bd = io_req->bd_tbl->bd_tbl; in bnx2fc_build_bd_list_from_sg()
1694 bd_count = bnx2fc_map_sg(io_req); in bnx2fc_build_bd_list_from_sg()
1702 io_req->bd_tbl->bd_valid = bd_count; in bnx2fc_build_bd_list_from_sg()
1707 static void bnx2fc_unmap_sg_list(struct bnx2fc_cmd *io_req) in bnx2fc_unmap_sg_list() argument
1709 struct scsi_cmnd *sc = io_req->sc_cmd; in bnx2fc_unmap_sg_list()
1710 struct bnx2fc_interface *interface = io_req->port->priv; in bnx2fc_unmap_sg_list()
1717 if (io_req->bd_tbl->bd_valid && sc && scsi_sg_count(sc)) { in bnx2fc_unmap_sg_list()
1720 io_req->bd_tbl->bd_valid = 0; in bnx2fc_unmap_sg_list()
1724 void bnx2fc_build_fcp_cmnd(struct bnx2fc_cmd *io_req, in bnx2fc_build_fcp_cmnd() argument
1727 struct scsi_cmnd *sc_cmd = io_req->sc_cmd; in bnx2fc_build_fcp_cmnd()
1734 fcp_cmnd->fc_dl = htonl(io_req->data_xfer_len); in bnx2fc_build_fcp_cmnd()
1739 fcp_cmnd->fc_tm_flags = io_req->mp_req.tm_flags; in bnx2fc_build_fcp_cmnd()
1740 fcp_cmnd->fc_flags = io_req->io_req_flags; in bnx2fc_build_fcp_cmnd()
1759 static void bnx2fc_parse_fcp_rsp(struct bnx2fc_cmd *io_req, in bnx2fc_parse_fcp_rsp() argument
1763 struct scsi_cmnd *sc_cmd = io_req->sc_cmd; in bnx2fc_parse_fcp_rsp()
1764 struct bnx2fc_rport *tgt = io_req->tgt; in bnx2fc_parse_fcp_rsp()
1773 io_req->fcp_status = FC_GOOD; in bnx2fc_parse_fcp_rsp()
1774 io_req->fcp_resid = fcp_rsp->fcp_resid; in bnx2fc_parse_fcp_rsp()
1776 io_req->scsi_comp_flags = rsp_flags; in bnx2fc_parse_fcp_rsp()
1777 CMD_SCSI_STATUS(sc_cmd) = io_req->cdb_status = in bnx2fc_parse_fcp_rsp()
1801 io_req->fcp_rsp_len = fcp_rsp_len; in bnx2fc_parse_fcp_rsp()
1802 io_req->fcp_sns_len = fcp_sns_len; in bnx2fc_parse_fcp_rsp()
1823 io_req->fcp_rsp_code = rq_data[3]; in bnx2fc_parse_fcp_rsp()
1825 io_req->fcp_rsp_code); in bnx2fc_parse_fcp_rsp()
1861 struct bnx2fc_cmd *io_req; in bnx2fc_queuecommand() local
1900 io_req = bnx2fc_cmd_alloc(tgt); in bnx2fc_queuecommand()
1901 if (!io_req) { in bnx2fc_queuecommand()
1905 io_req->sc_cmd = sc_cmd; in bnx2fc_queuecommand()
1907 if (bnx2fc_post_io_req(tgt, io_req)) { in bnx2fc_queuecommand()
1919 void bnx2fc_process_scsi_cmd_compl(struct bnx2fc_cmd *io_req, in bnx2fc_process_scsi_cmd_compl() argument
1924 struct bnx2fc_rport *tgt = io_req->tgt; in bnx2fc_process_scsi_cmd_compl()
1931 if (test_and_set_bit(BNX2FC_FLAG_IO_COMPL, &io_req->req_flags)) { in bnx2fc_process_scsi_cmd_compl()
1933 BNX2FC_IO_DBG(io_req, "Timer context finished processing " in bnx2fc_process_scsi_cmd_compl()
1938 if (cancel_delayed_work(&io_req->timeout_work)) in bnx2fc_process_scsi_cmd_compl()
1939 kref_put(&io_req->refcount, in bnx2fc_process_scsi_cmd_compl()
1942 sc_cmd = io_req->sc_cmd; in bnx2fc_process_scsi_cmd_compl()
1953 bnx2fc_parse_fcp_rsp(io_req, fcp_rsp, num_rq); in bnx2fc_process_scsi_cmd_compl()
1961 if (io_req->on_active_queue) { in bnx2fc_process_scsi_cmd_compl()
1962 list_del_init(&io_req->link); in bnx2fc_process_scsi_cmd_compl()
1963 io_req->on_active_queue = 0; in bnx2fc_process_scsi_cmd_compl()
1965 list_add_tail(&io_req->link, &tgt->io_retire_queue); in bnx2fc_process_scsi_cmd_compl()
1971 BNX2FC_IO_DBG(io_req, "xid not on active_cmd_queue\n"); in bnx2fc_process_scsi_cmd_compl()
1972 if (io_req->wait_for_comp) in bnx2fc_process_scsi_cmd_compl()
1974 &io_req->req_flags)) in bnx2fc_process_scsi_cmd_compl()
1975 complete(&io_req->tm_done); in bnx2fc_process_scsi_cmd_compl()
1978 bnx2fc_unmap_sg_list(io_req); in bnx2fc_process_scsi_cmd_compl()
1979 io_req->sc_cmd = NULL; in bnx2fc_process_scsi_cmd_compl()
1981 switch (io_req->fcp_status) { in bnx2fc_process_scsi_cmd_compl()
1983 if (io_req->cdb_status == 0) { in bnx2fc_process_scsi_cmd_compl()
1988 BNX2FC_IO_DBG(io_req, "scsi_cmpl: cdb_status = %d" in bnx2fc_process_scsi_cmd_compl()
1990 io_req->cdb_status, io_req->fcp_resid); in bnx2fc_process_scsi_cmd_compl()
1991 sc_cmd->result = (DID_OK << 16) | io_req->cdb_status; in bnx2fc_process_scsi_cmd_compl()
1993 if (io_req->cdb_status == SAM_STAT_TASK_SET_FULL || in bnx2fc_process_scsi_cmd_compl()
1994 io_req->cdb_status == SAM_STAT_BUSY) { in bnx2fc_process_scsi_cmd_compl()
2002 if (io_req->fcp_resid) in bnx2fc_process_scsi_cmd_compl()
2003 scsi_set_resid(sc_cmd, io_req->fcp_resid); in bnx2fc_process_scsi_cmd_compl()
2007 io_req->fcp_status); in bnx2fc_process_scsi_cmd_compl()
2012 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_process_scsi_cmd_compl()
2016 struct bnx2fc_cmd *io_req) in bnx2fc_post_io_req() argument
2020 struct scsi_cmnd *sc_cmd = io_req->sc_cmd; in bnx2fc_post_io_req()
2032 io_req->cmd_type = BNX2FC_SCSI_CMD; in bnx2fc_post_io_req()
2033 io_req->port = port; in bnx2fc_post_io_req()
2034 io_req->tgt = tgt; in bnx2fc_post_io_req()
2035 io_req->data_xfer_len = scsi_bufflen(sc_cmd); in bnx2fc_post_io_req()
2036 sc_cmd->SCp.ptr = (char *)io_req; in bnx2fc_post_io_req()
2040 io_req->io_req_flags = BNX2FC_READ; in bnx2fc_post_io_req()
2042 stats->InputBytes += io_req->data_xfer_len; in bnx2fc_post_io_req()
2044 io_req->io_req_flags = BNX2FC_WRITE; in bnx2fc_post_io_req()
2046 stats->OutputBytes += io_req->data_xfer_len; in bnx2fc_post_io_req()
2048 io_req->io_req_flags = 0; in bnx2fc_post_io_req()
2053 xid = io_req->xid; in bnx2fc_post_io_req()
2056 if (bnx2fc_build_bd_list_from_sg(io_req)) { in bnx2fc_post_io_req()
2058 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_post_io_req()
2068 bnx2fc_init_task(io_req, task); in bnx2fc_post_io_req()
2072 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_post_io_req()
2078 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_post_io_req()
2084 bnx2fc_cmd_timer_set(io_req, BNX2FC_IO_TIMEOUT); in bnx2fc_post_io_req()
2090 io_req->on_active_queue = 1; in bnx2fc_post_io_req()
2092 list_add_tail(&io_req->link, &tgt->active_cmd_queue); in bnx2fc_post_io_req()