Lines Matching refs:rdma

125 static void svc_rdma_send_cid_init(struct svcxprt_rdma *rdma,  in svc_rdma_send_cid_init()  argument
128 cid->ci_queue_id = rdma->sc_sq_cq->res.id; in svc_rdma_send_cid_init()
129 cid->ci_completion_id = atomic_inc_return(&rdma->sc_completion_ids); in svc_rdma_send_cid_init()
133 svc_rdma_send_ctxt_alloc(struct svcxprt_rdma *rdma) in svc_rdma_send_ctxt_alloc() argument
142 size += rdma->sc_max_send_sges * sizeof(struct ib_sge); in svc_rdma_send_ctxt_alloc()
146 buffer = kmalloc(rdma->sc_max_req_size, GFP_KERNEL); in svc_rdma_send_ctxt_alloc()
149 addr = ib_dma_map_single(rdma->sc_pd->device, buffer, in svc_rdma_send_ctxt_alloc()
150 rdma->sc_max_req_size, DMA_TO_DEVICE); in svc_rdma_send_ctxt_alloc()
151 if (ib_dma_mapping_error(rdma->sc_pd->device, addr)) in svc_rdma_send_ctxt_alloc()
154 svc_rdma_send_cid_init(rdma, &ctxt->sc_cid); in svc_rdma_send_ctxt_alloc()
163 rdma->sc_max_req_size); in svc_rdma_send_ctxt_alloc()
166 for (i = 0; i < rdma->sc_max_send_sges; i++) in svc_rdma_send_ctxt_alloc()
167 ctxt->sc_sges[i].lkey = rdma->sc_pd->local_dma_lkey; in svc_rdma_send_ctxt_alloc()
183 void svc_rdma_send_ctxts_destroy(struct svcxprt_rdma *rdma) in svc_rdma_send_ctxts_destroy() argument
187 while ((ctxt = svc_rdma_next_send_ctxt(&rdma->sc_send_ctxts))) { in svc_rdma_send_ctxts_destroy()
189 ib_dma_unmap_single(rdma->sc_pd->device, in svc_rdma_send_ctxts_destroy()
191 rdma->sc_max_req_size, in svc_rdma_send_ctxts_destroy()
205 struct svc_rdma_send_ctxt *svc_rdma_send_ctxt_get(struct svcxprt_rdma *rdma) in svc_rdma_send_ctxt_get() argument
209 spin_lock(&rdma->sc_send_lock); in svc_rdma_send_ctxt_get()
210 ctxt = svc_rdma_next_send_ctxt(&rdma->sc_send_ctxts); in svc_rdma_send_ctxt_get()
214 spin_unlock(&rdma->sc_send_lock); in svc_rdma_send_ctxt_get()
227 spin_unlock(&rdma->sc_send_lock); in svc_rdma_send_ctxt_get()
228 ctxt = svc_rdma_send_ctxt_alloc(rdma); in svc_rdma_send_ctxt_get()
241 void svc_rdma_send_ctxt_put(struct svcxprt_rdma *rdma, in svc_rdma_send_ctxt_put() argument
244 struct ib_device *device = rdma->sc_cm_id->device; in svc_rdma_send_ctxt_put()
255 trace_svcrdma_dma_unmap_page(rdma, in svc_rdma_send_ctxt_put()
263 spin_lock(&rdma->sc_send_lock); in svc_rdma_send_ctxt_put()
264 list_add(&ctxt->sc_list, &rdma->sc_send_ctxts); in svc_rdma_send_ctxt_put()
265 spin_unlock(&rdma->sc_send_lock); in svc_rdma_send_ctxt_put()
278 struct svcxprt_rdma *rdma = cq->cq_context; in svc_rdma_wc_send() local
285 atomic_inc(&rdma->sc_sq_avail); in svc_rdma_wc_send()
286 wake_up(&rdma->sc_send_wait); in svc_rdma_wc_send()
288 svc_rdma_send_ctxt_put(rdma, ctxt); in svc_rdma_wc_send()
291 set_bit(XPT_CLOSE, &rdma->sc_xprt.xpt_flags); in svc_rdma_wc_send()
292 svc_xprt_enqueue(&rdma->sc_xprt); in svc_rdma_wc_send()
304 int svc_rdma_send(struct svcxprt_rdma *rdma, struct svc_rdma_send_ctxt *ctxt) in svc_rdma_send() argument
312 ib_dma_sync_single_for_device(rdma->sc_pd->device, in svc_rdma_send()
319 if ((atomic_dec_return(&rdma->sc_sq_avail) < 0)) { in svc_rdma_send()
321 trace_svcrdma_sq_full(rdma); in svc_rdma_send()
322 atomic_inc(&rdma->sc_sq_avail); in svc_rdma_send()
323 wait_event(rdma->sc_send_wait, in svc_rdma_send()
324 atomic_read(&rdma->sc_sq_avail) > 1); in svc_rdma_send()
325 if (test_bit(XPT_CLOSE, &rdma->sc_xprt.xpt_flags)) in svc_rdma_send()
327 trace_svcrdma_sq_retry(rdma); in svc_rdma_send()
332 ret = ib_post_send(rdma->sc_qp, wr, NULL); in svc_rdma_send()
338 trace_svcrdma_sq_post_err(rdma, ret); in svc_rdma_send()
339 set_bit(XPT_CLOSE, &rdma->sc_xprt.xpt_flags); in svc_rdma_send()
340 wake_up(&rdma->sc_send_wait); in svc_rdma_send()
509 static int svc_rdma_dma_map_page(struct svcxprt_rdma *rdma, in svc_rdma_dma_map_page() argument
515 struct ib_device *dev = rdma->sc_cm_id->device; in svc_rdma_dma_map_page()
519 trace_svcrdma_dma_map_page(rdma, dma_addr, len); in svc_rdma_dma_map_page()
535 static int svc_rdma_dma_map_buf(struct svcxprt_rdma *rdma, in svc_rdma_dma_map_buf() argument
540 return svc_rdma_dma_map_page(rdma, ctxt, virt_to_page(base), in svc_rdma_dma_map_buf()
555 static bool svc_rdma_pull_up_needed(struct svcxprt_rdma *rdma, in svc_rdma_pull_up_needed() argument
593 return elements >= rdma->sc_max_send_sges; in svc_rdma_pull_up_needed()
608 static int svc_rdma_pull_up_reply_msg(struct svcxprt_rdma *rdma, in svc_rdma_pull_up_reply_msg() argument
668 int svc_rdma_map_reply_msg(struct svcxprt_rdma *rdma, in svc_rdma_map_reply_msg() argument
693 if (svc_rdma_pull_up_needed(rdma, sctxt, rctxt, xdr)) in svc_rdma_map_reply_msg()
694 return svc_rdma_pull_up_reply_msg(rdma, sctxt, rctxt, xdr); in svc_rdma_map_reply_msg()
697 ret = svc_rdma_dma_map_buf(rdma, sctxt, in svc_rdma_map_reply_msg()
728 ret = svc_rdma_dma_map_page(rdma, sctxt, *ppages++, in svc_rdma_map_reply_msg()
742 ret = svc_rdma_dma_map_buf(rdma, sctxt, base, len); in svc_rdma_map_reply_msg()
787 static int svc_rdma_send_reply_msg(struct svcxprt_rdma *rdma, in svc_rdma_send_reply_msg() argument
794 ret = svc_rdma_map_reply_msg(rdma, sctxt, rctxt, &rqstp->rq_res); in svc_rdma_send_reply_msg()
806 return svc_rdma_send(rdma, sctxt); in svc_rdma_send_reply_msg()
824 void svc_rdma_send_error_msg(struct svcxprt_rdma *rdma, in svc_rdma_send_error_msg() argument
843 *p++ = rdma->sc_fc_credits; in svc_rdma_send_error_msg()
870 if (svc_rdma_send(rdma, sctxt)) in svc_rdma_send_error_msg()
875 svc_rdma_send_ctxt_put(rdma, sctxt); in svc_rdma_send_error_msg()
893 struct svcxprt_rdma *rdma = in svc_rdma_sendto() local
909 sctxt = svc_rdma_send_ctxt_get(rdma); in svc_rdma_sendto()
919 *p++ = rdma->sc_fc_credits; in svc_rdma_sendto()
936 ret = svc_rdma_send_write_chunk(rdma, wr_lst, xdr, offset, in svc_rdma_sendto()
947 ret = svc_rdma_send_reply_chunk(rdma, rctxt, &rqstp->rq_res); in svc_rdma_sendto()
957 ret = svc_rdma_send_reply_msg(rdma, sctxt, rctxt, rqstp); in svc_rdma_sendto()
970 svc_rdma_send_error_msg(rdma, sctxt, rctxt, ret); in svc_rdma_sendto()
974 svc_rdma_send_ctxt_put(rdma, sctxt); in svc_rdma_sendto()