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/drivers/net/eoib.c | 19 ++++++++----------- src/drivers/net/ipoib.c | 20 +++++++++----------- 2 files changed, 17 insertions(+), 22 deletions(-) (limited to 'src/drivers/net') diff --git a/src/drivers/net/eoib.c b/src/drivers/net/eoib.c index e82478372..ba2912953 100644 --- a/src/drivers/net/eoib.c +++ b/src/drivers/net/eoib.c @@ -538,22 +538,19 @@ static int eoib_open ( struct net_device *netdev ) { } /* Allocate completion queue */ - eoib->cq = ib_create_cq ( ibdev, EOIB_NUM_CQES, &eoib_cq_op ); - if ( ! eoib->cq ) { - DBGC ( eoib, "EoIB %s could not allocate completion queue\n", - eoib->name ); - rc = -ENOMEM; + if ( ( rc = ib_create_cq ( ibdev, EOIB_NUM_CQES, &eoib_cq_op, + &eoib->cq ) ) != 0 ) { + DBGC ( eoib, "EoIB %s could not create completion queue: %s\n", + eoib->name, strerror ( rc ) ); goto err_create_cq; } /* Allocate queue pair */ - eoib->qp = ib_create_qp ( ibdev, IB_QPT_UD, EOIB_NUM_SEND_WQES, + if ( ( rc = ib_create_qp ( ibdev, IB_QPT_UD, EOIB_NUM_SEND_WQES, eoib->cq, EOIB_NUM_RECV_WQES, eoib->cq, - &eoib_qp_op, netdev->name ); - if ( ! eoib->qp ) { - DBGC ( eoib, "EoIB %s could not allocate queue pair\n", - eoib->name ); - rc = -ENOMEM; + &eoib_qp_op, netdev->name, &eoib->qp ) )!=0){ + DBGC ( eoib, "EoIB %s could not create queue pair: %s\n", + eoib->name, strerror ( rc ) ); goto err_create_qp; } ib_qp_set_ownerdata ( eoib->qp, eoib ); diff --git a/src/drivers/net/ipoib.c b/src/drivers/net/ipoib.c index 8a65c87ba..33c7ddccd 100644 --- a/src/drivers/net/ipoib.c +++ b/src/drivers/net/ipoib.c @@ -854,22 +854,20 @@ static int ipoib_open ( struct net_device *netdev ) { } /* Allocate completion queue */ - ipoib->cq = ib_create_cq ( ibdev, IPOIB_NUM_CQES, &ipoib_cq_op ); - if ( ! ipoib->cq ) { - DBGC ( ipoib, "IPoIB %p could not allocate completion queue\n", - ipoib ); - rc = -ENOMEM; + if ( ( rc = ib_create_cq ( ibdev, IPOIB_NUM_CQES, &ipoib_cq_op, + &ipoib->cq ) ) != 0 ) { + DBGC ( ipoib, "IPoIB %p could not create completion queue: " + "%s\n", ipoib, strerror ( rc ) ); goto err_create_cq; } /* Allocate queue pair */ - ipoib->qp = ib_create_qp ( ibdev, IB_QPT_UD, IPOIB_NUM_SEND_WQES, + if ( ( rc = ib_create_qp ( ibdev, IB_QPT_UD, IPOIB_NUM_SEND_WQES, ipoib->cq, IPOIB_NUM_RECV_WQES, ipoib->cq, - &ipoib_qp_op, netdev->name ); - if ( ! ipoib->qp ) { - DBGC ( ipoib, "IPoIB %p could not allocate queue pair\n", - ipoib ); - rc = -ENOMEM; + &ipoib_qp_op, netdev->name, + &ipoib->qp ) ) != 0 ) { + DBGC ( ipoib, "IPoIB %p could not create queue pair: %s\n", + ipoib, strerror ( rc ) ); goto err_create_qp; } ib_qp_set_ownerdata ( ipoib->qp, ipoib ); -- cgit v1.2.3-55-g7522