Skip to content

Commit 032de9a

Browse files
committed
UCP/UCT/IB: Add per-endpoint traffic class (DSCP) for RC/RoCE
Add an optional per-endpoint traffic class programmed onto the RC mlx5 QP, so endpoints can be tagged with a distinct DSCP (RoCEv2) or GRH traffic class (IB) for fabric QoS. - API: ucp_ep_params.ep_traffic_class + UCP_EP_PARAM_FIELD_EP_TRAFFIC_CLASS - UCT: uct_ep_connect_to_ep_params_t.ep_traffic_class + UCT_EP_CONNECT_TO_EP_PARAM_FIELD_EP_TRAFFIC_CLASS - Plumb UCP ep params -> wireup -> rc mlx5 devx QP (primary_address_path.dscp for RoCEv2, .tclass for IB); default behavior unchanged when unset - Sentinels UCP_EP_NO_TCLASS / UCT_EP_NO_TCLASS - Java binding constant
1 parent 3ef978e commit 032de9a

24 files changed

Lines changed: 109 additions & 29 deletions

File tree

AUTHORS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ Xu Yifeng <yifeng.xyf@alibaba-inc.com>
129129
Yaser Afshar <yaser.afshar@intel.com>
130130
Yihua Xu <yihua.xu@intel.com>
131131
Yiltan Hassan Temucin <yiltan.temucin@amd.com>
132+
Yoel Benabou <ybenabou@nvidia.com>
133+
Yoel Benabou <ybenabou@nvidia.com>
132134
Yossi Itigin <yosefe@nvidia.com>
133135
Yuriy Shestakov <yuriis@mellanox.com>
134136
Zhenlong Ma <zhenlongm@nvidia.com>

bindings/java/src/main/java/org/openucx/jucx/ucp/UcpConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ public class UcpConstants {
8686
static long UCP_EP_PARAM_FIELD_LOCAL_SOCK_ADDR;
8787
static long UCP_EP_PARAM_FIELD_CONN_REQUEST;
8888
static long UCP_EP_PARAM_FIELD_NAME;
89+
static long UCP_EP_PARAM_FIELD_EP_TRAFFIC_CLASS;
8990

9091
/**
9192
* UCP error handling mode.

bindings/java/src/main/native/ucp_constants.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ Java_org_openucx_jucx_ucp_UcpConstants_loadConstants(JNIEnv *env, jclass cls)
6565
JUCX_DEFINE_LONG_CONSTANT(UCP_EP_PARAM_FIELD_LOCAL_SOCK_ADDR);
6666
JUCX_DEFINE_LONG_CONSTANT(UCP_EP_PARAM_FIELD_CONN_REQUEST);
6767
JUCX_DEFINE_LONG_CONSTANT(UCP_EP_PARAM_FIELD_NAME);
68+
JUCX_DEFINE_LONG_CONSTANT(UCP_EP_PARAM_FIELD_EP_TRAFFIC_CLASS);
6869

6970
// UCP error handling mode
7071
JUCX_DEFINE_INT_CONSTANT(UCP_ERR_HANDLING_MODE_PEER);

src/ucp/api/ucp.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,10 @@ enum ucp_ep_params_field {
268268
/**< Connection request field */
269269
UCP_EP_PARAM_FIELD_CONN_REQUEST = UCS_BIT(6),
270270
UCP_EP_PARAM_FIELD_NAME = UCS_BIT(7), /**< Endpoint name */
271-
UCP_EP_PARAM_FIELD_LOCAL_SOCK_ADDR = UCS_BIT(8) /**< Local socket Address */
271+
UCP_EP_PARAM_FIELD_LOCAL_SOCK_ADDR = UCS_BIT(
272+
8), /**< Local socket Address */
273+
UCP_EP_PARAM_FIELD_EP_TRAFFIC_CLASS = UCS_BIT(
274+
9) /**< Endpoint traffic class */
272275
};
273276

274277

src/ucp/api/ucp_def.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,13 @@ typedef struct ucp_ep_params {
779779
*/
780780
const char *name;
781781

782+
/**
783+
* Traffic class for this endpoint.
784+
* This setting is optional. To enable it, the corresponding - @ref
785+
* UCP_EP_PARAM_FIELD_EP_TRAFFIC_CLASS bit in the field mask must be set.
786+
*/
787+
uint8_t ep_traffic_class;
788+
782789
/**
783790
* The sockaddr to bind locally. Specifies the associated network device
784791
* to bind locally to establish new connections.
@@ -787,7 +794,6 @@ typedef struct ucp_ep_params {
787794
* UCP_EP_PARAM_FIELD_LOCAL_SOCK_ADDR bit in the field mask must be set.
788795
*/
789796
ucs_sock_addr_t local_sockaddr;
790-
791797
} ucp_ep_params_t;
792798

793799

src/ucp/core/ucp_ep.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,13 @@ ucp_ep_adjust_params(ucp_ep_h ep, const ucp_ep_params_t *params)
667667
ep->flags |= UCP_EP_FLAG_USER_DATA_PARAM;
668668
}
669669

670+
if (params->field_mask & UCP_EP_PARAM_FIELD_EP_TRAFFIC_CLASS) {
671+
ep->ep_traffic_class = params->ep_traffic_class;
672+
ep->flags |= UCP_EP_FLAG_EP_TRAFFIC_CLASS;
673+
} else {
674+
ep->ep_traffic_class = UCP_EP_NO_TCLASS;
675+
}
676+
670677
return UCS_OK;
671678
}
672679

src/ucp/core/ucp_ep.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ enum {
104104
while merging pending queues */
105105
UCP_EP_FLAG_CONNECT_PRE_REQ_QUEUED = UCS_BIT(9), /* Pre-Connection request was queued */
106106
UCP_EP_FLAG_CLOSED = UCS_BIT(10),/* EP was closed */
107-
/* 11 bit is vacant for a flag */
107+
UCP_EP_FLAG_EP_TRAFFIC_CLASS = UCS_BIT(11), /* Endpoint traffic class */
108+
/* 12 bit is vacant for a flag */
108109
UCP_EP_FLAG_ERR_HANDLER_INVOKED = UCS_BIT(12),/* error handler was called */
109110
UCP_EP_FLAG_INTERNAL = UCS_BIT(13),/* the internal EP which holds
110111
temporary wireup configuration or
@@ -581,6 +582,7 @@ typedef struct ucp_ep {
581582
/* Transports for every lane */
582583
uct_ep_h uct_eps[UCP_MAX_FAST_PATH_LANES];
583584
ucp_ep_ext_t *ext; /* Endpoint extension */
585+
uint8_t ep_traffic_class; /* Endpoint traffic class */
584586

585587
#if ENABLE_DEBUG_DATA
586588
char peer_name[UCP_WORKER_ADDRESS_NAME_MAX];

src/ucp/core/ucp_types.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ typedef uint16_t ucp_worker_cfg_index_t;
6060
#define UCP_WORKER_MAX_RKEY_CONFIG UINT16_MAX
6161
#define UCP_WORKER_CFG_INDEX_NULL UINT16_MAX
6262

63+
#define UCP_EP_NO_TCLASS ((uint8_t)-1)
64+
6365

6466
/* Forward declarations */
6567
typedef struct ucp_request ucp_request_t;

src/ucp/wireup/wireup.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,9 @@ ucp_wireup_connect_local(ucp_ep_h ep,
480480
}
481481

482482
status = ucp_wireup_ep_connect_to_ep_v2(ucp_ep_get_lane(ep, lane),
483-
address_entry, ep_entry);
483+
address_entry, ep_entry,
484+
ep->ep_traffic_class,
485+
ep->flags);
484486
if (status != UCS_OK) {
485487
goto out;
486488
}

src/ucp/wireup/wireup_ep.c

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,14 @@ ucs_status_t ucp_wireup_ep_connect(uct_ep_h uct_ep, unsigned ep_init_flags,
513513
UCT_EP_PARAM_FIELD_PATH_INDEX;
514514
uct_ep_params.path_index = path_index;
515515
uct_ep_params.iface = ucp_worker_iface(worker, rsc_index)->iface;
516+
517+
if (ucp_ep->flags & UCP_EP_FLAG_EP_TRAFFIC_CLASS) {
518+
uct_ep_params.field_mask |= UCT_EP_PARAM_FIELD_EP_TRAFFIC_CLASS;
519+
uct_ep_params.ep_traffic_class = ucp_ep->ep_traffic_class;
520+
} else {
521+
uct_ep_params.ep_traffic_class = UCT_EP_NO_TCLASS;
522+
}
523+
516524
status = uct_ep_create(&uct_ep_params, &next_ep);
517525
if (status != UCS_OK) {
518526
/* make Coverity happy */
@@ -695,13 +703,19 @@ void ucp_wireup_eps_pending_extract(ucp_ep_t *ucp_ep, ucs_queue_head_t *queue)
695703
ucs_status_t
696704
ucp_wireup_ep_connect_to_ep_v2(uct_ep_h tl_ep,
697705
const ucp_address_entry_t *address_entry,
698-
const ucp_address_entry_ep_addr_t *ep_entry)
706+
const ucp_address_entry_ep_addr_t *ep_entry,
707+
uint8_t ep_traffic_class, ucp_ep_flags_t flags)
699708
{
700709
const uct_ep_connect_to_ep_params_t param = {
701-
.field_mask = UCT_EP_CONNECT_TO_EP_PARAM_FIELD_DEVICE_ADDR_LENGTH |
702-
UCT_EP_CONNECT_TO_EP_PARAM_FIELD_EP_ADDR_LENGTH,
710+
.field_mask =
711+
UCT_EP_CONNECT_TO_EP_PARAM_FIELD_DEVICE_ADDR_LENGTH |
712+
UCT_EP_CONNECT_TO_EP_PARAM_FIELD_EP_ADDR_LENGTH |
713+
((flags & UCP_EP_FLAG_EP_TRAFFIC_CLASS) ?
714+
UCT_EP_CONNECT_TO_EP_PARAM_FIELD_EP_TRAFFIC_CLASS :
715+
0),
703716
.device_addr_length = address_entry->dev_addr_len,
704-
.ep_addr_length = ep_entry->len
717+
.ep_addr_length = ep_entry->len,
718+
.ep_traffic_class = ep_traffic_class
705719
};
706720
ucp_wireup_ep_t *wireup_ep = ucp_wireup_ep(tl_ep);
707721

0 commit comments

Comments
 (0)