• 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()
185 io_req->xid); in bnx2fc_scsi_done()
190 BNX2FC_IO_DBG(io_req, "sc=%p, result=0x%x, retries=%d, allowed=%d\n", in bnx2fc_scsi_done()
202 struct bnx2fc_cmd *io_req; in bnx2fc_cmd_mgr_alloc() local
262 io_req = kzalloc(sizeof(*io_req), GFP_KERNEL); in bnx2fc_cmd_mgr_alloc()
264 if (!io_req) { in bnx2fc_cmd_mgr_alloc()
269 INIT_LIST_HEAD(&io_req->link); in bnx2fc_cmd_mgr_alloc()
270 INIT_DELAYED_WORK(&io_req->timeout_work, bnx2fc_cmd_timeout); in bnx2fc_cmd_mgr_alloc()
272 io_req->xid = xid++; in bnx2fc_cmd_mgr_alloc()
274 list_add_tail(&io_req->link, in bnx2fc_cmd_mgr_alloc()
275 &cmgr->free_list[io_req->xid % in bnx2fc_cmd_mgr_alloc()
278 list_add_tail(&io_req->link, in bnx2fc_cmd_mgr_alloc()
280 io_req++; in bnx2fc_cmd_mgr_alloc()
367 struct bnx2fc_cmd *tmp, *io_req; in bnx2fc_cmd_mgr_free() local
369 list_for_each_entry_safe(io_req, tmp, in bnx2fc_cmd_mgr_free()
371 list_del(&io_req->link); in bnx2fc_cmd_mgr_free()
372 kfree(io_req); in bnx2fc_cmd_mgr_free()
386 struct bnx2fc_cmd *io_req; in bnx2fc_elstm_alloc() local
427 io_req = (struct bnx2fc_cmd *) listp; in bnx2fc_elstm_alloc()
428 xid = io_req->xid; in bnx2fc_elstm_alloc()
429 cmd_mgr->cmds[xid] = io_req; in bnx2fc_elstm_alloc()
434 INIT_LIST_HEAD(&io_req->link); in bnx2fc_elstm_alloc()
436 io_req->port = port; in bnx2fc_elstm_alloc()
437 io_req->cmd_mgr = cmd_mgr; in bnx2fc_elstm_alloc()
438 io_req->req_flags = 0; in bnx2fc_elstm_alloc()
439 io_req->cmd_type = type; in bnx2fc_elstm_alloc()
443 bd_tbl = io_req->bd_tbl = cmd_mgr->io_bdt_pool[xid]; in bnx2fc_elstm_alloc()
444 bd_tbl->io_req = io_req; in bnx2fc_elstm_alloc()
447 kref_init(&io_req->refcount); in bnx2fc_elstm_alloc()
448 return io_req; in bnx2fc_elstm_alloc()
456 struct bnx2fc_cmd *io_req; in bnx2fc_cmd_alloc() local
482 io_req = (struct bnx2fc_cmd *) listp; in bnx2fc_cmd_alloc()
483 xid = io_req->xid; in bnx2fc_cmd_alloc()
484 cmd_mgr->cmds[xid] = io_req; in bnx2fc_cmd_alloc()
490 INIT_LIST_HEAD(&io_req->link); in bnx2fc_cmd_alloc()
492 io_req->port = port; in bnx2fc_cmd_alloc()
493 io_req->cmd_mgr = cmd_mgr; in bnx2fc_cmd_alloc()
494 io_req->req_flags = 0; in bnx2fc_cmd_alloc()
498 bd_tbl = io_req->bd_tbl = cmd_mgr->io_bdt_pool[xid]; in bnx2fc_cmd_alloc()
499 bd_tbl->io_req = io_req; in bnx2fc_cmd_alloc()
502 kref_init(&io_req->refcount); in bnx2fc_cmd_alloc()
503 return io_req; in bnx2fc_cmd_alloc()
508 struct bnx2fc_cmd *io_req = container_of(ref, in bnx2fc_cmd_release() local
510 struct bnx2fc_cmd_mgr *cmd_mgr = io_req->cmd_mgr; in bnx2fc_cmd_release()
513 if (io_req->cmd_type == BNX2FC_SCSI_CMD) in bnx2fc_cmd_release()
514 index = io_req->xid % num_possible_cpus(); in bnx2fc_cmd_release()
520 if (io_req->cmd_type != BNX2FC_SCSI_CMD) in bnx2fc_cmd_release()
521 bnx2fc_free_mp_resc(io_req); in bnx2fc_cmd_release()
522 cmd_mgr->cmds[io_req->xid] = NULL; in bnx2fc_cmd_release()
524 list_del_init(&io_req->link); in bnx2fc_cmd_release()
526 list_add(&io_req->link, in bnx2fc_cmd_release()
528 atomic_dec(&io_req->tgt->num_active_ios); in bnx2fc_cmd_release()
533 static void bnx2fc_free_mp_resc(struct bnx2fc_cmd *io_req) in bnx2fc_free_mp_resc() argument
535 struct bnx2fc_mp_req *mp_req = &(io_req->mp_req); in bnx2fc_free_mp_resc()
536 struct bnx2fc_interface *interface = io_req->port->priv; in bnx2fc_free_mp_resc()
568 int bnx2fc_init_mp_req(struct bnx2fc_cmd *io_req) in bnx2fc_init_mp_req() argument
573 struct bnx2fc_interface *interface = io_req->port->priv; in bnx2fc_init_mp_req()
578 mp_req = (struct bnx2fc_mp_req *)&(io_req->mp_req); in bnx2fc_init_mp_req()
581 if (io_req->cmd_type != BNX2FC_ELS) { in bnx2fc_init_mp_req()
583 io_req->data_xfer_len = mp_req->req_len; in bnx2fc_init_mp_req()
585 mp_req->req_len = io_req->data_xfer_len; in bnx2fc_init_mp_req()
592 bnx2fc_free_mp_resc(io_req); in bnx2fc_init_mp_req()
601 bnx2fc_free_mp_resc(io_req); in bnx2fc_init_mp_req()
614 bnx2fc_free_mp_resc(io_req); in bnx2fc_init_mp_req()
622 bnx2fc_free_mp_resc(io_req); in bnx2fc_init_mp_req()
656 struct bnx2fc_cmd *io_req; in bnx2fc_initiate_tmf() local
699 io_req = bnx2fc_elstm_alloc(tgt, BNX2FC_TASK_MGMT_CMD); in bnx2fc_initiate_tmf()
700 if (!io_req) { in bnx2fc_initiate_tmf()
710 io_req->sc_cmd = sc_cmd; in bnx2fc_initiate_tmf()
711 io_req->port = port; in bnx2fc_initiate_tmf()
712 io_req->tgt = tgt; in bnx2fc_initiate_tmf()
714 tm_req = (struct bnx2fc_mp_req *)&(io_req->mp_req); in bnx2fc_initiate_tmf()
716 rc = bnx2fc_init_mp_req(io_req); in bnx2fc_initiate_tmf()
720 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_initiate_tmf()
726 io_req->io_req_flags = 0; in bnx2fc_initiate_tmf()
730 bnx2fc_build_fcp_cmnd(io_req, (struct fcp_cmnd *)tm_req->req_buf); in bnx2fc_initiate_tmf()
743 xid = io_req->xid; in bnx2fc_initiate_tmf()
753 bnx2fc_init_mp_task(io_req, task); in bnx2fc_initiate_tmf()
755 sc_cmd->SCp.ptr = (char *)io_req; in bnx2fc_initiate_tmf()
762 io_req->on_tmf_queue = 1; in bnx2fc_initiate_tmf()
763 list_add_tail(&io_req->link, &tgt->active_tm_queue); in bnx2fc_initiate_tmf()
765 init_completion(&io_req->tm_done); in bnx2fc_initiate_tmf()
766 io_req->wait_for_comp = 1; in bnx2fc_initiate_tmf()
772 rc = wait_for_completion_timeout(&io_req->tm_done, in bnx2fc_initiate_tmf()
776 io_req->wait_for_comp = 0; in bnx2fc_initiate_tmf()
777 if (!(test_bit(BNX2FC_FLAG_TM_COMPL, &io_req->req_flags))) { in bnx2fc_initiate_tmf()
778 set_bit(BNX2FC_FLAG_TM_TIMEOUT, &io_req->req_flags); in bnx2fc_initiate_tmf()
779 if (io_req->on_tmf_queue) { in bnx2fc_initiate_tmf()
780 list_del_init(&io_req->link); in bnx2fc_initiate_tmf()
781 io_req->on_tmf_queue = 0; in bnx2fc_initiate_tmf()
783 io_req->wait_for_comp = 1; in bnx2fc_initiate_tmf()
784 bnx2fc_initiate_cleanup(io_req); in bnx2fc_initiate_tmf()
786 rc = wait_for_completion_timeout(&io_req->tm_done, in bnx2fc_initiate_tmf()
789 io_req->wait_for_comp = 0; in bnx2fc_initiate_tmf()
791 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_initiate_tmf()
807 int bnx2fc_initiate_abts(struct bnx2fc_cmd *io_req) in bnx2fc_initiate_abts() argument
810 struct bnx2fc_rport *tgt = io_req->tgt; in bnx2fc_initiate_abts()
827 BNX2FC_IO_DBG(io_req, "Entered bnx2fc_initiate_abts\n"); in bnx2fc_initiate_abts()
829 port = io_req->port; in bnx2fc_initiate_abts()
871 fc_hdr->fh_ox_id = htons(io_req->xid); in bnx2fc_initiate_abts()
872 fc_hdr->fh_rx_id = htons(io_req->task->rxwr_txrd.var_ctx.rx_id); in bnx2fc_initiate_abts()
904 bnx2fc_cmd_timer_set(io_req, 2 * r_a_tov); in bnx2fc_initiate_abts()
969 cb_arg->io_req = seq_clnp_req; in bnx2fc_initiate_seq_cleanup()
986 int bnx2fc_initiate_cleanup(struct bnx2fc_cmd *io_req) in bnx2fc_initiate_cleanup() argument
989 struct bnx2fc_rport *tgt = io_req->tgt; in bnx2fc_initiate_cleanup()
1000 BNX2FC_IO_DBG(io_req, "Entered bnx2fc_initiate_cleanup\n"); in bnx2fc_initiate_cleanup()
1002 port = io_req->port; in bnx2fc_initiate_cleanup()
1028 orig_xid = io_req->xid; in bnx2fc_initiate_cleanup()
1030 BNX2FC_IO_DBG(io_req, "CLEANUP io_req xid = 0x%x\n", xid); in bnx2fc_initiate_cleanup()
1070 int bnx2fc_abts_cleanup(struct bnx2fc_cmd *io_req) in bnx2fc_abts_cleanup() argument
1072 struct bnx2fc_rport *tgt = io_req->tgt; in bnx2fc_abts_cleanup()
1075 io_req->wait_for_comp = 1; in bnx2fc_abts_cleanup()
1076 bnx2fc_initiate_cleanup(io_req); in bnx2fc_abts_cleanup()
1080 wait_for_completion(&io_req->tm_done); in bnx2fc_abts_cleanup()
1082 io_req->wait_for_comp = 0; in bnx2fc_abts_cleanup()
1087 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_abts_cleanup()
1104 struct bnx2fc_cmd *io_req; in bnx2fc_eh_abort() local
1125 io_req = (struct bnx2fc_cmd *)sc_cmd->SCp.ptr; in bnx2fc_eh_abort()
1126 if (!io_req) { in bnx2fc_eh_abort()
1132 BNX2FC_IO_DBG(io_req, "eh_abort - refcnt = %d\n", in bnx2fc_eh_abort()
1133 io_req->refcount.refcount.counter); in bnx2fc_eh_abort()
1136 kref_get(&io_req->refcount); in bnx2fc_eh_abort()
1138 BUG_ON(tgt != io_req->tgt); in bnx2fc_eh_abort()
1148 "flush in progress\n", io_req->xid); in bnx2fc_eh_abort()
1149 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_eh_abort()
1154 if (io_req->on_active_queue == 0) { in bnx2fc_eh_abort()
1156 "not on active_q\n", io_req->xid); in bnx2fc_eh_abort()
1163 bnx2fc_scsi_done(io_req, DID_ABORT); in bnx2fc_eh_abort()
1165 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_eh_abort()
1177 list_del_init(&io_req->link); in bnx2fc_eh_abort()
1178 io_req->on_active_queue = 0; in bnx2fc_eh_abort()
1180 list_add_tail(&io_req->link, &tgt->io_retire_queue); in bnx2fc_eh_abort()
1182 init_completion(&io_req->tm_done); in bnx2fc_eh_abort()
1184 if (test_and_set_bit(BNX2FC_FLAG_ISSUE_ABTS, &io_req->req_flags)) { in bnx2fc_eh_abort()
1186 "already in abts processing\n", io_req->xid); in bnx2fc_eh_abort()
1187 if (cancel_delayed_work(&io_req->timeout_work)) in bnx2fc_eh_abort()
1188 kref_put(&io_req->refcount, in bnx2fc_eh_abort()
1190 rc = bnx2fc_abts_cleanup(io_req); in bnx2fc_eh_abort()
1196 set_bit(BNX2FC_FLAG_IO_CLEANUP, &io_req->req_flags); in bnx2fc_eh_abort()
1201 if (cancel_delayed_work(&io_req->timeout_work)) in bnx2fc_eh_abort()
1202 kref_put(&io_req->refcount, in bnx2fc_eh_abort()
1204 set_bit(BNX2FC_FLAG_EH_ABORT, &io_req->req_flags); in bnx2fc_eh_abort()
1205 io_req->wait_for_comp = 1; in bnx2fc_eh_abort()
1206 rc = bnx2fc_initiate_abts(io_req); in bnx2fc_eh_abort()
1208 bnx2fc_initiate_cleanup(io_req); in bnx2fc_eh_abort()
1210 wait_for_completion(&io_req->tm_done); in bnx2fc_eh_abort()
1212 io_req->wait_for_comp = 0; in bnx2fc_eh_abort()
1217 wait_for_completion(&io_req->tm_done); in bnx2fc_eh_abort()
1220 io_req->wait_for_comp = 0; in bnx2fc_eh_abort()
1221 if (test_bit(BNX2FC_FLAG_IO_COMPL, &io_req->req_flags)) { in bnx2fc_eh_abort()
1222 BNX2FC_IO_DBG(io_req, "IO completed in a different context\n"); in bnx2fc_eh_abort()
1225 &io_req->req_flags))) { in bnx2fc_eh_abort()
1228 io_req->xid); in bnx2fc_eh_abort()
1229 rc = bnx2fc_abts_cleanup(io_req); in bnx2fc_eh_abort()
1237 BNX2FC_IO_DBG(io_req, "abort succeeded\n"); in bnx2fc_eh_abort()
1239 bnx2fc_scsi_done(io_req, DID_ABORT); in bnx2fc_eh_abort()
1240 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_eh_abort()
1244 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_eh_abort()
1285 void bnx2fc_process_cleanup_compl(struct bnx2fc_cmd *io_req, in bnx2fc_process_cleanup_compl() argument
1289 BNX2FC_IO_DBG(io_req, "Entered process_cleanup_compl " in bnx2fc_process_cleanup_compl()
1291 io_req->refcount.refcount.counter, io_req->cmd_type); in bnx2fc_process_cleanup_compl()
1292 bnx2fc_scsi_done(io_req, DID_ERROR); in bnx2fc_process_cleanup_compl()
1293 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_process_cleanup_compl()
1294 if (io_req->wait_for_comp) in bnx2fc_process_cleanup_compl()
1295 complete(&io_req->tm_done); in bnx2fc_process_cleanup_compl()
1298 void bnx2fc_process_abts_compl(struct bnx2fc_cmd *io_req, in bnx2fc_process_abts_compl() argument
1305 struct bnx2fc_rport *tgt = io_req->tgt; in bnx2fc_process_abts_compl()
1307 BNX2FC_IO_DBG(io_req, "Entered process_abts_compl xid = 0x%x" in bnx2fc_process_abts_compl()
1309 io_req->xid, in bnx2fc_process_abts_compl()
1310 io_req->refcount.refcount.counter, io_req->cmd_type); in bnx2fc_process_abts_compl()
1313 &io_req->req_flags)) { in bnx2fc_process_abts_compl()
1314 BNX2FC_IO_DBG(io_req, "Timer context finished processing" in bnx2fc_process_abts_compl()
1321 &io_req->req_flags)) in bnx2fc_process_abts_compl()
1330 if (test_bit(BNX2FC_FLAG_ISSUE_ABTS, &io_req->req_flags)) in bnx2fc_process_abts_compl()
1331 if (cancel_delayed_work(&io_req->timeout_work)) in bnx2fc_process_abts_compl()
1332 kref_put(&io_req->refcount, in bnx2fc_process_abts_compl()
1343 BNX2FC_IO_DBG(io_req, "ABTS response - ACC Send RRQ\n"); in bnx2fc_process_abts_compl()
1348 BNX2FC_IO_DBG(io_req, "ABTS response - RJT\n"); in bnx2fc_process_abts_compl()
1356 BNX2FC_IO_DBG(io_req, "Issue RRQ after R_A_TOV\n"); in bnx2fc_process_abts_compl()
1357 set_bit(BNX2FC_FLAG_ISSUE_RRQ, &io_req->req_flags); in bnx2fc_process_abts_compl()
1359 set_bit(BNX2FC_FLAG_RETIRE_OXID, &io_req->req_flags); in bnx2fc_process_abts_compl()
1360 bnx2fc_cmd_timer_set(io_req, r_a_tov); in bnx2fc_process_abts_compl()
1363 if (io_req->wait_for_comp) { in bnx2fc_process_abts_compl()
1365 &io_req->req_flags)) in bnx2fc_process_abts_compl()
1366 complete(&io_req->tm_done); in bnx2fc_process_abts_compl()
1377 if (io_req->on_active_queue) { in bnx2fc_process_abts_compl()
1378 list_del_init(&io_req->link); in bnx2fc_process_abts_compl()
1379 io_req->on_active_queue = 0; in bnx2fc_process_abts_compl()
1381 list_add_tail(&io_req->link, &tgt->io_retire_queue); in bnx2fc_process_abts_compl()
1383 bnx2fc_scsi_done(io_req, DID_ERROR); in bnx2fc_process_abts_compl()
1384 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_process_abts_compl()
1388 static void bnx2fc_lun_reset_cmpl(struct bnx2fc_cmd *io_req) in bnx2fc_lun_reset_cmpl() argument
1390 struct scsi_cmnd *sc_cmd = io_req->sc_cmd; in bnx2fc_lun_reset_cmpl()
1391 struct bnx2fc_rport *tgt = io_req->tgt; in bnx2fc_lun_reset_cmpl()
1398 BNX2FC_IO_DBG(io_req, "Entered bnx2fc_lun_reset_cmpl\n"); in bnx2fc_lun_reset_cmpl()
1411 if (cancel_delayed_work(&io_req->timeout_work)) in bnx2fc_lun_reset_cmpl()
1412 kref_put(&io_req->refcount, in bnx2fc_lun_reset_cmpl()
1426 static void bnx2fc_tgt_reset_cmpl(struct bnx2fc_cmd *io_req) in bnx2fc_tgt_reset_cmpl() argument
1428 struct bnx2fc_rport *tgt = io_req->tgt; in bnx2fc_tgt_reset_cmpl()
1433 BNX2FC_IO_DBG(io_req, "Entered bnx2fc_tgt_reset_cmpl\n"); in bnx2fc_tgt_reset_cmpl()
1444 if (cancel_delayed_work(&io_req->timeout_work)) in bnx2fc_tgt_reset_cmpl()
1445 kref_put(&io_req->refcount, in bnx2fc_tgt_reset_cmpl()
1457 void bnx2fc_process_tm_compl(struct bnx2fc_cmd *io_req, in bnx2fc_process_tm_compl() argument
1462 struct scsi_cmnd *sc_cmd = io_req->sc_cmd; in bnx2fc_process_tm_compl()
1468 BNX2FC_IO_DBG(io_req, "Entered process_tm_compl\n"); in bnx2fc_process_tm_compl()
1470 if (!(test_bit(BNX2FC_FLAG_TM_TIMEOUT, &io_req->req_flags))) in bnx2fc_process_tm_compl()
1471 set_bit(BNX2FC_FLAG_TM_COMPL, &io_req->req_flags); in bnx2fc_process_tm_compl()
1480 tm_req = &(io_req->mp_req); in bnx2fc_process_tm_compl()
1495 bnx2fc_parse_fcp_rsp(io_req, in bnx2fc_process_tm_compl()
1498 if (io_req->fcp_rsp_code == 0) { in bnx2fc_process_tm_compl()
1501 bnx2fc_lun_reset_cmpl(io_req); in bnx2fc_process_tm_compl()
1503 bnx2fc_tgt_reset_cmpl(io_req); in bnx2fc_process_tm_compl()
1513 switch (io_req->fcp_status) { in bnx2fc_process_tm_compl()
1515 if (io_req->cdb_status == 0) { in bnx2fc_process_tm_compl()
1520 sc_cmd->result = (DID_OK << 16) | io_req->cdb_status; in bnx2fc_process_tm_compl()
1522 if (io_req->fcp_resid) in bnx2fc_process_tm_compl()
1523 scsi_set_resid(sc_cmd, io_req->fcp_resid); in bnx2fc_process_tm_compl()
1527 BNX2FC_IO_DBG(io_req, "process_tm_compl: fcp_status = %d\n", in bnx2fc_process_tm_compl()
1528 io_req->fcp_status); in bnx2fc_process_tm_compl()
1532 sc_cmd = io_req->sc_cmd; in bnx2fc_process_tm_compl()
1533 io_req->sc_cmd = NULL; in bnx2fc_process_tm_compl()
1536 if (io_req->on_tmf_queue) { in bnx2fc_process_tm_compl()
1538 list_del_init(&io_req->link); in bnx2fc_process_tm_compl()
1539 io_req->on_tmf_queue = 0; in bnx2fc_process_tm_compl()
1549 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_process_tm_compl()
1550 if (io_req->wait_for_comp) { in bnx2fc_process_tm_compl()
1551 BNX2FC_IO_DBG(io_req, "tm_compl - wake up the waiter\n"); in bnx2fc_process_tm_compl()
1552 complete(&io_req->tm_done); in bnx2fc_process_tm_compl()
1556 static int bnx2fc_split_bd(struct bnx2fc_cmd *io_req, u64 addr, int sg_len, in bnx2fc_split_bd() argument
1559 struct fcoe_bd_ctx *bd = io_req->bd_tbl->bd_tbl; in bnx2fc_split_bd()
1581 static int bnx2fc_map_sg(struct bnx2fc_cmd *io_req) in bnx2fc_map_sg() argument
1583 struct bnx2fc_interface *interface = io_req->port->priv; in bnx2fc_map_sg()
1585 struct scsi_cmnd *sc = io_req->sc_cmd; in bnx2fc_map_sg()
1586 struct fcoe_bd_ctx *bd = io_req->bd_tbl->bd_tbl; in bnx2fc_map_sg()
1606 sg_frags = bnx2fc_split_bd(io_req, addr, sg_len, in bnx2fc_map_sg()
1622 io_req->xid); in bnx2fc_map_sg()
1626 static int bnx2fc_build_bd_list_from_sg(struct bnx2fc_cmd *io_req) in bnx2fc_build_bd_list_from_sg() argument
1628 struct scsi_cmnd *sc = io_req->sc_cmd; in bnx2fc_build_bd_list_from_sg()
1629 struct fcoe_bd_ctx *bd = io_req->bd_tbl->bd_tbl; in bnx2fc_build_bd_list_from_sg()
1633 bd_count = bnx2fc_map_sg(io_req); in bnx2fc_build_bd_list_from_sg()
1641 io_req->bd_tbl->bd_valid = bd_count; in bnx2fc_build_bd_list_from_sg()
1646 static void bnx2fc_unmap_sg_list(struct bnx2fc_cmd *io_req) in bnx2fc_unmap_sg_list() argument
1648 struct scsi_cmnd *sc = io_req->sc_cmd; in bnx2fc_unmap_sg_list()
1649 struct bnx2fc_interface *interface = io_req->port->priv; in bnx2fc_unmap_sg_list()
1656 if (io_req->bd_tbl->bd_valid && sc && scsi_sg_count(sc)) { in bnx2fc_unmap_sg_list()
1659 io_req->bd_tbl->bd_valid = 0; in bnx2fc_unmap_sg_list()
1663 void bnx2fc_build_fcp_cmnd(struct bnx2fc_cmd *io_req, in bnx2fc_build_fcp_cmnd() argument
1666 struct scsi_cmnd *sc_cmd = io_req->sc_cmd; in bnx2fc_build_fcp_cmnd()
1672 fcp_cmnd->fc_dl = htonl(io_req->data_xfer_len); in bnx2fc_build_fcp_cmnd()
1677 fcp_cmnd->fc_tm_flags = io_req->mp_req.tm_flags; in bnx2fc_build_fcp_cmnd()
1678 fcp_cmnd->fc_flags = io_req->io_req_flags; in bnx2fc_build_fcp_cmnd()
1682 static void bnx2fc_parse_fcp_rsp(struct bnx2fc_cmd *io_req, in bnx2fc_parse_fcp_rsp() argument
1686 struct scsi_cmnd *sc_cmd = io_req->sc_cmd; in bnx2fc_parse_fcp_rsp()
1687 struct bnx2fc_rport *tgt = io_req->tgt; in bnx2fc_parse_fcp_rsp()
1696 io_req->fcp_status = FC_GOOD; in bnx2fc_parse_fcp_rsp()
1697 io_req->fcp_resid = 0; in bnx2fc_parse_fcp_rsp()
1700 io_req->fcp_resid = fcp_rsp->fcp_resid; in bnx2fc_parse_fcp_rsp()
1702 io_req->scsi_comp_flags = rsp_flags; in bnx2fc_parse_fcp_rsp()
1703 CMD_SCSI_STATUS(sc_cmd) = io_req->cdb_status = in bnx2fc_parse_fcp_rsp()
1727 io_req->fcp_rsp_len = fcp_rsp_len; in bnx2fc_parse_fcp_rsp()
1728 io_req->fcp_sns_len = fcp_sns_len; in bnx2fc_parse_fcp_rsp()
1749 io_req->fcp_rsp_code = rq_data[3]; in bnx2fc_parse_fcp_rsp()
1751 io_req->fcp_rsp_code); in bnx2fc_parse_fcp_rsp()
1787 struct bnx2fc_cmd *io_req; in bnx2fc_queuecommand() local
1826 io_req = bnx2fc_cmd_alloc(tgt); in bnx2fc_queuecommand()
1827 if (!io_req) { in bnx2fc_queuecommand()
1831 io_req->sc_cmd = sc_cmd; in bnx2fc_queuecommand()
1833 if (bnx2fc_post_io_req(tgt, io_req)) { in bnx2fc_queuecommand()
1845 void bnx2fc_process_scsi_cmd_compl(struct bnx2fc_cmd *io_req, in bnx2fc_process_scsi_cmd_compl() argument
1850 struct bnx2fc_rport *tgt = io_req->tgt; in bnx2fc_process_scsi_cmd_compl()
1857 if (test_and_set_bit(BNX2FC_FLAG_IO_COMPL, &io_req->req_flags)) { in bnx2fc_process_scsi_cmd_compl()
1859 BNX2FC_IO_DBG(io_req, "Timer context finished processing " in bnx2fc_process_scsi_cmd_compl()
1865 if (cancel_delayed_work(&io_req->timeout_work)) in bnx2fc_process_scsi_cmd_compl()
1866 kref_put(&io_req->refcount, in bnx2fc_process_scsi_cmd_compl()
1869 sc_cmd = io_req->sc_cmd; in bnx2fc_process_scsi_cmd_compl()
1880 bnx2fc_parse_fcp_rsp(io_req, fcp_rsp, num_rq); in bnx2fc_process_scsi_cmd_compl()
1888 if (io_req->on_active_queue) { in bnx2fc_process_scsi_cmd_compl()
1889 list_del_init(&io_req->link); in bnx2fc_process_scsi_cmd_compl()
1890 io_req->on_active_queue = 0; in bnx2fc_process_scsi_cmd_compl()
1892 list_add_tail(&io_req->link, &tgt->io_retire_queue); in bnx2fc_process_scsi_cmd_compl()
1898 BNX2FC_IO_DBG(io_req, "xid not on active_cmd_queue\n"); in bnx2fc_process_scsi_cmd_compl()
1899 if (io_req->wait_for_comp) in bnx2fc_process_scsi_cmd_compl()
1901 &io_req->req_flags)) in bnx2fc_process_scsi_cmd_compl()
1902 complete(&io_req->tm_done); in bnx2fc_process_scsi_cmd_compl()
1905 bnx2fc_unmap_sg_list(io_req); in bnx2fc_process_scsi_cmd_compl()
1906 io_req->sc_cmd = NULL; in bnx2fc_process_scsi_cmd_compl()
1908 switch (io_req->fcp_status) { in bnx2fc_process_scsi_cmd_compl()
1910 if (io_req->cdb_status == 0) { in bnx2fc_process_scsi_cmd_compl()
1915 BNX2FC_IO_DBG(io_req, "scsi_cmpl: cdb_status = %d" in bnx2fc_process_scsi_cmd_compl()
1917 io_req->cdb_status, io_req->fcp_resid); in bnx2fc_process_scsi_cmd_compl()
1918 sc_cmd->result = (DID_OK << 16) | io_req->cdb_status; in bnx2fc_process_scsi_cmd_compl()
1920 if (io_req->cdb_status == SAM_STAT_TASK_SET_FULL || in bnx2fc_process_scsi_cmd_compl()
1921 io_req->cdb_status == SAM_STAT_BUSY) { in bnx2fc_process_scsi_cmd_compl()
1929 if (io_req->fcp_resid) in bnx2fc_process_scsi_cmd_compl()
1930 scsi_set_resid(sc_cmd, io_req->fcp_resid); in bnx2fc_process_scsi_cmd_compl()
1934 io_req->fcp_status); in bnx2fc_process_scsi_cmd_compl()
1939 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_process_scsi_cmd_compl()
1943 struct bnx2fc_cmd *io_req) in bnx2fc_post_io_req() argument
1947 struct scsi_cmnd *sc_cmd = io_req->sc_cmd; in bnx2fc_post_io_req()
1959 io_req->cmd_type = BNX2FC_SCSI_CMD; in bnx2fc_post_io_req()
1960 io_req->port = port; in bnx2fc_post_io_req()
1961 io_req->tgt = tgt; in bnx2fc_post_io_req()
1962 io_req->data_xfer_len = scsi_bufflen(sc_cmd); in bnx2fc_post_io_req()
1963 sc_cmd->SCp.ptr = (char *)io_req; in bnx2fc_post_io_req()
1967 io_req->io_req_flags = BNX2FC_READ; in bnx2fc_post_io_req()
1969 stats->InputBytes += io_req->data_xfer_len; in bnx2fc_post_io_req()
1971 io_req->io_req_flags = BNX2FC_WRITE; in bnx2fc_post_io_req()
1973 stats->OutputBytes += io_req->data_xfer_len; in bnx2fc_post_io_req()
1975 io_req->io_req_flags = 0; in bnx2fc_post_io_req()
1980 xid = io_req->xid; in bnx2fc_post_io_req()
1983 if (bnx2fc_build_bd_list_from_sg(io_req)) { in bnx2fc_post_io_req()
1985 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_post_io_req()
1995 bnx2fc_init_task(io_req, task); in bnx2fc_post_io_req()
1999 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_post_io_req()
2005 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_post_io_req()
2011 bnx2fc_cmd_timer_set(io_req, BNX2FC_IO_TIMEOUT); in bnx2fc_post_io_req()
2017 io_req->on_active_queue = 1; in bnx2fc_post_io_req()
2019 list_add_tail(&io_req->link, &tgt->active_cmd_queue); in bnx2fc_post_io_req()