static struct fi_info * fi_ibv_eq_cm_getinfo(struct fi_ibv_fabric *fab, struct rdma_cm_event *event, struct fi_info *pep_info) { struct fi_info *info, *fi; struct fi_ibv_connreq *connreq; const char *devname = ibv_get_device_name(event->id->verbs->device); if (strcmp(devname, fab->info->domain_attr->name)) { fi = fi_ibv_get_verbs_info(fab->all_infos, devname); if (!fi) return NULL; } else { fi = fab->info; } info = fi_dupinfo(fi); if (!info) return NULL; info->fabric_attr->fabric = &fab->util_fabric.fabric_fid; if (!(info->fabric_attr->prov_name = strdup(VERBS_PROV_NAME))) goto err; ofi_alter_info(info, pep_info, fab->util_fabric.fabric_fid.api_version); info->src_addrlen = fi_ibv_sockaddr_len(rdma_get_local_addr(event->id)); if (!(info->src_addr = malloc(info->src_addrlen))) goto err; memcpy(info->src_addr, rdma_get_local_addr(event->id), info->src_addrlen); info->dest_addrlen = fi_ibv_sockaddr_len(rdma_get_peer_addr(event->id)); if (!(info->dest_addr = malloc(info->dest_addrlen))) goto err; memcpy(info->dest_addr, rdma_get_peer_addr(event->id), info->dest_addrlen); VERBS_INFO(FI_LOG_CORE, "src_addr: %s:%d\n", inet_ntoa(((struct sockaddr_in *)info->src_addr)->sin_addr), ntohs(((struct sockaddr_in *)info->src_addr)->sin_port)); VERBS_INFO(FI_LOG_CORE, "dst_addr: %s:%d\n", inet_ntoa(((struct sockaddr_in *)info->dest_addr)->sin_addr), ntohs(((struct sockaddr_in *)info->dest_addr)->sin_port)); connreq = calloc(1, sizeof *connreq); if (!connreq) goto err; connreq->handle.fclass = FI_CLASS_CONNREQ; connreq->id = event->id; info->handle = &connreq->handle; return info; err: fi_freeinfo(info); return NULL; }
/* TODO: This should copy the listening fi_info as the base */ static struct fi_info * fi_ibv_eq_cm_getinfo(struct fi_ibv_fabric *fab, struct rdma_cm_event *event) { struct fi_info *info, *fi; struct fi_ibv_connreq *connreq; fi = fi_ibv_get_verbs_info(ibv_get_device_name(event->id->verbs->device)); if (!fi) return NULL; info = fi_dupinfo(fi); if (!info) return NULL; info->fabric_attr->fabric = &fab->fabric_fid; if (!(info->fabric_attr->prov_name = strdup(VERBS_PROV_NAME))) goto err; fi_ibv_update_info(NULL, info); info->src_addrlen = fi_ibv_sockaddr_len(rdma_get_local_addr(event->id)); if (!(info->src_addr = malloc(info->src_addrlen))) goto err; memcpy(info->src_addr, rdma_get_local_addr(event->id), info->src_addrlen); info->dest_addrlen = fi_ibv_sockaddr_len(rdma_get_peer_addr(event->id)); if (!(info->dest_addr = malloc(info->dest_addrlen))) goto err; memcpy(info->dest_addr, rdma_get_peer_addr(event->id), info->dest_addrlen); FI_INFO(&fi_ibv_prov, FI_LOG_CORE, "src_addr: %s:%d\n", inet_ntoa(((struct sockaddr_in *)info->src_addr)->sin_addr), ntohs(((struct sockaddr_in *)info->src_addr)->sin_port)); FI_INFO(&fi_ibv_prov, FI_LOG_CORE, "dst_addr: %s:%d\n", inet_ntoa(((struct sockaddr_in *)info->dest_addr)->sin_addr), ntohs(((struct sockaddr_in *)info->dest_addr)->sin_port)); connreq = calloc(1, sizeof *connreq); if (!connreq) goto err; connreq->handle.fclass = FI_CLASS_CONNREQ; connreq->id = event->id; info->handle = &connreq->handle; return info; err: fi_freeinfo(info); return NULL; }
static int fi_ibv_copy_addr(void *dst_addr, size_t *dst_addrlen, void *src_addr) { size_t src_addrlen = fi_ibv_sockaddr_len(src_addr); if (*dst_addrlen == 0) { *dst_addrlen = src_addrlen; return -FI_ETOOSMALL; } if (*dst_addrlen < src_addrlen) { memcpy(dst_addr, src_addr, *dst_addrlen); } else { memcpy(dst_addr, src_addr, src_addrlen); } *dst_addrlen = src_addrlen; return 0; }
int fi_ibv_create_ep(const char *node, const char *service, uint64_t flags, const struct fi_info *hints, struct rdma_addrinfo **rai, struct rdma_cm_id **id) { struct rdma_addrinfo *_rai; struct sockaddr *local_addr; int ret; ret = fi_ibv_get_rdma_rai(node, service, flags, hints, &_rai); if (ret) { return ret; } ret = rdma_create_ep(id, _rai, NULL, NULL); if (ret) { VERBS_INFO_ERRNO(FI_LOG_FABRIC, "rdma_create_ep", errno); ret = -errno; goto err1; } if (rai && !_rai->ai_src_addr) { local_addr = rdma_get_local_addr(*id); _rai->ai_src_len = fi_ibv_sockaddr_len(local_addr); if (!(_rai->ai_src_addr = malloc(_rai->ai_src_len))) { ret = -FI_ENOMEM; goto err2; } memcpy(_rai->ai_src_addr, local_addr, _rai->ai_src_len); } if (rai) { *rai = _rai; } else { rdma_freeaddrinfo(_rai); } return ret; err2: rdma_destroy_ep(*id); err1: rdma_freeaddrinfo(_rai); return ret; }