1 /*
2 * * Copyright (C) Mellanox Technologies Ltd. 2017. ALL RIGHTS RESERVED.
3 * * See file LICENSE for terms.
4 * */
5
6 #ifndef UCT_RDMACM_H
7 #define UCT_RDMACM_H
8
9 #include <uct/api/uct.h>
10 #include <uct/api/uct_def.h>
11 #include <uct/base/uct_iface.h>
12 #include <uct/base/uct_md.h>
13 #include <ucs/type/class.h>
14 #include <ucs/time/time.h>
15 #include <ucs/async/async.h>
16 #include <ucs/sys/sock.h>
17 #include <ucs/sys/string.h>
18 #include <rdma/rdma_cma.h>
19 #include <sys/poll.h>
20
21 #define UCT_RDMACM_TL_NAME "rdmacm"
22 #define UCT_RDMACM_UDP_PRIV_DATA_LEN 136 /** See rdma_accept(3) */
23 #define UCT_RDMACM_TCP_PRIV_DATA_LEN 56 /** See rdma_connect(3) */
24 #define UCT_RDMACM_EP_FLAGS_STRING_LEN 128 /** A string to hold the
25 representation of the ep flags */
26 #define UCT_RDMACM_EP_STRING_LEN 192 /** A string to hold the ep info */
27
28 typedef struct uct_rdmacm_iface uct_rdmacm_iface_t;
29 typedef struct uct_rdmacm_ep uct_rdmacm_ep_t;
30
31 typedef struct uct_rdmacm_priv_data_hdr {
32 uint8_t length; /* length of the private data */
33 uint8_t status;
34 } uct_rdmacm_priv_data_hdr_t;
35
36 typedef struct uct_rdmacm_ctx {
37 struct rdma_cm_id *cm_id;
38 uct_rdmacm_ep_t *ep;
39 ucs_list_link_t list; /* for list of used cm_ids */
40 } uct_rdmacm_ctx_t;
41
42 size_t uct_rdmacm_cm_get_max_conn_priv();
43
44 ucs_status_t uct_rdmacm_resolve_addr(struct rdma_cm_id *cm_id,
45 struct sockaddr *addr, int timeout_ms,
46 ucs_log_level_t log_level);
47
48 ucs_status_t uct_rdmacm_ep_resolve_addr(uct_rdmacm_ep_t *ep);
49
50 ucs_status_t uct_rdmacm_ep_set_cm_id(uct_rdmacm_iface_t *iface, uct_rdmacm_ep_t *ep);
51
uct_rdmacm_cm_id_to_dev_name(struct rdma_cm_id * cm_id,char * dev_name)52 static inline void uct_rdmacm_cm_id_to_dev_name(struct rdma_cm_id *cm_id, char *dev_name)
53 {
54 ucs_snprintf_zero(dev_name, UCT_DEVICE_NAME_MAX, "%s:%d",
55 ibv_get_device_name(cm_id->verbs->device), cm_id->port_num);
56 }
57
58 #endif /* UCT_RDMACM_H */
59