|
@@ -45,6 +45,9 @@ FILE_LICENCE ( GPL2_OR_LATER );
|
45
|
45
|
/** List of Infiniband devices */
|
46
|
46
|
struct list_head ib_devices = LIST_HEAD_INIT ( ib_devices );
|
47
|
47
|
|
|
48
|
+/** List of open Infiniband devices, in reverse order of opening */
|
|
49
|
+static struct list_head open_ib_devices = LIST_HEAD_INIT ( open_ib_devices );
|
|
50
|
+
|
48
|
51
|
/***************************************************************************
|
49
|
52
|
*
|
50
|
53
|
* Completion queues
|
|
@@ -565,6 +568,9 @@ int ib_open ( struct ib_device *ibdev ) {
|
565
|
568
|
goto err_open;
|
566
|
569
|
}
|
567
|
570
|
|
|
571
|
+ /* Add to head of open devices list */
|
|
572
|
+ list_add ( &ibdev->open_list, &open_ib_devices );
|
|
573
|
+
|
568
|
574
|
assert ( ibdev->open_count == 1 );
|
569
|
575
|
return 0;
|
570
|
576
|
|
|
@@ -593,6 +599,7 @@ void ib_close ( struct ib_device *ibdev ) {
|
593
|
599
|
|
594
|
600
|
/* Close device if this was the last remaining requested opening */
|
595
|
601
|
if ( ibdev->open_count == 0 ) {
|
|
602
|
+ list_del ( &ibdev->open_list );
|
596
|
603
|
ib_destroy_mi ( ibdev, ibdev->gsi );
|
597
|
604
|
ib_destroy_sma ( ibdev, ibdev->smi );
|
598
|
605
|
ib_destroy_mi ( ibdev, ibdev->smi );
|
|
@@ -898,3 +905,19 @@ struct ib_device * find_ibdev ( struct ib_gid *gid ) {
|
898
|
905
|
}
|
899
|
906
|
return NULL;
|
900
|
907
|
}
|
|
908
|
+
|
|
909
|
+/**
|
|
910
|
+ * Get most recently opened Infiniband device
|
|
911
|
+ *
|
|
912
|
+ * @ret ibdev Most recently opened Infiniband device, or NULL
|
|
913
|
+ */
|
|
914
|
+struct ib_device * last_opened_ibdev ( void ) {
|
|
915
|
+ struct ib_device *ibdev;
|
|
916
|
+
|
|
917
|
+ list_for_each_entry ( ibdev, &open_ib_devices, open_list ) {
|
|
918
|
+ assert ( ibdev->open_count != 0 );
|
|
919
|
+ return ibdev;
|
|
920
|
+ }
|
|
921
|
+
|
|
922
|
+ return NULL;
|
|
923
|
+}
|