Lines Matching refs:io_req
11 void qedf_cmd_timer_set(struct qedf_ctx *qedf, struct qedf_ioreq *io_req, in qedf_cmd_timer_set() argument
14 queue_delayed_work(qedf->timer_work_queue, &io_req->timeout_work, in qedf_cmd_timer_set()
21 struct qedf_ioreq *io_req = in qedf_cmd_timeout() local
26 fcport = io_req->fcport; in qedf_cmd_timeout()
27 if (io_req->fcport == NULL) { in qedf_cmd_timeout()
34 switch (io_req->cmd_type) { in qedf_cmd_timeout()
39 io_req->xid); in qedf_cmd_timeout()
44 io_req->xid); in qedf_cmd_timeout()
46 qedf_initiate_cleanup(io_req, true); in qedf_cmd_timeout()
47 complete(&io_req->abts_done); in qedf_cmd_timeout()
54 kref_put(&io_req->refcount, qedf_release_cmd); in qedf_cmd_timeout()
57 clear_bit(QEDF_CMD_IN_ABORT, &io_req->flags); in qedf_cmd_timeout()
69 io_req->xid); in qedf_cmd_timeout()
73 clear_bit(QEDF_CMD_OUTSTANDING, &io_req->flags); in qedf_cmd_timeout()
75 kref_get(&io_req->refcount); in qedf_cmd_timeout()
82 io_req->xid); in qedf_cmd_timeout()
83 qedf_initiate_cleanup(io_req, true); in qedf_cmd_timeout()
84 io_req->event = QEDF_IOREQ_EV_ELS_TMO; in qedf_cmd_timeout()
86 if (io_req->cb_func && io_req->cb_arg) { in qedf_cmd_timeout()
87 io_req->cb_func(io_req->cb_arg); in qedf_cmd_timeout()
88 io_req->cb_arg = NULL; in qedf_cmd_timeout()
90 kref_put(&io_req->refcount, qedf_release_cmd); in qedf_cmd_timeout()
94 "xid=0x%x.\n", io_req->xid); in qedf_cmd_timeout()
95 qedf_initiate_cleanup(io_req, true); in qedf_cmd_timeout()
96 io_req->event = QEDF_IOREQ_EV_ELS_TMO; in qedf_cmd_timeout()
97 qedf_process_seq_cleanup_compl(qedf, NULL, io_req); in qedf_cmd_timeout()
101 "Hit default case, xid=0x%x.\n", io_req->xid); in qedf_cmd_timeout()
115 struct qedf_ioreq *io_req; in qedf_cmd_mgr_free() local
147 io_req = &cmgr->cmds[i]; in qedf_cmd_mgr_free()
148 kfree(io_req->sgl_task_params); in qedf_cmd_mgr_free()
149 kfree(io_req->task_params); in qedf_cmd_mgr_free()
151 if (io_req->sense_buffer) in qedf_cmd_mgr_free()
153 QEDF_SCSI_SENSE_BUFFERSIZE, io_req->sense_buffer, in qedf_cmd_mgr_free()
154 io_req->sense_buffer_dma); in qedf_cmd_mgr_free()
155 cancel_delayed_work_sync(&io_req->rrq_work); in qedf_cmd_mgr_free()
164 struct qedf_ioreq *io_req = in qedf_handle_rrq() local
167 atomic_set(&io_req->state, QEDFC_CMD_ST_RRQ_ACTIVE); in qedf_handle_rrq()
168 qedf_send_rrq(io_req); in qedf_handle_rrq()
176 struct qedf_ioreq *io_req; in qedf_cmd_mgr_alloc() local
215 io_req = &cmgr->cmds[i]; in qedf_cmd_mgr_alloc()
216 INIT_DELAYED_WORK(&io_req->timeout_work, qedf_cmd_timeout); in qedf_cmd_mgr_alloc()
218 io_req->xid = xid++; in qedf_cmd_mgr_alloc()
220 INIT_DELAYED_WORK(&io_req->rrq_work, qedf_handle_rrq); in qedf_cmd_mgr_alloc()
223 io_req->sense_buffer = dma_alloc_coherent(&qedf->pdev->dev, in qedf_cmd_mgr_alloc()
224 QEDF_SCSI_SENSE_BUFFERSIZE, &io_req->sense_buffer_dma, in qedf_cmd_mgr_alloc()
226 if (!io_req->sense_buffer) { in qedf_cmd_mgr_alloc()
233 io_req->task_params = kzalloc(sizeof(*io_req->task_params), in qedf_cmd_mgr_alloc()
235 if (!io_req->task_params) { in qedf_cmd_mgr_alloc()
246 io_req->sgl_task_params = kzalloc( in qedf_cmd_mgr_alloc()
248 if (!io_req->sgl_task_params) { in qedf_cmd_mgr_alloc()
302 struct qedf_ioreq *io_req = NULL; in qedf_alloc_cmd() local
337 io_req = &cmd_mgr->cmds[cmd_mgr->idx]; in qedf_alloc_cmd()
343 if (!io_req->alloc) in qedf_alloc_cmd()
352 if (test_bit(QEDF_CMD_DIRTY, &io_req->flags)) in qedf_alloc_cmd()
355 io_req->xid); in qedf_alloc_cmd()
358 io_req->flags = 0; in qedf_alloc_cmd()
359 io_req->alloc = 1; in qedf_alloc_cmd()
364 xid = io_req->xid; in qedf_alloc_cmd()
367 io_req->cmd_mgr = cmd_mgr; in qedf_alloc_cmd()
368 io_req->fcport = fcport; in qedf_alloc_cmd()
371 io_req->sc_cmd = NULL; in qedf_alloc_cmd()
372 io_req->lun = -1; in qedf_alloc_cmd()
375 kref_init(&io_req->refcount); /* ID: 001 */ in qedf_alloc_cmd()
376 atomic_set(&io_req->state, QEDFC_CMD_ST_IO_ACTIVE); in qedf_alloc_cmd()
380 bd_tbl = io_req->bd_tbl = cmd_mgr->io_bdt_pool[xid]; in qedf_alloc_cmd()
383 kref_put(&io_req->refcount, qedf_release_cmd); in qedf_alloc_cmd()
386 bd_tbl->io_req = io_req; in qedf_alloc_cmd()
387 io_req->cmd_type = cmd_type; in qedf_alloc_cmd()
388 io_req->tm_flags = 0; in qedf_alloc_cmd()
391 io_req->rx_buf_off = 0; in qedf_alloc_cmd()
392 io_req->tx_buf_off = 0; in qedf_alloc_cmd()
393 io_req->rx_id = 0xffff; /* No OX_ID */ in qedf_alloc_cmd()
395 return io_req; in qedf_alloc_cmd()
403 static void qedf_free_mp_resc(struct qedf_ioreq *io_req) in qedf_free_mp_resc() argument
405 struct qedf_mp_req *mp_req = &(io_req->mp_req); in qedf_free_mp_resc()
406 struct qedf_ctx *qedf = io_req->fcport->qedf; in qedf_free_mp_resc()
434 struct qedf_ioreq *io_req = in qedf_release_cmd() local
436 struct qedf_cmd_mgr *cmd_mgr = io_req->cmd_mgr; in qedf_release_cmd()
437 struct qedf_rport *fcport = io_req->fcport; in qedf_release_cmd()
440 if (io_req->cmd_type == QEDF_SCSI_CMD) { in qedf_release_cmd()
443 io_req, io_req->xid); in qedf_release_cmd()
444 WARN_ON(io_req->sc_cmd); in qedf_release_cmd()
447 if (io_req->cmd_type == QEDF_ELS || in qedf_release_cmd()
448 io_req->cmd_type == QEDF_TASK_MGMT_CMD) in qedf_release_cmd()
449 qedf_free_mp_resc(io_req); in qedf_release_cmd()
453 atomic_set(&io_req->state, QEDF_CMD_ST_INACTIVE); in qedf_release_cmd()
460 io_req->task_retry_identifier++; in qedf_release_cmd()
461 io_req->fcport = NULL; in qedf_release_cmd()
463 clear_bit(QEDF_CMD_DIRTY, &io_req->flags); in qedf_release_cmd()
464 io_req->cpu = 0; in qedf_release_cmd()
466 io_req->fcport = NULL; in qedf_release_cmd()
467 io_req->alloc = 0; in qedf_release_cmd()
471 static int qedf_map_sg(struct qedf_ioreq *io_req) in qedf_map_sg() argument
473 struct scsi_cmnd *sc = io_req->sc_cmd; in qedf_map_sg()
477 struct scsi_sge *bd = io_req->bd_tbl->bd_tbl; in qedf_map_sg()
490 io_req->sge_type = QEDF_IOREQ_UNKNOWN_SGE; in qedf_map_sg()
492 if (sg_count <= 8 || io_req->io_req_flags == QEDF_READ) in qedf_map_sg()
493 io_req->sge_type = QEDF_IOREQ_FAST_SGE; in qedf_map_sg()
504 if (io_req->sge_type == QEDF_IOREQ_UNKNOWN_SGE && (i) && in qedf_map_sg()
506 io_req->sge_type = QEDF_IOREQ_SLOW_SGE; in qedf_map_sg()
517 if (io_req->sge_type == QEDF_IOREQ_UNKNOWN_SGE) in qedf_map_sg()
518 io_req->sge_type = QEDF_IOREQ_FAST_SGE; in qedf_map_sg()
523 scsi_bufflen(sc), io_req->xid); in qedf_map_sg()
528 static int qedf_build_bd_list_from_sg(struct qedf_ioreq *io_req) in qedf_build_bd_list_from_sg() argument
530 struct scsi_cmnd *sc = io_req->sc_cmd; in qedf_build_bd_list_from_sg()
531 struct scsi_sge *bd = io_req->bd_tbl->bd_tbl; in qedf_build_bd_list_from_sg()
535 bd_count = qedf_map_sg(io_req); in qedf_build_bd_list_from_sg()
543 io_req->bd_tbl->bd_valid = bd_count; in qedf_build_bd_list_from_sg()
548 static void qedf_build_fcp_cmnd(struct qedf_ioreq *io_req, in qedf_build_fcp_cmnd() argument
551 struct scsi_cmnd *sc_cmd = io_req->sc_cmd; in qedf_build_fcp_cmnd()
562 fcp_cmnd->fc_tm_flags = io_req->tm_flags; in qedf_build_fcp_cmnd()
563 fcp_cmnd->fc_flags = io_req->io_req_flags; in qedf_build_fcp_cmnd()
567 if (io_req->cmd_type == QEDF_TASK_MGMT_CMD) { in qedf_build_fcp_cmnd()
579 if (io_req->cmd_type != QEDF_TASK_MGMT_CMD) in qedf_build_fcp_cmnd()
583 fcp_cmnd->fc_dl = htonl(io_req->data_xfer_len); in qedf_build_fcp_cmnd()
587 struct qedf_ioreq *io_req, struct fcoe_task_context *task_ctx, in qedf_init_task() argument
591 struct scsi_cmnd *sc_cmd = io_req->sc_cmd; in qedf_init_task()
592 struct io_bdt *bd_tbl = io_req->bd_tbl; in qedf_init_task()
604 io_req->task = task_ctx; in qedf_init_task()
606 memset(io_req->task_params, 0, sizeof(struct fcoe_task_params)); in qedf_init_task()
607 memset(io_req->sgl_task_params, 0, sizeof(struct scsi_sgl_task_params)); in qedf_init_task()
610 if (io_req->cmd_type == QEDF_TASK_MGMT_CMD) { in qedf_init_task()
615 tx_io_size = io_req->data_xfer_len; in qedf_init_task()
618 rx_io_size = io_req->data_xfer_len; in qedf_init_task()
623 io_req->task_params->context = task_ctx; in qedf_init_task()
624 io_req->task_params->sqe = sqe; in qedf_init_task()
625 io_req->task_params->task_type = task_type; in qedf_init_task()
626 io_req->task_params->tx_io_size = tx_io_size; in qedf_init_task()
627 io_req->task_params->rx_io_size = rx_io_size; in qedf_init_task()
628 io_req->task_params->conn_cid = fcport->fw_cid; in qedf_init_task()
629 io_req->task_params->itid = io_req->xid; in qedf_init_task()
630 io_req->task_params->cq_rss_number = cq_idx; in qedf_init_task()
631 io_req->task_params->is_tape_device = fcport->dev_type; in qedf_init_task()
634 if (io_req->cmd_type != QEDF_TASK_MGMT_CMD) { in qedf_init_task()
636 io_req->sgl_task_params->sgl = bd_tbl->bd_tbl; in qedf_init_task()
637 io_req->sgl_task_params->sgl_phys_addr.lo = in qedf_init_task()
639 io_req->sgl_task_params->sgl_phys_addr.hi = in qedf_init_task()
641 io_req->sgl_task_params->num_sges = bd_count; in qedf_init_task()
642 io_req->sgl_task_params->total_buffer_size = in qedf_init_task()
643 scsi_bufflen(io_req->sc_cmd); in qedf_init_task()
644 if (io_req->sge_type == QEDF_IOREQ_SLOW_SGE) in qedf_init_task()
645 io_req->sgl_task_params->small_mid_sge = 1; in qedf_init_task()
647 io_req->sgl_task_params->small_mid_sge = 0; in qedf_init_task()
651 sense_data_buffer_phys_addr.lo = U64_LO(io_req->sense_buffer_dma); in qedf_init_task()
652 sense_data_buffer_phys_addr.hi = U64_HI(io_req->sense_buffer_dma); in qedf_init_task()
655 qedf_build_fcp_cmnd(io_req, (struct fcp_cmnd *)tmp_fcp_cmnd); in qedf_init_task()
664 init_initiator_rw_fcoe_task(io_req->task_params, in qedf_init_task()
665 io_req->sgl_task_params, in qedf_init_task()
667 io_req->task_retry_identifier, fcp_cmnd); in qedf_init_task()
670 if (io_req->sge_type == QEDF_IOREQ_SLOW_SGE) in qedf_init_task()
676 void qedf_init_mp_task(struct qedf_ioreq *io_req, in qedf_init_mp_task() argument
679 struct qedf_mp_req *mp_req = &(io_req->mp_req); in qedf_init_mp_task()
680 struct qedf_rport *fcport = io_req->fcport; in qedf_init_mp_task()
681 struct qedf_ctx *qedf = io_req->fcport->qedf; in qedf_init_mp_task()
689 io_req->cmd_type); in qedf_init_mp_task()
699 io_req->task = task_ctx; in qedf_init_mp_task()
702 io_req->task_params->context = task_ctx; in qedf_init_mp_task()
703 io_req->task_params->sqe = sqe; in qedf_init_mp_task()
704 io_req->task_params->task_type = FCOE_TASK_TYPE_MIDPATH; in qedf_init_mp_task()
705 io_req->task_params->tx_io_size = io_req->data_xfer_len; in qedf_init_mp_task()
707 io_req->task_params->rx_io_size = PAGE_SIZE; in qedf_init_mp_task()
708 io_req->task_params->conn_cid = fcport->fw_cid; in qedf_init_mp_task()
709 io_req->task_params->itid = io_req->xid; in qedf_init_mp_task()
711 io_req->task_params->cq_rss_number = 0; in qedf_init_mp_task()
712 io_req->task_params->is_tape_device = fcport->dev_type; in qedf_init_mp_task()
716 fc_hdr->fh_ox_id = io_req->xid; in qedf_init_mp_task()
734 tx_sgl_task_params.total_buffer_size = io_req->data_xfer_len; in qedf_init_mp_task()
751 init_initiator_midpath_unsolicited_fcoe_task(io_req->task_params, in qedf_init_mp_task()
800 static void qedf_trace_io(struct qedf_rport *fcport, struct qedf_ioreq *io_req, in qedf_trace_io() argument
805 struct scsi_cmnd *sc_cmd = io_req->sc_cmd; in qedf_trace_io()
812 io_log->task_id = io_req->xid; in qedf_trace_io()
824 io_log->refcount = kref_read(&io_req->refcount); in qedf_trace_io()
828 io_log->req_cpu = io_req->cpu; in qedf_trace_io()
832 io_log->req_cpu = io_req->cpu; in qedf_trace_io()
833 io_log->int_cpu = io_req->int_cpu; in qedf_trace_io()
837 io_log->sge_type = io_req->sge_type; in qedf_trace_io()
846 int qedf_post_io_req(struct qedf_rport *fcport, struct qedf_ioreq *io_req) in qedf_post_io_req() argument
848 struct scsi_cmnd *sc_cmd = io_req->sc_cmd; in qedf_post_io_req()
858 io_req->data_xfer_len = scsi_bufflen(sc_cmd); in qedf_post_io_req()
859 qedf_priv(sc_cmd)->io_req = io_req; in qedf_post_io_req()
860 io_req->sge_type = QEDF_IOREQ_FAST_SGE; /* Assume fast SGL by default */ in qedf_post_io_req()
863 io_req->cpu = smp_processor_id(); in qedf_post_io_req()
866 io_req->io_req_flags = QEDF_READ; in qedf_post_io_req()
869 io_req->io_req_flags = QEDF_WRITE; in qedf_post_io_req()
872 io_req->io_req_flags = 0; in qedf_post_io_req()
876 xid = io_req->xid; in qedf_post_io_req()
879 if (qedf_build_bd_list_from_sg(io_req)) { in qedf_post_io_req()
882 io_req->sc_cmd = NULL; in qedf_post_io_req()
883 kref_put(&io_req->refcount, qedf_release_cmd); in qedf_post_io_req()
891 io_req->sc_cmd = NULL; in qedf_post_io_req()
892 kref_put(&io_req->refcount, qedf_release_cmd); in qedf_post_io_req()
897 io_req->lun = (int)sc_cmd->device->lun; in qedf_post_io_req()
910 io_req->sc_cmd = NULL; in qedf_post_io_req()
911 kref_put(&io_req->refcount, qedf_release_cmd); in qedf_post_io_req()
915 qedf_init_task(fcport, lport, io_req, task_ctx, sqe); in qedf_post_io_req()
921 set_bit(QEDF_CMD_OUTSTANDING, &io_req->flags); in qedf_post_io_req()
923 if (qedf_io_tracing && io_req->sc_cmd) in qedf_post_io_req()
924 qedf_trace_io(fcport, io_req, QEDF_IO_TRACE_REQ); in qedf_post_io_req()
937 struct qedf_ioreq *io_req; in qedf_queuecommand() local
1026 io_req = qedf_alloc_cmd(fcport, QEDF_SCSI_CMD); in qedf_queuecommand()
1027 if (!io_req) { in qedf_queuecommand()
1033 io_req->sc_cmd = sc_cmd; in qedf_queuecommand()
1037 if (qedf_post_io_req(fcport, io_req)) { in qedf_queuecommand()
1050 static void qedf_parse_fcp_rsp(struct qedf_ioreq *io_req, in qedf_parse_fcp_rsp() argument
1053 struct scsi_cmnd *sc_cmd = io_req->sc_cmd; in qedf_parse_fcp_rsp()
1054 struct qedf_ctx *qedf = io_req->fcport->qedf; in qedf_parse_fcp_rsp()
1060 io_req->fcp_status = FC_GOOD; in qedf_parse_fcp_rsp()
1061 io_req->fcp_resid = 0; in qedf_parse_fcp_rsp()
1064 io_req->fcp_resid = fcp_rsp->fcp_resid; in qedf_parse_fcp_rsp()
1066 io_req->scsi_comp_flags = rsp_flags; in qedf_parse_fcp_rsp()
1067 io_req->cdb_status = fcp_rsp->scsi_status_code; in qedf_parse_fcp_rsp()
1077 io_req->fcp_rsp_len = fcp_rsp_len; in qedf_parse_fcp_rsp()
1078 io_req->fcp_sns_len = fcp_sns_len; in qedf_parse_fcp_rsp()
1079 rsp_info = sense_data = io_req->sense_buffer; in qedf_parse_fcp_rsp()
1084 io_req->fcp_rsp_code = rsp_info[3]; in qedf_parse_fcp_rsp()
1086 "fcp_rsp_code = %d\n", io_req->fcp_rsp_code); in qedf_parse_fcp_rsp()
1106 static void qedf_unmap_sg_list(struct qedf_ctx *qedf, struct qedf_ioreq *io_req) in qedf_unmap_sg_list() argument
1108 struct scsi_cmnd *sc = io_req->sc_cmd; in qedf_unmap_sg_list()
1110 if (io_req->bd_tbl->bd_valid && sc && scsi_sg_count(sc)) { in qedf_unmap_sg_list()
1113 io_req->bd_tbl->bd_valid = 0; in qedf_unmap_sg_list()
1118 struct qedf_ioreq *io_req) in qedf_scsi_completion() argument
1129 if (!io_req) in qedf_scsi_completion()
1134 if (!test_bit(QEDF_CMD_OUTSTANDING, &io_req->flags) || in qedf_scsi_completion()
1135 test_bit(QEDF_CMD_IN_CLEANUP, &io_req->flags) || in qedf_scsi_completion()
1136 test_bit(QEDF_CMD_IN_ABORT, &io_req->flags)) { in qedf_scsi_completion()
1139 io_req->xid); in qedf_scsi_completion()
1143 sc_cmd = io_req->sc_cmd; in qedf_scsi_completion()
1151 if (!qedf_priv(sc_cmd)->io_req) { in qedf_scsi_completion()
1169 fcport = io_req->fcport; in qedf_scsi_completion()
1180 io_req->xid); in qedf_scsi_completion()
1184 qedf_parse_fcp_rsp(io_req, fcp_rsp); in qedf_scsi_completion()
1186 qedf_unmap_sg_list(qedf, io_req); in qedf_scsi_completion()
1189 if (io_req->fcp_rsp_len > 3 && io_req->fcp_rsp_code) { in qedf_scsi_completion()
1192 "fcp_rsp_code=%d.\n", io_req->xid, io_req->fcp_rsp_len, in qedf_scsi_completion()
1193 io_req->fcp_rsp_code); in qedf_scsi_completion()
1203 io_req->xid, fcp_rsp->rsp_flags.flags, in qedf_scsi_completion()
1204 io_req->fcp_resid, in qedf_scsi_completion()
1208 if (io_req->cdb_status == 0) in qedf_scsi_completion()
1209 sc_cmd->result = (DID_ERROR << 16) | io_req->cdb_status; in qedf_scsi_completion()
1211 sc_cmd->result = (DID_OK << 16) | io_req->cdb_status; in qedf_scsi_completion()
1221 switch (io_req->fcp_status) { in qedf_scsi_completion()
1223 if (io_req->cdb_status == 0) { in qedf_scsi_completion()
1227 refcount = kref_read(&io_req->refcount); in qedf_scsi_completion()
1233 sc_cmd->device->lun, io_req->xid, in qedf_scsi_completion()
1236 io_req->cdb_status, io_req->fcp_resid, in qedf_scsi_completion()
1238 sc_cmd->result = (DID_OK << 16) | io_req->cdb_status; in qedf_scsi_completion()
1240 if (io_req->cdb_status == SAM_STAT_TASK_SET_FULL || in qedf_scsi_completion()
1241 io_req->cdb_status == SAM_STAT_BUSY) { in qedf_scsi_completion()
1256 if (io_req->cdb_status == in qedf_scsi_completion()
1263 if (io_req->fcp_resid) in qedf_scsi_completion()
1264 scsi_set_resid(sc_cmd, io_req->fcp_resid); in qedf_scsi_completion()
1298 io_req->fcp_status); in qedf_scsi_completion()
1304 qedf_trace_io(fcport, io_req, QEDF_IO_TRACE_RSP); in qedf_scsi_completion()
1310 clear_bit(QEDF_CMD_OUTSTANDING, &io_req->flags); in qedf_scsi_completion()
1312 io_req->sc_cmd = NULL; in qedf_scsi_completion()
1313 qedf_priv(sc_cmd)->io_req = NULL; in qedf_scsi_completion()
1315 kref_put(&io_req->refcount, qedf_release_cmd); in qedf_scsi_completion()
1319 void qedf_scsi_done(struct qedf_ctx *qedf, struct qedf_ioreq *io_req, in qedf_scsi_done() argument
1325 if (!io_req) { in qedf_scsi_done()
1330 if (test_and_set_bit(QEDF_CMD_ERR_SCSI_DONE, &io_req->flags)) { in qedf_scsi_done()
1333 io_req); in qedf_scsi_done()
1341 clear_bit(QEDF_CMD_OUTSTANDING, &io_req->flags); in qedf_scsi_done()
1343 sc_cmd = io_req->sc_cmd; in qedf_scsi_done()
1355 if (!qedf_priv(sc_cmd)->io_req) { in qedf_scsi_done()
1387 qedf_unmap_sg_list(qedf, io_req); in qedf_scsi_done()
1390 refcount = kref_read(&io_req->refcount); in qedf_scsi_done()
1407 qedf_trace_io(io_req->fcport, io_req, QEDF_IO_TRACE_RSP); in qedf_scsi_done()
1409 io_req->sc_cmd = NULL; in qedf_scsi_done()
1410 qedf_priv(sc_cmd)->io_req = NULL; in qedf_scsi_done()
1412 kref_put(&io_req->refcount, qedf_release_cmd); in qedf_scsi_done()
1420 io_req->sc_cmd = NULL; in qedf_scsi_done()
1421 kref_put(&io_req->refcount, qedf_release_cmd); /* ID: 001 */ in qedf_scsi_done()
1429 struct qedf_ioreq *io_req) in qedf_process_warning_compl() argument
1432 struct qedf_rport *fcport = io_req->fcport; in qedf_process_warning_compl()
1439 io_req, io_req->xid); in qedf_process_warning_compl()
1443 QEDF_ERR(&(io_req->fcport->qedf->dbg_ctx), "Warning CQE, " in qedf_process_warning_compl()
1444 "xid=0x%x\n", io_req->xid); in qedf_process_warning_compl()
1445 QEDF_ERR(&(io_req->fcport->qedf->dbg_ctx), in qedf_process_warning_compl()
1449 QEDF_ERR(&(io_req->fcport->qedf->dbg_ctx), "tx_buff_off=%08x, " in qedf_process_warning_compl()
1471 if (!test_bit(QEDF_CMD_SRR_SENT, &io_req->flags)) { in qedf_process_warning_compl()
1472 io_req->rx_buf_off = in qedf_process_warning_compl()
1474 io_req->tx_buf_off = in qedf_process_warning_compl()
1476 io_req->rx_id = cqe->cqe_info.err_info.rx_id; in qedf_process_warning_compl()
1477 rval = qedf_send_rec(io_req); in qedf_process_warning_compl()
1491 init_completion(&io_req->abts_done); in qedf_process_warning_compl()
1492 rval = qedf_initiate_abts(io_req, true); in qedf_process_warning_compl()
1499 struct qedf_ioreq *io_req) in qedf_process_error_detect() argument
1503 if (io_req == NULL) { in qedf_process_error_detect()
1508 if (io_req->fcport == NULL) { in qedf_process_error_detect()
1515 "cqe is NULL for io_req %p\n", io_req); in qedf_process_error_detect()
1519 QEDF_ERR(&(io_req->fcport->qedf->dbg_ctx), "Error detection CQE, " in qedf_process_error_detect()
1520 "xid=0x%x\n", io_req->xid); in qedf_process_error_detect()
1521 QEDF_ERR(&(io_req->fcport->qedf->dbg_ctx), in qedf_process_error_detect()
1525 QEDF_ERR(&(io_req->fcport->qedf->dbg_ctx), "tx_buff_off=%08x, " in qedf_process_error_detect()
1532 if (test_bit(QEDF_RPORT_IN_TARGET_RESET, &io_req->fcport->flags) || in qedf_process_error_detect()
1533 (test_bit(QEDF_RPORT_IN_LUN_RESET, &io_req->fcport->flags) && in qedf_process_error_detect()
1534 io_req->sc_cmd->device->lun == (u64)io_req->fcport->lun_reset_lun)) { in qedf_process_error_detect()
1537 io_req->xid); in qedf_process_error_detect()
1546 init_completion(&io_req->abts_done); in qedf_process_error_detect()
1547 rval = qedf_initiate_abts(io_req, true); in qedf_process_error_detect()
1585 struct qedf_ioreq *io_req; in qedf_flush_active_ios() local
1646 io_req = &cmd_mgr->cmds[i]; in qedf_flush_active_ios()
1648 if (!io_req) in qedf_flush_active_ios()
1650 if (!io_req->fcport) in qedf_flush_active_ios()
1655 if (io_req->alloc) { in qedf_flush_active_ios()
1656 if (!test_bit(QEDF_CMD_OUTSTANDING, &io_req->flags)) { in qedf_flush_active_ios()
1657 if (io_req->cmd_type == QEDF_SCSI_CMD) in qedf_flush_active_ios()
1660 io_req->xid); in qedf_flush_active_ios()
1668 if (io_req->fcport != fcport) in qedf_flush_active_ios()
1676 if (!test_bit(QEDF_CMD_OUTSTANDING, &io_req->flags)) { in qedf_flush_active_ios()
1677 refcount = kref_read(&io_req->refcount); in qedf_flush_active_ios()
1680 io_req->xid, io_req->cmd_type, refcount); in qedf_flush_active_ios()
1684 if (atomic_read(&io_req->state) == in qedf_flush_active_ios()
1687 (&io_req->rrq_work)) { in qedf_flush_active_ios()
1690 io_req->xid); in qedf_flush_active_ios()
1692 kref_put(&io_req->refcount, in qedf_flush_active_ios()
1700 if (io_req->cmd_type == QEDF_ELS && in qedf_flush_active_ios()
1702 rc = kref_get_unless_zero(&io_req->refcount); in qedf_flush_active_ios()
1706 io_req, io_req->xid); in qedf_flush_active_ios()
1709 qedf_initiate_cleanup(io_req, false); in qedf_flush_active_ios()
1711 qedf_flush_els_req(qedf, io_req); in qedf_flush_active_ios()
1720 if (io_req->cmd_type == QEDF_ABTS) { in qedf_flush_active_ios()
1722 rc = kref_get_unless_zero(&io_req->refcount); in qedf_flush_active_ios()
1726 io_req, io_req->xid); in qedf_flush_active_ios()
1729 if (lun != -1 && io_req->lun != lun) in qedf_flush_active_ios()
1733 "Flushing abort xid=0x%x.\n", io_req->xid); in qedf_flush_active_ios()
1735 if (cancel_delayed_work_sync(&io_req->rrq_work)) { in qedf_flush_active_ios()
1738 io_req->xid); in qedf_flush_active_ios()
1739 kref_put(&io_req->refcount, qedf_release_cmd); in qedf_flush_active_ios()
1742 if (cancel_delayed_work_sync(&io_req->timeout_work)) { in qedf_flush_active_ios()
1745 io_req->xid); in qedf_flush_active_ios()
1746 qedf_initiate_cleanup(io_req, true); in qedf_flush_active_ios()
1750 complete(&io_req->abts_done); in qedf_flush_active_ios()
1751 clear_bit(QEDF_CMD_IN_ABORT, &io_req->flags); in qedf_flush_active_ios()
1753 kref_put(&io_req->refcount, qedf_release_cmd); in qedf_flush_active_ios()
1759 if (!io_req->sc_cmd) in qedf_flush_active_ios()
1761 if (!io_req->sc_cmd->device) { in qedf_flush_active_ios()
1764 io_req->sc_cmd); in qedf_flush_active_ios()
1766 io_req->sc_cmd = NULL; in qedf_flush_active_ios()
1767 qedf_initiate_cleanup(io_req, false); in qedf_flush_active_ios()
1768 kref_put(&io_req->refcount, qedf_release_cmd); in qedf_flush_active_ios()
1772 if (io_req->lun != lun) in qedf_flush_active_ios()
1780 rc = kref_get_unless_zero(&io_req->refcount); in qedf_flush_active_ios()
1783 "io_req=0x%p xid=0x%x\n", io_req, io_req->xid); in qedf_flush_active_ios()
1788 "Cleanup xid=0x%x.\n", io_req->xid); in qedf_flush_active_ios()
1792 qedf_initiate_cleanup(io_req, true); in qedf_flush_active_ios()
1795 kref_put(&io_req->refcount, qedf_release_cmd); /* ID: 004 */ in qedf_flush_active_ios()
1817 io_req = &cmd_mgr->cmds[i]; in qedf_flush_active_ios()
1818 if (io_req->fcport && in qedf_flush_active_ios()
1819 io_req->fcport == fcport) { in qedf_flush_active_ios()
1821 kref_read(&io_req->refcount); in qedf_flush_active_ios()
1823 &io_req->flags); in qedf_flush_active_ios()
1826 io_req, io_req->xid, in qedf_flush_active_ios()
1827 io_req->flags, in qedf_flush_active_ios()
1828 io_req->sc_cmd, in qedf_flush_active_ios()
1830 io_req->cmd_type); in qedf_flush_active_ios()
1851 int qedf_initiate_abts(struct qedf_ioreq *io_req, bool return_scsi_cmd_on_abts) in qedf_initiate_abts() argument
1854 struct qedf_rport *fcport = io_req->fcport; in qedf_initiate_abts()
1908 if (!test_bit(QEDF_CMD_OUTSTANDING, &io_req->flags) || in qedf_initiate_abts()
1909 test_bit(QEDF_CMD_IN_CLEANUP, &io_req->flags) || in qedf_initiate_abts()
1910 test_bit(QEDF_CMD_IN_ABORT, &io_req->flags)) { in qedf_initiate_abts()
1913 io_req->xid, io_req->sc_cmd); in qedf_initiate_abts()
1920 io_req->cmd_type = QEDF_ABTS; in qedf_initiate_abts()
1923 kref_get(&io_req->refcount); in qedf_initiate_abts()
1925 xid = io_req->xid; in qedf_initiate_abts()
1929 io_req->return_scsi_cmd_on_abts = return_scsi_cmd_on_abts; in qedf_initiate_abts()
1931 set_bit(QEDF_CMD_IN_ABORT, &io_req->flags); in qedf_initiate_abts()
1932 refcount = kref_read(&io_req->refcount); in qedf_initiate_abts()
1937 qedf_cmd_timer_set(qedf, io_req, QEDF_ABORT_TIMEOUT); in qedf_initiate_abts()
1944 io_req->task_params->sqe = sqe; in qedf_initiate_abts()
1946 init_initiator_abort_fcoe_task(io_req->task_params); in qedf_initiate_abts()
1958 struct qedf_ioreq *io_req) in qedf_process_abts_compl() argument
1962 struct qedf_rport *fcport = io_req->fcport; in qedf_process_abts_compl()
1965 "0x%x cmd_type = %d\n", io_req->xid, io_req->cmd_type); in qedf_process_abts_compl()
1976 io_req->xid); in qedf_process_abts_compl()
1988 io_req->xid); in qedf_process_abts_compl()
1992 if (!cancel_delayed_work(&io_req->timeout_work)) { in qedf_process_abts_compl()
2001 io_req->event = QEDF_IOREQ_EV_ABORT_SUCCESS; in qedf_process_abts_compl()
2002 rc = kref_get_unless_zero(&io_req->refcount); /* ID: 003 */ in qedf_process_abts_compl()
2006 io_req->xid); in qedf_process_abts_compl()
2013 queue_delayed_work(qedf->dpc_wq, &io_req->rrq_work, in qedf_process_abts_compl()
2015 atomic_set(&io_req->state, QEDFC_CMD_ST_RRQ_WAIT); in qedf_process_abts_compl()
2021 io_req->event = QEDF_IOREQ_EV_ABORT_FAILED; in qedf_process_abts_compl()
2028 clear_bit(QEDF_CMD_IN_ABORT, &io_req->flags); in qedf_process_abts_compl()
2030 if (io_req->sc_cmd) { in qedf_process_abts_compl()
2031 if (!io_req->return_scsi_cmd_on_abts) in qedf_process_abts_compl()
2034 io_req->xid); in qedf_process_abts_compl()
2035 if (io_req->return_scsi_cmd_on_abts) in qedf_process_abts_compl()
2036 qedf_scsi_done(qedf, io_req, DID_ERROR); in qedf_process_abts_compl()
2040 complete(&io_req->abts_done); in qedf_process_abts_compl()
2042 kref_put(&io_req->refcount, qedf_release_cmd); in qedf_process_abts_compl()
2045 int qedf_init_mp_req(struct qedf_ioreq *io_req) in qedf_init_mp_req() argument
2050 struct qedf_ctx *qedf = io_req->fcport->qedf; in qedf_init_mp_req()
2056 mp_req = (struct qedf_mp_req *)&(io_req->mp_req); in qedf_init_mp_req()
2059 if (io_req->cmd_type != QEDF_ELS) { in qedf_init_mp_req()
2061 io_req->data_xfer_len = mp_req->req_len; in qedf_init_mp_req()
2063 mp_req->req_len = io_req->data_xfer_len; in qedf_init_mp_req()
2069 qedf_free_mp_resc(io_req); in qedf_init_mp_req()
2078 qedf_free_mp_resc(io_req); in qedf_init_mp_req()
2088 qedf_free_mp_resc(io_req); in qedf_init_mp_req()
2096 qedf_free_mp_resc(io_req); in qedf_init_mp_req()
2149 int qedf_initiate_cleanup(struct qedf_ioreq *io_req, in qedf_initiate_cleanup() argument
2161 fcport = io_req->fcport; in qedf_initiate_cleanup()
2179 if (io_req->cmd_type == QEDF_ELS) { in qedf_initiate_cleanup()
2183 if (!test_bit(QEDF_CMD_OUTSTANDING, &io_req->flags) || in qedf_initiate_cleanup()
2184 test_and_set_bit(QEDF_CMD_IN_CLEANUP, &io_req->flags)) { in qedf_initiate_cleanup()
2187 io_req->xid); in qedf_initiate_cleanup()
2190 set_bit(QEDF_CMD_IN_CLEANUP, &io_req->flags); in qedf_initiate_cleanup()
2197 clear_bit(QEDF_CMD_IN_CLEANUP, &io_req->flags); in qedf_initiate_cleanup()
2201 if (io_req->cmd_type == QEDF_CLEANUP) { in qedf_initiate_cleanup()
2204 io_req->xid, io_req->cmd_type); in qedf_initiate_cleanup()
2205 clear_bit(QEDF_CMD_IN_CLEANUP, &io_req->flags); in qedf_initiate_cleanup()
2209 refcount = kref_read(&io_req->refcount); in qedf_initiate_cleanup()
2213 io_req->xid, io_req->sc_cmd, io_req->cmd_type, io_req->flags, in qedf_initiate_cleanup()
2218 io_req->cmd_type = QEDF_CLEANUP; in qedf_initiate_cleanup()
2220 io_req->return_scsi_cmd_on_abts = return_scsi_cmd_on_abts; in qedf_initiate_cleanup()
2222 init_completion(&io_req->cleanup_done); in qedf_initiate_cleanup()
2229 io_req->task_params->sqe = sqe; in qedf_initiate_cleanup()
2231 init_initiator_cleanup_fcoe_task(io_req->task_params); in qedf_initiate_cleanup()
2236 tmo = wait_for_completion_timeout(&io_req->cleanup_done, in qedf_initiate_cleanup()
2243 "xid=%x.\n", io_req->xid); in qedf_initiate_cleanup()
2244 clear_bit(QEDF_CMD_IN_CLEANUP, &io_req->flags); in qedf_initiate_cleanup()
2253 if (io_req->tm_flags == FCP_TMF_LUN_RESET || in qedf_initiate_cleanup()
2254 io_req->tm_flags == FCP_TMF_TGT_RESET) { in qedf_initiate_cleanup()
2255 clear_bit(QEDF_CMD_OUTSTANDING, &io_req->flags); in qedf_initiate_cleanup()
2256 io_req->sc_cmd = NULL; in qedf_initiate_cleanup()
2257 kref_put(&io_req->refcount, qedf_release_cmd); in qedf_initiate_cleanup()
2258 complete(&io_req->tm_done); in qedf_initiate_cleanup()
2261 if (io_req->sc_cmd) { in qedf_initiate_cleanup()
2262 if (!io_req->return_scsi_cmd_on_abts) in qedf_initiate_cleanup()
2265 io_req->xid); in qedf_initiate_cleanup()
2266 if (io_req->return_scsi_cmd_on_abts) in qedf_initiate_cleanup()
2267 qedf_scsi_done(qedf, io_req, DID_ERROR); in qedf_initiate_cleanup()
2271 io_req->event = QEDF_IOREQ_EV_CLEANUP_SUCCESS; in qedf_initiate_cleanup()
2273 io_req->event = QEDF_IOREQ_EV_CLEANUP_FAILED; in qedf_initiate_cleanup()
2279 struct qedf_ioreq *io_req) in qedf_process_cleanup_compl() argument
2282 io_req->xid); in qedf_process_cleanup_compl()
2284 clear_bit(QEDF_CMD_IN_CLEANUP, &io_req->flags); in qedf_process_cleanup_compl()
2287 complete(&io_req->cleanup_done); in qedf_process_cleanup_compl()
2293 struct qedf_ioreq *io_req; in qedf_execute_tmf() local
2317 io_req = qedf_alloc_cmd(fcport, QEDF_TASK_MGMT_CMD); in qedf_execute_tmf()
2318 if (!io_req) { in qedf_execute_tmf()
2330 io_req->sc_cmd = sc_cmd; in qedf_execute_tmf()
2331 io_req->fcport = fcport; in qedf_execute_tmf()
2332 io_req->cmd_type = QEDF_TASK_MGMT_CMD; in qedf_execute_tmf()
2335 io_req->io_req_flags = QEDF_READ; in qedf_execute_tmf()
2336 io_req->data_xfer_len = 0; in qedf_execute_tmf()
2337 io_req->tm_flags = tm_flags; in qedf_execute_tmf()
2340 io_req->return_scsi_cmd_on_abts = false; in qedf_execute_tmf()
2343 xid = io_req->xid; in qedf_execute_tmf()
2351 init_completion(&io_req->tm_done); in qedf_execute_tmf()
2356 io_req->cpu = smp_processor_id(); in qedf_execute_tmf()
2362 qedf_init_task(fcport, lport, io_req, task, sqe); in qedf_execute_tmf()
2367 set_bit(QEDF_CMD_OUTSTANDING, &io_req->flags); in qedf_execute_tmf()
2368 tmo = wait_for_completion_timeout(&io_req->tm_done, in qedf_execute_tmf()
2375 clear_bit(QEDF_CMD_OUTSTANDING, &io_req->flags); in qedf_execute_tmf()
2376 io_req->sc_cmd = NULL; in qedf_execute_tmf()
2379 if (io_req->fcp_rsp_code == 0) in qedf_execute_tmf()
2394 kref_put(&io_req->refcount, qedf_release_cmd); in qedf_execute_tmf()
2422 struct qedf_ioreq *io_req = NULL; in qedf_initiate_tmf() local
2440 if (qedf_priv(sc_cmd)->io_req) { in qedf_initiate_tmf()
2441 io_req = qedf_priv(sc_cmd)->io_req; in qedf_initiate_tmf()
2442 ref_cnt = kref_read(&io_req->refcount); in qedf_initiate_tmf()
2445 io_req, io_req->xid, ref_cnt); in qedf_initiate_tmf()
2511 struct qedf_ioreq *io_req) in qedf_process_tmf_compl() argument
2515 clear_bit(QEDF_CMD_OUTSTANDING, &io_req->flags); in qedf_process_tmf_compl()
2518 qedf_parse_fcp_rsp(io_req, fcp_rsp); in qedf_process_tmf_compl()
2520 io_req->sc_cmd = NULL; in qedf_process_tmf_compl()
2521 complete(&io_req->tm_done); in qedf_process_tmf_compl()