static int psmx_ep_control(fid_t fid, int command, void *arg) { struct fi_alias *alias; struct psmx_fid_ep *ep, *new_ep; int err; ep = container_of(fid, struct psmx_fid_ep, ep.fid); switch (command) { case FI_ALIAS: new_ep = (struct psmx_fid_ep *) calloc(1, sizeof *ep); if (!new_ep) return -FI_ENOMEM; alias = arg; *new_ep = *ep; err = psmx_ep_set_flags(new_ep, alias->flags); if (err) { free(new_ep); return err; } new_ep->base_ep = ep; atomic_inc(&ep->ref); psmx_ep_optimize_ops(new_ep); *alias->fid = &new_ep->ep.fid; break; case FI_SETOPSFLAG: err = psmx_ep_set_flags(ep, *(uint64_t *)arg); if (err) return err; psmx_ep_optimize_ops(ep); break; case FI_GETOPSFLAG: if (!arg) return -FI_EINVAL; err = psmx_ep_get_flags(ep, arg); if (err) return err; break; case FI_ENABLE: ep->enabled = 1; return 0; default: return -FI_ENOSYS; } return 0; }
int psmx_ep_open(struct fid_domain *domain, struct fi_info *info, struct fid_ep **ep, void *context) { struct psmx_fid_domain *domain_priv; struct psmx_fid_ep *ep_priv; int err; uint64_t ep_cap; if (info) ep_cap = info->caps; else ep_cap = FI_TAGGED; domain_priv = container_of(domain, struct psmx_fid_domain, util_domain.domain_fid.fid); if (!domain_priv) return -FI_EINVAL; if (info && info->ep_attr && info->ep_attr->auth_key) { if (info->ep_attr->auth_keylen != sizeof(psm_uuid_t)) { FI_WARN(&psmx_prov, FI_LOG_EP_CTRL, "Invalid auth_key_len %d, should be %d.\n", info->ep_attr->auth_keylen, sizeof(psm_uuid_t)); return -FI_EINVAL; } if (memcmp(domain_priv->fabric->uuid, info->ep_attr->auth_key, sizeof(psm_uuid_t))) { FI_WARN(&psmx_prov, FI_LOG_EP_CTRL, "Invalid auth_key: %s\n", psmx_uuid_to_string((void *)info->ep_attr->auth_key)); return -FI_EINVAL; } } err = psmx_domain_check_features(domain_priv, ep_cap); if (err) return err; ep_priv = (struct psmx_fid_ep *) calloc(1, sizeof *ep_priv); if (!ep_priv) return -FI_ENOMEM; ep_priv->ep.fid.fclass = FI_CLASS_EP; ep_priv->ep.fid.context = context; ep_priv->ep.fid.ops = &psmx_fi_ops; ep_priv->ep.ops = &psmx_ep_ops; ep_priv->ep.cm = &psmx_cm_ops; ep_priv->domain = domain_priv; atomic_initialize(&ep_priv->ref, 0); PSMX_CTXT_TYPE(&ep_priv->nocomp_send_context) = PSMX_NOCOMP_SEND_CONTEXT; PSMX_CTXT_EP(&ep_priv->nocomp_send_context) = ep_priv; PSMX_CTXT_TYPE(&ep_priv->nocomp_recv_context) = PSMX_NOCOMP_RECV_CONTEXT; PSMX_CTXT_EP(&ep_priv->nocomp_recv_context) = ep_priv; if (ep_cap & FI_TAGGED) ep_priv->ep.tagged = &psmx_tagged_ops; if (ep_cap & FI_MSG) ep_priv->ep.msg = &psmx_msg_ops; if ((ep_cap & FI_MSG) && psmx_env.am_msg) ep_priv->ep.msg = &psmx_msg2_ops; if (ep_cap & FI_RMA) ep_priv->ep.rma = &psmx_rma_ops; if (ep_cap & FI_ATOMICS) ep_priv->ep.atomic = &psmx_atomic_ops; ep_priv->caps = ep_cap; err = psmx_domain_enable_ep(domain_priv, ep_priv); if (err) { free(ep_priv); return err; } psmx_domain_acquire(domain_priv); if (info) { if (info->tx_attr) ep_priv->tx_flags = info->tx_attr->op_flags; if (info->rx_attr) ep_priv->rx_flags = info->rx_attr->op_flags; } psmx_ep_optimize_ops(ep_priv); ep_priv->service = PSMX_ANY_SERVICE; if (info && info->src_addr) ep_priv->service = ((struct psmx_src_name *)info->src_addr)->service; if (ep_priv->service == PSMX_ANY_SERVICE) ep_priv->service = ((getpid() & 0x7FFF) << 16) + ((uintptr_t)ep_priv & 0xFFFF); psmx_ns_add_local_name(ep_priv->service, domain_priv->psm_epid); *ep = &ep_priv->ep; return 0; }
static int psmx_ep_bind(struct fid *fid, struct fid *bfid, uint64_t flags) { struct psmx_fid_ep *ep; struct psmx_fid_av *av; struct psmx_fid_cq *cq; struct psmx_fid_cntr *cntr; struct psmx_fid_stx *stx; int err; ep = container_of(fid, struct psmx_fid_ep, ep.fid); err = ofi_ep_bind_valid(&psmx_prov, bfid, flags); if (err) return err; switch (bfid->fclass) { case FI_CLASS_EQ: return -FI_ENOSYS; case FI_CLASS_CQ: cq = container_of(bfid, struct psmx_fid_cq, cq.fid); if (ep->domain != cq->domain) return -FI_EINVAL; if (flags & FI_SEND) { ep->send_cq = cq; if (flags & FI_SELECTIVE_COMPLETION) ep->send_selective_completion = 1; } if (flags & FI_RECV) { ep->recv_cq = cq; if (flags & FI_SELECTIVE_COMPLETION) ep->recv_selective_completion = 1; } psmx_ep_optimize_ops(ep); break; case FI_CLASS_CNTR: cntr = container_of(bfid, struct psmx_fid_cntr, cntr.fid); if (ep->domain != cntr->domain) return -FI_EINVAL; if (flags & FI_SEND) ep->send_cntr = cntr; if (flags & FI_RECV) ep->recv_cntr = cntr; if (flags & FI_WRITE) ep->write_cntr = cntr; if (flags & FI_READ) ep->read_cntr = cntr; if (flags & FI_REMOTE_WRITE) ep->remote_write_cntr = cntr; if (flags & FI_REMOTE_READ) ep->remote_read_cntr = cntr; break; case FI_CLASS_AV: av = container_of(bfid, struct psmx_fid_av, av.fid); if (ep->domain != av->domain) return -FI_EINVAL; ep->av = av; psmx_ep_optimize_ops(ep); break; case FI_CLASS_MR: if (!bfid->ops || !bfid->ops->bind) return -FI_EINVAL; err = bfid->ops->bind(bfid, fid, flags); if (err) return err; break; case FI_CLASS_STX_CTX: stx = container_of(bfid, struct psmx_fid_stx, stx.fid); if (ep->domain != stx->domain) return -FI_EINVAL; break; default: return -FI_ENOSYS; } return 0; }
int psmx_ep_open(struct fid_domain *domain, struct fi_info *info, struct fid_ep **ep, void *context) { struct psmx_fid_domain *domain_priv; struct psmx_fid_ep *ep_priv; int err; uint64_t ep_cap; if (info) ep_cap = info->caps; else ep_cap = FI_TAGGED; domain_priv = container_of(domain, struct psmx_fid_domain, util_domain.domain_fid.fid); if (!domain_priv) return -FI_EINVAL; err = psmx_domain_check_features(domain_priv, ep_cap); if (err) return err; ep_priv = (struct psmx_fid_ep *) calloc(1, sizeof *ep_priv); if (!ep_priv) return -FI_ENOMEM; ep_priv->ep.fid.fclass = FI_CLASS_EP; ep_priv->ep.fid.context = context; ep_priv->ep.fid.ops = &psmx_fi_ops; ep_priv->ep.ops = &psmx_ep_ops; ep_priv->ep.cm = &psmx_cm_ops; ep_priv->domain = domain_priv; atomic_initialize(&ep_priv->ref, 0); PSMX_CTXT_TYPE(&ep_priv->nocomp_send_context) = PSMX_NOCOMP_SEND_CONTEXT; PSMX_CTXT_EP(&ep_priv->nocomp_send_context) = ep_priv; PSMX_CTXT_TYPE(&ep_priv->nocomp_recv_context) = PSMX_NOCOMP_RECV_CONTEXT; PSMX_CTXT_EP(&ep_priv->nocomp_recv_context) = ep_priv; if (ep_cap & FI_TAGGED) ep_priv->ep.tagged = &psmx_tagged_ops; if (ep_cap & FI_MSG) ep_priv->ep.msg = &psmx_msg_ops; if ((ep_cap & FI_MSG) && psmx_env.am_msg) ep_priv->ep.msg = &psmx_msg2_ops; if (ep_cap & FI_RMA) ep_priv->ep.rma = &psmx_rma_ops; if (ep_cap & FI_ATOMICS) ep_priv->ep.atomic = &psmx_atomic_ops; ep_priv->caps = ep_cap; err = psmx_domain_enable_ep(domain_priv, ep_priv); if (err) { free(ep_priv); return err; } psmx_domain_acquire(domain_priv); if (info) { if (info->tx_attr) ep_priv->tx_flags = info->tx_attr->op_flags; if (info->rx_attr) ep_priv->rx_flags = info->rx_attr->op_flags; } psmx_ep_optimize_ops(ep_priv); *ep = &ep_priv->ep; return 0; }