Skip to content

Commit 3c58ba0

Browse files
committed
RFC: prov/verbs: add param for setting RDMA CM ToS
By default, if the RDMA CM application does not explicitly set a ToS, then the system default is used. This system default can be changed via the default_roce_tos configfs param, but this is global to the system and is somewhat cumbersome to deal with. This change introduces a new environment param: FI_VERBS_TOS This param can be used to explicitly set the ToS via the rdma_set_option API. If the ToS is set, then the system default is ignored and the new value is used instead. This allows for multiple concurrent workloads to use different ToS values. Valid range is -1 through 255. If unset or set to -1, then the call to rdma_set_option is omitted, thus preserving existing behavior. Not supported/tested on Windows. Signed-off-by: Jacob Moroni <[email protected]>
1 parent 8477665 commit 3c58ba0

File tree

6 files changed

+45
-0
lines changed

6 files changed

+45
-0
lines changed

prov/verbs/src/verbs_domain_xrc.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ static int vrb_create_ini_qp(struct vrb_xrc_ep *ep)
6767
"XRC INI QP rdma_create_qp_ex failed %d\n", -ret);
6868
return ret;
6969
}
70+
71+
if (vrb_rdma_set_tos(ep->base_ep.id)) {
72+
VRB_WARN_ERRNO(FI_LOG_EP_CTRL, "vrb_rdma_set_tos");
73+
}
74+
7075
return FI_SUCCESS;
7176
#else /* VERBS_HAVE_XRC */
7277
return -FI_ENOSYS;
@@ -400,6 +405,10 @@ int vrb_ep_create_tgt_qp(struct vrb_xrc_ep *ep, uint32_t tgt_qpn)
400405
}
401406
ep->tgt_ibv_qp = ep->tgt_id->qp;
402407

408+
if (vrb_rdma_set_tos(ep->tgt_id)) {
409+
VRB_WARN_ERRNO(FI_LOG_EP_CTRL, "vrb_rdma_set_tos");
410+
}
411+
403412
return FI_SUCCESS;
404413
#else /* VERBS_HAVE_XRC */
405414
return -FI_ENOSYS;

prov/verbs/src/verbs_ep.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,6 +1063,10 @@ static int vrb_ep_enable(struct fid_ep *ep_fid)
10631063
/* Allow shared XRC INI QP not controlled by RDMA CM
10641064
* to share same post functions as RC QP. */
10651065
ep->ibv_qp = ep->id->qp;
1066+
1067+
if (vrb_rdma_set_tos(ep->id)) {
1068+
VRB_WARN_ERRNO(FI_LOG_EP_CTRL, "vrb_rdma_set_tos");
1069+
}
10661070
}
10671071
break;
10681072
case FI_EP_DGRAM:

prov/verbs/src/verbs_eq.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -893,6 +893,10 @@ vrb_eq_addr_resolved_event(struct vrb_ep *ep)
893893
/* Allow shared XRC INI QP not controlled by RDMA CM
894894
* to share same post functions as RC QP. */
895895
ep->ibv_qp = ep->id->qp;
896+
897+
if (vrb_rdma_set_tos(ep->id)) {
898+
VRB_WARN_ERRNO(FI_LOG_EP_CTRL, "vrb_rdma_set_tos");
899+
}
896900
}
897901

898902
assert(ep->ibv_qp);

prov/verbs/src/verbs_init.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ static const char *local_node = "localhost";
4545
#define VERBS_DEFAULT_MIN_RNR_TIMER 12
4646

4747
struct vrb_gl_data vrb_gl_data = {
48+
.tos = VERBS_TOS_UNSET,
4849
.def_tx_size = 384,
4950
.def_rx_size = 384,
5051
.def_tx_iov_limit = 4,
@@ -637,6 +638,14 @@ static int vrb_get_param_str(const char *param_name,
637638
int vrb_read_params(void)
638639
{
639640
/* Common parameters */
641+
if (vrb_get_param_int("tos", "RDMA CM ToS value. If unset or -1, then "
642+
"the ToS will not be explicitly set and the system "
643+
"default will be used. Valid range is -1 through 255.",
644+
&vrb_gl_data.tos) ||
645+
(vrb_gl_data.tos < -1 || vrb_gl_data.tos > 255)) {
646+
VRB_WARN(FI_LOG_CORE, "Invalid value of ToS\n");
647+
return -FI_EINVAL;
648+
}
640649
if (vrb_get_param_int("tx_size", "Default maximum tx context size",
641650
&vrb_gl_data.def_tx_size) ||
642651
(vrb_gl_data.def_tx_size < 0)) {

prov/verbs/src/verbs_ofi.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,8 @@
161161
#define VERBS_ANY_DOMAIN "verbs_any_domain"
162162
#define VERBS_ANY_FABRIC "verbs_any_fabric"
163163

164+
#define VERBS_TOS_UNSET -1
165+
164166
#ifdef HAVE_FABRIC_PROFILE
165167
struct vrb_profile;
166168
typedef struct vrb_profile vrb_profile_t;
@@ -176,6 +178,7 @@ extern ofi_mutex_t vrb_init_mutex;
176178
extern struct dlist_entry verbs_devs;
177179

178180
extern struct vrb_gl_data {
181+
int tos;
179182
int def_tx_size;
180183
int def_rx_size;
181184
int def_tx_iov_limit;
@@ -1050,6 +1053,15 @@ vrb_free_recv_wr(struct vrb_progress *progress, struct vrb_recv_wr *wr)
10501053
ofi_buf_free(wr);
10511054
}
10521055

1056+
static inline int vrb_rdma_set_tos(struct rdma_cm_id *id)
1057+
{
1058+
if (vrb_gl_data.tos == VERBS_TOS_UNSET) return 0;
1059+
1060+
uint8_t tos = vrb_gl_data.tos;
1061+
return rdma_set_option(id, RDMA_OPTION_ID, RDMA_OPTION_ID_TOS, &tos,
1062+
sizeof(tos));
1063+
}
1064+
10531065
int vrb_ep_ops_open(struct fid *fid, const char *name,
10541066
uint64_t flags, void **ops, void *context);
10551067

prov/verbs/src/windows/verbs_nd_rdma.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,13 @@ int rdma_destroy_id(struct rdma_cm_id *id)
240240
return 0;
241241
}
242242

243+
int rdma_set_option(struct rdma_cm_id *id, int level, int optname,
244+
void *optval, size_t optlen)
245+
{
246+
errno = ENOSYS;
247+
return -1;
248+
}
249+
243250
int rdma_migrate_id(struct rdma_cm_id *id, struct rdma_event_channel *channel)
244251
{
245252
struct nd_cm_id *id_nd;

0 commit comments

Comments
 (0)