uct_ud_send_skb_t *uct_ud_ep_prepare_crep(uct_ud_ep_t *ep) { uct_ud_send_skb_t *skb; uct_ud_neth_t *neth; uct_ud_ctl_hdr_t *crep; uct_ud_iface_t *iface = ucs_derived_of(ep->super.super.iface, uct_ud_iface_t); ucs_assert_always(ep->dest_ep_id != UCT_UD_EP_NULL_ID); ucs_assert_always(ep->ep_id != UCT_UD_EP_NULL_ID); skb = uct_ud_iface_get_tx_skb(iface, ep); if (!skb) { return NULL; } neth = skb->neth; uct_ud_neth_init_data(ep, neth); neth->packet_type = ep->dest_ep_id; neth->packet_type |= (UCT_UD_PACKET_FLAG_ACK_REQ|UCT_UD_PACKET_FLAG_CTL); crep = (uct_ud_ctl_hdr_t *)(neth + 1); crep->type = UCT_UD_PACKET_CREP; crep->conn_rep.src_ep_id = ep->ep_id; skb->len = sizeof(*neth) + sizeof(*crep); UCT_UD_EP_HOOK_CALL_TX(ep, skb->neth); uct_ud_iface_complete_tx_skb_nolog(iface, ep, skb); /* uct_ud_ep_notify(ep); TODO: allow to send data on CREQ RX */ return skb; }
static inline ucs_status_t uct_ud_verbs_am_common(uct_ud_verbs_iface_t *iface, uct_ud_verbs_ep_t *ep, uint8_t id, uct_ud_send_skb_t **skb_p) { uct_ud_send_skb_t *skb; uct_ud_neth_t *neth; UCT_CHECK_AM_ID(id); if (!uct_ud_ep_is_connected(&ep->super)) { return UCS_ERR_NO_RESOURCE; } skb = uct_ud_iface_get_tx_skb(&iface->super, &ep->super); if (!skb) { return UCS_ERR_NO_RESOURCE; } VALGRIND_MAKE_MEM_DEFINED(skb, sizeof *skb); neth = skb->neth; uct_ud_neth_init_data(&ep->super, neth); uct_ud_neth_set_type_am(&ep->super, neth, id); uct_ud_neth_ack_req(&ep->super, neth); iface->tx.sge[0].addr = (uintptr_t)neth; *skb_p = skb; return UCS_OK; }
static ucs_status_t uct_ud_mlx5_ep_put_short(uct_ep_h tl_ep, const void *buffer, unsigned length, uint64_t remote_addr, uct_rkey_t rkey) { uct_ud_mlx5_ep_t *ep = ucs_derived_of(tl_ep, uct_ud_mlx5_ep_t); uct_ud_mlx5_iface_t *iface = ucs_derived_of(tl_ep->iface, uct_ud_mlx5_iface_t); struct mlx5_wqe_ctrl_seg *ctrl; struct mlx5_wqe_inl_data_seg *inl; unsigned wqe_size; uct_ud_put_hdr_t *put_hdr; uct_ud_neth_t *neth; uct_ud_send_skb_t *skb; uct_ud_enter(&iface->super); uct_ud_iface_progress_pending_tx(&iface->super); skb = uct_ud_ep_get_tx_skb(&iface->super, &ep->super); if (!skb) { uct_ud_leave(&iface->super); return UCS_ERR_NO_RESOURCE; } ctrl = iface->tx.wq.curr; /* Set inline segment which has AM id, AM header, and AM payload */ inl = uct_ib_mlx5_get_next_seg(&iface->tx.wq, ctrl, UCT_UD_MLX5_WQE_SIZE); wqe_size = length + sizeof(*put_hdr) + sizeof(*neth); inl->byte_count = htonl(wqe_size | MLX5_INLINE_SEG); /* assume that neth and am header fit into one bb */ ucs_assert(sizeof(*put_hdr) + sizeof(*neth) < MLX5_SEND_WQE_BB); neth = (void*)(inl + 1); uct_ud_neth_init_data(&ep->super, neth); uct_ud_neth_set_type_put(&ep->super, neth); uct_ud_neth_ack_req(&ep->super, neth); put_hdr = (uct_ud_put_hdr_t *)(neth+1); put_hdr->rva = remote_addr; uct_ib_mlx5_inline_copy(put_hdr + 1, buffer, length, &iface->tx.wq); wqe_size += UCT_UD_MLX5_WQE_SIZE + sizeof(*inl); UCT_CHECK_LENGTH(wqe_size, UCT_IB_MLX5_MAX_BB * MLX5_SEND_WQE_BB, "put_short"); UCT_UD_EP_HOOK_CALL_TX(&ep->super, neth); uct_ud_mlx5_post_send(iface, ep, ctrl, wqe_size); skb->len = sizeof(*neth) + sizeof(*put_hdr); memcpy(skb->neth, neth, skb->len); uct_ud_iface_complete_tx_inl(&iface->super, &ep->super, skb, (char *)skb->neth + skb->len, buffer, length); UCT_TL_EP_STAT_OP(&ep->super.super, PUT, SHORT, length); uct_ud_leave(&iface->super); return UCS_OK; }
static ucs_status_t uct_ud_verbs_ep_put_short(uct_ep_h tl_ep, const void *buffer, unsigned length, uint64_t remote_addr, uct_rkey_t rkey) { uct_ud_verbs_ep_t *ep = ucs_derived_of(tl_ep, uct_ud_verbs_ep_t); uct_ud_verbs_iface_t *iface = ucs_derived_of(tl_ep->iface, uct_ud_verbs_iface_t); uct_ud_send_skb_t *skb; uct_ud_put_hdr_t *put_hdr; uct_ud_neth_t *neth; if (!uct_ud_ep_is_connected(&ep->super)) { return UCS_ERR_NO_RESOURCE; } /* TODO: UCT_CHECK_LENGTH(length <= iface->config.max_inline, "put_short"); */ skb = uct_ud_iface_get_tx_skb(&iface->super, &ep->super); if (!skb) { return UCS_ERR_NO_RESOURCE; } skb = uct_ud_iface_get_tx_skb(&iface->super, &ep->super); if (!skb) { return UCS_ERR_NO_RESOURCE; } neth = skb->neth; uct_ud_neth_init_data(&ep->super, neth); uct_ud_neth_set_type_put(&ep->super, neth); uct_ud_neth_ack_req(&ep->super, neth); put_hdr = (uct_ud_put_hdr_t *)(neth+1); put_hdr->rva = remote_addr; iface->tx.sge[0].addr = (uintptr_t)neth; iface->tx.sge[0].length = sizeof(*neth) + sizeof(*put_hdr); uct_ud_verbs_iface_tx_inl(iface, ep, buffer, length); ucs_trace_data("TX: PUT [%0llx] buf=%p len=%u", (unsigned long long)remote_addr, buffer, length); skb->len = iface->tx.sge[0].length; uct_ud_iface_complete_tx_inl(&iface->super, &ep->super, skb, put_hdr+1, buffer, length); return UCS_OK; }
uct_ud_send_skb_t *uct_ud_ep_prepare_creq(uct_ud_ep_t *ep) { uct_ud_send_skb_t *skb; uct_ud_neth_t *neth; uct_ud_ctl_hdr_t *creq; uct_ud_iface_t *iface = ucs_derived_of(ep->super.super.iface, uct_ud_iface_t); uct_sockaddr_ib_t iface_addr; ucs_status_t status; ucs_assert_always(ep->dest_ep_id == UCT_UD_EP_NULL_ID); ucs_assert_always(ep->ep_id != UCT_UD_EP_NULL_ID); memset(&iface_addr, 0, sizeof(iface_addr)); /* make coverity happy */ status = uct_ud_iface_get_address(&iface->super.super.super, (struct sockaddr *)&iface_addr); if (status != UCS_OK) { return NULL; } skb = uct_ud_iface_get_tx_skb(iface, ep); if (!skb) { return NULL; } neth = skb->neth; uct_ud_neth_init_data(ep, neth); neth->packet_type = UCT_UD_EP_NULL_ID; neth->packet_type |= UCT_UD_PACKET_FLAG_CTL; creq = (uct_ud_ctl_hdr_t *)(neth + 1); creq->type = UCT_UD_PACKET_CREQ; creq->conn_req.ib_addr.qp_num = iface_addr.qp_num; creq->conn_req.ib_addr.lid = iface_addr.lid; creq->conn_req.ib_addr.id = ep->ep_id; creq->conn_req.conn_id = ep->conn_id; skb->len = sizeof(*neth) + sizeof(*creq); return skb; }