Lines Matching full:ep
75 static void rpcrdma_ep_get(struct rpcrdma_ep *ep);
76 static int rpcrdma_ep_put(struct rpcrdma_ep *ep);
91 struct rpcrdma_ep *ep = r_xprt->rx_ep; in rpcrdma_xprt_drain() local
92 struct rdma_cm_id *id = ep->re_id; in rpcrdma_xprt_drain()
97 if (atomic_inc_return(&ep->re_receiving) > 1) in rpcrdma_xprt_drain()
98 wait_for_completion(&ep->re_done); in rpcrdma_xprt_drain()
110 rpcrdma_ep_put(ep); in rpcrdma_xprt_drain()
117 void rpcrdma_force_disconnect(struct rpcrdma_ep *ep) in rpcrdma_force_disconnect() argument
119 if (atomic_add_unless(&ep->re_force_disconnect, 1, 1)) in rpcrdma_force_disconnect()
120 xprt_force_disconnect(ep->re_xprt); in rpcrdma_force_disconnect()
191 static void rpcrdma_update_cm_private(struct rpcrdma_ep *ep, in rpcrdma_update_cm_private() argument
208 if (rsize < ep->re_inline_recv) in rpcrdma_update_cm_private()
209 ep->re_inline_recv = rsize; in rpcrdma_update_cm_private()
210 if (wsize < ep->re_inline_send) in rpcrdma_update_cm_private()
211 ep->re_inline_send = wsize; in rpcrdma_update_cm_private()
213 rpcrdma_set_max_header_sizes(ep); in rpcrdma_update_cm_private()
227 struct rpcrdma_ep *ep = id->context; in rpcrdma_cm_event_handler() local
234 ep->re_async_rc = 0; in rpcrdma_cm_event_handler()
235 complete(&ep->re_done); in rpcrdma_cm_event_handler()
238 ep->re_async_rc = -EPROTO; in rpcrdma_cm_event_handler()
239 complete(&ep->re_done); in rpcrdma_cm_event_handler()
242 ep->re_async_rc = -ENETUNREACH; in rpcrdma_cm_event_handler()
243 complete(&ep->re_done); in rpcrdma_cm_event_handler()
246 ep->re_connect_status = -ENODEV; in rpcrdma_cm_event_handler()
249 rpcrdma_ep_get(ep); in rpcrdma_cm_event_handler()
250 ep->re_connect_status = 1; in rpcrdma_cm_event_handler()
251 rpcrdma_update_cm_private(ep, &event->param.conn); in rpcrdma_cm_event_handler()
252 trace_xprtrdma_inline_thresh(ep); in rpcrdma_cm_event_handler()
253 wake_up_all(&ep->re_connect_wait); in rpcrdma_cm_event_handler()
256 ep->re_connect_status = -ENOTCONN; in rpcrdma_cm_event_handler()
259 ep->re_connect_status = -ENETUNREACH; in rpcrdma_cm_event_handler()
262 ep->re_connect_status = -ECONNREFUSED; in rpcrdma_cm_event_handler()
264 ep->re_connect_status = -ENOTCONN; in rpcrdma_cm_event_handler()
266 wake_up_all(&ep->re_connect_wait); in rpcrdma_cm_event_handler()
269 ep->re_connect_status = -ECONNABORTED; in rpcrdma_cm_event_handler()
271 rpcrdma_force_disconnect(ep); in rpcrdma_cm_event_handler()
272 return rpcrdma_ep_put(ep); in rpcrdma_cm_event_handler()
282 struct rpcrdma_ep *ep = container_of(rn, struct rpcrdma_ep, re_rn); in rpcrdma_ep_removal_done() local
284 trace_xprtrdma_device_removal(ep->re_id); in rpcrdma_ep_removal_done()
285 xprt_force_disconnect(ep->re_xprt); in rpcrdma_ep_removal_done()
289 struct rpcrdma_ep *ep) in rpcrdma_create_id() argument
296 init_completion(&ep->re_done); in rpcrdma_create_id()
298 id = rdma_create_id(xprt->xprt_net, rpcrdma_cm_event_handler, ep, in rpcrdma_create_id()
303 ep->re_async_rc = -ETIMEDOUT; in rpcrdma_create_id()
308 rc = wait_for_completion_interruptible_timeout(&ep->re_done, wtimeout); in rpcrdma_create_id()
312 rc = ep->re_async_rc; in rpcrdma_create_id()
316 ep->re_async_rc = -ETIMEDOUT; in rpcrdma_create_id()
320 rc = wait_for_completion_interruptible_timeout(&ep->re_done, wtimeout); in rpcrdma_create_id()
323 rc = ep->re_async_rc; in rpcrdma_create_id()
327 rc = rpcrdma_rn_register(id->device, &ep->re_rn, rpcrdma_ep_removal_done); in rpcrdma_create_id()
340 struct rpcrdma_ep *ep = container_of(kref, struct rpcrdma_ep, re_kref); in rpcrdma_ep_destroy() local
342 if (ep->re_id->qp) { in rpcrdma_ep_destroy()
343 rdma_destroy_qp(ep->re_id); in rpcrdma_ep_destroy()
344 ep->re_id->qp = NULL; in rpcrdma_ep_destroy()
347 if (ep->re_attr.recv_cq) in rpcrdma_ep_destroy()
348 ib_free_cq(ep->re_attr.recv_cq); in rpcrdma_ep_destroy()
349 ep->re_attr.recv_cq = NULL; in rpcrdma_ep_destroy()
350 if (ep->re_attr.send_cq) in rpcrdma_ep_destroy()
351 ib_free_cq(ep->re_attr.send_cq); in rpcrdma_ep_destroy()
352 ep->re_attr.send_cq = NULL; in rpcrdma_ep_destroy()
354 if (ep->re_pd) in rpcrdma_ep_destroy()
355 ib_dealloc_pd(ep->re_pd); in rpcrdma_ep_destroy()
356 ep->re_pd = NULL; in rpcrdma_ep_destroy()
358 rpcrdma_rn_unregister(ep->re_id->device, &ep->re_rn); in rpcrdma_ep_destroy()
360 kfree(ep); in rpcrdma_ep_destroy()
364 static noinline void rpcrdma_ep_get(struct rpcrdma_ep *ep) in rpcrdma_ep_get() argument
366 kref_get(&ep->re_kref); in rpcrdma_ep_get()
370 * %0 if @ep still has a positive kref count, or
371 * %1 if @ep was destroyed successfully.
373 static noinline int rpcrdma_ep_put(struct rpcrdma_ep *ep) in rpcrdma_ep_put() argument
375 return kref_put(&ep->re_kref, rpcrdma_ep_destroy); in rpcrdma_ep_put()
383 struct rpcrdma_ep *ep; in rpcrdma_ep_create() local
386 ep = kzalloc(sizeof(*ep), XPRTRDMA_GFP_FLAGS); in rpcrdma_ep_create()
387 if (!ep) in rpcrdma_ep_create()
389 ep->re_xprt = &r_xprt->rx_xprt; in rpcrdma_ep_create()
390 kref_init(&ep->re_kref); in rpcrdma_ep_create()
392 id = rpcrdma_create_id(r_xprt, ep); in rpcrdma_ep_create()
394 kfree(ep); in rpcrdma_ep_create()
399 ep->re_id = id; in rpcrdma_ep_create()
400 reinit_completion(&ep->re_done); in rpcrdma_ep_create()
402 ep->re_max_requests = r_xprt->rx_xprt.max_reqs; in rpcrdma_ep_create()
403 ep->re_inline_send = xprt_rdma_max_inline_write; in rpcrdma_ep_create()
404 ep->re_inline_recv = xprt_rdma_max_inline_read; in rpcrdma_ep_create()
405 rc = frwr_query_device(ep, device); in rpcrdma_ep_create()
409 r_xprt->rx_buf.rb_max_requests = cpu_to_be32(ep->re_max_requests); in rpcrdma_ep_create()
411 ep->re_attr.srq = NULL; in rpcrdma_ep_create()
412 ep->re_attr.cap.max_inline_data = 0; in rpcrdma_ep_create()
413 ep->re_attr.sq_sig_type = IB_SIGNAL_REQ_WR; in rpcrdma_ep_create()
414 ep->re_attr.qp_type = IB_QPT_RC; in rpcrdma_ep_create()
415 ep->re_attr.port_num = ~0; in rpcrdma_ep_create()
417 ep->re_send_batch = ep->re_max_requests >> 3; in rpcrdma_ep_create()
418 ep->re_send_count = ep->re_send_batch; in rpcrdma_ep_create()
419 init_waitqueue_head(&ep->re_connect_wait); in rpcrdma_ep_create()
421 ep->re_attr.send_cq = ib_alloc_cq_any(device, r_xprt, in rpcrdma_ep_create()
422 ep->re_attr.cap.max_send_wr, in rpcrdma_ep_create()
424 if (IS_ERR(ep->re_attr.send_cq)) { in rpcrdma_ep_create()
425 rc = PTR_ERR(ep->re_attr.send_cq); in rpcrdma_ep_create()
426 ep->re_attr.send_cq = NULL; in rpcrdma_ep_create()
430 ep->re_attr.recv_cq = ib_alloc_cq_any(device, r_xprt, in rpcrdma_ep_create()
431 ep->re_attr.cap.max_recv_wr, in rpcrdma_ep_create()
433 if (IS_ERR(ep->re_attr.recv_cq)) { in rpcrdma_ep_create()
434 rc = PTR_ERR(ep->re_attr.recv_cq); in rpcrdma_ep_create()
435 ep->re_attr.recv_cq = NULL; in rpcrdma_ep_create()
438 ep->re_receive_count = 0; in rpcrdma_ep_create()
441 memset(&ep->re_remote_cma, 0, sizeof(ep->re_remote_cma)); in rpcrdma_ep_create()
444 pmsg = &ep->re_cm_private; in rpcrdma_ep_create()
448 pmsg->cp_send_size = rpcrdma_encode_buffer_size(ep->re_inline_send); in rpcrdma_ep_create()
449 pmsg->cp_recv_size = rpcrdma_encode_buffer_size(ep->re_inline_recv); in rpcrdma_ep_create()
450 ep->re_remote_cma.private_data = pmsg; in rpcrdma_ep_create()
451 ep->re_remote_cma.private_data_len = sizeof(*pmsg); in rpcrdma_ep_create()
454 ep->re_remote_cma.initiator_depth = 0; in rpcrdma_ep_create()
455 ep->re_remote_cma.responder_resources = in rpcrdma_ep_create()
462 ep->re_remote_cma.retry_count = 6; in rpcrdma_ep_create()
468 ep->re_remote_cma.flow_control = 0; in rpcrdma_ep_create()
469 ep->re_remote_cma.rnr_retry_count = 0; in rpcrdma_ep_create()
471 ep->re_pd = ib_alloc_pd(device, 0); in rpcrdma_ep_create()
472 if (IS_ERR(ep->re_pd)) { in rpcrdma_ep_create()
473 rc = PTR_ERR(ep->re_pd); in rpcrdma_ep_create()
474 ep->re_pd = NULL; in rpcrdma_ep_create()
478 rc = rdma_create_qp(id, ep->re_pd, &ep->re_attr); in rpcrdma_ep_create()
482 r_xprt->rx_ep = ep; in rpcrdma_ep_create()
486 rpcrdma_ep_put(ep); in rpcrdma_ep_create()
500 struct rpcrdma_ep *ep; in rpcrdma_xprt_connect() local
506 ep = r_xprt->rx_ep; in rpcrdma_xprt_connect()
511 /* Bump the ep's reference count while there are in rpcrdma_xprt_connect()
514 rpcrdma_ep_get(ep); in rpcrdma_xprt_connect()
517 rc = rdma_connect(ep->re_id, &ep->re_remote_cma); in rpcrdma_xprt_connect()
523 wait_event_interruptible(ep->re_connect_wait, in rpcrdma_xprt_connect()
524 ep->re_connect_status != 0); in rpcrdma_xprt_connect()
525 if (ep->re_connect_status <= 0) { in rpcrdma_xprt_connect()
526 rc = ep->re_connect_status; in rpcrdma_xprt_connect()
561 struct rpcrdma_ep *ep = r_xprt->rx_ep; in rpcrdma_xprt_disconnect() local
565 if (!ep) in rpcrdma_xprt_disconnect()
568 id = ep->re_id; in rpcrdma_xprt_disconnect()
578 if (rpcrdma_ep_put(ep)) in rpcrdma_xprt_disconnect()
614 static struct rpcrdma_sendctx *rpcrdma_sendctx_create(struct rpcrdma_ep *ep) in rpcrdma_sendctx_create() argument
618 sc = kzalloc(struct_size(sc, sc_sges, ep->re_attr.cap.max_send_sge), in rpcrdma_sendctx_create()
624 sc->sc_cid.ci_queue_id = ep->re_attr.send_cq->res.id; in rpcrdma_sendctx_create()
626 atomic_inc_return(&ep->re_completion_ids); in rpcrdma_sendctx_create()
752 struct rpcrdma_ep *ep = r_xprt->rx_ep; in rpcrdma_mrs_create() local
753 struct ib_device *device = ep->re_id->device; in rpcrdma_mrs_create()
757 for (count = 0; count < ep->re_max_rdma_segs; count++) { in rpcrdma_mrs_create()
802 struct rpcrdma_ep *ep = r_xprt->rx_ep; in rpcrdma_mrs_refresh() local
807 if (ep->re_connect_status != 1) in rpcrdma_mrs_refresh()
951 struct rpcrdma_ep *ep = r_xprt->rx_ep; in rpcrdma_rep_create() local
952 struct ib_device *device = ep->re_id->device; in rpcrdma_rep_create()
959 rep->rr_rdmabuf = rpcrdma_regbuf_alloc_node(ep->re_inline_recv, in rpcrdma_rep_create()
1351 struct rpcrdma_ep *ep = r_xprt->rx_ep; in rpcrdma_post_recvs() local
1359 if (likely(ep->re_receive_count > needed)) in rpcrdma_post_recvs()
1361 needed -= ep->re_receive_count; in rpcrdma_post_recvs()
1364 if (atomic_inc_return(&ep->re_receiving) > 1) in rpcrdma_post_recvs()
1380 rep->rr_cid.ci_queue_id = ep->re_attr.recv_cq->res.id; in rpcrdma_post_recvs()
1390 rc = ib_post_recv(ep->re_id->qp, wr, in rpcrdma_post_recvs()
1403 if (atomic_dec_return(&ep->re_receiving) > 0) in rpcrdma_post_recvs()
1404 complete(&ep->re_done); in rpcrdma_post_recvs()
1408 ep->re_receive_count += count; in rpcrdma_post_recvs()