Lines Matching refs:ioctx

657 	struct srpt_ioctx *ioctx;  in srpt_alloc_ioctx()  local
659 ioctx = kzalloc(ioctx_size, GFP_KERNEL); in srpt_alloc_ioctx()
660 if (!ioctx) in srpt_alloc_ioctx()
663 ioctx->buf = kmem_cache_alloc(buf_cache, GFP_KERNEL); in srpt_alloc_ioctx()
664 if (!ioctx->buf) in srpt_alloc_ioctx()
667 ioctx->dma = ib_dma_map_single(sdev->device, ioctx->buf, in srpt_alloc_ioctx()
669 if (ib_dma_mapping_error(sdev->device, ioctx->dma)) in srpt_alloc_ioctx()
672 return ioctx; in srpt_alloc_ioctx()
675 kmem_cache_free(buf_cache, ioctx->buf); in srpt_alloc_ioctx()
677 kfree(ioctx); in srpt_alloc_ioctx()
689 static void srpt_free_ioctx(struct srpt_device *sdev, struct srpt_ioctx *ioctx, in srpt_free_ioctx() argument
693 if (!ioctx) in srpt_free_ioctx()
696 ib_dma_unmap_single(sdev->device, ioctx->dma, in srpt_free_ioctx()
698 kmem_cache_free(buf_cache, ioctx->buf); in srpt_free_ioctx()
699 kfree(ioctx); in srpt_free_ioctx()
776 static enum srpt_command_state srpt_set_cmd_state(struct srpt_send_ioctx *ioctx, in srpt_set_cmd_state() argument
781 previous = ioctx->state; in srpt_set_cmd_state()
783 ioctx->state = new; in srpt_set_cmd_state()
796 static bool srpt_test_and_set_cmd_state(struct srpt_send_ioctx *ioctx, in srpt_test_and_set_cmd_state() argument
802 WARN_ON(!ioctx); in srpt_test_and_set_cmd_state()
806 previous = ioctx->state; in srpt_test_and_set_cmd_state()
808 ioctx->state = new; in srpt_test_and_set_cmd_state()
820 struct srpt_recv_ioctx *ioctx) in srpt_post_recv() argument
826 list.addr = ioctx->ioctx.dma + ioctx->ioctx.offset; in srpt_post_recv()
830 ioctx->ioctx.cqe.done = srpt_recv_done; in srpt_post_recv()
831 wr.wr_cqe = &ioctx->ioctx.cqe; in srpt_post_recv()
886 static int srpt_alloc_rw_ctxs(struct srpt_send_ioctx *ioctx, in srpt_alloc_rw_ctxs() argument
890 enum dma_data_direction dir = target_reverse_dma_direction(&ioctx->cmd); in srpt_alloc_rw_ctxs()
891 struct srpt_rdma_ch *ch = ioctx->ch; in srpt_alloc_rw_ctxs()
897 ioctx->rw_ctxs = &ioctx->s_rw_ctx; in srpt_alloc_rw_ctxs()
899 ioctx->rw_ctxs = kmalloc_array(nbufs, sizeof(*ioctx->rw_ctxs), in srpt_alloc_rw_ctxs()
901 if (!ioctx->rw_ctxs) in srpt_alloc_rw_ctxs()
905 for (i = ioctx->n_rw_ctx; i < nbufs; i++, db++) { in srpt_alloc_rw_ctxs()
906 struct srpt_rw_ctx *ctx = &ioctx->rw_ctxs[i]; in srpt_alloc_rw_ctxs()
923 ioctx->n_rdma += ret; in srpt_alloc_rw_ctxs()
924 ioctx->n_rw_ctx++; in srpt_alloc_rw_ctxs()
943 struct srpt_rw_ctx *ctx = &ioctx->rw_ctxs[i]; in srpt_alloc_rw_ctxs()
949 if (ioctx->rw_ctxs != &ioctx->s_rw_ctx) in srpt_alloc_rw_ctxs()
950 kfree(ioctx->rw_ctxs); in srpt_alloc_rw_ctxs()
955 struct srpt_send_ioctx *ioctx) in srpt_free_rw_ctxs() argument
957 enum dma_data_direction dir = target_reverse_dma_direction(&ioctx->cmd); in srpt_free_rw_ctxs()
960 for (i = 0; i < ioctx->n_rw_ctx; i++) { in srpt_free_rw_ctxs()
961 struct srpt_rw_ctx *ctx = &ioctx->rw_ctxs[i]; in srpt_free_rw_ctxs()
968 if (ioctx->rw_ctxs != &ioctx->s_rw_ctx) in srpt_free_rw_ctxs()
969 kfree(ioctx->rw_ctxs); in srpt_free_rw_ctxs()
1010 struct srpt_send_ioctx *ioctx, in srpt_get_desc_tbl() argument
1033 ioctx->cmd.data_direction = *dir; in srpt_get_desc_tbl()
1040 return srpt_alloc_rw_ctxs(ioctx, db, 1, sg, sg_cnt); in srpt_get_desc_tbl()
1058 return srpt_alloc_rw_ctxs(ioctx, idb->desc_list, nbufs, in srpt_get_desc_tbl()
1085 ioctx->recv_ioctx = recv_ioctx; in srpt_get_desc_tbl()
1090 sg_init_one(&ioctx->imm_sg, data, len); in srpt_get_desc_tbl()
1091 *sg = &ioctx->imm_sg; in srpt_get_desc_tbl()
1217 struct srpt_send_ioctx *ioctx; in srpt_get_send_ioctx() local
1226 ioctx = ch->ioctx_ring[tag]; in srpt_get_send_ioctx()
1227 BUG_ON(ioctx->ch != ch); in srpt_get_send_ioctx()
1228 ioctx->state = SRPT_STATE_NEW; in srpt_get_send_ioctx()
1229 WARN_ON_ONCE(ioctx->recv_ioctx); in srpt_get_send_ioctx()
1230 ioctx->n_rdma = 0; in srpt_get_send_ioctx()
1231 ioctx->n_rw_ctx = 0; in srpt_get_send_ioctx()
1232 ioctx->queue_status_only = false; in srpt_get_send_ioctx()
1237 memset(&ioctx->cmd, 0, sizeof(ioctx->cmd)); in srpt_get_send_ioctx()
1238 memset(&ioctx->sense_data, 0, sizeof(ioctx->sense_data)); in srpt_get_send_ioctx()
1239 ioctx->cmd.map_tag = tag; in srpt_get_send_ioctx()
1240 ioctx->cmd.map_cpu = cpu; in srpt_get_send_ioctx()
1242 return ioctx; in srpt_get_send_ioctx()
1249 static int srpt_abort_cmd(struct srpt_send_ioctx *ioctx) in srpt_abort_cmd() argument
1253 BUG_ON(!ioctx); in srpt_abort_cmd()
1260 state = ioctx->state; in srpt_abort_cmd()
1263 ioctx->state = SRPT_STATE_DATA_IN; in srpt_abort_cmd()
1267 ioctx->state = SRPT_STATE_DONE; in srpt_abort_cmd()
1276 ioctx->state, ioctx->cmd.tag); in srpt_abort_cmd()
1289 pr_debug("tag %#llx: RDMA read error\n", ioctx->cmd.tag); in srpt_abort_cmd()
1290 transport_generic_request_failure(&ioctx->cmd, in srpt_abort_cmd()
1298 transport_generic_free_cmd(&ioctx->cmd, 0); in srpt_abort_cmd()
1301 transport_generic_free_cmd(&ioctx->cmd, 0); in srpt_abort_cmd()
1324 struct srpt_send_ioctx *ioctx = in srpt_rdma_read_done() local
1327 WARN_ON(ioctx->n_rdma <= 0); in srpt_rdma_read_done()
1328 atomic_add(ioctx->n_rdma, &ch->sq_wr_avail); in srpt_rdma_read_done()
1329 ioctx->n_rdma = 0; in srpt_rdma_read_done()
1333 ioctx, wc->status); in srpt_rdma_read_done()
1334 srpt_abort_cmd(ioctx); in srpt_rdma_read_done()
1338 if (srpt_test_and_set_cmd_state(ioctx, SRPT_STATE_NEED_DATA, in srpt_rdma_read_done()
1340 target_execute_cmd(&ioctx->cmd); in srpt_rdma_read_done()
1343 __LINE__, ioctx->state); in srpt_rdma_read_done()
1362 struct srpt_send_ioctx *ioctx, u64 tag, in srpt_build_cmd_rsp() argument
1365 struct se_cmd *cmd = &ioctx->cmd; in srpt_build_cmd_rsp()
1377 srp_rsp = ioctx->ioctx.buf; in srpt_build_cmd_rsp()
1380 sense_data = ioctx->sense_data; in srpt_build_cmd_rsp()
1381 sense_data_len = ioctx->cmd.scsi_sense_length; in srpt_build_cmd_rsp()
1382 WARN_ON(sense_data_len > sizeof(ioctx->sense_data)); in srpt_build_cmd_rsp()
1444 struct srpt_send_ioctx *ioctx, in srpt_build_tskmgmt_rsp() argument
1454 srp_rsp = ioctx->ioctx.buf; in srpt_build_tskmgmt_rsp()
1472 struct srpt_send_ioctx *ioctx = container_of(cmd, in srpt_check_stop_free() local
1475 return target_put_sess_cmd(&ioctx->cmd); in srpt_check_stop_free()
1498 srp_cmd = recv_ioctx->ioctx.buf + recv_ioctx->ioctx.offset; in srpt_handle_cmd()
1585 srp_tsk = recv_ioctx->ioctx.buf + recv_ioctx->ioctx.offset; in srpt_handle_tsk_mgmt()
1626 recv_ioctx->ioctx.dma, in srpt_handle_new_iu()
1627 recv_ioctx->ioctx.offset + srp_max_req_size, in srpt_handle_new_iu()
1630 srp_cmd = recv_ioctx->ioctx.buf + recv_ioctx->ioctx.offset; in srpt_handle_new_iu()
1685 struct srpt_recv_ioctx *ioctx = in srpt_recv_done() local
1686 container_of(wc->wr_cqe, struct srpt_recv_ioctx, ioctx.cqe); in srpt_recv_done()
1694 ioctx->byte_len = wc->byte_len; in srpt_recv_done()
1695 srpt_handle_new_iu(ch, ioctx); in srpt_recv_done()
1698 ioctx, wc->status); in srpt_recv_done()
1746 struct srpt_send_ioctx *ioctx = in srpt_send_done() local
1747 container_of(wc->wr_cqe, struct srpt_send_ioctx, ioctx.cqe); in srpt_send_done()
1750 state = srpt_set_cmd_state(ioctx, SRPT_STATE_DONE); in srpt_send_done()
1755 atomic_add(1 + ioctx->n_rdma, &ch->sq_wr_avail); in srpt_send_done()
1759 ioctx, wc->status); in srpt_send_done()
1762 transport_generic_free_cmd(&ioctx->cmd, 0); in srpt_send_done()
1765 ioctx->ioctx.index); in srpt_send_done()
2735 struct srpt_send_ioctx *ioctx = in srpt_write_pending() local
2737 struct srpt_rdma_ch *ch = ioctx->ch; in srpt_write_pending()
2739 struct ib_cqe *cqe = &ioctx->rdma_cqe; in srpt_write_pending()
2743 if (ioctx->recv_ioctx) { in srpt_write_pending()
2744 srpt_set_cmd_state(ioctx, SRPT_STATE_DATA_IN); in srpt_write_pending()
2745 target_execute_cmd(&ioctx->cmd); in srpt_write_pending()
2749 new_state = srpt_set_cmd_state(ioctx, SRPT_STATE_NEED_DATA); in srpt_write_pending()
2752 if (atomic_sub_return(ioctx->n_rdma, &ch->sq_wr_avail) < 0) { in srpt_write_pending()
2754 __func__, ioctx->n_rdma); in srpt_write_pending()
2760 for (i = ioctx->n_rw_ctx - 1; i >= 0; i--) { in srpt_write_pending()
2761 struct srpt_rw_ctx *ctx = &ioctx->rw_ctxs[i]; in srpt_write_pending()
2771 __func__, ret, ioctx->n_rdma, in srpt_write_pending()
2778 atomic_add(ioctx->n_rdma, &ch->sq_wr_avail); in srpt_write_pending()
2802 struct srpt_send_ioctx *ioctx = in srpt_queue_response() local
2804 struct srpt_rdma_ch *ch = ioctx->ch; in srpt_queue_response()
2812 state = ioctx->state; in srpt_queue_response()
2816 ioctx->state = SRPT_STATE_CMD_RSP_SENT; in srpt_queue_response()
2819 ioctx->state = SRPT_STATE_MGMT_RSP_SENT; in srpt_queue_response()
2823 ch, ioctx->ioctx.index, ioctx->state); in srpt_queue_response()
2831 if (ioctx->cmd.data_direction == DMA_FROM_DEVICE && in srpt_queue_response()
2832 ioctx->cmd.data_length && in srpt_queue_response()
2833 !ioctx->queue_status_only) { in srpt_queue_response()
2834 for (i = ioctx->n_rw_ctx - 1; i >= 0; i--) { in srpt_queue_response()
2835 struct srpt_rw_ctx *ctx = &ioctx->rw_ctxs[i]; in srpt_queue_response()
2843 resp_len = srpt_build_cmd_rsp(ch, ioctx, ioctx->cmd.tag, in srpt_queue_response()
2848 resp_len = srpt_build_tskmgmt_rsp(ch, ioctx, srp_tm_status, in srpt_queue_response()
2849 ioctx->cmd.tag); in srpt_queue_response()
2854 if (unlikely(atomic_sub_return(1 + ioctx->n_rdma, in srpt_queue_response()
2857 __func__, ioctx->n_rdma); in srpt_queue_response()
2862 ib_dma_sync_single_for_device(sdev->device, ioctx->ioctx.dma, resp_len, in srpt_queue_response()
2865 sge.addr = ioctx->ioctx.dma; in srpt_queue_response()
2869 ioctx->ioctx.cqe.done = srpt_send_done; in srpt_queue_response()
2871 send_wr.wr_cqe = &ioctx->ioctx.cqe; in srpt_queue_response()
2880 __func__, ioctx->cmd.tag, ret); in srpt_queue_response()
2887 atomic_add(1 + ioctx->n_rdma, &ch->sq_wr_avail); in srpt_queue_response()
2889 srpt_set_cmd_state(ioctx, SRPT_STATE_DONE); in srpt_queue_response()
2890 target_put_sess_cmd(&ioctx->cmd); in srpt_queue_response()
2912 struct srpt_send_ioctx *ioctx = container_of(cmd, in srpt_aborted_task() local
2914 struct srpt_rdma_ch *ch = ioctx->ch; in srpt_aborted_task()
2921 struct srpt_send_ioctx *ioctx; in srpt_queue_status() local
2923 ioctx = container_of(cmd, struct srpt_send_ioctx, cmd); in srpt_queue_status()
2924 BUG_ON(ioctx->sense_data != cmd->sense_buffer); in srpt_queue_status()
2928 ioctx->queue_status_only = true; in srpt_queue_status()
3340 struct srpt_send_ioctx *ioctx = container_of(se_cmd, in srpt_release_cmd() local
3342 struct srpt_rdma_ch *ch = ioctx->ch; in srpt_release_cmd()
3343 struct srpt_recv_ioctx *recv_ioctx = ioctx->recv_ioctx; in srpt_release_cmd()
3345 WARN_ON_ONCE(ioctx->state != SRPT_STATE_DONE && in srpt_release_cmd()
3346 !(ioctx->cmd.transport_state & CMD_T_ABORTED)); in srpt_release_cmd()
3350 ioctx->recv_ioctx = NULL; in srpt_release_cmd()
3354 if (ioctx->n_rw_ctx) { in srpt_release_cmd()
3355 srpt_free_rw_ctxs(ch, ioctx); in srpt_release_cmd()
3356 ioctx->n_rw_ctx = 0; in srpt_release_cmd()
3398 struct srpt_send_ioctx *ioctx; in srpt_get_tcm_cmd_state() local
3400 ioctx = container_of(se_cmd, struct srpt_send_ioctx, cmd); in srpt_get_tcm_cmd_state()
3401 return ioctx->state; in srpt_get_tcm_cmd_state()