From 39ef530088859ccbbcf29bf6af2cf9f0307dc476 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Wed, 22 Mar 2017 10:47:46 +0200 Subject: [infiniband] Return status code from ib_create_cq() and ib_create_qp() Any underlying errors arising during ib_create_cq() or ib_create_qp() are lost since the functions simply return NULL on error. This makes debugging harder, since a debug-enabled build is required to discover the root cause of the error. Fix by returning a status code from these functions, thereby allowing any underlying errors to be propagated. Signed-off-by: Michael Brown --- src/net/infiniband/ib_cmrc.c | 23 ++++++++++------------- src/net/infiniband/ib_mi.c | 17 +++++++++-------- 2 files changed, 19 insertions(+), 21 deletions(-) (limited to 'src/net/infiniband') diff --git a/src/net/infiniband/ib_cmrc.c b/src/net/infiniband/ib_cmrc.c index 2cd49018f..b8f4bf36b 100644 --- a/src/net/infiniband/ib_cmrc.c +++ b/src/net/infiniband/ib_cmrc.c @@ -423,23 +423,20 @@ int ib_cmrc_open ( struct interface *xfer, struct ib_device *ibdev, } /* Create completion queue */ - cmrc->cq = ib_create_cq ( ibdev, IB_CMRC_NUM_CQES, - &ib_cmrc_completion_ops ); - if ( ! cmrc->cq ) { - DBGC ( cmrc, "CMRC %s %s could not create completion queue\n", - ibdev->name, cmrc->name ); - rc = -ENOMEM; + if ( ( rc = ib_create_cq ( ibdev, IB_CMRC_NUM_CQES, + &ib_cmrc_completion_ops, &cmrc->cq ) ) != 0){ + DBGC ( cmrc, "CMRC %s %s could not create completion queue: " + "%s\n", ibdev->name, cmrc->name, strerror ( rc ) ); goto err_create_cq; } /* Create queue pair */ - cmrc->qp = ib_create_qp ( ibdev, IB_QPT_RC, IB_CMRC_NUM_SEND_WQES, - cmrc->cq, IB_CMRC_NUM_RECV_WQES, cmrc->cq, - &ib_cmrc_queue_pair_ops, name ); - if ( ! cmrc->qp ) { - DBGC ( cmrc, "CMRC %s %s could not create queue pair\n", - ibdev->name, cmrc->name ); - rc = -ENOMEM; + if ( ( rc = ib_create_qp ( ibdev, IB_QPT_RC, IB_CMRC_NUM_SEND_WQES, + cmrc->cq, IB_CMRC_NUM_RECV_WQES, cmrc->cq, + &ib_cmrc_queue_pair_ops, name, + &cmrc->qp ) ) != 0 ) { + DBGC ( cmrc, "CMRC %s %s could not create queue pair: %s\n", + ibdev->name, cmrc->name, strerror ( rc ) ); goto err_create_qp; } ib_qp_set_ownerdata ( cmrc->qp, cmrc ); diff --git a/src/net/infiniband/ib_mi.c b/src/net/infiniband/ib_mi.c index 548a1c829..149c1e4dd 100644 --- a/src/net/infiniband/ib_mi.c +++ b/src/net/infiniband/ib_mi.c @@ -357,19 +357,20 @@ struct ib_mad_interface * ib_create_mi ( struct ib_device *ibdev, INIT_LIST_HEAD ( &mi->madx ); /* Create completion queue */ - mi->cq = ib_create_cq ( ibdev, IB_MI_NUM_CQES, &ib_mi_completion_ops ); - if ( ! mi->cq ) { - DBGC ( mi, "MI %p could not allocate completion queue\n", mi ); + if ( ( rc = ib_create_cq ( ibdev, IB_MI_NUM_CQES, &ib_mi_completion_ops, + &mi->cq ) ) != 0 ) { + DBGC ( mi, "MI %p could not create completion queue: %s\n", + mi, strerror ( rc ) ); goto err_create_cq; } /* Create queue pair */ name = ( ( type == IB_QPT_SMI ) ? "SMI" : "GSI" ); - mi->qp = ib_create_qp ( ibdev, type, IB_MI_NUM_SEND_WQES, mi->cq, - IB_MI_NUM_RECV_WQES, mi->cq, - &ib_mi_queue_pair_ops, name ); - if ( ! mi->qp ) { - DBGC ( mi, "MI %p could not allocate queue pair\n", mi ); + if ( ( rc = ib_create_qp ( ibdev, type, IB_MI_NUM_SEND_WQES, mi->cq, + IB_MI_NUM_RECV_WQES, mi->cq, + &ib_mi_queue_pair_ops, name, &mi->qp ) )!=0){ + DBGC ( mi, "MI %p could not create queue pair: %s\n", + mi, strerror ( rc ) ); goto err_create_qp; } ib_qp_set_ownerdata ( mi->qp, mi ); -- cgit v1.2.3-55-g7522