Lines Matching full:rdma

51  * XDR-encoded RPC Reply message. sendto must construct the RPC-over-RDMA
105 #include <rdma/ib_verbs.h>
106 #include <rdma/rdma_cm.h>
116 static void svc_rdma_send_cid_init(struct svcxprt_rdma *rdma, in svc_rdma_send_cid_init() argument
119 cid->ci_queue_id = rdma->sc_sq_cq->res.id; in svc_rdma_send_cid_init()
120 cid->ci_completion_id = atomic_inc_return(&rdma->sc_completion_ids); in svc_rdma_send_cid_init()
124 svc_rdma_send_ctxt_alloc(struct svcxprt_rdma *rdma) in svc_rdma_send_ctxt_alloc() argument
126 int node = ibdev_to_node(rdma->sc_cm_id->device); in svc_rdma_send_ctxt_alloc()
132 ctxt = kmalloc_node(struct_size(ctxt, sc_sges, rdma->sc_max_send_sges), in svc_rdma_send_ctxt_alloc()
136 buffer = kmalloc_node(rdma->sc_max_req_size, GFP_KERNEL, node); in svc_rdma_send_ctxt_alloc()
139 addr = ib_dma_map_single(rdma->sc_pd->device, buffer, in svc_rdma_send_ctxt_alloc()
140 rdma->sc_max_req_size, DMA_TO_DEVICE); in svc_rdma_send_ctxt_alloc()
141 if (ib_dma_mapping_error(rdma->sc_pd->device, addr)) in svc_rdma_send_ctxt_alloc()
144 svc_rdma_send_cid_init(rdma, &ctxt->sc_cid); in svc_rdma_send_ctxt_alloc()
153 rdma->sc_max_req_size); in svc_rdma_send_ctxt_alloc()
156 for (i = 0; i < rdma->sc_max_send_sges; i++) in svc_rdma_send_ctxt_alloc()
157 ctxt->sc_sges[i].lkey = rdma->sc_pd->local_dma_lkey; in svc_rdma_send_ctxt_alloc()
170 * @rdma: svcxprt_rdma being torn down
173 void svc_rdma_send_ctxts_destroy(struct svcxprt_rdma *rdma) in svc_rdma_send_ctxts_destroy() argument
178 while ((node = llist_del_first(&rdma->sc_send_ctxts)) != NULL) { in svc_rdma_send_ctxts_destroy()
180 ib_dma_unmap_single(rdma->sc_pd->device, in svc_rdma_send_ctxts_destroy()
182 rdma->sc_max_req_size, in svc_rdma_send_ctxts_destroy()
191 * @rdma: controlling svcxprt_rdma
196 struct svc_rdma_send_ctxt *svc_rdma_send_ctxt_get(struct svcxprt_rdma *rdma) in svc_rdma_send_ctxt_get() argument
201 spin_lock(&rdma->sc_send_lock); in svc_rdma_send_ctxt_get()
202 node = llist_del_first(&rdma->sc_send_ctxts); in svc_rdma_send_ctxt_get()
206 spin_unlock(&rdma->sc_send_lock); in svc_rdma_send_ctxt_get()
219 spin_unlock(&rdma->sc_send_lock); in svc_rdma_send_ctxt_get()
220 ctxt = svc_rdma_send_ctxt_alloc(rdma); in svc_rdma_send_ctxt_get()
228 * @rdma: controlling svcxprt_rdma
233 void svc_rdma_send_ctxt_put(struct svcxprt_rdma *rdma, in svc_rdma_send_ctxt_put() argument
236 struct ib_device *device = rdma->sc_cm_id->device; in svc_rdma_send_ctxt_put()
250 trace_svcrdma_dma_unmap_page(rdma, in svc_rdma_send_ctxt_put()
255 llist_add(&ctxt->sc_node, &rdma->sc_send_ctxts); in svc_rdma_send_ctxt_put()
260 * @rdma: controlling transport
264 void svc_rdma_wake_send_waiters(struct svcxprt_rdma *rdma, int avail) in svc_rdma_wake_send_waiters() argument
266 atomic_add(avail, &rdma->sc_sq_avail); in svc_rdma_wake_send_waiters()
268 if (unlikely(waitqueue_active(&rdma->sc_send_wait))) in svc_rdma_wake_send_waiters()
269 wake_up(&rdma->sc_send_wait); in svc_rdma_wake_send_waiters()
273 * svc_rdma_wc_send - Invoked by RDMA provider for each polled Send WC
282 struct svcxprt_rdma *rdma = cq->cq_context; in svc_rdma_wc_send() local
287 svc_rdma_wake_send_waiters(rdma, 1); in svc_rdma_wc_send()
293 svc_rdma_send_ctxt_put(rdma, ctxt); in svc_rdma_wc_send()
301 svc_rdma_send_ctxt_put(rdma, ctxt); in svc_rdma_wc_send()
302 svc_xprt_deferred_close(&rdma->sc_xprt); in svc_rdma_wc_send()
307 * @rdma: transport on which to post the WR
313 int svc_rdma_send(struct svcxprt_rdma *rdma, struct svc_rdma_send_ctxt *ctxt) in svc_rdma_send() argument
321 ib_dma_sync_single_for_device(rdma->sc_pd->device, in svc_rdma_send()
328 if ((atomic_dec_return(&rdma->sc_sq_avail) < 0)) { in svc_rdma_send()
330 trace_svcrdma_sq_full(rdma); in svc_rdma_send()
331 atomic_inc(&rdma->sc_sq_avail); in svc_rdma_send()
332 wait_event(rdma->sc_send_wait, in svc_rdma_send()
333 atomic_read(&rdma->sc_sq_avail) > 1); in svc_rdma_send()
334 if (test_bit(XPT_CLOSE, &rdma->sc_xprt.xpt_flags)) in svc_rdma_send()
336 trace_svcrdma_sq_retry(rdma); in svc_rdma_send()
341 ret = ib_post_send(rdma->sc_qp, wr, NULL); in svc_rdma_send()
347 trace_svcrdma_sq_post_err(rdma, ret); in svc_rdma_send()
348 svc_xprt_deferred_close(&rdma->sc_xprt); in svc_rdma_send()
349 wake_up(&rdma->sc_send_wait); in svc_rdma_send()
364 /* RPC-over-RDMA version 1 replies never have a Read list. */ in svc_rdma_encode_read_list()
526 struct svcxprt_rdma *rdma = args->md_rdma; in svc_rdma_page_dma_map() local
528 struct ib_device *dev = rdma->sc_cm_id->device; in svc_rdma_page_dma_map()
537 trace_svcrdma_dma_map_page(rdma, dma_addr, len); in svc_rdma_page_dma_map()
544 trace_svcrdma_dma_map_err(rdma, dma_addr, len); in svc_rdma_page_dma_map()
654 * @rdma: controlling transport
663 static bool svc_rdma_pull_up_needed(const struct svcxprt_rdma *rdma, in svc_rdma_pull_up_needed() argument
682 return args.pd_num_sges >= rdma->sc_max_send_sges; in svc_rdma_pull_up_needed()
729 * @rdma: controlling transport
744 static int svc_rdma_pull_up_reply_msg(const struct svcxprt_rdma *rdma, in svc_rdma_pull_up_reply_msg() argument
765 * @rdma: controlling transport
777 int svc_rdma_map_reply_msg(struct svcxprt_rdma *rdma, in svc_rdma_map_reply_msg() argument
783 .md_rdma = rdma, in svc_rdma_map_reply_msg()
800 if (svc_rdma_pull_up_needed(rdma, sctxt, rctxt, xdr)) in svc_rdma_map_reply_msg()
801 return svc_rdma_pull_up_reply_msg(rdma, sctxt, rctxt, xdr); in svc_rdma_map_reply_msg()
827 * via RDMA Send. The RPC-over-RDMA transport header is prepared
835 * RDMA Send is the last step of transmitting an RPC reply. Pages
836 * involved in the earlier RDMA Writes are here transferred out
844 static int svc_rdma_send_reply_msg(struct svcxprt_rdma *rdma, in svc_rdma_send_reply_msg() argument
851 ret = svc_rdma_map_reply_msg(rdma, sctxt, rctxt, &rqstp->rq_res); in svc_rdma_send_reply_msg()
864 return svc_rdma_send(rdma, sctxt); in svc_rdma_send_reply_msg()
868 * svc_rdma_send_error_msg - Send an RPC/RDMA v1 error response
869 * @rdma: controlling transport context
882 void svc_rdma_send_error_msg(struct svcxprt_rdma *rdma, in svc_rdma_send_error_msg() argument
901 *p++ = rdma->sc_fc_credits; in svc_rdma_send_error_msg()
928 if (svc_rdma_send(rdma, sctxt)) in svc_rdma_send_error_msg()
933 svc_rdma_send_ctxt_put(rdma, sctxt); in svc_rdma_send_error_msg()
951 struct svcxprt_rdma *rdma = in svc_rdma_sendto() local
965 sctxt = svc_rdma_send_ctxt_get(rdma); in svc_rdma_sendto()
975 ret = svc_rdma_send_reply_chunk(rdma, rctxt, &rqstp->rq_res); in svc_rdma_sendto()
982 *p++ = rdma->sc_fc_credits; in svc_rdma_sendto()
995 ret = svc_rdma_send_reply_msg(rdma, sctxt, rctxt, rqstp); in svc_rdma_sendto()
1005 * of previously posted RDMA Writes. in svc_rdma_sendto()
1008 svc_rdma_send_error_msg(rdma, sctxt, rctxt, ret); in svc_rdma_sendto()
1012 svc_rdma_send_ctxt_put(rdma, sctxt); in svc_rdma_sendto()
1015 svc_xprt_deferred_close(&rdma->sc_xprt); in svc_rdma_sendto()
1039 struct svcxprt_rdma *rdma; in svc_rdma_result_payload() local
1057 rdma = container_of(rqstp->rq_xprt, struct svcxprt_rdma, sc_xprt); in svc_rdma_result_payload()
1058 ret = svc_rdma_send_write_chunk(rdma, chunk, &subbuf); in svc_rdma_result_payload()