int rxd_av_create(struct fid_domain *domain_fid, struct fi_av_attr *attr, struct fid_av **av_fid, void *context) { int ret; struct rxd_av *av; struct rxd_domain *domain; struct util_av_attr util_attr; struct fi_av_attr av_attr; if (!attr) return -FI_EINVAL; if (attr->name) return -FI_ENOSYS; domain = container_of(domain_fid, struct rxd_domain, util_domain.domain_fid); av = calloc(1, sizeof(*av)); if (!av) return -FI_ENOMEM; util_attr.addrlen = sizeof(fi_addr_t); util_attr.overhead = attr->count; util_attr.flags = FI_SOURCE; av->size = attr->count ? attr->count : RXD_AV_DEF_COUNT; if (attr->type == FI_AV_UNSPEC) attr->type = FI_AV_TABLE; ret = ofi_av_init(&domain->util_domain, attr, &util_attr, &av->util_av, context); if (ret) goto err1; av->size = av->util_av.count; av_attr = *attr; av_attr.type = FI_AV_TABLE; av_attr.count = 0; av_attr.flags = 0; ret = fi_av_open(domain->dg_domain, &av_attr, &av->dg_av, context); if (ret) goto err2; fastlock_init(&av->lock); av->addrlen = domain->addrlen; *av_fid = &av->util_av.av_fid; (*av_fid)->fid.fclass = FI_CLASS_AV; (*av_fid)->fid.ops = &rxd_av_fi_ops; (*av_fid)->ops = &rxd_av_ops; return 0; err2: ofi_av_close(&av->util_av); err1: free(av); return ret; }
static int ip_av_close(struct fid *av_fid) { int ret; struct util_av *av; av = container_of(av_fid, struct util_av, av_fid.fid); ret = ofi_av_close(av); if (ret) return ret; free(av); return 0; }
static int rxd_av_close(struct fid *fid) { struct rxd_av *av; int ret; av = container_of(fid, struct rxd_av, util_av.av_fid); ret = fi_close(&av->dg_av->fid); if (ret) return ret; ret = ofi_av_close(&av->util_av); if (ret) return ret; free(av); return 0; }
int rxd_av_close(struct fid *fid) { int ret; struct rxd_av *av; av = container_of(fid, struct rxd_av, util_av.av_fid); ret = fi_close(&av->dg_av->fid); if (ret) return ret; ret = ofi_av_close(&av->util_av); if (ret) return ret; fastlock_destroy(&av->lock); free(av); return 0; }
int rxd_av_create(struct fid_domain *domain_fid, struct fi_av_attr *attr, struct fid_av **av_fid, void *context) { int ret, i; struct rxd_av *av; struct rxd_domain *domain; struct util_av_attr util_attr; struct fi_av_attr av_attr; if (!attr) return -FI_EINVAL; if (attr->name) return -FI_ENOSYS; attr->count = roundup_power_of_two(attr->count ? attr->count : RXD_DEFAULT_AV_SIZE); domain = container_of(domain_fid, struct rxd_domain, util_domain.domain_fid); av = calloc(1, sizeof(*av)); if (!av) return -FI_ENOMEM; av->fi_addr_table = calloc(1, attr->count * sizeof(fi_addr_t)); av->rxd_addr_table = calloc(1, rxd_env.max_peers * sizeof(struct rxd_addr)); if (!av->fi_addr_table || !av->rxd_addr_table) { ret = -FI_ENOMEM; goto err1; } util_attr.addrlen = sizeof(fi_addr_t); util_attr.flags = 0; attr->type = domain->util_domain.av_type != FI_AV_UNSPEC ? domain->util_domain.av_type : FI_AV_TABLE; ret = ofi_av_init(&domain->util_domain, attr, &util_attr, &av->util_av, context); if (ret) goto err1; av->rbmap.compare = &rxd_tree_compare; ofi_rbmap_init(&av->rbmap); for (i = 0; i < attr->count; av->fi_addr_table[i++] = FI_ADDR_UNSPEC) ; for (i = 0; i < rxd_env.max_peers; i++) { av->rxd_addr_table[i].fi_addr = FI_ADDR_UNSPEC; av->rxd_addr_table[i].dg_addr = FI_ADDR_UNSPEC; } av_attr = *attr; av_attr.count = 0; av_attr.flags = 0; ret = fi_av_open(domain->dg_domain, &av_attr, &av->dg_av, context); if (ret) goto err2; av->util_av.av_fid.fid.ops = &rxd_av_fi_ops; av->util_av.av_fid.ops = &rxd_av_ops; *av_fid = &av->util_av.av_fid; return 0; err2: ofi_av_close(&av->util_av); err1: free(av->fi_addr_table); free(av->rxd_addr_table); free(av); return ret; }