Skip to content

Commit 20fac51

Browse files
committed
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 99c0ce9 commit 20fac51

File tree

7 files changed

+47
-0
lines changed

7 files changed

+47
-0
lines changed

man/fi_verbs.7.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,11 @@ The verbs provider checks for the following environment variables.
157157

158158
### Common variables:
159159

160+
*FI_VERBS_TOS*
161+
: RDMA CM ToS value. If unset or set to -1, then the ToS will not be
162+
explicitly set and the system default will be used. Valid range is -1
163+
through 255.
164+
160165
*FI_VERBS_TX_SIZE*
161166
: Default maximum tx context size (default: 384)
162167

prov/verbs/src/verbs_domain_xrc.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ 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+
7074
return FI_SUCCESS;
7175
#else /* VERBS_HAVE_XRC */
7276
return -FI_ENOSYS;
@@ -400,6 +404,9 @@ int vrb_ep_create_tgt_qp(struct vrb_xrc_ep *ep, uint32_t tgt_qpn)
400404
}
401405
ep->tgt_ibv_qp = ep->tgt_id->qp;
402406

407+
if (vrb_rdma_set_tos(ep->tgt_id))
408+
VRB_WARN_ERRNO(FI_LOG_EP_CTRL, "vrb_rdma_set_tos");
409+
403410
return FI_SUCCESS;
404411
#else /* VERBS_HAVE_XRC */
405412
return -FI_ENOSYS;

prov/verbs/src/verbs_ep.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,6 +1063,9 @@ 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");
10661069
}
10671070
break;
10681071
case FI_EP_DGRAM:

prov/verbs/src/verbs_eq.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -893,6 +893,9 @@ 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");
896899
}
897900

898901
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 set to -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: 13 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,16 @@ 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)
1059+
return 0;
1060+
1061+
uint8_t tos = vrb_gl_data.tos;
1062+
return rdma_set_option(id, RDMA_OPTION_ID, RDMA_OPTION_ID_TOS, &tos,
1063+
sizeof(tos));
1064+
}
1065+
10531066
int vrb_ep_ops_open(struct fid *fid, const char *name,
10541067
uint64_t flags, void **ops, void *context);
10551068

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)