diff options
author | Michael Brown <mcb30@ipxe.org> | 2017-03-22 10:47:46 +0200 |
---|---|---|
committer | Michael Brown <mcb30@ipxe.org> | 2017-03-22 11:18:02 +0200 |
commit | 39ef530088859ccbbcf29bf6af2cf9f0307dc476 (patch) | |
tree | 1f90063aa65d6fa2065bdb7f430aebf70623856e /src/net/infiniband.c | |
parent | e88e2a29657824963c4fdb948e5ac99dfe6472ee (diff) | |
download | ipxe-39ef530088859ccbbcf29bf6af2cf9f0307dc476.tar.gz |
[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 <mcb30@ipxe.org>
Diffstat (limited to 'src/net/infiniband.c')
-rw-r--r-- | src/net/infiniband.c | 45 |
1 files changed, 26 insertions, 19 deletions
diff --git a/src/net/infiniband.c b/src/net/infiniband.c index 15ff0529b..fa45653ea 100644 --- a/src/net/infiniband.c +++ b/src/net/infiniband.c @@ -92,11 +92,12 @@ struct errortab infiniband_errors[] __errortab = { * @v ibdev Infiniband device * @v num_cqes Number of completion queue entries * @v op Completion queue operations - * @ret cq New completion queue + * @v new_cq New completion queue to fill in + * @ret rc Return status code */ -struct ib_completion_queue * -ib_create_cq ( struct ib_device *ibdev, unsigned int num_cqes, - struct ib_completion_queue_operations *op ) { +int ib_create_cq ( struct ib_device *ibdev, unsigned int num_cqes, + struct ib_completion_queue_operations *op, + struct ib_completion_queue **new_cq ) { struct ib_completion_queue *cq; int rc; @@ -104,8 +105,10 @@ ib_create_cq ( struct ib_device *ibdev, unsigned int num_cqes, /* Allocate and initialise data structure */ cq = zalloc ( sizeof ( *cq ) ); - if ( ! cq ) + if ( ! cq ) { + rc = -ENOMEM; goto err_alloc_cq; + } cq->ibdev = ibdev; list_add_tail ( &cq->list, &ibdev->cqs ); cq->num_cqes = num_cqes; @@ -122,14 +125,15 @@ ib_create_cq ( struct ib_device *ibdev, unsigned int num_cqes, DBGC ( ibdev, "IBDEV %s created %d-entry completion queue %p (%p) " "with CQN %#lx\n", ibdev->name, num_cqes, cq, ib_cq_get_drvdata ( cq ), cq->cqn ); - return cq; + *new_cq = cq; + return 0; ibdev->op->destroy_cq ( ibdev, cq ); err_dev_create_cq: list_del ( &cq->list ); free ( cq ); err_alloc_cq: - return NULL; + return rc; } /** @@ -186,19 +190,19 @@ void ib_poll_cq ( struct ib_device *ibdev, * @v recv_cq Receive completion queue * @v op Queue pair operations * @v name Queue pair name - * @ret qp Queue pair + * @v new_qp New queue pair to fill in + * @ret rc Return status code * * The queue pair will be left in the INIT state; you must call * ib_modify_qp() before it is ready to use for sending and receiving. */ -struct ib_queue_pair * ib_create_qp ( struct ib_device *ibdev, - enum ib_queue_pair_type type, - unsigned int num_send_wqes, - struct ib_completion_queue *send_cq, - unsigned int num_recv_wqes, - struct ib_completion_queue *recv_cq, - struct ib_queue_pair_operations *op, - const char *name ) { +int ib_create_qp ( struct ib_device *ibdev, enum ib_queue_pair_type type, + unsigned int num_send_wqes, + struct ib_completion_queue *send_cq, + unsigned int num_recv_wqes, + struct ib_completion_queue *recv_cq, + struct ib_queue_pair_operations *op, const char *name, + struct ib_queue_pair **new_qp ) { struct ib_queue_pair *qp; size_t total_size; int rc; @@ -210,8 +214,10 @@ struct ib_queue_pair * ib_create_qp ( struct ib_device *ibdev, ( num_send_wqes * sizeof ( qp->send.iobufs[0] ) ) + ( num_recv_wqes * sizeof ( qp->recv.iobufs[0] ) ) ); qp = zalloc ( total_size ); - if ( ! qp ) + if ( ! qp ) { + rc = -ENOMEM; goto err_alloc_qp; + } qp->ibdev = ibdev; list_add_tail ( &qp->list, &ibdev->qps ); qp->type = type; @@ -265,7 +271,8 @@ struct ib_queue_pair * ib_create_qp ( struct ib_device *ibdev, ibdev->name, qp->qpn, qp->ext_qpn ); } - return qp; + *new_qp = qp; + return 0; ibdev->op->destroy_qp ( ibdev, qp ); err_dev_create_qp: @@ -274,7 +281,7 @@ struct ib_queue_pair * ib_create_qp ( struct ib_device *ibdev, list_del ( &qp->list ); free ( qp ); err_alloc_qp: - return NULL; + return rc; } /** |