ucs_status_t uct_ud_mlx5_iface_get_av(uct_ib_iface_t *iface, uct_ud_mlx5_iface_common_t *ud_common_iface, const uct_ib_address_t *ib_addr, uint8_t path_bits, uct_ib_mlx5_base_av_t *base_av, struct mlx5_grh_av *grh_av, int *is_global) { ucs_status_t status; struct ibv_ah *ah; struct mlx5_wqe_av mlx5_av; status = uct_ib_iface_create_ah(iface, ib_addr, path_bits, &ah, is_global); if (status != UCS_OK) { return UCS_ERR_INVALID_ADDR; } uct_ib_mlx5_get_av(ah, &mlx5_av); ibv_destroy_ah(ah); base_av->stat_rate_sl = mlx5_av_base(&mlx5_av)->stat_rate_sl; base_av->fl_mlid = mlx5_av_base(&mlx5_av)->fl_mlid; base_av->rlid = mlx5_av_base(&mlx5_av)->rlid; /* copy MLX5_EXTENDED_UD_AV from the driver, if the flag is not present then * the device supports compact address vector. */ if (ud_common_iface->config.compact_av) { base_av->dqp_dct = mlx5_av_base(&mlx5_av)->dqp_dct & UCT_IB_MLX5_EXTENDED_UD_AV; } else { base_av->dqp_dct = UCT_IB_MLX5_EXTENDED_UD_AV; } ucs_assertv_always((UCT_IB_MLX5_AV_FULL_SIZE > UCT_IB_MLX5_AV_BASE_SIZE) || (base_av->dqp_dct & UCT_IB_MLX5_EXTENDED_UD_AV), "compact address vector not supported, and EXTENDED_AV flag is missing"); if (*is_global) { ucs_assert_always(grh_av != NULL); memcpy(grh_av, mlx5_av_grh(&mlx5_av), sizeof(*grh_av)); } return UCS_OK; }
static ucs_status_t uct_ud_mlx5_ep_create_ah(uct_ud_mlx5_iface_t *iface, uct_ud_mlx5_ep_t *ep, const uct_sockaddr_ib_t *if_addr) { struct ibv_ah *ah; ah = uct_ib_create_ah(&iface->super.super, if_addr->lid); if (ah == NULL) { ucs_error("failed to create address handle: %m"); return UCS_ERR_INVALID_ADDR; } uct_ib_mlx5_get_av(ah, &ep->av); mlx5_av_base(&ep->av)->key.qkey.qkey = htonl(UCT_IB_QKEY); mlx5_av_base(&ep->av)->key.qkey.reserved = iface->super.qp->qp_num; mlx5_av_base(&ep->av)->dqp_dct = htonl(if_addr->qp_num | UCT_IB_MLX5_EXTENDED_UD_AV); ibv_destroy_ah(ah); return UCS_OK; }