int usdf_cq_open(struct fid_domain *domain, struct fi_cq_attr *attr, struct fid_cq **cq_o, void *context) { struct usdf_cq *cq; struct usdf_domain *udp; int ret; USDF_TRACE_SYS(CQ, "\n"); udp = dom_ftou(domain); ret = usdf_cq_process_attr(attr, udp); if (ret != 0) { return ret; } cq = calloc(1, sizeof(*cq)); if (cq == NULL) { return -FI_ENOMEM; } cq->cq_domain = udp; cq->cq_fid.fid.fclass = FI_CLASS_CQ; cq->cq_fid.fid.context = context; cq->cq_fid.fid.ops = &usdf_cq_fi_ops; atomic_initialize(&cq->cq_refcnt, 0); switch (attr->format) { case FI_CQ_FORMAT_CONTEXT: cq->cq_fid.ops = &usdf_cq_context_ops; break; case FI_CQ_FORMAT_MSG: cq->cq_fid.ops = &usdf_cq_msg_ops; break; case FI_CQ_FORMAT_DATA: cq->cq_fid.ops = &usdf_cq_data_ops; break; default: ret = -FI_ENOSYS; goto fail; } cq->cq_attr = *attr; *cq_o = &cq->cq_fid; return 0; fail: if (cq != NULL) { if (cq->c.hard.cq_cq != NULL) { usd_destroy_cq(cq->c.hard.cq_cq); } free(cq); } return ret; }
int usdf_ep_msg_open(struct fid_domain *domain, struct fi_info *info, struct fid_ep **ep_o, void *context) { struct usdf_domain *udp; struct usdf_ep *ep; int ret; if ((info->caps & ~USDF_DGRAM_CAPS) != 0) { return -FI_EBADF; } udp = dom_ftou(domain); ep = calloc(1, sizeof(*ep)); if (ep == NULL) { return -FI_ENOMEM; } ep->ep_sock = socket(AF_INET, SOCK_DGRAM, 0); if (ep->ep_sock == -1) { ret = -errno; goto fail; } if (info->src_addr != NULL) { if (info->addr_format == FI_SOCKADDR || info->addr_format == FI_SOCKADDR_IN) { ret = usdf_ep_port_bind(ep, info); if (ret != 0) { goto fail; } } } ep->ep_fid.fid.fclass = FI_CLASS_EP; ep->ep_fid.fid.context = context; ep->ep_fid.fid.ops = &usdf_ep_ops; ep->ep_fid.ops = &usdf_base_msg_ops; ep->ep_fid.cm = &usdf_cm_msg_ops; ep->ep_fid.msg = &usdf_msg_ops; ep->ep_domain = udp; ep->ep_caps = info->caps; ep->ep_mode = info->mode; if (info->tx_attr != NULL && info->tx_attr->size != 0) { ep->ep_wqe = info->tx_attr->size; } else { ep->ep_wqe = udp->dom_dev_attrs.uda_max_send_credits; } if (info->rx_attr != NULL && info->rx_attr->size != 0) { ep->ep_rqe = info->rx_attr->size; } else { ep->ep_rqe = udp->dom_dev_attrs.uda_max_recv_credits; } atomic_init(&ep->ep_refcnt, 0); atomic_inc(&udp->dom_refcnt); *ep_o = ep_utof(ep); return 0; fail: if (ep != NULL) { if (ep->ep_sock != -1) { close(ep->ep_sock); } free(ep); } return ret; }