Skip to content

Commit

Permalink
Perftest: check device capability and operation
Browse files Browse the repository at this point in the history
Signed-off-by: Changcheng Liu <[email protected]>
  • Loading branch information
changchengx committed Apr 16, 2022
1 parent d003032 commit 90999b3
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 0 deletions.
68 changes: 68 additions & 0 deletions src/perftest_parameters.c
Original file line number Diff line number Diff line change
Expand Up @@ -3137,6 +3137,74 @@ int check_link(struct ibv_context *context,struct perftest_parameters *user_para
return SUCCESS;
}

/******************************************************************************
*
******************************************************************************/
int check_ece(struct ibv_context *context,struct perftest_parameters *user_param)
{
int rst = SUCCESS;
if (user_param->use_ece == 0) {
goto out;
}
#ifdef HAVE_RDMACM_ECE
struct ibv_ece dummy_ece = {};
struct ibv_qp_init_attr dummy_qp_init_attr = {};
struct ibv_pd *dummy_pd = NULL;
struct ibv_qp *dummy_qp = NULL;
struct ibv_cq *dummy_cq = NULL;

dummy_pd = ibv_alloc_pd(context);
if (dummy_pd != NULL) {
fprintf(stderr, " failed to create PD\n");
rst = FAILURE;
goto out;
return FAILURE;
}

dummy_cq = ibv_create_cq(context, 1, NULL, NULL, 0);
if (dummy_cq == NULL) {
fprintf(stderr, " failed to create CQ\n");
rst = FAILURE;
goto free_pd;
}

dummy_qp_init_attr.send_cq = dummy_cq;
dummy_qp_init_attr.recv_cq = dummy_cq;
dummy_qp_init_attr.qp_type = IBV_QPT_RC;

dummy_qp_init_attr.cap.max_send_wr = 1;
dummy_qp_init_attr.cap.max_recv_wr = 1;
dummy_qp_init_attr.cap.max_send_sge = 1;
dummy_qp_init_attr.cap.max_recv_sge = 1;

dummy_qp = ibv_create_qp(dummy_pd, &dummy_qp_init_attr);
if (dummy_qp == NULL) {
fprintf(stderr, " failed to create RC QP\n");
rst = FAILURE;
goto free_cq;
}

/* ibv_set_ece() check whether ECE is supported */
if ((ibv_query_ece(dummy_qp, &dummy_ece) != 0) ||
(ibv_set_ece(dummy_qp, &dummy_ece) != 0)) {
fprintf(stderr, " device not support ECE\n");
rst = FAILURE;
}

ibv_destroy_qp(dummy_qp);
free_cq:
ibv_destroy_cq(dummy_cq);
free_pd:
ibv_dealloc_pd(dummy_pd);
#else
fprintf(stderr, " No support ECE operation\n");
rst = FAILURE;
#endif

out:
return rst;
}

/******************************************************************************
*
******************************************************************************/
Expand Down
14 changes: 14 additions & 0 deletions src/perftest_parameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,20 @@ int check_link(struct ibv_context *context,struct perftest_parameters *user_para
*/
int check_link_and_mtu(struct ibv_context *context,struct perftest_parameters *user_param);

/* check ECE capability if using it
*
* Description: check Device ECE capability.
*
* Parameters :
*
* context - Context of the device.
* user_param - Perftest parameters.
*
* Return Value : SUCCESS, FAILURE.
*/
int check_ece(struct ibv_context *context, struct perftest_parameters *user_param);

/* ctx_print_test_info
*
* Description : Prints all the parameters selected for this run.
Expand Down
5 changes: 5 additions & 0 deletions src/read_bw.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ int main(int argc, char *argv[])
return FAILURE;
}

/* See if ECE capability is supported if using it. */
if (check_ece(ctx.context, &user_param)) {
return FAILURE;
}

/* copy the relevant user parameters to the comm struct + creating rdma_cm resources. */
if (create_comm_struct(&user_comm,&user_param)) {
fprintf(stderr," Unable to create RDMA_CM resources\n");
Expand Down

0 comments on commit 90999b3

Please sign in to comment.