int ofi_ep_bind(struct util_ep *util_ep, struct fid *fid, uint64_t flags) { int ret; struct util_av *av; struct util_cq *cq; struct util_eq *eq; struct util_cntr *cntr; ret = ofi_ep_bind_valid(util_ep->domain->prov, fid, flags); if (ret) return ret; switch (fid->fclass) { case FI_CLASS_CQ: cq = container_of(fid, struct util_cq, cq_fid.fid); return ofi_ep_bind_cq(util_ep, cq, flags); case FI_CLASS_EQ: eq = container_of(fid, struct util_eq, eq_fid.fid); return ofi_ep_bind_eq(util_ep, eq); case FI_CLASS_AV: av = container_of(fid, struct util_av, av_fid.fid); return ofi_ep_bind_av(util_ep, av); case FI_CLASS_CNTR: cntr = container_of(fid, struct util_cntr, cntr_fid.fid); return ofi_ep_bind_cntr(util_ep, cntr, flags); } return -FI_EINVAL; }
int ofi_endpoint_init(struct fid_domain *domain, const struct util_prov *util_prov, struct fi_info *info, struct util_ep *ep, void *context, ofi_ep_progress_func progress) { struct util_domain *util_domain; int ret; util_domain = container_of(domain, struct util_domain, domain_fid); if (!info || !info->ep_attr || !info->rx_attr || !info->tx_attr) return -FI_EINVAL; ret = ofi_prov_check_info(util_prov, util_domain->fabric->fabric_fid.api_version, info); if (ret) return ret; ep->ep_fid.fid.fclass = FI_CLASS_EP; ep->ep_fid.fid.context = context; ep->domain = util_domain; ep->caps = info->caps; ep->progress = progress; ep->tx_op_flags = info->tx_attr->op_flags; ep->rx_op_flags = info->rx_attr->op_flags; ofi_atomic_inc32(&util_domain->ref); if (util_domain->eq) ofi_ep_bind_eq(ep, util_domain->eq); fastlock_init(&ep->lock); return 0; }
int ofi_endpoint_init(struct fid_domain *domain, const struct util_prov *util_prov, struct fi_info *info, struct util_ep *ep, void *context, ofi_ep_progress_func progress) { struct util_domain *util_domain; int ret; util_domain = container_of(domain, struct util_domain, domain_fid); if (!info || !info->ep_attr || !info->rx_attr || !info->tx_attr) return -FI_EINVAL; ret = ofi_prov_check_info(util_prov, util_domain->fabric->fabric_fid.api_version, info); if (ret) return ret; ep->ep_fid.fid.fclass = FI_CLASS_EP; ep->ep_fid.fid.context = context; ep->domain = util_domain; ep->caps = info->caps; ep->flags = 0; ep->progress = progress; ep->tx_op_flags = info->tx_attr->op_flags; ep->rx_op_flags = info->rx_attr->op_flags; ep->tx_msg_flags = 0; ep->rx_msg_flags = 0; ep->inject_op_flags = ((info->tx_attr->op_flags & ~(FI_COMPLETION | FI_INJECT_COMPLETE | FI_TRANSMIT_COMPLETE | FI_DELIVERY_COMPLETE)) | FI_INJECT); ep->tx_cntr_inc = ofi_cntr_inc_noop; ep->rx_cntr_inc = ofi_cntr_inc_noop; ep->rd_cntr_inc = ofi_cntr_inc_noop; ep->wr_cntr_inc = ofi_cntr_inc_noop; ep->rem_rd_cntr_inc = ofi_cntr_inc_noop; ep->rem_wr_cntr_inc = ofi_cntr_inc_noop; ep->type = info->ep_attr->type; ofi_atomic_inc32(&util_domain->ref); if (util_domain->eq) ofi_ep_bind_eq(ep, util_domain->eq); fastlock_init(&ep->lock); if (ep->domain->threading != FI_THREAD_SAFE) { ep->lock_acquire = ofi_fastlock_acquire_noop; ep->lock_release = ofi_fastlock_release_noop; } else { ep->lock_acquire = ofi_fastlock_acquire; ep->lock_release = ofi_fastlock_release; } return 0; }