Skip to content

Commit 934ec35

Browse files
committed
UCT/IB/MLX5: cleanup
1 parent a4c34c9 commit 934ec35

10 files changed

Lines changed: 364 additions & 113 deletions

File tree

src/uct/api/v2/uct_v2.h

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -412,11 +412,17 @@ typedef enum {
412412
* @brief Flags used by @ref uct_ep_invalidate.
413413
*/
414414
typedef enum {
415+
/** Move the endpoint QP to the error state. */
416+
UCT_EP_INVALIDATE_FLAG_MODIFY_QP_TO_ERR = UCS_BIT(0),
417+
415418
/**
416-
* Do not complete outstanding operations when the endpoint transitions to
417-
* the error state. The caller is responsible for completing them.
419+
* Suppress completion of outstanding operations by the normal endpoint
420+
* error path. The caller transfers outstanding-operation ownership to an
421+
* external provider and is responsible for completing them. This state
422+
* remains active until endpoint cancellation or destruction. This flag
423+
* does not modify QP state.
418424
*/
419-
UCT_EP_INVALIDATE_FLAG_SUPPRESS_COMPLETIONS = UCS_BIT(0)
425+
UCT_EP_INVALIDATE_FLAG_SUPPRESS_COMPLETIONS = UCS_BIT(1)
420426
} uct_ep_invalidate_flags_t;
421427

422428

@@ -1372,10 +1378,11 @@ ucs_status_t uct_ep_query(uct_ep_h ep, uct_ep_attr_t *ep_attr);
13721378
* @ingroup UCT_RESOURCE
13731379
* @brief Invalidate the endpoint.
13741380
*
1375-
* This routine invalidates the endpoint and moves it to the error state.
1376-
* All the incomplete and subsequent operations on the endpoint will be
1377-
* completed with error, unless
1378-
* @ref UCT_EP_INVALIDATE_FLAG_SUPPRESS_COMPLETIONS is specified.
1381+
* This routine invalidates the endpoint according to the requested flags.
1382+
* @ref UCT_EP_INVALIDATE_FLAG_MODIFY_QP_TO_ERR moves a QP-based endpoint to
1383+
* the error state. Incomplete operations are completed with error unless
1384+
* @ref UCT_EP_INVALIDATE_FLAG_SUPPRESS_COMPLETIONS transfers their ownership
1385+
* to the caller.
13791386
*
13801387
* @param [in] ep Endpoint to invalidate.
13811388
* @param [in] params Operation parameters, see @ref
@@ -1893,8 +1900,7 @@ typedef void (*uct_ep_outstanding_purge_callback_t)(
18931900
typedef enum {
18941901
UCT_EP_OUTSTANDING_FIELD_RX_TOKEN = UCS_BIT(0),
18951902
UCT_EP_OUTSTANDING_FIELD_CB = UCS_BIT(1),
1896-
UCT_EP_OUTSTANDING_FIELD_ARG = UCS_BIT(2),
1897-
UCT_EP_OUTSTANDING_FIELD_STATUS = UCS_BIT(3)
1903+
UCT_EP_OUTSTANDING_FIELD_ARG = UCS_BIT(2)
18981904
} uct_ep_outstanding_purge_field_t;
18991905

19001906

@@ -1922,20 +1928,18 @@ typedef struct {
19221928
* Valid when @ref UCT_EP_OUTSTANDING_FIELD_ARG is set.
19231929
*/
19241930
void *arg;
1925-
1926-
/** Completion status for purging all outstanding operations. */
1927-
ucs_status_t status;
19281931
} uct_ep_outstanding_purge_params_t;
19291932

19301933

19311934
/**
19321935
* @ingroup UCT_RESOURCE
19331936
* @brief Purge outstanding (undelivered) operations from an endpoint.
19341937
*
1935-
* If only @ref UCT_EP_OUTSTANDING_FIELD_STATUS is specified, all outstanding
1936-
* operations are completed with the supplied error status. Otherwise,
1937-
* @ref uct_ep_outstanding_purge_params_t::cb is invoked once for each
1938-
* undelivered outstanding operation, in the original endpoint posting order.
1938+
* The transport delegates outstanding-operation classification to its
1939+
* external provider. The provider invokes @ref
1940+
* uct_ep_outstanding_purge_params_t::cb once for each undelivered operation,
1941+
* in the original endpoint posting order. No transport-local status purge is
1942+
* provided by this API.
19391943
*/
19401944
ucs_status_t
19411945
uct_ep_outstanding_purge(uct_ep_h ep,

src/uct/base/uct_iface.h

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -324,23 +324,6 @@ typedef ucs_status_t (*uct_ep_outstanding_purge_func_t)(
324324
uct_ep_h ep, const uct_ep_outstanding_purge_params_t *params);
325325

326326

327-
static UCS_F_ALWAYS_INLINE ucs_status_t uct_ep_outstanding_purge_get_status(
328-
const uct_ep_outstanding_purge_params_t *params, ucs_status_t *status_p)
329-
{
330-
if (params == NULL) {
331-
return UCS_ERR_INVALID_PARAM;
332-
}
333-
334-
if ((params->field_mask != UCT_EP_OUTSTANDING_FIELD_STATUS) ||
335-
!UCS_STATUS_IS_ERR(params->status)) {
336-
return UCS_ERR_UNSUPPORTED;
337-
}
338-
339-
*status_p = params->status;
340-
return UCS_OK;
341-
}
342-
343-
344327
/* Internal operations, not exposed by the external API */
345328
typedef struct uct_iface_internal_ops {
346329
uct_iface_query_v2_func_t iface_query_v2;

src/uct/ib/mlx5/dc/dc_mlx5_ep.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -847,6 +847,19 @@ ucs_status_t uct_dc_mlx5_ep_invalidate(uct_ep_h tl_ep,
847847
{
848848
uct_dc_mlx5_ep_t *ep = ucs_derived_of(tl_ep, uct_dc_mlx5_ep_t);
849849

850+
if ((params == NULL) ||
851+
!(params->field_mask & UCT_EP_INVALIDATE_PARAM_FIELD_FLAGS)) {
852+
return UCS_ERR_INVALID_PARAM;
853+
}
854+
855+
if ((params->flags & UCT_EP_INVALIDATE_FLAG_SUPPRESS_COMPLETIONS)) {
856+
return UCS_ERR_UNSUPPORTED;
857+
}
858+
859+
if (!(params->flags & UCT_EP_INVALIDATE_FLAG_MODIFY_QP_TO_ERR)) {
860+
return UCS_OK;
861+
}
862+
850863
if (ep->dci == UCT_DC_MLX5_EP_NO_DCI) {
851864
ep->flags |= UCT_DC_MLX5_EP_FLAG_INVALIDATED;
852865
return UCS_OK;

src/uct/ib/mlx5/rc/rc_mlx5.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,9 +268,6 @@ ucs_status_t uct_rc_mlx5_ep_get_address(uct_ep_h tl_ep, uct_ep_addr_t *addr);
268268

269269
ucs_status_t uct_rc_mlx5_base_ep_query(uct_ep_h tl_ep, uct_ep_attr_t *ep_attr);
270270

271-
ucs_status_t uct_rc_mlx5_ep_outstanding_purge(
272-
uct_ep_h tl_ep, const uct_ep_outstanding_purge_params_t *params);
273-
274271
void uct_rc_mlx5_ep_update_tx_res(uct_ep_h tl_ep);
275272

276273
unsigned uct_rc_mlx5_ep_cleanup_qp(void *arg);

src/uct/ib/mlx5/rc/rc_mlx5_ep.c

Lines changed: 16 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -64,39 +64,6 @@ void uct_rc_mlx5_ep_update_tx_res(uct_ep_h tl_ep)
6464
}
6565

6666

67-
ucs_status_t uct_rc_mlx5_ep_outstanding_purge(
68-
uct_ep_h tl_ep, const uct_ep_outstanding_purge_params_t *params)
69-
{
70-
UCT_RC_MLX5_BASE_EP_DECL(tl_ep, iface, ep);
71-
ucs_status_t purge_status;
72-
ucs_status_t status;
73-
74-
if ((params != NULL) &&
75-
(params->field_mask & UCT_EP_OUTSTANDING_FIELD_STATUS)) {
76-
status = uct_ep_outstanding_purge_get_status(params, &purge_status);
77-
if (status != UCS_OK) {
78-
return status;
79-
}
80-
81-
if (ep->flags & UCT_RC_MLX5_EP_FLAG_SUPPRESS_COMPLETIONS) {
82-
uct_rc_mlx5_ep_update_tx_res(tl_ep);
83-
ep->flags &= ~UCT_RC_MLX5_EP_FLAG_SUPPRESS_COMPLETIONS;
84-
}
85-
} else {
86-
status = uct_ib_mlx5_ext_ep_outstanding_purge(tl_ep, params);
87-
if (status != UCS_OK) {
88-
return status;
89-
}
90-
91-
purge_status = UCS_ERR_CANCELED;
92-
}
93-
94-
uct_rc_txqp_purge_outstanding(&iface->super, &ep->super.txqp, purge_status,
95-
ep->tx.wq.sw_pi, 0);
96-
return UCS_OK;
97-
}
98-
99-
10067
static ucs_status_t UCS_F_ALWAYS_INLINE uct_rc_mlx5_base_ep_put_short_inline(
10168
uct_ep_h tl_ep, const void *buffer, unsigned length,
10269
uint64_t remote_addr, uct_rkey_t rkey)
@@ -849,24 +816,31 @@ ucs_status_t uct_rc_mlx5_ep_invalidate(uct_ep_h tl_ep,
849816
{
850817
UCT_RC_MLX5_EP_DECL(tl_ep, iface, ep);
851818
uct_ib_mlx5_txwq_t *txwq = &ep->super.tx.wq;
819+
ucs_status_t status;
852820

853-
if ((params != NULL) &&
854-
(params->field_mask & UCT_EP_INVALIDATE_PARAM_FIELD_FLAGS) &&
855-
(params->flags & UCT_EP_INVALIDATE_FLAG_SUPPRESS_COMPLETIONS) &&
821+
if ((params == NULL) ||
822+
!(params->field_mask & UCT_EP_INVALIDATE_PARAM_FIELD_FLAGS)) {
823+
return UCS_ERR_INVALID_PARAM;
824+
}
825+
826+
if (params->flags & UCT_EP_INVALIDATE_FLAG_MODIFY_QP_TO_ERR) {
827+
status = uct_ib_mlx5_modify_qp_state(&iface->super.super, &txwq->super,
828+
IBV_QPS_ERR);
829+
if (status != UCS_OK) {
830+
return status;
831+
}
832+
}
833+
834+
if ((params->flags & UCT_EP_INVALIDATE_FLAG_SUPPRESS_COMPLETIONS) &&
856835
!(ep->super.super.flags & UCT_RC_EP_FLAG_FLUSH_CANCEL) &&
857836
!(ep->super.flags & UCT_RC_MLX5_EP_FLAG_SUPPRESS_COMPLETIONS)) {
858837
ep->super.flags |= UCT_RC_MLX5_EP_FLAG_SUPPRESS_COMPLETIONS;
859838
txwq->ft_ci = txwq->hw_ci;
860-
ucs_assert(txwq->ft_ci ==
861-
(txwq->prev_sw_pi -
862-
(txwq->bb_max -
863-
uct_rc_txqp_available(&ep->super.super.txqp))));
864839
ucs_debug("ep %p suppress completions WQE range (%u, %u) next token %u",
865840
ep, txwq->ft_ci, txwq->sw_pi, txwq->next_token);
866841
}
867842

868-
return uct_ib_mlx5_modify_qp_state(&iface->super.super, &txwq->super,
869-
IBV_QPS_ERR);
843+
return UCS_OK;
870844
}
871845

872846
ucs_status_t uct_rc_mlx5_base_ep_fc_ctrl(uct_ep_t *tl_ep, unsigned op,

src/uct/ib/mlx5/rc/rc_mlx5_iface.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1140,7 +1140,7 @@ static uct_rc_iface_ops_t uct_rc_mlx5_iface_ops = {
11401140
.ep_is_connected = uct_rc_mlx5_base_ep_is_connected,
11411141
.ep_get_device_ep = (uct_ep_get_device_ep_func_t)ucs_empty_function_return_unsupported,
11421142
.ep_put_sgl_zcopy = uct_rc_mlx5_ep_put_sgl_zcopy,
1143-
.ep_outstanding_purge = uct_rc_mlx5_ep_outstanding_purge
1143+
.ep_outstanding_purge = uct_ib_mlx5_ext_ep_outstanding_purge
11441144
},
11451145
.create_cq = uct_rc_mlx5_iface_common_create_cq,
11461146
.destroy_cq = uct_rc_mlx5_iface_common_destroy_cq,

test/gtest/ucp/test_ucp_fault_tolerance.cc

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,15 @@ class test_ucp_fault_tolerance : public test_ucp_memheap {
5353
protected:
5454
static constexpr uint16_t AM_ID = 0;
5555

56+
static ucs_status_t invalidate_uct_ep(uct_ep_h ep)
57+
{
58+
uct_ep_invalidate_params_t params = {};
59+
60+
params.field_mask = UCT_EP_INVALIDATE_PARAM_FIELD_FLAGS;
61+
params.flags = UCT_EP_INVALIDATE_FLAG_MODIFY_QP_TO_ERR;
62+
return uct_ep_invalidate(ep, &params);
63+
}
64+
5665
enum {
5766
GOOD_EP_INDEX = 0, /* Index for good endpoint */
5867
INJECTED_EP_INDEX = 1 /* Index for failure-injected endpoint */
@@ -248,7 +257,7 @@ class test_ucp_fault_tolerance : public test_ucp_memheap {
248257
std::vector<ucs_status_ptr_t> status_ptrs;
249258
ucp_lane_index_t lane = lanes[lane_idx];
250259
uct_ep_h uct_ep_for_injection = ucp_ep_get_lane(ucp_ep_for_injection, lane);
251-
ucs_status_t status = uct_ep_invalidate(uct_ep_for_injection, 0);
260+
ucs_status_t status = invalidate_uct_ep(uct_ep_for_injection);
252261
if (status == UCS_ERR_UNSUPPORTED) {
253262
UCS_TEST_SKIP_R("uct_ep_invalidate is not supported");
254263
}
@@ -322,7 +331,7 @@ class test_ucp_fault_tolerance : public test_ucp_memheap {
322331
break;
323332
}
324333

325-
status = uct_ep_invalidate(uct_ep_for_injection, 0);
334+
status = invalidate_uct_ep(uct_ep_for_injection);
326335
if (status == UCS_ERR_UNSUPPORTED) {
327336
UCS_TEST_SKIP_R("uct_ep_invalidate is not supported");
328337
}
@@ -404,7 +413,7 @@ class test_ucp_fault_tolerance : public test_ucp_memheap {
404413
for (size_t lane_idx = 0; lane_idx < rma_bw_lanes.size() - 1; ++lane_idx) {
405414
ucp_lane_index_t lane = rma_bw_lanes[lane_idx];
406415
uct_ep_h uct_ep_for_injection = ucp_ep_get_lane(ucp_ep_for_injection, lane);
407-
status = uct_ep_invalidate(uct_ep_for_injection, 0);
416+
status = invalidate_uct_ep(uct_ep_for_injection);
408417
if (status == UCS_ERR_UNSUPPORTED) {
409418
UCS_TEST_SKIP_R("uct_ep_invalidate is not supported");
410419
}

0 commit comments

Comments
 (0)