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 e4_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()
813 io_log->task_id = io_req->xid; in qedf_trace_io()
825 io_log->refcount = kref_read(&io_req->refcount); in qedf_trace_io()
829 io_log->req_cpu = io_req->cpu; in qedf_trace_io()
833 io_log->req_cpu = io_req->cpu; in qedf_trace_io()
834 io_log->int_cpu = io_req->int_cpu; in qedf_trace_io()
838 io_log->sge_type = io_req->sge_type; in qedf_trace_io()
847 int qedf_post_io_req(struct qedf_rport *fcport, struct qedf_ioreq *io_req) in qedf_post_io_req() argument
849 struct scsi_cmnd *sc_cmd = io_req->sc_cmd; in qedf_post_io_req()
859 io_req->data_xfer_len = scsi_bufflen(sc_cmd); in qedf_post_io_req()
860 sc_cmd->SCp.ptr = (char *)io_req; in qedf_post_io_req()
861 io_req->sge_type = QEDF_IOREQ_FAST_SGE; /* Assume fast SGL by default */ in qedf_post_io_req()
864 io_req->cpu = smp_processor_id(); in qedf_post_io_req()
867 io_req->io_req_flags = QEDF_READ; in qedf_post_io_req()
870 io_req->io_req_flags = QEDF_WRITE; in qedf_post_io_req()
873 io_req->io_req_flags = 0; in qedf_post_io_req()
877 xid = io_req->xid; in qedf_post_io_req()
880 if (qedf_build_bd_list_from_sg(io_req)) { in qedf_post_io_req()
883 io_req->sc_cmd = NULL; in qedf_post_io_req()
884 kref_put(&io_req->refcount, qedf_release_cmd); in qedf_post_io_req()
892 io_req->sc_cmd = NULL; in qedf_post_io_req()
893 kref_put(&io_req->refcount, qedf_release_cmd); in qedf_post_io_req()
898 io_req->lun = (int)sc_cmd->device->lun; in qedf_post_io_req()
911 io_req->sc_cmd = NULL; in qedf_post_io_req()
912 kref_put(&io_req->refcount, qedf_release_cmd); in qedf_post_io_req()
916 qedf_init_task(fcport, lport, io_req, task_ctx, sqe); in qedf_post_io_req()
922 set_bit(QEDF_CMD_OUTSTANDING, &io_req->flags); in qedf_post_io_req()
924 if (qedf_io_tracing && io_req->sc_cmd) in qedf_post_io_req()
925 qedf_trace_io(fcport, io_req, QEDF_IO_TRACE_REQ); in qedf_post_io_req()
938 struct qedf_ioreq *io_req; in qedf_queuecommand() local
1027 io_req = qedf_alloc_cmd(fcport, QEDF_SCSI_CMD); in qedf_queuecommand()
1028 if (!io_req) { in qedf_queuecommand()
1034 io_req->sc_cmd = sc_cmd; in qedf_queuecommand()
1038 if (qedf_post_io_req(fcport, io_req)) { in qedf_queuecommand()
1051 static void qedf_parse_fcp_rsp(struct qedf_ioreq *io_req, in qedf_parse_fcp_rsp() argument
1054 struct scsi_cmnd *sc_cmd = io_req->sc_cmd; in qedf_parse_fcp_rsp()
1055 struct qedf_ctx *qedf = io_req->fcport->qedf; in qedf_parse_fcp_rsp()
1061 io_req->fcp_status = FC_GOOD; in qedf_parse_fcp_rsp()
1062 io_req->fcp_resid = 0; in qedf_parse_fcp_rsp()
1065 io_req->fcp_resid = fcp_rsp->fcp_resid; in qedf_parse_fcp_rsp()
1067 io_req->scsi_comp_flags = rsp_flags; in qedf_parse_fcp_rsp()
1068 CMD_SCSI_STATUS(sc_cmd) = io_req->cdb_status = in qedf_parse_fcp_rsp()
1079 io_req->fcp_rsp_len = fcp_rsp_len; in qedf_parse_fcp_rsp()
1080 io_req->fcp_sns_len = fcp_sns_len; in qedf_parse_fcp_rsp()
1081 rsp_info = sense_data = io_req->sense_buffer; in qedf_parse_fcp_rsp()
1086 io_req->fcp_rsp_code = rsp_info[3]; in qedf_parse_fcp_rsp()
1088 "fcp_rsp_code = %d\n", io_req->fcp_rsp_code); in qedf_parse_fcp_rsp()
1108 static void qedf_unmap_sg_list(struct qedf_ctx *qedf, struct qedf_ioreq *io_req) in qedf_unmap_sg_list() argument
1110 struct scsi_cmnd *sc = io_req->sc_cmd; in qedf_unmap_sg_list()
1112 if (io_req->bd_tbl->bd_valid && sc && scsi_sg_count(sc)) { in qedf_unmap_sg_list()
1115 io_req->bd_tbl->bd_valid = 0; in qedf_unmap_sg_list()
1120 struct qedf_ioreq *io_req) in qedf_scsi_completion() argument
1131 if (!io_req) in qedf_scsi_completion()
1136 if (!test_bit(QEDF_CMD_OUTSTANDING, &io_req->flags) || in qedf_scsi_completion()
1137 test_bit(QEDF_CMD_IN_CLEANUP, &io_req->flags) || in qedf_scsi_completion()
1138 test_bit(QEDF_CMD_IN_ABORT, &io_req->flags)) { in qedf_scsi_completion()
1141 io_req->xid); in qedf_scsi_completion()
1145 sc_cmd = io_req->sc_cmd; in qedf_scsi_completion()
1171 fcport = io_req->fcport; in qedf_scsi_completion()
1182 io_req->xid); in qedf_scsi_completion()
1186 qedf_parse_fcp_rsp(io_req, fcp_rsp); in qedf_scsi_completion()
1188 qedf_unmap_sg_list(qedf, io_req); in qedf_scsi_completion()
1191 if (io_req->fcp_rsp_len > 3 && io_req->fcp_rsp_code) { in qedf_scsi_completion()
1194 "fcp_rsp_code=%d.\n", io_req->xid, io_req->fcp_rsp_len, in qedf_scsi_completion()
1195 io_req->fcp_rsp_code); in qedf_scsi_completion()
1205 io_req->xid, fcp_rsp->rsp_flags.flags, in qedf_scsi_completion()
1206 io_req->fcp_resid, in qedf_scsi_completion()
1210 if (io_req->cdb_status == 0) in qedf_scsi_completion()
1211 sc_cmd->result = (DID_ERROR << 16) | io_req->cdb_status; in qedf_scsi_completion()
1213 sc_cmd->result = (DID_OK << 16) | io_req->cdb_status; in qedf_scsi_completion()
1223 switch (io_req->fcp_status) { in qedf_scsi_completion()
1225 if (io_req->cdb_status == 0) { in qedf_scsi_completion()
1229 refcount = kref_read(&io_req->refcount); in qedf_scsi_completion()
1235 sc_cmd->device->lun, io_req->xid, in qedf_scsi_completion()
1238 io_req->cdb_status, io_req->fcp_resid, in qedf_scsi_completion()
1240 sc_cmd->result = (DID_OK << 16) | io_req->cdb_status; in qedf_scsi_completion()
1242 if (io_req->cdb_status == SAM_STAT_TASK_SET_FULL || in qedf_scsi_completion()
1243 io_req->cdb_status == SAM_STAT_BUSY) { in qedf_scsi_completion()
1258 if (io_req->cdb_status == in qedf_scsi_completion()
1265 if (io_req->fcp_resid) in qedf_scsi_completion()
1266 scsi_set_resid(sc_cmd, io_req->fcp_resid); in qedf_scsi_completion()
1300 io_req->fcp_status); in qedf_scsi_completion()
1306 qedf_trace_io(fcport, io_req, QEDF_IO_TRACE_RSP); in qedf_scsi_completion()
1312 clear_bit(QEDF_CMD_OUTSTANDING, &io_req->flags); in qedf_scsi_completion()
1314 io_req->sc_cmd = NULL; in qedf_scsi_completion()
1317 kref_put(&io_req->refcount, qedf_release_cmd); in qedf_scsi_completion()
1321 void qedf_scsi_done(struct qedf_ctx *qedf, struct qedf_ioreq *io_req, in qedf_scsi_done() argument
1327 if (!io_req) { in qedf_scsi_done()
1332 if (test_and_set_bit(QEDF_CMD_ERR_SCSI_DONE, &io_req->flags)) { in qedf_scsi_done()
1335 io_req); in qedf_scsi_done()
1343 clear_bit(QEDF_CMD_OUTSTANDING, &io_req->flags); in qedf_scsi_done()
1345 sc_cmd = io_req->sc_cmd; in qedf_scsi_done()
1396 qedf_unmap_sg_list(qedf, io_req); in qedf_scsi_done()
1399 refcount = kref_read(&io_req->refcount); in qedf_scsi_done()
1416 qedf_trace_io(io_req->fcport, io_req, QEDF_IO_TRACE_RSP); in qedf_scsi_done()
1418 io_req->sc_cmd = NULL; in qedf_scsi_done()
1421 kref_put(&io_req->refcount, qedf_release_cmd); in qedf_scsi_done()
1429 io_req->sc_cmd = NULL; in qedf_scsi_done()
1430 kref_put(&io_req->refcount, qedf_release_cmd); /* ID: 001 */ in qedf_scsi_done()
1438 struct qedf_ioreq *io_req) in qedf_process_warning_compl() argument
1441 struct qedf_rport *fcport = io_req->fcport; in qedf_process_warning_compl()
1448 io_req, io_req->xid); in qedf_process_warning_compl()
1452 QEDF_ERR(&(io_req->fcport->qedf->dbg_ctx), "Warning CQE, " in qedf_process_warning_compl()
1453 "xid=0x%x\n", io_req->xid); in qedf_process_warning_compl()
1454 QEDF_ERR(&(io_req->fcport->qedf->dbg_ctx), in qedf_process_warning_compl()
1458 QEDF_ERR(&(io_req->fcport->qedf->dbg_ctx), "tx_buff_off=%08x, " in qedf_process_warning_compl()
1480 if (!test_bit(QEDF_CMD_SRR_SENT, &io_req->flags)) { in qedf_process_warning_compl()
1481 io_req->rx_buf_off = in qedf_process_warning_compl()
1483 io_req->tx_buf_off = in qedf_process_warning_compl()
1485 io_req->rx_id = cqe->cqe_info.err_info.rx_id; in qedf_process_warning_compl()
1486 rval = qedf_send_rec(io_req); in qedf_process_warning_compl()
1500 init_completion(&io_req->abts_done); in qedf_process_warning_compl()
1501 rval = qedf_initiate_abts(io_req, true); in qedf_process_warning_compl()
1508 struct qedf_ioreq *io_req) in qedf_process_error_detect() argument
1512 if (io_req == NULL) { in qedf_process_error_detect()
1517 if (io_req->fcport == NULL) { in qedf_process_error_detect()
1524 "cqe is NULL for io_req %p\n", io_req); in qedf_process_error_detect()
1528 QEDF_ERR(&(io_req->fcport->qedf->dbg_ctx), "Error detection CQE, " in qedf_process_error_detect()
1529 "xid=0x%x\n", io_req->xid); in qedf_process_error_detect()
1530 QEDF_ERR(&(io_req->fcport->qedf->dbg_ctx), in qedf_process_error_detect()
1534 QEDF_ERR(&(io_req->fcport->qedf->dbg_ctx), "tx_buff_off=%08x, " in qedf_process_error_detect()
1541 if (test_bit(QEDF_RPORT_IN_TARGET_RESET, &io_req->fcport->flags) || in qedf_process_error_detect()
1542 (test_bit(QEDF_RPORT_IN_LUN_RESET, &io_req->fcport->flags) && in qedf_process_error_detect()
1543 io_req->sc_cmd->device->lun == (u64)io_req->fcport->lun_reset_lun)) { in qedf_process_error_detect()
1546 io_req->xid); in qedf_process_error_detect()
1555 init_completion(&io_req->abts_done); in qedf_process_error_detect()
1556 rval = qedf_initiate_abts(io_req, true); in qedf_process_error_detect()
1594 struct qedf_ioreq *io_req; in qedf_flush_active_ios() local
1655 io_req = &cmd_mgr->cmds[i]; in qedf_flush_active_ios()
1657 if (!io_req) in qedf_flush_active_ios()
1659 if (!io_req->fcport) in qedf_flush_active_ios()
1664 if (io_req->alloc) { in qedf_flush_active_ios()
1665 if (!test_bit(QEDF_CMD_OUTSTANDING, &io_req->flags)) { in qedf_flush_active_ios()
1666 if (io_req->cmd_type == QEDF_SCSI_CMD) in qedf_flush_active_ios()
1669 io_req->xid); in qedf_flush_active_ios()
1677 if (io_req->fcport != fcport) in qedf_flush_active_ios()
1685 if (!test_bit(QEDF_CMD_OUTSTANDING, &io_req->flags)) { in qedf_flush_active_ios()
1686 refcount = kref_read(&io_req->refcount); in qedf_flush_active_ios()
1689 io_req->xid, io_req->cmd_type, refcount); in qedf_flush_active_ios()
1693 if (atomic_read(&io_req->state) == in qedf_flush_active_ios()
1696 (&io_req->rrq_work)) { in qedf_flush_active_ios()
1699 io_req->xid); in qedf_flush_active_ios()
1701 kref_put(&io_req->refcount, in qedf_flush_active_ios()
1709 if (io_req->cmd_type == QEDF_ELS && in qedf_flush_active_ios()
1711 rc = kref_get_unless_zero(&io_req->refcount); in qedf_flush_active_ios()
1715 io_req, io_req->xid); in qedf_flush_active_ios()
1718 qedf_initiate_cleanup(io_req, false); in qedf_flush_active_ios()
1720 qedf_flush_els_req(qedf, io_req); in qedf_flush_active_ios()
1729 if (io_req->cmd_type == QEDF_ABTS) { in qedf_flush_active_ios()
1731 rc = kref_get_unless_zero(&io_req->refcount); in qedf_flush_active_ios()
1735 io_req, io_req->xid); in qedf_flush_active_ios()
1738 if (lun != -1 && io_req->lun != lun) in qedf_flush_active_ios()
1742 "Flushing abort xid=0x%x.\n", io_req->xid); in qedf_flush_active_ios()
1744 if (cancel_delayed_work_sync(&io_req->rrq_work)) { in qedf_flush_active_ios()
1747 io_req->xid); in qedf_flush_active_ios()
1748 kref_put(&io_req->refcount, qedf_release_cmd); in qedf_flush_active_ios()
1751 if (cancel_delayed_work_sync(&io_req->timeout_work)) { in qedf_flush_active_ios()
1754 io_req->xid); in qedf_flush_active_ios()
1755 qedf_initiate_cleanup(io_req, true); in qedf_flush_active_ios()
1759 complete(&io_req->abts_done); in qedf_flush_active_ios()
1760 clear_bit(QEDF_CMD_IN_ABORT, &io_req->flags); in qedf_flush_active_ios()
1762 kref_put(&io_req->refcount, qedf_release_cmd); in qedf_flush_active_ios()
1768 if (!io_req->sc_cmd) in qedf_flush_active_ios()
1770 if (!io_req->sc_cmd->device) { in qedf_flush_active_ios()
1773 io_req->sc_cmd); in qedf_flush_active_ios()
1775 io_req->sc_cmd = NULL; in qedf_flush_active_ios()
1776 qedf_initiate_cleanup(io_req, false); in qedf_flush_active_ios()
1777 kref_put(&io_req->refcount, qedf_release_cmd); in qedf_flush_active_ios()
1781 if (io_req->lun != lun) in qedf_flush_active_ios()
1789 rc = kref_get_unless_zero(&io_req->refcount); in qedf_flush_active_ios()
1792 "io_req=0x%p xid=0x%x\n", io_req, io_req->xid); in qedf_flush_active_ios()
1797 "Cleanup xid=0x%x.\n", io_req->xid); in qedf_flush_active_ios()
1801 qedf_initiate_cleanup(io_req, true); in qedf_flush_active_ios()
1804 kref_put(&io_req->refcount, qedf_release_cmd); /* ID: 004 */ in qedf_flush_active_ios()
1826 io_req = &cmd_mgr->cmds[i]; in qedf_flush_active_ios()
1827 if (io_req->fcport && in qedf_flush_active_ios()
1828 io_req->fcport == fcport) { in qedf_flush_active_ios()
1830 kref_read(&io_req->refcount); in qedf_flush_active_ios()
1832 &io_req->flags); in qedf_flush_active_ios()
1835 io_req, io_req->xid, in qedf_flush_active_ios()
1836 io_req->flags, in qedf_flush_active_ios()
1837 io_req->sc_cmd, in qedf_flush_active_ios()
1839 io_req->cmd_type); in qedf_flush_active_ios()
1860 int qedf_initiate_abts(struct qedf_ioreq *io_req, bool return_scsi_cmd_on_abts) in qedf_initiate_abts() argument
1863 struct qedf_rport *fcport = io_req->fcport; in qedf_initiate_abts()
1916 if (!test_bit(QEDF_CMD_OUTSTANDING, &io_req->flags) || in qedf_initiate_abts()
1917 test_bit(QEDF_CMD_IN_CLEANUP, &io_req->flags) || in qedf_initiate_abts()
1918 test_bit(QEDF_CMD_IN_ABORT, &io_req->flags)) { in qedf_initiate_abts()
1921 io_req->xid, io_req->sc_cmd); in qedf_initiate_abts()
1926 kref_get(&io_req->refcount); in qedf_initiate_abts()
1928 xid = io_req->xid; in qedf_initiate_abts()
1933 io_req->cmd_type = QEDF_ABTS; in qedf_initiate_abts()
1934 io_req->return_scsi_cmd_on_abts = return_scsi_cmd_on_abts; in qedf_initiate_abts()
1936 set_bit(QEDF_CMD_IN_ABORT, &io_req->flags); in qedf_initiate_abts()
1937 refcount = kref_read(&io_req->refcount); in qedf_initiate_abts()
1942 qedf_cmd_timer_set(qedf, io_req, QEDF_ABORT_TIMEOUT); in qedf_initiate_abts()
1949 io_req->task_params->sqe = sqe; in qedf_initiate_abts()
1951 init_initiator_abort_fcoe_task(io_req->task_params); in qedf_initiate_abts()
1963 struct qedf_ioreq *io_req) in qedf_process_abts_compl() argument
1967 struct qedf_rport *fcport = io_req->fcport; in qedf_process_abts_compl()
1970 "0x%x cmd_type = %d\n", io_req->xid, io_req->cmd_type); in qedf_process_abts_compl()
1981 io_req->xid); in qedf_process_abts_compl()
1993 io_req->xid); in qedf_process_abts_compl()
1997 if (!cancel_delayed_work(&io_req->timeout_work)) { in qedf_process_abts_compl()
2006 io_req->event = QEDF_IOREQ_EV_ABORT_SUCCESS; in qedf_process_abts_compl()
2007 rc = kref_get_unless_zero(&io_req->refcount); /* ID: 003 */ in qedf_process_abts_compl()
2011 io_req->xid); in qedf_process_abts_compl()
2018 queue_delayed_work(qedf->dpc_wq, &io_req->rrq_work, in qedf_process_abts_compl()
2020 atomic_set(&io_req->state, QEDFC_CMD_ST_RRQ_WAIT); in qedf_process_abts_compl()
2026 io_req->event = QEDF_IOREQ_EV_ABORT_FAILED; in qedf_process_abts_compl()
2033 clear_bit(QEDF_CMD_IN_ABORT, &io_req->flags); in qedf_process_abts_compl()
2035 if (io_req->sc_cmd) { in qedf_process_abts_compl()
2036 if (!io_req->return_scsi_cmd_on_abts) in qedf_process_abts_compl()
2039 io_req->xid); in qedf_process_abts_compl()
2040 if (io_req->return_scsi_cmd_on_abts) in qedf_process_abts_compl()
2041 qedf_scsi_done(qedf, io_req, DID_ERROR); in qedf_process_abts_compl()
2045 complete(&io_req->abts_done); in qedf_process_abts_compl()
2047 kref_put(&io_req->refcount, qedf_release_cmd); in qedf_process_abts_compl()
2050 int qedf_init_mp_req(struct qedf_ioreq *io_req) in qedf_init_mp_req() argument
2055 struct qedf_ctx *qedf = io_req->fcport->qedf; in qedf_init_mp_req()
2061 mp_req = (struct qedf_mp_req *)&(io_req->mp_req); in qedf_init_mp_req()
2064 if (io_req->cmd_type != QEDF_ELS) { in qedf_init_mp_req()
2066 io_req->data_xfer_len = mp_req->req_len; in qedf_init_mp_req()
2068 mp_req->req_len = io_req->data_xfer_len; in qedf_init_mp_req()
2074 qedf_free_mp_resc(io_req); in qedf_init_mp_req()
2083 qedf_free_mp_resc(io_req); in qedf_init_mp_req()
2093 qedf_free_mp_resc(io_req); in qedf_init_mp_req()
2101 qedf_free_mp_resc(io_req); in qedf_init_mp_req()
2154 int qedf_initiate_cleanup(struct qedf_ioreq *io_req, in qedf_initiate_cleanup() argument
2166 fcport = io_req->fcport; in qedf_initiate_cleanup()
2184 if (io_req->cmd_type == QEDF_ELS) { in qedf_initiate_cleanup()
2188 if (!test_bit(QEDF_CMD_OUTSTANDING, &io_req->flags) || in qedf_initiate_cleanup()
2189 test_and_set_bit(QEDF_CMD_IN_CLEANUP, &io_req->flags)) { in qedf_initiate_cleanup()
2192 io_req->xid); in qedf_initiate_cleanup()
2195 set_bit(QEDF_CMD_IN_CLEANUP, &io_req->flags); in qedf_initiate_cleanup()
2202 clear_bit(QEDF_CMD_IN_CLEANUP, &io_req->flags); in qedf_initiate_cleanup()
2206 if (io_req->cmd_type == QEDF_CLEANUP) { in qedf_initiate_cleanup()
2209 io_req->xid, io_req->cmd_type); in qedf_initiate_cleanup()
2210 clear_bit(QEDF_CMD_IN_CLEANUP, &io_req->flags); in qedf_initiate_cleanup()
2214 refcount = kref_read(&io_req->refcount); in qedf_initiate_cleanup()
2218 io_req->xid, io_req->sc_cmd, io_req->cmd_type, io_req->flags, in qedf_initiate_cleanup()
2222 io_req->cmd_type = QEDF_CLEANUP; in qedf_initiate_cleanup()
2223 io_req->return_scsi_cmd_on_abts = return_scsi_cmd_on_abts; in qedf_initiate_cleanup()
2225 init_completion(&io_req->cleanup_done); in qedf_initiate_cleanup()
2232 io_req->task_params->sqe = sqe; in qedf_initiate_cleanup()
2234 init_initiator_cleanup_fcoe_task(io_req->task_params); in qedf_initiate_cleanup()
2239 tmo = wait_for_completion_timeout(&io_req->cleanup_done, in qedf_initiate_cleanup()
2246 "xid=%x.\n", io_req->xid); in qedf_initiate_cleanup()
2247 clear_bit(QEDF_CMD_IN_CLEANUP, &io_req->flags); in qedf_initiate_cleanup()
2256 if (io_req->tm_flags == FCP_TMF_LUN_RESET || in qedf_initiate_cleanup()
2257 io_req->tm_flags == FCP_TMF_TGT_RESET) { in qedf_initiate_cleanup()
2258 clear_bit(QEDF_CMD_OUTSTANDING, &io_req->flags); in qedf_initiate_cleanup()
2259 io_req->sc_cmd = NULL; in qedf_initiate_cleanup()
2260 complete(&io_req->tm_done); in qedf_initiate_cleanup()
2263 if (io_req->sc_cmd) { in qedf_initiate_cleanup()
2264 if (!io_req->return_scsi_cmd_on_abts) in qedf_initiate_cleanup()
2267 io_req->xid); in qedf_initiate_cleanup()
2268 if (io_req->return_scsi_cmd_on_abts) in qedf_initiate_cleanup()
2269 qedf_scsi_done(qedf, io_req, DID_ERROR); in qedf_initiate_cleanup()
2273 io_req->event = QEDF_IOREQ_EV_CLEANUP_SUCCESS; in qedf_initiate_cleanup()
2275 io_req->event = QEDF_IOREQ_EV_CLEANUP_FAILED; in qedf_initiate_cleanup()
2281 struct qedf_ioreq *io_req) in qedf_process_cleanup_compl() argument
2284 io_req->xid); in qedf_process_cleanup_compl()
2286 clear_bit(QEDF_CMD_IN_CLEANUP, &io_req->flags); in qedf_process_cleanup_compl()
2289 complete(&io_req->cleanup_done); in qedf_process_cleanup_compl()
2295 struct qedf_ioreq *io_req; in qedf_execute_tmf() local
2319 io_req = qedf_alloc_cmd(fcport, QEDF_TASK_MGMT_CMD); in qedf_execute_tmf()
2320 if (!io_req) { in qedf_execute_tmf()
2332 io_req->sc_cmd = sc_cmd; in qedf_execute_tmf()
2333 io_req->fcport = fcport; in qedf_execute_tmf()
2334 io_req->cmd_type = QEDF_TASK_MGMT_CMD; in qedf_execute_tmf()
2337 io_req->cpu = smp_processor_id(); in qedf_execute_tmf()
2340 io_req->io_req_flags = QEDF_READ; in qedf_execute_tmf()
2341 io_req->data_xfer_len = 0; in qedf_execute_tmf()
2342 io_req->tm_flags = tm_flags; in qedf_execute_tmf()
2345 io_req->return_scsi_cmd_on_abts = false; in qedf_execute_tmf()
2348 xid = io_req->xid; in qedf_execute_tmf()
2356 init_completion(&io_req->tm_done); in qedf_execute_tmf()
2364 qedf_init_task(fcport, lport, io_req, task, sqe); in qedf_execute_tmf()
2369 set_bit(QEDF_CMD_OUTSTANDING, &io_req->flags); in qedf_execute_tmf()
2370 tmo = wait_for_completion_timeout(&io_req->tm_done, in qedf_execute_tmf()
2377 clear_bit(QEDF_CMD_OUTSTANDING, &io_req->flags); in qedf_execute_tmf()
2378 io_req->sc_cmd = NULL; in qedf_execute_tmf()
2381 if (io_req->fcp_rsp_code == 0) in qedf_execute_tmf()
2396 kref_put(&io_req->refcount, qedf_release_cmd); in qedf_execute_tmf()
2424 struct qedf_ioreq *io_req = NULL; in qedf_initiate_tmf() local
2443 io_req = (struct qedf_ioreq *)sc_cmd->SCp.ptr; in qedf_initiate_tmf()
2444 ref_cnt = kref_read(&io_req->refcount); in qedf_initiate_tmf()
2447 io_req, io_req->xid, ref_cnt); in qedf_initiate_tmf()
2513 struct qedf_ioreq *io_req) in qedf_process_tmf_compl() argument
2517 clear_bit(QEDF_CMD_OUTSTANDING, &io_req->flags); in qedf_process_tmf_compl()
2520 qedf_parse_fcp_rsp(io_req, fcp_rsp); in qedf_process_tmf_compl()
2522 io_req->sc_cmd = NULL; in qedf_process_tmf_compl()
2523 complete(&io_req->tm_done); in qedf_process_tmf_compl()