diff options
| author | Michael Brown | 2009-07-07 00:09:26 +0200 |
|---|---|---|
| committer | Michael Brown | 2009-07-18 00:06:33 +0200 |
| commit | 1d8c85d1120ab52a397cdc747d4854cc13cf8293 (patch) | |
| tree | 7a5ce4b7c26b554a4d5ba6bae1e58741ac678185 /src/net/infiniband.c | |
| parent | [infiniband] Centralise SMA and GMA queue constants (diff) | |
| download | ipxe-1d8c85d1120ab52a397cdc747d4854cc13cf8293.tar.gz ipxe-1d8c85d1120ab52a397cdc747d4854cc13cf8293.tar.xz ipxe-1d8c85d1120ab52a397cdc747d4854cc13cf8293.zip | |
[infiniband] Create a general management agent
Generalise the subnet management agent into a general management agent
capable of sending and responding to MADs, including support for
retransmissions as necessary.
Diffstat (limited to 'src/net/infiniband.c')
| -rw-r--r-- | src/net/infiniband.c | 36 |
1 files changed, 29 insertions, 7 deletions
diff --git a/src/net/infiniband.c b/src/net/infiniband.c index 48572e03b..497c20f6a 100644 --- a/src/net/infiniband.c +++ b/src/net/infiniband.c @@ -485,16 +485,36 @@ void ib_refill_recv ( struct ib_device *ibdev, struct ib_queue_pair *qp ) { int ib_open ( struct ib_device *ibdev ) { int rc; - /* Open device if this is the first requested opening */ - if ( ibdev->open_count == 0 ) { - if ( ( rc = ibdev->op->open ( ibdev ) ) != 0 ) - return rc; + /* Increment device open request counter */ + if ( ibdev->open_count++ > 0 ) { + /* Device was already open; do nothing */ + return 0; } - /* Increment device open request counter */ - ibdev->open_count++; + /* Open device */ + if ( ( rc = ibdev->op->open ( ibdev ) ) != 0 ) { + DBGC ( ibdev, "IBDEV %p could not open: %s\n", + ibdev, strerror ( rc ) ); + goto err_open; + } + + /* Create general management agent */ + if ( ( rc = ib_create_gma ( &ibdev->gma, ibdev, IB_QKEY_GMA ) ) != 0 ){ + DBGC ( ibdev, "IBDEV %p could not create GMA: %s\n", + ibdev, strerror ( rc ) ); + goto err_create_gma; + } + assert ( ibdev->open_count == 1 ); return 0; + + ib_destroy_gma ( &ibdev->gma ); + err_create_gma: + ibdev->op->close ( ibdev ); + err_open: + assert ( ibdev->open_count == 1 ); + ibdev->open_count = 0; + return rc; } /** @@ -508,8 +528,10 @@ void ib_close ( struct ib_device *ibdev ) { ibdev->open_count--; /* Close device if this was the last remaining requested opening */ - if ( ibdev->open_count == 0 ) + if ( ibdev->open_count == 0 ) { + ib_destroy_gma ( &ibdev->gma ); ibdev->op->close ( ibdev ); + } } /*************************************************************************** |
