Skip to content

Commit 98bfb36

Browse files
committed
Perftest: Add ibv_reg_mr_ex support with TLP Processing Hints and refactor MR registration
* Add support for new unified ibv_reg_mr_ex API with proper mask handling: - Host memory: IBV_REG_MR_MASK_ADDR + in.addr - DMABUF: IBV_REG_MR_MASK_FD | IBV_REG_MR_MASK_IOVA | IBV_REG_MR_MASK_FD_OFFSET - TPH: IBV_REG_MR_MASK_DMAH + in.dmah * Implement TLP Processing Hints (TPH) feature: - Add --tph_mem flag with memory type support (volatile/vm, persistent/pm) - Add --cpu_id flag to specify CPU core ID for TLP processing - Add --ph flag for processing hints (0=Bidirectional, 1=Requester, 2=Target, 3=Target with priority) - Add validation requiring --tph_mem/--cpu_id flags to be used with --ph. * Major refactoring of create_single_mr() into focused helper functions: - Extract setup_mr_flags() for consolidating access flag logic - Extract initialize_buffer_content() for buffer initialization patterns - Create register_mr_ex() for new unified API handling - Create register_mr() for standard APIs (ibv_reg_mr + ibv_reg_dmabuf_mr + mlx5dv_reg_dmabuf_mr)) - Create register_memory_region() as intelligent coordinator with function pointer selection. - ibv_reg_mr_ex doesn't support data_direct feature which requires mlx5dv_reg_dmabuf_mr specifically Add logic to bypass ibv_reg_mr_ex when use_data_direct. Signed-off-by: Shmuel Shaul <[email protected]>
1 parent c543c84 commit 98bfb36

File tree

6 files changed

+341
-76
lines changed

6 files changed

+341
-76
lines changed

configure.ac

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,13 @@ if [test $HAVE_TD_API = yes]; then
553553
AC_DEFINE([HAVE_TD_API], [1], [Have TD API support])
554554
fi
555555

556+
AC_TRY_LINK([#include <infiniband/verbs.h>],
557+
[ibv_reg_mr_ex], [HAVE_REG_MR_EX=yes], [HAVE_REG_MR_EX=no])
558+
AM_CONDITIONAL([HAVE_REG_MR_EX], [test "x$HAVE_REG_MR_EX" = "xyes"])
559+
if [test $HAVE_REG_MR_EX = yes]; then
560+
AC_DEFINE([HAVE_REG_MR_EX], [1], [Have reg mr extended API support])
561+
fi
562+
556563
CFLAGS="-g -Wall -D_GNU_SOURCE -O3 $CFLAGS"
557564
LDFLAGS="$LDFLAGS"
558565
LIBS=$LIBS" -lpthread"

man/perftest.1

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,22 @@ many different options and modes.
414414
Use Hugepages instead of contig, memalign allocations.
415415
Not relevant for raw_ethernet_fs_rate.
416416
.TP
417+
.B --tph_mem=<memory_type>
418+
Set TPH memory type.
419+
<memory_type> can be 'persistent'/'pm' or 'volatile'/'vm'.
420+
Must be used together with --ph flag.
421+
Requires hardware and driver support for TPH functionality.
422+
.TP
423+
.B --cpu_id=<cpu_core_id>
424+
Specify the CPU core ID that should handle the TPH request.
425+
Must be used together with --tph_mem flag.
426+
Requires hardware and driver support for TPH functionality.
427+
.TP
428+
.B --ph=<processing_hints>
429+
Specify processing hints for TPH:
430+
0 = Bidirectional, 1 = Requester, 2 = Target (Completer), 3 = Target with priority.
431+
Requires hardware and driver support for TPH functionality.
432+
.TP
417433
.B --wait_destroy=<seconds>
418434
Wait <seconds> before destroying allocated resources (QP/CQ/PD/MR..).
419435
Relevant only for bandwidth and raw_ethernet_burst_lat.

src/perftest_parameters.c

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,15 @@ static void usage(const char *argv0, VerbType verb, TestType tst, int connection
492492
printf(" --cqe_poll ");
493493
printf(" Number of CQEs polled per iteration \n");
494494

495+
#ifdef HAVE_REG_MR_EX
496+
printf(" --tph_mem=<memory_type> ");
497+
printf(" Use TPH with 'persistent'/'pm' or 'volatile'/'vm' memory type\n");
498+
printf(" --cpu_id=<cpu_core_id> ");
499+
printf(" Specify the CPU core ID that should handle the request.\n");
500+
printf(" --ph=<processing_hints> ");
501+
printf(" Specify processing hints: 0=Bidirectional, 1=Requester, 2=Target(Completer), 3=Target with priority.\n");
502+
#endif
503+
495504
#ifdef HAVE_HNSDV
496505
printf(" --congest_type=<DCQCN, LDCP, HC3, DIP> ");
497506
printf(" Use the hnsdv interface to set congestion control algorithm.\n");
@@ -991,6 +1000,9 @@ static void init_perftest_params(struct perftest_parameters *user_param)
9911000
user_param->connectionless = OFF;
9921001
user_param->cqe_poll = CTX_POLL_BATCH;
9931002
user_param->use_cqe_poll = OFF;
1003+
user_param->tph_mem_type = -1;
1004+
user_param->cpu_id = -1;
1005+
user_param->processing_hints = -1;
9941006
}
9951007

9961008
static int open_file_write(const char* file_path)
@@ -2004,6 +2016,32 @@ static void force_dependecies(struct perftest_parameters *user_param)
20042016
user_param->cqe_poll = CTX_POLL_BATCH_INTENSE;
20052017
}
20062018

2019+
#ifdef HAVE_REG_MR_EX
2020+
if (user_param->processing_hints != -1 && user_param->use_data_direct) {
2021+
printf(RESULT_LINE);
2022+
fprintf(stderr, " data direct is not supported with TPH\n");
2023+
exit(1);
2024+
}
2025+
2026+
if (user_param->tph_mem_type != -1 && user_param->cpu_id == -1) {
2027+
printf(RESULT_LINE);
2028+
fprintf(stderr, " --tph_mem requires --cpu_id to be specified\n");
2029+
exit(1);
2030+
}
2031+
2032+
if (user_param->cpu_id != -1 && user_param->tph_mem_type == -1) {
2033+
printf(RESULT_LINE);
2034+
fprintf(stderr, " --cpu_id requires --tph_mem to be specified\n");
2035+
exit(1);
2036+
}
2037+
2038+
if ((user_param->tph_mem_type != -1 || user_param->cpu_id != -1) && user_param->processing_hints == -1) {
2039+
printf(RESULT_LINE);
2040+
fprintf(stderr, " --tph_mem and --cpu_id can only be used when --ph is specified\n");
2041+
exit(1);
2042+
}
2043+
#endif
2044+
20072045
return;
20082046
}
20092047
/******************************************************************************
@@ -2559,6 +2597,11 @@ int parser(struct perftest_parameters *user_param,char *argv[], int argc)
25592597
#endif
25602598
static int connectionless_flag = 0;
25612599
static int cqe_poll_flag = 0;
2600+
#ifdef HAVE_REG_MR_EX
2601+
static int tph_mem_flag = 0;
2602+
static int cpu_id_flag = 0;
2603+
static int processing_hints_flag = 0;
2604+
#endif
25622605

25632606
char *server_ip = NULL;
25642607
char *client_ip = NULL;
@@ -2737,6 +2780,11 @@ int parser(struct perftest_parameters *user_param,char *argv[], int argc)
27372780
#endif
27382781
{.name = "connectionless", .has_arg = 0, .flag = &connectionless_flag, .val = 1 },
27392782
{.name = "cqe_poll", .has_arg = 1, .flag = &cqe_poll_flag, .val = 1 },
2783+
#ifdef HAVE_REG_MR_EX
2784+
{ .name = "tph_mem", .has_arg = 1, .flag = &tph_mem_flag, .val = 1},
2785+
{ .name = "cpu_id", .has_arg = 1, .flag = &cpu_id_flag, .val = 1},
2786+
{ .name = "ph", .has_arg = 1, .flag = &processing_hints_flag, .val = 1},
2787+
#endif
27402788
{0}
27412789
};
27422790
if (!duplicates_checker) {
@@ -3497,6 +3545,30 @@ int parser(struct perftest_parameters *user_param,char *argv[], int argc)
34973545
user_param->use_cqe_poll = ON;
34983546
cqe_poll_flag = 0;
34993547
}
3548+
#ifdef HAVE_REG_MR_EX
3549+
if (tph_mem_flag) {
3550+
if (optarg) {
3551+
if (strcasecmp(optarg, "volatile") == 0 || strcasecmp(optarg, "vm") == 0) {
3552+
user_param->tph_mem_type = IBV_TPH_MEM_TYPE_VM;
3553+
} else if (strcasecmp(optarg, "persistent") == 0 || strcasecmp(optarg, "pm") == 0) {
3554+
user_param->tph_mem_type = IBV_TPH_MEM_TYPE_PM;
3555+
} else {
3556+
fprintf(stderr, "Invalid TPH memory type. Use 'volatile'/'vm' or 'persistent'/'pm'\n");
3557+
free(duplicates_checker);
3558+
return FAILURE;
3559+
}
3560+
}
3561+
tph_mem_flag = 0;
3562+
}
3563+
if (cpu_id_flag) {
3564+
CHECK_VALUE_NON_NEGATIVE(user_param->cpu_id,int,"cpu_id",not_int_ptr);
3565+
cpu_id_flag = 0;
3566+
}
3567+
if (processing_hints_flag) {
3568+
CHECK_VALUE_IN_RANGE(user_param->processing_hints,int,0,3,"Processing Hints",not_int_ptr);
3569+
processing_hints_flag = 0;
3570+
}
3571+
#endif
35003572
break;
35013573
default:
35023574
fprintf(stderr," Invalid Command or flag.\n");

src/perftest_parameters.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,9 @@ struct perftest_parameters {
675675
int connectionless;
676676
uint16_t cqe_poll;
677677
int use_cqe_poll;
678+
int tph_mem_type;
679+
int cpu_id;
680+
int processing_hints;
678681
};
679682

680683
struct report_options {

0 commit comments

Comments
 (0)