From 3ea6ea2490eb19e5951201804ab9df525338c799 Mon Sep 17 00:00:00 2001 From: Ge Hu Date: Mon, 2 Sep 2024 19:43:09 +0800 Subject: [PATCH] Perftest: Fix failure in creating cq when create cq ex is not supported by providers The previous TD lock-free patch introduced ibv_create_cq_ex() to perftest, but it breaks the provider devices which do not support this API yet. For these devices calling this API leads to an errno of EOPNOTSUPP. So add a check of errno, and if it is EOPNOTSUPP, use ibv_create_cq() as a fallback. Fixes: b6f957f6bc6c ("Perftest: Add support for TD lock-free mode") Tested-By: Selvin Xavier Signed-off-by: Junxian Huang Signed-off-by: Xinghai Cen --- src/perftest_resources.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/perftest_resources.c b/src/perftest_resources.c index 58dbdef..843c45f 100755 --- a/src/perftest_resources.c +++ b/src/perftest_resources.c @@ -1516,7 +1516,7 @@ int create_reg_cqs(struct pingpong_context *ctx, struct perftest_parameters *user_param, int tx_buffer_depth, int need_recv_cq) { - #ifdef HAVE_CQ_EX +#ifdef HAVE_CQ_EX struct ibv_cq_init_attr_ex send_cq_attr = { .cqe = tx_buffer_depth * user_param->num_of_qps, .cq_context = NULL, @@ -1532,6 +1532,8 @@ int create_reg_cqs(struct pingpong_context *ctx, #endif ctx->send_cq = ibv_cq_ex_to_cq(ibv_create_cq_ex(ctx->context, &send_cq_attr)); if (!ctx->send_cq) { + if (!user_param->no_lock && errno == EOPNOTSUPP) + goto cq_ex_not_supported; fprintf(stderr, "Couldn't create CQ\n"); return FAILURE; } @@ -1556,7 +1558,9 @@ int create_reg_cqs(struct pingpong_context *ctx, } } return SUCCESS; -#else + +cq_ex_not_supported: +#endif ctx->send_cq = ibv_create_cq(ctx->context,tx_buffer_depth * user_param->num_of_qps, NULL, ctx->channel, user_param->eq_num); if (!ctx->send_cq) { @@ -1574,7 +1578,6 @@ int create_reg_cqs(struct pingpong_context *ctx, } return SUCCESS; -#endif } /****************************************************************************** -- 2.25.1