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