int index;\r
volatile LONG refcnt;\r
struct rdma_cm_id **req_list;\r
+ struct ibv_pd *pd;\r
+ struct ibv_qp_init_attr *qp_init_attr;\r
uint8_t initiator_depth;\r
uint8_t responder_resources;\r
};\r
goto err;\r
}\r
\r
+ if (id_priv->qp_init_attr) {\r
+ ret = rdma_create_qp(event->id, id_priv->pd, id_priv->qp_init_attr);\r
+ if (ret)\r
+ goto err;\r
+ }\r
+\r
*id = event->id;\r
(*id)->event = event;\r
return 0;\r
return 0;\r
}\r
\r
+static int ucma_passive_ep(struct rdma_cm_id *id, struct rdma_addrinfo *res,\r
+ struct ibv_pd *pd, struct ibv_qp_init_attr *qp_init_attr)\r
+{\r
+ struct cma_id_private *id_priv;\r
+ int ret;\r
+\r
+ ret = rdma_bind_addr(id, res->ai_src_addr);\r
+ if (ret)\r
+ return ret;\r
+\r
+ id_priv = CONTAINING_RECORD(id, struct cma_id_private, id);\r
+ id_priv->pd = pd;\r
+\r
+ if (qp_init_attr) {\r
+ id_priv->qp_init_attr = new struct ibv_qp_init_attr;\r
+ if (!id_priv->qp_init_attr)\r
+ return rdma_seterrno(ENOMEM);\r
+\r
+ *id_priv->qp_init_attr = *qp_init_attr;\r
+ id_priv->qp_init_attr->qp_type = (enum ibv_qp_type) res->ai_qp_type;\r
+ }\r
+\r
+ return 0;\r
+}\r
+\r
+int rdma_create_ep(struct rdma_cm_id **id, struct rdma_addrinfo *res,\r
+ struct ibv_pd *pd, struct ibv_qp_init_attr *qp_init_attr)\r
+{\r
+ struct rdma_cm_id *cm_id;\r
+ int ret;\r
+\r
+ ret = rdma_create_id(NULL, &cm_id, NULL, (enum rdma_port_space) res->ai_port_space);\r
+ if (ret)\r
+ return ret;\r
+\r
+ if (res->ai_flags & RAI_PASSIVE) {\r
+ ret = ucma_passive_ep(cm_id, res, pd, qp_init_attr);\r
+ if (ret)\r
+ goto err;\r
+ goto out;\r
+ }\r
+\r
+ ret = rdma_resolve_addr(cm_id, res->ai_src_addr, res->ai_dst_addr, 2000);\r
+ if (ret)\r
+ goto err;\r
+\r
+ ret = rdma_resolve_route(cm_id, 2000);\r
+ if (ret)\r
+ goto err;\r
+\r
+ qp_init_attr->qp_type = (enum ibv_qp_type) res->ai_qp_type;\r
+ ret = rdma_create_qp(cm_id, pd, qp_init_attr);\r
+ if (ret)\r
+ goto err;\r
+\r
+out:\r
+ *id = cm_id;\r
+ return 0;\r
+\r
+err:\r
+ rdma_destroy_ep(cm_id);\r
+ return ret;\r
+}\r
+\r
+void rdma_destroy_ep(struct rdma_cm_id *id)\r
+{\r
+ struct cma_id_private *id_priv;\r
+\r
+ if (id->qp)\r
+ rdma_destroy_qp(id);\r
+\r
+ id_priv = CONTAINING_RECORD(id, struct cma_id_private, id);\r
+ if (id_priv->qp_init_attr) {\r
+ delete id_priv->qp_init_attr;\r
+ }\r
+ rdma_destroy_id(id);\r
+}\r
+\r
__declspec(dllexport)\r
int rdmaw_wsa_errno(int wsa_err)\r
{\r