1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
|
From e8164fdc9ce332217a7877ffb6d1535bf0261fb1 Mon Sep 17 00:00:00 2001
From: Guofeng Yue <yueguofeng@h-partners.com>
Date: Fri, 28 Jun 2024 10:56:09 +0800
Subject: [PATCH] Perftest: Support selecting congestion control algorithms
Support configuring congestion control algorithms with hns direct verbs.
New option: --congest_type
Usage example:
./ib_send_bw -d hns_0 --congest_type=DCQCN
./ib_send_bw -d hns_0 --congest_type=DCQCN 192.168.100.100
Signed-off-by: Guofeng Yue <yueguofeng@h-partners.com>
Signed-off-by: Junxian Huang <huangjunxian6@hisilicon.com>
---
Makefile.am | 24 ++++++++---------
configure.ac | 7 +++++
src/perftest_parameters.c | 57 +++++++++++++++++++++++++++++++++++++++
src/perftest_parameters.h | 1 +
src/perftest_resources.c | 12 +++++++++
src/perftest_resources.h | 3 +++
6 files changed, 92 insertions(+), 12 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index e6a1132..1f09a61 100755
--- a/Makefile.am
+++ b/Makefile.am
@@ -57,41 +57,41 @@ LIBMLX4=
endif
ib_send_bw_SOURCES = src/send_bw.c src/multicast_resources.c src/multicast_resources.h
-ib_send_bw_LDADD = libperftest.a $(LIBUMAD) $(LIBMATH) $(LIBMLX4) $(LIBMLX5) $(LIBEFA)
+ib_send_bw_LDADD = libperftest.a $(LIBUMAD) $(LIBMATH) $(LIBMLX4) $(LIBMLX5) $(LIBEFA) $(LIBHNS)
ib_send_lat_SOURCES = src/send_lat.c src/multicast_resources.c src/multicast_resources.h
-ib_send_lat_LDADD = libperftest.a $(LIBUMAD) $(LIBMATH) $(LIBMLX4) $(LIBMLX5) $(LIBEFA)
+ib_send_lat_LDADD = libperftest.a $(LIBUMAD) $(LIBMATH) $(LIBMLX4) $(LIBMLX5) $(LIBEFA) $(LIBHNS)
ib_write_lat_SOURCES = src/write_lat.c
-ib_write_lat_LDADD = libperftest.a $(LIBMATH) $(LIBMLX4) $(LIBMLX5) $(LIBEFA)
+ib_write_lat_LDADD = libperftest.a $(LIBMATH) $(LIBMLX4) $(LIBMLX5) $(LIBEFA) $(LIBHNS)
ib_write_bw_SOURCES = src/write_bw.c
-ib_write_bw_LDADD = libperftest.a $(LIBMATH) $(LIBMLX4) $(LIBMLX5) $(LIBEFA)
+ib_write_bw_LDADD = libperftest.a $(LIBMATH) $(LIBMLX4) $(LIBMLX5) $(LIBEFA) $(LIBHNS)
ib_read_lat_SOURCES = src/read_lat.c
-ib_read_lat_LDADD = libperftest.a $(LIBMATH) $(LIBMLX4) $(LIBMLX5) $(LIBEFA)
+ib_read_lat_LDADD = libperftest.a $(LIBMATH) $(LIBMLX4) $(LIBMLX5) $(LIBEFA) $(LIBHNS)
ib_read_bw_SOURCES = src/read_bw.c
-ib_read_bw_LDADD = libperftest.a $(LIBMATH) $(LIBMLX4) $(LIBMLX5) $(LIBEFA)
+ib_read_bw_LDADD = libperftest.a $(LIBMATH) $(LIBMLX4) $(LIBMLX5) $(LIBEFA) $(LIBHNS)
ib_atomic_lat_SOURCES = src/atomic_lat.c
-ib_atomic_lat_LDADD = libperftest.a $(LIBMATH) $(LIBMLX4) $(LIBMLX5) $(LIBEFA)
+ib_atomic_lat_LDADD = libperftest.a $(LIBMATH) $(LIBMLX4) $(LIBMLX5) $(LIBEFA) $(LIBHNS)
ib_atomic_bw_SOURCES = src/atomic_bw.c
-ib_atomic_bw_LDADD = libperftest.a $(LIBMATH) $(LIBMLX4) $(LIBMLX5) $(LIBEFA)
+ib_atomic_bw_LDADD = libperftest.a $(LIBMATH) $(LIBMLX4) $(LIBMLX5) $(LIBEFA) $(LIBHNS)
if HAVE_RAW_ETH
raw_ethernet_bw_SOURCES = src/raw_ethernet_send_bw.c
-raw_ethernet_bw_LDADD = libperftest.a $(LIBMATH) $(LIBMLX4) $(LIBMLX5) $(LIBEFA)
+raw_ethernet_bw_LDADD = libperftest.a $(LIBMATH) $(LIBMLX4) $(LIBMLX5) $(LIBEFA) $(LIBHNS)
raw_ethernet_lat_SOURCES = src/raw_ethernet_send_lat.c
-raw_ethernet_lat_LDADD = libperftest.a $(LIBMATH) $(LIBMLX4) $(LIBMLX5) $(LIBEFA)
+raw_ethernet_lat_LDADD = libperftest.a $(LIBMATH) $(LIBMLX4) $(LIBMLX5) $(LIBEFA) $(LIBHNS)
raw_ethernet_burst_lat_SOURCES = src/raw_ethernet_send_burst_lat.c
-raw_ethernet_burst_lat_LDADD = libperftest.a $(LIBMATH) $(LIBMLX4) $(LIBMLX5) $(LIBEFA)
+raw_ethernet_burst_lat_LDADD = libperftest.a $(LIBMATH) $(LIBMLX4) $(LIBMLX5) $(LIBEFA) $(LIBHNS)
raw_ethernet_fs_rate_SOURCES = src/raw_ethernet_fs_rate.c
-raw_ethernet_fs_rate_LDADD = libperftest.a $(LIBMATH) $(LIBMLX4) $(LIBMLX5) $(LIBEFA)
+raw_ethernet_fs_rate_LDADD = libperftest.a $(LIBMATH) $(LIBMLX4) $(LIBMLX5) $(LIBEFA) $(LIBHNS)
else
raw_ethernet_bw_SOURCES =
diff --git a/configure.ac b/configure.ac
index 2bbc7fc..54fc2cc 100755
--- a/configure.ac
+++ b/configure.ac
@@ -291,6 +291,13 @@ if [test $HAVE_MLX5DV_LIB = yes] && [test $HAVE_MLX5DV = yes]; then
AC_SUBST([LIBMLX5])
fi
+AC_CHECK_LIB([hns], [hnsdv_query_device], [HAVE_HNSDV=yes LIBHNS=-lhns], [HAVE_HNSDV=no])
+AM_CONDITIONAL([HAVE_HNSDV], [test "x$HAVE_HNSDV" = "xyes"])
+if [test $HAVE_HNSDV = yes]; then
+ AC_DEFINE([HAVE_HNSDV], [1], [Have hns Direct Verbs support])
+ AC_SUBST([LIBHNS])
+fi
+
CFLAGS="-g -Wall -D_GNU_SOURCE -O3 $CFLAGS"
LIBS=$LIBS" -lpthread"
AC_SUBST([LIBUMAD])
diff --git a/src/perftest_parameters.c b/src/perftest_parameters.c
index 034a20e..6fdf0a1 100755
--- a/src/perftest_parameters.c
+++ b/src/perftest_parameters.c
@@ -27,6 +27,9 @@ static const char *portStates[] = {"Nop","Down","Init","Armed","","Active Defer"
static const char *qp_state[] = {"OFF","ON"};
static const char *exchange_state[] = {"Ethernet","rdma_cm"};
static const char *atomicTypesStr[] = {"CMP_AND_SWAP","FETCH_AND_ADD"};
+#ifdef HAVE_HNSDV
+static const char *congestStr[] = {"DCQCN","LDCP","HC3","DIP"};
+#endif
/******************************************************************************
* parse_mac_from_str.
@@ -432,6 +435,11 @@ static void usage(const char *argv0, VerbType verb, TestType tst, int connection
printf(" --cpu_util ");
printf(" Show CPU Utilization in report, valid only in Duration mode \n");
+ #ifdef HAVE_HNSDV
+ printf(" --congest_type=<DCQCN, LDCP, HC3, DIP> ");
+ printf(" Use the hnsdv interface to set congestion control algorithm.\n");
+ #endif
+
if (tst != FS_RATE) {
printf(" --dlid ");
printf(" Set a Destination LID instead of getting it from the other side.\n");
@@ -814,6 +822,7 @@ static void init_perftest_params(struct perftest_parameters *user_param)
user_param->disable_pcir = 0;
user_param->source_ip = NULL;
user_param->has_source_ip = 0;
+ user_param->congest_type = OFF;
}
static int open_file_write(const char* file_path)
@@ -911,6 +920,25 @@ static void change_conn_type(int *cptr, VerbType verb, const char *optarg)
exit(1);
}
}
+
+#ifdef HAVE_HNSDV
+static void set_congest_type(int *cgtr, const char *optarg)
+{
+ if (strcmp(congestStr[0], optarg) == 0) {
+ *cgtr = HNSDV_QP_CREATE_ENABLE_DCQCN;
+ } else if (strcmp(congestStr[1], optarg) == 0) {
+ *cgtr = HNSDV_QP_CREATE_ENABLE_LDCP;
+ } else if (strcmp(congestStr[2], optarg) == 0) {
+ *cgtr = HNSDV_QP_CREATE_ENABLE_HC3;
+ } else if (strcmp(congestStr[3], optarg) == 0) {
+ *cgtr = HNSDV_QP_CREATE_ENABLE_DIP;
+ } else {
+ fprintf(stderr, " Invalid congest type. Please choose from {DCQCN,LDCP,HC3,DIP}\n");
+ exit(1);
+ }
+}
+#endif
+
/******************************************************************************
*
******************************************************************************/
@@ -2057,6 +2085,23 @@ static void ctx_set_max_inline(struct ibv_context *context,struct perftest_param
}
}
+ #ifdef HAVE_HNSDV
+ if (user_param->congest_type) {
+ if (user_param->work_rdma_cm == ON)
+ {
+ printf(RESULT_LINE);
+ fprintf(stderr, "rdma_cm does not support setting congest type.\n");
+ exit(1);
+ }
+
+ if (user_param->connection_type == XRC || user_param->connection_type == UD) {
+ printf(RESULT_LINE);
+ fprintf(stdout, "XRC/UD does not support setting congest type.\n");
+ exit(1);
+ }
+ }
+ #endif
+
return;
}
/******************************************************************************
@@ -2176,6 +2221,9 @@ int parser(struct perftest_parameters *user_param,char *argv[], int argc)
static int credentials_path_flag = 0;
static int data_enc_key_app_path_flag = 0;
#endif
+ #ifdef HAVE_HNSDV
+ static int congest_type_flag = 0;
+ #endif
char *server_ip = NULL;
char *client_ip = NULL;
@@ -2323,6 +2371,9 @@ int parser(struct perftest_parameters *user_param,char *argv[], int argc)
#if defined HAVE_OOO_ATTR
{.name = "use_ooo", .has_arg = 0, .flag = &use_ooo_flag, .val = 1},
#endif
+ #ifdef HAVE_HNSDV
+ { .name = "congest_type", .has_arg = 1, .flag = &congest_type_flag, .val = 1},
+ #endif
{.name = "source_ip", .has_arg = 1, .flag = &source_ip_flag, .val = 1},
{0}
};
@@ -2569,6 +2620,12 @@ int parser(struct perftest_parameters *user_param,char *argv[], int argc)
case 'v': user_param->mac_fwd = ON; break;
case 'G': user_param->use_rss = ON; break;
case 0: /* required for long options to work. */
+ #ifdef HAVE_HNSDV
+ if (congest_type_flag) {
+ set_congest_type(&user_param->congest_type, optarg);
+ congest_type_flag = 0;
+ }
+ #endif
if (pkey_flag) {
user_param->pkey_index = strtol(optarg,NULL,0);
pkey_flag = 0;
diff --git a/src/perftest_parameters.h b/src/perftest_parameters.h
index 909d771..ffc19ab 100755
--- a/src/perftest_parameters.h
+++ b/src/perftest_parameters.h
@@ -462,6 +462,7 @@ struct perftest_parameters {
int recv_post_list;
int duration;
int use_srq;
+ int congest_type;
int use_xrc;
int use_rss;
int srq_exists;
diff --git a/src/perftest_resources.c b/src/perftest_resources.c
index bcec080..451f11d 100755
--- a/src/perftest_resources.c
+++ b/src/perftest_resources.c
@@ -2155,6 +2155,9 @@ struct ibv_qp* ctx_qp_create(struct pingpong_context *ctx,
struct efadv_qp_init_attr efa_attr = {};
#endif
#endif
+ #ifdef HAVE_HNSDV
+ struct hnsdv_qp_init_attr hns_attr = {};
+ #endif
attr.send_cq = ctx->send_cq;
attr.recv_cq = (user_param->verb == SEND) ? ctx->recv_cq : ctx->send_cq;
@@ -2316,6 +2319,15 @@ struct ibv_qp* ctx_qp_create(struct pingpong_context *ctx,
#endif // HAVE_AES_XTS
else
#endif // HAVE_MLX5DV
+
+ #ifdef HAVE_HNSDV
+ if (user_param->congest_type) {
+ hns_attr.comp_mask = HNSDV_QP_INIT_ATTR_MASK_QP_CONGEST_TYPE;
+ hns_attr.congest_type = user_param->congest_type;
+ qp = hnsdv_create_qp(ctx->context, &attr_ex, &hns_attr);
+ }
+ else
+ #endif //HAVE_HNSDV
qp = ibv_create_qp_ex(ctx->context, &attr_ex);
}
else
diff --git a/src/perftest_resources.h b/src/perftest_resources.h
index ea4a6c4..cf0502c 100755
--- a/src/perftest_resources.h
+++ b/src/perftest_resources.h
@@ -55,6 +55,9 @@
#if defined(HAVE_MLX5DV)
#include <infiniband/mlx5dv.h>
#endif
+#if defined(HAVE_HNSDV)
+#include <infiniband/hnsdv.h>
+#endif
#include <rdma/rdma_cma.h>
#include <stdint.h>
#if defined(__FreeBSD__)
--
2.25.1
|