• Home
  • Raw
  • Download

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
43 u8 cmd_type = io_req->cmd_type; in bnx2fc_cmd_timeout()
44 struct bnx2fc_rport *tgt = io_req->tgt; in bnx2fc_cmd_timeout()
47 BNX2FC_IO_DBG(io_req, "cmd_timeout, cmd_type = %d," in bnx2fc_cmd_timeout()
48 "req_flags = %lx\n", cmd_type, io_req->req_flags); in bnx2fc_cmd_timeout()
51 if (test_and_clear_bit(BNX2FC_FLAG_ISSUE_RRQ, &io_req->req_flags)) { in bnx2fc_cmd_timeout()
52 clear_bit(BNX2FC_FLAG_RETIRE_OXID, &io_req->req_flags); in bnx2fc_cmd_timeout()
58 bnx2fc_send_rrq(io_req); in bnx2fc_cmd_timeout()
61 if (test_and_clear_bit(BNX2FC_FLAG_RETIRE_OXID, &io_req->req_flags)) { in bnx2fc_cmd_timeout()
62 BNX2FC_IO_DBG(io_req, "IO ready for reuse now\n"); in bnx2fc_cmd_timeout()
69 &io_req->req_flags)) { in bnx2fc_cmd_timeout()
71 BNX2FC_IO_DBG(io_req, "eh_abort timed out\n"); in bnx2fc_cmd_timeout()
72 complete(&io_req->tm_done); in bnx2fc_cmd_timeout()
74 &io_req->req_flags)) { in bnx2fc_cmd_timeout()
76 BNX2FC_IO_DBG(io_req, "ABTS timed out refcnt = %d\n", in bnx2fc_cmd_timeout()
77 io_req->refcount.refcount.counter); in bnx2fc_cmd_timeout()
79 &io_req->req_flags))) { in bnx2fc_cmd_timeout()
84 bnx2fc_initiate_cleanup(io_req); in bnx2fc_cmd_timeout()
85 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_cmd_timeout()
92 BNX2FC_IO_DBG(io_req, "IO timed out. issue ABTS\n"); in bnx2fc_cmd_timeout()
94 &io_req->req_flags)) { in bnx2fc_cmd_timeout()
95 BNX2FC_IO_DBG(io_req, "IO completed before " in bnx2fc_cmd_timeout()
101 &io_req->req_flags)) { in bnx2fc_cmd_timeout()
102 rc = bnx2fc_initiate_abts(io_req); in bnx2fc_cmd_timeout()
106 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_cmd_timeout()
111 BNX2FC_IO_DBG(io_req, "IO already in " in bnx2fc_cmd_timeout()
118 if (test_bit(BNX2FC_FLAG_ISSUE_ABTS, &io_req->req_flags)) { in bnx2fc_cmd_timeout()
119 BNX2FC_IO_DBG(io_req, "ABTS for ELS timed out\n"); in bnx2fc_cmd_timeout()
122 &io_req->req_flags)) { in bnx2fc_cmd_timeout()
123 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_cmd_timeout()
135 BNX2FC_IO_DBG(io_req, "ELS timed out\n"); in bnx2fc_cmd_timeout()
137 &io_req->req_flags)) in bnx2fc_cmd_timeout()
141 set_bit(BNX2FC_FLAG_ELS_TIMEOUT, &io_req->req_flags); in bnx2fc_cmd_timeout()
143 if ((io_req->cb_func) && (io_req->cb_arg)) { in bnx2fc_cmd_timeout()
144 io_req->cb_func(io_req->cb_arg); in bnx2fc_cmd_timeout()
145 io_req->cb_arg = NULL; in bnx2fc_cmd_timeout()
157 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_cmd_timeout()
161 static void bnx2fc_scsi_done(struct bnx2fc_cmd *io_req, int err_code) in bnx2fc_scsi_done() argument
164 struct scsi_cmnd *sc_cmd = io_req->sc_cmd; in bnx2fc_scsi_done()
171 if (io_req->cmd_type != BNX2FC_SCSI_CMD) in bnx2fc_scsi_done()
174 BNX2FC_IO_DBG(io_req, "scsi_done. err_code = 0x%x\n", err_code); in bnx2fc_scsi_done()
175 if (test_bit(BNX2FC_FLAG_CMD_LOST, &io_req->req_flags)) { in bnx2fc_scsi_done()
180 bnx2fc_unmap_sg_list(io_req); in bnx2fc_scsi_done()
181 io_req->sc_cmd = NULL; in bnx2fc_scsi_done()
187 io_req->xid); in bnx2fc_scsi_done()
191 pr_err(PFX "0x%x: sc_cmd->device is NULL.\n", io_req->xid); in bnx2fc_scsi_done()
196 io_req->xid); in bnx2fc_scsi_done()
202 BNX2FC_IO_DBG(io_req, "sc=%p, result=0x%x, retries=%d, allowed=%d\n", in bnx2fc_scsi_done()
214 struct bnx2fc_cmd *io_req; in bnx2fc_cmd_mgr_alloc() local
274 io_req = kzalloc(sizeof(*io_req), GFP_KERNEL); in bnx2fc_cmd_mgr_alloc()
276 if (!io_req) { in bnx2fc_cmd_mgr_alloc()
281 INIT_LIST_HEAD(&io_req->link); in bnx2fc_cmd_mgr_alloc()
282 INIT_DELAYED_WORK(&io_req->timeout_work, bnx2fc_cmd_timeout); in bnx2fc_cmd_mgr_alloc()
284 io_req->xid = xid++; in bnx2fc_cmd_mgr_alloc()
286 list_add_tail(&io_req->link, in bnx2fc_cmd_mgr_alloc()
287 &cmgr->free_list[io_req->xid % in bnx2fc_cmd_mgr_alloc()
290 list_add_tail(&io_req->link, in bnx2fc_cmd_mgr_alloc()
292 io_req++; in bnx2fc_cmd_mgr_alloc()
379 struct bnx2fc_cmd *tmp, *io_req; in bnx2fc_cmd_mgr_free() local
381 list_for_each_entry_safe(io_req, tmp, in bnx2fc_cmd_mgr_free()
383 list_del(&io_req->link); in bnx2fc_cmd_mgr_free()
384 kfree(io_req); in bnx2fc_cmd_mgr_free()
398 struct bnx2fc_cmd *io_req; in bnx2fc_elstm_alloc() local
439 io_req = (struct bnx2fc_cmd *) listp; in bnx2fc_elstm_alloc()
440 xid = io_req->xid; in bnx2fc_elstm_alloc()
441 cmd_mgr->cmds[xid] = io_req; in bnx2fc_elstm_alloc()
446 INIT_LIST_HEAD(&io_req->link); in bnx2fc_elstm_alloc()
448 io_req->port = port; in bnx2fc_elstm_alloc()
449 io_req->cmd_mgr = cmd_mgr; in bnx2fc_elstm_alloc()
450 io_req->req_flags = 0; in bnx2fc_elstm_alloc()
451 io_req->cmd_type = type; in bnx2fc_elstm_alloc()
455 bd_tbl = io_req->bd_tbl = cmd_mgr->io_bdt_pool[xid]; in bnx2fc_elstm_alloc()
456 bd_tbl->io_req = io_req; in bnx2fc_elstm_alloc()
459 kref_init(&io_req->refcount); in bnx2fc_elstm_alloc()
460 return io_req; in bnx2fc_elstm_alloc()
468 struct bnx2fc_cmd *io_req; in bnx2fc_cmd_alloc() local
494 io_req = (struct bnx2fc_cmd *) listp; in bnx2fc_cmd_alloc()
495 xid = io_req->xid; in bnx2fc_cmd_alloc()
496 cmd_mgr->cmds[xid] = io_req; in bnx2fc_cmd_alloc()
502 INIT_LIST_HEAD(&io_req->link); in bnx2fc_cmd_alloc()
504 io_req->port = port; in bnx2fc_cmd_alloc()
505 io_req->cmd_mgr = cmd_mgr; in bnx2fc_cmd_alloc()
506 io_req->req_flags = 0; in bnx2fc_cmd_alloc()
510 bd_tbl = io_req->bd_tbl = cmd_mgr->io_bdt_pool[xid]; in bnx2fc_cmd_alloc()
511 bd_tbl->io_req = io_req; in bnx2fc_cmd_alloc()
514 kref_init(&io_req->refcount); in bnx2fc_cmd_alloc()
515 return io_req; in bnx2fc_cmd_alloc()
520 struct bnx2fc_cmd *io_req = container_of(ref, in bnx2fc_cmd_release() local
522 struct bnx2fc_cmd_mgr *cmd_mgr = io_req->cmd_mgr; in bnx2fc_cmd_release()
525 if (io_req->cmd_type == BNX2FC_SCSI_CMD) in bnx2fc_cmd_release()
526 index = io_req->xid % num_possible_cpus(); in bnx2fc_cmd_release()
532 if (io_req->cmd_type != BNX2FC_SCSI_CMD) in bnx2fc_cmd_release()
533 bnx2fc_free_mp_resc(io_req); in bnx2fc_cmd_release()
534 cmd_mgr->cmds[io_req->xid] = NULL; in bnx2fc_cmd_release()
536 list_del_init(&io_req->link); in bnx2fc_cmd_release()
538 list_add(&io_req->link, in bnx2fc_cmd_release()
540 atomic_dec(&io_req->tgt->num_active_ios); in bnx2fc_cmd_release()
545 static void bnx2fc_free_mp_resc(struct bnx2fc_cmd *io_req) in bnx2fc_free_mp_resc() argument
547 struct bnx2fc_mp_req *mp_req = &(io_req->mp_req); in bnx2fc_free_mp_resc()
548 struct bnx2fc_interface *interface = io_req->port->priv; in bnx2fc_free_mp_resc()
580 int bnx2fc_init_mp_req(struct bnx2fc_cmd *io_req) in bnx2fc_init_mp_req() argument
585 struct bnx2fc_interface *interface = io_req->port->priv; in bnx2fc_init_mp_req()
590 mp_req = (struct bnx2fc_mp_req *)&(io_req->mp_req); in bnx2fc_init_mp_req()
593 if (io_req->cmd_type != BNX2FC_ELS) { in bnx2fc_init_mp_req()
595 io_req->data_xfer_len = mp_req->req_len; in bnx2fc_init_mp_req()
597 mp_req->req_len = io_req->data_xfer_len; in bnx2fc_init_mp_req()
604 bnx2fc_free_mp_resc(io_req); in bnx2fc_init_mp_req()
613 bnx2fc_free_mp_resc(io_req); in bnx2fc_init_mp_req()
626 bnx2fc_free_mp_resc(io_req); in bnx2fc_init_mp_req()
634 bnx2fc_free_mp_resc(io_req); in bnx2fc_init_mp_req()
668 struct bnx2fc_cmd *io_req; in bnx2fc_initiate_tmf() local
711 io_req = bnx2fc_elstm_alloc(tgt, BNX2FC_TASK_MGMT_CMD); in bnx2fc_initiate_tmf()
712 if (!io_req) { in bnx2fc_initiate_tmf()
722 io_req->sc_cmd = sc_cmd; in bnx2fc_initiate_tmf()
723 io_req->port = port; in bnx2fc_initiate_tmf()
724 io_req->tgt = tgt; in bnx2fc_initiate_tmf()
726 tm_req = (struct bnx2fc_mp_req *)&(io_req->mp_req); in bnx2fc_initiate_tmf()
728 rc = bnx2fc_init_mp_req(io_req); in bnx2fc_initiate_tmf()
732 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_initiate_tmf()
738 io_req->io_req_flags = 0; in bnx2fc_initiate_tmf()
742 bnx2fc_build_fcp_cmnd(io_req, (struct fcp_cmnd *)tm_req->req_buf); in bnx2fc_initiate_tmf()
755 xid = io_req->xid; in bnx2fc_initiate_tmf()
765 bnx2fc_init_mp_task(io_req, task); in bnx2fc_initiate_tmf()
767 sc_cmd->SCp.ptr = (char *)io_req; in bnx2fc_initiate_tmf()
774 io_req->on_tmf_queue = 1; in bnx2fc_initiate_tmf()
775 list_add_tail(&io_req->link, &tgt->active_tm_queue); in bnx2fc_initiate_tmf()
777 init_completion(&io_req->tm_done); in bnx2fc_initiate_tmf()
778 io_req->wait_for_comp = 1; in bnx2fc_initiate_tmf()
784 rc = wait_for_completion_timeout(&io_req->tm_done, in bnx2fc_initiate_tmf()
788 io_req->wait_for_comp = 0; in bnx2fc_initiate_tmf()
789 if (!(test_bit(BNX2FC_FLAG_TM_COMPL, &io_req->req_flags))) { in bnx2fc_initiate_tmf()
790 set_bit(BNX2FC_FLAG_TM_TIMEOUT, &io_req->req_flags); in bnx2fc_initiate_tmf()
791 if (io_req->on_tmf_queue) { in bnx2fc_initiate_tmf()
792 list_del_init(&io_req->link); in bnx2fc_initiate_tmf()
793 io_req->on_tmf_queue = 0; in bnx2fc_initiate_tmf()
795 io_req->wait_for_comp = 1; in bnx2fc_initiate_tmf()
796 bnx2fc_initiate_cleanup(io_req); in bnx2fc_initiate_tmf()
798 rc = wait_for_completion_timeout(&io_req->tm_done, in bnx2fc_initiate_tmf()
801 io_req->wait_for_comp = 0; in bnx2fc_initiate_tmf()
803 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_initiate_tmf()
819 int bnx2fc_initiate_abts(struct bnx2fc_cmd *io_req) in bnx2fc_initiate_abts() argument
822 struct bnx2fc_rport *tgt = io_req->tgt; in bnx2fc_initiate_abts()
839 BNX2FC_IO_DBG(io_req, "Entered bnx2fc_initiate_abts\n"); in bnx2fc_initiate_abts()
841 port = io_req->port; in bnx2fc_initiate_abts()
883 fc_hdr->fh_ox_id = htons(io_req->xid); in bnx2fc_initiate_abts()
884 fc_hdr->fh_rx_id = htons(io_req->task->rxwr_txrd.var_ctx.rx_id); in bnx2fc_initiate_abts()
916 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
1001 struct bnx2fc_rport *tgt = io_req->tgt; in bnx2fc_initiate_cleanup()
1012 BNX2FC_IO_DBG(io_req, "Entered bnx2fc_initiate_cleanup\n"); in bnx2fc_initiate_cleanup()
1014 port = io_req->port; in bnx2fc_initiate_cleanup()
1040 orig_xid = io_req->xid; in bnx2fc_initiate_cleanup()
1042 BNX2FC_IO_DBG(io_req, "CLEANUP io_req xid = 0x%x\n", xid); in bnx2fc_initiate_cleanup()
1082 static int bnx2fc_abts_cleanup(struct bnx2fc_cmd *io_req) in bnx2fc_abts_cleanup() argument
1084 struct bnx2fc_rport *tgt = io_req->tgt; in bnx2fc_abts_cleanup()
1087 io_req->wait_for_comp = 1; in bnx2fc_abts_cleanup()
1088 bnx2fc_initiate_cleanup(io_req); in bnx2fc_abts_cleanup()
1092 wait_for_completion(&io_req->tm_done); in bnx2fc_abts_cleanup()
1094 io_req->wait_for_comp = 0; in bnx2fc_abts_cleanup()
1099 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_abts_cleanup()
1116 struct bnx2fc_cmd *io_req; in bnx2fc_eh_abort() local
1136 io_req = (struct bnx2fc_cmd *)sc_cmd->SCp.ptr; in bnx2fc_eh_abort()
1137 if (!io_req) { in bnx2fc_eh_abort()
1143 BNX2FC_IO_DBG(io_req, "eh_abort - refcnt = %d\n", in bnx2fc_eh_abort()
1144 io_req->refcount.refcount.counter); in bnx2fc_eh_abort()
1147 kref_get(&io_req->refcount); in bnx2fc_eh_abort()
1149 BUG_ON(tgt != io_req->tgt); in bnx2fc_eh_abort()
1159 "flush in progress\n", io_req->xid); in bnx2fc_eh_abort()
1160 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_eh_abort()
1165 if (io_req->on_active_queue == 0) { in bnx2fc_eh_abort()
1167 "not on active_q\n", io_req->xid); in bnx2fc_eh_abort()
1174 bnx2fc_scsi_done(io_req, DID_ABORT); in bnx2fc_eh_abort()
1176 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_eh_abort()
1188 list_del_init(&io_req->link); in bnx2fc_eh_abort()
1189 io_req->on_active_queue = 0; in bnx2fc_eh_abort()
1191 list_add_tail(&io_req->link, &tgt->io_retire_queue); in bnx2fc_eh_abort()
1193 init_completion(&io_req->tm_done); in bnx2fc_eh_abort()
1195 if (test_and_set_bit(BNX2FC_FLAG_ISSUE_ABTS, &io_req->req_flags)) { in bnx2fc_eh_abort()
1197 "already in abts processing\n", io_req->xid); in bnx2fc_eh_abort()
1198 if (cancel_delayed_work(&io_req->timeout_work)) in bnx2fc_eh_abort()
1199 kref_put(&io_req->refcount, in bnx2fc_eh_abort()
1201 rc = bnx2fc_abts_cleanup(io_req); in bnx2fc_eh_abort()
1207 set_bit(BNX2FC_FLAG_IO_CLEANUP, &io_req->req_flags); in bnx2fc_eh_abort()
1212 if (cancel_delayed_work(&io_req->timeout_work)) in bnx2fc_eh_abort()
1213 kref_put(&io_req->refcount, in bnx2fc_eh_abort()
1215 set_bit(BNX2FC_FLAG_EH_ABORT, &io_req->req_flags); in bnx2fc_eh_abort()
1216 io_req->wait_for_comp = 1; in bnx2fc_eh_abort()
1217 rc = bnx2fc_initiate_abts(io_req); in bnx2fc_eh_abort()
1219 bnx2fc_initiate_cleanup(io_req); in bnx2fc_eh_abort()
1221 wait_for_completion(&io_req->tm_done); in bnx2fc_eh_abort()
1223 io_req->wait_for_comp = 0; in bnx2fc_eh_abort()
1228 wait_for_completion(&io_req->tm_done); in bnx2fc_eh_abort()
1231 io_req->wait_for_comp = 0; in bnx2fc_eh_abort()
1232 if (test_bit(BNX2FC_FLAG_IO_COMPL, &io_req->req_flags)) { in bnx2fc_eh_abort()
1233 BNX2FC_IO_DBG(io_req, "IO completed in a different context\n"); in bnx2fc_eh_abort()
1236 &io_req->req_flags))) { in bnx2fc_eh_abort()
1239 io_req->xid); in bnx2fc_eh_abort()
1240 rc = bnx2fc_abts_cleanup(io_req); in bnx2fc_eh_abort()
1248 BNX2FC_IO_DBG(io_req, "abort succeeded\n"); in bnx2fc_eh_abort()
1250 bnx2fc_scsi_done(io_req, DID_ABORT); in bnx2fc_eh_abort()
1251 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_eh_abort()
1255 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_eh_abort()
1296 void bnx2fc_process_cleanup_compl(struct bnx2fc_cmd *io_req, in bnx2fc_process_cleanup_compl() argument
1300 BNX2FC_IO_DBG(io_req, "Entered process_cleanup_compl " in bnx2fc_process_cleanup_compl()
1302 io_req->refcount.refcount.counter, io_req->cmd_type); in bnx2fc_process_cleanup_compl()
1303 bnx2fc_scsi_done(io_req, DID_ERROR); in bnx2fc_process_cleanup_compl()
1304 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_process_cleanup_compl()
1305 if (io_req->wait_for_comp) in bnx2fc_process_cleanup_compl()
1306 complete(&io_req->tm_done); in bnx2fc_process_cleanup_compl()
1309 void bnx2fc_process_abts_compl(struct bnx2fc_cmd *io_req, in bnx2fc_process_abts_compl() argument
1316 struct bnx2fc_rport *tgt = io_req->tgt; in bnx2fc_process_abts_compl()
1318 BNX2FC_IO_DBG(io_req, "Entered process_abts_compl xid = 0x%x" in bnx2fc_process_abts_compl()
1320 io_req->xid, in bnx2fc_process_abts_compl()
1321 io_req->refcount.refcount.counter, io_req->cmd_type); in bnx2fc_process_abts_compl()
1324 &io_req->req_flags)) { in bnx2fc_process_abts_compl()
1325 BNX2FC_IO_DBG(io_req, "Timer context finished processing" in bnx2fc_process_abts_compl()
1332 &io_req->req_flags)) in bnx2fc_process_abts_compl()
1341 if (test_bit(BNX2FC_FLAG_ISSUE_ABTS, &io_req->req_flags)) in bnx2fc_process_abts_compl()
1342 if (cancel_delayed_work(&io_req->timeout_work)) in bnx2fc_process_abts_compl()
1343 kref_put(&io_req->refcount, in bnx2fc_process_abts_compl()
1354 BNX2FC_IO_DBG(io_req, "ABTS response - ACC Send RRQ\n"); in bnx2fc_process_abts_compl()
1359 BNX2FC_IO_DBG(io_req, "ABTS response - RJT\n"); in bnx2fc_process_abts_compl()
1367 BNX2FC_IO_DBG(io_req, "Issue RRQ after R_A_TOV\n"); in bnx2fc_process_abts_compl()
1368 set_bit(BNX2FC_FLAG_ISSUE_RRQ, &io_req->req_flags); in bnx2fc_process_abts_compl()
1370 set_bit(BNX2FC_FLAG_RETIRE_OXID, &io_req->req_flags); in bnx2fc_process_abts_compl()
1371 bnx2fc_cmd_timer_set(io_req, r_a_tov); in bnx2fc_process_abts_compl()
1374 if (io_req->wait_for_comp) { in bnx2fc_process_abts_compl()
1376 &io_req->req_flags)) in bnx2fc_process_abts_compl()
1377 complete(&io_req->tm_done); in bnx2fc_process_abts_compl()
1388 if (io_req->on_active_queue) { in bnx2fc_process_abts_compl()
1389 list_del_init(&io_req->link); in bnx2fc_process_abts_compl()
1390 io_req->on_active_queue = 0; in bnx2fc_process_abts_compl()
1392 list_add_tail(&io_req->link, &tgt->io_retire_queue); in bnx2fc_process_abts_compl()
1394 bnx2fc_scsi_done(io_req, DID_ERROR); in bnx2fc_process_abts_compl()
1395 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_process_abts_compl()
1399 static void bnx2fc_lun_reset_cmpl(struct bnx2fc_cmd *io_req) in bnx2fc_lun_reset_cmpl() argument
1401 struct scsi_cmnd *sc_cmd = io_req->sc_cmd; in bnx2fc_lun_reset_cmpl()
1402 struct bnx2fc_rport *tgt = io_req->tgt; in bnx2fc_lun_reset_cmpl()
1409 BNX2FC_IO_DBG(io_req, "Entered bnx2fc_lun_reset_cmpl\n"); in bnx2fc_lun_reset_cmpl()
1422 if (cancel_delayed_work(&io_req->timeout_work)) in bnx2fc_lun_reset_cmpl()
1423 kref_put(&io_req->refcount, in bnx2fc_lun_reset_cmpl()
1437 static void bnx2fc_tgt_reset_cmpl(struct bnx2fc_cmd *io_req) in bnx2fc_tgt_reset_cmpl() argument
1439 struct bnx2fc_rport *tgt = io_req->tgt; in bnx2fc_tgt_reset_cmpl()
1444 BNX2FC_IO_DBG(io_req, "Entered bnx2fc_tgt_reset_cmpl\n"); in bnx2fc_tgt_reset_cmpl()
1455 if (cancel_delayed_work(&io_req->timeout_work)) in bnx2fc_tgt_reset_cmpl()
1456 kref_put(&io_req->refcount, in bnx2fc_tgt_reset_cmpl()
1468 void bnx2fc_process_tm_compl(struct bnx2fc_cmd *io_req, in bnx2fc_process_tm_compl() argument
1473 struct scsi_cmnd *sc_cmd = io_req->sc_cmd; in bnx2fc_process_tm_compl()
1479 BNX2FC_IO_DBG(io_req, "Entered process_tm_compl\n"); in bnx2fc_process_tm_compl()
1481 if (!(test_bit(BNX2FC_FLAG_TM_TIMEOUT, &io_req->req_flags))) in bnx2fc_process_tm_compl()
1482 set_bit(BNX2FC_FLAG_TM_COMPL, &io_req->req_flags); in bnx2fc_process_tm_compl()
1491 tm_req = &(io_req->mp_req); in bnx2fc_process_tm_compl()
1506 bnx2fc_parse_fcp_rsp(io_req, in bnx2fc_process_tm_compl()
1509 if (io_req->fcp_rsp_code == 0) { in bnx2fc_process_tm_compl()
1512 bnx2fc_lun_reset_cmpl(io_req); in bnx2fc_process_tm_compl()
1514 bnx2fc_tgt_reset_cmpl(io_req); in bnx2fc_process_tm_compl()
1524 switch (io_req->fcp_status) { in bnx2fc_process_tm_compl()
1526 if (io_req->cdb_status == 0) { in bnx2fc_process_tm_compl()
1531 sc_cmd->result = (DID_OK << 16) | io_req->cdb_status; in bnx2fc_process_tm_compl()
1533 if (io_req->fcp_resid) in bnx2fc_process_tm_compl()
1534 scsi_set_resid(sc_cmd, io_req->fcp_resid); in bnx2fc_process_tm_compl()
1538 BNX2FC_IO_DBG(io_req, "process_tm_compl: fcp_status = %d\n", in bnx2fc_process_tm_compl()
1539 io_req->fcp_status); in bnx2fc_process_tm_compl()
1543 sc_cmd = io_req->sc_cmd; in bnx2fc_process_tm_compl()
1544 io_req->sc_cmd = NULL; in bnx2fc_process_tm_compl()
1547 if (io_req->on_tmf_queue) { in bnx2fc_process_tm_compl()
1549 list_del_init(&io_req->link); in bnx2fc_process_tm_compl()
1550 io_req->on_tmf_queue = 0; in bnx2fc_process_tm_compl()
1560 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_process_tm_compl()
1561 if (io_req->wait_for_comp) { in bnx2fc_process_tm_compl()
1562 BNX2FC_IO_DBG(io_req, "tm_compl - wake up the waiter\n"); in bnx2fc_process_tm_compl()
1563 complete(&io_req->tm_done); in bnx2fc_process_tm_compl()
1567 static int bnx2fc_split_bd(struct bnx2fc_cmd *io_req, u64 addr, int sg_len, in bnx2fc_split_bd() argument
1570 struct fcoe_bd_ctx *bd = io_req->bd_tbl->bd_tbl; in bnx2fc_split_bd()
1592 static int bnx2fc_map_sg(struct bnx2fc_cmd *io_req) in bnx2fc_map_sg() argument
1594 struct bnx2fc_interface *interface = io_req->port->priv; in bnx2fc_map_sg()
1596 struct scsi_cmnd *sc = io_req->sc_cmd; in bnx2fc_map_sg()
1597 struct fcoe_bd_ctx *bd = io_req->bd_tbl->bd_tbl; in bnx2fc_map_sg()
1617 sg_frags = bnx2fc_split_bd(io_req, addr, sg_len, in bnx2fc_map_sg()
1633 io_req->xid); in bnx2fc_map_sg()
1637 static int bnx2fc_build_bd_list_from_sg(struct bnx2fc_cmd *io_req) in bnx2fc_build_bd_list_from_sg() argument
1639 struct scsi_cmnd *sc = io_req->sc_cmd; in bnx2fc_build_bd_list_from_sg()
1640 struct fcoe_bd_ctx *bd = io_req->bd_tbl->bd_tbl; in bnx2fc_build_bd_list_from_sg()
1644 bd_count = bnx2fc_map_sg(io_req); in bnx2fc_build_bd_list_from_sg()
1652 io_req->bd_tbl->bd_valid = bd_count; in bnx2fc_build_bd_list_from_sg()
1657 static void bnx2fc_unmap_sg_list(struct bnx2fc_cmd *io_req) in bnx2fc_unmap_sg_list() argument
1659 struct scsi_cmnd *sc = io_req->sc_cmd; in bnx2fc_unmap_sg_list()
1660 struct bnx2fc_interface *interface = io_req->port->priv; in bnx2fc_unmap_sg_list()
1667 if (io_req->bd_tbl->bd_valid && sc && scsi_sg_count(sc)) { in bnx2fc_unmap_sg_list()
1670 io_req->bd_tbl->bd_valid = 0; in bnx2fc_unmap_sg_list()
1674 void bnx2fc_build_fcp_cmnd(struct bnx2fc_cmd *io_req, in bnx2fc_build_fcp_cmnd() argument
1677 struct scsi_cmnd *sc_cmd = io_req->sc_cmd; in bnx2fc_build_fcp_cmnd()
1683 fcp_cmnd->fc_dl = htonl(io_req->data_xfer_len); in bnx2fc_build_fcp_cmnd()
1688 fcp_cmnd->fc_tm_flags = io_req->mp_req.tm_flags; in bnx2fc_build_fcp_cmnd()
1689 fcp_cmnd->fc_flags = io_req->io_req_flags; in bnx2fc_build_fcp_cmnd()
1693 static void bnx2fc_parse_fcp_rsp(struct bnx2fc_cmd *io_req, in bnx2fc_parse_fcp_rsp() argument
1697 struct scsi_cmnd *sc_cmd = io_req->sc_cmd; in bnx2fc_parse_fcp_rsp()
1698 struct bnx2fc_rport *tgt = io_req->tgt; in bnx2fc_parse_fcp_rsp()
1707 io_req->fcp_status = FC_GOOD; in bnx2fc_parse_fcp_rsp()
1708 io_req->fcp_resid = 0; in bnx2fc_parse_fcp_rsp()
1711 io_req->fcp_resid = fcp_rsp->fcp_resid; in bnx2fc_parse_fcp_rsp()
1713 io_req->scsi_comp_flags = rsp_flags; in bnx2fc_parse_fcp_rsp()
1714 CMD_SCSI_STATUS(sc_cmd) = io_req->cdb_status = in bnx2fc_parse_fcp_rsp()
1738 io_req->fcp_rsp_len = fcp_rsp_len; in bnx2fc_parse_fcp_rsp()
1739 io_req->fcp_sns_len = fcp_sns_len; in bnx2fc_parse_fcp_rsp()
1760 io_req->fcp_rsp_code = rq_data[3]; in bnx2fc_parse_fcp_rsp()
1761 BNX2FC_IO_DBG(io_req, "fcp_rsp_code = %d\n", in bnx2fc_parse_fcp_rsp()
1762 io_req->fcp_rsp_code); in bnx2fc_parse_fcp_rsp()
1798 struct bnx2fc_cmd *io_req; in bnx2fc_queuecommand() local
1837 io_req = bnx2fc_cmd_alloc(tgt); in bnx2fc_queuecommand()
1838 if (!io_req) { in bnx2fc_queuecommand()
1842 io_req->sc_cmd = sc_cmd; in bnx2fc_queuecommand()
1844 if (bnx2fc_post_io_req(tgt, io_req)) { in bnx2fc_queuecommand()
1856 void bnx2fc_process_scsi_cmd_compl(struct bnx2fc_cmd *io_req, in bnx2fc_process_scsi_cmd_compl() argument
1861 struct bnx2fc_rport *tgt = io_req->tgt; in bnx2fc_process_scsi_cmd_compl()
1868 if (test_and_set_bit(BNX2FC_FLAG_IO_COMPL, &io_req->req_flags)) { in bnx2fc_process_scsi_cmd_compl()
1870 BNX2FC_IO_DBG(io_req, "Timer context finished processing " in bnx2fc_process_scsi_cmd_compl()
1875 if (cancel_delayed_work(&io_req->timeout_work)) in bnx2fc_process_scsi_cmd_compl()
1876 kref_put(&io_req->refcount, in bnx2fc_process_scsi_cmd_compl()
1879 sc_cmd = io_req->sc_cmd; in bnx2fc_process_scsi_cmd_compl()
1890 bnx2fc_parse_fcp_rsp(io_req, fcp_rsp, num_rq); in bnx2fc_process_scsi_cmd_compl()
1898 if (io_req->on_active_queue) { in bnx2fc_process_scsi_cmd_compl()
1899 list_del_init(&io_req->link); in bnx2fc_process_scsi_cmd_compl()
1900 io_req->on_active_queue = 0; in bnx2fc_process_scsi_cmd_compl()
1902 list_add_tail(&io_req->link, &tgt->io_retire_queue); in bnx2fc_process_scsi_cmd_compl()
1908 BNX2FC_IO_DBG(io_req, "xid not on active_cmd_queue\n"); in bnx2fc_process_scsi_cmd_compl()
1909 if (io_req->wait_for_comp) in bnx2fc_process_scsi_cmd_compl()
1911 &io_req->req_flags)) in bnx2fc_process_scsi_cmd_compl()
1912 complete(&io_req->tm_done); in bnx2fc_process_scsi_cmd_compl()
1915 bnx2fc_unmap_sg_list(io_req); in bnx2fc_process_scsi_cmd_compl()
1916 io_req->sc_cmd = NULL; in bnx2fc_process_scsi_cmd_compl()
1918 switch (io_req->fcp_status) { in bnx2fc_process_scsi_cmd_compl()
1920 if (io_req->cdb_status == 0) { in bnx2fc_process_scsi_cmd_compl()
1925 BNX2FC_IO_DBG(io_req, "scsi_cmpl: cdb_status = %d" in bnx2fc_process_scsi_cmd_compl()
1927 io_req->cdb_status, io_req->fcp_resid); in bnx2fc_process_scsi_cmd_compl()
1928 sc_cmd->result = (DID_OK << 16) | io_req->cdb_status; in bnx2fc_process_scsi_cmd_compl()
1930 if (io_req->cdb_status == SAM_STAT_TASK_SET_FULL || in bnx2fc_process_scsi_cmd_compl()
1931 io_req->cdb_status == SAM_STAT_BUSY) { in bnx2fc_process_scsi_cmd_compl()
1939 if (io_req->fcp_resid) in bnx2fc_process_scsi_cmd_compl()
1940 scsi_set_resid(sc_cmd, io_req->fcp_resid); in bnx2fc_process_scsi_cmd_compl()
1944 io_req->fcp_status); in bnx2fc_process_scsi_cmd_compl()
1949 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_process_scsi_cmd_compl()
1953 struct bnx2fc_cmd *io_req) in bnx2fc_post_io_req() argument
1957 struct scsi_cmnd *sc_cmd = io_req->sc_cmd; in bnx2fc_post_io_req()
1969 io_req->cmd_type = BNX2FC_SCSI_CMD; in bnx2fc_post_io_req()
1970 io_req->port = port; in bnx2fc_post_io_req()
1971 io_req->tgt = tgt; in bnx2fc_post_io_req()
1972 io_req->data_xfer_len = scsi_bufflen(sc_cmd); in bnx2fc_post_io_req()
1973 sc_cmd->SCp.ptr = (char *)io_req; in bnx2fc_post_io_req()
1977 io_req->io_req_flags = BNX2FC_READ; in bnx2fc_post_io_req()
1979 stats->InputBytes += io_req->data_xfer_len; in bnx2fc_post_io_req()
1981 io_req->io_req_flags = BNX2FC_WRITE; in bnx2fc_post_io_req()
1983 stats->OutputBytes += io_req->data_xfer_len; in bnx2fc_post_io_req()
1985 io_req->io_req_flags = 0; in bnx2fc_post_io_req()
1990 xid = io_req->xid; in bnx2fc_post_io_req()
1993 if (bnx2fc_build_bd_list_from_sg(io_req)) { in bnx2fc_post_io_req()
1995 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_post_io_req()
2005 bnx2fc_init_task(io_req, task); in bnx2fc_post_io_req()
2009 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_post_io_req()
2015 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_post_io_req()
2021 bnx2fc_cmd_timer_set(io_req, BNX2FC_IO_TIMEOUT); in bnx2fc_post_io_req()
2027 io_req->on_active_queue = 1; in bnx2fc_post_io_req()
2029 list_add_tail(&io_req->link, &tgt->active_cmd_queue); in bnx2fc_post_io_req()