Browse Source

[infiniband] Add last_opened_ibdev(), analogous to last_opened_netdev()

The minimal-surprise behaviour, when no explicit SRP initiator device
is specified, will probably be to use the most recently opened
Infiniband device.  This matches our behaviour with using the most
recently opened net device for PXE, iSCSI, AoE, NBI, etc.
tags/v0.9.8
Michael Brown 15 years ago
parent
commit
8de49af0d2
3 changed files with 27 additions and 1 deletions
  1. 3
    0
      src/include/gpxe/infiniband.h
  2. 23
    0
      src/net/infiniband.c
  3. 1
    1
      src/net/netdevice.c

+ 3
- 0
src/include/gpxe/infiniband.h View File

@@ -368,6 +368,8 @@ struct ib_device {
368 368
 	struct refcnt refcnt;
369 369
 	/** List of Infiniband devices */
370 370
 	struct list_head list;
371
+	/** List of open Infiniband devices */
372
+	struct list_head open_list;
371 373
 	/** Underlying device */
372 374
 	struct device *dev;
373 375
 	/** List of completion queues */
@@ -473,6 +475,7 @@ extern struct ib_device * alloc_ibdev ( size_t priv_size );
473 475
 extern int register_ibdev ( struct ib_device *ibdev );
474 476
 extern void unregister_ibdev ( struct ib_device *ibdev );
475 477
 extern struct ib_device * find_ibdev ( struct ib_gid *gid );
478
+extern struct ib_device * last_opened_ibdev ( void );
476 479
 extern void ib_link_state_changed ( struct ib_device *ibdev );
477 480
 extern void ib_poll_eq ( struct ib_device *ibdev );
478 481
 extern struct list_head ib_devices;

+ 23
- 0
src/net/infiniband.c View File

@@ -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
+}

+ 1
- 1
src/net/netdevice.c View File

@@ -43,7 +43,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
43 43
 struct list_head net_devices = LIST_HEAD_INIT ( net_devices );
44 44
 
45 45
 /** List of open network devices, in reverse order of opening */
46
-struct list_head open_net_devices = LIST_HEAD_INIT ( open_net_devices );
46
+static struct list_head open_net_devices = LIST_HEAD_INIT ( open_net_devices );
47 47
 
48 48
 /** Default link status code */
49 49
 #define EUNKNOWN_LINK_STATUS EINPROGRESS

Loading…
Cancel
Save