!30 [sync] PR-28: 从社区回合patch到openeuler

From: @openeuler-sync-bot 
Reviewed-by: @hellotcc 
Signed-off-by: @hellotcc
This commit is contained in:
openeuler-ci-bot 2024-07-17 01:42:45 +00:00 committed by Gitee
commit 9e4f0501e4
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 362 additions and 1 deletions

View File

@ -0,0 +1,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

View File

@ -0,0 +1,71 @@
From c642cd2753b1b9343a5642ffeaaa78ef135f0f6e Mon Sep 17 00:00:00 2001
From: Junxian Huang <huangjunxian6@hisilicon.com>
Date: Fri, 24 May 2024 17:32:27 +0800
Subject: [PATCH] Perftest: Fix rx_depth check for XRC
When users manually specifies --use_srq in perftest command, the rx_depth
will be checked. If rx_depth is less than the number of qps, the process
will throw an error and exit.
For XRC SEND where SRQ is definitely used, users normally don't need to
manually specifies --use_srq, since the use_srq flag will be set to on
when parsing the XRC parameters. However, the XRC parameters parsing is
after the SRQ rx_depth check. If rx_depth is less than the number of qps
in this case, it will miss the check, size_per_qp in ctx_set_recv_wqes()
will become 0 and ibv_post_srq_recv() won't be called.
Move the XRC parameters parsing ahead of SRQ rx_depth check and set
--use_srq to on in advance so that the rx_depth error can be thrown.
Fixes: 4c774a951b3c ("Added XRC for ib_send_bw test")
Signed-off-by: Junxian Huang <huangjunxian6@hisilicon.com>
---
src/perftest_parameters.c | 25 +++++++++++++------------
1 file changed, 13 insertions(+), 12 deletions(-)
diff --git a/src/perftest_parameters.c b/src/perftest_parameters.c
index 5d27132..52b21dc 100755
--- a/src/perftest_parameters.c
+++ b/src/perftest_parameters.c
@@ -1098,7 +1098,19 @@ static void force_dependecies(struct perftest_parameters *user_param)
exit (1);
}
- if (user_param->use_srq && user_param->num_of_qps > user_param->rx_depth) {
+ /* XRC Part */
+ if (user_param->connection_type == XRC) {
+ if (user_param->work_rdma_cm == ON) {
+ printf(RESULT_LINE);
+ fprintf(stderr," XRC does not support RDMA_CM\n");
+ exit(1);
+ }
+ user_param->use_xrc = ON;
+ user_param->use_srq = ON;
+ }
+
+ if (user_param->use_srq && user_param->verb == SEND &&
+ user_param->num_of_qps > user_param->rx_depth) {
printf(RESULT_LINE);
printf(" Using SRQ depth should be greater than number of QPs.\n");
exit (1);
@@ -1396,17 +1408,6 @@ static void force_dependecies(struct perftest_parameters *user_param)
if (user_param->connection_type == DC && !user_param->use_srq)
user_param->use_srq = ON;
- /* XRC Part */
- if (user_param->connection_type == XRC) {
- if (user_param->work_rdma_cm == ON) {
- printf(RESULT_LINE);
- fprintf(stderr," XRC does not support RDMA_CM\n");
- exit(1);
- }
- user_param->use_xrc = ON;
- user_param->use_srq = ON;
- }
-
if (!user_param->use_old_post_send)
{
#ifndef HAVE_IBV_WR_API
--
2.25.1

View File

@ -1,6 +1,6 @@
Name: perftest
Version: 4.5
Release: 6
Release: 8
License: GPLv2 or BSD
Summary: RDMA Performance Testing Tools
Url: https://github.com/linux-rdma/perftest
@ -15,6 +15,8 @@ Patch6: 0006-Perftest-Add-new-HNS-roce-device-ROH-to-support-new_.patch
Patch7: 0007-add-loongarch-support-for-perftest.patch
Patch8: 0008-Get-CPU-MHz-on-RISC-V.patch
Patch9: 0009-Get-CPU-cycles-on-RISC-V.patch
Patch10: 0010-Perftest-Support-selecting-congestion-control-algori.patch
Patch11: 0011-Perftest-Fix-rx_depth-check-for-XRC.patch
BuildRequires: automake gcc libibverbs-devel >= 1.2.0 librdmacm-devel >= 1.0.21 libibumad-devel >= 1.3.10.2
BuildRequires: pciutils-devel libibverbs librdmacm libibumad
@ -41,6 +43,18 @@ done
%_bindir/*
%changelog
* Mon Jul 8 2024 Xinghai Cen <cenxinghai@h-partners.com> - 4.5-8
- Type: bugfix
- ID: NA
- SUG: NA
- DESC: fix rx_depth check for XRC
* Mon Jul 8 2024 Xinghai Cen <cenxinghai@h-partners.com> - 4.5-7
- Type: feature
- ID: NA
- SUG: NA
- DESC: support selecting congestion control algorithms
* Fri Jan 19 2024 Chengchang Tang <tangchengchang@huawei.com> - 4.5-6
- Type: bugfix
- ID: NA