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, in bnx2fc_cmd_timer_set() argument
32 struct bnx2fc_interface *interface = io_req->port->priv; in bnx2fc_cmd_timer_set()
35 &io_req->timeout_work, in bnx2fc_cmd_timer_set()
37 kref_get(&io_req->refcount); in bnx2fc_cmd_timer_set()
42 struct bnx2fc_cmd *io_req = container_of(work, struct bnx2fc_cmd, in bnx2fc_cmd_timeout() local
44 u8 cmd_type = io_req->cmd_type; in bnx2fc_cmd_timeout()
45 struct bnx2fc_rport *tgt = io_req->tgt; in bnx2fc_cmd_timeout()
48 BNX2FC_IO_DBG(io_req, "cmd_timeout, cmd_type = %d," in bnx2fc_cmd_timeout()
49 "req_flags = %lx\n", cmd_type, io_req->req_flags); in bnx2fc_cmd_timeout()
52 if (test_and_clear_bit(BNX2FC_FLAG_ISSUE_RRQ, &io_req->req_flags)) { in bnx2fc_cmd_timeout()
53 clear_bit(BNX2FC_FLAG_RETIRE_OXID, &io_req->req_flags); in bnx2fc_cmd_timeout()
59 bnx2fc_send_rrq(io_req); in bnx2fc_cmd_timeout()
62 if (test_and_clear_bit(BNX2FC_FLAG_RETIRE_OXID, &io_req->req_flags)) { in bnx2fc_cmd_timeout()
63 BNX2FC_IO_DBG(io_req, "IO ready for reuse now\n"); in bnx2fc_cmd_timeout()
70 &io_req->req_flags)) { in bnx2fc_cmd_timeout()
72 BNX2FC_IO_DBG(io_req, "eh_abort timed out\n"); in bnx2fc_cmd_timeout()
73 complete(&io_req->abts_done); in bnx2fc_cmd_timeout()
75 &io_req->req_flags)) { in bnx2fc_cmd_timeout()
77 BNX2FC_IO_DBG(io_req, "ABTS timed out refcnt = %d\n", in bnx2fc_cmd_timeout()
78 kref_read(&io_req->refcount)); in bnx2fc_cmd_timeout()
80 &io_req->req_flags))) { in bnx2fc_cmd_timeout()
85 bnx2fc_initiate_cleanup(io_req); in bnx2fc_cmd_timeout()
86 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_cmd_timeout()
93 BNX2FC_IO_DBG(io_req, "IO timed out. issue ABTS\n"); in bnx2fc_cmd_timeout()
95 &io_req->req_flags)) { in bnx2fc_cmd_timeout()
96 BNX2FC_IO_DBG(io_req, "IO completed before " in bnx2fc_cmd_timeout()
102 &io_req->req_flags)) { in bnx2fc_cmd_timeout()
103 rc = bnx2fc_initiate_abts(io_req); in bnx2fc_cmd_timeout()
107 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_cmd_timeout()
112 BNX2FC_IO_DBG(io_req, "IO already in " in bnx2fc_cmd_timeout()
119 if (test_bit(BNX2FC_FLAG_ISSUE_ABTS, &io_req->req_flags)) { in bnx2fc_cmd_timeout()
120 BNX2FC_IO_DBG(io_req, "ABTS for ELS timed out\n"); in bnx2fc_cmd_timeout()
123 &io_req->req_flags)) { in bnx2fc_cmd_timeout()
124 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_cmd_timeout()
136 BNX2FC_IO_DBG(io_req, "ELS timed out\n"); in bnx2fc_cmd_timeout()
138 &io_req->req_flags)) in bnx2fc_cmd_timeout()
142 set_bit(BNX2FC_FLAG_ELS_TIMEOUT, &io_req->req_flags); in bnx2fc_cmd_timeout()
144 if ((io_req->cb_func) && (io_req->cb_arg)) { in bnx2fc_cmd_timeout()
145 io_req->cb_func(io_req->cb_arg); in bnx2fc_cmd_timeout()
146 io_req->cb_arg = NULL; in bnx2fc_cmd_timeout()
158 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_cmd_timeout()
162 static void bnx2fc_scsi_done(struct bnx2fc_cmd *io_req, int err_code) in bnx2fc_scsi_done() argument
165 struct scsi_cmnd *sc_cmd = io_req->sc_cmd; in bnx2fc_scsi_done()
172 if (io_req->cmd_type != BNX2FC_SCSI_CMD) in bnx2fc_scsi_done()
175 BNX2FC_IO_DBG(io_req, "scsi_done. err_code = 0x%x\n", err_code); in bnx2fc_scsi_done()
176 if (test_bit(BNX2FC_FLAG_CMD_LOST, &io_req->req_flags)) { in bnx2fc_scsi_done()
181 bnx2fc_unmap_sg_list(io_req); in bnx2fc_scsi_done()
182 io_req->sc_cmd = NULL; in bnx2fc_scsi_done()
188 io_req->xid); in bnx2fc_scsi_done()
192 pr_err(PFX "0x%x: sc_cmd->device is NULL.\n", io_req->xid); in bnx2fc_scsi_done()
197 io_req->xid); in bnx2fc_scsi_done()
203 BNX2FC_IO_DBG(io_req, "sc=%p, result=0x%x, retries=%d, allowed=%d\n", in bnx2fc_scsi_done()
215 struct bnx2fc_cmd *io_req; in bnx2fc_cmd_mgr_alloc() local
275 io_req = kzalloc(sizeof(*io_req), GFP_KERNEL); in bnx2fc_cmd_mgr_alloc()
277 if (!io_req) { in bnx2fc_cmd_mgr_alloc()
282 INIT_LIST_HEAD(&io_req->link); in bnx2fc_cmd_mgr_alloc()
283 INIT_DELAYED_WORK(&io_req->timeout_work, bnx2fc_cmd_timeout); in bnx2fc_cmd_mgr_alloc()
285 io_req->xid = xid++; in bnx2fc_cmd_mgr_alloc()
287 list_add_tail(&io_req->link, in bnx2fc_cmd_mgr_alloc()
288 &cmgr->free_list[io_req->xid % in bnx2fc_cmd_mgr_alloc()
291 list_add_tail(&io_req->link, in bnx2fc_cmd_mgr_alloc()
293 io_req++; in bnx2fc_cmd_mgr_alloc()
380 struct bnx2fc_cmd *tmp, *io_req; in bnx2fc_cmd_mgr_free() local
382 list_for_each_entry_safe(io_req, tmp, in bnx2fc_cmd_mgr_free()
384 list_del(&io_req->link); in bnx2fc_cmd_mgr_free()
385 kfree(io_req); in bnx2fc_cmd_mgr_free()
399 struct bnx2fc_cmd *io_req; in bnx2fc_elstm_alloc() local
440 io_req = (struct bnx2fc_cmd *) listp; in bnx2fc_elstm_alloc()
441 xid = io_req->xid; in bnx2fc_elstm_alloc()
442 cmd_mgr->cmds[xid] = io_req; in bnx2fc_elstm_alloc()
447 INIT_LIST_HEAD(&io_req->link); in bnx2fc_elstm_alloc()
449 io_req->port = port; in bnx2fc_elstm_alloc()
450 io_req->cmd_mgr = cmd_mgr; in bnx2fc_elstm_alloc()
451 io_req->req_flags = 0; in bnx2fc_elstm_alloc()
452 io_req->cmd_type = type; in bnx2fc_elstm_alloc()
456 bd_tbl = io_req->bd_tbl = cmd_mgr->io_bdt_pool[xid]; in bnx2fc_elstm_alloc()
457 bd_tbl->io_req = io_req; in bnx2fc_elstm_alloc()
460 kref_init(&io_req->refcount); in bnx2fc_elstm_alloc()
461 return io_req; in bnx2fc_elstm_alloc()
469 struct bnx2fc_cmd *io_req; in bnx2fc_cmd_alloc() local
495 io_req = (struct bnx2fc_cmd *) listp; in bnx2fc_cmd_alloc()
496 xid = io_req->xid; in bnx2fc_cmd_alloc()
497 cmd_mgr->cmds[xid] = io_req; in bnx2fc_cmd_alloc()
503 INIT_LIST_HEAD(&io_req->link); in bnx2fc_cmd_alloc()
505 io_req->port = port; in bnx2fc_cmd_alloc()
506 io_req->cmd_mgr = cmd_mgr; in bnx2fc_cmd_alloc()
507 io_req->req_flags = 0; in bnx2fc_cmd_alloc()
511 bd_tbl = io_req->bd_tbl = cmd_mgr->io_bdt_pool[xid]; in bnx2fc_cmd_alloc()
512 bd_tbl->io_req = io_req; in bnx2fc_cmd_alloc()
515 kref_init(&io_req->refcount); in bnx2fc_cmd_alloc()
516 return io_req; in bnx2fc_cmd_alloc()
521 struct bnx2fc_cmd *io_req = container_of(ref, in bnx2fc_cmd_release() local
523 struct bnx2fc_cmd_mgr *cmd_mgr = io_req->cmd_mgr; in bnx2fc_cmd_release()
526 if (io_req->cmd_type == BNX2FC_SCSI_CMD) in bnx2fc_cmd_release()
527 index = io_req->xid % num_possible_cpus(); in bnx2fc_cmd_release()
533 if (io_req->cmd_type != BNX2FC_SCSI_CMD) in bnx2fc_cmd_release()
534 bnx2fc_free_mp_resc(io_req); in bnx2fc_cmd_release()
535 cmd_mgr->cmds[io_req->xid] = NULL; in bnx2fc_cmd_release()
537 list_del_init(&io_req->link); in bnx2fc_cmd_release()
539 list_add(&io_req->link, in bnx2fc_cmd_release()
541 atomic_dec(&io_req->tgt->num_active_ios); in bnx2fc_cmd_release()
546 static void bnx2fc_free_mp_resc(struct bnx2fc_cmd *io_req) in bnx2fc_free_mp_resc() argument
548 struct bnx2fc_mp_req *mp_req = &(io_req->mp_req); in bnx2fc_free_mp_resc()
549 struct bnx2fc_interface *interface = io_req->port->priv; in bnx2fc_free_mp_resc()
581 int bnx2fc_init_mp_req(struct bnx2fc_cmd *io_req) in bnx2fc_init_mp_req() argument
586 struct bnx2fc_interface *interface = io_req->port->priv; in bnx2fc_init_mp_req()
591 mp_req = (struct bnx2fc_mp_req *)&(io_req->mp_req); in bnx2fc_init_mp_req()
594 if (io_req->cmd_type != BNX2FC_ELS) { in bnx2fc_init_mp_req()
596 io_req->data_xfer_len = mp_req->req_len; in bnx2fc_init_mp_req()
598 mp_req->req_len = io_req->data_xfer_len; in bnx2fc_init_mp_req()
605 bnx2fc_free_mp_resc(io_req); in bnx2fc_init_mp_req()
614 bnx2fc_free_mp_resc(io_req); in bnx2fc_init_mp_req()
627 bnx2fc_free_mp_resc(io_req); in bnx2fc_init_mp_req()
635 bnx2fc_free_mp_resc(io_req); in bnx2fc_init_mp_req()
669 struct bnx2fc_cmd *io_req; in bnx2fc_initiate_tmf() local
712 io_req = bnx2fc_elstm_alloc(tgt, BNX2FC_TASK_MGMT_CMD); in bnx2fc_initiate_tmf()
713 if (!io_req) { in bnx2fc_initiate_tmf()
723 io_req->sc_cmd = sc_cmd; in bnx2fc_initiate_tmf()
724 io_req->port = port; in bnx2fc_initiate_tmf()
725 io_req->tgt = tgt; in bnx2fc_initiate_tmf()
727 tm_req = (struct bnx2fc_mp_req *)&(io_req->mp_req); in bnx2fc_initiate_tmf()
729 rc = bnx2fc_init_mp_req(io_req); in bnx2fc_initiate_tmf()
733 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_initiate_tmf()
739 io_req->io_req_flags = 0; in bnx2fc_initiate_tmf()
743 bnx2fc_build_fcp_cmnd(io_req, (struct fcp_cmnd *)tm_req->req_buf); in bnx2fc_initiate_tmf()
756 xid = io_req->xid; in bnx2fc_initiate_tmf()
766 bnx2fc_init_mp_task(io_req, task); in bnx2fc_initiate_tmf()
768 sc_cmd->SCp.ptr = (char *)io_req; in bnx2fc_initiate_tmf()
775 io_req->on_tmf_queue = 1; in bnx2fc_initiate_tmf()
776 list_add_tail(&io_req->link, &tgt->active_tm_queue); in bnx2fc_initiate_tmf()
778 init_completion(&io_req->abts_done); in bnx2fc_initiate_tmf()
779 io_req->wait_for_abts_comp = 1; in bnx2fc_initiate_tmf()
785 rc = wait_for_completion_timeout(&io_req->abts_done, in bnx2fc_initiate_tmf()
789 io_req->wait_for_abts_comp = 0; in bnx2fc_initiate_tmf()
790 if (!(test_bit(BNX2FC_FLAG_TM_COMPL, &io_req->req_flags))) { in bnx2fc_initiate_tmf()
791 set_bit(BNX2FC_FLAG_TM_TIMEOUT, &io_req->req_flags); in bnx2fc_initiate_tmf()
792 if (io_req->on_tmf_queue) { in bnx2fc_initiate_tmf()
793 list_del_init(&io_req->link); in bnx2fc_initiate_tmf()
794 io_req->on_tmf_queue = 0; in bnx2fc_initiate_tmf()
796 io_req->wait_for_cleanup_comp = 1; in bnx2fc_initiate_tmf()
797 init_completion(&io_req->cleanup_done); in bnx2fc_initiate_tmf()
798 bnx2fc_initiate_cleanup(io_req); in bnx2fc_initiate_tmf()
800 rc = wait_for_completion_timeout(&io_req->cleanup_done, in bnx2fc_initiate_tmf()
803 io_req->wait_for_cleanup_comp = 0; in bnx2fc_initiate_tmf()
805 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_initiate_tmf()
821 int bnx2fc_initiate_abts(struct bnx2fc_cmd *io_req) in bnx2fc_initiate_abts() argument
824 struct bnx2fc_rport *tgt = io_req->tgt; in bnx2fc_initiate_abts()
841 BNX2FC_IO_DBG(io_req, "Entered bnx2fc_initiate_abts\n"); in bnx2fc_initiate_abts()
843 port = io_req->port; in bnx2fc_initiate_abts()
885 fc_hdr->fh_ox_id = htons(io_req->xid); in bnx2fc_initiate_abts()
886 fc_hdr->fh_rx_id = htons(io_req->task->rxwr_txrd.var_ctx.rx_id); in bnx2fc_initiate_abts()
918 bnx2fc_cmd_timer_set(io_req, 2 * r_a_tov); in bnx2fc_initiate_abts()
981 cb_arg->io_req = seq_clnp_req; in bnx2fc_initiate_seq_cleanup()
998 int bnx2fc_initiate_cleanup(struct bnx2fc_cmd *io_req) in bnx2fc_initiate_cleanup() argument
1000 struct bnx2fc_rport *tgt = io_req->tgt; in bnx2fc_initiate_cleanup()
1011 BNX2FC_IO_DBG(io_req, "Entered bnx2fc_initiate_cleanup\n"); in bnx2fc_initiate_cleanup()
1013 port = io_req->port; in bnx2fc_initiate_cleanup()
1038 orig_xid = io_req->xid; in bnx2fc_initiate_cleanup()
1040 BNX2FC_IO_DBG(io_req, "CLEANUP io_req xid = 0x%x\n", xid); in bnx2fc_initiate_cleanup()
1048 set_bit(BNX2FC_FLAG_ISSUE_CLEANUP_REQ, &io_req->req_flags); in bnx2fc_initiate_cleanup()
1083 static int bnx2fc_abts_cleanup(struct bnx2fc_cmd *io_req) in bnx2fc_abts_cleanup() argument
1085 struct bnx2fc_rport *tgt = io_req->tgt; in bnx2fc_abts_cleanup()
1088 init_completion(&io_req->cleanup_done); in bnx2fc_abts_cleanup()
1089 io_req->wait_for_cleanup_comp = 1; in bnx2fc_abts_cleanup()
1090 bnx2fc_initiate_cleanup(io_req); in bnx2fc_abts_cleanup()
1098 time_left = wait_for_completion_timeout(&io_req->cleanup_done, in bnx2fc_abts_cleanup()
1101 BNX2FC_IO_DBG(io_req, "%s(): Wait for cleanup timed out.\n", in bnx2fc_abts_cleanup()
1108 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_abts_cleanup()
1112 io_req->wait_for_cleanup_comp = 0; in bnx2fc_abts_cleanup()
1128 struct bnx2fc_cmd *io_req; in bnx2fc_eh_abort() local
1149 io_req = (struct bnx2fc_cmd *)sc_cmd->SCp.ptr; in bnx2fc_eh_abort()
1150 if (!io_req) { in bnx2fc_eh_abort()
1156 BNX2FC_IO_DBG(io_req, "eh_abort - refcnt = %d\n", in bnx2fc_eh_abort()
1157 kref_read(&io_req->refcount)); in bnx2fc_eh_abort()
1160 kref_get(&io_req->refcount); in bnx2fc_eh_abort()
1162 BUG_ON(tgt != io_req->tgt); in bnx2fc_eh_abort()
1172 "flush in progress\n", io_req->xid); in bnx2fc_eh_abort()
1173 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_eh_abort()
1178 if (io_req->on_active_queue == 0) { in bnx2fc_eh_abort()
1180 "not on active_q\n", io_req->xid); in bnx2fc_eh_abort()
1196 list_del_init(&io_req->link); in bnx2fc_eh_abort()
1197 io_req->on_active_queue = 0; in bnx2fc_eh_abort()
1199 list_add_tail(&io_req->link, &tgt->io_retire_queue); in bnx2fc_eh_abort()
1201 init_completion(&io_req->abts_done); in bnx2fc_eh_abort()
1202 init_completion(&io_req->cleanup_done); in bnx2fc_eh_abort()
1204 if (test_and_set_bit(BNX2FC_FLAG_ISSUE_ABTS, &io_req->req_flags)) { in bnx2fc_eh_abort()
1206 "already in abts processing\n", io_req->xid); in bnx2fc_eh_abort()
1207 if (cancel_delayed_work(&io_req->timeout_work)) in bnx2fc_eh_abort()
1208 kref_put(&io_req->refcount, in bnx2fc_eh_abort()
1215 rc = bnx2fc_abts_cleanup(io_req); in bnx2fc_eh_abort()
1221 set_bit(BNX2FC_FLAG_IO_CLEANUP, &io_req->req_flags); in bnx2fc_eh_abort()
1226 if (cancel_delayed_work(&io_req->timeout_work)) in bnx2fc_eh_abort()
1227 kref_put(&io_req->refcount, in bnx2fc_eh_abort()
1229 set_bit(BNX2FC_FLAG_EH_ABORT, &io_req->req_flags); in bnx2fc_eh_abort()
1230 io_req->wait_for_abts_comp = 1; in bnx2fc_eh_abort()
1231 rc = bnx2fc_initiate_abts(io_req); in bnx2fc_eh_abort()
1233 io_req->wait_for_cleanup_comp = 1; in bnx2fc_eh_abort()
1234 bnx2fc_initiate_cleanup(io_req); in bnx2fc_eh_abort()
1236 wait_for_completion(&io_req->cleanup_done); in bnx2fc_eh_abort()
1238 io_req->wait_for_cleanup_comp = 0; in bnx2fc_eh_abort()
1244 time_left = wait_for_completion_timeout(&io_req->abts_done, in bnx2fc_eh_abort()
1247 BNX2FC_IO_DBG(io_req, in bnx2fc_eh_abort()
1251 io_req->wait_for_abts_comp = 0; in bnx2fc_eh_abort()
1252 if (test_bit(BNX2FC_FLAG_IO_COMPL, &io_req->req_flags)) { in bnx2fc_eh_abort()
1253 BNX2FC_IO_DBG(io_req, "IO completed in a different context\n"); in bnx2fc_eh_abort()
1256 &io_req->req_flags))) { in bnx2fc_eh_abort()
1259 io_req->xid); in bnx2fc_eh_abort()
1264 rc = bnx2fc_abts_cleanup(io_req); in bnx2fc_eh_abort()
1272 BNX2FC_IO_DBG(io_req, "abort succeeded\n"); in bnx2fc_eh_abort()
1274 bnx2fc_scsi_done(io_req, DID_ABORT); in bnx2fc_eh_abort()
1275 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_eh_abort()
1279 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_eh_abort()
1319 void bnx2fc_process_cleanup_compl(struct bnx2fc_cmd *io_req, in bnx2fc_process_cleanup_compl() argument
1323 BNX2FC_IO_DBG(io_req, "Entered process_cleanup_compl " in bnx2fc_process_cleanup_compl()
1325 kref_read(&io_req->refcount), io_req->cmd_type); in bnx2fc_process_cleanup_compl()
1331 &io_req->req_flags)) in bnx2fc_process_cleanup_compl()
1338 if (test_bit(BNX2FC_FLAG_ISSUE_ABTS, &io_req->req_flags) && in bnx2fc_process_cleanup_compl()
1339 !test_bit(BNX2FC_FLAG_ABTS_DONE, &io_req->req_flags)) { in bnx2fc_process_cleanup_compl()
1340 set_bit(BNX2FC_FLAG_ABTS_DONE, &io_req->req_flags); in bnx2fc_process_cleanup_compl()
1341 if (io_req->wait_for_abts_comp) in bnx2fc_process_cleanup_compl()
1342 complete(&io_req->abts_done); in bnx2fc_process_cleanup_compl()
1345 bnx2fc_scsi_done(io_req, DID_ERROR); in bnx2fc_process_cleanup_compl()
1346 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_process_cleanup_compl()
1347 if (io_req->wait_for_cleanup_comp) in bnx2fc_process_cleanup_compl()
1348 complete(&io_req->cleanup_done); in bnx2fc_process_cleanup_compl()
1351 void bnx2fc_process_abts_compl(struct bnx2fc_cmd *io_req, in bnx2fc_process_abts_compl() argument
1358 struct bnx2fc_rport *tgt = io_req->tgt; in bnx2fc_process_abts_compl()
1360 BNX2FC_IO_DBG(io_req, "Entered process_abts_compl xid = 0x%x" in bnx2fc_process_abts_compl()
1362 io_req->xid, in bnx2fc_process_abts_compl()
1363 kref_read(&io_req->refcount), io_req->cmd_type); in bnx2fc_process_abts_compl()
1366 &io_req->req_flags)) { in bnx2fc_process_abts_compl()
1367 BNX2FC_IO_DBG(io_req, "Timer context finished processing" in bnx2fc_process_abts_compl()
1376 if (test_bit(BNX2FC_FLAG_ISSUE_CLEANUP_REQ, &io_req->req_flags)) { in bnx2fc_process_abts_compl()
1377 clear_bit(BNX2FC_FLAG_ISSUE_CLEANUP_REQ, &io_req->req_flags); in bnx2fc_process_abts_compl()
1378 if (io_req->wait_for_cleanup_comp) in bnx2fc_process_abts_compl()
1379 complete(&io_req->cleanup_done); in bnx2fc_process_abts_compl()
1384 &io_req->req_flags)) in bnx2fc_process_abts_compl()
1393 if (test_bit(BNX2FC_FLAG_ISSUE_ABTS, &io_req->req_flags)) in bnx2fc_process_abts_compl()
1394 if (cancel_delayed_work(&io_req->timeout_work)) in bnx2fc_process_abts_compl()
1395 kref_put(&io_req->refcount, in bnx2fc_process_abts_compl()
1406 BNX2FC_IO_DBG(io_req, "ABTS response - ACC Send RRQ\n"); in bnx2fc_process_abts_compl()
1411 BNX2FC_IO_DBG(io_req, "ABTS response - RJT\n"); in bnx2fc_process_abts_compl()
1419 BNX2FC_IO_DBG(io_req, "Issue RRQ after R_A_TOV\n"); in bnx2fc_process_abts_compl()
1420 set_bit(BNX2FC_FLAG_ISSUE_RRQ, &io_req->req_flags); in bnx2fc_process_abts_compl()
1422 set_bit(BNX2FC_FLAG_RETIRE_OXID, &io_req->req_flags); in bnx2fc_process_abts_compl()
1423 bnx2fc_cmd_timer_set(io_req, r_a_tov); in bnx2fc_process_abts_compl()
1426 if (io_req->wait_for_abts_comp) { in bnx2fc_process_abts_compl()
1428 &io_req->req_flags)) in bnx2fc_process_abts_compl()
1429 complete(&io_req->abts_done); in bnx2fc_process_abts_compl()
1440 if (io_req->on_active_queue) { in bnx2fc_process_abts_compl()
1441 list_del_init(&io_req->link); in bnx2fc_process_abts_compl()
1442 io_req->on_active_queue = 0; in bnx2fc_process_abts_compl()
1444 list_add_tail(&io_req->link, &tgt->io_retire_queue); in bnx2fc_process_abts_compl()
1446 bnx2fc_scsi_done(io_req, DID_ERROR); in bnx2fc_process_abts_compl()
1447 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_process_abts_compl()
1451 static void bnx2fc_lun_reset_cmpl(struct bnx2fc_cmd *io_req) in bnx2fc_lun_reset_cmpl() argument
1453 struct scsi_cmnd *sc_cmd = io_req->sc_cmd; in bnx2fc_lun_reset_cmpl()
1454 struct bnx2fc_rport *tgt = io_req->tgt; in bnx2fc_lun_reset_cmpl()
1461 BNX2FC_IO_DBG(io_req, "Entered bnx2fc_lun_reset_cmpl\n"); in bnx2fc_lun_reset_cmpl()
1474 if (cancel_delayed_work(&io_req->timeout_work)) in bnx2fc_lun_reset_cmpl()
1475 kref_put(&io_req->refcount, in bnx2fc_lun_reset_cmpl()
1489 static void bnx2fc_tgt_reset_cmpl(struct bnx2fc_cmd *io_req) in bnx2fc_tgt_reset_cmpl() argument
1491 struct bnx2fc_rport *tgt = io_req->tgt; in bnx2fc_tgt_reset_cmpl()
1496 BNX2FC_IO_DBG(io_req, "Entered bnx2fc_tgt_reset_cmpl\n"); in bnx2fc_tgt_reset_cmpl()
1507 if (cancel_delayed_work(&io_req->timeout_work)) in bnx2fc_tgt_reset_cmpl()
1508 kref_put(&io_req->refcount, in bnx2fc_tgt_reset_cmpl()
1520 void bnx2fc_process_tm_compl(struct bnx2fc_cmd *io_req, in bnx2fc_process_tm_compl() argument
1525 struct scsi_cmnd *sc_cmd = io_req->sc_cmd; in bnx2fc_process_tm_compl()
1531 BNX2FC_IO_DBG(io_req, "Entered process_tm_compl\n"); in bnx2fc_process_tm_compl()
1533 if (!(test_bit(BNX2FC_FLAG_TM_TIMEOUT, &io_req->req_flags))) in bnx2fc_process_tm_compl()
1534 set_bit(BNX2FC_FLAG_TM_COMPL, &io_req->req_flags); in bnx2fc_process_tm_compl()
1543 tm_req = &(io_req->mp_req); in bnx2fc_process_tm_compl()
1558 bnx2fc_parse_fcp_rsp(io_req, in bnx2fc_process_tm_compl()
1561 if (io_req->fcp_rsp_code == 0) { in bnx2fc_process_tm_compl()
1564 bnx2fc_lun_reset_cmpl(io_req); in bnx2fc_process_tm_compl()
1566 bnx2fc_tgt_reset_cmpl(io_req); in bnx2fc_process_tm_compl()
1576 switch (io_req->fcp_status) { in bnx2fc_process_tm_compl()
1578 if (io_req->cdb_status == 0) { in bnx2fc_process_tm_compl()
1583 sc_cmd->result = (DID_OK << 16) | io_req->cdb_status; in bnx2fc_process_tm_compl()
1585 if (io_req->fcp_resid) in bnx2fc_process_tm_compl()
1586 scsi_set_resid(sc_cmd, io_req->fcp_resid); in bnx2fc_process_tm_compl()
1590 BNX2FC_IO_DBG(io_req, "process_tm_compl: fcp_status = %d\n", in bnx2fc_process_tm_compl()
1591 io_req->fcp_status); in bnx2fc_process_tm_compl()
1595 sc_cmd = io_req->sc_cmd; in bnx2fc_process_tm_compl()
1596 io_req->sc_cmd = NULL; in bnx2fc_process_tm_compl()
1599 if (io_req->on_tmf_queue) { in bnx2fc_process_tm_compl()
1601 list_del_init(&io_req->link); in bnx2fc_process_tm_compl()
1602 io_req->on_tmf_queue = 0; in bnx2fc_process_tm_compl()
1612 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_process_tm_compl()
1613 if (io_req->wait_for_abts_comp) { in bnx2fc_process_tm_compl()
1614 BNX2FC_IO_DBG(io_req, "tm_compl - wake up the waiter\n"); in bnx2fc_process_tm_compl()
1615 complete(&io_req->abts_done); in bnx2fc_process_tm_compl()
1619 static int bnx2fc_split_bd(struct bnx2fc_cmd *io_req, u64 addr, int sg_len, in bnx2fc_split_bd() argument
1622 struct fcoe_bd_ctx *bd = io_req->bd_tbl->bd_tbl; in bnx2fc_split_bd()
1644 static int bnx2fc_map_sg(struct bnx2fc_cmd *io_req) in bnx2fc_map_sg() argument
1646 struct bnx2fc_interface *interface = io_req->port->priv; in bnx2fc_map_sg()
1648 struct scsi_cmnd *sc = io_req->sc_cmd; in bnx2fc_map_sg()
1649 struct fcoe_bd_ctx *bd = io_req->bd_tbl->bd_tbl; in bnx2fc_map_sg()
1670 sg_frags = bnx2fc_split_bd(io_req, addr, sg_len, in bnx2fc_map_sg()
1686 io_req->xid); in bnx2fc_map_sg()
1690 static int bnx2fc_build_bd_list_from_sg(struct bnx2fc_cmd *io_req) in bnx2fc_build_bd_list_from_sg() argument
1692 struct scsi_cmnd *sc = io_req->sc_cmd; in bnx2fc_build_bd_list_from_sg()
1693 struct fcoe_bd_ctx *bd = io_req->bd_tbl->bd_tbl; in bnx2fc_build_bd_list_from_sg()
1697 bd_count = bnx2fc_map_sg(io_req); in bnx2fc_build_bd_list_from_sg()
1705 io_req->bd_tbl->bd_valid = bd_count; in bnx2fc_build_bd_list_from_sg()
1713 bd_count, io_req->xid); in bnx2fc_build_bd_list_from_sg()
1720 static void bnx2fc_unmap_sg_list(struct bnx2fc_cmd *io_req) in bnx2fc_unmap_sg_list() argument
1722 struct scsi_cmnd *sc = io_req->sc_cmd; in bnx2fc_unmap_sg_list()
1723 struct bnx2fc_interface *interface = io_req->port->priv; in bnx2fc_unmap_sg_list()
1730 if (io_req->bd_tbl->bd_valid && sc && scsi_sg_count(sc)) { in bnx2fc_unmap_sg_list()
1733 io_req->bd_tbl->bd_valid = 0; in bnx2fc_unmap_sg_list()
1737 void bnx2fc_build_fcp_cmnd(struct bnx2fc_cmd *io_req, in bnx2fc_build_fcp_cmnd() argument
1740 struct scsi_cmnd *sc_cmd = io_req->sc_cmd; in bnx2fc_build_fcp_cmnd()
1746 fcp_cmnd->fc_dl = htonl(io_req->data_xfer_len); in bnx2fc_build_fcp_cmnd()
1751 fcp_cmnd->fc_tm_flags = io_req->mp_req.tm_flags; in bnx2fc_build_fcp_cmnd()
1752 fcp_cmnd->fc_flags = io_req->io_req_flags; in bnx2fc_build_fcp_cmnd()
1756 static void bnx2fc_parse_fcp_rsp(struct bnx2fc_cmd *io_req, in bnx2fc_parse_fcp_rsp() argument
1760 struct scsi_cmnd *sc_cmd = io_req->sc_cmd; in bnx2fc_parse_fcp_rsp()
1761 struct bnx2fc_rport *tgt = io_req->tgt; in bnx2fc_parse_fcp_rsp()
1770 io_req->fcp_status = FC_GOOD; in bnx2fc_parse_fcp_rsp()
1771 io_req->fcp_resid = 0; 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()
1824 BNX2FC_IO_DBG(io_req, "fcp_rsp_code = %d\n", 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()
1930 if (test_and_set_bit(BNX2FC_FLAG_IO_COMPL, &io_req->req_flags)) { in bnx2fc_process_scsi_cmd_compl()
1932 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()
1960 if (io_req->on_active_queue) { in bnx2fc_process_scsi_cmd_compl()
1961 list_del_init(&io_req->link); in bnx2fc_process_scsi_cmd_compl()
1962 io_req->on_active_queue = 0; in bnx2fc_process_scsi_cmd_compl()
1964 list_add_tail(&io_req->link, &tgt->io_retire_queue); in bnx2fc_process_scsi_cmd_compl()
1970 BNX2FC_IO_DBG(io_req, "xid not on active_cmd_queue\n"); in bnx2fc_process_scsi_cmd_compl()
1971 if (io_req->wait_for_abts_comp) in bnx2fc_process_scsi_cmd_compl()
1973 &io_req->req_flags)) in bnx2fc_process_scsi_cmd_compl()
1974 complete(&io_req->abts_done); in bnx2fc_process_scsi_cmd_compl()
1977 bnx2fc_unmap_sg_list(io_req); in bnx2fc_process_scsi_cmd_compl()
1978 io_req->sc_cmd = NULL; in bnx2fc_process_scsi_cmd_compl()
1980 switch (io_req->fcp_status) { in bnx2fc_process_scsi_cmd_compl()
1982 if (io_req->cdb_status == 0) { in bnx2fc_process_scsi_cmd_compl()
1987 BNX2FC_IO_DBG(io_req, "scsi_cmpl: cdb_status = %d" in bnx2fc_process_scsi_cmd_compl()
1989 io_req->cdb_status, io_req->fcp_resid); in bnx2fc_process_scsi_cmd_compl()
1990 sc_cmd->result = (DID_OK << 16) | io_req->cdb_status; in bnx2fc_process_scsi_cmd_compl()
1992 if (io_req->cdb_status == SAM_STAT_TASK_SET_FULL || in bnx2fc_process_scsi_cmd_compl()
1993 io_req->cdb_status == SAM_STAT_BUSY) { in bnx2fc_process_scsi_cmd_compl()
2019 if (io_req->fcp_resid) in bnx2fc_process_scsi_cmd_compl()
2020 scsi_set_resid(sc_cmd, io_req->fcp_resid); in bnx2fc_process_scsi_cmd_compl()
2024 io_req->fcp_status); in bnx2fc_process_scsi_cmd_compl()
2029 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_process_scsi_cmd_compl()
2033 struct bnx2fc_cmd *io_req) in bnx2fc_post_io_req() argument
2037 struct scsi_cmnd *sc_cmd = io_req->sc_cmd; in bnx2fc_post_io_req()
2049 io_req->cmd_type = BNX2FC_SCSI_CMD; in bnx2fc_post_io_req()
2050 io_req->port = port; in bnx2fc_post_io_req()
2051 io_req->tgt = tgt; in bnx2fc_post_io_req()
2052 io_req->data_xfer_len = scsi_bufflen(sc_cmd); in bnx2fc_post_io_req()
2053 sc_cmd->SCp.ptr = (char *)io_req; in bnx2fc_post_io_req()
2057 io_req->io_req_flags = BNX2FC_READ; in bnx2fc_post_io_req()
2059 stats->InputBytes += io_req->data_xfer_len; in bnx2fc_post_io_req()
2061 io_req->io_req_flags = BNX2FC_WRITE; in bnx2fc_post_io_req()
2063 stats->OutputBytes += io_req->data_xfer_len; in bnx2fc_post_io_req()
2065 io_req->io_req_flags = 0; in bnx2fc_post_io_req()
2070 xid = io_req->xid; in bnx2fc_post_io_req()
2073 if (bnx2fc_build_bd_list_from_sg(io_req)) { in bnx2fc_post_io_req()
2075 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_post_io_req()
2085 bnx2fc_init_task(io_req, task); in bnx2fc_post_io_req()
2089 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_post_io_req()
2095 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_post_io_req()
2101 bnx2fc_cmd_timer_set(io_req, BNX2FC_IO_TIMEOUT); in bnx2fc_post_io_req()
2107 io_req->on_active_queue = 1; in bnx2fc_post_io_req()
2109 list_add_tail(&io_req->link, &tgt->active_cmd_queue); in bnx2fc_post_io_req()