Repository navigation
UCT: add token query support in ucx #11804
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
f6010c7
a44fd1f
d8356a8
a895bef
9b1ba91
ea9be34
88929cb
0bb751f
c82cfe4
483f0e2
231a244
c0df534
b4cd8f9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1040,27 +1040,57 @@ static void uct_rc_mlx5_iface_fill_ext_query_attr( | |
| if (iface_attr->field_mask & UCT_IFACE_ATTR_FIELD_CAP_FLAGS) { | ||
| ext_attr->field_mask |= UCT_IB_MLX5_EXT_IFACE_QUERY_ATTR_FIELD_CAP_FLAGS; | ||
| } | ||
| } | ||
|
|
||
| if (iface_attr->field_mask & UCT_IFACE_ATTR_FIELD_TX_TOKEN_LENGTH) { | ||
| ext_attr->field_mask |= | ||
| UCT_IB_MLX5_EXT_IFACE_QUERY_ATTR_FIELD_TX_TOKEN_LEN; | ||
| #if HAVE_DEVX | ||
| static ucs_status_t | ||
| uct_rc_mlx5_iface_query_rx_token(uct_iface_h tl_iface, | ||
| uct_iface_attr_v2_t *iface_attr) | ||
| { | ||
| char in[UCT_IB_MLX5DV_ST_SZ_BYTES(query_qp_in)] = {}; | ||
| char out[UCT_IB_MLX5DV_ST_SZ_BYTES(query_qp_out)] = {}; | ||
| const uct_rc_mlx5_tx_token_t *tx_token; | ||
| uct_rc_mlx5_rx_token_t *rx_token; | ||
| uct_rc_iface_t *iface; | ||
| uct_rc_mlx5_base_ep_t *ep; | ||
| uct_rc_ep_t *rc_ep; | ||
| ucs_status_t status; | ||
| void *qpc; | ||
|
|
||
| if (!(iface_attr->field_mask & UCT_IFACE_ATTR_FIELD_TX_TOKEN)) { | ||
| ucs_error("rc mlx5: tx token is required to query rx token"); | ||
| return UCS_ERR_INVALID_PARAM; | ||
| } | ||
|
|
||
| if (iface_attr->field_mask & UCT_IFACE_ATTR_FIELD_RX_TOKEN_LENGTH) { | ||
| ext_attr->field_mask |= | ||
| UCT_IB_MLX5_EXT_IFACE_QUERY_ATTR_FIELD_RX_TOKEN_LEN; | ||
| if ((iface_attr->tx_token == NULL) || (iface_attr->rx_token == NULL)) { | ||
| ucs_error("rc mlx5: tx token or rx token is NULL"); | ||
| return UCS_ERR_INVALID_PARAM; | ||
|
evgeny-leksikov marked this conversation as resolved.
Resolved
|
||
| } | ||
|
|
||
| if (iface_attr->field_mask & UCT_IFACE_ATTR_FIELD_TX_TOKEN) { | ||
| ext_attr->field_mask |= UCT_IB_MLX5_EXT_IFACE_QUERY_ATTR_FIELD_TX_TOKEN; | ||
| ext_attr->tx_token = iface_attr->tx_token; | ||
| tx_token = iface_attr->tx_token; | ||
| iface = ucs_derived_of(tl_iface, uct_rc_iface_t); | ||
| rc_ep = uct_rc_iface_lookup_ep(iface, tx_token->remote_qpn); | ||
| if (rc_ep == NULL) { | ||
| ucs_error("rc mlx5: no ep for QPN %u", tx_token->remote_qpn); | ||
| return UCS_ERR_INVALID_PARAM; | ||
| } | ||
|
|
||
| if (iface_attr->field_mask & UCT_IFACE_ATTR_FIELD_RX_TOKEN) { | ||
| ext_attr->field_mask |= UCT_IB_MLX5_EXT_IFACE_QUERY_ATTR_FIELD_RX_TOKEN; | ||
| ext_attr->rx_token = iface_attr->rx_token; | ||
| ep = ucs_derived_of(rc_ep, uct_rc_mlx5_base_ep_t); | ||
| status = uct_ib_mlx5_devx_query_qp(&ep->tx.wq.super, in, sizeof(in), out, | ||
| sizeof(out)); | ||
| if (status != UCS_OK) { | ||
| ucs_error("rc mlx5: iface %p failed to query rx token: %s", tl_iface, | ||
| ucs_status_string(status)); | ||
| return status; | ||
| } | ||
|
|
||
| qpc = UCT_IB_MLX5DV_ADDR_OF(query_qp_out, out, qpc); | ||
| rx_token = iface_attr->rx_token; | ||
| rx_token->receiver_next_psn = UCT_IB_MLX5DV_GET(qpc, qpc, next_rcv_psn); | ||
|
|
||
| return UCS_OK; | ||
| } | ||
| #endif | ||
|
|
||
| static ucs_status_t | ||
| uct_rc_mlx5_iface_query_v2(uct_iface_h tl_iface, | ||
|
|
@@ -1073,6 +1103,34 @@ uct_rc_mlx5_iface_query_v2(uct_iface_h tl_iface, | |
|
|
||
| uct_iface_query_v2_init(tl_iface, iface_attr); | ||
|
|
||
| #if HAVE_DEVX | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be better to check UCT_IB_MLX5_MD_FLAG_DEVX at runtime rather than (or in addition to) how UCX was compiled |
||
| if (iface_attr->field_mask & UCT_IFACE_ATTR_FIELD_RX_TOKEN) { | ||
| status = uct_rc_mlx5_iface_query_rx_token(tl_iface, iface_attr); | ||
| if (status != UCS_OK) { | ||
| return status; | ||
| } | ||
| } | ||
|
|
||
| if (iface_attr->field_mask & UCT_IFACE_ATTR_FIELD_CAP_FLAGS) { | ||
| iface_attr->cap.flags |= UCT_IFACE_FLAG_V2_QUERY_TOKEN; | ||
| } | ||
|
|
||
| if (iface_attr->field_mask & UCT_IFACE_ATTR_FIELD_TX_TOKEN_LENGTH) { | ||
| iface_attr->tx_token_length = sizeof(uct_rc_mlx5_tx_token_t); | ||
| } | ||
|
|
||
| if (iface_attr->field_mask & UCT_IFACE_ATTR_FIELD_RX_TOKEN_LENGTH) { | ||
| iface_attr->rx_token_length = sizeof(uct_rc_mlx5_rx_token_t); | ||
| } | ||
| #else | ||
| if (iface_attr->field_mask & | ||
| (UCT_IFACE_ATTR_FIELD_TX_TOKEN | UCT_IFACE_ATTR_FIELD_RX_TOKEN | | ||
| UCT_IFACE_ATTR_FIELD_TX_TOKEN_LENGTH | | ||
| UCT_IFACE_ATTR_FIELD_RX_TOKEN_LENGTH)) { | ||
| return UCS_ERR_UNSUPPORTED; | ||
| } | ||
| #endif | ||
|
|
||
| if (iface_attr->field_mask & | ||
| (UCT_IFACE_ATTR_FIELD_CAP_FLAGS | | ||
| UCT_IFACE_ATTR_FIELD_MAX_PUT_SGL_ZCOPY_COUNT)) { | ||
|
|
@@ -1108,14 +1166,6 @@ uct_rc_mlx5_iface_query_v2(uct_iface_h tl_iface, | |
| iface_attr->cap.flags |= ext_attr.cap.flags; | ||
| } | ||
|
|
||
| if (iface_attr->field_mask & UCT_IFACE_ATTR_FIELD_TX_TOKEN_LENGTH) { | ||
| iface_attr->tx_token_length = ext_attr.tx_token_len; | ||
| } | ||
|
|
||
| if (iface_attr->field_mask & UCT_IFACE_ATTR_FIELD_RX_TOKEN_LENGTH) { | ||
| iface_attr->rx_token_length = ext_attr.rx_token_len; | ||
| } | ||
|
|
||
| return UCS_OK; | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1323,6 +1323,71 @@ UCT_INSTANTIATE_RC_TEST_CASE(test_rc_keepalive) | |
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In test_rc_mlx5_token_query.am_short, |
||
| #ifdef HAVE_MLX5_DV | ||
|
|
||
| class test_rc_mlx5_token_query : public test_rc { | ||
| protected: | ||
| static constexpr uint32_t NUM_MESSAGES = 10; | ||
|
|
||
| static ucs_status_t am_handler(void *arg, void*, size_t, unsigned) | ||
| { | ||
| ++*static_cast<uint32_t*>(arg); | ||
|
evgeny-leksikov marked this conversation as resolved.
Resolved
|
||
| return UCS_OK; | ||
| } | ||
|
|
||
| static void query_tx_token(uct_ep_h ep, uct_rc_mlx5_tx_token_t *tx_token) | ||
| { | ||
| uct_ep_attr_t attr = {}; | ||
|
|
||
| attr.field_mask = UCT_EP_ATTR_FIELD_TX_TOKEN; | ||
| attr.tx_token = tx_token; | ||
| ASSERT_UCS_OK(uct_ep_query(ep, &attr)); | ||
| } | ||
|
|
||
| static void query_rx_token(uct_iface_h iface, | ||
| const uct_rc_mlx5_tx_token_t *tx_token, | ||
| uct_rc_mlx5_rx_token_t *rx_token) | ||
| { | ||
| uct_iface_attr_v2_t attr = {}; | ||
|
|
||
| attr.field_mask = UCT_IFACE_ATTR_FIELD_TX_TOKEN | | ||
| UCT_IFACE_ATTR_FIELD_RX_TOKEN; | ||
| attr.tx_token = tx_token; | ||
| attr.rx_token = rx_token; | ||
| ASSERT_UCS_OK(uct_iface_query_v2(iface, &attr)); | ||
| } | ||
| }; | ||
|
|
||
| constexpr uint32_t test_rc_mlx5_token_query::NUM_MESSAGES; | ||
|
|
||
| UCS_TEST_SKIP_COND_P(test_rc_mlx5_token_query, am_short, | ||
| !check_caps(UCT_IFACE_FLAG_AM_SHORT)) | ||
| { | ||
| uct_rc_mlx5_tx_token_t tx_token = {}; | ||
| uct_rc_mlx5_rx_token_t rx_token = {}; | ||
| uint32_t rx_count = 0; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. pls align by |
||
| uct_rc_mlx5_base_ep_t *e2_ep; | ||
| ucs_status_t status; | ||
|
|
||
| ASSERT_UCS_OK(uct_iface_set_am_handler(m_e2->iface(), 0, am_handler, | ||
| &rx_count, 0)); | ||
|
|
||
| for (uint32_t i = 0; i < NUM_MESSAGES; ++i) { | ||
| UCT_TEST_CALL_AND_TRY_AGAIN(uct_ep_am_short(m_e1->ep(0), 0, i, NULL, 0), | ||
| status); | ||
| ASSERT_UCS_OK(status); | ||
| } | ||
|
|
||
| wait_for_value(&rx_count, NUM_MESSAGES, true); | ||
|
|
||
| query_tx_token(m_e1->ep(0), &tx_token); | ||
| query_rx_token(m_e2->iface(), &tx_token, &rx_token); | ||
|
|
||
| e2_ep = ucs_derived_of(m_e2->ep(0), uct_rc_mlx5_base_ep_t); | ||
| EXPECT_EQ(e2_ep->tx.wq.super.qp_num, tx_token.remote_qpn); | ||
| EXPECT_EQ(NUM_MESSAGES, rx_token.receiver_next_psn); | ||
| } | ||
|
|
||
| _UCT_INSTANTIATE_TEST_CASE(test_rc_mlx5_token_query, rc_mlx5) | ||
|
|
||
| class test_rc_srq : public test_rc { | ||
| public: | ||
| test_rc_srq() : m_buf8b(NULL), m_buf8k(NULL) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.