int fi_ibv_getinfo(uint32_t version, const char *node, const char *service, uint64_t flags, struct fi_info *hints, struct fi_info **info) { struct rdma_cm_id *id = NULL; struct rdma_addrinfo *rai; int ret; ret = fi_ibv_init_info(); if (ret) goto out; ret = fi_ibv_create_ep(node, service, flags, hints, &rai, &id); if (ret) goto out; if (id->verbs) { ret = fi_ibv_get_matching_info(ibv_get_device_name(id->verbs->device), hints, rai, info); } else { ret = fi_ibv_get_matching_info(NULL, hints, rai, info); if (!ret && !(flags & FI_SOURCE) && !node && (!hints || (!hints->src_addr && !hints->dest_addr))) { ret = fi_ibv_getifaddrs(service, flags, *info); if (ret) { fi_freeinfo(*info); fi_ibv_destroy_ep(rai, &id); goto out; } } } if (!ret) { ret = fi_ibv_rdm_remove_nonaddr_info(info); } ofi_alter_info(*info, hints); fi_ibv_destroy_ep(rai, &id); out: if (!ret || ret == -FI_ENOMEM || ret == -FI_ENODEV) return ret; else return -FI_ENODATA; }
static int fi_ibv_get_srcaddr_devs(struct fi_info **info) { struct fi_info *fi, *add_info; struct fi_info *fi_unconf = NULL, *fi_prev = NULL; struct verbs_dev_info *dev; struct verbs_addr *addr; int ret = 0; DEFINE_LIST(verbs_devs); ret = fi_ibv_getifaddrs(&verbs_devs); if (ret) return ret; if (dlist_empty(&verbs_devs)) { VERBS_WARN(FI_LOG_CORE, "No interface address found\n"); return 0; } for (fi = *info; fi; fi = fi->next) { dlist_foreach_container(&verbs_devs, struct verbs_dev_info, dev, entry) if (!strncmp(fi->domain_attr->name, dev->name, strlen(dev->name))) { dlist_foreach_container(&dev->addrs, struct verbs_addr, addr, entry) { /* When a device has multiple interfaces/addresses configured * duplicate fi_info and add the address info. fi->src_addr * would have been set in the previous iteration */ if (fi->src_addr) { if (!(add_info = fi_dupinfo(fi))) { ret = -FI_ENOMEM; goto out; } add_info->next = fi->next; fi->next = add_info; fi = add_info; } ret = fi_ibv_rai_to_fi(addr->rai, fi); if (ret) goto out; } break; } }