static int psmx2_domain_close(fid_t fid) { struct psmx2_fid_domain *domain; domain = container_of(fid, struct psmx2_fid_domain, util_domain.domain_fid.fid); FI_INFO(&psmx2_prov, FI_LOG_DOMAIN, "refcnt=%d\n", ofi_atomic_get32(&domain->util_domain.ref)); if (ofi_domain_close(&domain->util_domain)) return 0; if (domain->progress_thread_enabled) psmx2_domain_stop_progress(domain); fastlock_destroy(&domain->sep_lock); fastlock_destroy(&domain->mr_lock); rbtDelete(domain->mr_map); psmx2_lock(&domain->fabric->domain_lock, 1); dlist_remove(&domain->entry); psmx2_unlock(&domain->fabric->domain_lock, 1); psmx2_fabric_release(domain->fabric); free(domain); return 0; }
static int psmx2_domain_close(fid_t fid) { struct psmx2_fid_domain *domain; domain = container_of(fid, struct psmx2_fid_domain, util_domain.domain_fid.fid); FI_INFO(&psmx2_prov, FI_LOG_DOMAIN, "refcnt=%d\n", ofi_atomic_get32(&domain->util_domain.ref)); psmx2_domain_release(domain); if (ofi_domain_close(&domain->util_domain)) return 0; if (domain->progress_thread_enabled) psmx2_domain_stop_progress(domain); fastlock_destroy(&domain->sep_lock); fastlock_destroy(&domain->vl_lock); rbtDelete(domain->mr_map); fastlock_destroy(&domain->mr_lock); psmx2_trx_ctxt_free(domain->base_trx_ctxt); domain->fabric->active_domain = NULL; free(domain); psmx2_atomic_global_fini(); psmx2_am_global_fini(); return 0; }
static int efa_domain_close(fid_t fid) { struct efa_domain *domain; int ret; domain = container_of(fid, struct efa_domain, util_domain.domain_fid.fid); if (efa_mr_cache_enable) { ofi_mr_cache_cleanup(&domain->cache); ofi_monitor_cleanup(&domain->monitor); domain->notifier = NULL; } if (domain->pd) { ret = efa_cmd_dealloc_pd(domain->pd); if (ret) { EFA_INFO_ERRNO(FI_LOG_DOMAIN, "efa_cmd_dealloc_pd", ret); return ret; } domain->pd = NULL; } ret = ofi_domain_close(&domain->util_domain); if (ret) return ret; fi_freeinfo(domain->info); free(domain); return 0; }
static int udpx_domain_close(fid_t fid) { int ret; struct util_domain *domain; domain = container_of(fid, struct util_domain, domain_fid.fid); ret = ofi_domain_close(domain); if (ret) return ret; free(domain); return 0; }
static int psmx_domain_close(fid_t fid) { struct psmx_fid_domain *domain; int err; domain = container_of(fid, struct psmx_fid_domain, util_domain.domain_fid.fid); FI_INFO(&psmx_prov, FI_LOG_DOMAIN, "refcnt=%d\n", ofi_atomic_get32(&domain->util_domain.ref)); psmx_domain_release(domain); if (ofi_domain_close(&domain->util_domain)) return 0; if (domain->progress_thread_enabled) psmx_domain_stop_progress(domain); if (domain->am_initialized) psmx_am_fini(domain); fastlock_destroy(&domain->poll_lock); rbtDelete(domain->mr_map); fastlock_destroy(&domain->mr_lock); #if 0 /* AM messages could arrive after MQ is finalized, causing segfault * when trying to dereference the MQ pointer. There is no mechanism * to properly shutdown AM. The workaround is to keep MQ valid. */ psm_mq_finalize(domain->psm_mq); #endif /* workaround for: * Assertion failure at psm_ep.c:1059: ep->mctxt_master == ep */ sleep(psmx_env.delay); if (psmx_env.timeout) err = psm_ep_close(domain->psm_ep, PSM_EP_CLOSE_GRACEFUL, (int64_t) psmx_env.timeout * 1000000000LL); else err = PSM_EP_CLOSE_TIMEOUT; if (err != PSM_OK) psm_ep_close(domain->psm_ep, PSM_EP_CLOSE_FORCE, 0); domain->fabric->active_domain = NULL; free(domain); return 0; }
static int rxm_domain_close(fid_t fid) { struct rxm_domain *rxm_domain; int ret; rxm_domain = container_of(fid, struct rxm_domain, util_domain.domain_fid.fid); ret = fi_close(&rxm_domain->msg_domain->fid); if (ret) return ret; ret = ofi_domain_close(&rxm_domain->util_domain); if (ret) return ret; free(rxm_domain); return 0; }
static int rxd_domain_close(fid_t fid) { int ret; struct rxd_domain *rxd_domain; rxd_domain = container_of(fid, struct rxd_domain, util_domain.domain_fid.fid); ret = fi_close(&rxd_domain->dg_domain->fid); if (ret) return ret; ret = ofi_domain_close(&rxd_domain->util_domain); if (ret) return ret; ofi_mr_map_close(&rxd_domain->mr_map); free(rxd_domain); return 0; }
int psmx2_domain_open(struct fid_fabric *fabric, struct fi_info *info, struct fid_domain **domain, void *context) { struct psmx2_fid_fabric *fabric_priv; struct psmx2_fid_domain *domain_priv; struct psmx2_ep_name *src_addr = info->src_addr; int mr_mode = (info->domain_attr->mr_mode & FI_MR_BASIC) ? FI_MR_BASIC : 0; int err; FI_INFO(&psmx2_prov, FI_LOG_DOMAIN, "\n"); fabric_priv = container_of(fabric, struct psmx2_fid_fabric, util_fabric.fabric_fid); if (!info->domain_attr->name || strcmp(info->domain_attr->name, PSMX2_DOMAIN_NAME)) { err = -FI_EINVAL; goto err_out; } domain_priv = (struct psmx2_fid_domain *) calloc(1, sizeof *domain_priv); if (!domain_priv) { err = -FI_ENOMEM; goto err_out; } err = ofi_domain_init(fabric, info, &domain_priv->util_domain, context); if (err) goto err_out_free_domain; /* fclass & context are set in ofi_domain_init */ domain_priv->util_domain.domain_fid.fid.ops = &psmx2_fi_ops; domain_priv->util_domain.domain_fid.ops = &psmx2_domain_ops; domain_priv->util_domain.domain_fid.mr = &psmx2_mr_ops; domain_priv->mr_mode = mr_mode; domain_priv->mode = info->mode; domain_priv->caps = PSMX2_CAPS | PSMX2_DOM_CAPS; domain_priv->fabric = fabric_priv; domain_priv->progress_thread_enabled = (info->domain_attr->data_progress == FI_PROGRESS_AUTO); domain_priv->addr_format = info->addr_format; if (info->addr_format == FI_ADDR_STR) src_addr = psmx2_string_to_ep_name(info->src_addr); err = psmx2_domain_init(domain_priv, src_addr); if (info->addr_format == FI_ADDR_STR) free(src_addr); if (err) goto err_out_close_domain; psmx2_fabric_acquire(fabric_priv); psmx2_lock(&fabric_priv->domain_lock, 1); dlist_insert_before(&domain_priv->entry, &fabric_priv->domain_list); psmx2_unlock(&fabric_priv->domain_lock, 1); *domain = &domain_priv->util_domain.domain_fid; return 0; err_out_close_domain: ofi_domain_close(&domain_priv->util_domain); err_out_free_domain: free(domain_priv); err_out: return err; }
int psmx2_domain_open(struct fid_fabric *fabric, struct fi_info *info, struct fid_domain **domain, void *context) { struct psmx2_fid_fabric *fabric_priv; struct psmx2_fid_domain *domain_priv; int mr_mode = (info->domain_attr->mr_mode & FI_MR_BASIC) ? FI_MR_BASIC : 0; int err; FI_INFO(&psmx2_prov, FI_LOG_DOMAIN, "\n"); if (!psmx2_env.sep) psmx2_domain_ops.scalable_ep = fi_no_scalable_ep; fabric_priv = container_of(fabric, struct psmx2_fid_fabric, util_fabric.fabric_fid); if (fabric_priv->active_domain) { if (mr_mode != fabric_priv->active_domain->mr_mode) { FI_INFO(&psmx2_prov, FI_LOG_DOMAIN, "mr_mode mismatch: expecting %s\n", mr_mode ? "FI_MR_SCALABLE" : "FI_MR_BASIC"); return -FI_EINVAL; } psmx2_domain_acquire(fabric_priv->active_domain); *domain = &fabric_priv->active_domain->util_domain.domain_fid; return 0; } if (!info->domain_attr->name || strcmp(info->domain_attr->name, PSMX2_DOMAIN_NAME)) { err = -FI_EINVAL; goto err_out; } domain_priv = (struct psmx2_fid_domain *) calloc(1, sizeof *domain_priv); if (!domain_priv) { err = -FI_ENOMEM; goto err_out; } err = ofi_domain_init(fabric, info, &domain_priv->util_domain, context); if (err) goto err_out_free_domain; /* fclass & context are set in ofi_domain_init */ domain_priv->util_domain.domain_fid.fid.ops = &psmx2_fi_ops; domain_priv->util_domain.domain_fid.ops = &psmx2_domain_ops; domain_priv->util_domain.domain_fid.mr = &psmx2_mr_ops; domain_priv->mr_mode = mr_mode; domain_priv->mode = info->mode; domain_priv->caps = PSMX2_CAPS | PSMX2_DOM_CAPS; domain_priv->fabric = fabric_priv; domain_priv->progress_thread_enabled = (info->domain_attr->data_progress == FI_PROGRESS_AUTO); err = psmx2_domain_init(domain_priv, info->src_addr); if (err) goto err_out_close_domain; /* take the reference to count for multiple domain open calls */ psmx2_domain_acquire(fabric_priv->active_domain); *domain = &domain_priv->util_domain.domain_fid; return 0; err_out_close_domain: ofi_domain_close(&domain_priv->util_domain); err_out_free_domain: free(domain_priv); err_out: return err; }
int psmx_domain_open(struct fid_fabric *fabric, struct fi_info *info, struct fid_domain **domain, void *context) { struct psmx_fid_fabric *fabric_priv; struct psmx_fid_domain *domain_priv; int err; FI_INFO(&psmx_prov, FI_LOG_DOMAIN, "\n"); fabric_priv = container_of(fabric, struct psmx_fid_fabric, util_fabric.fabric_fid); if (fabric_priv->active_domain) { psmx_domain_acquire(fabric_priv->active_domain); *domain = &fabric_priv->active_domain->util_domain.domain_fid; return 0; } if (!info->domain_attr->name || strcmp(info->domain_attr->name, PSMX_DOMAIN_NAME)) { err = -FI_EINVAL; goto err_out; } domain_priv = (struct psmx_fid_domain *) calloc(1, sizeof *domain_priv); if (!domain_priv) { err = -FI_ENOMEM; goto err_out; } err = ofi_domain_init(fabric, info, &domain_priv->util_domain, context); if (err) goto err_out_free_domain; /* fclass & context are set in ofi_domain_init */ domain_priv->util_domain.domain_fid.fid.ops = &psmx_fi_ops; domain_priv->util_domain.domain_fid.ops = &psmx_domain_ops; domain_priv->util_domain.domain_fid.mr = &psmx_mr_ops; domain_priv->mr_mode = info->domain_attr->mr_mode; domain_priv->mode = info->mode; domain_priv->caps = info->caps; domain_priv->fabric = fabric_priv; domain_priv->progress_thread_enabled = (info->domain_attr->data_progress == FI_PROGRESS_AUTO && psmx_env.prog_thread); err = psmx_domain_init(domain_priv, info->src_addr); if (err) goto err_out_close_domain; /* tale the reference to count for multiple domain open calls */ psmx_domain_acquire(fabric_priv->active_domain); *domain = &domain_priv->util_domain.domain_fid; return 0; err_out_close_domain: ofi_domain_close(&domain_priv->util_domain); err_out_free_domain: free(domain_priv); err_out: return err; }
int efa_domain_open(struct fid_fabric *fabric_fid, struct fi_info *info, struct fid_domain **domain_fid, void *context) { struct efa_domain *domain; struct efa_fabric *fabric; const struct fi_info *fi; int ret; fi = efa_get_efa_info(info->domain_attr->name); if (!fi) return -FI_EINVAL; fabric = container_of(fabric_fid, struct efa_fabric, util_fabric.fabric_fid); ret = ofi_check_domain_attr(&efa_prov, fabric_fid->api_version, fi->domain_attr, info); if (ret) return ret; domain = calloc(1, sizeof(*domain)); if (!domain) return -FI_ENOMEM; ret = ofi_domain_init(fabric_fid, info, &domain->util_domain, context); if (ret) goto err_free_domain; domain->info = fi_dupinfo(info); if (!domain->info) { ret = -FI_ENOMEM; goto err_close_domain; } domain->rdm = EFA_EP_TYPE_IS_RDM(info); ret = efa_open_device_by_name(domain, info->domain_attr->name); if (ret) goto err_free_info; domain->pd = efa_cmd_alloc_pd(domain->ctx); if (!domain->pd) { ret = -errno; goto err_free_info; } EFA_INFO(FI_LOG_DOMAIN, "Allocated pd[%u].\n", domain->pd->pdn); domain->util_domain.domain_fid.fid.ops = &efa_fid_ops; domain->util_domain.domain_fid.ops = &efa_domain_ops; domain->fab = fabric; *domain_fid = &domain->util_domain.domain_fid; if (efa_mr_cache_enable) { domain->notifier = efa_mem_notifier; if (!domain->notifier) { EFA_DBG(FI_LOG_MR, "efa_mem_notifier is not initialized.\n"); ret = -FI_ENOMEM; goto err_free_pd; } domain->monitor.subscribe = efa_monitor_subscribe; domain->monitor.unsubscribe = efa_monitor_unsubscribe; ofi_monitor_init(&domain->monitor); domain->cache.max_cached_cnt = efa_mr_max_cached_count; domain->cache.max_cached_size = efa_mr_max_cached_size; domain->cache.merge_regions = efa_mr_cache_merge_regions; domain->cache.entry_data_size = sizeof(struct efa_mem_desc); domain->cache.add_region = efa_mr_cache_entry_reg; domain->cache.delete_region = efa_mr_cache_entry_dereg; ret = ofi_mr_cache_init(&domain->util_domain, &domain->monitor, &domain->cache); if (OFI_UNLIKELY(ret)) goto err_cleanup_monitor; domain->util_domain.domain_fid.mr = &efa_domain_mr_cache_ops; } else { domain->util_domain.domain_fid.mr = &efa_domain_mr_ops; } return 0; err_cleanup_monitor: ofi_monitor_cleanup(&domain->monitor); err_free_pd: ret = efa_cmd_dealloc_pd(domain->pd); if (ret) { EFA_INFO_ERRNO(FI_LOG_DOMAIN, "efa_cmd_dealloc_pd", ret); } domain->pd = NULL; err_free_info: fi_freeinfo(domain->info); err_close_domain: ofi_domain_close(&domain->util_domain); err_free_domain: free(domain); return ret; }