summaryrefslogtreecommitdiffstats
path: root/src/net/infiniband.c
diff options
context:
space:
mode:
authorMichael Brown2009-01-02 22:04:31 +0100
committerMichael Brown2009-01-02 22:04:31 +0100
commit53a7dd26cd0aff8409e16c6cc1c7423d4a551f4b (patch)
tree84a376781898482a5b6dba32d4134d7769f020b4 /src/net/infiniband.c
parent[pcbios] Add additional sanity check for bogus e820 map (diff)
downloadipxe-53a7dd26cd0aff8409e16c6cc1c7423d4a551f4b.tar.gz
ipxe-53a7dd26cd0aff8409e16c6cc1c7423d4a551f4b.tar.xz
ipxe-53a7dd26cd0aff8409e16c6cc1c7423d4a551f4b.zip
[infiniband] Call ib_open() only when opening the IPoIB net device
Defer the call to ib_open() until we want to actually open the device, rather than when the device is registered.
Diffstat (limited to 'src/net/infiniband.c')
-rw-r--r--src/net/infiniband.c43
1 files changed, 36 insertions, 7 deletions
diff --git a/src/net/infiniband.c b/src/net/infiniband.c
index fb6fca7d..d79bdc2c 100644
--- a/src/net/infiniband.c
+++ b/src/net/infiniband.c
@@ -392,6 +392,42 @@ void ib_complete_recv ( struct ib_device *ibdev, struct ib_queue_pair *qp,
}
/**
+ * Open port
+ *
+ * @v ibdev Infiniband device
+ * @ret rc Return status code
+ */
+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 */
+ ibdev->open_count++;
+
+ return 0;
+}
+
+/**
+ * Close port
+ *
+ * @v ibdev Infiniband device
+ */
+void ib_close ( struct ib_device *ibdev ) {
+
+ /* Decrement device open request counter */
+ ibdev->open_count--;
+
+ /* Close device if this was the last remaining requested opening */
+ if ( ibdev->open_count == 0 )
+ ibdev->op->close ( ibdev );
+}
+
+/**
* Attach to multicast group
*
* @v ibdev Infiniband device
@@ -530,10 +566,6 @@ int register_ibdev ( struct ib_device *ibdev ) {
ibdev_get ( ibdev );
list_add_tail ( &ibdev->list, &ib_devices );
- /* Open link */
- if ( ( rc = ib_open ( ibdev ) ) != 0 )
- goto err_open;
-
/* Add IPoIB device */
if ( ( rc = ipoib_probe ( ibdev ) ) != 0 ) {
DBGC ( ibdev, "IBDEV %p could not add IPoIB device: %s\n",
@@ -546,8 +578,6 @@ int register_ibdev ( struct ib_device *ibdev ) {
return 0;
err_ipoib_probe:
- ib_close ( ibdev );
- err_open:
list_del ( &ibdev->list );
ibdev_put ( ibdev );
return rc;
@@ -562,7 +592,6 @@ void unregister_ibdev ( struct ib_device *ibdev ) {
/* Close device */
ipoib_remove ( ibdev );
- ib_close ( ibdev );
/* Remove from device list */
list_del ( &ibdev->list );