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()
208 svc_rdma_cc_init(rdma, &ctxt->sc_reply_info.wi_cc); in svc_rdma_send_ctxt_get()
218 ctxt = svc_rdma_send_ctxt_alloc(rdma); in svc_rdma_send_ctxt_get()
224 static void svc_rdma_send_ctxt_release(struct svcxprt_rdma *rdma, in svc_rdma_send_ctxt_release() argument
227 struct ib_device *device = rdma->sc_cm_id->device; in svc_rdma_send_ctxt_release()
230 svc_rdma_reply_chunk_release(rdma, ctxt); in svc_rdma_send_ctxt_release()
248 llist_add(&ctxt->sc_node, &rdma->sc_send_ctxts); in svc_rdma_send_ctxt_release()
261 * @rdma: controlling svcxprt_rdma
266 void svc_rdma_send_ctxt_put(struct svcxprt_rdma *rdma, in svc_rdma_send_ctxt_put() argument
275 * @rdma: controlling transport
279 void svc_rdma_wake_send_waiters(struct svcxprt_rdma *rdma, int avail) in svc_rdma_wake_send_waiters() argument
281 atomic_add(avail, &rdma->sc_sq_avail); in svc_rdma_wake_send_waiters()
283 if (unlikely(waitqueue_active(&rdma->sc_send_wait))) in svc_rdma_wake_send_waiters()
284 wake_up(&rdma->sc_send_wait); in svc_rdma_wake_send_waiters()
288 * svc_rdma_wc_send - Invoked by RDMA provider for each polled Send WC
297 struct svcxprt_rdma *rdma = cq->cq_context; in svc_rdma_wc_send() local
302 svc_rdma_wake_send_waiters(rdma, ctxt->sc_sqecount); in svc_rdma_wc_send()
308 svc_rdma_send_ctxt_put(rdma, ctxt); in svc_rdma_wc_send()
316 svc_rdma_send_ctxt_put(rdma, ctxt); in svc_rdma_wc_send()
317 svc_xprt_deferred_close(&rdma->sc_xprt); in svc_rdma_wc_send()
322 * @rdma: transport context
338 int svc_rdma_post_send(struct svcxprt_rdma *rdma, in svc_rdma_post_send() argument
350 ib_dma_sync_single_for_device(rdma->sc_pd->device, in svc_rdma_post_send()
356 while (!test_bit(XPT_CLOSE, &rdma->sc_xprt.xpt_flags)) { in svc_rdma_post_send()
357 if (atomic_sub_return(sqecount, &rdma->sc_sq_avail) < 0) { in svc_rdma_post_send()
358 svc_rdma_wake_send_waiters(rdma, sqecount); in svc_rdma_post_send()
367 trace_svcrdma_sq_full(rdma, &cid); in svc_rdma_post_send()
368 wait_event(rdma->sc_send_wait, in svc_rdma_post_send()
369 atomic_read(&rdma->sc_sq_avail) > 0); in svc_rdma_post_send()
370 trace_svcrdma_sq_retry(rdma, &cid); in svc_rdma_post_send()
375 ret = ib_post_send(rdma->sc_qp, first_wr, &bad_wr); in svc_rdma_post_send()
377 trace_svcrdma_sq_post_err(rdma, &cid, ret); in svc_rdma_post_send()
378 svc_xprt_deferred_close(&rdma->sc_xprt); in svc_rdma_post_send()
384 svc_rdma_wake_send_waiters(rdma, sqecount); in svc_rdma_post_send()
404 /* RPC-over-RDMA version 1 replies never have a Read list. */ in svc_rdma_encode_read_list()
566 struct svcxprt_rdma *rdma = args->md_rdma; in svc_rdma_page_dma_map() local
568 struct ib_device *dev = rdma->sc_cm_id->device; in svc_rdma_page_dma_map()
694 * @rdma: controlling transport
703 static bool svc_rdma_pull_up_needed(const struct svcxprt_rdma *rdma, in svc_rdma_pull_up_needed() argument
722 return args.pd_num_sges >= rdma->sc_max_send_sges; in svc_rdma_pull_up_needed()
769 * @rdma: controlling transport
784 static int svc_rdma_pull_up_reply_msg(const struct svcxprt_rdma *rdma, in svc_rdma_pull_up_reply_msg() argument
805 * @rdma: controlling transport
818 int svc_rdma_map_reply_msg(struct svcxprt_rdma *rdma, in svc_rdma_map_reply_msg() argument
825 .md_rdma = rdma, in svc_rdma_map_reply_msg()
842 if (svc_rdma_pull_up_needed(rdma, sctxt, write_pcl, xdr)) in svc_rdma_map_reply_msg()
843 return svc_rdma_pull_up_reply_msg(rdma, sctxt, write_pcl, xdr); in svc_rdma_map_reply_msg()
869 * via RDMA Send. The RPC-over-RDMA transport header is prepared
880 static int svc_rdma_send_reply_msg(struct svcxprt_rdma *rdma, in svc_rdma_send_reply_msg() argument
888 ret = svc_rdma_map_reply_msg(rdma, sctxt, &rctxt->rc_write_pcl, in svc_rdma_send_reply_msg()
893 /* Transfer pages involved in RDMA Writes to the sctxt's in svc_rdma_send_reply_msg()
905 return svc_rdma_post_send(rdma, sctxt); in svc_rdma_send_reply_msg()
909 * svc_rdma_send_error_msg - Send an RPC/RDMA v1 error response
910 * @rdma: controlling transport context
923 void svc_rdma_send_error_msg(struct svcxprt_rdma *rdma, in svc_rdma_send_error_msg() argument
942 *p++ = rdma->sc_fc_credits; in svc_rdma_send_error_msg()
969 if (svc_rdma_post_send(rdma, sctxt)) in svc_rdma_send_error_msg()
974 svc_rdma_send_ctxt_put(rdma, sctxt); in svc_rdma_send_error_msg()
992 struct svcxprt_rdma *rdma = in svc_rdma_sendto() local
1006 sctxt = svc_rdma_send_ctxt_get(rdma); in svc_rdma_sendto()
1016 ret = svc_rdma_send_write_list(rdma, rctxt, &rqstp->rq_res); in svc_rdma_sendto()
1022 ret = svc_rdma_prepare_reply_chunk(rdma, &rctxt->rc_write_pcl, in svc_rdma_sendto()
1032 *p++ = rdma->sc_fc_credits; in svc_rdma_sendto()
1045 ret = svc_rdma_send_reply_msg(rdma, sctxt, rctxt, rqstp); in svc_rdma_sendto()
1055 * of previously posted RDMA Writes. in svc_rdma_sendto()
1058 svc_rdma_send_error_msg(rdma, sctxt, rctxt, ret); in svc_rdma_sendto()
1062 svc_rdma_send_ctxt_put(rdma, sctxt); in svc_rdma_sendto()
1065 svc_xprt_deferred_close(&rdma->sc_xprt); in svc_rdma_sendto()