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>
117 svc_rdma_send_ctxt_alloc(struct svcxprt_rdma *rdma) in svc_rdma_send_ctxt_alloc() argument
119 int node = ibdev_to_node(rdma->sc_cm_id->device); in svc_rdma_send_ctxt_alloc()
125 ctxt = kzalloc_node(struct_size(ctxt, sc_sges, rdma->sc_max_send_sges), in svc_rdma_send_ctxt_alloc()
129 buffer = kmalloc_node(rdma->sc_max_req_size, GFP_KERNEL, node); in svc_rdma_send_ctxt_alloc()
132 addr = ib_dma_map_single(rdma->sc_pd->device, buffer, in svc_rdma_send_ctxt_alloc()
133 rdma->sc_max_req_size, DMA_TO_DEVICE); in svc_rdma_send_ctxt_alloc()
134 if (ib_dma_mapping_error(rdma->sc_pd->device, addr)) in svc_rdma_send_ctxt_alloc()
137 svc_rdma_send_cid_init(rdma, &ctxt->sc_cid); in svc_rdma_send_ctxt_alloc()
139 ctxt->sc_rdma = rdma; in svc_rdma_send_ctxt_alloc()
147 rdma->sc_max_req_size); in svc_rdma_send_ctxt_alloc()
150 for (i = 0; i < rdma->sc_max_send_sges; i++) in svc_rdma_send_ctxt_alloc()
151 ctxt->sc_sges[i].lkey = rdma->sc_pd->local_dma_lkey; in svc_rdma_send_ctxt_alloc()
164 * @rdma: svcxprt_rdma being torn down
167 void svc_rdma_send_ctxts_destroy(struct svcxprt_rdma *rdma) in svc_rdma_send_ctxts_destroy() argument
172 while ((node = llist_del_first(&rdma->sc_send_ctxts)) != NULL) { in svc_rdma_send_ctxts_destroy()
174 ib_dma_unmap_single(rdma->sc_pd->device, in svc_rdma_send_ctxts_destroy()
176 rdma->sc_max_req_size, in svc_rdma_send_ctxts_destroy()
185 * @rdma: controlling svcxprt_rdma
190 struct svc_rdma_send_ctxt *svc_rdma_send_ctxt_get(struct svcxprt_rdma *rdma) in svc_rdma_send_ctxt_get() argument
195 spin_lock(&rdma->sc_send_lock); in svc_rdma_send_ctxt_get()
196 node = llist_del_first(&rdma->sc_send_ctxts); in svc_rdma_send_ctxt_get()
197 spin_unlock(&rdma->sc_send_lock); in svc_rdma_send_ctxt_get()
214 ctxt = svc_rdma_send_ctxt_alloc(rdma); in svc_rdma_send_ctxt_get()
220 static void svc_rdma_send_ctxt_release(struct svcxprt_rdma *rdma, in svc_rdma_send_ctxt_release() argument
223 struct ib_device *device = rdma->sc_cm_id->device; in svc_rdma_send_ctxt_release()
242 llist_add(&ctxt->sc_node, &rdma->sc_send_ctxts); in svc_rdma_send_ctxt_release()
255 * @rdma: controlling svcxprt_rdma
260 void svc_rdma_send_ctxt_put(struct svcxprt_rdma *rdma, in svc_rdma_send_ctxt_put() argument
269 * @rdma: controlling transport
273 void svc_rdma_wake_send_waiters(struct svcxprt_rdma *rdma, int avail) in svc_rdma_wake_send_waiters() argument
275 atomic_add(avail, &rdma->sc_sq_avail); in svc_rdma_wake_send_waiters()
277 if (unlikely(waitqueue_active(&rdma->sc_send_wait))) in svc_rdma_wake_send_waiters()
278 wake_up(&rdma->sc_send_wait); in svc_rdma_wake_send_waiters()
282 * svc_rdma_wc_send - Invoked by RDMA provider for each polled Send WC
291 struct svcxprt_rdma *rdma = cq->cq_context; in svc_rdma_wc_send() local
296 svc_rdma_wake_send_waiters(rdma, 1); in svc_rdma_wc_send()
302 svc_rdma_send_ctxt_put(rdma, ctxt); in svc_rdma_wc_send()
310 svc_rdma_send_ctxt_put(rdma, ctxt); in svc_rdma_wc_send()
311 svc_xprt_deferred_close(&rdma->sc_xprt); in svc_rdma_wc_send()
316 * @rdma: transport on which to post the WR
322 int svc_rdma_send(struct svcxprt_rdma *rdma, struct svc_rdma_send_ctxt *ctxt) in svc_rdma_send() argument
330 ib_dma_sync_single_for_device(rdma->sc_pd->device, in svc_rdma_send()
337 if ((atomic_dec_return(&rdma->sc_sq_avail) < 0)) { in svc_rdma_send()
339 trace_svcrdma_sq_full(rdma, &ctxt->sc_cid); in svc_rdma_send()
340 atomic_inc(&rdma->sc_sq_avail); in svc_rdma_send()
341 wait_event(rdma->sc_send_wait, in svc_rdma_send()
342 atomic_read(&rdma->sc_sq_avail) > 1); in svc_rdma_send()
343 if (test_bit(XPT_CLOSE, &rdma->sc_xprt.xpt_flags)) in svc_rdma_send()
345 trace_svcrdma_sq_retry(rdma, &ctxt->sc_cid); in svc_rdma_send()
350 ret = ib_post_send(rdma->sc_qp, wr, NULL); in svc_rdma_send()
356 trace_svcrdma_sq_post_err(rdma, &ctxt->sc_cid, ret); in svc_rdma_send()
357 svc_xprt_deferred_close(&rdma->sc_xprt); in svc_rdma_send()
358 wake_up(&rdma->sc_send_wait); in svc_rdma_send()
373 /* RPC-over-RDMA version 1 replies never have a Read list. */ in svc_rdma_encode_read_list()
535 struct svcxprt_rdma *rdma = args->md_rdma; in svc_rdma_page_dma_map() local
537 struct ib_device *dev = rdma->sc_cm_id->device; in svc_rdma_page_dma_map()
663 * @rdma: controlling transport
672 static bool svc_rdma_pull_up_needed(const struct svcxprt_rdma *rdma, in svc_rdma_pull_up_needed() argument
691 return args.pd_num_sges >= rdma->sc_max_send_sges; in svc_rdma_pull_up_needed()
738 * @rdma: controlling transport
753 static int svc_rdma_pull_up_reply_msg(const struct svcxprt_rdma *rdma, in svc_rdma_pull_up_reply_msg() argument
774 * @rdma: controlling transport
787 int svc_rdma_map_reply_msg(struct svcxprt_rdma *rdma, in svc_rdma_map_reply_msg() argument
794 .md_rdma = rdma, in svc_rdma_map_reply_msg()
811 if (svc_rdma_pull_up_needed(rdma, sctxt, write_pcl, xdr)) in svc_rdma_map_reply_msg()
812 return svc_rdma_pull_up_reply_msg(rdma, sctxt, write_pcl, xdr); in svc_rdma_map_reply_msg()
838 * via RDMA Send. The RPC-over-RDMA transport header is prepared
846 * RDMA Send is the last step of transmitting an RPC reply. Pages
847 * involved in the earlier RDMA Writes are here transferred out
855 static int svc_rdma_send_reply_msg(struct svcxprt_rdma *rdma, in svc_rdma_send_reply_msg() argument
862 ret = svc_rdma_map_reply_msg(rdma, sctxt, &rctxt->rc_write_pcl, in svc_rdma_send_reply_msg()
876 return svc_rdma_send(rdma, sctxt); in svc_rdma_send_reply_msg()
880 * svc_rdma_send_error_msg - Send an RPC/RDMA v1 error response
881 * @rdma: controlling transport context
894 void svc_rdma_send_error_msg(struct svcxprt_rdma *rdma, in svc_rdma_send_error_msg() argument
913 *p++ = rdma->sc_fc_credits; in svc_rdma_send_error_msg()
940 if (svc_rdma_send(rdma, sctxt)) in svc_rdma_send_error_msg()
945 svc_rdma_send_ctxt_put(rdma, sctxt); in svc_rdma_send_error_msg()
963 struct svcxprt_rdma *rdma = in svc_rdma_sendto() local
977 sctxt = svc_rdma_send_ctxt_get(rdma); in svc_rdma_sendto()
987 ret = svc_rdma_send_reply_chunk(rdma, rctxt, &rqstp->rq_res); in svc_rdma_sendto()
994 *p++ = rdma->sc_fc_credits; in svc_rdma_sendto()
1007 ret = svc_rdma_send_reply_msg(rdma, sctxt, rctxt, rqstp); in svc_rdma_sendto()
1017 * of previously posted RDMA Writes. in svc_rdma_sendto()
1020 svc_rdma_send_error_msg(rdma, sctxt, rctxt, ret); in svc_rdma_sendto()
1024 svc_rdma_send_ctxt_put(rdma, sctxt); in svc_rdma_sendto()
1027 svc_xprt_deferred_close(&rdma->sc_xprt); in svc_rdma_sendto()
1051 struct svcxprt_rdma *rdma; in svc_rdma_result_payload() local
1069 rdma = container_of(rqstp->rq_xprt, struct svcxprt_rdma, sc_xprt); in svc_rdma_result_payload()
1070 ret = svc_rdma_send_write_chunk(rdma, chunk, &subbuf); in svc_rdma_result_payload()