int fi_ibv_init_info(void) { struct ibv_context **ctx_list; struct fi_info *fi = NULL, *tail = NULL; int ret = 0, i, num_devices; if (verbs_info) return 0; pthread_mutex_lock(&verbs_info_lock); if (verbs_info) goto unlock; if (!fi_ibv_have_device()) { VERBS_INFO(FI_LOG_FABRIC, "No RDMA devices found\n"); ret = -FI_ENODATA; goto unlock; } ctx_list = rdma_get_devices(&num_devices); if (!num_devices) { VERBS_INFO_ERRNO(FI_LOG_FABRIC, "rdma_get_devices", errno); ret = -errno; goto unlock; } for (i = 0; i < num_devices; i++) { ret = fi_ibv_alloc_info(ctx_list[i], &fi, &verbs_msg_domain); if (!ret) { if (!verbs_info) verbs_info = fi; else tail->next = fi; tail = fi; ret = fi_ibv_alloc_info(ctx_list[i], &fi, &verbs_rdm_domain); if (!ret) { tail->next = fi; tail = fi; } } } ret = verbs_info ? 0 : ret; rdma_free_devices(ctx_list); unlock: pthread_mutex_unlock(&verbs_info_lock); return ret; }
int fi_ibv_init_info(void) { struct ibv_context **ctx_list; struct fi_info *fi = NULL, *tail = NULL; int ret = 0, i, num_devices, fork_unsafe = 0; if (verbs_info) return 0; pthread_mutex_lock(&verbs_info_lock); if (verbs_info) goto unlock; if (!fi_ibv_have_device()) { VERBS_INFO(FI_LOG_FABRIC, "No RDMA devices found\n"); ret = -FI_ENODATA; goto unlock; } fi_param_get_bool(NULL, "fork_unsafe", &fork_unsafe); if (!fork_unsafe) { FI_INFO(&fi_ibv_prov, FI_LOG_CORE, "Enabling IB fork support\n"); ret = ibv_fork_init(); if (ret) { FI_WARN(&fi_ibv_prov, FI_LOG_CORE, "Enabling IB fork support failed: %s (%d)\n", strerror(ret), ret); goto unlock; } } else { FI_INFO(&fi_ibv_prov, FI_LOG_CORE, "Not enabling IB fork support\n"); } ctx_list = rdma_get_devices(&num_devices); if (!num_devices) { VERBS_INFO_ERRNO(FI_LOG_FABRIC, "rdma_get_devices", errno); ret = -errno; goto unlock; } for (i = 0; i < num_devices; i++) { ret = fi_ibv_alloc_info(ctx_list[i], &fi, &verbs_msg_domain); if (!ret) { if (!verbs_info) verbs_info = fi; else tail->next = fi; tail = fi; ret = fi_ibv_alloc_info(ctx_list[i], &fi, &verbs_rdm_domain); if (!ret) { tail->next = fi; tail = fi; } } } ret = verbs_info ? 0 : ret; rdma_free_devices(ctx_list); unlock: pthread_mutex_unlock(&verbs_info_lock); return ret; }