Lines Matching refs:rdma
153 struct p9_trans_rdma *rdma = clnt->trans; in p9_rdma_show_options() local
155 if (rdma->port != P9_PORT) in p9_rdma_show_options()
156 seq_printf(m, ",port=%u", rdma->port); in p9_rdma_show_options()
157 if (rdma->sq_depth != P9_RDMA_SQ_DEPTH) in p9_rdma_show_options()
158 seq_printf(m, ",sq=%u", rdma->sq_depth); in p9_rdma_show_options()
159 if (rdma->rq_depth != P9_RDMA_RQ_DEPTH) in p9_rdma_show_options()
160 seq_printf(m, ",rq=%u", rdma->rq_depth); in p9_rdma_show_options()
161 if (rdma->timeout != P9_RDMA_TIMEOUT) in p9_rdma_show_options()
162 seq_printf(m, ",timeout=%lu", rdma->timeout); in p9_rdma_show_options()
163 if (rdma->privport) in p9_rdma_show_options()
243 struct p9_trans_rdma *rdma = c->trans; in p9_cm_event_handler() local
246 BUG_ON(rdma->state != P9_RDMA_INIT); in p9_cm_event_handler()
247 rdma->state = P9_RDMA_ADDR_RESOLVED; in p9_cm_event_handler()
251 BUG_ON(rdma->state != P9_RDMA_ADDR_RESOLVED); in p9_cm_event_handler()
252 rdma->state = P9_RDMA_ROUTE_RESOLVED; in p9_cm_event_handler()
256 BUG_ON(rdma->state != P9_RDMA_ROUTE_RESOLVED); in p9_cm_event_handler()
257 rdma->state = P9_RDMA_CONNECTED; in p9_cm_event_handler()
261 if (rdma) in p9_cm_event_handler()
262 rdma->state = P9_RDMA_CLOSED; in p9_cm_event_handler()
281 rdma_disconnect(rdma->cm_id); in p9_cm_event_handler()
286 complete(&rdma->cm_done); in p9_cm_event_handler()
294 struct p9_trans_rdma *rdma = client->trans; in recv_done() local
302 ib_dma_unmap_single(rdma->cm_id->device, c->busa, client->msize, in recv_done()
329 up(&rdma->rq_sem); in recv_done()
336 rdma->state = P9_RDMA_FLUSHING; in recv_done()
345 struct p9_trans_rdma *rdma = client->trans; in send_done() local
349 ib_dma_unmap_single(rdma->cm_id->device, in send_done()
352 up(&rdma->sq_sem); in send_done()
363 static void rdma_destroy_trans(struct p9_trans_rdma *rdma) in rdma_destroy_trans() argument
365 if (!rdma) in rdma_destroy_trans()
368 if (rdma->qp && !IS_ERR(rdma->qp)) in rdma_destroy_trans()
369 ib_destroy_qp(rdma->qp); in rdma_destroy_trans()
371 if (rdma->pd && !IS_ERR(rdma->pd)) in rdma_destroy_trans()
372 ib_dealloc_pd(rdma->pd); in rdma_destroy_trans()
374 if (rdma->cq && !IS_ERR(rdma->cq)) in rdma_destroy_trans()
375 ib_free_cq(rdma->cq); in rdma_destroy_trans()
377 if (rdma->cm_id && !IS_ERR(rdma->cm_id)) in rdma_destroy_trans()
378 rdma_destroy_id(rdma->cm_id); in rdma_destroy_trans()
380 kfree(rdma); in rdma_destroy_trans()
386 struct p9_trans_rdma *rdma = client->trans; in post_recv() local
390 c->busa = ib_dma_map_single(rdma->cm_id->device, in post_recv()
393 if (ib_dma_mapping_error(rdma->cm_id->device, c->busa)) in post_recv()
400 sge.lkey = rdma->pd->local_dma_lkey; in post_recv()
406 return ib_post_recv(rdma->qp, &wr, NULL); in post_recv()
415 struct p9_trans_rdma *rdma = client->trans; in rdma_request() local
431 if (unlikely(atomic_read(&rdma->excess_rc) > 0)) { in rdma_request()
432 if ((atomic_sub_return(1, &rdma->excess_rc) >= 0)) { in rdma_request()
439 atomic_inc(&rdma->excess_rc); in rdma_request()
458 if (down_interruptible(&rdma->rq_sem)) { in rdma_request()
480 c->busa = ib_dma_map_single(rdma->cm_id->device, in rdma_request()
483 if (ib_dma_mapping_error(rdma->cm_id->device, c->busa)) { in rdma_request()
492 sge.lkey = rdma->pd->local_dma_lkey; in rdma_request()
501 if (down_interruptible(&rdma->sq_sem)) { in rdma_request()
511 err = ib_post_send(rdma->qp, &wr, NULL); in rdma_request()
527 atomic_inc(&rdma->excess_rc); in rdma_request()
533 spin_lock_irqsave(&rdma->req_lock, flags); in rdma_request()
534 if (err != -EINTR && rdma->state < P9_RDMA_CLOSING) { in rdma_request()
535 rdma->state = P9_RDMA_CLOSING; in rdma_request()
536 spin_unlock_irqrestore(&rdma->req_lock, flags); in rdma_request()
537 rdma_disconnect(rdma->cm_id); in rdma_request()
539 spin_unlock_irqrestore(&rdma->req_lock, flags); in rdma_request()
545 struct p9_trans_rdma *rdma; in rdma_close() local
550 rdma = client->trans; in rdma_close()
551 if (!rdma) in rdma_close()
555 rdma_disconnect(rdma->cm_id); in rdma_close()
556 rdma_destroy_trans(rdma); in rdma_close()
565 struct p9_trans_rdma *rdma; in alloc_rdma() local
567 rdma = kzalloc(sizeof(struct p9_trans_rdma), GFP_KERNEL); in alloc_rdma()
568 if (!rdma) in alloc_rdma()
571 rdma->port = opts->port; in alloc_rdma()
572 rdma->privport = opts->privport; in alloc_rdma()
573 rdma->sq_depth = opts->sq_depth; in alloc_rdma()
574 rdma->rq_depth = opts->rq_depth; in alloc_rdma()
575 rdma->timeout = opts->timeout; in alloc_rdma()
576 spin_lock_init(&rdma->req_lock); in alloc_rdma()
577 init_completion(&rdma->cm_done); in alloc_rdma()
578 sema_init(&rdma->sq_sem, rdma->sq_depth); in alloc_rdma()
579 sema_init(&rdma->rq_sem, rdma->rq_depth); in alloc_rdma()
580 atomic_set(&rdma->excess_rc, 0); in alloc_rdma()
582 return rdma; in alloc_rdma()
598 struct p9_trans_rdma *rdma = client->trans; in rdma_cancelled() local
599 atomic_inc(&rdma->excess_rc); in rdma_cancelled()
603 static int p9_rdma_bind_privport(struct p9_trans_rdma *rdma) in p9_rdma_bind_privport() argument
613 err = rdma_bind_addr(rdma->cm_id, (struct sockaddr *)&cl); in p9_rdma_bind_privport()
631 struct p9_trans_rdma *rdma; in rdma_create_trans() local
644 rdma = alloc_rdma(&opts); in rdma_create_trans()
645 if (!rdma) in rdma_create_trans()
649 rdma->cm_id = rdma_create_id(&init_net, p9_cm_event_handler, client, in rdma_create_trans()
651 if (IS_ERR(rdma->cm_id)) in rdma_create_trans()
655 client->trans = rdma; in rdma_create_trans()
659 err = p9_rdma_bind_privport(rdma); in rdma_create_trans()
668 rdma->addr.sin_family = AF_INET; in rdma_create_trans()
669 rdma->addr.sin_addr.s_addr = in_aton(addr); in rdma_create_trans()
670 rdma->addr.sin_port = htons(opts.port); in rdma_create_trans()
671 err = rdma_resolve_addr(rdma->cm_id, NULL, in rdma_create_trans()
672 (struct sockaddr *)&rdma->addr, in rdma_create_trans()
673 rdma->timeout); in rdma_create_trans()
676 err = wait_for_completion_interruptible(&rdma->cm_done); in rdma_create_trans()
677 if (err || (rdma->state != P9_RDMA_ADDR_RESOLVED)) in rdma_create_trans()
681 err = rdma_resolve_route(rdma->cm_id, rdma->timeout); in rdma_create_trans()
684 err = wait_for_completion_interruptible(&rdma->cm_done); in rdma_create_trans()
685 if (err || (rdma->state != P9_RDMA_ROUTE_RESOLVED)) in rdma_create_trans()
689 rdma->cq = ib_alloc_cq_any(rdma->cm_id->device, client, in rdma_create_trans()
692 if (IS_ERR(rdma->cq)) in rdma_create_trans()
696 rdma->pd = ib_alloc_pd(rdma->cm_id->device, 0); in rdma_create_trans()
697 if (IS_ERR(rdma->pd)) in rdma_create_trans()
710 qp_attr.send_cq = rdma->cq; in rdma_create_trans()
711 qp_attr.recv_cq = rdma->cq; in rdma_create_trans()
712 err = rdma_create_qp(rdma->cm_id, rdma->pd, &qp_attr); in rdma_create_trans()
715 rdma->qp = rdma->cm_id->qp; in rdma_create_trans()
723 err = rdma_connect(rdma->cm_id, &conn_param); in rdma_create_trans()
726 err = wait_for_completion_interruptible(&rdma->cm_done); in rdma_create_trans()
727 if (err || (rdma->state != P9_RDMA_CONNECTED)) in rdma_create_trans()
735 rdma_destroy_trans(rdma); in rdma_create_trans()